diff options
-rw-r--r-- | experimental/AndroidPathRenderer/AndroidPathRenderer.cpp | 10 | ||||
-rw-r--r-- | gm/blurrect.cpp | 37 | ||||
-rw-r--r-- | gm/dashing.cpp | 2 | ||||
-rw-r--r-- | samplecode/SampleRotateCircles.cpp | 11 | ||||
-rw-r--r-- | src/core/SkBitmap.cpp | 4 | ||||
-rw-r--r-- | src/utils/SkDeferredCanvas.cpp | 2 |
6 files changed, 35 insertions, 31 deletions
diff --git a/experimental/AndroidPathRenderer/AndroidPathRenderer.cpp b/experimental/AndroidPathRenderer/AndroidPathRenderer.cpp index 3ade9e6fb0..051ed19738 100644 --- a/experimental/AndroidPathRenderer/AndroidPathRenderer.cpp +++ b/experimental/AndroidPathRenderer/AndroidPathRenderer.cpp @@ -52,8 +52,8 @@ inline void computeInverseScales(const SkMatrix* transform, float &inverseScaleX float m01 = transform->getSkewY(); float m10 = transform->getSkewX(); float m11 = transform->getScaleY(); - float scaleX = sqrt(m00 * m00 + m01 * m01); - float scaleY = sqrt(m10 * m10 + m11 * m11); + float scaleX = sk_float_sqrt(m00 * m00 + m01 * m01); + float scaleY = sk_float_sqrt(m10 * m10 + m11 * m11); inverseScaleX = (scaleX != 0) ? (1.0f / scaleX) : 1.0f; inverseScaleY = (scaleY != 0) ? (1.0f / scaleY) : 1.0f; } else { @@ -82,7 +82,7 @@ inline void copyAlphaVertex(AlphaVertex* destPtr, const AlphaVertex* srcPtr) { */ inline SkVector totalOffsetFromNormals(const SkVector& normalA, const SkVector& normalB) { SkVector pseudoNormal = normalA + normalB; - pseudoNormal.scale(1.0f / (1.0f + fabs(normalA.dot(normalB)))); + pseudoNormal.scale(1.0f / (1.0f + sk_float_abs(normalA.dot(normalB)))); return pseudoNormal; } @@ -661,8 +661,8 @@ void PathRenderer::RecursiveCubicBezierVertices( float sqrInvScaleX, float sqrInvScaleY, SkTArray<Vertex, true>* outputVertices) { float dx = p2x - p1x; float dy = p2y - p1y; - float d1 = fabs((c1x - p2x) * dy - (c1y - p2y) * dx); - float d2 = fabs((c2x - p2x) * dy - (c2y - p2y) * dx); + float d1 = sk_float_abs((c1x - p2x) * dy - (c1y - p2y) * dx); + float d2 = sk_float_abs((c2x - p2x) * dy - (c2y - p2y) * dx); float d = d1 + d2; // multiplying by sqrInvScaleY/X equivalent to multiplying in dimensional scale factors diff --git a/gm/blurrect.cpp b/gm/blurrect.cpp index a7598fe2d3..a1faf9480f 100644 --- a/gm/blurrect.cpp +++ b/gm/blurrect.cpp @@ -138,7 +138,7 @@ private: class BlurRectCompareGM : public skiagm::GM { SkString fName; unsigned int fRectWidth, fRectHeight; - float fRadius; + SkScalar fRadius; public: BlurRectCompareGM(const char name[], unsigned int rectWidth, unsigned int rectHeight, float radius) : fName(name) @@ -149,7 +149,7 @@ public: int width() const { return fRectWidth; } int height() const { return fRectHeight; } - int radius() const { return fRadius; } + SkScalar radius() const { return fRadius; } protected: virtual SkString onShortName() { @@ -160,7 +160,7 @@ protected: return SkISize::Make(640, 480); } - virtual void makeMask( SkMask *m, SkRect r ) = 0; + virtual void makeMask( SkMask *m, const SkRect& ) = 0; virtual void onDraw(SkCanvas* canvas) { SkRect r; @@ -184,12 +184,14 @@ private: class BlurRectFastGM: public BlurRectCompareGM { public: - BlurRectFastGM(const char name[], unsigned int rect_width, unsigned int rect_height, float blur_radius) : - BlurRectCompareGM( name, rect_width, rect_height, blur_radius ) {} + BlurRectFastGM(const char name[], unsigned int rect_width, + unsigned int rect_height, float blur_radius) : + BlurRectCompareGM( name, rect_width, rect_height, blur_radius ) {} protected: - virtual void makeMask( SkMask *m, SkRect r ) { - SkBlurMask::BlurRect( m, r, radius(), SkBlurMask::kNormal_Style, SkBlurMask::kHigh_Quality ); - } + virtual void makeMask( SkMask *m, const SkRect& r) SK_OVERRIDE { + SkBlurMask::BlurRect( m, r, radius(), SkBlurMask::kNormal_Style, + SkBlurMask::kHigh_Quality ); + } }; class BlurRectSlowGM: public BlurRectCompareGM { @@ -197,17 +199,18 @@ public: BlurRectSlowGM(const char name[], unsigned int rect_width, unsigned int rect_height, float blur_radius) : BlurRectCompareGM( name, rect_width, rect_height, blur_radius ) {} protected: - virtual void makeMask( SkMask *m, SkRect r ) { - SkMask src; - src.fFormat = SkMask::kA8_Format; - src.fRowBytes = r.width(); - src.fBounds = SkIRect::MakeWH(r.width(), r.height()); - src.fImage = SkMask::AllocImage( src.computeTotalImageSize() ); + virtual void makeMask( SkMask *m, const SkRect& r) SK_OVERRIDE { + SkMask src; + r.roundOut(&src.fBounds); + src.fBounds.offset(-src.fBounds.fLeft, -src.fBounds.fTop); // move to origin + src.fFormat = SkMask::kA8_Format; + src.fRowBytes = src.fBounds.width(); + src.fImage = SkMask::AllocImage( src.computeTotalImageSize() ); - memset( src.fImage, 0xff, src.computeTotalImageSize() ); + memset( src.fImage, 0xff, src.computeTotalImageSize() ); - SkBlurMask::BlurSeparable( m, src, radius()/2, SkBlurMask::kNormal_Style, SkBlurMask::kHigh_Quality ); - } + SkBlurMask::BlurSeparable( m, src, radius()/2, SkBlurMask::kNormal_Style, SkBlurMask::kHigh_Quality ); + } }; diff --git a/gm/dashing.cpp b/gm/dashing.cpp index 70fb9b1fa2..914824d885 100644 --- a/gm/dashing.cpp +++ b/gm/dashing.cpp @@ -245,7 +245,7 @@ protected: // 1on/1off 1x1 squares with phase of 1 and non-integer length - rects fastpath canvas->save(); canvas->translate(332, 0); - this->drawDashedLines(canvas, 99.5, SK_ScalarHalf, SK_Scalar1, 1, false); + this->drawDashedLines(canvas, 99.5f, SK_ScalarHalf, SK_Scalar1, 1, false); canvas->restore(); // 1on/1off 3x3 squares with phase of 0 - points fast path diff --git a/samplecode/SampleRotateCircles.cpp b/samplecode/SampleRotateCircles.cpp index 32a46a3bcc..5bac6cf127 100644 --- a/samplecode/SampleRotateCircles.cpp +++ b/samplecode/SampleRotateCircles.cpp @@ -249,11 +249,12 @@ protected: SkPoint pos, tan; for (SkScalar dist = 0; dist <= total; dist += delta) { - (void)meas.getPosTan(dist, &pos, &tan); - tan.scale(radius); - tan.rotateCCW(); - canvas->drawLine(pos.x() + tan.x(), pos.y() + tan.y(), - pos.x() - tan.x(), pos.y() - tan.y(), paint); + if (meas.getPosTan(dist, &pos, &tan)) { + tan.scale(radius); + tan.rotateCCW(); + canvas->drawLine(pos.x() + tan.x(), pos.y() + tan.y(), + pos.x() - tan.x(), pos.y() - tan.y(), paint); + } } } diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp index 5554f46ce6..f0dafc17fa 100644 --- a/src/core/SkBitmap.cpp +++ b/src/core/SkBitmap.cpp @@ -701,7 +701,7 @@ bool SkBitmap::ComputeIsOpaque(const SkBitmap& bm) { if (!table) { return false; } - SkPMColor c = ~0; + SkPMColor c = (SkPMColor)~0; for (int i = bm.getColorTable()->count() - 1; i >= 0; --i) { c &= table[i]; } @@ -724,7 +724,7 @@ bool SkBitmap::ComputeIsOpaque(const SkBitmap& bm) { return true; } break; case SkBitmap::kARGB_8888_Config: { - SkPMColor c = ~0; + SkPMColor c = (SkPMColor)~0; for (int y = 0; y < height; ++y) { const SkPMColor* row = bm.getAddr32(0, y); for (int x = 0; x < width; ++x) { diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp index a1e32bc373..26ac088809 100644 --- a/src/utils/SkDeferredCanvas.cpp +++ b/src/utils/SkDeferredCanvas.cpp @@ -20,7 +20,7 @@ enum { // Deferred canvas will auto-flush when recording reaches this limit kDefaultMaxRecordingStorageBytes = 64*1024*1024, - kDeferredCanvasBitmapSizeThreshold = ~0, // Disables this feature + kDeferredCanvasBitmapSizeThreshold = ~0U, // Disables this feature }; enum PlaybackMode { |