Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayer.cpp

Issue 1879223002: Support mask images for filter-based -webkit-box-reflect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@reflection-refactor
Patch Set: add comment referring to skbug.com/5210 Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 #include "core/layout/LayoutScrollbarPart.h" 65 #include "core/layout/LayoutScrollbarPart.h"
66 #include "core/layout/LayoutTreeAsText.h" 66 #include "core/layout/LayoutTreeAsText.h"
67 #include "core/layout/LayoutView.h" 67 #include "core/layout/LayoutView.h"
68 #include "core/layout/compositing/CompositedLayerMapping.h" 68 #include "core/layout/compositing/CompositedLayerMapping.h"
69 #include "core/layout/compositing/PaintLayerCompositor.h" 69 #include "core/layout/compositing/PaintLayerCompositor.h"
70 #include "core/layout/svg/LayoutSVGResourceClipper.h" 70 #include "core/layout/svg/LayoutSVGResourceClipper.h"
71 #include "core/layout/svg/LayoutSVGRoot.h" 71 #include "core/layout/svg/LayoutSVGRoot.h"
72 #include "core/layout/svg/ReferenceFilterBuilder.h" 72 #include "core/layout/svg/ReferenceFilterBuilder.h"
73 #include "core/page/Page.h" 73 #include "core/page/Page.h"
74 #include "core/page/scrolling/ScrollingCoordinator.h" 74 #include "core/page/scrolling/ScrollingCoordinator.h"
75 #include "core/paint/BoxReflectionUtils.h"
75 #include "core/paint/FilterEffectBuilder.h" 76 #include "core/paint/FilterEffectBuilder.h"
76 #include "core/paint/PaintTiming.h" 77 #include "core/paint/PaintTiming.h"
77 #include "platform/LengthFunctions.h" 78 #include "platform/LengthFunctions.h"
78 #include "platform/RuntimeEnabledFeatures.h" 79 #include "platform/RuntimeEnabledFeatures.h"
79 #include "platform/TraceEvent.h" 80 #include "platform/TraceEvent.h"
80 #include "platform/geometry/FloatPoint3D.h" 81 #include "platform/geometry/FloatPoint3D.h"
81 #include "platform/geometry/FloatRect.h" 82 #include "platform/geometry/FloatRect.h"
82 #include "platform/geometry/TransformState.h" 83 #include "platform/geometry/TransformState.h"
83 #include "platform/graphics/filters/Filter.h" 84 #include "platform/graphics/filters/Filter.h"
84 #include "platform/graphics/filters/SourceGraphic.h" 85 #include "platform/graphics/filters/SourceGraphic.h"
(...skipping 2560 matching lines...) Expand 10 before | Expand all | Expand 10 after
2645 2646
2646 return filters; 2647 return filters;
2647 } 2648 }
2648 2649
2649 } // unnamed namespace 2650 } // unnamed namespace
2650 2651
2651 FilterOperations PaintLayer::computeFilterOperations(const ComputedStyle& style) const 2652 FilterOperations PaintLayer::computeFilterOperations(const ComputedStyle& style) const
2652 { 2653 {
2653 FilterOperations filterOperations = style.filter(); 2654 FilterOperations filterOperations = style.filter();
2654 if (RuntimeEnabledFeatures::cssBoxReflectFilterEnabled() && layoutObject()-> hasReflection() && layoutObject()->isBox()) { 2655 if (RuntimeEnabledFeatures::cssBoxReflectFilterEnabled() && layoutObject()-> hasReflection() && layoutObject()->isBox()) {
2655 // TODO(jbroman): Incorporate the mask image. 2656 BoxReflection reflection = boxReflectionForPaintLayer(*this, style);
2656 const auto* reflectStyle = style.boxReflect();
2657 FloatRect frameRect(toLayoutBox(layoutObject())->frameRect());
2658 BoxReflection::ReflectionDirection direction = BoxReflection::VerticalRe flection;
2659 float offset = 0;
2660 switch (reflectStyle->direction()) {
2661 case ReflectionAbove:
2662 direction = BoxReflection::VerticalReflection;
2663 offset = -floatValueForLength(reflectStyle->offset(), frameRect.heig ht());
2664 break;
2665 case ReflectionBelow:
2666 direction = BoxReflection::VerticalReflection;
2667 offset = 2 * frameRect.height() + floatValueForLength(reflectStyle-> offset(), frameRect.height());
2668 break;
2669 case ReflectionLeft:
2670 direction = BoxReflection::HorizontalReflection;
2671 offset = -floatValueForLength(reflectStyle->offset(), frameRect.widt h());
2672 break;
2673 case ReflectionRight:
2674 direction = BoxReflection::HorizontalReflection;
2675 offset = 2 * frameRect.width() + floatValueForLength(reflectStyle->o ffset(), frameRect.width());
2676 break;
2677 }
2678
2679 // Since the filter origin is the corner of the input bounds, which may
2680 // include visual overflow (e.g. due to box-shadow), we must adjust the
2681 // offset to also account for this offset (this is equivalent to using
2682 // SkLocalMatrixImageFilter, but simpler).
2683 // The rect used here should match the one used in FilterPainter.
2684 LayoutRect filterInputBounds = physicalBoundingBoxIncludingReflectionAnd StackingChildren(LayoutPoint());
2685 offset -= 2 * (direction == BoxReflection::VerticalReflection ? filterIn putBounds.y() : filterInputBounds.x()).toFloat();
2686
2687 BoxReflection reflection(direction, offset);
2688 filterOperations.operations().append(BoxReflectFilterOperation::create(r eflection)); 2657 filterOperations.operations().append(BoxReflectFilterOperation::create(r eflection));
2689 } 2658 }
2690 return computeFilterOperationsHandleReferenceFilters(filterOperations, style .effectiveZoom(), enclosingNode()); 2659 return computeFilterOperationsHandleReferenceFilters(filterOperations, style .effectiveZoom(), enclosingNode());
2691 } 2660 }
2692 2661
2693 FilterOperations PaintLayer::computeBackdropFilterOperations(const ComputedStyle & style) const 2662 FilterOperations PaintLayer::computeBackdropFilterOperations(const ComputedStyle & style) const
2694 { 2663 {
2695 return computeFilterOperationsHandleReferenceFilters(style.backdropFilter(), style.effectiveZoom(), enclosingNode()); 2664 return computeFilterOperationsHandleReferenceFilters(style.backdropFilter(), style.effectiveZoom(), enclosingNode());
2696 } 2665 }
2697 2666
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
2941 2910
2942 void showLayerTree(const blink::LayoutObject* layoutObject) 2911 void showLayerTree(const blink::LayoutObject* layoutObject)
2943 { 2912 {
2944 if (!layoutObject) { 2913 if (!layoutObject) {
2945 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); 2914 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n");
2946 return; 2915 return;
2947 } 2916 }
2948 showLayerTree(layoutObject->enclosingLayer()); 2917 showLayerTree(layoutObject->enclosingLayer());
2949 } 2918 }
2950 #endif 2919 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698