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