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_RESOURCES_RASTER_SOURCE_H_ | 5 #ifndef CC_RESOURCES_RASTER_SOURCE_H_ |
6 #define CC_RESOURCES_RASTER_SOURCE_H_ | 6 #define CC_RESOURCES_RASTER_SOURCE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
12 #include "third_party/skia/include/core/SkColor.h" | 12 #include "third_party/skia/include/core/SkColor.h" |
13 | 13 |
14 class SkCanvas; | 14 class SkCanvas; |
15 | 15 |
16 namespace cc { | 16 namespace cc { |
17 | 17 |
18 class RenderingStatsInstrumentation; | |
19 | |
20 class CC_EXPORT RasterSource : public base::RefCountedThreadSafe<RasterSource> { | 18 class CC_EXPORT RasterSource : public base::RefCountedThreadSafe<RasterSource> { |
21 public: | 19 public: |
22 struct CC_EXPORT SolidColorAnalysis { | 20 struct CC_EXPORT SolidColorAnalysis { |
23 SolidColorAnalysis() | 21 SolidColorAnalysis() |
24 : is_solid_color(false), solid_color(SK_ColorTRANSPARENT) {} | 22 : is_solid_color(false), solid_color(SK_ColorTRANSPARENT) {} |
25 ~SolidColorAnalysis() {} | 23 ~SolidColorAnalysis() {} |
26 | 24 |
27 bool is_solid_color; | 25 bool is_solid_color; |
28 SkColor solid_color; | 26 SkColor solid_color; |
29 }; | 27 }; |
30 | 28 |
31 // Raster a subrect of this RasterSource into the given canvas. It is | 29 // Raster a subrect of this RasterSource into the given canvas. It is |
32 // assumed that contents_scale has already been applied to this canvas. | 30 // assumed that contents_scale has already been applied to this canvas. |
33 // Writes the total number of pixels rasterized and the time spent | 31 // Writes the total number of pixels rasterized and the time spent |
34 // rasterizing to the stats if the respective pointer is not nullptr. | 32 // rasterizing to the stats if the respective pointer is not nullptr. |
35 // TODO(vmpstr): Remove RenderingStatsInstrumentation from the interface. | 33 virtual void PlaybackToCanvas(SkCanvas* canvas, |
36 virtual void PlaybackToCanvas( | 34 const gfx::Rect& canvas_rect, |
37 SkCanvas* canvas, | 35 float contents_scale) const = 0; |
38 const gfx::Rect& canvas_rect, | |
39 float contents_scale, | |
40 RenderingStatsInstrumentation* rendering_stats_instrumentation) const = 0; | |
41 | 36 |
42 // Analyze to determine if the given rect at given scale is of solid color in | 37 // Analyze to determine if the given rect at given scale is of solid color in |
43 // this raster source. | 38 // this raster source. |
44 virtual void PerformSolidColorAnalysis( | 39 virtual void PerformSolidColorAnalysis( |
45 const gfx::Rect& content_rect, | 40 const gfx::Rect& content_rect, |
46 float contents_scale, | 41 float contents_scale, |
47 SolidColorAnalysis* analysis, | 42 SolidColorAnalysis* analysis) const = 0; |
48 RenderingStatsInstrumentation* rendering_stats_instrumentation) const = 0; | |
49 | 43 |
50 // Populate the given list with all SkPixelRefs that may overlap the given | 44 // Populate the given list with all SkPixelRefs that may overlap the given |
51 // rect at given scale. | 45 // rect at given scale. |
52 virtual void GatherPixelRefs(const gfx::Rect& content_rect, | 46 virtual void GatherPixelRefs(const gfx::Rect& content_rect, |
53 float contents_scale, | 47 float contents_scale, |
54 std::vector<SkPixelRef*>* pixel_refs) const = 0; | 48 std::vector<SkPixelRef*>* pixel_refs) const = 0; |
55 | 49 |
56 // Return true iff this raster source can raster the given rect at given | 50 // Return true iff this raster source can raster the given rect at given |
57 // scale. | 51 // scale. |
58 virtual bool CoversRect(const gfx::Rect& content_rect, | 52 virtual bool CoversRect(const gfx::Rect& content_rect, |
59 float contents_scale) const = 0; | 53 float contents_scale) const = 0; |
60 | 54 |
61 // Return true iff this raster source would benefit from using distance | 55 // Return true iff this raster source would benefit from using distance |
62 // field text. | 56 // field text. |
63 virtual bool SuitableForDistanceFieldText() const = 0; | 57 virtual bool SuitableForDistanceFieldText() const = 0; |
64 | 58 |
65 protected: | 59 protected: |
66 friend class base::RefCountedThreadSafe<RasterSource>; | 60 friend class base::RefCountedThreadSafe<RasterSource>; |
67 | 61 |
68 RasterSource() {} | 62 RasterSource() {} |
69 virtual ~RasterSource() {} | 63 virtual ~RasterSource() {} |
70 | 64 |
71 private: | 65 private: |
72 DISALLOW_COPY_AND_ASSIGN(RasterSource); | 66 DISALLOW_COPY_AND_ASSIGN(RasterSource); |
73 }; | 67 }; |
74 | 68 |
75 } // namespace cc | 69 } // namespace cc |
76 | 70 |
77 #endif // CC_RESOURCES_RASTER_SOURCE_H_ | 71 #endif // CC_RESOURCES_RASTER_SOURCE_H_ |
OLD | NEW |