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

Side by Side Diff: content/renderer/gpu/renderer_gl_context.cc

Issue 7838008: Revert 99648 - Reland 98392 - Split WebGraphicsContext3DCommandBufferImpl::initialize() into two ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/renderer/gpu/renderer_gl_context.h" 5 #include "content/renderer/gpu/renderer_gl_context.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 gles2_implementation_->DeleteTextures(1, &texture); 192 gles2_implementation_->DeleteTextures(1, &texture);
193 } 193 }
194 194
195 void RendererGLContext::SetContextLostCallback( 195 void RendererGLContext::SetContextLostCallback(
196 Callback1<ContextLostReason>::Type* callback) { 196 Callback1<ContextLostReason>::Type* callback) {
197 context_lost_callback_.reset(callback); 197 context_lost_callback_.reset(callback);
198 } 198 }
199 199
200 bool RendererGLContext::MakeCurrent(RendererGLContext* context) { 200 bool RendererGLContext::MakeCurrent(RendererGLContext* context) {
201 if (context) { 201 if (context) {
202 DCHECK(context->CalledOnValidThread());
203 gles2::SetGLContext(context->gles2_implementation_); 202 gles2::SetGLContext(context->gles2_implementation_);
204 203
205 // Don't request latest error status from service. Just use the locally 204 // Don't request latest error status from service. Just use the locally
206 // cached information from the last flush. 205 // cached information from the last flush.
207 // TODO(apatrick): I'm not sure if this should actually change the 206 // TODO(apatrick): I'm not sure if this should actually change the
208 // current context if it fails. For now it gets changed even if it fails 207 // current context if it fails. For now it gets changed even if it fails
209 // because making GL calls with a NULL context crashes. 208 // because making GL calls with a NULL context crashes.
210 if (context->command_buffer_->GetLastState().error != gpu::error::kNoError) 209 if (context->command_buffer_->GetLastState().error != gpu::error::kNoError)
211 return false; 210 return false;
212 } else { 211 } else {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 DCHECK(channel); 283 DCHECK(channel);
285 } 284 }
286 285
287 bool RendererGLContext::Initialize(bool onscreen, 286 bool RendererGLContext::Initialize(bool onscreen,
288 int render_view_id, 287 int render_view_id,
289 const gfx::Size& size, 288 const gfx::Size& size,
290 RendererGLContext* share_group, 289 RendererGLContext* share_group,
291 const char* allowed_extensions, 290 const char* allowed_extensions,
292 const int32* attrib_list, 291 const int32* attrib_list,
293 const GURL& active_url) { 292 const GURL& active_url) {
294 DCHECK(CalledOnValidThread());
295 DCHECK(size.width() >= 0 && size.height() >= 0); 293 DCHECK(size.width() >= 0 && size.height() >= 0);
296 TRACE_EVENT2("gpu", "RendererGLContext::Initialize", 294 TRACE_EVENT2("gpu", "RendererGLContext::Initialize",
297 "on_screen", onscreen, "num_pixels", size.GetArea()); 295 "on_screen", onscreen, "num_pixels", size.GetArea());
298 296
299 if (channel_->state() != GpuChannelHost::kConnected) 297 if (channel_->state() != GpuChannelHost::kConnected)
300 return false; 298 return false;
301 299
302 // Ensure the gles2 library is initialized first in a thread safe way. 300 // Ensure the gles2 library is initialized first in a thread safe way.
303 g_gles2_initializer.Get(); 301 g_gles2_initializer.Get();
304 302
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 transfer_buffer.ptr, 406 transfer_buffer.ptr,
409 transfer_buffer_id_, 407 transfer_buffer_id_,
410 share_resources, 408 share_resources,
411 bind_generates_resources); 409 bind_generates_resources);
412 410
413 return true; 411 return true;
414 } 412 }
415 413
416 void RendererGLContext::Destroy() { 414 void RendererGLContext::Destroy() {
417 TRACE_EVENT0("gpu", "RendererGLContext::Destroy"); 415 TRACE_EVENT0("gpu", "RendererGLContext::Destroy");
418 DCHECK(CalledOnValidThread());
419 SetParent(NULL); 416 SetParent(NULL);
420 417
421 if (gles2_implementation_) { 418 if (gles2_implementation_) {
422 // First flush the context to ensure that any pending frees of resources 419 // First flush the context to ensure that any pending frees of resources
423 // are completed. Otherwise, if this context is part of a share group, 420 // are completed. Otherwise, if this context is part of a share group,
424 // those resources might leak. Also, any remaining side effects of commands 421 // those resources might leak. Also, any remaining side effects of commands
425 // issued on this context might not be visible to other contexts in the 422 // issued on this context might not be visible to other contexts in the
426 // share group. 423 // share group.
427 gles2_implementation_->Flush(); 424 gles2_implementation_->Flush();
428 425
(...skipping 20 matching lines...) Expand all
449 void RendererGLContext::OnContextLost() { 446 void RendererGLContext::OnContextLost() {
450 if (context_lost_callback_.get()) { 447 if (context_lost_callback_.get()) {
451 RendererGLContext::ContextLostReason reason = kUnknown; 448 RendererGLContext::ContextLostReason reason = kUnknown;
452 if (command_buffer_) { 449 if (command_buffer_) {
453 reason = ConvertReason( 450 reason = ConvertReason(
454 command_buffer_->GetLastState().context_lost_reason); 451 command_buffer_->GetLastState().context_lost_reason);
455 } 452 }
456 context_lost_callback_->Run(reason); 453 context_lost_callback_->Run(reason);
457 } 454 }
458 } 455 }
OLDNEW
« no previous file with comments | « no previous file | content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698