| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 3 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
| 4 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> | 4 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> |
| 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| 11 * | 11 * |
| 12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
| 16 * | 16 * |
| 17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
| 18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
| 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #include "core/layout/svg/LayoutSVGResourceGradient.h" | 23 #include "core/layout/svg/LayoutSVGResourceGradient.h" |
| 24 | 24 |
| 25 #include "wtf/PtrUtil.h" |
| 26 #include <memory> |
| 27 |
| 25 namespace blink { | 28 namespace blink { |
| 26 | 29 |
| 27 LayoutSVGResourceGradient::LayoutSVGResourceGradient(SVGGradientElement* node) | 30 LayoutSVGResourceGradient::LayoutSVGResourceGradient(SVGGradientElement* node) |
| 28 : LayoutSVGResourcePaintServer(node) | 31 : LayoutSVGResourcePaintServer(node) |
| 29 , m_shouldCollectGradientAttributes(true) | 32 , m_shouldCollectGradientAttributes(true) |
| 30 { | 33 { |
| 31 } | 34 } |
| 32 | 35 |
| 33 void LayoutSVGResourceGradient::removeAllClientsFromCache(bool markForInvalidati
on) | 36 void LayoutSVGResourceGradient::removeAllClientsFromCache(bool markForInvalidati
on) |
| 34 { | 37 { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 63 | 66 |
| 64 m_shouldCollectGradientAttributes = false; | 67 m_shouldCollectGradientAttributes = false; |
| 65 } | 68 } |
| 66 | 69 |
| 67 // Spec: When the geometry of the applicable element has no width or height
and objectBoundingBox is specified, | 70 // Spec: When the geometry of the applicable element has no width or height
and objectBoundingBox is specified, |
| 68 // then the given effect (e.g. a gradient or a filter) will be ignored. | 71 // then the given effect (e.g. a gradient or a filter) will be ignored. |
| 69 FloatRect objectBoundingBox = object.objectBoundingBox(); | 72 FloatRect objectBoundingBox = object.objectBoundingBox(); |
| 70 if (gradientUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX && obje
ctBoundingBox.isEmpty()) | 73 if (gradientUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX && obje
ctBoundingBox.isEmpty()) |
| 71 return SVGPaintServer::invalid(); | 74 return SVGPaintServer::invalid(); |
| 72 | 75 |
| 73 OwnPtr<GradientData>& gradientData = m_gradientMap.add(&object, nullptr).sto
redValue->value; | 76 std::unique_ptr<GradientData>& gradientData = m_gradientMap.add(&object, nul
lptr).storedValue->value; |
| 74 if (!gradientData) | 77 if (!gradientData) |
| 75 gradientData = adoptPtr(new GradientData); | 78 gradientData = wrapUnique(new GradientData); |
| 76 | 79 |
| 77 // Create gradient object | 80 // Create gradient object |
| 78 if (!gradientData->gradient) { | 81 if (!gradientData->gradient) { |
| 79 gradientData->gradient = buildGradient(); | 82 gradientData->gradient = buildGradient(); |
| 80 | 83 |
| 81 // We want the text bounding box applied to the gradient space transform
now, so the gradient shader can use it. | 84 // We want the text bounding box applied to the gradient space transform
now, so the gradient shader can use it. |
| 82 if (gradientUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX &&
!objectBoundingBox.isEmpty()) { | 85 if (gradientUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX &&
!objectBoundingBox.isEmpty()) { |
| 83 gradientData->userspaceTransform.translate(objectBoundingBox.x(), ob
jectBoundingBox.y()); | 86 gradientData->userspaceTransform.translate(objectBoundingBox.x(), ob
jectBoundingBox.y()); |
| 84 gradientData->userspaceTransform.scaleNonUniform(objectBoundingBox.w
idth(), objectBoundingBox.height()); | 87 gradientData->userspaceTransform.scaleNonUniform(objectBoundingBox.w
idth(), objectBoundingBox.height()); |
| 85 } | 88 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 return SpreadMethodReflect; | 124 return SpreadMethodReflect; |
| 122 case SVGSpreadMethodRepeat: | 125 case SVGSpreadMethodRepeat: |
| 123 return SpreadMethodRepeat; | 126 return SpreadMethodRepeat; |
| 124 } | 127 } |
| 125 | 128 |
| 126 ASSERT_NOT_REACHED(); | 129 ASSERT_NOT_REACHED(); |
| 127 return SpreadMethodPad; | 130 return SpreadMethodPad; |
| 128 } | 131 } |
| 129 | 132 |
| 130 } // namespace blink | 133 } // namespace blink |
| OLD | NEW |