| 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 propertyTreeState(firstPaintChunk.properties.propertyTreeState), | 350 propertyTreeState(firstPaintChunk.properties.propertyTreeState), |
| 351 isForeign(chunkIsForeign) { | 351 isForeign(chunkIsForeign) { |
| 352 paintChunks.push_back(&firstPaintChunk); | 352 paintChunks.push_back(&firstPaintChunk); |
| 353 } | 353 } |
| 354 | 354 |
| 355 void PaintArtifactCompositor::PendingLayer::merge(const PendingLayer& guest) { | 355 void PaintArtifactCompositor::PendingLayer::merge(const PendingLayer& guest) { |
| 356 DCHECK(!isForeign && !guest.isForeign); | 356 DCHECK(!isForeign && !guest.isForeign); |
| 357 DCHECK_EQ(backfaceHidden, guest.backfaceHidden); | 357 DCHECK_EQ(backfaceHidden, guest.backfaceHidden); |
| 358 | 358 |
| 359 paintChunks.appendVector(guest.paintChunks); | 359 paintChunks.appendVector(guest.paintChunks); |
| 360 FloatRect guestBoundsInHome = guest.bounds; | 360 FloatClipRect guestBoundsInHome(guest.bounds); |
| 361 GeometryMapper::localToAncestorVisualRect( | 361 GeometryMapper::localToAncestorVisualRect( |
| 362 guest.propertyTreeState, propertyTreeState, guestBoundsInHome); | 362 guest.propertyTreeState, propertyTreeState, guestBoundsInHome); |
| 363 FloatRect oldBounds = bounds; | 363 FloatRect oldBounds = bounds; |
| 364 bounds.unite(guestBoundsInHome); | 364 bounds.unite(guestBoundsInHome.rect()); |
| 365 if (bounds != oldBounds) | 365 if (bounds != oldBounds) |
| 366 knownToBeOpaque = false; | 366 knownToBeOpaque = false; |
| 367 // TODO(crbug.com/701991): Upgrade GeometryMapper. | 367 // TODO(crbug.com/701991): Upgrade GeometryMapper. |
| 368 // 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 |
| 369 // 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. |
| 370 } | 370 } |
| 371 | 371 |
| 372 static bool canUpcastTo(const PropertyTreeState& guest, | 372 static bool canUpcastTo(const PropertyTreeState& guest, |
| 373 const PropertyTreeState& home); | 373 const PropertyTreeState& home); |
| 374 bool PaintArtifactCompositor::PendingLayer::canMerge( | 374 bool PaintArtifactCompositor::PendingLayer::canMerge( |
| 375 const PendingLayer& guest) const { | 375 const PendingLayer& guest) const { |
| 376 if (isForeign || guest.isForeign) | 376 if (isForeign || guest.isForeign) |
| 377 return false; | 377 return false; |
| 378 if (backfaceHidden != guest.backfaceHidden) | 378 if (backfaceHidden != guest.backfaceHidden) |
| 379 return false; | 379 return false; |
| 380 if (propertyTreeState.effect() != guest.propertyTreeState.effect()) | 380 if (propertyTreeState.effect() != guest.propertyTreeState.effect()) |
| 381 return false; | 381 return false; |
| 382 return canUpcastTo(guest.propertyTreeState, propertyTreeState); | 382 return canUpcastTo(guest.propertyTreeState, propertyTreeState); |
| 383 } | 383 } |
| 384 | 384 |
| 385 void PaintArtifactCompositor::PendingLayer::upcast( | 385 void PaintArtifactCompositor::PendingLayer::upcast( |
| 386 const PropertyTreeState& newState) { | 386 const PropertyTreeState& newState) { |
| 387 DCHECK(!isForeign); | 387 DCHECK(!isForeign); |
| 388 FloatClipRect floatClipRect(bounds); |
| 388 GeometryMapper::localToAncestorVisualRect(propertyTreeState, newState, | 389 GeometryMapper::localToAncestorVisualRect(propertyTreeState, newState, |
| 389 bounds); | 390 floatClipRect); |
| 391 bounds = floatClipRect.rect(); |
| 390 | 392 |
| 391 propertyTreeState = newState; | 393 propertyTreeState = newState; |
| 392 // TODO(crbug.com/701991): Upgrade GeometryMapper. | 394 // TODO(crbug.com/701991): Upgrade GeometryMapper. |
| 393 // A local visual rect mapped to an ancestor space may become a polygon | 395 // A local visual rect mapped to an ancestor space may become a polygon |
| 394 // (e.g. consider transformed clip), also effects may affect the opaque | 396 // (e.g. consider transformed clip), also effects may affect the opaque |
| 395 // region. To determine whether the layer is still opaque, we need to | 397 // region. To determine whether the layer is still opaque, we need to |
| 396 // query conservative opaque rect after mapping to an ancestor space, | 398 // query conservative opaque rect after mapping to an ancestor space, |
| 397 // which is not supported by GeometryMapper yet. | 399 // which is not supported by GeometryMapper yet. |
| 398 knownToBeOpaque = false; | 400 knownToBeOpaque = false; |
| 399 } | 401 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 } | 448 } |
| 447 return nullptr; | 449 return nullptr; |
| 448 } | 450 } |
| 449 | 451 |
| 450 bool PaintArtifactCompositor::mightOverlap(const PendingLayer& layerA, | 452 bool PaintArtifactCompositor::mightOverlap(const PendingLayer& layerA, |
| 451 const PendingLayer& layerB) { | 453 const PendingLayer& layerB) { |
| 452 PropertyTreeState rootPropertyTreeState(TransformPaintPropertyNode::root(), | 454 PropertyTreeState rootPropertyTreeState(TransformPaintPropertyNode::root(), |
| 453 ClipPaintPropertyNode::root(), | 455 ClipPaintPropertyNode::root(), |
| 454 EffectPaintPropertyNode::root()); | 456 EffectPaintPropertyNode::root()); |
| 455 | 457 |
| 456 FloatRect boundsA = layerA.bounds; | 458 FloatClipRect boundsA(layerA.bounds); |
| 457 GeometryMapper::localToAncestorVisualRect(layerA.propertyTreeState, | 459 GeometryMapper::localToAncestorVisualRect(layerA.propertyTreeState, |
| 458 rootPropertyTreeState, boundsA); | 460 rootPropertyTreeState, boundsA); |
| 459 FloatRect boundsB = layerB.bounds; | 461 FloatClipRect boundsB(layerB.bounds); |
| 460 GeometryMapper::localToAncestorVisualRect(layerB.propertyTreeState, | 462 GeometryMapper::localToAncestorVisualRect(layerB.propertyTreeState, |
| 461 rootPropertyTreeState, boundsB); | 463 rootPropertyTreeState, boundsB); |
| 462 | 464 |
| 463 return boundsA.intersects(boundsB); | 465 return boundsA.rect().intersects(boundsB.rect()); |
| 464 } | 466 } |
| 465 | 467 |
| 466 bool PaintArtifactCompositor::canDecompositeEffect( | 468 bool PaintArtifactCompositor::canDecompositeEffect( |
| 467 const EffectPaintPropertyNode* effect, | 469 const EffectPaintPropertyNode* effect, |
| 468 const PendingLayer& layer) { | 470 const PendingLayer& layer) { |
| 469 // If the effect associated with the layer is deeper than than the effect | 471 // If the effect associated with the layer is deeper than than the effect |
| 470 // we are attempting to decomposite, than implies some previous decision | 472 // we are attempting to decomposite, than implies some previous decision |
| 471 // did not allow to decomposite intermediate effects. | 473 // did not allow to decomposite intermediate effects. |
| 472 if (layer.propertyTreeState.effect() != effect) | 474 if (layer.propertyTreeState.effect() != effect) |
| 473 return false; | 475 return false; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 #ifndef NDEBUG | 663 #ifndef NDEBUG |
| 662 void PaintArtifactCompositor::showDebugData() { | 664 void PaintArtifactCompositor::showDebugData() { |
| 663 LOG(ERROR) << layersAsJSON(LayerTreeIncludesDebugInfo) | 665 LOG(ERROR) << layersAsJSON(LayerTreeIncludesDebugInfo) |
| 664 ->toPrettyJSONString() | 666 ->toPrettyJSONString() |
| 665 .utf8() | 667 .utf8() |
| 666 .data(); | 668 .data(); |
| 667 } | 669 } |
| 668 #endif | 670 #endif |
| 669 | 671 |
| 670 } // namespace blink | 672 } // namespace blink |
| OLD | NEW |