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_RASTER_SOURCE_H_ |
6 #define CC_PLAYBACK_DISPLAY_LIST_RASTER_SOURCE_H_ | 6 #define CC_PLAYBACK_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 "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
15 #include "base/trace_event/memory_allocator_dump.h" | 15 #include "base/trace_event/memory_allocator_dump.h" |
16 #include "base/trace_event/memory_dump_provider.h" | 16 #include "base/trace_event/memory_dump_provider.h" |
17 #include "cc/base/cc_export.h" | 17 #include "cc/base/cc_export.h" |
18 #include "cc/debug/rendering_stats_instrumentation.h" | 18 #include "cc/debug/rendering_stats_instrumentation.h" |
19 #include "cc/playback/display_list_recording_source.h" | 19 #include "cc/playback/display_list_recording_source.h" |
20 #include "skia/ext/analysis_canvas.h" | 20 #include "skia/ext/analysis_canvas.h" |
21 #include "third_party/skia/include/core/SkPicture.h" | 21 #include "third_party/skia/include/core/SkPicture.h" |
22 | 22 |
23 namespace cc { | 23 namespace cc { |
24 class DisplayItemList; | 24 class DisplayItemList; |
25 class DrawImage; | 25 class DrawImage; |
26 class ImageDecodeController; | 26 class ImageDecodeController; |
27 | 27 |
28 class CC_EXPORT DisplayListRasterSource | 28 class CC_EXPORT RasterSource : public base::trace_event::MemoryDumpProvider, |
29 : public base::trace_event::MemoryDumpProvider, | 29 public base::RefCountedThreadSafe<RasterSource> { |
30 public base::RefCountedThreadSafe<DisplayListRasterSource> { | |
31 public: | 30 public: |
32 static scoped_refptr<DisplayListRasterSource> | 31 static scoped_refptr<RasterSource> CreateFromDisplayListRecordingSource( |
33 CreateFromDisplayListRecordingSource(const DisplayListRecordingSource* other, | 32 const DisplayListRecordingSource* other, |
34 bool can_use_lcd_text); | 33 bool can_use_lcd_text); |
35 | 34 |
36 // Raster a subrect of this RasterSource into the given canvas. It is | 35 // Raster a subrect of this RasterSource into the given canvas. It is |
37 // assumed that contents_scale has already been applied to this canvas. | 36 // assumed that contents_scale has already been applied to this canvas. |
38 // Writes the total number of pixels rasterized and the time spent | 37 // Writes the total number of pixels rasterized and the time spent |
39 // rasterizing to the stats if the respective pointer is not nullptr. | 38 // rasterizing to the stats if the respective pointer is not nullptr. |
40 // It is assumed that the canvas passed here will only be rasterized by | 39 // It is assumed that the canvas passed here will only be rasterized by |
41 // this raster source via this call. | 40 // this raster source via this call. |
42 // | 41 // |
43 // Virtual for testing. | 42 // Virtual for testing. |
44 // | 43 // |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 100 |
102 // Tracing functionality. | 101 // Tracing functionality. |
103 virtual void DidBeginTracing(); | 102 virtual void DidBeginTracing(); |
104 virtual void AsValueInto(base::trace_event::TracedValue* array) const; | 103 virtual void AsValueInto(base::trace_event::TracedValue* array) const; |
105 virtual sk_sp<SkPicture> GetFlattenedPicture(); | 104 virtual sk_sp<SkPicture> GetFlattenedPicture(); |
106 virtual size_t GetPictureMemoryUsage() const; | 105 virtual size_t GetPictureMemoryUsage() const; |
107 | 106 |
108 // Return true if LCD anti-aliasing may be used when rastering text. | 107 // Return true if LCD anti-aliasing may be used when rastering text. |
109 virtual bool CanUseLCDText() const; | 108 virtual bool CanUseLCDText() const; |
110 | 109 |
111 scoped_refptr<DisplayListRasterSource> CreateCloneWithoutLCDText() const; | 110 scoped_refptr<RasterSource> CreateCloneWithoutLCDText() const; |
112 | 111 |
113 // Image decode controller should be set once. Its lifetime has to exceed that | 112 // Image decode controller should be set once. Its lifetime has to exceed that |
114 // of the raster source, since the raster source will access it during raster. | 113 // of the raster source, since the raster source will access it during raster. |
115 void SetImageDecodeController(ImageDecodeController* image_decode_controller); | 114 void SetImageDecodeController(ImageDecodeController* image_decode_controller); |
116 | 115 |
117 // base::trace_event::MemoryDumpProvider implementation | 116 // base::trace_event::MemoryDumpProvider implementation |
118 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 117 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
119 base::trace_event::ProcessMemoryDump* pmd) override; | 118 base::trace_event::ProcessMemoryDump* pmd) override; |
120 | 119 |
121 protected: | 120 protected: |
122 friend class base::RefCountedThreadSafe<DisplayListRasterSource>; | 121 friend class base::RefCountedThreadSafe<RasterSource>; |
123 | 122 |
124 DisplayListRasterSource(const DisplayListRecordingSource* other, | 123 RasterSource(const DisplayListRecordingSource* other, bool can_use_lcd_text); |
125 bool can_use_lcd_text); | 124 RasterSource(const RasterSource* other, bool can_use_lcd_text); |
126 DisplayListRasterSource(const DisplayListRasterSource* other, | 125 ~RasterSource() override; |
127 bool can_use_lcd_text); | |
128 ~DisplayListRasterSource() override; | |
129 | 126 |
130 // These members are const as this raster source may be in use on another | 127 // These members are const as this raster source may be in use on another |
131 // thread and so should not be touched after construction. | 128 // thread and so should not be touched after construction. |
132 const scoped_refptr<DisplayItemList> display_list_; | 129 const scoped_refptr<DisplayItemList> display_list_; |
133 const size_t painter_reported_memory_usage_; | 130 const size_t painter_reported_memory_usage_; |
134 const SkColor background_color_; | 131 const SkColor background_color_; |
135 const bool requires_clear_; | 132 const bool requires_clear_; |
136 const bool can_use_lcd_text_; | 133 const bool can_use_lcd_text_; |
137 const bool is_solid_color_; | 134 const bool is_solid_color_; |
138 const SkColor solid_color_; | 135 const SkColor solid_color_; |
(...skipping 23 matching lines...) Expand all Loading... |
162 float contents_scale) const; | 159 float contents_scale) const; |
163 | 160 |
164 void PrepareForPlaybackToCanvas(SkCanvas* canvas, | 161 void PrepareForPlaybackToCanvas(SkCanvas* canvas, |
165 const gfx::Rect& canvas_bitmap_rect, | 162 const gfx::Rect& canvas_bitmap_rect, |
166 const gfx::Rect& canvas_playback_rect, | 163 const gfx::Rect& canvas_playback_rect, |
167 float contents_scale) const; | 164 float contents_scale) const; |
168 | 165 |
169 // Used to ensure that memory dump logic always happens on the same thread. | 166 // Used to ensure that memory dump logic always happens on the same thread. |
170 base::ThreadChecker memory_dump_thread_checker_; | 167 base::ThreadChecker memory_dump_thread_checker_; |
171 | 168 |
172 DISALLOW_COPY_AND_ASSIGN(DisplayListRasterSource); | 169 DISALLOW_COPY_AND_ASSIGN(RasterSource); |
173 }; | 170 }; |
174 | 171 |
175 } // namespace cc | 172 } // namespace cc |
176 | 173 |
177 #endif // CC_PLAYBACK_DISPLAY_LIST_RASTER_SOURCE_H_ | 174 #endif // CC_PLAYBACK_RASTER_SOURCE_H_ |
OLD | NEW |