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