diff options
Diffstat (limited to 'cc/surfaces/display.cc')
-rw-r--r-- | cc/surfaces/display.cc | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/cc/surfaces/display.cc b/cc/surfaces/display.cc index fd7d4b6..e206eb8 100644 --- a/cc/surfaces/display.cc +++ b/cc/surfaces/display.cc @@ -37,17 +37,19 @@ Display::~Display() { manager_->RemoveObserver(this); } +bool Display::Initialize(scoped_ptr<OutputSurface> output_surface) { + output_surface_ = output_surface.Pass(); + return output_surface_->BindToClient(this); +} + void Display::Resize(SurfaceId id, const gfx::Size& size) { current_surface_id_ = id; current_surface_size_ = size; client_->DisplayDamaged(); } -void Display::InitializeOutputSurface() { - if (output_surface_) - return; - scoped_ptr<OutputSurface> output_surface = client_->CreateOutputSurface(); - if (!output_surface->BindToClient(this)) +void Display::InitializeRenderer() { + if (resource_provider_) return; int highp_threshold_min = 0; @@ -55,7 +57,7 @@ void Display::InitializeOutputSurface() { size_t id_allocation_chunk_size = 1; bool use_distance_field_text = false; scoped_ptr<ResourceProvider> resource_provider = - ResourceProvider::Create(output_surface.get(), + ResourceProvider::Create(output_surface_.get(), bitmap_manager_, blocking_main_thread_task_runner_.get(), highp_threshold_min, @@ -65,11 +67,11 @@ void Display::InitializeOutputSurface() { if (!resource_provider) return; - if (output_surface->context_provider()) { + if (output_surface_->context_provider()) { scoped_ptr<GLRenderer> renderer = GLRenderer::Create(this, &settings_, - output_surface.get(), + output_surface_.get(), resource_provider.get(), texture_mailbox_deleter_.get(), highp_threshold_min); @@ -78,22 +80,25 @@ void Display::InitializeOutputSurface() { renderer_ = renderer.Pass(); } else { scoped_ptr<SoftwareRenderer> renderer = SoftwareRenderer::Create( - this, &settings_, output_surface.get(), resource_provider.get()); + this, &settings_, output_surface_.get(), resource_provider.get()); if (!renderer) return; renderer_ = renderer.Pass(); } - output_surface_ = output_surface.Pass(); resource_provider_ = resource_provider.Pass(); aggregator_.reset(new SurfaceAggregator(manager_, resource_provider_.get())); } +void Display::DidLoseOutputSurface() { + client_->OutputSurfaceLost(); +} + bool Display::Draw() { if (current_surface_id_.is_null()) return false; - InitializeOutputSurface(); + InitializeRenderer(); if (!output_surface_) return false; @@ -147,6 +152,10 @@ void Display::CommitVSyncParameters(base::TimeTicks timebase, client_->CommitVSyncParameters(timebase, interval); } +void Display::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { + client_->SetMemoryPolicy(policy); +} + void Display::OnSurfaceDamaged(SurfaceId surface) { if (aggregator_ && aggregator_->previous_contained_surfaces().count(surface)) client_->DisplayDamaged(); |