Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Side by Side Diff: content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc

Issue 7782038: Prepare WebGL contexts for resource sharing with the compositor context. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Add an additional feature to GLES2DecoderImpl that is used to force the context to obey WebGL fea... Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 WebGraphicsContext3DCommandBufferImpl:: 60 WebGraphicsContext3DCommandBufferImpl::
61 ~WebGraphicsContext3DCommandBufferImpl() { 61 ~WebGraphicsContext3DCommandBufferImpl() {
62 { 62 {
63 base::AutoLock lock(g_all_shared_contexts_lock.Get()); 63 base::AutoLock lock(g_all_shared_contexts_lock.Get());
64 g_all_shared_contexts.Pointer()->erase(this); 64 g_all_shared_contexts.Pointer()->erase(this);
65 } 65 }
66 delete context_; 66 delete context_;
67 } 67 }
68 68
69 // This string should only be passed for WebGL contexts. Nothing ELSE!!!
70 // Compositor contexts, Canvas2D contexts, Pepper Contexts, nor any other use of
71 // a context should not pass this string.
72 static const char* kWebGLPreferredGLExtensions =
73 "GL_OES_packed_depth_stencil "
74 "GL_OES_depth24 "
75 "GL_CHROMIUM_webglsl";
76
77 bool WebGraphicsContext3DCommandBufferImpl::initialize( 69 bool WebGraphicsContext3DCommandBufferImpl::initialize(
78 WebGraphicsContext3D::Attributes attributes, 70 WebGraphicsContext3D::Attributes attributes,
79 WebKit::WebView* web_view, 71 WebKit::WebView* web_view,
80 bool render_directly_to_web_view) { 72 bool render_directly_to_web_view) {
81 DCHECK(!context_); 73 DCHECK(!context_);
82 TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::initialize"); 74 TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::initialize");
83 RenderThread* render_thread = RenderThread::current(); 75 RenderThread* render_thread = RenderThread::current();
84 if (!render_thread) 76 if (!render_thread)
85 return false; 77 return false;
86 host_ = render_thread->EstablishGpuChannelSync( 78 host_ = render_thread->EstablishGpuChannelSync(
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 RendererGLContext::ALPHA_SIZE, alpha_size, 128 RendererGLContext::ALPHA_SIZE, alpha_size,
137 RendererGLContext::DEPTH_SIZE, depth_size, 129 RendererGLContext::DEPTH_SIZE, depth_size,
138 RendererGLContext::STENCIL_SIZE, stencil_size, 130 RendererGLContext::STENCIL_SIZE, stencil_size,
139 RendererGLContext::SAMPLES, samples, 131 RendererGLContext::SAMPLES, samples,
140 RendererGLContext::SAMPLE_BUFFERS, sample_buffers, 132 RendererGLContext::SAMPLE_BUFFERS, sample_buffers,
141 RendererGLContext::SHARE_RESOURCES, attributes_.shareResources ? 1 : 0, 133 RendererGLContext::SHARE_RESOURCES, attributes_.shareResources ? 1 : 0,
142 RendererGLContext::BIND_GENERATES_RESOURCES, 0, 134 RendererGLContext::BIND_GENERATES_RESOURCES, 0,
143 RendererGLContext::NONE, 135 RendererGLContext::NONE,
144 }; 136 };
145 137
146 const char* preferred_extensions = attributes_.noExtensions ? 138 const char* preferred_extensions = "*";
147 kWebGLPreferredGLExtensions : "*";
148 139
149 // We need to lock g_all_shared_contexts until after RendererGLContext::Create 140 // We need to lock g_all_shared_contexts until after RendererGLContext::Create
150 // to ensure that the context we picked for our share group isn't deleted. 141 // to ensure that the context we picked for our share group isn't deleted.
151 // (There's also a lock in our destructor.) 142 // (There's also a lock in our destructor.)
152 { 143 {
153 base::AutoLock lock(g_all_shared_contexts_lock.Get()); 144 base::AutoLock lock(g_all_shared_contexts_lock.Get());
154 RendererGLContext* share_group = NULL; 145 RendererGLContext* share_group = NULL;
155 if (attributes_.shareResources) { 146 if (attributes_.shareResources) {
156 share_group = g_all_shared_contexts.Pointer()->empty() ? 147 share_group = g_all_shared_contexts.Pointer()->empty() ?
157 NULL : (*g_all_shared_contexts.Pointer()->begin())->context_; 148 NULL : (*g_all_shared_contexts.Pointer()->begin())->context_;
(...skipping 15 matching lines...) Expand all
173 preferred_extensions, 164 preferred_extensions,
174 attribs, 165 attribs,
175 active_url_); 166 active_url_);
176 } 167 }
177 } 168 }
178 169
179 if (!context_) 170 if (!context_)
180 return false; 171 return false;
181 172
182 gl_ = context_->GetImplementation(); 173 gl_ = context_->GetImplementation();
174
175 // TODO(twiz): This code is too fragile in that it assumes that only WebGL
176 // contexts will request noExtensions.
177 if (gl_ && attributes_.noExtensions)
178 gl_->EnableFeatureCHROMIUM("webgl_enable_glsl_webgl_validation");
179
183 context_->SetContextLostCallback( 180 context_->SetContextLostCallback(
184 NewCallback(this, 181 NewCallback(this,
185 &WebGraphicsContext3DCommandBufferImpl::OnContextLost)); 182 &WebGraphicsContext3DCommandBufferImpl::OnContextLost));
186 183
187 // TODO(gman): Remove this. 184 // TODO(gman): Remove this.
188 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 185 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
189 if (command_line.HasSwitch(switches::kDisableGLSLTranslator)) { 186 if (command_line.HasSwitch(switches::kDisableGLSLTranslator)) {
190 context_->DisableShaderTranslation(); 187 context_->DisableShaderTranslation();
191 } 188 }
192 189
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 } 1090 }
1094 #ifndef WTF_USE_THREADED_COMPOSITING 1091 #ifndef WTF_USE_THREADED_COMPOSITING
1095 RenderView* renderview = 1092 RenderView* renderview =
1096 web_view_ ? RenderView::FromWebView(web_view_) : NULL; 1093 web_view_ ? RenderView::FromWebView(web_view_) : NULL;
1097 if (renderview) 1094 if (renderview)
1098 renderview->OnViewContextSwapBuffersAborted(); 1095 renderview->OnViewContextSwapBuffersAborted();
1099 #endif 1096 #endif
1100 } 1097 }
1101 1098
1102 #endif // defined(ENABLE_GPU) 1099 #endif // defined(ENABLE_GPU)
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698