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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 } | 270 } |
271 | 271 |
272 WebGLId WebGraphicsContext3DCommandBufferImpl::getPlatformTextureId() { | 272 WebGLId WebGraphicsContext3DCommandBufferImpl::getPlatformTextureId() { |
273 return context_->GetParentTextureId(); | 273 return context_->GetParentTextureId(); |
274 } | 274 } |
275 | 275 |
276 void WebGraphicsContext3DCommandBufferImpl::prepareTexture() { | 276 void WebGraphicsContext3DCommandBufferImpl::prepareTexture() { |
277 // Copies the contents of the off-screen render target into the texture | 277 // Copies the contents of the off-screen render target into the texture |
278 // used by the compositor. | 278 // used by the compositor. |
279 RenderViewImpl* renderview = | 279 RenderViewImpl* renderview = |
280 web_view_ ? RenderViewImpl::FromWebView(web_view_) : NULL; | 280 web_view_ ? RenderViewImpl::FromWebView(web_view_) : NULL; |
jamesr
2011/11/09 04:51:58
hold up, this lookup is not threadsafe either.
I
| |
281 if (renderview) | 281 CompositorThread* compositor_thread = |
282 RenderThreadImpl::current()->compositor_thread(); | |
283 if (renderview && !compositor_thread) | |
282 renderview->OnViewContextSwapBuffersPosted(); | 284 renderview->OnViewContextSwapBuffersPosted(); |
283 context_->SwapBuffers(); | 285 context_->SwapBuffers(); |
284 context_->Echo(base::Bind( | 286 context_->Echo(base::Bind( |
285 &WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete, | 287 &WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete, |
286 weak_ptr_factory_.GetWeakPtr())); | 288 weak_ptr_factory_.GetWeakPtr())); |
287 #if defined(OS_MACOSX) | 289 #if defined(OS_MACOSX) |
288 // It appears that making the compositor's on-screen context current on | 290 // It appears that making the compositor's on-screen context current on |
289 // other platforms implies this flush. TODO(kbr): this means that the | 291 // other platforms implies this flush. TODO(kbr): this means that the |
290 // TOUCH build and, in the future, other platforms might need this. | 292 // TOUCH build and, in the future, other platforms might need this. |
291 gl_->Flush(); | 293 gl_->Flush(); |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1082 } | 1084 } |
1083 | 1085 |
1084 void WebGraphicsContext3DCommandBufferImpl::deleteTexture(WebGLId texture) { | 1086 void WebGraphicsContext3DCommandBufferImpl::deleteTexture(WebGLId texture) { |
1085 gl_->DeleteTextures(1, &texture); | 1087 gl_->DeleteTextures(1, &texture); |
1086 } | 1088 } |
1087 | 1089 |
1088 void WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete() { | 1090 void WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete() { |
1089 // This may be called after tear-down of the RenderView. | 1091 // This may be called after tear-down of the RenderView. |
1090 RenderViewImpl* renderview = | 1092 RenderViewImpl* renderview = |
1091 web_view_ ? RenderViewImpl::FromWebView(web_view_) : NULL; | 1093 web_view_ ? RenderViewImpl::FromWebView(web_view_) : NULL; |
1092 if (renderview) | 1094 CompositorThread* compositor_thread = |
1095 RenderThreadImpl::current()->compositor_thread(); | |
1096 if (renderview && !compositor_thread) | |
1093 renderview->OnViewContextSwapBuffersComplete(); | 1097 renderview->OnViewContextSwapBuffersComplete(); |
1094 | 1098 |
1095 if (swapbuffers_complete_callback_) | 1099 if (swapbuffers_complete_callback_) |
1096 swapbuffers_complete_callback_->onSwapBuffersComplete(); | 1100 swapbuffers_complete_callback_->onSwapBuffersComplete(); |
1097 } | 1101 } |
1098 | 1102 |
1099 void WebGraphicsContext3DCommandBufferImpl::setContextLostCallback( | 1103 void WebGraphicsContext3DCommandBufferImpl::setContextLostCallback( |
1100 WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) { | 1104 WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) { |
1101 context_lost_callback_ = cb; | 1105 context_lost_callback_ = cb; |
1102 } | 1106 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1141 } // anonymous namespace | 1145 } // anonymous namespace |
1142 | 1146 |
1143 void WebGraphicsContext3DCommandBufferImpl::OnContextLost( | 1147 void WebGraphicsContext3DCommandBufferImpl::OnContextLost( |
1144 RendererGLContext::ContextLostReason reason) { | 1148 RendererGLContext::ContextLostReason reason) { |
1145 context_lost_reason_ = convertReason(reason); | 1149 context_lost_reason_ = convertReason(reason); |
1146 if (context_lost_callback_) { | 1150 if (context_lost_callback_) { |
1147 context_lost_callback_->onContextLost(); | 1151 context_lost_callback_->onContextLost(); |
1148 } | 1152 } |
1149 RenderViewImpl* renderview = | 1153 RenderViewImpl* renderview = |
1150 web_view_ ? RenderViewImpl::FromWebView(web_view_) : NULL; | 1154 web_view_ ? RenderViewImpl::FromWebView(web_view_) : NULL; |
1151 if (renderview) | 1155 CompositorThread* compositor_thread = |
1156 RenderThreadImpl::current()->compositor_thread(); | |
1157 if (renderview && !compositor_thread) | |
1152 renderview->OnViewContextSwapBuffersAborted(); | 1158 renderview->OnViewContextSwapBuffersAborted(); |
1153 } | 1159 } |
1154 | 1160 |
1155 #endif // defined(ENABLE_GPU) | 1161 #endif // defined(ENABLE_GPU) |
OLD | NEW |