| 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> |
| 34 | 36 |
| 35 namespace blink { | 37 namespace blink { |
| 36 | 38 |
| 37 struct PatternData { | 39 struct PatternData { |
| 38 USING_FAST_MALLOC(PatternData); | 40 USING_FAST_MALLOC(PatternData); |
| 39 public: | 41 public: |
| 40 RefPtr<Pattern> pattern; | 42 RefPtr<Pattern> pattern; |
| 41 AffineTransform transform; | 43 AffineTransform transform; |
| 42 }; | 44 }; |
| 43 | 45 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 68 | 70 |
| 69 // FIXME: the double hash lookup is needed to guard against paint-time inval
idation | 71 // FIXME: the double hash lookup is needed to guard against paint-time inval
idation |
| 70 // (painting animated images may trigger layout invals which delete our map
entry). | 72 // (painting animated images may trigger layout invals which delete our map
entry). |
| 71 // Hopefully that will be addressed at some point, and then we can optimize
the lookup. | 73 // Hopefully that will be addressed at some point, and then we can optimize
the lookup. |
| 72 if (PatternData* currentData = m_patternMap.get(&object)) | 74 if (PatternData* currentData = m_patternMap.get(&object)) |
| 73 return currentData; | 75 return currentData; |
| 74 | 76 |
| 75 return m_patternMap.set(&object, buildPatternData(object)).storedValue->valu
e.get(); | 77 return m_patternMap.set(&object, buildPatternData(object)).storedValue->valu
e.get(); |
| 76 } | 78 } |
| 77 | 79 |
| 78 PassOwnPtr<PatternData> LayoutSVGResourcePattern::buildPatternData(const LayoutO
bject& object) | 80 std::unique_ptr<PatternData> LayoutSVGResourcePattern::buildPatternData(const La
youtObject& object) |
| 79 { | 81 { |
| 80 // If we couldn't determine the pattern content element root, stop here. | 82 // If we couldn't determine the pattern content element root, stop here. |
| 81 const PatternAttributes& attributes = this->attributes(); | 83 const PatternAttributes& attributes = this->attributes(); |
| 82 if (!attributes.patternContentElement()) | 84 if (!attributes.patternContentElement()) |
| 83 return nullptr; | 85 return nullptr; |
| 84 | 86 |
| 85 // An empty viewBox disables layout. | 87 // An empty viewBox disables layout. |
| 86 if (attributes.hasViewBox() && attributes.viewBox().isEmpty()) | 88 if (attributes.hasViewBox() && attributes.viewBox().isEmpty()) |
| 87 return nullptr; | 89 return nullptr; |
| 88 | 90 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 100 if (attributes.viewBox().isEmpty()) | 102 if (attributes.viewBox().isEmpty()) |
| 101 return nullptr; | 103 return nullptr; |
| 102 tileTransform = SVGFitToViewBox::viewBoxToViewTransform(attributes.viewB
ox(), | 104 tileTransform = SVGFitToViewBox::viewBoxToViewTransform(attributes.viewB
ox(), |
| 103 attributes.preserveAspectRatio(), tileBounds.width(), tileBounds.hei
ght()); | 105 attributes.preserveAspectRatio(), tileBounds.width(), tileBounds.hei
ght()); |
| 104 } else { | 106 } else { |
| 105 // A viewbox overrides patternContentUnits, per spec. | 107 // A viewbox overrides patternContentUnits, per spec. |
| 106 if (attributes.patternContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJE
CTBOUNDINGBOX) | 108 if (attributes.patternContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJE
CTBOUNDINGBOX) |
| 107 tileTransform.scale(clientBoundingBox.width(), clientBoundingBox.hei
ght()); | 109 tileTransform.scale(clientBoundingBox.width(), clientBoundingBox.hei
ght()); |
| 108 } | 110 } |
| 109 | 111 |
| 110 OwnPtr<PatternData> patternData = adoptPtr(new PatternData); | 112 std::unique_ptr<PatternData> patternData = wrapUnique(new PatternData); |
| 111 patternData->pattern = Pattern::createPicturePattern(asPicture(tileBounds, t
ileTransform)); | 113 patternData->pattern = Pattern::createPicturePattern(asPicture(tileBounds, t
ileTransform)); |
| 112 | 114 |
| 113 // Compute pattern space transformation. | 115 // Compute pattern space transformation. |
| 114 patternData->transform.translate(tileBounds.x(), tileBounds.y()); | 116 patternData->transform.translate(tileBounds.x(), tileBounds.y()); |
| 115 patternData->transform.preMultiply(attributes.patternTransform()); | 117 patternData->transform.preMultiply(attributes.patternTransform()); |
| 116 | 118 |
| 117 return patternData; | 119 return patternData; |
| 118 } | 120 } |
| 119 | 121 |
| 120 SVGPaintServer LayoutSVGResourcePattern::preparePaintServer(const LayoutObject&
object) | 122 SVGPaintServer LayoutSVGResourcePattern::preparePaintServer(const LayoutObject&
object) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 { | 193 { |
| 192 TransformRecorder transformRecorder(pictureBuilder.context(), *patternLa
youtObject, tileTransform); | 194 TransformRecorder transformRecorder(pictureBuilder.context(), *patternLa
youtObject, tileTransform); |
| 193 for (LayoutObject* child = patternLayoutObject->firstChild(); child; chi
ld = child->nextSibling()) | 195 for (LayoutObject* child = patternLayoutObject->firstChild(); child; chi
ld = child->nextSibling()) |
| 194 SVGPaintContext::paintSubtree(pictureBuilder.context(), child); | 196 SVGPaintContext::paintSubtree(pictureBuilder.context(), child); |
| 195 } | 197 } |
| 196 | 198 |
| 197 return pictureBuilder.endRecording(); | 199 return pictureBuilder.endRecording(); |
| 198 } | 200 } |
| 199 | 201 |
| 200 } // namespace blink | 202 } // namespace blink |
| OLD | NEW |