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

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

Issue 619843002: cc: Make separate interface for BeginFrame ipc from OutputSurface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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"
11 #include "cc/resources/returned_resource.h" 11 #include "cc/resources/returned_resource.h"
12 #include "cc/test/begin_frame_args_test.h" 12 #include "cc/test/begin_frame_args_test.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace cc { 15 namespace cc {
16 16
17 FakeOutputSurface::FakeOutputSurface( 17 FakeOutputSurface::FakeOutputSurface(
18 scoped_refptr<ContextProvider> context_provider, 18 scoped_refptr<ContextProvider> context_provider,
19 bool delegated_rendering) 19 bool delegated_rendering)
20 : OutputSurface(context_provider), 20 : OutputSurface(context_provider),
21 client_(NULL), 21 client_(NULL),
22 num_sent_frames_(0), 22 num_sent_frames_(0),
23 needs_begin_frame_(false),
24 has_external_stencil_test_(false), 23 has_external_stencil_test_(false),
25 fake_weak_ptr_factory_(this) { 24 fake_weak_ptr_factory_(this) {
26 if (delegated_rendering) { 25 if (delegated_rendering) {
27 capabilities_.delegated_rendering = true; 26 capabilities_.delegated_rendering = true;
28 capabilities_.max_frames_pending = 1; 27 capabilities_.max_frames_pending = 1;
29 } 28 }
30 } 29 }
31 30
32 FakeOutputSurface::FakeOutputSurface( 31 FakeOutputSurface::FakeOutputSurface(
33 scoped_ptr<SoftwareOutputDevice> software_device, 32 scoped_ptr<SoftwareOutputDevice> software_device,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 ++num_sent_frames_; 74 ++num_sent_frames_;
76 PostSwapBuffersComplete(); 75 PostSwapBuffersComplete();
77 client_->DidSwapBuffers(); 76 client_->DidSwapBuffers();
78 } else { 77 } else {
79 OutputSurface::SwapBuffers(frame); 78 OutputSurface::SwapBuffers(frame);
80 frame->AssignTo(&last_sent_frame_); 79 frame->AssignTo(&last_sent_frame_);
81 ++num_sent_frames_; 80 ++num_sent_frames_;
82 } 81 }
83 } 82 }
84 83
85 void FakeOutputSurface::SetNeedsBeginFrame(bool enable) {
86 needs_begin_frame_ = enable;
87 OutputSurface::SetNeedsBeginFrame(enable);
88
89 if (enable) {
90 base::MessageLoop::current()->PostDelayedTask(
91 FROM_HERE,
92 base::Bind(&FakeOutputSurface::OnBeginFrame,
93 fake_weak_ptr_factory_.GetWeakPtr()),
94 base::TimeDelta::FromMilliseconds(16));
95 }
96 }
97
98 void FakeOutputSurface::OnBeginFrame() {
99 client_->BeginFrame(CreateBeginFrameArgsForTesting());
100 }
101
102
103 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) { 84 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) {
104 if (OutputSurface::BindToClient(client)) { 85 if (OutputSurface::BindToClient(client)) {
105 client_ = client; 86 client_ = client;
106 if (memory_policy_to_set_at_bind_) { 87 if (memory_policy_to_set_at_bind_) {
107 client_->SetMemoryPolicy(*memory_policy_to_set_at_bind_.get()); 88 client_->SetMemoryPolicy(*memory_policy_to_set_at_bind_.get());
108 memory_policy_to_set_at_bind_ = nullptr; 89 memory_policy_to_set_at_bind_ = nullptr;
109 } 90 }
110 return true; 91 return true;
111 } else { 92 } else {
112 return false; 93 return false;
(...skipping 22 matching lines...) Expand all
135 bool FakeOutputSurface::HasExternalStencilTest() const { 116 bool FakeOutputSurface::HasExternalStencilTest() const {
136 return has_external_stencil_test_; 117 return has_external_stencil_test_;
137 } 118 }
138 119
139 void FakeOutputSurface::SetMemoryPolicyToSetAtBind( 120 void FakeOutputSurface::SetMemoryPolicyToSetAtBind(
140 scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind) { 121 scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind) {
141 memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind); 122 memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind);
142 } 123 }
143 124
144 } // namespace cc 125 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698