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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "cc/cc_export.h" | 14 #include "cc/cc_export.h" |
15 #include "cc/debug/rendering_stats_instrumentation.h" | 15 #include "cc/debug/rendering_stats_instrumentation.h" |
16 #include "cc/layers/recording_source.h" | 16 #include "cc/layers/recording_source.h" |
17 #include "cc/paint/image_id.h" | 17 #include "cc/paint/image_id.h" |
18 #include "skia/ext/analysis_canvas.h" | 18 #include "skia/ext/analysis_canvas.h" |
19 #include "third_party/skia/include/core/SkPicture.h" | 19 #include "third_party/skia/include/core/SkPicture.h" |
20 #include "ui/gfx/color_space.h" | 20 #include "ui/gfx/color_space.h" |
21 | 21 |
22 namespace cc { | 22 namespace cc { |
23 class DisplayItemList; | 23 class DisplayItemList; |
24 class DrawImage; | 24 class DrawImage; |
25 class ImageDecodeCache; | 25 class ImageDecodeCache; |
| 26 class ScaleTranslate2d; |
26 | 27 |
27 class CC_EXPORT RasterSource : public base::RefCountedThreadSafe<RasterSource> { | 28 class CC_EXPORT RasterSource : public base::RefCountedThreadSafe<RasterSource> { |
28 public: | 29 public: |
29 struct CC_EXPORT PlaybackSettings { | 30 struct CC_EXPORT PlaybackSettings { |
30 PlaybackSettings(); | 31 PlaybackSettings(); |
31 PlaybackSettings(const PlaybackSettings&); | 32 PlaybackSettings(const PlaybackSettings&); |
32 PlaybackSettings(PlaybackSettings&&); | 33 PlaybackSettings(PlaybackSettings&&); |
33 ~PlaybackSettings(); | 34 ~PlaybackSettings(); |
34 | 35 |
35 // If set to true, this indicates that the canvas has already been | 36 // If set to true, this indicates that the canvas has already been |
(...skipping 11 matching lines...) Expand all Loading... |
47 // during raster. | 48 // during raster. |
48 // TODO(khushalsagar): Consolidate more settings for playback here? See | 49 // TODO(khushalsagar): Consolidate more settings for playback here? See |
49 // crbug.com/691076. | 50 // crbug.com/691076. |
50 ImageIdFlatSet images_to_skip; | 51 ImageIdFlatSet images_to_skip; |
51 }; | 52 }; |
52 | 53 |
53 static scoped_refptr<RasterSource> CreateFromRecordingSource( | 54 static scoped_refptr<RasterSource> CreateFromRecordingSource( |
54 const RecordingSource* other, | 55 const RecordingSource* other, |
55 bool can_use_lcd_text); | 56 bool can_use_lcd_text); |
56 | 57 |
57 // TODO(trchen): Deprecated. | 58 // Helper function to apply a few common operations before passing the canvas |
| 59 // to the shorter version. This is useful for rastering into tiles. |
| 60 // canvas is expected to be backed by a tile, with a default state. |
| 61 // raster_transform will be applied to the display list, rastering the list |
| 62 // into the "content space". |
| 63 // canvas_bitmap_rect defines the extent of the tile in the content space, |
| 64 // i.e. contents in the rect will be cropped and translated onto the canvas. |
| 65 // canvas_playback_rect can be used to replay only part of the recording in, |
| 66 // the content space, so only a sub-rect of the tile gets rastered. |
58 void PlaybackToCanvas(SkCanvas* canvas, | 67 void PlaybackToCanvas(SkCanvas* canvas, |
59 const gfx::ColorSpace& canvas_color_space, | 68 const gfx::ColorSpace& canvas_color_space, |
60 const gfx::Rect& canvas_bitmap_rect, | 69 const gfx::Rect& canvas_bitmap_rect, |
61 const gfx::Rect& canvas_playback_rect, | 70 const gfx::Rect& canvas_playback_rect, |
62 float contents_scale, | 71 const ScaleTranslate2d& raster_transform, |
63 const PlaybackSettings& settings) const; | 72 const PlaybackSettings& settings) const; |
64 | 73 |
65 // Raster this RasterSource into the given canvas. Canvas states such as | 74 // Raster this RasterSource into the given canvas. Canvas states such as |
66 // CTM and clip region will be respected. This function will replace pixels | 75 // CTM and clip region will be respected. This function will replace pixels |
67 // in the clip region without blending. It is assumed that existing pixels | 76 // in the clip region without blending. It is assumed that existing pixels |
68 // may be uninitialized and will be cleared before playback. | 77 // may be uninitialized and will be cleared before playback. |
69 // | 78 // |
70 // Virtual for testing. | 79 // Virtual for testing. |
71 // | 80 // |
72 // Note that this should only be called after the image decode controller has | 81 // Note that this should only be called after the image decode controller has |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 SkPicture::AbortCallback* callback) const; | 168 SkPicture::AbortCallback* callback) const; |
160 | 169 |
161 void PrepareForPlaybackToCanvas(SkCanvas* canvas) const; | 170 void PrepareForPlaybackToCanvas(SkCanvas* canvas) const; |
162 | 171 |
163 DISALLOW_COPY_AND_ASSIGN(RasterSource); | 172 DISALLOW_COPY_AND_ASSIGN(RasterSource); |
164 }; | 173 }; |
165 | 174 |
166 } // namespace cc | 175 } // namespace cc |
167 | 176 |
168 #endif // CC_RASTER_RASTER_SOURCE_H_ | 177 #endif // CC_RASTER_RASTER_SOURCE_H_ |
OLD | NEW |