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

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

Issue 1787733003: Consolidate background fill layer opaqueness into one method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix windows build Created 4 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 // 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 "core/paint/BoxPainter.h" 5 #include "core/paint/BoxPainter.h"
6 6
7 #include "core/HTMLNames.h" 7 #include "core/HTMLNames.h"
8 #include "core/frame/Settings.h" 8 #include "core/frame/Settings.h"
9 #include "core/html/HTMLFrameOwnerElement.h" 9 #include "core/html/HTMLFrameOwnerElement.h"
10 #include "core/layout/ImageQualityController.h" 10 #include "core/layout/ImageQualityController.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 { 127 {
128 if (m_layoutBox.isDocumentElement()) 128 if (m_layoutBox.isDocumentElement())
129 return; 129 return;
130 if (m_layoutBox.backgroundStolenForBeingBody()) 130 if (m_layoutBox.backgroundStolenForBeingBody())
131 return; 131 return;
132 if (m_layoutBox.boxDecorationBackgroundIsKnownToBeObscured()) 132 if (m_layoutBox.boxDecorationBackgroundIsKnownToBeObscured())
133 return; 133 return;
134 paintFillLayers(paintInfo, backgroundColor, m_layoutBox.style()->backgroundL ayers(), paintRect, bleedAvoidance); 134 paintFillLayers(paintInfo, backgroundColor, m_layoutBox.style()->backgroundL ayers(), paintRect, bleedAvoidance);
135 } 135 }
136 136
137 bool BoxPainter::isFillLayerOpaque(const FillLayer& layer, const LayoutObject& i mageClient)
138 {
139 // The default object size passed down to imageSize is empty with the implic ation that images
140 // with no intrinsic size are treated as empty.
141 return layer.hasOpaqueImage(&imageClient)
142 && layer.image()->canRender()
143 && !layer.image()->imageSize(imageClient, imageClient.style()->effective Zoom(), LayoutSize()).isEmpty()
144 && layer.hasRepeatXY();
145 }
146
147 bool BoxPainter::calculateFillLayerOcclusionCulling(FillLayerOcclusionOutputList &reversedPaintList, const FillLayer& fillLayer) 137 bool BoxPainter::calculateFillLayerOcclusionCulling(FillLayerOcclusionOutputList &reversedPaintList, const FillLayer& fillLayer)
148 { 138 {
149 bool isNonAssociative = false; 139 bool isNonAssociative = false;
150 for (auto currentLayer = &fillLayer; currentLayer; currentLayer = currentLay er->next()) { 140 for (auto currentLayer = &fillLayer; currentLayer; currentLayer = currentLay er->next()) {
151 reversedPaintList.append(currentLayer); 141 reversedPaintList.append(currentLayer);
152 // Stop traversal when an opaque layer is encountered. 142 // Stop traversal when an opaque layer is encountered.
153 // FIXME : It would be possible for the following occlusion culling test to be more aggressive 143 // FIXME : It would be possible for the following occlusion culling test to be more aggressive
154 // on layers with no repeat by testing whether the image covers the layo ut rect. 144 // on layers with no repeat by testing whether the image covers the layo ut rect.
155 // Testing that here would imply duplicating a lot of calculations that are currently done in 145 // Testing that here would imply duplicating a lot of calculations that are currently done in
156 // LayoutBoxModelObject::paintFillLayer. A more efficient solution might be to move the layer 146 // LayoutBoxModelObject::paintFillLayer. A more efficient solution might be to move the layer
157 // recursion into paintFillLayer, or to compute the layer geometry here and pass it down. 147 // recursion into paintFillLayer, or to compute the layer geometry here and pass it down.
158 148
159 // TODO(trchen): Need to check compositing mode as well. 149 // TODO(trchen): Need to check compositing mode as well.
160 if (currentLayer->blendMode() != WebBlendModeNormal) 150 if (currentLayer->blendMode() != WebBlendModeNormal)
161 isNonAssociative = true; 151 isNonAssociative = true;
162 152
163 // TODO(trchen): A fill layer cannot paint if the calculated tile size i s empty. 153 // TODO(trchen): A fill layer cannot paint if the calculated tile size i s empty.
164 // This occlusion check can be wrong. 154 // This occlusion check can be wrong.
165 if (currentLayer->clipOccludesNextLayers() 155 if (currentLayer->clipOccludesNextLayers()
166 && isFillLayerOpaque(*currentLayer, m_layoutBox)) { 156 && currentLayer->imageOccludesNextLayers(m_layoutBox)) {
167 if (currentLayer->clip() == BorderFillBox) 157 if (currentLayer->clip() == BorderFillBox)
168 isNonAssociative = false; 158 isNonAssociative = false;
169 break; 159 break;
170 } 160 }
171 } 161 }
172 return isNonAssociative; 162 return isNonAssociative;
173 } 163 }
174 164
175 void BoxPainter::paintFillLayers(const PaintInfo& paintInfo, const Color& c, con st FillLayer& fillLayer, const LayoutRect& rect, BackgroundBleedAvoidance bleedA voidance, SkXfermode::Mode op, const LayoutObject* backgroundObject) 165 void BoxPainter::paintFillLayers(const PaintInfo& paintInfo, const Color& c, con st FillLayer& fillLayer, const LayoutRect& rect, BackgroundBleedAvoidance bleedA voidance, SkXfermode::Mode op, const LayoutObject* backgroundObject)
176 { 166 {
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 if (bgImage) 416 if (bgImage)
427 geometry.calculate(obj, paintInfo.paintContainer(), paintInfo.getGlobalP aintFlags(), bgLayer, scrolledPaintRect); 417 geometry.calculate(obj, paintInfo.paintContainer(), paintInfo.getGlobalP aintFlags(), bgLayer, scrolledPaintRect);
428 bool shouldPaintBackgroundImage = bgImage && bgImage->canRender(); 418 bool shouldPaintBackgroundImage = bgImage && bgImage->canRender();
429 419
430 // Paint the color first underneath all images, culled if background image o ccludes it. 420 // Paint the color first underneath all images, culled if background image o ccludes it.
431 // TODO(trchen): In the !bgLayer.hasRepeatXY() case, we could improve the cu lling test 421 // TODO(trchen): In the !bgLayer.hasRepeatXY() case, we could improve the cu lling test
432 // by verifying whether the background image covers the entire painting area . 422 // by verifying whether the background image covers the entire painting area .
433 if (isBottomLayer) { 423 if (isBottomLayer) {
434 IntRect backgroundRect(pixelSnappedIntRect(scrolledPaintRect)); 424 IntRect backgroundRect(pixelSnappedIntRect(scrolledPaintRect));
435 bool boxShadowShouldBeAppliedToBackground = obj.boxShadowShouldBeApplied ToBackground(bleedAvoidance, box); 425 bool boxShadowShouldBeAppliedToBackground = obj.boxShadowShouldBeApplied ToBackground(bleedAvoidance, box);
436 bool backgroundImageOccludesBackgroundColor = shouldPaintBackgroundImage && isFillLayerOpaque(bgLayer, obj); 426 bool backgroundImageOccludesBackgroundColor = shouldPaintBackgroundImage && bgLayer.imageOccludesNextLayers(obj);
437 if (boxShadowShouldBeAppliedToBackground || !backgroundImageOccludesBack groundColor) { 427 if (boxShadowShouldBeAppliedToBackground || !backgroundImageOccludesBack groundColor) {
438 GraphicsContextStateSaver shadowStateSaver(context, boxShadowShouldB eAppliedToBackground); 428 GraphicsContextStateSaver shadowStateSaver(context, boxShadowShouldB eAppliedToBackground);
439 if (boxShadowShouldBeAppliedToBackground) 429 if (boxShadowShouldBeAppliedToBackground)
440 BoxPainter::applyBoxShadowForBackground(context, obj); 430 BoxPainter::applyBoxShadowForBackground(context, obj);
441 431
442 if (bgColor.alpha()) 432 if (bgColor.alpha())
443 context.fillRect(backgroundRect, bgColor); 433 context.fillRect(backgroundRect, bgColor);
444 } 434 }
445 } 435 }
446 436
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 } 682 }
693 } 683 }
694 684
695 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle& style, const Document& document) 685 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle& style, const Document& document)
696 { 686 {
697 return document.printing() && style.getPrintColorAdjust() == PrintColorAdjus tEconomy 687 return document.printing() && style.getPrintColorAdjust() == PrintColorAdjus tEconomy
698 && (!document.settings() || !document.settings()->shouldPrintBackgrounds ()); 688 && (!document.settings() || !document.settings()->shouldPrintBackgrounds ());
699 } 689 }
700 690
701 } // namespace blink 691 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/BoxDecorationData.cpp ('k') | third_party/WebKit/Source/core/style/FillLayer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698