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

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

Issue 7395020: Create new GLSurface for cross process image transport. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: "" Created 9 years, 5 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/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 const scoped_refptr<gfx::GLContext>& context, 61 const scoped_refptr<gfx::GLContext>& context,
62 const gfx::Size& size, 62 const gfx::Size& size,
63 const gles2::DisallowedExtensions& disallowed_extensions, 63 const gles2::DisallowedExtensions& disallowed_extensions,
64 const char* allowed_extensions, 64 const char* allowed_extensions,
65 const std::vector<int32>& attribs) { 65 const std::vector<int32>& attribs) {
66 DCHECK(context); 66 DCHECK(context);
67 67
68 if (!context->MakeCurrent(surface)) 68 if (!context->MakeCurrent(surface))
69 return false; 69 return false;
70 70
71 #if !defined(OS_MACOSX) 71 #if !defined(OS_MACOSX) && !defined(TOUCH_UI)
72 // Set up swap interval for onscreen contexts. 72 // Set up swap interval for onscreen contexts.
73 if (!surface->IsOffscreen()) { 73 if (!surface->IsOffscreen()) {
74 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync)) 74 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync))
75 context->SetSwapInterval(0); 75 context->SetSwapInterval(0);
76 else 76 else
77 context->SetSwapInterval(1); 77 context->SetSwapInterval(1);
78 } 78 }
79 #endif 79 #endif
80 80
81 // Map the ring buffer and create the parser. 81 // Map the ring buffer and create the parser.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 bool GpuScheduler::SetParent(GpuScheduler* parent_scheduler, 123 bool GpuScheduler::SetParent(GpuScheduler* parent_scheduler,
124 uint32 parent_texture_id) { 124 uint32 parent_texture_id) {
125 if (parent_scheduler) 125 if (parent_scheduler)
126 return decoder_->SetParent(parent_scheduler->decoder_.get(), 126 return decoder_->SetParent(parent_scheduler->decoder_.get(),
127 parent_texture_id); 127 parent_texture_id);
128 else 128 else
129 return decoder_->SetParent(NULL, 0); 129 return decoder_->SetParent(NULL, 0);
130 } 130 }
131 131
132 #if defined(OS_MACOSX) || defined(TOUCH_UI) 132 #if defined(OS_MACOSX)
133 namespace { 133 namespace {
134 const unsigned int kMaxOutstandingSwapBuffersCallsPerOnscreenContext = 1; 134 const unsigned int kMaxOutstandingSwapBuffersCallsPerOnscreenContext = 1;
135 } 135 }
136 #endif 136 #endif
137 137
138 void GpuScheduler::PutChanged() { 138 void GpuScheduler::PutChanged() {
139 TRACE_EVENT1("gpu", "GpuScheduler:PutChanged", "this", this); 139 TRACE_EVENT1("gpu", "GpuScheduler:PutChanged", "this", this);
140 140
141 DCHECK(IsScheduled()); 141 DCHECK(IsScheduled());
142 142
143 CommandBuffer::State state = command_buffer_->GetState(); 143 CommandBuffer::State state = command_buffer_->GetState();
144 parser_->set_put(state.put_offset); 144 parser_->set_put(state.put_offset);
145 if (state.error != error::kNoError) 145 if (state.error != error::kNoError)
146 return; 146 return;
147 147
148 if (decoder_.get()) { 148 if (decoder_.get()) {
149 if (!decoder_->MakeCurrent()) { 149 if (!decoder_->MakeCurrent()) {
150 LOG(ERROR) << "Context lost because MakeCurrent failed."; 150 LOG(ERROR) << "Context lost because MakeCurrent failed.";
151 command_buffer_->SetContextLostReason(decoder_->GetContextLostReason()); 151 command_buffer_->SetContextLostReason(decoder_->GetContextLostReason());
152 command_buffer_->SetParseError(error::kLostContext); 152 command_buffer_->SetParseError(error::kLostContext);
153 return; 153 return;
154 } 154 }
155 } 155 }
156 156
157 #if defined(OS_MACOSX) 157 #if defined(OS_MACOSX)
158 bool do_rate_limiting = surface_.get() != NULL; 158 bool do_rate_limiting = surface_.get() != NULL;
159 #elif defined(TOUCH_UI)
160 bool do_rate_limiting = back_surface_.get() != NULL;
161 #endif
162 159
163 #if defined(OS_MACOSX) || defined(TOUCH_UI)
164 // Don't swamp the browser process with SwapBuffers calls it can't handle. 160 // Don't swamp the browser process with SwapBuffers calls it can't handle.
165 DCHECK(!do_rate_limiting || 161 DCHECK(!do_rate_limiting ||
166 swap_buffers_count_ - acknowledged_swap_buffers_count_ == 0); 162 swap_buffers_count_ - acknowledged_swap_buffers_count_ == 0);
167 #endif 163 #endif
168 164
169 error::Error error = error::kNoError; 165 error::Error error = error::kNoError;
170 while (!parser_->IsEmpty()) { 166 while (!parser_->IsEmpty()) {
171 error = parser_->ProcessCommand(); 167 error = parser_->ProcessCommand();
172 168
173 // TODO(piman): various classes duplicate various pieces of state, leading 169 // TODO(piman): various classes duplicate various pieces of state, leading
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 228
233 int32 GpuScheduler::GetGetOffset() { 229 int32 GpuScheduler::GetGetOffset() {
234 return parser_->get(); 230 return parser_->get();
235 } 231 }
236 232
237 void GpuScheduler::ResizeOffscreenFrameBuffer(const gfx::Size& size) { 233 void GpuScheduler::ResizeOffscreenFrameBuffer(const gfx::Size& size) {
238 decoder_->ResizeOffscreenFrameBuffer(size); 234 decoder_->ResizeOffscreenFrameBuffer(size);
239 } 235 }
240 236
241 void GpuScheduler::SetResizeCallback(Callback1<gfx::Size>::Type* callback) { 237 void GpuScheduler::SetResizeCallback(Callback1<gfx::Size>::Type* callback) {
242 wrapped_resize_callback_.reset(callback); 238 decoder_->SetResizeCallback(callback);
243 decoder_->SetResizeCallback(
244 NewCallback(this,
245 &GpuScheduler::WillResize));
246 } 239 }
247 240
248 void GpuScheduler::SetSwapBuffersCallback( 241 void GpuScheduler::SetSwapBuffersCallback(
249 Callback0::Type* callback) { 242 Callback0::Type* callback) {
250 wrapped_swap_buffers_callback_.reset(callback); 243 wrapped_swap_buffers_callback_.reset(callback);
251 decoder_->SetSwapBuffersCallback( 244 decoder_->SetSwapBuffersCallback(
252 NewCallback(this, 245 NewCallback(this,
253 &GpuScheduler::WillSwapBuffers)); 246 &GpuScheduler::WillSwapBuffers));
254 } 247 }
255 248
256 void GpuScheduler::SetCommandProcessedCallback( 249 void GpuScheduler::SetCommandProcessedCallback(
257 Callback0::Type* callback) { 250 Callback0::Type* callback) {
258 command_processed_callback_.reset(callback); 251 command_processed_callback_.reset(callback);
259 } 252 }
260 253
261 void GpuScheduler::SetTokenCallback( 254 void GpuScheduler::SetTokenCallback(
262 const base::Callback<void(int32)>& callback) { 255 const base::Callback<void(int32)>& callback) {
263 DCHECK(set_token_callback_.is_null()); 256 DCHECK(set_token_callback_.is_null());
264 set_token_callback_ = callback; 257 set_token_callback_ = callback;
265 } 258 }
266 259
267 GpuScheduler::GpuScheduler(CommandBuffer* command_buffer, 260 GpuScheduler::GpuScheduler(CommandBuffer* command_buffer,
268 gles2::GLES2Decoder* decoder, 261 gles2::GLES2Decoder* decoder,
269 CommandParser* parser) 262 CommandParser* parser)
270 : command_buffer_(command_buffer), 263 : command_buffer_(command_buffer),
271 decoder_(decoder), 264 decoder_(decoder),
272 parser_(parser), 265 parser_(parser),
273 unscheduled_count_(0), 266 unscheduled_count_(0),
274 #if defined(OS_MACOSX) || defined(TOUCH_UI) 267 #if defined(OS_MACOSX)
275 swap_buffers_count_(0), 268 swap_buffers_count_(0),
276 acknowledged_swap_buffers_count_(0), 269 acknowledged_swap_buffers_count_(0),
277 #endif 270 #endif
278 method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 271 method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
279 } 272 }
280 273
281 void GpuScheduler::WillResize(gfx::Size size) {
282 if (wrapped_resize_callback_.get()) {
283 wrapped_resize_callback_->Run(size);
284 }
285 }
286
287 } // namespace gpu 274 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gpu_scheduler.h ('k') | gpu/command_buffer/service/gpu_scheduler_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698