| 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 "cc/playback/raster_source.h" | 5 #include "cc/playback/raster_source.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "cc/test/fake_recording_source.h" | 11 #include "cc/test/fake_recording_source.h" |
| 12 #include "cc/test/skia_common.h" | 12 #include "cc/test/skia_common.h" |
| 13 #include "cc/tiles/software_image_decode_controller.h" | 13 #include "cc/tiles/software_image_decode_cache.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "third_party/skia/include/core/SkPixelRef.h" | 15 #include "third_party/skia/include/core/SkPixelRef.h" |
| 16 #include "third_party/skia/include/core/SkRefCnt.h" | 16 #include "third_party/skia/include/core/SkRefCnt.h" |
| 17 #include "third_party/skia/include/core/SkShader.h" | 17 #include "third_party/skia/include/core/SkShader.h" |
| 18 #include "ui/gfx/geometry/rect.h" | 18 #include "ui/gfx/geometry/rect.h" |
| 19 #include "ui/gfx/geometry/size_conversions.h" | 19 #include "ui/gfx/geometry/size_conversions.h" |
| 20 | 20 |
| 21 namespace cc { | 21 namespace cc { |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 gfx::Rect(0, size.height() - 4, 4, 4), paint); | 574 gfx::Rect(0, size.height() - 4, 4, 4), paint); |
| 575 recording_source->add_draw_rect_with_paint( | 575 recording_source->add_draw_rect_with_paint( |
| 576 gfx::Rect(size.width() - 4, size.height() - 4, 4, 4), paint); | 576 gfx::Rect(size.width() - 4, size.height() - 4, 4, 4), paint); |
| 577 | 577 |
| 578 recording_source->SetGenerateDiscardableImagesMetadata(true); | 578 recording_source->SetGenerateDiscardableImagesMetadata(true); |
| 579 recording_source->Rerecord(); | 579 recording_source->Rerecord(); |
| 580 | 580 |
| 581 bool can_use_lcd = true; | 581 bool can_use_lcd = true; |
| 582 scoped_refptr<RasterSource> raster_source = | 582 scoped_refptr<RasterSource> raster_source = |
| 583 recording_source->CreateRasterSource(can_use_lcd); | 583 recording_source->CreateRasterSource(can_use_lcd); |
| 584 SoftwareImageDecodeController controller( | 584 SoftwareImageDecodeCache controller( |
| 585 ResourceFormat::RGBA_8888, | 585 ResourceFormat::RGBA_8888, |
| 586 LayerTreeSettings().software_decoded_image_budget_bytes); | 586 LayerTreeSettings().software_decoded_image_budget_bytes); |
| 587 raster_source->set_image_decode_controller(&controller); | 587 raster_source->set_image_decode_cache(&controller); |
| 588 | 588 |
| 589 SkBitmap bitmap; | 589 SkBitmap bitmap; |
| 590 bitmap.allocN32Pixels(size.width() * 0.5f, size.height() * 0.25f); | 590 bitmap.allocN32Pixels(size.width() * 0.5f, size.height() * 0.25f); |
| 591 SkCanvas canvas(bitmap); | 591 SkCanvas canvas(bitmap); |
| 592 canvas.scale(0.5f, 0.25f); | 592 canvas.scale(0.5f, 0.25f); |
| 593 | 593 |
| 594 RasterSource::PlaybackSettings settings; | 594 RasterSource::PlaybackSettings settings; |
| 595 settings.playback_to_shared_canvas = true; | 595 settings.playback_to_shared_canvas = true; |
| 596 settings.use_image_hijack_canvas = true; | 596 settings.use_image_hijack_canvas = true; |
| 597 raster_source->PlaybackToCanvas(&canvas, gfx::Rect(size), gfx::Rect(size), | 597 raster_source->PlaybackToCanvas(&canvas, gfx::Rect(size), gfx::Rect(size), |
| 598 gfx::SizeF(1.f, 1.f), settings); | 598 gfx::SizeF(1.f, 1.f), settings); |
| 599 | 599 |
| 600 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(0, 0)); | 600 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(0, 0)); |
| 601 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(49, 0)); | 601 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(49, 0)); |
| 602 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(0, 24)); | 602 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(0, 24)); |
| 603 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(49, 24)); | 603 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(49, 24)); |
| 604 for (int x = 0; x < 49; ++x) | 604 for (int x = 0; x < 49; ++x) |
| 605 EXPECT_EQ(SK_ColorRED, bitmap.getColor(x, 12)); | 605 EXPECT_EQ(SK_ColorRED, bitmap.getColor(x, 12)); |
| 606 for (int y = 0; y < 24; ++y) | 606 for (int y = 0; y < 24; ++y) |
| 607 EXPECT_EQ(SK_ColorRED, bitmap.getColor(24, y)); | 607 EXPECT_EQ(SK_ColorRED, bitmap.getColor(24, y)); |
| 608 } | 608 } |
| 609 | 609 |
| 610 } // namespace | 610 } // namespace |
| 611 } // namespace cc | 611 } // namespace cc |
| OLD | NEW |