| 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" |
| 11 #include "core/paint/NinePieceImageGrid.h" | 11 #include "core/paint/NinePieceImageGrid.h" |
| 12 #include "core/style/ComputedStyle.h" | 12 #include "core/style/ComputedStyle.h" |
| 13 #include "core/style/NinePieceImage.h" | 13 #include "core/style/NinePieceImage.h" |
| 14 #include "core/svg/graphics/SVGImageForContainer.h" |
| 14 #include "platform/geometry/IntSize.h" | 15 #include "platform/geometry/IntSize.h" |
| 15 #include "platform/geometry/LayoutRect.h" | 16 #include "platform/geometry/LayoutRect.h" |
| 16 #include "platform/graphics/GraphicsContext.h" | 17 #include "platform/graphics/GraphicsContext.h" |
| 17 | 18 |
| 18 namespace blink { | 19 namespace blink { |
| 19 | 20 |
| 20 NinePieceImagePainter::NinePieceImagePainter(const LayoutBoxModelObject& layoutO
bject) | 21 NinePieceImagePainter::NinePieceImagePainter(const LayoutBoxModelObject& layoutO
bject) |
| 21 : m_layoutObject(layoutObject) | 22 : m_layoutObject(layoutObject) |
| 22 { | 23 { |
| 23 } | 24 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 37 | 38 |
| 38 // FIXME: border-image is broken with full page zooming when tiling has to h
appen, since the tiling function | 39 // 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. | 40 // doesn't have any understanding of the zoom that is in effect on the tile. |
| 40 LayoutRect rectWithOutsets = rect; | 41 LayoutRect rectWithOutsets = rect; |
| 41 rectWithOutsets.expand(style.imageOutsets(ninePieceImage)); | 42 rectWithOutsets.expand(style.imageOutsets(ninePieceImage)); |
| 42 IntRect borderImageRect = pixelSnappedIntRect(rectWithOutsets); | 43 IntRect borderImageRect = pixelSnappedIntRect(rectWithOutsets); |
| 43 | 44 |
| 44 IntSize imageSize = m_layoutObject.calculateImageIntrinsicDimensions(styleIm
age, borderImageRect.size(), | 45 IntSize imageSize = m_layoutObject.calculateImageIntrinsicDimensions(styleIm
age, borderImageRect.size(), |
| 45 LayoutBoxModelObject::DoNotScaleByEffectiveZoom); | 46 LayoutBoxModelObject::DoNotScaleByEffectiveZoom); |
| 46 | 47 |
| 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()
, | 48 IntRectOutsets borderWidths(style.borderTopWidth(), style.borderRightWidth()
, |
| 51 style.borderBottomWidth(), style.borderLeftWidth()); | 49 style.borderBottomWidth(), style.borderLeftWidth()); |
| 52 NinePieceImageGrid grid(ninePieceImage, imageSize, borderImageRect, borderWi
dths); | 50 NinePieceImageGrid grid(ninePieceImage, imageSize, borderImageRect, borderWi
dths); |
| 53 | 51 |
| 54 RefPtr<Image> image = styleImage->image(&m_layoutObject, imageSize); | 52 RefPtr<Image> image = styleImage->image(&m_layoutObject, imageSize, style.ef
fectiveZoom(), styleImage->url()); |
| 55 | 53 |
| 56 InterpolationQuality interpolationQuality = BoxPainter::chooseInterpolationQ
uality(m_layoutObject, | 54 InterpolationQuality interpolationQuality = BoxPainter::chooseInterpolationQ
uality(m_layoutObject, |
| 57 graphicsContext, image.get(), 0, rectWithOutsets.size()); | 55 graphicsContext, image.get(), 0, rectWithOutsets.size()); |
| 58 InterpolationQuality previousInterpolationQuality = graphicsContext->imageIn
terpolationQuality(); | 56 InterpolationQuality previousInterpolationQuality = graphicsContext->imageIn
terpolationQuality(); |
| 59 graphicsContext->setImageInterpolationQuality(interpolationQuality); | 57 graphicsContext->setImageInterpolationQuality(interpolationQuality); |
| 60 | 58 |
| 61 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", "
data", | 59 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", "
data", |
| 62 InspectorPaintImageEvent::data(m_layoutObject, *styleImage)); | 60 InspectorPaintImageEvent::data(m_layoutObject, *styleImage)); |
| 63 | 61 |
| 64 for (NinePiece piece = MinPiece; piece < MaxPiece; ++piece) { | 62 for (NinePiece piece = MinPiece; piece < MaxPiece; ++piece) { |
| 65 NinePieceImageGrid::NinePieceDrawInfo drawInfo = grid.getNinePieceDrawIn
fo(piece); | 63 NinePieceImageGrid::NinePieceDrawInfo drawInfo = grid.getNinePieceDrawIn
fo(piece); |
| 66 | 64 |
| 67 if (drawInfo.isDrawable) { | 65 if (drawInfo.isDrawable) { |
| 68 if (drawInfo.isCornerPiece) { | 66 if (drawInfo.isCornerPiece) { |
| 69 graphicsContext->drawImage(image.get(), drawInfo.destination, dr
awInfo.source, op); | 67 graphicsContext->drawImage(image.get(), drawInfo.destination, dr
awInfo.source, op); |
| 70 } else { | 68 } else { |
| 71 graphicsContext->drawTiledImage(image.get(), enclosingIntRect(dr
awInfo.destination), | 69 graphicsContext->drawTiledImage(image.get(), enclosingIntRect(dr
awInfo.destination), |
| 72 enclosingIntRect(drawInfo.source), drawInfo.tileScale, drawI
nfo.tileRule.horizontal, | 70 enclosingIntRect(drawInfo.source), drawInfo.tileScale, drawI
nfo.tileRule.horizontal, |
| 73 drawInfo.tileRule.vertical, op); | 71 drawInfo.tileRule.vertical, op); |
| 74 } | 72 } |
| 75 } | 73 } |
| 76 } | 74 } |
| 77 | 75 |
| 78 graphicsContext->setImageInterpolationQuality(previousInterpolationQuality); | 76 graphicsContext->setImageInterpolationQuality(previousInterpolationQuality); |
| 79 return true; | 77 return true; |
| 80 } | 78 } |
| 81 | 79 |
| 82 } // namespace blink | 80 } // namespace blink |
| OLD | NEW |