| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 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 |
| 56 // SkDrawPictureCallback, which allows us to early out from analysis. |
| 57 void RasterForAnalysis( |
| 58 skia::AnalysisCanvas* canvas, |
| 59 gfx::Rect canvas_rect, |
| 60 float contents_scale, |
| 61 RenderingStatsInstrumentation* stats_instrumentation); |
| 62 |
| 55 skia::RefPtr<SkPicture> GetFlattenedPicture(); | 63 skia::RefPtr<SkPicture> GetFlattenedPicture(); |
| 56 | 64 |
| 57 struct CC_EXPORT Analysis { | 65 struct CC_EXPORT Analysis { |
| 58 Analysis(); | 66 Analysis(); |
| 59 ~Analysis(); | 67 ~Analysis(); |
| 60 | 68 |
| 61 bool is_solid_color; | 69 bool is_solid_color; |
| 62 bool has_text; | 70 bool has_text; |
| 63 SkColor solid_color; | 71 SkColor solid_color; |
| 64 }; | 72 }; |
| 65 | 73 |
| 74 void AnalyzeInRect(gfx::Rect content_rect, |
| 75 float contents_scale, |
| 76 Analysis* analysis); |
| 77 |
| 78 void AnalyzeInRect(gfx::Rect content_rect, |
| 79 float contents_scale, |
| 80 Analysis* analysis, |
| 81 RenderingStatsInstrumentation* stats_instrumentation); |
| 82 |
| 66 class CC_EXPORT PixelRefIterator { | 83 class CC_EXPORT PixelRefIterator { |
| 67 public: | 84 public: |
| 68 PixelRefIterator(gfx::Rect content_rect, | 85 PixelRefIterator(gfx::Rect content_rect, |
| 69 float contents_scale, | 86 float contents_scale, |
| 70 const PicturePileImpl* picture_pile); | 87 const PicturePileImpl* picture_pile); |
| 71 ~PixelRefIterator(); | 88 ~PixelRefIterator(); |
| 72 | 89 |
| 73 skia::LazyPixelRef* operator->() const { return *pixel_ref_iterator_; } | 90 skia::LazyPixelRef* operator->() const { return *pixel_ref_iterator_; } |
| 74 skia::LazyPixelRef* operator*() const { return *pixel_ref_iterator_; } | 91 skia::LazyPixelRef* operator*() const { return *pixel_ref_iterator_; } |
| 75 PixelRefIterator& operator++(); | 92 PixelRefIterator& operator++(); |
| 76 operator bool() const { return pixel_ref_iterator_; } | 93 operator bool() const { return pixel_ref_iterator_; } |
| 77 | 94 |
| 78 private: | 95 private: |
| 79 void AdvanceToTilePictureWithPixelRefs(); | 96 void AdvanceToTilePictureWithPixelRefs(); |
| 80 | 97 |
| 81 const PicturePileImpl* picture_pile_; | 98 const PicturePileImpl* picture_pile_; |
| 82 gfx::Rect layer_rect_; | 99 gfx::Rect layer_rect_; |
| 83 TilingData::Iterator tile_iterator_; | 100 TilingData::Iterator tile_iterator_; |
| 84 Picture::PixelRefIterator pixel_ref_iterator_; | 101 Picture::PixelRefIterator pixel_ref_iterator_; |
| 85 std::set<const void*> processed_pictures_; | 102 std::set<const void*> processed_pictures_; |
| 86 }; | 103 }; |
| 87 | 104 |
| 88 gfx::Rect AnalysisRectForRaster(gfx::Rect content_rect, | |
| 89 float contents_scale) const; | |
| 90 | |
| 91 void DidBeginTracing(); | 105 void DidBeginTracing(); |
| 92 | 106 |
| 93 protected: | 107 protected: |
| 94 friend class PicturePile; | 108 friend class PicturePile; |
| 95 friend class PixelRefIterator; | 109 friend class PixelRefIterator; |
| 96 | 110 |
| 97 PicturePileImpl(); | 111 PicturePileImpl(); |
| 98 explicit PicturePileImpl(const PicturePileBase* other); | 112 explicit PicturePileImpl(const PicturePileBase* other); |
| 99 virtual ~PicturePileImpl(); | 113 virtual ~PicturePileImpl(); |
| 100 | 114 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 115 | 129 |
| 116 private: | 130 private: |
| 117 typedef std::map<Picture*, Region> PictureRegionMap; | 131 typedef std::map<Picture*, Region> PictureRegionMap; |
| 118 void CoalesceRasters(gfx::Rect canvas_rect, | 132 void CoalesceRasters(gfx::Rect canvas_rect, |
| 119 gfx::Rect content_rect, | 133 gfx::Rect content_rect, |
| 120 float contents_scale, | 134 float contents_scale, |
| 121 PictureRegionMap* result); | 135 PictureRegionMap* result); |
| 122 | 136 |
| 123 void RasterCommon( | 137 void RasterCommon( |
| 124 SkCanvas* canvas, | 138 SkCanvas* canvas, |
| 139 SkDrawPictureCallback* callback, |
| 125 gfx::Rect canvas_rect, | 140 gfx::Rect canvas_rect, |
| 126 float contents_scale, | 141 float contents_scale, |
| 127 RenderingStatsInstrumentation* rendering_stats_instrumentation); | 142 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 143 bool is_analysis); |
| 128 | 144 |
| 129 // Once instantiated, |clones_for_drawing_| can't be modified. This | 145 // Once instantiated, |clones_for_drawing_| can't be modified. This |
| 130 // guarantees thread-safe access during the life time of a PicturePileImpl | 146 // guarantees thread-safe access during the life time of a PicturePileImpl |
| 131 // instance. This member variable must be last so that other member | 147 // instance. This member variable must be last so that other member |
| 132 // variables have already been initialized and can be clonable. | 148 // variables have already been initialized and can be clonable. |
| 133 const ClonesForDrawing clones_for_drawing_; | 149 const ClonesForDrawing clones_for_drawing_; |
| 134 | 150 |
| 135 DISALLOW_COPY_AND_ASSIGN(PicturePileImpl); | 151 DISALLOW_COPY_AND_ASSIGN(PicturePileImpl); |
| 136 }; | 152 }; |
| 137 | 153 |
| 138 } // namespace cc | 154 } // namespace cc |
| 139 | 155 |
| 140 #endif // CC_RESOURCES_PICTURE_PILE_IMPL_H_ | 156 #endif // CC_RESOURCES_PICTURE_PILE_IMPL_H_ |
| OLD | NEW |