summaryrefslogtreecommitdiffstats
path: root/cc/output
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-16 18:07:17 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-16 18:07:17 +0000
commitb4a2939e0e9d4ad32d7ba21b2810620987ed3a50 (patch)
tree987304f9a58759733f6df914f98d25b7160de1d7 /cc/output
parente55bb2e9371f0068d937cfde128339cc0d597b5a (diff)
downloadchromium_src-b4a2939e0e9d4ad32d7ba21b2810620987ed3a50.zip
chromium_src-b4a2939e0e9d4ad32d7ba21b2810620987ed3a50.tar.gz
chromium_src-b4a2939e0e9d4ad32d7ba21b2810620987ed3a50.tar.bz2
Move swapcomplete callback into OutputSurface
Things like swap are concepts of an OutputSurface, not a context. Moving the callbacks to OutputSurface will also reduce cc's knowledge of the context guts and let us swap out the GL interface. Review URL: https://codereview.chromium.org/12545018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194394 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/output')
-rw-r--r--cc/output/delegating_renderer.cc13
-rw-r--r--cc/output/delegating_renderer.h9
-rw-r--r--cc/output/gl_renderer.cc13
-rw-r--r--cc/output/gl_renderer.h26
-rw-r--r--cc/output/gl_renderer_unittest.cc2
-rw-r--r--cc/output/output_surface.cc26
-rw-r--r--cc/output/output_surface.h3
-rw-r--r--cc/output/output_surface_client.h2
-rw-r--r--cc/output/renderer.h2
-rw-r--r--cc/output/software_renderer.cc2
-rw-r--r--cc/output/software_renderer_unittest.cc2
11 files changed, 39 insertions, 61 deletions
diff --git a/cc/output/delegating_renderer.cc b/cc/output/delegating_renderer.cc
index a1763e3..850ad0f 100644
--- a/cc/output/delegating_renderer.cc
+++ b/cc/output/delegating_renderer.cc
@@ -70,7 +70,6 @@ bool DelegatingRenderer::Initialize() {
if (!context3d->makeContextCurrent())
return false;
- context3d->setContextLostCallback(this);
context3d->pushGroupMarkerEXT("CompositorContext");
std::string extensions_string =
@@ -118,11 +117,7 @@ bool DelegatingRenderer::Initialize() {
return true;
}
-DelegatingRenderer::~DelegatingRenderer() {
- WebGraphicsContext3D* context3d = resource_provider_->GraphicsContext3D();
- if (context3d)
- context3d->setContextLostCallback(NULL);
-}
+DelegatingRenderer::~DelegatingRenderer() {}
const RendererCapabilities& DelegatingRenderer::Capabilities() const {
return capabilities_;
@@ -173,8 +168,6 @@ void DelegatingRenderer::GetFramebufferPixels(void* pixels, gfx::Rect rect) {
void DelegatingRenderer::ReceiveCompositorFrameAck(
const CompositorFrameAck& ack) {
resource_provider_->ReceiveFromParent(ack.resources);
- if (client_->HasImplThread())
- client_->OnSwapBuffersComplete();
}
@@ -189,8 +182,4 @@ void DelegatingRenderer::SetVisible(bool visible) {
visible_ = visible;
}
-void DelegatingRenderer::onContextLost() {
- client_->DidLoseOutputSurface();
-}
-
} // namespace cc
diff --git a/cc/output/delegating_renderer.h b/cc/output/delegating_renderer.h
index a1bac0e..59d3c37 100644
--- a/cc/output/delegating_renderer.h
+++ b/cc/output/delegating_renderer.h
@@ -15,10 +15,8 @@ namespace cc {
class OutputSurface;
class ResourceProvider;
-class CC_EXPORT DelegatingRenderer
- : public Renderer,
- public NON_EXPORTED_BASE(
- WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback) {
+class CC_EXPORT DelegatingRenderer :
+ public Renderer {
public:
static scoped_ptr<DelegatingRenderer> Create(
RendererClient* client,
@@ -46,9 +44,6 @@ class CC_EXPORT DelegatingRenderer
size_t bytes_visible_and_nearby,
size_t bytes_allocated) OVERRIDE {}
- // WebGraphicsContext3D::WebGraphicsContextLostCallback implementation.
- virtual void onContextLost() OVERRIDE;
-
private:
DelegatingRenderer(RendererClient* client,
OutputSurface* output_surface,
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index 5a70f38..dcd952a 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -119,7 +119,6 @@ bool GLRenderer::Initialize() {
if (!context_->makeContextCurrent())
return false;
- context_->setContextLostCallback(this);
context_->pushGroupMarkerEXT("CompositorContext");
std::string extensions_string =
@@ -144,8 +143,6 @@ bool GLRenderer::Initialize() {
if (client_->HasImplThread())
capabilities_.using_swap_complete_callback =
extensions.count("GL_CHROMIUM_swapbuffers_complete_callback") > 0;
- if (capabilities_.using_swap_complete_callback)
- context_->setSwapBuffersCompleteCallbackCHROMIUM(this);
capabilities_.using_set_visibility =
extensions.count("GL_CHROMIUM_set_visibility") > 0;
@@ -191,9 +188,7 @@ bool GLRenderer::Initialize() {
}
GLRenderer::~GLRenderer() {
- context_->setSwapBuffersCompleteCallbackCHROMIUM(NULL);
context_->setMemoryAllocationChangedCallbackCHROMIUM(NULL);
- context_->setContextLostCallback(NULL);
CleanupSharedObjects();
}
@@ -1889,12 +1884,6 @@ bool GLRenderer::SwapBuffers() {
return true;
}
-void GLRenderer::ReceiveCompositorFrameAck(const CompositorFrameAck& ack) {
- onSwapBuffersComplete();
-}
-
-void GLRenderer::onSwapBuffersComplete() { client_->OnSwapBuffersComplete(); }
-
void GLRenderer::onMemoryAllocationChanged(
WebGraphicsMemoryAllocation allocation) {
// Just ignore the memory manager when it says to set the limit to zero
@@ -1972,8 +1961,6 @@ void GLRenderer::EnsureBackbuffer() {
is_backbuffer_discarded_ = false;
}
-void GLRenderer::onContextLost() { client_->DidLoseOutputSurface(); }
-
void GLRenderer::GetFramebufferPixels(void* pixels, gfx::Rect rect) {
DCHECK(rect.right() <= ViewportWidth());
DCHECK(rect.bottom() <= ViewportHeight());
diff --git a/cc/output/gl_renderer.h b/cc/output/gl_renderer.h
index b5f8a46..8023486 100644
--- a/cc/output/gl_renderer.h
+++ b/cc/output/gl_renderer.h
@@ -32,16 +32,11 @@ class GeometryBinding;
class ScopedEnsureFramebufferAllocation;
// Class that handles drawing of composited render layers using GL.
-class CC_EXPORT GLRenderer
- : public DirectRenderer,
- public NON_EXPORTED_BASE(
- WebKit::WebGraphicsContext3D::
- WebGraphicsSwapBuffersCompleteCallbackCHROMIUM),
- public NON_EXPORTED_BASE(
- WebKit::WebGraphicsContext3D::
- WebGraphicsMemoryAllocationChangedCallbackCHROMIUM),
- public NON_EXPORTED_BASE(
- WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback) {
+class CC_EXPORT GLRenderer :
+ public DirectRenderer,
+ public NON_EXPORTED_BASE(
+ WebKit::WebGraphicsContext3D::
+ WebGraphicsMemoryAllocationChangedCallbackCHROMIUM) {
public:
static scoped_ptr<GLRenderer> Create(RendererClient* client,
OutputSurface* output_surface,
@@ -56,9 +51,6 @@ class CC_EXPORT GLRenderer
virtual void ViewportChanged() OVERRIDE;
- virtual void ReceiveCompositorFrameAck(const CompositorFrameAck& ack)
- OVERRIDE;
-
// Waits for rendering to finish.
virtual void Finish() OVERRIDE;
@@ -186,11 +178,6 @@ class CC_EXPORT GLRenderer
void CleanupSharedObjects();
// WebKit::
- // WebGraphicsContext3D::WebGraphicsSwapBuffersCompleteCallbackCHROMIUM
- // implementation.
- virtual void onSwapBuffersComplete() OVERRIDE;
-
- // WebKit::
// WebGraphicsContext3D::WebGraphicsMemoryAllocationChangedCallbackCHROMIUM
// implementation.
virtual void onMemoryAllocationChanged(
@@ -199,9 +186,6 @@ class CC_EXPORT GLRenderer
void EnsureBackbuffer();
void EnforceMemoryPolicy();
- // WebGraphicsContext3D::WebGraphicsContextLostCallback implementation.
- virtual void onContextLost() OVERRIDE;
-
RendererCapabilities capabilities_;
unsigned offscreen_framebuffer_id_;
diff --git a/cc/output/gl_renderer_unittest.cc b/cc/output/gl_renderer_unittest.cc
index 2dfdb39..5dd8d0b 100644
--- a/cc/output/gl_renderer_unittest.cc
+++ b/cc/output/gl_renderer_unittest.cc
@@ -165,8 +165,6 @@ class FakeRendererClient : public RendererClient {
static LayerTreeSettings fake_settings;
return fake_settings;
}
- virtual void DidLoseOutputSurface() OVERRIDE {}
- virtual void OnSwapBuffersComplete() OVERRIDE {}
virtual void SetFullRootLayerDamage() OVERRIDE {
set_full_root_layer_damage_count_++;
}
diff --git a/cc/output/output_surface.cc b/cc/output/output_surface.cc
index 4164402..8312790 100644
--- a/cc/output/output_surface.cc
+++ b/cc/output/output_surface.cc
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/string_util.h"
#include "base/strings/string_split.h"
+#include "cc/output/output_surface_client.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "third_party/khronos/GLES2/gl2ext.h"
@@ -23,6 +24,27 @@ using std::vector;
namespace cc {
+class OutputSurfaceCallbacks :
+ public WebKit::WebGraphicsContext3D::WebGraphicsSwapBuffersCompleteCallbackCHROMIUM,
+ public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback {
+ public:
+ explicit OutputSurfaceCallbacks(OutputSurfaceClient* client)
+ : client_(client) {}
+
+ // WK:WGC3D::WGSwapBuffersCompleteCallbackCHROMIUM implementation.
+ virtual void onSwapBuffersComplete() {
+ client_->OnSwapBuffersComplete();
+ }
+
+ // WK:WGC3D::WGContextLostCallback implementation.
+ virtual void onContextLost() {
+ client_->DidLoseOutputSurface();
+ }
+
+ private:
+ OutputSurfaceClient* client_;
+};
+
OutputSurface::OutputSurface(
scoped_ptr<WebKit::WebGraphicsContext3D> context3d)
: client_(NULL),
@@ -66,6 +88,10 @@ bool OutputSurface::BindToClient(
has_gl_discard_backbuffer_ =
extensions.count("GL_CHROMIUM_discard_backbuffer") > 0;
+ callbacks_.reset(new OutputSurfaceCallbacks(client_));
+ context3d_->setSwapBuffersCompleteCallbackCHROMIUM(callbacks_.get());
+ context3d_->setContextLostCallback(callbacks_.get());
+
return true;
}
diff --git a/cc/output/output_surface.h b/cc/output/output_surface.h
index 2e7a190..8ebf01c 100644
--- a/cc/output/output_surface.h
+++ b/cc/output/output_surface.h
@@ -20,6 +20,7 @@ namespace cc {
class CompositorFrame;
class OutputSurfaceClient;
+class OutputSurfaceCallbacks;
struct LatencyInfo;
// Represents the output surface for a compositor. The compositor owns
@@ -102,6 +103,8 @@ class CC_EXPORT OutputSurface {
scoped_ptr<cc::SoftwareOutputDevice> software_device_;
bool has_gl_discard_backbuffer_;
+ scoped_ptr<OutputSurfaceCallbacks> callbacks_;
+
private:
DISALLOW_COPY_AND_ASSIGN(OutputSurface);
};
diff --git a/cc/output/output_surface_client.h b/cc/output/output_surface_client.h
index 1ba5a43..1e2b542 100644
--- a/cc/output/output_surface_client.h
+++ b/cc/output/output_surface_client.h
@@ -18,6 +18,8 @@ class CC_EXPORT OutputSurfaceClient {
base::TimeDelta interval) = 0;
virtual void DidVSync(base::TimeTicks frame_time) = 0;
virtual void OnSendFrameToParentCompositorAck(const CompositorFrameAck&) = 0;
+ virtual void OnSwapBuffersComplete() = 0;
+ virtual void DidLoseOutputSurface() = 0;
protected:
virtual ~OutputSurfaceClient() {}
diff --git a/cc/output/renderer.h b/cc/output/renderer.h
index 3d26407..6a7d01e 100644
--- a/cc/output/renderer.h
+++ b/cc/output/renderer.h
@@ -21,8 +21,6 @@ class CC_EXPORT RendererClient {
public:
virtual gfx::Size DeviceViewportSize() const = 0;
virtual const LayerTreeSettings& Settings() const = 0;
- virtual void DidLoseOutputSurface() = 0;
- virtual void OnSwapBuffersComplete() = 0;
virtual void SetFullRootLayerDamage() = 0;
virtual void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy) = 0;
virtual void EnforceManagedMemoryPolicy(
diff --git a/cc/output/software_renderer.cc b/cc/output/software_renderer.cc
index 977e7f2..94f00ad 100644
--- a/cc/output/software_renderer.cc
+++ b/cc/output/software_renderer.cc
@@ -125,8 +125,6 @@ bool SoftwareRenderer::SwapBuffers() {
void SoftwareRenderer::ReceiveCompositorFrameAck(
const CompositorFrameAck& ack) {
- if (capabilities_.using_swap_complete_callback)
- client_->OnSwapBuffersComplete();
output_device_->ReclaimDIB(ack.last_dib_id);
}
diff --git a/cc/output/software_renderer_unittest.cc b/cc/output/software_renderer_unittest.cc
index 839cc05..4584757 100644
--- a/cc/output/software_renderer_unittest.cc
+++ b/cc/output/software_renderer_unittest.cc
@@ -55,8 +55,6 @@ class SoftwareRendererTest : public testing::Test, public RendererClient {
virtual const LayerTreeSettings& Settings() const OVERRIDE {
return settings_;
}
- virtual void DidLoseOutputSurface() OVERRIDE {}
- virtual void OnSwapBuffersComplete() OVERRIDE {}
virtual void SetFullRootLayerDamage() OVERRIDE {}
virtual void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy)
OVERRIDE {}