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" |
(...skipping 15 matching lines...) Expand all Loading... |
26 namespace { | 26 namespace { |
27 | 27 |
28 class SoftwareRendererTest : public testing::Test, public RendererClient { | 28 class SoftwareRendererTest : public testing::Test, public RendererClient { |
29 public: | 29 public: |
30 void InitializeRenderer( | 30 void InitializeRenderer( |
31 scoped_ptr<SoftwareOutputDevice> software_output_device) { | 31 scoped_ptr<SoftwareOutputDevice> software_output_device) { |
32 output_surface_ = FakeOutputSurface::CreateSoftware( | 32 output_surface_ = FakeOutputSurface::CreateSoftware( |
33 software_output_device.Pass()); | 33 software_output_device.Pass()); |
34 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 34 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
35 | 35 |
36 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0); | 36 resource_provider_ = |
| 37 ResourceProvider::Create(output_surface_.get(), 0, false); |
37 renderer_ = SoftwareRenderer::Create( | 38 renderer_ = SoftwareRenderer::Create( |
38 this, &settings_, output_surface_.get(), resource_provider()); | 39 this, &settings_, output_surface_.get(), resource_provider()); |
39 } | 40 } |
40 | 41 |
41 ResourceProvider* resource_provider() const { | 42 ResourceProvider* resource_provider() const { |
42 return resource_provider_.get(); | 43 return resource_provider_.get(); |
43 } | 44 } |
44 | 45 |
45 SoftwareRenderer* renderer() const { return renderer_.get(); } | 46 SoftwareRenderer* renderer() const { return renderer_.get(); } |
46 | 47 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 118 |
118 TEST_F(SoftwareRendererTest, TileQuad) { | 119 TEST_F(SoftwareRendererTest, TileQuad) { |
119 gfx::Size outer_size(100, 100); | 120 gfx::Size outer_size(100, 100); |
120 gfx::Size inner_size(98, 98); | 121 gfx::Size inner_size(98, 98); |
121 gfx::Rect outer_rect(outer_size); | 122 gfx::Rect outer_rect(outer_size); |
122 gfx::Rect inner_rect(gfx::Point(1, 1), inner_size); | 123 gfx::Rect inner_rect(gfx::Point(1, 1), inner_size); |
123 set_viewport(gfx::Rect(outer_size)); | 124 set_viewport(gfx::Rect(outer_size)); |
124 InitializeRenderer(make_scoped_ptr(new SoftwareOutputDevice)); | 125 InitializeRenderer(make_scoped_ptr(new SoftwareOutputDevice)); |
125 | 126 |
126 ResourceProvider::ResourceId resource_yellow = | 127 ResourceProvider::ResourceId resource_yellow = |
127 resource_provider()->CreateResource( | 128 resource_provider()->CreateResource(outer_size, |
128 outer_size, GL_RGBA, GL_CLAMP_TO_EDGE, | 129 GL_CLAMP_TO_EDGE, |
129 ResourceProvider::TextureUsageAny); | 130 ResourceProvider::TextureUsageAny, |
| 131 RGBA_8888); |
130 ResourceProvider::ResourceId resource_cyan = | 132 ResourceProvider::ResourceId resource_cyan = |
131 resource_provider()->CreateResource( | 133 resource_provider()->CreateResource(inner_size, |
132 inner_size, GL_RGBA, GL_CLAMP_TO_EDGE, | 134 GL_CLAMP_TO_EDGE, |
133 ResourceProvider::TextureUsageAny); | 135 ResourceProvider::TextureUsageAny, |
| 136 RGBA_8888); |
134 | 137 |
135 SkBitmap yellow_tile; | 138 SkBitmap yellow_tile; |
136 yellow_tile.setConfig( | 139 yellow_tile.setConfig( |
137 SkBitmap::kARGB_8888_Config, outer_size.width(), outer_size.height()); | 140 SkBitmap::kARGB_8888_Config, outer_size.width(), outer_size.height()); |
138 yellow_tile.allocPixels(); | 141 yellow_tile.allocPixels(); |
139 yellow_tile.eraseColor(SK_ColorYELLOW); | 142 yellow_tile.eraseColor(SK_ColorYELLOW); |
140 | 143 |
141 SkBitmap cyan_tile; | 144 SkBitmap cyan_tile; |
142 cyan_tile.setConfig( | 145 cyan_tile.setConfig( |
143 SkBitmap::kARGB_8888_Config, inner_size.width(), inner_size.height()); | 146 SkBitmap::kARGB_8888_Config, inner_size.width(), inner_size.height()); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 | 210 |
208 TEST_F(SoftwareRendererTest, TileQuadVisibleRect) { | 211 TEST_F(SoftwareRendererTest, TileQuadVisibleRect) { |
209 gfx::Size tile_size(100, 100); | 212 gfx::Size tile_size(100, 100); |
210 gfx::Rect tile_rect(tile_size); | 213 gfx::Rect tile_rect(tile_size); |
211 gfx::Rect visible_rect = tile_rect; | 214 gfx::Rect visible_rect = tile_rect; |
212 visible_rect.Inset(1, 2, 3, 4); | 215 visible_rect.Inset(1, 2, 3, 4); |
213 set_viewport(gfx::Rect(tile_size)); | 216 set_viewport(gfx::Rect(tile_size)); |
214 InitializeRenderer(make_scoped_ptr(new SoftwareOutputDevice)); | 217 InitializeRenderer(make_scoped_ptr(new SoftwareOutputDevice)); |
215 | 218 |
216 ResourceProvider::ResourceId resource_cyan = | 219 ResourceProvider::ResourceId resource_cyan = |
217 resource_provider()->CreateResource( | 220 resource_provider()->CreateResource(tile_size, |
218 tile_size, GL_RGBA, GL_CLAMP_TO_EDGE, | 221 GL_CLAMP_TO_EDGE, |
219 ResourceProvider::TextureUsageAny); | 222 ResourceProvider::TextureUsageAny, |
| 223 RGBA_8888); |
220 | 224 |
221 SkBitmap cyan_tile; // The lowest five rows are yellow. | 225 SkBitmap cyan_tile; // The lowest five rows are yellow. |
222 cyan_tile.setConfig( | 226 cyan_tile.setConfig( |
223 SkBitmap::kARGB_8888_Config, tile_size.width(), tile_size.height()); | 227 SkBitmap::kARGB_8888_Config, tile_size.width(), tile_size.height()); |
224 cyan_tile.allocPixels(); | 228 cyan_tile.allocPixels(); |
225 cyan_tile.eraseColor(SK_ColorCYAN); | 229 cyan_tile.eraseColor(SK_ColorCYAN); |
226 cyan_tile.eraseArea( | 230 cyan_tile.eraseArea( |
227 SkIRect::MakeLTRB( | 231 SkIRect::MakeLTRB( |
228 0, visible_rect.bottom() - 1, tile_rect.width(), tile_rect.bottom()), | 232 0, visible_rect.bottom() - 1, tile_rect.width(), tile_rect.bottom()), |
229 SK_ColorYELLOW); | 233 SK_ColorYELLOW); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 EXPECT_EQ( | 397 EXPECT_EQ( |
394 SK_ColorMAGENTA, | 398 SK_ColorMAGENTA, |
395 output.getColor(interior_visible_rect.x(), interior_visible_rect.y())); | 399 output.getColor(interior_visible_rect.x(), interior_visible_rect.y())); |
396 EXPECT_EQ(SK_ColorMAGENTA, | 400 EXPECT_EQ(SK_ColorMAGENTA, |
397 output.getColor(interior_visible_rect.right() - 1, | 401 output.getColor(interior_visible_rect.right() - 1, |
398 interior_visible_rect.bottom() - 1)); | 402 interior_visible_rect.bottom() - 1)); |
399 } | 403 } |
400 | 404 |
401 } // namespace | 405 } // namespace |
402 } // namespace cc | 406 } // namespace cc |
OLD | NEW |