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

Side by Side Diff: trunk/src/cc/test/fake_output_surface.cc

Issue 17204002: Revert 206020 "cc: Emulate BeginFrame in OutputSurfaces that don..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « trunk/src/cc/test/fake_output_surface.h ('k') | trunk/src/cc/test/layer_tree_test.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/test/fake_output_surface.h" 5 #include "cc/test/fake_output_surface.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "cc/output/compositor_frame_ack.h" 9 #include "cc/output/compositor_frame_ack.h"
10 #include "cc/output/output_surface_client.h" 10 #include "cc/output/output_surface_client.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 11
13 namespace cc { 12 namespace cc {
14 13
15 FakeOutputSurface::FakeOutputSurface( 14 FakeOutputSurface::FakeOutputSurface(
16 scoped_ptr<WebKit::WebGraphicsContext3D> context3d, 15 scoped_ptr<WebKit::WebGraphicsContext3D> context3d,
17 bool delegated_rendering) 16 bool delegated_rendering)
18 : OutputSurface(context3d.Pass()), 17 : OutputSurface(context3d.Pass()),
19 num_sent_frames_(0), 18 num_sent_frames_(0),
20 needs_begin_frame_(false), 19 needs_begin_frame_(false),
21 forced_draw_to_software_device_(false), 20 forced_draw_to_software_device_(false) {
22 fake_weak_ptr_factory_(this) {
23 if (delegated_rendering) { 21 if (delegated_rendering) {
24 capabilities_.delegated_rendering = true; 22 capabilities_.delegated_rendering = true;
25 capabilities_.max_frames_pending = 1; 23 capabilities_.max_frames_pending = 1;
26 } 24 }
27 } 25 }
28 26
29 FakeOutputSurface::FakeOutputSurface( 27 FakeOutputSurface::FakeOutputSurface(
30 scoped_ptr<SoftwareOutputDevice> software_device, bool delegated_rendering) 28 scoped_ptr<SoftwareOutputDevice> software_device, bool delegated_rendering)
31 : OutputSurface(software_device.Pass()), 29 : OutputSurface(software_device.Pass()),
32 num_sent_frames_(0), 30 num_sent_frames_(0),
33 forced_draw_to_software_device_(false), 31 forced_draw_to_software_device_(false) {
34 fake_weak_ptr_factory_(this) {
35 if (delegated_rendering) { 32 if (delegated_rendering) {
36 capabilities_.delegated_rendering = true; 33 capabilities_.delegated_rendering = true;
37 capabilities_.max_frames_pending = 1; 34 capabilities_.max_frames_pending = 1;
38 } 35 }
39 } 36 }
40 37
41 FakeOutputSurface::FakeOutputSurface( 38 FakeOutputSurface::FakeOutputSurface(
42 scoped_ptr<WebKit::WebGraphicsContext3D> context3d, 39 scoped_ptr<WebKit::WebGraphicsContext3D> context3d,
43 scoped_ptr<SoftwareOutputDevice> software_device, 40 scoped_ptr<SoftwareOutputDevice> software_device,
44 bool delegated_rendering) 41 bool delegated_rendering)
45 : OutputSurface(context3d.Pass(), software_device.Pass()), 42 : OutputSurface(context3d.Pass(), software_device.Pass()),
46 num_sent_frames_(0), 43 num_sent_frames_(0),
47 forced_draw_to_software_device_(false), 44 forced_draw_to_software_device_(false) {
48 fake_weak_ptr_factory_(this) {
49 if (delegated_rendering) { 45 if (delegated_rendering) {
50 capabilities_.delegated_rendering = true; 46 capabilities_.delegated_rendering = true;
51 capabilities_.max_frames_pending = 1; 47 capabilities_.max_frames_pending = 1;
52 } 48 }
53 } 49 }
54 50
55 FakeOutputSurface::~FakeOutputSurface() {} 51 FakeOutputSurface::~FakeOutputSurface() {}
56 52
57 void FakeOutputSurface::SwapBuffers(CompositorFrame* frame) { 53 void FakeOutputSurface::SwapBuffers(CompositorFrame* frame) {
58 if (frame->software_frame_data || frame->delegated_frame_data || 54 if (frame->software_frame_data || frame->delegated_frame_data ||
59 !context3d()) { 55 !context3d()) {
60 frame->AssignTo(&last_sent_frame_); 56 frame->AssignTo(&last_sent_frame_);
61 ++num_sent_frames_; 57 ++num_sent_frames_;
62 PostSwapBuffersComplete(); 58 PostSwapBuffersComplete();
63 DidSwapBuffers();
64 } else { 59 } else {
65 OutputSurface::SwapBuffers(frame); 60 OutputSurface::SwapBuffers(frame);
66 frame->AssignTo(&last_sent_frame_); 61 frame->AssignTo(&last_sent_frame_);
67 ++num_sent_frames_; 62 ++num_sent_frames_;
68 } 63 }
69 } 64 }
70 65
71 void FakeOutputSurface::SetNeedsBeginFrame(bool enable) { 66 void FakeOutputSurface::SetNeedsBeginFrame(bool enable) {
72 needs_begin_frame_ = enable; 67 needs_begin_frame_ = enable;
73 OutputSurface::SetNeedsBeginFrame(enable);
74
75 // If there is not BeginFrame emulation from the FrameRateController,
76 // then we just post a BeginFrame to emulate it as part of the test.
77 if (enable && !frame_rate_controller_) {
78 base::MessageLoop::current()->PostDelayedTask(
79 FROM_HERE, base::Bind(&FakeOutputSurface::OnBeginFrame,
80 fake_weak_ptr_factory_.GetWeakPtr()),
81 base::TimeDelta::FromMilliseconds(16));
82 }
83 } 68 }
84 69
85 void FakeOutputSurface::OnBeginFrame() { 70 void FakeOutputSurface::BeginFrame(base::TimeTicks frame_time) {
86 OutputSurface::BeginFrame(base::TimeTicks::Now()); 71 client_->BeginFrame(frame_time);
87 } 72 }
88 73
89
90 bool FakeOutputSurface::ForcedDrawToSoftwareDevice() const { 74 bool FakeOutputSurface::ForcedDrawToSoftwareDevice() const {
91 return forced_draw_to_software_device_; 75 return forced_draw_to_software_device_;
92 } 76 }
93 77
94 } // namespace cc 78 } // namespace cc
OLDNEW
« no previous file with comments | « trunk/src/cc/test/fake_output_surface.h ('k') | trunk/src/cc/test/layer_tree_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698