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/output/software_renderer.h" | 5 #include "cc/output/software_renderer.h" |
6 | 6 |
7 #include "cc/layers/quad_sink.h" | 7 #include "cc/layers/quad_sink.h" |
8 #include "cc/output/compositor_frame_metadata.h" | 8 #include "cc/output/compositor_frame_metadata.h" |
9 #include "cc/output/software_output_device.h" | 9 #include "cc/output/software_output_device.h" |
10 #include "cc/quads/render_pass.h" | 10 #include "cc/quads/render_pass.h" |
11 #include "cc/quads/render_pass_draw_quad.h" | 11 #include "cc/quads/render_pass_draw_quad.h" |
12 #include "cc/quads/solid_color_draw_quad.h" | 12 #include "cc/quads/solid_color_draw_quad.h" |
13 #include "cc/quads/tile_draw_quad.h" | 13 #include "cc/quads/tile_draw_quad.h" |
14 #include "cc/test/animation_test_common.h" | 14 #include "cc/test/animation_test_common.h" |
15 #include "cc/test/fake_output_surface.h" | 15 #include "cc/test/fake_output_surface.h" |
| 16 #include "cc/test/fake_output_surface_client.h" |
16 #include "cc/test/geometry_test_utils.h" | 17 #include "cc/test/geometry_test_utils.h" |
17 #include "cc/test/render_pass_test_common.h" | 18 #include "cc/test/render_pass_test_common.h" |
18 #include "cc/test/render_pass_test_utils.h" | 19 #include "cc/test/render_pass_test_utils.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "third_party/skia/include/core/SkCanvas.h" | 22 #include "third_party/skia/include/core/SkCanvas.h" |
22 #include "third_party/skia/include/core/SkDevice.h" | 23 #include "third_party/skia/include/core/SkDevice.h" |
23 | 24 |
24 namespace cc { | 25 namespace cc { |
25 namespace { | 26 namespace { |
26 | 27 |
27 class SoftwareRendererTest : public testing::Test, public RendererClient { | 28 class SoftwareRendererTest : public testing::Test, public RendererClient { |
28 public: | 29 public: |
29 SoftwareRendererTest() : should_clear_root_render_pass_(true) {} | 30 SoftwareRendererTest() : should_clear_root_render_pass_(true) {} |
30 | 31 |
31 void InitializeRenderer( | 32 void InitializeRenderer( |
32 scoped_ptr<SoftwareOutputDevice> software_output_device) { | 33 scoped_ptr<SoftwareOutputDevice> software_output_device) { |
33 output_surface_ = FakeOutputSurface::CreateSoftware( | 34 output_surface_ = FakeOutputSurface::CreateSoftware( |
34 software_output_device.Pass()); | 35 software_output_device.Pass()); |
| 36 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| 37 |
35 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0); | 38 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0); |
36 renderer_ = SoftwareRenderer::Create( | 39 renderer_ = SoftwareRenderer::Create( |
37 this, output_surface_.get(), resource_provider()); | 40 this, output_surface_.get(), resource_provider()); |
38 } | 41 } |
39 | 42 |
40 ResourceProvider* resource_provider() const { | 43 ResourceProvider* resource_provider() const { |
41 return resource_provider_.get(); | 44 return resource_provider_.get(); |
42 } | 45 } |
43 | 46 |
44 SoftwareRenderer* renderer() const { return renderer_.get(); } | 47 SoftwareRenderer* renderer() const { return renderer_.get(); } |
(...skipping 23 matching lines...) Expand all Loading... |
68 } | 71 } |
69 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const OVERRIDE { | 72 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const OVERRIDE { |
70 return CompositorFrameMetadata(); | 73 return CompositorFrameMetadata(); |
71 } | 74 } |
72 virtual bool AllowPartialSwap() const OVERRIDE { | 75 virtual bool AllowPartialSwap() const OVERRIDE { |
73 return true; | 76 return true; |
74 } | 77 } |
75 virtual bool ExternalStencilTestEnabled() const OVERRIDE { return false; } | 78 virtual bool ExternalStencilTestEnabled() const OVERRIDE { return false; } |
76 | 79 |
77 protected: | 80 protected: |
| 81 FakeOutputSurfaceClient output_surface_client_; |
78 scoped_ptr<FakeOutputSurface> output_surface_; | 82 scoped_ptr<FakeOutputSurface> output_surface_; |
79 scoped_ptr<ResourceProvider> resource_provider_; | 83 scoped_ptr<ResourceProvider> resource_provider_; |
80 scoped_ptr<SoftwareRenderer> renderer_; | 84 scoped_ptr<SoftwareRenderer> renderer_; |
81 gfx::Rect viewport_; | 85 gfx::Rect viewport_; |
82 LayerTreeSettings settings_; | 86 LayerTreeSettings settings_; |
83 bool should_clear_root_render_pass_; | 87 bool should_clear_root_render_pass_; |
84 }; | 88 }; |
85 | 89 |
86 TEST_F(SoftwareRendererTest, SolidColorQuad) { | 90 TEST_F(SoftwareRendererTest, SolidColorQuad) { |
87 gfx::Size outer_size(100, 100); | 91 gfx::Size outer_size(100, 100); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 output.getColor(viewport_rect.width() - 1, viewport_rect.height() - 1)); | 265 output.getColor(viewport_rect.width() - 1, viewport_rect.height() - 1)); |
262 | 266 |
263 EXPECT_EQ(SK_ColorMAGENTA, | 267 EXPECT_EQ(SK_ColorMAGENTA, |
264 output.getColor(smaller_rect.x(), smaller_rect.y())); | 268 output.getColor(smaller_rect.x(), smaller_rect.y())); |
265 EXPECT_EQ(SK_ColorMAGENTA, | 269 EXPECT_EQ(SK_ColorMAGENTA, |
266 output.getColor(smaller_rect.right() - 1, smaller_rect.bottom() - 1)); | 270 output.getColor(smaller_rect.right() - 1, smaller_rect.bottom() - 1)); |
267 } | 271 } |
268 | 272 |
269 } // namespace | 273 } // namespace |
270 } // namespace cc | 274 } // namespace cc |
OLD | NEW |