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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
12 #include "cc/debug/rendering_stats_instrumentation.h" | 12 #include "cc/debug/rendering_stats_instrumentation.h" |
13 #include "cc/playback/display_list_recording_source.h" | 13 #include "cc/playback/display_list_recording_source.h" |
14 #include "skia/ext/analysis_canvas.h" | 14 #include "skia/ext/analysis_canvas.h" |
15 #include "skia/ext/refptr.h" | 15 #include "skia/ext/refptr.h" |
16 #include "third_party/skia/include/core/SkPicture.h" | 16 #include "third_party/skia/include/core/SkPicture.h" |
17 | 17 |
18 namespace cc { | 18 namespace cc { |
19 class DisplayItemList; | 19 class DisplayItemList; |
20 class DrawImage; | 20 class DrawImage; |
21 class ImageDecodeController; | |
21 | 22 |
22 class CC_EXPORT DisplayListRasterSource | 23 class CC_EXPORT DisplayListRasterSource |
23 : public base::RefCountedThreadSafe<DisplayListRasterSource> { | 24 : public base::RefCountedThreadSafe<DisplayListRasterSource> { |
24 public: | 25 public: |
25 struct CC_EXPORT SolidColorAnalysis { | 26 struct CC_EXPORT SolidColorAnalysis { |
26 SolidColorAnalysis() | 27 SolidColorAnalysis() |
27 : is_solid_color(false), solid_color(SK_ColorTRANSPARENT) {} | 28 : is_solid_color(false), solid_color(SK_ColorTRANSPARENT) {} |
28 ~SolidColorAnalysis() {} | 29 ~SolidColorAnalysis() {} |
29 | 30 |
30 bool is_solid_color; | 31 bool is_solid_color; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 virtual void DidBeginTracing(); | 100 virtual void DidBeginTracing(); |
100 virtual void AsValueInto(base::trace_event::TracedValue* array) const; | 101 virtual void AsValueInto(base::trace_event::TracedValue* array) const; |
101 virtual skia::RefPtr<SkPicture> GetFlattenedPicture(); | 102 virtual skia::RefPtr<SkPicture> GetFlattenedPicture(); |
102 virtual size_t GetPictureMemoryUsage() const; | 103 virtual size_t GetPictureMemoryUsage() const; |
103 | 104 |
104 // Return true if LCD anti-aliasing may be used when rastering text. | 105 // Return true if LCD anti-aliasing may be used when rastering text. |
105 virtual bool CanUseLCDText() const; | 106 virtual bool CanUseLCDText() const; |
106 | 107 |
107 scoped_refptr<DisplayListRasterSource> CreateCloneWithoutLCDText() const; | 108 scoped_refptr<DisplayListRasterSource> CreateCloneWithoutLCDText() const; |
108 | 109 |
110 // Image decode controller should be set once. Its lifetime has to exceed that | |
111 // of the raster source, since the raster source will access it during raster. | |
112 void SetImageDecodeController(ImageDecodeController* image_decode_controller); | |
113 | |
109 protected: | 114 protected: |
110 friend class base::RefCountedThreadSafe<DisplayListRasterSource>; | 115 friend class base::RefCountedThreadSafe<DisplayListRasterSource>; |
111 | 116 |
112 DisplayListRasterSource(const DisplayListRecordingSource* other, | 117 DisplayListRasterSource(const DisplayListRecordingSource* other, |
113 bool can_use_lcd_text); | 118 bool can_use_lcd_text); |
114 DisplayListRasterSource(const DisplayListRasterSource* other, | 119 DisplayListRasterSource(const DisplayListRasterSource* other, |
115 bool can_use_lcd_text); | 120 bool can_use_lcd_text); |
116 virtual ~DisplayListRasterSource(); | 121 virtual ~DisplayListRasterSource(); |
117 | 122 |
118 // These members are const as this raster source may be in use on another | 123 // These members are const as this raster source may be in use on another |
119 // thread and so should not be touched after construction. | 124 // thread and so should not be touched after construction. |
120 const scoped_refptr<DisplayItemList> display_list_; | 125 const scoped_refptr<DisplayItemList> display_list_; |
121 const size_t painter_reported_memory_usage_; | 126 const size_t painter_reported_memory_usage_; |
122 const SkColor background_color_; | 127 const SkColor background_color_; |
123 const bool requires_clear_; | 128 const bool requires_clear_; |
124 const bool can_use_lcd_text_; | 129 const bool can_use_lcd_text_; |
125 const bool is_solid_color_; | 130 const bool is_solid_color_; |
126 const SkColor solid_color_; | 131 const SkColor solid_color_; |
127 const gfx::Rect recorded_viewport_; | 132 const gfx::Rect recorded_viewport_; |
128 const gfx::Size size_; | 133 const gfx::Size size_; |
129 const bool clear_canvas_with_debug_color_; | 134 const bool clear_canvas_with_debug_color_; |
130 const int slow_down_raster_scale_factor_for_debug_; | 135 const int slow_down_raster_scale_factor_for_debug_; |
131 // TODO(enne/vmiura): this has a read/write race between raster and compositor | 136 // TODO(enne/vmiura): this has a read/write race between raster and compositor |
132 // threads with multi-threaded Ganesh. Make this const or remove it. | 137 // threads with multi-threaded Ganesh. Make this const or remove it. |
133 bool should_attempt_to_use_distance_field_text_; | 138 bool should_attempt_to_use_distance_field_text_; |
134 | 139 |
140 ImageDecodeController* image_decode_controller_; | |
ericrk
2015/12/04 00:50:46
Given all the warnings above re threading, can you
| |
141 | |
135 private: | 142 private: |
136 // Called when analyzing a tile. We can use AnalysisCanvas as | 143 // Called when analyzing a tile. We can use AnalysisCanvas as |
137 // SkPicture::AbortCallback, which allows us to early out from analysis. | 144 // SkPicture::AbortCallback, which allows us to early out from analysis. |
138 void RasterForAnalysis(skia::AnalysisCanvas* canvas, | 145 void RasterForAnalysis(skia::AnalysisCanvas* canvas, |
139 const gfx::Rect& canvas_rect, | 146 const gfx::Rect& canvas_rect, |
140 float contents_scale) const; | 147 float contents_scale) const; |
141 | 148 |
142 void RasterCommon(SkCanvas* canvas, | 149 void RasterCommon(SkCanvas* canvas, |
143 SkPicture::AbortCallback* callback, | 150 SkPicture::AbortCallback* callback, |
144 const gfx::Rect& canvas_bitmap_rect, | 151 const gfx::Rect& canvas_bitmap_rect, |
145 const gfx::Rect& canvas_playback_rect, | 152 const gfx::Rect& canvas_playback_rect, |
146 float contents_scale) const; | 153 float contents_scale) const; |
147 | 154 |
148 void PrepareForPlaybackToCanvas(SkCanvas* canvas, | 155 void PrepareForPlaybackToCanvas(SkCanvas* canvas, |
149 const gfx::Rect& canvas_bitmap_rect, | 156 const gfx::Rect& canvas_bitmap_rect, |
150 const gfx::Rect& canvas_playback_rect, | 157 const gfx::Rect& canvas_playback_rect, |
151 float contents_scale) const; | 158 float contents_scale) const; |
152 | 159 |
153 DISALLOW_COPY_AND_ASSIGN(DisplayListRasterSource); | 160 DISALLOW_COPY_AND_ASSIGN(DisplayListRasterSource); |
154 }; | 161 }; |
155 | 162 |
156 } // namespace cc | 163 } // namespace cc |
157 | 164 |
158 #endif // CC_PLAYBACK_DISPLAY_LIST_RASTER_SOURCE_H_ | 165 #endif // CC_PLAYBACK_DISPLAY_LIST_RASTER_SOURCE_H_ |
OLD | NEW |