| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 shared_quad_state, outer_rect, outer_rect, SK_ColorYELLOW, false); | 128 shared_quad_state, outer_rect, outer_rect, SK_ColorYELLOW, false); |
| 129 | 129 |
| 130 RenderPassList list; | 130 RenderPassList list; |
| 131 list.push_back(root_render_pass.Pass()); | 131 list.push_back(root_render_pass.Pass()); |
| 132 | 132 |
| 133 float device_scale_factor = 1.f; | 133 float device_scale_factor = 1.f; |
| 134 gfx::Rect device_viewport_rect(outer_size); | 134 gfx::Rect device_viewport_rect(outer_size); |
| 135 scoped_ptr<SkBitmap> output = | 135 scoped_ptr<SkBitmap> output = |
| 136 DrawAndCopyOutput(&list, device_scale_factor, device_viewport_rect); | 136 DrawAndCopyOutput(&list, device_scale_factor, device_viewport_rect); |
| 137 EXPECT_EQ(outer_rect.width(), output->info().fWidth); | 137 EXPECT_EQ(outer_rect.width(), output->info().fWidth); |
| 138 EXPECT_EQ(outer_rect.width(), output->info().fHeight); | 138 EXPECT_EQ(outer_rect.height(), output->info().fHeight); |
| 139 | 139 |
| 140 EXPECT_EQ(SK_ColorYELLOW, output->getColor(0, 0)); | 140 EXPECT_EQ(SK_ColorYELLOW, output->getColor(0, 0)); |
| 141 EXPECT_EQ(SK_ColorYELLOW, | 141 EXPECT_EQ(SK_ColorYELLOW, |
| 142 output->getColor(outer_size.width() - 1, outer_size.height() - 1)); | 142 output->getColor(outer_size.width() - 1, outer_size.height() - 1)); |
| 143 EXPECT_EQ(SK_ColorYELLOW, output->getColor(1, 1)); | 143 EXPECT_EQ(SK_ColorYELLOW, output->getColor(1, 1)); |
| 144 EXPECT_EQ(SK_ColorCYAN, output->getColor(1, 2)); | 144 EXPECT_EQ(SK_ColorCYAN, output->getColor(1, 2)); |
| 145 EXPECT_EQ(SK_ColorCYAN, | 145 EXPECT_EQ(SK_ColorCYAN, |
| 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 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 false); | 226 false); |
| 227 | 227 |
| 228 RenderPassList list; | 228 RenderPassList list; |
| 229 list.push_back(root_render_pass.Pass()); | 229 list.push_back(root_render_pass.Pass()); |
| 230 | 230 |
| 231 float device_scale_factor = 1.f; | 231 float device_scale_factor = 1.f; |
| 232 gfx::Rect device_viewport_rect(outer_size); | 232 gfx::Rect device_viewport_rect(outer_size); |
| 233 scoped_ptr<SkBitmap> output = | 233 scoped_ptr<SkBitmap> output = |
| 234 DrawAndCopyOutput(&list, device_scale_factor, device_viewport_rect); | 234 DrawAndCopyOutput(&list, device_scale_factor, device_viewport_rect); |
| 235 EXPECT_EQ(outer_rect.width(), output->info().fWidth); | 235 EXPECT_EQ(outer_rect.width(), output->info().fWidth); |
| 236 EXPECT_EQ(outer_rect.width(), output->info().fHeight); | 236 EXPECT_EQ(outer_rect.height(), output->info().fHeight); |
| 237 | 237 |
| 238 EXPECT_EQ(SK_ColorYELLOW, output->getColor(0, 0)); | 238 EXPECT_EQ(SK_ColorYELLOW, output->getColor(0, 0)); |
| 239 EXPECT_EQ(SK_ColorYELLOW, | 239 EXPECT_EQ(SK_ColorYELLOW, |
| 240 output->getColor(outer_size.width() - 1, outer_size.height() - 1)); | 240 output->getColor(outer_size.width() - 1, outer_size.height() - 1)); |
| 241 EXPECT_EQ(SK_ColorCYAN, output->getColor(1, 1)); | 241 EXPECT_EQ(SK_ColorCYAN, output->getColor(1, 1)); |
| 242 EXPECT_EQ(SK_ColorCYAN, | 242 EXPECT_EQ(SK_ColorCYAN, |
| 243 output->getColor(inner_size.width() - 1, inner_size.height() - 1)); | 243 output->getColor(inner_size.width() - 1, inner_size.height() - 1)); |
| 244 } | 244 } |
| 245 | 245 |
| 246 TEST_F(SoftwareRendererTest, TileQuadVisibleRect) { | 246 TEST_F(SoftwareRendererTest, TileQuadVisibleRect) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 quad->visible_rect = visible_rect; | 301 quad->visible_rect = visible_rect; |
| 302 | 302 |
| 303 RenderPassList list; | 303 RenderPassList list; |
| 304 list.push_back(root_render_pass.Pass()); | 304 list.push_back(root_render_pass.Pass()); |
| 305 | 305 |
| 306 float device_scale_factor = 1.f; | 306 float device_scale_factor = 1.f; |
| 307 gfx::Rect device_viewport_rect(tile_size); | 307 gfx::Rect device_viewport_rect(tile_size); |
| 308 scoped_ptr<SkBitmap> output = | 308 scoped_ptr<SkBitmap> output = |
| 309 DrawAndCopyOutput(&list, device_scale_factor, device_viewport_rect); | 309 DrawAndCopyOutput(&list, device_scale_factor, device_viewport_rect); |
| 310 EXPECT_EQ(tile_rect.width(), output->info().fWidth); | 310 EXPECT_EQ(tile_rect.width(), output->info().fWidth); |
| 311 EXPECT_EQ(tile_rect.width(), output->info().fHeight); | 311 EXPECT_EQ(tile_rect.height(), output->info().fHeight); |
| 312 | 312 |
| 313 // Check portion of tile not in visible rect isn't drawn. | 313 // Check portion of tile not in visible rect isn't drawn. |
| 314 const unsigned int kTransparent = SK_ColorTRANSPARENT; | 314 const unsigned int kTransparent = SK_ColorTRANSPARENT; |
| 315 EXPECT_EQ(kTransparent, output->getColor(0, 0)); | 315 EXPECT_EQ(kTransparent, output->getColor(0, 0)); |
| 316 EXPECT_EQ(kTransparent, | 316 EXPECT_EQ(kTransparent, |
| 317 output->getColor(tile_rect.width() - 1, tile_rect.height() - 1)); | 317 output->getColor(tile_rect.width() - 1, tile_rect.height() - 1)); |
| 318 EXPECT_EQ(kTransparent, | 318 EXPECT_EQ(kTransparent, |
| 319 output->getColor(visible_rect.x() - 1, visible_rect.y() - 1)); | 319 output->getColor(visible_rect.x() - 1, visible_rect.y() - 1)); |
| 320 EXPECT_EQ(kTransparent, | 320 EXPECT_EQ(kTransparent, |
| 321 output->getColor(visible_rect.right(), visible_rect.bottom())); | 321 output->getColor(visible_rect.right(), visible_rect.bottom())); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 343 RenderPassId root_clear_pass_id(1, 0); | 343 RenderPassId root_clear_pass_id(1, 0); |
| 344 TestRenderPass* root_clear_pass = AddRenderPass( | 344 TestRenderPass* root_clear_pass = AddRenderPass( |
| 345 &list, root_clear_pass_id, device_viewport_rect, gfx::Transform()); | 345 &list, root_clear_pass_id, device_viewport_rect, gfx::Transform()); |
| 346 AddQuad(root_clear_pass, device_viewport_rect, SK_ColorGREEN); | 346 AddQuad(root_clear_pass, device_viewport_rect, SK_ColorGREEN); |
| 347 | 347 |
| 348 renderer()->DecideRenderPassAllocationsForFrame(list); | 348 renderer()->DecideRenderPassAllocationsForFrame(list); |
| 349 | 349 |
| 350 scoped_ptr<SkBitmap> output = | 350 scoped_ptr<SkBitmap> output = |
| 351 DrawAndCopyOutput(&list, device_scale_factor, device_viewport_rect); | 351 DrawAndCopyOutput(&list, device_scale_factor, device_viewport_rect); |
| 352 EXPECT_EQ(device_viewport_rect.width(), output->info().fWidth); | 352 EXPECT_EQ(device_viewport_rect.width(), output->info().fWidth); |
| 353 EXPECT_EQ(device_viewport_rect.width(), output->info().fHeight); | 353 EXPECT_EQ(device_viewport_rect.height(), output->info().fHeight); |
| 354 | 354 |
| 355 EXPECT_EQ(SK_ColorGREEN, output->getColor(0, 0)); | 355 EXPECT_EQ(SK_ColorGREEN, output->getColor(0, 0)); |
| 356 EXPECT_EQ(SK_ColorGREEN, | 356 EXPECT_EQ(SK_ColorGREEN, |
| 357 output->getColor(device_viewport_rect.width() - 1, | 357 output->getColor(device_viewport_rect.width() - 1, |
| 358 device_viewport_rect.height() - 1)); | 358 device_viewport_rect.height() - 1)); |
| 359 | 359 |
| 360 list.clear(); | 360 list.clear(); |
| 361 | 361 |
| 362 // Draw a smaller magenta rect without filling the viewport in a separate | 362 // Draw a smaller magenta rect without filling the viewport in a separate |
| 363 // frame. | 363 // frame. |
| 364 gfx::Rect smaller_rect(20, 20, 60, 60); | 364 gfx::Rect smaller_rect(20, 20, 60, 60); |
| 365 | 365 |
| 366 RenderPassId root_smaller_pass_id(2, 0); | 366 RenderPassId root_smaller_pass_id(2, 0); |
| 367 TestRenderPass* root_smaller_pass = AddRenderPass( | 367 TestRenderPass* root_smaller_pass = AddRenderPass( |
| 368 &list, root_smaller_pass_id, device_viewport_rect, gfx::Transform()); | 368 &list, root_smaller_pass_id, device_viewport_rect, gfx::Transform()); |
| 369 AddQuad(root_smaller_pass, smaller_rect, SK_ColorMAGENTA); | 369 AddQuad(root_smaller_pass, smaller_rect, SK_ColorMAGENTA); |
| 370 | 370 |
| 371 renderer()->DecideRenderPassAllocationsForFrame(list); | 371 renderer()->DecideRenderPassAllocationsForFrame(list); |
| 372 | 372 |
| 373 output = DrawAndCopyOutput(&list, device_scale_factor, device_viewport_rect); | 373 output = DrawAndCopyOutput(&list, device_scale_factor, device_viewport_rect); |
| 374 EXPECT_EQ(device_viewport_rect.width(), output->info().fWidth); | 374 EXPECT_EQ(device_viewport_rect.width(), output->info().fWidth); |
| 375 EXPECT_EQ(device_viewport_rect.width(), output->info().fHeight); | 375 EXPECT_EQ(device_viewport_rect.height(), output->info().fHeight); |
| 376 | 376 |
| 377 // If we didn't clear, the borders should still be green. | 377 // If we didn't clear, the borders should still be green. |
| 378 EXPECT_EQ(SK_ColorGREEN, output->getColor(0, 0)); | 378 EXPECT_EQ(SK_ColorGREEN, output->getColor(0, 0)); |
| 379 EXPECT_EQ(SK_ColorGREEN, | 379 EXPECT_EQ(SK_ColorGREEN, |
| 380 output->getColor(device_viewport_rect.width() - 1, | 380 output->getColor(device_viewport_rect.width() - 1, |
| 381 device_viewport_rect.height() - 1)); | 381 device_viewport_rect.height() - 1)); |
| 382 | 382 |
| 383 EXPECT_EQ(SK_ColorMAGENTA, | 383 EXPECT_EQ(SK_ColorMAGENTA, |
| 384 output->getColor(smaller_rect.x(), smaller_rect.y())); | 384 output->getColor(smaller_rect.x(), smaller_rect.y())); |
| 385 EXPECT_EQ( | 385 EXPECT_EQ( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 410 | 410 |
| 411 // Interior pass quad has smaller visible rect. | 411 // Interior pass quad has smaller visible rect. |
| 412 gfx::Rect interior_visible_rect(30, 30, 40, 40); | 412 gfx::Rect interior_visible_rect(30, 30, 40, 40); |
| 413 root_clear_pass->quad_list.front()->visible_rect = interior_visible_rect; | 413 root_clear_pass->quad_list.front()->visible_rect = interior_visible_rect; |
| 414 | 414 |
| 415 renderer()->DecideRenderPassAllocationsForFrame(list); | 415 renderer()->DecideRenderPassAllocationsForFrame(list); |
| 416 | 416 |
| 417 scoped_ptr<SkBitmap> output = | 417 scoped_ptr<SkBitmap> output = |
| 418 DrawAndCopyOutput(&list, device_scale_factor, device_viewport_rect); | 418 DrawAndCopyOutput(&list, device_scale_factor, device_viewport_rect); |
| 419 EXPECT_EQ(device_viewport_rect.width(), output->info().fWidth); | 419 EXPECT_EQ(device_viewport_rect.width(), output->info().fWidth); |
| 420 EXPECT_EQ(device_viewport_rect.width(), output->info().fHeight); | 420 EXPECT_EQ(device_viewport_rect.height(), output->info().fHeight); |
| 421 | 421 |
| 422 EXPECT_EQ(SK_ColorGREEN, output->getColor(0, 0)); | 422 EXPECT_EQ(SK_ColorGREEN, output->getColor(0, 0)); |
| 423 EXPECT_EQ(SK_ColorGREEN, | 423 EXPECT_EQ(SK_ColorGREEN, |
| 424 output->getColor(device_viewport_rect.width() - 1, | 424 output->getColor(device_viewport_rect.width() - 1, |
| 425 device_viewport_rect.height() - 1)); | 425 device_viewport_rect.height() - 1)); |
| 426 | 426 |
| 427 // Part outside visible rect should remain green. | 427 // Part outside visible rect should remain green. |
| 428 EXPECT_EQ(SK_ColorGREEN, | 428 EXPECT_EQ(SK_ColorGREEN, |
| 429 output->getColor(smaller_rect.x(), smaller_rect.y())); | 429 output->getColor(smaller_rect.x(), smaller_rect.y())); |
| 430 EXPECT_EQ( | 430 EXPECT_EQ( |
| 431 SK_ColorGREEN, | 431 SK_ColorGREEN, |
| 432 output->getColor(smaller_rect.right() - 1, smaller_rect.bottom() - 1)); | 432 output->getColor(smaller_rect.right() - 1, smaller_rect.bottom() - 1)); |
| 433 | 433 |
| 434 EXPECT_EQ( | 434 EXPECT_EQ( |
| 435 SK_ColorMAGENTA, | 435 SK_ColorMAGENTA, |
| 436 output->getColor(interior_visible_rect.x(), interior_visible_rect.y())); | 436 output->getColor(interior_visible_rect.x(), interior_visible_rect.y())); |
| 437 EXPECT_EQ(SK_ColorMAGENTA, | 437 EXPECT_EQ(SK_ColorMAGENTA, |
| 438 output->getColor(interior_visible_rect.right() - 1, | 438 output->getColor(interior_visible_rect.right() - 1, |
| 439 interior_visible_rect.bottom() - 1)); | 439 interior_visible_rect.bottom() - 1)); |
| 440 } | 440 } |
| 441 | 441 |
| 442 } // namespace | 442 } // namespace |
| 443 } // namespace cc | 443 } // namespace cc |
| OLD | NEW |