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" | |
danakj
2016/04/14 19:37:32
we should technically be including SkRefCnt.h in e
tomhudson
2016/04/25 20:48:13
Done.
| |
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" |
17 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
18 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
19 | 18 |
20 class SkImage; | 19 class SkImage; |
21 | 20 |
22 namespace cc { | 21 namespace cc { |
23 | 22 |
24 // Helper function to apply the matrix to the rect and return the result. | 23 // Helper function to apply the matrix to the rect and return the result. |
25 SkRect MapRect(const SkMatrix& matrix, const SkRect& src); | 24 SkRect MapRect(const SkMatrix& matrix, const SkRect& src); |
26 | 25 |
27 // This class is used for generating discardable images data (see DrawImage | 26 // 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 | 27 // 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. | 28 // rect and get back a list of DrawImages in that rect. |
30 class CC_EXPORT DiscardableImageMap { | 29 class CC_EXPORT DiscardableImageMap { |
31 public: | 30 public: |
32 class CC_EXPORT ScopedMetadataGenerator { | 31 class CC_EXPORT ScopedMetadataGenerator { |
33 public: | 32 public: |
34 ScopedMetadataGenerator(DiscardableImageMap* image_map, | 33 ScopedMetadataGenerator(DiscardableImageMap* image_map, |
35 const gfx::Size& bounds); | 34 const gfx::Size& bounds); |
36 ~ScopedMetadataGenerator(); | 35 ~ScopedMetadataGenerator(); |
37 | 36 |
38 SkCanvas* canvas() { return metadata_canvas_.get(); } | 37 SkCanvas* canvas() { return metadata_canvas_.get(); } |
39 | 38 |
40 private: | 39 private: |
41 DiscardableImageMap* image_map_; | 40 DiscardableImageMap* image_map_; |
42 skia::RefPtr<SkCanvas> metadata_canvas_; | 41 sk_sp<SkCanvas> metadata_canvas_; |
43 }; | 42 }; |
44 | 43 |
45 DiscardableImageMap(); | 44 DiscardableImageMap(); |
46 ~DiscardableImageMap(); | 45 ~DiscardableImageMap(); |
47 | 46 |
48 bool empty() const { return all_images_.empty(); } | 47 bool empty() const { return all_images_.empty(); } |
49 void GetDiscardableImagesInRect(const gfx::Rect& rect, | 48 void GetDiscardableImagesInRect(const gfx::Rect& rect, |
50 float raster_scale, | 49 float raster_scale, |
51 std::vector<DrawImage>* images) const; | 50 std::vector<DrawImage>* images) const; |
52 | 51 |
53 private: | 52 private: |
54 friend class ScopedMetadataGenerator; | 53 friend class ScopedMetadataGenerator; |
55 friend class DiscardableImageMapTest; | 54 friend class DiscardableImageMapTest; |
56 | 55 |
57 skia::RefPtr<SkCanvas> BeginGeneratingMetadata(const gfx::Size& bounds); | 56 sk_sp<SkCanvas> BeginGeneratingMetadata(const gfx::Size& bounds); |
58 void EndGeneratingMetadata(); | 57 void EndGeneratingMetadata(); |
59 | 58 |
60 std::vector<std::pair<DrawImage, gfx::Rect>> all_images_; | 59 std::vector<std::pair<DrawImage, gfx::Rect>> all_images_; |
61 RTree images_rtree_; | 60 RTree images_rtree_; |
62 }; | 61 }; |
63 | 62 |
64 } // namespace cc | 63 } // namespace cc |
65 | 64 |
66 #endif // CC_PLAYBACK_DISCARDABLE_IMAGE_MAP_H_ | 65 #endif // CC_PLAYBACK_DISCARDABLE_IMAGE_MAP_H_ |
OLD | NEW |