| Index: cc/test/fake_output_surface.cc
|
| diff --git a/cc/test/fake_output_surface.cc b/cc/test/fake_output_surface.cc
|
| index c3f3e1a83cd73a4ba320cdac0bf3bd7434af2b56..9ceaddad67117e3b908eb877f9fdf73612af7f08 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_;
|
| }
|
|
|