Minor code cleanup (left over from prior CL)

This was requested in https://codereview.chromium.org/1309543012/ (Add new GM to directly exercise perspective bitmap drawing)

Review URL: https://codereview.chromium.org/1320673011
This commit is contained in:
robertphillips 2015-09-03 13:32:33 -07:00 committed by Commit bot
parent 44c3128bd8
commit 943a462fef
16 changed files with 141 additions and 235 deletions

View File

@ -21,26 +21,13 @@ protected:
return SkString("bitmapsource");
}
void makeBitmap() {
fBitmap.allocN32Pixels(100, 100);
SkCanvas canvas(fBitmap);
canvas.clear(0x00000000);
SkPaint paint;
paint.setAntiAlias(true);
sk_tool_utils::set_portable_typeface(&paint);
paint.setColor(0xFFFFFFFF);
paint.setTextSize(SkIntToScalar(96));
const char* str = "e";
canvas.drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70), paint);
}
SkISize onISize() override { return SkISize::Make(500, 150); }
void onOnceBeforeDraw() override {
this->makeBitmap();
fBitmap = sk_tool_utils::create_string_bitmap(100, 100, 0xFFFFFFFF, 20, 70, 96, "e");
}
static void fillRectFiltered(SkCanvas* canvas, const SkRect& clipRect, SkImageFilter* filter) {
static void FillRectFiltered(SkCanvas* canvas, const SkRect& clipRect, SkImageFilter* filter) {
SkPaint paint;
paint.setImageFilter(filter);
canvas->save();
@ -63,19 +50,19 @@ protected:
SkAutoTUnref<SkImageFilter> bitmapSourceDstRectOnly(SkBitmapSource::Create(fBitmap, bounds, dstRect));
// Draw an unscaled bitmap.
fillRectFiltered(canvas, clipRect, bitmapSource);
FillRectFiltered(canvas, clipRect, bitmapSource);
canvas->translate(SkIntToScalar(100), 0);
// Draw an unscaled subset of the source bitmap (srcRect -> srcRect).
fillRectFiltered(canvas, clipRect, bitmapSourceSrcRect);
FillRectFiltered(canvas, clipRect, bitmapSourceSrcRect);
canvas->translate(SkIntToScalar(100), 0);
// Draw a subset of the bitmap scaled to a destination rect (srcRect -> dstRect).
fillRectFiltered(canvas, clipRect, bitmapSourceSrcRectDstRect);
FillRectFiltered(canvas, clipRect, bitmapSourceSrcRectDstRect);
canvas->translate(SkIntToScalar(100), 0);
// Draw the entire bitmap scaled to a destination rect (bounds -> dstRect).
fillRectFiltered(canvas, clipRect, bitmapSourceDstRectOnly);
FillRectFiltered(canvas, clipRect, bitmapSourceDstRectOnly);
canvas->translate(SkIntToScalar(100), 0);
}
}

View File

