| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #define WebGLRenderingContextBase_h | 27 #define WebGLRenderingContextBase_h |
| 28 | 28 |
| 29 #include "bindings/core/v8/Nullable.h" | 29 #include "bindings/core/v8/Nullable.h" |
| 30 #include "bindings/core/v8/ScopedPersistent.h" | 30 #include "bindings/core/v8/ScopedPersistent.h" |
| 31 #include "bindings/core/v8/ScriptState.h" | 31 #include "bindings/core/v8/ScriptState.h" |
| 32 #include "bindings/core/v8/ScriptValue.h" | 32 #include "bindings/core/v8/ScriptValue.h" |
| 33 #include "bindings/core/v8/ScriptWrappable.h" | 33 #include "bindings/core/v8/ScriptWrappable.h" |
| 34 #include "core/CoreExport.h" | 34 #include "core/CoreExport.h" |
| 35 #include "core/dom/DOMTypedArray.h" | 35 #include "core/dom/DOMTypedArray.h" |
| 36 #include "core/dom/TypedFlexibleArrayBufferView.h" | 36 #include "core/dom/TypedFlexibleArrayBufferView.h" |
| 37 #include "core/html/canvas/CanvasContextCreationAttributes.h" |
| 37 #include "core/html/canvas/CanvasRenderingContext.h" | 38 #include "core/html/canvas/CanvasRenderingContext.h" |
| 38 #include "core/layout/ContentChangeType.h" | 39 #include "core/layout/ContentChangeType.h" |
| 39 #include "modules/webgl/WebGLContextAttributes.h" | 40 #include "modules/webgl/WebGLContextAttributes.h" |
| 40 #include "modules/webgl/WebGLExtensionName.h" | 41 #include "modules/webgl/WebGLExtensionName.h" |
| 41 #include "modules/webgl/WebGLTexture.h" | 42 #include "modules/webgl/WebGLTexture.h" |
| 42 #include "modules/webgl/WebGLVertexArrayObjectBase.h" | 43 #include "modules/webgl/WebGLVertexArrayObjectBase.h" |
| 43 #include "platform/Timer.h" | 44 #include "platform/Timer.h" |
| 44 #include "platform/graphics/ImageBuffer.h" | 45 #include "platform/graphics/ImageBuffer.h" |
| 45 #include "platform/graphics/gpu/DrawingBuffer.h" | 46 #include "platform/graphics/gpu/DrawingBuffer.h" |
| 46 #include "platform/graphics/gpu/Extensions3DUtil.h" | 47 #include "platform/graphics/gpu/Extensions3DUtil.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 public: | 133 public: |
| 133 ~WebGLRenderingContextBase() override; | 134 ~WebGLRenderingContextBase() override; |
| 134 | 135 |
| 135 virtual String contextName() const = 0; | 136 virtual String contextName() const = 0; |
| 136 virtual void registerContextExtensions() = 0; | 137 virtual void registerContextExtensions() = 0; |
| 137 | 138 |
| 138 virtual void initializeNewContext(); | 139 virtual void initializeNewContext(); |
| 139 | 140 |
| 140 static unsigned getWebGLVersion(const CanvasRenderingContext*); | 141 static unsigned getWebGLVersion(const CanvasRenderingContext*); |
| 141 | 142 |
| 142 static std::unique_ptr<WebGraphicsContext3DProvider> createWebGraphicsContex
t3DProvider(HTMLCanvasElement*, WebGLContextAttributes, unsigned webGLVersion); | 143 static std::unique_ptr<WebGraphicsContext3DProvider> createWebGraphicsContex
t3DProvider(HTMLCanvasElement*, const CanvasContextCreationAttributes&, unsigned
webGLVersion); |
| 143 static std::unique_ptr<WebGraphicsContext3DProvider> createWebGraphicsContex
t3DProvider(ScriptState*, WebGLContextAttributes, unsigned webGLVersion); | 144 static std::unique_ptr<WebGraphicsContext3DProvider> createWebGraphicsContex
t3DProvider(ScriptState*, const CanvasContextCreationAttributes&, unsigned webGL
Version); |
| 144 static void forceNextWebGLContextCreationToFail(); | 145 static void forceNextWebGLContextCreationToFail(); |
| 145 | 146 |
| 146 unsigned version() const { return m_version; } | 147 unsigned version() const { return m_version; } |
| 147 | 148 |
| 148 int drawingBufferWidth() const; | 149 int drawingBufferWidth() const; |
| 149 int drawingBufferHeight() const; | 150 int drawingBufferHeight() const; |
| 150 | 151 |
| 151 void activeTexture(GLenum texture); | 152 void activeTexture(GLenum texture); |
| 152 void attachShader(ScriptState*, WebGLProgram*, WebGLShader*); | 153 void attachShader(ScriptState*, WebGLProgram*, WebGLShader*); |
| 153 void bindAttribLocation(WebGLProgram*, GLuint index, const String& name); | 154 void bindAttribLocation(WebGLProgram*, GLuint index, const String& name); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 friend class WebGLCompressedTextureASTC; | 428 friend class WebGLCompressedTextureASTC; |
| 428 friend class WebGLCompressedTextureATC; | 429 friend class WebGLCompressedTextureATC; |
| 429 friend class WebGLCompressedTextureETC1; | 430 friend class WebGLCompressedTextureETC1; |
| 430 friend class WebGLCompressedTexturePVRTC; | 431 friend class WebGLCompressedTexturePVRTC; |
| 431 friend class WebGLCompressedTextureS3TC; | 432 friend class WebGLCompressedTextureS3TC; |
| 432 friend class WebGLRenderingContextErrorMessageCallback; | 433 friend class WebGLRenderingContextErrorMessageCallback; |
| 433 friend class WebGLVertexArrayObjectBase; | 434 friend class WebGLVertexArrayObjectBase; |
| 434 friend class ScopedTexture2DRestorer; | 435 friend class ScopedTexture2DRestorer; |
| 435 friend class ScopedFramebufferRestorer; | 436 friend class ScopedFramebufferRestorer; |
| 436 | 437 |
| 437 WebGLRenderingContextBase(HTMLCanvasElement*, std::unique_ptr<WebGraphicsCon
text3DProvider>, const WebGLContextAttributes&, unsigned); | 438 WebGLRenderingContextBase(HTMLCanvasElement*, std::unique_ptr<WebGraphicsCon
text3DProvider>, const CanvasContextCreationAttributes&, unsigned); |
| 438 WebGLRenderingContextBase(OffscreenCanvas*, std::unique_ptr<WebGraphicsConte
xt3DProvider>, const WebGLContextAttributes&, unsigned); | 439 WebGLRenderingContextBase(OffscreenCanvas*, std::unique_ptr<WebGraphicsConte
xt3DProvider>, const CanvasContextCreationAttributes&, unsigned); |
| 439 PassRefPtr<DrawingBuffer> createDrawingBuffer(std::unique_ptr<WebGraphicsCon
text3DProvider>); | 440 PassRefPtr<DrawingBuffer> createDrawingBuffer(std::unique_ptr<WebGraphicsCon
text3DProvider>); |
| 440 void setupFlags(); | 441 void setupFlags(); |
| 441 | 442 |
| 442 // CanvasRenderingContext implementation. | 443 // CanvasRenderingContext implementation. |
| 443 bool is3d() const override { return true; } | 444 bool is3d() const override { return true; } |
| 444 bool isAccelerated() const override { return true; } | 445 bool isAccelerated() const override { return true; } |
| 445 void setIsHidden(bool) override; | 446 void setIsHidden(bool) override; |
| 446 bool paintRenderingResultsToCanvas(SourceDrawingBuffer) override; | 447 bool paintRenderingResultsToCanvas(SourceDrawingBuffer) override; |
| 447 WebLayer* platformLayer() const override; | 448 WebLayer* platformLayer() const override; |
| 448 void stop() override; | 449 void stop() override; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 bool m_drawBuffersWebGLRequirementsChecked; | 562 bool m_drawBuffersWebGLRequirementsChecked; |
| 562 bool m_drawBuffersSupported; | 563 bool m_drawBuffersSupported; |
| 563 | 564 |
| 564 GLenum m_readBufferOfDefaultFramebuffer; | 565 GLenum m_readBufferOfDefaultFramebuffer; |
| 565 | 566 |
| 566 GLint m_packAlignment; | 567 GLint m_packAlignment; |
| 567 GLint m_unpackAlignment; | 568 GLint m_unpackAlignment; |
| 568 bool m_unpackFlipY; | 569 bool m_unpackFlipY; |
| 569 bool m_unpackPremultiplyAlpha; | 570 bool m_unpackPremultiplyAlpha; |
| 570 GLenum m_unpackColorspaceConversion; | 571 GLenum m_unpackColorspaceConversion; |
| 571 WebGLContextAttributes m_requestedAttributes; | |
| 572 | 572 |
| 573 GLfloat m_clearColor[4]; | 573 GLfloat m_clearColor[4]; |
| 574 bool m_scissorEnabled; | 574 bool m_scissorEnabled; |
| 575 GLfloat m_clearDepth; | 575 GLfloat m_clearDepth; |
| 576 GLint m_clearStencil; | 576 GLint m_clearStencil; |
| 577 GLboolean m_colorMask[4]; | 577 GLboolean m_colorMask[4]; |
| 578 GLboolean m_depthMask; | 578 GLboolean m_depthMask; |
| 579 | 579 |
| 580 bool m_stencilEnabled; | 580 bool m_stencilEnabled; |
| 581 GLuint m_stencilMask, m_stencilMaskBack; | 581 GLuint m_stencilMask, m_stencilMaskBack; |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 // Helper functions for tex(Sub)Image2D && texSubImage3D | 1104 // Helper functions for tex(Sub)Image2D && texSubImage3D |
| 1105 void texImageHelperDOMArrayBufferView(TexImageFunctionID, GLenum, GLint, GLi
nt, GLsizei, GLsizei, GLint, GLenum, GLenum, GLsizei, GLint, GLint, GLint, DOMAr
rayBufferView*); | 1105 void texImageHelperDOMArrayBufferView(TexImageFunctionID, GLenum, GLint, GLi
nt, GLsizei, GLsizei, GLint, GLenum, GLenum, GLsizei, GLint, GLint, GLint, DOMAr
rayBufferView*); |
| 1106 void texImageHelperImageData(TexImageFunctionID, GLenum, GLint, GLint, GLint
, GLenum, GLenum, GLsizei, GLint, GLint, GLint, ImageData*); | 1106 void texImageHelperImageData(TexImageFunctionID, GLenum, GLint, GLint, GLint
, GLenum, GLenum, GLsizei, GLint, GLint, GLint, ImageData*); |
| 1107 void texImageHelperHTMLImageElement(TexImageFunctionID, GLenum, GLint, GLint
, GLenum, GLenum, GLint, GLint, GLint, HTMLImageElement*, ExceptionState&); | 1107 void texImageHelperHTMLImageElement(TexImageFunctionID, GLenum, GLint, GLint
, GLenum, GLenum, GLint, GLint, GLint, HTMLImageElement*, ExceptionState&); |
| 1108 void texImageHelperHTMLCanvasElement(TexImageFunctionID, GLenum, GLint, GLin
t, GLenum, GLenum, GLint, GLint, GLint, HTMLCanvasElement*, ExceptionState&); | 1108 void texImageHelperHTMLCanvasElement(TexImageFunctionID, GLenum, GLint, GLin
t, GLenum, GLenum, GLint, GLint, GLint, HTMLCanvasElement*, ExceptionState&); |
| 1109 void texImageHelperHTMLVideoElement(TexImageFunctionID, GLenum, GLint, GLint
, GLenum, GLenum, GLint, GLint, GLint, HTMLVideoElement*, ExceptionState&); | 1109 void texImageHelperHTMLVideoElement(TexImageFunctionID, GLenum, GLint, GLint
, GLenum, GLenum, GLint, GLint, GLint, HTMLVideoElement*, ExceptionState&); |
| 1110 void texImageHelperImageBitmap(TexImageFunctionID, GLenum, GLint, GLint, GLe
num, GLenum, GLint, GLint, GLint, ImageBitmap*, ExceptionState&); | 1110 void texImageHelperImageBitmap(TexImageFunctionID, GLenum, GLint, GLint, GLe
num, GLenum, GLint, GLint, GLint, ImageBitmap*, ExceptionState&); |
| 1111 static const char* getTexImageFunctionName(TexImageFunctionID); | 1111 static const char* getTexImageFunctionName(TexImageFunctionID); |
| 1112 | 1112 |
| 1113 private: | 1113 private: |
| 1114 WebGLRenderingContextBase(HTMLCanvasElement*, OffscreenCanvas*, std::unique_
ptr<WebGraphicsContext3DProvider>, const WebGLContextAttributes&, unsigned); | 1114 WebGLRenderingContextBase(HTMLCanvasElement*, OffscreenCanvas*, std::unique_
ptr<WebGraphicsContext3DProvider>, const CanvasContextCreationAttributes&, unsig
ned); |
| 1115 static std::unique_ptr<WebGraphicsContext3DProvider> createContextProviderIn
ternal(HTMLCanvasElement*, ScriptState*, WebGLContextAttributes, unsigned); | 1115 static std::unique_ptr<WebGraphicsContext3DProvider> createContextProviderIn
ternal(HTMLCanvasElement*, ScriptState*, const CanvasContextCreationAttributes&,
unsigned); |
| 1116 void texImageCanvasByGPU(HTMLCanvasElement*, GLuint, GLenum, GLenum, GLint); | 1116 void texImageCanvasByGPU(HTMLCanvasElement*, GLuint, GLenum, GLenum, GLint); |
| 1117 void texImageBitmapByGPU(ImageBitmap*, GLuint, GLenum, GLenum, GLint, bool); | 1117 void texImageBitmapByGPU(ImageBitmap*, GLuint, GLenum, GLenum, GLint, bool); |
| 1118 | 1118 |
| 1119 const unsigned m_version; | 1119 const unsigned m_version; |
| 1120 | 1120 |
| 1121 bool isPaintable() const final { return drawingBuffer(); } | 1121 bool isPaintable() const final { return drawingBuffer(); } |
| 1122 }; | 1122 }; |
| 1123 | 1123 |
| 1124 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co
ntext->is3d(), context.is3d()); | 1124 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co
ntext->is3d(), context.is3d()); |
| 1125 | 1125 |
| 1126 } // namespace blink | 1126 } // namespace blink |
| 1127 | 1127 |
| 1128 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB
ase::TextureUnitState); | 1128 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB
ase::TextureUnitState); |
| 1129 | 1129 |
| 1130 #endif // WebGLRenderingContextBase_h | 1130 #endif // WebGLRenderingContextBase_h |
| OLD | NEW |