OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_PLAYBACK_DISPLAY_LIST_RASTER_SOURCE_H_ | 5 #ifndef CC_PLAYBACK_DISPLAY_LIST_RASTER_SOURCE_H_ |
6 #define CC_PLAYBACK_DISPLAY_LIST_RASTER_SOURCE_H_ | 6 #define CC_PLAYBACK_DISPLAY_LIST_RASTER_SOURCE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.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/playback/display_list_recording_source.h" | 16 #include "cc/playback/display_list_recording_source.h" |
17 #include "skia/ext/analysis_canvas.h" | 17 #include "skia/ext/analysis_canvas.h" |
18 #include "skia/ext/refptr.h" | 18 #include "skia/ext/refptr.h" |
19 #include "third_party/skia/include/core/SkPicture.h" | 19 #include "third_party/skia/include/core/SkPicture.h" |
20 | 20 |
21 namespace cc { | 21 namespace cc { |
22 class DisplayItemList; | 22 class DisplayItemList; |
23 class DrawImage; | 23 class DrawImage; |
24 | 24 |
25 class CC_EXPORT DisplayListRasterSource | 25 class CC_EXPORT DisplayListRasterSource |
26 : public base::RefCountedThreadSafe<DisplayListRasterSource> { | 26 : public base::RefCountedThreadSafe<DisplayListRasterSource> { |
27 public: | 27 public: |
28 struct CC_EXPORT SolidColorAnalysis { | |
29 SolidColorAnalysis() | |
30 : is_solid_color(false), solid_color(SK_ColorTRANSPARENT) {} | |
31 ~SolidColorAnalysis() {} | |
32 | |
33 bool is_solid_color; | |
34 SkColor solid_color; | |
35 }; | |
36 | |
37 static scoped_refptr<DisplayListRasterSource> | 28 static scoped_refptr<DisplayListRasterSource> |
38 CreateFromDisplayListRecordingSource(const DisplayListRecordingSource* other, | 29 CreateFromDisplayListRecordingSource(const DisplayListRecordingSource* other, |
39 bool can_use_lcd_text); | 30 bool can_use_lcd_text); |
40 | 31 |
41 // Raster a subrect of this RasterSource into the given canvas. It is | 32 // Raster a subrect of this RasterSource into the given canvas. It is |
42 // assumed that contents_scale has already been applied to this canvas. | 33 // assumed 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 nullptr. | 35 // rasterizing to the stats if the respective pointer is not nullptr. |
45 // It is assumed that the canvas passed here will only be rasterized by | 36 // It is assumed that the canvas passed here will only be rasterized by |
46 // this raster source via this call. | 37 // this raster source via this call. |
47 // virtual for testing. | 38 // virtual for testing. |
48 virtual void PlaybackToCanvas(SkCanvas* canvas, | 39 virtual void PlaybackToCanvas(SkCanvas* canvas, |
49 const gfx::Rect& canvas_bitmap_rect, | 40 const gfx::Rect& canvas_bitmap_rect, |
50 const gfx::Rect& canvas_playback_rect, | 41 const gfx::Rect& canvas_playback_rect, |
51 float contents_scale) const; | 42 float contents_scale) const; |
52 | 43 |
53 // Similar to above, except that the canvas passed here can (or was already) | 44 // Similar to above, except that the canvas passed here can (or was already) |
54 // rasterized into by another raster source. That is, it is not safe to clear | 45 // rasterized into by another raster source. That is, it is not safe to clear |
55 // the canvas or discard its underlying memory. | 46 // the canvas or discard its underlying memory. |
56 void PlaybackToSharedCanvas(SkCanvas* canvas, | 47 void PlaybackToSharedCanvas(SkCanvas* canvas, |
57 const gfx::Rect& canvas_rect, | 48 const gfx::Rect& canvas_rect, |
58 float contents_scale) const; | 49 float contents_scale) const; |
59 | 50 |
60 // Analyze to determine if the given rect at given scale is of solid color in | 51 // Returns whether the given rect at given scale is of solid color in |
61 // this raster source. | 52 // this raster source, as well as the solid color value. |
62 void PerformSolidColorAnalysis(const gfx::Rect& content_rect, | 53 bool PerformSolidColorAnalysis(const gfx::Rect& content_rect, |
63 float contents_scale, | 54 float contents_scale, |
64 SolidColorAnalysis* analysis) const; | 55 SkColor* color) const; |
65 | 56 |
66 // Returns true iff the whole raster source is of solid color. | 57 // Returns true iff the whole raster source is of solid color. |
67 bool IsSolidColor() const; | 58 bool IsSolidColor() const; |
68 | 59 |
69 // Returns the color of the raster source if it is solid color. The results | 60 // Returns the color of the raster source if it is solid color. The results |
70 // are unspecified if IsSolidColor returns false. | 61 // are unspecified if IsSolidColor returns false. |
71 SkColor GetSolidColor() const; | 62 SkColor GetSolidColor() const; |
72 | 63 |
73 // Returns the size of this raster source. | 64 // Returns the size of this raster source. |
74 gfx::Size GetSize() const; | 65 gfx::Size GetSize() const; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 const gfx::Rect& canvas_bitmap_rect, | 143 const gfx::Rect& canvas_bitmap_rect, |
153 const gfx::Rect& canvas_playback_rect, | 144 const gfx::Rect& canvas_playback_rect, |
154 float contents_scale) const; | 145 float contents_scale) const; |
155 | 146 |
156 DISALLOW_COPY_AND_ASSIGN(DisplayListRasterSource); | 147 DISALLOW_COPY_AND_ASSIGN(DisplayListRasterSource); |
157 }; | 148 }; |
158 | 149 |
159 } // namespace cc | 150 } // namespace cc |
160 | 151 |
161 #endif // CC_PLAYBACK_DISPLAY_LIST_RASTER_SOURCE_H_ | 152 #endif // CC_PLAYBACK_DISPLAY_LIST_RASTER_SOURCE_H_ |
OLD | NEW |