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

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

Issue 577643002: Making OutputSurface a begin frame source and vsync source. (Closed)
Patch Set: Created 6 years, 3 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
« no previous file with comments | « cc/test/fake_output_surface.h ('k') | cc/test/fake_output_surface_client.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/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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 ++num_sent_frames_; 75 ++num_sent_frames_;
76 PostSwapBuffersComplete(); 76 PostSwapBuffersComplete();
77 client_->DidSwapBuffers(); 77 client_->DidSwapBuffers();
78 } else { 78 } else {
79 OutputSurface::SwapBuffers(frame); 79 OutputSurface::SwapBuffers(frame);
80 frame->AssignTo(&last_sent_frame_); 80 frame->AssignTo(&last_sent_frame_);
81 ++num_sent_frames_; 81 ++num_sent_frames_;
82 } 82 }
83 } 83 }
84 84
85 void FakeOutputSurface::SetNeedsBeginFrame(bool enable) { 85 void FakeOutputSurface::SetNeedsBeginFrames(bool enable) {
86 needs_begin_frame_ = enable; 86 OutputSurface::SetNeedsBeginFrames(enable);
87 OutputSurface::SetNeedsBeginFrame(enable); 87 if (enable)
88 OnBeginFrame();
89 }
88 90
89 if (enable) { 91 void FakeOutputSurface::OnBeginFrame() {
92 if (NeedsBeginFrames()) {
93 SendBeginFrame(CreateBeginFrameArgsForTesting());
94
90 base::MessageLoop::current()->PostDelayedTask( 95 base::MessageLoop::current()->PostDelayedTask(
91 FROM_HERE, 96 FROM_HERE,
92 base::Bind(&FakeOutputSurface::OnBeginFrame, 97 base::Bind(&FakeOutputSurface::OnBeginFrame,
93 fake_weak_ptr_factory_.GetWeakPtr()), 98 fake_weak_ptr_factory_.GetWeakPtr()),
94 base::TimeDelta::FromMilliseconds(16)); 99 base::TimeDelta::FromMilliseconds(16));
95 } 100 }
96 } 101 }
97 102
98 void FakeOutputSurface::OnBeginFrame() { 103 void FakeOutputSurface::AsValueInto(base::debug::TracedValue* dict) const {
99 client_->BeginFrame(CreateBeginFrameArgsForTesting()); 104 dict->SetString("type", "FakeOutputSurface");
100 } 105 }
101 106
102
103 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) { 107 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) {
104 if (OutputSurface::BindToClient(client)) { 108 if (OutputSurface::BindToClient(client)) {
105 client_ = client; 109 client_ = client;
106 if (memory_policy_to_set_at_bind_) { 110 if (memory_policy_to_set_at_bind_) {
107 client_->SetMemoryPolicy(*memory_policy_to_set_at_bind_.get()); 111 client_->SetMemoryPolicy(*memory_policy_to_set_at_bind_.get());
108 memory_policy_to_set_at_bind_.reset(); 112 memory_policy_to_set_at_bind_.reset();
109 } 113 }
110 return true; 114 return true;
111 } else { 115 } else {
112 return false; 116 return false;
(...skipping 22 matching lines...) Expand all
135 bool FakeOutputSurface::HasExternalStencilTest() const { 139 bool FakeOutputSurface::HasExternalStencilTest() const {
136 return has_external_stencil_test_; 140 return has_external_stencil_test_;
137 } 141 }
138 142
139 void FakeOutputSurface::SetMemoryPolicyToSetAtBind( 143 void FakeOutputSurface::SetMemoryPolicyToSetAtBind(
140 scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind) { 144 scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind) {
141 memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind); 145 memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind);
142 } 146 }
143 147
144 } // namespace cc 148 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_output_surface.h ('k') | cc/test/fake_output_surface_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698