gfx/angle/src/libGLESv2/renderer/VertexBuffer.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 //
     2 // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
     3 // Use of this source code is governed by a BSD-style license that can be
     4 // found in the LICENSE file.
     5 //
     7 // VertexBuffer.h: Defines the abstract VertexBuffer class and VertexBufferInterface
     8 // class with derivations, classes that perform graphics API agnostic vertex buffer operations.
    10 #ifndef LIBGLESV2_RENDERER_VERTEXBUFFER_H_
    11 #define LIBGLESV2_RENDERER_VERTEXBUFFER_H_
    13 #include "common/angleutils.h"
    15 namespace gl
    16 {
    17 class VertexAttribute;
    18 }
    20 namespace rx
    21 {
    22 class Renderer;
    24 class VertexBuffer
    25 {
    26   public:
    27     VertexBuffer();
    28     virtual ~VertexBuffer();
    30     virtual bool initialize(unsigned int size, bool dynamicUsage) = 0;
    32     virtual bool storeVertexAttributes(const gl::VertexAttribute &attrib, GLint start, GLsizei count,
    33                                        GLsizei instances, unsigned int offset) = 0;
    34     virtual bool storeRawData(const void* data, unsigned int size, unsigned int offset) = 0;
    36     virtual bool getSpaceRequired(const gl::VertexAttribute &attrib, GLsizei count, GLsizei instances,
    37                                   unsigned int *outSpaceRequired) const = 0;
    39     virtual bool requiresConversion(const gl::VertexAttribute &attrib) const = 0;
    41     virtual unsigned int getBufferSize() const = 0;
    42     virtual bool setBufferSize(unsigned int size) = 0;
    43     virtual bool discard() = 0;
    45     unsigned int getSerial() const;
    47   protected:
    48     void updateSerial();
    50   private:
    51     DISALLOW_COPY_AND_ASSIGN(VertexBuffer);
    53     unsigned int mSerial;
    54     static unsigned int mNextSerial;
    55 };
    57 class VertexBufferInterface
    58 {
    59   public:
    60     VertexBufferInterface(rx::Renderer *renderer, bool dynamic);
    61     virtual ~VertexBufferInterface();
    63     bool reserveVertexSpace(const gl::VertexAttribute &attribute, GLsizei count, GLsizei instances);
    64     bool reserveRawDataSpace(unsigned int size);
    66     unsigned int getBufferSize() const;
    68     unsigned int getSerial() const;
    70     virtual bool storeVertexAttributes(const gl::VertexAttribute &attrib, GLint start, GLsizei count, GLsizei instances,
    71                                       unsigned int *outStreamOffset);
    72     virtual bool storeRawData(const void* data, unsigned int size, unsigned int *outStreamOffset);
    74     VertexBuffer* getVertexBuffer() const;
    76   protected:
    77     virtual bool reserveSpace(unsigned int size) = 0;
    79     unsigned int getWritePosition() const;
    80     void setWritePosition(unsigned int writePosition);
    82     bool discard();
    84     bool setBufferSize(unsigned int size);
    86   private:
    87     DISALLOW_COPY_AND_ASSIGN(VertexBufferInterface);
    89     rx::Renderer *const mRenderer;
    91     VertexBuffer* mVertexBuffer;
    93     unsigned int mWritePosition;
    94     unsigned int mReservedSpace;
    95     bool mDynamic;
    96 };
    98 class StreamingVertexBufferInterface : public VertexBufferInterface
    99 {
   100   public:
   101     StreamingVertexBufferInterface(rx::Renderer *renderer, std::size_t initialSize);
   102     ~StreamingVertexBufferInterface();
   104   protected:
   105     bool reserveSpace(unsigned int size);
   106 };
   108 class StaticVertexBufferInterface : public VertexBufferInterface
   109 {
   110   public:
   111     explicit StaticVertexBufferInterface(rx::Renderer *renderer);
   112     ~StaticVertexBufferInterface();
   114     bool storeVertexAttributes(const gl::VertexAttribute &attrib, GLint start, GLsizei count, GLsizei instances,
   115                                unsigned int *outStreamOffset);
   117     bool lookupAttribute(const gl::VertexAttribute &attribute, unsigned int* outStreamOffset);
   119   protected:
   120     bool reserveSpace(unsigned int size);
   122   private:
   123     struct VertexElement
   124     {
   125         GLenum type;
   126         GLint size;
   127         GLsizei stride;
   128         bool normalized;
   129         int attributeOffset;
   131         unsigned int streamOffset;
   132     };
   134     std::vector<VertexElement> mCache;
   135 };
   137 }
   139 #endif // LIBGLESV2_RENDERER_VERTEXBUFFER_H_

mercurial