Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: cc/playback/raster_source.h

Issue 2748263002: Move cc::DisplayItemList and related classes into cc/paint/ (Closed)
Patch Set: Merge branch 'master' into ccpaint Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/playback/largest_display_item.cc ('k') | cc/playback/raster_source.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CC_PLAYBACK_RASTER_SOURCE_H_
6 #define CC_PLAYBACK_RASTER_SOURCE_H_
7
8 #include <stddef.h>
9
10 #include <memory>
11 #include <vector>
12
13 #include "base/macros.h"
14 #include "cc/base/cc_export.h"
15 #include "cc/debug/rendering_stats_instrumentation.h"
16 #include "cc/playback/image_id.h"
17 #include "cc/playback/recording_source.h"
18 #include "skia/ext/analysis_canvas.h"
19 #include "third_party/skia/include/core/SkPicture.h"
20 #include "ui/gfx/color_space.h"
21
22 namespace cc {
23 class DisplayItemList;
24 class DrawImage;
25 class ImageDecodeCache;
26
27 class CC_EXPORT RasterSource : public base::RefCountedThreadSafe<RasterSource> {
28 public:
29 struct CC_EXPORT PlaybackSettings {
30 PlaybackSettings();
31 PlaybackSettings(const PlaybackSettings&);
32 PlaybackSettings(PlaybackSettings&&);
33 ~PlaybackSettings();
34
35 // If set to true, this indicates that the canvas has already been
36 // rasterized into. This means that the canvas cannot be cleared safely.
37 bool playback_to_shared_canvas;
38
39 // If set to true, none of the images will be rasterized.
40 bool skip_images;
41
42 // If set to true, we will use an image hijack canvas, which enables
43 // compositor image caching.
44 bool use_image_hijack_canvas;
45
46 // If non-empty, an image hijack canvas will be used to skip these images
47 // during raster.
48 // TODO(khushalsagar): Consolidate more settings for playback here? See
49 // crbug.com/691076.
50 ImageIdFlatSet images_to_skip;
51 };
52
53 static scoped_refptr<RasterSource> CreateFromRecordingSource(
54 const RecordingSource* other,
55 bool can_use_lcd_text);
56
57 // TODO(trchen): Deprecated.
58 void PlaybackToCanvas(SkCanvas* canvas,
59 const gfx::ColorSpace& canvas_color_space,
60 const gfx::Rect& canvas_bitmap_rect,
61 const gfx::Rect& canvas_playback_rect,
62 float contents_scale,
63 const PlaybackSettings& settings) const;
64
65 // Raster this RasterSource into the given canvas. Canvas states such as
66 // 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
68 // may be uninitialized and will be cleared before playback.
69 //
70 // Virtual for testing.
71 //
72 // Note that this should only be called after the image decode controller has
73 // been set, which happens during commit.
74 virtual void PlaybackToCanvas(SkCanvas* canvas,
75 const gfx::ColorSpace& canvas_color_space,
76 const PlaybackSettings& settings) const;
77
78 // Returns whether the given rect at given scale is of solid color in
79 // this raster source, as well as the solid color value.
80 bool PerformSolidColorAnalysis(const gfx::Rect& content_rect,
81 float contents_scale,
82 SkColor* color) const;
83
84 // Returns true iff the whole raster source is of solid color.
85 bool IsSolidColor() const;
86
87 // Returns the color of the raster source if it is solid color. The results
88 // are unspecified if IsSolidColor returns false.
89 SkColor GetSolidColor() const;
90
91 // Returns the size of this raster source.
92 gfx::Size GetSize() const;
93
94 // Populate the given list with all images that may overlap the given
95 // rect in layer space. The returned draw images' matrices are modified as if
96 // they were being using during raster at scale |raster_scale|.
97 void GetDiscardableImagesInRect(const gfx::Rect& layer_rect,
98 float contents_scale,
99 std::vector<DrawImage>* images) const;
100
101 // Return true iff this raster source can raster the given rect in layer
102 // space.
103 bool CoversRect(const gfx::Rect& layer_rect) const;
104
105 // Returns true if this raster source has anything to rasterize.
106 virtual bool HasRecordings() const;
107
108 // Valid rectangle in which everything is recorded and can be rastered from.
109 virtual gfx::Rect RecordedViewport() const;
110
111 gfx::Rect GetRectForImage(ImageId image_id) const;
112
113 // Tracing functionality.
114 virtual void DidBeginTracing();
115 virtual void AsValueInto(base::trace_event::TracedValue* array) const;
116 virtual sk_sp<SkPicture> GetFlattenedPicture();
117 virtual size_t GetMemoryUsage() const;
118
119 // Return true if LCD anti-aliasing may be used when rastering text.
120 virtual bool CanUseLCDText() const;
121
122 scoped_refptr<RasterSource> CreateCloneWithoutLCDText() const;
123
124 // Image decode controller should be set once. Its lifetime has to exceed that
125 // of the raster source, since the raster source will access it during raster.
126 void set_image_decode_cache(ImageDecodeCache* image_decode_cache) {
127 DCHECK(image_decode_cache);
128 image_decode_cache_ = image_decode_cache;
129 }
130
131 protected:
132 friend class base::RefCountedThreadSafe<RasterSource>;
133
134 RasterSource(const RecordingSource* other, bool can_use_lcd_text);
135 RasterSource(const RasterSource* other, bool can_use_lcd_text);
136 virtual ~RasterSource();
137
138 // These members are const as this raster source may be in use on another
139 // thread and so should not be touched after construction.
140 const scoped_refptr<DisplayItemList> display_list_;
141 const size_t painter_reported_memory_usage_;
142 const SkColor background_color_;
143 const bool requires_clear_;
144 const bool can_use_lcd_text_;
145 const bool is_solid_color_;
146 const SkColor solid_color_;
147 const gfx::Rect recorded_viewport_;
148 const gfx::Size size_;
149 const bool clear_canvas_with_debug_color_;
150 const int slow_down_raster_scale_factor_for_debug_;
151
152 // In practice, this is only set once before raster begins, so it's ok with
153 // respect to threading.
154 ImageDecodeCache* image_decode_cache_;
155
156 private:
157 void RasterCommon(SkCanvas* canvas,
158 const gfx::ColorSpace& canvas_color_space,
159 SkPicture::AbortCallback* callback) const;
160
161 void PrepareForPlaybackToCanvas(SkCanvas* canvas) const;
162
163 DISALLOW_COPY_AND_ASSIGN(RasterSource);
164 };
165
166 } // namespace cc
167
168 #endif // CC_PLAYBACK_RASTER_SOURCE_H_
OLDNEW
« no previous file with comments | « cc/playback/largest_display_item.cc ('k') | cc/playback/raster_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698