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" | |
14 #include "core/rendering/ImageQualityController.h" | 15 #include "core/rendering/ImageQualityController.h" |
15 #include "core/rendering/PaintInfo.h" | 16 #include "core/rendering/PaintInfo.h" |
16 #include "core/rendering/RenderBox.h" | 17 #include "core/rendering/RenderBox.h" |
17 #include "core/rendering/RenderBoxModelObject.h" | 18 #include "core/rendering/RenderBoxModelObject.h" |
18 #include "core/rendering/RenderLayer.h" | 19 #include "core/rendering/RenderLayer.h" |
19 #include "core/rendering/RenderObject.h" | 20 #include "core/rendering/RenderObject.h" |
20 #include "core/rendering/RenderTable.h" | 21 #include "core/rendering/RenderTable.h" |
21 #include "core/rendering/RenderTheme.h" | 22 #include "core/rendering/RenderTheme.h" |
22 #include "core/rendering/RenderView.h" | 23 #include "core/rendering/RenderView.h" |
23 #include "core/rendering/compositing/CompositedLayerMapping.h" | 24 #include "core/rendering/compositing/CompositedLayerMapping.h" |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
508 if (!paintInfo.shouldPaintWithinRoot(&m_renderBox) || m_renderBox.style()->v isibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) | 509 if (!paintInfo.shouldPaintWithinRoot(&m_renderBox) || m_renderBox.style()->v isibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) |
509 return; | 510 return; |
510 | 511 |
511 LayoutRect paintRect = LayoutRect(paintOffset, m_renderBox.size()); | 512 LayoutRect paintRect = LayoutRect(paintOffset, m_renderBox.size()); |
512 paintMaskImages(paintInfo, paintRect); | 513 paintMaskImages(paintInfo, paintRect); |
513 } | 514 } |
514 | 515 |
515 void BoxPainter::paintMaskImages(const PaintInfo& paintInfo, const LayoutRect& p aintRect) | 516 void BoxPainter::paintMaskImages(const PaintInfo& paintInfo, const LayoutRect& p aintRect) |
516 { | 517 { |
517 // Figure out if we need to push a transparency layer to render our mask. | 518 // Figure out if we need to push a transparency layer to render our mask. |
518 bool pushTransparencyLayer = false; | 519 OwnPtr<TransparencyRecorder> transparencyRecorder; |
519 bool compositedMask = m_renderBox.hasLayer() && m_renderBox.layer()->hasComp ositedMask(); | 520 bool compositedMask = m_renderBox.hasLayer() && m_renderBox.layer()->hasComp ositedMask(); |
520 bool flattenCompositingLayers = m_renderBox.view()->frameView() && m_renderB ox.view()->frameView()->paintBehavior() & PaintBehaviorFlattenCompositingLayers; | 521 bool flattenCompositingLayers = m_renderBox.view()->frameView() && m_renderB ox.view()->frameView()->paintBehavior() & PaintBehaviorFlattenCompositingLayers; |
521 CompositeOperator compositeOp = CompositeSourceOver; | 522 CompositeOperator compositeOp = CompositeSourceOver; |
522 | 523 |
523 bool allMaskImagesLoaded = true; | 524 bool allMaskImagesLoaded = true; |
524 | 525 |
525 if (!compositedMask || flattenCompositingLayers) { | 526 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); |
chrishtr
2014/11/21 20:08:26
This line needs to be in a display item of some ki
| |
537 paintInfo.context->beginTransparencyLayer(1); | 537 |
538 transparencyRecorder = adoptPtr(new TransparencyRecorder(paintInfo.conte xt, &m_renderBox, DisplayItem::BeginTransparency, | |
539 paintRect, m_renderBox.style()->blendMode(), 1, TransparencyClipBeha vior::DoNotClip)); | |
540 | |
538 compositeOp = CompositeSourceOver; | 541 compositeOp = CompositeSourceOver; |
539 } | 542 } |
540 | 543 |
541 if (allMaskImagesLoaded) { | 544 if (allMaskImagesLoaded) { |
542 paintFillLayers(paintInfo, Color::transparent, m_renderBox.style()->mask Layers(), paintRect, BackgroundBleedNone, compositeOp); | 545 paintFillLayers(paintInfo, Color::transparent, m_renderBox.style()->mask Layers(), paintRect, BackgroundBleedNone, compositeOp); |
543 paintNinePieceImage(m_renderBox, paintInfo.context, paintRect, m_renderB ox.style(), m_renderBox.style()->maskBoxImage(), compositeOp); | 546 paintNinePieceImage(m_renderBox, paintInfo.context, paintRect, m_renderB ox.style(), m_renderBox.style()->maskBoxImage(), compositeOp); |
544 } | 547 } |
545 | |
546 if (pushTransparencyLayer) | |
547 paintInfo.context->endLayer(); | |
548 } | 548 } |
549 | 549 |
550 void BoxPainter::paintClippingMask(const PaintInfo& paintInfo, const LayoutPoint & paintOffset) | 550 void BoxPainter::paintClippingMask(const PaintInfo& paintInfo, const LayoutPoint & paintOffset) |
551 { | 551 { |
552 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) |
553 return; | 553 return; |
554 | 554 |
555 if (!m_renderBox.layer() || m_renderBox.layer()->compositingState() != Paint sIntoOwnBacking) | 555 if (!m_renderBox.layer() || m_renderBox.layer()->compositingState() != Paint sIntoOwnBacking) |
556 return; | 556 return; |
557 | 557 |
(...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2160 | 2160 |
2161 FloatPoint secondQuad[4]; | 2161 FloatPoint secondQuad[4]; |
2162 secondQuad[0] = quad[0]; | 2162 secondQuad[0] = quad[0]; |
2163 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); |
2164 secondQuad[2] = quad[2]; | 2164 secondQuad[2] = quad[2]; |
2165 secondQuad[3] = quad[3]; | 2165 secondQuad[3] = quad[3]; |
2166 graphicsContext->clipPolygon(4, secondQuad, !secondEdgeMatches); | 2166 graphicsContext->clipPolygon(4, secondQuad, !secondEdgeMatches); |
2167 } | 2167 } |
2168 | 2168 |
2169 } // namespace blink | 2169 } // namespace blink |
OLD | NEW |