@ -14,49 +14,33 @@ namespace skiagm {
class DisplacementMapGM : public GM {
public:
DisplacementMapGM() : fInitialized(false) {
DisplacementMapGM() {
this->setBGColor(0xFF000000);
}
protected:
virtual SkString onShortName() {
SkString onShortName() override {
return SkString("displacement");
}
void make_bitmaps() {
make_bitmap();
make_checkerboard(&fCheckerboard, 80, 80);
make_checkerboard(&fSmall, 64, 64);
make_checkerboard(&fLarge, 96, 96);
make_checkerboard(&fLargeW, 96, 64);
make_checkerboard(&fLargeH, 64, 96);
void onOnceBeforeDraw() override {
fBitmap = sk_tool_utils::create_string_bitmap(80, 80, 0xFF884422, 15, 55, 96, "g");
SkColor c1 = sk_tool_utils::color_to_565(0xFF244484);
SkColor c2 = sk_tool_utils::color_to_565(0xFF804020);
fCheckerboard = sk_tool_utils::create_checkerboard_bitmap(80, 80, c1, c2, 8);
fSmall = sk_tool_utils::create_checkerboard_bitmap(64, 64, c1, c2, 8);
fLarge = sk_tool_utils::create_checkerboard_bitmap(96, 96, c1, c2, 8);
fLargeW = sk_tool_utils::create_checkerboard_bitmap(96, 64, c1, c2, 8);
fLargeH = sk_tool_utils::create_checkerboard_bitmap(64, 96, c1, c2, 8);
}
void make_bitmap() {
fBitmap.allocN32Pixels(80, 80);
SkCanvas canvas(fBitmap);
canvas.clear(0x00000000);
SkPaint paint;
paint.setAntiAlias(true);
sk_tool_utils::set_portable_typeface(&paint);
paint.setColor(sk_tool_utils::color_to_565(0xFF884422));
paint.setTextSize(SkIntToScalar(96));
const char* str = "g";
canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(55), paint);
}
void make_checkerboard(SkBitmap* bitmap, int w, int h) {
bitmap->allocN32Pixels(w, h);
SkCanvas canvas(*bitmap);
sk_tool_utils::draw_checkerboard(&canvas, sk_tool_utils::color_to_565(0xFF244484),
sk_tool_utils::color_to_565(0xFF804020), 8);
}
virtual SkISize onISize() {
SkISize onISize() override {
return SkISize::Make(500, 500);
}
void drawClippedBitmap(SkCanvas* canvas, int x, int y, const SkPaint& paint) {
void drawClippedBitmap(SkCanvas* canvas, int x, int y, const SkPaint& paint) const {
canvas->save();
canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
canvas->clipRect(SkRect::MakeWH(SkIntToScalar(fBitmap.width()), SkIntToScalar(fBitmap.height())));
@ -64,11 +48,7 @@ protected:
canvas->restore();
}
virtual void onDraw(SkCanvas* canvas) {
if (!fInitialized) {
make_bitmaps();
fInitialized = true;
}
void onDraw(SkCanvas* canvas) override {
canvas->clear(SK_ColorBLACK);
SkPaint paint;
SkAutoTUnref<SkImageFilter> displ(SkBitmapSource::Create(fCheckerboard));
@ -204,14 +184,12 @@ protected:
}
private:
typedef GM INHERITED;
SkBitmap fBitmap, fCheckerboard, fSmall, fLarge, fLargeW, fLargeH;
bool fInitialized;
typedef GM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
static GM* MyFactory(void*) { return new DisplacementMapGM; }
static GMRegistry reg(MyFactory);
DEF_GM(return new DisplacementMapGM;)
}

View File

@ -28,12 +28,11 @@ namespace skiagm {
class ImageFiltersClippedGM : public GM {
public:
ImageFiltersClippedGM() : fInitialized(false) {
ImageFiltersClippedGM() {
this->setBGColor(0x00000000);
}
protected:
SkString onShortName() override {
return SkString("imagefiltersclipped");
}
@ -42,7 +41,7 @@ protected:
return SkISize::Make(860, 500);
}
void make_gradient_circle(int width, int height) {
void makeGradientCircle(int width, int height) {
SkScalar x = SkIntToScalar(width / 2);
SkScalar y = SkIntToScalar(height / 2);
SkScalar radius = SkMinScalar(x, y) * 0.8f;
@ -80,15 +79,13 @@ protected:
canvas->restore();
}
void onDraw(SkCanvas* canvas) override {
if (!fInitialized) {
fCheckerboard.allocN32Pixels(64, 64);
SkCanvas checkerboardCanvas(fCheckerboard);
sk_tool_utils::draw_checkerboard(&checkerboardCanvas, 0xFFA0A0A0, 0xFF404040, 8);
this->make_gradient_circle(64, 64);
fInitialized = true;
void onOnceBeforeDraw() override {
fCheckerboard = sk_tool_utils::create_checkerboard_bitmap(64, 64,
0xFFA0A0A0, 0xFF404040, 8);
this->makeGradientCircle(64, 64);
}
void onDraw(SkCanvas* canvas) override {
canvas->clear(SK_ColorBLACK);
SkAutoTUnref<SkImageFilter> gradient(SkBitmapSource::Create(fGradientCircle));
@ -150,15 +147,13 @@ protected:
}
private:
bool fInitialized;
SkBitmap fCheckerboard;
SkBitmap fGradientCircle;
typedef GM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
static GM* MyFactory(void*) { return new ImageFiltersClippedGM; }
static GMRegistry reg(MyFactory);
DEF_GM(return new ImageFiltersClippedGM;)
}

View File

@ -103,23 +103,10 @@ public:
protected:
virtual SkString onShortName() {
SkString onShortName() override {
return SkString("imagefiltersgraph");
}
void make_bitmap() {
fBitmap.allocN32Pixels(100, 100);
SkCanvas canvas(fBitmap);
canvas.clear(SK_ColorTRANSPARENT);
SkPaint paint;
paint.setAntiAlias(true);
sk_tool_utils::set_portable_typeface(&paint);
paint.setColor(SK_ColorWHITE);
paint.setTextSize(SkIntToScalar(96));
const char* str = "e";
canvas.drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70), paint);
}
void drawClippedBitmap(SkCanvas* canvas, const SkBitmap& bitmap, const SkPaint& paint) {
canvas->save();
canvas->clipRect(SkRect::MakeXYWH(0, 0,
@ -128,13 +115,13 @@ protected:
canvas->restore();
}
virtual SkISize onISize() { return SkISize::Make(500, 150); }
SkISize onISize() override { return SkISize::Make(500, 150); }
virtual void onOnceBeforeDraw() {
this->make_bitmap();
void onOnceBeforeDraw() override {
fBitmap = sk_tool_utils::create_string_bitmap(100, 100, SK_ColorWHITE, 20, 70, 96, "e");
}
virtual void onDraw(SkCanvas* canvas) {
void onDraw(SkCanvas* canvas) override {
canvas->clear(SK_ColorBLACK);
{
SkAutoTUnref<SkImageFilter> bitmapSource(SkBitmapSource::Create(fBitmap));
@ -229,5 +216,4 @@ private:
///////////////////////////////////////////////////////////////////////////////
static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; }
static skiagm::GMRegistry reg(MyFactory);
DEF_GM(return new ImageFiltersGraphGM;)

View File

@ -27,21 +27,21 @@ namespace skiagm {
class ImageFiltersScaledGM : public GM {
public:
ImageFiltersScaledGM() : fInitialized(false) {
ImageFiltersScaledGM() {
this->setBGColor(0x00000000);
}
protected:
virtual SkString onShortName() {
SkString onShortName() override {
return SkString("imagefiltersscaled");
}
virtual SkISize onISize() {
SkISize onISize() override {
return SkISize::Make(1428, 500);
}
void make_gradient_circle(int width, int height) {
void makeGradientCircle(int width, int height) {
SkScalar x = SkIntToScalar(width / 2);
SkScalar y = SkIntToScalar(height / 2);
SkScalar radius = SkScalarMul(SkMinScalar(x, y), SkIntToScalar(4) / SkIntToScalar(5));
@ -60,15 +60,13 @@ protected:
canvas.drawCircle(x, y, radius, paint);
}
virtual void onDraw(SkCanvas* canvas) {
if (!fInitialized) {
fCheckerboard.allocN32Pixels(64, 64);
SkCanvas checkerboardCanvas(fCheckerboard);
sk_tool_utils::draw_checkerboard(&checkerboardCanvas, 0xFFA0A0A0, 0xFF404040, 8);
this->make_gradient_circle(64, 64);
fInitialized = true;
void onOnceBeforeDraw() override {
fCheckerboard = sk_tool_utils::create_checkerboard_bitmap(64, 64,
0xFFA0A0A0, 0xFF404040, 8);
this->makeGradientCircle(64, 64);
}
void onDraw(SkCanvas* canvas) override {
canvas->clear(SK_ColorBLACK);
SkAutoTUnref<SkImageFilter> gradient(SkBitmapSource::Create(fGradientCircle));
@ -152,15 +150,13 @@ protected:
}
private:
bool fInitialized;
SkBitmap fCheckerboard;
SkBitmap fGradientCircle;
typedef GM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
static GM* MyFactory(void*) { return new ImageFiltersScaledGM; }
static GMRegistry reg(MyFactory);
DEF_GM(return new ImageFiltersScaledGM;)
}

View File

@ -54,10 +54,8 @@ protected:
}
void onOnceBeforeDraw() override {
fCheckerboard.allocN32Pixels(64, 64);
SkCanvas checkerboardCanvas(fCheckerboard);
sk_tool_utils::draw_checkerboard(&checkerboardCanvas, 0xFFA0A0A0, 0xFF404040, 8);
fCheckerboard = sk_tool_utils::create_checkerboard_bitmap(64, 64,
0xFFA0A0A0, 0xFF404040, 8);
this->makeGradientCircle(64, 64);
}

View File

@ -17,7 +17,7 @@ namespace skiagm {
class ImageLightingGM : public GM {
public:
ImageLightingGM() : fInitialized(false) {
ImageLightingGM() {
this->setBGColor(0xFF000000);
}
@ -27,19 +27,6 @@ protected:
return SkString("lighting");
}
void make_bitmap() {
fBitmap.allocN32Pixels(100, 100);
SkCanvas canvas(fBitmap);
canvas.clear(0x00000000);
SkPaint paint;
paint.setAntiAlias(true);
sk_tool_utils::set_portable_typeface(&paint);
paint.setColor(0xFFFFFFFF);
paint.setTextSize(SkIntToScalar(96));
const char* str = "e";
canvas.drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70), paint);
}
SkISize onISize() override {
return SkISize::Make(WIDTH, HEIGHT);
}
@ -53,11 +40,11 @@ protected:
canvas->restore();
}
void onDraw(SkCanvas* canvas) override {
if (!fInitialized) {
make_bitmap();
fInitialized = true;
void onOnceBeforeDraw() override {
fBitmap = sk_tool_utils::create_string_bitmap(100, 100, 0xFFFFFFFF, 20, 70, 96, "e");
}
void onDraw(SkCanvas* canvas) override {
canvas->clear(sk_tool_utils::color_to_565(0xFF101010));
SkPaint checkPaint;
checkPaint.setColor(sk_tool_utils::color_to_565(0xFF202020));
@ -163,9 +150,9 @@ protected:
}
private:
typedef GM INHERITED;
SkBitmap fBitmap;
bool fInitialized;
typedef GM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////

View File

@ -11,18 +11,6 @@
#include "SkPoint3.h"
#include "SkShader.h"
static SkBitmap make_checkerboard(int texSize) {
SkBitmap bitmap;
bitmap.allocN32Pixels(texSize, texSize);
SkCanvas canvas(bitmap);
sk_tool_utils::draw_checkerboard(&canvas,
sk_tool_utils::color_to_565(0x0),
sk_tool_utils::color_to_565(0xFF804020),
8);
return bitmap;
}
// Create a hemispherical normal map
static SkBitmap make_hemi_normalmap(int texSize) {
SkBitmap hemi;
@ -87,7 +75,11 @@ protected:
}
void onOnceBeforeDraw() override {
fDiffuse = make_checkerboard(kTexSize);
fDiffuse = sk_tool_utils::create_checkerboard_bitmap(
kTexSize, kTexSize,
sk_tool_utils::color_to_565(0x0),
sk_tool_utils::color_to_565(0xFF804020),
8);
fNormalMaps[kHemi_NormalMap] = make_hemi_normalmap(kTexSize);
fNormalMaps[kFrustum_NormalMap] = make_frustum_normalmap(kTexSize);

View File

@ -14,17 +14,17 @@ namespace skiagm {
class MatrixConvolutionGM : public GM {
public:
MatrixConvolutionGM() : fInitialized(false) {
MatrixConvolutionGM() {
this->setBGColor(0x00000000);
}
protected:
virtual SkString onShortName() {
SkString onShortName() override {
return SkString("matrixconvolution");
}
void make_bitmap() {
void makeBitmap() {
fBitmap.allocN32Pixels(80, 80);
SkCanvas canvas(fBitmap);
canvas.clear(0x00000000);
@ -43,7 +43,7 @@ protected:
canvas.drawText(str, strlen(str), SkIntToScalar(-10), SkIntToScalar(80), paint);
}
virtual SkISize onISize() {
SkISize onISize() override {
return SkISize::Make(500, 300);
}
@ -79,11 +79,11 @@ protected:
typedef SkMatrixConvolutionImageFilter MCIF;
virtual void onDraw(SkCanvas* canvas) {
if (!fInitialized) {
make_bitmap();
fInitialized = true;
void onOnceBeforeDraw() override {
this->makeBitmap();
}
void onDraw(SkCanvas* canvas) override {
canvas->clear(SK_ColorBLACK);
SkIPoint kernelOffset = SkIPoint::Make(1, 0);
for (int x = 10; x < 310; x += 100) {
@ -104,14 +104,13 @@ protected:
}
private:
typedef GM INHERITED;
SkBitmap fBitmap;
bool fInitialized;
typedef GM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
static GM* MyFactory(void*) { return new MatrixConvolutionGM; }
static GMRegistry reg(MyFactory);
DEF_GM(return new MatrixConvolutionGM;)
}

View File

@ -25,18 +25,6 @@ protected:
return SkString("offsetimagefilter");
}
void make_bitmap() {
fBitmap.allocN32Pixels(80, 80);
SkCanvas canvas(fBitmap);
canvas.clear(0);
SkPaint paint;
paint.setAntiAlias(true);
sk_tool_utils::set_portable_typeface(&paint);
paint.setColor(sk_tool_utils::color_to_565(0xD000D000));
paint.setTextSize(96);
canvas.drawText("e", 1, 15, 65, paint);
}
SkISize onISize() override {
return SkISize::Make(WIDTH, HEIGHT);
}
@ -64,13 +52,13 @@ protected:
}
void onOnceBeforeDraw() override {
make_bitmap();
fBitmap = sk_tool_utils::create_string_bitmap(80, 80, 0xD000D000, 15, 65, 96, "e");
fCheckerboard.allocN32Pixels(80, 80);
SkCanvas checkerboardCanvas(fCheckerboard);
sk_tool_utils::draw_checkerboard(&checkerboardCanvas,
fCheckerboard = sk_tool_utils::create_checkerboard_bitmap(
80, 80,
sk_tool_utils::color_to_565(0xFFA0A0A0),
sk_tool_utils::color_to_565(0xFF404040), 8);
sk_tool_utils::color_to_565(0xFF404040),
8);
}
void onDraw(SkCanvas* canvas) override {
@ -101,8 +89,9 @@ protected:
drawClippedBitmap(canvas, fBitmap, paint, 2, cropRect);
}
private:
typedef skiagm::GM INHERITED;
SkBitmap fBitmap, fCheckerboard;
typedef skiagm::GM INHERITED;
};
DEF_GM( return new OffsetImageFilterGM; )

View File

@ -23,15 +23,6 @@ static SkImage* make_image(SkCanvas* origCanvas, int w, int h) {
return surface->newImageSnapshot();
}
static SkBitmap make_bitmap(int w, int h) {
SkBitmap bitmap;
bitmap.allocN32Pixels(w, h);
SkCanvas canvas(bitmap);
sk_tool_utils::draw_checkerboard(&canvas, SK_ColorBLUE, SK_ColorYELLOW, w/10);
return bitmap;
}
namespace skiagm {
class PerspShadersGM : public GM {
@ -51,7 +42,9 @@ protected:
}
void onOnceBeforeDraw() override {
fBitmap = make_bitmap(kCellSize, kCellSize);
fBitmap = sk_tool_utils::create_checkerboard_bitmap(kCellSize, kCellSize,
SK_ColorBLUE, SK_ColorYELLOW,
kCellSize/10);
fBitmapShader.reset(SkShader::CreateBitmapShader(fBitmap,
SkShader::kClamp_TileMode,

View File

@ -16,22 +16,6 @@
#define HEIGHT 100
#define MARGIN 12
static SkBitmap make_bitmap() {
SkBitmap bitmap;
bitmap.allocN32Pixels(50, 50);
SkCanvas canvas(bitmap);
canvas.clear(0xFF000000);
SkPaint paint;
paint.setAntiAlias(true);
sk_tool_utils::set_portable_typeface(&paint);
paint.setColor(0xD000D000);
paint.setTextSize(SkIntToScalar(50));
const char* str = "e";
canvas.drawText(str, strlen(str), SkIntToScalar(10), SkIntToScalar(45), paint);
return bitmap;
}
namespace skiagm {
class TileImageFilterGM : public GM {
@ -50,13 +34,13 @@ protected:
}
void onOnceBeforeDraw() override {
fBitmap = make_bitmap();
fBitmap = sk_tool_utils::create_string_bitmap(50, 50, 0xD000D000, 10, 45, 50, "e");
fCheckerboard.allocN32Pixels(80, 80);
SkCanvas checkerboardCanvas(fCheckerboard);
sk_tool_utils::draw_checkerboard(&checkerboardCanvas,
fCheckerboard = sk_tool_utils::create_checkerboard_bitmap(
80, 80,
sk_tool_utils::color_to_565(0xFFA0A0A0),
sk_tool_utils::color_to_565(0xFF404040), 8);
sk_tool_utils::color_to_565(0xFF404040),
8);
}
void onDraw(SkCanvas* canvas) override {

View File

@ -29,19 +29,6 @@ protected:
return SkString("xfermodeimagefilter");
}
void make_bitmap() {
fBitmap.allocN32Pixels(80, 80);
SkCanvas canvas(fBitmap);
canvas.clear(0x00000000);
SkPaint paint;
paint.setAntiAlias(true);
sk_tool_utils::set_portable_typeface(&paint);
paint.setColor(0xD000D000);
paint.setTextSize(SkIntToScalar(96));
const char* str = "e";
canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(65), paint);
}
SkISize onISize() override {
return SkISize::Make(WIDTH, HEIGHT);
}
@ -66,13 +53,13 @@ protected:
}
void onOnceBeforeDraw() override {
make_bitmap();
fBitmap = sk_tool_utils::create_string_bitmap(80, 80, 0xD000D000, 15, 65, 96, "e");
fCheckerboard.allocN32Pixels(80, 80);
SkCanvas checkerboardCanvas(fCheckerboard);
sk_tool_utils::draw_checkerboard(&checkerboardCanvas,
fCheckerboard = sk_tool_utils::create_checkerboard_bitmap(
80, 80,
sk_tool_utils::color_to_565(0xFFA0A0A0),
sk_tool_utils::color_to_565(0xFF404040), 8);
sk_tool_utils::color_to_565(0xFF404040),
8);
}
void onDraw(SkCanvas* canvas) override {

View File

@ -188,6 +188,15 @@ SkShader* create_checkerboard_shader(SkColor c1, SkColor c2, int size) {
bm, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
}
SkBitmap create_checkerboard_bitmap(int w, int h, SkColor c1, SkColor c2, int checkSize) {
SkBitmap bitmap;
bitmap.allocN32Pixels(w, h);
SkCanvas canvas(bitmap);
sk_tool_utils::draw_checkerboard(&canvas, c1, c2, checkSize);
return bitmap;
}
void draw_checkerboard(SkCanvas* canvas, SkColor c1, SkColor c2, int size) {
SkPaint paint;
paint.setShader(create_checkerboard_shader(c1, c2, size))->unref();
@ -195,6 +204,24 @@ void draw_checkerboard(SkCanvas* canvas, SkColor c1, SkColor c2, int size) {
canvas->drawPaint(paint);
}
SkBitmap create_string_bitmap(int w, int h, SkColor c, int x, int y,
int textSize, const char* str) {
SkBitmap bitmap;
bitmap.allocN32Pixels(w, h);
SkCanvas canvas(bitmap);
SkPaint paint;
paint.setAntiAlias(true);
sk_tool_utils::set_portable_typeface(&paint);
paint.setColor(c);
paint.setTextSize(SkIntToScalar(textSize));
canvas.clear(0x00000000);
canvas.drawText(str, strlen(str), SkIntToScalar(x), SkIntToScalar(y), paint);
return bitmap;
}
void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const SkPaint& origPaint,
SkScalar x, SkScalar y) {
SkPaint paint(origPaint);

View File

@ -96,13 +96,21 @@ namespace sk_tool_utils {
void draw_checkerboard(SkCanvas* canvas,
SkColor color1,
SkColor color2,
int size);
int checkSize);
/** Make it easier to create a bitmap-based checkerboard */
SkBitmap create_checkerboard_bitmap(int w, int h,
SkColor c1, SkColor c2,
int checkSize);
/** A default checkerboard. */
inline void draw_checkerboard(SkCanvas* canvas) {
sk_tool_utils::draw_checkerboard(canvas, 0xFF999999, 0xFF666666, 8);
}
SkBitmap create_string_bitmap(int w, int h, SkColor c, int x, int y,
int textSize, const char* str);
// Encodes to PNG, unless there is already encoded data, in which case that gets
// used.
class PngPixelSerializer : public SkPixelSerializer {