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 "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "cc/output/compositor_frame_metadata.h" | 8 #include "cc/output/compositor_frame_metadata.h" |
9 #include "cc/output/copy_output_request.h" | 9 #include "cc/output/copy_output_request.h" |
10 #include "cc/output/copy_output_result.h" | 10 #include "cc/output/copy_output_result.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 output->getColor(inner_size.width() - 1, inner_size.height() - 1)); | 146 output->getColor(inner_size.width() - 1, inner_size.height() - 1)); |
147 } | 147 } |
148 | 148 |
149 TEST_F(SoftwareRendererTest, TileQuad) { | 149 TEST_F(SoftwareRendererTest, TileQuad) { |
150 gfx::Size outer_size(100, 100); | 150 gfx::Size outer_size(100, 100); |
151 gfx::Size inner_size(98, 98); | 151 gfx::Size inner_size(98, 98); |
152 gfx::Rect outer_rect(outer_size); | 152 gfx::Rect outer_rect(outer_size); |
153 gfx::Rect inner_rect(gfx::Point(1, 1), inner_size); | 153 gfx::Rect inner_rect(gfx::Point(1, 1), inner_size); |
154 InitializeRenderer(make_scoped_ptr(new SoftwareOutputDevice)); | 154 InitializeRenderer(make_scoped_ptr(new SoftwareOutputDevice)); |
155 | 155 |
156 ResourceProvider::ResourceId resource_yellow = | 156 ResourceId resource_yellow = resource_provider()->CreateResource( |
157 resource_provider()->CreateResource( | 157 outer_size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, |
158 outer_size, GL_CLAMP_TO_EDGE, | 158 RGBA_8888); |
159 ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888); | 159 ResourceId resource_cyan = resource_provider()->CreateResource( |
160 ResourceProvider::ResourceId resource_cyan = | 160 inner_size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, |
161 resource_provider()->CreateResource( | 161 RGBA_8888); |
162 inner_size, GL_CLAMP_TO_EDGE, | |
163 ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888); | |
164 | 162 |
165 SkBitmap yellow_tile; | 163 SkBitmap yellow_tile; |
166 yellow_tile.allocN32Pixels(outer_size.width(), outer_size.height()); | 164 yellow_tile.allocN32Pixels(outer_size.width(), outer_size.height()); |
167 yellow_tile.eraseColor(SK_ColorYELLOW); | 165 yellow_tile.eraseColor(SK_ColorYELLOW); |
168 | 166 |
169 SkBitmap cyan_tile; | 167 SkBitmap cyan_tile; |
170 cyan_tile.allocN32Pixels(inner_size.width(), inner_size.height()); | 168 cyan_tile.allocN32Pixels(inner_size.width(), inner_size.height()); |
171 cyan_tile.eraseColor(SK_ColorCYAN); | 169 cyan_tile.eraseColor(SK_ColorCYAN); |
172 | 170 |
173 resource_provider()->CopyToResource( | 171 resource_provider()->CopyToResource( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 output->getColor(inner_size.width() - 1, inner_size.height() - 1)); | 231 output->getColor(inner_size.width() - 1, inner_size.height() - 1)); |
234 } | 232 } |
235 | 233 |
236 TEST_F(SoftwareRendererTest, TileQuadVisibleRect) { | 234 TEST_F(SoftwareRendererTest, TileQuadVisibleRect) { |
237 gfx::Size tile_size(100, 100); | 235 gfx::Size tile_size(100, 100); |
238 gfx::Rect tile_rect(tile_size); | 236 gfx::Rect tile_rect(tile_size); |
239 gfx::Rect visible_rect = tile_rect; | 237 gfx::Rect visible_rect = tile_rect; |
240 visible_rect.Inset(1, 2, 3, 4); | 238 visible_rect.Inset(1, 2, 3, 4); |
241 InitializeRenderer(make_scoped_ptr(new SoftwareOutputDevice)); | 239 InitializeRenderer(make_scoped_ptr(new SoftwareOutputDevice)); |
242 | 240 |
243 ResourceProvider::ResourceId resource_cyan = | 241 ResourceId resource_cyan = resource_provider()->CreateResource( |
244 resource_provider()->CreateResource( | 242 tile_size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, |
245 tile_size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, | 243 RGBA_8888); |
246 RGBA_8888); | |
247 | 244 |
248 SkBitmap cyan_tile; // The lowest five rows are yellow. | 245 SkBitmap cyan_tile; // The lowest five rows are yellow. |
249 cyan_tile.allocN32Pixels(tile_size.width(), tile_size.height()); | 246 cyan_tile.allocN32Pixels(tile_size.width(), tile_size.height()); |
250 cyan_tile.eraseColor(SK_ColorCYAN); | 247 cyan_tile.eraseColor(SK_ColorCYAN); |
251 cyan_tile.eraseArea( | 248 cyan_tile.eraseArea( |
252 SkIRect::MakeLTRB( | 249 SkIRect::MakeLTRB( |
253 0, visible_rect.bottom() - 1, tile_rect.width(), tile_rect.bottom()), | 250 0, visible_rect.bottom() - 1, tile_rect.width(), tile_rect.bottom()), |
254 SK_ColorYELLOW); | 251 SK_ColorYELLOW); |
255 | 252 |
256 resource_provider()->CopyToResource( | 253 resource_provider()->CopyToResource( |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 EXPECT_EQ( | 416 EXPECT_EQ( |
420 SK_ColorMAGENTA, | 417 SK_ColorMAGENTA, |
421 output->getColor(interior_visible_rect.x(), interior_visible_rect.y())); | 418 output->getColor(interior_visible_rect.x(), interior_visible_rect.y())); |
422 EXPECT_EQ(SK_ColorMAGENTA, | 419 EXPECT_EQ(SK_ColorMAGENTA, |
423 output->getColor(interior_visible_rect.right() - 1, | 420 output->getColor(interior_visible_rect.right() - 1, |
424 interior_visible_rect.bottom() - 1)); | 421 interior_visible_rect.bottom() - 1)); |
425 } | 422 } |
426 | 423 |
427 } // namespace | 424 } // namespace |
428 } // namespace cc | 425 } // namespace cc |
OLD | NEW |