summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--content/browser/compositor/gpu_process_transport_factory.cc13
-rw-r--r--content/browser/compositor/onscreen_display_client.cc14
-rw-r--r--content/browser/compositor/onscreen_display_client.h4
-rw-r--r--content/browser/compositor/surface_display_output_surface.cc16
-rw-r--r--content/browser/compositor/surface_display_output_surface.h8
-rw-r--r--mojo/services/surfaces/surfaces_impl.cc13
-rw-r--r--mojo/services/surfaces/surfaces_impl.h3
11 files changed, 77 insertions, 42 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() {}
diff --git a/content/browser/compositor/gpu_process_transport_factory.cc b/content/browser/compositor/gpu_process_transport_factory.cc
index 80913c4..7db1620 100644
--- a/content/browser/compositor/gpu_process_transport_factory.cc
+++ b/content/browser/compositor/gpu_process_transport_factory.cc
@@ -200,18 +200,11 @@ scoped_ptr<cc::OutputSurface> GpuProcessTransportFactory::CreateOutputSurface(
scoped_ptr<OnscreenDisplayClient> display_client(new OnscreenDisplayClient(
display_surface.Pass(), manager, compositor->task_runner()));
- scoped_refptr<cc::ContextProvider> offscreen_context_provider;
- if (context_provider.get()) {
- offscreen_context_provider = ContextProviderCommandBuffer::Create(
- GpuProcessTransportFactory::CreateOffscreenCommandBufferContext(),
- "Offscreen-Compositor");
- }
scoped_ptr<SurfaceDisplayOutputSurface> output_surface(
- new SurfaceDisplayOutputSurface(manager,
- next_surface_id_namespace_++,
- offscreen_context_provider));
+ new SurfaceDisplayOutputSurface(
+ manager, next_surface_id_namespace_++, context_provider));
display_client->set_surface_output_surface(output_surface.get());
- output_surface->set_display(display_client->display());
+ output_surface->set_display_client(display_client.get());
data->display_client = display_client.Pass();
return output_surface.PassAs<cc::OutputSurface>();
}
diff --git a/content/browser/compositor/onscreen_display_client.cc b/content/browser/compositor/onscreen_display_client.cc
index f7b6fcd..2adb989 100644
--- a/content/browser/compositor/onscreen_display_client.cc
+++ b/content/browser/compositor/onscreen_display_client.cc
@@ -30,9 +30,8 @@ OnscreenDisplayClient::OnscreenDisplayClient(
OnscreenDisplayClient::~OnscreenDisplayClient() {
}
-scoped_ptr<cc::OutputSurface> OnscreenDisplayClient::CreateOutputSurface() {
- DCHECK(output_surface_.get());
- return output_surface_.Pass();
+bool OnscreenDisplayClient::Initialize() {
+ return display_->Initialize(output_surface_.Pass());
}
void OnscreenDisplayClient::CommitVSyncParameters(base::TimeTicks timebase,
@@ -60,6 +59,10 @@ void OnscreenDisplayClient::ScheduleDraw() {
base::Bind(&OnscreenDisplayClient::Draw, weak_ptr_factory_.GetWeakPtr()));
}
+void OnscreenDisplayClient::OutputSurfaceLost() {
+ surface_display_output_surface_->DidLoseOutputSurface();
+}
+
void OnscreenDisplayClient::Draw() {
TRACE_EVENT0("content", "OnscreenDisplayClient::Draw");
scheduled_draw_ = false;
@@ -78,4 +81,9 @@ void OnscreenDisplayClient::DidSwapBuffersComplete() {
}
}
+void OnscreenDisplayClient::SetMemoryPolicy(
+ const cc::ManagedMemoryPolicy& policy) {
+ surface_display_output_surface_->SetMemoryPolicy(policy);
+}
+
} // namespace content
diff --git a/content/browser/compositor/onscreen_display_client.h b/content/browser/compositor/onscreen_display_client.h
index be6b052..919880f 100644
--- a/content/browser/compositor/onscreen_display_client.h
+++ b/content/browser/compositor/onscreen_display_client.h
@@ -30,18 +30,20 @@ class OnscreenDisplayClient : cc::DisplayClient {
scoped_refptr<base::SingleThreadTaskRunner> task_runner);
virtual ~OnscreenDisplayClient();
+ bool Initialize();
cc::Display* display() { return display_.get(); }
void set_surface_output_surface(SurfaceDisplayOutputSurface* surface) {
surface_display_output_surface_ = surface;
}
// cc::DisplayClient implementation.
- virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface() OVERRIDE;
virtual void DisplayDamaged() OVERRIDE;
virtual void DidSwapBuffers() OVERRIDE;
virtual void DidSwapBuffersComplete() OVERRIDE;
virtual void CommitVSyncParameters(base::TimeTicks timebase,
base::TimeDelta interval) OVERRIDE;
+ virtual void OutputSurfaceLost() OVERRIDE;
+ virtual void SetMemoryPolicy(const cc::ManagedMemoryPolicy& policy) OVERRIDE;
private:
void ScheduleDraw();
diff --git a/content/browser/compositor/surface_display_output_surface.cc b/content/browser/compositor/surface_display_output_surface.cc
index bde972a..c1a09f8f 100644
--- a/content/browser/compositor/surface_display_output_surface.cc
+++ b/content/browser/compositor/surface_display_output_surface.cc
@@ -9,6 +9,7 @@
#include "cc/surfaces/display.h"
#include "cc/surfaces/surface.h"
#include "cc/surfaces/surface_manager.h"
+#include "content/browser/compositor/onscreen_display_client.h"
namespace content {
@@ -18,7 +19,7 @@ SurfaceDisplayOutputSurface::SurfaceDisplayOutputSurface(
const scoped_refptr<cc::ContextProvider>& context_provider)
: cc::OutputSurface(context_provider,
scoped_ptr<cc::SoftwareOutputDevice>()),
- display_(NULL),
+ display_client_(NULL),
surface_manager_(surface_manager),
factory_(surface_manager, this),
allocator_(surface_id_namespace) {
@@ -49,7 +50,7 @@ void SurfaceDisplayOutputSurface::SwapBuffers(cc::CompositorFrame* frame) {
surface_id_ = allocator_.GenerateId();
factory_.Create(surface_id_, frame_size);
display_size_ = frame_size;
- display_->Resize(surface_id_, frame_size);
+ display_client_->display()->Resize(surface_id_, frame_size);
}
scoped_ptr<cc::CompositorFrame> frame_copy(new cc::CompositorFrame());
@@ -63,6 +64,17 @@ void SurfaceDisplayOutputSurface::SwapBuffers(cc::CompositorFrame* frame) {
client_->DidSwapBuffers();
}
+bool SurfaceDisplayOutputSurface::BindToClient(
+ cc::OutputSurfaceClient* client) {
+ DCHECK(client);
+ DCHECK(display_client_);
+ client_ = client;
+ display_client_->Initialize();
+ // Avoid initializing GL context here, as this should be sharing the
+ // Display's context.
+ return true;
+}
+
void SurfaceDisplayOutputSurface::ReturnResources(
const cc::ReturnedResourceArray& resources) {
cc::CompositorFrameAck ack;
diff --git a/content/browser/compositor/surface_display_output_surface.h b/content/browser/compositor/surface_display_output_surface.h
index 69f5ca5..9fc012c 100644
--- a/content/browser/compositor/surface_display_output_surface.h
+++ b/content/browser/compositor/surface_display_output_surface.h
@@ -16,6 +16,7 @@ class SurfaceManager;
}
namespace content {
+class OnscreenDisplayClient;
// This class is maps a compositor OutputSurface to the surface system's Display
// concept, allowing a compositor client to submit frames for a native root
@@ -30,13 +31,16 @@ class SurfaceDisplayOutputSurface : public cc::OutputSurface,
const scoped_refptr<cc::ContextProvider>& context_provider);
virtual ~SurfaceDisplayOutputSurface();
- void set_display(cc::Display* display) { display_ = display; }
+ void set_display_client(OnscreenDisplayClient* display_client) {
+ display_client_ = display_client;
+ }
cc::SurfaceFactory* factory() { return &factory_; }
void ReceivedVSyncParameters(base::TimeTicks timebase,
base::TimeDelta interval);
// cc::OutputSurface implementation.
virtual void SwapBuffers(cc::CompositorFrame* frame) OVERRIDE;
+ virtual bool BindToClient(cc::OutputSurfaceClient* client) OVERRIDE;
// cc::SurfaceFactoryClient implementation.
virtual void ReturnResources(
@@ -45,7 +49,7 @@ class SurfaceDisplayOutputSurface : public cc::OutputSurface,
private:
void SwapBuffersComplete();
- cc::Display* display_;
+ OnscreenDisplayClient* display_client_;
cc::SurfaceManager* surface_manager_;
cc::SurfaceFactory factory_;
gfx::Size display_size_;
diff --git a/mojo/services/surfaces/surfaces_impl.cc b/mojo/services/surfaces/surfaces_impl.cc
index 52a1efe..9d79a7a 100644
--- a/mojo/services/surfaces/surfaces_impl.cc
+++ b/mojo/services/surfaces/surfaces_impl.cc
@@ -77,6 +77,8 @@ void SurfacesImpl::CreateGLES2BoundSurface(CommandBufferPtr gles2_client,
if (!display_) {
display_.reset(new cc::Display(this, manager_, NULL));
client_->SetDisplay(display_.get());
+ display_->Initialize(make_scoped_ptr(new cc::OutputSurface(
+ new ContextProviderMojo(command_buffer_handle_.Pass()))));
}
factory_.Create(cc_id, size.To<gfx::Size>());
display_->Resize(cc_id, size.To<gfx::Size>());
@@ -90,11 +92,6 @@ void SurfacesImpl::ReturnResources(const cc::ReturnedResourceArray& resources) {
client()->ReturnResources(ret.Pass());
}
-scoped_ptr<cc::OutputSurface> SurfacesImpl::CreateOutputSurface() {
- return make_scoped_ptr(new cc::OutputSurface(
- new ContextProviderMojo(command_buffer_handle_.Pass())));
-}
-
void SurfacesImpl::DisplayDamaged() {
}
@@ -108,4 +105,10 @@ void SurfacesImpl::CommitVSyncParameters(base::TimeTicks timebase,
base::TimeDelta interval) {
}
+void SurfacesImpl::OutputSurfaceLost() {
+}
+
+void SurfacesImpl::SetMemoryPolicy(const cc::ManagedMemoryPolicy& policy) {
+}
+
} // namespace mojo
diff --git a/mojo/services/surfaces/surfaces_impl.h b/mojo/services/surfaces/surfaces_impl.h
index 5c1e672..fb6ce53 100644
--- a/mojo/services/surfaces/surfaces_impl.h
+++ b/mojo/services/surfaces/surfaces_impl.h
@@ -50,12 +50,13 @@ class SurfacesImpl : public InterfaceImpl<Surface>,
const cc::ReturnedResourceArray& resources) OVERRIDE;
// DisplayClient implementation.
- virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface() OVERRIDE;
virtual void DisplayDamaged() OVERRIDE;
virtual void DidSwapBuffers() OVERRIDE;
virtual void DidSwapBuffersComplete() OVERRIDE;
virtual void CommitVSyncParameters(base::TimeTicks timebase,
base::TimeDelta interval) OVERRIDE;
+ virtual void OutputSurfaceLost() OVERRIDE;
+ virtual void SetMemoryPolicy(const cc::ManagedMemoryPolicy& policy) OVERRIDE;
cc::SurfaceFactory* factory() { return &factory_; }