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

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: thread safe 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 description.
30 // assumed that contents_scale has already been applied to this canvas. 31 void RasterToBitmap(
31 // Writes the total number of pixels rasterized and the time spent 32 SkCanvas* canvas,
32 // rasterizing to the stats if the respective pointer is not NULL. When 33 const gfx::Rect& canvas_rect,
33 // slow-down-raster-scale-factor is set to a value greater than 1, the 34 float contents_scale,
34 // reported rasterize time is the minimum measured value over all runs. 35 RenderingStatsInstrumentation* stats_instrumentation) const override;
36 void AnalyzeInRect(
37 const gfx::Rect& content_rect,
38 float contents_scale,
39 RasterSource::Analysis* analysis,
40 RenderingStatsInstrumentation* stats_instrumentation) const override;
41 void GatherPixelRefs(const gfx::Rect& content_rect,
42 float contents_scale,
43 std::vector<SkPixelRef*>* pixel_refs) const override;
44 bool RasterCoversRect(const gfx::Rect& content_rect,
45 float contents_scale) const override;
46 bool SuitableForDistanceFieldText() const override;
47
48 // Raster into the canvas without applying clips.
35 void RasterDirect( 49 void RasterDirect(
36 SkCanvas* canvas, 50 SkCanvas* canvas,
37 const gfx::Rect& canvas_rect, 51 const gfx::Rect& canvas_rect,
38 float contents_scale, 52 float contents_scale,
39 RenderingStatsInstrumentation* rendering_stats_instrumentation); 53 RenderingStatsInstrumentation* rendering_stats_instrumentation) const;
40 54
41 // Similar to the above RasterDirect method, but this is a convenience method 55 // Tracing functionality.
42 // for when it is known that the raster is going to an intermediate bitmap 56 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(); 57 skia::RefPtr<SkPicture> GetFlattenedPicture();
60 58
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() { 59 void set_likely_to_be_used_for_transform_animation() {
65 likely_to_be_used_for_transform_animation_ = true; 60 likely_to_be_used_for_transform_animation_ = true;
66 } 61 }
67 62
68 struct CC_EXPORT Analysis { 63 // Iterator used to return SkPixelRefs from this picture pile.
69 Analysis(); 64 // 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 { 65 class CC_EXPORT PixelRefIterator {
87 public: 66 public:
88 PixelRefIterator(const gfx::Rect& content_rect, 67 PixelRefIterator(const gfx::Rect& content_rect,
89 float contents_scale, 68 float contents_scale,
90 const PicturePileImpl* picture_pile); 69 const PicturePileImpl* picture_pile);
91 ~PixelRefIterator(); 70 ~PixelRefIterator();
92 71
93 SkPixelRef* operator->() const { return *pixel_ref_iterator_; } 72 SkPixelRef* operator->() const { return *pixel_ref_iterator_; }
94 SkPixelRef* operator*() const { return *pixel_ref_iterator_; } 73 SkPixelRef* operator*() const { return *pixel_ref_iterator_; }
95 PixelRefIterator& operator++(); 74 PixelRefIterator& operator++();
96 operator bool() const { return pixel_ref_iterator_; } 75 operator bool() const { return pixel_ref_iterator_; }
97 76
98 private: 77 private:
99 void AdvanceToTilePictureWithPixelRefs(); 78 void AdvanceToTilePictureWithPixelRefs();
100 79
101 const PicturePileImpl* picture_pile_; 80 const PicturePileImpl* picture_pile_;
102 gfx::Rect layer_rect_; 81 gfx::Rect layer_rect_;
103 TilingData::Iterator tile_iterator_; 82 TilingData::Iterator tile_iterator_;
104 Picture::PixelRefIterator pixel_ref_iterator_; 83 Picture::PixelRefIterator pixel_ref_iterator_;
105 std::set<const void*> processed_pictures_; 84 std::set<const void*> processed_pictures_;
106 }; 85 };
107 86
108 void DidBeginTracing();
109
110 protected: 87 protected:
111 friend class PicturePile; 88 friend class PicturePile;
112 friend class PixelRefIterator; 89 friend class PixelRefIterator;
113 90
114 PicturePileImpl(); 91 PicturePileImpl();
115 explicit PicturePileImpl(const PicturePileBase* other); 92 explicit PicturePileImpl(const PicturePileBase* other);
116 ~PicturePileImpl() override; 93 ~PicturePileImpl() override;
117 94
118 private: 95 private:
119 typedef std::map<const Picture*, Region> PictureRegionMap; 96 typedef std::map<const Picture*, Region> PictureRegionMap;
120 97
98 // Called when analyzing a tile. We can use AnalysisCanvas as
99 // SkDrawPictureCallback, which allows us to early out from analysis.
100 void RasterForAnalysis(
101 skia::AnalysisCanvas* canvas,
102 const gfx::Rect& canvas_rect,
103 float contents_scale,
104 RenderingStatsInstrumentation* stats_instrumentation) const;
105
121 void CoalesceRasters(const gfx::Rect& canvas_rect, 106 void CoalesceRasters(const gfx::Rect& canvas_rect,
122 const gfx::Rect& content_rect, 107 const gfx::Rect& content_rect,
123 float contents_scale, 108 float contents_scale,
124 PictureRegionMap* result) const; 109 PictureRegionMap* result) const;
125 110
126 void RasterCommon( 111 void RasterCommon(
127 SkCanvas* canvas, 112 SkCanvas* canvas,
128 SkDrawPictureCallback* callback, 113 SkDrawPictureCallback* callback,
129 const gfx::Rect& canvas_rect, 114 const gfx::Rect& canvas_rect,
130 float contents_scale, 115 float contents_scale,
131 RenderingStatsInstrumentation* rendering_stats_instrumentation, 116 RenderingStatsInstrumentation* rendering_stats_instrumentation,
132 bool is_analysis) const; 117 bool is_analysis) const;
133 118
134 bool likely_to_be_used_for_transform_animation_; 119 bool likely_to_be_used_for_transform_animation_;
135 120
136 DISALLOW_COPY_AND_ASSIGN(PicturePileImpl); 121 DISALLOW_COPY_AND_ASSIGN(PicturePileImpl);
137 }; 122 };
138 123
139 } // namespace cc 124 } // namespace cc
140 125
141 #endif // CC_RESOURCES_PICTURE_PILE_IMPL_H_ 126 #endif // CC_RESOURCES_PICTURE_PILE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698