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

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: 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 DCHECK(host_.get()); 251 DCHECK(host_.get());
252 252
253 // Create the object exposing the OpenGL API. 253 // Create the object exposing the OpenGL API.
254 const bool bind_generates_resources = false; 254 const bool bind_generates_resources = false;
255 const bool support_client_side_arrays = false; 255 const bool support_client_side_arrays = false;
256 256
257 real_gl_.reset(new gpu::gles2::GLES2Implementation( 257 real_gl_.reset(new gpu::gles2::GLES2Implementation(
258 gles2_helper_.get(), gles2_share_group.get(), transfer_buffer_.get(), 258 gles2_helper_.get(), gles2_share_group.get(), transfer_buffer_.get(),
259 bind_generates_resources, lose_context_when_out_of_memory_, 259 bind_generates_resources, lose_context_when_out_of_memory_,
260 support_client_side_arrays, command_buffer_.get())); 260 support_client_side_arrays, command_buffer_.get()));
261 setGLInterface(real_gl_.get()); 261 SetGLInterface(real_gl_.get());
262 262
263 if (!real_gl_->Initialize( 263 if (!real_gl_->Initialize(
264 mem_limits_.start_transfer_buffer_size, 264 mem_limits_.start_transfer_buffer_size,
265 mem_limits_.min_transfer_buffer_size, 265 mem_limits_.min_transfer_buffer_size,
266 mem_limits_.max_transfer_buffer_size, 266 mem_limits_.max_transfer_buffer_size,
267 mem_limits_.mapped_memory_reclaim_limit)) { 267 mem_limits_.mapped_memory_reclaim_limit)) {
268 LOG(ERROR) << "Failed to initialize GLES2Implementation."; 268 LOG(ERROR) << "Failed to initialize GLES2Implementation.";
269 return false; 269 return false;
270 } 270 }
271 271
272 if (add_to_share_group) 272 if (add_to_share_group)
273 share_group_->AddContextLocked(this); 273 share_group_->AddContextLocked(this);
274 274
275 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 275 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
276 switches::kEnableGpuClientTracing)) { 276 switches::kEnableGpuClientTracing)) {
277 trace_gl_.reset(new gpu::gles2::GLES2TraceImplementation(GetGLInterface())); 277 trace_gl_.reset(new gpu::gles2::GLES2TraceImplementation(GetGLInterface()));
278 setGLInterface(trace_gl_.get()); 278 SetGLInterface(trace_gl_.get());
279 } 279 }
280 return true; 280 return true;
281 } 281 }
282 282
283 bool WebGraphicsContext3DCommandBufferImpl::InitializeOnCurrentThread() { 283 bool WebGraphicsContext3DCommandBufferImpl::InitializeOnCurrentThread() {
284 if (!MaybeInitializeGL()) { 284 if (!MaybeInitializeGL()) {
285 DLOG(ERROR) << "Failed to initialize context."; 285 DLOG(ERROR) << "Failed to initialize context.";
286 return false; 286 return false;
287 } 287 }
288 if (gpu::error::IsError(command_buffer_->GetLastError())) { 288 if (gpu::error::IsError(command_buffer_->GetLastError())) {
289 LOG(ERROR) << "Context dead on arrival. Last error: " 289 LOG(ERROR) << "Context dead on arrival. Last error: "
290 << command_buffer_->GetLastError(); 290 << command_buffer_->GetLastError();
291 return false; 291 return false;
292 } 292 }
293 293
294 return true; 294 return true;
295 } 295 }
296 296
297 void WebGraphicsContext3DCommandBufferImpl::Destroy() { 297 void WebGraphicsContext3DCommandBufferImpl::Destroy() {
298 share_group_->RemoveContext(this); 298 share_group_->RemoveContext(this);
299 299
300 gpu::gles2::GLES2Interface* gl = GetGLInterface(); 300 gpu::gles2::GLES2Interface* gl = GetGLInterface();
301 if (gl) { 301 if (gl) {
302 // First flush the context to ensure that any pending frees of resources 302 // First flush the context to ensure that any pending frees of resources
303 // are completed. Otherwise, if this context is part of a share group, 303 // are completed. Otherwise, if this context is part of a share group,
304 // those resources might leak. Also, any remaining side effects of commands 304 // those resources might leak. Also, any remaining side effects of commands
305 // issued on this context might not be visible to other contexts in the 305 // issued on this context might not be visible to other contexts in the
306 // share group. 306 // share group.
307 gl->Flush(); 307 gl->Flush();
308 setGLInterface(NULL); 308 SetGLInterface(nullptr);
309 } 309 }
310 310
311 trace_gl_.reset(); 311 trace_gl_.reset();
312 real_gl_.reset(); 312 real_gl_.reset();
313 transfer_buffer_.reset(); 313 transfer_buffer_.reset();
314 gles2_helper_.reset(); 314 gles2_helper_.reset();
315 real_gl_.reset(); 315 real_gl_.reset();
316 command_buffer_.reset(); 316 command_buffer_.reset();
317 317
318 host_ = NULL; 318 host_ = nullptr;
319 } 319 }
320 320
321 gpu::ContextSupport* 321 gpu::ContextSupport*
322 WebGraphicsContext3DCommandBufferImpl::GetContextSupport() { 322 WebGraphicsContext3DCommandBufferImpl::GetContextSupport() {
323 return real_gl_.get(); 323 return real_gl_.get();
324 } 324 }
325 325
326 bool WebGraphicsContext3DCommandBufferImpl::IsCommandBufferContextLost() { 326 bool WebGraphicsContext3DCommandBufferImpl::IsCommandBufferContextLost() {
327 // If the channel shut down unexpectedly, let that supersede the 327 // If the channel shut down unexpectedly, let that supersede the
328 // command buffer's state. 328 // command buffer's state.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 { 367 {
368 base::AutoLock lock(g_default_share_groups_lock.Get()); 368 base::AutoLock lock(g_default_share_groups_lock.Get());
369 g_default_share_groups.Get().erase(host_.get()); 369 g_default_share_groups.Get().erase(host_.get());
370 } 370 }
371 371
372 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); 372 gpu::CommandBuffer::State state = command_buffer_->GetLastState();
373 UmaRecordContextLost(context_type_, state.error, state.context_lost_reason); 373 UmaRecordContextLost(context_type_, state.error, state.context_lost_reason);
374 } 374 }
375 375
376 } // namespace content 376 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698