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 "gpu/GLES2/gl2.h" | 9 #include "gpu/GLES2/gl2.h" |
10 #ifndef GL_GLEXT_PROTOTYPES | 10 #ifndef GL_GLEXT_PROTOTYPES |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "content/renderer/gpu/gpu_channel_host.h" | 28 #include "content/renderer/gpu/gpu_channel_host.h" |
29 #include "content/renderer/render_thread_impl.h" | 29 #include "content/renderer/render_thread_impl.h" |
30 #include "content/renderer/render_view_impl.h" | 30 #include "content/renderer/render_view_impl.h" |
31 #include "gpu/command_buffer/client/gles2_implementation.h" | 31 #include "gpu/command_buffer/client/gles2_implementation.h" |
32 #include "gpu/command_buffer/common/constants.h" | 32 #include "gpu/command_buffer/common/constants.h" |
33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
36 #include "webkit/glue/gl_bindings_skia_cmd_buffer.h" | 36 #include "webkit/glue/gl_bindings_skia_cmd_buffer.h" |
37 | 37 |
38 static base::LazyInstance<base::Lock> | 38 static base::LazyInstance<base::Lock, |
| 39 base::LeakyLazyInstanceTraits<base::Lock> > |
39 g_all_shared_contexts_lock(base::LINKER_INITIALIZED); | 40 g_all_shared_contexts_lock(base::LINKER_INITIALIZED); |
40 static base::LazyInstance<std::set<WebGraphicsContext3DCommandBufferImpl*> > | 41 static base::LazyInstance<std::set<WebGraphicsContext3DCommandBufferImpl*> > |
41 g_all_shared_contexts(base::LINKER_INITIALIZED); | 42 g_all_shared_contexts(base::LINKER_INITIALIZED); |
42 | 43 |
43 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl() | 44 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl() |
44 : initialize_failed_(false), | 45 : initialize_failed_(false), |
45 context_(NULL), | 46 context_(NULL), |
46 gl_(NULL), | 47 gl_(NULL), |
47 web_view_(NULL), | 48 web_view_(NULL), |
48 #if defined(OS_MACOSX) | 49 #if defined(OS_MACOSX) |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 // framebuffer vertically before reading it back for compositing | 341 // framebuffer vertically before reading it back for compositing |
341 // via software. This code was quite complicated, used a lot of | 342 // via software. This code was quite complicated, used a lot of |
342 // GPU memory, and didn't provide an obvious speedup. Since this | 343 // GPU memory, and didn't provide an obvious speedup. Since this |
343 // vertical flip is only a temporary solution anyway until Chrome | 344 // vertical flip is only a temporary solution anyway until Chrome |
344 // is fully GPU composited, it wasn't worth the complexity. | 345 // is fully GPU composited, it wasn't worth the complexity. |
345 | 346 |
346 bool mustRestoreFBO = (bound_fbo_ != buffer); | 347 bool mustRestoreFBO = (bound_fbo_ != buffer); |
347 if (mustRestoreFBO) { | 348 if (mustRestoreFBO) { |
348 gl_->BindFramebuffer(GL_FRAMEBUFFER, buffer); | 349 gl_->BindFramebuffer(GL_FRAMEBUFFER, buffer); |
349 } | 350 } |
350 gl_->ReadPixels(0, 0, width, height, | 351 gl_->ReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
351 GL_RGBA, GL_UNSIGNED_BYTE, pixels); | |
352 | 352 |
353 // Swizzle red and blue channels | 353 // Swizzle red and blue channels |
354 // TODO(kbr): expose GL_BGRA as extension | 354 // TODO(kbr): expose GL_BGRA as extension |
355 for (size_t i = 0; i < buffer_size; i += 4) { | 355 for (size_t i = 0; i < buffer_size; i += 4) { |
356 std::swap(pixels[i], pixels[i + 2]); | 356 std::swap(pixels[i], pixels[i + 2]); |
357 } | 357 } |
358 | 358 |
359 if (mustRestoreFBO) { | 359 if (mustRestoreFBO) { |
360 gl_->BindFramebuffer(GL_FRAMEBUFFER, bound_fbo_); | 360 gl_->BindFramebuffer(GL_FRAMEBUFFER, bound_fbo_); |
361 } | 361 } |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 if (context_lost_callback_) { | 1146 if (context_lost_callback_) { |
1147 context_lost_callback_->onContextLost(); | 1147 context_lost_callback_->onContextLost(); |
1148 } | 1148 } |
1149 RenderViewImpl* renderview = | 1149 RenderViewImpl* renderview = |
1150 web_view_ ? RenderViewImpl::FromWebView(web_view_) : NULL; | 1150 web_view_ ? RenderViewImpl::FromWebView(web_view_) : NULL; |
1151 if (renderview) | 1151 if (renderview) |
1152 renderview->OnViewContextSwapBuffersAborted(); | 1152 renderview->OnViewContextSwapBuffersAborted(); |
1153 } | 1153 } |
1154 | 1154 |
1155 #endif // defined(ENABLE_GPU) | 1155 #endif // defined(ENABLE_GPU) |
OLD | NEW |