Chromium Code Reviews| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 if (showDebugBorders()) { | 107 if (showDebugBorders()) { |
| 108 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), | 108 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), |
| 109 contentsScaleX(), | 109 contentsScaleX(), |
| 110 rect, | 110 rect, |
| 111 ideal_contents_scale_, | 111 ideal_contents_scale_, |
| 112 layerDeviceAlignment); | 112 layerDeviceAlignment); |
| 113 iter; | 113 iter; |
| 114 ++iter) { | 114 ++iter) { |
| 115 SkColor color; | 115 SkColor color; |
| 116 float width; | 116 float width; |
| 117 if (*iter && iter->GetResourceId()) { | 117 if (*iter && iter->drawing_info().IsReadyToDraw()) { |
| 118 if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { | 118 if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { |
| 119 color = DebugColors::HighResTileBorderColor(); | 119 color = DebugColors::HighResTileBorderColor(); |
| 120 width = DebugColors::HighResTileBorderWidth(layerTreeImpl()); | 120 width = DebugColors::HighResTileBorderWidth(layerTreeImpl()); |
| 121 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { | 121 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { |
| 122 color = DebugColors::LowResTileBorderColor(); | 122 color = DebugColors::LowResTileBorderColor(); |
| 123 width = DebugColors::LowResTileBorderWidth(layerTreeImpl()); | 123 width = DebugColors::LowResTileBorderWidth(layerTreeImpl()); |
| 124 } else if (iter->contents_scale() > contentsScaleX()) { | 124 } else if (iter->contents_scale() > contentsScaleX()) { |
| 125 color = DebugColors::ExtraHighResTileBorderColor(); | 125 color = DebugColors::ExtraHighResTileBorderColor(); |
| 126 width = DebugColors::ExtraHighResTileBorderWidth(layerTreeImpl()); | 126 width = DebugColors::ExtraHighResTileBorderWidth(layerTreeImpl()); |
| 127 } else { | 127 } else { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 145 // unused can be considered for removal. | 145 // unused can be considered for removal. |
| 146 std::vector<PictureLayerTiling*> seen_tilings; | 146 std::vector<PictureLayerTiling*> seen_tilings; |
| 147 | 147 |
| 148 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), | 148 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), |
| 149 contentsScaleX(), | 149 contentsScaleX(), |
| 150 rect, | 150 rect, |
| 151 ideal_contents_scale_, | 151 ideal_contents_scale_, |
| 152 layerDeviceAlignment); | 152 layerDeviceAlignment); |
| 153 iter; | 153 iter; |
| 154 ++iter) { | 154 ++iter) { |
| 155 ResourceProvider::ResourceId resource = 0; | |
| 156 if (*iter) | |
| 157 resource = iter->GetResourceId(); | |
| 158 | 155 |
| 159 gfx::Rect geometry_rect = iter.geometry_rect(); | 156 gfx::Rect geometry_rect = iter.geometry_rect(); |
| 160 | 157 if (!*iter || !iter->drawing_info().IsReadyToDraw()) { |
|
nduca
2013/03/12 19:44:34
i'm concerned about you moving the !*iter below th
enne (OOO)
2013/03/12 19:48:04
This is safe. All iterators have a geometry rect,
| |
| 161 if (!resource) { | |
| 162 if (drawCheckerboardForMissingTiles()) { | 158 if (drawCheckerboardForMissingTiles()) { |
| 163 // TODO(enne): Figure out how to show debug "invalidated checker" color | 159 // TODO(enne): Figure out how to show debug "invalidated checker" color |
| 164 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create(); | 160 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create(); |
| 165 SkColor color = DebugColors::DefaultCheckerboardColor(); | 161 SkColor color = DebugColors::DefaultCheckerboardColor(); |
| 166 quad->SetNew(sharedQuadState, geometry_rect, color); | 162 quad->SetNew(sharedQuadState, geometry_rect, color); |
| 167 if (quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData)) | 163 if (quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData)) |
| 168 appendQuadsData.numMissingTiles++; | 164 appendQuadsData.numMissingTiles++; |
| 169 } else { | 165 } else { |
| 170 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 166 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
| 171 quad->SetNew(sharedQuadState, geometry_rect, backgroundColor()); | 167 quad->SetNew(sharedQuadState, geometry_rect, backgroundColor()); |
| 172 if (quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData)) | 168 if (quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData)) |
| 173 appendQuadsData.numMissingTiles++; | 169 appendQuadsData.numMissingTiles++; |
| 174 } | 170 } |
| 175 | 171 |
| 176 appendQuadsData.hadIncompleteTile = true; | 172 appendQuadsData.hadIncompleteTile = true; |
| 177 continue; | 173 continue; |
| 178 } | 174 } |
| 179 | 175 |
| 180 if (iter->contents_scale() != ideal_contents_scale_) | 176 const TileDrawingInfo& drawing_info = iter->drawing_info(); |
| 181 appendQuadsData.hadIncompleteTile = true; | 177 switch (drawing_info.mode()) { |
| 178 case TileDrawingInfo::TEXTURE_MODE: { | |
| 179 if (iter->contents_scale() != ideal_contents_scale_) | |
| 180 appendQuadsData.hadIncompleteTile = true; | |
| 182 | 181 |
| 183 gfx::RectF texture_rect = iter.texture_rect(); | 182 gfx::RectF texture_rect = iter.texture_rect(); |
| 184 gfx::Rect opaque_rect = iter->opaque_rect(); | 183 gfx::Rect opaque_rect = iter->opaque_rect(); |
| 185 opaque_rect.Intersect(content_rect); | 184 opaque_rect.Intersect(content_rect); |
| 186 | 185 |
| 187 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); | 186 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); |
| 188 quad->SetNew(sharedQuadState, | 187 quad->SetNew(sharedQuadState, |
| 189 geometry_rect, | 188 geometry_rect, |
| 190 opaque_rect, | 189 opaque_rect, |
| 191 resource, | 190 drawing_info.get_resource_id(), |
| 192 texture_rect, | 191 texture_rect, |
| 193 iter.texture_size(), | 192 iter.texture_size(), |
| 194 iter->contents_swizzled()); | 193 drawing_info.contents_swizzled()); |
| 195 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 194 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
| 195 break; | |
| 196 } | |
| 197 case TileDrawingInfo::SOLID_COLOR_MODE: { | |
| 198 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | |
| 199 quad->SetNew(sharedQuadState, | |
| 200 geometry_rect, | |
| 201 drawing_info.get_solid_color()); | |
| 202 break; | |
| 203 } | |
| 204 case TileDrawingInfo::TRANSPARENT_MODE: | |
| 205 break; | |
| 206 case TileDrawingInfo::PICTURE_PILE_MODE: | |
| 207 // TODO: crbug.com/173011 would fill this part in. | |
| 208 default: | |
| 209 NOTREACHED(); | |
| 210 } | |
| 196 | 211 |
| 197 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) | 212 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) |
| 198 seen_tilings.push_back(iter.CurrentTiling()); | 213 seen_tilings.push_back(iter.CurrentTiling()); |
| 199 } | 214 } |
| 200 | 215 |
| 201 // Aggressively remove any tilings that are not seen to save memory. Note | 216 // Aggressively remove any tilings that are not seen to save memory. Note |
| 202 // that this is at the expense of doing cause more frequent re-painting. A | 217 // that this is at the expense of doing cause more frequent re-painting. A |
| 203 // better scheme would be to maintain a tighter visibleContentRect for the | 218 // better scheme would be to maintain a tighter visibleContentRect for the |
| 204 // finer tilings. | 219 // finer tilings. |
| 205 CleanUpTilingsOnActiveLayer(seen_tilings); | 220 CleanUpTilingsOnActiveLayer(seen_tilings); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 453 gfx::Rect content_rect(gfx::Point(), contentBounds()); | 468 gfx::Rect content_rect(gfx::Point(), contentBounds()); |
| 454 float scale = contentsScaleX(); | 469 float scale = contentsScaleX(); |
| 455 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), | 470 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), |
| 456 scale, | 471 scale, |
| 457 content_rect, | 472 content_rect, |
| 458 ideal_contents_scale_, | 473 ideal_contents_scale_, |
| 459 PictureLayerTiling::LayerDeviceAlign mentUnknown); | 474 PictureLayerTiling::LayerDeviceAlign mentUnknown); |
| 460 iter; | 475 iter; |
| 461 ++iter) { | 476 ++iter) { |
| 462 // Mask resource not ready yet. | 477 // Mask resource not ready yet. |
| 463 if (!*iter || !iter->GetResourceId()) | 478 if (!*iter || |
| 479 iter->drawing_info().mode() != TileDrawingInfo::TEXTURE_MODE || | |
| 480 !iter->drawing_info().IsReadyToDraw()) | |
| 464 return 0; | 481 return 0; |
| 465 // Masks only supported if they fit on exactly one tile. | 482 // Masks only supported if they fit on exactly one tile. |
| 466 if (iter.geometry_rect() != content_rect) | 483 if (iter.geometry_rect() != content_rect) |
| 467 return 0; | 484 return 0; |
| 468 return iter->GetResourceId(); | 485 return iter->drawing_info().get_resource_id(); |
| 469 } | 486 } |
| 470 return 0; | 487 return 0; |
| 471 } | 488 } |
| 472 | 489 |
| 473 bool PictureLayerImpl::areVisibleResourcesReady() const { | 490 bool PictureLayerImpl::areVisibleResourcesReady() const { |
| 474 DCHECK(layerTreeImpl()->IsPendingTree()); | 491 DCHECK(layerTreeImpl()->IsPendingTree()); |
| 475 DCHECK(ideal_contents_scale_); | 492 DCHECK(ideal_contents_scale_); |
| 476 | 493 |
| 477 const gfx::Rect& rect = visibleContentRect(); | 494 const gfx::Rect& rect = visibleContentRect(); |
| 478 | 495 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 502 if (tiling->contents_scale() < min_acceptable_scale) | 519 if (tiling->contents_scale() < min_acceptable_scale) |
| 503 continue; | 520 continue; |
| 504 | 521 |
| 505 for (PictureLayerTiling::Iterator iter(tiling, | 522 for (PictureLayerTiling::Iterator iter(tiling, |
| 506 contentsScaleX(), | 523 contentsScaleX(), |
| 507 rect, | 524 rect, |
| 508 PictureLayerTiling::LayerDeviceAlignm entUnknown); | 525 PictureLayerTiling::LayerDeviceAlignm entUnknown); |
| 509 iter; | 526 iter; |
| 510 ++iter) { | 527 ++iter) { |
| 511 // A null tile (i.e. no recording) is considered "ready". | 528 // A null tile (i.e. no recording) is considered "ready". |
| 512 if (!*iter || iter->GetResourceId()) | 529 if (!*iter || iter->drawing_info().IsReadyToDraw()) |
| 513 missing_region.Subtract(iter.geometry_rect()); | 530 missing_region.Subtract(iter.geometry_rect()); |
| 514 } | 531 } |
| 515 } | 532 } |
| 516 | 533 |
| 517 return missing_region.IsEmpty(); | 534 return missing_region.IsEmpty(); |
| 518 } | 535 } |
| 519 | 536 |
| 520 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { | 537 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { |
| 521 DCHECK(contents_scale >= MinimumContentsScale()); | 538 DCHECK(contents_scale >= MinimumContentsScale()); |
| 522 | 539 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 780 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { | 797 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { |
| 781 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 798 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 782 LayerImpl::AsValueInto(state.get()); | 799 LayerImpl::AsValueInto(state.get()); |
| 783 | 800 |
| 784 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 801 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
| 785 state->Set("tilings", tilings_->AsValue().release()); | 802 state->Set("tilings", tilings_->AsValue().release()); |
| 786 return state.PassAs<base::Value>(); | 803 return state.PassAs<base::Value>(); |
| 787 } | 804 } |
| 788 | 805 |
| 789 } // namespace cc | 806 } // namespace cc |
| OLD | NEW |