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 #include "cc/resources/display_list_raster_source.h" | 5 #include "cc/resources/display_list_raster_source.h" |
6 | 6 |
7 #include "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
8 #include "cc/base/region.h" | 8 #include "cc/base/region.h" |
9 #include "cc/debug/debug_colors.h" | 9 #include "cc/debug/debug_colors.h" |
10 #include "cc/resources/display_item_list.h" | 10 #include "cc/resources/display_item_list.h" |
11 #include "cc/resources/raster_source_helper.h" | 11 #include "cc/resources/raster_source_helper.h" |
12 #include "skia/ext/analysis_canvas.h" | 12 #include "skia/ext/analysis_canvas.h" |
13 #include "third_party/skia/include/core/SkCanvas.h" | 13 #include "third_party/skia/include/core/SkCanvas.h" |
14 #include "third_party/skia/include/core/SkPictureRecorder.h" | 14 #include "third_party/skia/include/core/SkPictureRecorder.h" |
15 #include "ui/gfx/geometry/rect_conversions.h" | 15 #include "ui/gfx/geometry/rect_conversions.h" |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 #ifdef NDEBUG | 19 #ifdef NDEBUG |
20 const bool kDefaultClearCanvasSetting = false; | 20 const bool kDefaultClearCanvasSetting = false; |
21 #else | 21 #else |
22 const bool kDefaultClearCanvasSetting = true; | 22 const bool kDefaultClearCanvasSetting = true; |
23 #endif | 23 #endif |
24 | 24 |
25 } // namespace | 25 } // namespace |
26 | 26 |
27 namespace cc { | 27 namespace cc { |
28 | 28 |
| 29 scoped_refptr<DisplayListRasterSource> DisplayListRasterSource::Create() { |
| 30 return make_scoped_refptr(new DisplayListRasterSource); |
| 31 } |
| 32 |
29 scoped_refptr<DisplayListRasterSource> | 33 scoped_refptr<DisplayListRasterSource> |
30 DisplayListRasterSource::CreateFromDisplayListRecordingSource( | 34 DisplayListRasterSource::CreateFromDisplayListRecordingSource( |
31 const DisplayListRecordingSource* other, | 35 const DisplayListRecordingSource* other) { |
32 bool can_use_lcd_text) { | 36 return make_scoped_refptr(new DisplayListRasterSource(other)); |
33 return make_scoped_refptr( | |
34 new DisplayListRasterSource(other, can_use_lcd_text)); | |
35 } | 37 } |
36 | 38 |
37 DisplayListRasterSource::DisplayListRasterSource() | 39 DisplayListRasterSource::DisplayListRasterSource() |
38 : background_color_(SK_ColorTRANSPARENT), | 40 : background_color_(SK_ColorTRANSPARENT), |
39 requires_clear_(true), | 41 requires_clear_(true), |
40 can_use_lcd_text_(true), | 42 can_use_lcd_text_(true), |
41 is_solid_color_(false), | 43 is_solid_color_(false), |
42 solid_color_(SK_ColorTRANSPARENT), | 44 solid_color_(SK_ColorTRANSPARENT), |
43 clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), | 45 clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), |
44 slow_down_raster_scale_factor_for_debug_(0), | 46 slow_down_raster_scale_factor_for_debug_(0), |
45 should_attempt_to_use_distance_field_text_(false) { | 47 should_attempt_to_use_distance_field_text_(false) { |
46 } | 48 } |
47 | 49 |
48 DisplayListRasterSource::DisplayListRasterSource( | 50 DisplayListRasterSource::DisplayListRasterSource( |
49 const DisplayListRecordingSource* other, | 51 const DisplayListRecordingSource* other) |
50 bool can_use_lcd_text) | |
51 : display_list_(other->display_list_), | 52 : display_list_(other->display_list_), |
52 background_color_(other->background_color_), | 53 background_color_(other->background_color_), |
53 requires_clear_(other->requires_clear_), | 54 requires_clear_(other->requires_clear_), |
54 can_use_lcd_text_(can_use_lcd_text), | 55 can_use_lcd_text_(other->can_use_lcd_text_), |
55 is_solid_color_(other->is_solid_color_), | 56 is_solid_color_(other->is_solid_color_), |
56 solid_color_(other->solid_color_), | 57 solid_color_(other->solid_color_), |
57 recorded_viewport_(other->recorded_viewport_), | 58 recorded_viewport_(other->recorded_viewport_), |
58 size_(other->size_), | 59 size_(other->size_), |
59 clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), | 60 clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), |
60 slow_down_raster_scale_factor_for_debug_( | 61 slow_down_raster_scale_factor_for_debug_( |
61 other->slow_down_raster_scale_factor_for_debug_), | 62 other->slow_down_raster_scale_factor_for_debug_), |
62 should_attempt_to_use_distance_field_text_(false) { | 63 should_attempt_to_use_distance_field_text_(false) { |
63 } | 64 } |
64 | 65 |
65 DisplayListRasterSource::DisplayListRasterSource( | |
66 const DisplayListRasterSource* other, | |
67 bool can_use_lcd_text) | |
68 : display_list_(other->display_list_), | |
69 background_color_(other->background_color_), | |
70 requires_clear_(other->requires_clear_), | |
71 can_use_lcd_text_(can_use_lcd_text), | |
72 is_solid_color_(other->is_solid_color_), | |
73 solid_color_(other->solid_color_), | |
74 recorded_viewport_(other->recorded_viewport_), | |
75 size_(other->size_), | |
76 clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), | |
77 slow_down_raster_scale_factor_for_debug_( | |
78 other->slow_down_raster_scale_factor_for_debug_), | |
79 should_attempt_to_use_distance_field_text_( | |
80 other->should_attempt_to_use_distance_field_text_) { | |
81 } | |
82 | |
83 DisplayListRasterSource::~DisplayListRasterSource() { | 66 DisplayListRasterSource::~DisplayListRasterSource() { |
84 } | 67 } |
85 | 68 |
86 void DisplayListRasterSource::PlaybackToSharedCanvas( | 69 void DisplayListRasterSource::PlaybackToSharedCanvas( |
87 SkCanvas* canvas, | 70 SkCanvas* canvas, |
88 const gfx::Rect& canvas_rect, | 71 const gfx::Rect& canvas_rect, |
89 float contents_scale) const { | 72 float contents_scale) const { |
90 RasterCommon(canvas, NULL, canvas_rect, contents_scale, false); | 73 RasterCommon(canvas, NULL, canvas_rect, contents_scale, false); |
91 } | 74 } |
92 | 75 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 | 190 |
208 void DisplayListRasterSource::DidBeginTracing() { | 191 void DisplayListRasterSource::DidBeginTracing() { |
209 if (display_list_.get()) | 192 if (display_list_.get()) |
210 display_list_->EmitTraceSnapshot(); | 193 display_list_->EmitTraceSnapshot(); |
211 } | 194 } |
212 | 195 |
213 bool DisplayListRasterSource::CanUseLCDText() const { | 196 bool DisplayListRasterSource::CanUseLCDText() const { |
214 return can_use_lcd_text_; | 197 return can_use_lcd_text_; |
215 } | 198 } |
216 | 199 |
217 scoped_refptr<RasterSource> DisplayListRasterSource::CreateCloneWithoutLCDText() | |
218 const { | |
219 bool can_use_lcd_text = false; | |
220 return scoped_refptr<RasterSource>( | |
221 new DisplayListRasterSource(this, can_use_lcd_text)); | |
222 } | |
223 | |
224 } // namespace cc | 200 } // namespace cc |
OLD | NEW |