summaryrefslogtreecommitdiffstats
path: root/cc/test/fake_output_surface.cc
diff options
context:
space:
mode:
authorbrianderson@chromium.org <brianderson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-18 12:32:35 +0000
committerbrianderson@chromium.org <brianderson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-18 12:32:35 +0000
commit049fc7a730faa0dc77df259cc63a7907bc87d922 (patch)
treef78d949c8bf641542c1225129ed49da901a333a5 /cc/test/fake_output_surface.cc
parentf56c7874661fc602acb108ad923b9e7118eba058 (diff)
downloadchromium_src-049fc7a730faa0dc77df259cc63a7907bc87d922.zip
chromium_src-049fc7a730faa0dc77df259cc63a7907bc87d922.tar.gz
chromium_src-049fc7a730faa0dc77df259cc63a7907bc87d922.tar.bz2
cc: Emulate BeginFrame in OutputSurfaces that don't support it natively
Relanding again. This time, the proactive SetNeedsBeginFrame is broken out explicitly with logic to workaround crbug 249806 and to avoid expensive redraws with the synchronous renderer. This includes two small fixes for the original version of this patch that broke software compositing and WebView. This will allow us to avoid having two different code paths in the Scheduler. It also allows us to more easily remove the VSyncTimeSource and FrameRateController from the Scheduler. This patch instantiates the FrameRateController inside of OutputSurface for now, but the FrameRateController could be removed in future patches. BUG=245920 BUG=243497 BUG=249806 TBR=nduca@chromium.org,sievers@chromium.org,kbr@chromium.org Review URL: https://chromiumcodereview.appspot.com/17353002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206955 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/test/fake_output_surface.cc')
-rw-r--r--cc/test/fake_output_surface.cc26
1 files changed, 21 insertions, 5 deletions
diff --git a/cc/test/fake_output_surface.cc b/cc/test/fake_output_surface.cc
index c3f3e1a..9ceadda 100644
--- a/cc/test/fake_output_surface.cc
+++ b/cc/test/fake_output_surface.cc
@@ -8,6 +8,7 @@
#include "base/message_loop.h"
#include "cc/output/compositor_frame_ack.h"
#include "cc/output/output_surface_client.h"
+#include "testing/gtest/include/gtest/gtest.h"
namespace cc {
@@ -17,7 +18,8 @@ FakeOutputSurface::FakeOutputSurface(
: OutputSurface(context3d.Pass()),
num_sent_frames_(0),
needs_begin_frame_(false),
- forced_draw_to_software_device_(false) {
+ forced_draw_to_software_device_(false),
+ fake_weak_ptr_factory_(this) {
if (delegated_rendering) {
capabilities_.delegated_rendering = true;
capabilities_.max_frames_pending = 1;
@@ -28,7 +30,8 @@ FakeOutputSurface::FakeOutputSurface(
scoped_ptr<SoftwareOutputDevice> software_device, bool delegated_rendering)
: OutputSurface(software_device.Pass()),
num_sent_frames_(0),
- forced_draw_to_software_device_(false) {
+ forced_draw_to_software_device_(false),
+ fake_weak_ptr_factory_(this) {
if (delegated_rendering) {
capabilities_.delegated_rendering = true;
capabilities_.max_frames_pending = 1;
@@ -41,7 +44,8 @@ FakeOutputSurface::FakeOutputSurface(
bool delegated_rendering)
: OutputSurface(context3d.Pass(), software_device.Pass()),
num_sent_frames_(0),
- forced_draw_to_software_device_(false) {
+ forced_draw_to_software_device_(false),
+ fake_weak_ptr_factory_(this) {
if (delegated_rendering) {
capabilities_.delegated_rendering = true;
capabilities_.max_frames_pending = 1;
@@ -56,6 +60,7 @@ void FakeOutputSurface::SwapBuffers(CompositorFrame* frame) {
frame->AssignTo(&last_sent_frame_);
++num_sent_frames_;
PostSwapBuffersComplete();
+ DidSwapBuffers();
} else {
OutputSurface::SwapBuffers(frame);
frame->AssignTo(&last_sent_frame_);
@@ -65,12 +70,23 @@ void FakeOutputSurface::SwapBuffers(CompositorFrame* frame) {
void FakeOutputSurface::SetNeedsBeginFrame(bool enable) {
needs_begin_frame_ = enable;
+ OutputSurface::SetNeedsBeginFrame(enable);
+
+ // If there is not BeginFrame emulation from the FrameRateController,
+ // then we just post a BeginFrame to emulate it as part of the test.
+ if (enable && !frame_rate_controller_) {
+ base::MessageLoop::current()->PostDelayedTask(
+ FROM_HERE, base::Bind(&FakeOutputSurface::OnBeginFrame,
+ fake_weak_ptr_factory_.GetWeakPtr()),
+ base::TimeDelta::FromMilliseconds(16));
+ }
}
-void FakeOutputSurface::BeginFrame(base::TimeTicks frame_time) {
- client_->BeginFrame(frame_time);
+void FakeOutputSurface::OnBeginFrame() {
+ OutputSurface::BeginFrame(base::TimeTicks::Now());
}
+
bool FakeOutputSurface::ForcedDrawToSoftwareDevice() const {
return forced_draw_to_software_device_;
}