OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/picture_layer_impl.h" | 5 #include "cc/picture_layer_impl.h" |
6 | 6 |
7 #include "base/time.h" | 7 #include "base/time.h" |
8 #include "cc/append_quads_data.h" | 8 #include "cc/append_quads_data.h" |
9 #include "cc/checkerboard_draw_quad.h" | 9 #include "cc/checkerboard_draw_quad.h" |
10 #include "cc/debug_border_draw_quad.h" | 10 #include "cc/debug_border_draw_quad.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 if (ShowDebugBorders()) { | 108 if (ShowDebugBorders()) { |
109 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), | 109 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), |
110 contents_scale_x(), | 110 contents_scale_x(), |
111 rect, | 111 rect, |
112 ideal_contents_scale_, | 112 ideal_contents_scale_, |
113 layerDeviceAlignment); | 113 layerDeviceAlignment); |
114 iter; | 114 iter; |
115 ++iter) { | 115 ++iter) { |
116 SkColor color; | 116 SkColor color; |
117 float width; | 117 float width; |
118 if (*iter && iter->IsReadyToDraw()) { | 118 if (*iter && iter->drawing_info().IsReadyToDraw()) { |
119 if (iter->is_solid_color() || iter->is_transparent()) { | 119 ManagedTileState::DrawingInfo::Mode mode = iter->drawing_info().mode(); |
| 120 if (mode == ManagedTileState::DrawingInfo::SOLID_COLOR_MODE || |
| 121 mode == ManagedTileState::DrawingInfo::TRANSPARENT_MODE) { |
120 color = DebugColors::SolidColorTileBorderColor(); | 122 color = DebugColors::SolidColorTileBorderColor(); |
121 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); | 123 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); |
122 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { | 124 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { |
123 color = DebugColors::HighResTileBorderColor(); | 125 color = DebugColors::HighResTileBorderColor(); |
124 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); | 126 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); |
125 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { | 127 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { |
126 color = DebugColors::LowResTileBorderColor(); | 128 color = DebugColors::LowResTileBorderColor(); |
127 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); | 129 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); |
128 } else if (iter->contents_scale() > contents_scale_x()) { | 130 } else if (iter->contents_scale() > contents_scale_x()) { |
129 color = DebugColors::ExtraHighResTileBorderColor(); | 131 color = DebugColors::ExtraHighResTileBorderColor(); |
(...skipping 22 matching lines...) Expand all Loading... |
152 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), | 154 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), |
153 contents_scale_x(), | 155 contents_scale_x(), |
154 rect, | 156 rect, |
155 ideal_contents_scale_, | 157 ideal_contents_scale_, |
156 layerDeviceAlignment); | 158 layerDeviceAlignment); |
157 iter; | 159 iter; |
158 ++iter) { | 160 ++iter) { |
159 | 161 |
160 gfx::Rect geometry_rect = iter.geometry_rect(); | 162 gfx::Rect geometry_rect = iter.geometry_rect(); |
161 ResourceProvider::ResourceId resource = 0; | 163 ResourceProvider::ResourceId resource = 0; |
162 if (*iter) { | 164 if (!*iter || !iter->drawing_info().IsReadyToDraw()) { |
163 if (iter->is_solid_color()) { | |
164 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | |
165 quad->SetNew(sharedQuadState, geometry_rect, iter->solid_color()); | |
166 quadSink->append(quad.PassAs<DrawQuad>(), appendQuadsData); | |
167 | |
168 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) | |
169 seen_tilings.push_back(iter.CurrentTiling()); | |
170 continue; | |
171 } else if (iter->is_transparent()) { | |
172 continue; | |
173 } | |
174 resource = iter->GetResourceId(); | |
175 } | |
176 if (!resource) { | |
177 if (DrawCheckerboardForMissingTiles()) { | 165 if (DrawCheckerboardForMissingTiles()) { |
178 // TODO(enne): Figure out how to show debug "invalidated checker" color | 166 // TODO(enne): Figure out how to show debug "invalidated checker" color |
179 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create(); | 167 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create(); |
180 SkColor color = DebugColors::DefaultCheckerboardColor(); | 168 SkColor color = DebugColors::DefaultCheckerboardColor(); |
181 quad->SetNew(sharedQuadState, geometry_rect, color); | 169 quad->SetNew(sharedQuadState, geometry_rect, color); |
182 if (quadSink->append(quad.PassAs<DrawQuad>(), appendQuadsData)) | 170 if (quadSink->append(quad.PassAs<DrawQuad>(), appendQuadsData)) |
183 appendQuadsData->numMissingTiles++; | 171 appendQuadsData->numMissingTiles++; |
184 } else { | 172 } else { |
185 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 173 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
186 quad->SetNew(sharedQuadState, geometry_rect, background_color()); | 174 quad->SetNew(sharedQuadState, geometry_rect, background_color()); |
187 if (quadSink->append(quad.PassAs<DrawQuad>(), appendQuadsData)) | 175 if (quadSink->append(quad.PassAs<DrawQuad>(), appendQuadsData)) |
188 appendQuadsData->numMissingTiles++; | 176 appendQuadsData->numMissingTiles++; |
189 } | 177 } |
190 | 178 |
191 appendQuadsData->hadIncompleteTile = true; | 179 appendQuadsData->hadIncompleteTile = true; |
192 continue; | 180 continue; |
193 } | 181 } |
194 | 182 |
195 if (iter->contents_scale() != ideal_contents_scale_) | 183 const ManagedTileState::DrawingInfo& drawing_info = iter->drawing_info(); |
196 appendQuadsData->hadIncompleteTile = true; | 184 switch (drawing_info.mode()) { |
| 185 case ManagedTileState::DrawingInfo::TEXTURE_MODE: { |
| 186 if (iter->contents_scale() != ideal_contents_scale_) |
| 187 appendQuadsData->hadIncompleteTile = true; |
197 | 188 |
198 gfx::RectF texture_rect = iter.texture_rect(); | 189 gfx::RectF texture_rect = iter.texture_rect(); |
199 gfx::Rect opaque_rect = iter->opaque_rect(); | 190 gfx::Rect opaque_rect = iter->opaque_rect(); |
200 opaque_rect.Intersect(content_rect); | 191 opaque_rect.Intersect(content_rect); |
201 | 192 |
202 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); | 193 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); |
203 quad->SetNew(sharedQuadState, | 194 quad->SetNew(sharedQuadState, |
204 geometry_rect, | 195 geometry_rect, |
205 opaque_rect, | 196 opaque_rect, |
206 resource, | 197 drawing_info.get_resource_id(), |
207 texture_rect, | 198 texture_rect, |
208 iter.texture_size(), | 199 iter.texture_size(), |
209 iter->contents_swizzled()); | 200 drawing_info.contents_swizzled()); |
210 quadSink->append(quad.PassAs<DrawQuad>(), appendQuadsData); | 201 quadSink->append(quad.PassAs<DrawQuad>(), appendQuadsData); |
| 202 break; |
| 203 } |
| 204 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { |
| 205 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
| 206 quad->SetNew(sharedQuadState, |
| 207 geometry_rect, |
| 208 drawing_info.get_solid_color()); |
| 209 quadSink->append(quad.PassAs<DrawQuad>(), appendQuadsData); |
| 210 break; |
| 211 } |
| 212 case ManagedTileState::DrawingInfo::TRANSPARENT_MODE: |
| 213 break; |
| 214 case ManagedTileState::DrawingInfo::PICTURE_PILE_MODE: |
| 215 // TODO: crbug.com/173011 would fill this part in. |
| 216 default: |
| 217 NOTREACHED(); |
| 218 } |
211 | 219 |
212 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) | 220 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) |
213 seen_tilings.push_back(iter.CurrentTiling()); | 221 seen_tilings.push_back(iter.CurrentTiling()); |
214 } | 222 } |
215 | 223 |
216 // Aggressively remove any tilings that are not seen to save memory. Note | 224 // Aggressively remove any tilings that are not seen to save memory. Note |
217 // that this is at the expense of doing cause more frequent re-painting. A | 225 // that this is at the expense of doing cause more frequent re-painting. A |
218 // better scheme would be to maintain a tighter visibleContentRect for the | 226 // better scheme would be to maintain a tighter visibleContentRect for the |
219 // finer tilings. | 227 // finer tilings. |
220 CleanUpTilingsOnActiveLayer(seen_tilings); | 228 CleanUpTilingsOnActiveLayer(seen_tilings); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 gfx::Rect content_rect(content_bounds()); | 475 gfx::Rect content_rect(content_bounds()); |
468 float scale = contents_scale_x(); | 476 float scale = contents_scale_x(); |
469 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), | 477 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), |
470 scale, | 478 scale, |
471 content_rect, | 479 content_rect, |
472 ideal_contents_scale_, | 480 ideal_contents_scale_, |
473 PictureLayerTiling::LayerDeviceAlign
mentUnknown); | 481 PictureLayerTiling::LayerDeviceAlign
mentUnknown); |
474 iter; | 482 iter; |
475 ++iter) { | 483 ++iter) { |
476 // Mask resource not ready yet. | 484 // Mask resource not ready yet. |
477 if (!*iter || !iter->GetResourceId()) | 485 if (!*iter || |
| 486 iter->drawing_info().mode() != |
| 487 ManagedTileState::DrawingInfo::TEXTURE_MODE || |
| 488 !iter->drawing_info().IsReadyToDraw()) |
478 return 0; | 489 return 0; |
479 // Masks only supported if they fit on exactly one tile. | 490 // Masks only supported if they fit on exactly one tile. |
480 if (iter.geometry_rect() != content_rect) | 491 if (iter.geometry_rect() != content_rect) |
481 return 0; | 492 return 0; |
482 return iter->GetResourceId(); | 493 return iter->drawing_info().get_resource_id(); |
483 } | 494 } |
484 return 0; | 495 return 0; |
485 } | 496 } |
486 | 497 |
487 bool PictureLayerImpl::AreVisibleResourcesReady() const { | 498 bool PictureLayerImpl::AreVisibleResourcesReady() const { |
488 DCHECK(layer_tree_impl()->IsPendingTree()); | 499 DCHECK(layer_tree_impl()->IsPendingTree()); |
489 DCHECK(ideal_contents_scale_); | 500 DCHECK(ideal_contents_scale_); |
490 | 501 |
491 const gfx::Rect& rect = visible_content_rect(); | 502 const gfx::Rect& rect = visible_content_rect(); |
492 | 503 |
(...skipping 23 matching lines...) Expand all Loading... |
516 if (tiling->contents_scale() < min_acceptable_scale) | 527 if (tiling->contents_scale() < min_acceptable_scale) |
517 continue; | 528 continue; |
518 | 529 |
519 for (PictureLayerTiling::Iterator iter(tiling, | 530 for (PictureLayerTiling::Iterator iter(tiling, |
520 contents_scale_x(), | 531 contents_scale_x(), |
521 rect, | 532 rect, |
522 PictureLayerTiling::LayerDeviceAlignm
entUnknown); | 533 PictureLayerTiling::LayerDeviceAlignm
entUnknown); |
523 iter; | 534 iter; |
524 ++iter) { | 535 ++iter) { |
525 // A null tile (i.e. no recording) is considered "ready". | 536 // A null tile (i.e. no recording) is considered "ready". |
526 if (!*iter || iter->IsReadyToDraw()) | 537 if (!*iter || iter->drawing_info().IsReadyToDraw()) |
527 missing_region.Subtract(iter.geometry_rect()); | 538 missing_region.Subtract(iter.geometry_rect()); |
528 } | 539 } |
529 } | 540 } |
530 | 541 |
531 return missing_region.IsEmpty(); | 542 return missing_region.IsEmpty(); |
532 } | 543 } |
533 | 544 |
534 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { | 545 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { |
535 DCHECK(contents_scale >= MinimumContentsScale()); | 546 DCHECK(contents_scale >= MinimumContentsScale()); |
536 | 547 |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { | 805 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { |
795 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 806 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
796 LayerImpl::AsValueInto(state.get()); | 807 LayerImpl::AsValueInto(state.get()); |
797 | 808 |
798 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 809 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
799 state->Set("tilings", tilings_->AsValue().release()); | 810 state->Set("tilings", tilings_->AsValue().release()); |
800 return state.PassAs<base::Value>(); | 811 return state.PassAs<base::Value>(); |
801 } | 812 } |
802 | 813 |
803 } // namespace cc | 814 } // namespace cc |
OLD | NEW |