OLD | NEW |
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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 } | 430 } |
431 case BorderFillBox: | 431 case BorderFillBox: |
432 break; | 432 break; |
433 default: | 433 default: |
434 ASSERT_NOT_REACHED(); | 434 ASSERT_NOT_REACHED(); |
435 break; | 435 break; |
436 } | 436 } |
437 | 437 |
438 BackgroundImageGeometry geometry; | 438 BackgroundImageGeometry geometry; |
439 if (bgImage) | 439 if (bgImage) |
440 geometry.calculate(obj, paintInfo.paintContainer(), paintInfo.globalPain
tFlags(), bgLayer, scrolledPaintRect, backgroundObject); | 440 geometry.calculate(obj, paintInfo.paintContainer(), paintInfo.globalPain
tFlags(), bgLayer, scrolledPaintRect); |
441 bool shouldPaintBackgroundImage = bgImage && bgImage->canRender(obj, obj.sty
le()->effectiveZoom()); | 441 bool shouldPaintBackgroundImage = bgImage && bgImage->canRender(obj, obj.sty
le()->effectiveZoom()); |
442 | 442 |
443 // Paint the color first underneath all images, culled if background image o
ccludes it. | 443 // Paint the color first underneath all images, culled if background image o
ccludes it. |
444 // TODO(trchen): In the !bgLayer.hasRepeatXY() case, we could improve the cu
lling test | 444 // TODO(trchen): In the !bgLayer.hasRepeatXY() case, we could improve the cu
lling test |
445 // by verifying whether the background image covers the entire painting area
. | 445 // by verifying whether the background image covers the entire painting area
. |
446 if (isBottomLayer) { | 446 if (isBottomLayer) { |
447 IntRect backgroundRect(pixelSnappedIntRect(scrolledPaintRect)); | 447 IntRect backgroundRect(pixelSnappedIntRect(scrolledPaintRect)); |
448 bool boxShadowShouldBeAppliedToBackground = obj.boxShadowShouldBeApplied
ToBackground(bleedAvoidance, box); | 448 bool boxShadowShouldBeAppliedToBackground = obj.boxShadowShouldBeApplied
ToBackground(bleedAvoidance, box); |
449 bool backgroundImageOccludesBackgroundColor = shouldPaintBackgroundImage
&& isFillLayerOpaque(bgLayer, obj); | 449 bool backgroundImageOccludesBackgroundColor = shouldPaintBackgroundImage
&& isFillLayerOpaque(bgLayer, obj); |
450 if (boxShadowShouldBeAppliedToBackground || !backgroundImageOccludesBack
groundColor) { | 450 if (boxShadowShouldBeAppliedToBackground || !backgroundImageOccludesBack
groundColor) { |
451 GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShould
BeAppliedToBackground); | 451 GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShould
BeAppliedToBackground); |
452 if (boxShadowShouldBeAppliedToBackground) | 452 if (boxShadowShouldBeAppliedToBackground) |
453 BoxPainter::applyBoxShadowForBackground(context, obj); | 453 BoxPainter::applyBoxShadowForBackground(context, obj); |
454 | 454 |
455 if (bgColor.alpha()) | 455 if (bgColor.alpha()) |
456 context->fillRect(backgroundRect, bgColor); | 456 context->fillRect(backgroundRect, bgColor); |
457 } | 457 } |
458 } | 458 } |
459 | 459 |
460 // no progressive loading of the background image | 460 // no progressive loading of the background image |
461 if (shouldPaintBackgroundImage) { | 461 if (shouldPaintBackgroundImage) { |
462 if (!geometry.destRect().isEmpty()) { | 462 if (!geometry.destRect().isEmpty()) { |
463 SkXfermode::Mode bgOp = WebCoreCompositeToSkiaComposite(bgLayer.comp
osite(), bgLayer.blendMode()); | 463 SkXfermode::Mode bgOp = WebCoreCompositeToSkiaComposite(bgLayer.comp
osite(), bgLayer.blendMode()); |
464 // if op != SkXfermode::kSrcOver_Mode, a mask is being painted. | 464 // if op != SkXfermode::kSrcOver_Mode, a mask is being painted. |
465 SkXfermode::Mode compositeOp = op == SkXfermode::kSrcOver_Mode ? bgO
p : op; | 465 SkXfermode::Mode compositeOp = op == SkXfermode::kSrcOver_Mode ? bgO
p : op; |
466 const LayoutObject* clientForBackgroundImage = backgroundObject ? ba
ckgroundObject : &obj; | 466 const LayoutObject* clientForBackgroundImage = backgroundObject ? ba
ckgroundObject : &obj; |
467 RefPtr<Image> image = bgImage->image(clientForBackgroundImage, geome
try.tileSize()); | 467 RefPtr<Image> image = bgImage->image(clientForBackgroundImage, geome
try.imageContainerSize(), obj.style()->effectiveZoom()); |
468 InterpolationQuality interpolationQuality = chooseInterpolationQuali
ty(*clientForBackgroundImage, context, image.get(), &bgLayer, LayoutSize(geometr
y.tileSize())); | 468 InterpolationQuality interpolationQuality = chooseInterpolationQuali
ty(*clientForBackgroundImage, context, image.get(), &bgLayer, LayoutSize(geometr
y.tileSize())); |
469 if (bgLayer.maskSourceType() == MaskLuminance) | 469 if (bgLayer.maskSourceType() == MaskLuminance) |
470 context->setColorFilter(ColorFilterLuminanceToAlpha); | 470 context->setColorFilter(ColorFilterLuminanceToAlpha); |
471 InterpolationQuality previousInterpolationQuality = context->imageIn
terpolationQuality(); | 471 InterpolationQuality previousInterpolationQuality = context->imageIn
terpolationQuality(); |
472 context->setImageInterpolationQuality(interpolationQuality); | 472 context->setImageInterpolationQuality(interpolationQuality); |
473 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintI
mage", "data", InspectorPaintImageEvent::data(obj, *bgImage)); | 473 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintI
mage", "data", InspectorPaintImageEvent::data(obj, *bgImage)); |
474 context->drawTiledImage(image.get(), geometry.destRect(), geometry.p
hase(), geometry.tileSize(), | 474 context->drawTiledImage(image.get(), geometry.destRect(), geometry.p
hase(), geometry.tileSize(), |
475 compositeOp, geometry.spaceSize()); | 475 compositeOp, geometry.spaceSize()); |
476 context->setImageInterpolationQuality(previousInterpolationQuality); | 476 context->setImageInterpolationQuality(previousInterpolationQuality); |
477 } | 477 } |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 } | 705 } |
706 } | 706 } |
707 | 707 |
708 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle&
style, const Document& document) | 708 bool BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(const ComputedStyle&
style, const Document& document) |
709 { | 709 { |
710 return document.printing() && style.printColorAdjust() == PrintColorAdjustEc
onomy | 710 return document.printing() && style.printColorAdjust() == PrintColorAdjustEc
onomy |
711 && (!document.settings() || !document.settings()->shouldPrintBackgrounds
()); | 711 && (!document.settings() || !document.settings()->shouldPrintBackgrounds
()); |
712 } | 712 } |
713 | 713 |
714 } // namespace blink | 714 } // namespace blink |
OLD | NEW |