Chromium Code Reviews| 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/webgraphicscontext3d_command_buffer_impl.h" | 7 #include "content/renderer/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 29 matching lines...) Expand all Loading... | |
| 40 cached_width_(0), | 40 cached_width_(0), |
| 41 cached_height_(0), | 41 cached_height_(0), |
| 42 bound_fbo_(0) { | 42 bound_fbo_(0) { |
| 43 } | 43 } |
| 44 | 44 |
| 45 WebGraphicsContext3DCommandBufferImpl:: | 45 WebGraphicsContext3DCommandBufferImpl:: |
| 46 ~WebGraphicsContext3DCommandBufferImpl() { | 46 ~WebGraphicsContext3DCommandBufferImpl() { |
| 47 delete context_; | 47 delete context_; |
| 48 } | 48 } |
| 49 | 49 |
| 50 static const char* kWebGraphicsContext3DPerferredGLExtensions = | 50 // This string should only be passed for WebGL contexts. Nothing ELSE!!! |
| 51 // Compositor contexts, Canvas2D contexts, Pepper Contexts, nor any other use of | |
| 52 // a context should not pass this string. | |
| 53 static const char* kWebGLPreferredGLExtensions = | |
| 51 "GL_OES_packed_depth_stencil " | 54 "GL_OES_packed_depth_stencil " |
| 52 "GL_OES_depth24 " | 55 "GL_OES_depth24 " |
| 53 "GL_CHROMIUM_webglsl"; | 56 "GL_CHROMIUM_webglsl"; |
| 54 | 57 |
| 55 bool WebGraphicsContext3DCommandBufferImpl::initialize( | 58 bool WebGraphicsContext3DCommandBufferImpl::initialize( |
| 56 WebGraphicsContext3D::Attributes attributes, | 59 WebGraphicsContext3D::Attributes attributes, |
| 57 WebKit::WebView* web_view, | 60 WebKit::WebView* web_view, |
| 58 bool render_directly_to_web_view) { | 61 bool render_directly_to_web_view) { |
| 59 TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::initialize"); | 62 TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::initialize"); |
| 60 webkit_glue::BindSkiaToCommandBufferGL(); | 63 webkit_glue::BindSkiaToCommandBufferGL(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 if (render_directly_to_web_view) { | 104 if (render_directly_to_web_view) { |
| 102 RenderView* renderview = RenderView::FromWebView(web_view); | 105 RenderView* renderview = RenderView::FromWebView(web_view); |
| 103 if (!renderview) | 106 if (!renderview) |
| 104 return false; | 107 return false; |
| 105 | 108 |
| 106 web_view_ = web_view; | 109 web_view_ = web_view; |
| 107 context_ = RendererGLContext::CreateViewContext( | 110 context_ = RendererGLContext::CreateViewContext( |
| 108 host, | 111 host, |
| 109 renderview->compositing_surface(), | 112 renderview->compositing_surface(), |
| 110 renderview->routing_id(), | 113 renderview->routing_id(), |
| 111 kWebGraphicsContext3DPerferredGLExtensions, | 114 kWebGLPreferredGLExtensions, |
|
jamesr
2011/05/24 22:05:11
i think this codepath (render_directly_to_web_view
| |
| 112 attribs, | 115 attribs, |
| 113 active_url); | 116 active_url); |
| 114 if (context_) { | 117 if (context_) { |
| 115 context_->SetSwapBuffersCallback( | 118 context_->SetSwapBuffersCallback( |
| 116 NewCallback(this, | 119 NewCallback(this, |
| 117 &WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete)); | 120 &WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete)); |
| 118 } | 121 } |
| 119 } else { | 122 } else { |
| 120 bool compositing_enabled = !CommandLine::ForCurrentProcess()->HasSwitch( | 123 bool compositing_enabled = !CommandLine::ForCurrentProcess()->HasSwitch( |
| 121 switches::kDisableAcceleratedCompositing); | 124 switches::kDisableAcceleratedCompositing); |
| 122 RendererGLContext* parent_context = NULL; | 125 RendererGLContext* parent_context = NULL; |
| 123 // If GPU compositing is enabled we need to create a GL context that shares | 126 // If GPU compositing is enabled we need to create a GL context that shares |
| 124 // resources with the compositor's context. | 127 // resources with the compositor's context. |
| 125 if (compositing_enabled) { | 128 if (compositing_enabled) { |
| 126 // Asking for the WebGraphicsContext3D on the WebView will force one to | 129 // Asking for the WebGraphicsContext3D on the WebView will force one to |
| 127 // be created if it doesn't already exist. When the compositor is created | 130 // be created if it doesn't already exist. When the compositor is created |
| 128 // for the view it will use the same context. | 131 // for the view it will use the same context. |
| 129 WebKit::WebGraphicsContext3D* view_context = | 132 WebKit::WebGraphicsContext3D* view_context = |
| 130 web_view->graphicsContext3D(); | 133 web_view->graphicsContext3D(); |
| 131 if (view_context) { | 134 if (view_context) { |
| 132 WebGraphicsContext3DCommandBufferImpl* context_impl = | 135 WebGraphicsContext3DCommandBufferImpl* context_impl = |
| 133 static_cast<WebGraphicsContext3DCommandBufferImpl*>(view_context); | 136 static_cast<WebGraphicsContext3DCommandBufferImpl*>(view_context); |
| 134 parent_context = context_impl->context_; | 137 parent_context = context_impl->context_; |
| 135 } | 138 } |
| 136 } | 139 } |
| 137 context_ = RendererGLContext::CreateOffscreenContext( | 140 context_ = RendererGLContext::CreateOffscreenContext( |
| 138 host, | 141 host, |
| 139 parent_context, | 142 parent_context, |
| 140 gfx::Size(1, 1), | 143 gfx::Size(1, 1), |
| 141 kWebGraphicsContext3DPerferredGLExtensions, | 144 kWebGLPreferredGLExtensions, |
|
jamesr
2011/05/24 22:05:11
this is used for webgl, canvas 2d, and probably ot
| |
| 142 attribs, | 145 attribs, |
| 143 active_url); | 146 active_url); |
| 144 web_view_ = NULL; | 147 web_view_ = NULL; |
| 145 } | 148 } |
| 146 if (!context_) | 149 if (!context_) |
| 147 return false; | 150 return false; |
| 148 | 151 |
| 149 gl_ = context_->GetImplementation(); | 152 gl_ = context_->GetImplementation(); |
| 150 context_->SetContextLostCallback( | 153 context_->SetContextLostCallback( |
| 151 NewCallback(this, | 154 NewCallback(this, |
| (...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1038 context_lost_callback_->onContextLost(); | 1041 context_lost_callback_->onContextLost(); |
| 1039 } | 1042 } |
| 1040 | 1043 |
| 1041 RenderView* renderview = | 1044 RenderView* renderview = |
| 1042 web_view_ ? RenderView::FromWebView(web_view_) : NULL; | 1045 web_view_ ? RenderView::FromWebView(web_view_) : NULL; |
| 1043 if (renderview) | 1046 if (renderview) |
| 1044 renderview->OnViewContextSwapBuffersAborted(); | 1047 renderview->OnViewContextSwapBuffersAborted(); |
| 1045 } | 1048 } |
| 1046 | 1049 |
| 1047 #endif // defined(ENABLE_GPU) | 1050 #endif // defined(ENABLE_GPU) |
| OLD | NEW |