bool gfxContext::UserToDevicePixelSnapped(gfxPoint& pt, bool ignoreScale) const { if (GetFlags() & FLAG_DISABLE_SNAPPING) return PR_FALSE; // if we're not at 1.0 scale, don't snap, unless we're // ignoring the scale. If we're not -just- a scale, // never snap. cairo_matrix_t mat; cairo_get_matrix(mCairo, &mat); if ((!ignoreScale && (mat.xx != 1.0 || mat.yy != 1.0)) || (mat.xy != 0.0 || mat.yx != 0.0)) return PR_FALSE; pt = UserToDevice(pt); pt.Round(); return PR_TRUE; }
bool gfxContext::UserToDevicePixelSnapped(gfxPoint& pt, bool ignoreScale) const { if (mDT->GetUserData(&sDisablePixelSnapping)) return false; // if we're not at 1.0 scale, don't snap, unless we're // ignoring the scale. If we're not -just- a scale, // never snap. const gfxFloat epsilon = 0.0000001; #define WITHIN_E(a,b) (fabs((a)-(b)) < epsilon) Matrix mat = mTransform; if (!ignoreScale && (!WITHIN_E(mat._11,1.0) || !WITHIN_E(mat._22,1.0) || !WITHIN_E(mat._12,0.0) || !WITHIN_E(mat._21,0.0))) return false; #undef WITHIN_E pt = UserToDevice(pt); pt.Round(); return true; }