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 "cc/playback/discardable_image_map.h" | 5 #include "cc/playback/discardable_image_map.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
| 9 #include <memory> |
| 10 |
9 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/values.h" | 12 #include "base/values.h" |
12 #include "cc/base/region.h" | 13 #include "cc/base/region.h" |
13 #include "cc/test/fake_content_layer_client.h" | 14 #include "cc/test/fake_content_layer_client.h" |
14 #include "cc/test/fake_recording_source.h" | 15 #include "cc/test/fake_recording_source.h" |
15 #include "cc/test/skia_common.h" | 16 #include "cc/test/skia_common.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "third_party/skia/include/core/SkCanvas.h" | 18 #include "third_party/skia/include/core/SkCanvas.h" |
18 #include "third_party/skia/include/core/SkGraphics.h" | 19 #include "third_party/skia/include/core/SkGraphics.h" |
19 #include "third_party/skia/include/core/SkImageGenerator.h" | 20 #include "third_party/skia/include/core/SkImageGenerator.h" |
20 #include "ui/gfx/geometry/rect.h" | 21 #include "ui/gfx/geometry/rect.h" |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 content_layer_client.set_bounds(visible_rect.size()); | 332 content_layer_client.set_bounds(visible_rect.size()); |
332 | 333 |
333 skia::RefPtr<SkImage> discardable_image; | 334 skia::RefPtr<SkImage> discardable_image; |
334 discardable_image = CreateDiscardableImage(gfx::Size(10, 10)); | 335 discardable_image = CreateDiscardableImage(gfx::Size(10, 10)); |
335 | 336 |
336 DiscardableImageMap image_map; | 337 DiscardableImageMap image_map; |
337 { | 338 { |
338 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, | 339 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, |
339 visible_rect.size()); | 340 visible_rect.size()); |
340 { | 341 { |
341 scoped_ptr<SkPaint> paint(new SkPaint()); | 342 std::unique_ptr<SkPaint> paint(new SkPaint()); |
342 generator.canvas()->saveLayer(gfx::RectToSkRect(visible_rect), | 343 generator.canvas()->saveLayer(gfx::RectToSkRect(visible_rect), |
343 paint.get()); | 344 paint.get()); |
344 } | 345 } |
345 generator.canvas()->drawImage(discardable_image.get(), 0, 0, nullptr); | 346 generator.canvas()->drawImage(discardable_image.get(), 0, 0, nullptr); |
346 generator.canvas()->restore(); | 347 generator.canvas()->restore(); |
347 } | 348 } |
348 | 349 |
349 std::vector<PositionDrawImage> images = | 350 std::vector<PositionDrawImage> images = |
350 GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1, 1)); | 351 GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1, 1)); |
351 EXPECT_EQ(1u, images.size()); | 352 EXPECT_EQ(1u, images.size()); |
352 EXPECT_TRUE(images[0].image == discardable_image.get()); | 353 EXPECT_TRUE(images[0].image == discardable_image.get()); |
353 } | 354 } |
354 | 355 |
355 } // namespace cc | 356 } // namespace cc |
OLD | NEW |