| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. |
| 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 return; | 703 return; |
| 704 } | 704 } |
| 705 | 705 |
| 706 // The RenderView can't be transformed in Sky. | 706 // The RenderView can't be transformed in Sky. |
| 707 ASSERT(layer()->parent()); | 707 ASSERT(layer()->parent()); |
| 708 | 708 |
| 709 // If the transform can't be inverted, then don't paint anything. | 709 // If the transform can't be inverted, then don't paint anything. |
| 710 if (!layerTransform->isInvertible()) | 710 if (!layerTransform->isInvertible()) |
| 711 return; | 711 return; |
| 712 | 712 |
| 713 // If we have a transparency layer enclosing us and we are the root of a tra
nsform, then we need to establish the transparency | |
| 714 // layer from the parent now, assuming there is a parent | |
| 715 if (layer()->isTransparent()) { | |
| 716 layer()->parent()->beginTransparencyLayers(context, paintingInfo.rootLay
er, paintingInfo.paintDirtyRect, paintingInfo.subPixelAccumulation); | |
| 717 } | |
| 718 | |
| 719 // Make sure the parent's clip rects have been calculated. | 713 // Make sure the parent's clip rects have been calculated. |
| 720 ClipRectsContext clipRectsContext(paintingInfo.rootLayer, PaintingClipRects)
; | 714 ClipRectsContext clipRectsContext(paintingInfo.rootLayer, PaintingClipRects)
; |
| 721 ClipRect clipRect = layer()->clipper().backgroundClipRect(clipRectsContext); | 715 ClipRect clipRect = layer()->clipper().backgroundClipRect(clipRectsContext); |
| 722 clipRect.intersect(paintingInfo.paintDirtyRect); | 716 clipRect.intersect(paintingInfo.paintDirtyRect); |
| 723 | 717 |
| 724 // Push the parent coordinate space's clip. | 718 // Push the parent coordinate space's clip. |
| 725 layer()->parent()->clipToRect(paintingInfo, context, clipRect); | 719 layer()->parent()->clipToRect(paintingInfo, context, clipRect); |
| 726 | 720 |
| 727 // This involves subtracting out the position of the layer in our current co
ordinate space, but preserving | 721 // This involves subtracting out the position of the layer in our current co
ordinate space, but preserving |
| 728 // the accumulated error for sub-pixel layout. | 722 // the accumulated error for sub-pixel layout. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 747 | 741 |
| 748 // Restore the clip. | 742 // Restore the clip. |
| 749 layer()->parent()->restoreClip(context, paintingInfo.paintDirtyRect, clipRec
t); | 743 layer()->parent()->restoreClip(context, paintingInfo.paintDirtyRect, clipRec
t); |
| 750 } | 744 } |
| 751 | 745 |
| 752 void RenderBox::paintLayerContents(GraphicsContext* context, const LayerPainting
Info& paintingInfo, const IntRect& rect) | 746 void RenderBox::paintLayerContents(GraphicsContext* context, const LayerPainting
Info& paintingInfo, const IntRect& rect) |
| 753 { | 747 { |
| 754 float deviceScaleFactor = blink::deviceScaleFactor(frame()); | 748 float deviceScaleFactor = blink::deviceScaleFactor(frame()); |
| 755 context->setDeviceScaleFactor(deviceScaleFactor); | 749 context->setDeviceScaleFactor(deviceScaleFactor); |
| 756 | 750 |
| 757 GraphicsContext* transparencyLayerContext = context; | |
| 758 | |
| 759 LayoutPoint offsetFromRoot; | 751 LayoutPoint offsetFromRoot; |
| 760 layer()->convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); | 752 layer()->convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); |
| 761 | 753 |
| 762 LayerPaintingInfo localPaintingInfo(paintingInfo); | 754 LayerPaintingInfo localPaintingInfo(paintingInfo); |
| 763 | 755 |
| 764 LayoutRect layerBounds; | 756 LayoutRect layerBounds; |
| 765 // FIXME(sky): Remove foregroundRect. It's unused. | 757 // FIXME(sky): Remove foregroundRect. It's unused. |
| 766 ClipRect contentRect, foregroundRect; | 758 ClipRect contentRect, foregroundRect; |
| 767 ClipRectsContext clipRectsContext(localPaintingInfo.rootLayer, PaintingClipR
ects, localPaintingInfo.subPixelAccumulation); | 759 ClipRectsContext clipRectsContext(localPaintingInfo.rootLayer, PaintingClipR
ects, localPaintingInfo.subPixelAccumulation); |
| 768 layer()->clipper().calculateRects(clipRectsContext, localPaintingInfo.paintD
irtyRect, | 760 layer()->clipper().calculateRects(clipRectsContext, localPaintingInfo.paintD
irtyRect, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 791 if (!rootRelativeBoundsComputed) { | 783 if (!rootRelativeBoundsComputed) { |
| 792 rootRelativeBounds = layer()->physicalBoundingBoxIncludingRe
flectionAndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); | 784 rootRelativeBounds = layer()->physicalBoundingBoxIncludingRe
flectionAndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); |
| 793 rootRelativeBoundsComputed = true; | 785 rootRelativeBoundsComputed = true; |
| 794 } | 786 } |
| 795 | 787 |
| 796 context->clipPath(clipPath->path(rootRelativeBounds), clipPath->
windRule()); | 788 context->clipPath(clipPath->path(rootRelativeBounds), clipPath->
windRule()); |
| 797 } | 789 } |
| 798 } | 790 } |
| 799 } | 791 } |
| 800 | 792 |
| 801 bool haveTransparency = layer()->isTransparent(); | 793 if (layer()->isTransparent()) |
| 794 layer()->beginTransparencyLayers(context, localPaintingInfo.rootLayer, p
aintingInfo.paintDirtyRect, localPaintingInfo.subPixelAccumulation); |
| 795 |
| 796 layer()->clipToRect(localPaintingInfo, context, contentRect); |
| 802 | 797 |
| 803 FilterEffectRendererHelper filterPainter(layer()->filterRenderer() && layer(
)->paintsWithFilters()); | 798 FilterEffectRendererHelper filterPainter(layer()->filterRenderer() && layer(
)->paintsWithFilters()); |
| 804 | 799 |
| 805 if (filterPainter.haveFilterEffect()) { | 800 if (filterPainter.haveFilterEffect()) { |
| 806 ASSERT(layer()->filterInfo()); | 801 ASSERT(layer()->filterInfo()); |
| 807 | 802 |
| 808 if (!rootRelativeBoundsComputed) | 803 if (!rootRelativeBoundsComputed) |
| 809 rootRelativeBounds = layer()->physicalBoundingBoxIncludingReflection
AndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); | 804 rootRelativeBounds = layer()->physicalBoundingBoxIncludingReflection
AndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); |
| 810 | 805 |
| 811 if (filterPainter.prepareFilterEffect(layer(), rootRelativeBounds, paint
ingInfo.paintDirtyRect)) { | 806 if (filterPainter.prepareFilterEffect(layer(), rootRelativeBounds, paint
ingInfo.paintDirtyRect)) |
| 812 // Rewire the old context to a memory buffer, so that we can capture
the contents of the layer. | |
| 813 // NOTE: We saved the old context in the "transparencyLayerContext"
local variable, to be able to start a transparency layer | |
| 814 // on the original context and avoid duplicating "beginFilterEffect"
after each transparency layer call. Also, note that | |
| 815 // beginTransparencyLayers will only create a single lazy transparen
cy layer, even though it is called twice in this method. | |
| 816 // With deferred filters, we don't need a separate context, but we d
o need to do transparency and clipping before starting | |
| 817 // filter processing. | |
| 818 // FIXME: when the legacy path is removed, remove the transparencyLa
yerContext as well. | |
| 819 if (haveTransparency) { | |
| 820 // If we have a filter and transparency, we have to eagerly star
t a transparency layer here, rather than risk a child layer lazily starts one af
ter filter processing. | |
| 821 layer()->beginTransparencyLayers(context, localPaintingInfo.root
Layer, paintingInfo.paintDirtyRect, paintingInfo.subPixelAccumulation); | |
| 822 } | |
| 823 // We'll handle clipping to the dirty rect before filter rasterizati
on. | |
| 824 // Filter processing will automatically expand the clip rect and the
offscreen to accommodate any filter outsets. | |
| 825 // FIXME: It is incorrect to just clip to the damageRect here once m
ultiple fragments are involved. | |
| 826 layer()->clipToRect(localPaintingInfo, context, contentRect); | |
| 827 // Subsequent code should not clip to the dirty rect, since we've al
ready | |
| 828 // done it above, and doing it later will defeat the outsets. | |
| 829 localPaintingInfo.clipToDirtyRect = false; | |
| 830 | |
| 831 context = filterPainter.beginFilterEffect(context); | 807 context = filterPainter.beginFilterEffect(context); |
| 832 } | |
| 833 } | 808 } |
| 834 | 809 |
| 835 LayoutPoint layerLocation = toPoint(layerBounds.location() - location() + lo
calPaintingInfo.subPixelAccumulation); | 810 LayoutPoint layerLocation = toPoint(layerBounds.location() - location() + lo
calPaintingInfo.subPixelAccumulation); |
| 836 | 811 |
| 837 // Begin transparency if we have something to paint. | |
| 838 if (haveTransparency) | |
| 839 layer()->beginTransparencyLayers(transparencyLayerContext, localPainting
Info.rootLayer, paintingInfo.paintDirtyRect, localPaintingInfo.subPixelAccumulat
ion); | |
| 840 | |
| 841 if (localPaintingInfo.clipToDirtyRect) | |
| 842 layer()->clipToRect(localPaintingInfo, context, contentRect); | |
| 843 | |
| 844 Vector<RenderBox*> layers; | 812 Vector<RenderBox*> layers; |
| 845 PaintInfo paintInfo(context, pixelSnappedIntRect(contentRect.rect()), localP
aintingInfo.rootLayer->renderer()); | 813 PaintInfo paintInfo(context, pixelSnappedIntRect(contentRect.rect()), localP
aintingInfo.rootLayer->renderer()); |
| 846 paint(paintInfo, layerLocation, layers); | 814 paint(paintInfo, layerLocation, layers); |
| 847 | 815 |
| 848 std::stable_sort(layers.begin(), layers.end(), forwardCompareZIndex); | 816 std::stable_sort(layers.begin(), layers.end(), forwardCompareZIndex); |
| 849 for (auto& box : layers) { | 817 for (auto& box : layers) { |
| 850 box->paintLayer(context, paintingInfo.rootLayer, rect); | 818 box->paintLayer(context, paintingInfo.rootLayer, rect); |
| 851 } | 819 } |
| 852 | 820 |
| 853 if (localPaintingInfo.clipToDirtyRect) | 821 if (filterPainter.hasStartedFilterEffect()) |
| 854 layer()->restoreClip(context, localPaintingInfo.paintDirtyRect, contentR
ect); | 822 context = filterPainter.applyFilterEffect(); |
| 855 | 823 |
| 856 if (filterPainter.hasStartedFilterEffect()) { | 824 layer()->restoreClip(context, localPaintingInfo.paintDirtyRect, contentRect)
; |
| 857 context = filterPainter.applyFilterEffect(); | |
| 858 layer()->restoreClip(transparencyLayerContext, localPaintingInfo.paintDi
rtyRect, contentRect); | |
| 859 } | |
| 860 | 825 |
| 861 // Make sure that we now use the original transparency context. | 826 if (layer()->isTransparent()) { |
| 862 ASSERT(transparencyLayerContext == context); | |
| 863 | |
| 864 // End our transparency layer | |
| 865 if (haveTransparency && layer()->usedTransparency()) { | |
| 866 context->endLayer(); | 827 context->endLayer(); |
| 867 context->restore(); | 828 context->restore(); |
| 868 layer()->clearUsedTransparency(); | |
| 869 } | 829 } |
| 870 } | 830 } |
| 871 | 831 |
| 872 void RenderBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, Vect
or<RenderBox*>& layers) | 832 void RenderBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, Vect
or<RenderBox*>& layers) |
| 873 { | 833 { |
| 874 LayoutPoint adjustedPaintOffset = paintOffset + location(); | 834 LayoutPoint adjustedPaintOffset = paintOffset + location(); |
| 875 for (RenderObject* child = slowFirstChild(); child; child = child->nextSibli
ng()) | 835 for (RenderObject* child = slowFirstChild(); child; child = child->nextSibli
ng()) |
| 876 child->paint(paintInfo, adjustedPaintOffset, layers); | 836 child->paint(paintInfo, adjustedPaintOffset, layers); |
| 877 } | 837 } |
| 878 | 838 |
| (...skipping 2125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3004 | 2964 |
| 3005 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) | 2965 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) |
| 3006 { | 2966 { |
| 3007 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor); | 2967 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor); |
| 3008 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); | 2968 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); |
| 3009 ASSERT(hasBackground == style.hasBackground()); | 2969 ASSERT(hasBackground == style.hasBackground()); |
| 3010 hasBorder = style.hasBorder(); | 2970 hasBorder = style.hasBorder(); |
| 3011 } | 2971 } |
| 3012 | 2972 |
| 3013 } // namespace blink | 2973 } // namespace blink |
| OLD | NEW |