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

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

Issue 9194005: gpu: reference target surfaces through a globally unique surface id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 11 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
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/renderer/gpu/renderer_gl_context.h" 5 #include "content/renderer/gpu/renderer_gl_context.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/shared_memory.h" 14 #include "base/shared_memory.h"
15 #include "content/common/view_messages.h" 15 #include "content/common/view_messages.h"
16 #include "content/renderer/gpu/command_buffer_proxy.h" 16 #include "content/renderer/gpu/command_buffer_proxy.h"
17 #include "content/renderer/gpu/gpu_channel_host.h" 17 #include "content/renderer/gpu/gpu_channel_host.h"
18 #include "content/renderer/render_widget.h" 18 #include "content/renderer/render_widget.h"
19 #include "googleurl/src/gurl.h" 19 #include "googleurl/src/gurl.h"
20 #include "ipc/ipc_channel_handle.h" 20 #include "ipc/ipc_channel_handle.h"
21 21
jonathan.backer 2012/01/16 19:47:26 nit: extra \n
piman 2012/01/17 19:40:54 Done.
22
22 #if defined(ENABLE_GPU) 23 #if defined(ENABLE_GPU)
23 #include "gpu/command_buffer/client/gles2_cmd_helper.h" 24 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
24 #include "gpu/command_buffer/client/gles2_implementation.h" 25 #include "gpu/command_buffer/client/gles2_implementation.h"
25 #include "gpu/command_buffer/client/gles2_lib.h" 26 #include "gpu/command_buffer/client/gles2_lib.h"
26 #include "gpu/command_buffer/common/constants.h" 27 #include "gpu/command_buffer/common/constants.h"
27 #endif // ENABLE_GPU 28 #endif // ENABLE_GPU
28 29
29 namespace { 30 namespace {
30 31
31 const int32 kCommandBufferSize = 1024 * 1024; 32 const int32 kCommandBufferSize = 1024 * 1024;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 #endif 73 #endif
73 74
74 } // namespace anonymous 75 } // namespace anonymous
75 76
76 RendererGLContext::~RendererGLContext() { 77 RendererGLContext::~RendererGLContext() {
77 Destroy(); 78 Destroy();
78 } 79 }
79 80
80 RendererGLContext* RendererGLContext::CreateViewContext( 81 RendererGLContext* RendererGLContext::CreateViewContext(
81 GpuChannelHost* channel, 82 GpuChannelHost* channel,
82 int render_view_id, 83 int32 surface_id,
83 RendererGLContext* share_group, 84 RendererGLContext* share_group,
84 const char* allowed_extensions, 85 const char* allowed_extensions,
85 const int32* attrib_list, 86 const int32* attrib_list,
86 const GURL& active_url, 87 const GURL& active_url,
87 gfx::GpuPreference gpu_preference) { 88 gfx::GpuPreference gpu_preference) {
88 #if defined(ENABLE_GPU) 89 #if defined(ENABLE_GPU)
89 scoped_ptr<RendererGLContext> context(new RendererGLContext(channel)); 90 scoped_ptr<RendererGLContext> context(new RendererGLContext(channel));
90 if (!context->Initialize( 91 if (!context->Initialize(
91 true, 92 true,
92 render_view_id, 93 surface_id,
93 gfx::Size(), 94 gfx::Size(),
94 share_group, 95 share_group,
95 allowed_extensions, 96 allowed_extensions,
96 attrib_list, 97 attrib_list,
97 active_url, 98 active_url,
98 gpu_preference)) 99 gpu_preference))
99 return NULL; 100 return NULL;
100 101
101 return context.release(); 102 return context.release();
102 #else 103 #else
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 command_buffer_(NULL), 283 command_buffer_(NULL),
283 gles2_helper_(NULL), 284 gles2_helper_(NULL),
284 transfer_buffer_id_(-1), 285 transfer_buffer_id_(-1),
285 gles2_implementation_(NULL), 286 gles2_implementation_(NULL),
286 last_error_(SUCCESS), 287 last_error_(SUCCESS),
287 frame_number_(0) { 288 frame_number_(0) {
288 DCHECK(channel); 289 DCHECK(channel);
289 } 290 }
290 291
291 bool RendererGLContext::Initialize(bool onscreen, 292 bool RendererGLContext::Initialize(bool onscreen,
292 int render_view_id, 293 int32 surface_id,
293 const gfx::Size& size, 294 const gfx::Size& size,
294 RendererGLContext* share_group, 295 RendererGLContext* share_group,
295 const char* allowed_extensions, 296 const char* allowed_extensions,
296 const int32* attrib_list, 297 const int32* attrib_list,
297 const GURL& active_url, 298 const GURL& active_url,
298 gfx::GpuPreference gpu_preference) { 299 gfx::GpuPreference gpu_preference) {
299 DCHECK(CalledOnValidThread()); 300 DCHECK(CalledOnValidThread());
300 DCHECK(size.width() >= 0 && size.height() >= 0); 301 DCHECK(size.width() >= 0 && size.height() >= 0);
301 TRACE_EVENT2("gpu", "RendererGLContext::Initialize", 302 TRACE_EVENT2("gpu", "RendererGLContext::Initialize",
302 "on_screen", onscreen, "num_pixels", size.GetArea()); 303 "on_screen", onscreen, "num_pixels", size.GetArea());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 attrib_list = NULL; 342 attrib_list = NULL;
342 break; 343 break;
343 } 344 }
344 } 345 }
345 346
346 // Create a proxy to a command buffer in the GPU process. 347 // Create a proxy to a command buffer in the GPU process.
347 if (onscreen) { 348 if (onscreen) {
348 TRACE_EVENT0("gpu", 349 TRACE_EVENT0("gpu",
349 "RendererGLContext::Initialize::CreateViewCommandBuffer"); 350 "RendererGLContext::Initialize::CreateViewCommandBuffer");
350 command_buffer_ = channel_->CreateViewCommandBuffer( 351 command_buffer_ = channel_->CreateViewCommandBuffer(
351 render_view_id, 352 surface_id,
352 share_group ? share_group->command_buffer_ : NULL, 353 share_group ? share_group->command_buffer_ : NULL,
353 allowed_extensions, 354 allowed_extensions,
354 attribs, 355 attribs,
355 active_url, 356 active_url,
356 gpu_preference); 357 gpu_preference);
357 } else { 358 } else {
358 command_buffer_ = channel_->CreateOffscreenCommandBuffer( 359 command_buffer_ = channel_->CreateOffscreenCommandBuffer(
359 size, 360 size,
360 share_group ? share_group->command_buffer_ : NULL, 361 share_group ? share_group->command_buffer_ : NULL,
361 allowed_extensions, 362 allowed_extensions,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 void RendererGLContext::OnContextLost() { 457 void RendererGLContext::OnContextLost() {
457 if (!context_lost_callback_.is_null()) { 458 if (!context_lost_callback_.is_null()) {
458 RendererGLContext::ContextLostReason reason = kUnknown; 459 RendererGLContext::ContextLostReason reason = kUnknown;
459 if (command_buffer_) { 460 if (command_buffer_) {
460 reason = ConvertReason( 461 reason = ConvertReason(
461 command_buffer_->GetLastState().context_lost_reason); 462 command_buffer_->GetLastState().context_lost_reason);
462 } 463 }
463 context_lost_callback_.Run(reason); 464 context_lost_callback_.Run(reason);
464 } 465 }
465 } 466 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698