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

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

Issue 1504463002: Turn down BackgroundImageGeometry aggressive LayoutUnit conversion by a notch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment to additional sub-pixel heuristic call 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/BackgroundImageGeometry.h" 6 #include "core/paint/BackgroundImageGeometry.h"
7 7
8 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/layout/LayoutBox.h" 9 #include "core/layout/LayoutBox.h"
10 #include "core/layout/LayoutBoxModelObject.h" 10 #include "core/layout/LayoutBoxModelObject.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 { 154 {
155 LayoutPoint alignedPoint = attachmentPoint; 155 LayoutPoint alignedPoint = attachmentPoint;
156 m_phase.move(std::max(alignedPoint.x() - m_destRect.x(), LayoutUnit()), std: :max(alignedPoint.y() - m_destRect.y(), LayoutUnit())); 156 m_phase.move(std::max(alignedPoint.x() - m_destRect.x(), LayoutUnit()), std: :max(alignedPoint.y() - m_destRect.y(), LayoutUnit()));
157 } 157 }
158 158
159 void BackgroundImageGeometry::clip(const LayoutRect& clipRect) 159 void BackgroundImageGeometry::clip(const LayoutRect& clipRect)
160 { 160 {
161 m_destRect.intersect(clipRect); 161 m_destRect.intersect(clipRect);
162 } 162 }
163 163
164 // When we match the destination rect in a dimension, we snap the same way. Othe rwise 164 // When we match the sub-pixel fraction of the destination rect in a dimension, we
165 // we floor to avoid growing our tile size. Often these tiles are from a sprite map, 165 // snap the same way. Otherwise we floor to avoid growing our tile size. Often t hese
166 // and bleeding adjactent sprites is visually worse than clipping the intenteded one. 166 // tiles are from a sprite map, and bleeding adjactent sprites is visually worse
167 // than clipping the intenteded one.
167 static LayoutSize applySubPixelHeuristicToImageSize(const LayoutSize& size, cons t LayoutRect& destination) 168 static LayoutSize applySubPixelHeuristicToImageSize(const LayoutSize& size, cons t LayoutRect& destination)
davve 2015/12/08 20:19:21 nit: If you like you can put this function in the
168 { 169 {
169 LayoutSize snappedSize = LayoutSize( 170 LayoutSize snappedSize = LayoutSize(
170 size.width() == destination.width() ? destination.pixelSnappedWidth() : size.width().floor(), 171 size.width().fraction() == destination.width().fraction() ? snapSizeToPi xel(size.width(), destination.x()) : size.width().floor(),
davve 2015/12/08 20:19:21 The other change below is easier to understand tha
171 size.height() == destination.height() ? destination.pixelSnappedHeight() : size.height().floor()); 172 size.height().fraction() == destination.height().fraction() ? snapSizeTo Pixel(size.height(), destination.y()) : size.height().floor());
172 return snappedSize; 173 return snappedSize;
173 } 174 }
174 175
175 void BackgroundImageGeometry::pixelSnapGeometry() 176 void BackgroundImageGeometry::pixelSnapGeometry()
176 { 177 {
177 setTileSize(applySubPixelHeuristicToImageSize(m_tileSize, m_destRect)); 178 setTileSize(applySubPixelHeuristicToImageSize(m_tileSize, m_destRect));
178 setImageContainerSize(applySubPixelHeuristicToImageSize(m_imageContainerSize , m_destRect)); 179 setImageContainerSize(applySubPixelHeuristicToImageSize(m_imageContainerSize , m_destRect));
179 setSpaceSize(LayoutSize(roundedIntSize(m_repeatSpacing))); 180 setSpaceSize(LayoutSize(roundedIntSize(m_repeatSpacing)));
180 setDestRect(LayoutRect(pixelSnappedIntRect(m_destRect))); 181 setDestRect(LayoutRect(pixelSnappedIntRect(m_destRect)));
181 setPhase(LayoutPoint(flooredIntPoint(m_phase))); 182 setPhase(LayoutPoint(flooredIntPoint(m_phase)));
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 viewportRect.moveBy(accumulatedScrollOffset(obj, paintContainer)); 259 viewportRect.moveBy(accumulatedScrollOffset(obj, paintContainer));
259 } 260 }
260 261
261 if (paintContainer) 262 if (paintContainer)
262 viewportRect.moveBy(LayoutPoint(-paintContainer->localToAbsolute(Flo atPoint()))); 263 viewportRect.moveBy(LayoutPoint(-paintContainer->localToAbsolute(Flo atPoint())));
263 264
264 setDestRect(viewportRect); 265 setDestRect(viewportRect);
265 positioningAreaSize = destRect().size(); 266 positioningAreaSize = destRect().size();
266 } 267 }
267 268
268 LayoutSize fillTileSize = calculateFillTileSize(positioningBox, fillLayer, p ositioningAreaSize); 269 LayoutSize fillTileSize(calculateFillTileSize(positioningBox, fillLayer, pos itioningAreaSize));
270 // It's necessary to apply the heuristic here prior to any further calculati ons to avoid
271 // incorrectly using sub-pixel values that won't be present in the painted t ile.
272 fillTileSize = applySubPixelHeuristicToImageSize(fillTileSize, m_destRect);
269 setTileSize(fillTileSize); 273 setTileSize(fillTileSize);
270 setImageContainerSize(fillTileSize); 274 setImageContainerSize(fillTileSize);
271 275
272 EFillRepeat backgroundRepeatX = fillLayer.repeatX(); 276 EFillRepeat backgroundRepeatX = fillLayer.repeatX();
273 EFillRepeat backgroundRepeatY = fillLayer.repeatY(); 277 EFillRepeat backgroundRepeatY = fillLayer.repeatY();
274 LayoutUnit availableWidth = positioningAreaSize.width() - tileSize().width() ; 278 LayoutUnit availableWidth = positioningAreaSize.width() - tileSize().width() ;
275 LayoutUnit availableHeight = positioningAreaSize.height() - tileSize().heigh t(); 279 LayoutUnit availableHeight = positioningAreaSize.height() - tileSize().heigh t();
276 280
277 LayoutUnit computedXPosition = roundedMinimumValueForLength(fillLayer.xPosit ion(), availableWidth); 281 LayoutUnit computedXPosition = roundedMinimumValueForLength(fillLayer.xPosit ion(), availableWidth);
278 if (backgroundRepeatX == RoundFill && positioningAreaSize.width() > LayoutUn it() && fillTileSize.width() > LayoutUnit()) { 282 if (backgroundRepeatX == RoundFill && positioningAreaSize.width() > LayoutUn it() && fillTileSize.width() > LayoutUnit()) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 } 357 }
354 358
355 if (fixedAttachment) 359 if (fixedAttachment)
356 useFixedAttachment(paintRect.location()); 360 useFixedAttachment(paintRect.location());
357 361
358 clip(paintRect); 362 clip(paintRect);
359 pixelSnapGeometry(); 363 pixelSnapGeometry();
360 } 364 }
361 365
362 } // namespace blink 366 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698