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

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

Issue 221833009: cc: Move scheduling logic out of OutputSurface (Closed) Base URL: http://git.chromium.org/chromium/src.git@swapAck2Sched11
Patch Set: rebase; sami's comments Created 6 years, 8 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
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/message_loop.h" 8 #include "base/message_loop/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"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 fake_weak_ptr_factory_(this) { 56 fake_weak_ptr_factory_(this) {
57 if (delegated_rendering) { 57 if (delegated_rendering) {
58 capabilities_.delegated_rendering = true; 58 capabilities_.delegated_rendering = true;
59 capabilities_.max_frames_pending = 1; 59 capabilities_.max_frames_pending = 1;
60 } 60 }
61 } 61 }
62 62
63 FakeOutputSurface::~FakeOutputSurface() {} 63 FakeOutputSurface::~FakeOutputSurface() {}
64 64
65 void FakeOutputSurface::SwapBuffers(CompositorFrame* frame) { 65 void FakeOutputSurface::SwapBuffers(CompositorFrame* frame) {
66 if (is_lost_)
67 return;
68
66 if (frame->software_frame_data || frame->delegated_frame_data || 69 if (frame->software_frame_data || frame->delegated_frame_data ||
67 !context_provider()) { 70 !context_provider()) {
68 frame->AssignTo(&last_sent_frame_); 71 frame->AssignTo(&last_sent_frame_);
69 72
70 if (last_sent_frame_.delegated_frame_data) { 73 if (last_sent_frame_.delegated_frame_data) {
71 resources_held_by_parent_.insert( 74 resources_held_by_parent_.insert(
72 resources_held_by_parent_.end(), 75 resources_held_by_parent_.end(),
73 last_sent_frame_.delegated_frame_data->resource_list.begin(), 76 last_sent_frame_.delegated_frame_data->resource_list.begin(),
74 last_sent_frame_.delegated_frame_data->resource_list.end()); 77 last_sent_frame_.delegated_frame_data->resource_list.end());
75 } 78 }
76 79
77 ++num_sent_frames_; 80 ++num_sent_frames_;
78 PostSwapBuffersComplete(); 81 PostSwapBuffersComplete();
79 DidSwapBuffers(); 82 client_->DidSwapBuffers();
80 } else { 83 } else {
81 OutputSurface::SwapBuffers(frame); 84 OutputSurface::SwapBuffers(frame);
82 frame->AssignTo(&last_sent_frame_); 85 frame->AssignTo(&last_sent_frame_);
83 ++num_sent_frames_; 86 ++num_sent_frames_;
84 } 87 }
85 } 88 }
86 89
87 void FakeOutputSurface::SetNeedsBeginFrame(bool enable) { 90 void FakeOutputSurface::SetNeedsBeginFrame(bool enable) {
88 needs_begin_frame_ = enable; 91 needs_begin_frame_ = enable;
89 OutputSurface::SetNeedsBeginFrame(enable); 92 OutputSurface::SetNeedsBeginFrame(enable);
90 93
91 // If there is not BeginFrame emulation from the FrameRateController, 94 if (enable) {
92 // then we just post a BeginFrame to emulate it as part of the test.
93 if (enable && !frame_rate_controller_) {
94 base::MessageLoop::current()->PostDelayedTask( 95 base::MessageLoop::current()->PostDelayedTask(
95 FROM_HERE, 96 FROM_HERE,
96 base::Bind(&FakeOutputSurface::OnBeginFrame, 97 base::Bind(&FakeOutputSurface::OnBeginFrame,
97 fake_weak_ptr_factory_.GetWeakPtr()), 98 fake_weak_ptr_factory_.GetWeakPtr()),
98 base::TimeDelta::FromMilliseconds(16)); 99 base::TimeDelta::FromMilliseconds(16));
99 } 100 }
100 } 101 }
101 102
102 void FakeOutputSurface::OnBeginFrame() { 103 void FakeOutputSurface::OnBeginFrame() {
103 OutputSurface::BeginFrame(BeginFrameArgs::CreateForTesting()); 104 client_->BeginFrame(BeginFrameArgs::CreateForTesting());
104 } 105 }
105 106
106 107
107 bool FakeOutputSurface::ForcedDrawToSoftwareDevice() const { 108 bool FakeOutputSurface::ForcedDrawToSoftwareDevice() const {
108 return forced_draw_to_software_device_; 109 return forced_draw_to_software_device_;
109 } 110 }
110 111
111 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) { 112 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) {
112 if (OutputSurface::BindToClient(client)) { 113 if (OutputSurface::BindToClient(client)) {
113 client_ = client; 114 client_ = client;
(...skipping 29 matching lines...) Expand all
143 bool FakeOutputSurface::HasExternalStencilTest() const { 144 bool FakeOutputSurface::HasExternalStencilTest() const {
144 return has_external_stencil_test_; 145 return has_external_stencil_test_;
145 } 146 }
146 147
147 void FakeOutputSurface::SetMemoryPolicyToSetAtBind( 148 void FakeOutputSurface::SetMemoryPolicyToSetAtBind(
148 scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind) { 149 scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind) {
149 memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind); 150 memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind);
150 } 151 }
151 152
152 } // namespace cc 153 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698