| 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" |
| 11 #include "core/paint/BackgroundImageGeometry.h" | 11 #include "core/paint/BackgroundImageGeometry.h" |
| 12 #include "core/paint/BoxDecorationData.h" | 12 #include "core/paint/BoxDecorationData.h" |
| 13 #include "core/paint/DrawingRecorder.h" | 13 #include "core/paint/DrawingRecorder.h" |
| 14 #include "core/paint/TransparencyDisplayItem.h" | |
| 15 #include "core/rendering/ImageQualityController.h" | 14 #include "core/rendering/ImageQualityController.h" |
| 16 #include "core/rendering/PaintInfo.h" | 15 #include "core/rendering/PaintInfo.h" |
| 17 #include "core/rendering/RenderBox.h" | 16 #include "core/rendering/RenderBox.h" |
| 18 #include "core/rendering/RenderBoxModelObject.h" | 17 #include "core/rendering/RenderBoxModelObject.h" |
| 19 #include "core/rendering/RenderLayer.h" | 18 #include "core/rendering/RenderLayer.h" |
| 20 #include "core/rendering/RenderObject.h" | 19 #include "core/rendering/RenderObject.h" |
| 21 #include "core/rendering/RenderTable.h" | 20 #include "core/rendering/RenderTable.h" |
| 22 #include "core/rendering/RenderTheme.h" | 21 #include "core/rendering/RenderTheme.h" |
| 23 #include "core/rendering/RenderView.h" | 22 #include "core/rendering/RenderView.h" |
| 24 #include "core/rendering/compositing/CompositedLayerMapping.h" | 23 #include "core/rendering/compositing/CompositedLayerMapping.h" |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 if (!paintInfo.shouldPaintWithinRoot(&m_renderBox) || m_renderBox.style()->v
isibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) | 508 if (!paintInfo.shouldPaintWithinRoot(&m_renderBox) || m_renderBox.style()->v
isibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) |
| 510 return; | 509 return; |
| 511 | 510 |
| 512 LayoutRect paintRect = LayoutRect(paintOffset, m_renderBox.size()); | 511 LayoutRect paintRect = LayoutRect(paintOffset, m_renderBox.size()); |
| 513 paintMaskImages(paintInfo, paintRect); | 512 paintMaskImages(paintInfo, paintRect); |
| 514 } | 513 } |
| 515 | 514 |
| 516 void BoxPainter::paintMaskImages(const PaintInfo& paintInfo, const LayoutRect& p
aintRect) | 515 void BoxPainter::paintMaskImages(const PaintInfo& paintInfo, const LayoutRect& p
aintRect) |
| 517 { | 516 { |
| 518 // Figure out if we need to push a transparency layer to render our mask. | 517 // Figure out if we need to push a transparency layer to render our mask. |
| 519 OwnPtr<TransparencyRecorder> transparencyRecorder; | 518 bool pushTransparencyLayer = false; |
| 520 bool compositedMask = m_renderBox.hasLayer() && m_renderBox.layer()->hasComp
ositedMask(); | 519 bool compositedMask = m_renderBox.hasLayer() && m_renderBox.layer()->hasComp
ositedMask(); |
| 521 bool flattenCompositingLayers = m_renderBox.view()->frameView() && m_renderB
ox.view()->frameView()->paintBehavior() & PaintBehaviorFlattenCompositingLayers; | 520 bool flattenCompositingLayers = m_renderBox.view()->frameView() && m_renderB
ox.view()->frameView()->paintBehavior() & PaintBehaviorFlattenCompositingLayers; |
| 522 CompositeOperator compositeOp = CompositeSourceOver; | 521 CompositeOperator compositeOp = CompositeSourceOver; |
| 523 | 522 |
| 524 bool allMaskImagesLoaded = true; | 523 bool allMaskImagesLoaded = true; |
| 525 | 524 |
| 526 if (!compositedMask || flattenCompositingLayers) { | 525 if (!compositedMask || flattenCompositingLayers) { |
| 526 pushTransparencyLayer = true; |
| 527 StyleImage* maskBoxImage = m_renderBox.style()->maskBoxImage().image(); | 527 StyleImage* maskBoxImage = m_renderBox.style()->maskBoxImage().image(); |
| 528 const FillLayer& maskLayers = m_renderBox.style()->maskLayers(); | 528 const FillLayer& maskLayers = m_renderBox.style()->maskLayers(); |
| 529 | 529 |
| 530 // Don't render a masked element until all the mask images have loaded,
to prevent a flash of unmasked content. | 530 // Don't render a masked element until all the mask images have loaded,
to prevent a flash of unmasked content. |
| 531 if (maskBoxImage) | 531 if (maskBoxImage) |
| 532 allMaskImagesLoaded &= maskBoxImage->isLoaded(); | 532 allMaskImagesLoaded &= maskBoxImage->isLoaded(); |
| 533 | 533 |
| 534 allMaskImagesLoaded &= maskLayers.imagesAreLoaded(); | 534 allMaskImagesLoaded &= maskLayers.imagesAreLoaded(); |
| 535 | 535 |
| 536 paintInfo.context->setCompositeOperation(CompositeDestinationIn); | 536 paintInfo.context->setCompositeOperation(CompositeDestinationIn); |
| 537 | 537 paintInfo.context->beginTransparencyLayer(1); |
| 538 transparencyRecorder = adoptPtr(new TransparencyRecorder(paintInfo.conte
xt, &m_renderBox, DisplayItem::BeginTransparency, WebBlendModeNormal, 1)); | |
| 539 | |
| 540 compositeOp = CompositeSourceOver; | 538 compositeOp = CompositeSourceOver; |
| 541 } | 539 } |
| 542 | 540 |
| 543 if (allMaskImagesLoaded) { | 541 if (allMaskImagesLoaded) { |
| 544 paintFillLayers(paintInfo, Color::transparent, m_renderBox.style()->mask
Layers(), paintRect, BackgroundBleedNone, compositeOp); | 542 paintFillLayers(paintInfo, Color::transparent, m_renderBox.style()->mask
Layers(), paintRect, BackgroundBleedNone, compositeOp); |
| 545 paintNinePieceImage(m_renderBox, paintInfo.context, paintRect, m_renderB
ox.style(), m_renderBox.style()->maskBoxImage(), compositeOp); | 543 paintNinePieceImage(m_renderBox, paintInfo.context, paintRect, m_renderB
ox.style(), m_renderBox.style()->maskBoxImage(), compositeOp); |
| 546 } | 544 } |
| 545 |
| 546 if (pushTransparencyLayer) |
| 547 paintInfo.context->endLayer(); |
| 547 } | 548 } |
| 548 | 549 |
| 549 void BoxPainter::paintClippingMask(const PaintInfo& paintInfo, const LayoutPoint
& paintOffset) | 550 void BoxPainter::paintClippingMask(const PaintInfo& paintInfo, const LayoutPoint
& paintOffset) |
| 550 { | 551 { |
| 551 if (!paintInfo.shouldPaintWithinRoot(&m_renderBox) || m_renderBox.style()->v
isibility() != VISIBLE || paintInfo.phase != PaintPhaseClippingMask) | 552 if (!paintInfo.shouldPaintWithinRoot(&m_renderBox) || m_renderBox.style()->v
isibility() != VISIBLE || paintInfo.phase != PaintPhaseClippingMask) |
| 552 return; | 553 return; |
| 553 | 554 |
| 554 if (!m_renderBox.layer() || m_renderBox.layer()->compositingState() != Paint
sIntoOwnBacking) | 555 if (!m_renderBox.layer() || m_renderBox.layer()->compositingState() != Paint
sIntoOwnBacking) |
| 555 return; | 556 return; |
| 556 | 557 |
| (...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2159 | 2160 |
| 2160 FloatPoint secondQuad[4]; | 2161 FloatPoint secondQuad[4]; |
| 2161 secondQuad[0] = quad[0]; | 2162 secondQuad[0] = quad[0]; |
| 2162 secondQuad[1] = FloatPoint(quad[0].x() - r1 * cx, quad[0].y() - r1 * cy); | 2163 secondQuad[1] = FloatPoint(quad[0].x() - r1 * cx, quad[0].y() - r1 * cy); |
| 2163 secondQuad[2] = quad[2]; | 2164 secondQuad[2] = quad[2]; |
| 2164 secondQuad[3] = quad[3]; | 2165 secondQuad[3] = quad[3]; |
| 2165 graphicsContext->clipPolygon(4, secondQuad, !secondEdgeMatches); | 2166 graphicsContext->clipPolygon(4, secondQuad, !secondEdgeMatches); |
| 2166 } | 2167 } |
| 2167 | 2168 |
| 2168 } // namespace blink | 2169 } // namespace blink |
| OLD | NEW |