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 "skia/ext/refptr.h" | |
14 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "third_party/skia/include/core/SkPixelRef.h" | 14 #include "third_party/skia/include/core/SkPixelRef.h" |
16 #include "third_party/skia/include/core/SkShader.h" | 15 #include "third_party/skia/include/core/SkShader.h" |
17 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
18 #include "ui/gfx/geometry/size_conversions.h" | 17 #include "ui/gfx/geometry/size_conversions.h" |
19 | 18 |
20 namespace cc { | 19 namespace cc { |
21 namespace { | 20 namespace { |
22 | 21 |
23 TEST(RasterSourceTest, AnalyzeIsSolidUnscaled) { | 22 TEST(RasterSourceTest, AnalyzeIsSolidUnscaled) { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 EXPECT_TRUE(is_solid_color); | 178 EXPECT_TRUE(is_solid_color); |
180 EXPECT_EQ(color, SkColorSetARGB(0, 0, 0, 0)); | 179 EXPECT_EQ(color, SkColorSetARGB(0, 0, 0, 0)); |
181 } | 180 } |
182 | 181 |
183 TEST(RasterSourceTest, PixelRefIteratorDiscardableRefsOneTile) { | 182 TEST(RasterSourceTest, PixelRefIteratorDiscardableRefsOneTile) { |
184 gfx::Size layer_bounds(512, 512); | 183 gfx::Size layer_bounds(512, 512); |
185 | 184 |
186 std::unique_ptr<FakeRecordingSource> recording_source = | 185 std::unique_ptr<FakeRecordingSource> recording_source = |
187 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); | 186 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); |
188 | 187 |
189 skia::RefPtr<SkImage> discardable_image[2][2]; | 188 sk_sp<SkImage> discardable_image[2][2]; |
190 discardable_image[0][0] = CreateDiscardableImage(gfx::Size(32, 32)); | 189 discardable_image[0][0] = CreateDiscardableImage(gfx::Size(32, 32)); |
191 discardable_image[0][1] = CreateDiscardableImage(gfx::Size(32, 32)); | 190 discardable_image[0][1] = CreateDiscardableImage(gfx::Size(32, 32)); |
192 discardable_image[1][1] = CreateDiscardableImage(gfx::Size(32, 32)); | 191 discardable_image[1][1] = CreateDiscardableImage(gfx::Size(32, 32)); |
193 | 192 |
194 // Discardable pixel refs are found in the following cells: | 193 // Discardable pixel refs are found in the following cells: |
195 // |---|---| | 194 // |---|---| |
196 // | x | x | | 195 // | x | x | |
197 // |---|---| | 196 // |---|---| |
198 // | | x | | 197 // | | x | |
199 // |---|---| | 198 // |---|---| |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 | 532 |
534 scoped_refptr<RasterSource> raster = | 533 scoped_refptr<RasterSource> raster = |
535 RasterSource::CreateFromRecordingSource(recording_source.get(), false); | 534 RasterSource::CreateFromRecordingSource(recording_source.get(), false); |
536 size_t total_memory_usage = raster->GetPictureMemoryUsage(); | 535 size_t total_memory_usage = raster->GetPictureMemoryUsage(); |
537 EXPECT_GE(total_memory_usage, kReportedMemoryUsageInBytes); | 536 EXPECT_GE(total_memory_usage, kReportedMemoryUsageInBytes); |
538 EXPECT_LT(total_memory_usage, 2 * kReportedMemoryUsageInBytes); | 537 EXPECT_LT(total_memory_usage, 2 * kReportedMemoryUsageInBytes); |
539 } | 538 } |
540 | 539 |
541 } // namespace | 540 } // namespace |
542 } // namespace cc | 541 } // namespace cc |
OLD | NEW |