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