Changeset 191324 in webkit
- Timestamp:
- Oct 19, 2015 5:36:03 PM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r191323 r191324 1 2015-10-19 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Host GraphicsContext's CTM inside GraphicsContextState 4 https://bugs.webkit.org/show_bug.cgi?id=150146 5 6 There are 6 operations which interact with CTMs: 7 - Get 8 - Set 9 - Concatenate 10 - Scale 11 - Rotate 12 - Translate 13 14 This patch modifies all these operations so that these operations shadow the 15 platform's CTM inside GraphicsContextState. This way, we don't have to consult 16 with the underlying graphics context in order to know the current CTM. 17 18 There are currently many places in the Core Graphics ports where we will change 19 the platform's CTM out from under the GraphicsContext. This patch migrates 20 those users to going through GraphicsContext, thereby preserving the integrity 21 of the shadowed state. 22 23 No new tests because there is no behavior change. 24 25 * platform/graphics/GraphicsContext.cpp: Setters deletate to platform calls. 26 The getter can just consult with the shadowed state. 27 (WebCore::GraphicsContext::concatCTM): 28 (WebCore::GraphicsContext::scale): 29 (WebCore::GraphicsContext::rotate): 30 (WebCore::GraphicsContext::translate): 31 (WebCore::GraphicsContext::setCTM): 32 (WebCore::GraphicsContext::getCTM): 33 (WebCore::GraphicsContext::beginTransparencyLayer): 34 (WebCore::GraphicsContext::applyDeviceScaleFactor): 35 * platform/graphics/GraphicsContext.h: 36 (WebCore::GraphicsContext::scale): 37 (WebCore::GraphicsContext::checkCTMInvariants): Make sure the shadowed state 38 matches the platform graphics context's state. 39 * platform/graphics/Image.h: 40 (WebCore::Image::nativeImageForCurrentFrame): 41 * platform/graphics/cairo/GraphicsContextCairo.cpp: Renaming functions. 42 (WebCore::GraphicsContext::resetPlatformCTM): 43 (WebCore::GraphicsContext::getPlatformCTM): 44 (WebCore::GraphicsContext::translatePlatformCTM): 45 (WebCore::GraphicsContext::concatPlatformCTM): 46 (WebCore::GraphicsContext::setPlatformCTM): 47 (WebCore::GraphicsContext::rotatePlatformCTM): 48 (WebCore::GraphicsContext::scalePlatformCTM): 49 (WebCore::GraphicsContext::getCTM): Deleted. 50 (WebCore::GraphicsContext::translate): Deleted. 51 (WebCore::GraphicsContext::concatCTM): Deleted. 52 (WebCore::GraphicsContext::setCTM): Deleted. 53 (WebCore::GraphicsContext::rotate): Deleted. 54 (WebCore::GraphicsContext::scale): Deleted. 55 * platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h: 56 Renaming functions. 57 (WebCore::GraphicsContextPlatformPrivate::save): 58 (WebCore::GraphicsContextPlatformPrivate::restore): 59 (WebCore::GraphicsContextPlatformPrivate::flush): 60 (WebCore::GraphicsContextPlatformPrivate::clip): 61 (WebCore::GraphicsContextPlatformPrivate::scalePlatformCTM): 62 (WebCore::GraphicsContextPlatformPrivate::rotatePlatformCTM): 63 (WebCore::GraphicsContextPlatformPrivate::translatePlatformCTM): 64 (WebCore::GraphicsContextPlatformPrivate::concatPlatformCTM): 65 (WebCore::GraphicsContextPlatformPrivate::setPlatformCTM): 66 (WebCore::GraphicsContextPlatformPrivate::scale): Deleted. 67 (WebCore::GraphicsContextPlatformPrivate::rotate): Deleted. 68 (WebCore::GraphicsContextPlatformPrivate::translate): Deleted. 69 (WebCore::GraphicsContextPlatformPrivate::concatCTM): Deleted. 70 (WebCore::GraphicsContextPlatformPrivate::setCTM): Deleted. 71 * platform/graphics/cg/GraphicsContextCG.cpp: Renaming functions. Also, 72 migrate CTM setters to go through GraphicsContext. 73 (WebCore::GraphicsContext::resetPlatformCTM): 74 (WebCore::GraphicsContext::platformInit): 75 (WebCore::GraphicsContext::drawNativeImage): 76 (WebCore::GraphicsContext::drawPattern): 77 (WebCore::GraphicsContext::fillPath): 78 (WebCore::GraphicsContext::scalePlatformCTM): 79 (WebCore::GraphicsContext::rotatePlatformCTM): 80 (WebCore::GraphicsContext::translatePlatformCTM): 81 (WebCore::GraphicsContext::concatPlatformCTM): 82 (WebCore::GraphicsContext::setPlatformCTM): 83 (WebCore::GraphicsContext::getPlatformCTM): 84 (WebCore::GraphicsContext::scale): Deleted. 85 (WebCore::GraphicsContext::rotate): Deleted. 86 (WebCore::GraphicsContext::translate): Deleted. 87 (WebCore::GraphicsContext::concatCTM): Deleted. 88 (WebCore::GraphicsContext::setCTM): Deleted. 89 (WebCore::GraphicsContext::getCTM): Deleted. 90 * platform/graphics/cg/GraphicsContextPlatformPrivateCG.h: 91 (WebCore::GraphicsContextPlatformPrivate::save): 92 (WebCore::GraphicsContextPlatformPrivate::restore): 93 (WebCore::GraphicsContextPlatformPrivate::flush): 94 (WebCore::GraphicsContextPlatformPrivate::clip): 95 (WebCore::GraphicsContextPlatformPrivate::scalePlatformCTM): 96 (WebCore::GraphicsContextPlatformPrivate::rotatePlatformCTM): 97 (WebCore::GraphicsContextPlatformPrivate::translatePlatformCTM): 98 (WebCore::GraphicsContextPlatformPrivate::concatPlatformCTM): 99 (WebCore::GraphicsContextPlatformPrivate::setPlatformCTM): 100 (WebCore::GraphicsContextPlatformPrivate::scale): Deleted. 101 (WebCore::GraphicsContextPlatformPrivate::rotate): Deleted. 102 (WebCore::GraphicsContextPlatformPrivate::translate): Deleted. 103 (WebCore::GraphicsContextPlatformPrivate::concatCTM): Deleted. 104 (WebCore::GraphicsContextPlatformPrivate::setCTM): Deleted. 105 * platform/graphics/transforms/AffineTransform.h: 106 (WebCore::AffineTransform::isEssentiallyEqualTo): Equality comparison on floats 107 is not a good idea. Instead, this function is more valuable. (However, note that 108 it is expected for values in a CTM to hold values close to 0, which means that 109 this function might erroneously return false (similar to operator=()). 110 * platform/graphics/win/GraphicsContextWin.cpp: 111 (WebCore::GraphicsContextPlatformPrivate::scalePlatformCTM): 112 (WebCore::GraphicsContextPlatformPrivate::rotatePlatformCTM): 113 (WebCore::GraphicsContextPlatformPrivate::translatePlatformCTM): 114 (WebCore::GraphicsContextPlatformPrivate::concatPlatformCTM): 115 (WebCore::GraphicsContextPlatformPrivate::setPlatformCTM): 116 (WebCore::GraphicsContextPlatformPrivate::scale): Deleted. 117 (WebCore::GraphicsContextPlatformPrivate::rotate): Deleted. 118 (WebCore::GraphicsContextPlatformPrivate::translate): Deleted. 119 (WebCore::GraphicsContextPlatformPrivate::concatCTM): Deleted. 120 (WebCore::GraphicsContextPlatformPrivate::setCTM): Deleted. 121 * platform/mac/DragImageMac.mm: 122 (WebCore::drawAtPoint): 123 * platform/spi/cg/CoreGraphicsSPI.h: 124 1 125 2015-10-19 Tim Horton <timothy_horton@apple.com> 2 126 -
trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp
r191314 r191324 143 143 } 144 144 145 void GraphicsContext::concatCTM(const AffineTransform& other) 146 { 147 if (paintingDisabled()) 148 return; 149 150 checkCTMInvariants(); 151 152 m_state.ctm *= other; 153 concatPlatformCTM(other); 154 155 checkCTMInvariants(); 156 } 157 158 void GraphicsContext::scale(float x, float y) 159 { 160 if (paintingDisabled()) 161 return; 162 163 checkCTMInvariants(); 164 165 m_state.ctm.scale(x, y); 166 scalePlatformCTM(x, y); 167 168 checkCTMInvariants(); 169 } 170 171 void GraphicsContext::rotate(float angle) 172 { 173 if (paintingDisabled()) 174 return; 175 176 checkCTMInvariants(); 177 178 m_state.ctm.rotate(rad2deg(angle)); 179 rotatePlatformCTM(angle); 180 181 checkCTMInvariants(); 182 } 183 184 void GraphicsContext::translate(float x, float y) 185 { 186 if (paintingDisabled()) 187 return; 188 189 checkCTMInvariants(); 190 191 m_state.ctm.translate(x, y); 192 translatePlatformCTM(x, y); 193 194 checkCTMInvariants(); 195 } 196 197 void GraphicsContext::setCTM(const AffineTransform& other) 198 { 199 if (paintingDisabled()) 200 return; 201 202 checkCTMInvariants(); 203 204 m_state.ctm = other; 205 setPlatformCTM(other); 206 207 checkCTMInvariants(); 208 } 209 210 AffineTransform GraphicsContext::getCTM(IncludeDeviceScale includeScale) const 211 { 212 if (paintingDisabled()) 213 return AffineTransform(); 214 215 AffineTransform result; 216 if (includeScale == DefinitelyIncludeDeviceScale) 217 result = m_state.userToDeviceSpaceCTM * m_state.ctm; 218 else 219 result = m_state.ctm; 220 221 ASSERT(result.isEssentiallyEqualTo(getPlatformCTM(includeScale))); 222 223 return result; 224 } 225 145 226 void GraphicsContext::drawRaisedEllipse(const FloatRect& rect, const Color& ellipseColor, ColorSpace ellipseColorSpace, const Color& shadowColor, ColorSpace shadowColorSpace) 146 227 { … … 296 377 beginPlatformTransparencyLayer(opacity); 297 378 ++m_transparencyCount; 379 380 resetPlatformCTM(); 298 381 } 299 382 … … 655 738 void GraphicsContext::applyDeviceScaleFactor(float deviceScaleFactor) 656 739 { 657 scale(FloatSize(deviceScaleFactor, deviceScaleFactor)); 740 scale(deviceScaleFactor, deviceScaleFactor); 741 658 742 platformApplyDeviceScaleFactor(deviceScaleFactor); 659 743 } -
trunk/Source/WebCore/platform/graphics/GraphicsContext.h
r191314 r191324 157 157 BlendMode blendMode { BlendModeNormal }; 158 158 159 AffineTransform userToDeviceSpaceCTM; 160 AffineTransform ctm; 161 159 162 bool shouldAntialias : 1; 160 163 bool shouldSmoothFonts : 1; … … 421 424 void clipOut(const Path&); 422 425 423 WEBCORE_EXPORT void scale(const FloatSize& );426 WEBCORE_EXPORT void scale(const FloatSize& size) { scale(size.width(), size.height()); } 424 427 void rotate(float angleInRadians); 425 428 void translate(const FloatSize& size) { translate(size.width(), size.height()); } 429 WEBCORE_EXPORT void scale(float x, float y); 426 430 WEBCORE_EXPORT void translate(float x, float y); 427 431 428 432 void setURLForRect(const URL&, const IntRect&); 429 433 434 void checkCTMInvariants() const 435 { 436 ASSERT(getCTM(DefinitelyIncludeDeviceScale).isEssentiallyEqualTo(getPlatformCTM(DefinitelyIncludeDeviceScale))); 437 ASSERT(getCTM(PossiblyIncludeDeviceScale).isEssentiallyEqualTo(getPlatformCTM(PossiblyIncludeDeviceScale))); 438 } 430 439 void concatCTM(const AffineTransform&); 431 440 void setCTM(const AffineTransform&); 441 void resetPlatformCTM(); 432 442 433 443 enum IncludeDeviceScale { DefinitelyIncludeDeviceScale, PossiblyIncludeDeviceScale }; 434 AffineTransform getCTM(IncludeDeviceScale includeScale= PossiblyIncludeDeviceScale) const;444 AffineTransform getCTM(IncludeDeviceScale = PossiblyIncludeDeviceScale) const; 435 445 436 446 #if ENABLE(3D_TRANSFORMS) && USE(TEXTURE_MAPPER) … … 546 556 void setPlatformCompositeOperation(CompositeOperator, BlendMode = BlendModeNormal); 547 557 558 void concatPlatformCTM(const AffineTransform&); 559 void scalePlatformCTM(float x, float y); 560 void rotatePlatformCTM(float); 561 void translatePlatformCTM(float, float); 562 void setPlatformCTM(const AffineTransform&); 563 AffineTransform getPlatformCTM(IncludeDeviceScale = PossiblyIncludeDeviceScale) const; // This is only computed to ASSERT() that the GraphicsContextState agrees with the underlying platform. 564 548 565 void beginPlatformTransparencyLayer(float opacity); 549 566 void endPlatformTransparencyLayer(); -
trunk/Source/WebCore/platform/graphics/Image.h
r191314 r191324 134 134 enum TileRule { StretchTile, RoundTile, SpaceTile, RepeatTile }; 135 135 136 virtual PassNativeImagePtr nativeImageForCurrentFrame() { return 0; }136 virtual PassNativeImagePtr nativeImageForCurrentFrame() { return nullptr; } 137 137 virtual ImageOrientation orientationForCurrentFrame() { return ImageOrientation(); } 138 138 -
trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
r191314 r191324 195 195 } 196 196 197 AffineTransform GraphicsContext::getCTM(IncludeDeviceScale) const 197 void GraphicsContext::resetPlatformCTM() 198 { 199 if (platformContext()) 200 m_state.ctm = getPlatformCTM(); 201 else 202 m_state.ctm.makeIdentity(); 203 } 204 205 AffineTransform GraphicsContext::getPlatformCTM(IncludeDeviceScale) const 198 206 { 199 207 if (paintingDisabled()) … … 712 720 } 713 721 714 void GraphicsContext::translate (float x, float y)722 void GraphicsContext::translatePlatformCTM(float x, float y) 715 723 { 716 724 if (paintingDisabled()) … … 719 727 cairo_t* cr = platformContext()->cr(); 720 728 cairo_translate(cr, x, y); 721 m_data->translate (x, y);729 m_data->translatePlatformCTM(x, y); 722 730 } 723 731 … … 774 782 } 775 783 776 void GraphicsContext::concat CTM(const AffineTransform& transform)784 void GraphicsContext::concatPlatformCTM(const AffineTransform& transform) 777 785 { 778 786 if (paintingDisabled()) … … 782 790 const cairo_matrix_t matrix = cairo_matrix_t(transform); 783 791 cairo_transform(cr, &matrix); 784 m_data->concat CTM(transform);785 } 786 787 void GraphicsContext::set CTM(const AffineTransform& transform)792 m_data->concatPlatformCTM(transform); 793 } 794 795 void GraphicsContext::setPlatformCTM(const AffineTransform& transform) 788 796 { 789 797 if (paintingDisabled()) … … 793 801 const cairo_matrix_t matrix = cairo_matrix_t(transform); 794 802 cairo_set_matrix(cr, &matrix); 795 m_data->set CTM(transform);803 m_data->setPlatformCTM(transform); 796 804 } 797 805 … … 1004 1012 } 1005 1013 1006 void GraphicsContext::rotate (float radians)1014 void GraphicsContext::rotatePlatformCTM(float radians) 1007 1015 { 1008 1016 if (paintingDisabled()) … … 1010 1018 1011 1019 cairo_rotate(platformContext()->cr(), radians); 1012 m_data->rotate (radians);1013 } 1014 1015 void GraphicsContext::scale (const FloatSize& size)1016 { 1017 if (paintingDisabled()) 1018 return; 1019 1020 cairo_scale(platformContext()->cr(), size.width(), size.height());1021 m_data->scale (size);1020 m_data->rotatePlatformCTM(radians); 1021 } 1022 1023 void GraphicsContext::scalePlatformCTM(float x, float y) 1024 { 1025 if (paintingDisabled()) 1026 return; 1027 1028 cairo_scale(platformContext()->cr(), x, y); 1029 m_data->scalePlatformCTM(x, y); 1022 1030 } 1023 1031 -
trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h
r191314 r191324 68 68 void clip(const FloatRect&); 69 69 void clip(const Path&); 70 void scale (const FloatSize&);71 void rotate (float);72 void translate (float, float);73 void concat CTM(const AffineTransform&);74 void set CTM(const AffineTransform&);70 void scalePlatformCTM(float, float); 71 void rotatePlatformCTM(float); 72 void translatePlatformCTM(float, float); 73 void concatPlatformCTM(const AffineTransform&); 74 void setPlatformCTM(const AffineTransform&); 75 75 void syncContext(cairo_t* cr); 76 76 #else 77 77 // On everything else, we do nothing. 78 void save() { }79 void restore() { }80 void flush() { }81 void clip(const FloatRect&) { }82 void clip(const Path&) { }83 void scale (const FloatSize&) {}84 void rotate (float) {}85 void translate (float, float) {}86 void concat CTM(const AffineTransform&) {}87 void set CTM(const AffineTransform&) {}78 void save() { } 79 void restore() { } 80 void flush() { } 81 void clip(const FloatRect&) { } 82 void clip(const Path&) { } 83 void scalePlatformCTM(float, float) { } 84 void rotatePlatformCTM(float) { } 85 void translatePlatformCTM(float, float) { } 86 void concatPlatformCTM(const AffineTransform&) { } 87 void setPlatformCTM(const AffineTransform&) { } 88 88 void syncContext(cairo_t*) { } 89 89 #endif -
trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
r191314 r191324 105 105 #endif 106 106 107 void GraphicsContext::resetPlatformCTM() 108 { 109 m_state.ctm = CGContextGetCTM(platformContext()); 110 #if PLATFORM(WIN) || PLATFORM(IOS) 111 m_state.userToDeviceSpaceCTM = static_cast<AffineTransform>(CGContextGetUserSpaceToDeviceSpaceTransform(platformContext())) * m_state.ctm.inverse(); 112 #else 113 m_state.userToDeviceSpaceCTM = CGContextGetDefaultUserSpaceToDeviceSpaceTransform(platformContext()); 114 #endif 115 } 116 107 117 void GraphicsContext::platformInit(CGContextRef cgContext) 108 118 { … … 114 124 setPlatformStrokeColor(strokeColor(), strokeColorSpace()); 115 125 setPlatformStrokeThickness(strokeThickness()); 126 resetPlatformCTM(); 116 127 } 117 128 } … … 155 166 156 167 CGContextRef context = platformContext(); 157 CGContextStateSaver stateSaver(context);168 GraphicsContextStateSaver stateSaver(*this); 158 169 159 170 #if PLATFORM(IOS) … … 269 280 270 281 CGContextRef context = platformContext(); 271 CGContextStateSaver stateSaver(context);282 GraphicsContextStateSaver stateSaver(*this); 272 283 CGContextClipToRect(context, destRect); 273 284 … … 671 682 FloatSize layerSize = getCTM().mapSize(rect.size()); 672 683 673 CGLayerRef layer = CGLayerCreateWithContext(context, layerSize, 0);684 CGLayerRef layer = CGLayerCreateWithContext(context, layerSize, nullptr); 674 685 CGContextRef layerContext = CGLayerGetContext(layer); 675 686 … … 1254 1265 } 1255 1266 1256 void GraphicsContext::scale (const FloatSize& size)1257 { 1258 if (paintingDisabled()) 1259 return; 1260 CGContextScaleCTM(platformContext(), size.width(), size.height());1261 m_data->scale (size);1267 void GraphicsContext::scalePlatformCTM(float x, float y) 1268 { 1269 if (paintingDisabled()) 1270 return; 1271 CGContextScaleCTM(platformContext(), x, y); 1272 m_data->scalePlatformCTM(x, y); 1262 1273 m_data->m_userToDeviceTransformKnownToBeIdentity = false; 1263 1274 } 1264 1275 1265 void GraphicsContext::rotate (float angle)1276 void GraphicsContext::rotatePlatformCTM(float angle) 1266 1277 { 1267 1278 if (paintingDisabled()) 1268 1279 return; 1269 1280 CGContextRotateCTM(platformContext(), angle); 1270 m_data->rotate (angle);1281 m_data->rotatePlatformCTM(angle); 1271 1282 m_data->m_userToDeviceTransformKnownToBeIdentity = false; 1272 1283 } 1273 1284 1274 void GraphicsContext::translate (float x, float y)1285 void GraphicsContext::translatePlatformCTM(float x, float y) 1275 1286 { 1276 1287 if (paintingDisabled()) 1277 1288 return; 1278 1289 CGContextTranslateCTM(platformContext(), x, y); 1279 m_data->translate (x, y);1290 m_data->translatePlatformCTM(x, y); 1280 1291 m_data->m_userToDeviceTransformKnownToBeIdentity = false; 1281 1292 } 1282 1293 1283 void GraphicsContext::concat CTM(const AffineTransform& transform)1294 void GraphicsContext::concatPlatformCTM(const AffineTransform& transform) 1284 1295 { 1285 1296 if (paintingDisabled()) 1286 1297 return; 1287 1298 CGContextConcatCTM(platformContext(), transform); 1288 m_data->concat CTM(transform);1299 m_data->concatPlatformCTM(transform); 1289 1300 m_data->m_userToDeviceTransformKnownToBeIdentity = false; 1290 1301 } 1291 1302 1292 void GraphicsContext::set CTM(const AffineTransform& transform)1303 void GraphicsContext::setPlatformCTM(const AffineTransform& transform) 1293 1304 { 1294 1305 if (paintingDisabled()) 1295 1306 return; 1296 1307 CGContextSetCTM(platformContext(), transform); 1297 m_data->set CTM(transform);1308 m_data->setPlatformCTM(transform); 1298 1309 m_data->m_userToDeviceTransformKnownToBeIdentity = false; 1299 1310 } 1300 1311 1301 AffineTransform GraphicsContext::get CTM(IncludeDeviceScale includeScale) const1312 AffineTransform GraphicsContext::getPlatformCTM(IncludeDeviceScale includeScale) const 1302 1313 { 1303 1314 if (paintingDisabled()) -
trunk/Source/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h
r191314 r191324 54 54 #if PLATFORM(COCOA) 55 55 // These methods do nothing on Mac. 56 void save() { }57 void restore() { }58 void flush() { }59 void clip(const FloatRect&) { }60 void clip(const Path&) { }61 void scale (const FloatSize&) {}62 void rotate (float) {}63 void translate (float, float) {}64 void concat CTM(const AffineTransform&) {}65 void set CTM(const AffineTransform&) {}56 void save() { } 57 void restore() { } 58 void flush() { } 59 void clip(const FloatRect&) { } 60 void clip(const Path&) { } 61 void scalePlatformCTM(float, float) { } 62 void rotatePlatformCTM(float) { } 63 void translatePlatformCTM(float, float) { } 64 void concatPlatformCTM(const AffineTransform&) { } 65 void setPlatformCTM(const AffineTransform&) { } 66 66 #endif 67 67 … … 73 73 void clip(const FloatRect&); 74 74 void clip(const Path&); 75 void scale (const FloatSize&);76 void rotate (float);77 void translate (float, float);78 void concat CTM(const AffineTransform&);79 void set CTM(const AffineTransform&);75 void scalePlatformCTM(float x, float y); 76 void rotatePlatformCTM(float); 77 void translatePlatformCTM(float, float); 78 void concatPlatformCTM(const AffineTransform&); 79 void setPlatformCTM(const AffineTransform&); 80 80 81 81 HDC m_hdc; -
trunk/Source/WebCore/platform/graphics/transforms/AffineTransform.h
r191314 r191324 31 31 #include <array> 32 32 #include <wtf/FastMalloc.h> 33 #include <wtf/MathExtras.h> 33 34 34 35 #if USE(CG) … … 141 142 } 142 143 144 // FIXME: If you compare floats for equality, you're gonna have a bad time. We should delete this. 143 145 bool operator== (const AffineTransform& m2) const 144 146 { … … 152 154 153 155 bool operator!=(const AffineTransform& other) const { return !(*this == other); } 156 157 bool isEssentiallyEqualTo(const AffineTransform& m2, double epsilon = 0.001) const 158 { 159 // WTF::areEssentiallyEqual() doesn't work well in this case. That function is designed to allow for error 160 // which scales proportionately to the values. However, AffineTransforms are often rotated by pi/2, which 161 // are not exactly representable. This results in AffineTransform components which are close to, but not 162 // exactly equal to, zero. In this case, the error and the value are approximately equal, which leads to 163 // a false negative return. 164 return std::abs(m_transform[0] - m2.m_transform[0]) < epsilon 165 && std::abs(m_transform[1] - m2.m_transform[1]) < epsilon 166 && std::abs(m_transform[2] - m2.m_transform[2]) < epsilon 167 && std::abs(m_transform[3] - m2.m_transform[3]) < epsilon 168 && std::abs(m_transform[4] - m2.m_transform[4]) < epsilon 169 && std::abs(m_transform[5] - m2.m_transform[5]) < epsilon; 170 } 154 171 155 172 // *this = *this * t (i.e., a multRight) -
trunk/Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp
r191314 r191324 172 172 } 173 173 174 void GraphicsContextPlatformPrivate::scale (const FloatSize& size)175 { 176 if (!m_hdc) 177 return; 178 179 XFORM xform = TransformationMatrix().scaleNonUniform( size.width(), size.height());174 void GraphicsContextPlatformPrivate::scalePlatformCTM(float x, float y) 175 { 176 if (!m_hdc) 177 return; 178 179 XFORM xform = TransformationMatrix().scaleNonUniform(x, y); 180 180 ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY); 181 181 } … … 183 183 static const double deg2rad = 0.017453292519943295769; // pi/180 184 184 185 void GraphicsContextPlatformPrivate::rotate (float degreesAngle)185 void GraphicsContextPlatformPrivate::rotatePlatformCTM(float degreesAngle) 186 186 { 187 187 XFORM xform = TransformationMatrix().rotate(degreesAngle); … … 189 189 } 190 190 191 void GraphicsContextPlatformPrivate::translate (float x , float y)191 void GraphicsContextPlatformPrivate::translatePlatformCTM(float x , float y) 192 192 { 193 193 if (!m_hdc) … … 198 198 } 199 199 200 void GraphicsContextPlatformPrivate::concat CTM(const AffineTransform& transform)200 void GraphicsContextPlatformPrivate::concatPlatformCTM(const AffineTransform& transform) 201 201 { 202 202 if (!m_hdc) … … 207 207 } 208 208 209 void GraphicsContextPlatformPrivate::set CTM(const AffineTransform& transform)209 void GraphicsContextPlatformPrivate::setPlatformCTM(const AffineTransform& transform) 210 210 { 211 211 if (!m_hdc) -
trunk/Source/WebCore/platform/mac/DragImageMac.mm
r191314 r191324 217 217 NSGraphicsContext *nsContext = [NSGraphicsContext currentContext]; 218 218 CGContextRef cgContext = static_cast<CGContextRef>([nsContext graphicsPort]); 219 GraphicsContext graphicsContext(cgContext);220 219 221 220 // Safari doesn't flip the NSGraphicsContext before calling WebKit, yet WebCore requires a flipped graphics context. … … 223 222 if (!flipped) 224 223 CGContextScaleCTM(cgContext, 1, -1); 224 225 GraphicsContext graphicsContext(cgContext); 225 226 226 227 FontCascade webCoreFont(FontPlatformData(toCTFont(font), [font pointSize]), Antialiased); -
trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h
r191314 r191324 144 144 void CGContextSetShouldAntialiasFonts(CGContextRef, bool shouldAntialiasFonts); 145 145 void CGContextResetClip(CGContextRef); 146 CGAffineTransform CGContextGetUserSpaceToDeviceSpaceTransform(CGContextRef); 147 CGAffineTransform CGContextGetDefaultUserSpaceToDeviceSpaceTransform(CGContextRef); 146 148 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100 147 149 void CGContextSetFontDilation(CGContextRef, CGSize);
Note: See TracChangeset
for help on using the changeset viewer.