OLD | NEW |
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 <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "cc/base/cc_export.h" | 13 #include "cc/base/cc_export.h" |
| 14 #include "cc/debug/rendering_stats_instrumentation.h" |
14 #include "cc/resources/picture_pile_base.h" | 15 #include "cc/resources/picture_pile_base.h" |
15 #include "skia/ext/analysis_canvas.h" | 16 #include "skia/ext/analysis_canvas.h" |
16 #include "skia/ext/refptr.h" | 17 #include "skia/ext/refptr.h" |
17 #include "third_party/skia/include/core/SkPicture.h" | 18 #include "third_party/skia/include/core/SkPicture.h" |
18 | 19 |
19 namespace cc { | 20 namespace cc { |
20 | 21 |
21 class CC_EXPORT PicturePileImpl : public PicturePileBase { | 22 class CC_EXPORT PicturePileImpl : public PicturePileBase { |
22 public: | 23 public: |
23 static scoped_refptr<PicturePileImpl> Create(); | 24 static scoped_refptr<PicturePileImpl> Create(); |
24 static scoped_refptr<PicturePileImpl> CreateFromOther( | 25 static scoped_refptr<PicturePileImpl> CreateFromOther( |
25 const PicturePileBase* other); | 26 const PicturePileBase* other); |
26 | 27 |
27 // Get paint-safe version of this picture for a specific thread. | 28 // Get paint-safe version of this picture for a specific thread. |
28 PicturePileImpl* GetCloneForDrawingOnThread(unsigned thread_index) const; | 29 PicturePileImpl* GetCloneForDrawingOnThread(unsigned thread_index) const; |
29 | 30 |
30 struct CC_EXPORT RasterStats { | |
31 // Minimum rasterize time from N runs | |
32 // N=max(1,slow-down-raster-scale-factor) | |
33 base::TimeDelta best_rasterize_time; | |
34 // Total rasterize time for all N runs | |
35 base::TimeDelta total_rasterize_time; | |
36 // Total number of pixels rasterize in all N runs | |
37 int64 total_pixels_rasterized; | |
38 }; | |
39 | |
40 // Raster a subrect of this PicturePileImpl into the given canvas. | 31 // Raster a subrect of this PicturePileImpl into the given canvas. |
41 // It's only safe to call paint on a cloned version. It is assumed | 32 // It's only safe to call paint on a cloned version. It is assumed |
42 // that contents_scale has already been applied to this canvas. | 33 // that contents_scale has already been applied to this canvas. |
43 // Writes the total number of pixels rasterized and the time spent | 34 // Writes the total number of pixels rasterized and the time spent |
44 // rasterizing to the stats if the respective pointer is not | 35 // rasterizing to the stats if the respective pointer is not |
45 // NULL. When slow-down-raster-scale-factor is set to a value | 36 // NULL. When slow-down-raster-scale-factor is set to a value |
46 // greater than 1, the reported rasterize time is the minimum | 37 // greater than 1, the reported rasterize time is the minimum |
47 // measured value over all runs. | 38 // measured value over all runs. |
48 void RasterDirect( | 39 void RasterDirect( |
49 SkCanvas* canvas, | 40 SkCanvas* canvas, |
50 gfx::Rect canvas_rect, | 41 gfx::Rect canvas_rect, |
51 float contents_scale, | 42 float contents_scale, |
52 RasterStats* raster_stats); | 43 RenderingStatsInstrumentation* rendering_stats_instrumentation); |
53 | 44 |
54 // Similar to the above RasterDirect method, but this is a convenience method | 45 // Similar to the above RasterDirect method, but this is a convenience method |
55 // for when it is known that the raster is going to an intermediate bitmap | 46 // for when it is known that the raster is going to an intermediate bitmap |
56 // that itself will then be blended and thus that a canvas clear is required. | 47 // that itself will then be blended and thus that a canvas clear is required. |
57 void RasterToBitmap( | 48 void RasterToBitmap( |
58 SkCanvas* canvas, | 49 SkCanvas* canvas, |
59 gfx::Rect canvas_rect, | 50 gfx::Rect canvas_rect, |
60 float contents_scale, | 51 float contents_scale, |
61 RasterStats* raster_stats); | 52 RenderingStatsInstrumentation* stats_instrumentation); |
62 | 53 |
63 // Called when analyzing a tile. We can use AnalysisCanvas as | 54 // Called when analyzing a tile. We can use AnalysisCanvas as |
64 // SkDrawPictureCallback, which allows us to early out from analysis. | 55 // SkDrawPictureCallback, which allows us to early out from analysis. |
65 void RasterForAnalysis( | 56 void RasterForAnalysis( |
66 skia::AnalysisCanvas* canvas, | 57 skia::AnalysisCanvas* canvas, |
67 gfx::Rect canvas_rect, | 58 gfx::Rect canvas_rect, |
68 float contents_scale); | 59 float contents_scale); |
69 | 60 |
70 | 61 |
71 skia::RefPtr<SkPicture> GetFlattenedPicture(); | 62 skia::RefPtr<SkPicture> GetFlattenedPicture(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 static scoped_refptr<PicturePileImpl> CreateCloneForDrawing( | 121 static scoped_refptr<PicturePileImpl> CreateCloneForDrawing( |
131 const PicturePileImpl* other, unsigned thread_index); | 122 const PicturePileImpl* other, unsigned thread_index); |
132 | 123 |
133 PicturePileImpl(const PicturePileImpl* other, unsigned thread_index); | 124 PicturePileImpl(const PicturePileImpl* other, unsigned thread_index); |
134 | 125 |
135 void RasterCommon( | 126 void RasterCommon( |
136 SkCanvas* canvas, | 127 SkCanvas* canvas, |
137 SkDrawPictureCallback* callback, | 128 SkDrawPictureCallback* callback, |
138 gfx::Rect canvas_rect, | 129 gfx::Rect canvas_rect, |
139 float contents_scale, | 130 float contents_scale, |
140 RasterStats* raster_stats); | 131 RenderingStatsInstrumentation* rendering_stats_instrumentation); |
141 | 132 |
142 // Once instantiated, |clones_for_drawing_| can't be modified. This | 133 // Once instantiated, |clones_for_drawing_| can't be modified. This |
143 // guarantees thread-safe access during the life time of a PicturePileImpl | 134 // guarantees thread-safe access during the life time of a PicturePileImpl |
144 // instance. This member variable must be last so that other member | 135 // instance. This member variable must be last so that other member |
145 // variables have already been initialized and can be clonable. | 136 // variables have already been initialized and can be clonable. |
146 const ClonesForDrawing clones_for_drawing_; | 137 const ClonesForDrawing clones_for_drawing_; |
147 | 138 |
148 DISALLOW_COPY_AND_ASSIGN(PicturePileImpl); | 139 DISALLOW_COPY_AND_ASSIGN(PicturePileImpl); |
149 }; | 140 }; |
150 | 141 |
151 } // namespace cc | 142 } // namespace cc |
152 | 143 |
153 #endif // CC_RESOURCES_PICTURE_PILE_IMPL_H_ | 144 #endif // CC_RESOURCES_PICTURE_PILE_IMPL_H_ |
OLD | NEW |