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

Unified Diff: content/browser/aura/software_browser_compositor_output_surface.cc

Issue 57883007: Adding support for VSyncProvider to the software drawing path (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added unittests Created 7 years, 1 month 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: content/browser/aura/software_browser_compositor_output_surface.cc
diff --git a/content/browser/aura/software_browser_compositor_output_surface.cc b/content/browser/aura/software_browser_compositor_output_surface.cc
index 773e7df75bb6edc62e1ded4cf8fe07e71472e616..882828d1647cb6081cf88711255e39f0dc856e24 100644
--- a/content/browser/aura/software_browser_compositor_output_surface.cc
+++ b/content/browser/aura/software_browser_compositor_output_surface.cc
@@ -4,18 +4,79 @@
#include "content/browser/aura/software_browser_compositor_output_surface.h"
+#include "base/memory/ref_counted.h"
#include "base/message_loop/message_loop.h"
#include "base/time/time.h"
#include "cc/output/compositor_frame.h"
#include "cc/output/software_output_device.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "ui/events/latency_info.h"
+#include "ui/gl/vsync_provider.h"
namespace content {
+class VSyncListener : public base::RefCountedThreadSafe<VSyncListener> {
+ public:
+ VSyncListener(SoftwareBrowserCompositorOutputSurface* surface,
+ scoped_refptr<base::MessageLoopProxy> compositor_message_loop,
+ base::WeakPtr<ui::Compositor> compositor);
+
+ // Called by the VSyncProvider when updating the time of the most recent
+ // screen refresh.
+ void VSyncCallback(const base::TimeTicks timebase,
+ const base::TimeDelta interval);
+
+ private:
+ friend class base::RefCountedThreadSafe<VSyncListener>;
+
+ virtual ~VSyncListener();
+
+ SoftwareBrowserCompositorOutputSurface* surface_;
+ scoped_refptr<base::MessageLoopProxy> compositor_message_loop_;
+ base::WeakPtr<ui::Compositor> compositor_;
+
+ DISALLOW_COPY_AND_ASSIGN(VSyncListener);
+};
piman 2013/11/05 23:32:27 So this class is really only there to forward the
dnicoara 2013/11/06 18:11:47 Yes, this would be similar to the BrowserComposito
+
+VSyncListener::VSyncListener(
+ SoftwareBrowserCompositorOutputSurface* surface,
+ scoped_refptr<base::MessageLoopProxy> compositor_message_loop,
+ base::WeakPtr<ui::Compositor> compositor)
+ : surface_(surface),
+ compositor_message_loop_(compositor_message_loop),
+ compositor_(compositor) {
+}
+
+VSyncListener::~VSyncListener() {
+}
+
+void VSyncListener::VSyncCallback(
+ const base::TimeTicks timebase,
+ const base::TimeDelta interval) {
piman 2013/11/05 23:32:27 So, this should be called on the compositor alread
+ // Update the OutputSurface.
+ surface_->OnVSyncParametersChanged(timebase, interval);
piman 2013/11/05 23:32:27 What guarantee do we have that surface_ is still v
+ // Propagate the update to the compositor.
+ compositor_message_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(&ui::Compositor::OnUpdateVSyncParameters,
+ compositor_,
+ timebase,
+ interval));
+}
+
SoftwareBrowserCompositorOutputSurface::SoftwareBrowserCompositorOutputSurface(
- scoped_ptr<cc::SoftwareOutputDevice> software_device)
- : cc::OutputSurface(software_device.Pass()) {}
+ scoped_ptr<cc::SoftwareOutputDevice> software_device,
+ base::MessageLoopProxy* compositor_message_loop,
+ base::WeakPtr<ui::Compositor> compositor)
+ : cc::OutputSurface(software_device.Pass()),
+ vsync_listener_(new VSyncListener(this,
+ compositor_message_loop,
+ compositor)) {
+}
+
+SoftwareBrowserCompositorOutputSurface::
+~SoftwareBrowserCompositorOutputSurface() {
piman 2013/11/05 23:32:27 nit: this looks indented wrong. git cl format?
+}
void SoftwareBrowserCompositorOutputSurface::SwapBuffers(
cc::CompositorFrame* frame) {
@@ -28,6 +89,13 @@ void SoftwareBrowserCompositorOutputSurface::SwapBuffers(
base::Bind(
&RenderWidgetHostImpl::CompositorFrameDrawn,
latency_info));
+
+ gfx::VSyncProvider* vsync_provider = software_device_->GetVSyncProvider();
+ if (vsync_provider) {
+ vsync_provider->GetVSyncParameters(base::Bind(
+ &VSyncListener::VSyncCallback,
+ vsync_listener_));
+ }
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698