Chromium Code Reviews| 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/image_id.h" | 16 #include "cc/playback/image_id.h" |
| 17 #include "cc/playback/recording_source.h" | 17 #include "cc/playback/recording_source.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 | 21 |
| 21 namespace cc { | 22 namespace cc { |
| 22 class DisplayItemList; | 23 class DisplayItemList; |
| 23 class DrawImage; | 24 class DrawImage; |
| 24 class ImageDecodeCache; | 25 class ImageDecodeCache; |
| 25 | 26 |
| 26 class CC_EXPORT RasterSource : public base::RefCountedThreadSafe<RasterSource> { | 27 class CC_EXPORT RasterSource : public base::RefCountedThreadSafe<RasterSource> { |
| 27 public: | 28 public: |
| 28 struct CC_EXPORT PlaybackSettings { | 29 struct CC_EXPORT PlaybackSettings { |
| 29 PlaybackSettings(); | 30 PlaybackSettings(); |
| 30 PlaybackSettings(const PlaybackSettings&); | 31 PlaybackSettings(const PlaybackSettings&); |
| 31 PlaybackSettings(PlaybackSettings&&); | 32 PlaybackSettings(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 |
| 46 // If set, use a SkColorSpaceXformCanvas to specify a transform all inputs | |
| 47 // to this color space. | |
| 48 gfx::ColorSpace target_color_space; | |
|
enne (OOO)
2017/03/16 18:20:57
Unused?
ccameron
2017/03/16 21:16:15
Oop. Yup, thats gone.
| |
| 49 | |
| 45 // If non-empty, an image hijack canvas will be used to skip these images | 50 // If non-empty, an image hijack canvas will be used to skip these images |
| 46 // during raster. | 51 // during raster. |
| 47 // TODO(khushalsagar): Consolidate more settings for playback here? See | 52 // TODO(khushalsagar): Consolidate more settings for playback here? See |
| 48 // crbug.com/691076. | 53 // crbug.com/691076. |
| 49 ImageIdFlatSet images_to_skip; | 54 ImageIdFlatSet images_to_skip; |
| 50 }; | 55 }; |
| 51 | 56 |
| 52 static scoped_refptr<RasterSource> CreateFromRecordingSource( | 57 static scoped_refptr<RasterSource> CreateFromRecordingSource( |
| 53 const RecordingSource* other, | 58 const RecordingSource* other, |
| 54 bool can_use_lcd_text); | 59 bool can_use_lcd_text); |
| 55 | 60 |
| 56 // TODO(trchen): Deprecated. | 61 // TODO(trchen): Deprecated. |
| 57 void PlaybackToCanvas(SkCanvas* canvas, | 62 void PlaybackToCanvas(SkCanvas* canvas, |
| 63 const gfx::ColorSpace& canvas_color_space, | |
| 58 const gfx::Rect& canvas_bitmap_rect, | 64 const gfx::Rect& canvas_bitmap_rect, |
| 59 const gfx::Rect& canvas_playback_rect, | 65 const gfx::Rect& canvas_playback_rect, |
| 60 float contents_scale, | 66 float contents_scale, |
| 61 const PlaybackSettings& settings) const; | 67 const PlaybackSettings& settings) const; |
| 62 | 68 |
| 63 // Raster this RasterSource into the given canvas. Canvas states such as | 69 // Raster this RasterSource into the given canvas. Canvas states such as |
| 64 // CTM and clip region will be respected. This function will replace pixels | 70 // CTM and clip region will be respected. This function will replace pixels |
| 65 // in the clip region without blending. It is assumed that existing pixels | 71 // in the clip region without blending. It is assumed that existing pixels |
| 66 // may be uninitialized and will be cleared before playback. | 72 // may be uninitialized and will be cleared before playback. |
| 67 // | 73 // |
| 68 // Virtual for testing. | 74 // Virtual for testing. |
| 69 // | 75 // |
| 70 // Note that this should only be called after the image decode controller has | 76 // Note that this should only be called after the image decode controller has |
| 71 // been set, which happens during commit. | 77 // been set, which happens during commit. |
| 72 virtual void PlaybackToCanvas(SkCanvas* canvas, | 78 virtual void PlaybackToCanvas(SkCanvas* canvas, |
| 79 const gfx::ColorSpace& canvas_color_space, | |
| 73 const PlaybackSettings& settings) const; | 80 const PlaybackSettings& settings) const; |
| 74 | 81 |
| 75 // Returns whether the given rect at given scale is of solid color in | 82 // Returns whether the given rect at given scale is of solid color in |
| 76 // this raster source, as well as the solid color value. | 83 // this raster source, as well as the solid color value. |
| 77 bool PerformSolidColorAnalysis(const gfx::Rect& content_rect, | 84 bool PerformSolidColorAnalysis(const gfx::Rect& content_rect, |
| 78 float contents_scale, | 85 float contents_scale, |
| 79 SkColor* color) const; | 86 SkColor* color) const; |
| 80 | 87 |
| 81 // Returns true iff the whole raster source is of solid color. | 88 // Returns true iff the whole raster source is of solid color. |
| 82 bool IsSolidColor() const; | 89 bool IsSolidColor() const; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 const gfx::Rect recorded_viewport_; | 151 const gfx::Rect recorded_viewport_; |
| 145 const gfx::Size size_; | 152 const gfx::Size size_; |
| 146 const bool clear_canvas_with_debug_color_; | 153 const bool clear_canvas_with_debug_color_; |
| 147 const int slow_down_raster_scale_factor_for_debug_; | 154 const int slow_down_raster_scale_factor_for_debug_; |
| 148 | 155 |
| 149 // In practice, this is only set once before raster begins, so it's ok with | 156 // In practice, this is only set once before raster begins, so it's ok with |
| 150 // respect to threading. | 157 // respect to threading. |
| 151 ImageDecodeCache* image_decode_cache_; | 158 ImageDecodeCache* image_decode_cache_; |
| 152 | 159 |
| 153 private: | 160 private: |
| 154 void RasterCommon(SkCanvas* canvas, SkPicture::AbortCallback* callback) const; | 161 void RasterCommon(SkCanvas* canvas, |
| 162 const gfx::ColorSpace& canvas_color_space, | |
| 163 SkPicture::AbortCallback* callback) const; | |
| 155 | 164 |
| 156 void PrepareForPlaybackToCanvas(SkCanvas* canvas) const; | 165 void PrepareForPlaybackToCanvas(SkCanvas* canvas) const; |
| 157 | 166 |
| 158 DISALLOW_COPY_AND_ASSIGN(RasterSource); | 167 DISALLOW_COPY_AND_ASSIGN(RasterSource); |
| 159 }; | 168 }; |
| 160 | 169 |
| 161 } // namespace cc | 170 } // namespace cc |
| 162 | 171 |
| 163 #endif // CC_PLAYBACK_RASTER_SOURCE_H_ | 172 #endif // CC_PLAYBACK_RASTER_SOURCE_H_ |
| OLD | NEW |