OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
5 * | 5 * |
6 * Other contributors: | 6 * Other contributors: |
7 * Robert O'Callahan <roc+@cs.cmu.edu> | 7 * Robert O'Callahan <roc+@cs.cmu.edu> |
8 * David Baron <dbaron@fas.harvard.edu> | 8 * David Baron <dbaron@fas.harvard.edu> |
9 * Christian Biesinger <cbiesinger@web.de> | 9 * Christian Biesinger <cbiesinger@web.de> |
10 * Randall Jesup <rjesup@wgate.com> | 10 * Randall Jesup <rjesup@wgate.com> |
(...skipping 2671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2682 } | 2682 } |
2683 | 2683 |
2684 bool PaintLayer::scrollsOverflow() const | 2684 bool PaintLayer::scrollsOverflow() const |
2685 { | 2685 { |
2686 if (PaintLayerScrollableArea* scrollableArea = this->getScrollableArea()) | 2686 if (PaintLayerScrollableArea* scrollableArea = this->getScrollableArea()) |
2687 return scrollableArea->scrollsOverflow(); | 2687 return scrollableArea->scrollsOverflow(); |
2688 | 2688 |
2689 return false; | 2689 return false; |
2690 } | 2690 } |
2691 | 2691 |
2692 namespace { | |
2693 | |
2694 FilterOperations resolveReferenceFilters(const FilterEffectBuilder& builder, con st FilterOperations& filters) | |
2695 { | |
2696 DCHECK(filters.hasReferenceFilter()); | |
2697 | |
2698 for (FilterOperation* filterOperation : filters.operations()) { | |
2699 if (filterOperation->type() != FilterOperation::REFERENCE) | |
2700 continue; | |
2701 ReferenceFilterOperation& referenceOperation = toReferenceFilterOperatio n(*filterOperation); | |
2702 // TODO(fs): Cache the Filter if it didn't change. | |
2703 referenceOperation.setFilter(builder.buildReferenceFilter(referenceOpera tion)); | |
2704 } | |
2705 return filters; | |
2706 } | |
2707 | |
2708 } // unnamed namespace | |
2709 | |
2710 FilterOperations PaintLayer::addReflectionToFilterOperations(const ComputedStyle & style) const | 2692 FilterOperations PaintLayer::addReflectionToFilterOperations(const ComputedStyle & style) const |
Stephen White
2016/09/21 14:21:24
I'm wondering if it would make sense to make the b
fs
2016/09/21 14:45:36
Yes, I've been pondering this a little bit... the
| |
2711 { | 2693 { |
2712 FilterOperations filterOperations = style.filter(); | 2694 FilterOperations filterOperations = style.filter(); |
2713 if (RuntimeEnabledFeatures::cssBoxReflectFilterEnabled() && layoutObject()-> hasReflection() && layoutObject()->isBox()) { | 2695 if (RuntimeEnabledFeatures::cssBoxReflectFilterEnabled() && layoutObject()-> hasReflection() && layoutObject()->isBox()) { |
2714 BoxReflection reflection = boxReflectionForPaintLayer(*this, style); | 2696 BoxReflection reflection = boxReflectionForPaintLayer(*this, style); |
2715 filterOperations.operations().append(BoxReflectFilterOperation::create(r eflection)); | 2697 filterOperations.operations().append(BoxReflectFilterOperation::create(r eflection)); |
2716 } | 2698 } |
2717 return filterOperations; | 2699 return filterOperations; |
2718 } | 2700 } |
2719 | 2701 |
2720 CompositorFilterOperations PaintLayer::createCompositorFilterOperationsForFilter (const ComputedStyle& style) | 2702 CompositorFilterOperations PaintLayer::createCompositorFilterOperationsForFilter (const ComputedStyle& style) |
2721 { | 2703 { |
2722 FilterOperations filterOperations = addReflectionToFilterOperations(style); | 2704 FloatRect zoomedReferenceBox; |
2723 if (filterOperations.hasReferenceFilter()) { | 2705 if (style.filter().hasReferenceFilter()) |
2724 FilterEffectBuilder builder(toElement(enclosingNode()), boxForFilter(), style.effectiveZoom()); | 2706 zoomedReferenceBox = boxForFilter(); |
2725 filterOperations = resolveReferenceFilters(builder, filterOperations); | 2707 FilterEffectBuilder builder(enclosingNode(), zoomedReferenceBox, style.effec tiveZoom()); |
2726 } | 2708 return builder.buildFilterOperations(addReflectionToFilterOperations(style)) ; |
2727 return SkiaImageFilterBuilder::buildFilterOperations(filterOperations); | |
2728 } | 2709 } |
2729 | 2710 |
2730 CompositorFilterOperations PaintLayer::createCompositorFilterOperationsForBackdr opFilter(const ComputedStyle& style) | 2711 CompositorFilterOperations PaintLayer::createCompositorFilterOperationsForBackdr opFilter(const ComputedStyle& style) |
2731 { | 2712 { |
2732 FilterOperations operations = style.backdropFilter(); | 2713 FloatRect zoomedReferenceBox; |
2733 if (operations.hasReferenceFilter()) { | 2714 if (style.backdropFilter().hasReferenceFilter()) |
2734 FilterEffectBuilder builder(toElement(enclosingNode()), boxForFilter(), style.effectiveZoom()); | 2715 zoomedReferenceBox = boxForFilter(); |
2735 operations = resolveReferenceFilters(builder, operations); | 2716 FilterEffectBuilder builder(enclosingNode(), zoomedReferenceBox, style.effec tiveZoom()); |
2736 } | 2717 return builder.buildFilterOperations(style.backdropFilter()); |
2737 return SkiaImageFilterBuilder::buildFilterOperations(operations); | |
2738 } | 2718 } |
2739 | 2719 |
2740 PaintLayerFilterInfo& PaintLayer::ensureFilterInfo() | 2720 PaintLayerFilterInfo& PaintLayer::ensureFilterInfo() |
2741 { | 2721 { |
2742 PaintLayerRareData& rareData = ensureRareData(); | 2722 PaintLayerRareData& rareData = ensureRareData(); |
2743 if (!rareData.filterInfo) | 2723 if (!rareData.filterInfo) |
2744 rareData.filterInfo = new PaintLayerFilterInfo(this); | 2724 rareData.filterInfo = new PaintLayerFilterInfo(this); |
2745 return *rareData.filterInfo; | 2725 return *rareData.filterInfo; |
2746 } | 2726 } |
2747 | 2727 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2788 | 2768 |
2789 PaintLayerFilterInfo* filterInfo = this->filterInfo(); | 2769 PaintLayerFilterInfo* filterInfo = this->filterInfo(); |
2790 | 2770 |
2791 // Should have been added by updateOrRemoveFilterEffect(). | 2771 // Should have been added by updateOrRemoveFilterEffect(). |
2792 ASSERT(filterInfo); | 2772 ASSERT(filterInfo); |
2793 | 2773 |
2794 if (filterInfo->lastEffect()) | 2774 if (filterInfo->lastEffect()) |
2795 return filterInfo->lastEffect(); | 2775 return filterInfo->lastEffect(); |
2796 | 2776 |
2797 const ComputedStyle& style = layoutObject()->styleRef(); | 2777 const ComputedStyle& style = layoutObject()->styleRef(); |
2798 const bool hasReferenceFilter = style.filter().hasReferenceFilter(); | |
2799 FloatRect zoomedReferenceBox; | 2778 FloatRect zoomedReferenceBox; |
2800 if (hasReferenceFilter) | 2779 if (style.filter().hasReferenceFilter()) |
2801 zoomedReferenceBox = boxForFilter(); | 2780 zoomedReferenceBox = boxForFilter(); |
2802 | 2781 FilterEffectBuilder builder(enclosingNode(), zoomedReferenceBox, style.effec tiveZoom()); |
2803 FilterOperations operations = addReflectionToFilterOperations(style); | 2782 filterInfo->setLastEffect(builder.buildFilterEffect(addReflectionToFilterOpe rations(style))); |
2804 FilterEffectBuilder builder(toElement(enclosingNode()), zoomedReferenceBox, style.effectiveZoom()); | |
2805 if (hasReferenceFilter) | |
2806 operations = resolveReferenceFilters(builder, operations); | |
2807 | |
2808 filterInfo->setLastEffect(builder.buildFilterEffect(operations)); | |
2809 return filterInfo->lastEffect(); | 2783 return filterInfo->lastEffect(); |
2810 } | 2784 } |
2811 | 2785 |
2812 FilterEffect* PaintLayer::lastFilterEffect() const | 2786 FilterEffect* PaintLayer::lastFilterEffect() const |
2813 { | 2787 { |
2814 return updateFilterEffect(); | 2788 return updateFilterEffect(); |
2815 } | 2789 } |
2816 | 2790 |
2817 FloatRect PaintLayer::mapRectForFilter(const FloatRect& rect) const | 2791 FloatRect PaintLayer::mapRectForFilter(const FloatRect& rect) const |
2818 { | 2792 { |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3006 | 2980 |
3007 void showLayerTree(const blink::LayoutObject* layoutObject) | 2981 void showLayerTree(const blink::LayoutObject* layoutObject) |
3008 { | 2982 { |
3009 if (!layoutObject) { | 2983 if (!layoutObject) { |
3010 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); | 2984 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); |
3011 return; | 2985 return; |
3012 } | 2986 } |
3013 showLayerTree(layoutObject->enclosingLayer()); | 2987 showLayerTree(layoutObject->enclosingLayer()); |
3014 } | 2988 } |
3015 #endif | 2989 #endif |
OLD | NEW |