| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "cc/base/region.h" | 8 #include "cc/base/region.h" |
| 9 #include "cc/playback/raster_source.h" | 9 #include "cc/playback/raster_source.h" |
| 10 #include "cc/test/fake_client_picture_cache.h" | 10 #include "cc/test/fake_client_picture_cache.h" |
| 11 #include "cc/test/fake_content_layer_client.h" | 11 #include "cc/test/fake_content_layer_client.h" |
| 12 #include "cc/test/fake_engine_picture_cache.h" | 12 #include "cc/test/fake_engine_picture_cache.h" |
| 13 #include "cc/test/fake_image_serialization_processor.h" | 13 #include "cc/test/fake_image_serialization_processor.h" |
| 14 #include "cc/test/fake_recording_source.h" | 14 #include "cc/test/fake_recording_source.h" |
| 15 #include "cc/test/skia_common.h" | 15 #include "cc/test/skia_common.h" |
| 16 #include "skia/ext/cdl_paint.h" |
| 16 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "third_party/skia/include/core/SkRefCnt.h" | 19 #include "third_party/skia/include/core/SkRefCnt.h" |
| 19 | 20 |
| 20 namespace cc { | 21 namespace cc { |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 std::unique_ptr<FakeRecordingSource> CreateRecordingSource( | 24 std::unique_ptr<FakeRecordingSource> CreateRecordingSource( |
| 24 const gfx::Rect& viewport) { | 25 const gfx::Rect& viewport) { |
| 25 gfx::Rect layer_rect(viewport.right(), viewport.bottom()); | 26 gfx::Rect layer_rect(viewport.right(), viewport.bottom()); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 EXPECT_TRUE(images.empty()); | 183 EXPECT_TRUE(images.empty()); |
| 183 } | 184 } |
| 184 } | 185 } |
| 185 | 186 |
| 186 TEST(RecordingSourceTest, NoDiscardableImages) { | 187 TEST(RecordingSourceTest, NoDiscardableImages) { |
| 187 gfx::Rect recorded_viewport(0, 0, 256, 256); | 188 gfx::Rect recorded_viewport(0, 0, 256, 256); |
| 188 | 189 |
| 189 std::unique_ptr<FakeRecordingSource> recording_source = | 190 std::unique_ptr<FakeRecordingSource> recording_source = |
| 190 CreateRecordingSource(recorded_viewport); | 191 CreateRecordingSource(recorded_viewport); |
| 191 | 192 |
| 192 SkPaint simple_paint; | 193 CdlPaint simple_paint; |
| 193 simple_paint.setColor(SkColorSetARGB(255, 12, 23, 34)); | 194 simple_paint.setColor(SkColorSetARGB(255, 12, 23, 34)); |
| 194 | 195 |
| 195 SkBitmap non_discardable_bitmap; | 196 SkBitmap non_discardable_bitmap; |
| 196 non_discardable_bitmap.allocN32Pixels(128, 128); | 197 non_discardable_bitmap.allocN32Pixels(128, 128); |
| 197 non_discardable_bitmap.setImmutable(); | 198 non_discardable_bitmap.setImmutable(); |
| 198 sk_sp<SkImage> non_discardable_image = | 199 sk_sp<SkImage> non_discardable_image = |
| 199 SkImage::MakeFromBitmap(non_discardable_bitmap); | 200 SkImage::MakeFromBitmap(non_discardable_bitmap); |
| 200 | 201 |
| 201 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 256, 256), | 202 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 256, 256), |
| 202 simple_paint); | 203 simple_paint); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 gfx::SizeF(1.f, 1.f), &images); | 369 gfx::SizeF(1.f, 1.f), &images); |
| 369 EXPECT_EQ(3u, images.size()); | 370 EXPECT_EQ(3u, images.size()); |
| 370 EXPECT_TRUE(images[0].image() == discardable_image[0][0]); | 371 EXPECT_TRUE(images[0].image() == discardable_image[0][0]); |
| 371 EXPECT_TRUE(images[1].image() == discardable_image[0][1]); | 372 EXPECT_TRUE(images[1].image() == discardable_image[0][1]); |
| 372 EXPECT_TRUE(images[2].image() == discardable_image[1][1]); | 373 EXPECT_TRUE(images[2].image() == discardable_image[1][1]); |
| 373 } | 374 } |
| 374 } | 375 } |
| 375 | 376 |
| 376 } // namespace | 377 } // namespace |
| 377 } // namespace cc | 378 } // namespace cc |
| OLD | NEW |