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

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

Issue 23961003: cc: Remove most methods from RendererClient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rendererclient: rebase Created 7 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 | Annotate | Revision Log
« no previous file with comments | « cc/test/pixel_test.h ('k') | cc/test/pixel_test_output_surface.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/pixel_test.h" 5 #include "cc/test/pixel_test.h"
6 6
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "cc/output/compositor_frame_metadata.h" 9 #include "cc/output/compositor_frame_metadata.h"
10 #include "cc/output/copy_output_request.h" 10 #include "cc/output/copy_output_request.h"
(...skipping 10 matching lines...) Expand all
21 #include "ui/gl/gl_implementation.h" 21 #include "ui/gl/gl_implementation.h"
22 #include "webkit/common/gpu/context_provider_in_process.h" 22 #include "webkit/common/gpu/context_provider_in_process.h"
23 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h" 23 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h"
24 24
25 namespace cc { 25 namespace cc {
26 26
27 class PixelTest::PixelTestRendererClient 27 class PixelTest::PixelTestRendererClient
28 : public RendererClient, public OutputSurfaceClient { 28 : public RendererClient, public OutputSurfaceClient {
29 public: 29 public:
30 explicit PixelTestRendererClient(gfx::Rect device_viewport) 30 explicit PixelTestRendererClient(gfx::Rect device_viewport)
31 : device_viewport_(device_viewport), 31 : device_viewport_(device_viewport), device_clip_(device_viewport) {}
32 device_clip_(device_viewport),
33 stencil_enabled_(false) {}
34 32
35 // RendererClient implementation. 33 // RendererClient implementation.
36 virtual gfx::Rect DeviceViewport() const OVERRIDE { 34 virtual gfx::Rect DeviceViewport() const OVERRIDE {
37 return device_viewport_; 35 return device_viewport_;
38 } 36 }
39 virtual gfx::Rect DeviceClip() const OVERRIDE { 37 virtual gfx::Rect DeviceClip() const OVERRIDE { return device_clip_; }
40 return device_clip_;
41 }
42 virtual float DeviceScaleFactor() const OVERRIDE {
43 return 1.f;
44 }
45 virtual const LayerTreeSettings& Settings() const OVERRIDE {
46 return settings_;
47 }
48 virtual void SetFullRootLayerDamage() OVERRIDE {} 38 virtual void SetFullRootLayerDamage() OVERRIDE {}
49 virtual bool HasImplThread() const OVERRIDE { return false; }
50 virtual bool ShouldClearRootRenderPass() const OVERRIDE { return true; }
51 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const 39 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const
52 OVERRIDE { 40 OVERRIDE {
53 return CompositorFrameMetadata(); 41 return CompositorFrameMetadata();
54 } 42 }
55 virtual bool AllowPartialSwap() const OVERRIDE {
56 return true;
57 }
58 virtual bool ExternalStencilTestEnabled() const OVERRIDE {
59 return stencil_enabled_;
60 }
61 43
62 // OutputSurfaceClient implementation. 44 // OutputSurfaceClient implementation.
63 virtual bool DeferredInitialize( 45 virtual bool DeferredInitialize(
64 scoped_refptr<ContextProvider> offscreen_context_provider) OVERRIDE { 46 scoped_refptr<ContextProvider> offscreen_context_provider) OVERRIDE {
65 return false; 47 return false;
66 } 48 }
67 virtual void ReleaseGL() OVERRIDE {} 49 virtual void ReleaseGL() OVERRIDE {}
68 virtual void SetNeedsRedrawRect(gfx::Rect damage_rect) OVERRIDE {} 50 virtual void SetNeedsRedrawRect(gfx::Rect damage_rect) OVERRIDE {}
69 virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE {} 51 virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE {}
70 virtual void OnSwapBuffersComplete(const CompositorFrameAck* ack) OVERRIDE {} 52 virtual void OnSwapBuffersComplete(const CompositorFrameAck* ack) OVERRIDE {}
71 virtual void DidLoseOutputSurface() OVERRIDE {} 53 virtual void DidLoseOutputSurface() OVERRIDE {}
72 virtual void SetExternalDrawConstraints( 54 virtual void SetExternalDrawConstraints(
73 const gfx::Transform& transform, 55 const gfx::Transform& transform,
74 gfx::Rect viewport, 56 gfx::Rect viewport,
75 gfx::Rect clip, 57 gfx::Rect clip,
76 bool valid_for_tile_management) OVERRIDE { 58 bool valid_for_tile_management) OVERRIDE {
77 device_viewport_ = viewport; 59 device_viewport_ = viewport;
78 device_clip_ = clip; 60 device_clip_ = clip;
79 } 61 }
80 virtual void SetExternalStencilTest(bool enable) OVERRIDE {
81 stencil_enabled_ = enable;
82 }
83 virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE {} 62 virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE {}
84 virtual void SetDiscardBackBufferWhenNotVisible(bool discard) OVERRIDE {} 63 virtual void SetDiscardBackBufferWhenNotVisible(bool discard) OVERRIDE {}
85 virtual void SetTreeActivationCallback(const base::Closure&) OVERRIDE {} 64 virtual void SetTreeActivationCallback(const base::Closure&) OVERRIDE {}
86 65
87 private: 66 private:
88 gfx::Rect device_viewport_; 67 gfx::Rect device_viewport_;
89 gfx::Rect device_clip_; 68 gfx::Rect device_clip_;
90 bool stencil_enabled_;
91 LayerTreeSettings settings_;
92 }; 69 };
93 70
94 PixelTest::PixelTest() 71 PixelTest::PixelTest()
95 : device_viewport_size_(gfx::Size(200, 200)), 72 : device_viewport_size_(gfx::Size(200, 200)),
96 fake_client_( 73 fake_client_(
97 new PixelTestRendererClient(gfx::Rect(device_viewport_size_))) {} 74 new PixelTestRendererClient(gfx::Rect(device_viewport_size_))) {}
98 75
99 PixelTest::~PixelTest() {} 76 PixelTest::~PixelTest() {}
100 77
101 bool PixelTest::RunPixelTest(RenderPassList* pass_list, 78 bool PixelTest::RunPixelTest(RenderPassList* pass_list,
(...skipping 24 matching lines...) Expand all
126 switch (provide_offscreen_context) { 103 switch (provide_offscreen_context) {
127 case NoOffscreenContext: 104 case NoOffscreenContext:
128 break; 105 break;
129 case WithOffscreenContext: 106 case WithOffscreenContext:
130 offscreen_contexts = 107 offscreen_contexts =
131 webkit::gpu::ContextProviderInProcess::CreateOffscreen(); 108 webkit::gpu::ContextProviderInProcess::CreateOffscreen();
132 CHECK(offscreen_contexts->BindToCurrentThread()); 109 CHECK(offscreen_contexts->BindToCurrentThread());
133 break; 110 break;
134 } 111 }
135 112
113 float device_scale_factor = 1.f;
114 bool allow_partial_swap = true;
115
136 renderer_->DecideRenderPassAllocationsForFrame(*pass_list); 116 renderer_->DecideRenderPassAllocationsForFrame(*pass_list);
137 renderer_->DrawFrame(pass_list, offscreen_contexts.get()); 117 renderer_->DrawFrame(pass_list,
118 offscreen_contexts.get(),
119 device_scale_factor,
120 allow_partial_swap);
138 121
139 // Wait for the readback to complete. 122 // Wait for the readback to complete.
140 resource_provider_->Finish(); 123 resource_provider_->Finish();
141 run_loop.Run(); 124 run_loop.Run();
142 125
143 return PixelsMatchReference(ref_file, comparator); 126 return PixelsMatchReference(ref_file, comparator);
144 } 127 }
145 128
146 void PixelTest::ReadbackResult(base::Closure quit_run_loop, 129 void PixelTest::ReadbackResult(base::Closure quit_run_loop,
147 scoped_ptr<CopyOutputResult> result) { 130 scoped_ptr<CopyOutputResult> result) {
(...skipping 24 matching lines...) Expand all
172 CHECK(fake_client_); 155 CHECK(fake_client_);
173 CHECK(gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL)); 156 CHECK(gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL));
174 157
175 using webkit::gpu::ContextProviderInProcess; 158 using webkit::gpu::ContextProviderInProcess;
176 output_surface_.reset(new PixelTestOutputSurface( 159 output_surface_.reset(new PixelTestOutputSurface(
177 ContextProviderInProcess::CreateOffscreen())); 160 ContextProviderInProcess::CreateOffscreen()));
178 output_surface_->BindToClient(fake_client_.get()); 161 output_surface_->BindToClient(fake_client_.get());
179 162
180 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0); 163 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0);
181 renderer_ = GLRenderer::Create(fake_client_.get(), 164 renderer_ = GLRenderer::Create(fake_client_.get(),
165 &settings_,
182 output_surface_.get(), 166 output_surface_.get(),
183 resource_provider_.get(), 167 resource_provider_.get(),
184 0, 168 0,
185 use_skia_gpu_backend).PassAs<DirectRenderer>(); 169 use_skia_gpu_backend).PassAs<DirectRenderer>();
186 } 170 }
187 171
188 void PixelTest::ForceExpandedViewport(gfx::Size surface_expansion, 172 void PixelTest::ForceExpandedViewport(gfx::Size surface_expansion,
189 gfx::Vector2d viewport_offset) { 173 gfx::Vector2d viewport_offset) {
190 static_cast<PixelTestOutputSurface*>(output_surface_.get()) 174 static_cast<PixelTestOutputSurface*>(output_surface_.get())
191 ->set_surface_expansion_size(surface_expansion); 175 ->set_surface_expansion_size(surface_expansion);
192 static_cast<PixelTestOutputSurface*>(output_surface_.get()) 176 static_cast<PixelTestOutputSurface*>(output_surface_.get())
193 ->set_viewport_offset(viewport_offset); 177 ->set_viewport_offset(viewport_offset);
194 SoftwareOutputDevice* device = output_surface_->software_device(); 178 SoftwareOutputDevice* device = output_surface_->software_device();
195 if (device) { 179 if (device) {
196 static_cast<PixelTestSoftwareOutputDevice*>(device) 180 static_cast<PixelTestSoftwareOutputDevice*>(device)
197 ->set_surface_expansion_size(surface_expansion); 181 ->set_surface_expansion_size(surface_expansion);
198 } 182 }
199 } 183 }
200 184
201 void PixelTest::ForceDeviceClip(gfx::Rect clip) { 185 void PixelTest::ForceDeviceClip(gfx::Rect clip) {
202 static_cast<PixelTestOutputSurface*>(output_surface_.get()) 186 static_cast<PixelTestOutputSurface*>(output_surface_.get())
203 ->set_device_clip(clip); 187 ->set_device_clip(clip);
204 } 188 }
205 189
206 void PixelTest::EnableExternalStencilTest() { 190 void PixelTest::EnableExternalStencilTest() {
207 fake_client_->SetExternalStencilTest(true); 191 static_cast<PixelTestOutputSurface*>(output_surface_.get())
192 ->set_has_external_stencil_test(true);
208 } 193 }
209 194
210 void PixelTest::SetUpSoftwareRenderer() { 195 void PixelTest::SetUpSoftwareRenderer() {
211 CHECK(fake_client_); 196 CHECK(fake_client_);
212 197
213 scoped_ptr<SoftwareOutputDevice> device(new PixelTestSoftwareOutputDevice()); 198 scoped_ptr<SoftwareOutputDevice> device(new PixelTestSoftwareOutputDevice());
214 output_surface_.reset(new PixelTestOutputSurface(device.Pass())); 199 output_surface_.reset(new PixelTestOutputSurface(device.Pass()));
215 output_surface_->BindToClient(fake_client_.get()); 200 output_surface_->BindToClient(fake_client_.get());
216 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0); 201 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0);
217 renderer_ = SoftwareRenderer::Create( 202 renderer_ = SoftwareRenderer::Create(fake_client_.get(),
218 fake_client_.get(), 203 &settings_,
219 output_surface_.get(), 204 output_surface_.get(),
220 resource_provider_.get()).PassAs<DirectRenderer>(); 205 resource_provider_.get())
206 .PassAs<DirectRenderer>();
221 } 207 }
222 208
223 } // namespace cc 209 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/pixel_test.h ('k') | cc/test/pixel_test_output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698