| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 : channel_(channel), | 47 : channel_(channel), |
| 48 handle_(handle), | 48 handle_(handle), |
| 49 initial_size_(size), | 49 initial_size_(size), |
| 50 disallowed_features_(disallowed_features), | 50 disallowed_features_(disallowed_features), |
| 51 allowed_extensions_(allowed_extensions), | 51 allowed_extensions_(allowed_extensions), |
| 52 requested_attribs_(attribs), | 52 requested_attribs_(attribs), |
| 53 gpu_preference_(gpu_preference), | 53 gpu_preference_(gpu_preference), |
| 54 route_id_(route_id), | 54 route_id_(route_id), |
| 55 software_(software), | 55 software_(software), |
| 56 last_flush_count_(0), | 56 last_flush_count_(0), |
| 57 allocation_(GpuMemoryAllocation::INVALID_RESOURCE_SIZE, true, true), | |
| 58 parent_stub_for_initialization_(), | 57 parent_stub_for_initialization_(), |
| 59 parent_texture_for_initialization_(0), | 58 parent_texture_for_initialization_(0), |
| 60 watchdog_(watchdog) { | 59 watchdog_(watchdog) { |
| 61 if (share_group) { | 60 if (share_group) { |
| 62 context_group_ = share_group->context_group_; | 61 context_group_ = share_group->context_group_; |
| 63 } else { | 62 } else { |
| 64 context_group_ = new gpu::gles2::ContextGroup(true); | 63 context_group_ = new gpu::gles2::ContextGroup(true); |
| 65 } | 64 } |
| 66 if (surface_id != 0) | 65 if (surface_id != 0) |
| 67 surface_state_.reset(new GpuCommandBufferStubBase::SurfaceState( | 66 surface_state_.reset(new GpuCommandBufferStubBase::SurfaceState( |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 void GpuCommandBufferStub::OnSetSurfaceVisible(bool visible) { | 568 void GpuCommandBufferStub::OnSetSurfaceVisible(bool visible) { |
| 570 DCHECK(surface_state_.get()); | 569 DCHECK(surface_state_.get()); |
| 571 surface_state_->visible = visible; | 570 surface_state_->visible = visible; |
| 572 surface_state_->last_used_time = base::TimeTicks::Now(); | 571 surface_state_->last_used_time = base::TimeTicks::Now(); |
| 573 channel_->gpu_channel_manager()->gpu_memory_manager()->ScheduleManage(); | 572 channel_->gpu_channel_manager()->gpu_memory_manager()->ScheduleManage(); |
| 574 } | 573 } |
| 575 | 574 |
| 576 void GpuCommandBufferStub::OnDiscardBackbuffer() { | 575 void GpuCommandBufferStub::OnDiscardBackbuffer() { |
| 577 if (!surface_) | 576 if (!surface_) |
| 578 return; | 577 return; |
| 579 if (allocation_.suggest_have_frontbuffer) | 578 surface_->SetBackbufferAllocation(false); |
| 580 surface_->SetBufferAllocation( | |
| 581 gfx::GLSurface::BUFFER_ALLOCATION_FRONT_ONLY); | |
| 582 else | |
| 583 surface_->SetBufferAllocation( | |
| 584 gfx::GLSurface::BUFFER_ALLOCATION_NONE); | |
| 585 } | 579 } |
| 586 | 580 |
| 587 void GpuCommandBufferStub::OnEnsureBackbuffer() { | 581 void GpuCommandBufferStub::OnEnsureBackbuffer() { |
| 588 if (!surface_) | 582 if (!surface_) |
| 589 return; | 583 return; |
| 590 // TODO(mmocny): Support backbuffer without frontbuffer. | 584 surface_->SetBackbufferAllocation(true); |
| 591 surface_->SetBufferAllocation( | |
| 592 gfx::GLSurface::BUFFER_ALLOCATION_FRONT_AND_BACK); | |
| 593 } | 585 } |
| 594 | 586 |
| 595 void GpuCommandBufferStub::SendConsoleMessage( | 587 void GpuCommandBufferStub::SendConsoleMessage( |
| 596 int32 id, | 588 int32 id, |
| 597 const std::string& message) { | 589 const std::string& message) { |
| 598 GPUCommandBufferConsoleMessage console_message; | 590 GPUCommandBufferConsoleMessage console_message; |
| 599 console_message.id = id; | 591 console_message.id = id; |
| 600 console_message.message = message; | 592 console_message.message = message; |
| 601 IPC::Message* msg = new GpuCommandBufferMsg_ConsoleMsg( | 593 IPC::Message* msg = new GpuCommandBufferMsg_ConsoleMsg( |
| 602 route_id_, console_message); | 594 route_id_, console_message); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 623 bool GpuCommandBufferStub::has_surface_state() const { | 615 bool GpuCommandBufferStub::has_surface_state() const { |
| 624 return surface_state_ != NULL; | 616 return surface_state_ != NULL; |
| 625 } | 617 } |
| 626 | 618 |
| 627 const GpuCommandBufferStubBase::SurfaceState& | 619 const GpuCommandBufferStubBase::SurfaceState& |
| 628 GpuCommandBufferStub::surface_state() const { | 620 GpuCommandBufferStub::surface_state() const { |
| 629 DCHECK(has_surface_state()); | 621 DCHECK(has_surface_state()); |
| 630 return *surface_state_.get(); | 622 return *surface_state_.get(); |
| 631 } | 623 } |
| 632 | 624 |
| 633 void GpuCommandBufferStub::SendMemoryAllocationToProxy( | |
| 634 const GpuMemoryAllocation& allocation) { | |
| 635 Send(new GpuCommandBufferMsg_SetMemoryAllocation(route_id_, allocation)); | |
| 636 } | |
| 637 | |
| 638 void GpuCommandBufferStub::SetMemoryAllocation( | 625 void GpuCommandBufferStub::SetMemoryAllocation( |
| 639 const GpuMemoryAllocation& allocation) { | 626 const GpuMemoryAllocation& allocation) { |
| 640 allocation_ = allocation; | 627 Send(new GpuCommandBufferMsg_SetMemoryAllocation(route_id_, allocation)); |
| 641 | 628 if (!surface_) |
| 642 SendMemoryAllocationToProxy(allocation); | 629 return; |
| 630 surface_->SetFrontbufferAllocation(allocation.suggest_have_frontbuffer); |
| 643 } | 631 } |
| 644 | 632 |
| 645 #endif // defined(ENABLE_GPU) | 633 #endif // defined(ENABLE_GPU) |
| OLD | NEW |