| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "platform/graphics/compositing/PaintArtifactCompositor.h" | 5 #include "platform/graphics/compositing/PaintArtifactCompositor.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include "cc/layers/content_layer_client.h" | 10 #include "cc/layers/content_layer_client.h" |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 : paintArtifact.getDisplayItemList()[paintChunk.beginIndex].getId())); | 263 : paintArtifact.getDisplayItemList()[paintChunk.beginIndex].getId())); |
| 264 } | 264 } |
| 265 | 265 |
| 266 scoped_refptr<cc::Layer> | 266 scoped_refptr<cc::Layer> |
| 267 PaintArtifactCompositor::compositedLayerForPendingLayer( | 267 PaintArtifactCompositor::compositedLayerForPendingLayer( |
| 268 const PaintArtifact& paintArtifact, | 268 const PaintArtifact& paintArtifact, |
| 269 const PendingLayer& pendingLayer, | 269 const PendingLayer& pendingLayer, |
| 270 gfx::Vector2dF& layerOffset, | 270 gfx::Vector2dF& layerOffset, |
| 271 Vector<std::unique_ptr<ContentLayerClientImpl>>& newContentLayerClients, | 271 Vector<std::unique_ptr<ContentLayerClientImpl>>& newContentLayerClients, |
| 272 RasterInvalidationTrackingMap<const PaintChunk>* trackingMap, | 272 RasterInvalidationTrackingMap<const PaintChunk>* trackingMap, |
| 273 bool storeDebugInfo, | 273 bool storeDebugInfo) { |
| 274 GeometryMapper& geometryMapper) { | |
| 275 DCHECK(pendingLayer.paintChunks.size()); | 274 DCHECK(pendingLayer.paintChunks.size()); |
| 276 const PaintChunk& firstPaintChunk = *pendingLayer.paintChunks[0]; | 275 const PaintChunk& firstPaintChunk = *pendingLayer.paintChunks[0]; |
| 277 DCHECK(firstPaintChunk.size()); | 276 DCHECK(firstPaintChunk.size()); |
| 278 | 277 |
| 279 // If the paint chunk is a foreign layer, just return that layer. | 278 // If the paint chunk is a foreign layer, just return that layer. |
| 280 if (scoped_refptr<cc::Layer> foreignLayer = foreignLayerForPaintChunk( | 279 if (scoped_refptr<cc::Layer> foreignLayer = foreignLayerForPaintChunk( |
| 281 paintArtifact, firstPaintChunk, layerOffset)) { | 280 paintArtifact, firstPaintChunk, layerOffset)) { |
| 282 DCHECK_EQ(pendingLayer.paintChunks.size(), 1u); | 281 DCHECK_EQ(pendingLayer.paintChunks.size(), 1u); |
| 283 return foreignLayer; | 282 return foreignLayer; |
| 284 } | 283 } |
| 285 | 284 |
| 286 // The common case: create or reuse a PictureLayer for painted content. | 285 // The common case: create or reuse a PictureLayer for painted content. |
| 287 std::unique_ptr<ContentLayerClientImpl> contentLayerClient = | 286 std::unique_ptr<ContentLayerClientImpl> contentLayerClient = |
| 288 clientForPaintChunk(firstPaintChunk, paintArtifact); | 287 clientForPaintChunk(firstPaintChunk, paintArtifact); |
| 289 | 288 |
| 290 gfx::Rect ccCombinedBounds(enclosingIntRect(pendingLayer.bounds)); | 289 gfx::Rect ccCombinedBounds(enclosingIntRect(pendingLayer.bounds)); |
| 291 | 290 |
| 292 layerOffset = ccCombinedBounds.OffsetFromOrigin(); | 291 layerOffset = ccCombinedBounds.OffsetFromOrigin(); |
| 293 scoped_refptr<cc::DisplayItemList> displayList = | 292 scoped_refptr<cc::DisplayItemList> displayList = |
| 294 PaintChunksToCcLayer::convert( | 293 PaintChunksToCcLayer::convert(pendingLayer.paintChunks, |
| 295 pendingLayer.paintChunks, pendingLayer.propertyTreeState, layerOffset, | 294 pendingLayer.propertyTreeState, layerOffset, |
| 296 paintArtifact.getDisplayItemList(), geometryMapper); | 295 paintArtifact.getDisplayItemList()); |
| 297 contentLayerClient->SetDisplayList(std::move(displayList)); | 296 contentLayerClient->SetDisplayList(std::move(displayList)); |
| 298 contentLayerClient->SetPaintableRegion(gfx::Rect(ccCombinedBounds.size())); | 297 contentLayerClient->SetPaintableRegion(gfx::Rect(ccCombinedBounds.size())); |
| 299 | 298 |
| 300 scoped_refptr<cc::PictureLayer> ccPictureLayer = | 299 scoped_refptr<cc::PictureLayer> ccPictureLayer = |
| 301 contentLayerClient->ccPictureLayer(); | 300 contentLayerClient->ccPictureLayer(); |
| 302 ccPictureLayer->SetBounds(ccCombinedBounds.size()); | 301 ccPictureLayer->SetBounds(ccCombinedBounds.size()); |
| 303 ccPictureLayer->SetIsDrawable(true); | 302 ccPictureLayer->SetIsDrawable(true); |
| 304 ccPictureLayer->SetContentsOpaque(pendingLayer.knownToBeOpaque); | 303 ccPictureLayer->SetContentsOpaque(pendingLayer.knownToBeOpaque); |
| 305 contentLayerClient->clearPaintChunkDebugData(); | 304 contentLayerClient->clearPaintChunkDebugData(); |
| 306 | 305 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 const PaintChunk& firstPaintChunk, | 345 const PaintChunk& firstPaintChunk, |
| 347 bool chunkIsForeign) | 346 bool chunkIsForeign) |
| 348 : bounds(firstPaintChunk.bounds), | 347 : bounds(firstPaintChunk.bounds), |
| 349 knownToBeOpaque(firstPaintChunk.knownToBeOpaque), | 348 knownToBeOpaque(firstPaintChunk.knownToBeOpaque), |
| 350 backfaceHidden(firstPaintChunk.properties.backfaceHidden), | 349 backfaceHidden(firstPaintChunk.properties.backfaceHidden), |
| 351 propertyTreeState(firstPaintChunk.properties.propertyTreeState), | 350 propertyTreeState(firstPaintChunk.properties.propertyTreeState), |
| 352 isForeign(chunkIsForeign) { | 351 isForeign(chunkIsForeign) { |
| 353 paintChunks.push_back(&firstPaintChunk); | 352 paintChunks.push_back(&firstPaintChunk); |
| 354 } | 353 } |
| 355 | 354 |
| 356 void PaintArtifactCompositor::PendingLayer::merge( | 355 void PaintArtifactCompositor::PendingLayer::merge(const PendingLayer& guest) { |
| 357 const PendingLayer& guest, | |
| 358 GeometryMapper& geometryMapper) { | |
| 359 DCHECK(!isForeign && !guest.isForeign); | 356 DCHECK(!isForeign && !guest.isForeign); |
| 360 DCHECK_EQ(backfaceHidden, guest.backfaceHidden); | 357 DCHECK_EQ(backfaceHidden, guest.backfaceHidden); |
| 361 | 358 |
| 362 paintChunks.appendVector(guest.paintChunks); | 359 paintChunks.appendVector(guest.paintChunks); |
| 363 FloatRect guestBoundsInHome = guest.bounds; | 360 FloatRect guestBoundsInHome = guest.bounds; |
| 364 geometryMapper.localToAncestorVisualRect( | 361 GeometryMapper::localToAncestorVisualRect( |
| 365 guest.propertyTreeState, propertyTreeState, guestBoundsInHome); | 362 guest.propertyTreeState, propertyTreeState, guestBoundsInHome); |
| 366 FloatRect oldBounds = bounds; | 363 FloatRect oldBounds = bounds; |
| 367 bounds.unite(guestBoundsInHome); | 364 bounds.unite(guestBoundsInHome); |
| 368 if (bounds != oldBounds) | 365 if (bounds != oldBounds) |
| 369 knownToBeOpaque = false; | 366 knownToBeOpaque = false; |
| 370 // TODO(crbug.com/701991): Upgrade GeometryMapper. | 367 // TODO(crbug.com/701991): Upgrade GeometryMapper. |
| 371 // If we knew the new bounds is enclosed by the mapped opaque region of | 368 // If we knew the new bounds is enclosed by the mapped opaque region of |
| 372 // the guest layer, we can deduce the merged layer being opaque too. | 369 // the guest layer, we can deduce the merged layer being opaque too. |
| 373 } | 370 } |
| 374 | 371 |
| 375 static bool canUpcastTo(const PropertyTreeState& guest, | 372 static bool canUpcastTo(const PropertyTreeState& guest, |
| 376 const PropertyTreeState& home); | 373 const PropertyTreeState& home); |
| 377 bool PaintArtifactCompositor::PendingLayer::canMerge( | 374 bool PaintArtifactCompositor::PendingLayer::canMerge( |
| 378 const PendingLayer& guest) const { | 375 const PendingLayer& guest) const { |
| 379 if (isForeign || guest.isForeign) | 376 if (isForeign || guest.isForeign) |
| 380 return false; | 377 return false; |
| 381 if (backfaceHidden != guest.backfaceHidden) | 378 if (backfaceHidden != guest.backfaceHidden) |
| 382 return false; | 379 return false; |
| 383 if (propertyTreeState.effect() != guest.propertyTreeState.effect()) | 380 if (propertyTreeState.effect() != guest.propertyTreeState.effect()) |
| 384 return false; | 381 return false; |
| 385 return canUpcastTo(guest.propertyTreeState, propertyTreeState); | 382 return canUpcastTo(guest.propertyTreeState, propertyTreeState); |
| 386 } | 383 } |
| 387 | 384 |
| 388 void PaintArtifactCompositor::PendingLayer::upcast( | 385 void PaintArtifactCompositor::PendingLayer::upcast( |
| 389 const PropertyTreeState& newState, | 386 const PropertyTreeState& newState) { |
| 390 GeometryMapper& geometryMapper) { | |
| 391 DCHECK(!isForeign); | 387 DCHECK(!isForeign); |
| 392 geometryMapper.localToAncestorVisualRect(propertyTreeState, newState, bounds); | 388 GeometryMapper::localToAncestorVisualRect(propertyTreeState, newState, |
| 389 bounds); |
| 393 | 390 |
| 394 propertyTreeState = newState; | 391 propertyTreeState = newState; |
| 395 // TODO(crbug.com/701991): Upgrade GeometryMapper. | 392 // TODO(crbug.com/701991): Upgrade GeometryMapper. |
| 396 // A local visual rect mapped to an ancestor space may become a polygon | 393 // A local visual rect mapped to an ancestor space may become a polygon |
| 397 // (e.g. consider transformed clip), also effects may affect the opaque | 394 // (e.g. consider transformed clip), also effects may affect the opaque |
| 398 // region. To determine whether the layer is still opaque, we need to | 395 // region. To determine whether the layer is still opaque, we need to |
| 399 // query conservative opaque rect after mapping to an ancestor space, | 396 // query conservative opaque rect after mapping to an ancestor space, |
| 400 // which is not supported by GeometryMapper yet. | 397 // which is not supported by GeometryMapper yet. |
| 401 knownToBeOpaque = false; | 398 knownToBeOpaque = false; |
| 402 } | 399 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 const EffectPaintPropertyNode* ancestor, | 441 const EffectPaintPropertyNode* ancestor, |
| 445 const EffectPaintPropertyNode* node) { | 442 const EffectPaintPropertyNode* node) { |
| 446 for (; node; node = node->parent()) { | 443 for (; node; node = node->parent()) { |
| 447 if (node->parent() == ancestor) | 444 if (node->parent() == ancestor) |
| 448 return node; | 445 return node; |
| 449 } | 446 } |
| 450 return nullptr; | 447 return nullptr; |
| 451 } | 448 } |
| 452 | 449 |
| 453 bool PaintArtifactCompositor::mightOverlap(const PendingLayer& layerA, | 450 bool PaintArtifactCompositor::mightOverlap(const PendingLayer& layerA, |
| 454 const PendingLayer& layerB, | 451 const PendingLayer& layerB) { |
| 455 GeometryMapper& geometryMapper) { | |
| 456 PropertyTreeState rootPropertyTreeState(TransformPaintPropertyNode::root(), | 452 PropertyTreeState rootPropertyTreeState(TransformPaintPropertyNode::root(), |
| 457 ClipPaintPropertyNode::root(), | 453 ClipPaintPropertyNode::root(), |
| 458 EffectPaintPropertyNode::root()); | 454 EffectPaintPropertyNode::root()); |
| 459 | 455 |
| 460 FloatRect boundsA = layerA.bounds; | 456 FloatRect boundsA = layerA.bounds; |
| 461 geometryMapper.localToAncestorVisualRect(layerA.propertyTreeState, | 457 GeometryMapper::localToAncestorVisualRect(layerA.propertyTreeState, |
| 462 rootPropertyTreeState, boundsA); | 458 rootPropertyTreeState, boundsA); |
| 463 FloatRect boundsB = layerB.bounds; | 459 FloatRect boundsB = layerB.bounds; |
| 464 geometryMapper.localToAncestorVisualRect(layerB.propertyTreeState, | 460 GeometryMapper::localToAncestorVisualRect(layerB.propertyTreeState, |
| 465 rootPropertyTreeState, boundsB); | 461 rootPropertyTreeState, boundsB); |
| 466 | 462 |
| 467 return boundsA.intersects(boundsB); | 463 return boundsA.intersects(boundsB); |
| 468 } | 464 } |
| 469 | 465 |
| 470 bool PaintArtifactCompositor::canDecompositeEffect( | 466 bool PaintArtifactCompositor::canDecompositeEffect( |
| 471 const EffectPaintPropertyNode* effect, | 467 const EffectPaintPropertyNode* effect, |
| 472 const PendingLayer& layer) { | 468 const PendingLayer& layer) { |
| 473 // If the effect associated with the layer is deeper than than the effect | 469 // If the effect associated with the layer is deeper than than the effect |
| 474 // we are attempting to decomposite, than implies some previous decision | 470 // we are attempting to decomposite, than implies some previous decision |
| 475 // did not allow to decomposite intermediate effects. | 471 // did not allow to decomposite intermediate effects. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 486 if (!canUpcastTo(layer.propertyTreeState, | 482 if (!canUpcastTo(layer.propertyTreeState, |
| 487 PropertyTreeState(effect->localTransformSpace(), | 483 PropertyTreeState(effect->localTransformSpace(), |
| 488 effect->outputClip(), effect))) | 484 effect->outputClip(), effect))) |
| 489 return false; | 485 return false; |
| 490 return true; | 486 return true; |
| 491 } | 487 } |
| 492 | 488 |
| 493 void PaintArtifactCompositor::layerizeGroup( | 489 void PaintArtifactCompositor::layerizeGroup( |
| 494 const PaintArtifact& paintArtifact, | 490 const PaintArtifact& paintArtifact, |
| 495 Vector<PendingLayer>& pendingLayers, | 491 Vector<PendingLayer>& pendingLayers, |
| 496 GeometryMapper& geometryMapper, | |
| 497 const EffectPaintPropertyNode& currentGroup, | 492 const EffectPaintPropertyNode& currentGroup, |
| 498 Vector<PaintChunk>::const_iterator& chunkIt) { | 493 Vector<PaintChunk>::const_iterator& chunkIt) { |
| 499 size_t firstLayerInCurrentGroup = pendingLayers.size(); | 494 size_t firstLayerInCurrentGroup = pendingLayers.size(); |
| 500 // The worst case time complexity of the algorithm is O(pqd), where | 495 // The worst case time complexity of the algorithm is O(pqd), where |
| 501 // p = the number of paint chunks. | 496 // p = the number of paint chunks. |
| 502 // q = average number of trials to find a squash layer or rejected | 497 // q = average number of trials to find a squash layer or rejected |
| 503 // for overlapping. | 498 // for overlapping. |
| 504 // d = (sum of) the depth of property trees. | 499 // d = (sum of) the depth of property trees. |
| 505 // The analysis as follows: | 500 // The analysis as follows: |
| 506 // Every paint chunk will be visited by the main loop below for exactly once, | 501 // Every paint chunk will be visited by the main loop below for exactly once, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 532 } else { | 527 } else { |
| 533 const EffectPaintPropertyNode* subgroup = | 528 const EffectPaintPropertyNode* subgroup = |
| 534 strictChildOfAlongPath(¤tGroup, chunkEffect); | 529 strictChildOfAlongPath(¤tGroup, chunkEffect); |
| 535 // Case B: This means we need to close the current group without | 530 // Case B: This means we need to close the current group without |
| 536 // processing the next chunk. | 531 // processing the next chunk. |
| 537 if (!subgroup) | 532 if (!subgroup) |
| 538 break; | 533 break; |
| 539 // Case C: The following chunks belong to a subgroup. Process them by | 534 // Case C: The following chunks belong to a subgroup. Process them by |
| 540 // a recursion call. | 535 // a recursion call. |
| 541 size_t firstLayerInSubgroup = pendingLayers.size(); | 536 size_t firstLayerInSubgroup = pendingLayers.size(); |
| 542 layerizeGroup(paintArtifact, pendingLayers, geometryMapper, *subgroup, | 537 layerizeGroup(paintArtifact, pendingLayers, *subgroup, chunkIt); |
| 543 chunkIt); | |
| 544 // Now the chunk iterator stepped over the subgroup we just saw. | 538 // Now the chunk iterator stepped over the subgroup we just saw. |
| 545 // If the subgroup generated 2 or more layers then the subgroup must be | 539 // If the subgroup generated 2 or more layers then the subgroup must be |
| 546 // composited to satisfy grouping requirement. | 540 // composited to satisfy grouping requirement. |
| 547 // i.e. Grouping effects generally must be applied atomically, | 541 // i.e. Grouping effects generally must be applied atomically, |
| 548 // for example, Opacity(A+B) != Opacity(A) + Opacity(B), thus an effect | 542 // for example, Opacity(A+B) != Opacity(A) + Opacity(B), thus an effect |
| 549 // either applied 100% within a layer, or not at all applied within layer | 543 // either applied 100% within a layer, or not at all applied within layer |
| 550 // (i.e. applied by compositor render surface instead). | 544 // (i.e. applied by compositor render surface instead). |
| 551 if (pendingLayers.size() != firstLayerInSubgroup + 1) | 545 if (pendingLayers.size() != firstLayerInSubgroup + 1) |
| 552 continue; | 546 continue; |
| 553 // Now attempt to "decomposite" subgroup. | 547 // Now attempt to "decomposite" subgroup. |
| 554 PendingLayer& subgroupLayer = pendingLayers[firstLayerInSubgroup]; | 548 PendingLayer& subgroupLayer = pendingLayers[firstLayerInSubgroup]; |
| 555 if (!canDecompositeEffect(subgroup, subgroupLayer)) | 549 if (!canDecompositeEffect(subgroup, subgroupLayer)) |
| 556 continue; | 550 continue; |
| 557 subgroupLayer.upcast( | 551 subgroupLayer.upcast(PropertyTreeState(subgroup->localTransformSpace(), |
| 558 PropertyTreeState(subgroup->localTransformSpace(), | 552 subgroup->outputClip(), |
| 559 subgroup->outputClip(), ¤tGroup), | 553 ¤tGroup)); |
| 560 geometryMapper); | |
| 561 } | 554 } |
| 562 // At this point pendingLayers.back() is the either a layer from a | 555 // At this point pendingLayers.back() is the either a layer from a |
| 563 // "decomposited" subgroup or a layer created from a chunk we just | 556 // "decomposited" subgroup or a layer created from a chunk we just |
| 564 // processed. Now determine whether it could be merged into a previous | 557 // processed. Now determine whether it could be merged into a previous |
| 565 // layer. | 558 // layer. |
| 566 const PendingLayer& newLayer = pendingLayers.back(); | 559 const PendingLayer& newLayer = pendingLayers.back(); |
| 567 DCHECK(!newLayer.isForeign); | 560 DCHECK(!newLayer.isForeign); |
| 568 DCHECK_EQ(¤tGroup, newLayer.propertyTreeState.effect()); | 561 DCHECK_EQ(¤tGroup, newLayer.propertyTreeState.effect()); |
| 569 // This iterates pendingLayers[firstLayerInCurrentGroup:-1] in reverse. | 562 // This iterates pendingLayers[firstLayerInCurrentGroup:-1] in reverse. |
| 570 for (size_t candidateIndex = pendingLayers.size() - 1; | 563 for (size_t candidateIndex = pendingLayers.size() - 1; |
| 571 candidateIndex-- > firstLayerInCurrentGroup;) { | 564 candidateIndex-- > firstLayerInCurrentGroup;) { |
| 572 PendingLayer& candidateLayer = pendingLayers[candidateIndex]; | 565 PendingLayer& candidateLayer = pendingLayers[candidateIndex]; |
| 573 if (candidateLayer.canMerge(newLayer)) { | 566 if (candidateLayer.canMerge(newLayer)) { |
| 574 candidateLayer.merge(newLayer, geometryMapper); | 567 candidateLayer.merge(newLayer); |
| 575 pendingLayers.pop_back(); | 568 pendingLayers.pop_back(); |
| 576 break; | 569 break; |
| 577 } | 570 } |
| 578 if (mightOverlap(newLayer, candidateLayer, geometryMapper)) | 571 if (mightOverlap(newLayer, candidateLayer)) |
| 579 break; | 572 break; |
| 580 } | 573 } |
| 581 } | 574 } |
| 582 } | 575 } |
| 583 | 576 |
| 584 void PaintArtifactCompositor::collectPendingLayers( | 577 void PaintArtifactCompositor::collectPendingLayers( |
| 585 const PaintArtifact& paintArtifact, | 578 const PaintArtifact& paintArtifact, |
| 586 Vector<PendingLayer>& pendingLayers, | 579 Vector<PendingLayer>& pendingLayers) { |
| 587 GeometryMapper& geometryMapper) { | |
| 588 Vector<PaintChunk>::const_iterator cursor = | 580 Vector<PaintChunk>::const_iterator cursor = |
| 589 paintArtifact.paintChunks().begin(); | 581 paintArtifact.paintChunks().begin(); |
| 590 layerizeGroup(paintArtifact, pendingLayers, geometryMapper, | 582 layerizeGroup(paintArtifact, pendingLayers, *EffectPaintPropertyNode::root(), |
| 591 *EffectPaintPropertyNode::root(), cursor); | 583 cursor); |
| 592 DCHECK_EQ(paintArtifact.paintChunks().end(), cursor); | 584 DCHECK_EQ(paintArtifact.paintChunks().end(), cursor); |
| 593 } | 585 } |
| 594 | 586 |
| 595 void PaintArtifactCompositor::update( | 587 void PaintArtifactCompositor::update( |
| 596 const PaintArtifact& paintArtifact, | 588 const PaintArtifact& paintArtifact, |
| 597 RasterInvalidationTrackingMap<const PaintChunk>* rasterChunkInvalidations, | 589 RasterInvalidationTrackingMap<const PaintChunk>* rasterChunkInvalidations, |
| 598 bool storeDebugInfo, | 590 bool storeDebugInfo) { |
| 599 GeometryMapper& geometryMapper) { | |
| 600 #ifndef NDEBUG | 591 #ifndef NDEBUG |
| 601 storeDebugInfo = true; | 592 storeDebugInfo = true; |
| 602 #endif | 593 #endif |
| 603 | 594 |
| 604 DCHECK(m_rootLayer); | 595 DCHECK(m_rootLayer); |
| 605 | 596 |
| 606 cc::LayerTreeHost* layerTreeHost = m_rootLayer->layer_tree_host(); | 597 cc::LayerTreeHost* layerTreeHost = m_rootLayer->layer_tree_host(); |
| 607 | 598 |
| 608 // The tree will be null after detaching and this update can be ignored. | 599 // The tree will be null after detaching and this update can be ignored. |
| 609 // See: WebViewImpl::detachPaintArtifactCompositor(). | 600 // See: WebViewImpl::detachPaintArtifactCompositor(). |
| 610 if (!layerTreeHost) | 601 if (!layerTreeHost) |
| 611 return; | 602 return; |
| 612 | 603 |
| 613 if (m_extraDataForTestingEnabled) | 604 if (m_extraDataForTestingEnabled) |
| 614 m_extraDataForTesting = WTF::wrapUnique(new ExtraDataForTesting); | 605 m_extraDataForTesting = WTF::wrapUnique(new ExtraDataForTesting); |
| 615 | 606 |
| 616 m_rootLayer->RemoveAllChildren(); | 607 m_rootLayer->RemoveAllChildren(); |
| 617 | 608 |
| 618 m_rootLayer->set_property_tree_sequence_number(sPropertyTreeSequenceNumber); | 609 m_rootLayer->set_property_tree_sequence_number(sPropertyTreeSequenceNumber); |
| 619 | 610 |
| 620 PropertyTreeManager propertyTreeManager(*layerTreeHost->property_trees(), | 611 PropertyTreeManager propertyTreeManager(*layerTreeHost->property_trees(), |
| 621 m_rootLayer.get(), | 612 m_rootLayer.get(), |
| 622 sPropertyTreeSequenceNumber); | 613 sPropertyTreeSequenceNumber); |
| 623 | 614 |
| 624 Vector<PendingLayer, 0> pendingLayers; | 615 Vector<PendingLayer, 0> pendingLayers; |
| 625 collectPendingLayers(paintArtifact, pendingLayers, geometryMapper); | 616 collectPendingLayers(paintArtifact, pendingLayers); |
| 626 | 617 |
| 627 Vector<std::unique_ptr<ContentLayerClientImpl>> newContentLayerClients; | 618 Vector<std::unique_ptr<ContentLayerClientImpl>> newContentLayerClients; |
| 628 newContentLayerClients.reserveCapacity(paintArtifact.paintChunks().size()); | 619 newContentLayerClients.reserveCapacity(paintArtifact.paintChunks().size()); |
| 629 for (const PendingLayer& pendingLayer : pendingLayers) { | 620 for (const PendingLayer& pendingLayer : pendingLayers) { |
| 630 gfx::Vector2dF layerOffset; | 621 gfx::Vector2dF layerOffset; |
| 631 scoped_refptr<cc::Layer> layer = compositedLayerForPendingLayer( | 622 scoped_refptr<cc::Layer> layer = compositedLayerForPendingLayer( |
| 632 paintArtifact, pendingLayer, layerOffset, newContentLayerClients, | 623 paintArtifact, pendingLayer, layerOffset, newContentLayerClients, |
| 633 rasterChunkInvalidations, storeDebugInfo, geometryMapper); | 624 rasterChunkInvalidations, storeDebugInfo); |
| 634 | 625 |
| 635 const auto* transform = pendingLayer.propertyTreeState.transform(); | 626 const auto* transform = pendingLayer.propertyTreeState.transform(); |
| 636 int transformId = | 627 int transformId = |
| 637 propertyTreeManager.ensureCompositorTransformNode(transform); | 628 propertyTreeManager.ensureCompositorTransformNode(transform); |
| 638 int clipId = propertyTreeManager.ensureCompositorClipNode( | 629 int clipId = propertyTreeManager.ensureCompositorClipNode( |
| 639 pendingLayer.propertyTreeState.clip()); | 630 pendingLayer.propertyTreeState.clip()); |
| 640 int effectId = propertyTreeManager.switchToEffectNode( | 631 int effectId = propertyTreeManager.switchToEffectNode( |
| 641 *pendingLayer.propertyTreeState.effect()); | 632 *pendingLayer.propertyTreeState.effect()); |
| 642 | 633 |
| 643 layer->set_offset_to_transform_parent(layerOffset); | 634 layer->set_offset_to_transform_parent(layerOffset); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 670 #ifndef NDEBUG | 661 #ifndef NDEBUG |
| 671 void PaintArtifactCompositor::showDebugData() { | 662 void PaintArtifactCompositor::showDebugData() { |
| 672 LOG(ERROR) << layersAsJSON(LayerTreeIncludesDebugInfo) | 663 LOG(ERROR) << layersAsJSON(LayerTreeIncludesDebugInfo) |
| 673 ->toPrettyJSONString() | 664 ->toPrettyJSONString() |
| 674 .utf8() | 665 .utf8() |
| 675 .data(); | 666 .data(); |
| 676 } | 667 } |
| 677 #endif | 668 #endif |
| 678 | 669 |
| 679 } // namespace blink | 670 } // namespace blink |
| OLD | NEW |