OLD | NEW |
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/software_renderer.h" | 5 #include "cc/software_renderer.h" |
6 | 6 |
7 #include "cc/quad_sink.h" | 7 #include "cc/quad_sink.h" |
8 #include "cc/render_pass.h" | 8 #include "cc/render_pass.h" |
9 #include "cc/render_pass_draw_quad.h" | 9 #include "cc/render_pass_draw_quad.h" |
10 #include "cc/solid_color_draw_quad.h" | 10 #include "cc/solid_color_draw_quad.h" |
11 #include "cc/test/animation_test_common.h" | 11 #include "cc/test/animation_test_common.h" |
12 #include "cc/test/fake_web_compositor_output_surface.h" | 12 #include "cc/test/fake_output_surface.h" |
13 #include "cc/test/fake_web_compositor_software_output_device.h" | 13 #include "cc/test/fake_software_output_device.h" |
14 #include "cc/test/geometry_test_utils.h" | 14 #include "cc/test/geometry_test_utils.h" |
15 #include "cc/test/render_pass_test_common.h" | 15 #include "cc/test/render_pass_test_common.h" |
16 #include "cc/tile_draw_quad.h" | 16 #include "cc/tile_draw_quad.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
20 using namespace WebKit; | 20 using namespace WebKit; |
21 using namespace WebKitTests; | 21 using namespace WebKitTests; |
22 | 22 |
23 namespace cc { | 23 namespace cc { |
24 namespace { | 24 namespace { |
25 | 25 |
26 class SoftwareRendererTest : public testing::Test, public RendererClient { | 26 class SoftwareRendererTest : public testing::Test, public RendererClient { |
27 public: | 27 public: |
28 void initializeRenderer() { | 28 void initializeRenderer() { |
29 m_outputSurface = FakeWebCompositorOutputSurface::createSoftware(scoped_
ptr<WebKit::WebCompositorSoftwareOutputDevice>(new FakeWebCompositorSoftwareOutp
utDevice)); | 29 m_outputSurface = FakeOutputSurface::CreateSoftware(scoped_ptr<SoftwareO
utputDevice>(new FakeSoftwareOutputDevice)); |
30 m_resourceProvider = ResourceProvider::create(m_outputSurface.get()); | 30 m_resourceProvider = ResourceProvider::create(m_outputSurface.get()); |
31 m_renderer = SoftwareRenderer::create(this, resourceProvider(), software
Device()); | 31 m_renderer = SoftwareRenderer::create(this, resourceProvider(), software
Device()); |
32 } | 32 } |
33 | 33 |
34 WebCompositorSoftwareOutputDevice* softwareDevice() const { return m_outputS
urface->softwareDevice(); } | 34 SoftwareOutputDevice* softwareDevice() const { return m_outputSurface->Softw
areDevice(); } |
35 FakeWebCompositorOutputSurface* outputSurface() const { return m_outputSurfa
ce.get(); } | 35 FakeOutputSurface* outputSurface() const { return m_outputSurface.get(); } |
36 ResourceProvider* resourceProvider() const { return m_resourceProvider.get()
; } | 36 ResourceProvider* resourceProvider() const { return m_resourceProvider.get()
; } |
37 SoftwareRenderer* renderer() const { return m_renderer.get(); } | 37 SoftwareRenderer* renderer() const { return m_renderer.get(); } |
38 void setViewportSize(gfx::Size viewportSize) { m_viewportSize = viewportSize
; } | 38 void setViewportSize(gfx::Size viewportSize) { m_viewportSize = viewportSize
; } |
39 | 39 |
40 // RendererClient implementation. | 40 // RendererClient implementation. |
41 virtual const gfx::Size& deviceViewportSize() const OVERRIDE { return m_view
portSize; } | 41 virtual const gfx::Size& deviceViewportSize() const OVERRIDE { return m_view
portSize; } |
42 virtual const LayerTreeSettings& settings() const OVERRIDE { return m_settin
gs; } | 42 virtual const LayerTreeSettings& settings() const OVERRIDE { return m_settin
gs; } |
43 virtual void didLoseOutputSurface() OVERRIDE { } | 43 virtual void didLoseOutputSurface() OVERRIDE { } |
44 virtual void onSwapBuffersComplete() OVERRIDE { } | 44 virtual void onSwapBuffersComplete() OVERRIDE { } |
45 virtual void setFullRootLayerDamage() OVERRIDE { } | 45 virtual void setFullRootLayerDamage() OVERRIDE { } |
46 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR
IDE { }; | 46 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR
IDE { }; |
47 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O
VERRIDE { }; | 47 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O
VERRIDE { }; |
48 virtual bool hasImplThread() const OVERRIDE { return false; } | 48 virtual bool hasImplThread() const OVERRIDE { return false; } |
49 | 49 |
50 protected: | 50 protected: |
51 scoped_ptr<FakeWebCompositorOutputSurface> m_outputSurface; | 51 scoped_ptr<FakeOutputSurface> m_outputSurface; |
52 scoped_ptr<ResourceProvider> m_resourceProvider; | 52 scoped_ptr<ResourceProvider> m_resourceProvider; |
53 scoped_ptr<SoftwareRenderer> m_renderer; | 53 scoped_ptr<SoftwareRenderer> m_renderer; |
54 gfx::Size m_viewportSize; | 54 gfx::Size m_viewportSize; |
55 LayerTreeSettings m_settings; | 55 LayerTreeSettings m_settings; |
56 }; | 56 }; |
57 | 57 |
58 TEST_F(SoftwareRendererTest, solidColorQuad) | 58 TEST_F(SoftwareRendererTest, solidColorQuad) |
59 { | 59 { |
60 gfx::Size outerSize(100, 100); | 60 gfx::Size outerSize(100, 100); |
61 int outerPixels = outerSize.width() * outerSize.height(); | 61 int outerPixels = outerSize.width() * outerSize.height(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 renderer()->getFramebufferPixels(pixels.get(), outerRect); | 149 renderer()->getFramebufferPixels(pixels.get(), outerRect); |
150 | 150 |
151 EXPECT_EQ(SK_ColorYELLOW, pixels[0]); | 151 EXPECT_EQ(SK_ColorYELLOW, pixels[0]); |
152 EXPECT_EQ(SK_ColorYELLOW, pixels[outerPixels - 1]); | 152 EXPECT_EQ(SK_ColorYELLOW, pixels[outerPixels - 1]); |
153 EXPECT_EQ(SK_ColorCYAN, pixels[outerSize.width() + 1]); | 153 EXPECT_EQ(SK_ColorCYAN, pixels[outerSize.width() + 1]); |
154 EXPECT_EQ(SK_ColorCYAN, pixels[outerPixels - outerSize.width() - 2]); | 154 EXPECT_EQ(SK_ColorCYAN, pixels[outerPixels - outerSize.width() - 2]); |
155 } | 155 } |
156 | 156 |
157 } // namespace | 157 } // namespace |
158 } // namespace cc | 158 } // namespace cc |
OLD | NEW |