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.

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

mercurial