Changeset 64767 in webkit
- Timestamp:
- Aug 5, 2010 11:33:48 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r64764 r64767 1 2010-08-04 Kenneth Russell <kbr@google.com> 2 3 Reviewed by Dimitri Glazkov. 4 5 Style cleanups in WebGL 6 https://bugs.webkit.org/show_bug.cgi?id=38761 7 8 Cleaned up all style violations in WebGL-related files reported by 9 check-webkit-style. No logic or other changes. Built WebKit and 10 Chromium and ran WebGL layout tests. 11 12 * html/canvas/ArrayBuffer.cpp: 13 (WebCore::ArrayBuffer::ArrayBuffer): 14 (WebCore::ArrayBuffer::data): 15 (WebCore::ArrayBuffer::byteLength): 16 (WebCore::ArrayBuffer::~ArrayBuffer): 17 (WebCore::ArrayBuffer::tryAllocate): 18 * html/canvas/ArrayBufferView.cpp: 19 (WebCore::ArrayBufferView::setImpl): 20 * html/canvas/ArrayBufferView.h: 21 * html/canvas/TypedArrayBase.h: 22 * html/canvas/WebGLBuffer.cpp: 23 (WebCore::WebGLBuffer::deleteObjectImpl): 24 (WebCore::WebGLBuffer::associateBufferData): 25 * html/canvas/WebGLBuffer.h: 26 (WebCore::WebGLBuffer::~WebGLBuffer): 27 (WebCore::WebGLBuffer::elementArrayBuffer): 28 (WebCore::WebGLBuffer::getTarget): 29 (WebCore::WebGLBuffer::isBuffer): 30 * html/canvas/WebGLFramebuffer.cpp: 31 (WebCore::WebGLFramebuffer::deleteObjectImpl): 32 * html/canvas/WebGLFramebuffer.h: 33 (WebCore::WebGLFramebuffer::~WebGLFramebuffer): 34 (WebCore::WebGLFramebuffer::isDepthAttached): 35 (WebCore::WebGLFramebuffer::isStencilAttached): 36 (WebCore::WebGLFramebuffer::isDepthStencilAttached): 37 (WebCore::WebGLFramebuffer::isFramebuffer): 38 * html/canvas/WebGLGetInfo.cpp: 39 * html/canvas/WebGLGetInfo.h: 40 * html/canvas/WebGLObject.cpp: 41 (WebCore::WebGLObject::deleteObject): 42 * html/canvas/WebGLObject.h: 43 (WebCore::WebGLObject::object): 44 (WebCore::WebGLObject::detachContext): 45 (WebCore::WebGLObject::context): 46 (WebCore::WebGLObject::isBuffer): 47 (WebCore::WebGLObject::isFramebuffer): 48 (WebCore::WebGLObject::isProgram): 49 (WebCore::WebGLObject::isRenderbuffer): 50 (WebCore::WebGLObject::isShader): 51 (WebCore::WebGLObject::isTexture): 52 * html/canvas/WebGLProgram.cpp: 53 (WebCore::WebGLProgram::deleteObjectImpl): 54 * html/canvas/WebGLProgram.h: 55 (WebCore::WebGLProgram::~WebGLProgram): 56 (WebCore::WebGLProgram::isLinkFailureFlagSet): 57 (WebCore::WebGLProgram::setLinkFailureFlag): 58 (WebCore::WebGLProgram::isProgram): 59 * html/canvas/WebGLRenderbuffer.cpp: 60 (WebCore::WebGLRenderbuffer::deleteObjectImpl): 61 * html/canvas/WebGLRenderbuffer.h: 62 (WebCore::WebGLRenderbuffer::~WebGLRenderbuffer): 63 (WebCore::WebGLRenderbuffer::setInternalFormat): 64 (WebCore::WebGLRenderbuffer::getInternalFormat): 65 (WebCore::WebGLRenderbuffer::isInitialized): 66 (WebCore::WebGLRenderbuffer::setInitialized): 67 (WebCore::WebGLRenderbuffer::isRenderbuffer): 68 * html/canvas/WebGLRenderingContext.cpp: 69 (WebCore::WebGLRenderingContext::beginPaint): 70 (WebCore::WebGLRenderingContext::blendEquation): 71 (WebCore::WebGLRenderingContext::getActiveAttrib): 72 (WebCore::WebGLRenderingContext::getActiveUniform): 73 (WebCore::WebGLRenderingContext::getBufferParameter): 74 (WebCore::WebGLRenderingContext::getFramebufferAttachmentParameter): 75 (WebCore::WebGLRenderingContext::vertexAttribPointer): 76 * html/canvas/WebGLRenderingContext.h: 77 (WebCore::WebGLRenderingContext::is3d): 78 (WebCore::WebGLRenderingContext::isAccelerated): 79 (WebCore::WebGLRenderingContext::graphicsContext3D): 80 (WebCore::WebGLRenderingContext::cleanupAfterGraphicsCall): 81 (WebCore::WebGLRenderingContext::VertexAttribState::VertexAttribState): 82 (WebCore::WebGLRenderingContext::VertexAttribState::initValue): 83 * html/canvas/WebGLShader.cpp: 84 (WebCore::WebGLShader::deleteObjectImpl): 85 * html/canvas/WebGLShader.h: 86 (WebCore::WebGLShader::~WebGLShader): 87 (WebCore::WebGLShader::getType): 88 (WebCore::WebGLShader::isShader): 89 * html/canvas/WebGLTexture.cpp: 90 (WebCore::WebGLTexture::deleteObjectImpl): 91 * html/canvas/WebGLTexture.h: 92 (WebCore::WebGLTexture::~WebGLTexture): 93 (WebCore::WebGLTexture::isCubeMapRWrapModeInitialized): 94 (WebCore::WebGLTexture::setCubeMapRWrapModeInitialized): 95 (WebCore::WebGLTexture::isTexture): 96 (WebCore::WebGLTexture::LevelInfo::LevelInfo): 97 (WebCore::WebGLTexture::LevelInfo::setInfo): 98 * platform/graphics/GraphicsContext3D.h: 99 (WebCore::GraphicsContext3D::): 100 (WebCore::GraphicsContext3D::Attributes::Attributes): 101 (WebCore::GraphicsContext3D::platformGraphicsContext3D): 102 (WebCore::GraphicsContext3D::platformTexture): 103 (WebCore::GraphicsContext3D::platformLayer): 104 1 105 2010-08-05 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org> 2 106 -
trunk/WebCore/html/canvas/ArrayBuffer.cpp
r59499 r64767 54 54 ArrayBuffer::ArrayBuffer(void* data, unsigned sizeInBytes) 55 55 : m_sizeInBytes(sizeInBytes) 56 , m_data(data) { 56 , m_data(data) 57 { 57 58 } 58 59 59 void* ArrayBuffer::data() { 60 void* ArrayBuffer::data() 61 { 60 62 return m_data; 61 63 } 62 64 63 const void* ArrayBuffer::data() const { 65 const void* ArrayBuffer::data() const 66 { 64 67 return m_data; 65 68 } 66 69 67 unsigned ArrayBuffer::byteLength() const { 70 unsigned ArrayBuffer::byteLength() const 71 { 68 72 return m_sizeInBytes; 69 73 } 70 74 71 ArrayBuffer::~ArrayBuffer() { 75 ArrayBuffer::~ArrayBuffer() 76 { 72 77 WTF::fastFree(m_data); 73 78 } 74 79 75 void* ArrayBuffer::tryAllocate(unsigned numElements, unsigned elementByteSize) { 80 void* ArrayBuffer::tryAllocate(unsigned numElements, unsigned elementByteSize) 81 { 76 82 void* result; 77 83 // Do not allow 32-bit overflow of the total size -
trunk/WebCore/html/canvas/ArrayBufferView.cpp
r59499 r64767 29 29 30 30 #include "ArrayBufferView.h" 31 31 32 #include "ArrayBuffer.h" 32 33 … … 47 48 void ArrayBufferView::setImpl(ArrayBufferView* array, unsigned byteOffset, ExceptionCode& ec) 48 49 { 49 if (byteOffset > byteLength() ||50 byteOffset + array->byteLength() > byteLength() ||51 byteOffset + array->byteLength() < byteOffset) {50 if (byteOffset > byteLength() 51 || byteOffset + array->byteLength() > byteLength() 52 || byteOffset + array->byteLength() < byteOffset) { 52 53 // Out of range offset or overflow 53 54 ec = INDEX_SIZE_ERR; -
trunk/WebCore/html/canvas/ArrayBufferView.h
r59499 r64767 27 27 #define ArrayBufferView_h 28 28 29 #include "ArrayBuffer.h" 30 #include "ExceptionCode.h" 31 29 32 #include <algorithm> 30 #include "ExceptionCode.h"31 33 #include <limits.h> 32 34 #include <wtf/PassRefPtr.h> 33 35 #include <wtf/RefCounted.h> 34 36 #include <wtf/RefPtr.h> 35 #include "ArrayBuffer.h"36 37 37 38 namespace WebCore { -
trunk/WebCore/html/canvas/TypedArrayBase.h
r61339 r64767 28 28 #define TypedArrayBase_h 29 29 30 #include "ArrayBuffer.h" 30 31 #include "ArrayBufferView.h" 31 #include "ArrayBuffer.h"32 32 33 33 namespace WebCore { -
trunk/WebCore/html/canvas/WebGLBuffer.cpp
r64685 r64767 29 29 30 30 #include "WebGLBuffer.h" 31 31 32 #include "WebGLRenderingContext.h" 32 33 … … 48 49 } 49 50 50 void WebGLBuffer:: _deleteObject(Platform3DObject object)51 void WebGLBuffer::deleteObjectImpl(Platform3DObject object) 51 52 { 52 53 context()->graphicsContext3D()->deleteBuffer(object); … … 67 68 } 68 69 return true; 69 } else if (m_target == GraphicsContext3D::ARRAY_BUFFER) { 70 } 71 72 if (m_target == GraphicsContext3D::ARRAY_BUFFER) { 70 73 m_byteLength = size; 71 74 return true; -
trunk/WebCore/html/canvas/WebGLBuffer.h
r64685 r64767 27 27 #define WebGLBuffer_h 28 28 29 #include "ArrayBuffer.h" 29 30 #include "WebGLObject.h" 30 #include "ArrayBuffer.h"31 31 32 32 #include <wtf/PassRefPtr.h> … … 34 34 35 35 namespace WebCore { 36 37 class WebGLBuffer : public WebGLObject {38 public:39 virtual ~WebGLBuffer() { deleteObject(); }40 41 static PassRefPtr<WebGLBuffer> create(WebGLRenderingContext*);42 36 43 bool associateBufferData(int size); 44 bool associateBufferData(ArrayBuffer* array); 45 bool associateBufferData(ArrayBufferView* array); 46 bool associateBufferSubData(long offset, ArrayBuffer* array); 47 bool associateBufferSubData(long offset, ArrayBufferView* array); 48 49 unsigned byteLength() const; 50 const ArrayBuffer* elementArrayBuffer() const { return m_elementArrayBuffer.get(); } 51 52 // Gets the cached max index for the given type. Returns -1 if 53 // none has been set. 54 long getCachedMaxIndex(unsigned long type); 55 // Sets the cached max index for the given type. 56 void setCachedMaxIndex(unsigned long type, long value); 37 class WebGLBuffer : public WebGLObject { 38 public: 39 virtual ~WebGLBuffer() { deleteObject(); } 57 40 58 unsigned long getTarget() const { return m_target; } 59 void setTarget(unsigned long); 41 static PassRefPtr<WebGLBuffer> create(WebGLRenderingContext*); 60 42 61 protected: 62 WebGLBuffer(WebGLRenderingContext*); 43 bool associateBufferData(int size); 44 bool associateBufferData(ArrayBuffer* array); 45 bool associateBufferData(ArrayBufferView* array); 46 bool associateBufferSubData(long offset, ArrayBuffer* array); 47 bool associateBufferSubData(long offset, ArrayBufferView* array); 63 48 64 virtual void _deleteObject(Platform3DObject o); 65 66 private: 67 virtual bool isBuffer() const { return true; } 49 unsigned byteLength() const; 50 const ArrayBuffer* elementArrayBuffer() const { return m_elementArrayBuffer.get(); } 68 51 69 unsigned long m_target; 52 // Gets the cached max index for the given type. Returns -1 if 53 // none has been set. 54 long getCachedMaxIndex(unsigned long type); 55 // Sets the cached max index for the given type. 56 void setCachedMaxIndex(unsigned long type, long value); 70 57 71 RefPtr<ArrayBuffer> m_elementArrayBuffer;72 unsigned m_byteLength;58 unsigned long getTarget() const { return m_target; } 59 void setTarget(unsigned long); 73 60 74 // Optimization for index validation. For each type of index 75 // (i.e., UNSIGNED_SHORT), cache the maximum index in the 76 // entire buffer. 77 // 78 // This is sufficient to eliminate a lot of work upon each 79 // draw call as long as all bound array buffers are at least 80 // that size. 81 struct MaxIndexCacheEntry { 82 unsigned long type; 83 long maxIndex; 84 }; 85 // OpenGL ES 2.0 only has two valid index types (UNSIGNED_BYTE 86 // and UNSIGNED_SHORT), but might as well leave open the 87 // possibility of adding others. 88 MaxIndexCacheEntry m_maxIndexCache[4]; 89 unsigned m_nextAvailableCacheEntry; 61 protected: 62 WebGLBuffer(WebGLRenderingContext*); 90 63 91 // Clears all of the cached max indices. 92 void clearCachedMaxIndices(); 64 virtual void deleteObjectImpl(Platform3DObject o); 65 66 private: 67 virtual bool isBuffer() const { return true; } 68 69 unsigned long m_target; 70 71 RefPtr<ArrayBuffer> m_elementArrayBuffer; 72 unsigned m_byteLength; 73 74 // Optimization for index validation. For each type of index 75 // (i.e., UNSIGNED_SHORT), cache the maximum index in the 76 // entire buffer. 77 // 78 // This is sufficient to eliminate a lot of work upon each 79 // draw call as long as all bound array buffers are at least 80 // that size. 81 struct MaxIndexCacheEntry { 82 unsigned long type; 83 long maxIndex; 93 84 }; 94 85 // OpenGL ES 2.0 only has two valid index types (UNSIGNED_BYTE 86 // and UNSIGNED_SHORT), but might as well leave open the 87 // possibility of adding others. 88 MaxIndexCacheEntry m_maxIndexCache[4]; 89 unsigned m_nextAvailableCacheEntry; 90 91 // Clears all of the cached max indices. 92 void clearCachedMaxIndices(); 93 }; 94 95 95 } // namespace WebCore 96 96 -
trunk/WebCore/html/canvas/WebGLFramebuffer.cpp
r64685 r64767 29 29 30 30 #include "WebGLFramebuffer.h" 31 31 32 #include "WebGLRenderingContext.h" 32 33 … … 106 107 } 107 108 108 void WebGLFramebuffer:: _deleteObject(Platform3DObject object)109 void WebGLFramebuffer::deleteObjectImpl(Platform3DObject object) 109 110 { 110 111 context()->graphicsContext3D()->deleteFramebuffer(object); -
trunk/WebCore/html/canvas/WebGLFramebuffer.h
r64685 r64767 34 34 namespace WebCore { 35 35 36 class WebGLFramebuffer : public WebGLObject { 37 public: 38 virtual ~WebGLFramebuffer() { deleteObject(); } 39 40 static PassRefPtr<WebGLFramebuffer> create(WebGLRenderingContext*); 36 class WebGLFramebuffer : public WebGLObject { 37 public: 38 virtual ~WebGLFramebuffer() { deleteObject(); } 41 39 42 bool isDepthAttached() const { return (m_depthAttachment && m_depthAttachment->object()); } 43 bool isStencilAttached() const { return (m_stencilAttachment && m_stencilAttachment->object()); } 44 bool isDepthStencilAttached() const { return (m_depthStencilAttachment && m_depthStencilAttachment->object()); } 40 static PassRefPtr<WebGLFramebuffer> create(WebGLRenderingContext*); 45 41 46 void setAttachment(unsigned long, WebGLObject*); 42 bool isDepthAttached() const { return (m_depthAttachment && m_depthAttachment->object()); } 43 bool isStencilAttached() const { return (m_stencilAttachment && m_stencilAttachment->object()); } 44 bool isDepthStencilAttached() const { return (m_depthStencilAttachment && m_depthStencilAttachment->object()); } 47 45 48 // This function is called right after a framebuffer is bound. 49 // Because renderbuffers and textures attached to the framebuffer might 50 // have changed and the framebuffer might have become complete when it 51 // isn't bound, so we need to clear un-initialized renderbuffers. 52 void onBind(); 46 void setAttachment(unsigned long, WebGLObject*); 53 47 54 // When a texture or a renderbuffer changes, we need to check the55 // current bound framebuffer; if the newly changed object is attached56 // to the framebuffer and the framebuffer becomes complete, we need to57 //clear un-initialized renderbuffers.58 void onAttachedObjectChange(WebGLObject*);48 // This function is called right after a framebuffer is bound. 49 // Because renderbuffers and textures attached to the framebuffer might 50 // have changed and the framebuffer might have become complete when it 51 // isn't bound, so we need to clear un-initialized renderbuffers. 52 void onBind(); 59 53 60 unsigned long getColorBufferFormat(); 54 // When a texture or a renderbuffer changes, we need to check the 55 // current bound framebuffer; if the newly changed object is attached 56 // to the framebuffer and the framebuffer becomes complete, we need to 57 // clear un-initialized renderbuffers. 58 void onAttachedObjectChange(WebGLObject*); 61 59 62 protected: 63 WebGLFramebuffer(WebGLRenderingContext*); 64 65 virtual void _deleteObject(Platform3DObject); 60 unsigned long getColorBufferFormat(); 66 61 67 private:68 virtual bool isFramebuffer() const { return true; }62 protected: 63 WebGLFramebuffer(WebGLRenderingContext*); 69 64 70 bool isUninitialized(WebGLObject*); 71 void setInitialized(WebGLObject*); 72 void initializeRenderbuffers(); 65 virtual void deleteObjectImpl(Platform3DObject); 73 66 74 // These objects are kept alive by the global table in 75 // WebGLRenderingContext. 76 WebGLObject* m_colorAttachment; 77 WebGLObject* m_depthAttachment; 78 WebGLObject* m_stencilAttachment; 79 WebGLObject* m_depthStencilAttachment; 80 }; 81 67 private: 68 virtual bool isFramebuffer() const { return true; } 69 70 bool isUninitialized(WebGLObject*); 71 void setInitialized(WebGLObject*); 72 void initializeRenderbuffers(); 73 74 // These objects are kept alive by the global table in 75 // WebGLRenderingContext. 76 WebGLObject* m_colorAttachment; 77 WebGLObject* m_depthAttachment; 78 WebGLObject* m_stencilAttachment; 79 WebGLObject* m_depthStencilAttachment; 80 }; 81 82 82 } // namespace WebCore 83 83 -
trunk/WebCore/html/canvas/WebGLGetInfo.cpp
r61910 r64767 30 30 31 31 #include "WebGLGetInfo.h" 32 33 #include "Float32Array.h" 34 #include "Int32Array.h" 35 #include "Uint8Array.h" 32 36 #include "WebGLBuffer.h" 33 #include "Float32Array.h"34 37 #include "WebGLFramebuffer.h" 35 #include "Int32Array.h"36 38 #include "WebGLProgram.h" 37 39 #include "WebGLRenderbuffer.h" 38 40 #include "WebGLTexture.h" 39 #include "Uint8Array.h"40 41 41 42 namespace WebCore { -
trunk/WebCore/html/canvas/WebGLGetInfo.h
r61910 r64767 28 28 #define WebGLGetInfo_h 29 29 30 #include " wtf/PassRefPtr.h"31 #include " wtf/RefPtr.h"30 #include "Float32Array.h" 31 #include "Int32Array.h" 32 32 #include "PlatformString.h" 33 33 #include "Uint8Array.h" 34 34 #include "WebGLBuffer.h" 35 #include "Float32Array.h"36 35 #include "WebGLFramebuffer.h" 37 #include "Int32Array.h"38 // FIXME: implement WebGLObjectArray39 //#include "WebGLObjectArray.h"40 36 #include "WebGLProgram.h" 41 37 #include "WebGLRenderbuffer.h" 42 38 #include "WebGLTexture.h" 43 #include "Uint8Array.h" 39 40 #include <wtf/PassRefPtr.h> 41 #include <wtf/RefPtr.h> 44 42 45 43 namespace WebCore { … … 75 73 WebGLGetInfo(float value); 76 74 WebGLGetInfo(long value); 77 // Represents the NULL value and type75 // Represents the null value and type. 78 76 WebGLGetInfo(); 79 77 WebGLGetInfo(const String& value); … … 133 131 } // namespace WebCore 134 132 135 #endif 133 #endif // WebGLGetInfo_h -
trunk/WebCore/html/canvas/WebGLObject.cpp
r64685 r64767 29 29 30 30 #include "WebGLObject.h" 31 31 32 #include "WebGLRenderingContext.h" 32 33 … … 62 63 if (m_context) { 63 64 m_context->graphicsContext3D()->makeContextCurrent(); 64 _deleteObject(m_object);65 deleteObjectImpl(m_object); 65 66 } 66 67 m_object = 0; -
trunk/WebCore/html/canvas/WebGLObject.h
r64685 r64767 27 27 #define WebGLObject_h 28 28 29 #include "GraphicsContext3D.h" 30 29 31 #include <wtf/PassRefPtr.h> 30 32 #include <wtf/RefCounted.h> 31 33 32 #include "GraphicsContext3D.h"33 34 34 namespace WebCore { 35 35 36 class WebGLRenderingContext; 37 38 class WebGLObject : public RefCounted<WebGLObject> { 39 public: 40 virtual ~WebGLObject(); 41 42 Platform3DObject object() const { return m_object; } 43 void setObject(Platform3DObject, bool shouldDeleteObject = true); 44 void deleteObject(); 45 46 void detachContext() 47 { 48 deleteObject(); 49 m_context = 0; 50 } 36 class WebGLRenderingContext; 51 37 52 WebGLRenderingContext* context() const { return m_context; } 38 class WebGLObject : public RefCounted<WebGLObject> { 39 public: 40 virtual ~WebGLObject(); 53 41 54 virtual bool isBuffer() const { return false; } 55 virtual bool isFramebuffer() const { return false; } 56 virtual bool isProgram() const { return false; } 57 virtual bool isRenderbuffer() const { return false; } 58 virtual bool isShader() const { return false; } 59 virtual bool isTexture() const { return false; } 42 Platform3DObject object() const { return m_object; } 43 void setObject(Platform3DObject, bool shouldDeleteObject = true); 44 void deleteObject(); 60 45 61 protected: 62 WebGLObject(WebGLRenderingContext*); 63 virtual void _deleteObject(Platform3DObject) = 0; 64 65 private: 66 Platform3DObject m_object; 67 // The shouldDeleteObject flag indicates whether this wrapper 68 // owns the underlying resource and should delete it when the 69 // wrapper is unreferenced for the last time and deleted. It 70 // is only set to false for certain objects returned from get 71 // queries. FIXME: should consider canonicalizing all of these 72 // objects in the future. 73 bool m_shouldDeleteObject; 74 WebGLRenderingContext* m_context; 75 }; 76 46 void detachContext() 47 { 48 deleteObject(); 49 m_context = 0; 50 } 51 52 WebGLRenderingContext* context() const { return m_context; } 53 54 virtual bool isBuffer() const { return false; } 55 virtual bool isFramebuffer() const { return false; } 56 virtual bool isProgram() const { return false; } 57 virtual bool isRenderbuffer() const { return false; } 58 virtual bool isShader() const { return false; } 59 virtual bool isTexture() const { return false; } 60 61 protected: 62 WebGLObject(WebGLRenderingContext*); 63 virtual void deleteObjectImpl(Platform3DObject) = 0; 64 65 private: 66 Platform3DObject m_object; 67 // The shouldDeleteObject flag indicates whether this wrapper 68 // owns the underlying resource and should delete it when the 69 // wrapper is unreferenced for the last time and deleted. It 70 // is only set to false for certain objects returned from get 71 // queries. FIXME: should consider canonicalizing all of these 72 // objects in the future. 73 bool m_shouldDeleteObject; 74 WebGLRenderingContext* m_context; 75 }; 76 77 77 } // namespace WebCore 78 78 -
trunk/WebCore/html/canvas/WebGLProgram.cpp
r64685 r64767 29 29 30 30 #include "WebGLProgram.h" 31 31 32 #include "WebGLRenderingContext.h" 32 33 … … 45 46 } 46 47 47 void WebGLProgram:: _deleteObject(Platform3DObject object)48 void WebGLProgram::deleteObjectImpl(Platform3DObject object) 48 49 { 49 50 context()->graphicsContext3D()->deleteProgram(object); -
trunk/WebCore/html/canvas/WebGLProgram.h
r64685 r64767 34 34 35 35 namespace WebCore { 36 37 class WebGLProgram : public WebGLObject {38 public:39 virtual ~WebGLProgram() { deleteObject(); }40 41 static PassRefPtr<WebGLProgram> create(WebGLRenderingContext*);42 36 43 // cacheActiveAttribLocation() is only called once after linkProgram() 44 // succeeds. 45 bool cacheActiveAttribLocations(); 46 int numActiveAttribLocations() const; 47 int getActiveAttribLocation(int index) const; 37 class WebGLProgram : public WebGLObject { 38 public: 39 virtual ~WebGLProgram() { deleteObject(); } 48 40 49 bool isUsingVertexAttrib0() const;41 static PassRefPtr<WebGLProgram> create(WebGLRenderingContext*); 50 42 51 // Return true means getProgramParameter(LINK_STATUS) should return52 // false; return false means we should actually call53 // getProgramParameter(LINK_STATUS) to find out.54 bool isLinkFailureFlagSet() const { return m_linkFailure; }55 void setLinkFailureFlag(bool failed) { m_linkFailure = failed; }43 // cacheActiveAttribLocation() is only called once after linkProgram() 44 // succeeds. 45 bool cacheActiveAttribLocations(); 46 int numActiveAttribLocations() const; 47 int getActiveAttribLocation(int index) const; 56 48 57 protected: 58 WebGLProgram(WebGLRenderingContext*); 59 60 virtual void _deleteObject(Platform3DObject); 49 bool isUsingVertexAttrib0() const; 61 50 62 private: 63 virtual bool isProgram() const { return true; } 51 // Return true means getProgramParameter(LINK_STATUS) should return 52 // false; return false means we should actually call 53 // getProgramParameter(LINK_STATUS) to find out. 54 bool isLinkFailureFlagSet() const { return m_linkFailure; } 55 void setLinkFailureFlag(bool failed) { m_linkFailure = failed; } 64 56 65 Vector<int> m_activeAttribLocations; 57 protected: 58 WebGLProgram(WebGLRenderingContext*); 66 59 67 bool m_linkFailure; 68 }; 69 60 virtual void deleteObjectImpl(Platform3DObject); 61 62 private: 63 virtual bool isProgram() const { return true; } 64 65 Vector<int> m_activeAttribLocations; 66 67 bool m_linkFailure; 68 }; 69 70 70 } // namespace WebCore 71 71 -
trunk/WebCore/html/canvas/WebGLRenderbuffer.cpp
r64685 r64767 29 29 30 30 #include "WebGLRenderbuffer.h" 31 31 32 #include "WebGLRenderingContext.h" 32 33 … … 46 47 } 47 48 48 void WebGLRenderbuffer:: _deleteObject(Platform3DObject object)49 void WebGLRenderbuffer::deleteObjectImpl(Platform3DObject object) 49 50 { 50 51 context()->graphicsContext3D()->deleteRenderbuffer(object); -
trunk/WebCore/html/canvas/WebGLRenderbuffer.h
r64685 r64767 33 33 34 34 namespace WebCore { 35 36 class WebGLRenderbuffer : public WebGLObject {37 public:38 virtual ~WebGLRenderbuffer() { deleteObject(); }39 40 static PassRefPtr<WebGLRenderbuffer> create(WebGLRenderingContext*);41 35 42 void setInternalFormat(unsigned long internalformat) { m_internalFormat = internalformat; } 43 unsigned long getInternalFormat() const { return m_internalFormat; } 36 class WebGLRenderbuffer : public WebGLObject { 37 public: 38 virtual ~WebGLRenderbuffer() { deleteObject(); } 44 39 45 bool isInitialized() const { return m_initialized; } 46 void setInitialized() { m_initialized = true; } 40 static PassRefPtr<WebGLRenderbuffer> create(WebGLRenderingContext*); 47 41 48 protected: 49 WebGLRenderbuffer(WebGLRenderingContext*); 50 51 virtual void _deleteObject(Platform3DObject); 42 void setInternalFormat(unsigned long internalformat) { m_internalFormat = internalformat; } 43 unsigned long getInternalFormat() const { return m_internalFormat; } 52 44 53 private:54 virtual bool isRenderbuffer() const { returntrue; }45 bool isInitialized() const { return m_initialized; } 46 void setInitialized() { m_initialized = true; } 55 47 56 unsigned long m_internalFormat; 57 bool m_initialized; 58 }; 59 48 protected: 49 WebGLRenderbuffer(WebGLRenderingContext*); 50 51 virtual void deleteObjectImpl(Platform3DObject); 52 53 private: 54 virtual bool isRenderbuffer() const { return true; } 55 56 unsigned long m_internalFormat; 57 bool m_initialized; 58 }; 59 60 60 } // namespace WebCore 61 61 -
trunk/WebCore/html/canvas/WebGLRenderingContext.cpp
r64685 r64767 30 30 #include "WebGLRenderingContext.h" 31 31 32 #include "CanvasPixelArray.h" 32 33 #include "CheckedInt.h" 33 #include "CanvasPixelArray.h"34 34 #include "Console.h" 35 35 #include "DOMWindow.h" … … 42 42 #include "RenderBox.h" 43 43 #include "RenderLayer.h" 44 #include "Uint16Array.h" 44 45 #include "WebGLActiveInfo.h" 45 #include "Uint16Array.h"46 46 #include "WebGLBuffer.h" 47 47 #include "WebGLContextAttributes.h" … … 49 49 #include "WebGLProgram.h" 50 50 #include "WebGLRenderbuffer.h" 51 #include "WebGLShader.h" 51 52 #include "WebGLTexture.h" 52 #include "WebGLShader.h"53 53 #include "WebGLUniformLocation.h" 54 54 … … 172 172 void WebGLRenderingContext::beginPaint() 173 173 { 174 if (m_markedCanvasDirty) {174 if (m_markedCanvasDirty) 175 175 m_context->beginPaint(this); 176 }177 176 } 178 177 … … 351 350 } 352 351 353 void WebGLRenderingContext::blendEquation( unsigned long mode)352 void WebGLRenderingContext::blendEquation(unsigned long mode) 354 353 { 355 354 if (!isGLES2Compliant()) { … … 1144 1143 if (!validateWebGLObject(program)) 1145 1144 return 0; 1146 if (!m_context->getActiveAttrib(objectOrZero(program), index, info)) {1145 if (!m_context->getActiveAttrib(objectOrZero(program), index, info)) 1147 1146 return 0; 1148 }1149 1147 return WebGLActiveInfo::create(info.name, info.type, info.size); 1150 1148 } … … 1156 1154 if (!validateWebGLObject(program)) 1157 1155 return 0; 1158 if (!m_context->getActiveUniform(objectOrZero(program), index, info)) {1156 if (!m_context->getActiveUniform(objectOrZero(program), index, info)) 1159 1157 return 0; 1160 } 1161 if (!isGLES2Compliant()) { 1158 if (!isGLES2Compliant()) 1162 1159 if (info.size > 1 && !info.name.endsWith("[0]")) 1163 1160 info.name.append("[0]"); 1164 }1165 1161 return WebGLActiveInfo::create(info.name, info.type, info.size); 1166 1162 } … … 1216 1212 if (pname == GraphicsContext3D::BUFFER_SIZE) 1217 1213 return WebGLGetInfo(static_cast<long>(value)); 1218 else 1219 return WebGLGetInfo(static_cast<unsigned long>(value)); 1214 return WebGLGetInfo(static_cast<unsigned long>(value)); 1220 1215 } 1221 1216 … … 1259 1254 if (pname == GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) 1260 1255 return WebGLGetInfo(static_cast<unsigned long>(value)); 1261 else 1262 return WebGLGetInfo(static_cast<long>(value)); 1263 } else { 1264 WebGLStateRestorer(this, false); 1265 int type = 0; 1266 m_context->getFramebufferAttachmentParameteriv(target, attachment, GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &type); 1267 int value = 0; 1268 m_context->getFramebufferAttachmentParameteriv(target, attachment, GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &value); 1269 switch (type) { 1270 case GraphicsContext3D::RENDERBUFFER: 1271 return WebGLGetInfo(PassRefPtr<WebGLRenderbuffer>(findRenderbuffer(static_cast<Platform3DObject>(value)))); 1272 case GraphicsContext3D::TEXTURE: 1273 return WebGLGetInfo(PassRefPtr<WebGLTexture>(findTexture(static_cast<Platform3DObject>(value)))); 1274 default: 1275 // FIXME: raise exception? 1276 return WebGLGetInfo(); 1277 } 1256 return WebGLGetInfo(static_cast<long>(value)); 1257 } 1258 1259 WebGLStateRestorer(this, false); 1260 int type = 0; 1261 m_context->getFramebufferAttachmentParameteriv(target, attachment, GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &type); 1262 int value = 0; 1263 m_context->getFramebufferAttachmentParameteriv(target, attachment, GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &value); 1264 switch (type) { 1265 case GraphicsContext3D::RENDERBUFFER: 1266 return WebGLGetInfo(PassRefPtr<WebGLRenderbuffer>(findRenderbuffer(static_cast<Platform3DObject>(value)))); 1267 case GraphicsContext3D::TEXTURE: 1268 return WebGLGetInfo(PassRefPtr<WebGLTexture>(findTexture(static_cast<Platform3DObject>(value)))); 1269 default: 1270 // FIXME: raise exception? 1271 return WebGLGetInfo(); 1278 1272 } 1279 1273 } … … 3051 3045 3052 3046 long validatedStride = bytesPerElement; 3053 if (stride != 0) {3047 if (stride) { 3054 3048 if ((long) stride < bytesPerElement) { 3055 3049 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE); -
trunk/WebCore/html/canvas/WebGLRenderingContext.h
r64685 r64767 30 30 #include "ExceptionCode.h" 31 31 #include "Float32Array.h" 32 #include "GraphicsContext3D.h" 33 #include "Int32Array.h" 34 #include "PlatformString.h" 35 #include "Uint8Array.h" 32 36 #include "WebGLGetInfo.h" 33 #include "Int32Array.h"34 #include "Uint8Array.h"35 #include "GraphicsContext3D.h"36 #include "PlatformString.h"37 37 38 38 namespace WebCore { … … 53 53 class WebKitCSSMatrix; 54 54 55 class WebGLRenderingContext : public CanvasRenderingContext { 55 class WebGLRenderingContext : public CanvasRenderingContext { 56 public: 57 static PassOwnPtr<WebGLRenderingContext> create(HTMLCanvasElement*, WebGLContextAttributes*); 58 virtual ~WebGLRenderingContext(); 59 60 virtual bool is3d() const { return true; } 61 virtual bool isAccelerated() const { return true; } 62 63 // Helper to return the size in bytes of OpenGL data types 64 // like GL_FLOAT, GL_INT, etc. 65 int sizeInBytes(int type, ExceptionCode& ec); 66 67 void activeTexture(unsigned long texture, ExceptionCode& ec); 68 void attachShader(WebGLProgram*, WebGLShader*, ExceptionCode& ec); 69 void bindAttribLocation(WebGLProgram*, unsigned long index, const String& name, ExceptionCode& ec); 70 void bindBuffer(unsigned long target, WebGLBuffer*, ExceptionCode& ec); 71 void bindFramebuffer(unsigned long target, WebGLFramebuffer*, ExceptionCode& ec); 72 void bindRenderbuffer(unsigned long target, WebGLRenderbuffer*, ExceptionCode& ec); 73 void bindTexture(unsigned long target, WebGLTexture*, ExceptionCode& ec); 74 void blendColor(double red, double green, double blue, double alpha); 75 void blendEquation(unsigned long mode); 76 void blendEquationSeparate(unsigned long modeRGB, unsigned long modeAlpha); 77 void blendFunc(unsigned long sfactor, unsigned long dfactor); 78 void blendFuncSeparate(unsigned long srcRGB, unsigned long dstRGB, unsigned long srcAlpha, unsigned long dstAlpha); 79 80 void bufferData(unsigned long target, int size, unsigned long usage, ExceptionCode&); 81 void bufferData(unsigned long target, ArrayBuffer* data, unsigned long usage, ExceptionCode&); 82 void bufferData(unsigned long target, ArrayBufferView* data, unsigned long usage, ExceptionCode&); 83 void bufferSubData(unsigned long target, long offset, ArrayBuffer* data, ExceptionCode&); 84 void bufferSubData(unsigned long target, long offset, ArrayBufferView* data, ExceptionCode&); 85 86 unsigned long checkFramebufferStatus(unsigned long target); 87 void clear(unsigned long mask); 88 void clearColor(double red, double green, double blue, double alpha); 89 void clearDepth(double); 90 void clearStencil(long); 91 void colorMask(bool red, bool green, bool blue, bool alpha); 92 void compileShader(WebGLShader*, ExceptionCode& ec); 93 94 // void compressedTexImage2D(unsigned long target, long level, unsigned long internalformat, unsigned long width, unsigned long height, long border, unsigned long imageSize, const void* data); 95 // void compressedTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, unsigned long width, unsigned long height, unsigned long format, unsigned long imageSize, const void* data); 96 97 void copyTexImage2D(unsigned long target, long level, unsigned long internalformat, long x, long y, unsigned long width, unsigned long height, long border); 98 void copyTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, long x, long y, unsigned long width, unsigned long height); 99 100 PassRefPtr<WebGLBuffer> createBuffer(); 101 PassRefPtr<WebGLFramebuffer> createFramebuffer(); 102 PassRefPtr<WebGLProgram> createProgram(); 103 PassRefPtr<WebGLRenderbuffer> createRenderbuffer(); 104 PassRefPtr<WebGLShader> createShader(unsigned long type, ExceptionCode&); 105 PassRefPtr<WebGLTexture> createTexture(); 106 107 void cullFace(unsigned long mode); 108 109 void deleteBuffer(WebGLBuffer*); 110 void deleteFramebuffer(WebGLFramebuffer*); 111 void deleteProgram(WebGLProgram*); 112 void deleteRenderbuffer(WebGLRenderbuffer*); 113 void deleteShader(WebGLShader*); 114 void deleteTexture(WebGLTexture*); 115 116 void depthFunc(unsigned long); 117 void depthMask(bool); 118 void depthRange(double zNear, double zFar); 119 void detachShader(WebGLProgram*, WebGLShader*, ExceptionCode&); 120 void disable(unsigned long cap); 121 void disableVertexAttribArray(unsigned long index, ExceptionCode&); 122 void drawArrays(unsigned long mode, long first, long count, ExceptionCode&); 123 void drawElements(unsigned long mode, long count, unsigned long type, long offset, ExceptionCode&); 124 125 void enable(unsigned long cap); 126 void enableVertexAttribArray(unsigned long index, ExceptionCode&); 127 void finish(); 128 void flush(); 129 void framebufferRenderbuffer(unsigned long target, unsigned long attachment, unsigned long renderbuffertarget, WebGLRenderbuffer*, ExceptionCode& ec); 130 void framebufferTexture2D(unsigned long target, unsigned long attachment, unsigned long textarget, WebGLTexture*, long level, ExceptionCode& ec); 131 void frontFace(unsigned long mode); 132 void generateMipmap(unsigned long target); 133 134 PassRefPtr<WebGLActiveInfo> getActiveAttrib(WebGLProgram*, unsigned long index, ExceptionCode&); 135 PassRefPtr<WebGLActiveInfo> getActiveUniform(WebGLProgram*, unsigned long index, ExceptionCode&); 136 137 bool getAttachedShaders(WebGLProgram*, Vector<WebGLShader*>&, ExceptionCode&); 138 139 int getAttribLocation(WebGLProgram*, const String& name); 140 141 WebGLGetInfo getBufferParameter(unsigned long target, unsigned long pname, ExceptionCode&); 142 143 PassRefPtr<WebGLContextAttributes> getContextAttributes(); 144 145 unsigned long getError(); 146 147 WebGLGetInfo getFramebufferAttachmentParameter(unsigned long target, unsigned long attachment, unsigned long pname, ExceptionCode&); 148 149 WebGLGetInfo getParameter(unsigned long pname, ExceptionCode&); 150 151 WebGLGetInfo getProgramParameter(WebGLProgram*, unsigned long pname, ExceptionCode&); 152 153 String getProgramInfoLog(WebGLProgram*, ExceptionCode& ec); 154 155 WebGLGetInfo getRenderbufferParameter(unsigned long target, unsigned long pname, ExceptionCode&); 156 157 WebGLGetInfo getShaderParameter(WebGLShader*, unsigned long pname, ExceptionCode& ec); 158 159 String getShaderInfoLog(WebGLShader*, ExceptionCode& ec); 160 161 // TBD 162 // void glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); 163 164 String getShaderSource(WebGLShader*, ExceptionCode&); 165 String getString(unsigned long name); 166 167 WebGLGetInfo getTexParameter(unsigned long target, unsigned long pname, ExceptionCode&); 168 169 WebGLGetInfo getUniform(WebGLProgram*, const WebGLUniformLocation*, ExceptionCode&); 170 171 PassRefPtr<WebGLUniformLocation> getUniformLocation(WebGLProgram*, const String&, ExceptionCode&); 172 173 WebGLGetInfo getVertexAttrib(unsigned long index, unsigned long pname, ExceptionCode&); 174 175 long getVertexAttribOffset(unsigned long index, unsigned long pname); 176 177 void hint(unsigned long target, unsigned long mode); 178 bool isBuffer(WebGLBuffer*); 179 bool isEnabled(unsigned long cap); 180 bool isFramebuffer(WebGLFramebuffer*); 181 bool isProgram(WebGLProgram*); 182 bool isRenderbuffer(WebGLRenderbuffer*); 183 bool isShader(WebGLShader*); 184 bool isTexture(WebGLTexture*); 185 void lineWidth(double); 186 void linkProgram(WebGLProgram*, ExceptionCode&); 187 void pixelStorei(unsigned long pname, long param); 188 void polygonOffset(double factor, double units); 189 void readPixels(long x, long y, long width, long height, unsigned long format, unsigned long type, ArrayBufferView* pixels); 190 void releaseShaderCompiler(); 191 void renderbufferStorage(unsigned long target, unsigned long internalformat, unsigned long width, unsigned long height); 192 void sampleCoverage(double value, bool invert); 193 void scissor(long x, long y, unsigned long width, unsigned long height); 194 void shaderSource(WebGLShader*, const String&, ExceptionCode&); 195 void stencilFunc(unsigned long func, long ref, unsigned long mask); 196 void stencilFuncSeparate(unsigned long face, unsigned long func, long ref, unsigned long mask); 197 void stencilMask(unsigned long); 198 void stencilMaskSeparate(unsigned long face, unsigned long mask); 199 void stencilOp(unsigned long fail, unsigned long zfail, unsigned long zpass); 200 void stencilOpSeparate(unsigned long face, unsigned long fail, unsigned long zfail, unsigned long zpass); 201 202 void texImage2D(unsigned target, unsigned level, unsigned internalformat, 203 unsigned width, unsigned height, unsigned border, 204 unsigned format, unsigned type, ArrayBufferView* pixels, ExceptionCode&); 205 void texImage2D(unsigned target, unsigned level, unsigned internalformat, 206 unsigned format, unsigned type, ImageData* pixels, ExceptionCode&); 207 void texImage2D(unsigned target, unsigned level, unsigned internalformat, 208 unsigned format, unsigned type, HTMLImageElement* image, ExceptionCode&); 209 void texImage2D(unsigned target, unsigned level, unsigned internalformat, 210 unsigned format, unsigned type, HTMLCanvasElement* canvas, ExceptionCode&); 211 void texImage2D(unsigned target, unsigned level, unsigned internalformat, 212 unsigned format, unsigned type, HTMLVideoElement* video, ExceptionCode&); 213 // Obsolete entry points -- to be removed shortly. (FIXME) 214 void texImage2D(unsigned target, unsigned level, ImageData* pixels, ExceptionCode&); 215 void texImage2D(unsigned target, unsigned level, ImageData* pixels, bool flipY, ExceptionCode&); 216 void texImage2D(unsigned target, unsigned level, ImageData* pixels, bool flipY, bool premultiplyAlpha, ExceptionCode&); 217 void texImage2D(unsigned target, unsigned level, HTMLImageElement* image, ExceptionCode&); 218 void texImage2D(unsigned target, unsigned level, HTMLImageElement* image, bool flipY, ExceptionCode&); 219 void texImage2D(unsigned target, unsigned level, HTMLImageElement* image, bool flipY, bool premultiplyAlpha, ExceptionCode&); 220 void texImage2D(unsigned target, unsigned level, HTMLCanvasElement* canvas, ExceptionCode&); 221 void texImage2D(unsigned target, unsigned level, HTMLCanvasElement* canvas, bool flipY, ExceptionCode&); 222 void texImage2D(unsigned target, unsigned level, HTMLCanvasElement* canvas, bool flipY, bool premultiplyAlpha, ExceptionCode&); 223 void texImage2D(unsigned target, unsigned level, HTMLVideoElement* video, ExceptionCode&); 224 void texImage2D(unsigned target, unsigned level, HTMLVideoElement* video, bool flipY, ExceptionCode&); 225 void texImage2D(unsigned target, unsigned level, HTMLVideoElement* video, bool flipY, bool premultiplyAlpha, ExceptionCode&); 226 227 void texParameterf(unsigned target, unsigned pname, float param); 228 void texParameteri(unsigned target, unsigned pname, int param); 229 230 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, 231 unsigned width, unsigned height, 232 unsigned format, unsigned type, ArrayBufferView* pixels, ExceptionCode&); 233 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, 234 unsigned format, unsigned type, ImageData* pixels, ExceptionCode&); 235 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, 236 unsigned format, unsigned type, HTMLImageElement* image, ExceptionCode&); 237 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, 238 unsigned format, unsigned type, HTMLCanvasElement* canvas, ExceptionCode&); 239 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, 240 unsigned format, unsigned type, HTMLVideoElement* video, ExceptionCode&); 241 // Obsolete entry points -- to be removed shortly. (FIXME) 242 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, ImageData* pixels, ExceptionCode&); 243 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, ImageData* pixels, bool flipY, ExceptionCode&); 244 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, ImageData* pixels, bool flipY, bool premultiplyAlpha, ExceptionCode&); 245 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, HTMLImageElement* image, ExceptionCode&); 246 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, HTMLImageElement* image, bool flipY, ExceptionCode&); 247 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, HTMLImageElement* image, bool flipY, bool premultiplyAlpha, ExceptionCode&); 248 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, HTMLCanvasElement* canvas, ExceptionCode&); 249 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, HTMLCanvasElement* canvas, bool flipY, ExceptionCode&); 250 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, HTMLCanvasElement* canvas, bool flipY, bool premultiplyAlpha, ExceptionCode&); 251 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, HTMLVideoElement* video, ExceptionCode&); 252 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, HTMLVideoElement* video, bool flipY, ExceptionCode&); 253 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, HTMLVideoElement* video, bool flipY, bool premultiplyAlpha, ExceptionCode&); 254 255 void uniform1f(const WebGLUniformLocation* location, float x, ExceptionCode&); 256 void uniform1fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode&); 257 void uniform1fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode&); 258 void uniform1i(const WebGLUniformLocation* location, int x, ExceptionCode&); 259 void uniform1iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode&); 260 void uniform1iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode&); 261 void uniform2f(const WebGLUniformLocation* location, float x, float y, ExceptionCode&); 262 void uniform2fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode&); 263 void uniform2fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode&); 264 void uniform2i(const WebGLUniformLocation* location, int x, int y, ExceptionCode&); 265 void uniform2iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode&); 266 void uniform2iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode&); 267 void uniform3f(const WebGLUniformLocation* location, float x, float y, float z, ExceptionCode&); 268 void uniform3fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode&); 269 void uniform3fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode&); 270 void uniform3i(const WebGLUniformLocation* location, int x, int y, int z, ExceptionCode&); 271 void uniform3iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode&); 272 void uniform3iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode&); 273 void uniform4f(const WebGLUniformLocation* location, float x, float y, float z, float w, ExceptionCode&); 274 void uniform4fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode&); 275 void uniform4fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode&); 276 void uniform4i(const WebGLUniformLocation* location, int x, int y, int z, int w, ExceptionCode&); 277 void uniform4iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode&); 278 void uniform4iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode&); 279 void uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, Float32Array* value, ExceptionCode&); 280 void uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, float* value, int size, ExceptionCode&); 281 void uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, Float32Array* value, ExceptionCode&); 282 void uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, float* value, int size, ExceptionCode&); 283 void uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, Float32Array* value, ExceptionCode&); 284 void uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, float* value, int size, ExceptionCode&); 285 286 void useProgram(WebGLProgram*, ExceptionCode&); 287 void validateProgram(WebGLProgram*, ExceptionCode&); 288 289 void vertexAttrib1f(unsigned long index, float x); 290 void vertexAttrib1fv(unsigned long index, Float32Array* values); 291 void vertexAttrib1fv(unsigned long index, float* values, int size); 292 void vertexAttrib2f(unsigned long index, float x, float y); 293 void vertexAttrib2fv(unsigned long index, Float32Array* values); 294 void vertexAttrib2fv(unsigned long index, float* values, int size); 295 void vertexAttrib3f(unsigned long index, float x, float y, float z); 296 void vertexAttrib3fv(unsigned long index, Float32Array* values); 297 void vertexAttrib3fv(unsigned long index, float* values, int size); 298 void vertexAttrib4f(unsigned long index, float x, float y, float z, float w); 299 void vertexAttrib4fv(unsigned long index, Float32Array* values); 300 void vertexAttrib4fv(unsigned long index, float* values, int size); 301 void vertexAttribPointer(unsigned long index, long size, unsigned long type, bool normalized, 302 long stride, long offset, ExceptionCode&); 303 304 void viewport(long x, long y, unsigned long width, unsigned long height); 305 306 virtual GraphicsContext3D* graphicsContext3D() const { return m_context.get(); } 307 308 void reshape(int width, int height); 309 310 // Return value true indicates canvas is updated during the call, 311 // false indicates no updates. 312 bool paintRenderingResultsToCanvas(); 313 314 // Helpers for notification about paint events. 315 void beginPaint(); 316 void endPaint(); 317 318 void removeObject(WebGLObject*); 319 320 private: 321 friend class WebGLObject; 322 323 WebGLRenderingContext(HTMLCanvasElement*, PassOwnPtr<GraphicsContext3D>); 324 325 void addObject(WebGLObject*); 326 void detachAndRemoveAllObjects(); 327 WebGLTexture* findTexture(Platform3DObject); 328 WebGLRenderbuffer* findRenderbuffer(Platform3DObject); 329 WebGLBuffer* findBuffer(Platform3DObject); 330 WebGLShader* findShader(Platform3DObject); 331 332 void markContextChanged(); 333 void cleanupAfterGraphicsCall(bool changed) 334 { 335 if (changed) 336 markContextChanged(); 337 } 338 339 bool isGLES2Compliant(); 340 341 // Basic validation of count and offset against number of elements in element array buffer 342 bool validateElementArraySize(unsigned long count, unsigned long type, long offset); 343 344 // Conservative but quick index validation 345 bool validateIndexArrayConservative(unsigned long type, long& numElementsRequired); 346 347 // Precise but slow index validation -- only done if conservative checks fail 348 bool validateIndexArrayPrecise(unsigned long count, unsigned long type, long offset, long& numElementsRequired); 349 bool validateRenderingState(long numElements); 350 351 bool validateWebGLObject(WebGLObject* object); 352 353 OwnPtr<GraphicsContext3D> m_context; 354 bool m_needsUpdate; 355 bool m_markedCanvasDirty; 356 // FIXME: I think this is broken -- it does not increment any 357 // reference counts, so may refer to destroyed objects. 358 HashSet<RefPtr<WebGLObject> > m_canvasObjects; 359 360 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER and stored values for ELEMENT_ARRAY_BUFFER 361 RefPtr<WebGLBuffer> m_boundArrayBuffer; 362 RefPtr<WebGLBuffer> m_boundElementArrayBuffer; 363 364 // Cached values for vertex attrib range checks 365 class VertexAttribState { 56 366 public: 57 static PassOwnPtr<WebGLRenderingContext> create(HTMLCanvasElement*, WebGLContextAttributes*); 58 virtual ~WebGLRenderingContext(); 59 60 virtual bool is3d() const { return true; } 61 virtual bool isAccelerated() const { return true; } 62 63 // Helper to return the size in bytes of OpenGL data types 64 // like GL_FLOAT, GL_INT, etc. 65 int sizeInBytes(int type, ExceptionCode& ec); 66 67 void activeTexture(unsigned long texture, ExceptionCode& ec); 68 void attachShader(WebGLProgram*, WebGLShader*, ExceptionCode& ec); 69 void bindAttribLocation(WebGLProgram*, unsigned long index, const String& name, ExceptionCode& ec); 70 void bindBuffer(unsigned long target, WebGLBuffer*, ExceptionCode& ec); 71 void bindFramebuffer(unsigned long target, WebGLFramebuffer*, ExceptionCode& ec); 72 void bindRenderbuffer(unsigned long target, WebGLRenderbuffer*, ExceptionCode& ec); 73 void bindTexture(unsigned long target, WebGLTexture*, ExceptionCode& ec); 74 void blendColor(double red, double green, double blue, double alpha); 75 void blendEquation(unsigned long mode); 76 void blendEquationSeparate(unsigned long modeRGB, unsigned long modeAlpha); 77 void blendFunc(unsigned long sfactor, unsigned long dfactor); 78 void blendFuncSeparate(unsigned long srcRGB, unsigned long dstRGB, unsigned long srcAlpha, unsigned long dstAlpha); 79 80 void bufferData(unsigned long target, int size, unsigned long usage, ExceptionCode&); 81 void bufferData(unsigned long target, ArrayBuffer* data, unsigned long usage, ExceptionCode&); 82 void bufferData(unsigned long target, ArrayBufferView* data, unsigned long usage, ExceptionCode&); 83 void bufferSubData(unsigned long target, long offset, ArrayBuffer* data, ExceptionCode&); 84 void bufferSubData(unsigned long target, long offset, ArrayBufferView* data, ExceptionCode&); 85 86 unsigned long checkFramebufferStatus(unsigned long target); 87 void clear(unsigned long mask); 88 void clearColor(double red, double green, double blue, double alpha); 89 void clearDepth(double); 90 void clearStencil(long); 91 void colorMask(bool red, bool green, bool blue, bool alpha); 92 void compileShader(WebGLShader*, ExceptionCode& ec); 93 94 //void compressedTexImage2D(unsigned long target, long level, unsigned long internalformat, unsigned long width, unsigned long height, long border, unsigned long imageSize, const void* data); 95 //void compressedTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, unsigned long width, unsigned long height, unsigned long format, unsigned long imageSize, const void* data); 96 97 void copyTexImage2D(unsigned long target, long level, unsigned long internalformat, long x, long y, unsigned long width, unsigned long height, long border); 98 void copyTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, long x, long y, unsigned long width, unsigned long height); 99 100 PassRefPtr<WebGLBuffer> createBuffer(); 101 PassRefPtr<WebGLFramebuffer> createFramebuffer(); 102 PassRefPtr<WebGLProgram> createProgram(); 103 PassRefPtr<WebGLRenderbuffer> createRenderbuffer(); 104 PassRefPtr<WebGLShader> createShader(unsigned long type, ExceptionCode&); 105 PassRefPtr<WebGLTexture> createTexture(); 106 107 void cullFace(unsigned long mode); 108 109 void deleteBuffer(WebGLBuffer*); 110 void deleteFramebuffer(WebGLFramebuffer*); 111 void deleteProgram(WebGLProgram*); 112 void deleteRenderbuffer(WebGLRenderbuffer*); 113 void deleteShader(WebGLShader*); 114 void deleteTexture(WebGLTexture*); 115 116 void depthFunc(unsigned long); 117 void depthMask(bool); 118 void depthRange(double zNear, double zFar); 119 void detachShader(WebGLProgram*, WebGLShader*, ExceptionCode&); 120 void disable(unsigned long cap); 121 void disableVertexAttribArray(unsigned long index, ExceptionCode&); 122 void drawArrays(unsigned long mode, long first, long count, ExceptionCode&); 123 void drawElements(unsigned long mode, long count, unsigned long type, long offset, ExceptionCode&); 124 125 void enable(unsigned long cap); 126 void enableVertexAttribArray(unsigned long index, ExceptionCode&); 127 void finish(); 128 void flush(); 129 void framebufferRenderbuffer(unsigned long target, unsigned long attachment, unsigned long renderbuffertarget, WebGLRenderbuffer*, ExceptionCode& ec); 130 void framebufferTexture2D(unsigned long target, unsigned long attachment, unsigned long textarget, WebGLTexture*, long level, ExceptionCode& ec); 131 void frontFace(unsigned long mode); 132 void generateMipmap(unsigned long target); 133 134 PassRefPtr<WebGLActiveInfo> getActiveAttrib(WebGLProgram*, unsigned long index, ExceptionCode&); 135 PassRefPtr<WebGLActiveInfo> getActiveUniform(WebGLProgram*, unsigned long index, ExceptionCode&); 136 137 bool getAttachedShaders(WebGLProgram*, Vector<WebGLShader*>&, ExceptionCode&); 138 139 int getAttribLocation(WebGLProgram*, const String& name); 140 141 WebGLGetInfo getBufferParameter(unsigned long target, unsigned long pname, ExceptionCode&); 142 143 PassRefPtr<WebGLContextAttributes> getContextAttributes(); 144 145 unsigned long getError(); 146 147 WebGLGetInfo getFramebufferAttachmentParameter(unsigned long target, unsigned long attachment, unsigned long pname, ExceptionCode&); 148 149 WebGLGetInfo getParameter(unsigned long pname, ExceptionCode&); 150 151 WebGLGetInfo getProgramParameter(WebGLProgram*, unsigned long pname, ExceptionCode&); 152 153 String getProgramInfoLog(WebGLProgram*, ExceptionCode& ec); 154 155 WebGLGetInfo getRenderbufferParameter(unsigned long target, unsigned long pname, ExceptionCode&); 156 157 WebGLGetInfo getShaderParameter(WebGLShader*, unsigned long pname, ExceptionCode& ec); 158 159 String getShaderInfoLog(WebGLShader*, ExceptionCode& ec); 160 161 // TBD 162 // void glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); 163 164 String getShaderSource(WebGLShader*, ExceptionCode&); 165 String getString(unsigned long name); 166 167 WebGLGetInfo getTexParameter(unsigned long target, unsigned long pname, ExceptionCode&); 168 169 WebGLGetInfo getUniform(WebGLProgram*, const WebGLUniformLocation*, ExceptionCode&); 170 171 PassRefPtr<WebGLUniformLocation> getUniformLocation(WebGLProgram*, const String&, ExceptionCode&); 172 173 WebGLGetInfo getVertexAttrib(unsigned long index, unsigned long pname, ExceptionCode&); 174 175 long getVertexAttribOffset(unsigned long index, unsigned long pname); 176 177 void hint(unsigned long target, unsigned long mode); 178 bool isBuffer(WebGLBuffer*); 179 bool isEnabled(unsigned long cap); 180 bool isFramebuffer(WebGLFramebuffer*); 181 bool isProgram(WebGLProgram*); 182 bool isRenderbuffer(WebGLRenderbuffer*); 183 bool isShader(WebGLShader*); 184 bool isTexture(WebGLTexture*); 185 void lineWidth(double); 186 void linkProgram(WebGLProgram*, ExceptionCode&); 187 void pixelStorei(unsigned long pname, long param); 188 void polygonOffset(double factor, double units); 189 void readPixels(long x, long y, long width, long height, unsigned long format, unsigned long type, ArrayBufferView* pixels); 190 void releaseShaderCompiler(); 191 void renderbufferStorage(unsigned long target, unsigned long internalformat, unsigned long width, unsigned long height); 192 void sampleCoverage(double value, bool invert); 193 void scissor(long x, long y, unsigned long width, unsigned long height); 194 void shaderSource(WebGLShader*, const String&, ExceptionCode&); 195 void stencilFunc(unsigned long func, long ref, unsigned long mask); 196 void stencilFuncSeparate(unsigned long face, unsigned long func, long ref, unsigned long mask); 197 void stencilMask(unsigned long); 198 void stencilMaskSeparate(unsigned long face, unsigned long mask); 199 void stencilOp(unsigned long fail, unsigned long zfail, unsigned long zpass); 200 void stencilOpSeparate(unsigned long face, unsigned long fail, unsigned long zfail, unsigned long zpass); 201 202 void texImage2D(unsigned target, unsigned level, unsigned internalformat, 367 VertexAttribState() 368 : enabled(false) 369 , bytesPerElement(0) 370 , size(4) 371 , type(GraphicsContext3D::FLOAT) 372 , normalized(false) 373 , stride(16) 374 , originalStride(0) 375 , offset(0) 376 { 377 initValue(); 378 } 379 380 void initValue() 381 { 382 value[0] = 0.0f; 383 value[1] = 0.0f; 384 value[2] = 0.0f; 385 value[3] = 1.0f; 386 } 387 388 bool enabled; 389 RefPtr<WebGLBuffer> bufferBinding; 390 long bytesPerElement; 391 long size; 392 unsigned long type; 393 bool normalized; 394 long stride; 395 long originalStride; 396 long offset; 397 float value[4]; 398 }; 399 400 Vector<VertexAttribState> m_vertexAttribState; 401 unsigned m_maxVertexAttribs; 402 RefPtr<WebGLBuffer> m_vertexAttrib0Buffer; 403 long m_vertexAttrib0BufferSize; 404 float m_vertexAttrib0BufferValue[4]; 405 406 RefPtr<WebGLProgram> m_currentProgram; 407 RefPtr<WebGLFramebuffer> m_framebufferBinding; 408 RefPtr<WebGLRenderbuffer> m_renderbufferBinding; 409 class TextureUnitState { 410 public: 411 RefPtr<WebGLTexture> m_texture2DBinding; 412 RefPtr<WebGLTexture> m_textureCubeMapBinding; 413 }; 414 Vector<TextureUnitState> m_textureUnits; 415 unsigned long m_activeTextureUnit; 416 417 RefPtr<WebGLTexture> m_blackTexture2D; 418 RefPtr<WebGLTexture> m_blackTextureCubeMap; 419 420 int m_maxTextureSize; 421 int m_maxCubeMapTextureSize; 422 int m_maxTextureLevel; 423 int m_maxCubeMapTextureLevel; 424 425 int m_packAlignment; 426 int m_unpackAlignment; 427 unsigned long m_implementationColorReadFormat; 428 unsigned long m_implementationColorReadType; 429 bool m_unpackFlipY; 430 bool m_unpackPremultiplyAlpha; 431 432 // Helpers for getParameter and others 433 WebGLGetInfo getBooleanParameter(unsigned long pname); 434 WebGLGetInfo getBooleanArrayParameter(unsigned long pname); 435 WebGLGetInfo getFloatParameter(unsigned long pname); 436 WebGLGetInfo getIntParameter(unsigned long pname); 437 WebGLGetInfo getLongParameter(unsigned long pname); 438 WebGLGetInfo getUnsignedLongParameter(unsigned long pname); 439 WebGLGetInfo getWebGLFloatArrayParameter(unsigned long pname); 440 WebGLGetInfo getWebGLIntArrayParameter(unsigned long pname); 441 442 void texImage2DBase(unsigned target, unsigned level, unsigned internalformat, 203 443 unsigned width, unsigned height, unsigned border, 204 unsigned format, unsigned type, ArrayBufferView* pixels, ExceptionCode&); 205 void texImage2D(unsigned target, unsigned level, unsigned internalformat, 206 unsigned format, unsigned type, ImageData* pixels, ExceptionCode&); 207 void texImage2D(unsigned target, unsigned level, unsigned internalformat, 208 unsigned format, unsigned type, HTMLImageElement* image, ExceptionCode&); 209 void texImage2D(unsigned target, unsigned level, unsigned internalformat, 210 unsigned format, unsigned type, HTMLCanvasElement* canvas, ExceptionCode&); 211 void texImage2D(unsigned target, unsigned level, unsigned internalformat, 212 unsigned format, unsigned type, HTMLVideoElement* video, ExceptionCode&); 213 // Obsolete entry points -- to be removed shortly. (FIXME) 214 void texImage2D(unsigned target, unsigned level, ImageData* pixels, ExceptionCode&); 215 void texImage2D(unsigned target, unsigned level, ImageData* pixels, bool flipY, ExceptionCode&); 216 void texImage2D(unsigned target, unsigned level, ImageData* pixels, bool flipY, bool premultiplyAlpha, ExceptionCode&); 217 void texImage2D(unsigned target, unsigned level, HTMLImageElement* image, ExceptionCode&); 218 void texImage2D(unsigned target, unsigned level, HTMLImageElement* image, bool flipY, ExceptionCode&); 219 void texImage2D(unsigned target, unsigned level, HTMLImageElement* image, bool flipY, bool premultiplyAlpha, ExceptionCode&); 220 void texImage2D(unsigned target, unsigned level, HTMLCanvasElement* canvas, ExceptionCode&); 221 void texImage2D(unsigned target, unsigned level, HTMLCanvasElement* canvas, bool flipY, ExceptionCode&); 222 void texImage2D(unsigned target, unsigned level, HTMLCanvasElement* canvas, bool flipY, bool premultiplyAlpha, ExceptionCode&); 223 void texImage2D(unsigned target, unsigned level, HTMLVideoElement* video, ExceptionCode&); 224 void texImage2D(unsigned target, unsigned level, HTMLVideoElement* video, bool flipY, ExceptionCode&); 225 void texImage2D(unsigned target, unsigned level, HTMLVideoElement* video, bool flipY, bool premultiplyAlpha, ExceptionCode&); 226 227 void texParameterf(unsigned target, unsigned pname, float param); 228 void texParameteri(unsigned target, unsigned pname, int param); 229 230 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, 444 unsigned format, unsigned type, void* pixels, ExceptionCode&); 445 void texImage2DImpl(unsigned target, unsigned level, unsigned internalformat, 446 unsigned format, unsigned type, Image* image, 447 bool flipY, bool premultiplyAlpha, ExceptionCode&); 448 void texSubImage2DBase(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, 231 449 unsigned width, unsigned height, 232 unsigned format, unsigned type, ArrayBufferView* pixels, ExceptionCode&); 233 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, 234 unsigned format, unsigned type, ImageData* pixels, ExceptionCode&); 235 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, 236 unsigned format, unsigned type, HTMLImageElement* image, ExceptionCode&); 237 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, 238 unsigned format, unsigned type, HTMLCanvasElement* canvas, ExceptionCode&); 239 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, 240 unsigned format, unsigned type, HTMLVideoElement* video, ExceptionCode&); 241 // Obsolete entry points -- to be removed shortly. (FIXME) 242 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, ImageData* pixels, ExceptionCode&); 243 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, ImageData* pixels, bool flipY, ExceptionCode&); 244 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, ImageData* pixels, bool flipY, bool premultiplyAlpha, ExceptionCode&); 245 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, HTMLImageElement* image, ExceptionCode&); 246 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, HTMLImageElement* image, bool flipY, ExceptionCode&); 247 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, HTMLImageElement* image, bool flipY, bool premultiplyAlpha, ExceptionCode&); 248 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, HTMLCanvasElement* canvas, ExceptionCode&); 249 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, HTMLCanvasElement* canvas, bool flipY, ExceptionCode&); 250 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, HTMLCanvasElement* canvas, bool flipY, bool premultiplyAlpha, ExceptionCode&); 251 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, HTMLVideoElement* video, ExceptionCode&); 252 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, HTMLVideoElement* video, bool flipY, ExceptionCode&); 253 void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, HTMLVideoElement* video, bool flipY, bool premultiplyAlpha, ExceptionCode&); 254 255 void uniform1f(const WebGLUniformLocation* location, float x, ExceptionCode&); 256 void uniform1fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode&); 257 void uniform1fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode&); 258 void uniform1i(const WebGLUniformLocation* location, int x, ExceptionCode&); 259 void uniform1iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode&); 260 void uniform1iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode&); 261 void uniform2f(const WebGLUniformLocation* location, float x, float y, ExceptionCode&); 262 void uniform2fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode&); 263 void uniform2fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode&); 264 void uniform2i(const WebGLUniformLocation* location, int x, int y, ExceptionCode&); 265 void uniform2iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode&); 266 void uniform2iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode&); 267 void uniform3f(const WebGLUniformLocation* location, float x, float y, float z, ExceptionCode&); 268 void uniform3fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode&); 269 void uniform3fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode&); 270 void uniform3i(const WebGLUniformLocation* location, int x, int y, int z, ExceptionCode&); 271 void uniform3iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode&); 272 void uniform3iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode&); 273 void uniform4f(const WebGLUniformLocation* location, float x, float y, float z, float w, ExceptionCode&); 274 void uniform4fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode&); 275 void uniform4fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode&); 276 void uniform4i(const WebGLUniformLocation* location, int x, int y, int z, int w, ExceptionCode&); 277 void uniform4iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode&); 278 void uniform4iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode&); 279 void uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, Float32Array* value, ExceptionCode&); 280 void uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, float* value, int size, ExceptionCode&); 281 void uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, Float32Array* value, ExceptionCode&); 282 void uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, float* value, int size, ExceptionCode&); 283 void uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, Float32Array* value, ExceptionCode&); 284 void uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, float* value, int size, ExceptionCode&); 285 286 void useProgram(WebGLProgram*, ExceptionCode&); 287 void validateProgram(WebGLProgram*, ExceptionCode&); 288 289 void vertexAttrib1f(unsigned long index, float x); 290 void vertexAttrib1fv(unsigned long index, Float32Array* values); 291 void vertexAttrib1fv(unsigned long index, float* values, int size); 292 void vertexAttrib2f(unsigned long index, float x, float y); 293 void vertexAttrib2fv(unsigned long index, Float32Array* values); 294 void vertexAttrib2fv(unsigned long index, float* values, int size); 295 void vertexAttrib3f(unsigned long index, float x, float y, float z); 296 void vertexAttrib3fv(unsigned long index, Float32Array* values); 297 void vertexAttrib3fv(unsigned long index, float* values, int size); 298 void vertexAttrib4f(unsigned long index, float x, float y, float z, float w); 299 void vertexAttrib4fv(unsigned long index, Float32Array* values); 300 void vertexAttrib4fv(unsigned long index, float* values, int size); 301 void vertexAttribPointer(unsigned long index, long size, unsigned long type, bool normalized, 302 long stride, long offset, ExceptionCode&); 303 304 void viewport(long x, long y, unsigned long width, unsigned long height); 305 306 virtual GraphicsContext3D* graphicsContext3D() const { return m_context.get(); } 307 308 void reshape(int width, int height); 309 310 // Return value true indicates canvas is updated during the call, 311 // false indicates no updates. 312 bool paintRenderingResultsToCanvas(); 313 314 // Helpers for notification about paint events. 315 void beginPaint(); 316 void endPaint(); 317 318 void removeObject(WebGLObject*); 319 320 private: 321 friend class WebGLObject; 322 323 WebGLRenderingContext(HTMLCanvasElement*, PassOwnPtr<GraphicsContext3D>); 324 325 void addObject(WebGLObject*); 326 void detachAndRemoveAllObjects(); 327 WebGLTexture* findTexture(Platform3DObject); 328 WebGLRenderbuffer* findRenderbuffer(Platform3DObject); 329 WebGLBuffer* findBuffer(Platform3DObject); 330 WebGLShader* findShader(Platform3DObject); 331 332 void markContextChanged(); 333 void cleanupAfterGraphicsCall(bool changed) 334 { 335 if (changed) 336 markContextChanged(); 337 } 338 339 bool isGLES2Compliant(); 340 341 // Basic validation of count and offset against number of elements in element array buffer 342 bool validateElementArraySize(unsigned long count, unsigned long type, long offset); 343 344 // Conservative but quick index validation 345 bool validateIndexArrayConservative(unsigned long type, long& numElementsRequired); 346 347 // Precise but slow index validation -- only done if conservative checks fail 348 bool validateIndexArrayPrecise(unsigned long count, unsigned long type, long offset, long& numElementsRequired); 349 bool validateRenderingState(long numElements); 350 351 bool validateWebGLObject(WebGLObject* object); 352 353 OwnPtr<GraphicsContext3D> m_context; 354 bool m_needsUpdate; 355 bool m_markedCanvasDirty; 356 // FIXME: I think this is broken -- it does not increment any 357 // reference counts, so may refer to destroyed objects. 358 HashSet<RefPtr<WebGLObject> > m_canvasObjects; 359 360 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER and stored values for ELEMENT_ARRAY_BUFFER 361 RefPtr<WebGLBuffer> m_boundArrayBuffer; 362 RefPtr<WebGLBuffer> m_boundElementArrayBuffer; 363 364 // Cached values for vertex attrib range checks 365 class VertexAttribState { 366 public: 367 VertexAttribState() 368 : enabled(false) 369 , bytesPerElement(0) 370 , size(4) 371 , type(GraphicsContext3D::FLOAT) 372 , normalized(false) 373 , stride(16) 374 , originalStride(0) 375 , offset(0) 376 { 377 initValue(); 378 } 379 380 void initValue() 381 { 382 value[0] = 0.0f; 383 value[1] = 0.0f; 384 value[2] = 0.0f; 385 value[3] = 1.0f; 386 } 387 388 bool enabled; 389 RefPtr<WebGLBuffer> bufferBinding; 390 long bytesPerElement; 391 long size; 392 unsigned long type; 393 bool normalized; 394 long stride; 395 long originalStride; 396 long offset; 397 float value[4]; 398 }; 399 400 Vector<VertexAttribState> m_vertexAttribState; 401 unsigned m_maxVertexAttribs; 402 RefPtr<WebGLBuffer> m_vertexAttrib0Buffer; 403 long m_vertexAttrib0BufferSize; 404 float m_vertexAttrib0BufferValue[4]; 405 406 RefPtr<WebGLProgram> m_currentProgram; 407 RefPtr<WebGLFramebuffer> m_framebufferBinding; 408 RefPtr<WebGLRenderbuffer> m_renderbufferBinding; 409 class TextureUnitState { 410 public: 411 RefPtr<WebGLTexture> m_texture2DBinding; 412 RefPtr<WebGLTexture> m_textureCubeMapBinding; 413 }; 414 Vector<TextureUnitState> m_textureUnits; 415 unsigned long m_activeTextureUnit; 416 417 RefPtr<WebGLTexture> m_blackTexture2D; 418 RefPtr<WebGLTexture> m_blackTextureCubeMap; 419 420 int m_maxTextureSize; 421 int m_maxCubeMapTextureSize; 422 int m_maxTextureLevel; 423 int m_maxCubeMapTextureLevel; 424 425 int m_packAlignment; 426 int m_unpackAlignment; 427 unsigned long m_implementationColorReadFormat; 428 unsigned long m_implementationColorReadType; 429 bool m_unpackFlipY; 430 bool m_unpackPremultiplyAlpha; 431 432 // Helpers for getParameter and others 433 WebGLGetInfo getBooleanParameter(unsigned long pname); 434 WebGLGetInfo getBooleanArrayParameter(unsigned long pname); 435 WebGLGetInfo getFloatParameter(unsigned long pname); 436 WebGLGetInfo getIntParameter(unsigned long pname); 437 WebGLGetInfo getLongParameter(unsigned long pname); 438 WebGLGetInfo getUnsignedLongParameter(unsigned long pname); 439 WebGLGetInfo getWebGLFloatArrayParameter(unsigned long pname); 440 WebGLGetInfo getWebGLIntArrayParameter(unsigned long pname); 441 442 void texImage2DBase(unsigned target, unsigned level, unsigned internalformat, 443 unsigned width, unsigned height, unsigned border, 444 unsigned format, unsigned type, void* pixels, ExceptionCode&); 445 void texImage2DImpl(unsigned target, unsigned level, unsigned internalformat, 446 unsigned format, unsigned type, Image* image, 447 bool flipY, bool premultiplyAlpha, ExceptionCode&); 448 void texSubImage2DBase(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, 449 unsigned width, unsigned height, 450 unsigned format, unsigned type, void* pixels, ExceptionCode&); 451 void texSubImage2DImpl(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, 452 unsigned format, unsigned type, 453 Image* image, bool flipY, bool premultiplyAlpha, ExceptionCode&); 454 455 void handleNPOTTextures(bool prepareToDraw); 456 457 void createFallbackBlackTextures1x1(); 458 459 // Helper function for copyTex{Sub}Image, check whether the internalformat 460 // and the color buffer format of the current bound framebuffer combination 461 // is valid. 462 bool isTexInternalFormatColorBufferCombinationValid(unsigned long texInternalFormat, 463 unsigned long colorBufferFormat); 464 465 // Helper function to get the current bound texture. 466 WebGLTexture* getTextureBinding(unsigned long target); 467 468 // Helper function to check input format/type for functions {copy}Tex{Sub}Image. 469 // Generates GL error and returns false if parameters are invalid. 470 bool validateTexFuncFormatAndType(unsigned long format, unsigned long type); 471 472 // Helper function to check input parameters for functions {copy}Tex{Sub}Image. 473 // Generates GL error and returns false if parameters are invalid. 474 bool validateTexFuncParameters(unsigned long target, long level, 475 unsigned long internalformat, 476 long width, long height, long border, 477 unsigned long format, unsigned long type); 478 479 // Helper function to validate that the given ArrayBufferView 480 // is of the correct type and contains enough data for the texImage call. 481 // Generates GL error and returns false if parameters are invalid. 482 bool validateTexFuncData(long width, long height, 483 unsigned long format, unsigned long type, 484 ArrayBufferView* pixels); 485 486 // Helper function to validate mode for draw{Arrays/Elements}. 487 bool validateDrawMode(unsigned long); 488 489 // Helper function for texParameterf and texParameteri. 490 void texParameter(unsigned long target, unsigned long pname, float parami, int paramf, bool isFloat); 491 492 // Helper function to print warnings to console. Currently 493 // used only to warn about use of obsolete functions. 494 void printWarningToConsole(const String& message); 495 496 // Helper function to validate input parameters for framebuffer functions. 497 // Generate GL error if parameters are illegal. 498 bool validateFramebufferFuncParameters(unsigned long target, unsigned long attachment); 499 500 // Helper function to validate blend equation mode. 501 bool validateBlendEquation(unsigned long); 502 503 // Helper function to validate a GL capability. 504 bool validateCapability(unsigned long); 505 506 // Helper function to validate input parameters for uniform functions. 507 bool validateUniformParameters(const WebGLUniformLocation* location, Float32Array* v, int mod); 508 bool validateUniformParameters(const WebGLUniformLocation* location, Int32Array* v, int mod); 509 bool validateUniformParameters(const WebGLUniformLocation* location, void* v, int size, int mod); 510 bool validateUniformMatrixParameters(const WebGLUniformLocation* location, bool transpose, Float32Array* v, int mod); 511 bool validateUniformMatrixParameters(const WebGLUniformLocation* location, bool transpose, void* v, int size, int mod); 512 513 // Helper function to validate parameters for bufferData. 514 // Return the current bound buffer to target, or 0 if parameters are invalid. 515 WebGLBuffer* validateBufferDataParameters(unsigned long target, unsigned long usage); 516 517 // Helper functions for vertexAttribNf{v}. 518 void vertexAttribfImpl(unsigned long index, int expectedSize, float v0, float v1, float v2, float v3); 519 void vertexAttribfvImpl(unsigned long index, Float32Array* v, int expectedSize); 520 void vertexAttribfvImpl(unsigned long index, float* v, int size, int expectedSize); 521 522 // Helpers for simulating vertexAttrib0 523 void initVertexAttrib0(); 524 bool simulateVertexAttrib0(long numVertex); 525 void restoreStatesAfterVertexAttrib0Simulation(); 526 527 friend class WebGLStateRestorer; 528 }; 450 unsigned format, unsigned type, void* pixels, ExceptionCode&); 451 void texSubImage2DImpl(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, 452 unsigned format, unsigned type, 453 Image* image, bool flipY, bool premultiplyAlpha, ExceptionCode&); 454 455 void handleNPOTTextures(bool prepareToDraw); 456 457 void createFallbackBlackTextures1x1(); 458 459 // Helper function for copyTex{Sub}Image, check whether the internalformat 460 // and the color buffer format of the current bound framebuffer combination 461 // is valid. 462 bool isTexInternalFormatColorBufferCombinationValid(unsigned long texInternalFormat, 463 unsigned long colorBufferFormat); 464 465 // Helper function to get the current bound texture. 466 WebGLTexture* getTextureBinding(unsigned long target); 467 468 // Helper function to check input format/type for functions {copy}Tex{Sub}Image. 469 // Generates GL error and returns false if parameters are invalid. 470 bool validateTexFuncFormatAndType(unsigned long format, unsigned long type); 471 472 // Helper function to check input parameters for functions {copy}Tex{Sub}Image. 473 // Generates GL error and returns false if parameters are invalid. 474 bool validateTexFuncParameters(unsigned long target, long level, 475 unsigned long internalformat, 476 long width, long height, long border, 477 unsigned long format, unsigned long type); 478 479 // Helper function to validate that the given ArrayBufferView 480 // is of the correct type and contains enough data for the texImage call. 481 // Generates GL error and returns false if parameters are invalid. 482 bool validateTexFuncData(long width, long height, 483 unsigned long format, unsigned long type, 484 ArrayBufferView* pixels); 485 486 // Helper function to validate mode for draw{Arrays/Elements}. 487 bool validateDrawMode(unsigned long); 488 489 // Helper function for texParameterf and texParameteri. 490 void texParameter(unsigned long target, unsigned long pname, float parami, int paramf, bool isFloat); 491 492 // Helper function to print warnings to console. Currently 493 // used only to warn about use of obsolete functions. 494 void printWarningToConsole(const String& message); 495 496 // Helper function to validate input parameters for framebuffer functions. 497 // Generate GL error if parameters are illegal. 498 bool validateFramebufferFuncParameters(unsigned long target, unsigned long attachment); 499 500 // Helper function to validate blend equation mode. 501 bool validateBlendEquation(unsigned long); 502 503 // Helper function to validate a GL capability. 504 bool validateCapability(unsigned long); 505 506 // Helper function to validate input parameters for uniform functions. 507 bool validateUniformParameters(const WebGLUniformLocation* location, Float32Array* v, int mod); 508 bool validateUniformParameters(const WebGLUniformLocation* location, Int32Array* v, int mod); 509 bool validateUniformParameters(const WebGLUniformLocation* location, void* v, int size, int mod); 510 bool validateUniformMatrixParameters(const WebGLUniformLocation* location, bool transpose, Float32Array* v, int mod); 511 bool validateUniformMatrixParameters(const WebGLUniformLocation* location, bool transpose, void* v, int size, int mod); 512 513 // Helper function to validate parameters for bufferData. 514 // Return the current bound buffer to target, or 0 if parameters are invalid. 515 WebGLBuffer* validateBufferDataParameters(unsigned long target, unsigned long usage); 516 517 // Helper functions for vertexAttribNf{v}. 518 void vertexAttribfImpl(unsigned long index, int expectedSize, float v0, float v1, float v2, float v3); 519 void vertexAttribfvImpl(unsigned long index, Float32Array* v, int expectedSize); 520 void vertexAttribfvImpl(unsigned long index, float* v, int size, int expectedSize); 521 522 // Helpers for simulating vertexAttrib0 523 void initVertexAttrib0(); 524 bool simulateVertexAttrib0(long numVertex); 525 void restoreStatesAfterVertexAttrib0Simulation(); 526 527 friend class WebGLStateRestorer; 528 }; 529 529 530 530 } // namespace WebCore -
trunk/WebCore/html/canvas/WebGLShader.cpp
r64685 r64767 29 29 30 30 #include "WebGLShader.h" 31 31 32 #include "WebGLRenderingContext.h" 32 33 … … 45 46 } 46 47 47 void WebGLShader:: _deleteObject(Platform3DObject object)48 void WebGLShader::deleteObjectImpl(Platform3DObject object) 48 49 { 49 50 context()->graphicsContext3D()->deleteShader(object); -
trunk/WebCore/html/canvas/WebGLShader.h
r64685 r64767 33 33 34 34 namespace WebCore { 35 36 class WebGLShader : public WebGLObject {37 public:38 virtual ~WebGLShader() { deleteObject(); }39 40 static PassRefPtr<WebGLShader> create(WebGLRenderingContext*, GraphicsContext3D::WebGLEnumType);41 35 42 GraphicsContext3D::WebGLEnumType getType() const { return m_type; } 36 class WebGLShader : public WebGLObject { 37 public: 38 virtual ~WebGLShader() { deleteObject(); } 43 39 44 private: 45 WebGLShader(WebGLRenderingContext*, GraphicsContext3D::WebGLEnumType); 40 static PassRefPtr<WebGLShader> create(WebGLRenderingContext*, GraphicsContext3D::WebGLEnumType); 46 41 47 virtual void _deleteObject(Platform3DObject);42 GraphicsContext3D::WebGLEnumType getType() const { return m_type; } 48 43 49 virtual bool isShader() const { return true; } 44 private: 45 WebGLShader(WebGLRenderingContext*, GraphicsContext3D::WebGLEnumType); 50 46 51 GraphicsContext3D::WebGLEnumType m_type; 52 }; 53 47 virtual void deleteObjectImpl(Platform3DObject); 48 49 virtual bool isShader() const { return true; } 50 51 GraphicsContext3D::WebGLEnumType m_type; 52 }; 53 54 54 } // namespace WebCore 55 55 -
trunk/WebCore/html/canvas/WebGLTexture.cpp
r64685 r64767 29 29 30 30 #include "WebGLTexture.h" 31 31 32 #include "WebGLRenderingContext.h" 32 33 … … 198 199 } 199 200 200 void WebGLTexture:: _deleteObject(Platform3DObject object)201 void WebGLTexture::deleteObjectImpl(Platform3DObject object) 201 202 { 202 203 context()->graphicsContext3D()->deleteTexture(object); -
trunk/WebCore/html/canvas/WebGLTexture.h
r64685 r64767 34 34 35 35 namespace WebCore { 36 37 class WebGLTexture : public WebGLObject { 36 37 class WebGLTexture : public WebGLObject { 38 public: 39 virtual ~WebGLTexture() { deleteObject(); } 40 41 static PassRefPtr<WebGLTexture> create(WebGLRenderingContext*); 42 43 bool isCubeMapRWrapModeInitialized() 44 { 45 return cubeMapRWrapModeInitialized; 46 } 47 48 void setCubeMapRWrapModeInitialized(bool initialized) 49 { 50 cubeMapRWrapModeInitialized = initialized; 51 } 52 53 void setTarget(unsigned long target, int maxLevel); 54 void setParameteri(unsigned long pname, int param); 55 void setParameterf(unsigned long pname, float param); 56 57 void setLevelInfo(unsigned long target, int level, unsigned long internalFormat, int width, int height, unsigned long type); 58 59 bool canGenerateMipmaps(); 60 // Generate all level information. 61 void generateMipmapLevelInfo(); 62 63 unsigned long getInternalFormat() const; 64 65 // Whether width/height is NotPowerOfTwo. 66 static bool isNPOT(unsigned, unsigned); 67 68 bool isNPOT() const; 69 // Determine if texture sampling should always return [0, 0, 0, 1] (OpenGL ES 2.0 Sec 3.8.2). 70 bool needToUseBlackTexture() const; 71 72 static int computeLevelCount(int width, int height); 73 74 protected: 75 WebGLTexture(WebGLRenderingContext*); 76 77 virtual void deleteObjectImpl(Platform3DObject); 78 79 private: 80 virtual bool isTexture() const { return true; } 81 82 void update(); 83 84 int mapTargetToIndex(unsigned long); 85 86 bool cubeMapRWrapModeInitialized; 87 88 unsigned long m_target; 89 90 int m_minFilter; 91 int m_magFilter; 92 int m_wrapS; 93 int m_wrapT; 94 95 class LevelInfo { 38 96 public: 39 virtual ~WebGLTexture() { deleteObject(); } 40 41 static PassRefPtr<WebGLTexture> create(WebGLRenderingContext*); 42 43 bool isCubeMapRWrapModeInitialized() { 44 return cubeMapRWrapModeInitialized; 97 LevelInfo() 98 : valid(false) 99 , internalFormat(0) 100 , width(0) 101 , height(0) 102 , type(0) 103 { 45 104 } 46 105 47 void setCubeMapRWrapModeInitialized(bool initialized) { 48 cubeMapRWrapModeInitialized = initialized; 106 void setInfo(unsigned long internalFmt, int w, int h, unsigned long tp) 107 { 108 valid = true; 109 internalFormat = internalFmt; 110 width = w; 111 height = h; 112 type = tp; 49 113 } 50 114 51 void setTarget(unsigned long target, int maxLevel); 52 void setParameteri(unsigned long pname, int param); 53 void setParameterf(unsigned long pname, float param); 115 bool valid; 116 unsigned long internalFormat; 117 int width; 118 int height; 119 unsigned long type; 120 }; 54 121 55 void setLevelInfo(unsigned long target, int level, unsigned long internalFormat, int width, int height, unsigned long type);122 Vector<Vector<LevelInfo> > m_info; 56 123 57 bool canGenerateMipmaps(); 58 // Generate all level information. 59 void generateMipmapLevelInfo(); 124 bool m_isNPOT; 125 bool m_isComplete; 126 bool m_needToUseBlackTexture; 127 }; 60 128 61 unsigned long getInternalFormat() const;62 63 // Whether width/height is NotPowerOfTwo.64 static bool isNPOT(unsigned, unsigned);65 66 bool isNPOT() const;67 // Determine if texture sampling should always return [0, 0, 0, 1] (OpenGL ES 2.0 Sec 3.8.2).68 bool needToUseBlackTexture() const;69 70 static int computeLevelCount(int width, int height);71 72 protected:73 WebGLTexture(WebGLRenderingContext*);74 75 virtual void _deleteObject(Platform3DObject);76 77 private:78 virtual bool isTexture() const { return true; }79 80 void update();81 82 int mapTargetToIndex(unsigned long);83 84 bool cubeMapRWrapModeInitialized;85 86 unsigned long m_target;87 88 int m_minFilter;89 int m_magFilter;90 int m_wrapS;91 int m_wrapT;92 93 class LevelInfo {94 public:95 LevelInfo()96 : valid(false)97 , internalFormat(0)98 , width(0)99 , height(0)100 , type(0)101 {102 }103 104 void setInfo(unsigned long internalFmt, int w, int h, unsigned long tp)105 {106 valid = true;107 internalFormat = internalFmt;108 width = w;109 height = h;110 type = tp;111 }112 113 bool valid;114 unsigned long internalFormat;115 int width;116 int height;117 unsigned long type;118 };119 120 Vector<Vector<LevelInfo> > m_info;121 122 bool m_isNPOT;123 bool m_isComplete;124 bool m_needToUseBlackTexture;125 };126 127 129 } // namespace WebCore 128 130 -
trunk/WebCore/platform/graphics/GraphicsContext3D.h
r64582 r64767 44 44 45 45 typedef CGLContextObj PlatformGraphicsContext3D; 46 const 46 const PlatformGraphicsContext3D NullPlatformGraphicsContext3D = 0; 47 47 typedef GLuint Platform3DObject; 48 48 const Platform3DObject NullPlatform3DObject = 0; … … 59 59 class QRect; 60 60 typedef void* PlatformGraphicsContext3D; 61 const 61 const PlatformGraphicsContext3D NullPlatformGraphicsContext3D = 0; 62 62 typedef int Platform3DObject; 63 63 const Platform3DObject NullPlatform3DObject = 0; 64 64 #else 65 65 typedef void* PlatformGraphicsContext3D; 66 const 66 const PlatformGraphicsContext3D NullPlatformGraphicsContext3D = 0; 67 67 typedef int Platform3DObject; 68 68 const Platform3DObject NullPlatform3DObject = 0; … … 74 74 75 75 namespace WebCore { 76 class ArrayBuffer; 77 class ArrayBufferView; 78 class CanvasRenderingContext; 79 class Float32Array; 80 class HostWindow; 81 class Image; 82 class ImageData; 83 class Int32Array; 84 class Uint8Array; 85 class WebGLActiveInfo; 86 87 struct ActiveInfo { 88 String name; 89 unsigned type; 90 int size; 76 class ArrayBuffer; 77 class ArrayBufferView; 78 class CanvasRenderingContext; 79 class Float32Array; 80 class HostWindow; 81 class Image; 82 class ImageData; 83 class Int32Array; 84 class Uint8Array; 85 class WebGLActiveInfo; 86 87 struct ActiveInfo { 88 String name; 89 unsigned type; 90 int size; 91 }; 92 93 // FIXME: ideally this would be used on all platforms. 94 #if PLATFORM(CHROMIUM) || PLATFORM(QT) 95 class GraphicsContext3DInternal; 96 #endif 97 98 class GraphicsContext3D : public Noncopyable { 99 public: 100 enum WebGLEnumType { 101 DEPTH_BUFFER_BIT = 0x00000100, 102 STENCIL_BUFFER_BIT = 0x00000400, 103 COLOR_BUFFER_BIT = 0x00004000, 104 POINTS = 0x0000, 105 LINES = 0x0001, 106 LINE_LOOP = 0x0002, 107 LINE_STRIP = 0x0003, 108 TRIANGLES = 0x0004, 109 TRIANGLE_STRIP = 0x0005, 110 TRIANGLE_FAN = 0x0006, 111 ZERO = 0, 112 ONE = 1, 113 SRC_COLOR = 0x0300, 114 ONE_MINUS_SRC_COLOR = 0x0301, 115 SRC_ALPHA = 0x0302, 116 ONE_MINUS_SRC_ALPHA = 0x0303, 117 DST_ALPHA = 0x0304, 118 ONE_MINUS_DST_ALPHA = 0x0305, 119 DST_COLOR = 0x0306, 120 ONE_MINUS_DST_COLOR = 0x0307, 121 SRC_ALPHA_SATURATE = 0x0308, 122 FUNC_ADD = 0x8006, 123 BLEND_EQUATION = 0x8009, 124 BLEND_EQUATION_RGB = 0x8009, 125 BLEND_EQUATION_ALPHA = 0x883D, 126 FUNC_SUBTRACT = 0x800A, 127 FUNC_REVERSE_SUBTRACT = 0x800B, 128 BLEND_DST_RGB = 0x80C8, 129 BLEND_SRC_RGB = 0x80C9, 130 BLEND_DST_ALPHA = 0x80CA, 131 BLEND_SRC_ALPHA = 0x80CB, 132 CONSTANT_COLOR = 0x8001, 133 ONE_MINUS_CONSTANT_COLOR = 0x8002, 134 CONSTANT_ALPHA = 0x8003, 135 ONE_MINUS_CONSTANT_ALPHA = 0x8004, 136 BLEND_COLOR = 0x8005, 137 ARRAY_BUFFER = 0x8892, 138 ELEMENT_ARRAY_BUFFER = 0x8893, 139 ARRAY_BUFFER_BINDING = 0x8894, 140 ELEMENT_ARRAY_BUFFER_BINDING = 0x8895, 141 STREAM_DRAW = 0x88E0, 142 STATIC_DRAW = 0x88E4, 143 DYNAMIC_DRAW = 0x88E8, 144 BUFFER_SIZE = 0x8764, 145 BUFFER_USAGE = 0x8765, 146 CURRENT_VERTEX_ATTRIB = 0x8626, 147 FRONT = 0x0404, 148 BACK = 0x0405, 149 FRONT_AND_BACK = 0x0408, 150 TEXTURE_2D = 0x0DE1, 151 CULL_FACE = 0x0B44, 152 BLEND = 0x0BE2, 153 DITHER = 0x0BD0, 154 STENCIL_TEST = 0x0B90, 155 DEPTH_TEST = 0x0B71, 156 SCISSOR_TEST = 0x0C11, 157 POLYGON_OFFSET_FILL = 0x8037, 158 SAMPLE_ALPHA_TO_COVERAGE = 0x809E, 159 SAMPLE_COVERAGE = 0x80A0, 160 NO_ERROR = 0, 161 INVALID_ENUM = 0x0500, 162 INVALID_VALUE = 0x0501, 163 INVALID_OPERATION = 0x0502, 164 OUT_OF_MEMORY = 0x0505, 165 CW = 0x0900, 166 CCW = 0x0901, 167 LINE_WIDTH = 0x0B21, 168 ALIASED_POINT_SIZE_RANGE = 0x846D, 169 ALIASED_LINE_WIDTH_RANGE = 0x846E, 170 CULL_FACE_MODE = 0x0B45, 171 FRONT_FACE = 0x0B46, 172 DEPTH_RANGE = 0x0B70, 173 DEPTH_WRITEMASK = 0x0B72, 174 DEPTH_CLEAR_VALUE = 0x0B73, 175 DEPTH_FUNC = 0x0B74, 176 STENCIL_CLEAR_VALUE = 0x0B91, 177 STENCIL_FUNC = 0x0B92, 178 STENCIL_FAIL = 0x0B94, 179 STENCIL_PASS_DEPTH_FAIL = 0x0B95, 180 STENCIL_PASS_DEPTH_PASS = 0x0B96, 181 STENCIL_REF = 0x0B97, 182 STENCIL_VALUE_MASK = 0x0B93, 183 STENCIL_WRITEMASK = 0x0B98, 184 STENCIL_BACK_FUNC = 0x8800, 185 STENCIL_BACK_FAIL = 0x8801, 186 STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802, 187 STENCIL_BACK_PASS_DEPTH_PASS = 0x8803, 188 STENCIL_BACK_REF = 0x8CA3, 189 STENCIL_BACK_VALUE_MASK = 0x8CA4, 190 STENCIL_BACK_WRITEMASK = 0x8CA5, 191 VIEWPORT = 0x0BA2, 192 SCISSOR_BOX = 0x0C10, 193 COLOR_CLEAR_VALUE = 0x0C22, 194 COLOR_WRITEMASK = 0x0C23, 195 UNPACK_ALIGNMENT = 0x0CF5, 196 PACK_ALIGNMENT = 0x0D05, 197 MAX_TEXTURE_SIZE = 0x0D33, 198 MAX_VIEWPORT_DIMS = 0x0D3A, 199 SUBPIXEL_BITS = 0x0D50, 200 RED_BITS = 0x0D52, 201 GREEN_BITS = 0x0D53, 202 BLUE_BITS = 0x0D54, 203 ALPHA_BITS = 0x0D55, 204 DEPTH_BITS = 0x0D56, 205 STENCIL_BITS = 0x0D57, 206 POLYGON_OFFSET_UNITS = 0x2A00, 207 POLYGON_OFFSET_FACTOR = 0x8038, 208 TEXTURE_BINDING_2D = 0x8069, 209 SAMPLE_BUFFERS = 0x80A8, 210 SAMPLES = 0x80A9, 211 SAMPLE_COVERAGE_VALUE = 0x80AA, 212 SAMPLE_COVERAGE_INVERT = 0x80AB, 213 NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2, 214 COMPRESSED_TEXTURE_FORMATS = 0x86A3, 215 DONT_CARE = 0x1100, 216 FASTEST = 0x1101, 217 NICEST = 0x1102, 218 GENERATE_MIPMAP_HINT = 0x8192, 219 BYTE = 0x1400, 220 UNSIGNED_BYTE = 0x1401, 221 SHORT = 0x1402, 222 UNSIGNED_SHORT = 0x1403, 223 INT = 0x1404, 224 UNSIGNED_INT = 0x1405, 225 FLOAT = 0x1406, 226 FIXED = 0x140C, 227 DEPTH_COMPONENT = 0x1902, 228 ALPHA = 0x1906, 229 RGB = 0x1907, 230 RGBA = 0x1908, 231 LUMINANCE = 0x1909, 232 LUMINANCE_ALPHA = 0x190A, 233 UNSIGNED_SHORT_4_4_4_4 = 0x8033, 234 UNSIGNED_SHORT_5_5_5_1 = 0x8034, 235 UNSIGNED_SHORT_5_6_5 = 0x8363, 236 FRAGMENT_SHADER = 0x8B30, 237 VERTEX_SHADER = 0x8B31, 238 MAX_VERTEX_ATTRIBS = 0x8869, 239 MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB, 240 MAX_VARYING_VECTORS = 0x8DFC, 241 MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D, 242 MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C, 243 MAX_TEXTURE_IMAGE_UNITS = 0x8872, 244 MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD, 245 SHADER_TYPE = 0x8B4F, 246 DELETE_STATUS = 0x8B80, 247 LINK_STATUS = 0x8B82, 248 VALIDATE_STATUS = 0x8B83, 249 ATTACHED_SHADERS = 0x8B85, 250 ACTIVE_UNIFORMS = 0x8B86, 251 ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87, 252 ACTIVE_ATTRIBUTES = 0x8B89, 253 ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A, 254 SHADING_LANGUAGE_VERSION = 0x8B8C, 255 CURRENT_PROGRAM = 0x8B8D, 256 NEVER = 0x0200, 257 LESS = 0x0201, 258 EQUAL = 0x0202, 259 LEQUAL = 0x0203, 260 GREATER = 0x0204, 261 NOTEQUAL = 0x0205, 262 GEQUAL = 0x0206, 263 ALWAYS = 0x0207, 264 KEEP = 0x1E00, 265 REPLACE = 0x1E01, 266 INCR = 0x1E02, 267 DECR = 0x1E03, 268 INVERT = 0x150A, 269 INCR_WRAP = 0x8507, 270 DECR_WRAP = 0x8508, 271 VENDOR = 0x1F00, 272 RENDERER = 0x1F01, 273 VERSION = 0x1F02, 274 EXTENSIONS = 0x1F03, 275 NEAREST = 0x2600, 276 LINEAR = 0x2601, 277 NEAREST_MIPMAP_NEAREST = 0x2700, 278 LINEAR_MIPMAP_NEAREST = 0x2701, 279 NEAREST_MIPMAP_LINEAR = 0x2702, 280 LINEAR_MIPMAP_LINEAR = 0x2703, 281 TEXTURE_MAG_FILTER = 0x2800, 282 TEXTURE_MIN_FILTER = 0x2801, 283 TEXTURE_WRAP_S = 0x2802, 284 TEXTURE_WRAP_T = 0x2803, 285 TEXTURE = 0x1702, 286 TEXTURE_CUBE_MAP = 0x8513, 287 TEXTURE_BINDING_CUBE_MAP = 0x8514, 288 TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515, 289 TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516, 290 TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517, 291 TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518, 292 TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519, 293 TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A, 294 MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C, 295 TEXTURE0 = 0x84C0, 296 TEXTURE1 = 0x84C1, 297 TEXTURE2 = 0x84C2, 298 TEXTURE3 = 0x84C3, 299 TEXTURE4 = 0x84C4, 300 TEXTURE5 = 0x84C5, 301 TEXTURE6 = 0x84C6, 302 TEXTURE7 = 0x84C7, 303 TEXTURE8 = 0x84C8, 304 TEXTURE9 = 0x84C9, 305 TEXTURE10 = 0x84CA, 306 TEXTURE11 = 0x84CB, 307 TEXTURE12 = 0x84CC, 308 TEXTURE13 = 0x84CD, 309 TEXTURE14 = 0x84CE, 310 TEXTURE15 = 0x84CF, 311 TEXTURE16 = 0x84D0, 312 TEXTURE17 = 0x84D1, 313 TEXTURE18 = 0x84D2, 314 TEXTURE19 = 0x84D3, 315 TEXTURE20 = 0x84D4, 316 TEXTURE21 = 0x84D5, 317 TEXTURE22 = 0x84D6, 318 TEXTURE23 = 0x84D7, 319 TEXTURE24 = 0x84D8, 320 TEXTURE25 = 0x84D9, 321 TEXTURE26 = 0x84DA, 322 TEXTURE27 = 0x84DB, 323 TEXTURE28 = 0x84DC, 324 TEXTURE29 = 0x84DD, 325 TEXTURE30 = 0x84DE, 326 TEXTURE31 = 0x84DF, 327 ACTIVE_TEXTURE = 0x84E0, 328 REPEAT = 0x2901, 329 CLAMP_TO_EDGE = 0x812F, 330 MIRRORED_REPEAT = 0x8370, 331 FLOAT_VEC2 = 0x8B50, 332 FLOAT_VEC3 = 0x8B51, 333 FLOAT_VEC4 = 0x8B52, 334 INT_VEC2 = 0x8B53, 335 INT_VEC3 = 0x8B54, 336 INT_VEC4 = 0x8B55, 337 BOOL = 0x8B56, 338 BOOL_VEC2 = 0x8B57, 339 BOOL_VEC3 = 0x8B58, 340 BOOL_VEC4 = 0x8B59, 341 FLOAT_MAT2 = 0x8B5A, 342 FLOAT_MAT3 = 0x8B5B, 343 FLOAT_MAT4 = 0x8B5C, 344 SAMPLER_2D = 0x8B5E, 345 SAMPLER_CUBE = 0x8B60, 346 VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622, 347 VERTEX_ATTRIB_ARRAY_SIZE = 0x8623, 348 VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624, 349 VERTEX_ATTRIB_ARRAY_TYPE = 0x8625, 350 VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A, 351 VERTEX_ATTRIB_ARRAY_POINTER = 0x8645, 352 VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F, 353 IMPLEMENTATION_COLOR_READ_TYPE = 0x8B9A, 354 IMPLEMENTATION_COLOR_READ_FORMAT = 0x8B9B, 355 COMPILE_STATUS = 0x8B81, 356 INFO_LOG_LENGTH = 0x8B84, 357 SHADER_SOURCE_LENGTH = 0x8B88, 358 SHADER_COMPILER = 0x8DFA, 359 SHADER_BINARY_FORMATS = 0x8DF8, 360 NUM_SHADER_BINARY_FORMATS = 0x8DF9, 361 LOW_FLOAT = 0x8DF0, 362 MEDIUM_FLOAT = 0x8DF1, 363 HIGH_FLOAT = 0x8DF2, 364 LOW_INT = 0x8DF3, 365 MEDIUM_INT = 0x8DF4, 366 HIGH_INT = 0x8DF5, 367 FRAMEBUFFER = 0x8D40, 368 RENDERBUFFER = 0x8D41, 369 RGBA4 = 0x8056, 370 RGB5_A1 = 0x8057, 371 RGB565 = 0x8D62, 372 DEPTH_COMPONENT16 = 0x81A5, 373 STENCIL_INDEX = 0x1901, 374 STENCIL_INDEX8 = 0x8D48, 375 DEPTH_STENCIL = 0x84F9, 376 RENDERBUFFER_WIDTH = 0x8D42, 377 RENDERBUFFER_HEIGHT = 0x8D43, 378 RENDERBUFFER_INTERNAL_FORMAT = 0x8D44, 379 RENDERBUFFER_RED_SIZE = 0x8D50, 380 RENDERBUFFER_GREEN_SIZE = 0x8D51, 381 RENDERBUFFER_BLUE_SIZE = 0x8D52, 382 RENDERBUFFER_ALPHA_SIZE = 0x8D53, 383 RENDERBUFFER_DEPTH_SIZE = 0x8D54, 384 RENDERBUFFER_STENCIL_SIZE = 0x8D55, 385 FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0, 386 FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1, 387 FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2, 388 FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3, 389 COLOR_ATTACHMENT0 = 0x8CE0, 390 DEPTH_ATTACHMENT = 0x8D00, 391 STENCIL_ATTACHMENT = 0x8D20, 392 DEPTH_STENCIL_ATTACHMENT = 0x821A, 393 NONE = 0, 394 FRAMEBUFFER_COMPLETE = 0x8CD5, 395 FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6, 396 FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7, 397 FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9, 398 FRAMEBUFFER_UNSUPPORTED = 0x8CDD, 399 FRAMEBUFFER_BINDING = 0x8CA6, 400 RENDERBUFFER_BINDING = 0x8CA7, 401 MAX_RENDERBUFFER_SIZE = 0x84E8, 402 INVALID_FRAMEBUFFER_OPERATION = 0x0506, 403 404 // WebGL-specific enums 405 UNPACK_FLIP_Y_WEBGL = 0x9240, 406 UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241 91 407 }; 408 409 // Context creation attributes. 410 struct Attributes { 411 Attributes() 412 : alpha(true) 413 , depth(true) 414 , stencil(false) 415 , antialias(true) 416 , premultipliedAlpha(true) 417 { 418 } 419 420 bool alpha; 421 bool depth; 422 bool stencil; 423 bool antialias; 424 bool premultipliedAlpha; 425 }; 426 427 static PassOwnPtr<GraphicsContext3D> create(Attributes attrs, HostWindow* hostWindow); 428 virtual ~GraphicsContext3D(); 429 430 #if PLATFORM(MAC) 431 PlatformGraphicsContext3D platformGraphicsContext3D() const { return m_contextObj; } 432 Platform3DObject platformTexture() const { return m_texture; } 433 CALayer* platformLayer() const { return static_cast<CALayer*>(m_webGLLayer.get()); } 434 #elif PLATFORM(CHROMIUM) 435 PlatformGraphicsContext3D platformGraphicsContext3D() const; 436 Platform3DObject platformTexture() const; 437 #if USE(ACCELERATED_COMPOSITING) 438 PlatformLayer* platformLayer() const; 439 #endif 440 #elif PLATFORM(QT) 441 PlatformGraphicsContext3D platformGraphicsContext3D(); 442 Platform3DObject platformTexture() const; 443 #if USE(ACCELERATED_COMPOSITING) 444 PlatformLayer* platformLayer() const { return 0; } 445 #endif 446 #else 447 PlatformGraphicsContext3D platformGraphicsContext3D() const { return NullPlatformGraphicsContext3D; } 448 Platform3DObject platformTexture() const { return NullPlatform3DObject; } 449 #if USE(ACCELERATED_COMPOSITING) 450 PlatformLayer* platformLayer() const { return 0; } 451 #endif 452 #endif 453 void makeContextCurrent(); 454 455 #if PLATFORM(MAC) || PLATFORM(CHROMIUM) 456 // With multisampling on, blit from multisampleFBO to regular FBO. 457 void prepareTexture(); 458 #endif 459 460 // Helper to return the size in bytes of OpenGL data types 461 // like GL_FLOAT, GL_INT, etc. 462 int sizeInBytes(int type); 463 464 bool isGLES2Compliant() const; 465 466 //---------------------------------------------------------------------- 467 // Helpers for texture uploading and pixel readback. 468 // 469 470 // Computes the components per pixel and bytes per component 471 // for the given format and type combination. Returns false if 472 // either was an invalid enum. 473 bool computeFormatAndTypeParameters(unsigned int format, 474 unsigned int type, 475 unsigned long* componentsPerPixel, 476 unsigned long* bytesPerComponent); 477 478 // Extracts the contents of the given Image into the passed Vector, 479 // packing the pixel data according to the given format and type, 480 // and obeying the flipY and premultiplyAlpha flags. Returns true 481 // upon success. 482 bool extractImageData(Image* image, 483 unsigned int format, 484 unsigned int type, 485 bool flipY, 486 bool premultiplyAlpha, 487 Vector<uint8_t>& data); 488 489 // Extracts the contents of the given ImageData into the passed Vector, 490 // packing the pixel data according to the given format and type, 491 // and obeying the flipY and premultiplyAlpha flags. Returns true 492 // upon success. 493 bool extractImageData(ImageData*, 494 unsigned int format, 495 unsigned int type, 496 bool flipY, 497 bool premultiplyAlpha, 498 Vector<uint8_t>& data); 499 500 // Helper function which extracts the user-supplied texture 501 // data, applying the flipY and premultiplyAlpha parameters. 502 // If the data is not tightly packed according to the passed 503 // unpackAlignment, the output data will be tightly packed. 504 // Returns true if successful, false if any error occurred. 505 bool extractTextureData(unsigned int width, unsigned int height, 506 unsigned int format, unsigned int type, 507 unsigned int unpackAlignment, 508 bool flipY, bool premultiplyAlpha, 509 ArrayBufferView* pixels, 510 Vector<uint8_t>& data); 511 512 // Flips the given image data vertically, in-place. 513 void flipVertically(void* imageData, 514 unsigned int width, 515 unsigned int height, 516 unsigned int bytesPerPixel, 517 unsigned int unpackAlignment); 518 519 // Attempt to enumerate all possible native image formats to 520 // reduce the amount of temporary allocations during texture 521 // uploading. This enum must be public because it is accessed 522 // by non-member functions. 523 enum SourceDataFormat { 524 kSourceFormatRGBA8, 525 kSourceFormatRGB8, 526 kSourceFormatBGRA8, 527 kSourceFormatRGBA5551, 528 kSourceFormatRGBA4444, 529 kSourceFormatRGB565, 530 kSourceFormatR8, 531 kSourceFormatRA8, 532 kSourceFormatA8 533 }; 534 535 //---------------------------------------------------------------------- 536 // Entry points for WebGL. 537 // 538 539 void activeTexture(unsigned long texture); 540 void attachShader(Platform3DObject program, Platform3DObject shader); 541 void bindAttribLocation(Platform3DObject, unsigned long index, const String& name); 542 void bindBuffer(unsigned long target, Platform3DObject); 543 void bindFramebuffer(unsigned long target, Platform3DObject); 544 void bindRenderbuffer(unsigned long target, Platform3DObject); 545 void bindTexture(unsigned long target, Platform3DObject texture); 546 void blendColor(double red, double green, double blue, double alpha); 547 void blendEquation(unsigned long mode); 548 void blendEquationSeparate(unsigned long modeRGB, unsigned long modeAlpha); 549 void blendFunc(unsigned long sfactor, unsigned long dfactor); 550 void blendFuncSeparate(unsigned long srcRGB, unsigned long dstRGB, unsigned long srcAlpha, unsigned long dstAlpha); 551 552 void bufferData(unsigned long target, int size, unsigned long usage); 553 void bufferData(unsigned long target, ArrayBuffer* data, unsigned long usage); 554 void bufferData(unsigned long target, ArrayBufferView* data, unsigned long usage); 555 void bufferSubData(unsigned long target, long offset, ArrayBuffer* data); 556 void bufferSubData(unsigned long target, long offset, ArrayBufferView* data); 557 558 unsigned long checkFramebufferStatus(unsigned long target); 559 void clear(unsigned long mask); 560 void clearColor(double red, double green, double blue, double alpha); 561 void clearDepth(double depth); 562 void clearStencil(long s); 563 void colorMask(bool red, bool green, bool blue, bool alpha); 564 void compileShader(Platform3DObject); 565 566 // void compressedTexImage2D(unsigned long target, long level, unsigned long internalformat, unsigned long width, unsigned long height, long border, unsigned long imageSize, const void* data); 567 // void compressedTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, unsigned long width, unsigned long height, unsigned long format, unsigned long imageSize, const void* data); 568 569 void copyTexImage2D(unsigned long target, long level, unsigned long internalformat, long x, long y, unsigned long width, unsigned long height, long border); 570 void copyTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, long x, long y, unsigned long width, unsigned long height); 571 void cullFace(unsigned long mode); 572 void depthFunc(unsigned long func); 573 void depthMask(bool flag); 574 void depthRange(double zNear, double zFar); 575 void detachShader(Platform3DObject, Platform3DObject); 576 void disable(unsigned long cap); 577 void disableVertexAttribArray(unsigned long index); 578 void drawArrays(unsigned long mode, long first, long count); 579 void drawElements(unsigned long mode, unsigned long count, unsigned long type, long offset); 580 581 void enable(unsigned long cap); 582 void enableVertexAttribArray(unsigned long index); 583 void finish(); 584 void flush(); 585 void framebufferRenderbuffer(unsigned long target, unsigned long attachment, unsigned long renderbuffertarget, Platform3DObject); 586 void framebufferTexture2D(unsigned long target, unsigned long attachment, unsigned long textarget, Platform3DObject, long level); 587 void frontFace(unsigned long mode); 588 void generateMipmap(unsigned long target); 589 590 bool getActiveAttrib(Platform3DObject program, unsigned long index, ActiveInfo&); 591 bool getActiveUniform(Platform3DObject program, unsigned long index, ActiveInfo&); 592 593 void getAttachedShaders(Platform3DObject program, int maxCount, int* count, unsigned int* shaders); 594 595 int getAttribLocation(Platform3DObject, const String& name); 596 597 void getBooleanv(unsigned long pname, unsigned char* value); 598 599 void getBufferParameteriv(unsigned long target, unsigned long pname, int* value); 600 601 Attributes getContextAttributes(); 602 603 unsigned long getError(); 604 605 void getFloatv(unsigned long pname, float* value); 606 607 void getFramebufferAttachmentParameteriv(unsigned long target, unsigned long attachment, unsigned long pname, int* value); 608 609 void getIntegerv(unsigned long pname, int* value); 610 611 void getProgramiv(Platform3DObject program, unsigned long pname, int* value); 612 613 String getProgramInfoLog(Platform3DObject); 614 615 void getRenderbufferParameteriv(unsigned long target, unsigned long pname, int* value); 616 617 void getShaderiv(Platform3DObject, unsigned long pname, int* value); 618 619 String getShaderInfoLog(Platform3DObject); 620 621 // TBD 622 // void glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); 623 624 String getShaderSource(Platform3DObject); 625 String getString(unsigned long name); 626 627 void getTexParameterfv(unsigned long target, unsigned long pname, float* value); 628 void getTexParameteriv(unsigned long target, unsigned long pname, int* value); 629 630 void getUniformfv(Platform3DObject program, long location, float* value); 631 void getUniformiv(Platform3DObject program, long location, int* value); 632 633 long getUniformLocation(Platform3DObject, const String& name); 634 635 void getVertexAttribfv(unsigned long index, unsigned long pname, float* value); 636 void getVertexAttribiv(unsigned long index, unsigned long pname, int* value); 637 638 long getVertexAttribOffset(unsigned long index, unsigned long pname); 639 640 void hint(unsigned long target, unsigned long mode); 641 bool isBuffer(Platform3DObject); 642 bool isEnabled(unsigned long cap); 643 bool isFramebuffer(Platform3DObject); 644 bool isProgram(Platform3DObject); 645 bool isRenderbuffer(Platform3DObject); 646 bool isShader(Platform3DObject); 647 bool isTexture(Platform3DObject); 648 void lineWidth(double); 649 void linkProgram(Platform3DObject); 650 void pixelStorei(unsigned long pname, long param); 651 void polygonOffset(double factor, double units); 652 653 void readPixels(long x, long y, unsigned long width, unsigned long height, unsigned long format, unsigned long type, void* data); 654 655 void releaseShaderCompiler(); 656 void renderbufferStorage(unsigned long target, unsigned long internalformat, unsigned long width, unsigned long height); 657 void sampleCoverage(double value, bool invert); 658 void scissor(long x, long y, unsigned long width, unsigned long height); 659 void shaderSource(Platform3DObject, const String& string); 660 void stencilFunc(unsigned long func, long ref, unsigned long mask); 661 void stencilFuncSeparate(unsigned long face, unsigned long func, long ref, unsigned long mask); 662 void stencilMask(unsigned long mask); 663 void stencilMaskSeparate(unsigned long face, unsigned long mask); 664 void stencilOp(unsigned long fail, unsigned long zfail, unsigned long zpass); 665 void stencilOpSeparate(unsigned long face, unsigned long fail, unsigned long zfail, unsigned long zpass); 666 667 int texImage2D(unsigned target, unsigned level, unsigned internalformat, unsigned width, unsigned height, unsigned border, unsigned format, unsigned type, void* pixels); 668 669 void texParameterf(unsigned target, unsigned pname, float param); 670 void texParameteri(unsigned target, unsigned pname, int param); 671 672 int texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, unsigned width, unsigned height, unsigned format, unsigned type, void* pixels); 673 674 void uniform1f(long location, float x); 675 void uniform1fv(long location, float* v, int size); 676 void uniform1i(long location, int x); 677 void uniform1iv(long location, int* v, int size); 678 void uniform2f(long location, float x, float y); 679 void uniform2fv(long location, float* v, int size); 680 void uniform2i(long location, int x, int y); 681 void uniform2iv(long location, int* v, int size); 682 void uniform3f(long location, float x, float y, float z); 683 void uniform3fv(long location, float* v, int size); 684 void uniform3i(long location, int x, int y, int z); 685 void uniform3iv(long location, int* v, int size); 686 void uniform4f(long location, float x, float y, float z, float w); 687 void uniform4fv(long location, float* v, int size); 688 void uniform4i(long location, int x, int y, int z, int w); 689 void uniform4iv(long location, int* v, int size); 690 void uniformMatrix2fv(long location, bool transpose, float* value, int size); 691 void uniformMatrix3fv(long location, bool transpose, float* value, int size); 692 void uniformMatrix4fv(long location, bool transpose, float* value, int size); 693 694 void useProgram(Platform3DObject); 695 void validateProgram(Platform3DObject); 696 697 void vertexAttrib1f(unsigned long indx, float x); 698 void vertexAttrib1fv(unsigned long indx, float* values); 699 void vertexAttrib2f(unsigned long indx, float x, float y); 700 void vertexAttrib2fv(unsigned long indx, float* values); 701 void vertexAttrib3f(unsigned long indx, float x, float y, float z); 702 void vertexAttrib3fv(unsigned long indx, float* values); 703 void vertexAttrib4f(unsigned long indx, float x, float y, float z, float w); 704 void vertexAttrib4fv(unsigned long indx, float* values); 705 void vertexAttribPointer(unsigned long indx, int size, int type, bool normalized, 706 unsigned long stride, unsigned long offset); 707 708 void viewport(long x, long y, unsigned long width, unsigned long height); 709 710 void reshape(int width, int height); 711 712 #if PLATFORM(CG) 713 void paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight, 714 int canvasWidth, int canvasHeight, CGContextRef context); 715 #endif 716 717 void paintRenderingResultsToCanvas(CanvasRenderingContext* context); 718 719 // Helpers for notification about paint events 720 void beginPaint(CanvasRenderingContext* context); 721 void endPaint(); 722 #if PLATFORM(QT) 723 void paint(QPainter* painter, const QRect& rect) const; 724 #endif 725 726 // Support for buffer creation and deletion 727 unsigned createBuffer(); 728 unsigned createFramebuffer(); 729 unsigned createProgram(); 730 unsigned createRenderbuffer(); 731 unsigned createShader(unsigned long); 732 unsigned createTexture(); 733 734 void deleteBuffer(unsigned); 735 void deleteFramebuffer(unsigned); 736 void deleteProgram(unsigned); 737 void deleteRenderbuffer(unsigned); 738 void deleteShader(unsigned); 739 void deleteTexture(unsigned); 740 741 // Synthesizes an OpenGL error which will be returned from a 742 // later call to getError. This is used to emulate OpenGL ES 743 // 2.0 behavior on the desktop and to enforce additional error 744 // checking mandated by WebGL. 745 // 746 // Per the behavior of glGetError, this stores at most one 747 // instance of any given error, and returns them from calls to 748 // getError in the order they were added. 749 void synthesizeGLError(unsigned long error); 750 751 private: 752 GraphicsContext3D(Attributes attrs, HostWindow* hostWindow); 753 754 // Each platform must provide an implementation of this method. 755 // 756 // Gets the data for the given Image into outputVector in the 757 // format specified by the (OpenGL-style) format and type 758 // arguments. Despite the fact that the outputVector contains 759 // uint8_t, if the format and type specify packed pixels, then 760 // it will essentially contain uint16_t after the extraction 761 // process. 762 // 763 // If premultiplyAlpha is true, the alpha channel, if any, 764 // will be multiplied into the color channels during the 765 // extraction process. This premultiplication occurs before 766 // any packing of pixel data. 767 // 768 // No vertical flip of the image data is performed by this 769 // method. 770 bool getImageData(Image* image, 771 unsigned int format, 772 unsigned int type, 773 bool premultiplyAlpha, 774 Vector<uint8_t>& outputVector); 775 776 // Possible alpha operations that may need to occur during 777 // pixel packing. FIXME: kAlphaDoUnmultiply is lossy and must 778 // be removed. 779 enum AlphaOp { 780 kAlphaDoNothing = 0, 781 kAlphaDoPremultiply = 1, 782 kAlphaDoUnmultiply = 2 783 }; 784 785 // Helper for getImageData which implements packing of pixel 786 // data into the specified OpenGL destination format and type. 787 // A sourceUnpackAlignment of zero indicates that the source 788 // data is tightly packed. Non-zero values may take a slow path. 789 // Destination data will have no gaps between rows. 790 bool packPixels(const uint8_t* sourceData, 791 SourceDataFormat sourceDataFormat, 792 unsigned int width, 793 unsigned int height, 794 unsigned int sourceUnpackAlignment, 795 unsigned int destinationFormat, 796 unsigned int destinationType, 797 AlphaOp alphaOp, 798 void* destinationData); 799 800 #if PLATFORM(MAC) 801 // Take into account the user's requested context creation attributes, 802 // in particular stencil and antialias, and determine which could or 803 // could not be honored based on the capabilities of the OpenGL 804 // implementation. 805 void validateAttributes(); 806 #endif 807 808 int m_currentWidth, m_currentHeight; 809 810 #if PLATFORM(MAC) 811 Attributes m_attrs; 812 Vector<Vector<float> > m_vertexArray; 813 814 CGLContextObj m_contextObj; 815 RetainPtr<WebGLLayer> m_webGLLayer; 816 GLuint m_texture; 817 GLuint m_fbo; 818 GLuint m_depthStencilBuffer; 819 820 // For tracking which FBO is bound 821 GLuint m_boundFBO; 822 823 // For multisampling 824 GLuint m_multisampleFBO; 825 GLuint m_multisampleDepthStencilBuffer; 826 GLuint m_multisampleColorBuffer; 827 828 // Errors raised by synthesizeGLError(). 829 ListHashSet<unsigned long> m_syntheticErrors; 830 #endif 92 831 93 832 // FIXME: ideally this would be used on all platforms. 94 833 #if PLATFORM(CHROMIUM) || PLATFORM(QT) 95 class GraphicsContext3DInternal; 96 #endif 97 98 class GraphicsContext3D : public Noncopyable { 99 public: 100 enum WebGLEnumType { 101 DEPTH_BUFFER_BIT = 0x00000100, 102 STENCIL_BUFFER_BIT = 0x00000400, 103 COLOR_BUFFER_BIT = 0x00004000, 104 POINTS = 0x0000, 105 LINES = 0x0001, 106 LINE_LOOP = 0x0002, 107 LINE_STRIP = 0x0003, 108 TRIANGLES = 0x0004, 109 TRIANGLE_STRIP = 0x0005, 110 TRIANGLE_FAN = 0x0006, 111 ZERO = 0, 112 ONE = 1, 113 SRC_COLOR = 0x0300, 114 ONE_MINUS_SRC_COLOR = 0x0301, 115 SRC_ALPHA = 0x0302, 116 ONE_MINUS_SRC_ALPHA = 0x0303, 117 DST_ALPHA = 0x0304, 118 ONE_MINUS_DST_ALPHA = 0x0305, 119 DST_COLOR = 0x0306, 120 ONE_MINUS_DST_COLOR = 0x0307, 121 SRC_ALPHA_SATURATE = 0x0308, 122 FUNC_ADD = 0x8006, 123 BLEND_EQUATION = 0x8009, 124 BLEND_EQUATION_RGB = 0x8009, 125 BLEND_EQUATION_ALPHA = 0x883D, 126 FUNC_SUBTRACT = 0x800A, 127 FUNC_REVERSE_SUBTRACT = 0x800B, 128 BLEND_DST_RGB = 0x80C8, 129 BLEND_SRC_RGB = 0x80C9, 130 BLEND_DST_ALPHA = 0x80CA, 131 BLEND_SRC_ALPHA = 0x80CB, 132 CONSTANT_COLOR = 0x8001, 133 ONE_MINUS_CONSTANT_COLOR = 0x8002, 134 CONSTANT_ALPHA = 0x8003, 135 ONE_MINUS_CONSTANT_ALPHA = 0x8004, 136 BLEND_COLOR = 0x8005, 137 ARRAY_BUFFER = 0x8892, 138 ELEMENT_ARRAY_BUFFER = 0x8893, 139 ARRAY_BUFFER_BINDING = 0x8894, 140 ELEMENT_ARRAY_BUFFER_BINDING = 0x8895, 141 STREAM_DRAW = 0x88E0, 142 STATIC_DRAW = 0x88E4, 143 DYNAMIC_DRAW = 0x88E8, 144 BUFFER_SIZE = 0x8764, 145 BUFFER_USAGE = 0x8765, 146 CURRENT_VERTEX_ATTRIB = 0x8626, 147 FRONT = 0x0404, 148 BACK = 0x0405, 149 FRONT_AND_BACK = 0x0408, 150 TEXTURE_2D = 0x0DE1, 151 CULL_FACE = 0x0B44, 152 BLEND = 0x0BE2, 153 DITHER = 0x0BD0, 154 STENCIL_TEST = 0x0B90, 155 DEPTH_TEST = 0x0B71, 156 SCISSOR_TEST = 0x0C11, 157 POLYGON_OFFSET_FILL = 0x8037, 158 SAMPLE_ALPHA_TO_COVERAGE = 0x809E, 159 SAMPLE_COVERAGE = 0x80A0, 160 NO_ERROR = 0, 161 INVALID_ENUM = 0x0500, 162 INVALID_VALUE = 0x0501, 163 INVALID_OPERATION = 0x0502, 164 OUT_OF_MEMORY = 0x0505, 165 CW = 0x0900, 166 CCW = 0x0901, 167 LINE_WIDTH = 0x0B21, 168 ALIASED_POINT_SIZE_RANGE = 0x846D, 169 ALIASED_LINE_WIDTH_RANGE = 0x846E, 170 CULL_FACE_MODE = 0x0B45, 171 FRONT_FACE = 0x0B46, 172 DEPTH_RANGE = 0x0B70, 173 DEPTH_WRITEMASK = 0x0B72, 174 DEPTH_CLEAR_VALUE = 0x0B73, 175 DEPTH_FUNC = 0x0B74, 176 STENCIL_CLEAR_VALUE = 0x0B91, 177 STENCIL_FUNC = 0x0B92, 178 STENCIL_FAIL = 0x0B94, 179 STENCIL_PASS_DEPTH_FAIL = 0x0B95, 180 STENCIL_PASS_DEPTH_PASS = 0x0B96, 181 STENCIL_REF = 0x0B97, 182 STENCIL_VALUE_MASK = 0x0B93, 183 STENCIL_WRITEMASK = 0x0B98, 184 STENCIL_BACK_FUNC = 0x8800, 185 STENCIL_BACK_FAIL = 0x8801, 186 STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802, 187 STENCIL_BACK_PASS_DEPTH_PASS = 0x8803, 188 STENCIL_BACK_REF = 0x8CA3, 189 STENCIL_BACK_VALUE_MASK = 0x8CA4, 190 STENCIL_BACK_WRITEMASK = 0x8CA5, 191 VIEWPORT = 0x0BA2, 192 SCISSOR_BOX = 0x0C10, 193 COLOR_CLEAR_VALUE = 0x0C22, 194 COLOR_WRITEMASK = 0x0C23, 195 UNPACK_ALIGNMENT = 0x0CF5, 196 PACK_ALIGNMENT = 0x0D05, 197 MAX_TEXTURE_SIZE = 0x0D33, 198 MAX_VIEWPORT_DIMS = 0x0D3A, 199 SUBPIXEL_BITS = 0x0D50, 200 RED_BITS = 0x0D52, 201 GREEN_BITS = 0x0D53, 202 BLUE_BITS = 0x0D54, 203 ALPHA_BITS = 0x0D55, 204 DEPTH_BITS = 0x0D56, 205 STENCIL_BITS = 0x0D57, 206 POLYGON_OFFSET_UNITS = 0x2A00, 207 POLYGON_OFFSET_FACTOR = 0x8038, 208 TEXTURE_BINDING_2D = 0x8069, 209 SAMPLE_BUFFERS = 0x80A8, 210 SAMPLES = 0x80A9, 211 SAMPLE_COVERAGE_VALUE = 0x80AA, 212 SAMPLE_COVERAGE_INVERT = 0x80AB, 213 NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2, 214 COMPRESSED_TEXTURE_FORMATS = 0x86A3, 215 DONT_CARE = 0x1100, 216 FASTEST = 0x1101, 217 NICEST = 0x1102, 218 GENERATE_MIPMAP_HINT = 0x8192, 219 BYTE = 0x1400, 220 UNSIGNED_BYTE = 0x1401, 221 SHORT = 0x1402, 222 UNSIGNED_SHORT = 0x1403, 223 INT = 0x1404, 224 UNSIGNED_INT = 0x1405, 225 FLOAT = 0x1406, 226 FIXED = 0x140C, 227 DEPTH_COMPONENT = 0x1902, 228 ALPHA = 0x1906, 229 RGB = 0x1907, 230 RGBA = 0x1908, 231 LUMINANCE = 0x1909, 232 LUMINANCE_ALPHA = 0x190A, 233 UNSIGNED_SHORT_4_4_4_4 = 0x8033, 234 UNSIGNED_SHORT_5_5_5_1 = 0x8034, 235 UNSIGNED_SHORT_5_6_5 = 0x8363, 236 FRAGMENT_SHADER = 0x8B30, 237 VERTEX_SHADER = 0x8B31, 238 MAX_VERTEX_ATTRIBS = 0x8869, 239 MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB, 240 MAX_VARYING_VECTORS = 0x8DFC, 241 MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D, 242 MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C, 243 MAX_TEXTURE_IMAGE_UNITS = 0x8872, 244 MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD, 245 SHADER_TYPE = 0x8B4F, 246 DELETE_STATUS = 0x8B80, 247 LINK_STATUS = 0x8B82, 248 VALIDATE_STATUS = 0x8B83, 249 ATTACHED_SHADERS = 0x8B85, 250 ACTIVE_UNIFORMS = 0x8B86, 251 ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87, 252 ACTIVE_ATTRIBUTES = 0x8B89, 253 ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A, 254 SHADING_LANGUAGE_VERSION = 0x8B8C, 255 CURRENT_PROGRAM = 0x8B8D, 256 NEVER = 0x0200, 257 LESS = 0x0201, 258 EQUAL = 0x0202, 259 LEQUAL = 0x0203, 260 GREATER = 0x0204, 261 NOTEQUAL = 0x0205, 262 GEQUAL = 0x0206, 263 ALWAYS = 0x0207, 264 KEEP = 0x1E00, 265 REPLACE = 0x1E01, 266 INCR = 0x1E02, 267 DECR = 0x1E03, 268 INVERT = 0x150A, 269 INCR_WRAP = 0x8507, 270 DECR_WRAP = 0x8508, 271 VENDOR = 0x1F00, 272 RENDERER = 0x1F01, 273 VERSION = 0x1F02, 274 EXTENSIONS = 0x1F03, 275 NEAREST = 0x2600, 276 LINEAR = 0x2601, 277 NEAREST_MIPMAP_NEAREST = 0x2700, 278 LINEAR_MIPMAP_NEAREST = 0x2701, 279 NEAREST_MIPMAP_LINEAR = 0x2702, 280 LINEAR_MIPMAP_LINEAR = 0x2703, 281 TEXTURE_MAG_FILTER = 0x2800, 282 TEXTURE_MIN_FILTER = 0x2801, 283 TEXTURE_WRAP_S = 0x2802, 284 TEXTURE_WRAP_T = 0x2803, 285 TEXTURE = 0x1702, 286 TEXTURE_CUBE_MAP = 0x8513, 287 TEXTURE_BINDING_CUBE_MAP = 0x8514, 288 TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515, 289 TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516, 290 TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517, 291 TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518, 292 TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519, 293 TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A, 294 MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C, 295 TEXTURE0 = 0x84C0, 296 TEXTURE1 = 0x84C1, 297 TEXTURE2 = 0x84C2, 298 TEXTURE3 = 0x84C3, 299 TEXTURE4 = 0x84C4, 300 TEXTURE5 = 0x84C5, 301 TEXTURE6 = 0x84C6, 302 TEXTURE7 = 0x84C7, 303 TEXTURE8 = 0x84C8, 304 TEXTURE9 = 0x84C9, 305 TEXTURE10 = 0x84CA, 306 TEXTURE11 = 0x84CB, 307 TEXTURE12 = 0x84CC, 308 TEXTURE13 = 0x84CD, 309 TEXTURE14 = 0x84CE, 310 TEXTURE15 = 0x84CF, 311 TEXTURE16 = 0x84D0, 312 TEXTURE17 = 0x84D1, 313 TEXTURE18 = 0x84D2, 314 TEXTURE19 = 0x84D3, 315 TEXTURE20 = 0x84D4, 316 TEXTURE21 = 0x84D5, 317 TEXTURE22 = 0x84D6, 318 TEXTURE23 = 0x84D7, 319 TEXTURE24 = 0x84D8, 320 TEXTURE25 = 0x84D9, 321 TEXTURE26 = 0x84DA, 322 TEXTURE27 = 0x84DB, 323 TEXTURE28 = 0x84DC, 324 TEXTURE29 = 0x84DD, 325 TEXTURE30 = 0x84DE, 326 TEXTURE31 = 0x84DF, 327 ACTIVE_TEXTURE = 0x84E0, 328 REPEAT = 0x2901, 329 CLAMP_TO_EDGE = 0x812F, 330 MIRRORED_REPEAT = 0x8370, 331 FLOAT_VEC2 = 0x8B50, 332 FLOAT_VEC3 = 0x8B51, 333 FLOAT_VEC4 = 0x8B52, 334 INT_VEC2 = 0x8B53, 335 INT_VEC3 = 0x8B54, 336 INT_VEC4 = 0x8B55, 337 BOOL = 0x8B56, 338 BOOL_VEC2 = 0x8B57, 339 BOOL_VEC3 = 0x8B58, 340 BOOL_VEC4 = 0x8B59, 341 FLOAT_MAT2 = 0x8B5A, 342 FLOAT_MAT3 = 0x8B5B, 343 FLOAT_MAT4 = 0x8B5C, 344 SAMPLER_2D = 0x8B5E, 345 SAMPLER_CUBE = 0x8B60, 346 VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622, 347 VERTEX_ATTRIB_ARRAY_SIZE = 0x8623, 348 VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624, 349 VERTEX_ATTRIB_ARRAY_TYPE = 0x8625, 350 VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A, 351 VERTEX_ATTRIB_ARRAY_POINTER = 0x8645, 352 VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F, 353 IMPLEMENTATION_COLOR_READ_TYPE = 0x8B9A, 354 IMPLEMENTATION_COLOR_READ_FORMAT = 0x8B9B, 355 COMPILE_STATUS = 0x8B81, 356 INFO_LOG_LENGTH = 0x8B84, 357 SHADER_SOURCE_LENGTH = 0x8B88, 358 SHADER_COMPILER = 0x8DFA, 359 SHADER_BINARY_FORMATS = 0x8DF8, 360 NUM_SHADER_BINARY_FORMATS = 0x8DF9, 361 LOW_FLOAT = 0x8DF0, 362 MEDIUM_FLOAT = 0x8DF1, 363 HIGH_FLOAT = 0x8DF2, 364 LOW_INT = 0x8DF3, 365 MEDIUM_INT = 0x8DF4, 366 HIGH_INT = 0x8DF5, 367 FRAMEBUFFER = 0x8D40, 368 RENDERBUFFER = 0x8D41, 369 RGBA4 = 0x8056, 370 RGB5_A1 = 0x8057, 371 RGB565 = 0x8D62, 372 DEPTH_COMPONENT16 = 0x81A5, 373 STENCIL_INDEX = 0x1901, 374 STENCIL_INDEX8 = 0x8D48, 375 DEPTH_STENCIL = 0x84F9, 376 RENDERBUFFER_WIDTH = 0x8D42, 377 RENDERBUFFER_HEIGHT = 0x8D43, 378 RENDERBUFFER_INTERNAL_FORMAT = 0x8D44, 379 RENDERBUFFER_RED_SIZE = 0x8D50, 380 RENDERBUFFER_GREEN_SIZE = 0x8D51, 381 RENDERBUFFER_BLUE_SIZE = 0x8D52, 382 RENDERBUFFER_ALPHA_SIZE = 0x8D53, 383 RENDERBUFFER_DEPTH_SIZE = 0x8D54, 384 RENDERBUFFER_STENCIL_SIZE = 0x8D55, 385 FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0, 386 FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1, 387 FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2, 388 FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3, 389 COLOR_ATTACHMENT0 = 0x8CE0, 390 DEPTH_ATTACHMENT = 0x8D00, 391 STENCIL_ATTACHMENT = 0x8D20, 392 DEPTH_STENCIL_ATTACHMENT = 0x821A, 393 NONE = 0, 394 FRAMEBUFFER_COMPLETE = 0x8CD5, 395 FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6, 396 FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7, 397 FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9, 398 FRAMEBUFFER_UNSUPPORTED = 0x8CDD, 399 FRAMEBUFFER_BINDING = 0x8CA6, 400 RENDERBUFFER_BINDING = 0x8CA7, 401 MAX_RENDERBUFFER_SIZE = 0x84E8, 402 INVALID_FRAMEBUFFER_OPERATION = 0x0506, 403 404 // WebGL-specific enums 405 UNPACK_FLIP_Y_WEBGL = 0x9240, 406 UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241 407 }; 408 409 // Context creation attributes. 410 struct Attributes { 411 Attributes() 412 : alpha(true) 413 , depth(true) 414 , stencil(false) 415 , antialias(true) 416 , premultipliedAlpha(true) 417 { 418 } 419 420 bool alpha; 421 bool depth; 422 bool stencil; 423 bool antialias; 424 bool premultipliedAlpha; 425 }; 426 427 static PassOwnPtr<GraphicsContext3D> create(Attributes attrs, HostWindow* hostWindow); 428 virtual ~GraphicsContext3D(); 429 430 #if PLATFORM(MAC) 431 PlatformGraphicsContext3D platformGraphicsContext3D() const { return m_contextObj; } 432 Platform3DObject platformTexture() const { return m_texture; } 433 CALayer* platformLayer() const { return static_cast<CALayer*>(m_webGLLayer.get()); } 434 #elif PLATFORM(CHROMIUM) 435 PlatformGraphicsContext3D platformGraphicsContext3D() const; 436 Platform3DObject platformTexture() const; 437 #if USE(ACCELERATED_COMPOSITING) 438 PlatformLayer* platformLayer() const; 439 #endif 440 #elif PLATFORM(QT) 441 PlatformGraphicsContext3D platformGraphicsContext3D(); 442 Platform3DObject platformTexture() const; 443 #if USE(ACCELERATED_COMPOSITING) 444 PlatformLayer* platformLayer() const { return 0; } 445 #endif 446 #else 447 PlatformGraphicsContext3D platformGraphicsContext3D() const { return NullPlatformGraphicsContext3D; } 448 Platform3DObject platformTexture() const { return NullPlatform3DObject; } 449 #if USE(ACCELERATED_COMPOSITING) 450 PlatformLayer* platformLayer() const { return 0; } 451 #endif 452 #endif 453 void makeContextCurrent(); 454 455 #if PLATFORM(MAC) || PLATFORM(CHROMIUM) 456 // With multisampling on, blit from multisampleFBO to regular FBO. 457 void prepareTexture(); 458 #endif 459 460 // Helper to return the size in bytes of OpenGL data types 461 // like GL_FLOAT, GL_INT, etc. 462 int sizeInBytes(int type); 463 464 bool isGLES2Compliant() const; 465 466 //---------------------------------------------------------------------- 467 // Helpers for texture uploading and pixel readback. 468 // 469 470 // Computes the components per pixel and bytes per component 471 // for the given format and type combination. Returns false if 472 // either was an invalid enum. 473 bool computeFormatAndTypeParameters(unsigned int format, 474 unsigned int type, 475 unsigned long* componentsPerPixel, 476 unsigned long* bytesPerComponent); 477 478 // Extracts the contents of the given Image into the passed Vector, 479 // packing the pixel data according to the given format and type, 480 // and obeying the flipY and premultiplyAlpha flags. Returns true 481 // upon success. 482 bool extractImageData(Image* image, 483 unsigned int format, 484 unsigned int type, 485 bool flipY, 486 bool premultiplyAlpha, 487 Vector<uint8_t>& data); 488 489 // Extracts the contents of the given ImageData into the passed Vector, 490 // packing the pixel data according to the given format and type, 491 // and obeying the flipY and premultiplyAlpha flags. Returns true 492 // upon success. 493 bool extractImageData(ImageData*, 494 unsigned int format, 495 unsigned int type, 496 bool flipY, 497 bool premultiplyAlpha, 498 Vector<uint8_t>& data); 499 500 // Helper function which extracts the user-supplied texture 501 // data, applying the flipY and premultiplyAlpha parameters. 502 // If the data is not tightly packed according to the passed 503 // unpackAlignment, the output data will be tightly packed. 504 // Returns true if successful, false if any error occurred. 505 bool extractTextureData(unsigned int width, unsigned int height, 506 unsigned int format, unsigned int type, 507 unsigned int unpackAlignment, 508 bool flipY, bool premultiplyAlpha, 509 ArrayBufferView* pixels, 510 Vector<uint8_t>& data); 511 512 // Flips the given image data vertically, in-place. 513 void flipVertically(void* imageData, 514 unsigned int width, 515 unsigned int height, 516 unsigned int bytesPerPixel, 517 unsigned int unpackAlignment); 518 519 // Attempt to enumerate all possible native image formats to 520 // reduce the amount of temporary allocations during texture 521 // uploading. This enum must be public because it is accessed 522 // by non-member functions. 523 enum SourceDataFormat { 524 kSourceFormatRGBA8, 525 kSourceFormatRGB8, 526 kSourceFormatBGRA8, 527 kSourceFormatRGBA5551, 528 kSourceFormatRGBA4444, 529 kSourceFormatRGB565, 530 kSourceFormatR8, 531 kSourceFormatRA8, 532 kSourceFormatA8 533 }; 534 535 //---------------------------------------------------------------------- 536 // Entry points for WebGL. 537 // 538 539 void activeTexture(unsigned long texture); 540 void attachShader(Platform3DObject program, Platform3DObject shader); 541 void bindAttribLocation(Platform3DObject, unsigned long index, const String& name); 542 void bindBuffer(unsigned long target, Platform3DObject); 543 void bindFramebuffer(unsigned long target, Platform3DObject); 544 void bindRenderbuffer(unsigned long target, Platform3DObject); 545 void bindTexture(unsigned long target, Platform3DObject texture); 546 void blendColor(double red, double green, double blue, double alpha); 547 void blendEquation(unsigned long mode); 548 void blendEquationSeparate(unsigned long modeRGB, unsigned long modeAlpha); 549 void blendFunc(unsigned long sfactor, unsigned long dfactor); 550 void blendFuncSeparate(unsigned long srcRGB, unsigned long dstRGB, unsigned long srcAlpha, unsigned long dstAlpha); 551 552 void bufferData(unsigned long target, int size, unsigned long usage); 553 void bufferData(unsigned long target, ArrayBuffer* data, unsigned long usage); 554 void bufferData(unsigned long target, ArrayBufferView* data, unsigned long usage); 555 void bufferSubData(unsigned long target, long offset, ArrayBuffer* data); 556 void bufferSubData(unsigned long target, long offset, ArrayBufferView* data); 557 558 unsigned long checkFramebufferStatus(unsigned long target); 559 void clear(unsigned long mask); 560 void clearColor(double red, double green, double blue, double alpha); 561 void clearDepth(double depth); 562 void clearStencil(long s); 563 void colorMask(bool red, bool green, bool blue, bool alpha); 564 void compileShader(Platform3DObject); 565 566 //void compressedTexImage2D(unsigned long target, long level, unsigned long internalformat, unsigned long width, unsigned long height, long border, unsigned long imageSize, const void* data); 567 //void compressedTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, unsigned long width, unsigned long height, unsigned long format, unsigned long imageSize, const void* data); 568 569 void copyTexImage2D(unsigned long target, long level, unsigned long internalformat, long x, long y, unsigned long width, unsigned long height, long border); 570 void copyTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, long x, long y, unsigned long width, unsigned long height); 571 void cullFace(unsigned long mode); 572 void depthFunc(unsigned long func); 573 void depthMask(bool flag); 574 void depthRange(double zNear, double zFar); 575 void detachShader(Platform3DObject, Platform3DObject); 576 void disable(unsigned long cap); 577 void disableVertexAttribArray(unsigned long index); 578 void drawArrays(unsigned long mode, long first, long count); 579 void drawElements(unsigned long mode, unsigned long count, unsigned long type, long offset); 580 581 void enable(unsigned long cap); 582 void enableVertexAttribArray(unsigned long index); 583 void finish(); 584 void flush(); 585 void framebufferRenderbuffer(unsigned long target, unsigned long attachment, unsigned long renderbuffertarget, Platform3DObject); 586 void framebufferTexture2D(unsigned long target, unsigned long attachment, unsigned long textarget, Platform3DObject, long level); 587 void frontFace(unsigned long mode); 588 void generateMipmap(unsigned long target); 589 590 bool getActiveAttrib(Platform3DObject program, unsigned long index, ActiveInfo&); 591 bool getActiveUniform(Platform3DObject program, unsigned long index, ActiveInfo&); 592 593 void getAttachedShaders(Platform3DObject program, int maxCount, int* count, unsigned int* shaders); 594 595 int getAttribLocation(Platform3DObject, const String& name); 596 597 void getBooleanv(unsigned long pname, unsigned char* value); 598 599 void getBufferParameteriv(unsigned long target, unsigned long pname, int* value); 600 601 Attributes getContextAttributes(); 602 603 unsigned long getError(); 604 605 void getFloatv(unsigned long pname, float* value); 606 607 void getFramebufferAttachmentParameteriv(unsigned long target, unsigned long attachment, unsigned long pname, int* value); 608 609 void getIntegerv(unsigned long pname, int* value); 610 611 void getProgramiv(Platform3DObject program, unsigned long pname, int* value); 612 613 String getProgramInfoLog(Platform3DObject); 614 615 void getRenderbufferParameteriv(unsigned long target, unsigned long pname, int* value); 616 617 void getShaderiv(Platform3DObject, unsigned long pname, int* value); 618 619 String getShaderInfoLog(Platform3DObject); 620 621 // TBD 622 // void glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); 623 624 String getShaderSource(Platform3DObject); 625 String getString(unsigned long name); 626 627 void getTexParameterfv(unsigned long target, unsigned long pname, float* value); 628 void getTexParameteriv(unsigned long target, unsigned long pname, int* value); 629 630 void getUniformfv(Platform3DObject program, long location, float* value); 631 void getUniformiv(Platform3DObject program, long location, int* value); 632 633 long getUniformLocation(Platform3DObject, const String& name); 634 635 void getVertexAttribfv(unsigned long index, unsigned long pname, float* value); 636 void getVertexAttribiv(unsigned long index, unsigned long pname, int* value); 637 638 long getVertexAttribOffset(unsigned long index, unsigned long pname); 639 640 void hint(unsigned long target, unsigned long mode); 641 bool isBuffer(Platform3DObject); 642 bool isEnabled(unsigned long cap); 643 bool isFramebuffer(Platform3DObject); 644 bool isProgram(Platform3DObject); 645 bool isRenderbuffer(Platform3DObject); 646 bool isShader(Platform3DObject); 647 bool isTexture(Platform3DObject); 648 void lineWidth(double); 649 void linkProgram(Platform3DObject); 650 void pixelStorei(unsigned long pname, long param); 651 void polygonOffset(double factor, double units); 652 653 void readPixels(long x, long y, unsigned long width, unsigned long height, unsigned long format, unsigned long type, void* data); 654 655 void releaseShaderCompiler(); 656 void renderbufferStorage(unsigned long target, unsigned long internalformat, unsigned long width, unsigned long height); 657 void sampleCoverage(double value, bool invert); 658 void scissor(long x, long y, unsigned long width, unsigned long height); 659 void shaderSource(Platform3DObject, const String& string); 660 void stencilFunc(unsigned long func, long ref, unsigned long mask); 661 void stencilFuncSeparate(unsigned long face, unsigned long func, long ref, unsigned long mask); 662 void stencilMask(unsigned long mask); 663 void stencilMaskSeparate(unsigned long face, unsigned long mask); 664 void stencilOp(unsigned long fail, unsigned long zfail, unsigned long zpass); 665 void stencilOpSeparate(unsigned long face, unsigned long fail, unsigned long zfail, unsigned long zpass); 666 667 int texImage2D(unsigned target, unsigned level, unsigned internalformat, unsigned width, unsigned height, unsigned border, unsigned format, unsigned type, void* pixels); 668 669 void texParameterf(unsigned target, unsigned pname, float param); 670 void texParameteri(unsigned target, unsigned pname, int param); 671 672 int texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, unsigned width, unsigned height, unsigned format, unsigned type, void* pixels); 673 674 void uniform1f(long location, float x); 675 void uniform1fv(long location, float* v, int size); 676 void uniform1i(long location, int x); 677 void uniform1iv(long location, int* v, int size); 678 void uniform2f(long location, float x, float y); 679 void uniform2fv(long location, float* v, int size); 680 void uniform2i(long location, int x, int y); 681 void uniform2iv(long location, int* v, int size); 682 void uniform3f(long location, float x, float y, float z); 683 void uniform3fv(long location, float* v, int size); 684 void uniform3i(long location, int x, int y, int z); 685 void uniform3iv(long location, int* v, int size); 686 void uniform4f(long location, float x, float y, float z, float w); 687 void uniform4fv(long location, float* v, int size); 688 void uniform4i(long location, int x, int y, int z, int w); 689 void uniform4iv(long location, int* v, int size); 690 void uniformMatrix2fv(long location, bool transpose, float* value, int size); 691 void uniformMatrix3fv(long location, bool transpose, float* value, int size); 692 void uniformMatrix4fv(long location, bool transpose, float* value, int size); 693 694 void useProgram(Platform3DObject); 695 void validateProgram(Platform3DObject); 696 697 void vertexAttrib1f(unsigned long indx, float x); 698 void vertexAttrib1fv(unsigned long indx, float* values); 699 void vertexAttrib2f(unsigned long indx, float x, float y); 700 void vertexAttrib2fv(unsigned long indx, float* values); 701 void vertexAttrib3f(unsigned long indx, float x, float y, float z); 702 void vertexAttrib3fv(unsigned long indx, float* values); 703 void vertexAttrib4f(unsigned long indx, float x, float y, float z, float w); 704 void vertexAttrib4fv(unsigned long indx, float* values); 705 void vertexAttribPointer(unsigned long indx, int size, int type, bool normalized, 706 unsigned long stride, unsigned long offset); 707 708 void viewport(long x, long y, unsigned long width, unsigned long height); 709 710 void reshape(int width, int height); 711 712 #if PLATFORM(CG) 713 void paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight, 714 int canvasWidth, int canvasHeight, CGContextRef context); 715 #endif 716 717 void paintRenderingResultsToCanvas(CanvasRenderingContext* context); 718 719 // Helpers for notification about paint events 720 void beginPaint(CanvasRenderingContext* context); 721 void endPaint(); 722 #if PLATFORM(QT) 723 void paint(QPainter* painter, const QRect& rect) const; 724 #endif 725 726 // Support for buffer creation and deletion 727 unsigned createBuffer(); 728 unsigned createFramebuffer(); 729 unsigned createProgram(); 730 unsigned createRenderbuffer(); 731 unsigned createShader(unsigned long); 732 unsigned createTexture(); 733 734 void deleteBuffer(unsigned); 735 void deleteFramebuffer(unsigned); 736 void deleteProgram(unsigned); 737 void deleteRenderbuffer(unsigned); 738 void deleteShader(unsigned); 739 void deleteTexture(unsigned); 740 741 // Synthesizes an OpenGL error which will be returned from a 742 // later call to getError. This is used to emulate OpenGL ES 743 // 2.0 behavior on the desktop and to enforce additional error 744 // checking mandated by WebGL. 745 // 746 // Per the behavior of glGetError, this stores at most one 747 // instance of any given error, and returns them from calls to 748 // getError in the order they were added. 749 void synthesizeGLError(unsigned long error); 750 751 private: 752 GraphicsContext3D(Attributes attrs, HostWindow* hostWindow); 753 754 // Each platform must provide an implementation of this method. 755 // 756 // Gets the data for the given Image into outputVector in the 757 // format specified by the (OpenGL-style) format and type 758 // arguments. Despite the fact that the outputVector contains 759 // uint8_t, if the format and type specify packed pixels, then 760 // it will essentially contain uint16_t after the extraction 761 // process. 762 // 763 // If premultiplyAlpha is true, the alpha channel, if any, 764 // will be multiplied into the color channels during the 765 // extraction process. This premultiplication occurs before 766 // any packing of pixel data. 767 // 768 // No vertical flip of the image data is performed by this 769 // method. 770 bool getImageData(Image* image, 771 unsigned int format, 772 unsigned int type, 773 bool premultiplyAlpha, 774 Vector<uint8_t>& outputVector); 775 776 // Possible alpha operations that may need to occur during 777 // pixel packing. FIXME: kAlphaDoUnmultiply is lossy and must 778 // be removed. 779 enum AlphaOp { 780 kAlphaDoNothing = 0, 781 kAlphaDoPremultiply = 1, 782 kAlphaDoUnmultiply = 2 783 }; 784 785 // Helper for getImageData which implements packing of pixel 786 // data into the specified OpenGL destination format and type. 787 // A sourceUnpackAlignment of zero indicates that the source 788 // data is tightly packed. Non-zero values may take a slow path. 789 // Destination data will have no gaps between rows. 790 bool packPixels(const uint8_t* sourceData, 791 SourceDataFormat sourceDataFormat, 792 unsigned int width, 793 unsigned int height, 794 unsigned int sourceUnpackAlignment, 795 unsigned int destinationFormat, 796 unsigned int destinationType, 797 AlphaOp alphaOp, 798 void* destinationData); 799 800 #if PLATFORM(MAC) 801 // Take into account the user's requested context creation attributes, 802 // in particular stencil and antialias, and determine which could or 803 // could not be honored based on the capabilities of the OpenGL 804 // implementation. 805 void validateAttributes(); 806 #endif 807 808 int m_currentWidth, m_currentHeight; 809 810 #if PLATFORM(MAC) 811 Attributes m_attrs; 812 Vector<Vector<float> > m_vertexArray; 813 814 CGLContextObj m_contextObj; 815 RetainPtr<WebGLLayer> m_webGLLayer; 816 GLuint m_texture; 817 GLuint m_fbo; 818 GLuint m_depthStencilBuffer; 819 820 // For tracking which FBO is bound 821 GLuint m_boundFBO; 822 823 // For multisampling 824 GLuint m_multisampleFBO; 825 GLuint m_multisampleDepthStencilBuffer; 826 GLuint m_multisampleColorBuffer; 827 828 // Errors raised by synthesizeGLError(). 829 ListHashSet<unsigned long> m_syntheticErrors; 830 #endif 831 832 // FIXME: ideally this would be used on all platforms. 833 #if PLATFORM(CHROMIUM) || PLATFORM(QT) 834 friend class GraphicsContext3DInternal; 835 OwnPtr<GraphicsContext3DInternal> m_internal; 836 #endif 837 }; 834 friend class GraphicsContext3DInternal; 835 OwnPtr<GraphicsContext3DInternal> m_internal; 836 #endif 837 }; 838 838 839 839 } // namespace WebCore -
trunk/WebKit/chromium/ChangeLog
r64763 r64767 1 2010-08-04 Kenneth Russell <kbr@google.com> 2 3 Reviewed by Dimitri Glazkov. 4 5 Style cleanups in WebGL 6 https://bugs.webkit.org/show_bug.cgi?id=38761 7 8 Cleaned up all style violations in WebGL-related files reported by 9 check-webkit-style. No logic or other changes. Built WebKit and 10 Chromium and ran WebGL layout tests. 11 12 * src/GraphicsContext3D.cpp: 13 (WebCore::GraphicsContext3DInternal::paintRenderingResultsToCanvas): 14 * src/WebGraphicsContext3DDefaultImpl.cpp: 15 * src/WebGraphicsContext3DDefaultImpl.h: 16 1 17 2010-08-05 Jian Li <jianli@chromium.org> 2 18 -
trunk/WebKit/chromium/src/GraphicsContext3D.cpp
r64582 r64767 39 39 #include "Chrome.h" 40 40 #include "ChromeClientImpl.h" 41 #include "Float32Array.h" 41 42 #include "HTMLCanvasElement.h" 42 43 #include "HTMLImageElement.h" 43 44 #include "ImageBuffer.h" 44 45 #include "ImageData.h" 46 #include "Int32Array.h" 45 47 #include "Int8Array.h" 46 #include "Float32Array.h"47 #include "Int32Array.h"48 48 #include "Uint8Array.h" 49 49 #include "WebGLLayerChromium.h" … … 415 415 m_impl->width(), 416 416 m_impl->height()); 417 if (!m_resizingBitmap.allocPixels()) {417 if (!m_resizingBitmap.allocPixels()) 418 418 return; 419 }420 419 } 421 420 readbackBitmap = &m_resizingBitmap; -
trunk/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp
r63705 r64767 33 33 #if ENABLE(3D_CANVAS) 34 34 35 #include "WebGraphicsContext3DDefaultImpl.h" 36 37 #include "NotImplemented.h" 38 35 39 #include <stdio.h> 36 40 #include <string.h> 37 38 #include "WebGraphicsContext3DDefaultImpl.h"39 40 #include "NotImplemented.h"41 41 42 42 #if OS(LINUX) -
trunk/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.h
r62288 r64767 326 326 static bool s_initializedGLEW; 327 327 #if OS(WINDOWS) 328 HWND 329 HDC 328 HWND m_canvasWindow; 329 HDC m_canvasDC; 330 330 HGLRC m_contextObj; 331 331 #elif PLATFORM(CG)
Note: See TracChangeset
for help on using the changeset viewer.