зеркало из https://github.com/mozilla/moz-skia.git
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:
Родитель
0368d06a29
Коммит
3c14d0f3d1
33
gm/blurs.cpp
33
gm/blurs.cpp
|
@ -5,14 +5,14 @@ namespace skiagm {
|
||||||
|
|
||||||
class BlursGM : public GM {
|
class BlursGM : public GM {
|
||||||
public:
|
public:
|
||||||
BlursGM() {}
|
BlursGM() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual SkString onShortName() {
|
virtual SkString onShortName() {
|
||||||
return SkString("blurs");
|
return SkString("blurs");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual SkISize onISize() {
|
virtual SkISize onISize() {
|
||||||
return make_isize(700, 500);
|
return make_isize(700, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,8 +37,8 @@ protected:
|
||||||
|
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
paint.setTextSize(25);
|
paint.setTextSize(SkIntToScalar(25));
|
||||||
canvas->translate(-40, 0);
|
canvas->translate(SkIntToScalar(-40), SkIntToScalar(0));
|
||||||
|
|
||||||
SkBlurMaskFilter::BlurFlags flags = SkBlurMaskFilter::kNone_BlurFlag;
|
SkBlurMaskFilter::BlurFlags flags = SkBlurMaskFilter::kNone_BlurFlag;
|
||||||
for (int j = 0; j < 2; j++) {
|
for (int j = 0; j < 2; j++) {
|
||||||
|
@ -46,27 +46,32 @@ protected:
|
||||||
paint.setColor(SK_ColorBLUE);
|
paint.setColor(SK_ColorBLUE);
|
||||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gRecs); i++) {
|
for (size_t i = 0; i < SK_ARRAY_COUNT(gRecs); i++) {
|
||||||
if (gRecs[i].fStyle != NONE) {
|
if (gRecs[i].fStyle != NONE) {
|
||||||
SkMaskFilter* mf = SkBlurMaskFilter::Create(20,
|
SkMaskFilter* mf = SkBlurMaskFilter::Create(
|
||||||
gRecs[i].fStyle,
|
SkIntToScalar(20), gRecs[i].fStyle, flags
|
||||||
flags);
|
);
|
||||||
paint.setMaskFilter(mf)->unref();
|
paint.setMaskFilter(mf)->unref();
|
||||||
} else {
|
} else {
|
||||||
paint.setMaskFilter(NULL);
|
paint.setMaskFilter(NULL);
|
||||||
}
|
}
|
||||||
canvas->drawCircle(200 + gRecs[i].fCx*100,
|
canvas->drawCircle(SkIntToScalar(200 + gRecs[i].fCx*100)
|
||||||
200 + gRecs[i].fCy*100, 50, paint);
|
, SkIntToScalar(200 + gRecs[i].fCy*100)
|
||||||
|
, SkIntToScalar(50)
|
||||||
|
, paint);
|
||||||
}
|
}
|
||||||
// draw text
|
// draw text
|
||||||
{
|
{
|
||||||
SkMaskFilter* mf = SkBlurMaskFilter::Create(4,
|
SkMaskFilter* mf = SkBlurMaskFilter::Create(
|
||||||
SkBlurMaskFilter::kNormal_BlurStyle,
|
SkIntToScalar(4)
|
||||||
flags);
|
, SkBlurMaskFilter::kNormal_BlurStyle
|
||||||
|
, flags
|
||||||
|
);
|
||||||
paint.setMaskFilter(mf)->unref();
|
paint.setMaskFilter(mf)->unref();
|
||||||
SkScalar x = SkIntToScalar(70);
|
SkScalar x = SkIntToScalar(70);
|
||||||
SkScalar y = SkIntToScalar(400);
|
SkScalar y = SkIntToScalar(400);
|
||||||
paint.setColor(SK_ColorBLACK);
|
paint.setColor(SK_ColorBLACK);
|
||||||
canvas->drawText("Hamburgefons Style", 18, x, y, paint);
|
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.setMaskFilter(NULL);
|
||||||
paint.setColor(SK_ColorWHITE);
|
paint.setColor(SK_ColorWHITE);
|
||||||
x -= SkIntToScalar(2);
|
x -= SkIntToScalar(2);
|
||||||
|
@ -75,7 +80,7 @@ protected:
|
||||||
}
|
}
|
||||||
canvas->restore();
|
canvas->restore();
|
||||||
flags = SkBlurMaskFilter::kHighQuality_BlurFlag;
|
flags = SkBlurMaskFilter::kHighQuality_BlurFlag;
|
||||||
canvas->translate(350, 0);
|
canvas->translate(SkIntToScalar(350), SkIntToScalar(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,14 @@ namespace skiagm {
|
||||||
|
|
||||||
class NoColorBleedGM : public GM {
|
class NoColorBleedGM : public GM {
|
||||||
public:
|
public:
|
||||||
NoColorBleedGM() {}
|
NoColorBleedGM() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual SkString onShortName() {
|
virtual SkString onShortName() {
|
||||||
return SkString("nocolorbleed");
|
return SkString("nocolorbleed");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual SkISize onISize() {
|
virtual SkISize onISize() {
|
||||||
return make_isize(200, 200);
|
return make_isize(200, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,15 +45,19 @@ protected:
|
||||||
paint.setFilterBitmap(true);
|
paint.setFilterBitmap(true);
|
||||||
//First row : full texture with and without filtering
|
//First row : full texture with and without filtering
|
||||||
srcRect.setXYWH(0, 0, 4, 4);
|
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);
|
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);
|
canvas->drawBitmapRect(sprite, &srcRect, dstRect);
|
||||||
//Second row : sub rect of texture with and without filtering
|
//Second row : sub rect of texture with and without filtering
|
||||||
srcRect.setXYWH(1, 1, 2, 2);
|
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);
|
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);
|
canvas->drawBitmapRect(sprite, &srcRect, dstRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,14 +6,15 @@
|
||||||
typedef SkScalar (*MakePathProc)(SkPath*);
|
typedef SkScalar (*MakePathProc)(SkPath*);
|
||||||
|
|
||||||
static SkScalar make_frame(SkPath* path) {
|
static SkScalar make_frame(SkPath* path) {
|
||||||
SkRect r = { 10, 10, 630, 470 };
|
SkRect r = { SkIntToScalar(10), SkIntToScalar(10),
|
||||||
path->addRoundRect(r, 15, 15);
|
SkIntToScalar(630), SkIntToScalar(470) };
|
||||||
|
path->addRoundRect(r, SkIntToScalar(15), SkIntToScalar(15));
|
||||||
|
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
paint.setStyle(SkPaint::kStroke_Style);
|
paint.setStyle(SkPaint::kStroke_Style);
|
||||||
paint.setStrokeWidth(5);
|
paint.setStrokeWidth(SkIntToScalar(5));
|
||||||
paint.getFillPath(*path, path);
|
paint.getFillPath(*path, path);
|
||||||
return 15;
|
return SkIntToScalar(15);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SkScalar make_triangle(SkPath* path) {
|
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[2]), SkIntToScalar(gCoord[3]));
|
||||||
path->lineTo(SkIntToScalar(gCoord[4]), SkIntToScalar(gCoord[5]));
|
path->lineTo(SkIntToScalar(gCoord[4]), SkIntToScalar(gCoord[5]));
|
||||||
path->close();
|
path->close();
|
||||||
path->offset(10, 0);
|
path->offset(SkIntToScalar(10), SkIntToScalar(0));
|
||||||
return SkIntToScalar(30);
|
return SkIntToScalar(30);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SkScalar make_rect(SkPath* path) {
|
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->addRect(r);
|
||||||
path->offset(10, 0);
|
path->offset(SkIntToScalar(10), SkIntToScalar(0));
|
||||||
return SkIntToScalar(30);
|
return SkIntToScalar(30);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SkScalar make_oval(SkPath* path) {
|
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->addOval(r);
|
||||||
path->offset(10, 0);
|
path->offset(SkIntToScalar(10), SkIntToScalar(0));
|
||||||
return SkIntToScalar(30);
|
return SkIntToScalar(30);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,8 +59,8 @@ static SkScalar make_sawtooth(SkPath* path) {
|
||||||
x += dx;
|
x += dx;
|
||||||
path->lineTo(x, y + dy);
|
path->lineTo(x, y + dy);
|
||||||
}
|
}
|
||||||
path->lineTo(x, y + 2 * dy);
|
path->lineTo(x, y + (2 * dy));
|
||||||
path->lineTo(x0, y + 2 * dy);
|
path->lineTo(x0, y + (2 * dy));
|
||||||
path->close();
|
path->close();
|
||||||
return SkIntToScalar(30);
|
return SkIntToScalar(30);
|
||||||
}
|
}
|
||||||
|
@ -100,7 +103,7 @@ class PathFillGM : public GM {
|
||||||
SkPath fPath[N];
|
SkPath fPath[N];
|
||||||
SkScalar fDY[N];
|
SkScalar fDY[N];
|
||||||
public:
|
public:
|
||||||
PathFillGM() {
|
PathFillGM() {
|
||||||
for (size_t i = 0; i < N; i++) {
|
for (size_t i = 0; i < N; i++) {
|
||||||
fDY[i] = gProcs[i](&fPath[i]);
|
fDY[i] = gProcs[i](&fPath[i]);
|
||||||
}
|
}
|
||||||
|
@ -111,7 +114,7 @@ protected:
|
||||||
return SkString("pathfill");
|
return SkString("pathfill");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual SkISize onISize() {
|
virtual SkISize onISize() {
|
||||||
return make_isize(640, 480);
|
return make_isize(640, 480);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +130,7 @@ protected:
|
||||||
|
|
||||||
for (size_t i = 0; i < N; i++) {
|
for (size_t i = 0; i < N; i++) {
|
||||||
canvas->drawPath(fPath[i], paint);
|
canvas->drawPath(fPath[i], paint);
|
||||||
canvas->translate(0, fDY[i]);
|
canvas->translate(SkIntToScalar(0), fDY[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,14 +29,14 @@ static const SkScalar SH = SkIntToScalar(H);
|
||||||
|
|
||||||
class StrokeRectGM : public GM {
|
class StrokeRectGM : public GM {
|
||||||
public:
|
public:
|
||||||
StrokeRectGM() {}
|
StrokeRectGM() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual SkString onShortName() {
|
virtual SkString onShortName() {
|
||||||
return SkString("strokerects");
|
return SkString("strokerects");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual SkISize onISize() {
|
virtual SkISize onISize() {
|
||||||
return make_isize(W*2, H*2);
|
return make_isize(W*2, H*2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,10 @@ protected:
|
||||||
|
|
||||||
SkAutoCanvasRestore acr(canvas, true);
|
SkAutoCanvasRestore acr(canvas, true);
|
||||||
canvas->translate(SW * x, SH * y);
|
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;
|
SkRandom rand;
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче