| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 : channel_(channel), | 52 : channel_(channel), |
| 53 handle_(handle), | 53 handle_(handle), |
| 54 initial_size_(size), | 54 initial_size_(size), |
| 55 disallowed_features_(disallowed_features), | 55 disallowed_features_(disallowed_features), |
| 56 allowed_extensions_(allowed_extensions), | 56 allowed_extensions_(allowed_extensions), |
| 57 requested_attribs_(attribs), | 57 requested_attribs_(attribs), |
| 58 gpu_preference_(gpu_preference), | 58 gpu_preference_(gpu_preference), |
| 59 route_id_(route_id), | 59 route_id_(route_id), |
| 60 software_(software), | 60 software_(software), |
| 61 last_flush_count_(0), | 61 last_flush_count_(0), |
| 62 allocation_(GpuMemoryAllocation::INVALID_RESOURCE_SIZE, | |
| 63 GpuMemoryAllocation::kHasFrontbuffer | | |
| 64 GpuMemoryAllocation::kHasBackbuffer), | |
| 65 parent_stub_for_initialization_(), | 62 parent_stub_for_initialization_(), |
| 66 parent_texture_for_initialization_(0), | 63 parent_texture_for_initialization_(0), |
| 67 watchdog_(watchdog) { | 64 watchdog_(watchdog) { |
| 68 if (share_group) { | 65 if (share_group) { |
| 69 context_group_ = share_group->context_group_; | 66 context_group_ = share_group->context_group_; |
| 70 } else { | 67 } else { |
| 71 context_group_ = new gpu::gles2::ContextGroup(mailbox_manager, true); | 68 context_group_ = new gpu::gles2::ContextGroup(mailbox_manager, true); |
| 72 } | 69 } |
| 73 if (surface_id != 0) | 70 if (surface_id != 0) |
| 74 surface_state_.reset(new GpuCommandBufferStubBase::SurfaceState( | 71 surface_state_.reset(new GpuCommandBufferStubBase::SurfaceState( |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 void GpuCommandBufferStub::OnSetSurfaceVisible(bool visible) { | 568 void GpuCommandBufferStub::OnSetSurfaceVisible(bool visible) { |
| 572 DCHECK(surface_state_.get()); | 569 DCHECK(surface_state_.get()); |
| 573 surface_state_->visible = visible; | 570 surface_state_->visible = visible; |
| 574 surface_state_->last_used_time = base::TimeTicks::Now(); | 571 surface_state_->last_used_time = base::TimeTicks::Now(); |
| 575 channel_->gpu_channel_manager()->gpu_memory_manager()->ScheduleManage(); | 572 channel_->gpu_channel_manager()->gpu_memory_manager()->ScheduleManage(); |
| 576 } | 573 } |
| 577 | 574 |
| 578 void GpuCommandBufferStub::OnDiscardBackbuffer() { | 575 void GpuCommandBufferStub::OnDiscardBackbuffer() { |
| 579 if (!surface_) | 576 if (!surface_) |
| 580 return; | 577 return; |
| 581 if (allocation_.suggest_have_frontbuffer) | 578 surface_->SetBackbufferAllocation(false); |
| 582 surface_->SetBufferAllocation( | |
| 583 gfx::GLSurface::BUFFER_ALLOCATION_FRONT_ONLY); | |
| 584 else | |
| 585 surface_->SetBufferAllocation( | |
| 586 gfx::GLSurface::BUFFER_ALLOCATION_NONE); | |
| 587 } | 579 } |
| 588 | 580 |
| 589 void GpuCommandBufferStub::OnEnsureBackbuffer() { | 581 void GpuCommandBufferStub::OnEnsureBackbuffer() { |
| 590 if (!surface_) | 582 if (!surface_) |
| 591 return; | 583 return; |
| 592 // TODO(mmocny): Support backbuffer without frontbuffer. | 584 surface_->SetBackbufferAllocation(true); |
| 593 surface_->SetBufferAllocation( | |
| 594 gfx::GLSurface::BUFFER_ALLOCATION_FRONT_AND_BACK); | |
| 595 } | 585 } |
| 596 | 586 |
| 597 void GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback( | 587 void GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback( |
| 598 bool has_callback) { | 588 bool has_callback) { |
| 599 client_has_memory_allocation_changed_callback_ = has_callback; | 589 client_has_memory_allocation_changed_callback_ = has_callback; |
| 600 channel_->gpu_channel_manager()->gpu_memory_manager()->ScheduleManage(); | 590 channel_->gpu_channel_manager()->gpu_memory_manager()->ScheduleManage(); |
| 601 } | 591 } |
| 602 | 592 |
| 603 void GpuCommandBufferStub::SendConsoleMessage( | 593 void GpuCommandBufferStub::SendConsoleMessage( |
| 604 int32 id, | 594 int32 id, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 bool GpuCommandBufferStub::has_surface_state() const { | 626 bool GpuCommandBufferStub::has_surface_state() const { |
| 637 return surface_state_ != NULL; | 627 return surface_state_ != NULL; |
| 638 } | 628 } |
| 639 | 629 |
| 640 const GpuCommandBufferStubBase::SurfaceState& | 630 const GpuCommandBufferStubBase::SurfaceState& |
| 641 GpuCommandBufferStub::surface_state() const { | 631 GpuCommandBufferStub::surface_state() const { |
| 642 DCHECK(has_surface_state()); | 632 DCHECK(has_surface_state()); |
| 643 return *surface_state_.get(); | 633 return *surface_state_.get(); |
| 644 } | 634 } |
| 645 | 635 |
| 646 void GpuCommandBufferStub::SendMemoryAllocationToProxy( | |
| 647 const GpuMemoryAllocation& allocation) { | |
| 648 Send(new GpuCommandBufferMsg_SetMemoryAllocation(route_id_, allocation)); | |
| 649 } | |
| 650 | |
| 651 void GpuCommandBufferStub::SetMemoryAllocation( | 636 void GpuCommandBufferStub::SetMemoryAllocation( |
| 652 const GpuMemoryAllocation& allocation) { | 637 const GpuMemoryAllocation& allocation) { |
| 653 allocation_ = allocation; | 638 Send(new GpuCommandBufferMsg_SetMemoryAllocation(route_id_, allocation)); |
| 654 | 639 if (!surface_) |
| 655 SendMemoryAllocationToProxy(allocation); | 640 return; |
| 641 surface_->SetFrontbufferAllocation(allocation.suggest_have_frontbuffer); |
| 656 } | 642 } |
| 657 | 643 |
| 658 #endif // defined(ENABLE_GPU) | 644 #endif // defined(ENABLE_GPU) |
| OLD | NEW |