OLD | NEW |
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 Loading... |
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), stencil_enabled_(false) {} | 31 : device_viewport_(device_viewport), |
| 32 device_clip_(device_viewport), |
| 33 stencil_enabled_(false) {} |
32 | 34 |
33 // RendererClient implementation. | 35 // RendererClient implementation. |
34 virtual gfx::Rect DeviceViewport() const OVERRIDE { | 36 virtual gfx::Rect DeviceViewport() const OVERRIDE { |
35 return device_viewport_; | 37 return device_viewport_; |
36 } | 38 } |
| 39 virtual gfx::Rect DeviceClip() const OVERRIDE { |
| 40 return device_clip_; |
| 41 } |
37 virtual float DeviceScaleFactor() const OVERRIDE { | 42 virtual float DeviceScaleFactor() const OVERRIDE { |
38 return 1.f; | 43 return 1.f; |
39 } | 44 } |
40 virtual const LayerTreeSettings& Settings() const OVERRIDE { | 45 virtual const LayerTreeSettings& Settings() const OVERRIDE { |
41 return settings_; | 46 return settings_; |
42 } | 47 } |
43 virtual void SetFullRootLayerDamage() OVERRIDE {} | 48 virtual void SetFullRootLayerDamage() OVERRIDE {} |
44 virtual bool HasImplThread() const OVERRIDE { return false; } | 49 virtual bool HasImplThread() const OVERRIDE { return false; } |
45 virtual bool ShouldClearRootRenderPass() const OVERRIDE { return true; } | 50 virtual bool ShouldClearRootRenderPass() const OVERRIDE { return true; } |
46 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const | 51 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const |
(...skipping 10 matching lines...) Expand all Loading... |
57 // OutputSurfaceClient implementation. | 62 // OutputSurfaceClient implementation. |
58 virtual bool DeferredInitialize( | 63 virtual bool DeferredInitialize( |
59 scoped_refptr<ContextProvider> offscreen_context_provider) OVERRIDE { | 64 scoped_refptr<ContextProvider> offscreen_context_provider) OVERRIDE { |
60 return false; | 65 return false; |
61 } | 66 } |
62 virtual void ReleaseGL() OVERRIDE {} | 67 virtual void ReleaseGL() OVERRIDE {} |
63 virtual void SetNeedsRedrawRect(gfx::Rect damage_rect) OVERRIDE {} | 68 virtual void SetNeedsRedrawRect(gfx::Rect damage_rect) OVERRIDE {} |
64 virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE {} | 69 virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE {} |
65 virtual void OnSwapBuffersComplete(const CompositorFrameAck* ack) OVERRIDE {} | 70 virtual void OnSwapBuffersComplete(const CompositorFrameAck* ack) OVERRIDE {} |
66 virtual void DidLoseOutputSurface() OVERRIDE {} | 71 virtual void DidLoseOutputSurface() OVERRIDE {} |
67 virtual void SetExternalDrawConstraints(const gfx::Transform& transform, | 72 virtual void SetExternalDrawConstraints( |
68 gfx::Rect viewport) OVERRIDE { | 73 const gfx::Transform& transform, |
| 74 gfx::Rect viewport, |
| 75 gfx::Rect clip, |
| 76 bool valid_for_tile_management) OVERRIDE { |
69 device_viewport_ = viewport; | 77 device_viewport_ = viewport; |
| 78 device_clip_ = clip; |
70 } | 79 } |
71 virtual void SetExternalStencilTest(bool enable) OVERRIDE { | 80 virtual void SetExternalStencilTest(bool enable) OVERRIDE { |
72 stencil_enabled_ = enable; | 81 stencil_enabled_ = enable; |
73 } | 82 } |
74 virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE {} | 83 virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE {} |
75 virtual void SetDiscardBackBufferWhenNotVisible(bool discard) OVERRIDE {} | 84 virtual void SetDiscardBackBufferWhenNotVisible(bool discard) OVERRIDE {} |
76 virtual void SetTreeActivationCallback(const base::Closure&) OVERRIDE {} | 85 virtual void SetTreeActivationCallback(const base::Closure&) OVERRIDE {} |
77 | 86 |
78 private: | 87 private: |
79 gfx::Rect device_viewport_; | 88 gfx::Rect device_viewport_; |
| 89 gfx::Rect device_clip_; |
80 bool stencil_enabled_; | 90 bool stencil_enabled_; |
81 LayerTreeSettings settings_; | 91 LayerTreeSettings settings_; |
82 }; | 92 }; |
83 | 93 |
84 PixelTest::PixelTest() | 94 PixelTest::PixelTest() |
85 : device_viewport_size_(gfx::Size(200, 200)), | 95 : device_viewport_size_(gfx::Size(200, 200)), |
86 fake_client_( | 96 fake_client_( |
87 new PixelTestRendererClient(gfx::Rect(device_viewport_size_))) {} | 97 new PixelTestRendererClient(gfx::Rect(device_viewport_size_))) {} |
88 | 98 |
89 PixelTest::~PixelTest() {} | 99 PixelTest::~PixelTest() {} |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 ->set_surface_expansion_size(surface_expansion); | 191 ->set_surface_expansion_size(surface_expansion); |
182 static_cast<PixelTestOutputSurface*>(output_surface_.get()) | 192 static_cast<PixelTestOutputSurface*>(output_surface_.get()) |
183 ->set_viewport_offset(viewport_offset); | 193 ->set_viewport_offset(viewport_offset); |
184 SoftwareOutputDevice* device = output_surface_->software_device(); | 194 SoftwareOutputDevice* device = output_surface_->software_device(); |
185 if (device) { | 195 if (device) { |
186 static_cast<PixelTestSoftwareOutputDevice*>(device) | 196 static_cast<PixelTestSoftwareOutputDevice*>(device) |
187 ->set_surface_expansion_size(surface_expansion); | 197 ->set_surface_expansion_size(surface_expansion); |
188 } | 198 } |
189 } | 199 } |
190 | 200 |
| 201 void PixelTest::ForceDeviceClip(gfx::Rect clip) { |
| 202 static_cast<PixelTestOutputSurface*>(output_surface_.get()) |
| 203 ->set_device_clip(clip); |
| 204 } |
| 205 |
191 void PixelTest::EnableExternalStencilTest() { | 206 void PixelTest::EnableExternalStencilTest() { |
192 fake_client_->SetExternalStencilTest(true); | 207 fake_client_->SetExternalStencilTest(true); |
193 } | 208 } |
194 | 209 |
195 void PixelTest::SetUpSoftwareRenderer() { | 210 void PixelTest::SetUpSoftwareRenderer() { |
196 CHECK(fake_client_); | 211 CHECK(fake_client_); |
197 | 212 |
198 scoped_ptr<SoftwareOutputDevice> device(new PixelTestSoftwareOutputDevice()); | 213 scoped_ptr<SoftwareOutputDevice> device(new PixelTestSoftwareOutputDevice()); |
199 output_surface_.reset(new PixelTestOutputSurface(device.Pass())); | 214 output_surface_.reset(new PixelTestOutputSurface(device.Pass())); |
200 output_surface_->BindToClient(fake_client_.get()); | 215 output_surface_->BindToClient(fake_client_.get()); |
201 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0); | 216 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0); |
202 renderer_ = SoftwareRenderer::Create( | 217 renderer_ = SoftwareRenderer::Create( |
203 fake_client_.get(), | 218 fake_client_.get(), |
204 output_surface_.get(), | 219 output_surface_.get(), |
205 resource_provider_.get()).PassAs<DirectRenderer>(); | 220 resource_provider_.get()).PassAs<DirectRenderer>(); |
206 } | 221 } |
207 | 222 |
208 } // namespace cc | 223 } // namespace cc |
OLD | NEW |