OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_RASTER_RASTER_SOURCE_H_ | 5 #ifndef CC_RASTER_RASTER_SOURCE_H_ |
6 #define CC_RASTER_RASTER_SOURCE_H_ | 6 #define CC_RASTER_RASTER_SOURCE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 // Helper function to apply a few common operations before passing the canvas | 61 // Helper function to apply a few common operations before passing the canvas |
62 // to the shorter version. This is useful for rastering into tiles. | 62 // to the shorter version. This is useful for rastering into tiles. |
63 // canvas is expected to be backed by a tile, with a default state. | 63 // canvas is expected to be backed by a tile, with a default state. |
64 // raster_transform will be applied to the display list, rastering the list | 64 // raster_transform will be applied to the display list, rastering the list |
65 // into the "content space". | 65 // into the "content space". |
66 // canvas_bitmap_rect defines the extent of the tile in the content space, | 66 // canvas_bitmap_rect defines the extent of the tile in the content space, |
67 // i.e. contents in the rect will be cropped and translated onto the canvas. | 67 // i.e. contents in the rect will be cropped and translated onto the canvas. |
68 // canvas_playback_rect can be used to replay only part of the recording in, | 68 // canvas_playback_rect can be used to replay only part of the recording in, |
69 // the content space, so only a sub-rect of the tile gets rastered. | 69 // the content space, so only a sub-rect of the tile gets rastered. |
70 void PlaybackToCanvas(SkCanvas* canvas, | 70 void PlaybackToCanvas(SkCanvas* canvas, |
71 const gfx::ColorSpace& canvas_color_space, | 71 const gfx::ColorSpace& target_color_space, |
72 const gfx::Rect& canvas_bitmap_rect, | 72 const gfx::Rect& canvas_bitmap_rect, |
73 const gfx::Rect& canvas_playback_rect, | 73 const gfx::Rect& canvas_playback_rect, |
74 const gfx::AxisTransform2d& raster_transform, | 74 const gfx::AxisTransform2d& raster_transform, |
75 const PlaybackSettings& settings) const; | 75 const PlaybackSettings& settings) const; |
76 | 76 |
77 // Raster this RasterSource into the given canvas. Canvas states such as | 77 // Raster this RasterSource into the given canvas. Canvas states such as |
78 // CTM and clip region will be respected. This function will replace pixels | 78 // CTM and clip region will be respected. This function will replace pixels |
79 // in the clip region without blending. It is assumed that existing pixels | 79 // in the clip region without blending. It is assumed that existing pixels |
80 // may be uninitialized and will be cleared before playback. | 80 // may be uninitialized and will be cleared before playback. |
81 // | 81 // |
82 // Virtual for testing. | 82 // Virtual for testing. |
83 // | 83 // |
84 // Note that this should only be called after the image decode controller has | 84 // Note that this should only be called after the image decode controller has |
85 // been set, which happens during commit. | 85 // been set, which happens during commit. |
86 virtual void PlaybackToCanvas(SkCanvas* canvas, | 86 virtual void PlaybackToCanvas(SkCanvas* canvas, |
87 const gfx::ColorSpace& canvas_color_space, | 87 const gfx::ColorSpace& target_color_space, |
88 const PlaybackSettings& settings) const; | 88 const PlaybackSettings& settings) const; |
89 | 89 |
90 // Returns whether the given rect at given scale is of solid color in | 90 // Returns whether the given rect at given scale is of solid color in |
91 // this raster source, as well as the solid color value. | 91 // this raster source, as well as the solid color value. |
92 bool PerformSolidColorAnalysis(const gfx::Rect& content_rect, | 92 bool PerformSolidColorAnalysis(const gfx::Rect& content_rect, |
93 float contents_scale, | 93 float contents_scale, |
94 SkColor* color) const; | 94 SkColor* color) const; |
95 | 95 |
96 // Returns true iff the whole raster source is of solid color. | 96 // Returns true iff the whole raster source is of solid color. |
97 bool IsSolidColor() const; | 97 bool IsSolidColor() const; |
98 | 98 |
99 // Returns the color of the raster source if it is solid color. The results | 99 // Returns the color of the raster source if it is solid color. The results |
100 // are unspecified if IsSolidColor returns false. | 100 // are unspecified if IsSolidColor returns false. |
101 SkColor GetSolidColor() const; | 101 SkColor GetSolidColor() const; |
102 | 102 |
103 // Returns the size of this raster source. | 103 // Returns the size of this raster source. |
104 gfx::Size GetSize() const; | 104 gfx::Size GetSize() const; |
105 | 105 |
106 // Populate the given list with all images that may overlap the given | 106 // Populate the given list with all images that may overlap the given |
107 // rect in layer space. The returned draw images' matrices are modified as if | 107 // rect in layer space. The returned draw images' matrices are modified as if |
108 // they were being using during raster at scale |raster_scale|. | 108 // they were being using during raster at scale |raster_scale|. |
109 void GetDiscardableImagesInRect(const gfx::Rect& layer_rect, | 109 void GetDiscardableImagesInRect(const gfx::Rect& layer_rect, |
110 float contents_scale, | 110 float contents_scale, |
| 111 const gfx::ColorSpace& target_color_space, |
111 std::vector<DrawImage>* images) const; | 112 std::vector<DrawImage>* images) const; |
112 | 113 |
113 // Return true iff this raster source can raster the given rect in layer | 114 // Return true iff this raster source can raster the given rect in layer |
114 // space. | 115 // space. |
115 bool CoversRect(const gfx::Rect& layer_rect) const; | 116 bool CoversRect(const gfx::Rect& layer_rect) const; |
116 | 117 |
117 // Returns true if this raster source has anything to rasterize. | 118 // Returns true if this raster source has anything to rasterize. |
118 virtual bool HasRecordings() const; | 119 virtual bool HasRecordings() const; |
119 | 120 |
120 // Valid rectangle in which everything is recorded and can be rastered from. | 121 // Valid rectangle in which everything is recorded and can be rastered from. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 const gfx::Size size_; | 161 const gfx::Size size_; |
161 const bool clear_canvas_with_debug_color_; | 162 const bool clear_canvas_with_debug_color_; |
162 const int slow_down_raster_scale_factor_for_debug_; | 163 const int slow_down_raster_scale_factor_for_debug_; |
163 | 164 |
164 // In practice, this is only set once before raster begins, so it's ok with | 165 // In practice, this is only set once before raster begins, so it's ok with |
165 // respect to threading. | 166 // respect to threading. |
166 ImageDecodeCache* image_decode_cache_; | 167 ImageDecodeCache* image_decode_cache_; |
167 | 168 |
168 private: | 169 private: |
169 void RasterCommon(SkCanvas* canvas, | 170 void RasterCommon(SkCanvas* canvas, |
170 const gfx::ColorSpace& canvas_color_space, | |
171 SkPicture::AbortCallback* callback) const; | 171 SkPicture::AbortCallback* callback) const; |
172 | 172 |
173 void PrepareForPlaybackToCanvas(SkCanvas* canvas) const; | 173 void PrepareForPlaybackToCanvas(SkCanvas* canvas) const; |
174 | 174 |
175 DISALLOW_COPY_AND_ASSIGN(RasterSource); | 175 DISALLOW_COPY_AND_ASSIGN(RasterSource); |
176 }; | 176 }; |
177 | 177 |
178 } // namespace cc | 178 } // namespace cc |
179 | 179 |
180 #endif // CC_RASTER_RASTER_SOURCE_H_ | 180 #endif // CC_RASTER_RASTER_SOURCE_H_ |
OLD | NEW |