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_recording_source.h" | 5 #include "cc/resources/display_list_recording_source.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "cc/base/region.h" | 9 #include "cc/base/region.h" |
10 #include "cc/layers/content_layer_client.h" | 10 #include "cc/layers/content_layer_client.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 DisplayListRecordingSource::~DisplayListRecordingSource() { | 38 DisplayListRecordingSource::~DisplayListRecordingSource() { |
39 } | 39 } |
40 | 40 |
41 bool DisplayListRecordingSource::UpdateAndExpandInvalidation( | 41 bool DisplayListRecordingSource::UpdateAndExpandInvalidation( |
42 ContentLayerClient* painter, | 42 ContentLayerClient* painter, |
43 Region* invalidation, | 43 Region* invalidation, |
44 bool can_use_lcd_text, | 44 bool can_use_lcd_text, |
45 const gfx::Size& layer_size, | 45 const gfx::Size& layer_size, |
46 const gfx::Rect& visible_layer_rect, | 46 const gfx::Rect& visible_layer_rect, |
47 int frame_number, | 47 int frame_number, |
48 Picture::RecordingMode recording_mode) { | 48 RecordingMode recording_mode) { |
49 bool updated = false; | 49 bool updated = false; |
50 | 50 |
51 if (size_ != layer_size) { | 51 if (size_ != layer_size) { |
52 size_ = layer_size; | 52 size_ = layer_size; |
53 updated = true; | 53 updated = true; |
54 } | 54 } |
55 | 55 |
56 if (can_use_lcd_text_ != can_use_lcd_text) { | 56 if (can_use_lcd_text_ != can_use_lcd_text) { |
57 can_use_lcd_text_ = can_use_lcd_text; | 57 can_use_lcd_text_ = can_use_lcd_text; |
58 invalidation->Union(gfx::Rect(GetSize())); | 58 invalidation->Union(gfx::Rect(GetSize())); |
(...skipping 15 matching lines...) Expand all Loading... |
74 Region no_longer_exposed_region(old_recorded_viewport); | 74 Region no_longer_exposed_region(old_recorded_viewport); |
75 no_longer_exposed_region.Subtract(recorded_viewport_); | 75 no_longer_exposed_region.Subtract(recorded_viewport_); |
76 invalidation->Union(no_longer_exposed_region); | 76 invalidation->Union(no_longer_exposed_region); |
77 | 77 |
78 updated = true; | 78 updated = true; |
79 } | 79 } |
80 | 80 |
81 if (!updated && !invalidation->Intersects(recorded_viewport_)) | 81 if (!updated && !invalidation->Intersects(recorded_viewport_)) |
82 return false; | 82 return false; |
83 | 83 |
84 // TODO(ajuma): Does repeating this way really makes sense with display lists? | 84 ContentLayerClient::PaintingControlSetting painting_control = |
85 // With Blink caching recordings, repeated calls will not cause re-recording. | 85 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL; |
86 int repeat_count = std::max(1, slow_down_raster_scale_factor_for_debug_); | 86 |
| 87 switch (recording_mode) { |
| 88 case RECORD_NORMALLY: |
| 89 // Already setup for normal recording. |
| 90 break; |
| 91 case RECORD_WITH_SK_NULL_CANVAS: |
| 92 // TODO(schenney): Remove this when DisplayList recording is the only |
| 93 // option. For now, fall through and disable construction. |
| 94 case RECORD_WITH_PAINTING_DISABLED: |
| 95 painting_control = ContentLayerClient::DISPLAY_LIST_CONSTRUCTION_DISABLED; |
| 96 break; |
| 97 case RECORD_WITH_CACHING_DISABLED: |
| 98 painting_control = ContentLayerClient::DISPLAY_LIST_CACHING_DISABLED; |
| 99 break; |
| 100 default: |
| 101 NOTREACHED(); |
| 102 } |
| 103 |
| 104 int repeat_count = 1; |
| 105 if (slow_down_raster_scale_factor_for_debug_ > 1) { |
| 106 repeat_count = slow_down_raster_scale_factor_for_debug_; |
| 107 if (painting_control != |
| 108 ContentLayerClient::DISPLAY_LIST_CONSTRUCTION_DISABLED) { |
| 109 painting_control = ContentLayerClient::DISPLAY_LIST_CACHING_DISABLED; |
| 110 } |
| 111 } |
87 for (int i = 0; i < repeat_count; ++i) { | 112 for (int i = 0; i < repeat_count; ++i) { |
88 display_list_ = painter->PaintContentsToDisplayList( | 113 display_list_ = painter->PaintContentsToDisplayList(recorded_viewport_, |
89 recorded_viewport_, ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); | 114 painting_control); |
90 } | 115 } |
91 display_list_->set_layer_rect(recorded_viewport_); | 116 display_list_->set_layer_rect(recorded_viewport_); |
92 is_suitable_for_gpu_rasterization_ = | 117 is_suitable_for_gpu_rasterization_ = |
93 display_list_->IsSuitableForGpuRasterization(); | 118 display_list_->IsSuitableForGpuRasterization(); |
94 | 119 |
95 DetermineIfSolidColor(); | 120 DetermineIfSolidColor(); |
96 display_list_->EmitTraceSnapshot(); | 121 display_list_->EmitTraceSnapshot(); |
97 return true; | 122 return true; |
98 } | 123 } |
99 | 124 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); | 167 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); |
143 } | 168 } |
144 | 169 |
145 void DisplayListRecordingSource::Clear() { | 170 void DisplayListRecordingSource::Clear() { |
146 recorded_viewport_ = gfx::Rect(); | 171 recorded_viewport_ = gfx::Rect(); |
147 display_list_ = NULL; | 172 display_list_ = NULL; |
148 is_solid_color_ = false; | 173 is_solid_color_ = false; |
149 } | 174 } |
150 | 175 |
151 } // namespace cc | 176 } // namespace cc |
OLD | NEW |