diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-12-12 22:01:06 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-12-12 22:01:06 +0000 |
commit | eb0fa29fc468e3f02d5a3b6456effd10b984f6ba (patch) | |
tree | 177e39ee9a0e7de8eed1eb9e17730d9fd02af4f4 /gm/arithmode.cpp | |
parent | f864ec467dfd518e32f6e4d709fafe57f1b3dbc6 (diff) |
try to make it draw correctly in fixed point
git-svn-id: http://skia.googlecode.com/svn/trunk@2860 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/arithmode.cpp')
-rw-r--r-- | gm/arithmode.cpp | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/gm/arithmode.cpp b/gm/arithmode.cpp index 4a7bef269d..21400fb22b 100644 --- a/gm/arithmode.cpp +++ b/gm/arithmode.cpp @@ -27,7 +27,7 @@ static SkBitmap make_src() { SkBitmap bm = make_bm(); SkCanvas canvas(bm); SkPaint paint; - SkPoint pts[] = { 0, 0, WW, HH }; + SkPoint pts[] = { 0, 0, SkIntToScalar(WW), SkIntToScalar(HH) }; SkColor colors[] = { SK_ColorBLACK, SK_ColorGREEN, SK_ColorCYAN, SK_ColorRED, SK_ColorMAGENTA, SK_ColorWHITE @@ -43,7 +43,7 @@ static SkBitmap make_dst() { SkBitmap bm = make_bm(); SkCanvas canvas(bm); SkPaint paint; - SkPoint pts[] = { 0, HH, WW, 0 }; + SkPoint pts[] = { 0, SkIntToScalar(HH), SkIntToScalar(WW), 0 }; SkColor colors[] = { SK_ColorBLUE, SK_ColorYELLOW, SK_ColorBLACK, SK_ColorGREEN, SK_ColorGRAY }; @@ -68,14 +68,14 @@ static SkBitmap make_arith(const SkBitmap& src, const SkBitmap& dst, static void show_k_text(SkCanvas* canvas, SkScalar x, SkScalar y, const SkScalar k[]) { SkPaint paint; - paint.setTextSize(24); + paint.setTextSize(SkIntToScalar(24)); paint.setAntiAlias(true); for (int i = 0; i < 4; ++i) { SkString str; str.appendScalar(k[i]); SkScalar width = paint.measureText(str.c_str(), str.size()); - canvas->drawText(str.c_str(), str.size(), x, y + 24, paint); - x += width + 10; + canvas->drawText(str.c_str(), str.size(), x, y + paint.getTextSize(), paint); + x += width + SkIntToScalar(10); } } @@ -95,25 +95,26 @@ protected: SkBitmap src = make_src(); SkBitmap dst = make_dst(); + const SkScalar one = SK_Scalar1; static const SkScalar K[] = { 0, 0, 0, 0, - 0, 0, 0, 1, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 1, 1, 0, - 0, 1, -1, 0, - 0, 0.5f, 0.5f, 0, - 0, 0.5f, 0.5f, 0.25f, - 0, 0.5f, 0.5f, -0.25f, - 0.25f, 0.5f, 0.5f, 0, - -0.25f, 0.5f, 0.5f, 0, + 0, 0, 0, one, + 0, one, 0, 0, + 0, 0, one, 0, + 0, one, one, 0, + 0, one, -one, 0, + 0, one/2, one/2, 0, + 0, one/2, one/2, one/4, + 0, one/2, one/2, -one/4, + one/4, one/2, one/2, 0, + -one/4, one/2, one/2, 0, }; const SkScalar* k = K; const SkScalar* stop = k + SK_ARRAY_COUNT(K); SkScalar y = 0; SkScalar x = 0; - SkScalar gap = src.width() + 20; + SkScalar gap = src.width() + SkIntToScalar(20); while (k < stop) { SkScalar x = 0; SkBitmap res = make_arith(src, dst, k); @@ -125,7 +126,7 @@ protected: x += gap; show_k_text(canvas, x, y, k); k += 4; - y += src.height() + 12; + y += src.height() + SkIntToScalar(12); } } |