OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_RESOURCES_PICTURE_PILE_IMPL_H_ | 5 #ifndef CC_RESOURCES_PICTURE_PILE_IMPL_H_ |
6 #define CC_RESOURCES_PICTURE_PILE_IMPL_H_ | 6 #define CC_RESOURCES_PICTURE_PILE_IMPL_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "cc/base/cc_export.h" | 14 #include "cc/base/cc_export.h" |
15 #include "cc/debug/rendering_stats_instrumentation.h" | 15 #include "cc/debug/rendering_stats_instrumentation.h" |
16 #include "cc/resources/picture_pile_base.h" | 16 #include "cc/resources/picture_pile.h" |
17 #include "cc/resources/raster_source.h" | 17 #include "cc/resources/raster_source.h" |
18 #include "skia/ext/analysis_canvas.h" | 18 #include "skia/ext/analysis_canvas.h" |
19 #include "skia/ext/refptr.h" | 19 #include "skia/ext/refptr.h" |
20 #include "third_party/skia/include/core/SkPicture.h" | 20 #include "third_party/skia/include/core/SkPicture.h" |
21 | 21 |
22 namespace cc { | 22 namespace cc { |
23 | 23 |
24 // TODO(vmpstr): Clean up PicturePileBase and make it a member. | 24 class CC_EXPORT PicturePileImpl : public RasterSource { |
25 class CC_EXPORT PicturePileImpl : public PicturePileBase, public RasterSource { | |
26 public: | 25 public: |
27 static scoped_refptr<PicturePileImpl> Create(); | 26 static scoped_refptr<PicturePileImpl> Create(); |
28 static scoped_refptr<PicturePileImpl> CreateFromOther( | 27 static scoped_refptr<PicturePileImpl> CreateFromPicturePile( |
29 const PicturePileBase* other); | 28 const PicturePile* other); |
30 | 29 |
31 // RasterSource overrides. See RasterSource header for full description. | 30 // RasterSource overrides. See RasterSource header for full description. |
32 // When slow-down-raster-scale-factor is set to a value greater than 1, the | 31 // When slow-down-raster-scale-factor is set to a value greater than 1, the |
33 // reported rasterize time (in stats_instrumentation) is the minimum measured | 32 // reported rasterize time (in stats_instrumentation) is the minimum measured |
34 // value over all runs. | 33 // value over all runs. |
35 void PlaybackToCanvas(SkCanvas* canvas, | 34 void PlaybackToCanvas(SkCanvas* canvas, |
36 const gfx::Rect& canvas_rect, | 35 const gfx::Rect& canvas_rect, |
37 float contents_scale) const override; | 36 float contents_scale) const override; |
| 37 void PlaybackToSharedCanvas(SkCanvas* canvas, |
| 38 const gfx::Rect& canvas_rect, |
| 39 float contents_scale) const override; |
38 void PerformSolidColorAnalysis( | 40 void PerformSolidColorAnalysis( |
39 const gfx::Rect& content_rect, | 41 const gfx::Rect& content_rect, |
40 float contents_scale, | 42 float contents_scale, |
41 RasterSource::SolidColorAnalysis* analysis) const override; | 43 RasterSource::SolidColorAnalysis* analysis) const override; |
42 void GatherPixelRefs(const gfx::Rect& content_rect, | 44 void GatherPixelRefs(const gfx::Rect& content_rect, |
43 float contents_scale, | 45 float contents_scale, |
44 std::vector<SkPixelRef*>* pixel_refs) const override; | 46 std::vector<SkPixelRef*>* pixel_refs) const override; |
45 bool CoversRect(const gfx::Rect& content_rect, | 47 bool CoversRect(const gfx::Rect& content_rect, |
46 float contents_scale) const override; | 48 float contents_scale) const override; |
47 bool SuitableForDistanceFieldText() const override; | 49 void SetShouldAttemptToUseDistanceFieldText() override; |
48 | 50 bool ShouldAttemptToUseDistanceFieldText() const override; |
49 // Raster into the canvas without applying clips. | 51 gfx::Size GetSize() const override; |
50 void RasterDirect(SkCanvas* canvas, | 52 bool IsSolidColor() const override; |
51 const gfx::Rect& canvas_rect, | 53 SkColor GetSolidColor() const override; |
52 float contents_scale) const; | 54 bool HasRecordings() const override; |
| 55 bool IsMask() const override; |
53 | 56 |
54 // Tracing functionality. | 57 // Tracing functionality. |
55 void DidBeginTracing(); | 58 void DidBeginTracing() override; |
56 skia::RefPtr<SkPicture> GetFlattenedPicture(); | 59 void AsValueInto(base::debug::TracedValue* array) const override; |
57 | 60 skia::RefPtr<SkPicture> GetFlattenedPicture() override; |
58 void set_likely_to_be_used_for_transform_animation() { | |
59 likely_to_be_used_for_transform_animation_ = true; | |
60 } | |
61 | 61 |
62 // Iterator used to return SkPixelRefs from this picture pile. | 62 // Iterator used to return SkPixelRefs from this picture pile. |
63 // Public for testing. | 63 // Public for testing. |
64 class CC_EXPORT PixelRefIterator { | 64 class CC_EXPORT PixelRefIterator { |
65 public: | 65 public: |
66 PixelRefIterator(const gfx::Rect& content_rect, | 66 PixelRefIterator(const gfx::Rect& content_rect, |
67 float contents_scale, | 67 float contents_scale, |
68 const PicturePileImpl* picture_pile); | 68 const PicturePileImpl* picture_pile); |
69 ~PixelRefIterator(); | 69 ~PixelRefIterator(); |
70 | 70 |
71 SkPixelRef* operator->() const { return *pixel_ref_iterator_; } | 71 SkPixelRef* operator->() const { return *pixel_ref_iterator_; } |
72 SkPixelRef* operator*() const { return *pixel_ref_iterator_; } | 72 SkPixelRef* operator*() const { return *pixel_ref_iterator_; } |
73 PixelRefIterator& operator++(); | 73 PixelRefIterator& operator++(); |
74 operator bool() const { return pixel_ref_iterator_; } | 74 operator bool() const { return pixel_ref_iterator_; } |
75 | 75 |
76 private: | 76 private: |
77 void AdvanceToTilePictureWithPixelRefs(); | 77 void AdvanceToTilePictureWithPixelRefs(); |
78 | 78 |
79 const PicturePileImpl* picture_pile_; | 79 const PicturePileImpl* picture_pile_; |
80 gfx::Rect layer_rect_; | 80 gfx::Rect layer_rect_; |
81 TilingData::Iterator tile_iterator_; | 81 TilingData::Iterator tile_iterator_; |
82 Picture::PixelRefIterator pixel_ref_iterator_; | 82 Picture::PixelRefIterator pixel_ref_iterator_; |
83 std::set<const void*> processed_pictures_; | 83 std::set<const void*> processed_pictures_; |
84 }; | 84 }; |
85 | 85 |
86 protected: | 86 protected: |
87 friend class PicturePile; | 87 friend class PicturePile; |
88 friend class PixelRefIterator; | 88 friend class PixelRefIterator; |
89 | 89 |
| 90 // TODO(vmpstr): Change this when pictures are split from invalidation info. |
| 91 using PictureMapKey = PicturePile::PictureMapKey; |
| 92 using PictureMap = PicturePile::PictureMap; |
| 93 using PictureInfo = PicturePile::PictureInfo; |
| 94 |
90 PicturePileImpl(); | 95 PicturePileImpl(); |
91 explicit PicturePileImpl(const PicturePileBase* other); | 96 explicit PicturePileImpl(const PicturePile* other); |
92 ~PicturePileImpl() override; | 97 ~PicturePileImpl() override; |
93 | 98 |
| 99 int buffer_pixels() const { return tiling_.border_texels(); } |
| 100 |
| 101 PictureMap picture_map_; |
| 102 TilingData tiling_; |
| 103 SkColor background_color_; |
| 104 bool contents_opaque_; |
| 105 bool contents_fill_bounds_completely_; |
| 106 bool is_solid_color_; |
| 107 SkColor solid_color_; |
| 108 gfx::Rect recorded_viewport_; |
| 109 bool has_any_recordings_; |
| 110 bool is_mask_; |
| 111 bool clear_canvas_with_debug_color_; |
| 112 float min_contents_scale_; |
| 113 int slow_down_raster_scale_factor_for_debug_; |
| 114 |
94 private: | 115 private: |
95 typedef std::map<const Picture*, Region> PictureRegionMap; | 116 typedef std::map<const Picture*, Region> PictureRegionMap; |
96 | 117 |
97 // Called when analyzing a tile. We can use AnalysisCanvas as | 118 // Called when analyzing a tile. We can use AnalysisCanvas as |
98 // SkDrawPictureCallback, which allows us to early out from analysis. | 119 // SkDrawPictureCallback, which allows us to early out from analysis. |
99 void RasterForAnalysis(skia::AnalysisCanvas* canvas, | 120 void RasterForAnalysis(skia::AnalysisCanvas* canvas, |
100 const gfx::Rect& canvas_rect, | 121 const gfx::Rect& canvas_rect, |
101 float contents_scale) const; | 122 float contents_scale) const; |
102 | 123 |
103 void CoalesceRasters(const gfx::Rect& canvas_rect, | 124 void CoalesceRasters(const gfx::Rect& canvas_rect, |
104 const gfx::Rect& content_rect, | 125 const gfx::Rect& content_rect, |
105 float contents_scale, | 126 float contents_scale, |
106 PictureRegionMap* result) const; | 127 PictureRegionMap* result) const; |
107 | 128 |
108 void RasterCommon( | 129 void RasterCommon( |
109 SkCanvas* canvas, | 130 SkCanvas* canvas, |
110 SkDrawPictureCallback* callback, | 131 SkDrawPictureCallback* callback, |
111 const gfx::Rect& canvas_rect, | 132 const gfx::Rect& canvas_rect, |
112 float contents_scale, | 133 float contents_scale, |
113 bool is_analysis) const; | 134 bool is_analysis) const; |
114 | 135 |
115 bool likely_to_be_used_for_transform_animation_; | 136 // An internal CanRaster check that goes to the picture_map rather than |
| 137 // using the recorded_viewport hint. |
| 138 bool CanRasterSlowTileCheck(const gfx::Rect& layer_rect) const; |
| 139 |
| 140 gfx::Rect PaddedRect(const PictureMapKey& key) const; |
| 141 |
| 142 bool should_attempt_to_use_distance_field_text_; |
116 | 143 |
117 DISALLOW_COPY_AND_ASSIGN(PicturePileImpl); | 144 DISALLOW_COPY_AND_ASSIGN(PicturePileImpl); |
118 }; | 145 }; |
119 | 146 |
120 } // namespace cc | 147 } // namespace cc |
121 | 148 |
122 #endif // CC_RESOURCES_PICTURE_PILE_IMPL_H_ | 149 #endif // CC_RESOURCES_PICTURE_PILE_IMPL_H_ |
OLD | NEW |