OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_PAINT_DISCARDABLE_IMAGE_STORE_H_ | 5 #ifndef CC_PAINT_DISCARDABLE_IMAGE_STORE_H_ |
6 #define CC_PAINT_DISCARDABLE_IMAGE_STORE_H_ | 6 #define CC_PAINT_DISCARDABLE_IMAGE_STORE_H_ |
7 | 7 |
8 #include "base/containers/flat_map.h" | 8 #include "base/containers/flat_map.h" |
9 #include "cc/paint/draw_image.h" | 9 #include "cc/paint/draw_image.h" |
10 #include "cc/paint/image_id.h" | 10 #include "cc/paint/image_id.h" |
11 #include "cc/paint/paint_export.h" | 11 #include "cc/paint/paint_export.h" |
12 #include "cc/paint/paint_op_buffer.h" | 12 #include "cc/paint/paint_op_buffer.h" |
13 #include "third_party/skia/include/core/SkMatrix.h" | 13 #include "third_party/skia/include/core/SkMatrix.h" |
14 #include "third_party/skia/include/core/SkRect.h" | 14 #include "third_party/skia/include/core/SkRect.h" |
15 #include "third_party/skia/include/utils/SkNoDrawCanvas.h" | 15 #include "third_party/skia/include/utils/SkNoDrawCanvas.h" |
16 | 16 |
17 namespace cc { | 17 namespace cc { |
18 class PaintFlags; | 18 class PaintFlags; |
19 class PaintImage; | 19 class PaintImage; |
20 | 20 |
21 class CC_PAINT_EXPORT DiscardableImageStore { | 21 class CC_PAINT_EXPORT DiscardableImageStore { |
22 public: | 22 public: |
23 DiscardableImageStore(int width, | 23 DiscardableImageStore( |
24 int height, | 24 int width, |
25 std::vector<std::pair<DrawImage, gfx::Rect>>* image_set, | 25 int height, |
26 base::flat_map<ImageId, gfx::Rect>* image_id_to_rect); | 26 std::vector<std::pair<DrawImage, gfx::Rect>>* image_set, |
| 27 base::flat_map<PaintImage::Id, gfx::Rect>* image_id_to_rect); |
27 ~DiscardableImageStore(); | 28 ~DiscardableImageStore(); |
28 | 29 |
29 void GatherDiscardableImages(const PaintOpBuffer* buffer); | 30 void GatherDiscardableImages(const PaintOpBuffer* buffer); |
30 SkNoDrawCanvas* GetNoDrawCanvas(); | 31 SkNoDrawCanvas* GetNoDrawCanvas(); |
31 | 32 |
32 private: | 33 private: |
33 class PaintTrackingCanvas; | 34 class PaintTrackingCanvas; |
34 | 35 |
35 void AddImageFromFlags(const SkRect& rect, const PaintFlags& flags); | 36 void AddImageFromFlags(const SkRect& rect, const PaintFlags& flags); |
36 void AddImage(const PaintImage& paint_image, | 37 void AddImage(PaintImage paint_image, |
37 const SkRect& src_rect, | 38 const SkRect& src_rect, |
38 const SkRect& rect, | 39 const SkRect& rect, |
39 const SkMatrix* local_matrix, | 40 const SkMatrix* local_matrix, |
40 const PaintFlags& flags); | 41 const PaintFlags& flags); |
41 | 42 |
42 // This canvas is used only for tracking transform/clip/filter state from the | 43 // This canvas is used only for tracking transform/clip/filter state from the |
43 // non-drawing ops. | 44 // non-drawing ops. |
44 std::unique_ptr<PaintTrackingCanvas> canvas_; | 45 std::unique_ptr<PaintTrackingCanvas> canvas_; |
45 std::vector<std::pair<DrawImage, gfx::Rect>>* image_set_; | 46 std::vector<std::pair<DrawImage, gfx::Rect>>* image_set_; |
46 base::flat_map<ImageId, gfx::Rect>* image_id_to_rect_; | 47 base::flat_map<PaintImage::Id, gfx::Rect>* image_id_to_rect_; |
47 // This is currently used for images that come from shaders. We don't know | |
48 // what the stable id is, but since the completion and animation states are | |
49 // both unknown, this value doesn't matter as it won't be used in checker | |
50 // imaging anyway. Keep this value the same to avoid id churn. | |
51 // TODO(vmpstr): Remove this when we can add paint images into shaders | |
52 // directly. | |
53 PaintImage::Id unknown_stable_id_; | |
54 }; | 48 }; |
55 | 49 |
56 } // namespace cc | 50 } // namespace cc |
57 | 51 |
58 #endif // CC_PAINT_DISCARDABLE_IMAGE_STORE_H_ | 52 #endif // CC_PAINT_DISCARDABLE_IMAGE_STORE_H_ |
OLD | NEW |