diff options
Diffstat (limited to 'WebCore/html/canvas/WebGLBuffer.h')
-rw-r--r-- | WebCore/html/canvas/WebGLBuffer.h | 123 |
1 files changed, 64 insertions, 59 deletions
diff --git a/WebCore/html/canvas/WebGLBuffer.h b/WebCore/html/canvas/WebGLBuffer.h index 1280cf9..a7a25b9 100644 --- a/WebCore/html/canvas/WebGLBuffer.h +++ b/WebCore/html/canvas/WebGLBuffer.h @@ -26,72 +26,77 @@ #ifndef WebGLBuffer_h #define WebGLBuffer_h -#include "CanvasObject.h" #include "ArrayBuffer.h" +#include "WebGLObject.h" #include <wtf/PassRefPtr.h> #include <wtf/RefCounted.h> namespace WebCore { - - class WebGLBuffer : public CanvasObject { - public: - virtual ~WebGLBuffer() { deleteObject(); } - - static PassRefPtr<WebGLBuffer> create(WebGLRenderingContext*); - - bool associateBufferData(int size); - bool associateBufferData(ArrayBuffer* array); - bool associateBufferData(ArrayBufferView* array); - bool associateBufferSubData(long offset, ArrayBuffer* array); - bool associateBufferSubData(long offset, ArrayBufferView* array); - - unsigned byteLength() const; - const ArrayBuffer* elementArrayBuffer() const { return m_elementArrayBuffer.get(); } - - // Gets the cached max index for the given type. Returns -1 if - // none has been set. - long getCachedMaxIndex(unsigned long type); - // Sets the cached max index for the given type. - void setCachedMaxIndex(unsigned long type, long value); - - unsigned long getTarget() const { return m_target; } - void setTarget(unsigned long); - - protected: - WebGLBuffer(WebGLRenderingContext*); - - virtual void _deleteObject(Platform3DObject o); - - private: - virtual bool isBuffer() const { return true; } - - unsigned long m_target; - - RefPtr<ArrayBuffer> m_elementArrayBuffer; - unsigned m_byteLength; - - // Optimization for index validation. For each type of index - // (i.e., UNSIGNED_SHORT), cache the maximum index in the - // entire buffer. - // - // This is sufficient to eliminate a lot of work upon each - // draw call as long as all bound array buffers are at least - // that size. - struct MaxIndexCacheEntry { - unsigned long type; - long maxIndex; - }; - // OpenGL ES 2.0 only has two valid index types (UNSIGNED_BYTE - // and UNSIGNED_SHORT), but might as well leave open the - // possibility of adding others. - MaxIndexCacheEntry m_maxIndexCache[4]; - unsigned m_nextAvailableCacheEntry; - - // Clears all of the cached max indices. - void clearCachedMaxIndices(); + +class WebGLBuffer : public WebGLObject { +public: + virtual ~WebGLBuffer() { deleteObject(); } + + static PassRefPtr<WebGLBuffer> create(WebGLRenderingContext*); + + bool associateBufferData(int size); + bool associateBufferData(ArrayBuffer* array); + bool associateBufferData(ArrayBufferView* array); + bool associateBufferSubData(long offset, ArrayBuffer* array); + bool associateBufferSubData(long offset, ArrayBufferView* array); + + unsigned byteLength() const; + const ArrayBuffer* elementArrayBuffer() const { return m_elementArrayBuffer.get(); } + + // Gets the cached max index for the given type. Returns -1 if + // none has been set. + long getCachedMaxIndex(unsigned long type); + // Sets the cached max index for the given type. + void setCachedMaxIndex(unsigned long type, long value); + + unsigned long getTarget() const { return m_target; } + void setTarget(unsigned long); + +protected: + WebGLBuffer(WebGLRenderingContext*); + + virtual void deleteObjectImpl(Platform3DObject o); + +private: + virtual bool isBuffer() const { return true; } + + unsigned long m_target; + + RefPtr<ArrayBuffer> m_elementArrayBuffer; + unsigned m_byteLength; + + // Optimization for index validation. For each type of index + // (i.e., UNSIGNED_SHORT), cache the maximum index in the + // entire buffer. + // + // This is sufficient to eliminate a lot of work upon each + // draw call as long as all bound array buffers are at least + // that size. + struct MaxIndexCacheEntry { + unsigned long type; + long maxIndex; }; - + // OpenGL ES 2.0 only has two valid index types (UNSIGNED_BYTE + // and UNSIGNED_SHORT), but might as well leave open the + // possibility of adding others. + MaxIndexCacheEntry m_maxIndexCache[4]; + unsigned m_nextAvailableCacheEntry; + + // Clears all of the cached max indices. + void clearCachedMaxIndices(); + + // Helper function called by the three associateBufferData(). + bool associateBufferDataImpl(ArrayBuffer* array, unsigned byteOffset, unsigned byteLength); + // Helper function called by the two associateBufferSubData(). + bool associateBufferSubDataImpl(long offset, ArrayBuffer* array, unsigned arrayByteOffset, unsigned byteLength); +}; + } // namespace WebCore #endif // WebGLBuffer_h |