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/playback/recording_source.h" | 16 #include "cc/playback/recording_source.h" |
17 #include "skia/ext/analysis_canvas.h" | 17 #include "skia/ext/analysis_canvas.h" |
18 #include "third_party/skia/include/core/SkPicture.h" | 18 #include "third_party/skia/include/core/SkPicture.h" |
19 | 19 |
20 namespace gfx { | 20 namespace gfx { |
21 class ColorSpace; | 21 class ColorSpace; |
22 } | 22 } |
23 | 23 |
24 namespace cc { | 24 namespace cc { |
25 class DisplayItemList; | 25 class DisplayItemList; |
26 class DrawImage; | 26 class DrawImage; |
27 class ImageDecodeCache; | 27 class ImageDecodeCache; |
| 28 class ScaleTranslate2d; |
28 | 29 |
29 class CC_EXPORT RasterSource : public base::RefCountedThreadSafe<RasterSource> { | 30 class CC_EXPORT RasterSource : public base::RefCountedThreadSafe<RasterSource> { |
30 public: | 31 public: |
31 struct CC_EXPORT PlaybackSettings { | 32 struct CC_EXPORT PlaybackSettings { |
32 PlaybackSettings(); | 33 PlaybackSettings(); |
33 | 34 |
34 // If set to true, this indicates that the canvas has already been | 35 // 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 // rasterized into. This means that the canvas cannot be cleared safely. |
36 bool playback_to_shared_canvas; | 37 bool playback_to_shared_canvas; |
37 | 38 |
38 // If set to true, none of the images will be rasterized. | 39 // If set to true, none of the images will be rasterized. |
39 bool skip_images; | 40 bool skip_images; |
40 | 41 |
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 // Helper function to apply a few common operations before passing the canvas |
| 52 // to the shorter version. This is useful for rastering into tiles. |
| 53 // canvas is expected to be backed by a tile, with a default state. |
| 54 // raster_transform will be applied to the display list, rastering the list |
| 55 // into the "content space". |
| 56 // canvas_bitmap_rect defines the extent of the tile in the content space, |
| 57 // i.e. contents in the rect will be cropped and translated onto the canvas. |
| 58 // canvas_playback_rect can be used to replay only part of the recording in, |
| 59 // the content space, so only a sub-rect of the tile gets rastered. |
51 void PlaybackToCanvas(SkCanvas* canvas, | 60 void PlaybackToCanvas(SkCanvas* canvas, |
52 const gfx::Rect& canvas_bitmap_rect, | 61 const gfx::Rect& canvas_bitmap_rect, |
53 const gfx::Rect& canvas_playback_rect, | 62 const gfx::Rect& canvas_playback_rect, |
54 const gfx::SizeF& raster_scales, | 63 const ScaleTranslate2d& raster_transform, |
55 const PlaybackSettings& settings) const; | 64 const PlaybackSettings& settings) const; |
56 | 65 |
57 // Raster this RasterSource into the given canvas. Canvas states such as | 66 // Raster this RasterSource into the given canvas. Canvas states such as |
58 // CTM and clip region will be respected. This function will replace pixels | 67 // 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 | 68 // in the clip region without blending. It is assumed that existing pixels |
60 // may be uninitialized and will be cleared before playback. | 69 // may be uninitialized and will be cleared before playback. |
61 // | 70 // |
62 // Virtual for testing. | 71 // Virtual for testing. |
63 // | 72 // |
64 // Note that this should only be called after the image decode controller has | 73 // Note that this should only be called after the image decode controller has |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 void RasterCommon(SkCanvas* canvas, SkPicture::AbortCallback* callback) const; | 183 void RasterCommon(SkCanvas* canvas, SkPicture::AbortCallback* callback) const; |
175 | 184 |
176 void PrepareForPlaybackToCanvas(SkCanvas* canvas) const; | 185 void PrepareForPlaybackToCanvas(SkCanvas* canvas) const; |
177 | 186 |
178 DISALLOW_COPY_AND_ASSIGN(RasterSource); | 187 DISALLOW_COPY_AND_ASSIGN(RasterSource); |
179 }; | 188 }; |
180 | 189 |
181 } // namespace cc | 190 } // namespace cc |
182 | 191 |
183 #endif // CC_PLAYBACK_RASTER_SOURCE_H_ | 192 #endif // CC_PLAYBACK_RASTER_SOURCE_H_ |
OLD | NEW |