| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> | 2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> |
| 3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> | 3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> |
| 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
| 5 * Copyright (C) 2009 Google, Inc. All rights reserved. | 5 * Copyright (C) 2009 Google, Inc. All rights reserved. |
| 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
| 7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 absoluteTransform = layerTransform->toAffineTransform() * absoluteTr
ansform; | 205 absoluteTransform = layerTransform->toAffineTransform() * absoluteTr
ansform; |
| 206 | 206 |
| 207 // We can stop at compositing layers, to match the backing resolution. | 207 // We can stop at compositing layers, to match the backing resolution. |
| 208 if (layer->isComposited()) | 208 if (layer->isComposited()) |
| 209 break; | 209 break; |
| 210 | 210 |
| 211 layer = layer->parent(); | 211 layer = layer->parent(); |
| 212 } | 212 } |
| 213 } | 213 } |
| 214 | 214 |
| 215 bool SVGRenderingContext::createImageBuffer(const FloatRect& targetRect, const A
ffineTransform& absoluteTransform, OwnPtr<ImageBuffer>& imageBuffer, ColorSpace
colorSpace, RenderingMode renderingMode) | 215 bool SVGRenderingContext::createImageBuffer(const FloatRect& targetRect, const A
ffineTransform& absoluteTransform, OwnPtr<ImageBuffer>& imageBuffer, RenderingMo
de renderingMode) |
| 216 { | 216 { |
| 217 IntRect paintRect = calculateImageBufferRect(targetRect, absoluteTransform); | 217 IntRect paintRect = calculateImageBufferRect(targetRect, absoluteTransform); |
| 218 // Don't create empty ImageBuffers. | 218 // Don't create empty ImageBuffers. |
| 219 if (paintRect.isEmpty()) | 219 if (paintRect.isEmpty()) |
| 220 return false; | 220 return false; |
| 221 | 221 |
| 222 IntSize clampedSize = clampedAbsoluteSize(paintRect.size()); | 222 IntSize clampedSize = clampedAbsoluteSize(paintRect.size()); |
| 223 OwnPtr<ImageBuffer> image = ImageBuffer::create(clampedSize, 1, colorSpace,
renderingMode); | 223 OwnPtr<ImageBuffer> image = ImageBuffer::create(clampedSize, 1, renderingMod
e); |
| 224 if (!image) | 224 if (!image) |
| 225 return false; | 225 return false; |
| 226 | 226 |
| 227 GraphicsContext* imageContext = image->context(); | 227 GraphicsContext* imageContext = image->context(); |
| 228 ASSERT(imageContext); | 228 ASSERT(imageContext); |
| 229 | 229 |
| 230 imageContext->scale(FloatSize(static_cast<float>(clampedSize.width()) / pain
tRect.width(), | 230 imageContext->scale(FloatSize(static_cast<float>(clampedSize.width()) / pain
tRect.width(), |
| 231 static_cast<float>(clampedSize.height()) / pai
ntRect.height())); | 231 static_cast<float>(clampedSize.height()) / pai
ntRect.height())); |
| 232 imageContext->translate(-paintRect.x(), -paintRect.y()); | 232 imageContext->translate(-paintRect.x(), -paintRect.y()); |
| 233 imageContext->concatCTM(absoluteTransform); | 233 imageContext->concatCTM(absoluteTransform); |
| 234 | 234 |
| 235 imageBuffer = image.release(); | 235 imageBuffer = image.release(); |
| 236 return true; | 236 return true; |
| 237 } | 237 } |
| 238 | 238 |
| 239 bool SVGRenderingContext::createImageBufferForPattern(const FloatRect& absoluteT
argetRect, const FloatRect& clampedAbsoluteTargetRect, OwnPtr<ImageBuffer>& imag
eBuffer, ColorSpace colorSpace, RenderingMode renderingMode) | 239 bool SVGRenderingContext::createImageBufferForPattern(const FloatRect& absoluteT
argetRect, const FloatRect& clampedAbsoluteTargetRect, OwnPtr<ImageBuffer>& imag
eBuffer, RenderingMode renderingMode) |
| 240 { | 240 { |
| 241 IntSize imageSize(roundedIntSize(clampedAbsoluteTargetRect.size())); | 241 IntSize imageSize(roundedIntSize(clampedAbsoluteTargetRect.size())); |
| 242 IntSize unclampedImageSize(roundedIntSize(absoluteTargetRect.size())); | 242 IntSize unclampedImageSize(roundedIntSize(absoluteTargetRect.size())); |
| 243 | 243 |
| 244 // Don't create empty ImageBuffers. | 244 // Don't create empty ImageBuffers. |
| 245 if (imageSize.isEmpty()) | 245 if (imageSize.isEmpty()) |
| 246 return false; | 246 return false; |
| 247 | 247 |
| 248 OwnPtr<ImageBuffer> image = ImageBuffer::create(imageSize, 1, colorSpace, re
nderingMode); | 248 OwnPtr<ImageBuffer> image = ImageBuffer::create(imageSize, 1, renderingMode)
; |
| 249 if (!image) | 249 if (!image) |
| 250 return false; | 250 return false; |
| 251 | 251 |
| 252 GraphicsContext* imageContext = image->context(); | 252 GraphicsContext* imageContext = image->context(); |
| 253 ASSERT(imageContext); | 253 ASSERT(imageContext); |
| 254 | 254 |
| 255 // Compensate rounding effects, as the absolute target rect is using floatin
g-point numbers and the image buffer size is integer. | 255 // Compensate rounding effects, as the absolute target rect is using floatin
g-point numbers and the image buffer size is integer. |
| 256 imageContext->scale(FloatSize(unclampedImageSize.width() / absoluteTargetRec
t.width(), unclampedImageSize.height() / absoluteTargetRect.height())); | 256 imageContext->scale(FloatSize(unclampedImageSize.width() / absoluteTargetRec
t.width(), unclampedImageSize.height() / absoluteTargetRect.height())); |
| 257 | 257 |
| 258 imageBuffer = image.release(); | 258 imageBuffer = image.release(); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 if ((imageBuffer = m_paintInfo->context->createCompatibleBuffer(expanded
IntSize(boundingBox.size()), true))) { | 336 if ((imageBuffer = m_paintInfo->context->createCompatibleBuffer(expanded
IntSize(boundingBox.size()), true))) { |
| 337 GraphicsContext* bufferedRenderingContext = imageBuffer->context(); | 337 GraphicsContext* bufferedRenderingContext = imageBuffer->context(); |
| 338 bufferedRenderingContext->translate(-boundingBox.x(), -boundingBox.y
()); | 338 bufferedRenderingContext->translate(-boundingBox.x(), -boundingBox.y
()); |
| 339 PaintInfo bufferedInfo(*m_paintInfo); | 339 PaintInfo bufferedInfo(*m_paintInfo); |
| 340 bufferedInfo.context = bufferedRenderingContext; | 340 bufferedInfo.context = bufferedRenderingContext; |
| 341 toRenderSVGImage(m_object)->paintForeground(bufferedInfo); | 341 toRenderSVGImage(m_object)->paintForeground(bufferedInfo); |
| 342 } else | 342 } else |
| 343 return false; | 343 return false; |
| 344 } | 344 } |
| 345 | 345 |
| 346 m_paintInfo->context->drawImageBuffer(imageBuffer.get(), ColorSpaceDeviceRGB
, boundingBox); | 346 m_paintInfo->context->drawImageBuffer(imageBuffer.get(), boundingBox); |
| 347 return true; | 347 return true; |
| 348 } | 348 } |
| 349 | 349 |
| 350 } | 350 } |
| OLD | NEW |