Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Unified Diff: ui/compositor/compositor.cc

Issue 11195011: Send vsync timebase updates to the browser compositor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use the existing output surface mechanism to feed vsync info into the compositor Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/compositor/compositor.cc
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc
index 31f47c7d0a715531384d08827ba91eb8d4f5517e..dfd4781b54967091d59cf6b3f339c9fadcc3d910 100644
--- a/ui/compositor/compositor.cc
+++ b/ui/compositor/compositor.cc
@@ -63,6 +63,48 @@ void ContextFactory::SetInstance(ContextFactory* instance) {
g_context_factory = instance;
}
+// Adapts a pure WebGraphicsContext3D into a WebCompositorOutputSurface.
+class WebGraphicsContextToOutputSurfaceAdapter :
+ public WebKit::WebCompositorOutputSurface {
+public:
piman 2012/10/24 16:56:54 nit: Chrome style please for all of this class.
ajuma 2012/10/26 20:12:39 Done.
+ explicit WebGraphicsContextToOutputSurfaceAdapter(
+ WebKit::WebGraphicsContext3D* context)
+ : m_context3D(context)
+ , m_client(0)
+ {
+ }
+
+ virtual bool bindToClient(
+ WebKit::WebCompositorOutputSurfaceClient* client) OVERRIDE
+ {
+ DCHECK(client);
+ if (!m_context3D->makeContextCurrent())
+ return false;
+ m_client = client;
+ return true;
+ }
+
+ virtual const Capabilities& capabilities() const OVERRIDE
+ {
+ return m_capabilities;
+ }
+
+ virtual WebKit::WebGraphicsContext3D* context3D() const OVERRIDE
+ {
+ return m_context3D.get();
+ }
+
+ virtual void sendFrameToParentCompositor(
+ const WebKit::WebCompositorFrame&) OVERRIDE
+ {
+ }
+
+private:
+ scoped_ptr<WebKit::WebGraphicsContext3D> m_context3D;
+ Capabilities m_capabilities;
+ WebKit::WebCompositorOutputSurfaceClient* m_client;
+};
+
DefaultContextFactory::DefaultContextFactory() {
}
@@ -87,6 +129,12 @@ WebKit::WebGraphicsContext3D* DefaultContextFactory::CreateContext(
return CreateContextCommon(compositor, false);
}
+WebKit::WebCompositorOutputSurface* DefaultContextFactory::CreateOutputSurface(
+ Compositor* compositor) {
+ return new WebGraphicsContextToOutputSurfaceAdapter(
+ CreateContext(compositor));
+}
+
WebKit::WebGraphicsContext3D* DefaultContextFactory::CreateOffscreenContext() {
return CreateContextCommon(NULL, true);
}
@@ -327,48 +375,6 @@ void Compositor::applyScrollAndScale(const WebKit::WebSize& scrollDelta,
float scaleFactor) {
}
-// Adapts a pure WebGraphicsContext3D into a WebCompositorOutputSurface.
-class WebGraphicsContextToOutputSurfaceAdapter :
- public WebKit::WebCompositorOutputSurface {
-public:
- explicit WebGraphicsContextToOutputSurfaceAdapter(
- WebKit::WebGraphicsContext3D* context)
- : m_context3D(context)
- , m_client(0)
- {
- }
-
- virtual bool bindToClient(
- WebKit::WebCompositorOutputSurfaceClient* client) OVERRIDE
- {
- DCHECK(client);
- if (!m_context3D->makeContextCurrent())
- return false;
- m_client = client;
- return true;
- }
-
- virtual const Capabilities& capabilities() const OVERRIDE
- {
- return m_capabilities;
- }
-
- virtual WebKit::WebGraphicsContext3D* context3D() const OVERRIDE
- {
- return m_context3D.get();
- }
-
- virtual void sendFrameToParentCompositor(
- const WebKit::WebCompositorFrame&) OVERRIDE
- {
- }
-
-private:
- scoped_ptr<WebKit::WebGraphicsContext3D> m_context3D;
- Capabilities m_capabilities;
- WebKit::WebCompositorOutputSurfaceClient* m_client;
-};
-
WebKit::WebCompositorOutputSurface* Compositor::createOutputSurface() {
if (test_compositor_enabled) {
ui::TestWebGraphicsContext3D* test_context =
@@ -376,8 +382,7 @@ WebKit::WebCompositorOutputSurface* Compositor::createOutputSurface() {
test_context->Initialize();
return new WebGraphicsContextToOutputSurfaceAdapter(test_context);
} else {
- return new WebGraphicsContextToOutputSurfaceAdapter(
- ContextFactory::GetInstance()->CreateContext(this));
+ return ContextFactory::GetInstance()->CreateOutputSurface(this);
}
}

Powered by Google App Engine
This is Rietveld 408576698