| 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 |
| 11 * License as published by the Free Software Foundation; either | 11 * License as published by the Free Software Foundation; either |
| 12 * version 2 of the License, or (at your option) any later version. | 12 * version 2 of the License, or (at your option) any later version. |
| 13 * | 13 * |
| 14 * This library is distributed in the hope that it will be useful, | 14 * This library is distributed in the hope that it will be useful, |
| 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 * Library General Public License for more details. | 17 * Library General Public License for more details. |
| 18 * | 18 * |
| 19 * You should have received a copy of the GNU Library General Public License | 19 * You should have received a copy of the GNU Library General Public License |
| 20 * along with this library; see the file COPYING.LIB. If not, write to | 20 * along with this library; see the file COPYING.LIB. If not, write to |
| 21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 22 * Boston, MA 02110-1301, USA. | 22 * Boston, MA 02110-1301, USA. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "config.h" | 25 #include "config.h" |
| 26 | |
| 27 #include "core/rendering/svg/SVGRenderingContext.h" | 26 #include "core/rendering/svg/SVGRenderingContext.h" |
| 28 | 27 |
| 29 #include "core/frame/FrameHost.h" | 28 #include "core/frame/FrameHost.h" |
| 30 #include "core/paint/SVGImagePainter.h" | 29 #include "core/rendering/PaintInfo.h" |
| 31 #include "core/rendering/RenderLayer.h" | 30 #include "core/rendering/RenderLayer.h" |
| 32 #include "core/rendering/svg/RenderSVGImage.h" | |
| 33 #include "core/rendering/svg/RenderSVGResourceFilter.h" | 31 #include "core/rendering/svg/RenderSVGResourceFilter.h" |
| 34 #include "core/rendering/svg/RenderSVGResourceMasker.h" | 32 #include "core/rendering/svg/RenderSVGResourceMasker.h" |
| 35 #include "core/rendering/svg/SVGRenderSupport.h" | 33 #include "core/rendering/svg/SVGRenderSupport.h" |
| 36 #include "core/rendering/svg/SVGResources.h" | 34 #include "core/rendering/svg/SVGResources.h" |
| 37 #include "core/rendering/svg/SVGResourcesCache.h" | 35 #include "core/rendering/svg/SVGResourcesCache.h" |
| 38 #include "platform/FloatConversion.h" | 36 #include "platform/FloatConversion.h" |
| 39 | 37 |
| 40 namespace blink { | 38 namespace blink { |
| 41 | 39 |
| 42 SVGRenderingContext::~SVGRenderingContext() | 40 SVGRenderingContext::~SVGRenderingContext() |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 void SVGRenderingContext::renderSubtree(GraphicsContext* context, RenderObject*
item) | 236 void SVGRenderingContext::renderSubtree(GraphicsContext* context, RenderObject*
item) |
| 239 { | 237 { |
| 240 ASSERT(context); | 238 ASSERT(context); |
| 241 ASSERT(item); | 239 ASSERT(item); |
| 242 ASSERT(!item->needsLayout()); | 240 ASSERT(!item->needsLayout()); |
| 243 | 241 |
| 244 PaintInfo info(context, PaintInfo::infiniteRect(), PaintPhaseForeground, Pai
ntBehaviorNormal); | 242 PaintInfo info(context, PaintInfo::infiniteRect(), PaintPhaseForeground, Pai
ntBehaviorNormal); |
| 245 item->paint(info, IntPoint()); | 243 item->paint(info, IntPoint()); |
| 246 } | 244 } |
| 247 | 245 |
| 248 bool SVGRenderingContext::bufferForeground(OwnPtr<ImageBuffer>& imageBuffer) | |
| 249 { | |
| 250 ASSERT(m_paintInfo); | |
| 251 ASSERT(m_object->isSVGImage()); | |
| 252 FloatRect boundingBox = m_object->objectBoundingBox(); | |
| 253 | |
| 254 // Invalidate an existing buffer if the scale is not correct. | |
| 255 if (imageBuffer) { | |
| 256 AffineTransform transform = m_paintInfo->context->getCTM(); | |
| 257 IntSize expandedBoundingBox = expandedIntSize(boundingBox.size()); | |
| 258 IntSize bufferSize(static_cast<int>(ceil(expandedBoundingBox.width() * t
ransform.xScale())), static_cast<int>(ceil(expandedBoundingBox.height() * transf
orm.yScale()))); | |
| 259 if (bufferSize != imageBuffer->size()) | |
| 260 imageBuffer.clear(); | |
| 261 } | |
| 262 | |
| 263 // Create a new buffer and paint the foreground into it. | |
| 264 if (!imageBuffer) { | |
| 265 if ((imageBuffer = m_paintInfo->context->createRasterBuffer(expandedIntS
ize(boundingBox.size())))) { | |
| 266 GraphicsContext* bufferedRenderingContext = imageBuffer->context(); | |
| 267 bufferedRenderingContext->translate(-boundingBox.x(), -boundingBox.y
()); | |
| 268 PaintInfo bufferedInfo(*m_paintInfo); | |
| 269 bufferedInfo.context = bufferedRenderingContext; | |
| 270 SVGImagePainter::paintForeground(toRenderSVGImage(*m_object), buffer
edInfo); | |
| 271 } else | |
| 272 return false; | |
| 273 } | |
| 274 | |
| 275 m_paintInfo->context->drawImageBuffer(imageBuffer.get(), boundingBox); | |
| 276 return true; | |
| 277 } | |
| 278 | |
| 279 } // namespace blink | 246 } // namespace blink |
| OLD | NEW |