diff options
author | reed <reed@google.com> | 2015-05-12 10:37:34 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-12 10:37:34 -0700 |
commit | 80ea19ca4bdd68c1493666a5fe7e4ce9d43ded8b (patch) | |
tree | 1ad73d17a3314363d114ddc95932e271ae1e828a /src | |
parent | 1ebf0d2edc48f886521e6f03af78ef5da24c7982 (diff) |
Revert of Revert of stop calling SkScalarDiv (patchset #1 id:1 of https://codereview.chromium.org/1138263002/)
Reason for revert:
android patched, blink has rolled
Original issue's description:
> Revert of stop calling SkScalarDiv (patchset #4 id:60001 of https://codereview.chromium.org/1135053002/)
>
> Reason for revert:
> need to wait for Blink roll (and patch android)
>
> Original issue's description:
> > stop calling SkScalarDiv
> >
> > BUG=skia:
> > TBR=
> >
> > Committed: https://skia.googlesource.com/skia/+/67d71c898249a7af3523b16c6a69895a63bfae0a
>
> TBR=
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/2629697933b5cc975e45d2a45c48f803fc6cbcec
TBR=
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/1135693003
Diffstat (limited to 'src')
37 files changed, 75 insertions, 96 deletions
diff --git a/src/animator/SkAnimateBase.cpp b/src/animator/SkAnimateBase.cpp index 3515ed5cb3..82f777ef39 100644 --- a/src/animator/SkAnimateBase.cpp +++ b/src/animator/SkAnimateBase.cpp @@ -91,7 +91,7 @@ void SkAnimateBase::dump(SkAnimateMaker* maker) { SkDebugf("to=\"%s\" ", to.c_str()); } if (begin != 0) { - SkDebugf("begin=\"%g\" ", SkScalarToFloat(SkScalarDiv(begin,1000))); + SkDebugf("begin=\"%g\" ", begin * 0.001); } } #endif diff --git a/src/animator/SkAnimateField.cpp b/src/animator/SkAnimateField.cpp index 7aebb78288..c6676e5be7 100644 --- a/src/animator/SkAnimateField.cpp +++ b/src/animator/SkAnimateField.cpp @@ -41,7 +41,7 @@ void SkAnimate::dump(SkAnimateMaker* maker) { SkDebugf("mirror=\"true\" "); if (fReset) SkDebugf("reset=\"true\" "); - SkDebugf("dur=\"%g\" ", SkScalarToFloat(SkScalarDiv(dur,1000))); + SkDebugf("dur=\"%g\" ", dur * 0.001); if (repeat != SK_Scalar1) SkDebugf("repeat=\"%g\" ", SkScalarToFloat(repeat)); //if (fHasValues) diff --git a/src/animator/SkAnimateSet.cpp b/src/animator/SkAnimateSet.cpp index d146118e89..ec06a9e666 100644 --- a/src/animator/SkAnimateSet.cpp +++ b/src/animator/SkAnimateSet.cpp @@ -39,7 +39,7 @@ SkSet::SkSet() { void SkSet::dump(SkAnimateMaker* maker) { INHERITED::dump(maker); if (dur != 1) { - SkDebugf("dur=\"%g\" ", SkScalarToFloat(SkScalarDiv(dur,1000))); + SkDebugf("dur=\"%g\" ", dur * 0.001); } //don't want double />\n's SkDebugf("/>\n"); diff --git a/src/animator/SkAnimatorScript.cpp b/src/animator/SkAnimatorScript.cpp index df2e5637a2..f4ea51890f 100644 --- a/src/animator/SkAnimatorScript.cpp +++ b/src/animator/SkAnimatorScript.cpp @@ -235,7 +235,7 @@ bool SkAnimatorScript::EvalMemberCommon(SkScriptEngine* engine, const SkMemberIn if (info->fType != SkType_MemberProperty && info->fType != SkType_MemberFunction) value->fOperand.fS32 = *(int32_t*) info->memberData(displayable); // OK for SkScalar too if (type == SkType_MSec) { - value->fOperand.fScalar = SkScalarDiv((SkScalar) value->fOperand.fS32, 1000); // dividing two ints is the same as dividing two scalars + value->fOperand.fScalar = value->fOperand.fS32 * 0.001f; type = SkType_Float; } break; diff --git a/src/animator/SkAnimatorScript2.cpp b/src/animator/SkAnimatorScript2.cpp index 80ae0c6aa8..28912fb6d0 100644 --- a/src/animator/SkAnimatorScript2.cpp +++ b/src/animator/SkAnimatorScript2.cpp @@ -412,7 +412,7 @@ bool SkAnimatorScript2::evalMemberCommon(const SkMemberInfo* info, if (info->fType != SkType_MemberProperty && info->fType != SkType_MemberFunction) value->fS32 = *(int32_t*) info->memberData(displayable); // OK for SkScalar too if (type == SkType_MSec) { - value->fScalar = SkScalarDiv((SkScalar) value->fS32, 1000); // dividing two ints is the same as dividing two scalars + value->fScalar = value->fS32 * 0.001f; type = SkType_Float; } break; diff --git a/src/animator/SkDisplayPost.cpp b/src/animator/SkDisplayPost.cpp index cc45b216ba..0fd4a06753 100644 --- a/src/animator/SkDisplayPost.cpp +++ b/src/animator/SkDisplayPost.cpp @@ -76,7 +76,7 @@ void SkPost::dump(SkAnimateMaker* maker) { delete eventType; if (delay > 0) { - SkDebugf("delay=\"%g\" ", SkScalarToFloat(SkScalarDiv(delay, 1000))); + SkDebugf("delay=\"%g\" ", delay * 0.001); } // if (initialized == false) // SkDebugf("(uninitialized) "); diff --git a/src/animator/SkDisplayable.cpp b/src/animator/SkDisplayable.cpp index aff3aaefc6..52532fedcd 100644 --- a/src/animator/SkDisplayable.cpp +++ b/src/animator/SkDisplayable.cpp @@ -377,7 +377,7 @@ void SkDisplayable::dumpValues(const SkMemberInfo* info, SkDisplayTypes type, Sk break; case SkType_MSec: if (op.fS32 != blankOp.fS32) { - SkDebugf(" %s=\"%g\" ", info->fName, SkScalarToFloat(SkScalarDiv(op.fS32, 1000))); + SkDebugf(" %s=\"%g\" ", info->fName, op.fS32 * 0.001); } default: SkDebugf(""); diff --git a/src/animator/SkDrawColor.cpp b/src/animator/SkDrawColor.cpp index eb57d9dad4..d86a2e93e7 100644 --- a/src/animator/SkDrawColor.cpp +++ b/src/animator/SkDrawColor.cpp @@ -30,14 +30,14 @@ static SkScalar RGB_to_HSV(SkColor color, HSV_Choice choice) { if (choice == kGetValue) return value/255; SkScalar delta = value - min; - SkScalar saturation = value == 0 ? 0 : SkScalarDiv(delta, value); + SkScalar saturation = value == 0 ? 0 : delta / value; if (choice == kGetSaturation) return saturation; SkScalar hue; if (saturation == 0) hue = 0; else { - SkScalar part60 = SkScalarDiv(60 * SK_Scalar1, delta); + SkScalar part60 = 60 / delta; if (red == value) { hue = SkScalarMul(green - blue, part60); if (hue < 0) diff --git a/src/animator/SkScript.cpp b/src/animator/SkScript.cpp index 1d04d1b276..c430695705 100644 --- a/src/animator/SkScript.cpp +++ b/src/animator/SkScript.cpp @@ -1387,7 +1387,7 @@ bool SkScriptEngine::processOp() { if (operand2.fScalar == 0) operand2.fScalar = operand1.fScalar == 0 ? SK_ScalarNaN : operand1.fScalar > 0 ? SK_ScalarMax : -SK_ScalarMax; else - operand2.fScalar = SkScalarDiv(operand1.fScalar, operand2.fScalar); + operand2.fScalar = operand1.fScalar / operand2.fScalar; break; case kEqualInt: operand2.fS32 = operand1.fS32 == operand2.fS32; diff --git a/src/animator/SkScriptRuntime.cpp b/src/animator/SkScriptRuntime.cpp index 78d9d5c208..07bd4c9c2f 100644 --- a/src/animator/SkScriptRuntime.cpp +++ b/src/animator/SkScriptRuntime.cpp @@ -249,7 +249,7 @@ bool SkScriptRuntime::executeTokens(unsigned char* opCode) { operand[0].fScalar = operand[0].fScalar == 0 ? SK_ScalarNaN : operand[0].fScalar > 0 ? SK_ScalarMax : -SK_ScalarMax; else - operand[0].fScalar = SkScalarDiv(operand[0].fScalar, operand[1].fScalar); + operand[0].fScalar = operand[0].fScalar / operand[1].fScalar; break; case SkScriptEngine2::kEqualInt: operand[0].fS32 = operand[0].fS32 == operand[1].fS32; diff --git a/src/core/SkGeometry.cpp b/src/core/SkGeometry.cpp index 3ee2fa5d26..b4489d28e3 100644 --- a/src/core/SkGeometry.cpp +++ b/src/core/SkGeometry.cpp @@ -62,7 +62,7 @@ static int valid_unit_divide(SkScalar numer, SkScalar denom, SkScalar* ratio) { return 0; } - SkScalar r = SkScalarDiv(numer, denom); + SkScalar r = numer / denom; if (SkScalarIsNaN(r)) { return 0; } @@ -1149,7 +1149,7 @@ static SkScalar conic_eval_pos(const SkScalar src[], SkScalar w, SkScalar t) { A = -B; SkScalar denom = SkScalarMulAdd(SkScalarMulAdd(A, t, B), t, C); - return SkScalarDiv(numer, denom); + return numer / denom; } // F' = 2 (C t (1 + t (-1 + w)) - A (-1 + t) (t (-1 + w) - w) + B (1 - 2 t) w) diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index 975d0ccc07..c00dcc6b4f 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -2313,7 +2313,7 @@ SkTextToPathIter::SkTextToPathIter( const char text[], size_t length, fPaint.setTextSize(SkIntToScalar(SkPaint::kCanonicalTextSizeForPaths)); fScale = paint.getTextSize() / SkPaint::kCanonicalTextSizeForPaths; if (has_thick_frame(fPaint)) { - fPaint.setStrokeWidth(SkScalarDiv(fPaint.getStrokeWidth(), fScale)); + fPaint.setStrokeWidth(fPaint.getStrokeWidth() / fScale); } } else { fScale = SK_Scalar1; diff --git a/src/core/SkPathMeasure.cpp b/src/core/SkPathMeasure.cpp index c963e9cf35..a5dd84048c 100644 --- a/src/core/SkPathMeasure.cpp +++ b/src/core/SkPathMeasure.cpp @@ -341,8 +341,7 @@ static void seg_to(const SkPoint pts[], int segType, if (SK_Scalar1 == stopT) { dst->quadTo(tmp0[3], tmp0[4]); } else { - SkChopQuadAt(&tmp0[2], tmp1, SkScalarDiv(stopT - startT, - SK_Scalar1 - startT)); + SkChopQuadAt(&tmp0[2], tmp1, (stopT - startT) / (1 - startT)); dst->quadTo(tmp1[1], tmp1[2]); } } @@ -383,8 +382,7 @@ static void seg_to(const SkPoint pts[], int segType, if (SK_Scalar1 == stopT) { dst->cubicTo(tmp0[4], tmp0[5], tmp0[6]); } else { - SkChopCubicAt(&tmp0[3], tmp1, SkScalarDiv(stopT - startT, - SK_Scalar1 - startT)); + SkChopCubicAt(&tmp0[3], tmp1, (stopT - startT) / (1 - startT)); dst->cubicTo(tmp1[1], tmp1[2], tmp1[3]); } } diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp index 2c835ed93e..c1c4755058 100644 --- a/src/core/SkPictureShader.cpp +++ b/src/core/SkPictureShader.cpp @@ -168,7 +168,7 @@ SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix, const SkMatri static const SkScalar kMaxTileArea = 2048 * 2048; SkScalar tileArea = SkScalarMul(scaledSize.width(), scaledSize.height()); if (tileArea > kMaxTileArea) { - SkScalar clampScale = SkScalarSqrt(SkScalarDiv(kMaxTileArea, tileArea)); + SkScalar clampScale = SkScalarSqrt(kMaxTileArea / tileArea); scaledSize.set(SkScalarMul(scaledSize.width(), clampScale), SkScalarMul(scaledSize.height(), clampScale)); } @@ -176,8 +176,7 @@ SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix, const SkMatri // Scale down the tile size if larger than maxTextureSize for GPU Path or it should fail on create texture if (maxTextureSize) { if (scaledSize.width() > maxTextureSize || scaledSize.height() > maxTextureSize) { - SkScalar downScale = SkScalarDiv(maxTextureSize, - SkMax32(scaledSize.width(), scaledSize.height())); + SkScalar downScale = maxTextureSize / SkMax32(scaledSize.width(), scaledSize.height()); scaledSize.set(SkScalarFloorToScalar(SkScalarMul(scaledSize.width(), downScale)), SkScalarFloorToScalar(SkScalarMul(scaledSize.height(), downScale))); } diff --git a/src/core/SkRRect.cpp b/src/core/SkRRect.cpp index e54256009a..0d1887d792 100644 --- a/src/core/SkRRect.cpp +++ b/src/core/SkRRect.cpp @@ -26,8 +26,7 @@ void SkRRect::setRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad) { } if (rect.width() < xRad+xRad || rect.height() < yRad+yRad) { - SkScalar scale = SkMinScalar(SkScalarDiv(rect.width(), xRad + xRad), - SkScalarDiv(rect.height(), yRad + yRad)); + SkScalar scale = SkMinScalar(rect.width() / (xRad + xRad), rect.height() / (yRad + yRad)); SkASSERT(scale < SK_Scalar1); xRad = SkScalarMul(xRad, scale); yRad = SkScalarMul(yRad, scale); @@ -66,10 +65,10 @@ void SkRRect::setNinePatch(const SkRect& rect, SkScalar leftRad, SkScalar topRad SkScalar scale = SK_Scalar1; if (leftRad + rightRad > rect.width()) { - scale = SkScalarDiv(rect.width(), leftRad + rightRad); + scale = rect.width() / (leftRad + rightRad); } if (topRad + bottomRad > rect.height()) { - scale = SkMinScalar(scale, SkScalarDiv(rect.height(), topRad + bottomRad)); + scale = SkMinScalar(scale, rect.height() / (topRad + bottomRad)); } if (scale < SK_Scalar1) { diff --git a/src/core/SkScalar.cpp b/src/core/SkScalar.cpp index c48d3890ad..e8f6e93348 100644 --- a/src/core/SkScalar.cpp +++ b/src/core/SkScalar.cpp @@ -31,6 +31,6 @@ SkScalar SkScalarInterpFunc(SkScalar searchKey, const SkScalar keys[], // Otherwise, interpolate between right - 1 and right. SkScalar rightKey = keys[right]; SkScalar leftKey = keys[right-1]; - SkScalar fract = SkScalarDiv(searchKey-leftKey,rightKey-leftKey); + SkScalar fract = (searchKey - leftKey) / (rightKey - leftKey); return SkScalarInterp(values[right-1], values[right], fract); } diff --git a/src/core/SkStroke.cpp b/src/core/SkStroke.cpp index a3641ffc4f..6454f1694d 100644 --- a/src/core/SkStroke.cpp +++ b/src/core/SkStroke.cpp @@ -454,8 +454,7 @@ void SkPathStroker::quad_to(const SkPoint pts[3], normalB = pts[2] - pts[0]; normalB.rotateCCW(); SkScalar dot = SkPoint::DotProduct(unitNormalAB, *unitNormalBC); - SkAssertResult(normalB.setLength(SkScalarDiv(fRadius, - SkScalarSqrt((SK_Scalar1 + dot)/2)))); + SkAssertResult(normalB.setLength(fRadius / SkScalarSqrt((SK_Scalar1 + dot)/2))); fOuter.quadTo( pts[1].fX + normalB.fX, pts[1].fY + normalB.fY, pts[2].fX + normalBC->fX, pts[2].fY + normalBC->fY); @@ -761,11 +760,9 @@ DRAW_LINE: normalC = *unitNormalCD + unitBC; SkScalar dot = SkPoint::DotProduct(unitNormalAB, unitBC); - SkAssertResult(normalB.setLength(SkScalarDiv(fRadius, - SkScalarSqrt((SK_Scalar1 + dot)/2)))); + SkAssertResult(normalB.setLength(fRadius / SkScalarSqrt((SK_Scalar1 + dot)/2))); dot = SkPoint::DotProduct(*unitNormalCD, unitBC); - SkAssertResult(normalC.setLength(SkScalarDiv(fRadius, - SkScalarSqrt((SK_Scalar1 + dot)/2)))); + SkAssertResult(normalC.setLength(fRadius / SkScalarSqrt((SK_Scalar1 + dot)/2))); fOuter.cubicTo( pts[1].fX + normalB.fX, pts[1].fY + normalB.fY, pts[2].fX + normalC.fX, pts[2].fY + normalC.fY, diff --git a/src/core/SkStrokerPriv.cpp b/src/core/SkStrokerPriv.cpp index bc8e0435a1..7fc773a114 100644 --- a/src/core/SkStrokerPriv.cpp +++ b/src/core/SkStrokerPriv.cpp @@ -214,7 +214,7 @@ static void MiterJoiner(SkPath* outer, SkPath* inner, const SkVector& beforeUnit else mid.set(before.fX + after.fX, before.fY + after.fY); - mid.setLength(SkScalarDiv(radius, sinHalfAngle)); + mid.setLength(radius / sinHalfAngle); DO_MITER: if (prevIsLine) outer->setLastPt(pivot.fX + mid.fX, pivot.fY + mid.fY); diff --git a/src/device/xps/SkXPSDevice.cpp b/src/device/xps/SkXPSDevice.cpp index a5c001393d..1c06235aef 100644 --- a/src/device/xps/SkXPSDevice.cpp +++ b/src/device/xps/SkXPSDevice.cpp @@ -512,7 +512,7 @@ static void transform_offsets(SkScalar* stopOffsets, const int numOffsets, SkScalar startToStop = (stopTransformed.fX - startTransformed.fX) + (stopTransformed.fY - startTransformed.fY); //Percentage along transformed line. - stopOffsets[i] = SkScalarDiv(startToStop, startToEnd); + stopOffsets[i] = startToStop / startToEnd; } } @@ -1396,10 +1396,8 @@ void SkXPSDevice::convertToPpm(const SkMaskFilter* filter, SkVector* ppuScale, const SkIRect& clip, SkIRect* clipIRect) { //This action is in unit space, but the ppm is specified in physical space. - ppuScale->fX = SkScalarDiv(this->fCurrentPixelsPerMeter.fX, - this->fCurrentUnitsPerMeter.fX); - ppuScale->fY = SkScalarDiv(this->fCurrentPixelsPerMeter.fY, - this->fCurrentUnitsPerMeter.fY); + ppuScale->set(fCurrentPixelsPerMeter.fX / fCurrentUnitsPerMeter.fX, + fCurrentPixelsPerMeter.fY / fCurrentUnitsPerMeter.fY); matrix->postScale(ppuScale->fX, ppuScale->fY); diff --git a/src/effects/SkCornerPathEffect.cpp b/src/effects/SkCornerPathEffect.cpp index 79d4c4cbd3..4b81f261fe 100644 --- a/src/effects/SkCornerPathEffect.cpp +++ b/src/effects/SkCornerPathEffect.cpp @@ -20,13 +20,12 @@ static bool ComputeStep(const SkPoint& a, const SkPoint& b, SkScalar radius, SkPoint* step) { SkScalar dist = SkPoint::Distance(a, b); - step->set(b.fX - a.fX, b.fY - a.fY); - + *step = b - a; if (dist <= radius * 2) { - step->scale(SK_ScalarHalf); + *step *= SK_ScalarHalf; return false; } else { - step->scale(SkScalarDiv(radius, dist)); + *step *= radius / dist; return true; } } @@ -47,6 +46,7 @@ bool SkCornerPathEffect::filterPath(SkPath* dst, const SkPath& src, bool prevIsValid = true; // to avoid warnings + step.set(0, 0); moveTo.set(0, 0); firstStep.set(0, 0); lastCorner.set(0, 0); diff --git a/src/effects/SkDashPathEffect.cpp b/src/effects/SkDashPathEffect.cpp index 5296f972d5..62e6771356 100644 --- a/src/effects/SkDashPathEffect.cpp +++ b/src/effects/SkDashPathEffect.cpp @@ -248,7 +248,7 @@ bool SkDashPathEffect::asPoints(PointData* results, len2 -= clampedInitialDashLength; // skip initial partial empty } } - int numMidPoints = SkScalarFloorToInt(SkScalarDiv(len2, fIntervalLength)); + int numMidPoints = SkScalarFloorToInt(len2 / fIntervalLength); results->fNumPoints += numMidPoints; len2 -= numMidPoints * fIntervalLength; bool partialLast = false; diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp index 6f0911ce68..2b9665c2c8 100644 --- a/src/effects/SkDisplacementMapEffect.cpp +++ b/src/effects/SkDisplacementMapEffect.cpp @@ -56,7 +56,7 @@ void computeDisplacement(const SkVector& scale, SkBitmap* dst, SkBitmap* src, const SkIRect& bounds) { - static const SkScalar Inv8bit = SkScalarDiv(SK_Scalar1, 255.0f); + static const SkScalar Inv8bit = SkScalarInvert(255); const int srcW = src->width(); const int srcH = src->height(); const SkVector scaleForColor = SkVector::Make(SkScalarMul(scale.fX, Inv8bit), @@ -625,8 +625,8 @@ void GrGLDisplacementMapEffect::setData(const GrGLProgramDataManager& pdman, const GrProcessor& proc) { const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMapEffect>(); GrTexture* colorTex = displacementMap.texture(1); - SkScalar scaleX = SkScalarDiv(displacementMap.scale().fX, SkIntToScalar(colorTex->width())); - SkScalar scaleY = SkScalarDiv(displacementMap.scale().fY, SkIntToScalar(colorTex->height())); + SkScalar scaleX = displacementMap.scale().fX / colorTex->width(); + SkScalar scaleY = displacementMap.scale().fY / colorTex->height(); pdman.set2f(fScaleUni, SkScalarToFloat(scaleX), colorTex->origin() == kTopLeft_GrSurfaceOrigin ? SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY)); diff --git a/src/effects/SkEmbossMaskFilter.cpp b/src/effects/SkEmbossMaskFilter.cpp index 8fcd272646..59d297835e 100644 --- a/src/effects/SkEmbossMaskFilter.cpp +++ b/src/effects/SkEmbossMaskFilter.cpp @@ -61,7 +61,7 @@ static void normalize(SkScalar v[3]) { mag = SkScalarSqrt(mag); for (int i = 0; i < 3; i++) { - v[i] = SkScalarDiv(v[i], mag); + v[i] /= mag; } } diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp index 39bd6c88a1..b324cc46d1 100644 --- a/src/effects/SkLightingImageFilter.cpp +++ b/src/effects/SkLightingImageFilter.cpp @@ -30,8 +30,8 @@ typedef GrGLProgramDataManager::UniformHandle UniformHandle; namespace { -const SkScalar gOneThird = SkScalarInvert(SkIntToScalar(3)); -const SkScalar gTwoThirds = SkScalarDiv(SkIntToScalar(2), SkIntToScalar(3)); +const SkScalar gOneThird = SkIntToScalar(1) / 3; +const SkScalar gTwoThirds = SkIntToScalar(2) / 3; const SkScalar gOneHalf = 0.5f; const SkScalar gOneQuarter = 0.25f; diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp index 7114703168..c59bd8c120 100644 --- a/src/effects/SkPerlinNoiseShader.cpp +++ b/src/effects/SkPerlinNoiseShader.cpp @@ -212,8 +212,7 @@ private: SkScalar highFrequencx = SkScalarCeilToScalar(tileWidth * fBaseFrequency.fX) / tileWidth; // BaseFrequency should be non-negative according to the standard. - if (SkScalarDiv(fBaseFrequency.fX, lowFrequencx) < - SkScalarDiv(highFrequencx, fBaseFrequency.fX)) { + if (fBaseFrequency.fX / lowFrequencx < highFrequencx / fBaseFrequency.fX) { fBaseFrequency.fX = lowFrequencx; } else { fBaseFrequency.fX = highFrequencx; @@ -224,8 +223,7 @@ private: SkScalarFloorToScalar(tileHeight * fBaseFrequency.fY) / tileHeight; SkScalar highFrequency = SkScalarCeilToScalar(tileHeight * fBaseFrequency.fY) / tileHeight; - if (SkScalarDiv(fBaseFrequency.fY, lowFrequency) < - SkScalarDiv(highFrequency, fBaseFrequency.fY)) { + if (fBaseFrequency.fY / lowFrequency < highFrequency / fBaseFrequency.fY) { fBaseFrequency.fY = lowFrequency; } else { fBaseFrequency.fY = highFrequency; @@ -384,8 +382,9 @@ SkScalar SkPerlinNoiseShader::PerlinNoiseShaderContext::calculateTurbulenceValue SkScalar ratio = SK_Scalar1; for (int octave = 0; octave < perlinNoiseShader.fNumOctaves; ++octave) { SkScalar noise = noise2D(channel, stitchData, noiseVector); - turbulenceFunctionResult += SkScalarDiv( - (perlinNoiseShader.fType == kFractalNoise_Type) ? noise : SkScalarAbs(noise), ratio); + SkScalar numer = (perlinNoiseShader.fType == kFractalNoise_Type) ? + noise : SkScalarAbs(noise); + turbulenceFunctionResult += numer / ratio; noiseVector.fX *= 2; noiseVector.fY *= 2; ratio *= 2; @@ -406,8 +405,7 @@ SkScalar SkPerlinNoiseShader::PerlinNoiseShaderContext::calculateTurbulenceValue } if (channel == 3) { // Scale alpha by paint value - turbulenceFunctionResult = SkScalarMul(turbulenceFunctionResult, - SkScalarDiv(SkIntToScalar(getPaintAlpha()), SkIntToScalar(255))); + turbulenceFunctionResult *= SkIntToScalar(getPaintAlpha()) / 255; } // Clamp result @@ -931,7 +929,7 @@ void GrGLPerlinNoise::setData(const GrGLProgramDataManager& pdman, const GrProce const SkVector& baseFrequency = turbulence.baseFrequency(); pdman.set2f(fBaseFrequencyUni, baseFrequency.fX, baseFrequency.fY); - pdman.set1f(fAlphaUni, SkScalarDiv(SkIntToScalar(turbulence.alpha()), SkIntToScalar(255))); + pdman.set1f(fAlphaUni, SkIntToScalar(turbulence.alpha()) / 255); if (turbulence.stitchTiles()) { const SkPerlinNoiseShader::StitchData& stitchData = turbulence.stitchData(); diff --git a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp index bc70d6bca4..f7b3eb89b2 100644 --- a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp +++ b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp @@ -357,7 +357,7 @@ static ConicalType set_matrix_focal_conical(const SkTwoPointConicalGradient& sha // Scale factor 1 / (1 - focalX * focalX) SkScalar oneMinusF2 = 1.f - SkScalarMul(*focalX, *focalX); - SkScalar s = SkScalarDiv(1.f, oneMinusF2); + SkScalar s = SkScalarInvert(oneMinusF2); if (s >= 0.f) { @@ -1115,8 +1115,7 @@ private: : INHERITED(ctx, shader, matrix, tm), fInfo(info) { this->initClassID<CircleOutside2PtConicalEffect>(); if (shader.getStartRadius() != shader.getEndRadius()) { - fTLimit = SkScalarDiv(shader.getStartRadius(), - (shader.getStartRadius() - shader.getEndRadius())); + fTLimit = shader.getStartRadius() / (shader.getStartRadius() - shader.getEndRadius()); } else { fTLimit = SK_ScalarMin; } diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp index fea943b436..c68410fc6a 100644 --- a/src/gpu/GrAAConvexPathRenderer.cpp +++ b/src/gpu/GrAAConvexPathRenderer.cpp @@ -105,7 +105,7 @@ static void center_of_mass(const SegmentArray& segments, SkPoint* c) { *c = avg; } else { area *= 3; - area = SkScalarDiv(SK_Scalar1, area); + area = SkScalarInvert(area); center.fX = SkScalarMul(center.fX, area); center.fY = SkScalarMul(center.fY, area); // undo the translate of p0 to the origin. diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp index ebac42fcac..b562167424 100644 --- a/src/gpu/GrOvalRenderer.cpp +++ b/src/gpu/GrOvalRenderer.cpp @@ -1253,11 +1253,11 @@ public: const SkRect& bounds = geom.fBounds; // This adjusts the "radius" to include the half-pixel border - SkScalar offsetDx = SkScalarDiv(geom.fGeoDx, xRadius); - SkScalar offsetDy = SkScalarDiv(geom.fGeoDy, yRadius); + SkScalar offsetDx = geom.fGeoDx / xRadius; + SkScalar offsetDy = geom.fGeoDy / yRadius; - SkScalar innerRatioX = SkScalarDiv(xRadius, geom.fInnerXRadius); - SkScalar innerRatioY = SkScalarDiv(yRadius, geom.fInnerYRadius); + SkScalar innerRatioX = xRadius / geom.fInnerXRadius; + SkScalar innerRatioY = yRadius / geom.fInnerYRadius; verts[0].fPos = SkPoint::Make(bounds.fLeft, bounds.fTop); verts[0].fOuterOffset = SkPoint::Make(-1.0f - offsetDx, -1.0f - offsetDy); @@ -1386,8 +1386,8 @@ static GrBatch* create_diellipse_batch(GrColor color, SkScalar b = viewMatrix[SkMatrix::kMSkewX]; SkScalar c = viewMatrix[SkMatrix::kMSkewY]; SkScalar d = viewMatrix[SkMatrix::kMScaleY]; - SkScalar geoDx = SkScalarDiv(SK_ScalarHalf, SkScalarSqrt(a*a + c*c)); - SkScalar geoDy = SkScalarDiv(SK_ScalarHalf, SkScalarSqrt(b*b + d*d)); + SkScalar geoDx = SK_ScalarHalf / SkScalarSqrt(a*a + c*c); + SkScalar geoDy = SK_ScalarHalf / SkScalarSqrt(b*b + d*d); DIEllipseBatch::Geometry geometry; geometry.fViewMatrix = viewMatrix; diff --git a/src/gpu/GrPathUtils.cpp b/src/gpu/GrPathUtils.cpp index 2a906664f2..3e2c3bfe66 100644 --- a/src/gpu/GrPathUtils.cpp +++ b/src/gpu/GrPathUtils.cpp @@ -29,8 +29,7 @@ SkScalar GrPathUtils::scaleToleranceToSrc(SkScalar devTol, stretch = SkMaxScalar(stretch, mat.mapRadius(SK_Scalar1)); } } - srcTol = SkScalarDiv(srcTol, stretch); - return srcTol; + return srcTol / stretch; } static const int MAX_POINTS_PER_CURVE = 1 << 10; @@ -51,7 +50,7 @@ uint32_t GrPathUtils::quadraticPointCount(const SkPoint points[], // subdivide x = log4(d/tol) times. x subdivisions creates 2^(x) // points. // 2^(log4(x)) = sqrt(x); - SkScalar divSqrt = SkScalarSqrt(SkScalarDiv(d, tol)); + SkScalar divSqrt = SkScalarSqrt(d / tol); if (((SkScalar)SK_MaxS32) <= divSqrt) { return MAX_POINTS_PER_CURVE; } else { @@ -107,11 +106,11 @@ uint32_t GrPathUtils::cubicPointCount(const SkPoint points[], if (d <= tol) { return 1; } else { - SkScalar divSqrt = SkScalarSqrt(SkScalarDiv(d, tol)); + SkScalar divSqrt = SkScalarSqrt(d / tol); if (((SkScalar)SK_MaxS32) <= divSqrt) { return MAX_POINTS_PER_CURVE; } else { - int temp = SkScalarCeilToInt(SkScalarSqrt(SkScalarDiv(d, tol))); + int temp = SkScalarCeilToInt(SkScalarSqrt(d / tol)); int pow2 = GrNextPow2(temp); // Because of NaNs & INFs we can wind up with a degenerate temp // such that pow2 comes out negative. Also, our point generator diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp index bd2997cdf3..1ca56487c2 100644 --- a/src/gpu/effects/GrDashingEffect.cpp +++ b/src/gpu/effects/GrDashingEffect.cpp @@ -135,10 +135,10 @@ static SkScalar calc_end_adjustment(const SkScalar intervals[2], const SkPoint p } SkScalar srcIntervalLen = intervals[0] + intervals[1]; SkScalar totalLen = pts[1].fX - pts[0].fX; - SkScalar temp = SkScalarDiv(totalLen, srcIntervalLen); + SkScalar temp = totalLen / srcIntervalLen; SkScalar numFullIntervals = SkScalarFloorToScalar(temp); *endingInt = totalLen - numFullIntervals * srcIntervalLen + phase; - temp = SkScalarDiv(*endingInt, srcIntervalLen); + temp = *endingInt / srcIntervalLen; *endingInt = *endingInt - SkScalarFloorToScalar(temp) * srcIntervalLen; if (0 == *endingInt) { *endingInt = srcIntervalLen; diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index 814504e5e8..3b0d6f72ae 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -39,15 +39,12 @@ static void emit_pdf_color(SkColor color, SkWStream* result) { SkASSERT(SkColorGetA(color) == 0xFF); // We handle alpha elsewhere. - SkScalar colorMax = SkIntToScalar(0xFF); - SkPDFUtils::AppendScalar( - SkScalarDiv(SkIntToScalar(SkColorGetR(color)), colorMax), result); + SkScalar colorScale = SkScalarInvert(0xFF); + SkPDFUtils::AppendScalar(SkColorGetR(color) * colorScale, result); result->writeText(" "); - SkPDFUtils::AppendScalar( - SkScalarDiv(SkIntToScalar(SkColorGetG(color)), colorMax), result); + SkPDFUtils::AppendScalar(SkColorGetG(color) * colorScale, result); result->writeText(" "); - SkPDFUtils::AppendScalar( - SkScalarDiv(SkIntToScalar(SkColorGetB(color)), colorMax), result); + SkPDFUtils::AppendScalar(SkColorGetB(color) * colorScale, result); result->writeText(" "); } diff --git a/src/pdf/SkPDFGraphicState.cpp b/src/pdf/SkPDFGraphicState.cpp index d063c1505e..6cf66456ab 100644 --- a/src/pdf/SkPDFGraphicState.cpp +++ b/src/pdf/SkPDFGraphicState.cpp @@ -201,7 +201,7 @@ void SkPDFGraphicState::emitObject(SkWStream* stream, SkAutoTUnref<SkPDFDict> dict(SkNEW_ARGS(SkPDFDict, ("ExtGState"))); dict->insertName("Type", "ExtGState"); - SkScalar alpha = SkScalarDiv(fAlpha, 0xFF); + SkScalar alpha = SkIntToScalar(fAlpha) / 0xFF; dict->insertScalar("CA", alpha); dict->insertScalar("ca", alpha); diff --git a/src/pdf/SkPDFShader.cpp b/src/pdf/SkPDFShader.cpp index c2f0bc4677..c627c14257 100644 --- a/src/pdf/SkPDFShader.cpp +++ b/src/pdf/SkPDFShader.cpp @@ -58,7 +58,7 @@ static void interpolateColorCode(SkScalar range, SkScalar* curColor, // Figure out how to scale each color component. SkScalar multiplier[kColorComponents]; for (int i = 0; i < kColorComponents; i++) { - multiplier[i] = SkScalarDiv(curColor[i] - prevColor[i], range); + multiplier[i] = (curColor[i] - prevColor[i]) / range; } // Calculate when we no longer need to keep a copy of the input parameter t. @@ -1132,7 +1132,7 @@ SkPDFShader::State::State(const SkShader& shader, const SkMatrix& canvasTransfor static const SkScalar kMaxBitmapArea = 1024 * 1024; SkScalar bitmapArea = rasterScale * bbox.width() * rasterScale * bbox.height(); if (bitmapArea > kMaxBitmapArea) { - rasterScale *= SkScalarSqrt(SkScalarDiv(kMaxBitmapArea, bitmapArea)); + rasterScale *= SkScalarSqrt(kMaxBitmapArea / bitmapArea); } SkISize size = SkISize::Make(SkScalarRoundToInt(rasterScale * bbox.width()), diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp index 0a69b436e4..5c53b9d913 100644 --- a/src/ports/SkFontHost_FreeType.cpp +++ b/src/ports/SkFontHost_FreeType.cpp @@ -1198,8 +1198,7 @@ void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph) { // This means do not try to scale embedded bitmaps; only scale bitmaps in bitmap only fonts. if (!FT_IS_SCALABLE(fFace) && fScaleY && fFace->size->metrics.y_ppem) { // NOTE: both dimensions are scaled by y_ppem. this is WAI. - scaleGlyphMetrics(*glyph, SkScalarDiv(SkFixedToScalar(fScaleY), - SkIntToScalar(fFace->size->metrics.y_ppem))); + scaleGlyphMetrics(*glyph, SkFixedToScalar(fScaleY) / fFace->size->metrics.y_ppem); } #ifdef ENABLE_GLYPH_SPEW diff --git a/src/svg/parser/SkSVGSVG.cpp b/src/svg/parser/SkSVGSVG.cpp index fcce62de9e..61ccb3c819 100644 --- a/src/svg/parser/SkSVGSVG.cpp +++ b/src/svg/parser/SkSVGSVG.cpp @@ -43,11 +43,8 @@ void SkSVGSVG::translate(SkSVGParser& parser, bool defState) { if (strcmp(wSuffix, "pt") == 0) width = SkScalarMulDiv(width, SK_Scalar1 * 72, SK_Scalar1 * 96); SkParse::FindScalars(f_viewBox.c_str(), viewBox, 4); - SkRect box; - box.fLeft = SkScalarDiv(viewBox[0], width); - box.fTop = SkScalarDiv(viewBox[1], height); - box.fRight = SkScalarDiv(viewBox[2], width); - box.fBottom = SkScalarDiv(viewBox[3], height); + SkRect box = SkRect::MakeLTRB(viewBox[0] / width, viewBox[1] / height, + viewBox[2] / width, viewBox[3] / height); if (box.fLeft == 0 && box.fTop == 0 && box.fRight == SK_Scalar1 && box.fBottom == SK_Scalar1) return; diff --git a/src/utils/SkInterpolator.cpp b/src/utils/SkInterpolator.cpp index 97574e475b..03e7e4a83f 100644 --- a/src/utils/SkInterpolator.cpp +++ b/src/utils/SkInterpolator.cpp @@ -62,8 +62,7 @@ SkScalar SkInterpolatorBase::ComputeRelativeT(SkMSec time, SkMSec prevTime, SkMSec nextTime, const SkScalar blend[4]) { SkASSERT(time > prevTime && time < nextTime); - SkScalar t = SkScalarDiv((SkScalar)(time - prevTime), - (SkScalar)(nextTime - prevTime)); + SkScalar t = (SkScalar)(time - prevTime) / (SkScalar)(nextTime - prevTime); return blend ? SkUnitCubicInterp(t, blend[0], blend[1], blend[2], blend[3]) : t; } diff --git a/src/utils/SkNinePatch.cpp b/src/utils/SkNinePatch.cpp index 4e0d1d1a39..ce8d4801c6 100644 --- a/src/utils/SkNinePatch.cpp +++ b/src/utils/SkNinePatch.cpp @@ -161,7 +161,7 @@ void SkNinePatch::DrawMesh(SkCanvas* canvas, const SkRect& bounds, if (bounds.width() >= fixed) stretchX = (bounds.width() - fixed) / stretchSize; else // reuse stretchX, but keep it negative as a signal - stretchX = SkScalarDiv(-bounds.width(), fixed); + stretchX = -bounds.width() / fixed; } if (numYStretch > 0) { @@ -173,7 +173,7 @@ void SkNinePatch::DrawMesh(SkCanvas* canvas, const SkRect& bounds, if (bounds.height() >= fixed) stretchY = (bounds.height() - fixed) / stretchSize; else // reuse stretchX, but keep it negative as a signal - stretchY = SkScalarDiv(-bounds.height(), fixed); + stretchY = -bounds.height() / fixed; } #if 0 |