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_PLAYBACK_RASTER_SOURCE_H_ | 5 #ifndef CC_PLAYBACK_RASTER_SOURCE_H_ |
6 #define CC_PLAYBACK_RASTER_SOURCE_H_ | 6 #define CC_PLAYBACK_RASTER_SOURCE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "third_party/skia/include/core/SkPicture.h" | 21 #include "third_party/skia/include/core/SkPicture.h" |
22 | 22 |
23 namespace cc { | 23 namespace cc { |
24 class DisplayItemList; | 24 class DisplayItemList; |
25 class DrawImage; | 25 class DrawImage; |
26 class ImageDecodeController; | 26 class ImageDecodeController; |
27 | 27 |
28 class CC_EXPORT RasterSource : public base::trace_event::MemoryDumpProvider, | 28 class CC_EXPORT RasterSource : public base::trace_event::MemoryDumpProvider, |
29 public base::RefCountedThreadSafe<RasterSource> { | 29 public base::RefCountedThreadSafe<RasterSource> { |
30 public: | 30 public: |
| 31 struct CC_EXPORT PlaybackSettings { |
| 32 PlaybackSettings(); |
| 33 |
| 34 // If set to true, this indicates that the canvas has already been |
| 35 // rasterized into. This means that the canvas cannot be cleared safely. |
| 36 bool playback_to_shared_canvas; |
| 37 |
| 38 // If set to true, none of the images will be rasterized. |
| 39 bool skip_images; |
| 40 |
| 41 // If set to true, we will use an image hijack canvas, which enables |
| 42 // compositor image caching. |
| 43 bool use_image_hijack_canvas; |
| 44 }; |
| 45 |
31 static scoped_refptr<RasterSource> CreateFromRecordingSource( | 46 static scoped_refptr<RasterSource> CreateFromRecordingSource( |
32 const RecordingSource* other, | 47 const RecordingSource* other, |
33 bool can_use_lcd_text); | 48 bool can_use_lcd_text); |
34 | 49 |
35 // Raster a subrect of this RasterSource into the given canvas. It is | 50 // Raster a subrect of this RasterSource into the given canvas. It is |
36 // assumed that contents_scale has already been applied to this canvas. | 51 // assumed that contents_scale has already been applied to this canvas. |
37 // Writes the total number of pixels rasterized and the time spent | 52 // Writes the total number of pixels rasterized and the time spent |
38 // rasterizing to the stats if the respective pointer is not nullptr. | 53 // rasterizing to the stats if the respective pointer is not nullptr. |
39 // It is assumed that the canvas passed here will only be rasterized by | 54 // It is assumed that the canvas passed here will only be rasterized by |
40 // this raster source via this call. | 55 // this raster source via this call. |
41 // | 56 // |
42 // Virtual for testing. | 57 // Virtual for testing. |
43 // | 58 // |
44 // Note that this should only be called after the image decode controller has | 59 // Note that this should only be called after the image decode controller has |
45 // been set, which happens during commit. | 60 // been set, which happens during commit. |
46 virtual void PlaybackToCanvas(SkCanvas* canvas, | 61 virtual void PlaybackToCanvas(SkCanvas* canvas, |
47 const gfx::Rect& canvas_bitmap_rect, | 62 const gfx::Rect& canvas_bitmap_rect, |
48 const gfx::Rect& canvas_playback_rect, | 63 const gfx::Rect& canvas_playback_rect, |
49 float contents_scale, | 64 float contents_scale, |
50 bool include_images) const; | 65 const PlaybackSettings& settings) const; |
51 | |
52 // Similar to above, except that the canvas passed here can (or was already) | |
53 // rasterized into by another raster source. That is, it is not safe to clear | |
54 // the canvas or discard its underlying memory. | |
55 void PlaybackToSharedCanvas(SkCanvas* canvas, | |
56 const gfx::Rect& canvas_rect, | |
57 float contents_scale, | |
58 bool include_images) const; | |
59 | 66 |
60 // Returns whether the given rect at given scale is of solid color in | 67 // Returns whether the given rect at given scale is of solid color in |
61 // this raster source, as well as the solid color value. | 68 // this raster source, as well as the solid color value. |
62 bool PerformSolidColorAnalysis(const gfx::Rect& content_rect, | 69 bool PerformSolidColorAnalysis(const gfx::Rect& content_rect, |
63 float contents_scale, | 70 float contents_scale, |
64 SkColor* color) const; | 71 SkColor* color) const; |
65 | 72 |
66 // Returns true iff the whole raster source is of solid color. | 73 // Returns true iff the whole raster source is of solid color. |
67 bool IsSolidColor() const; | 74 bool IsSolidColor() const; |
68 | 75 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 const int slow_down_raster_scale_factor_for_debug_; | 146 const int slow_down_raster_scale_factor_for_debug_; |
140 // TODO(enne/vmiura): this has a read/write race between raster and compositor | 147 // TODO(enne/vmiura): this has a read/write race between raster and compositor |
141 // threads with multi-threaded Ganesh. Make this const or remove it. | 148 // threads with multi-threaded Ganesh. Make this const or remove it. |
142 bool should_attempt_to_use_distance_field_text_; | 149 bool should_attempt_to_use_distance_field_text_; |
143 | 150 |
144 // In practice, this is only set once before raster begins, so it's ok with | 151 // In practice, this is only set once before raster begins, so it's ok with |
145 // respect to threading. | 152 // respect to threading. |
146 ImageDecodeController* image_decode_controller_; | 153 ImageDecodeController* image_decode_controller_; |
147 | 154 |
148 private: | 155 private: |
149 // Called when analyzing a tile. We can use AnalysisCanvas as | |
150 // SkPicture::AbortCallback, which allows us to early out from analysis. | |
151 void RasterForAnalysis(skia::AnalysisCanvas* canvas, | |
152 const gfx::Rect& canvas_rect, | |
153 float contents_scale) const; | |
154 | |
155 void RasterCommon(SkCanvas* canvas, | 156 void RasterCommon(SkCanvas* canvas, |
156 SkPicture::AbortCallback* callback, | 157 SkPicture::AbortCallback* callback, |
157 const gfx::Rect& canvas_bitmap_rect, | 158 const gfx::Rect& canvas_bitmap_rect, |
158 const gfx::Rect& canvas_playback_rect, | 159 const gfx::Rect& canvas_playback_rect, |
159 float contents_scale) const; | 160 float contents_scale) const; |
160 | 161 |
161 void PrepareForPlaybackToCanvas(SkCanvas* canvas, | 162 void PrepareForPlaybackToCanvas(SkCanvas* canvas, |
162 const gfx::Rect& canvas_bitmap_rect, | 163 const gfx::Rect& canvas_bitmap_rect, |
163 const gfx::Rect& canvas_playback_rect, | 164 const gfx::Rect& canvas_playback_rect, |
164 float contents_scale) const; | 165 float contents_scale) const; |
165 | 166 |
166 // Used to ensure that memory dump logic always happens on the same thread. | 167 // Used to ensure that memory dump logic always happens on the same thread. |
167 base::ThreadChecker memory_dump_thread_checker_; | 168 base::ThreadChecker memory_dump_thread_checker_; |
168 | 169 |
169 DISALLOW_COPY_AND_ASSIGN(RasterSource); | 170 DISALLOW_COPY_AND_ASSIGN(RasterSource); |
170 }; | 171 }; |
171 | 172 |
172 } // namespace cc | 173 } // namespace cc |
173 | 174 |
174 #endif // CC_PLAYBACK_RASTER_SOURCE_H_ | 175 #endif // CC_PLAYBACK_RASTER_SOURCE_H_ |
OLD | NEW |