| 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) Research In Motion Limited 2010. All rights reserved. | 3 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 4 * Copyright 2014 The Chromium Authors. All rights reserved. | 4 * Copyright 2014 The Chromium Authors. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "core/layout/svg/SVGLayoutSupport.h" | 24 #include "core/layout/svg/SVGLayoutSupport.h" |
| 25 #include "core/layout/svg/SVGResources.h" | 25 #include "core/layout/svg/SVGResources.h" |
| 26 #include "core/paint/SVGPaintContext.h" | 26 #include "core/paint/SVGPaintContext.h" |
| 27 #include "core/paint/TransformRecorder.h" | 27 #include "core/paint/TransformRecorder.h" |
| 28 #include "core/svg/SVGFitToViewBox.h" | 28 #include "core/svg/SVGFitToViewBox.h" |
| 29 #include "core/svg/SVGPatternElement.h" | 29 #include "core/svg/SVGPatternElement.h" |
| 30 #include "platform/graphics/GraphicsContext.h" | 30 #include "platform/graphics/GraphicsContext.h" |
| 31 #include "platform/graphics/paint/PaintController.h" | 31 #include "platform/graphics/paint/PaintController.h" |
| 32 #include "platform/graphics/paint/SkPictureBuilder.h" | 32 #include "platform/graphics/paint/SkPictureBuilder.h" |
| 33 #include "third_party/skia/include/core/SkPicture.h" | 33 #include "third_party/skia/include/core/SkPicture.h" |
| 34 #include "wtf/PtrUtil.h" | |
| 35 #include <memory> | |
| 36 | 34 |
| 37 namespace blink { | 35 namespace blink { |
| 38 | 36 |
| 39 struct PatternData { | 37 struct PatternData { |
| 40 USING_FAST_MALLOC(PatternData); | 38 USING_FAST_MALLOC(PatternData); |
| 41 public: | 39 public: |
| 42 RefPtr<Pattern> pattern; | 40 RefPtr<Pattern> pattern; |
| 43 AffineTransform transform; | 41 AffineTransform transform; |
| 44 }; | 42 }; |
| 45 | 43 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 70 | 68 |
| 71 // FIXME: the double hash lookup is needed to guard against paint-time inval
idation | 69 // FIXME: the double hash lookup is needed to guard against paint-time inval
idation |
| 72 // (painting animated images may trigger layout invals which delete our map
entry). | 70 // (painting animated images may trigger layout invals which delete our map
entry). |
| 73 // Hopefully that will be addressed at some point, and then we can optimize
the lookup. | 71 // Hopefully that will be addressed at some point, and then we can optimize
the lookup. |
| 74 if (PatternData* currentData = m_patternMap.get(&object)) | 72 if (PatternData* currentData = m_patternMap.get(&object)) |
| 75 return currentData; | 73 return currentData; |
| 76 | 74 |
| 77 return m_patternMap.set(&object, buildPatternData(object)).storedValue->valu
e.get(); | 75 return m_patternMap.set(&object, buildPatternData(object)).storedValue->valu
e.get(); |
| 78 } | 76 } |
| 79 | 77 |
| 80 std::unique_ptr<PatternData> LayoutSVGResourcePattern::buildPatternData(const La
youtObject& object) | 78 PassOwnPtr<PatternData> LayoutSVGResourcePattern::buildPatternData(const LayoutO
bject& object) |
| 81 { | 79 { |
| 82 // If we couldn't determine the pattern content element root, stop here. | 80 // If we couldn't determine the pattern content element root, stop here. |
| 83 const PatternAttributes& attributes = this->attributes(); | 81 const PatternAttributes& attributes = this->attributes(); |
| 84 if (!attributes.patternContentElement()) | 82 if (!attributes.patternContentElement()) |
| 85 return nullptr; | 83 return nullptr; |
| 86 | 84 |
| 87 // An empty viewBox disables layout. | 85 // An empty viewBox disables layout. |
| 88 if (attributes.hasViewBox() && attributes.viewBox().isEmpty()) | 86 if (attributes.hasViewBox() && attributes.viewBox().isEmpty()) |
| 89 return nullptr; | 87 return nullptr; |
| 90 | 88 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 102 if (attributes.viewBox().isEmpty()) | 100 if (attributes.viewBox().isEmpty()) |
| 103 return nullptr; | 101 return nullptr; |
| 104 tileTransform = SVGFitToViewBox::viewBoxToViewTransform(attributes.viewB
ox(), | 102 tileTransform = SVGFitToViewBox::viewBoxToViewTransform(attributes.viewB
ox(), |
| 105 attributes.preserveAspectRatio(), tileBounds.width(), tileBounds.hei
ght()); | 103 attributes.preserveAspectRatio(), tileBounds.width(), tileBounds.hei
ght()); |
| 106 } else { | 104 } else { |
| 107 // A viewbox overrides patternContentUnits, per spec. | 105 // A viewbox overrides patternContentUnits, per spec. |
| 108 if (attributes.patternContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJE
CTBOUNDINGBOX) | 106 if (attributes.patternContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJE
CTBOUNDINGBOX) |
| 109 tileTransform.scale(clientBoundingBox.width(), clientBoundingBox.hei
ght()); | 107 tileTransform.scale(clientBoundingBox.width(), clientBoundingBox.hei
ght()); |
| 110 } | 108 } |
| 111 | 109 |
| 112 std::unique_ptr<PatternData> patternData = wrapUnique(new PatternData); | 110 OwnPtr<PatternData> patternData = adoptPtr(new PatternData); |
| 113 patternData->pattern = Pattern::createPicturePattern(asPicture(tileBounds, t
ileTransform)); | 111 patternData->pattern = Pattern::createPicturePattern(asPicture(tileBounds, t
ileTransform)); |
| 114 | 112 |
| 115 // Compute pattern space transformation. | 113 // Compute pattern space transformation. |
| 116 patternData->transform.translate(tileBounds.x(), tileBounds.y()); | 114 patternData->transform.translate(tileBounds.x(), tileBounds.y()); |
| 117 patternData->transform.preMultiply(attributes.patternTransform()); | 115 patternData->transform.preMultiply(attributes.patternTransform()); |
| 118 | 116 |
| 119 return patternData; | 117 return patternData; |
| 120 } | 118 } |
| 121 | 119 |
| 122 SVGPaintServer LayoutSVGResourcePattern::preparePaintServer(const LayoutObject&
object) | 120 SVGPaintServer LayoutSVGResourcePattern::preparePaintServer(const LayoutObject&
object) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 { | 191 { |
| 194 TransformRecorder transformRecorder(pictureBuilder.context(), *patternLa
youtObject, tileTransform); | 192 TransformRecorder transformRecorder(pictureBuilder.context(), *patternLa
youtObject, tileTransform); |
| 195 for (LayoutObject* child = patternLayoutObject->firstChild(); child; chi
ld = child->nextSibling()) | 193 for (LayoutObject* child = patternLayoutObject->firstChild(); child; chi
ld = child->nextSibling()) |
| 196 SVGPaintContext::paintSubtree(pictureBuilder.context(), child); | 194 SVGPaintContext::paintSubtree(pictureBuilder.context(), child); |
| 197 } | 195 } |
| 198 | 196 |
| 199 return pictureBuilder.endRecording(); | 197 return pictureBuilder.endRecording(); |
| 200 } | 198 } |
| 201 | 199 |
| 202 } // namespace blink | 200 } // namespace blink |
| OLD | NEW |