| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 RefPtr<Image> copiedImage = tileImage->copyImage(CopyBackingStore); | 103 RefPtr<Image> copiedImage = tileImage->copyImage(CopyBackingStore); |
| 104 if (!copiedImage) | 104 if (!copiedImage) |
| 105 return 0; | 105 return 0; |
| 106 | 106 |
| 107 // Build pattern. | 107 // Build pattern. |
| 108 OwnPtr<PatternData> patternData = adoptPtr(new PatternData); | 108 OwnPtr<PatternData> patternData = adoptPtr(new PatternData); |
| 109 patternData->pattern = Pattern::create(copiedImage, true, true); | 109 patternData->pattern = Pattern::create(copiedImage, true, true); |
| 110 | 110 |
| 111 // Compute pattern space transformation. | 111 // Compute pattern space transformation. |
| 112 const IntSize tileImageSize = tileImage->logicalSize(); | 112 const IntSize tileImageSize = tileImage->size(); |
| 113 patternData->transform.translate(tileBoundaries.x(), tileBoundaries.y()); | 113 patternData->transform.translate(tileBoundaries.x(), tileBoundaries.y()); |
| 114 patternData->transform.scale(tileBoundaries.width() / tileImageSize.width(),
tileBoundaries.height() / tileImageSize.height()); | 114 patternData->transform.scale(tileBoundaries.width() / tileImageSize.width(),
tileBoundaries.height() / tileImageSize.height()); |
| 115 | 115 |
| 116 AffineTransform patternTransform = m_attributes.patternTransform(); | 116 AffineTransform patternTransform = m_attributes.patternTransform(); |
| 117 if (!patternTransform.isIdentity()) | 117 if (!patternTransform.isIdentity()) |
| 118 patternData->transform = patternTransform * patternData->transform; | 118 patternData->transform = patternTransform * patternData->transform; |
| 119 | 119 |
| 120 // Account for text drawing resetting the context to non-scaled, see SVGInli
neTextBox::paintTextWithShadows. | 120 // Account for text drawing resetting the context to non-scaled, see SVGInli
neTextBox::paintTextWithShadows. |
| 121 if (resourceMode & ApplyToTextMode) { | 121 if (resourceMode & ApplyToTextMode) { |
| 122 AffineTransform additionalTextTransformation; | 122 AffineTransform additionalTextTransformation; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 } | 233 } |
| 234 | 234 |
| 235 PassOwnPtr<ImageBuffer> RenderSVGResourcePattern::createTileImage(const PatternA
ttributes& attributes, | 235 PassOwnPtr<ImageBuffer> RenderSVGResourcePattern::createTileImage(const PatternA
ttributes& attributes, |
| 236 const FloatRec
t& tileBoundaries, | 236 const FloatRec
t& tileBoundaries, |
| 237 const FloatRec
t& absoluteTileBoundaries, | 237 const FloatRec
t& absoluteTileBoundaries, |
| 238 const AffineTr
ansform& tileImageTransform, | 238 const AffineTr
ansform& tileImageTransform, |
| 239 FloatRect& cla
mpedAbsoluteTileBoundaries) const | 239 FloatRect& cla
mpedAbsoluteTileBoundaries) const |
| 240 { | 240 { |
| 241 clampedAbsoluteTileBoundaries = SVGRenderingContext::clampedAbsoluteTargetRe
ct(absoluteTileBoundaries); | 241 clampedAbsoluteTileBoundaries = SVGRenderingContext::clampedAbsoluteTargetRe
ct(absoluteTileBoundaries); |
| 242 | 242 |
| 243 OwnPtr<ImageBuffer> tileImage = ImageBuffer::createBufferForTile(absoluteTil
eBoundaries.size(), clampedAbsoluteTileBoundaries.size(), Unaccelerated); | 243 IntSize imageSize(roundedIntSize(clampedAbsoluteTileBoundaries.size())); |
| 244 if (imageSize.isEmpty()) |
| 245 return nullptr; |
| 246 OwnPtr<ImageBuffer> tileImage = ImageBuffer::create(imageSize); |
| 244 if (!tileImage) | 247 if (!tileImage) |
| 245 return nullptr; | 248 return nullptr; |
| 246 | 249 |
| 247 GraphicsContext* tileImageContext = tileImage->context(); | 250 GraphicsContext* tileImageContext = tileImage->context(); |
| 248 ASSERT(tileImageContext); | 251 ASSERT(tileImageContext); |
| 252 IntSize unclampedImageSize(roundedIntSize(absoluteTileBoundaries.size())); |
| 253 tileImageContext->scale(FloatSize(unclampedImageSize.width() / absoluteTileB
oundaries.width(), unclampedImageSize.height() / absoluteTileBoundaries.height()
)); |
| 249 | 254 |
| 250 // The image buffer represents the final rendered size, so the content has t
o be scaled (to avoid pixelation). | 255 // The image buffer represents the final rendered size, so the content has t
o be scaled (to avoid pixelation). |
| 251 tileImageContext->scale(FloatSize(clampedAbsoluteTileBoundaries.width() / ti
leBoundaries.width(), | 256 tileImageContext->scale(FloatSize(clampedAbsoluteTileBoundaries.width() / ti
leBoundaries.width(), |
| 252 clampedAbsoluteTileBoundaries.height() / t
ileBoundaries.height())); | 257 clampedAbsoluteTileBoundaries.height() / t
ileBoundaries.height())); |
| 253 | 258 |
| 254 // Apply tile image transformations. | 259 // Apply tile image transformations. |
| 255 if (!tileImageTransform.isIdentity()) | 260 if (!tileImageTransform.isIdentity()) |
| 256 tileImageContext->concatCTM(tileImageTransform); | 261 tileImageContext->concatCTM(tileImageTransform); |
| 257 | 262 |
| 258 AffineTransform contentTransformation; | 263 AffineTransform contentTransformation; |
| 259 if (attributes.patternContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBO
UNDINGBOX) | 264 if (attributes.patternContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBO
UNDINGBOX) |
| 260 contentTransformation = tileImageTransform; | 265 contentTransformation = tileImageTransform; |
| 261 | 266 |
| 262 // Draw the content into the ImageBuffer. | 267 // Draw the content into the ImageBuffer. |
| 263 for (Node* node = attributes.patternContentElement()->firstChild(); node; no
de = node->nextSibling()) { | 268 for (Node* node = attributes.patternContentElement()->firstChild(); node; no
de = node->nextSibling()) { |
| 264 if (!node->isSVGElement() || !node->renderer()) | 269 if (!node->isSVGElement() || !node->renderer()) |
| 265 continue; | 270 continue; |
| 266 if (node->renderer()->needsLayout()) | 271 if (node->renderer()->needsLayout()) |
| 267 return nullptr; | 272 return nullptr; |
| 268 SVGRenderingContext::renderSubtree(tileImage->context(), node->renderer(
), contentTransformation); | 273 SVGRenderingContext::renderSubtree(tileImage->context(), node->renderer(
), contentTransformation); |
| 269 } | 274 } |
| 270 | 275 |
| 271 return tileImage.release(); | 276 return tileImage.release(); |
| 272 } | 277 } |
| 273 | 278 |
| 274 } | 279 } |
| OLD | NEW |