| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 GLboolean* colorMask, | 125 GLboolean* colorMask, |
| 126 DrawingBuffer*); | 126 DrawingBuffer*); |
| 127 ~ScopedRGBEmulationColorMask(); | 127 ~ScopedRGBEmulationColorMask(); |
| 128 | 128 |
| 129 private: | 129 private: |
| 130 gpu::gles2::GLES2Interface* m_contextGL; | 130 gpu::gles2::GLES2Interface* m_contextGL; |
| 131 GLboolean m_colorMask[4]; | 131 GLboolean m_colorMask[4]; |
| 132 const bool m_requiresEmulation; | 132 const bool m_requiresEmulation; |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext { | 135 class MODULES_EXPORT WebGLRenderingContextBase |
| 136 : public CanvasRenderingContext, |
| 137 public DrawingBufferStateTracker { |
| 136 WTF_MAKE_NONCOPYABLE(WebGLRenderingContextBase); | 138 WTF_MAKE_NONCOPYABLE(WebGLRenderingContextBase); |
| 137 | 139 |
| 138 public: | 140 public: |
| 139 ~WebGLRenderingContextBase() override; | 141 ~WebGLRenderingContextBase() override; |
| 140 | 142 |
| 141 virtual String contextName() const = 0; | 143 virtual String contextName() const = 0; |
| 142 virtual void registerContextExtensions() = 0; | 144 virtual void registerContextExtensions() = 0; |
| 143 | 145 |
| 144 virtual void initializeNewContext(); | 146 virtual void initializeNewContext(); |
| 145 | 147 |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 void forceLostContext(LostContextMode, AutoRecoveryMethod); | 540 void forceLostContext(LostContextMode, AutoRecoveryMethod); |
| 539 void forceRestoreContext(); | 541 void forceRestoreContext(); |
| 540 void loseContextImpl(LostContextMode, AutoRecoveryMethod); | 542 void loseContextImpl(LostContextMode, AutoRecoveryMethod); |
| 541 | 543 |
| 542 // Utilities to restore GL state to match the rendering context's | 544 // Utilities to restore GL state to match the rendering context's |
| 543 // saved state. Use these after contextGL()-based state changes that | 545 // saved state. Use these after contextGL()-based state changes that |
| 544 // bypass the rendering context. | 546 // bypass the rendering context. |
| 545 void restoreScissorEnabled(); | 547 void restoreScissorEnabled(); |
| 546 void restoreScissorBox(); | 548 void restoreScissorBox(); |
| 547 void restoreClearColor(); | 549 void restoreClearColor(); |
| 548 void restoreClearDepthf(); | |
| 549 void restoreClearStencil(); | |
| 550 void restoreStencilMaskSeparate(); | |
| 551 void restoreColorMask(); | 550 void restoreColorMask(); |
| 552 void restoreDepthMask(); | |
| 553 | 551 |
| 554 gpu::gles2::GLES2Interface* contextGL() const { | 552 gpu::gles2::GLES2Interface* contextGL() const { |
| 555 DrawingBuffer* d = drawingBuffer(); | 553 DrawingBuffer* d = drawingBuffer(); |
| 556 if (!d) | 554 if (!d) |
| 557 return nullptr; | 555 return nullptr; |
| 558 return d->contextGL(); | 556 return d->contextGL(); |
| 559 } | 557 } |
| 560 WebGLContextGroup* contextGroup() const { return m_contextGroup.get(); } | 558 WebGLContextGroup* contextGroup() const { return m_contextGroup.get(); } |
| 561 Extensions3DUtil* extensionsUtil(); | 559 Extensions3DUtil* extensionsUtil(); |
| 562 | 560 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 friend class WebGLDebugShaders; | 608 friend class WebGLDebugShaders; |
| 611 friend class WebGLCompressedTextureASTC; | 609 friend class WebGLCompressedTextureASTC; |
| 612 friend class WebGLCompressedTextureATC; | 610 friend class WebGLCompressedTextureATC; |
| 613 friend class WebGLCompressedTextureES30; | 611 friend class WebGLCompressedTextureES30; |
| 614 friend class WebGLCompressedTextureETC1; | 612 friend class WebGLCompressedTextureETC1; |
| 615 friend class WebGLCompressedTexturePVRTC; | 613 friend class WebGLCompressedTexturePVRTC; |
| 616 friend class WebGLCompressedTextureS3TC; | 614 friend class WebGLCompressedTextureS3TC; |
| 617 friend class WebGLCompressedTextureS3TCsRGB; | 615 friend class WebGLCompressedTextureS3TCsRGB; |
| 618 friend class WebGLRenderingContextErrorMessageCallback; | 616 friend class WebGLRenderingContextErrorMessageCallback; |
| 619 friend class WebGLVertexArrayObjectBase; | 617 friend class WebGLVertexArrayObjectBase; |
| 618 friend class ScopedDrawingBufferBinder; |
| 620 friend class ScopedTexture2DRestorer; | 619 friend class ScopedTexture2DRestorer; |
| 621 friend class ScopedFramebufferRestorer; | 620 friend class ScopedFramebufferRestorer; |
| 622 // To allow V8WebGL[2]RenderingContext to call visitChildDOMWrappers. | 621 // To allow V8WebGL[2]RenderingContext to call visitChildDOMWrappers. |
| 623 friend class V8WebGLRenderingContext; | 622 friend class V8WebGLRenderingContext; |
| 624 | 623 |
| 625 WebGLRenderingContextBase(HTMLCanvasElement*, | 624 WebGLRenderingContextBase(HTMLCanvasElement*, |
| 626 std::unique_ptr<WebGraphicsContext3DProvider>, | 625 std::unique_ptr<WebGraphicsContext3DProvider>, |
| 627 const CanvasContextCreationAttributes&, | 626 const CanvasContextCreationAttributes&, |
| 628 unsigned); | 627 unsigned); |
| 629 WebGLRenderingContextBase(OffscreenCanvas*, | 628 WebGLRenderingContextBase(OffscreenCanvas*, |
| 630 std::unique_ptr<WebGraphicsContext3DProvider>, | 629 std::unique_ptr<WebGraphicsContext3DProvider>, |
| 631 const CanvasContextCreationAttributes&, | 630 const CanvasContextCreationAttributes&, |
| 632 unsigned); | 631 unsigned); |
| 633 PassRefPtr<DrawingBuffer> createDrawingBuffer( | 632 PassRefPtr<DrawingBuffer> createDrawingBuffer( |
| 634 std::unique_ptr<WebGraphicsContext3DProvider>, | 633 std::unique_ptr<WebGraphicsContext3DProvider>, |
| 635 DrawingBuffer::ChromiumImageUsage); | 634 DrawingBuffer::ChromiumImageUsage); |
| 636 void setupFlags(); | 635 void setupFlags(); |
| 637 | 636 |
| 638 // CanvasRenderingContext implementation. | 637 // CanvasRenderingContext implementation. |
| 639 bool is3d() const override { return true; } | 638 bool is3d() const override { return true; } |
| 640 bool isAccelerated() const override { return true; } | 639 bool isAccelerated() const override { return true; } |
| 641 void setIsHidden(bool) override; | 640 void setIsHidden(bool) override; |
| 642 bool paintRenderingResultsToCanvas(SourceDrawingBuffer) override; | 641 bool paintRenderingResultsToCanvas(SourceDrawingBuffer) override; |
| 643 WebLayer* platformLayer() const override; | 642 WebLayer* platformLayer() const override; |
| 644 void stop() override; | 643 void stop() override; |
| 645 | 644 |
| 645 // DrawingBufferRestoreStateSource implementation. |
| 646 void GetDrawingBufferRestoreState(DrawingBufferRestoreState*) override; |
| 647 |
| 646 void addSharedObject(WebGLSharedObject*); | 648 void addSharedObject(WebGLSharedObject*); |
| 647 void addContextObject(WebGLContextObject*); | 649 void addContextObject(WebGLContextObject*); |
| 648 void detachAndRemoveAllObjects(); | 650 void detachAndRemoveAllObjects(); |
| 649 | 651 |
| 650 void destroyContext(); | 652 void destroyContext(); |
| 651 void markContextChanged(ContentChangeType); | 653 void markContextChanged(ContentChangeType); |
| 652 | 654 |
| 653 void onErrorMessage(const char*, int32_t id); | 655 void onErrorMessage(const char*, int32_t id); |
| 654 | 656 |
| 655 void notifyCanvasContextChanged(); | 657 void notifyCanvasContextChanged(); |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 class ScopedDrawingBufferBinder { | 908 class ScopedDrawingBufferBinder { |
| 907 STACK_ALLOCATED(); | 909 STACK_ALLOCATED(); |
| 908 | 910 |
| 909 public: | 911 public: |
| 910 ScopedDrawingBufferBinder(DrawingBuffer* drawingBuffer, | 912 ScopedDrawingBufferBinder(DrawingBuffer* drawingBuffer, |
| 911 WebGLFramebuffer* framebufferBinding) | 913 WebGLFramebuffer* framebufferBinding) |
| 912 : m_drawingBuffer(drawingBuffer), | 914 : m_drawingBuffer(drawingBuffer), |
| 913 m_readFramebufferBinding(framebufferBinding) { | 915 m_readFramebufferBinding(framebufferBinding) { |
| 914 // Commit DrawingBuffer if needed (e.g., for multisampling) | 916 // Commit DrawingBuffer if needed (e.g., for multisampling) |
| 915 if (!m_readFramebufferBinding && m_drawingBuffer) | 917 if (!m_readFramebufferBinding && m_drawingBuffer) |
| 916 m_drawingBuffer->commit(); | 918 m_drawingBuffer->resolveAndBindForReadAndDraw(); |
| 917 } | 919 } |
| 918 | 920 |
| 919 ~ScopedDrawingBufferBinder() { | 921 ~ScopedDrawingBufferBinder() { |
| 920 // Restore DrawingBuffer if needed | 922 // Restore DrawingBuffer if needed |
| 921 if (!m_readFramebufferBinding && m_drawingBuffer) | 923 if (!m_readFramebufferBinding && m_drawingBuffer) |
| 922 m_drawingBuffer->restoreFramebufferBindings(); | 924 m_drawingBuffer->restoreFramebufferBindings(); |
| 923 } | 925 } |
| 924 | 926 |
| 925 private: | 927 private: |
| 926 DrawingBuffer* m_drawingBuffer; | 928 DrawingBuffer* m_drawingBuffer; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 // Skip clearing the backbuffer. | 968 // Skip clearing the backbuffer. |
| 967 Skipped, | 969 Skipped, |
| 968 // Clear the backbuffer. | 970 // Clear the backbuffer. |
| 969 JustClear, | 971 JustClear, |
| 970 // Combine webgl.clear() API with the backbuffer clear, so webgl.clear() | 972 // Combine webgl.clear() API with the backbuffer clear, so webgl.clear() |
| 971 // doesn't have to call glClear() again. | 973 // doesn't have to call glClear() again. |
| 972 CombinedClear | 974 CombinedClear |
| 973 }; | 975 }; |
| 974 HowToClear clearIfComposited(GLbitfield clearMask = 0); | 976 HowToClear clearIfComposited(GLbitfield clearMask = 0); |
| 975 | 977 |
| 976 // Helper to restore state that clearing the framebuffer may destroy. | |
| 977 void restoreStateAfterClear(); | |
| 978 | |
| 979 // Convert texture internal format. | 978 // Convert texture internal format. |
| 980 GLenum convertTexInternalFormat(GLenum internalformat, GLenum type); | 979 GLenum convertTexInternalFormat(GLenum internalformat, GLenum type); |
| 981 | 980 |
| 982 enum TexImageFunctionType { | 981 enum TexImageFunctionType { |
| 983 TexImage, | 982 TexImage, |
| 984 TexSubImage, | 983 TexSubImage, |
| 985 CopyTexImage, | 984 CopyTexImage, |
| 986 CompressedTexImage | 985 CompressedTexImage |
| 987 }; | 986 }; |
| 988 enum TexImageFunctionID { | 987 enum TexImageFunctionID { |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1548 context, | 1547 context, |
| 1549 context->is3d(), | 1548 context->is3d(), |
| 1550 context.is3d()); | 1549 context.is3d()); |
| 1551 | 1550 |
| 1552 } // namespace blink | 1551 } // namespace blink |
| 1553 | 1552 |
| 1554 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS( | 1553 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS( |
| 1555 blink::WebGLRenderingContextBase::TextureUnitState); | 1554 blink::WebGLRenderingContextBase::TextureUnitState); |
| 1556 | 1555 |
| 1557 #endif // WebGLRenderingContextBase_h | 1556 #endif // WebGLRenderingContextBase_h |
| OLD | NEW |