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 "core/paint/NinePieceImagePainter.h" | 5 #include "core/paint/NinePieceImagePainter.h" |
6 | 6 |
7 #include "core/layout/ImageQualityController.h" | 7 #include "core/layout/ImageQualityController.h" |
8 #include "core/layout/LayoutBoxModelObject.h" | 8 #include "core/layout/LayoutBoxModelObject.h" |
9 #include "core/paint/BoxPainter.h" | 9 #include "core/paint/BoxPainter.h" |
10 #include "core/paint/NinePieceImageGrid.h" | 10 #include "core/paint/NinePieceImageGrid.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 return false; | 35 return false; |
36 | 36 |
37 // FIXME: border-image is broken with full page zooming when tiling has to h
appen, since the tiling function | 37 // FIXME: border-image is broken with full page zooming when tiling has to h
appen, since the tiling function |
38 // doesn't have any understanding of the zoom that is in effect on the tile. | 38 // doesn't have any understanding of the zoom that is in effect on the tile. |
39 LayoutRect rectWithOutsets = rect; | 39 LayoutRect rectWithOutsets = rect; |
40 rectWithOutsets.expand(style.imageOutsets(ninePieceImage)); | 40 rectWithOutsets.expand(style.imageOutsets(ninePieceImage)); |
41 LayoutRect borderImageRect = rectWithOutsets; | 41 LayoutRect borderImageRect = rectWithOutsets; |
42 | 42 |
43 // NinePieceImage returns the image slices without effective zoom applied an
d thus we compute | 43 // NinePieceImage returns the image slices without effective zoom applied an
d thus we compute |
44 // the nine piece grid on top of the image in unzoomed coordinates. | 44 // the nine piece grid on top of the image in unzoomed coordinates. |
45 LayoutSize defaultObjectSize = borderImageRect.size(); | 45 // |
46 defaultObjectSize.scale(1 / style.effectiveZoom()); | 46 // FIXME: The default object size passed to imageSize() should be scaled by
the zoom factor |
47 IntSize imageSize = roundedIntSize(styleImage->imageSize(m_layoutObject, 1,
defaultObjectSize)); | 47 // passed in. In this case it means that borderImageRect should be passed in
compensated by |
| 48 // effective zoom, since the scale factor is one. For generated images, the
actual image data |
| 49 // (gradient stops, etc.) are scaled to effective zoom instead so we must ta
ke care not to cause |
| 50 // scale of them again. |
| 51 IntSize imageSize = roundedIntSize(styleImage->imageSize(m_layoutObject, 1,
borderImageRect.size())); |
48 | 52 |
49 IntRectOutsets borderWidths(style.borderTopWidth(), style.borderRightWidth()
, | 53 IntRectOutsets borderWidths(style.borderTopWidth(), style.borderRightWidth()
, |
50 style.borderBottomWidth(), style.borderLeftWidth()); | 54 style.borderBottomWidth(), style.borderLeftWidth()); |
51 NinePieceImageGrid grid(ninePieceImage, imageSize, pixelSnappedIntRect(borde
rImageRect), borderWidths); | 55 NinePieceImageGrid grid(ninePieceImage, imageSize, pixelSnappedIntRect(borde
rImageRect), borderWidths); |
52 | 56 |
53 RefPtr<Image> image = styleImage->image(m_layoutObject, imageSize, 1); | 57 RefPtr<Image> image = styleImage->image(m_layoutObject, imageSize, style.eff
ectiveZoom()); |
54 | 58 |
55 InterpolationQuality interpolationQuality = BoxPainter::chooseInterpolationQ
uality(m_layoutObject, image.get(), 0, rectWithOutsets.size()); | 59 InterpolationQuality interpolationQuality = BoxPainter::chooseInterpolationQ
uality(m_layoutObject, image.get(), 0, rectWithOutsets.size()); |
56 InterpolationQuality previousInterpolationQuality = graphicsContext.imageInt
erpolationQuality(); | 60 InterpolationQuality previousInterpolationQuality = graphicsContext.imageInt
erpolationQuality(); |
57 graphicsContext.setImageInterpolationQuality(interpolationQuality); | 61 graphicsContext.setImageInterpolationQuality(interpolationQuality); |
58 | 62 |
59 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", "
data", | 63 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", "
data", |
60 InspectorPaintImageEvent::data(m_layoutObject, *styleImage)); | 64 InspectorPaintImageEvent::data(m_layoutObject, *styleImage)); |
61 | 65 |
62 for (NinePiece piece = MinPiece; piece < MaxPiece; ++piece) { | 66 for (NinePiece piece = MinPiece; piece < MaxPiece; ++piece) { |
63 NinePieceImageGrid::NinePieceDrawInfo drawInfo = grid.getNinePieceDrawIn
fo(piece, styleImage->imageScaleFactor()); | 67 NinePieceImageGrid::NinePieceDrawInfo drawInfo = grid.getNinePieceDrawIn
fo(piece, styleImage->imageScaleFactor()); |
64 | 68 |
65 if (drawInfo.isDrawable) { | 69 if (drawInfo.isDrawable) { |
66 if (drawInfo.isCornerPiece) { | 70 if (drawInfo.isCornerPiece) { |
67 graphicsContext.drawImage(image.get(), drawInfo.destination, dra
wInfo.source, op); | 71 graphicsContext.drawImage(image.get(), drawInfo.destination, dra
wInfo.source, op); |
68 } else { | 72 } else { |
69 graphicsContext.drawTiledImage(image.get(), drawInfo.destination
, | 73 graphicsContext.drawTiledImage(image.get(), drawInfo.destination
, |
70 drawInfo.source, drawInfo.tileScale, drawInfo.tileRule.horiz
ontal, | 74 drawInfo.source, drawInfo.tileScale, drawInfo.tileRule.horiz
ontal, |
71 drawInfo.tileRule.vertical, op); | 75 drawInfo.tileRule.vertical, op); |
72 } | 76 } |
73 } | 77 } |
74 } | 78 } |
75 | 79 |
76 graphicsContext.setImageInterpolationQuality(previousInterpolationQuality); | 80 graphicsContext.setImageInterpolationQuality(previousInterpolationQuality); |
77 return true; | 81 return true; |
78 } | 82 } |
79 | 83 |
80 } // namespace blink | 84 } // namespace blink |
OLD | NEW |