diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-04-14 17:53:24 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-04-14 17:53:24 +0000 |
commit | 261b8e2ca1cf22303ad95267f0bdc6e87e1bbe70 (patch) | |
tree | 4790daae42b569ae19627a12a5d7ef8473e58f20 /samplecode | |
parent | 9ccdb95319e36dd58629117d9a5ea3c8581f7759 (diff) |
fix warnings
git-svn-id: http://skia.googlecode.com/svn/trunk@1129 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode')
-rw-r--r-- | samplecode/SampleAll.cpp | 2 | ||||
-rw-r--r-- | samplecode/SampleApp.cpp | 4 | ||||
-rw-r--r-- | samplecode/SampleBlur.cpp | 4 | ||||
-rw-r--r-- | samplecode/SampleCamera.cpp | 2 | ||||
-rw-r--r-- | samplecode/SampleCircle.cpp | 2 | ||||
-rw-r--r-- | samplecode/SampleCull.cpp | 4 | ||||
-rw-r--r-- | samplecode/SampleDither.cpp | 7 | ||||
-rw-r--r-- | samplecode/SampleDraw.cpp | 10 | ||||
-rw-r--r-- | samplecode/SampleEffects.cpp | 10 | ||||
-rw-r--r-- | samplecode/SampleFontScalerTest.cpp | 9 | ||||
-rw-r--r-- | samplecode/SampleFuzz.cpp | 16 | ||||
-rw-r--r-- | samplecode/SampleMipMap.cpp | 2 | ||||
-rw-r--r-- | samplecode/SamplePath.cpp | 8 | ||||
-rw-r--r-- | samplecode/SampleShaderText.cpp | 4 | ||||
-rw-r--r-- | samplecode/SampleStrokePath.cpp | 2 | ||||
-rw-r--r-- | samplecode/SampleStrokeText.cpp | 4 | ||||
-rw-r--r-- | samplecode/SampleText.cpp | 6 | ||||
-rw-r--r-- | samplecode/SampleTextBox.cpp | 1 | ||||
-rw-r--r-- | samplecode/SampleTextEffects.cpp | 2 |
19 files changed, 53 insertions, 46 deletions
diff --git a/samplecode/SampleAll.cpp b/samplecode/SampleAll.cpp index bc24cd3176..17b28299a4 100644 --- a/samplecode/SampleAll.cpp +++ b/samplecode/SampleAll.cpp @@ -437,7 +437,7 @@ protected: SkRect rect = {0, 0, SkIntToScalar(40), SkIntToScalar(40) }; SkRect rect2 = {0, 0, SkIntToScalar(65), SkIntToScalar(20) }; SkScalar left = 0, top = 0, x = 0, y = 0; - int index; + size_t index; char ascii[] = "ascii..."; size_t asciiLength = sizeof(ascii) - 1; diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index 5291b7edaa..8ca095867f 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -579,8 +579,8 @@ void SampleWindow::draw(SkCanvas* canvas) { int count = canvas->save(); canvas->resetMatrix(); // Ensure the mouse position is on screen. - int width = this->width(); - int height = this->height(); + int width = SkScalarRound(this->width()); + int height = SkScalarRound(this->height()); if (fMouseX >= width) fMouseX = width - 1; else if (fMouseX < 0) fMouseX = 0; if (fMouseY >= height) fMouseY = height - 1; diff --git a/samplecode/SampleBlur.cpp b/samplecode/SampleBlur.cpp index 8fbcc71852..d2ea2b0aeb 100644 --- a/samplecode/SampleBlur.cpp +++ b/samplecode/SampleBlur.cpp @@ -94,8 +94,8 @@ protected: } else { paint.setMaskFilter(NULL); } - canvas->drawCircle(200 + gRecs[i].fCx*100, - 200 + gRecs[i].fCy*100, 50, paint); + canvas->drawCircle(200 + gRecs[i].fCx*100.f, + 200 + gRecs[i].fCy*100.f, 50, paint); } // draw text { diff --git a/samplecode/SampleCamera.cpp b/samplecode/SampleCamera.cpp index c71cc4377e..66cb4e7f74 100644 --- a/samplecode/SampleCamera.cpp +++ b/samplecode/SampleCamera.cpp @@ -30,7 +30,7 @@ public: SkShader::kClamp_TileMode, SkShader::kClamp_TileMode); - SkRect src = { 0, 0, bm.width(), bm.height() }; + SkRect src = { 0, 0, SkIntToScalar(bm.width()), SkIntToScalar(bm.height()) }; SkRect dst = { -150, -150, 150, 150 }; SkMatrix matrix; matrix.setRectToRect(src, dst, SkMatrix::kFill_ScaleToFit); diff --git a/samplecode/SampleCircle.cpp b/samplecode/SampleCircle.cpp index 8f0436b7d7..1f9957d3e6 100644 --- a/samplecode/SampleCircle.cpp +++ b/samplecode/SampleCircle.cpp @@ -10,7 +10,7 @@ // see bug# 1504910 static void test_circlebounds(SkCanvas* canvas) { #ifdef SK_SCALAR_IS_FLOAT - SkRect r = { 1.39999998, 1, 21.3999996, 21 }; + SkRect r = { 1.39999998f, 1, 21.3999996f, 21 }; SkPath p; p.addOval(r); SkASSERT(r == p.getBounds()); diff --git a/samplecode/SampleCull.cpp b/samplecode/SampleCull.cpp index ea1bb779ec..fb6231dd41 100644 --- a/samplecode/SampleCull.cpp +++ b/samplecode/SampleCull.cpp @@ -106,8 +106,8 @@ public: SkRandom rand; for (int i = 0; i < 50; i++) { - int x = nextScalarRange(rand, -fClip.width()*1, fClip.width()*2); - int y = nextScalarRange(rand, -fClip.height()*1, fClip.height()*2); + SkScalar x = nextScalarRange(rand, -fClip.width()*1, fClip.width()*2); + SkScalar y = nextScalarRange(rand, -fClip.height()*1, fClip.height()*2); if (i == 0) fPath.moveTo(x, y); else diff --git a/samplecode/SampleDither.cpp b/samplecode/SampleDither.cpp index 64af007e5e..1199fa4316 100644 --- a/samplecode/SampleDither.cpp +++ b/samplecode/SampleDither.cpp @@ -77,15 +77,14 @@ static void make_bm(SkBitmap* bm) draw_sweep(&c, bm->width(), bm->height(), 0); } -static void pre_dither(const SkBitmap& bm) -{ +static void pre_dither(const SkBitmap& bm) { SkAutoLockPixels alp(bm); - for (unsigned y = 0; y < bm.height(); y++) { + for (int y = 0; y < bm.height(); y++) { DITHER_4444_SCAN(y); SkPMColor* p = bm.getAddr32(0, y); - for (unsigned x = 0; x < bm.width(); x++) { + for (int x = 0; x < bm.width(); x++) { SkPMColor c = *p; unsigned a = SkGetPackedA32(c); diff --git a/samplecode/SampleDraw.cpp b/samplecode/SampleDraw.cpp index d34403ed66..39a64cf26d 100644 --- a/samplecode/SampleDraw.cpp +++ b/samplecode/SampleDraw.cpp @@ -27,27 +27,27 @@ static void test_strokerect(SkCanvas* canvas) { SkRect r; r.set(10, 10, 14, 14); - r.offset(0.25, 0.3333); + r.offset(0.25f, 0.3333f); test_strokerect(canvas, r); canvas->translate(0, 20); r.set(10, 10, 14.5f, 14.5f); - r.offset(0.25, 0.3333); + r.offset(0.25f, 0.3333f); test_strokerect(canvas, r); canvas->translate(0, 20); r.set(10, 10, 14.5f, 20); - r.offset(0.25, 0.3333); + r.offset(0.25f, 0.3333f); test_strokerect(canvas, r); canvas->translate(0, 20); r.set(10, 10, 20, 14.5f); - r.offset(0.25, 0.3333); + r.offset(0.25f, 0.3333f); test_strokerect(canvas, r); canvas->translate(0, 20); r.set(10, 10, 20, 20); - r.offset(0.25, 0.3333); + r.offset(0.25f, 0.3333f); test_strokerect(canvas, r); canvas->translate(0, 20); diff --git a/samplecode/SampleEffects.cpp b/samplecode/SampleEffects.cpp index 7b6191178f..97853c3c6b 100644 --- a/samplecode/SampleEffects.cpp +++ b/samplecode/SampleEffects.cpp @@ -12,10 +12,10 @@ static void test_edgeclipper() { SkPoint pts[] = { - { -8.38822452e+21, -7.69721471e+19 }, - { 1.57645875e+23, 1.44634003e+21 }, - { 1.61519691e+23, 1.48208059e+21 }, - { 3.13963584e+23, 2.88057438e+21 } + { -8.38822452e+21f, -7.69721471e+19f }, + { 1.57645875e+23f, 1.44634003e+21f }, + { 1.61519691e+23f, 1.48208059e+21f }, + { 3.13963584e+23f, 2.88057438e+21f } }; SkRect clip = { 0, 0, 300, 200 }; @@ -39,7 +39,7 @@ static void paint_proc1(SkPaint* paint) { static void paint_proc2(SkPaint* paint) { SkScalar dir[3] = { 1, 1, 1}; paint->setMaskFilter( - SkBlurMaskFilter::CreateEmboss(dir, 0.1, 0.05, 1))->unref(); + SkBlurMaskFilter::CreateEmboss(dir, 0.1f, 0.05f, 1))->unref(); } static void paint_proc3(SkPaint* paint) { diff --git a/samplecode/SampleFontScalerTest.cpp b/samplecode/SampleFontScalerTest.cpp index de70292520..c481503667 100644 --- a/samplecode/SampleFontScalerTest.cpp +++ b/samplecode/SampleFontScalerTest.cpp @@ -68,10 +68,10 @@ protected: // test handling of obscene cubic values (currently broken) if (false) { SkPoint pts[4]; - pts[0].set(1.61061274e+09, 6291456); - pts[1].set(-7.18397061e+15, -1.53091184e+13); - pts[2].set(-1.30077315e+16, -2.77196141e+13); - pts[3].set(-1.30077315e+16, -2.77196162e+13); + pts[0].set(1.61061274e+09f, 6291456); + pts[1].set(-7.18397061e+15f, -1.53091184e+13f); + pts[2].set(-1.30077315e+16f, -2.77196141e+13f); + pts[3].set(-1.30077315e+16f, -2.77196162e+13f); SkPath path; path.moveTo(pts[0]); @@ -83,6 +83,7 @@ protected: canvas->rotate(30); paint.setAntiAlias(true); + paint.setLCDRenderText(true); SkSafeUnref(paint.setTypeface(SkTypeface::CreateFromName("Times Roman", SkTypeface::kNormal))); // const char* text = "abcdefghijklmnopqrstuvwxyz"; diff --git a/samplecode/SampleFuzz.cpp b/samplecode/SampleFuzz.cpp index c6f45d6b0a..9be3c81204 100644 --- a/samplecode/SampleFuzz.cpp +++ b/samplecode/SampleFuzz.cpp @@ -31,6 +31,12 @@ static int R(float x) { return (int)floor(SkScalarToFloat(gRand.nextUScalar1()) * x); } +static float huge() { + double d = 1e100; + float f = (float)d; + return f; +} + static float make_number() { float v; int sel; @@ -38,15 +44,15 @@ static float make_number() { if (return_large == true && R(3) == 1) sel = R(6); else sel = R(4); if (return_undef == false && sel == 0) sel = 1; - if (R(2) == 1) v = R(100); else + if (R(2) == 1) v = (float)R(100); else switch (sel) { case 0: break; case 1: v = 0; break; - case 2: v = 0.000001; break; + case 2: v = 0.000001f; break; case 3: v = 10000; break; case 4: v = 2000000000; break; - case 5: v = 1e100; break; + case 5: v = huge(); break; } if (R(4) == 1) v = -v; @@ -303,8 +309,8 @@ static void do_fuzz(SkCanvas* canvas) { case 0: canvas->scale(-1000000000,1); canvas->scale(-1000000000,1); scval = 1; break; - case 1: canvas->scale(-.000000001,1); scval = 2; break; - case 2: canvas->scale(-.000000001,1); scval = 0; break; + case 1: canvas->scale(-.000000001f,1); scval = 2; break; + case 2: canvas->scale(-.000000001f,1); scval = 0; break; } } diff --git a/samplecode/SampleMipMap.cpp b/samplecode/SampleMipMap.cpp index 6e0efe0d3a..fd3f5cf437 100644 --- a/samplecode/SampleMipMap.cpp +++ b/samplecode/SampleMipMap.cpp @@ -88,7 +88,7 @@ protected: canvas->translate(SkIntToScalar(10), SkIntToScalar(10)); - canvas->scale(1.00000001, 0.9999999); + canvas->scale(1.00000001f, 0.9999999f); drawN2(canvas, fBitmap); diff --git a/samplecode/SamplePath.cpp b/samplecode/SamplePath.cpp index 2c8e8c2026..187de223a0 100644 --- a/samplecode/SamplePath.cpp +++ b/samplecode/SamplePath.cpp @@ -21,10 +21,10 @@ // http://code.google.com/p/skia/issues/detail?id=32 static void test_cubic() { SkPoint src[4] = { - { 556.25000, 523.03003 }, - { 556.23999, 522.96002 }, - { 556.21997, 522.89001 }, - { 556.21997, 522.82001 } + { 556.25000f, 523.03003f }, + { 556.23999f, 522.96002f }, + { 556.21997f, 522.89001f }, + { 556.21997f, 522.82001f } }; SkPoint dst[11]; dst[10].set(42, -42); // one past the end, that we don't clobber these diff --git a/samplecode/SampleShaderText.cpp b/samplecode/SampleShaderText.cpp index 36692d292a..a3cb6808ad 100644 --- a/samplecode/SampleShaderText.cpp +++ b/samplecode/SampleShaderText.cpp @@ -10,7 +10,7 @@ static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) { bm->eraseColor(0); SkCanvas canvas(*bm); - SkScalar s = w < h ? w : h; + SkScalar s = SkIntToScalar(w < h ? w : h); SkPoint pts[] = { 0, 0, s, s }; SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE }; SkScalar pos[] = { 0, SK_Scalar1/2, SK_Scalar1 }; @@ -122,7 +122,7 @@ protected: const char text[] = "Shaded Text"; const int textLen = SK_ARRAY_COUNT(text) - 1; - static int pointSize = SkIntToScalar(48); + static int pointSize = 48; int w = pointSize * textLen; int h = pointSize; diff --git a/samplecode/SampleStrokePath.cpp b/samplecode/SampleStrokePath.cpp index e7914dbe30..3691ac65c6 100644 --- a/samplecode/SampleStrokePath.cpp +++ b/samplecode/SampleStrokePath.cpp @@ -171,7 +171,7 @@ protected: mf = SkBlurMaskFilter::Create(radius, gStyle[x - 1]); paint.setMaskFilter(mf)->unref(); } - canvas->drawText("Title Bar", 9, x*100, y*30, paint); + canvas->drawText("Title Bar", 9, x*SkIntToScalar(100), y*SkIntToScalar(30), paint); radius *= 0.75f; } diff --git a/samplecode/SampleStrokeText.cpp b/samplecode/SampleStrokeText.cpp index a527bd26ad..e75bb54ca2 100644 --- a/samplecode/SampleStrokeText.cpp +++ b/samplecode/SampleStrokeText.cpp @@ -23,7 +23,7 @@ static void lettersToBitmap(SkBitmap* dst, const char chars[], SkScalar x = 0; SkScalar width; SkPath p; - for (int i = 0; i < strlen(chars); i++) { + for (size_t i = 0; i < strlen(chars); i++) { original.getTextPath(&chars[i], 1, x, 0, &p); path.addPath(p); original.getTextWidths(&chars[i], 1, &width); @@ -69,7 +69,7 @@ static void lettersToBitmap2(SkBitmap* dst, const char chars[], SkScalar x = 0; SkScalar width; SkPath p; - for (int i = 0; i < strlen(chars); i++) { + for (size_t i = 0; i < strlen(chars); i++) { original.getTextPath(&chars[i], 1, x, 0, &p); path.addPath(p); original.getTextWidths(&chars[i], 1, &width); diff --git a/samplecode/SampleText.cpp b/samplecode/SampleText.cpp index b1bb6cbc9f..c1090eefb9 100644 --- a/samplecode/SampleText.cpp +++ b/samplecode/SampleText.cpp @@ -134,12 +134,12 @@ static void test_breakText() SkASSERT(m > mm); } } - nn = n; + nn = SkIntToScalar(n); mm = m; } - nn = paint.breakText(text, length, width, &mm); - SkASSERT(nn == length); + int length2 = paint.breakText(text, length, width, &mm); + SkASSERT(length2 == length); SkASSERT(mm == width); } diff --git a/samplecode/SampleTextBox.cpp b/samplecode/SampleTextBox.cpp index f2b5e2c33b..a2db0117cd 100644 --- a/samplecode/SampleTextBox.cpp +++ b/samplecode/SampleTextBox.cpp @@ -76,6 +76,7 @@ protected: SkPaint paint; paint.setAntiAlias(true); + paint.setLCDRenderText(true); tbox.setText(gText, strlen(gText), paint); for (int i = 9; i < 24; i += 2) { diff --git a/samplecode/SampleTextEffects.cpp b/samplecode/SampleTextEffects.cpp index 77a3bd795a..bd134d0d23 100644 --- a/samplecode/SampleTextEffects.cpp +++ b/samplecode/SampleTextEffects.cpp @@ -17,7 +17,7 @@ static inline SkPMColor rgb2gray(SkPMColor c) unsigned g = SkGetPackedG32(c); unsigned b = SkGetPackedB32(c); - unsigned x = r * 5 + g * 7 + b * 4 >> 4; + unsigned x = (r * 5 + g * 7 + b * 4) >> 4; return SkPackARGB32(0, x, x, x) | (c & (SK_A32_MASK << SK_A32_SHIFT)); } |