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