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

Side by Side Diff: third_party/WebKit/Source/core/paint/BoxPainter.cpp

Issue 1527343002: Simplify paintFillLayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "core/paint/BoxPainter.h" 6 #include "core/paint/BoxPainter.h"
7 7
8 #include "core/HTMLNames.h" 8 #include "core/HTMLNames.h"
9 #include "core/frame/Settings.h" 9 #include "core/frame/Settings.h"
10 #include "core/html/HTMLFrameOwnerElement.h" 10 #include "core/html/HTMLFrameOwnerElement.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 150
151 bool BoxPainter::calculateFillLayerOcclusionCulling(FillLayerOcclusionOutputList &reversedPaintList, const FillLayer& fillLayer) 151 bool BoxPainter::calculateFillLayerOcclusionCulling(FillLayerOcclusionOutputList &reversedPaintList, const FillLayer& fillLayer)
152 { 152 {
153 bool isNonAssociative = false; 153 bool isNonAssociative = false;
154 for (auto currentLayer = &fillLayer; currentLayer; currentLayer = currentLay er->next()) { 154 for (auto currentLayer = &fillLayer; currentLayer; currentLayer = currentLay er->next()) {
155 reversedPaintList.append(currentLayer); 155 reversedPaintList.append(currentLayer);
156 // Stop traversal when an opaque layer is encountered. 156 // Stop traversal when an opaque layer is encountered.
157 // FIXME : It would be possible for the following occlusion culling test to be more aggressive 157 // FIXME : It would be possible for the following occlusion culling test to be more aggressive
158 // on layers with no repeat by testing whether the image covers the layo ut rect. 158 // on layers with no repeat by testing whether the image covers the layo ut rect.
159 // Testing that here would imply duplicating a lot of calculations that are currently done in 159 // Testing that here would imply duplicating a lot of calculations that are currently done in
160 // LayoutBoxModelObject::paintFillLayerExtended. A more efficient soluti on might be to move 160 // LayoutBoxModelObject::paintFillLayer. A more efficient solution might be to move the layer
161 // the layer recursion into paintFillLayerExtended, or to compute the la yer geometry here 161 // recursion into paintFillLayer, or to compute the layer geometry here and pass it down.
162 // and pass it down.
163 162
164 // TODO(trchen): Need to check compositing mode as well. 163 // TODO(trchen): Need to check compositing mode as well.
165 if (currentLayer->blendMode() != WebBlendModeNormal) 164 if (currentLayer->blendMode() != WebBlendModeNormal)
166 isNonAssociative = true; 165 isNonAssociative = true;
167 166
168 // TODO(trchen): A fill layer cannot paint if the calculated tile size i s empty. 167 // TODO(trchen): A fill layer cannot paint if the calculated tile size i s empty.
169 // This occlusion check can be wrong. 168 // This occlusion check can be wrong.
170 if (currentLayer->clipOccludesNextLayers() 169 if (currentLayer->clipOccludesNextLayers()
171 && isFillLayerOpaque(*currentLayer, m_layoutBox)) { 170 && isFillLayerOpaque(*currentLayer, m_layoutBox)) {
172 if (currentLayer->clip() == BorderFillBox) 171 if (currentLayer->clip() == BorderFillBox)
(...skipping 25 matching lines...) Expand all
198 197
199 // TODO(trchen): We can optimize out isolation group if we have a non-transp arent 198 // TODO(trchen): We can optimize out isolation group if we have a non-transp arent
200 // background color and the bottom layer encloses all other layers. 199 // background color and the bottom layer encloses all other layers.
201 200
202 GraphicsContext& context = paintInfo.context; 201 GraphicsContext& context = paintInfo.context;
203 202
204 if (shouldDrawBackgroundInSeparateBuffer) 203 if (shouldDrawBackgroundInSeparateBuffer)
205 context.beginLayer(); 204 context.beginLayer();
206 205
207 for (auto it = reversedPaintList.rbegin(); it != reversedPaintList.rend(); + +it) 206 for (auto it = reversedPaintList.rbegin(); it != reversedPaintList.rend(); + +it)
208 paintFillLayer(paintInfo, c, **it, rect, bleedAvoidance, op, backgroundO bject); 207 paintFillLayer(m_layoutBox, paintInfo, c, **it, rect, bleedAvoidance, 0, LayoutSize(), op, backgroundObject);
209 208
210 if (shouldDrawBackgroundInSeparateBuffer) 209 if (shouldDrawBackgroundInSeparateBuffer)
211 context.endLayer(); 210 context.endLayer();
212 } 211 }
213 212
214 void BoxPainter::paintFillLayer(const PaintInfo& paintInfo, const Color& c, cons t FillLayer& fillLayer, const LayoutRect& rect,
215 BackgroundBleedAvoidance bleedAvoidance, SkXfermode::Mode op, const LayoutOb ject* backgroundObject)
216 {
217 BoxPainter::paintFillLayerExtended(m_layoutBox, paintInfo, c, fillLayer, rec t, bleedAvoidance, 0, LayoutSize(), op, backgroundObject);
218 }
219
220 void BoxPainter::applyBoxShadowForBackground(GraphicsContext& context, const Lay outObject& obj) 213 void BoxPainter::applyBoxShadowForBackground(GraphicsContext& context, const Lay outObject& obj)
221 { 214 {
222 const ShadowList* shadowList = obj.style()->boxShadow(); 215 const ShadowList* shadowList = obj.style()->boxShadow();
223 ASSERT(shadowList); 216 ASSERT(shadowList);
224 for (size_t i = shadowList->shadows().size(); i--; ) { 217 for (size_t i = shadowList->shadows().size(); i--; ) {
225 const ShadowData& boxShadow = shadowList->shadows()[i]; 218 const ShadowData& boxShadow = shadowList->shadows()[i];
226 if (boxShadow.style() != Normal) 219 if (boxShadow.style() != Normal)
227 continue; 220 continue;
228 FloatSize shadowOffset(boxShadow.x(), boxShadow.y()); 221 FloatSize shadowOffset(boxShadow.x(), boxShadow.y());
229 context.setShadow(shadowOffset, boxShadow.blur(), 222 context.setShadow(shadowOffset, boxShadow.blur(),
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 FloatRect insetRect(backgroundRoundedRect.rect()); 272 FloatRect insetRect(backgroundRoundedRect.rect());
280 insetRect.expand(insets); 273 insetRect.expand(insets);
281 FloatRoundedRect::Radii insetRadii(backgroundRoundedRect.radii()); 274 FloatRoundedRect::Radii insetRadii(backgroundRoundedRect.radii());
282 insetRadii.shrink(-insets.top(), -insets.bottom(), -insets.left(), -inse ts.right()); 275 insetRadii.shrink(-insets.top(), -insets.bottom(), -insets.left(), -inse ts.right());
283 return FloatRoundedRect(insetRect, insetRadii); 276 return FloatRoundedRect(insetRect, insetRadii);
284 } 277 }
285 278
286 return getBackgroundRoundedRect(obj, borderRect, box, boxSize.width(), boxSi ze.height(), includeLogicalLeftEdge, includeLogicalRightEdge); 279 return getBackgroundRoundedRect(obj, borderRect, box, boxSize.width(), boxSi ze.height(), includeLogicalLeftEdge, includeLogicalRightEdge);
287 } 280 }
288 281
289 void BoxPainter::paintFillLayerExtended(const LayoutBoxModelObject& obj, const P aintInfo& paintInfo, const Color& color, const FillLayer& bgLayer, const LayoutR ect& rect, BackgroundBleedAvoidance bleedAvoidance, const InlineFlowBox* box, co nst LayoutSize& boxSize, SkXfermode::Mode op, const LayoutObject* backgroundObje ct) 282 void BoxPainter::paintFillLayer(const LayoutBoxModelObject& obj, const PaintInfo & paintInfo, const Color& color, const FillLayer& bgLayer, const LayoutRect& rec t, BackgroundBleedAvoidance bleedAvoidance, const InlineFlowBox* box, const Layo utSize& boxSize, SkXfermode::Mode op, const LayoutObject* backgroundObject)
290 { 283 {
291 GraphicsContext& context = paintInfo.context; 284 GraphicsContext& context = paintInfo.context;
292 if (rect.isEmpty()) 285 if (rect.isEmpty())
293 return; 286 return;
294 287
295 bool includeLeftEdge = box ? box->includeLogicalLeftEdge() : true; 288 bool includeLeftEdge = box ? box->includeLogicalLeftEdge() : true;
296 bool includeRightEdge = box ? box->includeLogicalRightEdge() : true; 289 bool includeRightEdge = box ? box->includeLogicalRightEdge() : true;
297 290
298 bool hasRoundedBorder = obj.style()->hasBorderRadius() && (includeLeftEdge | | includeRightEdge); 291 bool hasRoundedBorder = obj.style()->hasBorderRadius() && (includeLeftEdge | | includeRightEdge);
299 bool clippedWithLocalScrolling = obj.hasOverflowClip() && bgLayer.attachment () == LocalBackgroundAttachment; 292 bool clippedWithLocalScrolling = obj.hasOverflowClip() && bgLayer.attachment () == LocalBackgroundAttachment;
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 } 696 }
704 } 697 }
705 698
706 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle& style, const Document& document) 699 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle& style, const Document& document)
707 { 700 {
708 return document.printing() && style.printColorAdjust() == PrintColorAdjustEc onomy 701 return document.printing() && style.printColorAdjust() == PrintColorAdjustEc onomy
709 && (!document.settings() || !document.settings()->shouldPrintBackgrounds ()); 702 && (!document.settings() || !document.settings()->shouldPrintBackgrounds ());
710 } 703 }
711 704
712 } // namespace blink 705 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/BoxPainter.h ('k') | third_party/WebKit/Source/core/paint/InlineFlowBoxPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698