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

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

Issue 7021014: GLContext no longer holds a pointer to a GLSurface. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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 #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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 glDeleteTextures(1, &texture_); 84 glDeleteTextures(1, &texture_);
85 glDeleteFramebuffersEXT(1, &copy_texture_to_parent_texture_fbo_); 85 glDeleteFramebuffersEXT(1, &copy_texture_to_parent_texture_fbo_);
86 #ifdef FLIP_FRAMEBUFFER_VERTICALLY 86 #ifdef FLIP_FRAMEBUFFER_VERTICALLY
87 if (scanline_) 87 if (scanline_)
88 delete[] scanline_; 88 delete[] scanline_;
89 #endif 89 #endif
90 glDeleteFramebuffersEXT(1, &fbo_); 90 glDeleteFramebuffersEXT(1, &fbo_);
91 91
92 gl_context_->Destroy(); 92 gl_context_->Destroy();
93 gl_surface_->Destroy();
93 94
94 for (ShaderSourceMap::iterator ii = shader_source_map_.begin(); 95 for (ShaderSourceMap::iterator ii = shader_source_map_.begin();
95 ii != shader_source_map_.end(); ++ii) { 96 ii != shader_source_map_.end(); ++ii) {
96 if (ii->second) 97 if (ii->second)
97 delete ii->second; 98 delete ii->second;
98 } 99 }
99 AngleDestroyCompilers(); 100 AngleDestroyCompilers();
100 } 101 }
101 102
102 bool WebGraphicsContext3DInProcessImpl::initialize( 103 bool WebGraphicsContext3DInProcessImpl::initialize(
(...skipping 23 matching lines...) Expand all
126 } 127 }
127 128
128 is_gles2_ = gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2; 129 is_gles2_ = gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2;
129 130
130 // This implementation always renders offscreen regardless of 131 // This implementation always renders offscreen regardless of
131 // whether render_directly_to_web_view is true. Both DumpRenderTree 132 // whether render_directly_to_web_view is true. Both DumpRenderTree
132 // and test_shell paint first to an intermediate offscreen buffer 133 // and test_shell paint first to an intermediate offscreen buffer
133 // and from there to the window, and WebViewImpl::paint already 134 // and from there to the window, and WebViewImpl::paint already
134 // correctly handles the case where the compositor is active but 135 // correctly handles the case where the compositor is active but
135 // the output needs to go to a WebCanvas. 136 // the output needs to go to a WebCanvas.
136 scoped_ptr<gfx::GLSurface> surface(gfx::GLSurface::CreateOffscreenGLSurface( 137 gl_surface_.reset(gfx::GLSurface::CreateOffscreenGLSurface(
137 gfx::Size(1, 1))); 138 gfx::Size(1, 1)));
138 if (!surface.get()) { 139 if (!gl_surface_.get()) {
139 if (!is_gles2_) 140 if (!is_gles2_)
140 return false; 141 return false;
141 142
142 // Embedded systems have smaller limit on number of GL contexts. Sometimes 143 // Embedded systems have smaller limit on number of GL contexts. Sometimes
143 // failure of GL context creation is because of existing GL contexts 144 // failure of GL context creation is because of existing GL contexts
144 // referenced by JavaScript garbages. Collect garbage and try again. 145 // referenced by JavaScript garbages. Collect garbage and try again.
145 // TODO: Besides this solution, kbr@chromium.org suggested: upon receiving 146 // TODO: Besides this solution, kbr@chromium.org suggested: upon receiving
146 // a page unload event, iterate down any live WebGraphicsContext3D instances 147 // a page unload event, iterate down any live WebGraphicsContext3D instances
147 // and force them to drop their contexts, sending a context lost event if 148 // and force them to drop their contexts, sending a context lost event if
148 // necessary. 149 // necessary.
149 webView->mainFrame()->collectGarbage(); 150 webView->mainFrame()->collectGarbage();
150 surface.reset(gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1))); 151 gl_surface_.reset(
151 if (!surface.get()) 152 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)));
153 if (!gl_surface_.get())
152 return false; 154 return false;
153 } 155 }
154 156
155 gl_context_.reset(gfx::GLContext::CreateGLContext(surface.release(), 157 gl_context_.reset(gfx::GLContext::CreateGLContext(share_context));
156 share_context));
157 if (!gl_context_.get()) 158 if (!gl_context_.get())
158 return false; 159 return false;
159 160
160 attributes_ = attributes; 161 attributes_ = attributes;
161 162
162 // FIXME: for the moment we disable multisampling for the compositor. 163 // FIXME: for the moment we disable multisampling for the compositor.
163 // It actually works in this implementation, but there are a few 164 // It actually works in this implementation, but there are a few
164 // considerations. First, we likely want to reduce the fuzziness in 165 // considerations. First, we likely want to reduce the fuzziness in
165 // these tests as much as possible because we want to run pixel tests. 166 // these tests as much as possible because we want to run pixel tests.
166 // Second, Mesa's multisampling doesn't seem to antialias straight 167 // Second, Mesa's multisampling doesn't seem to antialias straight
167 // edges in some CSS 3D samples. Third, we don't have multisampling 168 // edges in some CSS 3D samples. Third, we don't have multisampling
168 // support for the compositor in the normal case at the time of this 169 // support for the compositor in the normal case at the time of this
169 // writing. 170 // writing.
170 if (render_directly_to_web_view) 171 if (render_directly_to_web_view)
171 attributes_.antialias = false; 172 attributes_.antialias = false;
172 173
173 if (!gl_context_->MakeCurrent()) { 174 if (!gl_context_->MakeCurrent(gl_surface_.get())) {
174 gl_context_.reset(); 175 gl_context_.reset();
175 return false; 176 return false;
176 } 177 }
177 178
178 const char* extensions = 179 const char* extensions =
179 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)); 180 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
180 DCHECK(extensions); 181 DCHECK(extensions);
181 have_ext_framebuffer_object_ = 182 have_ext_framebuffer_object_ =
182 strstr(extensions, "GL_EXT_framebuffer_object") != NULL; 183 strstr(extensions, "GL_EXT_framebuffer_object") != NULL;
183 have_ext_framebuffer_multisample_ = 184 have_ext_framebuffer_multisample_ =
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 x + width, y + height, 259 x + width, y + height,
259 x, y, 260 x, y,
260 x + width, y + height, 261 x + width, y + height,
261 GL_COLOR_BUFFER_BIT, GL_NEAREST); 262 GL_COLOR_BUFFER_BIT, GL_NEAREST);
262 } 263 }
263 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, bound_fbo_); 264 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, bound_fbo_);
264 } 265 }
265 } 266 }
266 267
267 bool WebGraphicsContext3DInProcessImpl::makeContextCurrent() { 268 bool WebGraphicsContext3DInProcessImpl::makeContextCurrent() {
268 return gl_context_->MakeCurrent(); 269 return gl_context_->MakeCurrent(gl_surface_.get());
269 } 270 }
270 271
271 int WebGraphicsContext3DInProcessImpl::width() { 272 int WebGraphicsContext3DInProcessImpl::width() {
272 return cached_width_; 273 return cached_width_;
273 } 274 }
274 275
275 int WebGraphicsContext3DInProcessImpl::height() { 276 int WebGraphicsContext3DInProcessImpl::height() {
276 return cached_height_; 277 return cached_height_;
277 } 278 }
278 279
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 strncpy(entry->translated_source.get(), entry->source.get(), length); 1635 strncpy(entry->translated_source.get(), entry->source.get(), length);
1635 else 1636 else
1636 ShGetObjectCode(compiler, entry->translated_source.get()); 1637 ShGetObjectCode(compiler, entry->translated_source.get());
1637 } 1638 }
1638 entry->is_valid = true; 1639 entry->is_valid = true;
1639 return true; 1640 return true;
1640 } 1641 }
1641 1642
1642 } // namespace gpu 1643 } // namespace gpu
1643 } // namespace webkit 1644 } // namespace webkit
OLDNEW
« ui/gfx/gl/gl_context_glx.cc ('K') | « webkit/gpu/webgraphicscontext3d_in_process_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698