Changeset 163265 in webkit
- Timestamp:
- Feb 2, 2014 10:38:45 AM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r163264 r163265 1 2014-02-02 Zalan Bujtas <zalan@apple.com> 2 3 Subpixel rendering: Introduce device pixel snapping helper functions. 4 https://bugs.webkit.org/show_bug.cgi?id=128049 5 6 Reviewed by Simon Fraser. 7 8 These functions help device pixel snapping during painting. They follow the logic of 9 the corresponding pixelSnappedInt* functions. 10 11 No change in functionality. 12 13 * platform/LayoutUnit.h: 14 (WebCore::roundToDevicePixel): 15 (WebCore::floorToDevicePixel): 16 (WebCore::snapSizeToPixel): 17 (WebCore::snapSizeToDevicePixel): 18 * platform/graphics/GraphicsContext.cpp: 19 (WebCore::GraphicsContext::GraphicsContext): 20 * platform/graphics/GraphicsContext.h: 21 (WebCore::GraphicsContext::pixelSnappingFactor): 22 * platform/graphics/LayoutRect.h: 23 (WebCore::pixelSnappedForPainting): 24 * platform/graphics/cg/GraphicsContextCG.cpp: 25 (WebCore::GraphicsContext::platformInit): 26 1 27 2014-02-02 Zalan Bujtas <zalan@apple.com> 2 28 -
trunk/Source/WebCore/platform/LayoutUnit.h
r163260 r163265 936 936 } 937 937 938 inline float roundToDevicePixel(LayoutUnit value, float pixelSnappingFactor) 939 { 940 return round((value.rawValue() * pixelSnappingFactor) / kEffectiveFixedPointDenominator) / pixelSnappingFactor; 941 } 942 943 inline float floorToDevicePixel(LayoutUnit value, float pixelSnappingFactor) 944 { 945 return floor((value.rawValue() * pixelSnappingFactor) / kEffectiveFixedPointDenominator) / pixelSnappingFactor; 946 } 947 948 inline float snapSizeToDevicePixel(LayoutUnit size, LayoutUnit location, float pixelSnappingFactor) 949 { 950 LayoutUnit fraction = location.fraction(); 951 return roundToDevicePixel(fraction + size, pixelSnappingFactor) - roundToDevicePixel(fraction, pixelSnappingFactor); 952 } 953 938 954 inline LayoutUnit roundedLayoutUnit(float value) 939 955 { -
trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp
r163156 r163265 81 81 : m_updatingControlTints(false) 82 82 , m_transparencyCount(0) 83 , m_pixelSnappingFactor(1) 83 84 { 84 85 platformInit(platformGraphicsContext); … … 88 89 : m_updatingControlTints(false) 89 90 , m_transparencyCount(0) 91 , m_pixelSnappingFactor(1) 90 92 { 91 93 platformInit(platformGraphicsContext, shouldUseContextColors); -
trunk/Source/WebCore/platform/graphics/GraphicsContext.h
r163159 r163265 445 445 AffineTransform getCTM(IncludeDeviceScale includeScale = PossiblyIncludeDeviceScale) const; 446 446 447 float pixelSnappingFactor() const { return m_pixelSnappingFactor; } 448 447 449 #if ENABLE(3D_RENDERING) && USE(TEXTURE_MAPPER) 448 450 // This is needed when using accelerated-compositing in software mode, like in TextureMapper. … … 581 583 bool m_updatingControlTints; 582 584 unsigned m_transparencyCount; 585 float m_pixelSnappingFactor; 583 586 }; 584 587 -
trunk/Source/WebCore/platform/graphics/LayoutRect.h
r162732 r163265 232 232 } 233 233 234 inline FloatRect pixelSnappedForPainting(const LayoutRect& rect, float pixelSnappingFactor) 235 { 236 #if ENABLE(SUBPIXEL_LAYOUT) 237 return FloatRect(roundToDevicePixel(rect.x(), pixelSnappingFactor), roundToDevicePixel(rect.y(), pixelSnappingFactor), 238 snapSizeToDevicePixel(rect.width(), rect.x(), pixelSnappingFactor), snapSizeToDevicePixel(rect.height(), rect.y(), pixelSnappingFactor)); 239 #else 240 UNUSED_PARAM(pixelSnappingFactor); 241 return FloatRect(rect); 242 #endif 243 } 244 245 inline FloatRect pixelSnappedForPainting(LayoutUnit x, LayoutUnit y, LayoutUnit width, LayoutUnit height, float pixelSnappingFactor) 246 { 247 return pixelSnappedForPainting(LayoutRect(x, y, width, height), pixelSnappingFactor); 248 } 249 234 250 } // namespace WebCore 235 251 -
trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
r163159 r163265 139 139 setPlatformStrokeColor(strokeColor(), strokeColorSpace()); 140 140 } 141 142 CGAffineTransform baseDeviceMatrix = CGContextGetUserSpaceToDeviceSpaceTransform(cgContext); 143 ASSERT(abs(baseDeviceMatrix.a) == abs(baseDeviceMatrix.d)); 144 m_pixelSnappingFactor = baseDeviceMatrix.a; 141 145 } 142 146
Note: See TracChangeset
for help on using the changeset viewer.