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

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

Issue 666273002: cc: Added raster source. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reviews Created 6 years, 1 month 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 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 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_RESOURCES_PICTURE_PILE_IMPL_H_ 5 #ifndef CC_RESOURCES_PICTURE_PILE_IMPL_H_
6 #define CC_RESOURCES_PICTURE_PILE_IMPL_H_ 6 #define CC_RESOURCES_PICTURE_PILE_IMPL_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/time/time.h" 13 #include "base/time/time.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/resources/picture_pile_base.h" 16 #include "cc/resources/picture_pile_base.h"
17 #include "cc/resources/raster_source.h"
17 #include "skia/ext/analysis_canvas.h" 18 #include "skia/ext/analysis_canvas.h"
18 #include "skia/ext/refptr.h" 19 #include "skia/ext/refptr.h"
19 #include "third_party/skia/include/core/SkPicture.h" 20 #include "third_party/skia/include/core/SkPicture.h"
20 21
21 namespace cc { 22 namespace cc {
22 23
23 class CC_EXPORT PicturePileImpl : public PicturePileBase { 24 class CC_EXPORT PicturePileImpl : public PicturePileBase, public RasterSource {
24 public: 25 public:
25 static scoped_refptr<PicturePileImpl> Create(); 26 static scoped_refptr<PicturePileImpl> Create();
26 static scoped_refptr<PicturePileImpl> CreateFromOther( 27 static scoped_refptr<PicturePileImpl> CreateFromOther(
27 const PicturePileBase* other); 28 const PicturePileBase* other);
28 29
29 // Raster a subrect of this PicturePileImpl into the given canvas. It is 30 // RasterSource overrides. See RasterSource header for full description.
30 // assumed that contents_scale has already been applied to this canvas. 31 // When slow-down-raster-scale-factor is set to a value greater than 1, the
31 // Writes the total number of pixels rasterized and the time spent 32 // reported rasterize time (in stats_instrumentation) is the minimum measured
32 // rasterizing to the stats if the respective pointer is not NULL. When 33 // value over all runs.
33 // slow-down-raster-scale-factor is set to a value greater than 1, the 34 void RasterToBitmap(
34 // reported rasterize time is the minimum measured value over all runs. 35 SkCanvas* canvas,
36 const gfx::Rect& canvas_rect,
37 float contents_scale,
38 RenderingStatsInstrumentation* stats_instrumentation) const override;
39 void AnalyzeInRect(
40 const gfx::Rect& content_rect,
41 float contents_scale,
42 RasterSource::Analysis* analysis,
43 RenderingStatsInstrumentation* stats_instrumentation) const override;
44 void GatherPixelRefs(const gfx::Rect& content_rect,
45 float contents_scale,
46 std::vector<SkPixelRef*>* pixel_refs) const override;
47 bool RasterCoversRect(const gfx::Rect& content_rect,
48 float contents_scale) const override;
49 bool SuitableForDistanceFieldText() const override;
50
51 // Raster into the canvas without applying clips.
35 void RasterDirect( 52 void RasterDirect(
36 SkCanvas* canvas, 53 SkCanvas* canvas,
37 const gfx::Rect& canvas_rect, 54 const gfx::Rect& canvas_rect,
38 float contents_scale, 55 float contents_scale,
39 RenderingStatsInstrumentation* rendering_stats_instrumentation); 56 RenderingStatsInstrumentation* rendering_stats_instrumentation) const;
40 57
41 // Similar to the above RasterDirect method, but this is a convenience method 58 // Tracing functionality.
42 // for when it is known that the raster is going to an intermediate bitmap 59 void DidBeginTracing();
43 // that itself will then be blended and thus that a canvas clear is required.
44 // Note that this function may write outside the canvas_rect.
45 void RasterToBitmap(
46 SkCanvas* canvas,
47 const gfx::Rect& canvas_rect,
48 float contents_scale,
49 RenderingStatsInstrumentation* stats_instrumentation) const;
50
51 // Called when analyzing a tile. We can use AnalysisCanvas as
52 // SkDrawPictureCallback, which allows us to early out from analysis.
53 void RasterForAnalysis(
54 skia::AnalysisCanvas* canvas,
55 const gfx::Rect& canvas_rect,
56 float contents_scale,
57 RenderingStatsInstrumentation* stats_instrumentation) const;
58
59 skia::RefPtr<SkPicture> GetFlattenedPicture(); 60 skia::RefPtr<SkPicture> GetFlattenedPicture();
60 61
61 bool likely_to_be_used_for_transform_animation() const {
62 return likely_to_be_used_for_transform_animation_;
63 }
64 void set_likely_to_be_used_for_transform_animation() { 62 void set_likely_to_be_used_for_transform_animation() {
65 likely_to_be_used_for_transform_animation_ = true; 63 likely_to_be_used_for_transform_animation_ = true;
66 } 64 }
67 65
68 struct CC_EXPORT Analysis { 66 // Iterator used to return SkPixelRefs from this picture pile.
69 Analysis(); 67 // Public for testing.
70 ~Analysis();
71
72 bool is_solid_color;
73 SkColor solid_color;
74 };
75
76 void AnalyzeInRect(const gfx::Rect& content_rect,
77 float contents_scale,
78 Analysis* analysis) const;
79
80 void AnalyzeInRect(
81 const gfx::Rect& content_rect,
82 float contents_scale,
83 Analysis* analysis,
84 RenderingStatsInstrumentation* stats_instrumentation) const;
85
86 class CC_EXPORT PixelRefIterator { 68 class CC_EXPORT PixelRefIterator {
87 public: 69 public:
88 PixelRefIterator(const gfx::Rect& content_rect, 70 PixelRefIterator(const gfx::Rect& content_rect,
89 float contents_scale, 71 float contents_scale,
90 const PicturePileImpl* picture_pile); 72 const PicturePileImpl* picture_pile);
91 ~PixelRefIterator(); 73 ~PixelRefIterator();
92 74
93 SkPixelRef* operator->() const { return *pixel_ref_iterator_; } 75 SkPixelRef* operator->() const { return *pixel_ref_iterator_; }
94 SkPixelRef* operator*() const { return *pixel_ref_iterator_; } 76 SkPixelRef* operator*() const { return *pixel_ref_iterator_; }
95 PixelRefIterator& operator++(); 77 PixelRefIterator& operator++();
96 operator bool() const { return pixel_ref_iterator_; } 78 operator bool() const { return pixel_ref_iterator_; }
97 79
98 private: 80 private:
99 void AdvanceToTilePictureWithPixelRefs(); 81 void AdvanceToTilePictureWithPixelRefs();
100 82
101 const PicturePileImpl* picture_pile_; 83 const PicturePileImpl* picture_pile_;
102 gfx::Rect layer_rect_; 84 gfx::Rect layer_rect_;
103 TilingData::Iterator tile_iterator_; 85 TilingData::Iterator tile_iterator_;
104 Picture::PixelRefIterator pixel_ref_iterator_; 86 Picture::PixelRefIterator pixel_ref_iterator_;
105 std::set<const void*> processed_pictures_; 87 std::set<const void*> processed_pictures_;
106 }; 88 };
107 89
108 void DidBeginTracing();
109
110 protected: 90 protected:
111 friend class PicturePile; 91 friend class PicturePile;
112 friend class PixelRefIterator; 92 friend class PixelRefIterator;
113 93
114 PicturePileImpl(); 94 PicturePileImpl();
115 explicit PicturePileImpl(const PicturePileBase* other); 95 explicit PicturePileImpl(const PicturePileBase* other);
116 ~PicturePileImpl() override; 96 ~PicturePileImpl() override;
117 97
118 private: 98 private:
119 typedef std::map<const Picture*, Region> PictureRegionMap; 99 typedef std::map<const Picture*, Region> PictureRegionMap;
120 100
101 // Called when analyzing a tile. We can use AnalysisCanvas as
102 // SkDrawPictureCallback, which allows us to early out from analysis.
103 void RasterForAnalysis(
104 skia::AnalysisCanvas* canvas,
105 const gfx::Rect& canvas_rect,
106 float contents_scale,
107 RenderingStatsInstrumentation* stats_instrumentation) const;
108
121 void CoalesceRasters(const gfx::Rect& canvas_rect, 109 void CoalesceRasters(const gfx::Rect& canvas_rect,
122 const gfx::Rect& content_rect, 110 const gfx::Rect& content_rect,
123 float contents_scale, 111 float contents_scale,
124 PictureRegionMap* result) const; 112 PictureRegionMap* result) const;
125 113
126 void RasterCommon( 114 void RasterCommon(
127 SkCanvas* canvas, 115 SkCanvas* canvas,
128 SkDrawPictureCallback* callback, 116 SkDrawPictureCallback* callback,
129 const gfx::Rect& canvas_rect, 117 const gfx::Rect& canvas_rect,
130 float contents_scale, 118 float contents_scale,
131 RenderingStatsInstrumentation* rendering_stats_instrumentation, 119 RenderingStatsInstrumentation* rendering_stats_instrumentation,
132 bool is_analysis) const; 120 bool is_analysis) const;
133 121
134 bool likely_to_be_used_for_transform_animation_; 122 bool likely_to_be_used_for_transform_animation_;
135 123
136 DISALLOW_COPY_AND_ASSIGN(PicturePileImpl); 124 DISALLOW_COPY_AND_ASSIGN(PicturePileImpl);
137 }; 125 };
138 126
139 } // namespace cc 127 } // namespace cc
140 128
141 #endif // CC_RESOURCES_PICTURE_PILE_IMPL_H_ 129 #endif // CC_RESOURCES_PICTURE_PILE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698