Index: tools/sk_tool_utils.cpp |
diff --git a/tools/sk_tool_utils.cpp b/tools/sk_tool_utils.cpp |
index a746d8b9fdae30488019dfd78decc769753d6da8..aab068cbd75df85e5064ed504043611c733fb3a9 100644 |
--- a/tools/sk_tool_utils.cpp |
+++ b/tools/sk_tool_utils.cpp |
@@ -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); |