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 12 matching lines...) Expand all Loading... |
23 bool NinePieceImagePainter::paint(GraphicsContext& graphicsContext, | 23 bool NinePieceImagePainter::paint(GraphicsContext& graphicsContext, |
24 const LayoutRect& rect, | 24 const LayoutRect& rect, |
25 const ComputedStyle& style, | 25 const ComputedStyle& style, |
26 const NinePieceImage& ninePieceImage, | 26 const NinePieceImage& ninePieceImage, |
27 SkXfermode::Mode op) const { | 27 SkXfermode::Mode op) const { |
28 StyleImage* styleImage = ninePieceImage.image(); | 28 StyleImage* styleImage = ninePieceImage.image(); |
29 if (!styleImage) | 29 if (!styleImage) |
30 return false; | 30 return false; |
31 | 31 |
32 if (!styleImage->isLoaded()) | 32 if (!styleImage->isLoaded()) |
33 return true; // Never paint a nine-piece image incrementally, but don't pai
nt the fallback borders either. | 33 return true; // Never paint a nine-piece image incrementally, but don't |
| 34 // paint the fallback borders either. |
34 | 35 |
35 if (!styleImage->canRender()) | 36 if (!styleImage->canRender()) |
36 return false; | 37 return false; |
37 | 38 |
38 // FIXME: border-image is broken with full page zooming when tiling has to hap
pen, since the tiling function | 39 // FIXME: border-image is broken with full page zooming when tiling has to |
39 // doesn't have any understanding of the zoom that is in effect on the tile. | 40 // happen, since the tiling function doesn't have any understanding of the |
| 41 // zoom that is in effect on the tile. |
40 LayoutRect rectWithOutsets = rect; | 42 LayoutRect rectWithOutsets = rect; |
41 rectWithOutsets.expand(style.imageOutsets(ninePieceImage)); | 43 rectWithOutsets.expand(style.imageOutsets(ninePieceImage)); |
42 LayoutRect borderImageRect = rectWithOutsets; | 44 LayoutRect borderImageRect = rectWithOutsets; |
43 | 45 |
44 // NinePieceImage returns the image slices without effective zoom applied and
thus we compute | 46 // NinePieceImage returns the image slices without effective zoom applied and |
45 // the nine piece grid on top of the image in unzoomed coordinates. | 47 // thus we compute the nine piece grid on top of the image in unzoomed |
| 48 // coordinates. |
46 // | 49 // |
47 // FIXME: The default object size passed to imageSize() should be scaled by th
e zoom factor | 50 // FIXME: The default object size passed to imageSize() should be scaled by |
48 // passed in. In this case it means that borderImageRect should be passed in c
ompensated by | 51 // the zoom factor passed in. In this case it means that borderImageRect |
49 // effective zoom, since the scale factor is one. For generated images, the ac
tual image data | 52 // should be passed in compensated by effective zoom, since the scale factor |
50 // (gradient stops, etc.) are scaled to effective zoom instead so we must take
care not to cause | 53 // is one. For generated images, the actual image data (gradient stops, etc.) |
| 54 // are scaled to effective zoom instead so we must take care not to cause |
51 // scale of them again. | 55 // scale of them again. |
52 IntSize imageSize = roundedIntSize( | 56 IntSize imageSize = roundedIntSize( |
53 styleImage->imageSize(m_layoutObject, 1, borderImageRect.size())); | 57 styleImage->imageSize(m_layoutObject, 1, borderImageRect.size())); |
54 | 58 |
55 IntRectOutsets borderWidths(style.borderTopWidth(), style.borderRightWidth(), | 59 IntRectOutsets borderWidths(style.borderTopWidth(), style.borderRightWidth(), |
56 style.borderBottomWidth(), | 60 style.borderBottomWidth(), |
57 style.borderLeftWidth()); | 61 style.borderLeftWidth()); |
58 NinePieceImageGrid grid(ninePieceImage, imageSize, | 62 NinePieceImageGrid grid(ninePieceImage, imageSize, |
59 pixelSnappedIntRect(borderImageRect), borderWidths); | 63 pixelSnappedIntRect(borderImageRect), borderWidths); |
60 | 64 |
(...skipping 26 matching lines...) Expand all Loading... |
87 drawInfo.tileRule.vertical, op); | 91 drawInfo.tileRule.vertical, op); |
88 } | 92 } |
89 } | 93 } |
90 } | 94 } |
91 | 95 |
92 graphicsContext.setImageInterpolationQuality(previousInterpolationQuality); | 96 graphicsContext.setImageInterpolationQuality(previousInterpolationQuality); |
93 return true; | 97 return true; |
94 } | 98 } |
95 | 99 |
96 } // namespace blink | 100 } // namespace blink |
OLD | NEW |