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