| 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_controller.h" |
| 14 #include "skia/ext/refptr.h" | |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "third_party/skia/include/core/SkPixelRef.h" | 15 #include "third_party/skia/include/core/SkPixelRef.h" |
| 17 #include "third_party/skia/include/core/SkShader.h" | 16 #include "third_party/skia/include/core/SkShader.h" |
| 18 #include "ui/gfx/geometry/rect.h" | 17 #include "ui/gfx/geometry/rect.h" |
| 19 #include "ui/gfx/geometry/size_conversions.h" | 18 #include "ui/gfx/geometry/size_conversions.h" |
| 20 | 19 |
| 21 namespace cc { | 20 namespace cc { |
| 22 namespace { | 21 namespace { |
| 23 | 22 |
| 24 TEST(RasterSourceTest, AnalyzeIsSolidUnscaled) { | 23 TEST(RasterSourceTest, AnalyzeIsSolidUnscaled) { |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 EXPECT_TRUE(is_solid_color); | 179 EXPECT_TRUE(is_solid_color); |
| 181 EXPECT_EQ(color, SkColorSetARGB(0, 0, 0, 0)); | 180 EXPECT_EQ(color, SkColorSetARGB(0, 0, 0, 0)); |
| 182 } | 181 } |
| 183 | 182 |
| 184 TEST(RasterSourceTest, PixelRefIteratorDiscardableRefsOneTile) { | 183 TEST(RasterSourceTest, PixelRefIteratorDiscardableRefsOneTile) { |
| 185 gfx::Size layer_bounds(512, 512); | 184 gfx::Size layer_bounds(512, 512); |
| 186 | 185 |
| 187 std::unique_ptr<FakeRecordingSource> recording_source = | 186 std::unique_ptr<FakeRecordingSource> recording_source = |
| 188 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); | 187 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); |
| 189 | 188 |
| 190 skia::RefPtr<SkImage> discardable_image[2][2]; | 189 sk_sp<SkImage> discardable_image[2][2]; |
| 191 discardable_image[0][0] = CreateDiscardableImage(gfx::Size(32, 32)); | 190 discardable_image[0][0] = CreateDiscardableImage(gfx::Size(32, 32)); |
| 192 discardable_image[0][1] = CreateDiscardableImage(gfx::Size(32, 32)); | 191 discardable_image[0][1] = CreateDiscardableImage(gfx::Size(32, 32)); |
| 193 discardable_image[1][1] = CreateDiscardableImage(gfx::Size(32, 32)); | 192 discardable_image[1][1] = CreateDiscardableImage(gfx::Size(32, 32)); |
| 194 | 193 |
| 195 // Discardable pixel refs are found in the following cells: | 194 // Discardable pixel refs are found in the following cells: |
| 196 // |---|---| | 195 // |---|---| |
| 197 // | x | x | | 196 // | x | x | |
| 198 // |---|---| | 197 // |---|---| |
| 199 // | | x | | 198 // | | x | |
| 200 // |---|---| | 199 // |---|---| |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 gfx::Size size(100, 100); | 542 gfx::Size size(100, 100); |
| 544 | 543 |
| 545 // Create a recording source that is filled with red and every corner is | 544 // Create a recording source that is filled with red and every corner is |
| 546 // green (4x4 rects in the corner are green to account for blending when | 545 // green (4x4 rects in the corner are green to account for blending when |
| 547 // scaling). Note that we paint an image first, so that we can force image | 546 // scaling). Note that we paint an image first, so that we can force image |
| 548 // hijack canvas to be used. | 547 // hijack canvas to be used. |
| 549 std::unique_ptr<FakeRecordingSource> recording_source = | 548 std::unique_ptr<FakeRecordingSource> recording_source = |
| 550 FakeRecordingSource::CreateFilledRecordingSource(size); | 549 FakeRecordingSource::CreateFilledRecordingSource(size); |
| 551 | 550 |
| 552 // 1. Paint the image. | 551 // 1. Paint the image. |
| 553 skia::RefPtr<SkImage> image = CreateDiscardableImage(gfx::Size(5, 5)); | 552 sk_sp<SkImage> image = CreateDiscardableImage(gfx::Size(5, 5)); |
| 554 recording_source->add_draw_image(image.get(), gfx::Point(0, 0)); | 553 recording_source->add_draw_image(image.get(), gfx::Point(0, 0)); |
| 555 | 554 |
| 556 // 2. Cover everything in red. | 555 // 2. Cover everything in red. |
| 557 SkPaint paint; | 556 SkPaint paint; |
| 558 paint.setColor(SK_ColorRED); | 557 paint.setColor(SK_ColorRED); |
| 559 recording_source->add_draw_rect_with_paint(gfx::Rect(size), paint); | 558 recording_source->add_draw_rect_with_paint(gfx::Rect(size), paint); |
| 560 | 559 |
| 561 // 3. Draw 4x4 green rects into every corner. | 560 // 3. Draw 4x4 green rects into every corner. |
| 562 paint.setColor(SK_ColorGREEN); | 561 paint.setColor(SK_ColorGREEN); |
| 563 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 4, 4), paint); | 562 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 4, 4), paint); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 593 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(0, 24)); | 592 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(0, 24)); |
| 594 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(49, 24)); | 593 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(49, 24)); |
| 595 for (int x = 0; x < 49; ++x) | 594 for (int x = 0; x < 49; ++x) |
| 596 EXPECT_EQ(SK_ColorRED, bitmap.getColor(x, 12)); | 595 EXPECT_EQ(SK_ColorRED, bitmap.getColor(x, 12)); |
| 597 for (int y = 0; y < 24; ++y) | 596 for (int y = 0; y < 24; ++y) |
| 598 EXPECT_EQ(SK_ColorRED, bitmap.getColor(24, y)); | 597 EXPECT_EQ(SK_ColorRED, bitmap.getColor(24, y)); |
| 599 } | 598 } |
| 600 | 599 |
| 601 } // namespace | 600 } // namespace |
| 602 } // namespace cc | 601 } // namespace cc |
| OLD | NEW |