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 #ifndef CC_PLAYBACK_DISCARDABLE_IMAGE_MAP_H_ | 5 #ifndef CC_PLAYBACK_DISCARDABLE_IMAGE_MAP_H_ |
6 #define CC_PLAYBACK_DISCARDABLE_IMAGE_MAP_H_ | 6 #define CC_PLAYBACK_DISCARDABLE_IMAGE_MAP_H_ |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
12 #include "cc/base/rtree.h" | 12 #include "cc/base/rtree.h" |
13 #include "cc/playback/draw_image.h" | 13 #include "cc/playback/draw_image.h" |
14 #include "skia/ext/refptr.h" | |
15 #include "third_party/skia/include/core/SkCanvas.h" | 14 #include "third_party/skia/include/core/SkCanvas.h" |
16 #include "third_party/skia/include/core/SkPicture.h" | 15 #include "third_party/skia/include/core/SkPicture.h" |
| 16 #include "third_party/skia/include/core/SkRefCnt.h" |
17 #include "ui/gfx/geometry/rect.h" | 17 #include "ui/gfx/geometry/rect.h" |
18 #include "ui/gfx/geometry/size.h" | 18 #include "ui/gfx/geometry/size.h" |
19 | 19 |
20 class SkImage; | 20 class SkImage; |
21 | 21 |
22 namespace cc { | 22 namespace cc { |
23 | 23 |
24 // Helper function to apply the matrix to the rect and return the result. | 24 // Helper function to apply the matrix to the rect and return the result. |
25 SkRect MapRect(const SkMatrix& matrix, const SkRect& src); | 25 SkRect MapRect(const SkMatrix& matrix, const SkRect& src); |
26 | 26 |
27 // This class is used for generating discardable images data (see DrawImage | 27 // This class is used for generating discardable images data (see DrawImage |
28 // for the type of data it stores). It allows the client to query a particular | 28 // for the type of data it stores). It allows the client to query a particular |
29 // rect and get back a list of DrawImages in that rect. | 29 // rect and get back a list of DrawImages in that rect. |
30 class CC_EXPORT DiscardableImageMap { | 30 class CC_EXPORT DiscardableImageMap { |
31 public: | 31 public: |
32 class CC_EXPORT ScopedMetadataGenerator { | 32 class CC_EXPORT ScopedMetadataGenerator { |
33 public: | 33 public: |
34 ScopedMetadataGenerator(DiscardableImageMap* image_map, | 34 ScopedMetadataGenerator(DiscardableImageMap* image_map, |
35 const gfx::Size& bounds); | 35 const gfx::Size& bounds); |
36 ~ScopedMetadataGenerator(); | 36 ~ScopedMetadataGenerator(); |
37 | 37 |
38 SkCanvas* canvas() { return metadata_canvas_.get(); } | 38 SkCanvas* canvas() { return metadata_canvas_.get(); } |
39 | 39 |
40 private: | 40 private: |
41 DiscardableImageMap* image_map_; | 41 DiscardableImageMap* image_map_; |
42 skia::RefPtr<SkCanvas> metadata_canvas_; | 42 sk_sp<SkCanvas> metadata_canvas_; |
43 }; | 43 }; |
44 | 44 |
45 DiscardableImageMap(); | 45 DiscardableImageMap(); |
46 ~DiscardableImageMap(); | 46 ~DiscardableImageMap(); |
47 | 47 |
48 bool empty() const { return all_images_.empty(); } | 48 bool empty() const { return all_images_.empty(); } |
49 void GetDiscardableImagesInRect(const gfx::Rect& rect, | 49 void GetDiscardableImagesInRect(const gfx::Rect& rect, |
50 float raster_scale, | 50 float raster_scale, |
51 std::vector<DrawImage>* images) const; | 51 std::vector<DrawImage>* images) const; |
52 | 52 |
53 private: | 53 private: |
54 friend class ScopedMetadataGenerator; | 54 friend class ScopedMetadataGenerator; |
55 friend class DiscardableImageMapTest; | 55 friend class DiscardableImageMapTest; |
56 | 56 |
57 skia::RefPtr<SkCanvas> BeginGeneratingMetadata(const gfx::Size& bounds); | 57 sk_sp<SkCanvas> BeginGeneratingMetadata(const gfx::Size& bounds); |
58 void EndGeneratingMetadata(); | 58 void EndGeneratingMetadata(); |
59 | 59 |
60 std::vector<std::pair<DrawImage, gfx::Rect>> all_images_; | 60 std::vector<std::pair<DrawImage, gfx::Rect>> all_images_; |
61 RTree images_rtree_; | 61 RTree images_rtree_; |
62 }; | 62 }; |
63 | 63 |
64 } // namespace cc | 64 } // namespace cc |
65 | 65 |
66 #endif // CC_PLAYBACK_DISCARDABLE_IMAGE_MAP_H_ | 66 #endif // CC_PLAYBACK_DISCARDABLE_IMAGE_MAP_H_ |
OLD | NEW |