make tests portable by using 565 compatible colors

TBR=reed@google.com

Review URL: https://codereview.chromium.org/1262703002
This commit is contained in:
caryclark 2015-07-29 05:27:47 -07:00 committed by Commit bot
parent a52b7a03c6
commit 125960152d
28 changed files with 51 additions and 46 deletions

View File

@ -225,7 +225,7 @@ protected:
SkPaint paint;
paint.setAntiAlias(true);
paint.setColor(0xFFCCCCCC);
paint.setColor(sk_tool_utils::color_to_565(0xFFCCCCCC));
canvas->drawPath(path, paint);
paint.setColor(SK_ColorRED);
@ -238,7 +238,7 @@ protected:
SkRect r = SkRect::MakeXYWH(0, H/4, W, H/2);
SkPaint paint;
paint.setColor(0xFF8888FF);
paint.setColor(sk_tool_utils::color_to_565(0xFF8888FF));
canvas->drawRect(r, paint);
this->doDraw(canvas, path);

View File

@ -110,8 +110,8 @@ static SkShader* make_bg_shader() {
SkBitmap bm;
bm.allocN32Pixels(2, 2);
*bm.getAddr32(0, 0) = *bm.getAddr32(1, 1) = 0xFFFFFFFF;
*bm.getAddr32(1, 0) = *bm.getAddr32(0, 1) = SkPackARGB32(0xFF, 0xCC,
0xCC, 0xCC);
*bm.getAddr32(1, 0) = *bm.getAddr32(0, 1) = SkPackARGB32(0xFF, 0xCE,
0xCF, 0xCE);
const SkMatrix m = SkMatrix::MakeScale(SkIntToScalar(6), SkIntToScalar(6));
SkShader* s = SkShader::CreateBitmapShader(bm,

View File

@ -36,7 +36,7 @@ protected:
SkScalar sign = 1;
while (r.width() > paint.getStrokeWidth() * 3) {
paint.setColor(rand.nextU() | (0xFF << 24));
paint.setColor(sk_tool_utils::color_to_565(rand.nextU() | (0xFF << 24)));
SkScalar startAngle = rand.nextUScalar1() * 360;
SkScalar speed = SkScalarSqrt(16 / r.width()) * 0.5f;
@ -144,7 +144,7 @@ protected:
SkAutoCanvasRestore acr(canvas, true);
canvas->rotate(fRotate * sign);
paint.setColor(rand.nextU() | (0xFF << 24));
paint.setColor(sk_tool_utils::color_to_565(rand.nextU() | (0xFF << 24)));
canvas->drawOval(r, paint);
r.inset(delta, delta);
sign = -sign;

View File

@ -46,7 +46,7 @@ protected:
}
void onDraw(SkCanvas* canvas) override {
canvas->drawColor(0xFFCCCCCC);
canvas->drawColor(sk_tool_utils::color_to_565(0xFFCCCCCC));
const SkIRect src[] = {
{ 0, 0, 32, 32 },

View File

@ -29,7 +29,7 @@ DEF_SIMPLE_GM(blend, canvas, 300, 100) {
p.setColor(SK_ColorRED);
canvas->drawRect(SkRect::MakeXYWH(2,0,1,1), p);
canvas->saveLayerAlpha(NULL, 0xFC);
p.setColor(0xFF008000);
p.setColor(sk_tool_utils::color_to_565(0xFF008000));
canvas->drawRect(SkRect::MakeXYWH(2,0,1,1), p);
canvas->restore();
canvas->restore();

View File

@ -25,11 +25,11 @@ protected:
colorBmp.allocN32Pixels(20, 20, true);
colorBmp.eraseColor(0xFFFF0000);
canvas.drawBitmap(colorBmp, 0, 0);
colorBmp.eraseColor(0xFF008200);
colorBmp.eraseColor(sk_tool_utils::color_to_565(0xFF008200));
canvas.drawBitmap(colorBmp, 20, 0);
colorBmp.eraseColor(0xFFFF9000);
colorBmp.eraseColor(sk_tool_utils::color_to_565(0xFFFF9000));
canvas.drawBitmap(colorBmp, 0, 20);
colorBmp.eraseColor(0xFF2000FF);
colorBmp.eraseColor(sk_tool_utils::color_to_565(0xFF2000FF));
canvas.drawBitmap(colorBmp, 20, 20);
}

View File

@ -85,10 +85,11 @@ protected:
for (int r = 0; r < size; ++r) {
for (int g = 0; g < size; ++g) {
for (int b = 0; b < size; ++b) {
pixels[(size * ((size * b) + g)) + r] = SkColorSetARGB(0xFF,
pixels[(size * ((size * b) + g)) + r] = sk_tool_utils::color_to_565(
SkColorSetARGB(0xFF,
invR ? invLut[r] : lut[r],
invG ? invLut[g] : lut[g],
invB ? invLut[b] : lut[b]);
invB ? invLut[b] : lut[b]));
}
}
}

View File

@ -58,7 +58,7 @@ protected:
for (int y = 0; y < 10; ++y) {
surface->getCanvas()->discard();
// Make something that isn't too close to the background color, black.
SkColor color = rand.nextU() | 0xFF404040;
SkColor color = sk_tool_utils::color_to_565(rand.nextU() | 0xFF404040);
switch (rand.nextULessThan(3)) {
case 0:
surface->getCanvas()->drawColor(color);

View File

@ -96,12 +96,12 @@ protected:
static SkColor GetColor(SkRandom* random, int i, int nextColor) {
static SkColor colors[] = { SK_ColorRED,
0xFFFF7F00, // Orange
sk_tool_utils::color_to_565(0xFFFF7F00), // Orange
SK_ColorYELLOW,
SK_ColorGREEN,
SK_ColorBLUE,
0xFF4B0082, // indigo
0xFF7F00FF }; // violet
sk_tool_utils::color_to_565(0xFF4B0082), // indigo
sk_tool_utils::color_to_565(0xFF7F00FF) }; // violet
SkColor color;
int index = nextColor % SK_ARRAY_COUNT(colors);
switch (i) {

View File

@ -21,7 +21,7 @@ static SkSurface* new_surface(int width, int height) {
static void draw_pixel_centers(SkCanvas* canvas) {
SkPaint paint;
paint.setColor(0xFF0088FF);
paint.setColor(sk_tool_utils::color_to_565(0xFF0088FF));
paint.setAntiAlias(true);
for (int y = 0; y < SMALL_H; ++y) {

View File

@ -296,7 +296,7 @@ protected:
virtual SkISize onISize() { return SkISize::Make(640, 510); }
void drawBG(SkCanvas* canvas) {
canvas->drawColor(0xFFDDDDDD);
canvas->drawColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
}
virtual void onDraw(SkCanvas* canvas) {

View File

@ -62,7 +62,7 @@ static SkShader* make_bg_shader() {
SkBitmap bm;
bm.allocN32Pixels(2, 2);
*bm.getAddr32(0, 0) = *bm.getAddr32(1, 1) = 0xFFFFFFFF;
*bm.getAddr32(1, 0) = *bm.getAddr32(0, 1) = SkPackARGB32(0xFF, 0xCC, 0xCC, 0xCC);
*bm.getAddr32(1, 0) = *bm.getAddr32(0, 1) = SkPackARGB32(0xFF, 0xCE, 0xCF, 0xCE);
SkMatrix m;
m.setScale(SkIntToScalar(6), SkIntToScalar(6));

View File

@ -41,9 +41,9 @@ protected:
SkCanvas canvas(*bitmap);
canvas.clear(0xFFFF0000);
SkPaint darkPaint;
darkPaint.setColor(0xFF404040);
darkPaint.setColor(sk_tool_utils::color_to_565(0xFF404040));
SkPaint lightPaint;
lightPaint.setColor(0xFFA0A0A0);
lightPaint.setColor(sk_tool_utils::color_to_565(0xFFA0A0A0));
for (int y = 8; y < 48; y += 16) {
for (int x = 8; x < 48; x += 16) {
canvas.save();

View File

@ -107,9 +107,9 @@ protected:
SkCanvas canvas(fCheckerboard);
canvas.clear(SK_ColorTRANSPARENT);
SkPaint darkPaint;
darkPaint.setColor(0xFF404040);
darkPaint.setColor(sk_tool_utils::color_to_565(0xFF404040));
SkPaint lightPaint;
lightPaint.setColor(0xFFA0A0A0);
lightPaint.setColor(sk_tool_utils::color_to_565(0xFFA0A0A0));
for (int y = 0; y < 80; y += 16) {
for (int x = 0; x < 80; x += 16) {
canvas.save();

View File

@ -58,9 +58,9 @@ protected:
make_bitmap();
fInitialized = true;
}
canvas->clear(0xFF101010);
canvas->clear(sk_tool_utils::color_to_565(0xFF101010));
SkPaint checkPaint;
checkPaint.setColor(0xFF202020);
checkPaint.setColor(sk_tool_utils::color_to_565(0xFF202020));
for (int y = 0; y < HEIGHT; y += 16) {
for (int x = 0; x < WIDTH; x += 16) {
canvas->save();

View File

@ -41,9 +41,9 @@ protected:
bitmap->allocN32Pixels(64, 64);
SkCanvas canvas(*bitmap);
SkPaint darkPaint;
darkPaint.setColor(0xFF404040);
darkPaint.setColor(sk_tool_utils::color_to_565(0xFF404040));
SkPaint lightPaint;
lightPaint.setColor(0xFFA0A0A0);
lightPaint.setColor(sk_tool_utils::color_to_565(0xFFA0A0A0));
for (int y = 0; y < 64; y += 32) {
for (int x = 0; x < 64; x += 32) {
canvas.save();

View File

@ -15,7 +15,7 @@ static SkImage* make_image() {
const SkImageInfo info = SkImageInfo::MakeN32Premul(319, 52);
SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
SkCanvas* canvas = surface->getCanvas();
canvas->drawColor(0xFFF8F8F8);
canvas->drawColor(sk_tool_utils::color_to_565(0xFFF8F8F8));
SkPaint paint;
paint.setAntiAlias(true);

View File

@ -24,7 +24,7 @@ static SkShader* make_color_shader(SkColor color) {
}
static SkShader* make_solid_shader() {
return make_color_shader(SkColorSetARGB(0xFF, 0x40, 0x80, 0x20));
return make_color_shader(SkColorSetARGB(0xFF, 0x42, 0x82, 0x21));
}
static SkShader* make_transparent_shader() {
@ -40,9 +40,9 @@ static SkShader* make_bg_shader(int checkSize) {
SkBitmap bmp;
bmp.allocN32Pixels(2 * checkSize, 2 * checkSize);
SkCanvas canvas(bmp);
canvas.clear(0xFF800000);
canvas.clear(sk_tool_utils::color_to_565(0xFF800000));
SkPaint paint;
paint.setColor(0xFF000080);
paint.setColor(sk_tool_utils::color_to_565(0xFF000080));
SkRect rect0 = SkRect::MakeXYWH(0, 0,
SkIntToScalar(checkSize), SkIntToScalar(checkSize));
SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(checkSize), SkIntToScalar(checkSize),
@ -94,7 +94,7 @@ protected:
SkColorSetARGB(0xFF, 0xFF, 0xFF, 0xFF),
SkColorSetARGB(0xFF, 0x00, 0x00, 0x00),
SkColorSetARGB(0x00, 0x00, 0x00, 0x00),
SkColorSetARGB(0xFF, 0x10, 0x20, 0x40),
SkColorSetARGB(0xFF, 0x10, 0x20, 0x42),
SkColorSetARGB(0xA0, 0x20, 0x30, 0x90),
};

View File

@ -20,16 +20,16 @@ public:
protected:
void onOnceBeforeDraw() override {
const unsigned oneColor = 0xFF8080FF;
const unsigned oneColor = sk_tool_utils::color_to_565(0xFF8080FF);
const unsigned twoColor = 0x807F1f1f;
SkColor blendColor = blend(oneColor, twoColor);
makePaint(&fOnePaint, oneColor);
makePaint(&fTwoPaint, twoColor);
makePaint(&fOpPaint[kDifference_SkPathOp], oneColor);
makePaint(&fOpPaint[kIntersect_SkPathOp], blendColor);
makePaint(&fOpPaint[kUnion_SkPathOp], 0xFFc0FFc0);
makePaint(&fOpPaint[kUnion_SkPathOp], sk_tool_utils::color_to_565(0xFFc0FFc0));
makePaint(&fOpPaint[kReverseDifference_SkPathOp], twoColor);
makePaint(&fOpPaint[kXOR_SkPathOp], 0xFFa0FFe0);
makePaint(&fOpPaint[kXOR_SkPathOp], sk_tool_utils::color_to_565(0xFFa0FFe0));
makePaint(&fOutlinePaint, 0xFF000000);
fOutlinePaint.setStyle(SkPaint::kStroke_Style);
}

View File

@ -10,7 +10,8 @@
#include "Resources.h"
DEF_SIMPLE_GM(repeated_bitmap, canvas, 576, 576) {
sk_tool_utils::draw_checkerboard(canvas, 0xFF999999, SK_ColorWHITE, 12);
sk_tool_utils::draw_checkerboard(canvas, sk_tool_utils::color_to_565(0xFF999999),
SK_ColorWHITE, 12);
SkRect rect = SkRect::MakeLTRB(-4.25f, -4.25f, 4.25f, 4.25f);
SkPaint paint;
paint.setColor(0xFF333333);
@ -31,7 +32,8 @@ DEF_SIMPLE_GM(repeated_bitmap, canvas, 576, 576) {
}
DEF_SIMPLE_GM(repeated_bitmap_jpg, canvas, 576, 576) {
sk_tool_utils::draw_checkerboard(canvas, 0xFF999999, SK_ColorWHITE, 12);
sk_tool_utils::draw_checkerboard(canvas, sk_tool_utils::color_to_565(0xFF999999),
SK_ColorWHITE, 12);
SkRect rect = SkRect::MakeLTRB(-68.0f, -68.0f, 68.0f, 68.0f);
SkPaint paint;
paint.setColor(0xFF333333);

View File

@ -104,7 +104,7 @@ static void draw_rrect_color(SkCanvas* canvas, const SkRRect& rrect) {
if (rrect.isRect()) {
paint.setColor(SK_ColorRED);
} else if (rrect.isOval()) {
paint.setColor(0xFF008800);
paint.setColor(sk_tool_utils::color_to_565(0xFF008800));
} else if (rrect.isSimple()) {
paint.setColor(SK_ColorBLUE);
} else {

View File

@ -52,7 +52,8 @@ protected:
}
void onDraw(SkCanvas* canvas) override {
const SkColor colors[] = { 0xFF555555, 0xFF444444 };
const SkColor colors[] = { sk_tool_utils::color_to_565(0xFF555555),
sk_tool_utils::color_to_565(0xFF444444) };
const int colorCount = SK_ARRAY_COUNT(colors);
SkRect r = { 0, 0, this->width(), this->height() };

View File

@ -148,7 +148,7 @@ protected:
} gOps[] = {
{ SK_ColorBLACK, "Difference", SkRegion::kDifference_Op },
{ SK_ColorRED, "Intersect", SkRegion::kIntersect_Op },
{ 0xFF008800, "Union", SkRegion::kUnion_Op },
{ sk_tool_utils::color_to_565(0xFF008800), "Union", SkRegion::kUnion_Op },
{ SK_ColorGREEN, "Rev Diff", SkRegion::kReverseDifference_Op },
{ SK_ColorYELLOW, "Replace", SkRegion::kReplace_Op },
{ SK_ColorBLUE, "XOR", SkRegion::kXOR_Op },

View File

@ -34,7 +34,7 @@ protected:
void onDrawBackground(SkCanvas* canvas) override {
SkPaint bgPaint;
bgPaint.setColor(0xFF303030);
bgPaint.setColor(sk_tool_utils::color_to_565(0xFF303030));
canvas->drawPaint(bgPaint);
}

View File

@ -55,7 +55,7 @@ protected:
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
paint.setColor(0xFF007700);
paint.setColor(sk_tool_utils::color_to_565(0xFF007700));
canvas->drawPath(path, paint);
}

View File

@ -205,7 +205,7 @@ protected:
SkPaint fillPaint(origPaint);
fillPaint.setColor(SK_ColorRED);
SkPaint strokePaint(origPaint);
strokePaint.setColor(0xFF4444FF);
strokePaint.setColor(sk_tool_utils::color_to_565(0xFF4444FF));
void (*procs[])(SkPath*, const SkRect&, SkString*) = {
make0, make1, make2, make3, make4, make5

View File

@ -110,7 +110,7 @@ protected:
}
virtual void onDraw(SkCanvas* canvas) {
canvas->drawColor(0xFFDDDDDD);
canvas->drawColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
canvas->translate(20, 20);
@ -222,7 +222,7 @@ protected:
SkBitmap bm;
make_bm1(&bm);
canvas->drawColor(0xFFDDDDDD);
canvas->drawColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
const int MODES = MODE_COUNT * COLOR_COUNT;
SkAutoTUnref<SkColorFilter> filters[MODES];

View File

@ -29,6 +29,7 @@
'../src/utils/debugger/SkObjectParser.cpp',
],
'sources!': [
'../gm/annotated_text.cpp',
'../gm/system_preferences_default.cpp',
'../gm/techtalk1.cpp',
],