Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(376)

Side by Side Diff: third_party/WebKit/Source/core/paint/NinePieceImagePainter.cpp

Issue 1477393003: Use LayoutUnit in NinePieceImage drawing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase on top of leviw's sub-pixel changes Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/paint/NinePieceImageGridTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/frame/UseCounter.h" 8 #include "core/frame/UseCounter.h"
9 #include "core/layout/ImageQualityController.h" 9 #include "core/layout/ImageQualityController.h"
10 #include "core/layout/LayoutBoxModelObject.h" 10 #include "core/layout/LayoutBoxModelObject.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 || (style.borderTopWidth() && (style.borderTop().style() == BNONE || sty le.borderTop().style() == BHIDDEN)) 43 || (style.borderTopWidth() && (style.borderTop().style() == BNONE || sty le.borderTop().style() == BHIDDEN))
44 || (style.borderBottomWidth() && (style.borderBottom().style() == BNONE || style.borderBottom().style() == BHIDDEN))) 44 || (style.borderBottomWidth() && (style.borderBottom().style() == BNONE || style.borderBottom().style() == BHIDDEN)))
45 UseCounter::count(m_layoutObject.document(), UseCounter::BorderImageWith BorderStyleNone); 45 UseCounter::count(m_layoutObject.document(), UseCounter::BorderImageWith BorderStyleNone);
46 46
47 // FIXME: border-image is broken with full page zooming when tiling has to h appen, since the tiling function 47 // FIXME: border-image is broken with full page zooming when tiling has to h appen, since the tiling function
48 // doesn't have any understanding of the zoom that is in effect on the tile. 48 // doesn't have any understanding of the zoom that is in effect on the tile.
49 LayoutRect rectWithOutsets = rect; 49 LayoutRect rectWithOutsets = rect;
50 rectWithOutsets.expand(style.imageOutsets(ninePieceImage)); 50 rectWithOutsets.expand(style.imageOutsets(ninePieceImage));
51 LayoutRect borderImageRect = rectWithOutsets; 51 LayoutRect borderImageRect = rectWithOutsets;
52 52
53 IntSize imageSize = roundedIntSize(m_layoutObject.calculateImageIntrinsicDim ensions(styleImage, borderImageRect.size(), 53 LayoutSize imageSize = m_layoutObject.calculateImageIntrinsicDimensions(styl eImage, borderImageRect.size(),
54 LayoutBoxModelObject::DoNotScaleByEffectiveZoom)); 54 LayoutBoxModelObject::DoNotScaleByEffectiveZoom);
55 55
56 IntRectOutsets borderWidths(style.borderTopWidth(), style.borderRightWidth() , 56 IntRectOutsets borderWidths(style.borderTopWidth(), style.borderRightWidth() ,
57 style.borderBottomWidth(), style.borderLeftWidth()); 57 style.borderBottomWidth(), style.borderLeftWidth());
58 NinePieceImageGrid grid(ninePieceImage, imageSize, pixelSnappedIntRect(borde rImageRect), borderWidths); 58 NinePieceImageGrid grid(ninePieceImage, imageSize, borderImageRect, borderWi dths);
59 59
60 RefPtr<Image> image = styleImage->image(&m_layoutObject, imageSize, style.ef fectiveZoom()); 60 RefPtr<Image> image = styleImage->image(&m_layoutObject, flooredIntSize(imag eSize), style.effectiveZoom());
61 61
62 InterpolationQuality interpolationQuality = BoxPainter::chooseInterpolationQ uality(m_layoutObject, 62 InterpolationQuality interpolationQuality = BoxPainter::chooseInterpolationQ uality(m_layoutObject,
63 graphicsContext, image.get(), 0, rectWithOutsets.size()); 63 graphicsContext, image.get(), 0, rectWithOutsets.size());
64 InterpolationQuality previousInterpolationQuality = graphicsContext->imageIn terpolationQuality(); 64 InterpolationQuality previousInterpolationQuality = graphicsContext->imageIn terpolationQuality();
65 graphicsContext->setImageInterpolationQuality(interpolationQuality); 65 graphicsContext->setImageInterpolationQuality(interpolationQuality);
66 66
67 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", " data", 67 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", " data",
68 InspectorPaintImageEvent::data(m_layoutObject, *styleImage)); 68 InspectorPaintImageEvent::data(m_layoutObject, *styleImage));
69 69
70 for (NinePiece piece = MinPiece; piece < MaxPiece; ++piece) { 70 for (NinePiece piece = MinPiece; piece < MaxPiece; ++piece) {
71 NinePieceImageGrid::NinePieceDrawInfo drawInfo = grid.getNinePieceDrawIn fo(piece); 71 NinePieceImageGrid::NinePieceDrawInfo drawInfo = grid.getNinePieceDrawIn fo(piece);
72 72
73 if (drawInfo.isDrawable) { 73 if (drawInfo.isDrawable) {
74 if (drawInfo.isCornerPiece) { 74 if (drawInfo.isCornerPiece) {
75 graphicsContext->drawImage(image.get(), drawInfo.destination, dr awInfo.source, op); 75 graphicsContext->drawImage(image.get(), drawInfo.destination, dr awInfo.source, op);
76 } else { 76 } else {
77 graphicsContext->drawTiledImage(image.get(), drawInfo.destinatio n, 77 graphicsContext->drawTiledImage(image.get(), drawInfo.destinatio n,
78 drawInfo.source, drawInfo.tileScale, drawInfo.tileRule.horiz ontal, 78 drawInfo.source, drawInfo.tileScale, drawInfo.tileRule.horiz ontal,
79 drawInfo.tileRule.vertical, op); 79 drawInfo.tileRule.vertical, op);
80 } 80 }
81 } 81 }
82 } 82 }
83 83
84 graphicsContext->setImageInterpolationQuality(previousInterpolationQuality); 84 graphicsContext->setImageInterpolationQuality(previousInterpolationQuality);
85 return true; 85 return true;
86 } 86 }
87 87
88 } // namespace blink 88 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/NinePieceImageGridTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698