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

Side by Side Diff: sky/engine/core/rendering/RenderBox.cpp

Issue 840403003: First pass at deleting paint invalidation code. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « sky/engine/core/rendering/RenderBox.h ('k') | sky/engine/core/rendering/RenderFlexibleBox.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 if (isRootObject || isViewObject) 140 if (isRootObject || isViewObject)
141 setHasBoxDecorationBackground(true); 141 setHasBoxDecorationBackground(true);
142 142
143 bool boxHasOverflowClip = false; 143 bool boxHasOverflowClip = false;
144 if (!styleToUse->isOverflowVisible() && isRenderBlock() && !isViewObject) { 144 if (!styleToUse->isOverflowVisible() && isRenderBlock() && !isViewObject) {
145 // If overflow has been propagated to the viewport, it has no effect her e. 145 // If overflow has been propagated to the viewport, it has no effect her e.
146 if (node() != document().viewportDefiningElement()) 146 if (node() != document().viewportDefiningElement())
147 boxHasOverflowClip = true; 147 boxHasOverflowClip = true;
148 } 148 }
149 149
150 if (boxHasOverflowClip != hasOverflowClip()) {
151 // FIXME: This shouldn't be required if we tracked the visual overflow
152 // generated by positioned children or self painting layers. crbug.com/3 45403
153 for (RenderObject* child = slowFirstChild(); child; child = child->nextS ibling())
154 child->setShouldDoFullPaintInvalidationIfSelfPaintingLayer(true);
155 }
156
157 setHasOverflowClip(boxHasOverflowClip); 150 setHasOverflowClip(boxHasOverflowClip);
158 setHasTransform(styleToUse->hasTransformRelatedProperty()); 151 setHasTransform(styleToUse->hasTransformRelatedProperty());
159 } 152 }
160 153
161 void RenderBox::layout() 154 void RenderBox::layout()
162 { 155 {
163 ASSERT(needsLayout()); 156 ASSERT(needsLayout());
164 157
165 RenderObject* child = slowFirstChild(); 158 RenderObject* child = slowFirstChild();
166 if (!child) { 159 if (!child) {
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 981
989 for (const FillLayer* curLayer = &layers; curLayer; curLayer = curLayer->nex t()) { 982 for (const FillLayer* curLayer = &layers; curLayer; curLayer = curLayer->nex t()) {
990 if (curLayer->image() && image == curLayer->image()->data() && curLayer- >image()->canRender(*this)) { 983 if (curLayer->image() && image == curLayer->image()->data() && curLayer- >image()->canRender(*this)) {
991 layerRenderer->setShouldDoFullPaintInvalidation(true); 984 layerRenderer->setShouldDoFullPaintInvalidation(true);
992 return true; 985 return true;
993 } 986 }
994 } 987 }
995 return false; 988 return false;
996 } 989 }
997 990
998 InvalidationReason RenderBox::invalidatePaintIfNeeded(const PaintInvalidationSta te& paintInvalidationState, const RenderLayerModelObject& newPaintInvalidationCo ntainer)
999 {
1000 const LayoutRect oldPaintInvalidationRect = previousPaintInvalidationRect();
1001 const LayoutPoint oldPositionFromPaintInvalidationContainer = previousPositi onFromPaintInvalidationContainer();
1002 setPreviousPaintInvalidationRect(boundsRectForPaintInvalidation(&newPaintInv alidationContainer, &paintInvalidationState));
1003 setPreviousPositionFromPaintInvalidationContainer(RenderLayer::positionFromP aintInvalidationContainer(this, &newPaintInvalidationContainer, &paintInvalidati onState));
1004
1005 InvalidationReason reason = InvalidationNone;
1006
1007 // If we are set to do a full paint invalidation that means the RenderView w ill be
1008 // issue paint invalidations. We can then skip issuing of paint invalidation s for the child
1009 // renderers as they'll be covered by the RenderView.
1010 if (!view()->doingFullPaintInvalidation()) {
1011 if (onlyNeededPositionedMovementLayout()
1012 || (shouldDoFullPaintInvalidationIfSelfPaintingLayer()
1013 && hasLayer()
1014 && layer()->isSelfPaintingLayer())) {
1015 setShouldDoFullPaintInvalidation(true, MarkOnlyThis);
1016 }
1017
1018 reason = RenderObject::invalidatePaintIfNeeded(newPaintInvalidationConta iner, oldPaintInvalidationRect, oldPositionFromPaintInvalidationContainer, paint InvalidationState);
1019 if (reason == InvalidationNone || reason == InvalidationIncremental)
1020 invalidatePaintForOverflowIfNeeded();
1021
1022 // Issue paint invalidations for any scrollbars if there is a scrollable area for this renderer.
1023 if (ScrollableArea* area = scrollableArea()) {
1024 if (area->hasVerticalBarDamage())
1025 invalidatePaintRectangle(area->verticalBarDamage());
1026 if (area->hasHorizontalBarDamage())
1027 invalidatePaintRectangle(area->horizontalBarDamage());
1028 }
1029 }
1030
1031 // This is for the next invalidatePaintIfNeeded so must be at the end.
1032 savePreviousBorderBoxSizeIfNeeded();
1033 return reason;
1034 }
1035
1036 void RenderBox::clearPaintInvalidationState(const PaintInvalidationState& paintI nvalidationState) 991 void RenderBox::clearPaintInvalidationState(const PaintInvalidationState& paintI nvalidationState)
1037 { 992 {
1038 RenderBoxModelObject::clearPaintInvalidationState(paintInvalidationState); 993 RenderBoxModelObject::clearPaintInvalidationState(paintInvalidationState);
1039 994
1040 if (ScrollableArea* area = scrollableArea()) 995 if (ScrollableArea* area = scrollableArea())
1041 area->resetScrollbarDamage(); 996 area->resetScrollbarDamage();
1042 } 997 }
1043 998
1044 #if ENABLE(ASSERT) 999 #if ENABLE(ASSERT)
1045 bool RenderBox::paintInvalidationStateIsDirty() const 1000 bool RenderBox::paintInvalidationStateIsDirty() const
(...skipping 2025 matching lines...) Expand 10 before | Expand all | Expand 10 after
3071 } 3026 }
3072 3027
3073 if (oldBorderBoxSize.width() != newBorderBoxSize.width() && mustInvalidateBa ckgroundOrBorderPaintOnWidthChange()) 3028 if (oldBorderBoxSize.width() != newBorderBoxSize.width() && mustInvalidateBa ckgroundOrBorderPaintOnWidthChange())
3074 return InvalidationBorderBoxChange; 3029 return InvalidationBorderBoxChange;
3075 if (oldBorderBoxSize.height() != newBorderBoxSize.height() && mustInvalidate BackgroundOrBorderPaintOnHeightChange()) 3030 if (oldBorderBoxSize.height() != newBorderBoxSize.height() && mustInvalidate BackgroundOrBorderPaintOnHeightChange())
3076 return InvalidationBorderBoxChange; 3031 return InvalidationBorderBoxChange;
3077 3032
3078 return InvalidationIncremental; 3033 return InvalidationIncremental;
3079 } 3034 }
3080 3035
3081 void RenderBox::incrementallyInvalidatePaint(const RenderLayerModelObject& paint InvalidationContainer, const LayoutRect& oldBounds, const LayoutRect& newBounds, const LayoutPoint& positionFromPaintInvalidationContainer)
3082 {
3083 RenderObject::incrementallyInvalidatePaint(paintInvalidationContainer, oldBo unds, newBounds, positionFromPaintInvalidationContainer);
3084
3085 bool hasBoxDecorations = style()->hasBoxDecorations();
3086 if (!style()->hasBackground() && !hasBoxDecorations)
3087 return;
3088
3089 LayoutSize oldBorderBoxSize = computePreviousBorderBoxSize(oldBounds.size()) ;
3090 LayoutSize newBorderBoxSize = size();
3091
3092 // If border box size didn't change, RenderBox's incrementallyInvalidatePain t() is good.
3093 if (oldBorderBoxSize == newBorderBoxSize)
3094 return;
3095
3096 // If size of the paint invalidation rect equals to size of border box, Rend erObject::incrementallyInvalidatePaint()
3097 // is good for boxes having background without box decorations.
3098 ASSERT(oldBounds.location() == newBounds.location()); // Otherwise we won't do incremental invalidation.
3099 if (!hasBoxDecorations
3100 && positionFromPaintInvalidationContainer == newBounds.location()
3101 && oldBorderBoxSize == oldBounds.size()
3102 && newBorderBoxSize == newBounds.size())
3103 return;
3104
3105 // Invalidate the right delta part and the right border of the old or new bo x which has smaller width.
3106 LayoutUnit deltaWidth = absoluteValue(oldBorderBoxSize.width() - newBorderBo xSize.width());
3107 if (deltaWidth) {
3108 LayoutUnit smallerWidth = std::min(oldBorderBoxSize.width(), newBorderBo xSize.width());
3109 LayoutUnit borderTopRightRadiusWidth = valueForLength(style()->borderTop RightRadius().width(), smallerWidth);
3110 LayoutUnit borderBottomRightRadiusWidth = valueForLength(style()->border BottomRightRadius().width(), smallerWidth);
3111 LayoutUnit borderWidth = std::max<LayoutUnit>(borderRight(), std::max(bo rderTopRightRadiusWidth, borderBottomRightRadiusWidth));
3112 LayoutRect rightDeltaRect(positionFromPaintInvalidationContainer.x() + s mallerWidth - borderWidth,
3113 positionFromPaintInvalidationContainer.y(),
3114 deltaWidth + borderWidth,
3115 std::max(oldBorderBoxSize.height(), newBorderBoxSize.height()));
3116 invalidatePaintUsingContainer(&paintInvalidationContainer, rightDeltaRec t, InvalidationIncremental);
3117 }
3118
3119 // Invalidate the bottom delta part and the bottom border of the old or new box which has smaller height.
3120 LayoutUnit deltaHeight = absoluteValue(oldBorderBoxSize.height() - newBorder BoxSize.height());
3121 if (deltaHeight) {
3122 LayoutUnit smallerHeight = std::min(oldBorderBoxSize.height(), newBorder BoxSize.height());
3123 LayoutUnit borderBottomLeftRadiusHeight = valueForLength(style()->border BottomLeftRadius().height(), smallerHeight);
3124 LayoutUnit borderBottomRightRadiusHeight = valueForLength(style()->borde rBottomRightRadius().height(), smallerHeight);
3125 LayoutUnit borderHeight = std::max<LayoutUnit>(borderBottom(), std::max( borderBottomLeftRadiusHeight, borderBottomRightRadiusHeight));
3126 LayoutRect bottomDeltaRect(positionFromPaintInvalidationContainer.x(),
3127 positionFromPaintInvalidationContainer.y() + smallerHeight - borderH eight,
3128 std::max(oldBorderBoxSize.width(), newBorderBoxSize.width()),
3129 deltaHeight + borderHeight);
3130 invalidatePaintUsingContainer(&paintInvalidationContainer, bottomDeltaRe ct, InvalidationIncremental);
3131 }
3132 }
3133
3134 void RenderBox::addVisualEffectOverflow() 3036 void RenderBox::addVisualEffectOverflow()
3135 { 3037 {
3136 if (!style()->hasVisualOverflowingEffect()) 3038 if (!style()->hasVisualOverflowingEffect())
3137 return; 3039 return;
3138 3040
3139 // Add in the final overflow with shadows, outsets and outline combined. 3041 // Add in the final overflow with shadows, outsets and outline combined.
3140 LayoutRect visualEffectOverflow = borderBoxRect(); 3042 LayoutRect visualEffectOverflow = borderBoxRect();
3141 visualEffectOverflow.expand(computeVisualEffectOverflowExtent()); 3043 visualEffectOverflow.expand(computeVisualEffectOverflowExtent());
3142 addVisualOverflow(visualEffectOverflow); 3044 addVisualOverflow(visualEffectOverflow);
3143 } 3045 }
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
3436 3338
3437 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) 3339 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style)
3438 { 3340 {
3439 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor); 3341 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor);
3440 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); 3342 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage();
3441 ASSERT(hasBackground == style.hasBackground()); 3343 ASSERT(hasBackground == style.hasBackground());
3442 hasBorder = style.hasBorder(); 3344 hasBorder = style.hasBorder();
3443 } 3345 }
3444 3346
3445 } // namespace blink 3347 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderBox.h ('k') | sky/engine/core/rendering/RenderFlexibleBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698