OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/gpu/webgraphicscontext3d_in_process_impl.h" | 5 #include "webkit/common/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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 WebGraphicsContext3DInProcessImpl* | 118 WebGraphicsContext3DInProcessImpl* |
119 WebGraphicsContext3DInProcessImpl::CreateForWindow( | 119 WebGraphicsContext3DInProcessImpl::CreateForWindow( |
120 WebGraphicsContext3D::Attributes attributes, | 120 WebGraphicsContext3D::Attributes attributes, |
121 gfx::AcceleratedWidget window, | 121 gfx::AcceleratedWidget window, |
122 gfx::GLShareGroup* share_group) { | 122 gfx::GLShareGroup* share_group) { |
123 if (!gfx::GLSurface::InitializeOneOff()) | 123 if (!gfx::GLSurface::InitializeOneOff()) |
124 return NULL; | 124 return NULL; |
125 | 125 |
126 scoped_refptr<gfx::GLSurface> gl_surface = | 126 scoped_refptr<gfx::GLSurface> gl_surface = |
127 gfx::GLSurface::CreateViewGLSurface(false, window); | 127 gfx::GLSurface::CreateViewGLSurface(false, window); |
128 if (!gl_surface) | 128 if (!gl_surface.get()) |
129 return NULL; | 129 return NULL; |
130 | 130 |
131 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; | 131 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
132 | 132 |
133 scoped_refptr<gfx::GLContext> gl_context = gfx::GLContext::CreateGLContext( | 133 scoped_refptr<gfx::GLContext> gl_context = gfx::GLContext::CreateGLContext( |
134 share_group, | 134 share_group, |
135 gl_surface.get(), | 135 gl_surface.get(), |
136 gpu_preference); | 136 gpu_preference); |
137 if (!gl_context) | 137 if (!gl_context.get()) |
138 return NULL; | 138 return NULL; |
139 scoped_ptr<WebGraphicsContext3DInProcessImpl> context( | 139 scoped_ptr<WebGraphicsContext3DInProcessImpl> context( |
140 new WebGraphicsContext3DInProcessImpl( | 140 new WebGraphicsContext3DInProcessImpl( |
141 gl_surface.get(), gl_context.get(), true)); | 141 gl_surface.get(), gl_context.get(), true)); |
142 if (!context->Initialize(attributes)) | 142 if (!context->Initialize(attributes)) |
143 return NULL; | 143 return NULL; |
144 return context.release(); | 144 return context.release(); |
145 } | 145 } |
146 | 146 |
147 bool WebGraphicsContext3DInProcessImpl::Initialize( | 147 bool WebGraphicsContext3DInProcessImpl::Initialize( |
148 WebGraphicsContext3D::Attributes attributes) { | 148 WebGraphicsContext3D::Attributes attributes) { |
149 is_gles2_ = gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2; | 149 is_gles2_ = gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2; |
150 | 150 |
151 | 151 |
152 attributes_ = attributes; | 152 attributes_ = attributes; |
153 | 153 |
154 // FIXME: for the moment we disable multisampling for the compositor. | 154 // FIXME: for the moment we disable multisampling for the compositor. |
155 // It actually works in this implementation, but there are a few | 155 // It actually works in this implementation, but there are a few |
156 // considerations. First, we likely want to reduce the fuzziness in | 156 // considerations. First, we likely want to reduce the fuzziness in |
157 // these tests as much as possible because we want to run pixel tests. | 157 // these tests as much as possible because we want to run pixel tests. |
158 // Second, Mesa's multisampling doesn't seem to antialias straight | 158 // Second, Mesa's multisampling doesn't seem to antialias straight |
159 // edges in some CSS 3D samples. Third, we don't have multisampling | 159 // edges in some CSS 3D samples. Third, we don't have multisampling |
160 // support for the compositor in the normal case at the time of this | 160 // support for the compositor in the normal case at the time of this |
161 // writing. | 161 // writing. |
162 if (render_directly_to_web_view_) | 162 if (render_directly_to_web_view_) |
163 attributes_.antialias = false; | 163 attributes_.antialias = false; |
164 | 164 |
165 if (!gl_context_->MakeCurrent(gl_surface_)) { | 165 if (!gl_context_->MakeCurrent(gl_surface_.get())) { |
166 gl_context_ = NULL; | 166 gl_context_ = NULL; |
167 return false; | 167 return false; |
168 } | 168 } |
169 | 169 |
170 const char* extensions = | 170 const char* extensions = |
171 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)); | 171 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)); |
172 DCHECK(extensions); | 172 DCHECK(extensions); |
173 have_ext_framebuffer_object_ = | 173 have_ext_framebuffer_object_ = |
174 strstr(extensions, "GL_EXT_framebuffer_object") != NULL; | 174 strstr(extensions, "GL_EXT_framebuffer_object") != NULL; |
175 have_ext_framebuffer_multisample_ = | 175 have_ext_framebuffer_multisample_ = |
(...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1804 if (length > 1) { | 1804 if (length > 1) { |
1805 entry->translated_source.reset(new char[length]); | 1805 entry->translated_source.reset(new char[length]); |
1806 ShGetObjectCode(compiler, entry->translated_source.get()); | 1806 ShGetObjectCode(compiler, entry->translated_source.get()); |
1807 } | 1807 } |
1808 entry->is_valid = true; | 1808 entry->is_valid = true; |
1809 return true; | 1809 return true; |
1810 } | 1810 } |
1811 | 1811 |
1812 } // namespace gpu | 1812 } // namespace gpu |
1813 } // namespace webkit | 1813 } // namespace webkit |
OLD | NEW |