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/layout/svg/SVGLayoutSupport.h" | 10 #include "core/layout/svg/SVGLayoutSupport.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 void SVGImagePainter::paintForeground(const PaintInfo& paintInfo) | 51 void SVGImagePainter::paintForeground(const PaintInfo& paintInfo) |
52 { | 52 { |
53 const LayoutImageResource* imageResource = m_layoutSVGImage.imageResource(); | 53 const LayoutImageResource* imageResource = m_layoutSVGImage.imageResource(); |
54 IntSize imageViewportSize = expandedIntSize(computeImageViewportSize()); | 54 IntSize imageViewportSize = expandedIntSize(computeImageViewportSize()); |
55 if (imageViewportSize.isEmpty()) | 55 if (imageViewportSize.isEmpty()) |
56 return; | 56 return; |
57 | 57 |
58 RefPtr<Image> image = imageResource->image(imageViewportSize, m_layoutSVGIma
ge.style()->effectiveZoom()); | 58 RefPtr<Image> image = imageResource->image(imageViewportSize, m_layoutSVGIma
ge.style()->effectiveZoom()); |
59 FloatRect destRect = m_layoutSVGImage.objectBoundingBox(); | 59 FloatRect destRect = m_layoutSVGImage.objectBoundingBox(); |
60 FloatRect srcRect(0, 0, image->width(), image->height()); | 60 FloatRect srcRect(0, 0, image->defaultConcreteObjectSizeWidth(), image->defa
ultConcreteObjectSizeHeight()); |
61 | 61 |
62 SVGImageElement* imageElement = toSVGImageElement(m_layoutSVGImage.element()
); | 62 SVGImageElement* imageElement = toSVGImageElement(m_layoutSVGImage.element()
); |
63 imageElement->preserveAspectRatio()->currentValue()->transformRect(destRect,
srcRect); | 63 imageElement->preserveAspectRatio()->currentValue()->transformRect(destRect,
srcRect); |
64 | 64 |
65 InterpolationQuality interpolationQuality = InterpolationDefault; | 65 InterpolationQuality interpolationQuality = InterpolationDefault; |
66 interpolationQuality = ImageQualityController::imageQualityController()->cho
oseInterpolationQuality(m_layoutSVGImage, image.get(), image.get(), LayoutSize(d
estRect.size())); | 66 interpolationQuality = ImageQualityController::imageQualityController()->cho
oseInterpolationQuality(m_layoutSVGImage, image.get(), image.get(), LayoutSize(d
estRect.size())); |
67 | 67 |
68 InterpolationQuality previousInterpolationQuality = paintInfo.context.imageI
nterpolationQuality(); | 68 InterpolationQuality previousInterpolationQuality = paintInfo.context.imageI
nterpolationQuality(); |
69 paintInfo.context.setImageInterpolationQuality(interpolationQuality); | 69 paintInfo.context.setImageInterpolationQuality(interpolationQuality); |
70 paintInfo.context.drawImage(image.get(), destRect, srcRect, SkXfermode::kSrc
Over_Mode); | 70 paintInfo.context.drawImage(image.get(), destRect, srcRect, SkXfermode::kSrc
Over_Mode); |
(...skipping 13 matching lines...) Expand all Loading... |
84 // scaling. This can be achieved by setting the image's container size to | 84 // scaling. This can be achieved by setting the image's container size to |
85 // its viewport size (i.e. if a viewBox is available - use that - else use i
ntrinsic size.) | 85 // its viewport size (i.e. if a viewBox is available - use that - else use i
ntrinsic size.) |
86 // See: http://www.w3.org/TR/SVG/single-page.html, 7.8 The 'preserveAspectRa
tio' attribute. | 86 // See: http://www.w3.org/TR/SVG/single-page.html, 7.8 The 'preserveAspectRa
tio' attribute. |
87 FloatSize intrinsicSize; | 87 FloatSize intrinsicSize; |
88 FloatSize intrinsicRatio; | 88 FloatSize intrinsicRatio; |
89 cachedImage->computeIntrinsicDimensions(intrinsicSize, intrinsicRatio); | 89 cachedImage->computeIntrinsicDimensions(intrinsicSize, intrinsicRatio); |
90 return intrinsicRatio; | 90 return intrinsicRatio; |
91 } | 91 } |
92 | 92 |
93 } // namespace blink | 93 } // namespace blink |
OLD | NEW |