| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/paint/SVGImagePainter.h" | 5 #include "core/paint/SVGImagePainter.h" |
| 6 | 6 |
| 7 #include "core/layout/ImageQualityController.h" | 7 #include "core/layout/ImageQualityController.h" |
| 8 #include "core/layout/LayoutImageResource.h" | 8 #include "core/layout/LayoutImageResource.h" |
| 9 #include "core/layout/svg/LayoutSVGImage.h" | 9 #include "core/layout/svg/LayoutSVGImage.h" |
| 10 #include "core/paint/LayoutObjectDrawingRecorder.h" | 10 #include "core/paint/LayoutObjectDrawingRecorder.h" |
| 11 #include "core/paint/ObjectPainter.h" | 11 #include "core/paint/ObjectPainter.h" |
| 12 #include "core/paint/PaintInfo.h" | 12 #include "core/paint/PaintInfo.h" |
| 13 #include "core/paint/SVGPaintContext.h" | 13 #include "core/paint/SVGPaintContext.h" |
| 14 #include "core/paint/TransformRecorder.h" | |
| 15 #include "core/svg/SVGImageElement.h" | 14 #include "core/svg/SVGImageElement.h" |
| 16 #include "core/svg/graphics/SVGImage.h" | 15 #include "core/svg/graphics/SVGImage.h" |
| 17 #include "platform/graphics/GraphicsContext.h" | 16 #include "platform/graphics/GraphicsContext.h" |
| 18 #include "third_party/skia/include/core/SkPicture.h" | 17 #include "third_party/skia/include/core/SkPicture.h" |
| 19 | 18 |
| 20 namespace blink { | 19 namespace blink { |
| 21 | 20 |
| 22 void SVGImagePainter::paint(const PaintInfo& paintInfo) | 21 void SVGImagePainter::paint(const PaintInfo& paintInfo) |
| 23 { | 22 { |
| 24 if (paintInfo.phase != PaintPhaseForeground | 23 if (paintInfo.phase != PaintPhaseForeground |
| 25 || m_layoutSVGImage.style()->visibility() != VISIBLE | 24 || m_layoutSVGImage.style()->visibility() != VISIBLE |
| 26 || !m_layoutSVGImage.imageResource()->hasImage()) | 25 || !m_layoutSVGImage.imageResource()->hasImage()) |
| 27 return; | 26 return; |
| 28 | 27 |
| 29 FloatRect boundingBox = m_layoutSVGImage.paintInvalidationRectInLocalSVGCoor
dinates(); | 28 FloatRect boundingBox = m_layoutSVGImage.paintInvalidationRectInLocalSVGCoor
dinates(); |
| 30 if (!paintInfo.cullRect().intersectsCullRect(m_layoutSVGImage.localToSVGPare
ntTransform(), boundingBox)) | 29 if (!paintInfo.cullRect().intersectsCullRect(m_layoutSVGImage.localToSVGPare
ntTransform(), boundingBox)) |
| 31 return; | 30 return; |
| 32 | 31 |
| 33 PaintInfo paintInfoBeforeFiltering(paintInfo); | 32 PaintInfo paintInfoBeforeFiltering(paintInfo); |
| 34 // Images cannot have children so do not call updateCullRect. | 33 // Images cannot have children so do not call updateCullRect. |
| 35 TransformRecorder transformRecorder(paintInfoBeforeFiltering.context, m_layo
utSVGImage, m_layoutSVGImage.localToSVGParentTransform()); | 34 SVGTransformContext transformContext(paintInfoBeforeFiltering.context, m_lay
outSVGImage, m_layoutSVGImage.localToSVGParentTransform()); |
| 36 { | 35 { |
| 37 SVGPaintContext paintContext(m_layoutSVGImage, paintInfoBeforeFiltering)
; | 36 SVGPaintContext paintContext(m_layoutSVGImage, paintInfoBeforeFiltering)
; |
| 38 if (paintContext.applyClipMaskAndFilterIfNecessary() && !LayoutObjectDra
wingRecorder::useCachedDrawingIfPossible(paintContext.paintInfo().context, m_lay
outSVGImage, paintContext.paintInfo().phase)) { | 37 if (paintContext.applyClipMaskAndFilterIfNecessary() && !LayoutObjectDra
wingRecorder::useCachedDrawingIfPossible(paintContext.paintInfo().context, m_lay
outSVGImage, paintContext.paintInfo().phase)) { |
| 39 LayoutObjectDrawingRecorder recorder(paintContext.paintInfo().contex
t, m_layoutSVGImage, paintContext.paintInfo().phase, boundingBox); | 38 LayoutObjectDrawingRecorder recorder(paintContext.paintInfo().contex
t, m_layoutSVGImage, paintContext.paintInfo().phase, boundingBox); |
| 40 paintForeground(paintContext.paintInfo()); | 39 paintForeground(paintContext.paintInfo()); |
| 41 } | 40 } |
| 42 } | 41 } |
| 43 | 42 |
| 44 if (m_layoutSVGImage.style()->outlineWidth()) { | 43 if (m_layoutSVGImage.style()->outlineWidth()) { |
| 45 PaintInfo outlinePaintInfo(paintInfoBeforeFiltering); | 44 PaintInfo outlinePaintInfo(paintInfoBeforeFiltering); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 if (cachedImage->errorOccurred()) | 89 if (cachedImage->errorOccurred()) |
| 91 return FloatSize(); | 90 return FloatSize(); |
| 92 | 91 |
| 93 if (cachedImage->getImage()->isSVGImage()) | 92 if (cachedImage->getImage()->isSVGImage()) |
| 94 return toSVGImage(cachedImage->getImage())->concreteObjectSize(m_layoutS
VGImage.objectBoundingBox().size()); | 93 return toSVGImage(cachedImage->getImage())->concreteObjectSize(m_layoutS
VGImage.objectBoundingBox().size()); |
| 95 | 94 |
| 96 return FloatSize(cachedImage->getImage()->size()); | 95 return FloatSize(cachedImage->getImage()->size()); |
| 97 } | 96 } |
| 98 | 97 |
| 99 } // namespace blink | 98 } // namespace blink |
| OLD | NEW |