OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010, Google Inc. All rights reserved. | 2 * Copyright (c) 2010, Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "platform/TraceEvent.h" | 36 #include "platform/TraceEvent.h" |
37 #include "platform/graphics/GraphicsLayer.h" | 37 #include "platform/graphics/GraphicsLayer.h" |
38 #include "platform/graphics/ImageBuffer.h" | 38 #include "platform/graphics/ImageBuffer.h" |
39 #include "platform/graphics/gpu/Extensions3DUtil.h" | 39 #include "platform/graphics/gpu/Extensions3DUtil.h" |
40 #include "public/platform/Platform.h" | 40 #include "public/platform/Platform.h" |
41 #include "public/platform/WebCompositorSupport.h" | 41 #include "public/platform/WebCompositorSupport.h" |
42 #include "public/platform/WebExternalBitmap.h" | 42 #include "public/platform/WebExternalBitmap.h" |
43 #include "public/platform/WebExternalTextureLayer.h" | 43 #include "public/platform/WebExternalTextureLayer.h" |
44 #include "public/platform/WebGraphicsContext3DProvider.h" | 44 #include "public/platform/WebGraphicsContext3DProvider.h" |
45 #include "wtf/CheckedNumeric.h" | 45 #include "wtf/CheckedNumeric.h" |
46 #include "wtf/PtrUtil.h" | |
47 #include "wtf/typed_arrays/ArrayBufferContents.h" | 46 #include "wtf/typed_arrays/ArrayBufferContents.h" |
48 #include <algorithm> | 47 #include <algorithm> |
49 #include <memory> | |
50 | 48 |
51 namespace blink { | 49 namespace blink { |
52 | 50 |
53 namespace { | 51 namespace { |
54 | 52 |
55 const float s_resourceAdjustedRatio = 0.5; | 53 const float s_resourceAdjustedRatio = 0.5; |
56 | 54 |
57 class ScopedTextureUnit0BindingRestorer { | 55 class ScopedTextureUnit0BindingRestorer { |
58 STACK_ALLOCATED(); | 56 STACK_ALLOCATED(); |
59 WTF_MAKE_NONCOPYABLE(ScopedTextureUnit0BindingRestorer); | 57 WTF_MAKE_NONCOPYABLE(ScopedTextureUnit0BindingRestorer); |
(...skipping 14 matching lines...) Expand all Loading... |
74 private: | 72 private: |
75 gpu::gles2::GLES2Interface* m_gl; | 73 gpu::gles2::GLES2Interface* m_gl; |
76 GLenum m_oldActiveTextureUnit; | 74 GLenum m_oldActiveTextureUnit; |
77 GLuint m_oldTextureUnitZeroId; | 75 GLuint m_oldTextureUnitZeroId; |
78 }; | 76 }; |
79 | 77 |
80 static bool shouldFailDrawingBufferCreationForTesting = false; | 78 static bool shouldFailDrawingBufferCreationForTesting = false; |
81 | 79 |
82 } // namespace | 80 } // namespace |
83 | 81 |
84 PassRefPtr<DrawingBuffer> DrawingBuffer::create(std::unique_ptr<WebGraphicsConte
xt3DProvider> contextProvider, const IntSize& size, bool premultipliedAlpha, boo
l wantAlphaChannel, bool wantDepthBuffer, bool wantStencilBuffer, bool wantAntia
liasing, PreserveDrawingBuffer preserve) | 82 PassRefPtr<DrawingBuffer> DrawingBuffer::create(PassOwnPtr<WebGraphicsContext3DP
rovider> contextProvider, const IntSize& size, bool premultipliedAlpha, bool wan
tAlphaChannel, bool wantDepthBuffer, bool wantStencilBuffer, bool wantAntialiasi
ng, PreserveDrawingBuffer preserve) |
85 { | 83 { |
86 ASSERT(contextProvider); | 84 ASSERT(contextProvider); |
87 | 85 |
88 if (shouldFailDrawingBufferCreationForTesting) { | 86 if (shouldFailDrawingBufferCreationForTesting) { |
89 shouldFailDrawingBufferCreationForTesting = false; | 87 shouldFailDrawingBufferCreationForTesting = false; |
90 return nullptr; | 88 return nullptr; |
91 } | 89 } |
92 | 90 |
93 std::unique_ptr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(
contextProvider->contextGL()); | 91 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(contextPr
ovider->contextGL()); |
94 if (!extensionsUtil->isValid()) { | 92 if (!extensionsUtil->isValid()) { |
95 // This might be the first time we notice that the GL context is lost. | 93 // This might be the first time we notice that the GL context is lost. |
96 return nullptr; | 94 return nullptr; |
97 } | 95 } |
98 ASSERT(extensionsUtil->supportsExtension("GL_OES_packed_depth_stencil")); | 96 ASSERT(extensionsUtil->supportsExtension("GL_OES_packed_depth_stencil")); |
99 extensionsUtil->ensureExtensionEnabled("GL_OES_packed_depth_stencil"); | 97 extensionsUtil->ensureExtensionEnabled("GL_OES_packed_depth_stencil"); |
100 bool multisampleSupported = wantAntialiasing | 98 bool multisampleSupported = wantAntialiasing |
101 && (extensionsUtil->supportsExtension("GL_CHROMIUM_framebuffer_multisamp
le") | 99 && (extensionsUtil->supportsExtension("GL_CHROMIUM_framebuffer_multisamp
le") |
102 || extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_
texture")) | 100 || extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_
texture")) |
103 && extensionsUtil->supportsExtension("GL_OES_rgb8_rgba8"); | 101 && extensionsUtil->supportsExtension("GL_OES_rgb8_rgba8"); |
(...skipping 15 matching lines...) Expand all Loading... |
119 } | 117 } |
120 return drawingBuffer.release(); | 118 return drawingBuffer.release(); |
121 } | 119 } |
122 | 120 |
123 void DrawingBuffer::forceNextDrawingBufferCreationToFail() | 121 void DrawingBuffer::forceNextDrawingBufferCreationToFail() |
124 { | 122 { |
125 shouldFailDrawingBufferCreationForTesting = true; | 123 shouldFailDrawingBufferCreationForTesting = true; |
126 } | 124 } |
127 | 125 |
128 DrawingBuffer::DrawingBuffer( | 126 DrawingBuffer::DrawingBuffer( |
129 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, | 127 PassOwnPtr<WebGraphicsContext3DProvider> contextProvider, |
130 std::unique_ptr<Extensions3DUtil> extensionsUtil, | 128 PassOwnPtr<Extensions3DUtil> extensionsUtil, |
131 bool discardFramebufferSupported, | 129 bool discardFramebufferSupported, |
132 bool wantAlphaChannel, | 130 bool wantAlphaChannel, |
133 bool premultipliedAlpha, | 131 bool premultipliedAlpha, |
134 PreserveDrawingBuffer preserve, | 132 PreserveDrawingBuffer preserve, |
135 bool wantDepth, | 133 bool wantDepth, |
136 bool wantStencil) | 134 bool wantStencil) |
137 : m_preserveDrawingBuffer(preserve) | 135 : m_preserveDrawingBuffer(preserve) |
138 , m_contextProvider(std::move(contextProvider)) | 136 , m_contextProvider(std::move(contextProvider)) |
139 , m_gl(m_contextProvider->contextGL()) | 137 , m_gl(m_contextProvider->contextGL()) |
140 , m_extensionsUtil(std::move(extensionsUtil)) | 138 , m_extensionsUtil(std::move(extensionsUtil)) |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 } | 551 } |
554 | 552 |
555 GLuint DrawingBuffer::framebuffer() const | 553 GLuint DrawingBuffer::framebuffer() const |
556 { | 554 { |
557 return m_fbo; | 555 return m_fbo; |
558 } | 556 } |
559 | 557 |
560 WebLayer* DrawingBuffer::platformLayer() | 558 WebLayer* DrawingBuffer::platformLayer() |
561 { | 559 { |
562 if (!m_layer) { | 560 if (!m_layer) { |
563 m_layer = wrapUnique(Platform::current()->compositorSupport()->createExt
ernalTextureLayer(this)); | 561 m_layer = adoptPtr(Platform::current()->compositorSupport()->createExter
nalTextureLayer(this)); |
564 | 562 |
565 m_layer->setOpaque(!m_wantAlphaChannel); | 563 m_layer->setOpaque(!m_wantAlphaChannel); |
566 m_layer->setBlendBackgroundColor(m_wantAlphaChannel); | 564 m_layer->setBlendBackgroundColor(m_wantAlphaChannel); |
567 m_layer->setPremultipliedAlpha(m_premultipliedAlpha); | 565 m_layer->setPremultipliedAlpha(m_premultipliedAlpha); |
568 m_layer->setNearestNeighbor(m_filterQuality == kNone_SkFilterQuality); | 566 m_layer->setNearestNeighbor(m_filterQuality == kNone_SkFilterQuality); |
569 GraphicsLayer::registerContentsLayer(m_layer->layer()); | 567 GraphicsLayer::registerContentsLayer(m_layer->layer()); |
570 } | 568 } |
571 | 569 |
572 return m_layer->layer(); | 570 return m_layer->layer(); |
573 } | 571 } |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 | 1077 |
1080 void DrawingBuffer::restoreTextureBindings() | 1078 void DrawingBuffer::restoreTextureBindings() |
1081 { | 1079 { |
1082 // This class potentially modifies the bindings for GL_TEXTURE_2D and | 1080 // This class potentially modifies the bindings for GL_TEXTURE_2D and |
1083 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since | 1081 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since |
1084 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. | 1082 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. |
1085 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); | 1083 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); |
1086 } | 1084 } |
1087 | 1085 |
1088 } // namespace blink | 1086 } // namespace blink |
OLD | NEW |