| 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 30 matching lines...) Expand all Loading... |
| 41 #include "modules/webgl/WebGLTexture.h" | 41 #include "modules/webgl/WebGLTexture.h" |
| 42 #include "modules/webgl/WebGLVertexArrayObjectBase.h" | 42 #include "modules/webgl/WebGLVertexArrayObjectBase.h" |
| 43 #include "platform/Timer.h" | 43 #include "platform/Timer.h" |
| 44 #include "platform/graphics/ImageBuffer.h" | 44 #include "platform/graphics/ImageBuffer.h" |
| 45 #include "platform/graphics/gpu/DrawingBuffer.h" | 45 #include "platform/graphics/gpu/DrawingBuffer.h" |
| 46 #include "platform/graphics/gpu/Extensions3DUtil.h" | 46 #include "platform/graphics/gpu/Extensions3DUtil.h" |
| 47 #include "platform/graphics/gpu/WebGLImageConversion.h" | 47 #include "platform/graphics/gpu/WebGLImageConversion.h" |
| 48 #include "public/platform/Platform.h" | 48 #include "public/platform/Platform.h" |
| 49 #include "public/platform/WebGraphicsContext3DProvider.h" | 49 #include "public/platform/WebGraphicsContext3DProvider.h" |
| 50 #include "third_party/khronos/GLES2/gl2.h" | 50 #include "third_party/khronos/GLES2/gl2.h" |
| 51 #include "wtf/OwnPtr.h" |
| 51 #include "wtf/text/WTFString.h" | 52 #include "wtf/text/WTFString.h" |
| 52 #include <memory> | 53 |
| 53 #include <set> | 54 #include <set> |
| 54 | 55 |
| 55 namespace blink { | 56 namespace blink { |
| 56 class WebLayer; | 57 class WebLayer; |
| 57 } | 58 } |
| 58 | 59 |
| 59 namespace gpu { | 60 namespace gpu { |
| 60 namespace gles2 { | 61 namespace gles2 { |
| 61 class GLES2Interface; | 62 class GLES2Interface; |
| 62 } | 63 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 ~WebGLRenderingContextBase() override; | 133 ~WebGLRenderingContextBase() override; |
| 133 | 134 |
| 134 virtual unsigned version() const = 0; | 135 virtual unsigned version() const = 0; |
| 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 PassOwnPtr<WebGraphicsContext3DProvider> createWebGraphicsContext3DPr
ovider(HTMLCanvasElement*, WebGLContextAttributes, unsigned webGLVersion); |
| 143 static std::unique_ptr<WebGraphicsContext3DProvider> createWebGraphicsContex
t3DProvider(ScriptState*, WebGLContextAttributes, unsigned webGLVersion); | 144 static PassOwnPtr<WebGraphicsContext3DProvider> createWebGraphicsContext3DPr
ovider(ScriptState*, WebGLContextAttributes, unsigned webGLVersion); |
| 144 static void forceNextWebGLContextCreationToFail(); | 145 static void forceNextWebGLContextCreationToFail(); |
| 145 | 146 |
| 146 int drawingBufferWidth() const; | 147 int drawingBufferWidth() const; |
| 147 int drawingBufferHeight() const; | 148 int drawingBufferHeight() const; |
| 148 | 149 |
| 149 void activeTexture(GLenum texture); | 150 void activeTexture(GLenum texture); |
| 150 void attachShader(ScriptState*, WebGLProgram*, WebGLShader*); | 151 void attachShader(ScriptState*, WebGLProgram*, WebGLShader*); |
| 151 void bindAttribLocation(WebGLProgram*, GLuint index, const String& name); | 152 void bindAttribLocation(WebGLProgram*, GLuint index, const String& name); |
| 152 void bindBuffer(ScriptState*, GLenum target, WebGLBuffer*); | 153 void bindBuffer(ScriptState*, GLenum target, WebGLBuffer*); |
| 153 virtual void bindFramebuffer(ScriptState*, GLenum target, WebGLFramebuffer*)
; | 154 virtual void bindFramebuffer(ScriptState*, GLenum target, WebGLFramebuffer*)
; |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 friend class WebGLCompressedTextureASTC; | 424 friend class WebGLCompressedTextureASTC; |
| 424 friend class WebGLCompressedTextureATC; | 425 friend class WebGLCompressedTextureATC; |
| 425 friend class WebGLCompressedTextureETC1; | 426 friend class WebGLCompressedTextureETC1; |
| 426 friend class WebGLCompressedTexturePVRTC; | 427 friend class WebGLCompressedTexturePVRTC; |
| 427 friend class WebGLCompressedTextureS3TC; | 428 friend class WebGLCompressedTextureS3TC; |
| 428 friend class WebGLRenderingContextErrorMessageCallback; | 429 friend class WebGLRenderingContextErrorMessageCallback; |
| 429 friend class WebGLVertexArrayObjectBase; | 430 friend class WebGLVertexArrayObjectBase; |
| 430 friend class ScopedTexture2DRestorer; | 431 friend class ScopedTexture2DRestorer; |
| 431 friend class ScopedFramebufferRestorer; | 432 friend class ScopedFramebufferRestorer; |
| 432 | 433 |
| 433 WebGLRenderingContextBase(HTMLCanvasElement*, std::unique_ptr<WebGraphicsCon
text3DProvider>, const WebGLContextAttributes&); | 434 WebGLRenderingContextBase(HTMLCanvasElement*, PassOwnPtr<WebGraphicsContext3
DProvider>, const WebGLContextAttributes&); |
| 434 WebGLRenderingContextBase(OffscreenCanvas*, std::unique_ptr<WebGraphicsConte
xt3DProvider>, const WebGLContextAttributes&); | 435 WebGLRenderingContextBase(OffscreenCanvas*, PassOwnPtr<WebGraphicsContext3DP
rovider>, const WebGLContextAttributes&); |
| 435 PassRefPtr<DrawingBuffer> createDrawingBuffer(std::unique_ptr<WebGraphicsCon
text3DProvider>); | 436 PassRefPtr<DrawingBuffer> createDrawingBuffer(PassOwnPtr<WebGraphicsContext3
DProvider>); |
| 436 void setupFlags(); | 437 void setupFlags(); |
| 437 | 438 |
| 438 // CanvasRenderingContext implementation. | 439 // CanvasRenderingContext implementation. |
| 439 bool is3d() const override { return true; } | 440 bool is3d() const override { return true; } |
| 440 bool isAccelerated() const override { return true; } | 441 bool isAccelerated() const override { return true; } |
| 441 void setIsHidden(bool) override; | 442 void setIsHidden(bool) override; |
| 442 bool paintRenderingResultsToCanvas(SourceDrawingBuffer) override; | 443 bool paintRenderingResultsToCanvas(SourceDrawingBuffer) override; |
| 443 WebLayer* platformLayer() const override; | 444 WebLayer* platformLayer() const override; |
| 444 void stop() override; | 445 void stop() override; |
| 445 | 446 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 Vector<GLenum> m_compressedTextureFormats; | 530 Vector<GLenum> m_compressedTextureFormats; |
| 530 | 531 |
| 531 // Fixed-size cache of reusable image buffers for video texImage2D calls. | 532 // Fixed-size cache of reusable image buffers for video texImage2D calls. |
| 532 class LRUImageBufferCache { | 533 class LRUImageBufferCache { |
| 533 public: | 534 public: |
| 534 LRUImageBufferCache(int capacity); | 535 LRUImageBufferCache(int capacity); |
| 535 // The pointer returned is owned by the image buffer map. | 536 // The pointer returned is owned by the image buffer map. |
| 536 ImageBuffer* imageBuffer(const IntSize&); | 537 ImageBuffer* imageBuffer(const IntSize&); |
| 537 private: | 538 private: |
| 538 void bubbleToFront(int idx); | 539 void bubbleToFront(int idx); |
| 539 std::unique_ptr<std::unique_ptr<ImageBuffer>[]> m_buffers; | 540 OwnPtr<OwnPtr<ImageBuffer>[]> m_buffers; |
| 540 int m_capacity; | 541 int m_capacity; |
| 541 }; | 542 }; |
| 542 LRUImageBufferCache m_generatedImageCache; | 543 LRUImageBufferCache m_generatedImageCache; |
| 543 | 544 |
| 544 GLint m_maxTextureSize; | 545 GLint m_maxTextureSize; |
| 545 GLint m_maxCubeMapTextureSize; | 546 GLint m_maxCubeMapTextureSize; |
| 546 GLint m_max3DTextureSize; | 547 GLint m_max3DTextureSize; |
| 547 GLint m_maxArrayTextureLayers; | 548 GLint m_maxArrayTextureLayers; |
| 548 GLint m_maxRenderbufferSize; | 549 GLint m_maxRenderbufferSize; |
| 549 GLint m_maxViewportDims[2]; | 550 GLint m_maxViewportDims[2]; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 578 GLint m_stencilFuncRef, m_stencilFuncRefBack; // Note that these are the use
r specified values, not the internal clamped value. | 579 GLint m_stencilFuncRef, m_stencilFuncRefBack; // Note that these are the use
r specified values, not the internal clamped value. |
| 579 GLuint m_stencilFuncMask, m_stencilFuncMaskBack; | 580 GLuint m_stencilFuncMask, m_stencilFuncMaskBack; |
| 580 | 581 |
| 581 bool m_isDepthStencilSupported; | 582 bool m_isDepthStencilSupported; |
| 582 | 583 |
| 583 bool m_synthesizedErrorsToConsole; | 584 bool m_synthesizedErrorsToConsole; |
| 584 int m_numGLErrorsToConsoleAllowed; | 585 int m_numGLErrorsToConsoleAllowed; |
| 585 | 586 |
| 586 unsigned long m_onePlusMaxNonDefaultTextureUnit; | 587 unsigned long m_onePlusMaxNonDefaultTextureUnit; |
| 587 | 588 |
| 588 std::unique_ptr<Extensions3DUtil> m_extensionsUtil; | 589 OwnPtr<Extensions3DUtil> m_extensionsUtil; |
| 589 | 590 |
| 590 enum ExtensionFlags { | 591 enum ExtensionFlags { |
| 591 ApprovedExtension = 0x00, | 592 ApprovedExtension = 0x00, |
| 592 // Extension that is behind the draft extensions runtime flag: | 593 // Extension that is behind the draft extensions runtime flag: |
| 593 DraftExtension = 0x01, | 594 DraftExtension = 0x01, |
| 594 }; | 595 }; |
| 595 | 596 |
| 596 class ExtensionTracker : public GarbageCollected<ExtensionTracker> { | 597 class ExtensionTracker : public GarbageCollected<ExtensionTracker> { |
| 597 public: | 598 public: |
| 598 ExtensionTracker(ExtensionFlags flags, const char* const* prefixes) | 599 ExtensionTracker(ExtensionFlags flags, const char* const* prefixes) |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 // Helper functions for tex(Sub)Image2D && texSubImage3D | 1097 // Helper functions for tex(Sub)Image2D && texSubImage3D |
| 1097 void texImageHelperDOMArrayBufferView(TexImageFunctionID, GLenum, GLint, GLi
nt, GLsizei, GLsizei, GLint, GLenum, GLenum, GLsizei, GLint, GLint, GLint, DOMAr
rayBufferView*); | 1098 void texImageHelperDOMArrayBufferView(TexImageFunctionID, GLenum, GLint, GLi
nt, GLsizei, GLsizei, GLint, GLenum, GLenum, GLsizei, GLint, GLint, GLint, DOMAr
rayBufferView*); |
| 1098 void texImageHelperImageData(TexImageFunctionID, GLenum, GLint, GLint, GLint
, GLenum, GLenum, GLsizei, GLint, GLint, GLint, ImageData*); | 1099 void texImageHelperImageData(TexImageFunctionID, GLenum, GLint, GLint, GLint
, GLenum, GLenum, GLsizei, GLint, GLint, GLint, ImageData*); |
| 1099 void texImageHelperHTMLImageElement(TexImageFunctionID, GLenum, GLint, GLint
, GLenum, GLenum, GLint, GLint, GLint, HTMLImageElement*, ExceptionState&); | 1100 void texImageHelperHTMLImageElement(TexImageFunctionID, GLenum, GLint, GLint
, GLenum, GLenum, GLint, GLint, GLint, HTMLImageElement*, ExceptionState&); |
| 1100 void texImageHelperHTMLCanvasElement(TexImageFunctionID, GLenum, GLint, GLin
t, GLenum, GLenum, GLint, GLint, GLint, HTMLCanvasElement*, ExceptionState&); | 1101 void texImageHelperHTMLCanvasElement(TexImageFunctionID, GLenum, GLint, GLin
t, GLenum, GLenum, GLint, GLint, GLint, HTMLCanvasElement*, ExceptionState&); |
| 1101 void texImageHelperHTMLVideoElement(TexImageFunctionID, GLenum, GLint, GLint
, GLenum, GLenum, GLint, GLint, GLint, HTMLVideoElement*, ExceptionState&); | 1102 void texImageHelperHTMLVideoElement(TexImageFunctionID, GLenum, GLint, GLint
, GLenum, GLenum, GLint, GLint, GLint, HTMLVideoElement*, ExceptionState&); |
| 1102 void texImageHelperImageBitmap(TexImageFunctionID, GLenum, GLint, GLint, GLe
num, GLenum, GLint, GLint, GLint, ImageBitmap*, ExceptionState&); | 1103 void texImageHelperImageBitmap(TexImageFunctionID, GLenum, GLint, GLint, GLe
num, GLenum, GLint, GLint, GLint, ImageBitmap*, ExceptionState&); |
| 1103 static const char* getTexImageFunctionName(TexImageFunctionID); | 1104 static const char* getTexImageFunctionName(TexImageFunctionID); |
| 1104 | 1105 |
| 1105 private: | 1106 private: |
| 1106 WebGLRenderingContextBase(HTMLCanvasElement*, OffscreenCanvas*, std::unique_
ptr<WebGraphicsContext3DProvider>, const WebGLContextAttributes&); | 1107 WebGLRenderingContextBase(HTMLCanvasElement*, OffscreenCanvas*, PassOwnPtr<W
ebGraphicsContext3DProvider>, const WebGLContextAttributes&); |
| 1107 static std::unique_ptr<WebGraphicsContext3DProvider> createContextProviderIn
ternal(HTMLCanvasElement*, ScriptState*, WebGLContextAttributes, unsigned); | 1108 static PassOwnPtr<WebGraphicsContext3DProvider> createContextProviderInterna
l(HTMLCanvasElement*, ScriptState*, WebGLContextAttributes, unsigned); |
| 1108 }; | 1109 }; |
| 1109 | 1110 |
| 1110 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co
ntext->is3d(), context.is3d()); | 1111 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co
ntext->is3d(), context.is3d()); |
| 1111 | 1112 |
| 1112 } // namespace blink | 1113 } // namespace blink |
| 1113 | 1114 |
| 1114 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB
ase::TextureUnitState); | 1115 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB
ase::TextureUnitState); |
| 1115 | 1116 |
| 1116 #endif // WebGLRenderingContextBase_h | 1117 #endif // WebGLRenderingContextBase_h |
| OLD | NEW |