OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #if defined(ENABLE_GPU) | 5 #if defined(ENABLE_GPU) |
6 | 6 |
7 #include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h" | 7 #include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h" |
8 | 8 |
9 #include <GLES2/gl2.h> | 9 #include <GLES2/gl2.h> |
10 #ifndef GL_GLEXT_PROTOTYPES | 10 #ifndef GL_GLEXT_PROTOTYPES |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 // framebuffer vertically before reading it back for compositing | 288 // framebuffer vertically before reading it back for compositing |
289 // via software. This code was quite complicated, used a lot of | 289 // via software. This code was quite complicated, used a lot of |
290 // GPU memory, and didn't provide an obvious speedup. Since this | 290 // GPU memory, and didn't provide an obvious speedup. Since this |
291 // vertical flip is only a temporary solution anyway until Chrome | 291 // vertical flip is only a temporary solution anyway until Chrome |
292 // is fully GPU composited, it wasn't worth the complexity. | 292 // is fully GPU composited, it wasn't worth the complexity. |
293 | 293 |
294 bool mustRestoreFBO = (bound_fbo_ != buffer); | 294 bool mustRestoreFBO = (bound_fbo_ != buffer); |
295 if (mustRestoreFBO) { | 295 if (mustRestoreFBO) { |
296 gl_->BindFramebuffer(GL_FRAMEBUFFER, buffer); | 296 gl_->BindFramebuffer(GL_FRAMEBUFFER, buffer); |
297 } | 297 } |
298 gl_->ReadPixels(0, 0, width, height, | 298 |
299 GL_RGBA, GL_UNSIGNED_BYTE, pixels); | 299 gl_->ReadPixels(0, 0, width, height, |
| 300 GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
300 | 301 |
301 // Swizzle red and blue channels | 302 // Swizzle red and blue channels |
302 // TODO(kbr): expose GL_BGRA as extension | 303 // TODO(kbr): expose GL_BGRA as extension |
303 for (size_t i = 0; i < buffer_size; i += 4) { | 304 for (size_t i = 0; i < buffer_size; i += 4) { |
304 std::swap(pixels[i], pixels[i + 2]); | 305 std::swap(pixels[i], pixels[i + 2]); |
305 } | 306 } |
306 | 307 |
307 if (mustRestoreFBO) { | 308 if (mustRestoreFBO) { |
308 gl_->BindFramebuffer(GL_FRAMEBUFFER, bound_fbo_); | 309 gl_->BindFramebuffer(GL_FRAMEBUFFER, bound_fbo_); |
309 } | 310 } |
310 | 311 |
311 #ifdef FLIP_FRAMEBUFFER_VERTICALLY | 312 #ifdef FLIP_FRAMEBUFFER_VERTICALLY |
312 if (pixels) { | 313 if (pixels) { |
313 FlipVertically(pixels, width, height); | 314 FlipVertically(pixels, width, height); |
314 } | 315 } |
315 #endif | 316 #endif |
316 | 317 |
317 return true; | 318 return true; |
318 } | 319 } |
319 | 320 |
320 bool WebGraphicsContext3DCommandBufferImpl::readBackFramebuffer( | 321 bool WebGraphicsContext3DCommandBufferImpl::readBackFramebuffer( |
321 unsigned char* pixels, | 322 unsigned char* pixels, |
322 size_t buffer_size) { | 323 size_t buffer_size, bool bindDefaultFramebuffer) { |
323 return readBackFramebuffer(pixels, buffer_size, 0, width(), height()); | 324 if (bindDefaultFramebuffer) |
| 325 return readBackFramebuffer(pixels, buffer_size, 0, width(), height()); |
| 326 |
| 327 return readBackFramebuffer(pixels, buffer_size, bound_fbo_, width(), height())
; |
324 } | 328 } |
325 | 329 |
326 void WebGraphicsContext3DCommandBufferImpl::synthesizeGLError( | 330 void WebGraphicsContext3DCommandBufferImpl::synthesizeGLError( |
327 WGC3Denum error) { | 331 WGC3Denum error) { |
328 if (find(synthetic_errors_.begin(), synthetic_errors_.end(), error) == | 332 if (find(synthetic_errors_.begin(), synthetic_errors_.end(), error) == |
329 synthetic_errors_.end()) { | 333 synthetic_errors_.end()) { |
330 synthetic_errors_.push_back(error); | 334 synthetic_errors_.push_back(error); |
331 } | 335 } |
332 } | 336 } |
333 | 337 |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 context_lost_callback_->onContextLost(); | 1062 context_lost_callback_->onContextLost(); |
1059 } | 1063 } |
1060 | 1064 |
1061 RenderView* renderview = | 1065 RenderView* renderview = |
1062 web_view_ ? RenderView::FromWebView(web_view_) : NULL; | 1066 web_view_ ? RenderView::FromWebView(web_view_) : NULL; |
1063 if (renderview) | 1067 if (renderview) |
1064 renderview->OnViewContextSwapBuffersAborted(); | 1068 renderview->OnViewContextSwapBuffersAborted(); |
1065 } | 1069 } |
1066 | 1070 |
1067 #endif // defined(ENABLE_GPU) | 1071 #endif // defined(ENABLE_GPU) |
OLD | NEW |