Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: third_party/WebKit/Source/core/layout/compositing/CompositingRequirementsUpdater.cpp

Issue 2714283002: Fix unexpected blurry text caused by combination of skew and promotion (Closed)
Patch Set: Refactor && add unit tests Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2014 Google Inc. All rights reserved. 3 * Copyright (C) 2014 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 Vector<OverlapMapContainers> m_overlapStack; 140 Vector<OverlapMapContainers> m_overlapStack;
141 }; 141 };
142 142
143 class CompositingRequirementsUpdater::RecursionData { 143 class CompositingRequirementsUpdater::RecursionData {
144 public: 144 public:
145 explicit RecursionData(PaintLayer* compositingAncestor) 145 explicit RecursionData(PaintLayer* compositingAncestor)
146 : m_compositingAncestor(compositingAncestor), 146 : m_compositingAncestor(compositingAncestor),
147 m_subtreeIsCompositing(false), 147 m_subtreeIsCompositing(false),
148 m_hasUnisolatedCompositedBlendingDescendant(false), 148 m_hasUnisolatedCompositedBlendingDescendant(false),
149 m_testingOverlap(true), 149 m_testingOverlap(true),
150 m_hasCompositedScrollingAncestor(false) {} 150 m_hasCompositedScrollingAncestor(false),
151 m_hasCompositedSkewedAncestor(false) {}
151 152
152 PaintLayer* m_compositingAncestor; 153 PaintLayer* m_compositingAncestor;
153 bool m_subtreeIsCompositing; 154 bool m_subtreeIsCompositing;
154 bool m_hasUnisolatedCompositedBlendingDescendant; 155 bool m_hasUnisolatedCompositedBlendingDescendant;
155 bool m_testingOverlap; 156 bool m_testingOverlap;
156 bool m_hasCompositedScrollingAncestor; 157 bool m_hasCompositedScrollingAncestor;
158 bool m_hasCompositedSkewedAncestor;
157 }; 159 };
158 160
159 static bool requiresCompositingOrSquashing(CompositingReasons reasons) { 161 static bool requiresCompositingOrSquashing(CompositingReasons reasons) {
160 #if DCHECK_IS_ON() 162 #if DCHECK_IS_ON()
161 bool fastAnswer = reasons != CompositingReasonNone; 163 bool fastAnswer = reasons != CompositingReasonNone;
162 bool slowAnswer = requiresCompositing(reasons) || requiresSquashing(reasons); 164 bool slowAnswer = requiresCompositing(reasons) || requiresSquashing(reasons);
163 DCHECK_EQ(slowAnswer, fastAnswer); 165 DCHECK_EQ(slowAnswer, fastAnswer);
164 #endif 166 #endif
165 return reasons != CompositingReasonNone; 167 return reasons != CompositingReasonNone;
166 } 168 }
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 } 512 }
511 513
512 if (willBeCompositedOrSquashed && 514 if (willBeCompositedOrSquashed &&
513 layer->layoutObject().style()->hasBlendMode()) 515 layer->layoutObject().style()->hasBlendMode())
514 currentRecursionData.m_hasUnisolatedCompositedBlendingDescendant = true; 516 currentRecursionData.m_hasUnisolatedCompositedBlendingDescendant = true;
515 517
516 // Tell the parent it has compositing descendants. 518 // Tell the parent it has compositing descendants.
517 if (willBeCompositedOrSquashed) 519 if (willBeCompositedOrSquashed)
518 currentRecursionData.m_subtreeIsCompositing = true; 520 currentRecursionData.m_subtreeIsCompositing = true;
519 521
522 // If an skewed element is composited due to its descendants, we have to
flackr 2017/02/28 21:40:14 We want the opposite behavior, the descendant shou
523 // update the uncomposited skewed descendants to composite them.
524 if (currentRecursionData.m_subtreeIsCompositing &&
525 layer->layoutObject().styleRef().hasTransform() &&
526 layer->layoutObject().styleRef().transform().hasSkew()) {
527 childRecursionData.m_hasCompositedSkewedAncestor = true;
528
529 PaintLayerStackingNodeIterator iterator(
530 *layer->stackingNode(), NormalFlowChildren | PositiveZOrderChildren);
531 while (PaintLayerStackingNode* curNode = iterator.next()) {
532 IntRect absoluteChildDescendantBoundingBox;
533 updateRecursive(layer, curNode->layer(), overlapMap, childRecursionData,
534 anyDescendantHas3DTransform, unclippedDescendants,
535 absoluteChildDescendantBoundingBox);
536 absoluteDescendantBoundingBox.unite(absoluteChildDescendantBoundingBox);
537 }
538 }
539
540 // Promote skewed elements within a promoted skewed element to improve
541 // output quality.
542 if (canBeComposited && !willBeCompositedOrSquashed &&
543 currentRecursionData.m_hasCompositedSkewedAncestor) {
544 if (layer->layoutObject().styleRef().hasTransform()) {
545 if (layer->layoutObject().styleRef().transform().hasSkew()) {
546 reasonsToComposite |=
547 CompositingReasonSkewWithCompositedSkewedAncestor;
548 }
549 }
550 }
551
520 // Turn overlap testing off for later layers if it's already off, or if we 552 // Turn overlap testing off for later layers if it's already off, or if we
521 // have an animating transform. Note that if the layer clips its 553 // have an animating transform. Note that if the layer clips its
522 // descendants, there's no reason to propagate the child animation to the 554 // descendants, there's no reason to propagate the child animation to the
523 // parent layers. That's because we know for sure the animation is contained 555 // parent layers. That's because we know for sure the animation is contained
524 // inside the clipping rectangle, which is already added to the overlap map. 556 // inside the clipping rectangle, which is already added to the overlap map.
525 bool isCompositedClippingLayer = 557 bool isCompositedClippingLayer =
526 canBeComposited && 558 canBeComposited &&
527 (reasonsToComposite & CompositingReasonClipsCompositingDescendants); 559 (reasonsToComposite & CompositingReasonClipsCompositingDescendants);
528 bool isCompositedWithInlineTransform = 560 bool isCompositedWithInlineTransform =
529 reasonsToComposite & CompositingReasonInlineTransform; 561 reasonsToComposite & CompositingReasonInlineTransform;
530 if ((!childRecursionData.m_testingOverlap && !isCompositedClippingLayer) || 562 if ((!childRecursionData.m_testingOverlap && !isCompositedClippingLayer) ||
531 layer->layoutObject().style()->hasCurrentTransformAnimation() || 563 layer->layoutObject().style()->hasCurrentTransformAnimation() ||
532 isCompositedWithInlineTransform) 564 isCompositedWithInlineTransform)
533 currentRecursionData.m_testingOverlap = false; 565 currentRecursionData.m_testingOverlap = false;
534 566
535 if (childRecursionData.m_compositingAncestor == layer) 567 if (childRecursionData.m_compositingAncestor == layer)
536 overlapMap.finishCurrentOverlapTestingContext(); 568 overlapMap.finishCurrentOverlapTestingContext();
537 569
538 descendantHas3DTransform |= 570 descendantHas3DTransform |=
539 anyDescendantHas3DTransform || layer->has3DTransform(); 571 anyDescendantHas3DTransform || layer->has3DTransform();
540 } 572 }
541 573
542 // At this point we have finished collecting all reasons to composite this 574 // At this point we have finished collecting all reasons to composite this
543 // layer. 575 // layer.
544 layer->setCompositingReasons(reasonsToComposite); 576 layer->setCompositingReasons(reasonsToComposite);
545 } 577 }
546 578
547 } // namespace blink 579 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698