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 24 matching lines...) Expand all Loading... |
35 | 35 |
36 static base::LazyInstance<base::Lock> | 36 static base::LazyInstance<base::Lock> |
37 g_all_shared_contexts_lock(base::LINKER_INITIALIZED); | 37 g_all_shared_contexts_lock(base::LINKER_INITIALIZED); |
38 static base::LazyInstance<std::set<WebGraphicsContext3DCommandBufferImpl*> > | 38 static base::LazyInstance<std::set<WebGraphicsContext3DCommandBufferImpl*> > |
39 g_all_shared_contexts(base::LINKER_INITIALIZED); | 39 g_all_shared_contexts(base::LINKER_INITIALIZED); |
40 | 40 |
41 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl() | 41 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl() |
42 : initialize_failed_(false), | 42 : initialize_failed_(false), |
43 context_(NULL), | 43 context_(NULL), |
44 gl_(NULL), | 44 gl_(NULL), |
45 #ifndef WTF_USE_THREADED_COMPOSITING | |
46 web_view_(NULL), | 45 web_view_(NULL), |
47 #endif | |
48 #if defined(OS_MACOSX) | 46 #if defined(OS_MACOSX) |
49 plugin_handle_(NULL), | 47 plugin_handle_(NULL), |
50 #endif // defined(OS_MACOSX) | 48 #endif // defined(OS_MACOSX) |
51 context_lost_callback_(0), | 49 context_lost_callback_(0), |
52 context_lost_reason_(GL_NO_ERROR), | 50 context_lost_reason_(GL_NO_ERROR), |
53 swapbuffers_complete_callback_(0), | 51 swapbuffers_complete_callback_(0), |
54 cached_width_(0), | 52 cached_width_(0), |
55 cached_height_(0), | 53 cached_height_(0), |
56 bound_fbo_(0), | 54 bound_fbo_(0), |
57 method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 55 method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 if (web_view && web_view->mainFrame()) | 93 if (web_view && web_view->mainFrame()) |
96 active_url_ = GURL(web_view->mainFrame()->document().url()); | 94 active_url_ = GURL(web_view->mainFrame()->document().url()); |
97 | 95 |
98 attributes_ = attributes; | 96 attributes_ = attributes; |
99 render_directly_to_web_view_ = render_directly_to_web_view; | 97 render_directly_to_web_view_ = render_directly_to_web_view; |
100 if (render_directly_to_web_view_) { | 98 if (render_directly_to_web_view_) { |
101 RenderView* render_view = RenderView::FromWebView(web_view); | 99 RenderView* render_view = RenderView::FromWebView(web_view); |
102 if (!render_view) | 100 if (!render_view) |
103 return false; | 101 return false; |
104 render_view_routing_id_ = render_view->routing_id(); | 102 render_view_routing_id_ = render_view->routing_id(); |
105 #ifndef WTF_USE_THREADED_COMPOSITING | |
106 web_view_ = web_view; | 103 web_view_ = web_view; |
107 #endif | |
108 } | 104 } |
109 return true; | 105 return true; |
110 } | 106 } |
111 | 107 |
112 bool WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL() { | 108 bool WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL() { |
113 if (context_) | 109 if (context_) |
114 return true; | 110 return true; |
115 if (initialize_failed_) | 111 if (initialize_failed_) |
116 return false; | 112 return false; |
117 | 113 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 parent_context_impl ? parent_context_impl->context() : NULL); | 233 parent_context_impl ? parent_context_impl->context() : NULL); |
238 } | 234 } |
239 | 235 |
240 WebGLId WebGraphicsContext3DCommandBufferImpl::getPlatformTextureId() { | 236 WebGLId WebGraphicsContext3DCommandBufferImpl::getPlatformTextureId() { |
241 return context_->GetParentTextureId(); | 237 return context_->GetParentTextureId(); |
242 } | 238 } |
243 | 239 |
244 void WebGraphicsContext3DCommandBufferImpl::prepareTexture() { | 240 void WebGraphicsContext3DCommandBufferImpl::prepareTexture() { |
245 // Copies the contents of the off-screen render target into the texture | 241 // Copies the contents of the off-screen render target into the texture |
246 // used by the compositor. | 242 // used by the compositor. |
247 #ifndef WTF_USE_THREADED_COMPOSITING | |
248 RenderView* renderview = | 243 RenderView* renderview = |
249 web_view_ ? RenderView::FromWebView(web_view_) : NULL; | 244 web_view_ ? RenderView::FromWebView(web_view_) : NULL; |
250 if (renderview) | 245 if (renderview) |
251 renderview->OnViewContextSwapBuffersPosted(); | 246 renderview->OnViewContextSwapBuffersPosted(); |
252 #endif | |
253 context_->SwapBuffers(); | 247 context_->SwapBuffers(); |
254 context_->Echo(method_factory_.NewRunnableMethod( | 248 context_->Echo(method_factory_.NewRunnableMethod( |
255 &WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete)); | 249 &WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete)); |
256 #if defined(OS_MACOSX) | 250 #if defined(OS_MACOSX) |
257 // It appears that making the compositor's on-screen context current on | 251 // It appears that making the compositor's on-screen context current on |
258 // other platforms implies this flush. TODO(kbr): this means that the | 252 // other platforms implies this flush. TODO(kbr): this means that the |
259 // TOUCH build and, in the future, other platforms might need this. | 253 // TOUCH build and, in the future, other platforms might need this. |
260 gl_->Flush(); | 254 gl_->Flush(); |
261 #endif | 255 #endif |
262 } | 256 } |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 | 1014 |
1021 void WebGraphicsContext3DCommandBufferImpl::deleteShader(WebGLId shader) { | 1015 void WebGraphicsContext3DCommandBufferImpl::deleteShader(WebGLId shader) { |
1022 gl_->DeleteShader(shader); | 1016 gl_->DeleteShader(shader); |
1023 } | 1017 } |
1024 | 1018 |
1025 void WebGraphicsContext3DCommandBufferImpl::deleteTexture(WebGLId texture) { | 1019 void WebGraphicsContext3DCommandBufferImpl::deleteTexture(WebGLId texture) { |
1026 gl_->DeleteTextures(1, &texture); | 1020 gl_->DeleteTextures(1, &texture); |
1027 } | 1021 } |
1028 | 1022 |
1029 void WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete() { | 1023 void WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete() { |
1030 #ifndef WTF_USE_THREADED_COMPOSITING | |
1031 // This may be called after tear-down of the RenderView. | 1024 // This may be called after tear-down of the RenderView. |
1032 RenderView* renderview = | 1025 RenderView* renderview = |
1033 web_view_ ? RenderView::FromWebView(web_view_) : NULL; | 1026 web_view_ ? RenderView::FromWebView(web_view_) : NULL; |
1034 if (renderview) | 1027 if (renderview) |
1035 renderview->OnViewContextSwapBuffersComplete(); | 1028 renderview->OnViewContextSwapBuffersComplete(); |
1036 #endif | 1029 |
1037 if (swapbuffers_complete_callback_) | 1030 if (swapbuffers_complete_callback_) |
1038 swapbuffers_complete_callback_->onSwapBuffersComplete(); | 1031 swapbuffers_complete_callback_->onSwapBuffersComplete(); |
1039 } | 1032 } |
1040 | 1033 |
1041 void WebGraphicsContext3DCommandBufferImpl::setContextLostCallback( | 1034 void WebGraphicsContext3DCommandBufferImpl::setContextLostCallback( |
1042 WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) { | 1035 WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) { |
1043 context_lost_callback_ = cb; | 1036 context_lost_callback_ = cb; |
1044 } | 1037 } |
1045 | 1038 |
1046 WGC3Denum WebGraphicsContext3DCommandBufferImpl::getGraphicsResetStatusARB() { | 1039 WGC3Denum WebGraphicsContext3DCommandBufferImpl::getGraphicsResetStatusARB() { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 } | 1074 } |
1082 | 1075 |
1083 } // anonymous namespace | 1076 } // anonymous namespace |
1084 | 1077 |
1085 void WebGraphicsContext3DCommandBufferImpl::OnContextLost( | 1078 void WebGraphicsContext3DCommandBufferImpl::OnContextLost( |
1086 RendererGLContext::ContextLostReason reason) { | 1079 RendererGLContext::ContextLostReason reason) { |
1087 context_lost_reason_ = convertReason(reason); | 1080 context_lost_reason_ = convertReason(reason); |
1088 if (context_lost_callback_) { | 1081 if (context_lost_callback_) { |
1089 context_lost_callback_->onContextLost(); | 1082 context_lost_callback_->onContextLost(); |
1090 } | 1083 } |
1091 #ifndef WTF_USE_THREADED_COMPOSITING | |
1092 RenderView* renderview = | 1084 RenderView* renderview = |
1093 web_view_ ? RenderView::FromWebView(web_view_) : NULL; | 1085 web_view_ ? RenderView::FromWebView(web_view_) : NULL; |
1094 if (renderview) | 1086 if (renderview) |
1095 renderview->OnViewContextSwapBuffersAborted(); | 1087 renderview->OnViewContextSwapBuffersAborted(); |
1096 #endif | |
1097 } | 1088 } |
1098 | 1089 |
1099 #endif // defined(ENABLE_GPU) | 1090 #endif // defined(ENABLE_GPU) |
OLD | NEW |