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

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, 1 month 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"
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), 23 has_external_stencil_test_(false) {
24 has_external_stencil_test_(false),
25 fake_weak_ptr_factory_(this) {
26 if (delegated_rendering) { 24 if (delegated_rendering) {
27 capabilities_.delegated_rendering = true; 25 capabilities_.delegated_rendering = true;
28 capabilities_.max_frames_pending = 1; 26 capabilities_.max_frames_pending = 1;
29 } 27 }
30 } 28 }
31 29
32 FakeOutputSurface::FakeOutputSurface( 30 FakeOutputSurface::FakeOutputSurface(
33 scoped_ptr<SoftwareOutputDevice> software_device, 31 scoped_ptr<SoftwareOutputDevice> software_device,
34 bool delegated_rendering) 32 bool delegated_rendering)
35 : OutputSurface(software_device.Pass()), 33 : OutputSurface(software_device.Pass()),
36 client_(NULL), 34 client_(NULL),
37 num_sent_frames_(0), 35 num_sent_frames_(0),
38 has_external_stencil_test_(false), 36 has_external_stencil_test_(false) {
39 fake_weak_ptr_factory_(this) {
40 if (delegated_rendering) { 37 if (delegated_rendering) {
41 capabilities_.delegated_rendering = true; 38 capabilities_.delegated_rendering = true;
42 capabilities_.max_frames_pending = 1; 39 capabilities_.max_frames_pending = 1;
43 } 40 }
44 } 41 }
45 42
46 FakeOutputSurface::FakeOutputSurface( 43 FakeOutputSurface::FakeOutputSurface(
47 scoped_refptr<ContextProvider> context_provider, 44 scoped_refptr<ContextProvider> context_provider,
48 scoped_ptr<SoftwareOutputDevice> software_device, 45 scoped_ptr<SoftwareOutputDevice> software_device,
49 bool delegated_rendering) 46 bool delegated_rendering)
50 : OutputSurface(context_provider, software_device.Pass()), 47 : OutputSurface(context_provider, software_device.Pass()),
51 client_(NULL), 48 client_(NULL),
52 num_sent_frames_(0), 49 num_sent_frames_(0),
53 has_external_stencil_test_(false), 50 has_external_stencil_test_(false) {
54 fake_weak_ptr_factory_(this) {
55 if (delegated_rendering) { 51 if (delegated_rendering) {
56 capabilities_.delegated_rendering = true; 52 capabilities_.delegated_rendering = true;
57 capabilities_.max_frames_pending = 1; 53 capabilities_.max_frames_pending = 1;
58 } 54 }
59 } 55 }
60 56
61 FakeOutputSurface::~FakeOutputSurface() {} 57 FakeOutputSurface::~FakeOutputSurface() {}
62 58
63 void FakeOutputSurface::SwapBuffers(CompositorFrame* frame) { 59 void FakeOutputSurface::SwapBuffers(CompositorFrame* frame) {
64 if (frame->software_frame_data || frame->delegated_frame_data || 60 if (frame->software_frame_data || frame->delegated_frame_data ||
(...skipping 10 matching lines...) Expand all
75 ++num_sent_frames_; 71 ++num_sent_frames_;
76 } else { 72 } else {
77 last_swap_rect_ = frame->gl_frame_data->sub_buffer_rect; 73 last_swap_rect_ = frame->gl_frame_data->sub_buffer_rect;
78 frame->AssignTo(&last_sent_frame_); 74 frame->AssignTo(&last_sent_frame_);
79 ++num_sent_frames_; 75 ++num_sent_frames_;
80 } 76 }
81 PostSwapBuffersComplete(); 77 PostSwapBuffersComplete();
82 client_->DidSwapBuffers(); 78 client_->DidSwapBuffers();
83 } 79 }
84 80
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) { 81 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) {
104 if (OutputSurface::BindToClient(client)) { 82 if (OutputSurface::BindToClient(client)) {
105 client_ = client; 83 client_ = client;
106 if (memory_policy_to_set_at_bind_) { 84 if (memory_policy_to_set_at_bind_) {
107 client_->SetMemoryPolicy(*memory_policy_to_set_at_bind_.get()); 85 client_->SetMemoryPolicy(*memory_policy_to_set_at_bind_.get());
108 memory_policy_to_set_at_bind_ = nullptr; 86 memory_policy_to_set_at_bind_ = nullptr;
109 } 87 }
110 return true; 88 return true;
111 } else { 89 } else {
112 return false; 90 return false;
(...skipping 22 matching lines...) Expand all
135 bool FakeOutputSurface::HasExternalStencilTest() const { 113 bool FakeOutputSurface::HasExternalStencilTest() const {
136 return has_external_stencil_test_; 114 return has_external_stencil_test_;
137 } 115 }
138 116
139 void FakeOutputSurface::SetMemoryPolicyToSetAtBind( 117 void FakeOutputSurface::SetMemoryPolicyToSetAtBind(
140 scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind) { 118 scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind) {
141 memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind); 119 memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind);
142 } 120 }
143 121
144 } // namespace cc 122 } // 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