| OLD | NEW |
| 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 Loading... |
| 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) const | 59 FloatRect FilterEffect::mapInputs(const FloatRect& rect) const |
| 60 { | 60 { |
| 61 FloatRect requestedRect = originalRequestedRect; | 61 if (!m_inputEffects.size()) { |
| 62 // Filters in SVG clip to primitive subregion, while CSS doesn't. | 62 if (clipsToBounds()) |
| 63 if (clipsToBounds()) | 63 return absoluteBounds(); |
| 64 requestedRect.intersect(absoluteBounds()); | 64 return rect; |
| 65 | 65 } |
| 66 FloatRect inputRect = mapPaintRect(requestedRect, false); | |
| 67 FloatRect inputUnion; | 66 FloatRect inputUnion; |
| 68 unsigned size = m_inputEffects.size(); | 67 for (const auto& effect : m_inputEffects) |
| 69 | 68 inputUnion.unite(effect->mapRect(rect)); |
| 70 for (unsigned i = 0; i < size; ++i) | |
| 71 inputUnion.unite(m_inputEffects.at(i)->determineAbsolutePaintRect(inputR
ect)); | |
| 72 inputUnion = mapPaintRect(inputUnion, true); | |
| 73 | |
| 74 if (affectsTransparentPixels() || !size) { | |
| 75 inputUnion = requestedRect; | |
| 76 } else { | |
| 77 // Rect may have inflated. Re-intersect with request. | |
| 78 inputUnion.intersect(requestedRect); | |
| 79 } | |
| 80 return inputUnion; | 69 return inputUnion; |
| 81 } | 70 } |
| 82 | 71 |
| 83 FloatRect FilterEffect::mapRectRecursive(const FloatRect& rect) const | 72 FloatRect FilterEffect::mapEffect(const FloatRect& rect) const |
| 84 { | 73 { |
| 85 FloatRect result; | 74 return rect; |
| 86 if (m_inputEffects.size() > 0) { | 75 } |
| 87 result = m_inputEffects.at(0)->mapRectRecursive(rect); | 76 |
| 88 for (unsigned i = 1; i < m_inputEffects.size(); ++i) | 77 FloatRect FilterEffect::applyBounds(const FloatRect& rect) const |
| 89 result.unite(m_inputEffects.at(i)->mapRectRecursive(rect)); | 78 { |
| 90 } else | 79 // Filters in SVG clip to primitive subregion, while CSS doesn't. |
| 91 result = rect; | 80 if (!clipsToBounds()) |
| 92 return mapRect(result); | 81 return rect; |
| 82 FloatRect bounds = absoluteBounds(); |
| 83 if (affectsTransparentPixels()) |
| 84 return bounds; |
| 85 return intersection(rect, bounds); |
| 86 } |
| 87 |
| 88 FloatRect FilterEffect::mapRect(const FloatRect& rect) const |
| 89 { |
| 90 FloatRect result = mapInputs(rect); |
| 91 result = mapEffect(result); |
| 92 return applyBounds(result); |
| 93 } | 93 } |
| 94 | 94 |
| 95 FilterEffect* FilterEffect::inputEffect(unsigned number) const | 95 FilterEffect* FilterEffect::inputEffect(unsigned number) const |
| 96 { | 96 { |
| 97 ASSERT_WITH_SECURITY_IMPLICATION(number < m_inputEffects.size()); | 97 ASSERT_WITH_SECURITY_IMPLICATION(number < m_inputEffects.size()); |
| 98 return m_inputEffects.at(number).get(); | 98 return m_inputEffects.at(number).get(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void FilterEffect::clearResult() | 101 void FilterEffect::clearResult() |
| 102 { | 102 { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 return m_imageFilters[index].get(); | 169 return m_imageFilters[index].get(); |
| 170 } | 170 } |
| 171 | 171 |
| 172 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) |
| 173 { | 173 { |
| 174 int index = getImageFilterIndex(colorSpace, requiresPMColorValidation); | 174 int index = getImageFilterIndex(colorSpace, requiresPMColorValidation); |
| 175 m_imageFilters[index] = std::move(imageFilter); | 175 m_imageFilters[index] = std::move(imageFilter); |
| 176 } | 176 } |
| 177 | 177 |
| 178 } // namespace blink | 178 } // namespace blink |
| OLD | NEW |