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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 Client* client, | 71 Client* client, |
72 const IntSize& size, | 72 const IntSize& size, |
73 bool premultipliedAlpha, | 73 bool premultipliedAlpha, |
74 bool wantAlphaChannel, | 74 bool wantAlphaChannel, |
75 bool wantDepthBuffer, | 75 bool wantDepthBuffer, |
76 bool wantStencilBuffer, | 76 bool wantStencilBuffer, |
77 bool wantAntialiasing, | 77 bool wantAntialiasing, |
78 PreserveDrawingBuffer preserve, | 78 PreserveDrawingBuffer preserve, |
79 WebGLVersion webGLVersion, | 79 WebGLVersion webGLVersion, |
80 ChromiumImageUsage chromiumImageUsage) { | 80 ChromiumImageUsage chromiumImageUsage) { |
81 ASSERT(contextProvider); | 81 DCHECK(contextProvider); |
82 | 82 |
83 if (shouldFailDrawingBufferCreationForTesting) { | 83 if (shouldFailDrawingBufferCreationForTesting) { |
84 shouldFailDrawingBufferCreationForTesting = false; | 84 shouldFailDrawingBufferCreationForTesting = false; |
85 return nullptr; | 85 return nullptr; |
86 } | 86 } |
87 | 87 |
88 std::unique_ptr<Extensions3DUtil> extensionsUtil = | 88 std::unique_ptr<Extensions3DUtil> extensionsUtil = |
89 Extensions3DUtil::create(contextProvider->contextGL()); | 89 Extensions3DUtil::create(contextProvider->contextGL()); |
90 if (!extensionsUtil->isValid()) { | 90 if (!extensionsUtil->isValid()) { |
91 // This might be the first time we notice that the GL context is lost. | 91 // This might be the first time we notice that the GL context is lost. |
92 return nullptr; | 92 return nullptr; |
93 } | 93 } |
94 ASSERT(extensionsUtil->supportsExtension("GL_OES_packed_depth_stencil")); | 94 DCHECK(extensionsUtil->supportsExtension("GL_OES_packed_depth_stencil")); |
95 extensionsUtil->ensureExtensionEnabled("GL_OES_packed_depth_stencil"); | 95 extensionsUtil->ensureExtensionEnabled("GL_OES_packed_depth_stencil"); |
96 bool multisampleSupported = | 96 bool multisampleSupported = |
97 wantAntialiasing && (extensionsUtil->supportsExtension( | 97 wantAntialiasing && (extensionsUtil->supportsExtension( |
98 "GL_CHROMIUM_framebuffer_multisample") || | 98 "GL_CHROMIUM_framebuffer_multisample") || |
99 extensionsUtil->supportsExtension( | 99 extensionsUtil->supportsExtension( |
100 "GL_EXT_multisampled_render_to_texture")) && | 100 "GL_EXT_multisampled_render_to_texture")) && |
101 extensionsUtil->supportsExtension("GL_OES_rgb8_rgba8"); | 101 extensionsUtil->supportsExtension("GL_OES_rgb8_rgba8"); |
102 if (multisampleSupported) { | 102 if (multisampleSupported) { |
103 extensionsUtil->ensureExtensionEnabled("GL_OES_rgb8_rgba8"); | 103 extensionsUtil->ensureExtensionEnabled("GL_OES_rgb8_rgba8"); |
104 if (extensionsUtil->supportsExtension( | 104 if (extensionsUtil->supportsExtension( |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 } | 178 } |
179 | 179 |
180 bool DrawingBuffer::bufferClearNeeded() const { | 180 bool DrawingBuffer::bufferClearNeeded() const { |
181 return m_bufferClearNeeded; | 181 return m_bufferClearNeeded; |
182 } | 182 } |
183 | 183 |
184 void DrawingBuffer::setBufferClearNeeded(bool flag) { | 184 void DrawingBuffer::setBufferClearNeeded(bool flag) { |
185 if (m_preserveDrawingBuffer == Discard) { | 185 if (m_preserveDrawingBuffer == Discard) { |
186 m_bufferClearNeeded = flag; | 186 m_bufferClearNeeded = flag; |
187 } else { | 187 } else { |
188 ASSERT(!m_bufferClearNeeded); | 188 DCHECK(!m_bufferClearNeeded); |
189 } | 189 } |
190 } | 190 } |
191 | 191 |
192 gpu::gles2::GLES2Interface* DrawingBuffer::contextGL() { | 192 gpu::gles2::GLES2Interface* DrawingBuffer::contextGL() { |
193 return m_gl; | 193 return m_gl; |
194 } | 194 } |
195 | 195 |
196 WebGraphicsContext3DProvider* DrawingBuffer::contextProvider() { | 196 WebGraphicsContext3DProvider* DrawingBuffer::contextProvider() { |
197 return m_contextProvider->contextProvider(); | 197 return m_contextProvider->contextProvider(); |
198 } | 198 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 bool forceGpuResult) { | 262 bool forceGpuResult) { |
263 DCHECK(m_stateRestorer); | 263 DCHECK(m_stateRestorer); |
264 if (m_destructionInProgress) { | 264 if (m_destructionInProgress) { |
265 // It can be hit in the following sequence. | 265 // It can be hit in the following sequence. |
266 // 1. WebGL draws something. | 266 // 1. WebGL draws something. |
267 // 2. The compositor begins the frame. | 267 // 2. The compositor begins the frame. |
268 // 3. Javascript makes a context lost using WEBGL_lose_context extension. | 268 // 3. Javascript makes a context lost using WEBGL_lose_context extension. |
269 // 4. Here. | 269 // 4. Here. |
270 return false; | 270 return false; |
271 } | 271 } |
272 ASSERT(!m_isHidden); | 272 DCHECK(!m_isHidden); |
273 if (!m_contentsChanged) | 273 if (!m_contentsChanged) |
274 return false; | 274 return false; |
275 | 275 |
276 // If the context is lost, we don't know if we should be producing GPU or | 276 // If the context is lost, we don't know if we should be producing GPU or |
277 // software frames, until we get a new context, since the compositor will | 277 // software frames, until we get a new context, since the compositor will |
278 // be trying to get a new context and may change modes. | 278 // be trying to get a new context and may change modes. |
279 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) | 279 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) |
280 return false; | 280 return false; |
281 | 281 |
282 TRACE_EVENT0("blink,rail", "DrawingBuffer::prepareMailbox"); | 282 TRACE_EVENT0("blink,rail", "DrawingBuffer::prepareMailbox"); |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 } | 774 } |
775 | 775 |
776 void DrawingBuffer::clearPlatformLayer() { | 776 void DrawingBuffer::clearPlatformLayer() { |
777 if (m_layer) | 777 if (m_layer) |
778 m_layer->clearTexture(); | 778 m_layer->clearTexture(); |
779 | 779 |
780 m_gl->Flush(); | 780 m_gl->Flush(); |
781 } | 781 } |
782 | 782 |
783 void DrawingBuffer::beginDestruction() { | 783 void DrawingBuffer::beginDestruction() { |
784 ASSERT(!m_destructionInProgress); | 784 DCHECK(!m_destructionInProgress); |
785 m_destructionInProgress = true; | 785 m_destructionInProgress = true; |
786 | 786 |
787 clearPlatformLayer(); | 787 clearPlatformLayer(); |
788 m_recycledColorBufferQueue.clear(); | 788 m_recycledColorBufferQueue.clear(); |
789 | 789 |
790 if (m_multisampleFBO) | 790 if (m_multisampleFBO) |
791 m_gl->DeleteFramebuffers(1, &m_multisampleFBO); | 791 m_gl->DeleteFramebuffers(1, &m_multisampleFBO); |
792 | 792 |
793 if (m_fbo) | 793 if (m_fbo) |
794 m_gl->DeleteFramebuffers(1, &m_fbo); | 794 m_gl->DeleteFramebuffers(1, &m_fbo); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 wantExplicitResolve() ? m_multisampleFBO : m_fbo); | 1039 wantExplicitResolve() ? m_multisampleFBO : m_fbo); |
1040 } | 1040 } |
1041 | 1041 |
1042 bool DrawingBuffer::paintRenderingResultsToImageData( | 1042 bool DrawingBuffer::paintRenderingResultsToImageData( |
1043 int& width, | 1043 int& width, |
1044 int& height, | 1044 int& height, |
1045 SourceDrawingBuffer sourceBuffer, | 1045 SourceDrawingBuffer sourceBuffer, |
1046 WTF::ArrayBufferContents& contents) { | 1046 WTF::ArrayBufferContents& contents) { |
1047 ScopedStateRestorer scopedStateRestorer(this); | 1047 ScopedStateRestorer scopedStateRestorer(this); |
1048 | 1048 |
1049 ASSERT(!m_premultipliedAlpha); | 1049 DCHECK(!m_premultipliedAlpha); |
1050 width = size().width(); | 1050 width = size().width(); |
1051 height = size().height(); | 1051 height = size().height(); |
1052 | 1052 |
1053 CheckedNumeric<int> dataSize = 4; | 1053 CheckedNumeric<int> dataSize = 4; |
1054 dataSize *= width; | 1054 dataSize *= width; |
1055 dataSize *= height; | 1055 dataSize *= height; |
1056 if (!dataSize.IsValid()) | 1056 if (!dataSize.IsValid()) |
1057 return false; | 1057 return false; |
1058 | 1058 |
1059 WTF::ArrayBufferContents pixels(width * height, 4, | 1059 WTF::ArrayBufferContents pixels(width * height, 4, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 #endif | 1108 #endif |
1109 } | 1109 } |
1110 | 1110 |
1111 if (op == WebGLImageConversion::AlphaDoPremultiply) { | 1111 if (op == WebGLImageConversion::AlphaDoPremultiply) { |
1112 for (size_t i = 0; i < bufferSize; i += 4) { | 1112 for (size_t i = 0; i < bufferSize; i += 4) { |
1113 pixels[i + 0] = std::min(255, pixels[i + 0] * pixels[i + 3] / 255); | 1113 pixels[i + 0] = std::min(255, pixels[i + 0] * pixels[i + 3] / 255); |
1114 pixels[i + 1] = std::min(255, pixels[i + 1] * pixels[i + 3] / 255); | 1114 pixels[i + 1] = std::min(255, pixels[i + 1] * pixels[i + 3] / 255); |
1115 pixels[i + 2] = std::min(255, pixels[i + 2] * pixels[i + 3] / 255); | 1115 pixels[i + 2] = std::min(255, pixels[i + 2] * pixels[i + 3] / 255); |
1116 } | 1116 } |
1117 } else if (op != WebGLImageConversion::AlphaDoNothing) { | 1117 } else if (op != WebGLImageConversion::AlphaDoNothing) { |
1118 ASSERT_NOT_REACHED(); | 1118 NOTREACHED(); |
1119 } | 1119 } |
1120 } | 1120 } |
1121 | 1121 |
1122 void DrawingBuffer::flipVertically(uint8_t* framebuffer, | 1122 void DrawingBuffer::flipVertically(uint8_t* framebuffer, |
1123 int width, | 1123 int width, |
1124 int height) { | 1124 int height) { |
1125 std::vector<uint8_t> scanline(width * 4); | 1125 std::vector<uint8_t> scanline(width * 4); |
1126 unsigned rowBytes = width * 4; | 1126 unsigned rowBytes = width * 4; |
1127 unsigned count = height / 2; | 1127 unsigned count = height / 2; |
1128 for (unsigned i = 0; i < count; i++) { | 1128 for (unsigned i = 0; i < count; i++) { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 if (m_pixelUnpackBufferBindingDirty) | 1296 if (m_pixelUnpackBufferBindingDirty) |
1297 client->DrawingBufferClientRestorePixelUnpackBufferBinding(); | 1297 client->DrawingBufferClientRestorePixelUnpackBufferBinding(); |
1298 } | 1298 } |
1299 | 1299 |
1300 bool DrawingBuffer::shouldUseChromiumImage() { | 1300 bool DrawingBuffer::shouldUseChromiumImage() { |
1301 return RuntimeEnabledFeatures::webGLImageChromiumEnabled() && | 1301 return RuntimeEnabledFeatures::webGLImageChromiumEnabled() && |
1302 m_chromiumImageUsage == AllowChromiumImage; | 1302 m_chromiumImageUsage == AllowChromiumImage; |
1303 } | 1303 } |
1304 | 1304 |
1305 } // namespace blink | 1305 } // namespace blink |
OLD | NEW |