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 <memory> | 10 #include <memory> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.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/paint/paint_canvas.h" |
| 17 #include "cc/paint/paint_record.h" |
16 #include "cc/playback/recording_source.h" | 18 #include "cc/playback/recording_source.h" |
17 #include "skia/ext/analysis_canvas.h" | 19 #include "skia/ext/analysis_canvas.h" |
18 #include "third_party/skia/include/core/SkPicture.h" | |
19 | 20 |
20 namespace gfx { | 21 namespace gfx { |
21 class ColorSpace; | 22 class ColorSpace; |
22 } | 23 } |
23 | 24 |
24 namespace cc { | 25 namespace cc { |
25 class DisplayItemList; | 26 class DisplayItemList; |
26 class DrawImage; | 27 class DrawImage; |
27 class ImageDecodeCache; | 28 class ImageDecodeCache; |
28 | 29 |
(...skipping 12 matching lines...) Expand all Loading... |
41 // If set to true, we will use an image hijack canvas, which enables | 42 // If set to true, we will use an image hijack canvas, which enables |
42 // compositor image caching. | 43 // compositor image caching. |
43 bool use_image_hijack_canvas; | 44 bool use_image_hijack_canvas; |
44 }; | 45 }; |
45 | 46 |
46 static scoped_refptr<RasterSource> CreateFromRecordingSource( | 47 static scoped_refptr<RasterSource> CreateFromRecordingSource( |
47 const RecordingSource* other, | 48 const RecordingSource* other, |
48 bool can_use_lcd_text); | 49 bool can_use_lcd_text); |
49 | 50 |
50 // TODO(trchen): Deprecated. | 51 // TODO(trchen): Deprecated. |
51 void PlaybackToCanvas(SkCanvas* canvas, | 52 void PlaybackToCanvas(PaintCanvas* canvas, |
52 const gfx::Rect& canvas_bitmap_rect, | 53 const gfx::Rect& canvas_bitmap_rect, |
53 const gfx::Rect& canvas_playback_rect, | 54 const gfx::Rect& canvas_playback_rect, |
54 float contents_scale, | 55 float contents_scale, |
55 const PlaybackSettings& settings) const; | 56 const PlaybackSettings& settings) const; |
56 | 57 |
57 // Raster this RasterSource into the given canvas. Canvas states such as | 58 // Raster this RasterSource into the given canvas. Canvas states such as |
58 // CTM and clip region will be respected. This function will replace pixels | 59 // CTM and clip region will be respected. This function will replace pixels |
59 // in the clip region without blending. It is assumed that existing pixels | 60 // in the clip region without blending. It is assumed that existing pixels |
60 // may be uninitialized and will be cleared before playback. | 61 // may be uninitialized and will be cleared before playback. |
61 // | 62 // |
62 // Virtual for testing. | 63 // Virtual for testing. |
63 // | 64 // |
64 // Note that this should only be called after the image decode controller has | 65 // Note that this should only be called after the image decode controller has |
65 // been set, which happens during commit. | 66 // been set, which happens during commit. |
66 virtual void PlaybackToCanvas(SkCanvas* canvas, | 67 virtual void PlaybackToCanvas(PaintCanvas* canvas, |
67 const PlaybackSettings& settings) const; | 68 const PlaybackSettings& settings) const; |
68 | 69 |
69 // Returns whether the given rect at given scale is of solid color in | 70 // Returns whether the given rect at given scale is of solid color in |
70 // this raster source, as well as the solid color value. | 71 // this raster source, as well as the solid color value. |
71 bool PerformSolidColorAnalysis(const gfx::Rect& content_rect, | 72 bool PerformSolidColorAnalysis(const gfx::Rect& content_rect, |
72 float contents_scale, | 73 float contents_scale, |
73 SkColor* color) const; | 74 SkColor* color) const; |
74 | 75 |
75 // Returns true iff the whole raster source is of solid color. | 76 // Returns true iff the whole raster source is of solid color. |
76 bool IsSolidColor() const; | 77 bool IsSolidColor() const; |
(...skipping 26 matching lines...) Expand all Loading... |
103 | 104 |
104 // Returns true if this raster source has anything to rasterize. | 105 // Returns true if this raster source has anything to rasterize. |
105 virtual bool HasRecordings() const; | 106 virtual bool HasRecordings() const; |
106 | 107 |
107 // Valid rectangle in which everything is recorded and can be rastered from. | 108 // Valid rectangle in which everything is recorded and can be rastered from. |
108 virtual gfx::Rect RecordedViewport() const; | 109 virtual gfx::Rect RecordedViewport() const; |
109 | 110 |
110 // Tracing functionality. | 111 // Tracing functionality. |
111 virtual void DidBeginTracing(); | 112 virtual void DidBeginTracing(); |
112 virtual void AsValueInto(base::trace_event::TracedValue* array) const; | 113 virtual void AsValueInto(base::trace_event::TracedValue* array) const; |
113 virtual sk_sp<SkPicture> GetFlattenedPicture(); | 114 virtual sk_sp<PaintRecord> GetFlattenedPicture(); |
114 virtual size_t GetPictureMemoryUsage() const; | 115 virtual size_t GetPictureMemoryUsage() const; |
115 | 116 |
116 // Return true if LCD anti-aliasing may be used when rastering text. | 117 // Return true if LCD anti-aliasing may be used when rastering text. |
117 virtual bool CanUseLCDText() const; | 118 virtual bool CanUseLCDText() const; |
118 | 119 |
119 scoped_refptr<RasterSource> CreateCloneWithoutLCDText() const; | 120 scoped_refptr<RasterSource> CreateCloneWithoutLCDText() const; |
120 | 121 |
121 // Image decode controller should be set once. Its lifetime has to exceed that | 122 // Image decode controller should be set once. Its lifetime has to exceed that |
122 // of the raster source, since the raster source will access it during raster. | 123 // of the raster source, since the raster source will access it during raster. |
123 void set_image_decode_cache(ImageDecodeCache* image_decode_cache) { | 124 void set_image_decode_cache(ImageDecodeCache* image_decode_cache) { |
(...skipping 20 matching lines...) Expand all Loading... |
144 const gfx::Rect recorded_viewport_; | 145 const gfx::Rect recorded_viewport_; |
145 const gfx::Size size_; | 146 const gfx::Size size_; |
146 const bool clear_canvas_with_debug_color_; | 147 const bool clear_canvas_with_debug_color_; |
147 const int slow_down_raster_scale_factor_for_debug_; | 148 const int slow_down_raster_scale_factor_for_debug_; |
148 | 149 |
149 // In practice, this is only set once before raster begins, so it's ok with | 150 // In practice, this is only set once before raster begins, so it's ok with |
150 // respect to threading. | 151 // respect to threading. |
151 ImageDecodeCache* image_decode_cache_; | 152 ImageDecodeCache* image_decode_cache_; |
152 | 153 |
153 private: | 154 private: |
154 void RasterCommon(SkCanvas* canvas, SkPicture::AbortCallback* callback) const; | 155 void RasterCommon(PaintCanvas* canvas, |
| 156 PaintRecord::AbortCallback* callback) const; |
155 | 157 |
156 void PrepareForPlaybackToCanvas(SkCanvas* canvas) const; | 158 void PrepareForPlaybackToCanvas(PaintCanvas* canvas) const; |
157 | 159 |
158 DISALLOW_COPY_AND_ASSIGN(RasterSource); | 160 DISALLOW_COPY_AND_ASSIGN(RasterSource); |
159 }; | 161 }; |
160 | 162 |
161 } // namespace cc | 163 } // namespace cc |
162 | 164 |
163 #endif // CC_PLAYBACK_RASTER_SOURCE_H_ | 165 #endif // CC_PLAYBACK_RASTER_SOURCE_H_ |
OLD | NEW |