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> |
(...skipping 21 matching lines...) Expand all Loading... |
32 // Raster a subrect of this PicturePileImpl into the given canvas. | 32 // Raster a subrect of this PicturePileImpl into the given canvas. |
33 // It's only safe to call paint on a cloned version. It is assumed | 33 // It's only safe to call paint on a cloned version. It is assumed |
34 // that contents_scale has already been applied to this canvas. | 34 // that contents_scale has already been applied to this canvas. |
35 // Writes the total number of pixels rasterized and the time spent | 35 // Writes the total number of pixels rasterized and the time spent |
36 // rasterizing to the stats if the respective pointer is not | 36 // rasterizing to the stats if the respective pointer is not |
37 // NULL. When slow-down-raster-scale-factor is set to a value | 37 // NULL. When slow-down-raster-scale-factor is set to a value |
38 // greater than 1, the reported rasterize time is the minimum | 38 // greater than 1, the reported rasterize time is the minimum |
39 // measured value over all runs. | 39 // measured value over all runs. |
40 void RasterDirect( | 40 void RasterDirect( |
41 SkCanvas* canvas, | 41 SkCanvas* canvas, |
42 gfx::Rect canvas_rect, | 42 const gfx::Rect& canvas_rect, |
43 float contents_scale, | 43 float contents_scale, |
44 RenderingStatsInstrumentation* rendering_stats_instrumentation); | 44 RenderingStatsInstrumentation* rendering_stats_instrumentation); |
45 | 45 |
46 // Similar to the above RasterDirect method, but this is a convenience method | 46 // Similar to the above RasterDirect method, but this is a convenience method |
47 // for when it is known that the raster is going to an intermediate bitmap | 47 // for when it is known that the raster is going to an intermediate bitmap |
48 // that itself will then be blended and thus that a canvas clear is required. | 48 // that itself will then be blended and thus that a canvas clear is required. |
49 void RasterToBitmap( | 49 void RasterToBitmap( |
50 SkCanvas* canvas, | 50 SkCanvas* canvas, |
51 gfx::Rect canvas_rect, | 51 const gfx::Rect& canvas_rect, |
52 float contents_scale, | 52 float contents_scale, |
53 RenderingStatsInstrumentation* stats_instrumentation); | 53 RenderingStatsInstrumentation* stats_instrumentation); |
54 | 54 |
55 // Called when analyzing a tile. We can use AnalysisCanvas as | 55 // Called when analyzing a tile. We can use AnalysisCanvas as |
56 // SkDrawPictureCallback, which allows us to early out from analysis. | 56 // SkDrawPictureCallback, which allows us to early out from analysis. |
57 void RasterForAnalysis( | 57 void RasterForAnalysis( |
58 skia::AnalysisCanvas* canvas, | 58 skia::AnalysisCanvas* canvas, |
59 gfx::Rect canvas_rect, | 59 const gfx::Rect& canvas_rect, |
60 float contents_scale, | 60 float contents_scale, |
61 RenderingStatsInstrumentation* stats_instrumentation); | 61 RenderingStatsInstrumentation* stats_instrumentation); |
62 | 62 |
63 skia::RefPtr<SkPicture> GetFlattenedPicture(); | 63 skia::RefPtr<SkPicture> GetFlattenedPicture(); |
64 | 64 |
65 struct CC_EXPORT Analysis { | 65 struct CC_EXPORT Analysis { |
66 Analysis(); | 66 Analysis(); |
67 ~Analysis(); | 67 ~Analysis(); |
68 | 68 |
69 bool is_solid_color; | 69 bool is_solid_color; |
70 bool has_text; | 70 bool has_text; |
71 SkColor solid_color; | 71 SkColor solid_color; |
72 }; | 72 }; |
73 | 73 |
74 void AnalyzeInRect(gfx::Rect content_rect, | 74 void AnalyzeInRect(const gfx::Rect& content_rect, |
75 float contents_scale, | 75 float contents_scale, |
76 Analysis* analysis); | 76 Analysis* analysis); |
77 | 77 |
78 void AnalyzeInRect(gfx::Rect content_rect, | 78 void AnalyzeInRect(const gfx::Rect& content_rect, |
79 float contents_scale, | 79 float contents_scale, |
80 Analysis* analysis, | 80 Analysis* analysis, |
81 RenderingStatsInstrumentation* stats_instrumentation); | 81 RenderingStatsInstrumentation* stats_instrumentation); |
82 | 82 |
83 class CC_EXPORT PixelRefIterator { | 83 class CC_EXPORT PixelRefIterator { |
84 public: | 84 public: |
85 PixelRefIterator(gfx::Rect content_rect, | 85 PixelRefIterator(const gfx::Rect& content_rect, |
86 float contents_scale, | 86 float contents_scale, |
87 const PicturePileImpl* picture_pile); | 87 const PicturePileImpl* picture_pile); |
88 ~PixelRefIterator(); | 88 ~PixelRefIterator(); |
89 | 89 |
90 SkPixelRef* operator->() const { return *pixel_ref_iterator_; } | 90 SkPixelRef* operator->() const { return *pixel_ref_iterator_; } |
91 SkPixelRef* operator*() const { return *pixel_ref_iterator_; } | 91 SkPixelRef* operator*() const { return *pixel_ref_iterator_; } |
92 PixelRefIterator& operator++(); | 92 PixelRefIterator& operator++(); |
93 operator bool() const { return pixel_ref_iterator_; } | 93 operator bool() const { return pixel_ref_iterator_; } |
94 | 94 |
95 private: | 95 private: |
(...skipping 26 matching lines...) Expand all Loading... |
122 PicturePileVector clones_; | 122 PicturePileVector clones_; |
123 }; | 123 }; |
124 | 124 |
125 static scoped_refptr<PicturePileImpl> CreateCloneForDrawing( | 125 static scoped_refptr<PicturePileImpl> CreateCloneForDrawing( |
126 const PicturePileImpl* other, unsigned thread_index); | 126 const PicturePileImpl* other, unsigned thread_index); |
127 | 127 |
128 PicturePileImpl(const PicturePileImpl* other, unsigned thread_index); | 128 PicturePileImpl(const PicturePileImpl* other, unsigned thread_index); |
129 | 129 |
130 private: | 130 private: |
131 typedef std::map<Picture*, Region> PictureRegionMap; | 131 typedef std::map<Picture*, Region> PictureRegionMap; |
132 void CoalesceRasters(gfx::Rect canvas_rect, | 132 void CoalesceRasters(const gfx::Rect& canvas_rect, |
133 gfx::Rect content_rect, | 133 const gfx::Rect& content_rect, |
134 float contents_scale, | 134 float contents_scale, |
135 PictureRegionMap* result); | 135 PictureRegionMap* result); |
136 | 136 |
137 void RasterCommon( | 137 void RasterCommon( |
138 SkCanvas* canvas, | 138 SkCanvas* canvas, |
139 SkDrawPictureCallback* callback, | 139 SkDrawPictureCallback* callback, |
140 gfx::Rect canvas_rect, | 140 const gfx::Rect& canvas_rect, |
141 float contents_scale, | 141 float contents_scale, |
142 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 142 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
143 bool is_analysis); | 143 bool is_analysis); |
144 | 144 |
145 // Once instantiated, |clones_for_drawing_| can't be modified. This | 145 // Once instantiated, |clones_for_drawing_| can't be modified. This |
146 // guarantees thread-safe access during the life time of a PicturePileImpl | 146 // guarantees thread-safe access during the life time of a PicturePileImpl |
147 // instance. This member variable must be last so that other member | 147 // instance. This member variable must be last so that other member |
148 // variables have already been initialized and can be clonable. | 148 // variables have already been initialized and can be clonable. |
149 const ClonesForDrawing clones_for_drawing_; | 149 const ClonesForDrawing clones_for_drawing_; |
150 | 150 |
151 DISALLOW_COPY_AND_ASSIGN(PicturePileImpl); | 151 DISALLOW_COPY_AND_ASSIGN(PicturePileImpl); |
152 }; | 152 }; |
153 | 153 |
154 } // namespace cc | 154 } // namespace cc |
155 | 155 |
156 #endif // CC_RESOURCES_PICTURE_PILE_IMPL_H_ | 156 #endif // CC_RESOURCES_PICTURE_PILE_IMPL_H_ |
OLD | NEW |