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

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

Issue 2349743004: cc: Remove things from OutputSurface and CompositorFrameSink. (Closed)
Patch Set: delete-stuff-cfs: comment-and-rebase Created 4 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_compositor_frame_sink.h ('k') | cc/test/fake_compositor_frame_sink_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_compositor_frame_sink.h" 5 #include "cc/test/fake_compositor_frame_sink.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_sink_client.h" 9 #include "cc/output/compositor_frame_sink_client.h"
10 #include "cc/resources/returned_resource.h" 10 #include "cc/resources/returned_resource.h"
11 #include "cc/test/begin_frame_args_test.h" 11 #include "cc/test/begin_frame_args_test.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace cc { 14 namespace cc {
15 15
16 FakeCompositorFrameSink::FakeCompositorFrameSink( 16 FakeCompositorFrameSink::FakeCompositorFrameSink(
17 scoped_refptr<ContextProvider> context_provider, 17 scoped_refptr<ContextProvider> context_provider,
18 scoped_refptr<ContextProvider> worker_context_provider, 18 scoped_refptr<ContextProvider> worker_context_provider)
19 bool delegated_rendering)
20 : FakeCompositorFrameSink(std::move(context_provider),
21 std::move(worker_context_provider),
22 nullptr,
23 delegated_rendering) {}
24
25 FakeCompositorFrameSink::FakeCompositorFrameSink(
26 scoped_refptr<ContextProvider> context_provider,
27 scoped_refptr<ContextProvider> worker_context_provider,
28 std::unique_ptr<SoftwareOutputDevice> software_device,
29 bool delegated_rendering)
30 : CompositorFrameSink(std::move(context_provider), 19 : CompositorFrameSink(std::move(context_provider),
31 std::move(worker_context_provider), 20 std::move(worker_context_provider)) {}
32 std::move(software_device)) {
33 capabilities_.delegated_rendering = delegated_rendering;
34 }
35 21
36 FakeCompositorFrameSink::~FakeCompositorFrameSink() = default; 22 FakeCompositorFrameSink::~FakeCompositorFrameSink() = default;
37 23
38 void FakeCompositorFrameSink::SwapBuffers(CompositorFrame frame) { 24 void FakeCompositorFrameSink::SwapBuffers(CompositorFrame frame) {
39 ReturnResourcesHeldByParent(); 25 ReturnResourcesHeldByParent();
40 26
41 last_sent_frame_.reset(new CompositorFrame(std::move(frame))); 27 last_sent_frame_.reset(new CompositorFrame(std::move(frame)));
42 ++num_sent_frames_; 28 ++num_sent_frames_;
43 29
44 if (last_sent_frame_->delegated_frame_data) { 30 if (last_sent_frame_->delegated_frame_data) {
(...skipping 14 matching lines...) Expand all
59 auto* frame_data = last_sent_frame_->delegated_frame_data.get(); 45 auto* frame_data = last_sent_frame_->delegated_frame_data.get();
60 resources_held_by_parent_.insert(resources_held_by_parent_.end(), 46 resources_held_by_parent_.insert(resources_held_by_parent_.end(),
61 frame_data->resource_list.begin(), 47 frame_data->resource_list.begin(),
62 frame_data->resource_list.end()); 48 frame_data->resource_list.end());
63 } 49 }
64 } 50 }
65 51
66 PostSwapBuffersComplete(); 52 PostSwapBuffersComplete();
67 } 53 }
68 54
69 void FakeCompositorFrameSink::BindFramebuffer() {
70 if (framebuffer_) {
71 context_provider_->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER,
72 framebuffer_);
73 } else {
74 CompositorFrameSink::BindFramebuffer();
75 }
76 }
77
78 uint32_t FakeCompositorFrameSink::GetFramebufferCopyTextureFormat() {
79 if (framebuffer_)
80 return framebuffer_format_;
81 else
82 return GL_RGB;
83 }
84
85 bool FakeCompositorFrameSink::BindToClient(CompositorFrameSinkClient* client) { 55 bool FakeCompositorFrameSink::BindToClient(CompositorFrameSinkClient* client) {
86 if (CompositorFrameSink::BindToClient(client)) { 56 if (CompositorFrameSink::BindToClient(client)) {
87 client_ = client; 57 client_ = client;
88 return true; 58 return true;
89 } else { 59 } else {
90 return false; 60 return false;
91 } 61 }
92 } 62 }
93 63
94 void FakeCompositorFrameSink::DetachFromClient() { 64 void FakeCompositorFrameSink::DetachFromClient() {
95 ReturnResourcesHeldByParent(); 65 ReturnResourcesHeldByParent();
96 CompositorFrameSink::DetachFromClient(); 66 CompositorFrameSink::DetachFromClient();
97 } 67 }
98 68
99 bool FakeCompositorFrameSink::HasExternalStencilTest() const {
100 return has_external_stencil_test_;
101 }
102
103 bool FakeCompositorFrameSink::SurfaceIsSuspendForRecycle() const {
104 return suspended_for_recycle_;
105 }
106
107 OverlayCandidateValidator*
108 FakeCompositorFrameSink::GetOverlayCandidateValidator() const {
109 return overlay_candidate_validator_;
110 }
111
112 void FakeCompositorFrameSink::ReturnResourcesHeldByParent() { 69 void FakeCompositorFrameSink::ReturnResourcesHeldByParent() {
113 // Check |delegated_frame_data| because we shouldn't reclaim resources 70 // Check |delegated_frame_data| because we shouldn't reclaim resources
114 // for the Display which does not swap delegated frames. 71 // for the Display which does not swap delegated frames.
115 if (last_sent_frame_ && last_sent_frame_->delegated_frame_data) { 72 if (last_sent_frame_ && last_sent_frame_->delegated_frame_data) {
116 // Return the last frame's resources immediately. 73 // Return the last frame's resources immediately.
117 ReturnedResourceArray resources; 74 ReturnedResourceArray resources;
118 for (const auto& resource : resources_held_by_parent_) 75 for (const auto& resource : resources_held_by_parent_)
119 resources.push_back(resource.ToReturnedResource()); 76 resources.push_back(resource.ToReturnedResource());
120 resources_held_by_parent_.clear(); 77 resources_held_by_parent_.clear();
121 client_->ReclaimResources(resources); 78 client_->ReclaimResources(resources);
122 } 79 }
123 } 80 }
124 81
125 } // namespace cc 82 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_compositor_frame_sink.h ('k') | cc/test/fake_compositor_frame_sink_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698