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

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

Issue 9699125: Chromium implementation of discardBackbuffer WebGraphicsContext3D extension. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 9 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 #if defined(ENABLE_GPU) 5 #if defined(ENABLE_GPU)
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_DestroyTransferBuffer, 116 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_DestroyTransferBuffer,
117 OnDestroyTransferBuffer); 117 OnDestroyTransferBuffer);
118 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetTransferBuffer, 118 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetTransferBuffer,
119 OnGetTransferBuffer); 119 OnGetTransferBuffer);
120 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateVideoDecoder, 120 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateVideoDecoder,
121 OnCreateVideoDecoder) 121 OnCreateVideoDecoder)
122 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyVideoDecoder, 122 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyVideoDecoder,
123 OnDestroyVideoDecoder) 123 OnDestroyVideoDecoder)
124 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetSurfaceVisible, 124 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetSurfaceVisible,
125 OnSetSurfaceVisible) 125 OnSetSurfaceVisible)
126 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DiscardBackbuffer,
127 OnDiscardBackbuffer)
128 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_EnsureBackbuffer,
129 OnEnsureBackbuffer)
126 IPC_MESSAGE_UNHANDLED(handled = false) 130 IPC_MESSAGE_UNHANDLED(handled = false)
127 IPC_END_MESSAGE_MAP() 131 IPC_END_MESSAGE_MAP()
128 132
129 DCHECK(handled); 133 DCHECK(handled);
130 return handled; 134 return handled;
131 } 135 }
132 136
133 bool GpuCommandBufferStub::Send(IPC::Message* message) { 137 bool GpuCommandBufferStub::Send(IPC::Message* message) {
134 return channel_->Send(message); 138 return channel_->Send(message);
135 } 139 }
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 decoder->Initialize(profile, reply_message, 560 decoder->Initialize(profile, reply_message,
557 channel_->renderer_process()); 561 channel_->renderer_process());
558 } 562 }
559 563
560 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) { 564 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) {
561 channel_->RemoveRoute(decoder_route_id); 565 channel_->RemoveRoute(decoder_route_id);
562 video_decoders_.Remove(decoder_route_id); 566 video_decoders_.Remove(decoder_route_id);
563 } 567 }
564 568
565 void GpuCommandBufferStub::OnSetSurfaceVisible(bool visible) { 569 void GpuCommandBufferStub::OnSetSurfaceVisible(bool visible) {
566 if (visible)
567 surface_->SetBufferAllocation(
568 gfx::GLSurface::BUFFER_ALLOCATION_FRONT_AND_BACK);
569 DCHECK(surface_state_.get()); 570 DCHECK(surface_state_.get());
570 surface_state_->visible = visible; 571 surface_state_->visible = visible;
571 surface_state_->last_used_time = base::TimeTicks::Now(); 572 surface_state_->last_used_time = base::TimeTicks::Now();
572 channel_->gpu_channel_manager()->gpu_memory_manager()->ScheduleManage(); 573 channel_->gpu_channel_manager()->gpu_memory_manager()->ScheduleManage();
573 } 574 }
574 575
576 void GpuCommandBufferStub::OnDiscardBackbuffer() {
577 if (!surface_)
578 return;
579 if (allocation_.suggest_have_frontbuffer)
580 surface_->SetBufferAllocation(
581 gfx::GLSurface::BUFFER_ALLOCATION_FRONT_ONLY);
582 else
583 surface_->SetBufferAllocation(
584 gfx::GLSurface::BUFFER_ALLOCATION_NONE);
585 }
586
587 void GpuCommandBufferStub::OnEnsureBackbuffer() {
588 if (!surface_)
589 return;
590 // TODO(mmocny): Support backbuffer without frontbuffer.
591 surface_->SetBufferAllocation(
592 gfx::GLSurface::BUFFER_ALLOCATION_FRONT_AND_BACK);
593 }
594
575 void GpuCommandBufferStub::SendConsoleMessage( 595 void GpuCommandBufferStub::SendConsoleMessage(
576 int32 id, 596 int32 id,
577 const std::string& message) { 597 const std::string& message) {
578 GPUCommandBufferConsoleMessage console_message; 598 GPUCommandBufferConsoleMessage console_message;
579 console_message.id = id; 599 console_message.id = id;
580 console_message.message = message; 600 console_message.message = message;
581 IPC::Message* msg = new GpuCommandBufferMsg_ConsoleMsg( 601 IPC::Message* msg = new GpuCommandBufferMsg_ConsoleMsg(
582 route_id_, console_message); 602 route_id_, console_message);
583 msg->set_unblock(true); 603 msg->set_unblock(true);
584 Send(msg); 604 Send(msg);
(...skipping 30 matching lines...) Expand all
615 Send(new GpuCommandBufferMsg_SetMemoryAllocation(route_id_, allocation)); 635 Send(new GpuCommandBufferMsg_SetMemoryAllocation(route_id_, allocation));
616 } 636 }
617 637
618 void GpuCommandBufferStub::SetMemoryAllocation( 638 void GpuCommandBufferStub::SetMemoryAllocation(
619 const GpuMemoryAllocation& allocation) { 639 const GpuMemoryAllocation& allocation) {
620 if (allocation == allocation_) 640 if (allocation == allocation_)
621 return; 641 return;
622 allocation_ = allocation; 642 allocation_ = allocation;
623 643
624 SendMemoryAllocationToProxy(allocation); 644 SendMemoryAllocationToProxy(allocation);
625
626 if (!surface_)
627 return;
628 if (allocation.suggest_have_frontbuffer && allocation.suggest_have_backbuffer)
629 surface_->SetBufferAllocation(
630 gfx::GLSurface::BUFFER_ALLOCATION_FRONT_AND_BACK);
631 else if (allocation.suggest_have_frontbuffer)
632 surface_->SetBufferAllocation(
633 gfx::GLSurface::BUFFER_ALLOCATION_FRONT_ONLY);
634 else
635 surface_->SetBufferAllocation(
636 gfx::GLSurface::BUFFER_ALLOCATION_NONE);
637 } 645 }
638 646
639 #endif // defined(ENABLE_GPU) 647 #endif // defined(ENABLE_GPU)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698