summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorjbauman <jbauman@chromium.org>2014-10-03 13:51:23 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-03 20:51:34 +0000
commita8c5cc954741060cf01a5cf156b5ecaabc219444 (patch)
treec3e15218458ba558a66689a7353b2138fa7859e6 /cc
parentf4518c10c2862ffaa359a6b47726f4d28d4ee14f (diff)
downloadchromium_src-a8c5cc954741060cf01a5cf156b5ecaabc219444.zip
chromium_src-a8c5cc954741060cf01a5cf156b5ecaabc219444.tar.gz
chromium_src-a8c5cc954741060cf01a5cf156b5ecaabc219444.tar.bz2
Make browser compositor and display share a context
The browser compositor and the display won't interfere with each other, so sharing a context avoids wasting time and memory creating a second context. The display should own the context, though it passes information related to context lost and memory management to the browser compositor. Review URL: https://codereview.chromium.org/615313003 Cr-Commit-Position: refs/heads/master@{#298093}
Diffstat (limited to 'cc')
-rw-r--r--cc/output/output_surface.h5
-rw-r--r--cc/surfaces/display.cc31
-rw-r--r--cc/surfaces/display.h7
-rw-r--r--cc/surfaces/display_client.h5
4 files changed, 30 insertions, 18 deletions
diff --git a/cc/output/output_surface.h b/cc/output/output_surface.h
index 9bc95d0..c79f770 100644
--- a/cc/output/output_surface.h
+++ b/cc/output/output_surface.h
@@ -133,6 +133,9 @@ class CC_EXPORT OutputSurface {
return overlay_candidate_validator_.get();
}
+ void DidLoseOutputSurface();
+ void SetMemoryPolicy(const ManagedMemoryPolicy& policy);
+
protected:
OutputSurfaceClient* client_;
@@ -156,7 +159,6 @@ class CC_EXPORT OutputSurface {
void SetNeedsRedrawRect(const gfx::Rect& damage_rect);
void ReclaimResources(const CompositorFrameAck* ack);
- void DidLoseOutputSurface();
void SetExternalStencilTest(bool enabled);
void SetExternalDrawConstraints(
const gfx::Transform& transform,
@@ -169,7 +171,6 @@ class CC_EXPORT OutputSurface {
private:
void SetUpContext3d();
void ResetContext3d();
- void SetMemoryPolicy(const ManagedMemoryPolicy& policy);
bool external_stencil_test_enabled_;
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();
diff --git a/cc/surfaces/display.h b/cc/surfaces/display.h
index af972cb..d12d956 100644
--- a/cc/surfaces/display.h
+++ b/cc/surfaces/display.h
@@ -44,6 +44,7 @@ class CC_SURFACES_EXPORT Display : public OutputSurfaceClient,
SharedBitmapManager* bitmap_manager);
virtual ~Display();
+ bool Initialize(scoped_ptr<OutputSurface> output_surface);
void Resize(SurfaceId id, const gfx::Size& new_size);
bool Draw();
@@ -60,7 +61,7 @@ class CC_SURFACES_EXPORT Display : public OutputSurfaceClient,
virtual void DidSwapBuffers() OVERRIDE;
virtual void DidSwapBuffersComplete() OVERRIDE;
virtual void ReclaimResources(const CompositorFrameAck* ack) OVERRIDE {}
- virtual void DidLoseOutputSurface() OVERRIDE {}
+ virtual void DidLoseOutputSurface() OVERRIDE;
virtual void SetExternalDrawConstraints(
const gfx::Transform& transform,
const gfx::Rect& viewport,
@@ -68,7 +69,7 @@ class CC_SURFACES_EXPORT Display : public OutputSurfaceClient,
const gfx::Rect& viewport_rect_for_tile_priority,
const gfx::Transform& transform_for_tile_priority,
bool resourceless_software_draw) OVERRIDE {}
- virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE {}
+ virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE;
virtual void SetTreeActivationCallback(
const base::Closure& callback) OVERRIDE {}
@@ -79,7 +80,7 @@ class CC_SURFACES_EXPORT Display : public OutputSurfaceClient,
virtual void OnSurfaceDamaged(SurfaceId surface) OVERRIDE;
private:
- void InitializeOutputSurface();
+ void InitializeRenderer();
DisplayClient* client_;
SurfaceManager* manager_;
diff --git a/cc/surfaces/display_client.h b/cc/surfaces/display_client.h
index 2c89883..b0f8f79 100644
--- a/cc/surfaces/display_client.h
+++ b/cc/surfaces/display_client.h
@@ -10,16 +10,17 @@
namespace cc {
-class OutputSurface;
+struct ManagedMemoryPolicy;
class DisplayClient {
public:
- virtual scoped_ptr<OutputSurface> CreateOutputSurface() = 0;
virtual void DisplayDamaged() = 0;
virtual void DidSwapBuffers() = 0;
virtual void DidSwapBuffersComplete() = 0;
virtual void CommitVSyncParameters(base::TimeTicks timebase,
base::TimeDelta interval) = 0;
+ virtual void OutputSurfaceLost() = 0;
+ virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) = 0;
protected:
virtual ~DisplayClient() {}