OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "config.h" | 5 #include "config.h" |
6 #include "core/paint/NinePieceImagePainter.h" | 6 #include "core/paint/NinePieceImagePainter.h" |
7 | 7 |
8 #include "core/frame/UseCounter.h" | 8 #include "core/frame/UseCounter.h" |
9 #include "core/layout/ImageQualityController.h" | 9 #include "core/layout/ImageQualityController.h" |
10 #include "core/layout/LayoutBoxModelObject.h" | 10 #include "core/layout/LayoutBoxModelObject.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 // FIXME: border-image is broken with full page zooming when tiling has to h
appen, since the tiling function | 47 // FIXME: border-image is broken with full page zooming when tiling has to h
appen, since the tiling function |
48 // doesn't have any understanding of the zoom that is in effect on the tile. | 48 // doesn't have any understanding of the zoom that is in effect on the tile. |
49 LayoutRect rectWithOutsets = rect; | 49 LayoutRect rectWithOutsets = rect; |
50 rectWithOutsets.expand(style.imageOutsets(ninePieceImage)); | 50 rectWithOutsets.expand(style.imageOutsets(ninePieceImage)); |
51 IntRect borderImageRect = pixelSnappedIntRect(rectWithOutsets); | 51 IntRect borderImageRect = pixelSnappedIntRect(rectWithOutsets); |
52 | 52 |
53 IntSize imageSize = m_layoutObject.calculateImageIntrinsicDimensions(styleIm
age, borderImageRect.size(), | 53 IntSize imageSize = m_layoutObject.calculateImageIntrinsicDimensions(styleIm
age, borderImageRect.size(), |
54 LayoutBoxModelObject::DoNotScaleByEffectiveZoom); | 54 LayoutBoxModelObject::DoNotScaleByEffectiveZoom); |
55 | 55 |
56 // If both values are 'auto' then the intrinsic width and/or height of the i
mage should be used, if any. | |
57 styleImage->setContainerSizeForLayoutObject(&m_layoutObject, imageSize, styl
e.effectiveZoom()); | |
58 | |
59 IntRectOutsets borderWidths(style.borderTopWidth(), style.borderRightWidth()
, | 56 IntRectOutsets borderWidths(style.borderTopWidth(), style.borderRightWidth()
, |
60 style.borderBottomWidth(), style.borderLeftWidth()); | 57 style.borderBottomWidth(), style.borderLeftWidth()); |
61 NinePieceImageGrid grid(ninePieceImage, imageSize, borderImageRect, borderWi
dths); | 58 NinePieceImageGrid grid(ninePieceImage, imageSize, borderImageRect, borderWi
dths); |
62 | 59 |
63 RefPtr<Image> image = styleImage->image(&m_layoutObject, imageSize); | 60 RefPtr<Image> image = styleImage->image(&m_layoutObject, imageSize, style.ef
fectiveZoom()); |
64 | 61 |
65 InterpolationQuality interpolationQuality = BoxPainter::chooseInterpolationQ
uality(m_layoutObject, | 62 InterpolationQuality interpolationQuality = BoxPainter::chooseInterpolationQ
uality(m_layoutObject, |
66 graphicsContext, image.get(), 0, rectWithOutsets.size()); | 63 graphicsContext, image.get(), 0, rectWithOutsets.size()); |
67 InterpolationQuality previousInterpolationQuality = graphicsContext->imageIn
terpolationQuality(); | 64 InterpolationQuality previousInterpolationQuality = graphicsContext->imageIn
terpolationQuality(); |
68 graphicsContext->setImageInterpolationQuality(interpolationQuality); | 65 graphicsContext->setImageInterpolationQuality(interpolationQuality); |
69 | 66 |
70 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", "
data", | 67 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", "
data", |
71 InspectorPaintImageEvent::data(m_layoutObject, *styleImage)); | 68 InspectorPaintImageEvent::data(m_layoutObject, *styleImage)); |
72 | 69 |
73 for (NinePiece piece = MinPiece; piece < MaxPiece; ++piece) { | 70 for (NinePiece piece = MinPiece; piece < MaxPiece; ++piece) { |
74 NinePieceImageGrid::NinePieceDrawInfo drawInfo = grid.getNinePieceDrawIn
fo(piece); | 71 NinePieceImageGrid::NinePieceDrawInfo drawInfo = grid.getNinePieceDrawIn
fo(piece); |
75 | 72 |
76 if (drawInfo.isDrawable) { | 73 if (drawInfo.isDrawable) { |
77 if (drawInfo.isCornerPiece) { | 74 if (drawInfo.isCornerPiece) { |
78 graphicsContext->drawImage(image.get(), drawInfo.destination, dr
awInfo.source, op); | 75 graphicsContext->drawImage(image.get(), drawInfo.destination, dr
awInfo.source, op); |
79 } else { | 76 } else { |
80 graphicsContext->drawTiledImage(image.get(), enclosingIntRect(dr
awInfo.destination), | 77 graphicsContext->drawTiledImage(image.get(), enclosingIntRect(dr
awInfo.destination), |
81 enclosingIntRect(drawInfo.source), drawInfo.tileScale, drawI
nfo.tileRule.horizontal, | 78 enclosingIntRect(drawInfo.source), drawInfo.tileScale, drawI
nfo.tileRule.horizontal, |
82 drawInfo.tileRule.vertical, op); | 79 drawInfo.tileRule.vertical, op); |
83 } | 80 } |
84 } | 81 } |
85 } | 82 } |
86 | 83 |
87 graphicsContext->setImageInterpolationQuality(previousInterpolationQuality); | 84 graphicsContext->setImageInterpolationQuality(previousInterpolationQuality); |
88 return true; | 85 return true; |
89 } | 86 } |
90 | 87 |
91 } // namespace blink | 88 } // namespace blink |
OLD | NEW |