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

Side by Side Diff: cc/resources/picture_pile_impl.h

Issue 1144693002: cc: Move files out of cc/resources/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resources: android Created 5 years, 7 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/resources/picture_pile.cc ('k') | cc/resources/picture_pile_impl.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 2012 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_RESOURCES_PICTURE_PILE_IMPL_H_
6 #define CC_RESOURCES_PICTURE_PILE_IMPL_H_
7
8 #include <map>
9 #include <set>
10 #include <vector>
11
12 #include "base/time/time.h"
13 #include "cc/base/cc_export.h"
14 #include "cc/debug/rendering_stats_instrumentation.h"
15 #include "cc/resources/picture_pile.h"
16 #include "cc/resources/pixel_ref_map.h"
17 #include "cc/resources/raster_source.h"
18 #include "skia/ext/analysis_canvas.h"
19 #include "skia/ext/refptr.h"
20
21 class SkCanvas;
22 class SkPicture;
23 class SkPixelRef;
24
25 namespace gfx {
26 class Rect;
27 }
28
29 namespace cc {
30
31 class CC_EXPORT PicturePileImpl : public RasterSource {
32 public:
33 static scoped_refptr<PicturePileImpl> CreateFromPicturePile(
34 const PicturePile* other,
35 bool can_use_lcd_text);
36
37 // RasterSource overrides. See RasterSource header for full description.
38 // When slow-down-raster-scale-factor is set to a value greater than 1, the
39 // reported rasterize time (in stats_instrumentation) is the minimum measured
40 // value over all runs.
41 void PlaybackToCanvas(SkCanvas* canvas,
42 const gfx::Rect& canvas_rect,
43 float contents_scale) const override;
44 void PlaybackToSharedCanvas(SkCanvas* canvas,
45 const gfx::Rect& canvas_rect,
46 float contents_scale) const override;
47 void PerformSolidColorAnalysis(
48 const gfx::Rect& content_rect,
49 float contents_scale,
50 RasterSource::SolidColorAnalysis* analysis) const override;
51 void GatherPixelRefs(const gfx::Rect& content_rect,
52 float contents_scale,
53 std::vector<SkPixelRef*>* pixel_refs) const override;
54 bool CoversRect(const gfx::Rect& content_rect,
55 float contents_scale) const override;
56 void SetShouldAttemptToUseDistanceFieldText() override;
57 bool ShouldAttemptToUseDistanceFieldText() const override;
58 gfx::Size GetSize() const override;
59 bool IsSolidColor() const override;
60 SkColor GetSolidColor() const override;
61 bool HasRecordings() const override;
62 bool CanUseLCDText() const override;
63 scoped_refptr<RasterSource> CreateCloneWithoutLCDText() const override;
64
65 // Tracing functionality.
66 void DidBeginTracing() override;
67 void AsValueInto(base::trace_event::TracedValue* array) const override;
68 skia::RefPtr<SkPicture> GetFlattenedPicture() override;
69 size_t GetPictureMemoryUsage() const override;
70
71 // Iterator used to return SkPixelRefs from this picture pile.
72 // Public for testing.
73 class CC_EXPORT PixelRefIterator {
74 public:
75 PixelRefIterator(const gfx::Rect& content_rect,
76 float contents_scale,
77 const PicturePileImpl* picture_pile);
78 ~PixelRefIterator();
79
80 SkPixelRef* operator->() const { return *pixel_ref_iterator_; }
81 SkPixelRef* operator*() const { return *pixel_ref_iterator_; }
82 PixelRefIterator& operator++();
83 operator bool() const { return pixel_ref_iterator_; }
84
85 private:
86 void AdvanceToTilePictureWithPixelRefs();
87
88 const PicturePileImpl* picture_pile_;
89 gfx::Rect layer_rect_;
90 TilingData::Iterator tile_iterator_;
91 PixelRefMap::Iterator pixel_ref_iterator_;
92 std::set<const void*> processed_pictures_;
93 };
94
95 protected:
96 friend class PicturePile;
97 friend class PixelRefIterator;
98
99 using PictureMapKey = PicturePile::PictureMapKey;
100 using PictureMap = PicturePile::PictureMap;
101
102 PicturePileImpl();
103 explicit PicturePileImpl(const PicturePile* other, bool can_use_lcd_text);
104 explicit PicturePileImpl(const PicturePileImpl* other, bool can_use_lcd_text);
105 ~PicturePileImpl() override;
106
107 int buffer_pixels() const { return tiling_.border_texels(); }
108
109 // These members are const as this raster source may be in use on another
110 // thread and so should not be touched after construction.
111 const PictureMap picture_map_;
112 const TilingData tiling_;
113 const SkColor background_color_;
114 const bool requires_clear_;
115 const bool can_use_lcd_text_;
116 const bool is_solid_color_;
117 const SkColor solid_color_;
118 const gfx::Rect recorded_viewport_;
119 const bool has_any_recordings_;
120 const bool clear_canvas_with_debug_color_;
121 const float min_contents_scale_;
122 const int slow_down_raster_scale_factor_for_debug_;
123 // TODO(enne/vmiura): this has a read/write race between raster and compositor
124 // threads with multi-threaded Ganesh. Make this const or remove it.
125 bool should_attempt_to_use_distance_field_text_;
126
127 size_t picture_memory_usage_;
128
129 private:
130 typedef std::map<const Picture*, Region> PictureRegionMap;
131
132 // Called when analyzing a tile. We can use AnalysisCanvas as
133 // SkDrawPictureCallback, which allows us to early out from analysis.
134 void RasterForAnalysis(skia::AnalysisCanvas* canvas,
135 const gfx::Rect& canvas_rect,
136 float contents_scale) const;
137
138 void CoalesceRasters(const gfx::Rect& canvas_rect,
139 const gfx::Rect& content_rect,
140 float contents_scale,
141 PictureRegionMap* result) const;
142
143 void RasterCommon(SkCanvas* canvas,
144 SkDrawPictureCallback* callback,
145 const gfx::Rect& canvas_rect,
146 float contents_scale) const;
147
148 // An internal CanRaster check that goes to the picture_map rather than
149 // using the recorded_viewport hint.
150 bool CanRasterSlowTileCheck(const gfx::Rect& layer_rect) const;
151
152 gfx::Rect PaddedRect(const PictureMapKey& key) const;
153
154 DISALLOW_COPY_AND_ASSIGN(PicturePileImpl);
155 };
156
157 } // namespace cc
158
159 #endif // CC_RESOURCES_PICTURE_PILE_IMPL_H_
OLDNEW
« no previous file with comments | « cc/resources/picture_pile.cc ('k') | cc/resources/picture_pile_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698