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

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

Issue 2161323002: cc: Make LayerTreeHostImpl unittests use a delegating output surface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: display-lthi-tests: . Created 4 years, 5 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 #ifndef CC_TEST_FAKE_OUTPUT_SURFACE_H_ 5 #ifndef CC_TEST_FAKE_OUTPUT_SURFACE_H_
6 #define CC_TEST_FAKE_OUTPUT_SURFACE_H_ 6 #define CC_TEST_FAKE_OUTPUT_SURFACE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "cc/output/begin_frame_args.h" 14 #include "cc/output/begin_frame_args.h"
15 #include "cc/output/compositor_frame.h" 15 #include "cc/output/compositor_frame.h"
16 #include "cc/output/managed_memory_policy.h" 16 #include "cc/output/managed_memory_policy.h"
17 #include "cc/output/output_surface.h" 17 #include "cc/output/output_surface.h"
18 #include "cc/output/software_output_device.h" 18 #include "cc/output/software_output_device.h"
19 #include "cc/test/test_context_provider.h" 19 #include "cc/test/test_context_provider.h"
20 #include "cc/test/test_gles2_interface.h"
20 #include "cc/test/test_web_graphics_context_3d.h" 21 #include "cc/test/test_web_graphics_context_3d.h"
21 22
22 namespace cc { 23 namespace cc {
23 24
24 class FakeOutputSurface : public OutputSurface { 25 class FakeOutputSurface : public OutputSurface {
25 public: 26 public:
26 ~FakeOutputSurface() override; 27 ~FakeOutputSurface() override;
27 28
28 static std::unique_ptr<FakeOutputSurface> Create3d() { 29 static std::unique_ptr<FakeOutputSurface> Create3d() {
29 return base::WrapUnique( 30 return base::WrapUnique(
30 new FakeOutputSurface(TestContextProvider::Create(), 31 new FakeOutputSurface(TestContextProvider::Create(),
31 TestContextProvider::CreateWorker(), false)); 32 TestContextProvider::CreateWorker(), false));
32 } 33 }
33 34
34 static std::unique_ptr<FakeOutputSurface> Create3d( 35 static std::unique_ptr<FakeOutputSurface> Create3d(
35 scoped_refptr<ContextProvider> context_provider) { 36 scoped_refptr<ContextProvider> context_provider) {
36 return base::WrapUnique(new FakeOutputSurface( 37 return base::WrapUnique(new FakeOutputSurface(
37 context_provider, TestContextProvider::CreateWorker(), false)); 38 context_provider, TestContextProvider::CreateWorker(), false));
38 } 39 }
39 40
40 static std::unique_ptr<FakeOutputSurface> Create3d( 41 static std::unique_ptr<FakeOutputSurface> Create3d(
41 scoped_refptr<ContextProvider> context_provider, 42 scoped_refptr<ContextProvider> context_provider,
42 scoped_refptr<ContextProvider> worker_context_provider) { 43 scoped_refptr<ContextProvider> worker_context_provider) {
43 return base::WrapUnique(new FakeOutputSurface( 44 return base::WrapUnique(new FakeOutputSurface(
44 context_provider, worker_context_provider, false)); 45 context_provider, worker_context_provider, false));
45 } 46 }
46 47
47 static std::unique_ptr<FakeOutputSurface> Create3d( 48 static std::unique_ptr<FakeOutputSurface> Create3d(
49 std::unique_ptr<TestGLES2Interface> gl) {
50 return base::WrapUnique(
vmpstr 2016/07/20 01:11:22 nit: MakeUnique here? Or keep it for consistency.
danakj 2016/07/20 18:57:41 That doesnt work for Create functions where the co
51 new FakeOutputSurface(TestContextProvider::Create(std::move(gl)),
52 TestContextProvider::CreateWorker(), false));
53 }
54
55 static std::unique_ptr<FakeOutputSurface> Create3d(
48 std::unique_ptr<TestWebGraphicsContext3D> context) { 56 std::unique_ptr<TestWebGraphicsContext3D> context) {
49 return base::WrapUnique( 57 return base::WrapUnique(
50 new FakeOutputSurface(TestContextProvider::Create(std::move(context)), 58 new FakeOutputSurface(TestContextProvider::Create(std::move(context)),
51 TestContextProvider::CreateWorker(), false)); 59 TestContextProvider::CreateWorker(), false));
52 } 60 }
53 61
54 static std::unique_ptr<FakeOutputSurface> CreateSoftware( 62 static std::unique_ptr<FakeOutputSurface> CreateSoftware(
55 std::unique_ptr<SoftwareOutputDevice> software_device) { 63 std::unique_ptr<SoftwareOutputDevice> software_device) {
56 return base::WrapUnique( 64 return base::WrapUnique(
57 new FakeOutputSurface(std::move(software_device), false)); 65 new FakeOutputSurface(std::move(software_device), false));
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 146 }
139 147
140 void set_suspended_for_recycle(bool suspended) { 148 void set_suspended_for_recycle(bool suspended) {
141 suspended_for_recycle_ = suspended; 149 suspended_for_recycle_ = suspended;
142 } 150 }
143 151
144 void SetMemoryPolicyToSetAtBind( 152 void SetMemoryPolicyToSetAtBind(
145 std::unique_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind); 153 std::unique_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind);
146 154
147 gfx::Rect last_swap_rect() const { 155 gfx::Rect last_swap_rect() const {
156 DCHECK(last_swap_rect_valid_);
148 return last_swap_rect_; 157 return last_swap_rect_;
149 } 158 }
150 159
151 void ReturnResourcesHeldByParent(); 160 void ReturnResourcesHeldByParent();
152 161
153 protected: 162 protected:
154 FakeOutputSurface(scoped_refptr<ContextProvider> context_provider, 163 FakeOutputSurface(scoped_refptr<ContextProvider> context_provider,
155 scoped_refptr<ContextProvider> worker_context_provider, 164 scoped_refptr<ContextProvider> worker_context_provider,
156 bool delegated_rendering); 165 bool delegated_rendering);
157 166
158 FakeOutputSurface(std::unique_ptr<SoftwareOutputDevice> software_device, 167 FakeOutputSurface(std::unique_ptr<SoftwareOutputDevice> software_device,
159 bool delegated_rendering); 168 bool delegated_rendering);
160 169
161 FakeOutputSurface(scoped_refptr<ContextProvider> context_provider, 170 FakeOutputSurface(scoped_refptr<ContextProvider> context_provider,
162 scoped_refptr<ContextProvider> worker_context_provider, 171 scoped_refptr<ContextProvider> worker_context_provider,
163 std::unique_ptr<SoftwareOutputDevice> software_device, 172 std::unique_ptr<SoftwareOutputDevice> software_device,
164 bool delegated_rendering); 173 bool delegated_rendering);
165 174
166 OutputSurfaceClient* client_ = nullptr; 175 OutputSurfaceClient* client_ = nullptr;
167 std::unique_ptr<CompositorFrame> last_sent_frame_; 176 std::unique_ptr<CompositorFrame> last_sent_frame_;
168 size_t num_sent_frames_ = 0; 177 size_t num_sent_frames_ = 0;
169 bool has_external_stencil_test_ = false; 178 bool has_external_stencil_test_ = false;
170 bool suspended_for_recycle_ = false; 179 bool suspended_for_recycle_ = false;
171 GLint framebuffer_ = 0; 180 GLint framebuffer_ = 0;
172 GLenum framebuffer_format_ = 0; 181 GLenum framebuffer_format_ = 0;
173 TransferableResourceArray resources_held_by_parent_; 182 TransferableResourceArray resources_held_by_parent_;
174 std::unique_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind_; 183 std::unique_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind_;
175 OverlayCandidateValidator* overlay_candidate_validator_ = nullptr; 184 OverlayCandidateValidator* overlay_candidate_validator_ = nullptr;
185 bool last_swap_rect_valid_ = false;
176 gfx::Rect last_swap_rect_; 186 gfx::Rect last_swap_rect_;
177 }; 187 };
178 188
179 } // namespace cc 189 } // namespace cc
180 190
181 #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_ 191 #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698