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: content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc

Issue 1790753002: Expose GLES2Interface to blink, and delete isContextLost() from WGC3D. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wgc3d: deps-for-tests Created 4 years, 9 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 "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 5 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
6 6
7 #include "third_party/khronos/GLES2/gl2.h" 7 #include "third_party/khronos/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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 DCHECK(host_.get()); 242 DCHECK(host_.get());
243 243
244 // Create the object exposing the OpenGL API. 244 // Create the object exposing the OpenGL API.
245 const bool bind_generates_resources = false; 245 const bool bind_generates_resources = false;
246 const bool support_client_side_arrays = false; 246 const bool support_client_side_arrays = false;
247 247
248 real_gl_.reset(new gpu::gles2::GLES2Implementation( 248 real_gl_.reset(new gpu::gles2::GLES2Implementation(
249 gles2_helper_.get(), gles2_share_group.get(), transfer_buffer_.get(), 249 gles2_helper_.get(), gles2_share_group.get(), transfer_buffer_.get(),
250 bind_generates_resources, lose_context_when_out_of_memory_, 250 bind_generates_resources, lose_context_when_out_of_memory_,
251 support_client_side_arrays, command_buffer_.get())); 251 support_client_side_arrays, command_buffer_.get()));
252 setGLInterface(real_gl_.get()); 252 SetGLInterface(real_gl_.get());
253 253
254 if (!real_gl_->Initialize( 254 if (!real_gl_->Initialize(
255 mem_limits_.start_transfer_buffer_size, 255 mem_limits_.start_transfer_buffer_size,
256 mem_limits_.min_transfer_buffer_size, 256 mem_limits_.min_transfer_buffer_size,
257 mem_limits_.max_transfer_buffer_size, 257 mem_limits_.max_transfer_buffer_size,
258 mem_limits_.mapped_memory_reclaim_limit)) { 258 mem_limits_.mapped_memory_reclaim_limit)) {
259 LOG(ERROR) << "Failed to initialize GLES2Implementation."; 259 LOG(ERROR) << "Failed to initialize GLES2Implementation.";
260 return false; 260 return false;
261 } 261 }
262 262
263 if (add_to_share_group) 263 if (add_to_share_group)
264 share_group_->AddContextLocked(this); 264 share_group_->AddContextLocked(this);
265 265
266 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 266 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
267 switches::kEnableGpuClientTracing)) { 267 switches::kEnableGpuClientTracing)) {
268 trace_gl_.reset(new gpu::gles2::GLES2TraceImplementation(GetGLInterface())); 268 trace_gl_.reset(new gpu::gles2::GLES2TraceImplementation(GetGLInterface()));
269 setGLInterface(trace_gl_.get()); 269 SetGLInterface(trace_gl_.get());
270 } 270 }
271 return true; 271 return true;
272 } 272 }
273 273
274 bool WebGraphicsContext3DCommandBufferImpl::InitializeOnCurrentThread() { 274 bool WebGraphicsContext3DCommandBufferImpl::InitializeOnCurrentThread() {
275 if (!MaybeInitializeGL()) { 275 if (!MaybeInitializeGL()) {
276 DLOG(ERROR) << "Failed to initialize context."; 276 DLOG(ERROR) << "Failed to initialize context.";
277 return false; 277 return false;
278 } 278 }
279 if (gpu::error::IsError(command_buffer_->GetLastError())) { 279 if (gpu::error::IsError(command_buffer_->GetLastError())) {
280 LOG(ERROR) << "Context dead on arrival. Last error: " 280 LOG(ERROR) << "Context dead on arrival. Last error: "
281 << command_buffer_->GetLastError(); 281 << command_buffer_->GetLastError();
282 return false; 282 return false;
283 } 283 }
284 284
285 return true; 285 return true;
286 } 286 }
287 287
288 void WebGraphicsContext3DCommandBufferImpl::Destroy() { 288 void WebGraphicsContext3DCommandBufferImpl::Destroy() {
289 share_group_->RemoveContext(this); 289 share_group_->RemoveContext(this);
290 290
291 gpu::gles2::GLES2Interface* gl = GetGLInterface(); 291 gpu::gles2::GLES2Interface* gl = GetGLInterface();
292 if (gl) { 292 if (gl) {
293 // First flush the context to ensure that any pending frees of resources 293 // First flush the context to ensure that any pending frees of resources
294 // are completed. Otherwise, if this context is part of a share group, 294 // are completed. Otherwise, if this context is part of a share group,
295 // those resources might leak. Also, any remaining side effects of commands 295 // those resources might leak. Also, any remaining side effects of commands
296 // issued on this context might not be visible to other contexts in the 296 // issued on this context might not be visible to other contexts in the
297 // share group. 297 // share group.
298 gl->Flush(); 298 gl->Flush();
299 setGLInterface(NULL); 299 SetGLInterface(nullptr);
300 } 300 }
301 301
302 trace_gl_.reset(); 302 trace_gl_.reset();
303 real_gl_.reset(); 303 real_gl_.reset();
304 transfer_buffer_.reset(); 304 transfer_buffer_.reset();
305 gles2_helper_.reset(); 305 gles2_helper_.reset();
306 real_gl_.reset(); 306 real_gl_.reset();
307 command_buffer_.reset(); 307 command_buffer_.reset();
308 308
309 host_ = NULL; 309 host_ = nullptr;
310 } 310 }
311 311
312 gpu::ContextSupport* 312 gpu::ContextSupport*
313 WebGraphicsContext3DCommandBufferImpl::GetContextSupport() { 313 WebGraphicsContext3DCommandBufferImpl::GetContextSupport() {
314 return real_gl_.get(); 314 return real_gl_.get();
315 } 315 }
316 316
317 bool WebGraphicsContext3DCommandBufferImpl::IsCommandBufferContextLost() { 317 bool WebGraphicsContext3DCommandBufferImpl::IsCommandBufferContextLost() {
318 // If the channel shut down unexpectedly, let that supersede the 318 // If the channel shut down unexpectedly, let that supersede the
319 // command buffer's state. 319 // command buffer's state.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 { 358 {
359 base::AutoLock lock(g_default_share_groups_lock.Get()); 359 base::AutoLock lock(g_default_share_groups_lock.Get());
360 g_default_share_groups.Get().erase(host_.get()); 360 g_default_share_groups.Get().erase(host_.get());
361 } 361 }
362 362
363 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); 363 gpu::CommandBuffer::State state = command_buffer_->GetLastState();
364 UmaRecordContextLost(context_type_, state.error, state.context_lost_reason); 364 UmaRecordContextLost(context_type_, state.error, state.context_lost_reason);
365 } 365 }
366 366
367 } // namespace content 367 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698