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