| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 || (style.borderTopWidth() && (style.borderTop().style() == BorderStyleN
one || style.borderTop().style() == BorderStyleHidden)) | 42 || (style.borderTopWidth() && (style.borderTop().style() == BorderStyleN
one || style.borderTop().style() == BorderStyleHidden)) |
| 43 || (style.borderBottomWidth() && (style.borderBottom().style() == Border
StyleNone || style.borderBottom().style() == BorderStyleHidden))) | 43 || (style.borderBottomWidth() && (style.borderBottom().style() == Border
StyleNone || style.borderBottom().style() == BorderStyleHidden))) |
| 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 IntSize imageSize = roundedIntSize(m_layoutObject.calculateImageIntrinsicDim
ensions(styleImage, borderImageRect.size(), | 52 IntSize imageSize = roundedIntSize(styleImage->imageSize(&m_layoutObject, 1,
borderImageRect.size())); |
| 53 LayoutBoxModelObject::DoNotScaleByEffectiveZoom)); | |
| 54 | 53 |
| 55 IntRectOutsets borderWidths(style.borderTopWidth(), style.borderRightWidth()
, | 54 IntRectOutsets borderWidths(style.borderTopWidth(), style.borderRightWidth()
, |
| 56 style.borderBottomWidth(), style.borderLeftWidth()); | 55 style.borderBottomWidth(), style.borderLeftWidth()); |
| 57 NinePieceImageGrid grid(ninePieceImage, imageSize, pixelSnappedIntRect(borde
rImageRect), borderWidths); | 56 NinePieceImageGrid grid(ninePieceImage, imageSize, pixelSnappedIntRect(borde
rImageRect), borderWidths); |
| 58 | 57 |
| 59 RefPtr<Image> image = styleImage->image(&m_layoutObject, imageSize, style.ef
fectiveZoom()); | 58 RefPtr<Image> image = styleImage->image(&m_layoutObject, imageSize, style.ef
fectiveZoom()); |
| 60 | 59 |
| 61 InterpolationQuality interpolationQuality = BoxPainter::chooseInterpolationQ
uality(m_layoutObject, image.get(), 0, rectWithOutsets.size()); | 60 InterpolationQuality interpolationQuality = BoxPainter::chooseInterpolationQ
uality(m_layoutObject, image.get(), 0, rectWithOutsets.size()); |
| 62 InterpolationQuality previousInterpolationQuality = graphicsContext.imageInt
erpolationQuality(); | 61 InterpolationQuality previousInterpolationQuality = graphicsContext.imageInt
erpolationQuality(); |
| 63 graphicsContext.setImageInterpolationQuality(interpolationQuality); | 62 graphicsContext.setImageInterpolationQuality(interpolationQuality); |
| 64 | 63 |
| 65 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", "
data", | 64 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", "
data", |
| 66 InspectorPaintImageEvent::data(m_layoutObject, *styleImage)); | 65 InspectorPaintImageEvent::data(m_layoutObject, *styleImage)); |
| 67 | 66 |
| 68 for (NinePiece piece = MinPiece; piece < MaxPiece; ++piece) { | 67 for (NinePiece piece = MinPiece; piece < MaxPiece; ++piece) { |
| 69 NinePieceImageGrid::NinePieceDrawInfo drawInfo = grid.getNinePieceDrawIn
fo(piece); | 68 NinePieceImageGrid::NinePieceDrawInfo drawInfo = grid.getNinePieceDrawIn
fo(piece); |
| 70 | 69 |
| 70 // The nine piece grid is computed in unscaled image coordinates but mus
t be drawn using |
| 71 // scaled image coordinates. |
| 72 drawInfo.source.scale(styleImage->imageScaleFactor()); |
| 73 |
| 71 if (drawInfo.isDrawable) { | 74 if (drawInfo.isDrawable) { |
| 72 if (drawInfo.isCornerPiece) { | 75 if (drawInfo.isCornerPiece) { |
| 73 graphicsContext.drawImage(image.get(), drawInfo.destination, dra
wInfo.source, op); | 76 graphicsContext.drawImage(image.get(), drawInfo.destination, dra
wInfo.source, op); |
| 74 } else { | 77 } else { |
| 75 graphicsContext.drawTiledImage(image.get(), drawInfo.destination
, | 78 graphicsContext.drawTiledImage(image.get(), drawInfo.destination
, |
| 76 drawInfo.source, drawInfo.tileScale, drawInfo.tileRule.horiz
ontal, | 79 drawInfo.source, drawInfo.tileScale, drawInfo.tileRule.horiz
ontal, |
| 77 drawInfo.tileRule.vertical, op); | 80 drawInfo.tileRule.vertical, op); |
| 78 } | 81 } |
| 79 } | 82 } |
| 80 } | 83 } |
| 81 | 84 |
| 82 graphicsContext.setImageInterpolationQuality(previousInterpolationQuality); | 85 graphicsContext.setImageInterpolationQuality(previousInterpolationQuality); |
| 83 return true; | 86 return true; |
| 84 } | 87 } |
| 85 | 88 |
| 86 } // namespace blink | 89 } // namespace blink |
| OLD | NEW |