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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 outer_quad->SetNew( | 127 outer_quad->SetNew( |
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().width()); |
138 EXPECT_EQ(outer_rect.height(), output->info().fHeight); | 138 EXPECT_EQ(outer_rect.height(), output->info().height()); |
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 false, | 215 false, |
216 false); | 216 false); |
217 | 217 |
218 RenderPassList list; | 218 RenderPassList list; |
219 list.push_back(root_render_pass.Pass()); | 219 list.push_back(root_render_pass.Pass()); |
220 | 220 |
221 float device_scale_factor = 1.f; | 221 float device_scale_factor = 1.f; |
222 gfx::Rect device_viewport_rect(outer_size); | 222 gfx::Rect device_viewport_rect(outer_size); |
223 scoped_ptr<SkBitmap> output = | 223 scoped_ptr<SkBitmap> output = |
224 DrawAndCopyOutput(&list, device_scale_factor, device_viewport_rect); | 224 DrawAndCopyOutput(&list, device_scale_factor, device_viewport_rect); |
225 EXPECT_EQ(outer_rect.width(), output->info().fWidth); | 225 EXPECT_EQ(outer_rect.width(), output->info().width()); |
226 EXPECT_EQ(outer_rect.height(), output->info().fHeight); | 226 EXPECT_EQ(outer_rect.height(), output->info().height()); |
227 | 227 |
228 EXPECT_EQ(SK_ColorYELLOW, output->getColor(0, 0)); | 228 EXPECT_EQ(SK_ColorYELLOW, output->getColor(0, 0)); |
229 EXPECT_EQ(SK_ColorYELLOW, | 229 EXPECT_EQ(SK_ColorYELLOW, |
230 output->getColor(outer_size.width() - 1, outer_size.height() - 1)); | 230 output->getColor(outer_size.width() - 1, outer_size.height() - 1)); |
231 EXPECT_EQ(SK_ColorCYAN, output->getColor(1, 1)); | 231 EXPECT_EQ(SK_ColorCYAN, output->getColor(1, 1)); |
232 EXPECT_EQ(SK_ColorCYAN, | 232 EXPECT_EQ(SK_ColorCYAN, |
233 output->getColor(inner_size.width() - 1, inner_size.height() - 1)); | 233 output->getColor(inner_size.width() - 1, inner_size.height() - 1)); |
234 } | 234 } |
235 | 235 |
236 TEST_F(SoftwareRendererTest, TileQuadVisibleRect) { | 236 TEST_F(SoftwareRendererTest, TileQuadVisibleRect) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 false); | 285 false); |
286 quad->visible_rect = visible_rect; | 286 quad->visible_rect = visible_rect; |
287 | 287 |
288 RenderPassList list; | 288 RenderPassList list; |
289 list.push_back(root_render_pass.Pass()); | 289 list.push_back(root_render_pass.Pass()); |
290 | 290 |
291 float device_scale_factor = 1.f; | 291 float device_scale_factor = 1.f; |
292 gfx::Rect device_viewport_rect(tile_size); | 292 gfx::Rect device_viewport_rect(tile_size); |
293 scoped_ptr<SkBitmap> output = | 293 scoped_ptr<SkBitmap> output = |
294 DrawAndCopyOutput(&list, device_scale_factor, device_viewport_rect); | 294 DrawAndCopyOutput(&list, device_scale_factor, device_viewport_rect); |
295 EXPECT_EQ(tile_rect.width(), output->info().fWidth); | 295 EXPECT_EQ(tile_rect.width(), output->info().width()); |
296 EXPECT_EQ(tile_rect.height(), output->info().fHeight); | 296 EXPECT_EQ(tile_rect.height(), output->info().height()); |
297 | 297 |
298 // Check portion of tile not in visible rect isn't drawn. | 298 // Check portion of tile not in visible rect isn't drawn. |
299 const unsigned int kTransparent = SK_ColorTRANSPARENT; | 299 const unsigned int kTransparent = SK_ColorTRANSPARENT; |
300 EXPECT_EQ(kTransparent, output->getColor(0, 0)); | 300 EXPECT_EQ(kTransparent, output->getColor(0, 0)); |
301 EXPECT_EQ(kTransparent, | 301 EXPECT_EQ(kTransparent, |
302 output->getColor(tile_rect.width() - 1, tile_rect.height() - 1)); | 302 output->getColor(tile_rect.width() - 1, tile_rect.height() - 1)); |
303 EXPECT_EQ(kTransparent, | 303 EXPECT_EQ(kTransparent, |
304 output->getColor(visible_rect.x() - 1, visible_rect.y() - 1)); | 304 output->getColor(visible_rect.x() - 1, visible_rect.y() - 1)); |
305 EXPECT_EQ(kTransparent, | 305 EXPECT_EQ(kTransparent, |
306 output->getColor(visible_rect.right(), visible_rect.bottom())); | 306 output->getColor(visible_rect.right(), visible_rect.bottom())); |
(...skipping 20 matching lines...) Expand all Loading... |
327 // Draw a fullscreen green quad in a first frame. | 327 // Draw a fullscreen green quad in a first frame. |
328 RenderPassId root_clear_pass_id(1, 0); | 328 RenderPassId root_clear_pass_id(1, 0); |
329 TestRenderPass* root_clear_pass = AddRenderPass( | 329 TestRenderPass* root_clear_pass = AddRenderPass( |
330 &list, root_clear_pass_id, device_viewport_rect, gfx::Transform()); | 330 &list, root_clear_pass_id, device_viewport_rect, gfx::Transform()); |
331 AddQuad(root_clear_pass, device_viewport_rect, SK_ColorGREEN); | 331 AddQuad(root_clear_pass, device_viewport_rect, SK_ColorGREEN); |
332 | 332 |
333 renderer()->DecideRenderPassAllocationsForFrame(list); | 333 renderer()->DecideRenderPassAllocationsForFrame(list); |
334 | 334 |
335 scoped_ptr<SkBitmap> output = | 335 scoped_ptr<SkBitmap> output = |
336 DrawAndCopyOutput(&list, device_scale_factor, device_viewport_rect); | 336 DrawAndCopyOutput(&list, device_scale_factor, device_viewport_rect); |
337 EXPECT_EQ(device_viewport_rect.width(), output->info().fWidth); | 337 EXPECT_EQ(device_viewport_rect.width(), output->info().width()); |
338 EXPECT_EQ(device_viewport_rect.height(), output->info().fHeight); | 338 EXPECT_EQ(device_viewport_rect.height(), output->info().height()); |
339 | 339 |
340 EXPECT_EQ(SK_ColorGREEN, output->getColor(0, 0)); | 340 EXPECT_EQ(SK_ColorGREEN, output->getColor(0, 0)); |
341 EXPECT_EQ(SK_ColorGREEN, | 341 EXPECT_EQ(SK_ColorGREEN, |
342 output->getColor(device_viewport_rect.width() - 1, | 342 output->getColor(device_viewport_rect.width() - 1, |
343 device_viewport_rect.height() - 1)); | 343 device_viewport_rect.height() - 1)); |
344 | 344 |
345 list.clear(); | 345 list.clear(); |
346 | 346 |
347 // Draw a smaller magenta rect without filling the viewport in a separate | 347 // Draw a smaller magenta rect without filling the viewport in a separate |
348 // frame. | 348 // frame. |
349 gfx::Rect smaller_rect(20, 20, 60, 60); | 349 gfx::Rect smaller_rect(20, 20, 60, 60); |
350 | 350 |
351 RenderPassId root_smaller_pass_id(2, 0); | 351 RenderPassId root_smaller_pass_id(2, 0); |
352 TestRenderPass* root_smaller_pass = AddRenderPass( | 352 TestRenderPass* root_smaller_pass = AddRenderPass( |
353 &list, root_smaller_pass_id, device_viewport_rect, gfx::Transform()); | 353 &list, root_smaller_pass_id, device_viewport_rect, gfx::Transform()); |
354 AddQuad(root_smaller_pass, smaller_rect, SK_ColorMAGENTA); | 354 AddQuad(root_smaller_pass, smaller_rect, SK_ColorMAGENTA); |
355 | 355 |
356 renderer()->DecideRenderPassAllocationsForFrame(list); | 356 renderer()->DecideRenderPassAllocationsForFrame(list); |
357 | 357 |
358 output = DrawAndCopyOutput(&list, device_scale_factor, device_viewport_rect); | 358 output = DrawAndCopyOutput(&list, device_scale_factor, device_viewport_rect); |
359 EXPECT_EQ(device_viewport_rect.width(), output->info().fWidth); | 359 EXPECT_EQ(device_viewport_rect.width(), output->info().width()); |
360 EXPECT_EQ(device_viewport_rect.height(), output->info().fHeight); | 360 EXPECT_EQ(device_viewport_rect.height(), output->info().height()); |
361 | 361 |
362 // If we didn't clear, the borders should still be green. | 362 // If we didn't clear, the borders should still be green. |
363 EXPECT_EQ(SK_ColorGREEN, output->getColor(0, 0)); | 363 EXPECT_EQ(SK_ColorGREEN, output->getColor(0, 0)); |
364 EXPECT_EQ(SK_ColorGREEN, | 364 EXPECT_EQ(SK_ColorGREEN, |
365 output->getColor(device_viewport_rect.width() - 1, | 365 output->getColor(device_viewport_rect.width() - 1, |
366 device_viewport_rect.height() - 1)); | 366 device_viewport_rect.height() - 1)); |
367 | 367 |
368 EXPECT_EQ(SK_ColorMAGENTA, | 368 EXPECT_EQ(SK_ColorMAGENTA, |
369 output->getColor(smaller_rect.x(), smaller_rect.y())); | 369 output->getColor(smaller_rect.x(), smaller_rect.y())); |
370 EXPECT_EQ( | 370 EXPECT_EQ( |
(...skipping 23 matching lines...) Expand all Loading... |
394 AddQuad(root_clear_pass, device_viewport_rect, SK_ColorGREEN); | 394 AddQuad(root_clear_pass, device_viewport_rect, SK_ColorGREEN); |
395 | 395 |
396 // Interior pass quad has smaller visible rect. | 396 // Interior pass quad has smaller visible rect. |
397 gfx::Rect interior_visible_rect(30, 30, 40, 40); | 397 gfx::Rect interior_visible_rect(30, 30, 40, 40); |
398 root_clear_pass->quad_list.front()->visible_rect = interior_visible_rect; | 398 root_clear_pass->quad_list.front()->visible_rect = interior_visible_rect; |
399 | 399 |
400 renderer()->DecideRenderPassAllocationsForFrame(list); | 400 renderer()->DecideRenderPassAllocationsForFrame(list); |
401 | 401 |
402 scoped_ptr<SkBitmap> output = | 402 scoped_ptr<SkBitmap> output = |
403 DrawAndCopyOutput(&list, device_scale_factor, device_viewport_rect); | 403 DrawAndCopyOutput(&list, device_scale_factor, device_viewport_rect); |
404 EXPECT_EQ(device_viewport_rect.width(), output->info().fWidth); | 404 EXPECT_EQ(device_viewport_rect.width(), output->info().width()); |
405 EXPECT_EQ(device_viewport_rect.height(), output->info().fHeight); | 405 EXPECT_EQ(device_viewport_rect.height(), output->info().height()); |
406 | 406 |
407 EXPECT_EQ(SK_ColorGREEN, output->getColor(0, 0)); | 407 EXPECT_EQ(SK_ColorGREEN, output->getColor(0, 0)); |
408 EXPECT_EQ(SK_ColorGREEN, | 408 EXPECT_EQ(SK_ColorGREEN, |
409 output->getColor(device_viewport_rect.width() - 1, | 409 output->getColor(device_viewport_rect.width() - 1, |
410 device_viewport_rect.height() - 1)); | 410 device_viewport_rect.height() - 1)); |
411 | 411 |
412 // Part outside visible rect should remain green. | 412 // Part outside visible rect should remain green. |
413 EXPECT_EQ(SK_ColorGREEN, | 413 EXPECT_EQ(SK_ColorGREEN, |
414 output->getColor(smaller_rect.x(), smaller_rect.y())); | 414 output->getColor(smaller_rect.x(), smaller_rect.y())); |
415 EXPECT_EQ( | 415 EXPECT_EQ( |
416 SK_ColorGREEN, | 416 SK_ColorGREEN, |
417 output->getColor(smaller_rect.right() - 1, smaller_rect.bottom() - 1)); | 417 output->getColor(smaller_rect.right() - 1, smaller_rect.bottom() - 1)); |
418 | 418 |
419 EXPECT_EQ( | 419 EXPECT_EQ( |
420 SK_ColorMAGENTA, | 420 SK_ColorMAGENTA, |
421 output->getColor(interior_visible_rect.x(), interior_visible_rect.y())); | 421 output->getColor(interior_visible_rect.x(), interior_visible_rect.y())); |
422 EXPECT_EQ(SK_ColorMAGENTA, | 422 EXPECT_EQ(SK_ColorMAGENTA, |
423 output->getColor(interior_visible_rect.right() - 1, | 423 output->getColor(interior_visible_rect.right() - 1, |
424 interior_visible_rect.bottom() - 1)); | 424 interior_visible_rect.bottom() - 1)); |
425 } | 425 } |
426 | 426 |
427 } // namespace | 427 } // namespace |
428 } // namespace cc | 428 } // namespace cc |
OLD | NEW |