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

Side by Side Diff: content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc

Issue 1864723003: Make lost context and error message callbacks on GpuControl go to client (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: errorcallback: blimp Created 4 years, 8 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } else if (share_resources) { 113 } else if (share_resources) {
114 share_group_ = GetDefaultShareGroupForHost(host); 114 share_group_ = GetDefaultShareGroupForHost(host);
115 } else { 115 } else {
116 share_group_ = make_scoped_refptr(new ShareGroup); 116 share_group_ = make_scoped_refptr(new ShareGroup);
117 } 117 }
118 } 118 }
119 119
120 WebGraphicsContext3DCommandBufferImpl:: 120 WebGraphicsContext3DCommandBufferImpl::
121 ~WebGraphicsContext3DCommandBufferImpl() { 121 ~WebGraphicsContext3DCommandBufferImpl() {
122 if (real_gl_) { 122 if (real_gl_) {
123 real_gl_->SetErrorMessageCallback(NULL); 123 real_gl_->SetErrorMessageCallback(
124 base::Callback<void(const char*, int32_t)>());
125 real_gl_->SetLostContextCallback(base::Closure());
124 } 126 }
125 127
126 Destroy(); 128 Destroy();
127 } 129 }
128 130
129 bool WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL() { 131 bool WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL() {
130 if (initialized_) 132 if (initialized_)
131 return true; 133 return true;
132 134
133 if (initialize_failed_) 135 if (initialize_failed_)
134 return false; 136 return false;
135 137
136 TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::MaybeInitializeGL"); 138 TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::MaybeInitializeGL");
137 139
138 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is fixed. 140 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is fixed.
139 tracked_objects::ScopedTracker tracking_profile( 141 tracked_objects::ScopedTracker tracking_profile(
140 FROM_HERE_WITH_EXPLICIT_FUNCTION( 142 FROM_HERE_WITH_EXPLICIT_FUNCTION(
141 "125248 WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL")); 143 "125248 WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL"));
142 144
143 if (!CreateContext()) { 145 if (!CreateContext()) {
144 Destroy(); 146 Destroy();
145 147
146 initialize_failed_ = true; 148 initialize_failed_ = true;
147 return false; 149 return false;
148 } 150 }
149 151
150 command_buffer_->SetContextLostCallback( 152 real_gl_->SetErrorMessageCallback(
153 // This method is in WebGraphicsContext3DImpl.
154 base::Bind(&WebGraphicsContext3DCommandBufferImpl::OnErrorMessage,
155 // The callback is unset in the destructor.
156 base::Unretained(this)));
157 real_gl_->SetLostContextCallback(
151 base::Bind(&WebGraphicsContext3DCommandBufferImpl::OnContextLost, 158 base::Bind(&WebGraphicsContext3DCommandBufferImpl::OnContextLost,
152 weak_ptr_factory_.GetWeakPtr())); 159 // The callback is unset in the destructor.
160 base::Unretained(this)));
153 161
154 command_buffer_->SetOnConsoleMessageCallback(
155 base::Bind(&WebGraphicsContext3DCommandBufferImpl::OnErrorMessage,
156 weak_ptr_factory_.GetWeakPtr()));
157
158 real_gl_->SetErrorMessageCallback(getErrorMessageCallback());
159 real_gl_->TraceBeginCHROMIUM("WebGraphicsContext3D", 162 real_gl_->TraceBeginCHROMIUM("WebGraphicsContext3D",
160 "CommandBufferContext"); 163 "CommandBufferContext");
161 164
162 initialized_ = true; 165 initialized_ = true;
163 return true; 166 return true;
164 } 167 }
165 168
166 bool WebGraphicsContext3DCommandBufferImpl::InitializeCommandBuffer( 169 bool WebGraphicsContext3DCommandBufferImpl::InitializeCommandBuffer(
167 WebGraphicsContext3DCommandBufferImpl* share_context) { 170 WebGraphicsContext3DCommandBufferImpl* share_context) {
168 if (!host_.get()) 171 if (!host_.get())
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 { 359 {
357 base::AutoLock lock(g_default_share_groups_lock.Get()); 360 base::AutoLock lock(g_default_share_groups_lock.Get());
358 g_default_share_groups.Get().erase(host_.get()); 361 g_default_share_groups.Get().erase(host_.get());
359 } 362 }
360 363
361 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); 364 gpu::CommandBuffer::State state = command_buffer_->GetLastState();
362 UmaRecordContextLost(context_type_, state.error, state.context_lost_reason); 365 UmaRecordContextLost(context_type_, state.error, state.context_lost_reason);
363 } 366 }
364 367
365 } // namespace content 368 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698