| 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 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 AffineTransform tileImageTransform; | 83 AffineTransform tileImageTransform; |
| 84 if (!buildTileImageTransform(object, m_attributes, patternElement, tileBound
aries, tileImageTransform)) | 84 if (!buildTileImageTransform(object, m_attributes, patternElement, tileBound
aries, tileImageTransform)) |
| 85 return 0; | 85 return 0; |
| 86 | 86 |
| 87 AffineTransform absoluteTransformIgnoringRotation; | 87 AffineTransform absoluteTransformIgnoringRotation; |
| 88 SVGRenderingContext::calculateDeviceSpaceTransformation(object, absoluteTran
sformIgnoringRotation); | 88 SVGRenderingContext::calculateDeviceSpaceTransformation(object, absoluteTran
sformIgnoringRotation); |
| 89 | 89 |
| 90 // Ignore 2D rotation, as it doesn't affect the size of the tile. | 90 // Ignore 2D rotation, as it doesn't affect the size of the tile. |
| 91 SVGRenderingContext::clear2DRotation(absoluteTransformIgnoringRotation); | 91 SVGRenderingContext::clear2DRotation(absoluteTransformIgnoringRotation); |
| 92 FloatRect absoluteTileBoundaries = absoluteTransformIgnoringRotation.mapRect
(tileBoundaries); | 92 FloatRect absoluteTileBoundaries = absoluteTransformIgnoringRotation.mapRect
(tileBoundaries); |
| 93 FloatRect clampedAbsoluteTileBoundaries; | |
| 94 | 93 |
| 95 // Scale the tile size to match the scale level of the patternTransform. | 94 // Scale the tile size to match the scale level of the patternTransform. |
| 96 absoluteTileBoundaries.scale(static_cast<float>(m_attributes.patternTransfor
m().xScale()), | 95 absoluteTileBoundaries.scale(static_cast<float>(m_attributes.patternTransfor
m().xScale()), |
| 97 static_cast<float>(m_attributes.patternTransform().yScale())); | 96 static_cast<float>(m_attributes.patternTransform().yScale())); |
| 98 | 97 |
| 99 // Build tile image. | 98 // Build tile image. |
| 100 OwnPtr<ImageBuffer> tileImage = createTileImage(m_attributes, tileBoundaries
, absoluteTileBoundaries, tileImageTransform, clampedAbsoluteTileBoundaries); | 99 OwnPtr<ImageBuffer> tileImage = createTileImage(m_attributes, tileBoundaries
, absoluteTileBoundaries, tileImageTransform); |
| 101 if (!tileImage) | 100 if (!tileImage) |
| 102 return 0; | 101 return 0; |
| 103 | 102 |
| 104 RefPtr<Image> copiedImage = tileImage->copyImage(CopyBackingStore); | 103 RefPtr<Image> copiedImage = tileImage->copyImage(CopyBackingStore); |
| 105 if (!copiedImage) | 104 if (!copiedImage) |
| 106 return 0; | 105 return 0; |
| 107 | 106 |
| 108 // Build pattern. | 107 // Build pattern. |
| 109 OwnPtr<PatternData> patternData = adoptPtr(new PatternData); | 108 OwnPtr<PatternData> patternData = adoptPtr(new PatternData); |
| 110 patternData->pattern = Pattern::create(copiedImage, true, true); | 109 patternData->pattern = Pattern::create(copiedImage, true, true); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 tileImageTransform = viewBoxCTM; | 221 tileImageTransform = viewBoxCTM; |
| 223 else if (attributes.patternContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJ
ECTBOUNDINGBOX) | 222 else if (attributes.patternContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJ
ECTBOUNDINGBOX) |
| 224 tileImageTransform.scale(objectBoundingBox.width(), objectBoundingBox.he
ight()); | 223 tileImageTransform.scale(objectBoundingBox.width(), objectBoundingBox.he
ight()); |
| 225 | 224 |
| 226 return true; | 225 return true; |
| 227 } | 226 } |
| 228 | 227 |
| 229 PassOwnPtr<ImageBuffer> RenderSVGResourcePattern::createTileImage(const PatternA
ttributes& attributes, | 228 PassOwnPtr<ImageBuffer> RenderSVGResourcePattern::createTileImage(const PatternA
ttributes& attributes, |
| 230 const FloatRec
t& tileBoundaries, | 229 const FloatRec
t& tileBoundaries, |
| 231 const FloatRec
t& absoluteTileBoundaries, | 230 const FloatRec
t& absoluteTileBoundaries, |
| 232 const AffineTr
ansform& tileImageTransform, | 231 const AffineTr
ansform& tileImageTransform) const |
| 233 FloatRect& cla
mpedAbsoluteTileBoundaries) const | |
| 234 { | 232 { |
| 235 clampedAbsoluteTileBoundaries = SVGRenderingContext::clampedAbsoluteTargetRe
ct(absoluteTileBoundaries); | 233 FloatRect clampedAbsoluteTileBoundaries = SVGRenderingContext::clampedAbsolu
teTargetRect(absoluteTileBoundaries); |
| 236 | 234 |
| 237 IntSize imageSize(roundedIntSize(clampedAbsoluteTileBoundaries.size())); | 235 IntSize imageSize(roundedIntSize(clampedAbsoluteTileBoundaries.size())); |
| 238 if (imageSize.isEmpty()) | 236 if (imageSize.isEmpty()) |
| 239 return nullptr; | 237 return nullptr; |
| 240 OwnPtr<ImageBuffer> tileImage = ImageBuffer::create(imageSize); | 238 OwnPtr<ImageBuffer> tileImage = ImageBuffer::create(imageSize); |
| 241 if (!tileImage) | 239 if (!tileImage) |
| 242 return nullptr; | 240 return nullptr; |
| 243 | 241 |
| 244 GraphicsContext* tileImageContext = tileImage->context(); | 242 GraphicsContext* tileImageContext = tileImage->context(); |
| 245 ASSERT(tileImageContext); | 243 ASSERT(tileImageContext); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 264 continue; | 262 continue; |
| 265 if (element->renderer()->needsLayout()) | 263 if (element->renderer()->needsLayout()) |
| 266 return nullptr; | 264 return nullptr; |
| 267 SVGRenderingContext::renderSubtree(tileImage->context(), element->render
er(), contentTransformation); | 265 SVGRenderingContext::renderSubtree(tileImage->context(), element->render
er(), contentTransformation); |
| 268 } | 266 } |
| 269 | 267 |
| 270 return tileImage.release(); | 268 return tileImage.release(); |
| 271 } | 269 } |
| 272 | 270 |
| 273 } | 271 } |
| OLD | NEW |