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

Side by Side Diff: webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc

Issue 470973002: gpu: Remove WebGraphicsContext3D::makeContextCurrent() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use scoped_ptr and remove unrelated changes. Created 6 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
OLDNEW
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_command_buffer_impl. h" 5 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h"
6 6
7 #include <GLES2/gl2.h> 7 #include <GLES2/gl2.h>
8 #ifndef GL_GLEXT_PROTOTYPES 8 #ifndef GL_GLEXT_PROTOTYPES
9 #define GL_GLEXT_PROTOTYPES 1 9 #define GL_GLEXT_PROTOTYPES 1
10 #endif 10 #endif
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 119 }
120 120
121 bool WebGraphicsContext3DInProcessCommandBufferImpl::MaybeInitializeGL() { 121 bool WebGraphicsContext3DInProcessCommandBufferImpl::MaybeInitializeGL() {
122 if (initialized_) 122 if (initialized_)
123 return true; 123 return true;
124 124
125 if (initialize_failed_) 125 if (initialize_failed_)
126 return false; 126 return false;
127 127
128 // Ensure the gles2 library is initialized first in a thread safe way. 128 // Ensure the gles2 library is initialized first in a thread safe way.
129 g_gles2_initializer.Get(); 129 g_gles2_initializer.Get();
piman 2014/08/15 17:47:34 Same comment here.
130 130
131 if (!context_) { 131 if (!context_) {
132 // TODO(kbr): More work will be needed in this implementation to 132 // TODO(kbr): More work will be needed in this implementation to
133 // properly support GPU switching. Like in the out-of-process 133 // properly support GPU switching. Like in the out-of-process
134 // command buffer implementation, all previously created contexts 134 // command buffer implementation, all previously created contexts
135 // will need to be lost either when the first context requesting the 135 // will need to be lost either when the first context requesting the
136 // discrete GPU is created, or the last one is destroyed. 136 // discrete GPU is created, or the last one is destroyed.
137 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; 137 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
138 context_.reset(GLInProcessContext::Create(NULL, /* service */ 138 context_.reset(GLInProcessContext::Create(NULL, /* service */
139 NULL, /* surface */ 139 NULL, /* surface */
(...skipping 19 matching lines...) Expand all
159 real_gl_ = context_->GetImplementation(); 159 real_gl_ = context_->GetImplementation();
160 setGLInterface(real_gl_); 160 setGLInterface(real_gl_);
161 161
162 if (real_gl_ && webgl_context_) 162 if (real_gl_ && webgl_context_)
163 real_gl_->EnableFeatureCHROMIUM("webgl_enable_glsl_webgl_validation"); 163 real_gl_->EnableFeatureCHROMIUM("webgl_enable_glsl_webgl_validation");
164 164
165 initialized_ = true; 165 initialized_ = true;
166 return true; 166 return true;
167 } 167 }
168 168
169 bool WebGraphicsContext3DInProcessCommandBufferImpl::makeContextCurrent() { 169 bool WebGraphicsContext3DInProcessCommandBufferImpl::BindToCurrentThread() {
170 if (!MaybeInitializeGL()) 170 if (!MaybeInitializeGL())
171 return false; 171 return false;
172 ::gles2::SetGLContext(GetGLInterface());
173 return context_ && !isContextLost(); 172 return context_ && !isContextLost();
174 } 173 }
175 174
176 bool WebGraphicsContext3DInProcessCommandBufferImpl::isContextLost() { 175 bool WebGraphicsContext3DInProcessCommandBufferImpl::isContextLost() {
177 return context_lost_reason_ != GL_NO_ERROR; 176 return context_lost_reason_ != GL_NO_ERROR;
178 } 177 }
179 178
180 WGC3Denum WebGraphicsContext3DInProcessCommandBufferImpl:: 179 WGC3Denum WebGraphicsContext3DInProcessCommandBufferImpl::
181 getGraphicsResetStatusARB() { 180 getGraphicsResetStatusARB() {
182 return context_lost_reason_; 181 return context_lost_reason_;
183 } 182 }
184 183
185 ::gpu::ContextSupport* 184 ::gpu::ContextSupport*
186 WebGraphicsContext3DInProcessCommandBufferImpl::GetContextSupport() { 185 WebGraphicsContext3DInProcessCommandBufferImpl::GetContextSupport() {
187 return real_gl_; 186 return real_gl_;
188 } 187 }
189 188
190 void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() { 189 void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() {
191 // TODO(kbr): improve the precision here. 190 // TODO(kbr): improve the precision here.
192 context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB; 191 context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB;
193 if (context_lost_callback_) { 192 if (context_lost_callback_) {
194 context_lost_callback_->onContextLost(); 193 context_lost_callback_->onContextLost();
195 } 194 }
196 } 195 }
197 196
198 } // namespace gpu 197 } // namespace gpu
199 } // namespace webkit 198 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698