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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/filters/FilterEffect.cpp

Issue 2329803002: Drop FilterEffect::m_absolutePaintRect (Closed)
Patch Set: Created 4 years, 3 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) 2008 Alex Mathews <possessedpenguinbob@gmail.com> 2 * Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com>
3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
5 * Copyright (C) 2012 University of Szeged 5 * Copyright (C) 2012 University of Szeged
6 * Copyright (C) 2013 Google Inc. All rights reserved. 6 * Copyright (C) 2013 Google Inc. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 49 }
50 50
51 FloatRect FilterEffect::absoluteBounds() const 51 FloatRect FilterEffect::absoluteBounds() const
52 { 52 {
53 FloatRect computedBounds = getFilter()->filterRegion(); 53 FloatRect computedBounds = getFilter()->filterRegion();
54 if (!filterPrimitiveSubregion().isEmpty()) 54 if (!filterPrimitiveSubregion().isEmpty())
55 computedBounds.intersect(filterPrimitiveSubregion()); 55 computedBounds.intersect(filterPrimitiveSubregion());
56 return getFilter()->mapLocalRectToAbsoluteRect(computedBounds); 56 return getFilter()->mapLocalRectToAbsoluteRect(computedBounds);
57 } 57 }
58 58
59 FloatRect FilterEffect::determineAbsolutePaintRect(const FloatRect& originalRequ estedRect) 59 FloatRect FilterEffect::determineAbsolutePaintRect(const FloatRect& originalRequ estedRect) const
60 { 60 {
61 FloatRect requestedRect = originalRequestedRect; 61 FloatRect requestedRect = originalRequestedRect;
62 // Filters in SVG clip to primitive subregion, while CSS doesn't. 62 // Filters in SVG clip to primitive subregion, while CSS doesn't.
63 if (clipsToBounds()) 63 if (clipsToBounds())
64 requestedRect.intersect(absoluteBounds()); 64 requestedRect.intersect(absoluteBounds());
65 65
66 // We may be called multiple times if result is used more than once. Return
67 // quickly if if nothing new is required.
68 if (absolutePaintRect().contains(enclosingIntRect(requestedRect)))
69 return requestedRect;
70
71 FloatRect inputRect = mapPaintRect(requestedRect, false); 66 FloatRect inputRect = mapPaintRect(requestedRect, false);
72 FloatRect inputUnion; 67 FloatRect inputUnion;
73 unsigned size = m_inputEffects.size(); 68 unsigned size = m_inputEffects.size();
74 69
75 for (unsigned i = 0; i < size; ++i) 70 for (unsigned i = 0; i < size; ++i)
76 inputUnion.unite(m_inputEffects.at(i)->determineAbsolutePaintRect(inputR ect)); 71 inputUnion.unite(m_inputEffects.at(i)->determineAbsolutePaintRect(inputR ect));
77 inputUnion = mapPaintRect(inputUnion, true); 72 inputUnion = mapPaintRect(inputUnion, true);
78 73
79 if (affectsTransparentPixels() || !size) { 74 if (affectsTransparentPixels() || !size) {
80 inputUnion = requestedRect; 75 inputUnion = requestedRect;
81 } else { 76 } else {
82 // Rect may have inflated. Re-intersect with request. 77 // Rect may have inflated. Re-intersect with request.
83 inputUnion.intersect(requestedRect); 78 inputUnion.intersect(requestedRect);
84 } 79 }
85
86 addAbsolutePaintRect(inputUnion);
87 return inputUnion; 80 return inputUnion;
88 } 81 }
89 82
90 FloatRect FilterEffect::mapRectRecursive(const FloatRect& rect) const 83 FloatRect FilterEffect::mapRectRecursive(const FloatRect& rect) const
91 { 84 {
92 FloatRect result; 85 FloatRect result;
93 if (m_inputEffects.size() > 0) { 86 if (m_inputEffects.size() > 0) {
94 result = m_inputEffects.at(0)->mapRectRecursive(rect); 87 result = m_inputEffects.at(0)->mapRectRecursive(rect);
95 for (unsigned i = 1; i < m_inputEffects.size(); ++i) 88 for (unsigned i = 1; i < m_inputEffects.size(); ++i)
96 result.unite(m_inputEffects.at(i)->mapRectRecursive(rect)); 89 result.unite(m_inputEffects.at(i)->mapRectRecursive(rect));
97 } else 90 } else
98 result = rect; 91 result = rect;
99 return mapRect(result); 92 return mapRect(result);
100 } 93 }
101 94
102 FilterEffect* FilterEffect::inputEffect(unsigned number) const 95 FilterEffect* FilterEffect::inputEffect(unsigned number) const
103 { 96 {
104 ASSERT_WITH_SECURITY_IMPLICATION(number < m_inputEffects.size()); 97 ASSERT_WITH_SECURITY_IMPLICATION(number < m_inputEffects.size());
105 return m_inputEffects.at(number).get(); 98 return m_inputEffects.at(number).get();
106 } 99 }
107 100
108 void FilterEffect::addAbsolutePaintRect(const FloatRect& paintRect)
109 {
110 IntRect intPaintRect(enclosingIntRect(paintRect));
111 if (m_absolutePaintRect.contains(intPaintRect))
112 return;
113 intPaintRect.unite(m_absolutePaintRect);
114 m_absolutePaintRect = intPaintRect;
115 }
116
117 void FilterEffect::clearResult() 101 void FilterEffect::clearResult()
118 { 102 {
119 m_absolutePaintRect = IntRect(); 103 for (int i = 0; i < 4; i++)
120 for (int i = 0; i < 4; i++) {
121 m_imageFilters[i] = nullptr; 104 m_imageFilters[i] = nullptr;
122 }
123 } 105 }
124 106
125 Color FilterEffect::adaptColorToOperatingColorSpace(const Color& deviceColor) 107 Color FilterEffect::adaptColorToOperatingColorSpace(const Color& deviceColor)
126 { 108 {
127 // |deviceColor| is assumed to be DeviceRGB. 109 // |deviceColor| is assumed to be DeviceRGB.
128 return ColorSpaceUtilities::convertColor(deviceColor, operatingColorSpace()) ; 110 return ColorSpaceUtilities::convertColor(deviceColor, operatingColorSpace()) ;
129 } 111 }
130 112
131 TextStream& FilterEffect::externalRepresentation(TextStream& ts, int) const 113 TextStream& FilterEffect::externalRepresentation(TextStream& ts, int) const
132 { 114 {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 return m_imageFilters[index].get(); 169 return m_imageFilters[index].get();
188 } 170 }
189 171
190 void FilterEffect::setImageFilter(ColorSpace colorSpace, bool requiresPMColorVal idation, sk_sp<SkImageFilter> imageFilter) 172 void FilterEffect::setImageFilter(ColorSpace colorSpace, bool requiresPMColorVal idation, sk_sp<SkImageFilter> imageFilter)
191 { 173 {
192 int index = getImageFilterIndex(colorSpace, requiresPMColorValidation); 174 int index = getImageFilterIndex(colorSpace, requiresPMColorValidation);
193 m_imageFilters[index] = std::move(imageFilter); 175 m_imageFilters[index] = std::move(imageFilter);
194 } 176 }
195 177
196 } // namespace blink 178 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698