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

Side by Side Diff: gpu/command_buffer/service/gpu_scheduler.cc

Issue 7021014: GLContext no longer holds a pointer to a GLSurface. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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) 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 "gpu/command_buffer/service/gpu_scheduler.h" 5 #include "gpu/command_buffer/service/gpu_scheduler.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "ui/gfx/gl/gl_context.h" 11 #include "ui/gfx/gl/gl_context.h"
12 #include "ui/gfx/gl/gl_bindings.h" 12 #include "ui/gfx/gl/gl_bindings.h"
13 #include "ui/gfx/gl/gl_surface.h"
13 14
14 using ::base::SharedMemory; 15 using ::base::SharedMemory;
15 16
16 namespace gpu { 17 namespace gpu {
17 18
18 GpuScheduler::GpuScheduler(CommandBuffer* command_buffer, 19 GpuScheduler::GpuScheduler(CommandBuffer* command_buffer,
19 gles2::ContextGroup* group) 20 gles2::ContextGroup* group)
20 : command_buffer_(command_buffer), 21 : command_buffer_(command_buffer),
21 commands_per_update_(100), 22 commands_per_update_(100),
22 unscheduled_count_(0), 23 unscheduled_count_(0),
(...skipping 22 matching lines...) Expand all
45 DCHECK(command_buffer); 46 DCHECK(command_buffer);
46 decoder_.reset(decoder); 47 decoder_.reset(decoder);
47 parser_.reset(parser); 48 parser_.reset(parser);
48 } 49 }
49 50
50 GpuScheduler::~GpuScheduler() { 51 GpuScheduler::~GpuScheduler() {
51 Destroy(); 52 Destroy();
52 } 53 }
53 54
54 bool GpuScheduler::InitializeCommon( 55 bool GpuScheduler::InitializeCommon(
56 gfx::GLSurface* surface,
55 gfx::GLContext* context, 57 gfx::GLContext* context,
56 const gfx::Size& size, 58 const gfx::Size& size,
57 const gles2::DisallowedExtensions& disallowed_extensions, 59 const gles2::DisallowedExtensions& disallowed_extensions,
58 const char* allowed_extensions, 60 const char* allowed_extensions,
59 const std::vector<int32>& attribs, 61 const std::vector<int32>& attribs,
60 gles2::GLES2Decoder* parent_decoder, 62 gles2::GLES2Decoder* parent_decoder,
61 uint32 parent_texture_id) { 63 uint32 parent_texture_id) {
62 DCHECK(context); 64 DCHECK(context);
63 65
64 if (!context->MakeCurrent()) 66 if (!context->MakeCurrent(surface))
65 return false; 67 return false;
66 68
67 // Do not limit to a certain number of commands before scheduling another 69 // Do not limit to a certain number of commands before scheduling another
68 // update when rendering onscreen. 70 // update when rendering onscreen.
69 if (!context->IsOffscreen()) 71 if (!surface->IsOffscreen())
70 commands_per_update_ = INT_MAX; 72 commands_per_update_ = INT_MAX;
71 73
72 // Map the ring buffer and create the parser. 74 // Map the ring buffer and create the parser.
73 Buffer ring_buffer = command_buffer_->GetRingBuffer(); 75 Buffer ring_buffer = command_buffer_->GetRingBuffer();
74 if (ring_buffer.ptr) { 76 if (ring_buffer.ptr) {
75 parser_.reset(new CommandParser(ring_buffer.ptr, 77 parser_.reset(new CommandParser(ring_buffer.ptr,
76 ring_buffer.size, 78 ring_buffer.size,
77 0, 79 0,
78 ring_buffer.size, 80 ring_buffer.size,
79 0, 81 0,
80 decoder_.get())); 82 decoder_.get()));
81 } else { 83 } else {
82 parser_.reset(new CommandParser(NULL, 0, 0, 0, 0, 84 parser_.reset(new CommandParser(NULL, 0, 0, 0, 0,
83 decoder_.get())); 85 decoder_.get()));
84 } 86 }
85 87
86 // Initialize the decoder with either the view or pbuffer GLContext. 88 // Initialize the decoder with either the view or pbuffer GLContext.
87 if (!decoder_->Initialize(context, 89 // TODO(apatrick): The GpuScheduler should know nothing about the surface the
90 // decoder is rendering to. Get rid of the surface parameter.
91 if (!decoder_->Initialize(surface,
92 context,
88 size, 93 size,
89 disallowed_extensions, 94 disallowed_extensions,
90 allowed_extensions, 95 allowed_extensions,
91 attribs, 96 attribs,
92 parent_decoder, 97 parent_decoder,
93 parent_texture_id)) { 98 parent_texture_id)) {
94 LOG(ERROR) << "GpuScheduler::InitializeCommon failed because decoder " 99 LOG(ERROR) << "GpuScheduler::InitializeCommon failed because decoder "
95 << "failed to initialize."; 100 << "failed to initialize.";
96 Destroy(); 101 Destroy();
97 return false; 102 return false;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 command_processed_callback_.reset(callback); 261 command_processed_callback_.reset(callback);
257 } 262 }
258 263
259 void GpuScheduler::ScheduleProcessCommands() { 264 void GpuScheduler::ScheduleProcessCommands() {
260 MessageLoop::current()->PostTask( 265 MessageLoop::current()->PostTask(
261 FROM_HERE, 266 FROM_HERE,
262 method_factory_.NewRunnableMethod(&GpuScheduler::ProcessCommands)); 267 method_factory_.NewRunnableMethod(&GpuScheduler::ProcessCommands));
263 } 268 }
264 269
265 } // namespace gpu 270 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698