OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "cc/test/fake_picture_pile_impl.h" | 6 #include "cc/test/fake_picture_pile_impl.h" |
7 #include "cc/test/skia_common.h" | 7 #include "cc/test/skia_common.h" |
8 #include "skia/ext/refptr.h" | 8 #include "skia/ext/refptr.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "third_party/skia/include/core/SkPixelRef.h" | 10 #include "third_party/skia/include/core/SkPixelRef.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 white_paint.setColor(SK_ColorWHITE); | 285 white_paint.setColor(SK_ColorWHITE); |
286 recording_source->add_draw_rect_with_paint(gfx::Rect(layer_bounds), | 286 recording_source->add_draw_rect_with_paint(gfx::Rect(layer_bounds), |
287 white_paint); | 287 white_paint); |
288 | 288 |
289 recording_source->SetMinContentsScale(contents_scale); | 289 recording_source->SetMinContentsScale(contents_scale); |
290 recording_source->Rerecord(); | 290 recording_source->Rerecord(); |
291 | 291 |
292 scoped_refptr<FakePicturePileImpl> pile = | 292 scoped_refptr<FakePicturePileImpl> pile = |
293 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); | 293 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); |
294 | 294 |
295 gfx::Size content_bounds( | 295 gfx::Size content_bounds = |
296 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale))); | 296 gfx::ScaleToCeiledSize(layer_bounds, contents_scale); |
297 | 297 |
298 // Simulate drawing into different tiles at different offsets. | 298 // Simulate drawing into different tiles at different offsets. |
299 int step_x = std::ceil(content_bounds.width() / raster_divisions); | 299 int step_x = std::ceil(content_bounds.width() / raster_divisions); |
300 int step_y = std::ceil(content_bounds.height() / raster_divisions); | 300 int step_y = std::ceil(content_bounds.height() / raster_divisions); |
301 for (int offset_x = 0; offset_x < content_bounds.width(); | 301 for (int offset_x = 0; offset_x < content_bounds.width(); |
302 offset_x += step_x) { | 302 offset_x += step_x) { |
303 for (int offset_y = 0; offset_y < content_bounds.height(); | 303 for (int offset_y = 0; offset_y < content_bounds.height(); |
304 offset_y += step_y) { | 304 offset_y += step_y) { |
305 gfx::Rect content_rect(offset_x, offset_y, step_x, step_y); | 305 gfx::Rect content_rect(offset_x, offset_y, step_x, step_y); |
306 content_rect.Intersect(gfx::Rect(content_bounds)); | 306 content_rect.Intersect(gfx::Rect(content_bounds)); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 scoped_ptr<FakePicturePile> recording_source = | 344 scoped_ptr<FakePicturePile> recording_source = |
345 FakePicturePile::CreateFilledPile(tile_size, layer_bounds); | 345 FakePicturePile::CreateFilledPile(tile_size, layer_bounds); |
346 recording_source->SetBackgroundColor(SK_ColorTRANSPARENT); | 346 recording_source->SetBackgroundColor(SK_ColorTRANSPARENT); |
347 recording_source->SetRequiresClear(true); | 347 recording_source->SetRequiresClear(true); |
348 recording_source->SetMinContentsScale(contents_scale); | 348 recording_source->SetMinContentsScale(contents_scale); |
349 recording_source->SetClearCanvasWithDebugColor(false); | 349 recording_source->SetClearCanvasWithDebugColor(false); |
350 recording_source->Rerecord(); | 350 recording_source->Rerecord(); |
351 | 351 |
352 scoped_refptr<FakePicturePileImpl> pile = | 352 scoped_refptr<FakePicturePileImpl> pile = |
353 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); | 353 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); |
354 gfx::Size content_bounds( | 354 gfx::Size content_bounds = |
355 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale))); | 355 gfx::ScaleToCeiledSize(layer_bounds, contents_scale); |
356 | 356 |
357 gfx::Rect canvas_rect(content_bounds); | 357 gfx::Rect canvas_rect(content_bounds); |
358 canvas_rect.Inset(0, 0, -1, -1); | 358 canvas_rect.Inset(0, 0, -1, -1); |
359 | 359 |
360 SkBitmap bitmap; | 360 SkBitmap bitmap; |
361 bitmap.allocN32Pixels(canvas_rect.width(), canvas_rect.height()); | 361 bitmap.allocN32Pixels(canvas_rect.width(), canvas_rect.height()); |
362 SkCanvas canvas(bitmap); | 362 SkCanvas canvas(bitmap); |
363 | 363 |
364 pile->PlaybackToCanvas(&canvas, canvas_rect, canvas_rect, contents_scale); | 364 pile->PlaybackToCanvas(&canvas, canvas_rect, canvas_rect, contents_scale); |
365 | 365 |
(...skipping 28 matching lines...) Expand all Loading... |
394 color_paint.setColor(test_color); | 394 color_paint.setColor(test_color); |
395 // Additive paint, so that if two paints overlap, the color will change. | 395 // Additive paint, so that if two paints overlap, the color will change. |
396 color_paint.setXfermodeMode(SkXfermode::kPlus_Mode); | 396 color_paint.setXfermodeMode(SkXfermode::kPlus_Mode); |
397 // Paint outside the layer to make sure that blending works. | 397 // Paint outside the layer to make sure that blending works. |
398 recording_source->add_draw_rect_with_paint( | 398 recording_source->add_draw_rect_with_paint( |
399 gfx::Rect(bigger_than_layer_bounds), color_paint); | 399 gfx::Rect(bigger_than_layer_bounds), color_paint); |
400 recording_source->Rerecord(); | 400 recording_source->Rerecord(); |
401 | 401 |
402 scoped_refptr<FakePicturePileImpl> pile = | 402 scoped_refptr<FakePicturePileImpl> pile = |
403 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); | 403 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); |
404 gfx::Size content_bounds( | 404 gfx::Size content_bounds = |
405 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale))); | 405 gfx::ScaleToCeiledSize(layer_bounds, contents_scale); |
406 | 406 |
407 SkBitmap bitmap; | 407 SkBitmap bitmap; |
408 bitmap.allocN32Pixels(content_bounds.width(), content_bounds.height()); | 408 bitmap.allocN32Pixels(content_bounds.width(), content_bounds.height()); |
409 SkCanvas canvas(bitmap); | 409 SkCanvas canvas(bitmap); |
410 | 410 |
411 pile->PlaybackToCanvas(&canvas, gfx::Rect(content_bounds), | 411 pile->PlaybackToCanvas(&canvas, gfx::Rect(content_bounds), |
412 gfx::Rect(content_bounds), contents_scale); | 412 gfx::Rect(content_bounds), contents_scale); |
413 | 413 |
414 for (int y = 0; y < bitmap.height(); y++) { | 414 for (int y = 0; y < bitmap.height(); y++) { |
415 for (int x = 0; x < bitmap.width(); x++) { | 415 for (int x = 0; x < bitmap.width(); x++) { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 EXPECT_TRUE(++iterator); | 531 EXPECT_TRUE(++iterator); |
532 EXPECT_TRUE(iterator->image == discardable_image[2].get()); | 532 EXPECT_TRUE(iterator->image == discardable_image[2].get()); |
533 EXPECT_EQ(expected_rects[2].ToString(), | 533 EXPECT_EQ(expected_rects[2].ToString(), |
534 gfx::SkRectToRectF(iterator->image_rect).ToString()); | 534 gfx::SkRectToRectF(iterator->image_rect).ToString()); |
535 EXPECT_FALSE(++iterator); | 535 EXPECT_FALSE(++iterator); |
536 } | 536 } |
537 } | 537 } |
538 | 538 |
539 } // namespace | 539 } // namespace |
540 } // namespace cc | 540 } // namespace cc |
OLD | NEW |