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

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

Issue 7834021: Fix build error in release mode. (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 | « content/renderer/gpu/renderer_gl_context.h ('k') | no next file » | 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"
11 #include "base/memory/singleton.h" 11 #include "base/memory/singleton.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/message_loop.h"
14 #include "base/shared_memory.h" 13 #include "base/shared_memory.h"
15 #include "content/common/view_messages.h" 14 #include "content/common/view_messages.h"
16 #include "content/renderer/gpu/command_buffer_proxy.h" 15 #include "content/renderer/gpu/command_buffer_proxy.h"
17 #include "content/renderer/gpu/gpu_channel_host.h" 16 #include "content/renderer/gpu/gpu_channel_host.h"
18 #include "content/renderer/gpu/transport_texture_host.h" 17 #include "content/renderer/gpu/transport_texture_host.h"
19 #include "content/renderer/gpu/transport_texture_service.h" 18 #include "content/renderer/gpu/transport_texture_service.h"
20 #include "content/renderer/render_thread.h" 19 #include "content/renderer/render_thread.h"
21 #include "content/renderer/render_widget.h" 20 #include "content/renderer/render_widget.h"
22 #include "googleurl/src/gurl.h" 21 #include "googleurl/src/gurl.h"
23 #include "ipc/ipc_channel_handle.h" 22 #include "ipc/ipc_channel_handle.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 gles2_implementation_->DeleteTextures(1, &texture); 192 gles2_implementation_->DeleteTextures(1, &texture);
194 } 193 }
195 194
196 void RendererGLContext::SetContextLostCallback( 195 void RendererGLContext::SetContextLostCallback(
197 Callback1<ContextLostReason>::Type* callback) { 196 Callback1<ContextLostReason>::Type* callback) {
198 context_lost_callback_.reset(callback); 197 context_lost_callback_.reset(callback);
199 } 198 }
200 199
201 bool RendererGLContext::MakeCurrent(RendererGLContext* context) { 200 bool RendererGLContext::MakeCurrent(RendererGLContext* context) {
202 if (context) { 201 if (context) {
203 DCHECK(MessageLoop::current() == context->message_loop_); 202 DCHECK(context->CalledOnValidThread());
204 gles2::SetGLContext(context->gles2_implementation_); 203 gles2::SetGLContext(context->gles2_implementation_);
205 204
206 // Don't request latest error status from service. Just use the locally 205 // Don't request latest error status from service. Just use the locally
207 // cached information from the last flush. 206 // cached information from the last flush.
208 // TODO(apatrick): I'm not sure if this should actually change the 207 // TODO(apatrick): I'm not sure if this should actually change the
209 // current context if it fails. For now it gets changed even if it fails 208 // current context if it fails. For now it gets changed even if it fails
210 // because making GL calls with a NULL context crashes. 209 // because making GL calls with a NULL context crashes.
211 if (context->command_buffer_->GetLastState().error != gpu::error::kNoError) 210 if (context->command_buffer_->GetLastState().error != gpu::error::kNoError)
212 return false; 211 return false;
213 } else { 212 } else {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 273
275 RendererGLContext::RendererGLContext(GpuChannelHost* channel) 274 RendererGLContext::RendererGLContext(GpuChannelHost* channel)
276 : channel_(channel), 275 : channel_(channel),
277 parent_(base::WeakPtr<RendererGLContext>()), 276 parent_(base::WeakPtr<RendererGLContext>()),
278 parent_texture_id_(0), 277 parent_texture_id_(0),
279 command_buffer_(NULL), 278 command_buffer_(NULL),
280 gles2_helper_(NULL), 279 gles2_helper_(NULL),
281 transfer_buffer_id_(-1), 280 transfer_buffer_id_(-1),
282 gles2_implementation_(NULL), 281 gles2_implementation_(NULL),
283 last_error_(SUCCESS), 282 last_error_(SUCCESS),
284 frame_number_(0) 283 frame_number_(0) {
285 #ifndef NDEBUG
286 , message_loop_(MessageLoop::current())
287 #endif
288 {
289 DCHECK(channel); 284 DCHECK(channel);
290 } 285 }
291 286
292 bool RendererGLContext::Initialize(bool onscreen, 287 bool RendererGLContext::Initialize(bool onscreen,
293 int render_view_id, 288 int render_view_id,
294 const gfx::Size& size, 289 const gfx::Size& size,
295 RendererGLContext* share_group, 290 RendererGLContext* share_group,
296 const char* allowed_extensions, 291 const char* allowed_extensions,
297 const int32* attrib_list, 292 const int32* attrib_list,
298 const GURL& active_url) { 293 const GURL& active_url) {
299 DCHECK(MessageLoop::current() == message_loop_); 294 DCHECK(CalledOnValidThread());
300 DCHECK(size.width() >= 0 && size.height() >= 0); 295 DCHECK(size.width() >= 0 && size.height() >= 0);
301 TRACE_EVENT2("gpu", "RendererGLContext::Initialize", 296 TRACE_EVENT2("gpu", "RendererGLContext::Initialize",
302 "on_screen", onscreen, "num_pixels", size.GetArea()); 297 "on_screen", onscreen, "num_pixels", size.GetArea());
303 298
304 if (channel_->state() != GpuChannelHost::kConnected) 299 if (channel_->state() != GpuChannelHost::kConnected)
305 return false; 300 return false;
306 301
307 // Ensure the gles2 library is initialized first in a thread safe way. 302 // Ensure the gles2 library is initialized first in a thread safe way.
308 g_gles2_initializer.Get(); 303 g_gles2_initializer.Get();
309 304
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 transfer_buffer.ptr, 408 transfer_buffer.ptr,
414 transfer_buffer_id_, 409 transfer_buffer_id_,
415 share_resources, 410 share_resources,
416 bind_generates_resources); 411 bind_generates_resources);
417 412
418 return true; 413 return true;
419 } 414 }
420 415
421 void RendererGLContext::Destroy() { 416 void RendererGLContext::Destroy() {
422 TRACE_EVENT0("gpu", "RendererGLContext::Destroy"); 417 TRACE_EVENT0("gpu", "RendererGLContext::Destroy");
423 DCHECK(MessageLoop::current() == message_loop_); 418 DCHECK(CalledOnValidThread());
424 SetParent(NULL); 419 SetParent(NULL);
425 420
426 if (gles2_implementation_) { 421 if (gles2_implementation_) {
427 // First flush the context to ensure that any pending frees of resources 422 // First flush the context to ensure that any pending frees of resources
428 // are completed. Otherwise, if this context is part of a share group, 423 // are completed. Otherwise, if this context is part of a share group,
429 // those resources might leak. Also, any remaining side effects of commands 424 // those resources might leak. Also, any remaining side effects of commands
430 // issued on this context might not be visible to other contexts in the 425 // issued on this context might not be visible to other contexts in the
431 // share group. 426 // share group.
432 gles2_implementation_->Flush(); 427 gles2_implementation_->Flush();
433 428
(...skipping 20 matching lines...) Expand all
454 void RendererGLContext::OnContextLost() { 449 void RendererGLContext::OnContextLost() {
455 if (context_lost_callback_.get()) { 450 if (context_lost_callback_.get()) {
456 RendererGLContext::ContextLostReason reason = kUnknown; 451 RendererGLContext::ContextLostReason reason = kUnknown;
457 if (command_buffer_) { 452 if (command_buffer_) {
458 reason = ConvertReason( 453 reason = ConvertReason(
459 command_buffer_->GetLastState().context_lost_reason); 454 command_buffer_->GetLastState().context_lost_reason);
460 } 455 }
461 context_lost_callback_->Run(reason); 456 context_lost_callback_->Run(reason);
462 } 457 }
463 } 458 }
OLDNEW
« no previous file with comments | « content/renderer/gpu/renderer_gl_context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698