Fix gm tests for fixed point.

git-svn-id: http://skia.googlecode.com/svn/trunk@1389 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
bungeman@google.com 2011-05-20 14:05:03 +00:00
parent 0368d06a29
commit 3c14d0f3d1
4 changed files with 52 additions and 37 deletions

View File

@ -5,14 +5,14 @@ namespace skiagm {
class BlursGM : public GM {
public:
BlursGM() {}
BlursGM() {}
protected:
virtual SkString onShortName() {
return SkString("blurs");
}
virtual SkISize onISize() {
virtual SkISize onISize() {
return make_isize(700, 500);
}
@ -37,8 +37,8 @@ protected:
SkPaint paint;
paint.setAntiAlias(true);
paint.setTextSize(25);
canvas->translate(-40, 0);
paint.setTextSize(SkIntToScalar(25));
canvas->translate(SkIntToScalar(-40), SkIntToScalar(0));
SkBlurMaskFilter::BlurFlags flags = SkBlurMaskFilter::kNone_BlurFlag;
for (int j = 0; j < 2; j++) {
@ -46,27 +46,32 @@ protected:
paint.setColor(SK_ColorBLUE);
for (size_t i = 0; i < SK_ARRAY_COUNT(gRecs); i++) {
if (gRecs[i].fStyle != NONE) {
SkMaskFilter* mf = SkBlurMaskFilter::Create(20,
gRecs[i].fStyle,
flags);
SkMaskFilter* mf = SkBlurMaskFilter::Create(
SkIntToScalar(20), gRecs[i].fStyle, flags
);
paint.setMaskFilter(mf)->unref();
} else {
paint.setMaskFilter(NULL);
}
canvas->drawCircle(200 + gRecs[i].fCx*100,
200 + gRecs[i].fCy*100, 50, paint);
canvas->drawCircle(SkIntToScalar(200 + gRecs[i].fCx*100)
, SkIntToScalar(200 + gRecs[i].fCy*100)
, SkIntToScalar(50)
, paint);
}
// draw text
{
SkMaskFilter* mf = SkBlurMaskFilter::Create(4,
SkBlurMaskFilter::kNormal_BlurStyle,
flags);
SkMaskFilter* mf = SkBlurMaskFilter::Create(
SkIntToScalar(4)
, SkBlurMaskFilter::kNormal_BlurStyle
, flags
);
paint.setMaskFilter(mf)->unref();
SkScalar x = SkIntToScalar(70);
SkScalar y = SkIntToScalar(400);
paint.setColor(SK_ColorBLACK);
canvas->drawText("Hamburgefons Style", 18, x, y, paint);
canvas->drawText("Hamburgefons Style", 18, x, y + SkIntToScalar(50), paint);
canvas->drawText("Hamburgefons Style", 18
, x, y + SkIntToScalar(50), paint);
paint.setMaskFilter(NULL);
paint.setColor(SK_ColorWHITE);
x -= SkIntToScalar(2);
@ -75,7 +80,7 @@ protected:
}
canvas->restore();
flags = SkBlurMaskFilter::kHighQuality_BlurFlag;
canvas->translate(350, 0);
canvas->translate(SkIntToScalar(350), SkIntToScalar(0));
}
}

View File

@ -4,14 +4,14 @@ namespace skiagm {
class NoColorBleedGM : public GM {
public:
NoColorBleedGM() {}
NoColorBleedGM() {}
protected:
virtual SkString onShortName() {
return SkString("nocolorbleed");
}
virtual SkISize onISize() {
virtual SkISize onISize() {
return make_isize(200, 200);
}
@ -45,15 +45,19 @@ protected:
paint.setFilterBitmap(true);
//First row : full texture with and without filtering
srcRect.setXYWH(0, 0, 4, 4);
dstRect.setXYWH(0.0f, 0.0f, 100.0f, 100.0f);
dstRect.setXYWH(SkIntToScalar(0), SkIntToScalar(0)
, SkIntToScalar(100), SkIntToScalar(100));
canvas->drawBitmapRect(sprite, &srcRect, dstRect, &paint);
dstRect.setXYWH(100.0f, 0.0f, 100.0f, 100.0f);
dstRect.setXYWH(SkIntToScalar(100), SkIntToScalar(0)
, SkIntToScalar(100), SkIntToScalar(100));
canvas->drawBitmapRect(sprite, &srcRect, dstRect);
//Second row : sub rect of texture with and without filtering
srcRect.setXYWH(1, 1, 2, 2);
dstRect.setXYWH(25.0f, 125.0f, 50.0f, 50.0f);
dstRect.setXYWH(SkIntToScalar(25), SkIntToScalar(125)
, SkIntToScalar(50), SkIntToScalar(50));
canvas->drawBitmapRect(sprite, &srcRect, dstRect, &paint);
dstRect.setXYWH(125.0f, 125.0f, 50.0f, 50.0f);
dstRect.setXYWH(SkIntToScalar(125), SkIntToScalar(125)
, SkIntToScalar(50), SkIntToScalar(50));
canvas->drawBitmapRect(sprite, &srcRect, dstRect);
}

View File

@ -6,14 +6,15 @@
typedef SkScalar (*MakePathProc)(SkPath*);
static SkScalar make_frame(SkPath* path) {
SkRect r = { 10, 10, 630, 470 };
path->addRoundRect(r, 15, 15);
SkRect r = { SkIntToScalar(10), SkIntToScalar(10),
SkIntToScalar(630), SkIntToScalar(470) };
path->addRoundRect(r, SkIntToScalar(15), SkIntToScalar(15));
SkPaint paint;
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(5);
paint.setStrokeWidth(SkIntToScalar(5));
paint.getFillPath(*path, path);
return 15;
return SkIntToScalar(15);
}
static SkScalar make_triangle(SkPath* path) {
@ -24,21 +25,23 @@ static SkScalar make_triangle(SkPath* path) {
path->lineTo(SkIntToScalar(gCoord[2]), SkIntToScalar(gCoord[3]));
path->lineTo(SkIntToScalar(gCoord[4]), SkIntToScalar(gCoord[5]));
path->close();
path->offset(10, 0);
path->offset(SkIntToScalar(10), SkIntToScalar(0));
return SkIntToScalar(30);
}
static SkScalar make_rect(SkPath* path) {
SkRect r = { 10, 10, 30, 30 };
SkRect r = { SkIntToScalar(10), SkIntToScalar(10),
SkIntToScalar(30), SkIntToScalar(30) };
path->addRect(r);
path->offset(10, 0);
path->offset(SkIntToScalar(10), SkIntToScalar(0));
return SkIntToScalar(30);
}
static SkScalar make_oval(SkPath* path) {
SkRect r = { 10, 10, 30, 30 };
SkRect r = { SkIntToScalar(10), SkIntToScalar(10),
SkIntToScalar(30), SkIntToScalar(30) };
path->addOval(r);
path->offset(10, 0);
path->offset(SkIntToScalar(10), SkIntToScalar(0));
return SkIntToScalar(30);
}
@ -56,8 +59,8 @@ static SkScalar make_sawtooth(SkPath* path) {
x += dx;
path->lineTo(x, y + dy);
}
path->lineTo(x, y + 2 * dy);
path->lineTo(x0, y + 2 * dy);
path->lineTo(x, y + (2 * dy));
path->lineTo(x0, y + (2 * dy));
path->close();
return SkIntToScalar(30);
}
@ -100,7 +103,7 @@ class PathFillGM : public GM {
SkPath fPath[N];
SkScalar fDY[N];
public:
PathFillGM() {
PathFillGM() {
for (size_t i = 0; i < N; i++) {
fDY[i] = gProcs[i](&fPath[i]);
}
@ -111,7 +114,7 @@ protected:
return SkString("pathfill");
}
virtual SkISize onISize() {
virtual SkISize onISize() {
return make_isize(640, 480);
}
@ -127,7 +130,7 @@ protected:
for (size_t i = 0; i < N; i++) {
canvas->drawPath(fPath[i], paint);
canvas->translate(0, fDY[i]);
canvas->translate(SkIntToScalar(0), fDY[i]);
}
}

View File

@ -29,14 +29,14 @@ static const SkScalar SH = SkIntToScalar(H);
class StrokeRectGM : public GM {
public:
StrokeRectGM() {}
StrokeRectGM() {}
protected:
virtual SkString onShortName() {
return SkString("strokerects");
}
virtual SkISize onISize() {
virtual SkISize onISize() {
return make_isize(W*2, H*2);
}
@ -63,7 +63,10 @@ protected:
SkAutoCanvasRestore acr(canvas, true);
canvas->translate(SW * x, SH * y);
canvas->clipRect(SkRect::MakeLTRB(SkIntToScalar(2), SkIntToScalar(2), SW - SkIntToScalar(2), SH - SkIntToScalar(2)));
canvas->clipRect(SkRect::MakeLTRB(
SkIntToScalar(2), SkIntToScalar(2)
, SW - SkIntToScalar(2), SH - SkIntToScalar(2)
));
SkRandom rand;
for (int i = 0; i < N; i++) {