OLD | NEW |
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 : channel_(channel), | 51 : channel_(channel), |
52 handle_(handle), | 52 handle_(handle), |
53 initial_size_(size), | 53 initial_size_(size), |
54 disallowed_features_(disallowed_features), | 54 disallowed_features_(disallowed_features), |
55 allowed_extensions_(allowed_extensions), | 55 allowed_extensions_(allowed_extensions), |
56 requested_attribs_(attribs), | 56 requested_attribs_(attribs), |
57 gpu_preference_(gpu_preference), | 57 gpu_preference_(gpu_preference), |
58 route_id_(route_id), | 58 route_id_(route_id), |
59 software_(software), | 59 software_(software), |
60 last_flush_count_(0), | 60 last_flush_count_(0), |
61 allocation_(GpuMemoryAllocation::INVALID_RESOURCE_SIZE, | 61 allocation_(GpuMemoryAllocation::INVALID_RESOURCE_SIZE, true, true), |
62 GpuMemoryAllocation::kHasFrontbuffer | | |
63 GpuMemoryAllocation::kHasBackbuffer), | |
64 parent_stub_for_initialization_(), | 62 parent_stub_for_initialization_(), |
65 parent_texture_for_initialization_(0), | 63 parent_texture_for_initialization_(0), |
66 watchdog_(watchdog) { | 64 watchdog_(watchdog) { |
67 if (share_group) { | 65 if (share_group) { |
68 context_group_ = share_group->context_group_; | 66 context_group_ = share_group->context_group_; |
69 } else { | 67 } else { |
70 context_group_ = new gpu::gles2::ContextGroup(true); | 68 context_group_ = new gpu::gles2::ContextGroup(true); |
71 } | 69 } |
72 if (surface_id != 0) | 70 if (surface_id != 0) |
73 surface_state_.reset(new GpuCommandBufferStubBase::SurfaceState( | 71 surface_state_.reset(new GpuCommandBufferStubBase::SurfaceState( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateVideoDecoder, | 123 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateVideoDecoder, |
126 OnCreateVideoDecoder) | 124 OnCreateVideoDecoder) |
127 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyVideoDecoder, | 125 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyVideoDecoder, |
128 OnDestroyVideoDecoder) | 126 OnDestroyVideoDecoder) |
129 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetSurfaceVisible, | 127 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetSurfaceVisible, |
130 OnSetSurfaceVisible) | 128 OnSetSurfaceVisible) |
131 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DiscardBackbuffer, | 129 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DiscardBackbuffer, |
132 OnDiscardBackbuffer) | 130 OnDiscardBackbuffer) |
133 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_EnsureBackbuffer, | 131 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_EnsureBackbuffer, |
134 OnEnsureBackbuffer) | 132 OnEnsureBackbuffer) |
135 IPC_MESSAGE_HANDLER( | |
136 GpuCommandBufferMsg_SetClientHasMemoryAllocationChangedCallback, | |
137 OnSetClientHasMemoryAllocationChangedCallback) | |
138 IPC_MESSAGE_UNHANDLED(handled = false) | 133 IPC_MESSAGE_UNHANDLED(handled = false) |
139 IPC_END_MESSAGE_MAP() | 134 IPC_END_MESSAGE_MAP() |
140 | 135 |
141 DCHECK(handled); | 136 DCHECK(handled); |
142 return handled; | 137 return handled; |
143 } | 138 } |
144 | 139 |
145 bool GpuCommandBufferStub::Send(IPC::Message* message) { | 140 bool GpuCommandBufferStub::Send(IPC::Message* message) { |
146 return channel_->Send(message); | 141 return channel_->Send(message); |
147 } | 142 } |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 } | 581 } |
587 | 582 |
588 void GpuCommandBufferStub::OnEnsureBackbuffer() { | 583 void GpuCommandBufferStub::OnEnsureBackbuffer() { |
589 if (!surface_) | 584 if (!surface_) |
590 return; | 585 return; |
591 // TODO(mmocny): Support backbuffer without frontbuffer. | 586 // TODO(mmocny): Support backbuffer without frontbuffer. |
592 surface_->SetBufferAllocation( | 587 surface_->SetBufferAllocation( |
593 gfx::GLSurface::BUFFER_ALLOCATION_FRONT_AND_BACK); | 588 gfx::GLSurface::BUFFER_ALLOCATION_FRONT_AND_BACK); |
594 } | 589 } |
595 | 590 |
596 void GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback( | |
597 bool has_callback) { | |
598 client_has_memory_allocation_changed_callback_ = has_callback; | |
599 channel_->gpu_channel_manager()->gpu_memory_manager()->ScheduleManage(); | |
600 } | |
601 | |
602 void GpuCommandBufferStub::SendConsoleMessage( | 591 void GpuCommandBufferStub::SendConsoleMessage( |
603 int32 id, | 592 int32 id, |
604 const std::string& message) { | 593 const std::string& message) { |
605 GPUCommandBufferConsoleMessage console_message; | 594 GPUCommandBufferConsoleMessage console_message; |
606 console_message.id = id; | 595 console_message.id = id; |
607 console_message.message = message; | 596 console_message.message = message; |
608 IPC::Message* msg = new GpuCommandBufferMsg_ConsoleMsg( | 597 IPC::Message* msg = new GpuCommandBufferMsg_ConsoleMsg( |
609 route_id_, console_message); | 598 route_id_, console_message); |
610 msg->set_unblock(true); | 599 msg->set_unblock(true); |
611 Send(msg); | 600 Send(msg); |
612 } | 601 } |
613 | 602 |
614 void GpuCommandBufferStub::AddDestructionObserver( | 603 void GpuCommandBufferStub::AddDestructionObserver( |
615 DestructionObserver* observer) { | 604 DestructionObserver* observer) { |
616 destruction_observers_.AddObserver(observer); | 605 destruction_observers_.AddObserver(observer); |
617 } | 606 } |
618 | 607 |
619 void GpuCommandBufferStub::RemoveDestructionObserver( | 608 void GpuCommandBufferStub::RemoveDestructionObserver( |
620 DestructionObserver* observer) { | 609 DestructionObserver* observer) { |
621 destruction_observers_.RemoveObserver(observer); | 610 destruction_observers_.RemoveObserver(observer); |
622 } | 611 } |
623 | 612 |
624 bool GpuCommandBufferStub::IsInSameContextShareGroup( | 613 bool GpuCommandBufferStub::IsInSameContextShareGroup( |
625 const GpuCommandBufferStubBase& other) const { | 614 const GpuCommandBufferStubBase& other) const { |
626 return context_group_ == | 615 return context_group_ == |
627 static_cast<const GpuCommandBufferStub&>(other).context_group_; | 616 static_cast<const GpuCommandBufferStub&>(other).context_group_; |
628 } | 617 } |
629 | 618 |
630 bool GpuCommandBufferStub:: | |
631 client_has_memory_allocation_changed_callback() const { | |
632 return client_has_memory_allocation_changed_callback_; | |
633 } | |
634 | |
635 bool GpuCommandBufferStub::has_surface_state() const { | 619 bool GpuCommandBufferStub::has_surface_state() const { |
636 return surface_state_ != NULL; | 620 return surface_state_ != NULL; |
637 } | 621 } |
638 | 622 |
639 const GpuCommandBufferStubBase::SurfaceState& | 623 const GpuCommandBufferStubBase::SurfaceState& |
640 GpuCommandBufferStub::surface_state() const { | 624 GpuCommandBufferStub::surface_state() const { |
641 DCHECK(has_surface_state()); | 625 DCHECK(has_surface_state()); |
642 return *surface_state_.get(); | 626 return *surface_state_.get(); |
643 } | 627 } |
644 | 628 |
645 void GpuCommandBufferStub::SendMemoryAllocationToProxy( | 629 void GpuCommandBufferStub::SendMemoryAllocationToProxy( |
646 const GpuMemoryAllocation& allocation) { | 630 const GpuMemoryAllocation& allocation) { |
647 Send(new GpuCommandBufferMsg_SetMemoryAllocation(route_id_, allocation)); | 631 Send(new GpuCommandBufferMsg_SetMemoryAllocation(route_id_, allocation)); |
648 } | 632 } |
649 | 633 |
650 void GpuCommandBufferStub::SetMemoryAllocation( | 634 void GpuCommandBufferStub::SetMemoryAllocation( |
651 const GpuMemoryAllocation& allocation) { | 635 const GpuMemoryAllocation& allocation) { |
652 allocation_ = allocation; | 636 allocation_ = allocation; |
653 | 637 |
654 SendMemoryAllocationToProxy(allocation); | 638 SendMemoryAllocationToProxy(allocation); |
655 } | 639 } |
656 | 640 |
657 #endif // defined(ENABLE_GPU) | 641 #endif // defined(ENABLE_GPU) |
OLD | NEW |