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

Side by Side Diff: webkit/gpu/webgraphicscontext3d_in_process_impl.cc

Issue 7633076: Allow GraphicsContext3D to be created with a NULL WebView for offscreen (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 4 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
« no previous file with comments | « webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" 5 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 bool render_directly_to_web_view) { 107 bool render_directly_to_web_view) {
108 if (!gfx::GLSurface::InitializeOneOff()) 108 if (!gfx::GLSurface::InitializeOneOff())
109 return false; 109 return false;
110 gfx::BindSkiaToInProcessGL(); 110 gfx::BindSkiaToInProcessGL();
111 111
112 render_directly_to_web_view_ = render_directly_to_web_view; 112 render_directly_to_web_view_ = render_directly_to_web_view;
113 gfx::GLShareGroup* share_group = 0; 113 gfx::GLShareGroup* share_group = 0;
114 114
115 if (!render_directly_to_web_view) { 115 if (!render_directly_to_web_view) {
116 // Pick up the compositor's context to share resources with. 116 // Pick up the compositor's context to share resources with.
117 WebGraphicsContext3D* view_context = webView->graphicsContext3D(); 117 WebGraphicsContext3D* view_context = webView ?
118 webView->graphicsContext3D() : NULL;
118 if (view_context) { 119 if (view_context) {
119 WebGraphicsContext3DInProcessImpl* contextImpl = 120 WebGraphicsContext3DInProcessImpl* contextImpl =
120 static_cast<WebGraphicsContext3DInProcessImpl*>(view_context); 121 static_cast<WebGraphicsContext3DInProcessImpl*>(view_context);
121 share_group = contextImpl->gl_context_->share_group(); 122 share_group = contextImpl->gl_context_->share_group();
122 } else { 123 } else {
123 // The compositor's context didn't get created 124 // The compositor's context didn't get created
124 // successfully, so conceptually there is no way we can 125 // successfully, so conceptually there is no way we can
125 // render successfully to the WebView. 126 // render successfully to the WebView.
126 render_directly_to_web_view_ = false; 127 render_directly_to_web_view_ = false;
127 } 128 }
(...skipping 13 matching lines...) Expand all
141 if (!is_gles2_) 142 if (!is_gles2_)
142 return false; 143 return false;
143 144
144 // Embedded systems have smaller limit on number of GL contexts. Sometimes 145 // Embedded systems have smaller limit on number of GL contexts. Sometimes
145 // failure of GL context creation is because of existing GL contexts 146 // failure of GL context creation is because of existing GL contexts
146 // referenced by JavaScript garbages. Collect garbage and try again. 147 // referenced by JavaScript garbages. Collect garbage and try again.
147 // TODO: Besides this solution, kbr@chromium.org suggested: upon receiving 148 // TODO: Besides this solution, kbr@chromium.org suggested: upon receiving
148 // a page unload event, iterate down any live WebGraphicsContext3D instances 149 // a page unload event, iterate down any live WebGraphicsContext3D instances
149 // and force them to drop their contexts, sending a context lost event if 150 // and force them to drop their contexts, sending a context lost event if
150 // necessary. 151 // necessary.
151 webView->mainFrame()->collectGarbage(); 152 if (webView) webView->mainFrame()->collectGarbage();
152 153
153 gl_surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, 154 gl_surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false,
154 gfx::Size(1, 1)); 155 gfx::Size(1, 1));
155 if (!gl_surface_.get()) 156 if (!gl_surface_.get())
156 return false; 157 return false;
157 } 158 }
158 159
159 gl_context_ = gfx::GLContext::CreateGLContext(share_group, 160 gl_context_ = gfx::GLContext::CreateGLContext(share_group,
160 gl_surface_.get()); 161 gl_surface_.get());
161 if (!gl_context_.get()) { 162 if (!gl_context_.get()) {
162 if (!is_gles2_) 163 if (!is_gles2_)
163 return false; 164 return false;
164 165
165 // Embedded systems have smaller limit on number of GL contexts. Sometimes 166 // Embedded systems have smaller limit on number of GL contexts. Sometimes
166 // failure of GL context creation is because of existing GL contexts 167 // failure of GL context creation is because of existing GL contexts
167 // referenced by JavaScript garbages. Collect garbage and try again. 168 // referenced by JavaScript garbages. Collect garbage and try again.
168 // TODO: Besides this solution, kbr@chromium.org suggested: upon receiving 169 // TODO: Besides this solution, kbr@chromium.org suggested: upon receiving
169 // a page unload event, iterate down any live WebGraphicsContext3D instances 170 // a page unload event, iterate down any live WebGraphicsContext3D instances
170 // and force them to drop their contexts, sending a context lost event if 171 // and force them to drop their contexts, sending a context lost event if
171 // necessary. 172 // necessary.
172 webView->mainFrame()->collectGarbage(); 173 if (webView) webView->mainFrame()->collectGarbage();
173 174
174 gl_context_ = gfx::GLContext::CreateGLContext(share_group, 175 gl_context_ = gfx::GLContext::CreateGLContext(share_group,
175 gl_surface_.get()); 176 gl_surface_.get());
176 if (!gl_context_.get()) 177 if (!gl_context_.get())
177 return false; 178 return false;
178 } 179 }
179 180
180 attributes_ = attributes; 181 attributes_ = attributes;
181 182
182 // FIXME: for the moment we disable multisampling for the compositor. 183 // FIXME: for the moment we disable multisampling for the compositor.
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 } 1323 }
1323 1324
1324 DELEGATE_TO_GL_2(sampleCoverage, SampleCoverage, WGC3Dclampf, WGC3Dboolean) 1325 DELEGATE_TO_GL_2(sampleCoverage, SampleCoverage, WGC3Dclampf, WGC3Dboolean)
1325 1326
1326 DELEGATE_TO_GL_4(scissor, Scissor, WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei) 1327 DELEGATE_TO_GL_4(scissor, Scissor, WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei)
1327 1328
1328 void WebGraphicsContext3DInProcessImpl::texImage2D( 1329 void WebGraphicsContext3DInProcessImpl::texImage2D(
1329 WGC3Denum target, WGC3Dint level, WGC3Denum internalFormat, 1330 WGC3Denum target, WGC3Dint level, WGC3Denum internalFormat,
1330 WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border, 1331 WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border,
1331 WGC3Denum format, WGC3Denum type, const void* pixels) { 1332 WGC3Denum format, WGC3Denum type, const void* pixels) {
1332 if (width && height && !pixels) {
1333 synthesizeGLError(GL_INVALID_VALUE);
1334 return;
1335 }
1336 makeContextCurrent(); 1333 makeContextCurrent();
1337 glTexImage2D(target, level, internalFormat, 1334 glTexImage2D(target, level, internalFormat,
1338 width, height, border, format, type, pixels); 1335 width, height, border, format, type, pixels);
1339 } 1336 }
1340 1337
1341 void WebGraphicsContext3DInProcessImpl::shaderSource( 1338 void WebGraphicsContext3DInProcessImpl::shaderSource(
1342 WebGLId shader, const WGC3Dchar* source) { 1339 WebGLId shader, const WGC3Dchar* source) {
1343 makeContextCurrent(); 1340 makeContextCurrent();
1344 GLint length = source ? strlen(source) : 0; 1341 GLint length = source ? strlen(source) : 0;
1345 ShaderSourceMap::iterator result = shader_source_map_.find(shader); 1342 ShaderSourceMap::iterator result = shader_source_map_.find(shader);
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 if (length > 1) { 1625 if (length > 1) {
1629 entry->translated_source.reset(new char[length]); 1626 entry->translated_source.reset(new char[length]);
1630 ShGetObjectCode(compiler, entry->translated_source.get()); 1627 ShGetObjectCode(compiler, entry->translated_source.get());
1631 } 1628 }
1632 entry->is_valid = true; 1629 entry->is_valid = true;
1633 return true; 1630 return true;
1634 } 1631 }
1635 1632
1636 } // namespace gpu 1633 } // namespace gpu
1637 } // namespace webkit 1634 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698