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

Side by Side Diff: content/common/gpu/gpu_command_buffer_stub.cc

Issue 6883179: Rework FlushSync to return early if commands have been processed since the last update (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup, fix tests Created 9 years, 8 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 #if defined(ENABLE_GPU) 5 #if defined(ENABLE_GPU)
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/process_util.h" 8 #include "base/process_util.h"
9 #include "base/shared_memory.h" 9 #include "base/shared_memory.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 disallowed_extensions_(disallowed_extensions), 49 disallowed_extensions_(disallowed_extensions),
50 allowed_extensions_(allowed_extensions), 50 allowed_extensions_(allowed_extensions),
51 requested_attribs_(attribs), 51 requested_attribs_(attribs),
52 parent_texture_id_(parent_texture_id), 52 parent_texture_id_(parent_texture_id),
53 route_id_(route_id), 53 route_id_(route_id),
54 #if defined(OS_WIN) 54 #if defined(OS_WIN)
55 compositor_window_(NULL), 55 compositor_window_(NULL),
56 #endif // defined(OS_WIN) 56 #endif // defined(OS_WIN)
57 renderer_id_(renderer_id), 57 renderer_id_(renderer_id),
58 render_view_id_(render_view_id), 58 render_view_id_(render_view_id),
59 watchdog_(watchdog) { 59 watchdog_(watchdog),
60 task_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
60 } 61 }
61 62
62 #if defined(OS_WIN) 63 #if defined(OS_WIN)
63 static LRESULT CALLBACK CompositorWindowProc( 64 static LRESULT CALLBACK CompositorWindowProc(
64 HWND hwnd, 65 HWND hwnd,
65 UINT message, 66 UINT message,
66 WPARAM wparam, 67 WPARAM wparam,
67 LPARAM lparam) { 68 LPARAM lparam) {
68 switch (message) { 69 switch (message) {
69 case WM_ERASEBKGND: 70 case WM_ERASEBKGND:
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 if (scheduler_->Initialize( 250 if (scheduler_->Initialize(
250 output_window_handle, 251 output_window_handle,
251 initial_size_, 252 initial_size_,
252 disallowed_extensions_, 253 disallowed_extensions_,
253 allowed_extensions_.c_str(), 254 allowed_extensions_.c_str(),
254 requested_attribs_, 255 requested_attribs_,
255 parent_processor, 256 parent_processor,
256 parent_texture_id_)) { 257 parent_texture_id_)) {
257 command_buffer_->SetPutOffsetChangeCallback( 258 command_buffer_->SetPutOffsetChangeCallback(
258 NewCallback(scheduler_.get(), 259 NewCallback(scheduler_.get(),
259 &gpu::GpuScheduler::ProcessCommands)); 260 &gpu::GpuScheduler::PutChanged));
260 scheduler_->SetSwapBuffersCallback( 261 scheduler_->SetSwapBuffersCallback(
261 NewCallback(this, &GpuCommandBufferStub::OnSwapBuffers)); 262 NewCallback(this, &GpuCommandBufferStub::OnSwapBuffers));
262 scheduler_->SetLatchCallback(base::Bind( 263 scheduler_->SetLatchCallback(base::Bind(
263 &GpuChannel::OnLatchCallback, base::Unretained(channel_), route_id_)); 264 &GpuChannel::OnLatchCallback, base::Unretained(channel_), route_id_));
264 if (watchdog_) 265 if (watchdog_)
265 scheduler_->SetCommandProcessedCallback( 266 scheduler_->SetCommandProcessedCallback(
266 NewCallback(this, &GpuCommandBufferStub::OnCommandProcessed)); 267 NewCallback(this, &GpuCommandBufferStub::OnCommandProcessed));
267 268
268 #if defined(OS_MACOSX) 269 #if defined(OS_MACOSX)
269 if (handle_) { 270 if (handle_) {
(...skipping 24 matching lines...) Expand all
294 if (watchdog_) 295 if (watchdog_)
295 watchdog_->CheckArmed(); 296 watchdog_->CheckArmed();
296 } 297 }
297 298
298 void GpuCommandBufferStub::OnGetState(gpu::CommandBuffer::State* state) { 299 void GpuCommandBufferStub::OnGetState(gpu::CommandBuffer::State* state) {
299 *state = command_buffer_->GetState(); 300 *state = command_buffer_->GetState();
300 } 301 }
301 302
302 void GpuCommandBufferStub::OnAsyncGetState() { 303 void GpuCommandBufferStub::OnAsyncGetState() {
303 gpu::CommandBuffer::State state = command_buffer_->GetState(); 304 gpu::CommandBuffer::State state = command_buffer_->GetState();
304 Send(new GpuCommandBufferMsg_UpdateState(route_id_, state)); 305 IPC::Message* msg = new GpuCommandBufferMsg_UpdateState(route_id_, state);
306 msg->set_unblock(true);
307 Send(msg);
305 } 308 }
306 309
307 void GpuCommandBufferStub::OnFlush(int32 put_offset, 310 void GpuCommandBufferStub::OnFlush(int32 put_offset,
311 int32 last_known_get,
308 gpu::CommandBuffer::State* state) { 312 gpu::CommandBuffer::State* state) {
309 GPU_TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnFlush"); 313 GPU_TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnFlush");
310 *state = command_buffer_->FlushSync(put_offset); 314 *state = command_buffer_->FlushSync(put_offset, last_known_get);
311 if (state->error == gpu::error::kLostContext && 315 if (state->error == gpu::error::kLostContext &&
312 gfx::GLContext::LosesAllContextsOnContextLost()) 316 gfx::GLContext::LosesAllContextsOnContextLost())
313 channel_->LoseAllContexts(); 317 channel_->LoseAllContexts();
314 } 318 }
315 319
316 void GpuCommandBufferStub::OnAsyncFlush(int32 put_offset) { 320 void GpuCommandBufferStub::OnAsyncFlush(int32 put_offset) {
317 GPU_TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnAsyncFlush"); 321 GPU_TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnAsyncFlush");
318 gpu::CommandBuffer::State state = command_buffer_->FlushSync(put_offset); 322 command_buffer_->Flush(put_offset);
319 if (state.error == gpu::error::kLostContext && 323 // TODO(piman): Do this everytime the scheduler finishes processing a batch of
320 gfx::GLContext::LosesAllContextsOnContextLost()) 324 // commands.
321 channel_->LoseAllContexts(); 325 MessageLoop::current()->PostTask(FROM_HERE,
apatrick_chromium 2011/04/27 22:52:44 Why did you remove this?
piman 2011/04/27 23:44:29 Since we're not waiting on any command to execute,
322 else 326 task_factory_.NewRunnableMethod(&GpuCommandBufferStub::OnAsyncGetState));
323 Send(new GpuCommandBufferMsg_UpdateState(route_id_, state));
324 } 327 }
325 328
326 void GpuCommandBufferStub::OnCreateTransferBuffer(int32 size, 329 void GpuCommandBufferStub::OnCreateTransferBuffer(int32 size,
327 int32 id_request, 330 int32 id_request,
328 int32* id) { 331 int32* id) {
329 *id = command_buffer_->CreateTransferBuffer(size, id_request); 332 *id = command_buffer_->CreateTransferBuffer(size, id_request);
330 } 333 }
331 334
332 void GpuCommandBufferStub::OnRegisterTransferBuffer( 335 void GpuCommandBufferStub::OnRegisterTransferBuffer(
333 base::SharedMemoryHandle transfer_buffer, 336 base::SharedMemoryHandle transfer_buffer,
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 #elif defined(OS_WIN) 445 #elif defined(OS_WIN)
443 HWND hwnd = static_cast<HWND>(compositor_window_); 446 HWND hwnd = static_cast<HWND>(compositor_window_);
444 UINT swp_flags = SWP_NOSENDCHANGING | SWP_NOOWNERZORDER | SWP_NOCOPYBITS | 447 UINT swp_flags = SWP_NOSENDCHANGING | SWP_NOOWNERZORDER | SWP_NOCOPYBITS |
445 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE; 448 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE;
446 SetWindowPos(hwnd, NULL, 0, 0, size.width(), size.height(), swp_flags); 449 SetWindowPos(hwnd, NULL, 0, 0, size.width(), size.height(), swp_flags);
447 #endif // defined(OS_LINUX) 450 #endif // defined(OS_LINUX)
448 } 451 }
449 } 452 }
450 453
451 #endif // defined(ENABLE_GPU) 454 #endif // defined(ENABLE_GPU)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698