Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 2225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2236 } | 2236 } |
| 2237 | 2237 |
| 2238 unsigned buffer = context_->createBuffer(); | 2238 unsigned buffer = context_->createBuffer(); |
| 2239 GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, | 2239 GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, |
| 2240 buffer)); | 2240 buffer)); |
| 2241 GLC(context_, context_->bufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, | 2241 GLC(context_, context_->bufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, |
| 2242 4 * rect.size().GetArea(), | 2242 4 * rect.size().GetArea(), |
| 2243 NULL, | 2243 NULL, |
| 2244 GL_STREAM_READ)); | 2244 GL_STREAM_READ)); |
| 2245 | 2245 |
| 2246 WebKit::WebGLId query = 0; | |
| 2247 if (is_async) { | |
| 2248 query = context_->createQueryEXT(); | |
| 2249 GLC(context_, context_->beginQueryEXT( | |
| 2250 GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM, | |
| 2251 query)); | |
| 2252 } | |
| 2253 | |
| 2254 | |
|
danakj
2013/06/17 18:36:48
nit: a single line of whitespace is sufficient.
hubbe
2013/06/17 19:47:19
Done.
| |
| 2246 GLC(context_, | 2255 GLC(context_, |
| 2247 context_->readPixels(window_rect.x(), | 2256 context_->readPixels(window_rect.x(), |
| 2248 window_rect.y(), | 2257 window_rect.y(), |
| 2249 window_rect.width(), | 2258 window_rect.width(), |
| 2250 window_rect.height(), | 2259 window_rect.height(), |
| 2251 GL_RGBA, | 2260 GL_RGBA, |
| 2252 GL_UNSIGNED_BYTE, | 2261 GL_UNSIGNED_BYTE, |
| 2253 NULL)); | 2262 NULL)); |
| 2254 | 2263 |
| 2255 GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, | 2264 GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, |
| 2256 0)); | 2265 0)); |
| 2257 | 2266 |
| 2258 if (do_workaround) { | 2267 if (do_workaround) { |
| 2259 // Clean up. | 2268 // Clean up. |
| 2260 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, 0)); | 2269 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, 0)); |
| 2261 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0)); | 2270 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0)); |
| 2262 GLC(context_, context_->deleteFramebuffer(temporary_fbo)); | 2271 GLC(context_, context_->deleteFramebuffer(temporary_fbo)); |
| 2263 GLC(context_, context_->deleteTexture(temporary_texture)); | 2272 GLC(context_, context_->deleteTexture(temporary_texture)); |
| 2264 } | 2273 } |
| 2265 | 2274 |
| 2266 base::Closure finished_callback = | 2275 base::Closure finished_callback = |
| 2267 base::Bind(&GLRenderer::FinishedReadback, | 2276 base::Bind(&GLRenderer::FinishedReadback, |
| 2268 base::Unretained(this), | 2277 base::Unretained(this), |
| 2269 cleanup_callback, | 2278 cleanup_callback, |
| 2270 buffer, | 2279 buffer, |
| 2280 query, | |
| 2271 dest_pixels, | 2281 dest_pixels, |
| 2272 rect.size()); | 2282 rect.size()); |
| 2273 // Save the finished_callback so it can be cancelled. | 2283 // Save the finished_callback so it can be cancelled. |
| 2274 pending_async_read_pixels_.front()->finished_read_pixels_callback.Reset( | 2284 pending_async_read_pixels_.front()->finished_read_pixels_callback.Reset( |
| 2275 finished_callback); | 2285 finished_callback); |
| 2276 | 2286 |
| 2277 // Save the buffer to verify the callbacks happen in the expected order. | 2287 // Save the buffer to verify the callbacks happen in the expected order. |
| 2278 pending_async_read_pixels_.front()->buffer = buffer; | 2288 pending_async_read_pixels_.front()->buffer = buffer; |
| 2279 | 2289 |
| 2280 if (is_async) { | 2290 if (is_async) { |
| 2281 unsigned sync_point = context_->insertSyncPoint(); | 2291 SyncPointHelper::SignalQuery( |
| 2282 SyncPointHelper::SignalSyncPoint( | |
| 2283 context_, | 2292 context_, |
| 2284 sync_point, | 2293 query, |
| 2285 finished_callback); | 2294 finished_callback); |
| 2295 GLC(context_, context_->endQueryEXT( | |
| 2296 GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM)); | |
| 2286 } else { | 2297 } else { |
| 2287 resource_provider_->Finish(); | 2298 resource_provider_->Finish(); |
| 2288 finished_callback.Run(); | 2299 finished_callback.Run(); |
| 2289 } | 2300 } |
| 2290 | 2301 |
| 2291 EnforceMemoryPolicy(); | 2302 EnforceMemoryPolicy(); |
| 2292 } | 2303 } |
| 2293 | 2304 |
| 2294 void GLRenderer::FinishedReadback( | 2305 void GLRenderer::FinishedReadback( |
| 2295 const AsyncGetFramebufferPixelsCleanupCallback& cleanup_callback, | 2306 const AsyncGetFramebufferPixelsCleanupCallback& cleanup_callback, |
| 2296 unsigned source_buffer, | 2307 unsigned source_buffer, |
| 2308 unsigned query, | |
| 2297 uint8* dest_pixels, | 2309 uint8* dest_pixels, |
| 2298 gfx::Size size) { | 2310 gfx::Size size) { |
| 2299 DCHECK(!pending_async_read_pixels_.empty()); | 2311 DCHECK(!pending_async_read_pixels_.empty()); |
| 2300 | 2312 |
| 2313 if (query != 0) { | |
| 2314 GLC(context_, context_->deleteQueryEXT(query)); | |
| 2315 } | |
| 2316 | |
| 2301 PendingAsyncReadPixels* current_read = pending_async_read_pixels_.back(); | 2317 PendingAsyncReadPixels* current_read = pending_async_read_pixels_.back(); |
| 2302 // Make sure we service the readbacks in order. | 2318 // Make sure we service the readbacks in order. |
| 2303 DCHECK_EQ(source_buffer, current_read->buffer); | 2319 DCHECK_EQ(source_buffer, current_read->buffer); |
| 2304 | 2320 |
| 2305 uint8* src_pixels = NULL; | 2321 uint8* src_pixels = NULL; |
| 2306 | 2322 |
| 2307 if (source_buffer != 0) { | 2323 if (source_buffer != 0) { |
| 2308 GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, | 2324 GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, |
| 2309 source_buffer)); | 2325 source_buffer)); |
| 2310 src_pixels = static_cast<uint8*>( | 2326 src_pixels = static_cast<uint8*>( |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2972 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas | 2988 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas |
| 2973 // implementation. | 2989 // implementation. |
| 2974 return gr_context_ && context_->getContextAttributes().stencil; | 2990 return gr_context_ && context_->getContextAttributes().stencil; |
| 2975 } | 2991 } |
| 2976 | 2992 |
| 2977 bool GLRenderer::IsContextLost() { | 2993 bool GLRenderer::IsContextLost() { |
| 2978 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); | 2994 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); |
| 2979 } | 2995 } |
| 2980 | 2996 |
| 2981 } // namespace cc | 2997 } // namespace cc |
| OLD | NEW |