sk_tool_utils -> ToolUtils, and git clang-format
sk_tool_utils doesn't really fit the naming convention
the rest of code under tools/ tends to use.
Change-Id: I45326a174101c6eb4b6149e9c742f658f2fd23b1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/202313
Auto-Submit: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index b18af6a..f65d472 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1565,6 +1565,7 @@
"tools/LsanSuppressions.cpp",
"tools/ProcStats.cpp",
"tools/Resources.cpp",
+ "tools/ToolUtils.cpp",
"tools/UrlDataManager.cpp",
"tools/debugger/SkDebugCanvas.cpp",
"tools/debugger/SkDrawCommand.cpp",
@@ -1577,9 +1578,8 @@
"tools/fonts/TestSVGTypeface.h",
"tools/fonts/TestTypeface.cpp",
"tools/fonts/TestTypeface.h",
- "tools/fonts/sk_tool_utils_font.cpp",
+ "tools/fonts/ToolUtilsFont.cpp",
"tools/random_parse_path.cpp",
- "tools/sk_tool_utils.cpp",
"tools/timer/SkAnimTimer.h",
"tools/timer/Timer.cpp",
"tools/trace/SkChromeTracingTracer.cpp",
diff --git a/bench/BigPathBench.cpp b/bench/BigPathBench.cpp
index a2f3ae0..6c49ae7 100644
--- a/bench/BigPathBench.cpp
+++ b/bench/BigPathBench.cpp
@@ -8,7 +8,7 @@
#include "Benchmark.h"
#include "SkCanvas.h"
#include "SkPath.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
enum Align {
kLeft_Align,
@@ -42,9 +42,7 @@
return SkIPoint::Make(640, 100);
}
- void onDelayedSetup() override {
- sk_tool_utils::make_big_path(fPath);
- }
+ void onDelayedSetup() override { ToolUtils::make_big_path(fPath); }
void onDraw(int loops, SkCanvas* canvas) override {
SkPaint paint;
diff --git a/bench/BitmapBench.cpp b/bench/BitmapBench.cpp
index cc6f325..a44a897 100644
--- a/bench/BitmapBench.cpp
+++ b/bench/BitmapBench.cpp
@@ -12,7 +12,7 @@
#include "SkPaint.h"
#include "SkRandom.h"
#include "SkString.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
/* Variants for bitmaps
@@ -48,7 +48,8 @@
protected:
const char* onGetName() override {
fName.set("bitmap");
- fName.appendf("_%s%s", sk_tool_utils::colortype_name(fColorType),
+ fName.appendf("_%s%s",
+ ToolUtils::colortype_name(fColorType),
kOpaque_SkAlphaType == fAlphaType ? "" : "_A");
if (fDoScale) {
fName.append("_scale");
diff --git a/bench/ClipMaskBench.cpp b/bench/ClipMaskBench.cpp
index b3b98f2..a6e4994 100644
--- a/bench/ClipMaskBench.cpp
+++ b/bench/ClipMaskBench.cpp
@@ -6,16 +6,16 @@
*/
#include "Benchmark.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkColorSpace.h"
#include "SkImage.h"
#include "SkPictureRecorder.h"
#include "SkString.h"
#include "SkSurface.h"
+#include "ToolUtils.h"
static void DrawMask(SkCanvas* canvas) {
- sk_tool_utils::draw_checkerboard(canvas, SK_ColorTRANSPARENT, SK_ColorGREEN, 10);
+ ToolUtils::draw_checkerboard(canvas, SK_ColorTRANSPARENT, SK_ColorGREEN, 10);
}
class ClipMaskBench : public Benchmark {
diff --git a/bench/ImageCacheBudgetBench.cpp b/bench/ImageCacheBudgetBench.cpp
index 518713d..fb714ba 100644
--- a/bench/ImageCacheBudgetBench.cpp
+++ b/bench/ImageCacheBudgetBench.cpp
@@ -6,10 +6,10 @@
*/
#include "Benchmark.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkImage.h"
#include "SkSurface.h"
+#include "ToolUtils.h"
#include "GrContext.h"
#include "GrContextPriv.h"
@@ -27,8 +27,8 @@
static void make_images(sk_sp<SkImage> imgs[], int cnt) {
for (int i = 0; i < cnt; ++i) {
- SkBitmap bmp = sk_tool_utils::create_checkerboard_bitmap(kS, kS, SK_ColorBLACK,
- SK_ColorCYAN, 10);
+ SkBitmap bmp =
+ ToolUtils::create_checkerboard_bitmap(kS, kS, SK_ColorBLACK, SK_ColorCYAN, 10);
imgs[i] = SkImage::MakeFromBitmap(bmp);
}
}
diff --git a/bench/PathTextBench.cpp b/bench/PathTextBench.cpp
index 3dc31c9..a9b845d 100644
--- a/bench/PathTextBench.cpp
+++ b/bench/PathTextBench.cpp
@@ -12,7 +12,7 @@
#include "SkRandom.h"
#include "SkStrike.h"
#include "SkStrikeCache.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
static constexpr int kScreenWidth = 1500;
static constexpr int kScreenHeight = 1500;
@@ -76,7 +76,7 @@
}
if (fClipped) {
- fClipPath = sk_tool_utils::make_star(SkRect::MakeIWH(kScreenWidth,kScreenHeight), 11,3);
+ fClipPath = ToolUtils::make_star(SkRect::MakeIWH(kScreenWidth, kScreenHeight), 11, 3);
fClipPath.setIsVolatile(fUncached);
}
}
diff --git a/bench/PremulAndUnpremulAlphaOpsBench.cpp b/bench/PremulAndUnpremulAlphaOpsBench.cpp
index 89c9bd5..22467ec 100644
--- a/bench/PremulAndUnpremulAlphaOpsBench.cpp
+++ b/bench/PremulAndUnpremulAlphaOpsBench.cpp
@@ -8,7 +8,7 @@
#include "Benchmark.h"
#include "SkCanvas.h"
#include "SkString.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
class PremulAndUnpremulAlphaOpsBench : public Benchmark {
enum {
@@ -20,7 +20,7 @@
public:
PremulAndUnpremulAlphaOpsBench(SkColorType ct) {
fColorType = ct;
- fName.printf("premul_and_unpremul_alpha_%s", sk_tool_utils::colortype_name(ct));
+ fName.printf("premul_and_unpremul_alpha_%s", ToolUtils::colortype_name(ct));
}
protected:
diff --git a/bench/RepeatTileBench.cpp b/bench/RepeatTileBench.cpp
index 83ba3f1..cebe797 100644
--- a/bench/RepeatTileBench.cpp
+++ b/bench/RepeatTileBench.cpp
@@ -11,7 +11,7 @@
#include "SkPaint.h"
#include "SkShader.h"
#include "SkString.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
static void draw_into_bitmap(const SkBitmap& bm) {
const int w = bm.width();
@@ -44,7 +44,8 @@
fBitmap.setInfo(SkImageInfo::Make(w, h, ct, at));
fName.printf("repeatTile_%s_%c",
- sk_tool_utils::colortype_name(ct), kOpaque_SkAlphaType == at ? 'X' : 'A');
+ ToolUtils::colortype_name(ct),
+ kOpaque_SkAlphaType == at ? 'X' : 'A');
}
protected:
diff --git a/bench/SkGlyphCacheBench.cpp b/bench/SkGlyphCacheBench.cpp
index 27c6d26..fca0381 100644
--- a/bench/SkGlyphCacheBench.cpp
+++ b/bench/SkGlyphCacheBench.cpp
@@ -10,12 +10,11 @@
#include "Benchmark.h"
#include "SkCanvas.h"
-#include "SkStrikeCache.h"
#include "SkGraphics.h"
+#include "SkStrikeCache.h"
#include "SkTaskGroup.h"
#include "SkTypeface.h"
-#include "sk_tool_utils.h"
-
+#include "ToolUtils.h"
static void do_font_stuff(SkFont* font) {
SkPaint defaultPaint;
@@ -58,7 +57,7 @@
SkFont font;
font.setEdging(SkFont::Edging::kAntiAlias);
font.setSubpixel(true);
- font.setTypeface(sk_tool_utils::create_portable_typeface("serif", SkFontStyle::Italic()));
+ font.setTypeface(ToolUtils::create_portable_typeface("serif", SkFontStyle::Italic()));
for (int work = 0; work < loops; work++) {
do_font_stuff(&font);
@@ -89,9 +88,9 @@
void onDraw(int loops, SkCanvas*) override {
size_t oldCacheLimitSize = SkGraphics::GetFontCacheLimit();
SkGraphics::SetFontCacheLimit(fCacheSize);
- sk_sp<SkTypeface> typefaces[] =
- {sk_tool_utils::create_portable_typeface("serif", SkFontStyle::Italic()),
- sk_tool_utils::create_portable_typeface("sans-serif", SkFontStyle::Italic())};
+ sk_sp<SkTypeface> typefaces[] = {
+ ToolUtils::create_portable_typeface("serif", SkFontStyle::Italic()),
+ ToolUtils::create_portable_typeface("sans-serif", SkFontStyle::Italic())};
for (int work = 0; work < loops; work++) {
SkTaskGroup().batch(16, [&](int threadIndex) {
diff --git a/bench/TextBlobBench.cpp b/bench/TextBlobBench.cpp
index 3f54336..a52b09c 100644
--- a/bench/TextBlobBench.cpp
+++ b/bench/TextBlobBench.cpp
@@ -17,7 +17,7 @@
#include "SkTextBlob.h"
#include "SkTypeface.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
/*
* A trivial test which benchmarks the performance of a textblob with a single run.
@@ -27,7 +27,7 @@
SkTextBlobBench() {}
void onDelayedSetup() override {
- fFont.setTypeface(sk_tool_utils::create_portable_typeface("serif", SkFontStyle()));
+ fFont.setTypeface(ToolUtils::create_portable_typeface("serif", SkFontStyle()));
fFont.setSubpixel(true);
// This text seems representative in both length and letter frequency.
diff --git a/bench/TopoSortBench.cpp b/bench/TopoSortBench.cpp
index 123ff74..d0b6202 100644
--- a/bench/TopoSortBench.cpp
+++ b/bench/TopoSortBench.cpp
@@ -10,7 +10,7 @@
#include "SkString.h"
#include "SkTTopoSort.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
class TopoSortBench : public Benchmark {
public:
@@ -30,7 +30,7 @@
// Delayed initialization only done if onDraw will be called.
void onDelayedSetup() override {
- sk_tool_utils::TopoTestNode::AllocNodes(&fGraph, kNumElements);
+ ToolUtils::TopoTestNode::AllocNodes(&fGraph, kNumElements);
for (int i = kNumElements-1; i > 0; --i) {
int numEdges = fRand.nextU() % (kMaxEdges+1);
@@ -49,9 +49,9 @@
fGraph[j]->reset();
}
- sk_tool_utils::TopoTestNode::Shuffle(&fGraph, &fRand);
+ ToolUtils::TopoTestNode::Shuffle(&fGraph, &fRand);
- SkDEBUGCODE(bool actualResult =) SkTTopoSort<sk_tool_utils::TopoTestNode>(&fGraph);
+ SkDEBUGCODE(bool actualResult =) SkTTopoSort<ToolUtils::TopoTestNode>(&fGraph);
SkASSERT(actualResult);
#ifdef SK_DEBUG
@@ -66,7 +66,7 @@
static const int kNumElements = 1000;
static const int kMaxEdges = 5;
- SkTArray<sk_sp<sk_tool_utils::TopoTestNode>> fGraph;
+ SkTArray<sk_sp<ToolUtils::TopoTestNode>> fGraph;
SkRandom fRand;
typedef Benchmark INHERITED;
diff --git a/dm/DM.cpp b/dm/DM.cpp
index fd1409a..8ca0de9 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -40,8 +40,8 @@
#include "SkTypeface_win.h"
#include "Test.h"
#include "TestFontMgr.h"
+#include "ToolUtils.h"
#include "ios_utils.h"
-#include "sk_tool_utils.h"
#include <vector>
@@ -1401,8 +1401,8 @@
if (bitmap) {
result.gamut = identify_gamut (bitmap->colorSpace());
result.transferFn = identify_transfer_fn (bitmap->colorSpace());
- result.colorType = sk_tool_utils::colortype_name(bitmap->colorType ());
- result.alphaType = sk_tool_utils::alphatype_name(bitmap->alphaType ());
+ result.colorType = ToolUtils::colortype_name(bitmap->colorType());
+ result.alphaType = ToolUtils::alphatype_name(bitmap->alphaType());
result.colorDepth = color_depth (bitmap->colorType());
}
JsonWriter::AddBitmapResult(result);
@@ -1518,7 +1518,7 @@
CommandLineFlags::Parse(argc, argv);
if (!FLAGS_nativeFonts) {
- gSkFontMgr_DefaultFactory = &sk_tool_utils::MakePortableFontMgr;
+ gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr;
}
#if defined(SK_BUILD_FOR_WIN)
diff --git a/fuzz/FuzzMain.cpp b/fuzz/FuzzMain.cpp
index eaa5241..23059f2 100644
--- a/fuzz/FuzzMain.cpp
+++ b/fuzz/FuzzMain.cpp
@@ -23,7 +23,7 @@
#include "SkSurface.h"
#include "SkTextBlob.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
#include <iostream>
#include <map>
@@ -354,7 +354,7 @@
static void dump_png(SkBitmap bitmap) {
if (!FLAGS_dump.isEmpty()) {
- sk_tool_utils::EncodeImageToFile(FLAGS_dump[0], bitmap, SkEncodedImageFormat::kPNG, 100);
+ ToolUtils::EncodeImageToFile(FLAGS_dump[0], bitmap, SkEncodedImageFormat::kPNG, 100);
SkDebugf("Dumped to %s\n", FLAGS_dump[0]);
}
}
diff --git a/fuzz/oss_fuzz/FuzzImageFilterDeserialize.cpp b/fuzz/oss_fuzz/FuzzImageFilterDeserialize.cpp
index c388c6e..cb3e332 100644
--- a/fuzz/oss_fuzz/FuzzImageFilterDeserialize.cpp
+++ b/fuzz/oss_fuzz/FuzzImageFilterDeserialize.cpp
@@ -41,7 +41,7 @@
#if defined(IS_FUZZING_WITH_LIBFUZZER)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- gSkFontMgr_DefaultFactory = &sk_tool_utils::MakePortableFontMgr;
+ gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr;
auto bytes = SkData::MakeWithoutCopy(data, size);
FuzzImageFilterDeserialize(bytes);
return 0;
diff --git a/fuzz/oss_fuzz/FuzzMockGPUCanvas.cpp b/fuzz/oss_fuzz/FuzzMockGPUCanvas.cpp
index b55475e..e65467a 100644
--- a/fuzz/oss_fuzz/FuzzMockGPUCanvas.cpp
+++ b/fuzz/oss_fuzz/FuzzMockGPUCanvas.cpp
@@ -20,7 +20,7 @@
}
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- gSkFontMgr_DefaultFactory = &sk_tool_utils::MakePortableFontMgr;
+ gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr;
auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size));
fuzz_MockGPUCanvas(&fuzz);
return 0;
diff --git a/fuzz/oss_fuzz/FuzzNullCanvas.cpp b/fuzz/oss_fuzz/FuzzNullCanvas.cpp
index 1796262..a90f55a 100644
--- a/fuzz/oss_fuzz/FuzzNullCanvas.cpp
+++ b/fuzz/oss_fuzz/FuzzNullCanvas.cpp
@@ -12,7 +12,7 @@
void fuzz_NullCanvas(Fuzz* f);
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- gSkFontMgr_DefaultFactory = &sk_tool_utils::MakePortableFontMgr;
+ gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr;
auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size));
fuzz_NullCanvas(&fuzz);
return 0;
diff --git a/fuzz/oss_fuzz/FuzzRasterN32Canvas.cpp b/fuzz/oss_fuzz/FuzzRasterN32Canvas.cpp
index d29a269..ed16131 100644
--- a/fuzz/oss_fuzz/FuzzRasterN32Canvas.cpp
+++ b/fuzz/oss_fuzz/FuzzRasterN32Canvas.cpp
@@ -12,7 +12,7 @@
void fuzz_RasterN32Canvas(Fuzz* f);
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- gSkFontMgr_DefaultFactory = &sk_tool_utils::MakePortableFontMgr;
+ gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr;
auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size));
fuzz_RasterN32Canvas(&fuzz);
return 0;
diff --git a/fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp b/fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp
index 657ea68..6cd0ca9 100644
--- a/fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp
+++ b/fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp
@@ -29,7 +29,7 @@
#if defined(IS_FUZZING_WITH_LIBFUZZER)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- gSkFontMgr_DefaultFactory = &sk_tool_utils::MakePortableFontMgr;
+ gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr;
SkReadBuffer buf(data, size);
FuzzTextBlobDeserialize(buf);
return 0;
diff --git a/gm/aaclip.cpp b/gm/aaclip.cpp
index e475c74..0260f27 100644
--- a/gm/aaclip.cpp
+++ b/gm/aaclip.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvasPriv.h"
-#include "SkPath.h"
#include "SkMakeUnique.h"
+#include "SkPath.h"
+#include "ToolUtils.h"
+#include "gm.h"
static void do_draw(SkCanvas* canvas, const SkRect& r) {
SkPaint paint;
@@ -257,7 +257,7 @@
SkRect r = SkRect::MakeXYWH(0, H/4, W, H/2);
SkPaint paint;
- paint.setColor(sk_tool_utils::color_to_565(0xFF8888FF));
+ paint.setColor(ToolUtils::color_to_565(0xFF8888FF));
canvas->drawRect(r, paint);
this->doDraw(canvas, path);
diff --git a/gm/aaxfermodes.cpp b/gm/aaxfermodes.cpp
index cbf8db4..58b4c44 100644
--- a/gm/aaxfermodes.cpp
+++ b/gm/aaxfermodes.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkColorPriv.h"
#include "SkPath.h"
#include "SkShader.h"
#include "SkTextUtils.h"
+#include "ToolUtils.h"
+#include "gm.h"
enum {
kXfermodeCount = (int)SkBlendMode::kLastMode + 1 + 1, // extra for arith
@@ -68,7 +68,7 @@
}
void onOnceBeforeDraw() override {
- fLabelFont.setTypeface(sk_tool_utils::create_portable_typeface());
+ fLabelFont.setTypeface(ToolUtils::create_portable_typeface());
fLabelFont.setSize(5 * kShapeSize/8);
fLabelFont.setSubpixel(true);
@@ -141,8 +141,7 @@
canvas->save();
canvas->clipRect(clipRect);
if (kCheckerboard_Pass == drawingPass) {
- sk_tool_utils::draw_checkerboard(canvas, 0xffffffff, 0xffc6c3c6,
- 10);
+ ToolUtils::draw_checkerboard(canvas, 0xffffffff, 0xffc6c3c6, 10);
} else {
SkASSERT(kBackground_Pass == drawingPass);
canvas->drawColor(kBGColor, SkBlendMode::kSrc);
diff --git a/gm/addarc.cpp b/gm/addarc.cpp
index cfb8fed..8a6dd73 100644
--- a/gm/addarc.cpp
+++ b/gm/addarc.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkAnimTimer.h"
#include "SkCanvas.h"
#include "SkPathMeasure.h"
#include "SkRandom.h"
+#include "ToolUtils.h"
+#include "gm.h"
class AddArcGM : public skiagm::GM {
public:
@@ -37,7 +37,7 @@
SkScalar sign = 1;
while (r.width() > paint.getStrokeWidth() * 3) {
- paint.setColor(sk_tool_utils::color_to_565(rand.nextU() | (0xFF << 24)));
+ paint.setColor(ToolUtils::color_to_565(rand.nextU() | (0xFF << 24)));
SkScalar startAngle = rand.nextUScalar1() * 360;
SkScalar speed = SkScalarSqrt(16 / r.width()) * 0.5f;
@@ -131,7 +131,7 @@
SkAutoCanvasRestore acr(canvas, true);
canvas->rotate(fRotate * sign);
- paint.setColor(sk_tool_utils::color_to_565(rand.nextU() | (0xFF << 24)));
+ paint.setColor(ToolUtils::color_to_565(rand.nextU() | (0xFF << 24)));
canvas->drawOval(r, paint);
r.inset(delta, delta);
sign = -sign;
@@ -184,7 +184,7 @@
while (r.width() > strokeWidth * 2) {
SkAutoCanvasRestore acr(canvas, true);
canvas->rotate(fRotate * sign);
- paint.setColor(sk_tool_utils::color_to_565(rand.nextU() | (0xFF << 24)));
+ paint.setColor(ToolUtils::color_to_565(rand.nextU() | (0xFF << 24)));
canvas->drawOval(r, paint);
r.inset(delta, delta);
sign = -sign;
diff --git a/gm/all_bitmap_configs.cpp b/gm/all_bitmap_configs.cpp
index 6bdef12..4435942 100644
--- a/gm/all_bitmap_configs.cpp
+++ b/gm/all_bitmap_configs.cpp
@@ -5,10 +5,10 @@
* found in the LICENSE file.
*/
-#include "SkSurface.h"
#include "Resources.h"
+#include "SkSurface.h"
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkColorPriv.h"
#include "SkFont.h"
@@ -23,7 +23,7 @@
}
SkBitmap copy;
- sk_tool_utils::copy_to(©, colorType, *srcPtr);
+ ToolUtils::copy_to(©, colorType, *srcPtr);
copy.setImmutable();
return copy;
}
@@ -83,7 +83,7 @@
SkFont font;
font.setEdging(SkFont::Edging::kAlias);
- font.setTypeface(sk_tool_utils::create_portable_typeface(nullptr, SkFontStyle::Bold()));
+ font.setTypeface(ToolUtils::create_portable_typeface(nullptr, SkFontStyle::Bold()));
font.setSize(0.28125f * SCALE);
draw_center_letter('K', font, SK_ColorBLACK, Z, Z, canvas);
draw_center_letter('R', font, SK_ColorRED, Z, D, canvas);
@@ -121,9 +121,9 @@
p.setColor(SK_ColorBLACK);
p.setAntiAlias(true);
- SkFont font(sk_tool_utils::create_portable_typeface());
+ SkFont font(ToolUtils::create_portable_typeface());
- sk_tool_utils::draw_checkerboard(canvas, SK_ColorLTGRAY, SK_ColorWHITE, 8);
+ ToolUtils::draw_checkerboard(canvas, SK_ColorLTGRAY, SK_ColorWHITE, 8);
SkBitmap bitmap;
if (GetResourceAsBitmap("images/color_wheel.png", &bitmap)) {
@@ -170,7 +170,7 @@
const SkColorType ct = kBGRA_8888_SkColorType;
#endif
static_assert(ct != kN32_SkColorType, "BRGA!=RGBA");
- SkAssertResult(sk_tool_utils::copy_to(¬N32bitmap, ct, n32bitmap));
+ SkAssertResult(ToolUtils::copy_to(¬N32bitmap, ct, n32bitmap));
SkASSERT(notN32bitmap.colorType() == ct);
return SkImage::MakeFromBitmap(notN32bitmap);
}
@@ -178,7 +178,7 @@
DEF_SIMPLE_GM(not_native32_bitmap_config, canvas, SCALE, SCALE) {
sk_sp<SkImage> notN32image(make_not_native32_color_wheel());
SkASSERT(notN32image);
- sk_tool_utils::draw_checkerboard(canvas, SK_ColorLTGRAY, SK_ColorWHITE, 8);
+ ToolUtils::draw_checkerboard(canvas, SK_ColorLTGRAY, SK_ColorWHITE, 8);
canvas->drawImage(notN32image.get(), 0.0f, 0.0f);
}
@@ -228,7 +228,7 @@
}
DEF_SIMPLE_GM(all_variants_8888, canvas, 4 * SCALE + 30, 2 * SCALE + 10) {
- sk_tool_utils::draw_checkerboard(canvas, SK_ColorLTGRAY, SK_ColorWHITE, 8);
+ ToolUtils::draw_checkerboard(canvas, SK_ColorLTGRAY, SK_ColorWHITE, 8);
sk_sp<SkColorSpace> colorSpaces[] {
SkColorSpace::MakeSRGB(),
diff --git a/gm/androidblendmodes.cpp b/gm/androidblendmodes.cpp
index 1f1500f..0665ddf 100644
--- a/gm/androidblendmodes.cpp
+++ b/gm/androidblendmodes.cpp
@@ -5,10 +5,10 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkBitmap.h"
#include "SkTextUtils.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace skiagm {
@@ -36,7 +36,7 @@
tmp.clear(SK_ColorTRANSPARENT);
SkPaint p;
p.setAntiAlias(true);
- p.setColor(sk_tool_utils::color_to_565(kBlue));
+ p.setColor(ToolUtils::color_to_565(kBlue));
tmp.drawRect(SkRect::MakeLTRB(16, 96, 160, 240), p);
}
@@ -46,7 +46,7 @@
tmp.clear(SK_ColorTRANSPARENT);
SkPaint p;
p.setAntiAlias(true);
- p.setColor(sk_tool_utils::color_to_565(kRed));
+ p.setColor(ToolUtils::color_to_565(kRed));
tmp.drawCircle(160, 95, 80, p);
}
}
@@ -65,12 +65,9 @@
}
void onDraw(SkCanvas* canvas) override {
- SkFont font(sk_tool_utils::create_portable_typeface());
+ SkFont font(ToolUtils::create_portable_typeface());
- sk_tool_utils::draw_checkerboard(canvas,
- kWhite,
- kGrey,
- 32);
+ ToolUtils::draw_checkerboard(canvas, kWhite, kGrey, 32);
int xOffset = 0, yOffset = 0;
diff --git a/gm/animatedGif.cpp b/gm/animatedGif.cpp
index bc12dc8..2d941fa 100644
--- a/gm/animatedGif.cpp
+++ b/gm/animatedGif.cpp
@@ -14,8 +14,8 @@
#include "SkFont.h"
#include "SkPaint.h"
#include "SkString.h"
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include <vector>
@@ -49,7 +49,7 @@
SkBitmap& requiredBitmap = fFrames[requiredFrame];
// For simplicity, do not try to cache old frames
if (requiredBitmap.getPixels() &&
- sk_tool_utils::copy_to(&bm, requiredBitmap.colorType(), requiredBitmap)) {
+ ToolUtils::copy_to(&bm, requiredBitmap.colorType(), requiredBitmap)) {
opts.fPriorFrame = requiredFrame;
}
}
diff --git a/gm/arithmode.cpp b/gm/arithmode.cpp
index adf71ce..7832be8 100644
--- a/gm/arithmode.cpp
+++ b/gm/arithmode.cpp
@@ -6,8 +6,6 @@
*/
#include <SkFont.h>
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkArithmeticImageFilter.h"
#include "SkCanvas.h"
#include "SkColorPriv.h"
@@ -16,6 +14,8 @@
#include "SkImageSource.h"
#include "SkShader.h"
#include "SkSurface.h"
+#include "ToolUtils.h"
+#include "gm.h"
#define WW 100
#define HH 32
@@ -53,7 +53,7 @@
}
static void show_k_text(SkCanvas* canvas, SkScalar x, SkScalar y, const SkScalar k[]) {
- SkFont font(sk_tool_utils::create_portable_typeface(), 24);
+ SkFont font(ToolUtils::create_portable_typeface(), 24);
font.setEdging(SkFont::Edging::kAntiAlias);
SkPaint paint;
paint.setAntiAlias(true);
@@ -149,7 +149,7 @@
canvas->translate(gap, 0);
// Label
- SkFont font(sk_tool_utils::create_portable_typeface(), 24);
+ SkFont font(ToolUtils::create_portable_typeface(), 24);
SkString str(enforcePMColor ? "enforcePM" : "no enforcePM");
canvas->drawString(str, 0, font.getSize(), font, SkPaint());
}
diff --git a/gm/atlastext.cpp b/gm/atlastext.cpp
index 0f539f2..052ea9f 100644
--- a/gm/atlastext.cpp
+++ b/gm/atlastext.cpp
@@ -18,10 +18,10 @@
#include "SkFont.h"
#include "SkTypeface.h"
#include "SkUTF.h"
+#include "ToolUtils.h"
#include "gpu/TestContext.h"
#include "gpu/atlastext/GLTestAtlasTextRenderer.h"
#include "gpu/atlastext/TestAtlasTextRenderer.h"
-#include "sk_tool_utils.h"
// GM that draws text using the Atlas Text interface offscreen and then blits that to the canvas.
@@ -76,14 +76,12 @@
fTarget = SkAtlasTextTarget::Make(fContext, kSize, kSize, targetHandle);
- fTypefaces[0] = sk_tool_utils::create_portable_typeface("serif", SkFontStyle::Italic());
- fTypefaces[1] =
- sk_tool_utils::create_portable_typeface("sans-serif", SkFontStyle::Italic());
- fTypefaces[2] = sk_tool_utils::create_portable_typeface("serif", SkFontStyle::Normal());
- fTypefaces[3] =
- sk_tool_utils::create_portable_typeface("sans-serif", SkFontStyle::Normal());
- fTypefaces[4] = sk_tool_utils::create_portable_typeface("serif", SkFontStyle::Bold());
- fTypefaces[5] = sk_tool_utils::create_portable_typeface("sans-serif", SkFontStyle::Bold());
+ fTypefaces[0] = ToolUtils::create_portable_typeface("serif", SkFontStyle::Italic());
+ fTypefaces[1] = ToolUtils::create_portable_typeface("sans-serif", SkFontStyle::Italic());
+ fTypefaces[2] = ToolUtils::create_portable_typeface("serif", SkFontStyle::Normal());
+ fTypefaces[3] = ToolUtils::create_portable_typeface("sans-serif", SkFontStyle::Normal());
+ fTypefaces[4] = ToolUtils::create_portable_typeface("serif", SkFontStyle::Bold());
+ fTypefaces[5] = ToolUtils::create_portable_typeface("sans-serif", SkFontStyle::Bold());
}
DrawResult onDraw(SkCanvas* canvas, SkString* errorMsg) override {
diff --git a/gm/beziereffects.cpp b/gm/beziereffects.cpp
index 3a3b33b..2e0e52c0 100644
--- a/gm/beziereffects.cpp
+++ b/gm/beziereffects.cpp
@@ -7,8 +7,8 @@
// This test only works with the GPU backend.
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "GrContext.h"
#include "GrContextPriv.h"
diff --git a/gm/bigmatrix.cpp b/gm/bigmatrix.cpp
index 273b049..ca62cc3 100644
--- a/gm/bigmatrix.cpp
+++ b/gm/bigmatrix.cpp
@@ -5,62 +5,59 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkColorPriv.h"
#include "SkPath.h"
#include "SkShader.h"
-DEF_SIMPLE_GM_BG(bigmatrix, canvas, 50, 50,
- sk_tool_utils::color_to_565(0xFF66AA99)) {
- SkMatrix m;
- m.reset();
- m.setRotate(33 * SK_Scalar1);
- m.postScale(3000 * SK_Scalar1, 3000 * SK_Scalar1);
- m.postTranslate(6000 * SK_Scalar1, -5000 * SK_Scalar1);
- canvas->concat(m);
+DEF_SIMPLE_GM_BG(bigmatrix, canvas, 50, 50, ToolUtils::color_to_565(0xFF66AA99)) {
+ SkMatrix m;
+ m.reset();
+ m.setRotate(33 * SK_Scalar1);
+ m.postScale(3000 * SK_Scalar1, 3000 * SK_Scalar1);
+ m.postTranslate(6000 * SK_Scalar1, -5000 * SK_Scalar1);
+ canvas->concat(m);
- SkPaint paint;
- paint.setColor(SK_ColorRED);
- paint.setAntiAlias(true);
+ SkPaint paint;
+ paint.setColor(SK_ColorRED);
+ paint.setAntiAlias(true);
- bool success = m.invert(&m);
- SkASSERT(success);
- (void) success; // silence compiler :(
+ bool success = m.invert(&m);
+ SkASSERT(success);
+ (void)success; // silence compiler :(
- SkPath path;
+ SkPath path;
- SkPoint pt = {10 * SK_Scalar1, 10 * SK_Scalar1};
- SkScalar small = 1 / (500 * SK_Scalar1);
+ SkPoint pt = {10 * SK_Scalar1, 10 * SK_Scalar1};
+ SkScalar small = 1 / (500 * SK_Scalar1);
- m.mapPoints(&pt, 1);
- path.addCircle(pt.fX, pt.fY, small);
- canvas->drawPath(path, paint);
+ m.mapPoints(&pt, 1);
+ path.addCircle(pt.fX, pt.fY, small);
+ canvas->drawPath(path, paint);
- pt.set(30 * SK_Scalar1, 10 * SK_Scalar1);
- m.mapPoints(&pt, 1);
- SkRect rect = {pt.fX - small, pt.fY - small,
- pt.fX + small, pt.fY + small};
- canvas->drawRect(rect, paint);
+ pt.set(30 * SK_Scalar1, 10 * SK_Scalar1);
+ m.mapPoints(&pt, 1);
+ SkRect rect = {pt.fX - small, pt.fY - small, pt.fX + small, pt.fY + small};
+ canvas->drawRect(rect, paint);
- SkBitmap bmp;
- bmp.allocN32Pixels(2, 2);
- uint32_t* pixels = reinterpret_cast<uint32_t*>(bmp.getPixels());
- pixels[0] = SkPackARGB32(0xFF, 0xFF, 0x00, 0x00);
- pixels[1] = SkPackARGB32(0xFF, 0x00, 0xFF, 0x00);
- pixels[2] = SkPackARGB32(0x80, 0x00, 0x00, 0x00);
- pixels[3] = SkPackARGB32(0xFF, 0x00, 0x00, 0xFF);
- pt.set(30 * SK_Scalar1, 30 * SK_Scalar1);
- m.mapPoints(&pt, 1);
- SkMatrix s;
- s.reset();
- s.setScale(SK_Scalar1 / 1000, SK_Scalar1 / 1000);
- paint.setShader(SkShader::MakeBitmapShader(bmp, SkShader::kRepeat_TileMode,
- SkShader::kRepeat_TileMode, &s));
- paint.setAntiAlias(false);
- paint.setFilterQuality(kLow_SkFilterQuality);
- rect.setLTRB(pt.fX - small, pt.fY - small,
- pt.fX + small, pt.fY + small);
- canvas->drawRect(rect, paint);
+ SkBitmap bmp;
+ bmp.allocN32Pixels(2, 2);
+ uint32_t* pixels = reinterpret_cast<uint32_t*>(bmp.getPixels());
+ pixels[0] = SkPackARGB32(0xFF, 0xFF, 0x00, 0x00);
+ pixels[1] = SkPackARGB32(0xFF, 0x00, 0xFF, 0x00);
+ pixels[2] = SkPackARGB32(0x80, 0x00, 0x00, 0x00);
+ pixels[3] = SkPackARGB32(0xFF, 0x00, 0x00, 0xFF);
+ pt.set(30 * SK_Scalar1, 30 * SK_Scalar1);
+ m.mapPoints(&pt, 1);
+ SkMatrix s;
+ s.reset();
+ s.setScale(SK_Scalar1 / 1000, SK_Scalar1 / 1000);
+ paint.setShader(SkShader::MakeBitmapShader(
+ bmp, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &s));
+ paint.setAntiAlias(false);
+ paint.setFilterQuality(kLow_SkFilterQuality);
+ rect.setLTRB(pt.fX - small, pt.fY - small, pt.fX + small, pt.fY + small);
+ canvas->drawRect(rect, paint);
}
diff --git a/gm/bigrrectaaeffect.cpp b/gm/bigrrectaaeffect.cpp
index 613cf2d..86e3daa 100644
--- a/gm/bigrrectaaeffect.cpp
+++ b/gm/bigrrectaaeffect.cpp
@@ -5,13 +5,13 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "GrCaps.h"
#include "GrContext.h"
#include "GrRenderTargetContextPriv.h"
#include "SkRRect.h"
+#include "ToolUtils.h"
#include "effects/GrRRectEffect.h"
+#include "gm.h"
#include "ops/GrDrawOp.h"
#include "ops/GrFillRectOp.h"
@@ -24,7 +24,7 @@
BigRRectAAEffectGM(const SkRRect& rrect, const char* name)
: fRRect(rrect)
, fName(name) {
- this->setBGColor(sk_tool_utils::color_to_565(SK_ColorBLUE));
+ this->setBGColor(ToolUtils::color_to_565(SK_ColorBLUE));
// Each test case draws the rrect with gaps around it.
fTestWidth = SkScalarCeilToInt(rrect.width()) + 2 * kGap;
fTestHeight = SkScalarCeilToInt(rrect.height()) + 2 * kGap;
diff --git a/gm/bigtext.cpp b/gm/bigtext.cpp
index 839609e..f30c7b9 100644
--- a/gm/bigtext.cpp
+++ b/gm/bigtext.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkFont.h"
#include "SkPath.h"
+#include "ToolUtils.h"
+#include "gm.h"
/**
* Skia may draw from outlines when the size is very large, so we exercise that
@@ -33,7 +33,7 @@
void onDraw(SkCanvas* canvas) override {
SkPaint paint;
paint.setAntiAlias(true);
- SkFont font(sk_tool_utils::create_portable_typeface(), 1500);
+ SkFont font(ToolUtils::create_portable_typeface(), 1500);
SkRect r;
(void)font.measureText("/", 1, kUTF8_SkTextEncoding, &r);
diff --git a/gm/bitmapcopy.cpp b/gm/bitmapcopy.cpp
index 7fba4b6..9c4fbb7 100644
--- a/gm/bitmapcopy.cpp
+++ b/gm/bitmapcopy.cpp
@@ -5,9 +5,9 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkFont.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace skiagm {
@@ -82,13 +82,13 @@
draw_checks(&canvasTmp, 40, 40);
for (unsigned i = 0; i < NUM_CONFIGS; ++i) {
- sk_tool_utils::copy_to(&fDst[i], gColorTypes[i], src);
+ ToolUtils::copy_to(&fDst[i], gColorTypes[i], src);
}
canvas->clear(0xFFDDDDDD);
paint.setAntiAlias(true);
- SkFont font(sk_tool_utils::create_portable_typeface());
+ SkFont font(ToolUtils::create_portable_typeface());
SkScalar width = SkIntToScalar(40);
SkScalar height = SkIntToScalar(40);
diff --git a/gm/bitmapfilters.cpp b/gm/bitmapfilters.cpp
index 8248d02..2ae7fc9 100644
--- a/gm/bitmapfilters.cpp
+++ b/gm/bitmapfilters.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
static void make_bm(SkBitmap* bm) {
const SkColor colors[4] = {
@@ -49,8 +49,8 @@
SkScalar x = 0;
const int scale = 32;
- SkFont font(sk_tool_utils::create_portable_typeface());
- const char* name = sk_tool_utils::colortype_name(bm.colorType());
+ SkFont font(ToolUtils::create_portable_typeface());
+ const char* name = ToolUtils::colortype_name(bm.colorType());
canvas->drawString(name, x, SkIntToScalar(bm.height())*scale*5/8,
font, paint);
canvas->translate(SkIntToScalar(48), 0);
@@ -67,8 +67,8 @@
class FilterGM : public skiagm::GM {
void onOnceBeforeDraw() override {
make_bm(&fBM32);
- sk_tool_utils::copy_to(&fBM4444, kARGB_4444_SkColorType, fBM32);
- sk_tool_utils::copy_to(&fBM16, kRGB_565_SkColorType, fBM32);
+ ToolUtils::copy_to(&fBM4444, kARGB_4444_SkColorType, fBM32);
+ ToolUtils::copy_to(&fBM16, kRGB_565_SkColorType, fBM32);
}
public:
diff --git a/gm/bleed.cpp b/gm/bleed.cpp
index f7d582f..ab7ca99 100644
--- a/gm/bleed.cpp
+++ b/gm/bleed.cpp
@@ -5,7 +5,6 @@
* found in the LICENSE file.
*/
-#include "gm.h"
#include "SkBlurMask.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
@@ -13,7 +12,8 @@
#include "SkMaskFilter.h"
#include "SkTDArray.h"
#include "SkUTF.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
+#include "gm.h"
#include "GrContext.h"
#include "GrContextOptions.h"
@@ -457,7 +457,7 @@
// produce different mipmap filtering when we have an odd sized texture.
const int N = 10 + 2 + 8 + 2 + 10;
SkImageInfo info = SkImageInfo::MakeN32Premul(N, N);
- auto surface = sk_tool_utils::makeSurface(canvas, info);
+ auto surface = ToolUtils::makeSurface(canvas, info);
SkCanvas* c = surface->getCanvas();
SkRect r = SkRect::MakeIWH(info.width(), info.height());
SkPaint paint;
@@ -489,7 +489,7 @@
canvas->save();
for (auto quality : qualities) {
paint.setFilterQuality(quality);
- auto surf = sk_tool_utils::makeSurface(canvas, SkImageInfo::MakeN32Premul(1, 1));
+ auto surf = ToolUtils::makeSurface(canvas, SkImageInfo::MakeN32Premul(1, 1));
surf->getCanvas()->drawImageRect(img, src, SkRect::MakeWH(1, 1), &paint, constraint);
// now blow up the 1 pixel result
canvas->drawImageRect(surf->makeImageSnapshot(), SkRect::MakeWH(100, 100), nullptr);
diff --git a/gm/blend.cpp b/gm/blend.cpp
index 28ec6ff..aaaeeeb 100644
--- a/gm/blend.cpp
+++ b/gm/blend.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
DEF_SIMPLE_GM(blend, canvas, 300, 100) {
SkPaint p;
@@ -30,8 +30,8 @@
p.setColor(SK_ColorRED);
canvas->drawRect(SkRect::MakeXYWH(2,0,1,1), p);
canvas->saveLayerAlpha(nullptr, 0xFC);
- p.setColor(sk_tool_utils::color_to_565(0xFF208000));
- canvas->drawRect(SkRect::MakeXYWH(2,0,1,1), p);
+ p.setColor(ToolUtils::color_to_565(0xFF208000));
+ canvas->drawRect(SkRect::MakeXYWH(2, 0, 1, 1), p);
canvas->restore();
canvas->restore();
}
diff --git a/gm/blurignorexform.cpp b/gm/blurignorexform.cpp
index 28fc19d..9a68daf 100644
--- a/gm/blurignorexform.cpp
+++ b/gm/blurignorexform.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkBlurMask.h"
#include "SkCanvas.h"
@@ -95,7 +95,7 @@
void drawOverlay(SkCanvas* canvas) {
canvas->translate(10, 0);
- SkFont font(sk_tool_utils::create_portable_typeface());
+ SkFont font(ToolUtils::create_portable_typeface());
canvas->save();
for (int i = 0; i < kNumBlurs; ++i) {
canvas->drawString(kBlurFlags[i].fName, 100, 0, font, SkPaint());
diff --git a/gm/blurimagevmask.cpp b/gm/blurimagevmask.cpp
index 9a213d5..78524ca 100644
--- a/gm/blurimagevmask.cpp
+++ b/gm/blurimagevmask.cpp
@@ -7,16 +7,15 @@
#include "SkBlurImageFilter.h"
#include "SkMaskFilter.h"
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
-
DEF_SIMPLE_GM(blurimagevmask, canvas, 700, 1200) {
SkPaint paint;
paint.setAntiAlias(true);
paint.setColor(SK_ColorBLACK);
- SkFont font(sk_tool_utils::create_portable_typeface(), 25);
+ SkFont font(ToolUtils::create_portable_typeface(), 25);
const double sigmas[] = {3.0, 8.0, 16.0, 24.0, 32.0};
diff --git a/gm/blurs.cpp b/gm/blurs.cpp
index 6892ad3..23ef092 100644
--- a/gm/blurs.cpp
+++ b/gm/blurs.cpp
@@ -5,13 +5,13 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "Resources.h"
#include "SkBlurMask.h"
#include "SkImage.h"
#include "SkMaskFilter.h"
#include "SkPath.h"
+#include "ToolUtils.h"
+#include "gm.h"
DEF_SIMPLE_GM_BG(blurs, canvas, 700, 500, 0xFFDDDDDD) {
SkBlurStyle NONE = SkBlurStyle(-999);
@@ -46,7 +46,7 @@
}
// draw text
{
- SkFont font(sk_tool_utils::create_portable_typeface(), 25);
+ SkFont font(ToolUtils::create_portable_typeface(), 25);
paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(4))));
SkScalar x = SkIntToScalar(70);
diff --git a/gm/bmpfilterqualityrepeat.cpp b/gm/bmpfilterqualityrepeat.cpp
index ba41c3a..ee4529f 100644
--- a/gm/bmpfilterqualityrepeat.cpp
+++ b/gm/bmpfilterqualityrepeat.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkShader.h"
@@ -15,7 +15,7 @@
// the bmp filter respects the repeat mode at the tile seams.
class BmpFilterQualityRepeat : public skiagm::GM {
public:
- BmpFilterQualityRepeat() { this->setBGColor(sk_tool_utils::color_to_565(0xFFCCBBAA)); }
+ BmpFilterQualityRepeat() { this->setBGColor(ToolUtils::color_to_565(0xFFCCBBAA)); }
protected:
@@ -26,11 +26,11 @@
colorBmp.allocN32Pixels(20, 20, true);
colorBmp.eraseColor(0xFFFF0000);
canvas.drawBitmap(colorBmp, 0, 0);
- colorBmp.eraseColor(sk_tool_utils::color_to_565(0xFF008200));
+ colorBmp.eraseColor(ToolUtils::color_to_565(0xFF008200));
canvas.drawBitmap(colorBmp, 20, 0);
- colorBmp.eraseColor(sk_tool_utils::color_to_565(0xFFFF9000));
+ colorBmp.eraseColor(ToolUtils::color_to_565(0xFFFF9000));
canvas.drawBitmap(colorBmp, 0, 20);
- colorBmp.eraseColor(sk_tool_utils::color_to_565(0xFF2000FF));
+ colorBmp.eraseColor(ToolUtils::color_to_565(0xFF2000FF));
canvas.drawBitmap(colorBmp, 20, 20);
}
@@ -68,7 +68,7 @@
SkPaint bmpPaint(textPaint);
- SkFont font(sk_tool_utils::create_portable_typeface());
+ SkFont font(ToolUtils::create_portable_typeface());
SkAutoCanvasRestore acr(canvas, true);
diff --git a/gm/clip_error.cpp b/gm/clip_error.cpp
index 7e9c4ce..43c00ec 100644
--- a/gm/clip_error.cpp
+++ b/gm/clip_error.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkBlurMask.h"
#include "SkCanvas.h"
#include "SkMaskFilter.h"
#include "SkTextBlob.h"
+#include "ToolUtils.h"
+#include "gm.h"
#define WIDTH 800
#define HEIGHT 800
@@ -42,7 +42,7 @@
SkPaint paint;
paint.setAntiAlias(true);
- SkFont font(sk_tool_utils::create_portable_typeface(), 256);
+ SkFont font(ToolUtils::create_portable_typeface(), 256);
// setup up maskfilter
const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(50));
diff --git a/gm/coloremoji.cpp b/gm/coloremoji.cpp
index 8ec41d2..a64ca07 100644
--- a/gm/coloremoji.cpp
+++ b/gm/coloremoji.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "Resources.h"
#include "SkBlurImageFilter.h"
@@ -62,8 +62,8 @@
const char* text;
} emojiFont;
virtual void onOnceBeforeDraw() override {
- emojiFont.typeface = sk_tool_utils::emoji_typeface();
- emojiFont.text = sk_tool_utils::emoji_sample_text();
+ emojiFont.typeface = ToolUtils::emoji_typeface();
+ emojiFont.text = ToolUtils::emoji_sample_text();
}
SkString onShortName() override {
diff --git a/gm/coloremoji_blendmodes.cpp b/gm/coloremoji_blendmodes.cpp
index 8538cdd..57febb9 100644
--- a/gm/coloremoji_blendmodes.cpp
+++ b/gm/coloremoji_blendmodes.cpp
@@ -24,8 +24,8 @@
#include "SkTypeface.h"
#include "SkTypes.h"
#include "SkUTF.h"
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
namespace skiagm {
@@ -50,12 +50,11 @@
paint.setShader(SkGradientShader::MakeSweep(0, 0, colors, nullptr, SK_ARRAY_COUNT(colors),
0, &local));
- sk_sp<SkTypeface> orig(sk_tool_utils::create_portable_typeface("serif",
- SkFontStyle::Bold()));
+ sk_sp<SkTypeface> orig(ToolUtils::create_portable_typeface("serif", SkFontStyle::Bold()));
if (nullptr == orig) {
orig = SkTypeface::MakeDefault();
}
- fColorType = sk_tool_utils::emoji_typeface();
+ fColorType = ToolUtils::emoji_typeface();
fBG.installPixels(SkImageInfo::Make(2, 2, kARGB_4444_SkColorType,
kOpaque_SkAlphaType), gData, 4);
@@ -112,7 +111,7 @@
auto s = SkShader::MakeBitmapShader(fBG, SkShader::kRepeat_TileMode,
SkShader::kRepeat_TileMode, &m);
- SkFont labelFont(sk_tool_utils::create_portable_typeface());
+ SkFont labelFont(ToolUtils::create_portable_typeface());
SkPaint textP;
textP.setAntiAlias(true);
@@ -141,7 +140,7 @@
SkAutoCanvasRestore arc(canvas, true);
canvas->clipRect(r);
textP.setBlendMode(gModes[i]);
- const char* text = sk_tool_utils::emoji_sample_text();
+ const char* text = ToolUtils::emoji_sample_text();
SkUnichar unichar = SkUTF::NextUTF8(&text, text + strlen(text));
SkASSERT(unichar >= 0);
canvas->drawSimpleText(&unichar, 4, kUTF32_SkTextEncoding, x+ w/10.f, y + 7.f*h/8.f,
diff --git a/gm/colorwheel.cpp b/gm/colorwheel.cpp
index 230b85c..2f2d1a3 100644
--- a/gm/colorwheel.cpp
+++ b/gm/colorwheel.cpp
@@ -8,8 +8,8 @@
#include "Resources.h"
#include "SkData.h"
#include "SkImage.h"
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
static void draw_image(SkCanvas* canvas, const char* resource, int x, int y) {
sk_sp<SkImage> image(GetResourceAsImage(resource));
@@ -31,7 +31,7 @@
background and compression artifacts.
*/
DEF_SIMPLE_GM(colorwheel, canvas, 256, 256) {
- sk_tool_utils::draw_checkerboard(canvas);
+ ToolUtils::draw_checkerboard(canvas);
draw_image(canvas, "images/color_wheel.png", 0, 0); // top left
draw_image(canvas, "images/color_wheel.gif", 128, 0); // top right
draw_image(canvas, "images/color_wheel.webp", 0, 128); // bottom left
@@ -40,7 +40,7 @@
DEF_SIMPLE_GM(colorwheelnative, canvas, 128, 28) {
SkPaint paint;
- SkFont font(sk_tool_utils::create_portable_typeface("sans-serif", SkFontStyle::Bold()), 18);
+ SkFont font(ToolUtils::create_portable_typeface("sans-serif", SkFontStyle::Bold()), 18);
font.setEdging(SkFont::Edging::kAlias);
canvas->clear(SK_ColorLTGRAY);
diff --git a/gm/complexclip.cpp b/gm/complexclip.cpp
index 415151f..c0a64c9 100644
--- a/gm/complexclip.cpp
+++ b/gm/complexclip.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkFont.h"
#include "SkPath.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace skiagm {
@@ -69,7 +69,7 @@
SkPath clipB;
clipB.addPoly({{40, 10}, {190, 15}, {195, 190}, {40, 185}, {155, 100}}, false).close();
- SkFont font(sk_tool_utils::create_portable_typeface(), 20);
+ SkFont font(ToolUtils::create_portable_typeface(), 20);
constexpr struct {
SkClipOp fOp;
diff --git a/gm/complexclip3.cpp b/gm/complexclip3.cpp
index afb5a5a..b2b2a57 100644
--- a/gm/complexclip3.cpp
+++ b/gm/complexclip3.cpp
@@ -4,10 +4,10 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkPath.h"
+#include "ToolUtils.h"
+#include "gm.h"
#include <utility>
@@ -53,7 +53,7 @@
SkPaint paint;
paint.setAntiAlias(true);
- SkFont font(sk_tool_utils::create_portable_typeface(), 20);
+ SkFont font(ToolUtils::create_portable_typeface(), 20);
constexpr struct {
SkClipOp fOp;
diff --git a/gm/complexclip_blur_tiled.cpp b/gm/complexclip_blur_tiled.cpp
index 47234da..f69c40d 100644
--- a/gm/complexclip_blur_tiled.cpp
+++ b/gm/complexclip_blur_tiled.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
-#include "gm.h"
#include "SkBlurImageFilter.h"
+#include "SkClipOpPriv.h"
#include "SkRRect.h"
#include "SkSurface.h"
-#include "SkClipOpPriv.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
+#include "gm.h"
#define WIDTH 512
#define HEIGHT 512
@@ -38,7 +38,7 @@
SkRect bounds = canvas->getLocalClipBounds();
int ts = SkScalarCeilToInt(tileSize);
SkImageInfo info = SkImageInfo::MakeN32Premul(ts, ts);
- auto tileSurface(sk_tool_utils::makeSurface(canvas, info));
+ auto tileSurface(ToolUtils::makeSurface(canvas, info));
SkCanvas* tileCanvas = tileSurface->getCanvas();
for (SkScalar y = bounds.top(); y < bounds.bottom(); y += tileSize) {
for (SkScalar x = bounds.left(); x < bounds.right(); x += tileSize) {
diff --git a/gm/constcolorprocessor.cpp b/gm/constcolorprocessor.cpp
index af99e60..2fbfb15 100644
--- a/gm/constcolorprocessor.cpp
+++ b/gm/constcolorprocessor.cpp
@@ -7,8 +7,8 @@
// This test only works with the GPU backend.
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "GrContext.h"
#include "GrRenderTargetContextPriv.h"
@@ -103,7 +103,7 @@
// Draw labels for the input to the processor and the processor to the right of
// the test rect. The input label appears above the processor label.
SkFont labelFont;
- labelFont.setTypeface(sk_tool_utils::create_portable_typeface());
+ labelFont.setTypeface(ToolUtils::create_portable_typeface());
labelFont.setEdging(SkFont::Edging::kAntiAlias);
labelFont.setSize(10.f);
SkPaint labelPaint;
diff --git a/gm/convexpolyclip.cpp b/gm/convexpolyclip.cpp
index 2ab41ca..4d702ad 100644
--- a/gm/convexpolyclip.cpp
+++ b/gm/convexpolyclip.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkBitmap.h"
#include "SkFont.h"
@@ -26,12 +26,13 @@
SkScalar radius = 3 * SkMaxScalar(wScalar, hScalar);
- SkColor colors[] = { SK_ColorDKGRAY,
- sk_tool_utils::color_to_565(0xFF222255),
- sk_tool_utils::color_to_565(0xFF331133),
- sk_tool_utils::color_to_565(0xFF884422),
- sk_tool_utils::color_to_565(0xFF000022), SK_ColorWHITE,
- sk_tool_utils::color_to_565(0xFFAABBCC) };
+ SkColor colors[] = {SK_ColorDKGRAY,
+ ToolUtils::color_to_565(0xFF222255),
+ ToolUtils::color_to_565(0xFF331133),
+ ToolUtils::color_to_565(0xFF884422),
+ ToolUtils::color_to_565(0xFF000022),
+ SK_ColorWHITE,
+ ToolUtils::color_to_565(0xFFAABBCC)};
SkScalar pos[] = {0,
SK_Scalar1 / 6,
@@ -57,7 +58,7 @@
mat.postScale(SK_Scalar1 / 3, SK_Scalar1 / 3);
}
- SkFont font(sk_tool_utils::create_portable_typeface(), wScalar / 2.2f);
+ SkFont font(ToolUtils::create_portable_typeface(), wScalar / 2.2f);
paint.setShader(nullptr);
paint.setColor(SK_ColorLTGRAY);
@@ -150,7 +151,7 @@
canvas->drawBitmapRect(fBmp, SkRect::MakeIWH(size.fWidth, size.fHeight), &bgPaint);
constexpr char kTxt[] = "Clip Me!";
- SkFont font(sk_tool_utils::create_portable_typeface(), 23);
+ SkFont font(ToolUtils::create_portable_typeface(), 23);
SkScalar textW = font.measureText(kTxt, SK_ARRAY_COUNT(kTxt)-1, kUTF8_SkTextEncoding);
SkPaint txtPaint;
txtPaint.setColor(SK_ColorDKGRAY);
diff --git a/gm/copyTo4444.cpp b/gm/copyTo4444.cpp
index 194a30a..0f4a276 100644
--- a/gm/copyTo4444.cpp
+++ b/gm/copyTo4444.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "Resources.h"
#include "SkCanvas.h"
@@ -39,7 +39,7 @@
canvas->drawBitmap(bm, 0, 0);
// This should dither or we will see artifacts in the background of the image.
- SkAssertResult(sk_tool_utils::copy_to(&bm4444, kARGB_4444_SkColorType, bm));
+ SkAssertResult(ToolUtils::copy_to(&bm4444, kARGB_4444_SkColorType, bm));
canvas->drawBitmap(bm4444, SkIntToScalar(bm.width()), 0);
return DrawResult::kOk;
}
diff --git a/gm/cubicpaths.cpp b/gm/cubicpaths.cpp
index 14f8ae6..d4bf225 100644
--- a/gm/cubicpaths.cpp
+++ b/gm/cubicpaths.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkPaint.h"
#include "SkPath.h"
#include "SkRandom.h"
+#include "ToolUtils.h"
+#include "gm.h"
// https://bug.skia.org/1316 shows that this cubic, when slightly clipped, creates big
// (incorrect) changes to its control points.
@@ -198,7 +198,7 @@
SkPaint titlePaint;
titlePaint.setColor(SK_ColorBLACK);
titlePaint.setAntiAlias(true);
- SkFont font(sk_tool_utils::create_portable_typeface(), 15);
+ SkFont font(ToolUtils::create_portable_typeface(), 15);
const char title[] = "Cubic Drawn Into Rectangle Clips With "
"Indicated Style, Fill and Linecaps, with stroke width 10";
canvas->drawString(title, 20, 20, font, titlePaint);
@@ -328,7 +328,7 @@
SkPaint titlePaint;
titlePaint.setColor(SK_ColorBLACK);
titlePaint.setAntiAlias(true);
- SkFont font(sk_tool_utils::create_portable_typeface(), 15);
+ SkFont font(ToolUtils::create_portable_typeface(), 15);
const char title[] = "Cubic Closed Drawn Into Rectangle Clips With "
"Indicated Style, Fill and Linecaps, with stroke width 10";
canvas->drawString(title, 20, 20, font, titlePaint);
diff --git a/gm/dashing.cpp b/gm/dashing.cpp
index cacdc00..58b10ce 100644
--- a/gm/dashing.cpp
+++ b/gm/dashing.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
-#include "SkPaint.h"
#include "SkDashPathEffect.h"
+#include "SkPaint.h"
+#include "ToolUtils.h"
+#include "gm.h"
static void drawline(SkCanvas* canvas, int on, int off, const SkPaint& paint,
SkScalar finalX = SkIntToScalar(600), SkScalar finalY = SkIntToScalar(0),
@@ -562,7 +562,7 @@
p.setStrokeJoin(SkPaint::kRound_Join);
p.setARGB(0xff, 0xbb, 0x00, 0x00);
- SkFont font(sk_tool_utils::create_portable_typeface(), 100);
+ SkFont font(ToolUtils::create_portable_typeface(), 100);
const SkScalar intervals[] = { 12, 12 };
p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0));
diff --git a/gm/degeneratesegments.cpp b/gm/degeneratesegments.cpp
index 0ebca10..17de581 100644
--- a/gm/degeneratesegments.cpp
+++ b/gm/degeneratesegments.cpp
@@ -4,12 +4,12 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkPaint.h"
#include "SkPath.h"
#include "SkRandom.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace skiagm {
@@ -289,7 +289,7 @@
SkPaint titlePaint;
titlePaint.setColor(SK_ColorBLACK);
titlePaint.setAntiAlias(true);
- SkFont font(sk_tool_utils::create_portable_typeface(), 15);
+ SkFont font(ToolUtils::create_portable_typeface(), 15);
const char title[] = "Random Paths Drawn Into Rectangle Clips With "
"Indicated Style, Fill and Linecaps, "
"with Stroke width 6";
@@ -314,7 +314,7 @@
canvas->translate(rect.width() + 4*SK_Scalar1, 0);
}
- SkColor color = sk_tool_utils::color_to_565(0xff007000);
+ SkColor color = ToolUtils::color_to_565(0xff007000);
StyleAndName style = gStyles[(rand.nextU() >> 16) % numStyles];
CapAndName cap = gCaps[(rand.nextU() >> 16) % numCaps];
FillAndName fill = gFills[(rand.nextU() >> 16) % numFills];
diff --git a/gm/dftext.cpp b/gm/dftext.cpp
index e8fe2b8..37f8b84 100644
--- a/gm/dftext.cpp
+++ b/gm/dftext.cpp
@@ -13,8 +13,8 @@
#include "SkTextBlob.h"
#include "SkTo.h"
#include "SkTypeface.h"
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
class DFTextGM : public skiagm::GM {
public:
@@ -24,8 +24,8 @@
protected:
void onOnceBeforeDraw() override {
- fEmojiTypeface = sk_tool_utils::emoji_typeface();
- fEmojiText = sk_tool_utils::emoji_sample_text();
+ fEmojiTypeface = ToolUtils::emoji_typeface();
+ fEmojiText = ToolUtils::emoji_sample_text();
}
SkString onShortName() override {
@@ -58,7 +58,7 @@
SkPaint paint;
paint.setAntiAlias(true);
- SkFont font(sk_tool_utils::create_portable_typeface("serif", SkFontStyle()));
+ SkFont font(ToolUtils::create_portable_typeface("serif", SkFontStyle()));
font.setSubpixel(true);
const char* text = "Hamburgefons";
diff --git a/gm/dftext_blob_persp.cpp b/gm/dftext_blob_persp.cpp
index 32f19b1..70111e4 100644
--- a/gm/dftext_blob_persp.cpp
+++ b/gm/dftext_blob_persp.cpp
@@ -5,13 +5,13 @@
* found in the LICENSE file.
*/
-#include "gm.h"
#include "Resources.h"
#include "SkCanvas.h"
#include "SkSurface.h"
#include "SkTextBlob.h"
#include "SkTypeface.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
+#include "gm.h"
/**
* This GM tests reusing the same text blobs with distance fields rendering using various
@@ -38,7 +38,7 @@
SkFont::Edging::kSubpixelAntiAlias));
font.setSubpixel(true);
SkTextBlobBuilder builder;
- sk_tool_utils::add_to_text_blob(&builder, "SkiaText", font, 0, 0);
+ ToolUtils::add_to_text_blob(&builder, "SkiaText", font, 0, 0);
fBlobs.emplace_back(builder.make());
}
}
diff --git a/gm/discard.cpp b/gm/discard.cpp
index 8cec42f..18023aa 100644
--- a/gm/discard.cpp
+++ b/gm/discard.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkPaint.h"
#include "SkRandom.h"
#include "SkSurface.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace skiagm {
@@ -52,7 +52,7 @@
for (int y = 0; y < 10; ++y) {
surface->getCanvas()->discard();
// Make something that isn't too close to the background color, black.
- SkColor color = sk_tool_utils::color_to_565(rand.nextU() | 0xFF404040);
+ SkColor color = ToolUtils::color_to_565(rand.nextU() | 0xFF404040);
switch (rand.nextULessThan(3)) {
case 0:
surface->getCanvas()->drawColor(color);
diff --git a/gm/displacement.cpp b/gm/displacement.cpp
index 9fea018..83a5085 100644
--- a/gm/displacement.cpp
+++ b/gm/displacement.cpp
@@ -8,8 +8,8 @@
#include "SkDisplacementMapEffect.h"
#include "SkImage.h"
#include "SkImageSource.h"
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
namespace skiagm {
@@ -25,21 +25,17 @@
}
void onOnceBeforeDraw() override {
- fBitmap = sk_tool_utils::create_string_bitmap(80, 80, 0xFF884422, 15, 55, 96, "g");
+ fBitmap = ToolUtils::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);
+ SkColor c1 = ToolUtils::color_to_565(0xFF244484);
+ SkColor c2 = ToolUtils::color_to_565(0xFF804020);
- fCheckerboard = SkImage::MakeFromBitmap(
- sk_tool_utils::create_checkerboard_bitmap(80, 80, c1, c2, 8));
- fSmall = SkImage::MakeFromBitmap(
- sk_tool_utils::create_checkerboard_bitmap(64, 64, c1, c2, 8));
- fLarge = SkImage::MakeFromBitmap(
- sk_tool_utils::create_checkerboard_bitmap(96, 96, c1, c2, 8));
- fLargeW =
- SkImage::MakeFromBitmap(sk_tool_utils::create_checkerboard_bitmap(96, 64, c1, c2, 8));
- fLargeH = SkImage::MakeFromBitmap(
- sk_tool_utils::create_checkerboard_bitmap(64, 96, c1, c2, 8));
+ fCheckerboard =
+ SkImage::MakeFromBitmap(ToolUtils::create_checkerboard_bitmap(80, 80, c1, c2, 8));
+ fSmall = SkImage::MakeFromBitmap(ToolUtils::create_checkerboard_bitmap(64, 64, c1, c2, 8));
+ fLarge = SkImage::MakeFromBitmap(ToolUtils::create_checkerboard_bitmap(96, 96, c1, c2, 8));
+ fLargeW = SkImage::MakeFromBitmap(ToolUtils::create_checkerboard_bitmap(96, 64, c1, c2, 8));
+ fLargeH = SkImage::MakeFromBitmap(ToolUtils::create_checkerboard_bitmap(64, 96, c1, c2, 8));
}
SkISize onISize() override {
diff --git a/gm/downsamplebitmap.cpp b/gm/downsamplebitmap.cpp
index cc521d0..e0dde1b 100644
--- a/gm/downsamplebitmap.cpp
+++ b/gm/downsamplebitmap.cpp
@@ -6,8 +6,8 @@
*/
#include "Resources.h"
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
static const char* kFilterQualityNames[] = { "none", "low", "medium", "high" };
@@ -87,13 +87,13 @@
font.setSubpixel(true);
font.setSize(textSize);
- font.setTypeface(sk_tool_utils::create_portable_typeface("serif", SkFontStyle()));
+ font.setTypeface(ToolUtils::create_portable_typeface("serif", SkFontStyle()));
canvas.drawString("Hamburgefons", textSize/2, 1.2f*textSize, font, paint);
- font.setTypeface(sk_tool_utils::create_portable_typeface("serif", SkFontStyle::Bold()));
+ font.setTypeface(ToolUtils::create_portable_typeface("serif", SkFontStyle::Bold()));
canvas.drawString("Hamburgefons", textSize/2, 2.4f*textSize, font, paint);
- font.setTypeface(sk_tool_utils::create_portable_typeface("serif", SkFontStyle::Italic()));
+ font.setTypeface(ToolUtils::create_portable_typeface("serif", SkFontStyle::Italic()));
canvas.drawString("Hamburgefons", textSize/2, 3.6f*textSize, font, paint);
- font.setTypeface(sk_tool_utils::create_portable_typeface("serif", SkFontStyle::BoldItalic()));
+ font.setTypeface(ToolUtils::create_portable_typeface("serif", SkFontStyle::BoldItalic()));
canvas.drawString("Hamburgefons", textSize/2, 4.8f*textSize, font, paint);
return bm;
diff --git a/gm/drawatlas.cpp b/gm/drawatlas.cpp
index 0146822..5ee6d39 100644
--- a/gm/drawatlas.cpp
+++ b/gm/drawatlas.cpp
@@ -12,12 +12,12 @@
#include "SkRSXform.h"
#include "SkSurface.h"
#include "SkTextBlob.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
class DrawAtlasGM : public skiagm::GM {
static sk_sp<SkImage> MakeAtlas(SkCanvas* caller, const SkRect& target) {
SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
- auto surface(sk_tool_utils::makeSurface(caller, info));
+ auto surface(ToolUtils::makeSurface(caller, info));
SkCanvas* canvas = surface->getCanvas();
// draw red everywhere, but we don't expect to see it in the draw, testing the notion
// that drawAtlas draws a subset-region of the atlas.
@@ -212,7 +212,7 @@
// Exercise xform blob and its bounds
DEF_SIMPLE_GM(blob_rsxform, canvas, 500, 100) {
SkFont font;
- font.setTypeface(sk_tool_utils::create_portable_typeface());
+ font.setTypeface(ToolUtils::create_portable_typeface());
font.setSize(50);
const char text[] = "CrazyXform";
diff --git a/gm/drawatlascolor.cpp b/gm/drawatlascolor.cpp
index 82bf998..532b771 100644
--- a/gm/drawatlascolor.cpp
+++ b/gm/drawatlascolor.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkRSXform.h"
#include "SkSurface.h"
+#include "ToolUtils.h"
+#include "gm.h"
// Create a square atlas of:
// opaque white | opaque red
@@ -20,7 +20,7 @@
const int kBlockSize = atlasSize/2;
SkImageInfo info = SkImageInfo::MakeN32Premul(atlasSize, atlasSize);
- auto surface(sk_tool_utils::makeSurface(caller, info));
+ auto surface(ToolUtils::makeSurface(caller, info));
SkCanvas* canvas = surface->getCanvas();
SkPaint paint;
@@ -128,7 +128,7 @@
quadColors[i] = gColors[i];
}
- SkFont font(sk_tool_utils::create_portable_typeface(), kTextPad);
+ SkFont font(ToolUtils::create_portable_typeface(), kTextPad);
for (int i = 0; i < numModes; ++i) {
const char* label = SkBlendMode_Name(gModes[i]);
diff --git a/gm/drawbitmaprect.cpp b/gm/drawbitmaprect.cpp
index 5c8eb6d..4d4204c 100644
--- a/gm/drawbitmaprect.cpp
+++ b/gm/drawbitmaprect.cpp
@@ -5,8 +5,6 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkColorPriv.h"
@@ -16,7 +14,8 @@
#include "SkMathPriv.h"
#include "SkShader.h"
#include "SkSurface.h"
-
+#include "ToolUtils.h"
+#include "gm.h"
static SkBitmap make_chessbm(int w, int h) {
SkBitmap bm;
@@ -35,7 +34,7 @@
static sk_sp<SkImage> makebm(SkCanvas* origCanvas, SkBitmap* resultBM, int w, int h) {
SkImageInfo info = SkImageInfo::MakeN32Premul(w, h);
- auto surface(sk_tool_utils::makeSurface(origCanvas, info));
+ auto surface(ToolUtils::makeSurface(origCanvas, info));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(SK_ColorTRANSPARENT);
@@ -172,7 +171,7 @@
blackPaint.setColor(SK_ColorBLACK);
blackPaint.setAntiAlias(true);
- SkFont font(sk_tool_utils::create_portable_typeface(), titleHeight);
+ SkFont font(ToolUtils::create_portable_typeface(), titleHeight);
SkString title;
title.printf("Bitmap size: %d x %d", gBmpSize, gBmpSize);
diff --git a/gm/drawimageset.cpp b/gm/drawimageset.cpp
index f993a7c..fae0a5e 100644
--- a/gm/drawimageset.cpp
+++ b/gm/drawimageset.cpp
@@ -10,7 +10,7 @@
#include <algorithm>
#include "SkGradientShader.h"
#include "SkSurface.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
// Makes a set of m x n tiled images to be drawn with SkCanvas::experimental_drawImageSetV1().
static void make_image_tiles(int tileW, int tileH, int m, int n, const SkColor colors[4],
@@ -183,7 +183,7 @@
}
void onDraw(SkCanvas* canvas) override {
- sk_tool_utils::draw_checkerboard(canvas, SK_ColorBLACK, SK_ColorWHITE, 50);
+ ToolUtils::draw_checkerboard(canvas, SK_ColorBLACK, SK_ColorWHITE, 50);
static constexpr SkScalar kW = kM * kTileW;
static constexpr SkScalar kH = kN * kTileH;
SkMatrix matrices[5];
diff --git a/gm/drawlooper.cpp b/gm/drawlooper.cpp
index a9fe09f..cb1bf9c 100644
--- a/gm/drawlooper.cpp
+++ b/gm/drawlooper.cpp
@@ -5,14 +5,14 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkBlurMask.h"
#include "SkCanvas.h"
#include "SkGraphics.h"
#include "SkLayerDrawLooper.h"
#include "SkMaskFilter.h"
#include "SkRandom.h"
+#include "ToolUtils.h"
+#include "gm.h"
#define WIDTH 200
#define HEIGHT 200
@@ -39,7 +39,7 @@
paint.setAntiAlias(true);
paint.setLooper(fLooper);
- SkFont font(sk_tool_utils::create_portable_typeface(), 72);
+ SkFont font(ToolUtils::create_portable_typeface(), 72);
canvas->drawCircle(50, 50, 30, paint);
canvas->drawRect({ 150, 50, 200, 100 }, paint);
diff --git a/gm/dropshadowimagefilter.cpp b/gm/dropshadowimagefilter.cpp
index 1710dbd..04db009 100644
--- a/gm/dropshadowimagefilter.cpp
+++ b/gm/dropshadowimagefilter.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkColorFilter.h"
#include "SkColorFilterImageFilter.h"
#include "SkDropShadowImageFilter.h"
#include "SkTextUtils.h"
+#include "ToolUtils.h"
+#include "gm.h"
///////////////////////////////////////////////////////////////////////////////
@@ -41,7 +41,7 @@
paint.setColor(SK_ColorGREEN);
paint.setAntiAlias(true);
- SkFont font(sk_tool_utils::create_portable_typeface(), r.height()/2);
+ SkFont font(ToolUtils::create_portable_typeface(), r.height() / 2);
canvas->save();
canvas->clipRect(r);
SkTextUtils::DrawString(canvas, "Text", r.centerX(), r.centerY(), font, paint, SkTextUtils::kCenter_Align);
diff --git a/gm/dstreadshuffle.cpp b/gm/dstreadshuffle.cpp
index fbaac15..a73b71c 100644
--- a/gm/dstreadshuffle.cpp
+++ b/gm/dstreadshuffle.cpp
@@ -4,13 +4,13 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkBitmap.h"
#include "SkPath.h"
#include "SkRandom.h"
#include "SkShader.h"
#include "SkSurface.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace skiagm {
@@ -82,7 +82,7 @@
break;
case kText_ShapeType: {
const char* text = "N";
- SkFont font(sk_tool_utils::create_portable_typeface(), 100);
+ SkFont font(ToolUtils::create_portable_typeface(), 100);
font.setEmbolden(true);
canvas->drawString(text, 0.f, 100.f, font, *paint);
}
@@ -92,7 +92,7 @@
}
static SkColor GetColor(SkRandom* random) {
- SkColor color = sk_tool_utils::color_to_565(random->nextU() | 0xFF000000);
+ SkColor color = ToolUtils::color_to_565(random->nextU() | 0xFF000000);
return SkColorSetA(color, 0x80);
}
diff --git a/gm/emptypath.cpp b/gm/emptypath.cpp
index 1c77580..4f77bfe 100644
--- a/gm/emptypath.cpp
+++ b/gm/emptypath.cpp
@@ -4,12 +4,12 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkPaint.h"
#include "SkPath.h"
#include "SkRandom.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace skiagm {
@@ -61,7 +61,7 @@
{SkPaint::kStrokeAndFill_Style, "Stroke And Fill"},
};
- SkFont font(sk_tool_utils::create_portable_typeface(), 15);
+ SkFont font(ToolUtils::create_portable_typeface(), 15);
const char title[] = "Empty Paths Drawn Into Rectangle Clips With "
"Indicated Style and Fill";
canvas->drawString(title, 20.0f, 20.0f, font, SkPaint());
@@ -86,7 +86,7 @@
SkColor color = rand.nextU();
color = 0xff000000 | color; // force solid
- color = sk_tool_utils::color_to_565(color);
+ color = ToolUtils::color_to_565(color);
this->drawEmpty(canvas, color, rect,
gStyles[style].fStyle, gFills[fill].fFill);
@@ -99,7 +99,7 @@
SkPaint labelPaint;
labelPaint.setColor(color);
- SkFont labelFont(sk_tool_utils::create_portable_typeface(), 12);
+ SkFont labelFont(ToolUtils::create_portable_typeface(), 12);
canvas->drawString(gStyles[style].fName, 0, rect.height() + 15.0f,
labelFont, labelPaint);
canvas->drawString(gFills[fill].fName, 0, rect.height() + 28.0f,
diff --git a/gm/etc1.cpp b/gm/etc1.cpp
index 446c085..e8a126c 100644
--- a/gm/etc1.cpp
+++ b/gm/etc1.cpp
@@ -5,10 +5,10 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkImage.h"
#include "SkRandom.h"
+#include "ToolUtils.h"
+#include "gm.h"
#if SK_SUPPORT_GPU && !defined(SK_BUILD_FOR_GOOGLE3)
#include "etc1.h"
diff --git a/gm/fatpathfill.cpp b/gm/fatpathfill.cpp
index 21d9085..3b842a2 100644
--- a/gm/fatpathfill.cpp
+++ b/gm/fatpathfill.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkPath.h"
#include "SkSurface.h"
+#include "ToolUtils.h"
+#include "gm.h"
#define ZOOM 32
#define SMALL_W 9
@@ -22,7 +22,7 @@
static void draw_pixel_centers(SkCanvas* canvas) {
SkPaint paint;
- paint.setColor(sk_tool_utils::color_to_565(0xFF0088FF));
+ paint.setColor(ToolUtils::color_to_565(0xFF0088FF));
paint.setAntiAlias(true);
for (int y = 0; y < SMALL_H; ++y) {
diff --git a/gm/filterbitmap.cpp b/gm/filterbitmap.cpp
index 9694155..0deb828 100644
--- a/gm/filterbitmap.cpp
+++ b/gm/filterbitmap.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "Resources.h"
#include "SkGradientShader.h"
@@ -14,7 +14,7 @@
#include "SkTypeface.h"
static void setTypeface(SkFont* font, const char name[], SkFontStyle style) {
- font->setTypeface(sk_tool_utils::create_portable_typeface(name, style));
+ font->setTypeface(ToolUtils::create_portable_typeface(name, style));
}
static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) {
@@ -170,7 +170,7 @@
}
if (fConvertToG8) {
SkBitmap tmp;
- sk_tool_utils::copy_to_g8(&tmp, fBM);
+ ToolUtils::copy_to_g8(&tmp, fBM);
fBM = tmp;
}
}
@@ -205,7 +205,7 @@
if (fConvertToG8) {
SkBitmap tmp;
- sk_tool_utils::copy_to_g8(&tmp, fBM);
+ ToolUtils::copy_to_g8(&tmp, fBM);
fBM = tmp;
}
}
diff --git a/gm/filterindiabox.cpp b/gm/filterindiabox.cpp
index 01ecb21..fe4f31f 100644
--- a/gm/filterindiabox.cpp
+++ b/gm/filterindiabox.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "Resources.h"
#include "SkBitmapProcState.h"
@@ -60,9 +60,7 @@
SkMatrix fMatrix[2];
SkString fName;
- FilterIndiaBoxGM() {
- this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
- }
+ FilterIndiaBoxGM() { this->setBGColor(ToolUtils::color_to_565(0xFFDDDDDD)); }
FilterIndiaBoxGM(const char filename[]) : fFilename(filename) {
fName.printf("filterindiabox");
diff --git a/gm/flippity.cpp b/gm/flippity.cpp
index ccd16f6..4a8696e 100644
--- a/gm/flippity.cpp
+++ b/gm/flippity.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkSurface.h"
@@ -64,7 +64,7 @@
SkFont font;
font.setEdging(SkFont::Edging::kAntiAlias);
- font.setTypeface(sk_tool_utils::create_portable_typeface());
+ font.setTypeface(ToolUtils::create_portable_typeface());
font.setSize(32);
SkRect bounds;
diff --git a/gm/fontcache.cpp b/gm/fontcache.cpp
index 53d241d..a96e944 100644
--- a/gm/fontcache.cpp
+++ b/gm/fontcache.cpp
@@ -11,14 +11,14 @@
#include "gm.h"
#include "GrContext.h"
-#include "GrContextPriv.h"
#include "GrContextOptions.h"
+#include "GrContextPriv.h"
#include "SkCanvas.h"
#include "SkGraphics.h"
#include "SkImage.h"
#include "SkTypeface.h"
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
static SkScalar draw_string(SkCanvas* canvas, const SkString& text, SkScalar x,
SkScalar y, const SkFont& font) {
@@ -51,13 +51,12 @@
SkISize onISize() override { return SkISize::Make(kSize, kSize); }
void onOnceBeforeDraw() override {
- fTypefaces[0] = sk_tool_utils::create_portable_typeface("serif", SkFontStyle::Italic());
- fTypefaces[1] = sk_tool_utils::create_portable_typeface("sans-serif",SkFontStyle::Italic());
- fTypefaces[2] = sk_tool_utils::create_portable_typeface("serif", SkFontStyle::Normal());
- fTypefaces[3] =
- sk_tool_utils::create_portable_typeface("sans-serif", SkFontStyle::Normal());
- fTypefaces[4] = sk_tool_utils::create_portable_typeface("serif", SkFontStyle::Bold());
- fTypefaces[5] = sk_tool_utils::create_portable_typeface("sans-serif", SkFontStyle::Bold());
+ fTypefaces[0] = ToolUtils::create_portable_typeface("serif", SkFontStyle::Italic());
+ fTypefaces[1] = ToolUtils::create_portable_typeface("sans-serif", SkFontStyle::Italic());
+ fTypefaces[2] = ToolUtils::create_portable_typeface("serif", SkFontStyle::Normal());
+ fTypefaces[3] = ToolUtils::create_portable_typeface("sans-serif", SkFontStyle::Normal());
+ fTypefaces[4] = ToolUtils::create_portable_typeface("serif", SkFontStyle::Bold());
+ fTypefaces[5] = ToolUtils::create_portable_typeface("sans-serif", SkFontStyle::Bold());
}
void onDraw(GrContext*, GrRenderTargetContext*, SkCanvas* canvas) override {
diff --git a/gm/fontmgr.cpp b/gm/fontmgr.cpp
index b8d9b8c..cf11350 100644
--- a/gm/fontmgr.cpp
+++ b/gm/fontmgr.cpp
@@ -13,8 +13,8 @@
#include "SkGraphics.h"
#include "SkPath.h"
#include "SkTypeface.h"
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
// limit this just so we don't take too long to draw
#define MAX_FAMILIES 30
@@ -271,7 +271,7 @@
SkFont labelFont;
labelFont.setEdging(SkFont::Edging::kAntiAlias);
- labelFont.setTypeface(sk_tool_utils::create_portable_typeface());
+ labelFont.setTypeface(ToolUtils::create_portable_typeface());
if (FLAGS_veryVerbose) {
SkString name;
diff --git a/gm/fontregen.cpp b/gm/fontregen.cpp
index fa56fda..7f1d697 100644
--- a/gm/fontregen.cpp
+++ b/gm/fontregen.cpp
@@ -24,7 +24,7 @@
#include "SkTypeface.h"
#include "gm.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
static sk_sp<SkTextBlob> make_blob(const SkString& text, const SkFont& font) {
size_t len = text.size();
@@ -56,7 +56,7 @@
SkISize onISize() override { return SkISize::Make(kSize, kSize); }
void onOnceBeforeDraw() override {
- auto tf = sk_tool_utils::create_portable_typeface("sans-serif", SkFontStyle::Normal());
+ auto tf = ToolUtils::create_portable_typeface("sans-serif", SkFontStyle::Normal());
static const SkString kTexts[] = {
SkString("abcdefghijklmnopqrstuvwxyz"),
diff --git a/gm/fontscaler.cpp b/gm/fontscaler.cpp
index e3aa82e..85e58e4 100644
--- a/gm/fontscaler.cpp
+++ b/gm/fontscaler.cpp
@@ -5,9 +5,9 @@
* found in the LICENSE file.
*/
#include <SkFont.h>
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkTypeface.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace skiagm {
diff --git a/gm/fwidth_squircle.cpp b/gm/fwidth_squircle.cpp
index 345c701..829c3d96 100644
--- a/gm/fwidth_squircle.cpp
+++ b/gm/fwidth_squircle.cpp
@@ -5,9 +5,9 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkTextUtils.h"
+#include "ToolUtils.h"
+#include "gm.h"
#if SK_SUPPORT_GPU
diff --git a/gm/gamma.cpp b/gm/gamma.cpp
index 6c854ae..e211db6 100644
--- a/gm/gamma.cpp
+++ b/gm/gamma.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "Resources.h"
#include "SkBlendModePriv.h"
@@ -49,7 +49,7 @@
mipmapPixels[0] = mipmapPixels[3] = SkPackARGB32(0xFF, s25, s25, s25);
mipmapPixels[1] = mipmapPixels[2] = SkPackARGB32(0xFF, s75, s75, s75);
- SkFont font(sk_tool_utils::create_portable_typeface());
+ SkFont font(ToolUtils::create_portable_typeface());
SkPaint textPaint;
textPaint.setAntiAlias(true);
diff --git a/gm/gammatext.cpp b/gm/gammatext.cpp
index 81ea5ae..ef1c8b9 100644
--- a/gm/gammatext.cpp
+++ b/gm/gammatext.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
-#include "SkPath.h"
#include "SkGradientShader.h"
+#include "SkPath.h"
#include "SkTypeface.h"
+#include "ToolUtils.h"
+#include "gm.h"
static sk_sp<SkShader> make_heatGradient(const SkPoint pts[2]) {
const SkColor bw[] = { SK_ColorBLACK, SK_ColorWHITE };
diff --git a/gm/getpostextpath.cpp b/gm/getpostextpath.cpp
index cde2099..f61aad6 100644
--- a/gm/getpostextpath.cpp
+++ b/gm/getpostextpath.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkFontPriv.h"
@@ -30,7 +30,7 @@
SkPath path;
SkFont font;
- font.setTypeface(sk_tool_utils::create_portable_typeface());
+ font.setTypeface(ToolUtils::create_portable_typeface());
font.setSize(48);
SkPaint paint;
@@ -39,7 +39,7 @@
canvas->translate(SkIntToScalar(10), SkIntToScalar(64));
canvas->drawSimpleText(text, len, kUTF8_SkTextEncoding, 0, 0, font, paint);
- sk_tool_utils::get_text_path(font, text, len, kUTF8_SkTextEncoding, &path, nullptr);
+ ToolUtils::get_text_path(font, text, len, kUTF8_SkTextEncoding, &path, nullptr);
strokePath(canvas, path);
path.reset();
@@ -60,6 +60,6 @@
canvas->translate(0, SkIntToScalar(64));
canvas->drawTextBlob(SkTextBlob::MakeFromPosText(text, len, &pos[0], font), 0, 0, paint);
- sk_tool_utils::get_text_path(font, text, len, kUTF8_SkTextEncoding, &path, &pos[0]);
+ ToolUtils::get_text_path(font, text, len, kUTF8_SkTextEncoding, &path, &pos[0]);
strokePath(canvas, path);
}
diff --git a/gm/glyph_pos.cpp b/gm/glyph_pos.cpp
index c5e43c8..54d5ff8 100644
--- a/gm/glyph_pos.cpp
+++ b/gm/glyph_pos.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkFont.h"
#include "SkTypeface.h"
+#include "ToolUtils.h"
+#include "gm.h"
/* This test tries to define the effect of using hairline strokes on text.
* Provides non-hairline images for reference and consistency checks.
@@ -87,7 +87,7 @@
paint.setStrokeWidth(strokeWidth);
paint.setStyle(strokeStyle);
- SkFont font(sk_tool_utils::create_portable_typeface(), kTextHeight * textScale);
+ SkFont font(ToolUtils::create_portable_typeface(), kTextHeight * textScale);
// This demonstrates that we can not measure the text if
// there's a device transform. The canvas total matrix will
diff --git a/gm/gm.cpp b/gm/gm.cpp
index 5ea795c..3bb58a7 100644
--- a/gm/gm.cpp
+++ b/gm/gm.cpp
@@ -8,9 +8,9 @@
#include "gm.h"
#include "GrContext.h"
-#include "sk_tool_utils.h"
#include "SkShader.h"
#include "SkTraceEvent.h"
+#include "ToolUtils.h"
using namespace skiagm;
constexpr char GM::kErrorMsg_DrawSkippedGpuOnly[];
@@ -38,7 +38,7 @@
bmp.allocN32Pixels(128, 64);
SkCanvas bmpCanvas(bmp);
bmpCanvas.drawColor(SK_ColorWHITE);
- SkFont font(sk_tool_utils::create_portable_typeface(), 20);
+ SkFont font(ToolUtils::create_portable_typeface(), 20);
SkPaint paint;
paint.setColor(SK_ColorRED);
bmpCanvas.drawString("GPU Only", 20, 40, font, paint);
diff --git a/gm/gradtext.cpp b/gm/gradtext.cpp
index 873b516..a2fce97 100644
--- a/gm/gradtext.cpp
+++ b/gm/gradtext.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
#include "SkTypeface.h"
+#include "ToolUtils.h"
+#include "gm.h"
// test shader w/ transparency
static sk_sp<SkShader> make_grad(SkScalar width) {
@@ -55,7 +55,7 @@
// Minimal repro doesn't require AA, LCD, or a nondefault typeface
paint.setShader(make_chrome_solid());
- SkFont font(sk_tool_utils::create_portable_typeface(), 500);
+ SkFont font(ToolUtils::create_portable_typeface(), 500);
font.setEdging(SkFont::Edging::kAlias);
canvas->drawString("I", 0, 100, font, paint);
@@ -75,7 +75,7 @@
virtual SkISize onISize() { return SkISize::Make(500, 480); }
virtual void onDraw(SkCanvas* canvas) {
SkPaint paint;
- SkFont font(sk_tool_utils::create_portable_typeface());
+ SkFont font(ToolUtils::create_portable_typeface());
font.setEdging(SkFont::Edging::kAlias);
paint.setStyle(SkPaint::kFill_Style);
@@ -103,7 +103,7 @@
DEF_SIMPLE_GM(gradtext, canvas, 500, 480) {
static constexpr float kTextSize = 26.0f;
- SkFont font(sk_tool_utils::create_portable_typeface(), kTextSize);
+ SkFont font(ToolUtils::create_portable_typeface(), kTextSize);
canvas->drawRect({0, 0, 500, 240}, SkPaint());
canvas->translate(20.0f, kTextSize);
diff --git a/gm/highcontrastfilter.cpp b/gm/highcontrastfilter.cpp
index d3da2ac..9672ffa 100644
--- a/gm/highcontrastfilter.cpp
+++ b/gm/highcontrastfilter.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkFont.h"
#include "SkGradientShader.h"
#include "SkHighContrastFilter.h"
+#include "ToolUtils.h"
+#include "gm.h"
using InvertStyle = SkHighContrastConfig::InvertStyle;
@@ -32,7 +32,7 @@
config.fContrast);
SkFont font;
- font.setTypeface(sk_tool_utils::create_portable_typeface());
+ font.setTypeface(ToolUtils::create_portable_typeface());
font.setSize(0.05f);
font.setEdging(SkFont::Edging::kAlias);
diff --git a/gm/hsl.cpp b/gm/hsl.cpp
index 03bc3f7..6839811 100644
--- a/gm/hsl.cpp
+++ b/gm/hsl.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
// Hue, Saturation, Color, and Luminosity blend modes are oddballs.
// They nominally convert their inputs to unpremul, then to HSL, then
@@ -146,7 +146,7 @@
DEF_SIMPLE_GM(hsl, canvas, 600, 100) {
SkPaint paint;
- SkFont font(sk_tool_utils::create_portable_typeface());
+ SkFont font(ToolUtils::create_portable_typeface());
const char* comment = "HSL blend modes are correct when you see no circles in the squares.";
canvas->drawString(comment, 10,10, font, paint);
diff --git a/gm/image.cpp b/gm/image.cpp
index 49acff5..b6e438c 100644
--- a/gm/image.cpp
+++ b/gm/image.cpp
@@ -13,8 +13,8 @@
#include "SkRandom.h"
#include "SkStream.h"
#include "SkSurface.h"
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include <functional>
@@ -113,7 +113,7 @@
void onDraw(SkCanvas* canvas) override {
canvas->scale(2, 2);
- SkFont font(sk_tool_utils::create_portable_typeface(), 8);
+ SkFont font(ToolUtils::create_portable_typeface(), 8);
canvas->drawString("Original Img", 10, 60, font, SkPaint());
canvas->drawString("Modified Img", 10, 140, font, SkPaint());
@@ -398,7 +398,7 @@
DEF_SIMPLE_GM_CAN_FAIL(image_subset, canvas, errorMsg, 440, 220) {
SkImageInfo info = SkImageInfo::MakeN32Premul(200, 200, nullptr);
- auto surf = sk_tool_utils::makeSurface(canvas, info, nullptr);
+ auto surf = ToolUtils::makeSurface(canvas, info, nullptr);
auto img = make_lazy_image(surf.get());
if (!img) {
*errorMsg = "Failed to make lazy image.";
diff --git a/gm/imagealphathreshold.cpp b/gm/imagealphathreshold.cpp
index c0246bd..1fe4dad 100644
--- a/gm/imagealphathreshold.cpp
+++ b/gm/imagealphathreshold.cpp
@@ -5,14 +5,14 @@
* found in the LICENSE file.
*/
-#include "gm.h"
#include "SkAlphaThresholdFilter.h"
#include "SkImageSource.h"
#include "SkOffsetImageFilter.h"
#include "SkRandom.h"
#include "SkRegion.h"
#include "SkSurface.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
+#include "gm.h"
#define WIDTH 500
#define HEIGHT 500
@@ -104,7 +104,7 @@
SkImageInfo info = SkImageInfo::Make(width, height, ct, at, std::move(cs));
- return sk_tool_utils::makeSurface(canvas, info);
+ return ToolUtils::makeSurface(canvas, info);
}
class ImageAlphaThresholdSurfaceGM : public skiagm::GM {
diff --git a/gm/imageblur.cpp b/gm/imageblur.cpp
index 3531658..5aca868 100644
--- a/gm/imageblur.cpp
+++ b/gm/imageblur.cpp
@@ -5,10 +5,10 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkBlurImageFilter.h"
#include "SkRandom.h"
+#include "ToolUtils.h"
+#include "gm.h"
#define WIDTH 500
#define HEIGHT 500
@@ -21,11 +21,11 @@
SkRandom rand;
SkPaint textPaint;
- SkFont font(sk_tool_utils::create_portable_typeface());
+ SkFont font(ToolUtils::create_portable_typeface());
for (int i = 0; i < 25; ++i) {
int x = rand.nextULessThan(WIDTH);
int y = rand.nextULessThan(HEIGHT);
- textPaint.setColor(sk_tool_utils::color_to_565(rand.nextBits(24) | 0xFF000000));
+ textPaint.setColor(ToolUtils::color_to_565(rand.nextBits(24) | 0xFF000000));
font.setSize(rand.nextRangeScalar(0, 300));
canvas->drawString(str, SkIntToScalar(x), SkIntToScalar(y), font, textPaint);
}
diff --git a/gm/imageblur2.cpp b/gm/imageblur2.cpp
index 4cb94c9..1bed94c 100644
--- a/gm/imageblur2.cpp
+++ b/gm/imageblur2.cpp
@@ -5,10 +5,10 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkBlurImageFilter.h"
#include "SkRandom.h"
+#include "ToolUtils.h"
+#include "gm.h"
// TODO deprecate imageblur
@@ -31,7 +31,7 @@
constexpr SkScalar dy = kHeight / sigmaCount;
constexpr SkScalar textSize = 12;
- SkFont font(sk_tool_utils::create_portable_typeface(), textSize);
+ SkFont font(ToolUtils::create_portable_typeface(), textSize);
font.setEdging(SkFont::Edging::kAlias);
for (int x = 0; x < sigmaCount; x++) {
@@ -45,7 +45,7 @@
SkRandom rand;
SkPaint textPaint;
- textPaint.setColor(sk_tool_utils::color_to_565(rand.nextBits(24) | 0xFF000000));
+ textPaint.setColor(ToolUtils::color_to_565(rand.nextBits(24) | 0xFF000000));
for (int i = 0; i < testStringCount; i++) {
canvas->drawString(kTestStrings[i],
SkIntToScalar(x * dx),
diff --git a/gm/imageblurclampmode.cpp b/gm/imageblurclampmode.cpp
index f16f01d..2cd1723 100644
--- a/gm/imageblurclampmode.cpp
+++ b/gm/imageblurclampmode.cpp
@@ -5,14 +5,14 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
-#include "SkSurface.h"
#include "SkBlurImageFilter.h"
+#include "SkSurface.h"
+#include "ToolUtils.h"
+#include "gm.h"
static sk_sp<SkImage> make_image(SkCanvas* canvas) {
SkImageInfo info = SkImageInfo::MakeN32Premul(250, 200);
- auto surface = sk_tool_utils::makeSurface(canvas, info);
+ auto surface = ToolUtils::makeSurface(canvas, info);
SkCanvas* c = surface->getCanvas();
SkPaint paint;
paint.setAntiAlias(true);
diff --git a/gm/imageblurrepeatmode.cpp b/gm/imageblurrepeatmode.cpp
index 0423a99..9dafd1d 100644
--- a/gm/imageblurrepeatmode.cpp
+++ b/gm/imageblurrepeatmode.cpp
@@ -5,14 +5,14 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
-#include "SkSurface.h"
#include "SkBlurImageFilter.h"
+#include "SkSurface.h"
+#include "ToolUtils.h"
+#include "gm.h"
static sk_sp<SkImage> make_image(SkCanvas* canvas, int direction) {
SkImageInfo info = SkImageInfo::MakeN32Premul(250, 200);
- auto surface = sk_tool_utils::makeSurface(canvas, info);
+ auto surface = ToolUtils::makeSurface(canvas, info);
SkCanvas* c = surface->getCanvas();
SkPaint paint;
paint.setAntiAlias(true);
diff --git a/gm/imageblurtiled.cpp b/gm/imageblurtiled.cpp
index 5a57721..f1d15d0 100644
--- a/gm/imageblurtiled.cpp
+++ b/gm/imageblurtiled.cpp
@@ -5,10 +5,10 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkBlurImageFilter.h"
#include "SkRandom.h"
+#include "ToolUtils.h"
+#include "gm.h"
#define WIDTH 640
#define HEIGHT 480
@@ -46,7 +46,7 @@
"jumped over",
"the lazy dog.",
};
- SkFont font(sk_tool_utils::create_portable_typeface(), 100);
+ SkFont font(ToolUtils::create_portable_typeface(), 100);
int posY = 0;
for (unsigned i = 0; i < SK_ARRAY_COUNT(str); i++) {
posY += 100;
diff --git a/gm/imagefilters.cpp b/gm/imagefilters.cpp
index bc33a57..bf1940e 100644
--- a/gm/imagefilters.cpp
+++ b/gm/imagefilters.cpp
@@ -5,13 +5,13 @@
* found in the LICENSE file.
*/
-#include "gm.h"
#include "SkBlurImageFilter.h"
#include "SkColorMatrixFilter.h"
#include "SkImage.h"
#include "SkImageFilter.h"
#include "SkSurface.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
+#include "gm.h"
/**
* Test drawing a primitive w/ an imagefilter (in this case, just matrix w/ identity) to see
@@ -70,7 +70,7 @@
static sk_sp<SkImage> make_image(SkCanvas* canvas) {
const SkImageInfo info = SkImageInfo::MakeS32(100, 100, kPremul_SkAlphaType);
- auto surface(sk_tool_utils::makeSurface(canvas, info));
+ auto surface(ToolUtils::makeSurface(canvas, info));
surface->getCanvas()->drawRect(SkRect::MakeXYWH(25, 25, 50, 50), SkPaint());
return surface->makeImageSnapshot();
}
diff --git a/gm/imagefiltersbase.cpp b/gm/imagefiltersbase.cpp
index 40bb810..5a7c05a 100644
--- a/gm/imagefiltersbase.cpp
+++ b/gm/imagefiltersbase.cpp
@@ -5,14 +5,14 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkColorFilter.h"
#include "SkColorPriv.h"
#include "SkImageFilterPriv.h"
#include "SkShader.h"
#include "SkTextUtils.h"
+#include "ToolUtils.h"
+#include "gm.h"
#include "SkBlurImageFilter.h"
#include "SkColorFilterImageFilter.h"
@@ -127,7 +127,7 @@
SkPaint paint;
paint.setImageFilter(imf);
paint.setColor(SK_ColorCYAN);
- SkFont font(sk_tool_utils::create_portable_typeface(), r.height()/2);
+ SkFont font(ToolUtils::create_portable_typeface(), r.height() / 2);
SkTextUtils::DrawString(canvas, "Text", r.centerX(), r.centerY(), font, paint,
SkTextUtils::kCenter_Align);
}
@@ -241,7 +241,7 @@
SkFont::Edging::kAntiAlias,
SkFont::Edging::kSubpixelAntiAlias,
};
- SkFont font(sk_tool_utils::create_portable_typeface(), 30);
+ SkFont font(ToolUtils::create_portable_typeface(), 30);
SkAutoCanvasRestore acr(canvas, true);
for (SkFont::Edging edging : kEdgings) {
diff --git a/gm/imagefiltersclipped.cpp b/gm/imagefiltersclipped.cpp
index 6236c38..a038d7f 100644
--- a/gm/imagefiltersclipped.cpp
+++ b/gm/imagefiltersclipped.cpp
@@ -20,8 +20,8 @@
#include "SkPoint3.h"
#include "SkScalar.h"
#include "SkSurface.h"
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#define RESIZE_FACTOR_X SkIntToScalar(2)
#define RESIZE_FACTOR_Y SkIntToScalar(5)
@@ -79,8 +79,8 @@
}
void onOnceBeforeDraw() override {
- fCheckerboard = SkImage::MakeFromBitmap
- (sk_tool_utils::create_checkerboard_bitmap(64, 64, 0xFFA0A0A0, 0xFF404040, 8));
+ fCheckerboard = SkImage::MakeFromBitmap(
+ ToolUtils::create_checkerboard_bitmap(64, 64, 0xFFA0A0A0, 0xFF404040, 8));
fGradientCircle = make_gradient_circle(64, 64);
}
diff --git a/gm/imagefilterscropped.cpp b/gm/imagefilterscropped.cpp
index 179fdc3..f28f116 100644
--- a/gm/imagefilterscropped.cpp
+++ b/gm/imagefilterscropped.cpp
@@ -5,13 +5,13 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkColorFilter.h"
#include "SkColorPriv.h"
#include "SkShader.h"
#include "SkTextUtils.h"
+#include "ToolUtils.h"
+#include "gm.h"
#include "SkBlurImageFilter.h"
#include "SkMorphologyImageFilter.h"
@@ -44,7 +44,7 @@
paint.setImageFilter(std::move(imf));
paint.setColor(SK_ColorGREEN);
- SkFont font(sk_tool_utils::create_portable_typeface(), r.height()/2);
+ SkFont font(ToolUtils::create_portable_typeface(), r.height() / 2);
SkTextUtils::DrawString(canvas, "Text", r.centerX(), r.centerY(), font, paint, SkTextUtils::kCenter_Align);
}
diff --git a/gm/imagefiltersgraph.cpp b/gm/imagefiltersgraph.cpp
index a369dc0..8820879 100644
--- a/gm/imagefiltersgraph.cpp
+++ b/gm/imagefiltersgraph.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkArithmeticImageFilter.h"
#include "SkBlurImageFilter.h"
@@ -39,7 +39,7 @@
void onOnceBeforeDraw() override {
fImage = SkImage::MakeFromBitmap(
- sk_tool_utils::create_string_bitmap(100, 100, SK_ColorWHITE, 20, 70, 96, "e"));
+ ToolUtils::create_string_bitmap(100, 100, SK_ColorWHITE, 20, 70, 96, "e"));
}
void onDraw(SkCanvas* canvas) override {
diff --git a/gm/imagefiltersscaled.cpp b/gm/imagefiltersscaled.cpp
index dc87da3..73006af 100644
--- a/gm/imagefiltersscaled.cpp
+++ b/gm/imagefiltersscaled.cpp
@@ -20,8 +20,8 @@
#include "SkPoint3.h"
#include "SkScalar.h"
#include "SkSurface.h"
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#define RESIZE_FACTOR SkIntToScalar(4)
@@ -64,7 +64,7 @@
void onOnceBeforeDraw() override {
fCheckerboard = SkImage::MakeFromBitmap(
- sk_tool_utils::create_checkerboard_bitmap(64, 64, 0xFFA0A0A0, 0xFF404040, 8));
+ ToolUtils::create_checkerboard_bitmap(64, 64, 0xFFA0A0A0, 0xFF404040, 8));
fGradientCircle = make_gradient_circle(64, 64);
}
diff --git a/gm/imagefilterstransformed.cpp b/gm/imagefilterstransformed.cpp
index 941a04c..6b6fd1c 100644
--- a/gm/imagefilterstransformed.cpp
+++ b/gm/imagefilterstransformed.cpp
@@ -15,8 +15,8 @@
#include "SkMorphologyImageFilter.h"
#include "SkScalar.h"
#include "SkSurface.h"
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
namespace skiagm {
@@ -58,7 +58,7 @@
void onOnceBeforeDraw() override {
fCheckerboard = SkImage::MakeFromBitmap(
- sk_tool_utils::create_checkerboard_bitmap(64, 64, 0xFFA0A0A0, 0xFF404040, 8));
+ ToolUtils::create_checkerboard_bitmap(64, 64, 0xFFA0A0A0, 0xFF404040, 8));
fGradientCircle = make_gradient_circle(64, 64);
}
diff --git a/gm/imagemagnifier.cpp b/gm/imagemagnifier.cpp
index 8fbc58d..b34dfb6 100644
--- a/gm/imagemagnifier.cpp
+++ b/gm/imagemagnifier.cpp
@@ -5,13 +5,13 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkImageSource.h"
#include "SkMagnifierImageFilter.h"
#include "SkPixelRef.h"
#include "SkRandom.h"
#include "SkSurface.h"
+#include "ToolUtils.h"
+#include "gm.h"
#define WIDTH 500
#define HEIGHT 500
@@ -27,12 +27,12 @@
canvas->saveLayer(nullptr, &filterPaint);
const char* str = "The quick brown fox jumped over the lazy dog.";
SkRandom rand;
- SkFont font(sk_tool_utils::create_portable_typeface());
+ SkFont font(ToolUtils::create_portable_typeface());
for (int i = 0; i < 25; ++i) {
int x = rand.nextULessThan(WIDTH);
int y = rand.nextULessThan(HEIGHT);
SkPaint paint;
- paint.setColor(sk_tool_utils::color_to_565(rand.nextBits(24) | 0xFF000000));
+ paint.setColor(ToolUtils::color_to_565(rand.nextBits(24) | 0xFF000000));
font.setSize(rand.nextRangeScalar(0, 300));
canvas->drawString(str, SkIntToScalar(x), SkIntToScalar(y), font, paint);
}
diff --git a/gm/imagemakewithfilter.cpp b/gm/imagemakewithfilter.cpp
index 9805a0b..2bc7e1a 100644
--- a/gm/imagemakewithfilter.cpp
+++ b/gm/imagemakewithfilter.cpp
@@ -5,14 +5,14 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkBlurImageFilter.h"
#include "SkCanvas.h"
#include "SkColorFilter.h"
#include "SkColorFilterImageFilter.h"
#include "SkDropShadowImageFilter.h"
#include "SkSurface.h"
+#include "ToolUtils.h"
+#include "gm.h"
///////////////////////////////////////////////////////////////////////////////
@@ -70,8 +70,8 @@
canvas->translate(MARGIN, MARGIN);
- sk_sp<SkSurface> surface = sk_tool_utils::makeSurface(canvas, info);
- sk_tool_utils::draw_checkerboard(surface->getCanvas());
+ sk_sp<SkSurface> surface = ToolUtils::makeSurface(canvas, info);
+ ToolUtils::draw_checkerboard(surface->getCanvas());
sk_sp<SkImage> source = surface->makeImageSnapshot();
for (auto clipBound : clipBounds) {
diff --git a/gm/imagemasksubset.cpp b/gm/imagemasksubset.cpp
index adfea6b..6998055 100644
--- a/gm/imagemasksubset.cpp
+++ b/gm/imagemasksubset.cpp
@@ -5,13 +5,13 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkImage.h"
#include "SkImageGenerator.h"
#include "SkMakeUnique.h"
#include "SkSurface.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace {
@@ -20,7 +20,7 @@
const SkRect kDest = SkRect::MakeXYWH(10, 10, 100, 100);
sk_sp<SkImage> make_mask(const sk_sp<SkSurface>& surface) {
- sk_tool_utils::draw_checkerboard(surface->getCanvas(), 0x80808080, 0x00000000, 5);
+ ToolUtils::draw_checkerboard(surface->getCanvas(), 0x80808080, 0x00000000, 5);
return surface->makeImageSnapshot();
}
diff --git a/gm/imageresizetiled.cpp b/gm/imageresizetiled.cpp
index c242cc5..f85afd8 100644
--- a/gm/imageresizetiled.cpp
+++ b/gm/imageresizetiled.cpp
@@ -5,10 +5,10 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkImageFilter.h"
#include "SkRandom.h"
+#include "ToolUtils.h"
+#include "gm.h"
#define WIDTH 640
#define HEIGHT 480
@@ -23,7 +23,7 @@
kNone_SkFilterQuality,
nullptr));
- SkFont font(sk_tool_utils::create_portable_typeface(), 100);
+ SkFont font(ToolUtils::create_portable_typeface(), 100);
const SkScalar tile_size = SkIntToScalar(100);
for (SkScalar y = 0; y < HEIGHT; y += tile_size) {
for (SkScalar x = 0; x < WIDTH; x += tile_size) {
diff --git a/gm/imagesource.cpp b/gm/imagesource.cpp
index 50d818b..ea323e6 100644
--- a/gm/imagesource.cpp
+++ b/gm/imagesource.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkImage.h"
#include "SkImageSource.h"
@@ -36,7 +36,7 @@
SkISize onISize() override { return SkISize::Make(500, 150); }
void onOnceBeforeDraw() override {
- SkBitmap bm = sk_tool_utils::create_string_bitmap(100, 100, 0xFFFFFFFF, 20, 70, 96, "e");
+ SkBitmap bm = ToolUtils::create_string_bitmap(100, 100, 0xFFFFFFFF, 20, 70, 96, "e");
fImage = SkImage::MakeFromBitmap(bm);
}
diff --git a/gm/internal_links.cpp b/gm/internal_links.cpp
index 51d5e20..fc710a8 100644
--- a/gm/internal_links.cpp
+++ b/gm/internal_links.cpp
@@ -4,8 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkAnnotation.h"
#include "SkData.h"
@@ -60,7 +60,7 @@
SkIntToScalar(50), SkIntToScalar(20));
canvas->drawRect(rect, paint);
- SkFont font(sk_tool_utils::create_portable_typeface(), 25);
+ SkFont font(ToolUtils::create_portable_typeface(), 25);
paint.setColor(SK_ColorBLACK);
canvas->drawString(text, x, y, font, paint);
}
diff --git a/gm/largeglyphblur.cpp b/gm/largeglyphblur.cpp
index c07c246..f1fe1d1 100644
--- a/gm/largeglyphblur.cpp
+++ b/gm/largeglyphblur.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkBlurMask.h"
#include "SkCanvas.h"
@@ -18,7 +18,7 @@
DEF_SIMPLE_GM(largeglyphblur, canvas, 1920, 600) {
const char text[] = "Hamburgefons";
- SkFont font(sk_tool_utils::create_portable_typeface(), 256);
+ SkFont font(ToolUtils::create_portable_typeface(), 256);
auto blob = SkTextBlob::MakeFromText(text, strlen(text), font);
// setup up maskfilter
diff --git a/gm/lattice.cpp b/gm/lattice.cpp
index 5c2bd50..b56e980 100644
--- a/gm/lattice.cpp
+++ b/gm/lattice.cpp
@@ -5,14 +5,14 @@
* found in the LICENSE file.
*/
-#include "gm.h"
#include "SkSurface.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
+#include "gm.h"
static sk_sp<SkSurface> make_surface(SkCanvas* root, int N, int padLeft, int padTop,
int padRight, int padBottom) {
SkImageInfo info = SkImageInfo::MakeN32Premul(N + padLeft + padRight, N + padTop + padBottom);
- return sk_tool_utils::makeSurface(root, info);
+ return ToolUtils::makeSurface(root, info);
}
static sk_sp<SkImage> make_image(SkCanvas* root, int* xDivs, int* yDivs, int padLeft, int padTop,
@@ -339,7 +339,7 @@
// Code paths that incorporate the paint color when drawing the lattice (using an alpha image)
DEF_SIMPLE_GM_BG(lattice_alpha, canvas, 120, 120, SK_ColorWHITE) {
- auto surface = sk_tool_utils::makeSurface(canvas, SkImageInfo::MakeA8(100, 100));
+ auto surface = ToolUtils::makeSurface(canvas, SkImageInfo::MakeA8(100, 100));
surface->getCanvas()->clear(0);
surface->getCanvas()->drawCircle(50, 50, 50, SkPaint());
auto image = surface->makeImageSnapshot();
diff --git a/gm/lcdblendmodes.cpp b/gm/lcdblendmodes.cpp
index 02650f0..fbfe105 100644
--- a/gm/lcdblendmodes.cpp
+++ b/gm/lcdblendmodes.cpp
@@ -10,11 +10,11 @@
* Tests text rendering with LCD and the various blend modes.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
#include "SkSurface.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace skiagm {
@@ -48,7 +48,7 @@
}
void onOnceBeforeDraw() override {
- fCheckerboard = sk_tool_utils::create_checkerboard_shader(SK_ColorBLACK, SK_ColorWHITE, 4);
+ fCheckerboard = ToolUtils::create_checkerboard_shader(SK_ColorBLACK, SK_ColorWHITE, 4);
}
SkISize onISize() override { return SkISize::Make(kWidth, kHeight); }
@@ -62,7 +62,7 @@
canvas->drawRect(r, p);
SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight);
- auto surface(sk_tool_utils::makeSurface(canvas, info));
+ auto surface(ToolUtils::makeSurface(canvas, info));
SkCanvas* surfCanvas = surface->getCanvas();
this->drawColumn(surfCanvas, SK_ColorBLACK, SK_ColorWHITE, false);
@@ -119,7 +119,7 @@
SkPaint paint;
paint.setColor(textColor);
paint.setBlendMode(gModes[m]);
- SkFont font(sk_tool_utils::create_portable_typeface(), fTextHeight);
+ SkFont font(ToolUtils::create_portable_typeface(), fTextHeight);
font.setSubpixel(true);
font.setEdging(SkFont::Edging::kSubpixelAntiAlias);
if (useGrad) {
diff --git a/gm/lcdoverlap.cpp b/gm/lcdoverlap.cpp
index 6dd54a0..19e69f1 100644
--- a/gm/lcdoverlap.cpp
+++ b/gm/lcdoverlap.cpp
@@ -10,11 +10,11 @@
* Tests overlapping LCD text
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkSurface.h"
#include "SkTextBlob.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace skiagm {
@@ -37,12 +37,12 @@
// build text blob
SkTextBlobBuilder builder;
- SkFont font(sk_tool_utils::create_portable_typeface(), 32);
+ SkFont font(ToolUtils::create_portable_typeface(), 32);
const char* text = "able was I ere I saw elba";
font.setSubpixel(true);
font.setEdging(SkFont::Edging::kSubpixelAntiAlias);
// If we use SkTextBlob::MakeFromText, we get very different positioning ... why?
- sk_tool_utils::add_to_text_blob(&builder, text, font, 0, 0);
+ ToolUtils::add_to_text_blob(&builder, text, font, 0, 0);
fBlob = builder.make();
}
diff --git a/gm/lcdtext.cpp b/gm/lcdtext.cpp
index 153e835..0f7304e 100644
--- a/gm/lcdtext.cpp
+++ b/gm/lcdtext.cpp
@@ -9,14 +9,13 @@
/* Tests text rendering with LCD and subpixel rendering turned on and off.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkPicture.h"
#include "SkPictureImageFilter.h"
#include "SkPictureRecorder.h"
#include "SkSurface.h"
-
+#include "ToolUtils.h"
+#include "gm.h"
class LcdTextGM : public skiagm::GM {
public:
diff --git a/gm/lighting.cpp b/gm/lighting.cpp
index f4d83ba..d56a428 100644
--- a/gm/lighting.cpp
+++ b/gm/lighting.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkAnimTimer.h"
#include "SkLightingImageFilter.h"
#include "SkOffsetImageFilter.h"
#include "SkPoint3.h"
+#include "ToolUtils.h"
+#include "gm.h"
#define WIDTH 330
#define HEIGHT 660
@@ -44,7 +44,7 @@
}
void onOnceBeforeDraw() override {
- fBitmap = sk_tool_utils::create_string_bitmap(100, 100, 0xFFFFFFFF, 20, 70, 96, "e");
+ fBitmap = ToolUtils::create_string_bitmap(100, 100, 0xFFFFFFFF, 20, 70, 96, "e");
}
void onDraw(SkCanvas* canvas) override {
diff --git a/gm/lightingshader.cpp b/gm/lightingshader.cpp
index f7fbe34..e061e83 100644
--- a/gm/lightingshader.cpp
+++ b/gm/lightingshader.cpp
@@ -5,19 +5,19 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkLightingShader.h"
#include "SkNormalSource.h"
#include "SkPoint3.h"
#include "SkShader.h"
+#include "ToolUtils.h"
+#include "gm.h"
// Create a hemispherical normal map
static SkBitmap make_hemi_normalmap(int texSize) {
SkBitmap hemi;
hemi.allocN32Pixels(texSize, texSize);
- sk_tool_utils::create_hemi_normal_map(&hemi, SkIRect::MakeWH(texSize, texSize));
+ ToolUtils::create_hemi_normal_map(&hemi, SkIRect::MakeWH(texSize, texSize));
return hemi;
}
@@ -26,7 +26,7 @@
SkBitmap frustum;
frustum.allocN32Pixels(texSize, texSize);
- sk_tool_utils::create_frustum_normal_map(&frustum, SkIRect::MakeWH(texSize, texSize));
+ ToolUtils::create_frustum_normal_map(&frustum, SkIRect::MakeWH(texSize, texSize));
return frustum;
}
@@ -35,7 +35,7 @@
SkBitmap tetra;
tetra.allocN32Pixels(texSize, texSize);
- sk_tool_utils::create_tetra_normal_map(&tetra, SkIRect::MakeWH(texSize, texSize));
+ ToolUtils::create_tetra_normal_map(&tetra, SkIRect::MakeWH(texSize, texSize));
return tetra;
}
@@ -78,11 +78,8 @@
fLights = builder.finish();
}
- fDiffuse = sk_tool_utils::create_checkerboard_bitmap(
- kTexSize, kTexSize,
- 0x00000000,
- sk_tool_utils::color_to_565(0xFF804020),
- 8);
+ fDiffuse = ToolUtils::create_checkerboard_bitmap(
+ kTexSize, kTexSize, 0x00000000, ToolUtils::color_to_565(0xFF804020), 8);
fNormalMaps[kHemi_NormalMap] = make_hemi_normalmap(kTexSize);
fNormalMaps[kFrustum_NormalMap] = make_frustum_normalmap(kTexSize);
diff --git a/gm/lightingshader2.cpp b/gm/lightingshader2.cpp
index 62d9c2a..1ad1c74 100644
--- a/gm/lightingshader2.cpp
+++ b/gm/lightingshader2.cpp
@@ -5,20 +5,20 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkLightingShader.h"
#include "SkNormalSource.h"
#include "SkPoint3.h"
#include "SkShader.h"
#include "SkTypeface.h"
+#include "ToolUtils.h"
+#include "gm.h"
// Create a truncated pyramid normal map
static SkBitmap make_frustum_normalmap(int texSize) {
SkBitmap frustum;
frustum.allocN32Pixels(texSize, texSize);
- sk_tool_utils::create_frustum_normal_map(&frustum, SkIRect::MakeWH(texSize, texSize));
+ ToolUtils::create_frustum_normal_map(&frustum, SkIRect::MakeWH(texSize, texSize));
return frustum;
}
@@ -29,7 +29,7 @@
class LightingShader2GM : public GM {
public:
LightingShader2GM() : fRect(SkRect::MakeIWH(kTexSize, kTexSize)) {
- this->setBGColor(sk_tool_utils::color_to_565(0xFF0000CC));
+ this->setBGColor(ToolUtils::color_to_565(0xFF0000CC));
}
protected:
@@ -77,18 +77,17 @@
SkRect bitmapBounds = SkRect::MakeIWH(kTexSize, kTexSize);
matrix.setRectToRect(bitmapBounds, fRect, SkMatrix::kFill_ScaleToFit);
- SkBitmap opaqueDiffuseMap = sk_tool_utils::create_checkerboard_bitmap(
- kTexSize, kTexSize, SK_ColorBLACK,
- 0xFF808080,
- 8);
+ SkBitmap opaqueDiffuseMap = ToolUtils::create_checkerboard_bitmap(
+ kTexSize, kTexSize, SK_ColorBLACK, 0xFF808080, 8);
fOpaqueDiffuse = SkShader::MakeBitmapShader(opaqueDiffuseMap, SkShader::kClamp_TileMode,
SkShader::kClamp_TileMode, &matrix);
- SkBitmap translucentDiffuseMap = sk_tool_utils::create_checkerboard_bitmap(
- kTexSize, kTexSize,
- SkColorSetARGB(0x55, 0x00, 0x00, 0x00),
- SkColorSetARGB(0x55, 0x80, 0x80, 0x80),
- 8);
+ SkBitmap translucentDiffuseMap =
+ ToolUtils::create_checkerboard_bitmap(kTexSize,
+ kTexSize,
+ SkColorSetARGB(0x55, 0x00, 0x00, 0x00),
+ SkColorSetARGB(0x55, 0x80, 0x80, 0x80),
+ 8);
fTranslucentDiffuse = SkShader::MakeBitmapShader(translucentDiffuseMap,
SkShader::kClamp_TileMode,
SkShader::kClamp_TileMode, &matrix);
@@ -143,8 +142,7 @@
void onDraw(SkCanvas* canvas) override {
SkPaint labelPaint;
- SkFont font(
- sk_tool_utils::create_portable_typeface("sans-serif", SkFontStyle()), kLabelSize);
+ SkFont font(ToolUtils::create_portable_typeface("sans-serif", SkFontStyle()), kLabelSize);
int gridNum = 0;
diff --git a/gm/linepaths.cpp b/gm/linepaths.cpp
index e3f386d..f6424a7 100644
--- a/gm/linepaths.cpp
+++ b/gm/linepaths.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
-#include "SkPath.h"
#include "SkPaint.h"
+#include "SkPath.h"
#include "SkRandom.h"
+#include "ToolUtils.h"
+#include "gm.h"
static void drawPath(SkPath& path,SkCanvas* canvas,SkColor color,
const SkRect& clip,SkPaint::Cap cap, SkPaint::Join join,
@@ -77,7 +77,7 @@
titlePaint.setColor(SK_ColorBLACK);
titlePaint.setAntiAlias(true);
- SkFont font(sk_tool_utils::create_portable_typeface(), 15.0f);
+ SkFont font(ToolUtils::create_portable_typeface(), 15.0f);
const char titleNoClose[] = "Line Drawn Into Rectangle Clips With "
"Indicated Style, Fill and Linecaps, with stroke width 10";
@@ -106,7 +106,7 @@
canvas->translate(rect.width() + 40 * SK_Scalar1, 0);
}
- SkColor color = sk_tool_utils::color_to_565(0xff007000);
+ SkColor color = ToolUtils::color_to_565(0xff007000);
drawPath(path.fPath, canvas, color, rect,
gCaps[cap].fCap, gCaps[cap].fJoin, gStyles[style].fStyle,
gFills[fill].fFill, SK_Scalar1*10);
diff --git a/gm/localmatriximagefilter.cpp b/gm/localmatriximagefilter.cpp
index 8280c07..4bb433c 100644
--- a/gm/localmatriximagefilter.cpp
+++ b/gm/localmatriximagefilter.cpp
@@ -5,19 +5,19 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "SkCanvas.h"
#include "SkBlurImageFilter.h"
+#include "SkCanvas.h"
#include "SkColorFilterImageFilter.h"
#include "SkModeColorFilter.h"
#include "SkMorphologyImageFilter.h"
#include "SkOffsetImageFilter.h"
#include "SkSurface.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
+#include "gm.h"
static sk_sp<SkImage> make_image(SkCanvas* rootCanvas) {
SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
- auto surface(sk_tool_utils::makeSurface(rootCanvas, info));
+ auto surface(ToolUtils::makeSurface(rootCanvas, info));
SkPaint paint;
paint.setAntiAlias(true);
diff --git a/gm/localmatriximageshader.cpp b/gm/localmatriximageshader.cpp
index b041c70..8b15679 100644
--- a/gm/localmatriximageshader.cpp
+++ b/gm/localmatriximageshader.cpp
@@ -5,15 +5,15 @@
* found in the LICENSE file.
*/
-#include "gm.h"
#include "Resources.h"
#include "SkCanvas.h"
#include "SkSurface.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
+#include "gm.h"
static sk_sp<SkImage> make_image(SkCanvas* rootCanvas, SkColor color) {
SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
- auto surface(sk_tool_utils::makeSurface(rootCanvas, info));
+ auto surface(ToolUtils::makeSurface(rootCanvas, info));
SkPaint paint;
paint.setAntiAlias(true);
diff --git a/gm/localmatrixshader.cpp b/gm/localmatrixshader.cpp
index bbd2775..a23363e 100644
--- a/gm/localmatrixshader.cpp
+++ b/gm/localmatrixshader.cpp
@@ -5,16 +5,16 @@
* found in the LICENSE file.
*/
-#include "gm.h"
#include "SkCanvas.h"
#include "SkShader.h"
#include "SkSurface.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
+#include "gm.h"
static sk_sp<SkImage> make_image(SkCanvas* rootCanvas) {
static constexpr SkScalar kSize = 50;
SkImageInfo info = SkImageInfo::MakeN32Premul(kSize, kSize);
- auto surface = sk_tool_utils::makeSurface(rootCanvas, info);
+ auto surface = ToolUtils::makeSurface(rootCanvas, info);
SkPaint p;
p.setAntiAlias(true);
diff --git a/gm/lumafilter.cpp b/gm/lumafilter.cpp
index 82cb1a0..ff9dc70 100644
--- a/gm/lumafilter.cpp
+++ b/gm/lumafilter.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkBlendModePriv.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
#include "SkLumaColorFilter.h"
+#include "ToolUtils.h"
+#include "gm.h"
static SkScalar kSize = 80;
static SkScalar kInset = 10;
@@ -19,7 +19,7 @@
static void draw_label(SkCanvas* canvas, const char* label,
const SkPoint& offset) {
- SkFont font(sk_tool_utils::create_portable_typeface());
+ SkFont font(ToolUtils::create_portable_typeface());
font.setEdging(SkFont::Edging::kAlias);
size_t len = strlen(label);
diff --git a/gm/manypaths.cpp b/gm/manypaths.cpp
index 0d8c842..00bdfad 100644
--- a/gm/manypaths.cpp
+++ b/gm/manypaths.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
+#include "SkRRect.h"
#include "SkRandom.h"
#include "SkRect.h"
-#include "SkRRect.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace skiagm {
@@ -19,7 +19,7 @@
hsv[1] = rand->nextRangeF(0.5f, 1.0f);
hsv[2] = rand->nextRangeF(0.5f, 1.0f);
- return sk_tool_utils::color_to_565(SkHSVToColor(hsv));
+ return ToolUtils::color_to_565(SkHSVToColor(hsv));
}
class ManyCirclesGM : public GM {
diff --git a/gm/matrixconvolution.cpp b/gm/matrixconvolution.cpp
index 24fa578..0cfb5c2 100644
--- a/gm/matrixconvolution.cpp
+++ b/gm/matrixconvolution.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkColor.h"
#include "SkGradientShader.h"
#include "SkMatrixConvolutionImageFilter.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace skiagm {
@@ -40,7 +40,7 @@
SkScalar pos[2] = { 0, 80.0f };
paint.setShader(SkGradientShader::MakeLinear(
pts, fColors, pos, 2, SkShader::kClamp_TileMode));
- SkFont font(sk_tool_utils::create_portable_typeface(), 180.0f);
+ SkFont font(ToolUtils::create_portable_typeface(), 180.0f);
canvas.drawString("e", -10.0f, 80.0f, font, paint);
}
diff --git a/gm/mixedtextblobs.cpp b/gm/mixedtextblobs.cpp
index 47579a7..788a98a 100644
--- a/gm/mixedtextblobs.cpp
+++ b/gm/mixedtextblobs.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "Resources.h"
#include "SkCanvas.h"
@@ -40,7 +40,7 @@
protected:
void onOnceBeforeDraw() override {
- fEmojiTypeface = sk_tool_utils::planet_typeface();
+ fEmojiTypeface = ToolUtils::planet_typeface();
fEmojiText = "♁♃";
fReallyBigATypeface = MakeResourceAsTypeface("fonts/ReallyBigA.ttf");
@@ -48,7 +48,7 @@
// make textblob
// Text so large we draw as paths
- SkFont font(sk_tool_utils::create_portable_typeface(), 385);
+ SkFont font(ToolUtils::create_portable_typeface(), 385);
font.setEdging(SkFont::Edging::kAlias);
const char* text = "O";
@@ -56,7 +56,7 @@
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
SkScalar yOffset = bounds.height();
- sk_tool_utils::add_to_text_blob(&builder, text, font, 10, yOffset);
+ ToolUtils::add_to_text_blob(&builder, text, font, 10, yOffset);
SkScalar corruptedAx = bounds.width();
SkScalar corruptedAy = yOffset;
@@ -72,8 +72,11 @@
font.setSubpixel(true);
text = "LCD!!!!!";
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
- sk_tool_utils::add_to_text_blob(&builder, text, font, xOffset - bounds.width() * 0.25f,
- yOffset - bounds.height() * 0.5f);
+ ToolUtils::add_to_text_blob(&builder,
+ text,
+ font,
+ xOffset - bounds.width() * 0.25f,
+ yOffset - bounds.height() * 0.5f);
// color emoji font with large glyph
if (fEmojiTypeface) {
@@ -81,14 +84,14 @@
font.setSubpixel(false);
font.setTypeface(fEmojiTypeface);
font.measureText(fEmojiText, strlen(fEmojiText), kUTF8_SkTextEncoding, &bounds);
- sk_tool_utils::add_to_text_blob(&builder, fEmojiText, font, xOffset, yOffset);
+ ToolUtils::add_to_text_blob(&builder, fEmojiText, font, xOffset, yOffset);
}
// outline font with large glyph
font.setSize(12);
text = "aA";
font.setTypeface(fReallyBigATypeface);
- sk_tool_utils::add_to_text_blob(&builder, text, font, corruptedAx, corruptedAy);
+ ToolUtils::add_to_text_blob(&builder, text, font, corruptedAx, corruptedAy);
fBlob = builder.make();
}
diff --git a/gm/modecolorfilters.cpp b/gm/modecolorfilters.cpp
index 6f933fe..3c51af4 100644
--- a/gm/modecolorfilters.cpp
+++ b/gm/modecolorfilters.cpp
@@ -5,10 +5,10 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkColorFilter.h"
#include "SkGradientShader.h"
+#include "ToolUtils.h"
+#include "gm.h"
#define WIDTH 512
#define HEIGHT 1024
@@ -40,9 +40,9 @@
SkBitmap bmp;
bmp.allocN32Pixels(2 * checkSize, 2 * checkSize);
SkCanvas canvas(bmp);
- canvas.clear(sk_tool_utils::color_to_565(0xFF800000));
+ canvas.clear(ToolUtils::color_to_565(0xFF800000));
SkPaint paint;
- paint.setColor(sk_tool_utils::color_to_565(0xFF000080));
+ paint.setColor(ToolUtils::color_to_565(0xFF000080));
SkRect rect0 = SkRect::MakeXYWH(0, 0,
SkIntToScalar(checkSize), SkIntToScalar(checkSize));
SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(checkSize), SkIntToScalar(checkSize),
diff --git a/gm/morphology.cpp b/gm/morphology.cpp
index d21053a..063508c 100644
--- a/gm/morphology.cpp
+++ b/gm/morphology.cpp
@@ -5,9 +5,9 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkMorphologyImageFilter.h"
+#include "ToolUtils.h"
+#include "gm.h"
#define WIDTH 700
#define HEIGHT 560
@@ -30,7 +30,7 @@
SkCanvas canvas(fBitmap);
canvas.clear(0x0);
- SkFont font(sk_tool_utils::create_portable_typeface(), 64.0f);
+ SkFont font(ToolUtils::create_portable_typeface(), 64.0f);
SkPaint paint;
paint.setColor(0xFFFFFFFF);
canvas.drawString("ABC", 10, 55, font, paint);
diff --git a/gm/multipicturedraw.cpp b/gm/multipicturedraw.cpp
index 3879fe7..293573d 100644
--- a/gm/multipicturedraw.cpp
+++ b/gm/multipicturedraw.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkColorFilter.h"
#include "SkMultiPictureDraw.h"
@@ -241,7 +241,7 @@
static sk_sp<SkSurface> create_compat_surface(SkCanvas* canvas, int width, int height) {
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
- return sk_tool_utils::makeSurface(canvas, info);
+ return ToolUtils::makeSurface(canvas, info);
}
// This class stores the information required to compose all the result
diff --git a/gm/ninepatchstretch.cpp b/gm/ninepatchstretch.cpp
index 1644c2c..c2b51f8 100644
--- a/gm/ninepatchstretch.cpp
+++ b/gm/ninepatchstretch.cpp
@@ -5,13 +5,13 @@
* found in the LICENSE file.
*/
-#include "gm.h"
#include "SkSurface.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
+#include "gm.h"
static sk_sp<SkSurface> make_surface(SkCanvas* root, int N) {
SkImageInfo info = SkImageInfo::MakeN32Premul(N, N);
- return sk_tool_utils::makeSurface(root, info);
+ return ToolUtils::makeSurface(root, info);
}
static sk_sp<SkImage> make_image(SkCanvas* root, SkIRect* center) {
diff --git a/gm/offsetimagefilter.cpp b/gm/offsetimagefilter.cpp
index 0c1d32c..4706157 100644
--- a/gm/offsetimagefilter.cpp
+++ b/gm/offsetimagefilter.cpp
@@ -9,8 +9,8 @@
#include "SkImageSource.h"
#include "SkOffsetImageFilter.h"
#include "SkSurface.h"
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#define WIDTH 600
#define HEIGHT 100
@@ -33,13 +33,10 @@
void onOnceBeforeDraw() override {
fBitmap = SkImage::MakeFromBitmap(
- sk_tool_utils::create_string_bitmap(80, 80, 0xD000D000, 15, 65, 96, "e"));
+ ToolUtils::create_string_bitmap(80, 80, 0xD000D000, 15, 65, 96, "e"));
fCheckerboard = SkImage::MakeFromBitmap(
- sk_tool_utils::create_checkerboard_bitmap(80, 80,
- 0xFFA0A0A0,
- 0xFF404040,
- 8));
+ ToolUtils::create_checkerboard_bitmap(80, 80, 0xFFA0A0A0, 0xFF404040, 8));
}
void onDraw(SkCanvas* canvas) override {
diff --git a/gm/ovals.cpp b/gm/ovals.cpp
index d9de1a5..8549f13 100644
--- a/gm/ovals.cpp
+++ b/gm/ovals.cpp
@@ -5,16 +5,16 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
-#include "SkTArray.h"
-#include "SkRandom.h"
-#include "SkMatrix.h"
+#include "SkBlurDrawLooper.h"
#include "SkBlurMaskFilter.h"
#include "SkColorFilter.h"
#include "SkGradientShader.h"
-#include "SkBlurDrawLooper.h"
+#include "SkMatrix.h"
+#include "SkRandom.h"
#include "SkRect.h"
+#include "SkTArray.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace skiagm {
@@ -133,7 +133,7 @@
hsv[1] = rand->nextRangeF(0.75f, 1.0f);
hsv[2] = rand->nextRangeF(0.75f, 1.0f);
- return sk_tool_utils::color_to_565(SkHSVToColor(hsv));
+ return ToolUtils::color_to_565(SkHSVToColor(hsv));
}
void onDraw(SkCanvas* canvas) override {
diff --git a/gm/pathinterior.cpp b/gm/pathinterior.cpp
index 4ad18a6..d53cffb 100644
--- a/gm/pathinterior.cpp
+++ b/gm/pathinterior.cpp
@@ -5,14 +5,14 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkBlurMaskFilter.h"
#include "SkCanvas.h"
#include "SkGraphics.h"
#include "SkLayerDrawLooper.h"
#include "SkPath.h"
#include "SkRandom.h"
+#include "ToolUtils.h"
+#include "gm.h"
static SkRect inset(const SkRect& r) {
SkRect rect = r;
@@ -46,7 +46,7 @@
bool hasInterior = false;
#endif
- paint.setColor(hasInterior ? sk_tool_utils::color_to_565(0xFF8888FF) : SK_ColorGRAY);
+ paint.setColor(hasInterior ? ToolUtils::color_to_565(0xFF8888FF) : SK_ColorGRAY);
canvas->drawPath(path, paint);
paint.setStyle(SkPaint::kStroke_Style);
paint.setColor(SK_ColorRED);
diff --git a/gm/pathopsinverse.cpp b/gm/pathopsinverse.cpp
index 32dcda9..3e2d08c 100644
--- a/gm/pathopsinverse.cpp
+++ b/gm/pathopsinverse.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkBitmap.h"
#include "SkPath.h"
#include "SkPathOps.h"
#include "SkRect.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace skiagm {
@@ -21,16 +21,16 @@
protected:
void onOnceBeforeDraw() override {
- const unsigned oneColor = sk_tool_utils::color_to_565(0xFF8080FF);
+ const unsigned oneColor = ToolUtils::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], sk_tool_utils::color_to_565(0xFFc0FFc0));
+ makePaint(&fOpPaint[kUnion_SkPathOp], ToolUtils::color_to_565(0xFFc0FFc0));
makePaint(&fOpPaint[kReverseDifference_SkPathOp], twoColor);
- makePaint(&fOpPaint[kXOR_SkPathOp], sk_tool_utils::color_to_565(0xFFa0FFe0));
+ makePaint(&fOpPaint[kXOR_SkPathOp], ToolUtils::color_to_565(0xFFa0FFe0));
makePaint(&fOutlinePaint, 0xFF000000);
fOutlinePaint.setStyle(SkPaint::kStroke_Style);
}
diff --git a/gm/perspimages.cpp b/gm/perspimages.cpp
index b4ad5eb..ebce9e9 100644
--- a/gm/perspimages.cpp
+++ b/gm/perspimages.cpp
@@ -5,13 +5,13 @@
* found in the LICENSE file.
*/
-#include "gm.h"
#include "Resources.h"
#include "SkGradientShader.h"
#include "SkImage.h"
#include "SkPath.h"
#include "SkSurface.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
+#include "gm.h"
static sk_sp<SkImage> make_image1() { return GetResourceAsImage("images/mandrill_128.png"); }
diff --git a/gm/perspshaders.cpp b/gm/perspshaders.cpp
index 31c48f2..1692726 100644
--- a/gm/perspshaders.cpp
+++ b/gm/perspshaders.cpp
@@ -5,20 +5,19 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkGradientShader.h"
#include "SkImage.h"
#include "SkPath.h"
#include "SkSurface.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
+#include "gm.h"
static sk_sp<SkImage> make_image(SkCanvas* origCanvas, int w, int h) {
SkImageInfo info = SkImageInfo::MakeN32Premul(w, h);
- auto surface(sk_tool_utils::makeSurface(origCanvas, info));
+ auto surface(ToolUtils::makeSurface(origCanvas, info));
SkCanvas* canvas = surface->getCanvas();
- sk_tool_utils::draw_checkerboard(canvas, SK_ColorRED, SK_ColorGREEN, w/10);
+ ToolUtils::draw_checkerboard(canvas, SK_ColorRED, SK_ColorGREEN, w / 10);
return surface->makeImageSnapshot();
}
@@ -41,9 +40,8 @@
}
void onOnceBeforeDraw() override {
- fBitmap = sk_tool_utils::create_checkerboard_bitmap(kCellSize, kCellSize,
- SK_ColorBLUE, SK_ColorYELLOW,
- kCellSize/10);
+ fBitmap = ToolUtils::create_checkerboard_bitmap(
+ kCellSize, kCellSize, SK_ColorBLUE, SK_ColorYELLOW, kCellSize / 10);
fBitmapShader = SkShader::MakeBitmapShader(fBitmap, SkShader::kClamp_TileMode,
SkShader::kClamp_TileMode);
diff --git a/gm/pictureimagefilter.cpp b/gm/pictureimagefilter.cpp
index cf8b579..7e5210e 100644
--- a/gm/pictureimagefilter.cpp
+++ b/gm/pictureimagefilter.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkPictureImageFilter.h"
#include "SkPictureRecorder.h"
@@ -32,7 +32,7 @@
SkCanvas* canvas = recorder.beginRecording(100, 100, nullptr, 0);
SkPaint paint;
paint.setColor(0xFFFFFFFF);
- SkFont font(sk_tool_utils::create_portable_typeface(), 96.0f);
+ SkFont font(ToolUtils::create_portable_typeface(), 96.0f);
canvas->drawString("e", 20.0f, 70.0f, font, paint);
return recorder.finishRecordingAsPicture();
}
@@ -45,7 +45,7 @@
SkPaint paint;
paint.setColor(0xFFFFFFFF);
// this has to be small enough that it doesn't become a path
- SkFont font(sk_tool_utils::create_portable_typeface(), 36.0f);
+ SkFont font(ToolUtils::create_portable_typeface(), 36.0f);
font.setEdging(SkFont::Edging::kSubpixelAntiAlias);
canvas->drawString("e", 20.0f, 70.0f, font, paint);
return recorder.finishRecordingAsPicture();
diff --git a/gm/pictureimagegenerator.cpp b/gm/pictureimagegenerator.cpp
index bfb3736..dd71153 100644
--- a/gm/pictureimagegenerator.cpp
+++ b/gm/pictureimagegenerator.cpp
@@ -5,8 +5,6 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkBitmap.h"
#include "SkCanvas.h"
#include "SkFontPriv.h"
@@ -18,6 +16,8 @@
#include "SkPicture.h"
#include "SkPictureRecorder.h"
#include "SkTextUtils.h"
+#include "ToolUtils.h"
+#include "gm.h"
static void draw_vector_logo(SkCanvas* canvas, const SkRect& viewBox) {
constexpr char kSkiaStr[] = "SKIA";
@@ -28,7 +28,7 @@
SkPaint paint;
paint.setAntiAlias(true);
- SkFont font(sk_tool_utils::create_portable_typeface());
+ SkFont font(ToolUtils::create_portable_typeface());
font.setSubpixel(true);
font.setEmbolden(true);
diff --git a/gm/pictureshader.cpp b/gm/pictureshader.cpp
index 1f98d46..0dbab54 100644
--- a/gm/pictureshader.cpp
+++ b/gm/pictureshader.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkBitmap.h"
#include "SkPaint.h"
@@ -199,15 +199,15 @@
SkRect r = tile;
r.inset(4, 4);
SkPaint p;
- p.setColor(sk_tool_utils::color_to_565(0xFF303F9F)); // dark blue
+ p.setColor(ToolUtils::color_to_565(0xFF303F9F)); // dark blue
c->drawRect(r, p);
- p.setColor(sk_tool_utils::color_to_565(0xFFC5CAE9)); // light blue
+ p.setColor(ToolUtils::color_to_565(0xFFC5CAE9)); // light blue
p.setStrokeWidth(10);
c->drawLine(20, 20, 80, 80, p);
sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
- p.setColor(sk_tool_utils::color_to_565(0xFF8BC34A)); // green
+ p.setColor(ToolUtils::color_to_565(0xFF8BC34A)); // green
canvas->drawPaint(p);
canvas->clipRect(SkRect::MakeXYWH(0, 0, 400, 350));
diff --git a/gm/pixelsnap.cpp b/gm/pixelsnap.cpp
index b1373b6..671045f 100644
--- a/gm/pixelsnap.cpp
+++ b/gm/pixelsnap.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkShader.h"
@@ -35,14 +35,13 @@
void onDraw(SkCanvas* canvas) override {
SkPaint bgPaint;
- bgPaint.setShader(
- sk_tool_utils::create_checkerboard_shader(0xFFAAAAAA, 0xFF777777, 1));
+ bgPaint.setShader(ToolUtils::create_checkerboard_shader(0xFFAAAAAA, 0xFF777777, 1));
canvas->drawPaint(bgPaint);
SkString offset;
SkPaint labelPaint;
labelPaint.setColor(SK_ColorWHITE);
- SkFont font(sk_tool_utils::create_portable_typeface(), SkIntToScalar(kLabelTextSize));
+ SkFont font(ToolUtils::create_portable_typeface(), SkIntToScalar(kLabelTextSize));
SkPaint linePaint;
linePaint.setColor(SK_ColorWHITE);
diff --git a/gm/poly2poly.cpp b/gm/poly2poly.cpp
index 070ff6a..4f1dae9 100644
--- a/gm/poly2poly.cpp
+++ b/gm/poly2poly.cpp
@@ -5,13 +5,13 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "Resources.h"
#include "SkFontMetrics.h"
#include "SkPath.h"
#include "SkTextUtils.h"
#include "SkTypeface.h"
+#include "ToolUtils.h"
+#include "gm.h"
class Poly2PolyGM : public skiagm::GM {
public:
diff --git a/gm/polygonoffset.cpp b/gm/polygonoffset.cpp
index 705eeda..92552cd 100644
--- a/gm/polygonoffset.cpp
+++ b/gm/polygonoffset.cpp
@@ -5,10 +5,10 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
-#include "SkPolyUtils.h"
#include "SkPathPriv.h"
+#include "SkPolyUtils.h"
+#include "ToolUtils.h"
+#include "gm.h"
static void create_ngon(int n, SkPoint* pts, SkScalar w, SkScalar h, SkPath::Direction dir) {
float angleStep = 360.0f / n, angle = 0.0f, sin, cos;
@@ -572,7 +572,7 @@
}
path.close();
- paint.setColor(sk_tool_utils::color_to_565(colors[i]));
+ paint.setColor(ToolUtils::color_to_565(colors[i]));
canvas->save();
canvas->translate(center.fX, center.fY);
canvas->drawPath(path, paint);
diff --git a/gm/quadpaths.cpp b/gm/quadpaths.cpp
index 6f4f7d0..3f3d861 100644
--- a/gm/quadpaths.cpp
+++ b/gm/quadpaths.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkPaint.h"
#include "SkPath.h"
#include "SkRandom.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace skiagm {
@@ -84,8 +84,8 @@
path.fName = "moveTo-quad";
SkPaint titlePaint;
- SkFont font(sk_tool_utils::create_portable_typeface(), 15);
- SkFont labelFont(sk_tool_utils::create_portable_typeface(), 10);
+ SkFont font(ToolUtils::create_portable_typeface(), 15);
+ SkFont labelFont(ToolUtils::create_portable_typeface(), 10);
const char title[] = "Quad Drawn Into Rectangle Clips With "
"Indicated Style, Fill and Linecaps, with stroke width 10";
@@ -111,7 +111,7 @@
canvas->translate(rect.width() + 40 * SK_Scalar1, 0);
}
- SkColor color = sk_tool_utils::color_to_565(0xff007000);
+ SkColor color = ToolUtils::color_to_565(0xff007000);
this->drawPath(path.fPath, canvas, color, rect,
gCaps[cap].fCap, gCaps[cap].fJoin, gStyles[style].fStyle,
gFills[fill].fFill, SK_Scalar1*10);
@@ -215,8 +215,8 @@
path.fName = "moveTo-quad-close";
SkPaint titlePaint;
- SkFont font(sk_tool_utils::create_portable_typeface(), 15);
- SkFont labelFont(sk_tool_utils::create_portable_typeface(), 10);
+ SkFont font(ToolUtils::create_portable_typeface(), 15);
+ SkFont labelFont(ToolUtils::create_portable_typeface(), 10);
const char title[] = "Quad Closed Drawn Into Rectangle Clips With "
"Indicated Style, Fill and Linecaps, with stroke width 10";
canvas->drawString(title, 20.0f, 20.0f, font, titlePaint);
@@ -241,7 +241,7 @@
canvas->translate(rect.width() + 40 * SK_Scalar1, 0);
}
- SkColor color = sk_tool_utils::color_to_565(0xff007000);
+ SkColor color = ToolUtils::color_to_565(0xff007000);
this->drawPath(path.fPath, canvas, color, rect,
gCaps[cap].fCap, gCaps[cap].fJoin, gStyles[style].fStyle,
gFills[fill].fFill, SK_Scalar1*10);
diff --git a/gm/repeated_bitmap.cpp b/gm/repeated_bitmap.cpp
index 54f57c5..154810d 100644
--- a/gm/repeated_bitmap.cpp
+++ b/gm/repeated_bitmap.cpp
@@ -7,13 +7,12 @@
#include "Resources.h"
#include "SkImage.h"
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
static skiagm::DrawResult draw_rotated_image(SkCanvas* canvas, const SkImage* image,
SkString* errorMsg) {
- sk_tool_utils::draw_checkerboard(canvas, SkColorSetRGB(156, 154, 156),
- SK_ColorWHITE, 12);
+ ToolUtils::draw_checkerboard(canvas, SkColorSetRGB(156, 154, 156), SK_ColorWHITE, 12);
if (!image) {
*errorMsg = "No image. Did you forget to set the resourcePath?";
return skiagm::DrawResult::kFail;
diff --git a/gm/roundrects.cpp b/gm/roundrects.cpp
index 12b0e71..ae5a4e9 100644
--- a/gm/roundrects.cpp
+++ b/gm/roundrects.cpp
@@ -5,17 +5,17 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
-#include "SkTArray.h"
-#include "SkRandom.h"
-#include "SkMatrix.h"
+#include "SkBlurDrawLooper.h"
#include "SkBlurMaskFilter.h"
#include "SkColorFilter.h"
#include "SkGradientShader.h"
-#include "SkBlurDrawLooper.h"
-#include "SkRect.h"
+#include "SkMatrix.h"
#include "SkRRect.h"
+#include "SkRandom.h"
+#include "SkRect.h"
+#include "SkTArray.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace skiagm {
@@ -25,7 +25,7 @@
hsv[1] = rand->nextRangeF(0.75f, 1.0f);
hsv[2] = rand->nextRangeF(0.75f, 1.0f);
- return sk_tool_utils::color_to_565(SkHSVToColor(hsv));
+ return ToolUtils::color_to_565(SkHSVToColor(hsv));
}
class RoundRectGM : public GM {
diff --git a/gm/rrect.cpp b/gm/rrect.cpp
index f8fff7a..c7d9cca 100644
--- a/gm/rrect.cpp
+++ b/gm/rrect.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
-#include "SkRRect.h"
#include "SkPath.h"
+#include "SkRRect.h"
+#include "ToolUtils.h"
+#include "gm.h"
typedef void (*InsetProc)(const SkRRect&, SkScalar dx, SkScalar dy, SkRRect*);
@@ -105,7 +105,7 @@
if (rrect.isRect()) {
paint.setColor(SK_ColorRED);
} else if (rrect.isOval()) {
- paint.setColor(sk_tool_utils::color_to_565(0xFF008800));
+ paint.setColor(ToolUtils::color_to_565(0xFF008800));
} else if (rrect.isSimple()) {
paint.setColor(SK_ColorBLUE);
} else {
diff --git a/gm/runtimecolorfilter.cpp b/gm/runtimecolorfilter.cpp
index 0967c22..ebc6a20 100644
--- a/gm/runtimecolorfilter.cpp
+++ b/gm/runtimecolorfilter.cpp
@@ -5,14 +5,14 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
-#include "SkCanvas.h"
-#include "SkImage.h"
#include "Resources.h"
+#include "SkCanvas.h"
#include "SkColorFilterPriv.h"
+#include "SkImage.h"
#include "SkReadBuffer.h"
+#include "ToolUtils.h"
#include "effects/GrSkSLFP.h"
+#include "gm.h"
const char* SKSL_TEST_SRC = R"(
in uniform float b;
diff --git a/gm/samplerstress.cpp b/gm/samplerstress.cpp
index 538a385..a2ea141 100644
--- a/gm/samplerstress.cpp
+++ b/gm/samplerstress.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkMaskFilter.h"
#include "SkPath.h"
#include "SkShader.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace skiagm {
@@ -97,7 +97,7 @@
paint.setAntiAlias(true);
paint.setShader(fShader);
paint.setMaskFilter(fMaskFilter);
- SkFont font(sk_tool_utils::create_portable_typeface(), 72);
+ SkFont font(ToolUtils::create_portable_typeface(), 72);
SkRect temp;
temp.set(SkIntToScalar(115),
diff --git a/gm/savelayer.cpp b/gm/savelayer.cpp
index d6a33b2..a116006 100644
--- a/gm/savelayer.cpp
+++ b/gm/savelayer.cpp
@@ -5,10 +5,9 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvasPriv.h"
-
+#include "ToolUtils.h"
+#include "gm.h"
// This GM tests out the deprecated Android-specific unclipped saveLayer "feature".
// In particular, it attempts to compare the performance of unclipped saveLayers with alternatives.
@@ -25,7 +24,7 @@
SkRandom rand;
for (int i = 0; i < 20; ++i) {
- paint.setColor(sk_tool_utils::color_to_565(rand.nextU() | (0xFF << 24)));
+ paint.setColor(ToolUtils::color_to_565(rand.nextU() | (0xFF << 24)));
canvas->drawRect({ 15, 15, 290, 40 }, paint);
canvas->translate(0, 30);
}
diff --git a/gm/scaledemoji.cpp b/gm/scaledemoji.cpp
index 56143e0..c082dcd 100644
--- a/gm/scaledemoji.cpp
+++ b/gm/scaledemoji.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "Resources.h"
#include "SkCanvas.h"
@@ -40,8 +40,8 @@
} fEmojiFont;
void onOnceBeforeDraw() override {
- fEmojiFont.fTypeface = sk_tool_utils::emoji_typeface();
- fEmojiFont.fText = sk_tool_utils::emoji_sample_text();
+ fEmojiFont.fTypeface = ToolUtils::emoji_typeface();
+ fEmojiFont.fText = ToolUtils::emoji_sample_text();
}
SkString onShortName() override {
@@ -90,8 +90,8 @@
} fEmojiFont;
void onOnceBeforeDraw() override {
- fEmojiFont.fTypeface = sk_tool_utils::emoji_typeface();
- fEmojiFont.fText = sk_tool_utils::emoji_sample_text();
+ fEmojiFont.fTypeface = ToolUtils::emoji_typeface();
+ fEmojiFont.fText = ToolUtils::emoji_sample_text();
}
SkString onShortName() override {
diff --git a/gm/scaledemoji_rendering.cpp b/gm/scaledemoji_rendering.cpp
index df3c382..3440bc6 100644
--- a/gm/scaledemoji_rendering.cpp
+++ b/gm/scaledemoji_rendering.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "Resources.h"
#include "SkCanvas.h"
@@ -27,7 +27,7 @@
typefaces[0] = MakeResourceAsTypeface("fonts/colr.ttf");
typefaces[1] = MakeResourceAsTypeface("fonts/sbix.ttf");
typefaces[2] = MakeResourceAsTypeface("fonts/cbdt.ttf");
- typefaces[3] = sk_tool_utils::create_portable_typeface("Emoji", SkFontStyle());
+ typefaces[3] = ToolUtils::create_portable_typeface("Emoji", SkFontStyle());
}
SkString onShortName() override {
@@ -46,7 +46,7 @@
font.setEdging(SkFont::Edging::kAlias);
SkPaint paint;
- const char* text = sk_tool_utils::emoji_sample_text();
+ const char* text = ToolUtils::emoji_sample_text();
SkFontMetrics metrics;
for (SkScalar textSize : { 70, 150 }) {
diff --git a/gm/shadermaskfilter.cpp b/gm/shadermaskfilter.cpp
index 4499317..9925448 100644
--- a/gm/shadermaskfilter.cpp
+++ b/gm/shadermaskfilter.cpp
@@ -5,8 +5,6 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkBlendModePriv.h"
#include "SkCanvas.h"
#include "SkImage.h"
@@ -14,6 +12,8 @@
#include "SkPictureRecorder.h"
#include "SkShaderMaskFilter.h"
#include "SkTextUtils.h"
+#include "ToolUtils.h"
+#include "gm.h"
static void draw_masked_image(SkCanvas* canvas, const SkImage* image, SkScalar x, SkScalar y,
const SkImage* mask, sk_sp<SkMaskFilter> outer, SkBlendMode mode) {
@@ -178,7 +178,7 @@
#include "SkMaskFilter.h"
static sk_sp<SkImage> make_circle_image(SkCanvas* canvas, SkScalar radius, int margin) {
const int n = SkScalarCeilToInt(radius) * 2 + margin * 2;
- auto surf = sk_tool_utils::makeSurface(canvas, SkImageInfo::MakeN32Premul(n, n));
+ auto surf = ToolUtils::makeSurface(canvas, SkImageInfo::MakeN32Premul(n, n));
SkPaint paint;
paint.setAntiAlias(true);
surf->getCanvas()->drawCircle(n * 0.5f, n * 0.5f, radius, paint);
@@ -240,21 +240,22 @@
using ShaderMakerT = sk_sp<SkShader>(*)(SkCanvas*, const SkMatrix& lm);
static const ShaderMakerT gShaderMakers[] = {
- [](SkCanvas* canvas, const SkMatrix& lm) -> sk_sp<SkShader> {
- auto surface = sk_tool_utils::makeSurface(canvas,
- SkImageInfo::MakeN32Premul(kSize, kSize));
- draw_mask(surface->getCanvas());
- return surface->makeImageSnapshot()->makeShader(SkShader::kClamp_TileMode,
- SkShader::kClamp_TileMode, &lm);
- },
- [](SkCanvas*, const SkMatrix& lm) -> sk_sp<SkShader> {
- SkPictureRecorder recorder;
- draw_mask(recorder.beginRecording(kSize, kSize));
- return SkShader::MakePictureShader(recorder.finishRecordingAsPicture(),
- SkShader::kClamp_TileMode,
- SkShader::kClamp_TileMode,
- &lm, nullptr);
- },
+ [](SkCanvas* canvas, const SkMatrix& lm) -> sk_sp<SkShader> {
+ auto surface =
+ ToolUtils::makeSurface(canvas, SkImageInfo::MakeN32Premul(kSize, kSize));
+ draw_mask(surface->getCanvas());
+ return surface->makeImageSnapshot()->makeShader(
+ SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, &lm);
+ },
+ [](SkCanvas*, const SkMatrix& lm) -> sk_sp<SkShader> {
+ SkPictureRecorder recorder;
+ draw_mask(recorder.beginRecording(kSize, kSize));
+ return SkShader::MakePictureShader(recorder.finishRecordingAsPicture(),
+ SkShader::kClamp_TileMode,
+ SkShader::kClamp_TileMode,
+ &lm,
+ nullptr);
+ },
};
struct Config {
diff --git a/gm/shadertext3.cpp b/gm/shadertext3.cpp
index 07b6413..83975ab 100644
--- a/gm/shadertext3.cpp
+++ b/gm/shadertext3.cpp
@@ -5,10 +5,10 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace skiagm {
@@ -70,7 +70,7 @@
bmpPaint.setAlphaf(0.5f);
canvas->drawBitmap(fBmp, 5.f, 5.f, &bmpPaint);
- SkFont font(sk_tool_utils::create_portable_typeface(), SkIntToScalar(kPointSize));
+ SkFont font(ToolUtils::create_portable_typeface(), SkIntToScalar(kPointSize));
SkPaint outlinePaint;
outlinePaint.setStyle(SkPaint::kStroke_Style);
outlinePaint.setStrokeWidth(0.f);
diff --git a/gm/sharedcorners.cpp b/gm/sharedcorners.cpp
index 7d9dedd..8d0e434 100644
--- a/gm/sharedcorners.cpp
+++ b/gm/sharedcorners.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkPaint.h"
#include "SkPath.h"
#include "SkPoint.h"
+#include "ToolUtils.h"
+#include "gm.h"
#include <array>
#include <vector>
@@ -24,9 +24,7 @@
// analytic AA is working properly.
class SharedCornersGM : public GM {
public:
- SharedCornersGM() {
- this->setBGColor(sk_tool_utils::color_to_565(0xFF1A65D7));
- }
+ SharedCornersGM() { this->setBGColor(ToolUtils::color_to_565(0xFF1A65D7)); }
protected:
SkString onShortName() override {
diff --git a/gm/showmiplevels.cpp b/gm/showmiplevels.cpp
index 4a3a836..ce3c119 100644
--- a/gm/showmiplevels.cpp
+++ b/gm/showmiplevels.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "Resources.h"
#include "SkColorPriv.h"
@@ -118,7 +118,7 @@
static void DrawAndFrame(SkCanvas* canvas, const SkBitmap& orig, SkScalar x, SkScalar y) {
SkBitmap bm;
- sk_tool_utils::copy_to(&bm, orig.colorType(), orig);
+ ToolUtils::copy_to(&bm, orig.colorType(), orig);
apply_gamma(bm);
canvas->drawBitmap(bm, x, y, nullptr);
@@ -169,7 +169,7 @@
}
void onOnceBeforeDraw() override {
- fBM[0] = sk_tool_utils::create_checkerboard_bitmap(fN, fN, SK_ColorBLACK, SK_ColorWHITE, 2);
+ fBM[0] = ToolUtils::create_checkerboard_bitmap(fN, fN, SK_ColorBLACK, SK_ColorWHITE, 2);
fBM[1] = make_bitmap(fN, fN);
fBM[2] = make_bitmap2(fN, fN);
fBM[3] = make_bitmap3(fN, fN);
@@ -196,7 +196,7 @@
void copy_to(SkBitmap* dst, SkColorType dstColorType, const SkBitmap& src) {
if (kGray_8_SkColorType == dstColorType) {
- return sk_tool_utils::copy_to_g8(dst, src);
+ return ToolUtils::copy_to_g8(dst, src);
}
const SkBitmap* srcPtr = &src;
@@ -206,7 +206,7 @@
srcPtr = &tmp;
}
- sk_tool_utils::copy_to(dst, dstColorType, *srcPtr);
+ ToolUtils::copy_to(dst, dstColorType, *srcPtr);
}
/**
@@ -282,8 +282,7 @@
}
void onOnceBeforeDraw() override {
- fBM[0] = sk_tool_utils::create_checkerboard_bitmap(fW, fH,
- SHOW_MIP_COLOR, SK_ColorWHITE, 2);
+ fBM[0] = ToolUtils::create_checkerboard_bitmap(fW, fH, SHOW_MIP_COLOR, SK_ColorWHITE, 2);
fBM[1] = make_bitmap(fW, fH);
fBM[2] = make_bitmap2(fW, fH);
fBM[3] = make_bitmap3(fW, fH);
diff --git a/gm/simpleaaclip.cpp b/gm/simpleaaclip.cpp
index c2d64df..b534b84 100644
--- a/gm/simpleaaclip.cpp
+++ b/gm/simpleaaclip.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkAAClip.h"
#include "SkCanvas.h"
#include "SkPath.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace skiagm {
@@ -27,7 +27,7 @@
// need to copy for deferred drawing test to work
SkBitmap bm2;
- sk_tool_utils::copy_to(&bm2, bm.colorType(), bm);
+ ToolUtils::copy_to(&bm2, bm.colorType(), bm);
canvas->drawBitmap(bm2,
SK_Scalar1 * mask.fBounds.fLeft,
@@ -147,16 +147,16 @@
const char* fName;
SkClipOp fOp;
} gOps[] = {
- { SK_ColorBLACK, "Difference", kDifference_SkClipOp },
- { SK_ColorRED, "Intersect", kIntersect_SkClipOp },
- { sk_tool_utils::color_to_565(0xFF008800), "Union", kUnion_SkClipOp },
- { SK_ColorGREEN, "Rev Diff", kReverseDifference_SkClipOp },
- { SK_ColorYELLOW, "Replace", kReplace_SkClipOp },
- { SK_ColorBLUE, "XOR", kXOR_SkClipOp },
+ {SK_ColorBLACK, "Difference", kDifference_SkClipOp},
+ {SK_ColorRED, "Intersect", kIntersect_SkClipOp},
+ {ToolUtils::color_to_565(0xFF008800), "Union", kUnion_SkClipOp},
+ {SK_ColorGREEN, "Rev Diff", kReverseDifference_SkClipOp},
+ {SK_ColorYELLOW, "Replace", kReplace_SkClipOp},
+ {SK_ColorBLUE, "XOR", kXOR_SkClipOp},
};
SkPaint textPaint;
- SkFont font(sk_tool_utils::create_portable_typeface(), 24);
+ SkFont font(ToolUtils::create_portable_typeface(), 24);
int xOff = 0;
for (size_t op = 0; op < SK_ARRAY_COUNT(gOps); op++) {
diff --git a/gm/simplerect.cpp b/gm/simplerect.cpp
index b27c348..24c5016 100644
--- a/gm/simplerect.cpp
+++ b/gm/simplerect.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkPath.h"
+#include "ToolUtils.h"
+#include "gm.h"
class SimpleRectGM : public skiagm::GM {
public:
@@ -36,7 +36,7 @@
SkRandom rand;
SkPaint paint;
for (int i = 0; i < 10000; i++) {
- paint.setColor(sk_tool_utils::color_to_565(rand.nextU() | (0xFF << 24)));
+ paint.setColor(ToolUtils::color_to_565(rand.nextU() | (0xFF << 24)));
SkScalar x = rand.nextRangeScalar(min, max);
SkScalar y = rand.nextRangeScalar(min, max);
SkScalar w = rand.nextRangeScalar(0, size);
diff --git a/gm/skbug1719.cpp b/gm/skbug1719.cpp
index ca9e8bd..ad311fb 100644
--- a/gm/skbug1719.cpp
+++ b/gm/skbug1719.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkColorFilter.h"
#include "SkMaskFilter.h"
#include "SkPath.h"
+#include "ToolUtils.h"
+#include "gm.h"
/**
* This test exercises bug 1719. An anti-aliased blurred path is rendered through a soft clip. On
diff --git a/gm/skbug_257.cpp b/gm/skbug_257.cpp
index 49f06dc..919e980 100644
--- a/gm/skbug_257.cpp
+++ b/gm/skbug_257.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkImage.h"
#include "SkRRect.h"
#include "SkTextBlob.h"
+#include "ToolUtils.h"
+#include "gm.h"
static void rotated_checkerboard_shader(SkPaint* paint,
SkColor c1,
@@ -54,7 +54,7 @@
static void test_text(SkCanvas* canvas, SkScalar size,
SkColor color, SkScalar Y) {
- SkFont font(sk_tool_utils::create_portable_typeface(), 24);
+ SkFont font(ToolUtils::create_portable_typeface(), 24);
font.setEdging(SkFont::Edging::kAlias);
SkPaint type;
type.setColor(color);
diff --git a/gm/srcmode.cpp b/gm/srcmode.cpp
index f64b1d1..88e9e42 100644
--- a/gm/srcmode.cpp
+++ b/gm/srcmode.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
#include "SkPath.h"
#include "SkSurface.h"
+#include "ToolUtils.h"
+#include "gm.h"
#define W SkIntToScalar(80)
#define H SkIntToScalar(60)
@@ -74,7 +74,7 @@
canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
SkPaint paint;
- SkFont font(sk_tool_utils::create_portable_typeface(), H/4);
+ SkFont font(ToolUtils::create_portable_typeface(), H / 4);
paint.setColor(0x80F60000);
const Proc procs[] = {
diff --git a/gm/srgb.cpp b/gm/srgb.cpp
index 21571c5..fb6fc2c 100644
--- a/gm/srgb.cpp
+++ b/gm/srgb.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
-#include "SkCanvas.h"
-#include "SkImage.h"
#include "Resources.h"
+#include "SkCanvas.h"
#include "SkColorFilter.h"
+#include "SkImage.h"
+#include "ToolUtils.h"
+#include "gm.h"
DEF_SIMPLE_GM(srgb_colorfilter, canvas, 512, 256*3) {
auto img = GetResourceAsImage("images/mandrill_256.png");
diff --git a/gm/stringart.cpp b/gm/stringart.cpp
index cc423eb..48f7df0 100644
--- a/gm/stringart.cpp
+++ b/gm/stringart.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkAnimTimer.h"
#include "SkCanvas.h"
#include "SkPath.h"
+#include "ToolUtils.h"
+#include "gm.h"
// Reproduces https://code.google.com/p/chromium/issues/detail?id=279014
@@ -56,7 +56,7 @@
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
- paint.setColor(sk_tool_utils::color_to_565(0xFF007700));
+ paint.setColor(ToolUtils::color_to_565(0xFF007700));
canvas->drawPath(path, paint);
}
diff --git a/gm/strokedlines.cpp b/gm/strokedlines.cpp
index e3f409e..ac2cf53 100644
--- a/gm/strokedlines.cpp
+++ b/gm/strokedlines.cpp
@@ -5,14 +5,14 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkDashPathEffect.h"
#include "SkGradientShader.h"
#include "SkMaskFilter.h"
#include "SkPaint.h"
#include "SkPath.h"
#include "SkPoint3.h"
+#include "ToolUtils.h"
+#include "gm.h"
constexpr int kNumColumns = 6;
constexpr int kNumRows = 8;
@@ -99,9 +99,7 @@
// Various shaders are applied to ensure the coordinate spaces work out right.
class StrokedLinesGM : public GM {
public:
- StrokedLinesGM() {
- this->setBGColor(sk_tool_utils::color_to_565(0xFF1A65D7));
- }
+ StrokedLinesGM() { this->setBGColor(ToolUtils::color_to_565(0xFF1A65D7)); }
protected:
SkString onShortName() override {
diff --git a/gm/strokefill.cpp b/gm/strokefill.cpp
index a557ab2..afce0c4 100644
--- a/gm/strokefill.cpp
+++ b/gm/strokefill.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkPathPriv.h"
#include "SkTextFormatParams.h"
#include "SkTypeface.h"
+#include "ToolUtils.h"
+#include "gm.h"
/* Generated on a Mac with:
* paint.setTypeface(SkTypeface::CreateByName("Papyrus"));
@@ -258,7 +258,7 @@
// use the portable typeface to generically test the fake bold code everywhere
// (as long as the freetype option to do the bolding itself isn't enabled)
- SkFont font(sk_tool_utils::create_portable_typeface("serif", SkFontStyle()), 100);
+ SkFont font(ToolUtils::create_portable_typeface("serif", SkFontStyle()), 100);
SkPaint paint;
paint.setAntiAlias(true);
paint.setStrokeWidth(SkIntToScalar(5));
diff --git a/gm/strokes.cpp b/gm/strokes.cpp
index c8d14e0..588ea06 100644
--- a/gm/strokes.cpp
+++ b/gm/strokes.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
-#include "SkPath.h"
-#include "SkRandom.h"
#include "SkDashPathEffect.h"
#include "SkParsePath.h"
+#include "SkPath.h"
+#include "SkRandom.h"
+#include "ToolUtils.h"
+#include "gm.h"
#define W 400
#define H 400
@@ -390,7 +390,7 @@
SkPaint fillPaint(origPaint);
fillPaint.setColor(SK_ColorRED);
SkPaint strokePaint(origPaint);
- strokePaint.setColor(sk_tool_utils::color_to_565(0xFF4444FF));
+ strokePaint.setColor(ToolUtils::color_to_565(0xFF4444FF));
void (*procs[])(SkPath*, const SkRect&, SkString*) = {
make0, make1, make2, make3, make4, make5
diff --git a/gm/stroketext.cpp b/gm/stroketext.cpp
index fb76975..bff1228 100644
--- a/gm/stroketext.cpp
+++ b/gm/stroketext.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkDashPathEffect.h"
#include "SkTextBlob.h"
+#include "ToolUtils.h"
+#include "gm.h"
static void test_nulldev(SkCanvas* canvas) {
SkBitmap bm;
@@ -75,7 +75,7 @@
SkPaint paint;
paint.setAntiAlias(true);
- SkFont font(sk_tool_utils::create_portable_typeface(), kBelowThreshold_TextSize);
+ SkFont font(ToolUtils::create_portable_typeface(), kBelowThreshold_TextSize);
draw_text_set(canvas, paint, font);
canvas->translate(600, 0);
diff --git a/gm/surface.cpp b/gm/surface.cpp
index 633f07d..98c8abd 100644
--- a/gm/surface.cpp
+++ b/gm/surface.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkGradientShader.h"
#include "SkSurface.h"
#include "SkSurfaceProps.h"
#include "SkTextUtils.h"
+#include "ToolUtils.h"
+#include "gm.h"
#define W 200
#define H 100
@@ -43,7 +43,7 @@
paint.setShader(nullptr);
paint.setColor(SK_ColorWHITE);
- SkFont font(sk_tool_utils::create_portable_typeface(), 32);
+ SkFont font(ToolUtils::create_portable_typeface(), 32);
font.setEdging(SkFont::Edging::kSubpixelAntiAlias);
SkTextUtils::DrawString(canvas, label, W / 2, H * 3 / 4, font, paint,
SkTextUtils::kCenter_Align);
@@ -124,7 +124,7 @@
void onDraw(SkCanvas* canvas) override {
SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
- auto surf(sk_tool_utils::makeSurface(canvas, info, nullptr));
+ auto surf(ToolUtils::makeSurface(canvas, info, nullptr));
drawInto(surf->getCanvas());
sk_sp<SkImage> image(surf->makeImageSnapshot());
@@ -149,7 +149,7 @@
DEF_SIMPLE_GM(copy_on_write_retain, canvas, 256, 256) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(256, 256);
- sk_sp<SkSurface> surf = sk_tool_utils::makeSurface(canvas, info);
+ sk_sp<SkSurface> surf = ToolUtils::makeSurface(canvas, info);
surf->getCanvas()->clear(SK_ColorRED);
// its important that image survives longer than the next draw, so the surface will see
@@ -167,7 +167,7 @@
DEF_SIMPLE_GM(copy_on_write_savelayer, canvas, 256, 256) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(256, 256);
- sk_sp<SkSurface> surf = sk_tool_utils::makeSurface(canvas, info);
+ sk_sp<SkSurface> surf = ToolUtils::makeSurface(canvas, info);
surf->getCanvas()->clear(SK_ColorRED);
// its important that image survives longer than the next draw, so the surface will see
// an outstanding image, and have to decide if it should retain or discard those pixels
@@ -188,7 +188,7 @@
DEF_SIMPLE_GM(surface_underdraw, canvas, 256, 256) {
SkImageInfo info = SkImageInfo::MakeN32Premul(256, 256, nullptr);
- auto surf = sk_tool_utils::makeSurface(canvas, info);
+ auto surf = ToolUtils::makeSurface(canvas, info);
const SkIRect subset = SkIRect::MakeLTRB(180, 0, 256, 256);
diff --git a/gm/textblob.cpp b/gm/textblob.cpp
index d22a35c..6d6bfab 100644
--- a/gm/textblob.cpp
+++ b/gm/textblob.cpp
@@ -19,8 +19,8 @@
#include "SkTextBlob.h"
#include "SkTypeface.h"
#include "SkTypes.h"
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include <cstring>
@@ -84,7 +84,7 @@
protected:
void onOnceBeforeDraw() override {
- fTypeface = sk_tool_utils::create_portable_typeface("serif", SkFontStyle());
+ fTypeface = ToolUtils::create_portable_typeface("serif", SkFontStyle());
SkFont font(fTypeface);
size_t txtLen = strlen(fText);
int glyphCount = font.countText(fText, txtLen, kUTF8_SkTextEncoding);
diff --git a/gm/textblobblockreordering.cpp b/gm/textblobblockreordering.cpp
index 1121380..b847c29 100644
--- a/gm/textblobblockreordering.cpp
+++ b/gm/textblobblockreordering.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkTextBlob.h"
@@ -24,7 +24,7 @@
// make textblob
// Large text is used to trigger atlas eviction
- SkFont font(sk_tool_utils::create_portable_typeface(), 56);
+ SkFont font(ToolUtils::create_portable_typeface(), 56);
font.setEdging(SkFont::Edging::kAlias);
const char* text = "AB";
@@ -32,7 +32,7 @@
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
SkScalar yOffset = bounds.height();
- sk_tool_utils::add_to_text_blob(&builder, text, font, 0, yOffset - 30);
+ ToolUtils::add_to_text_blob(&builder, text, font, 0, yOffset - 30);
// build
fBlob = builder.make();
diff --git a/gm/textblobcolortrans.cpp b/gm/textblobcolortrans.cpp
index 40f58ed..faaf936 100644
--- a/gm/textblobcolortrans.cpp
+++ b/gm/textblobcolortrans.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "Resources.h"
#include "SkCanvas.h"
@@ -29,7 +29,7 @@
// make textblob
// Large text is used to trigger atlas eviction
- SkFont font(sk_tool_utils::create_portable_typeface(), 256);
+ SkFont font(ToolUtils::create_portable_typeface(), 256);
font.setEdging(SkFont::Edging::kAlias);
const char* text = "AB";
@@ -37,13 +37,13 @@
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
SkScalar yOffset = bounds.height();
- sk_tool_utils::add_to_text_blob(&builder, text, font, 0, yOffset - 30);
+ ToolUtils::add_to_text_blob(&builder, text, font, 0, yOffset - 30);
// A8
font.setSize(28);
text = "The quick brown fox jumps over the lazy dog.";
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
- sk_tool_utils::add_to_text_blob(&builder, text, font, 0, yOffset - 8);
+ ToolUtils::add_to_text_blob(&builder, text, font, 0, yOffset - 8);
// build
fBlob = builder.make();
diff --git a/gm/textblobgeometrychange.cpp b/gm/textblobgeometrychange.cpp
index 250d012..97dc6fc 100644
--- a/gm/textblobgeometrychange.cpp
+++ b/gm/textblobgeometrychange.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkSurface.h"
@@ -31,18 +31,18 @@
void onDraw(SkCanvas* canvas) override {
const char text[] = "Hamburgefons";
- SkFont font(sk_tool_utils::create_portable_typeface(), 20);
+ SkFont font(ToolUtils::create_portable_typeface(), 20);
font.setEdging(SkFont::Edging::kSubpixelAntiAlias);
SkTextBlobBuilder builder;
- sk_tool_utils::add_to_text_blob(&builder, text, font, 10, 10);
+ ToolUtils::add_to_text_blob(&builder, text, font, 10, 10);
sk_sp<SkTextBlob> blob(builder.make());
SkImageInfo info = SkImageInfo::MakeN32Premul(200, 200);
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
- auto surface = sk_tool_utils::makeSurface(canvas, info, &props);
+ auto surface = ToolUtils::makeSurface(canvas, info, &props);
SkCanvas* c = surface->getCanvas();
// LCD text on white background
diff --git a/gm/textbloblooper.cpp b/gm/textbloblooper.cpp
index 51e8155..73628f9 100644
--- a/gm/textbloblooper.cpp
+++ b/gm/textbloblooper.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "Sk2DPathEffect.h"
#include "SkBlurMask.h"
@@ -24,7 +24,7 @@
constexpr int kWidth = 1250;
constexpr int kHeight = 700;
-// Unlike the variant in sk_tool_utils, this version positions the glyphs on a diagonal
+// Unlike the variant in ToolUtils, this version positions the glyphs on a diagonal
static void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const SkFont& font,
SkScalar x, SkScalar y) {
SkTDArray<uint16_t> glyphs;
@@ -143,7 +143,7 @@
const char* text = "The quick brown fox jumps over the lazy dog";
font.setSubpixel(true);
font.setEdging(SkFont::Edging::kSubpixelAntiAlias);
- font.setTypeface(sk_tool_utils::create_portable_typeface());
+ font.setTypeface(ToolUtils::create_portable_typeface());
add_to_text_blob(&builder, text, font, 0, 0);
fBlob = builder.make();
diff --git a/gm/textblobmixedsizes.cpp b/gm/textblobmixedsizes.cpp
index 1072959..51e560d 100644
--- a/gm/textblobmixedsizes.cpp
+++ b/gm/textblobmixedsizes.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "Resources.h"
#include "SkBlurMask.h"
@@ -37,7 +37,7 @@
const char* text = "Skia";
- sk_tool_utils::add_to_text_blob(&builder, text, font, 0, 0);
+ ToolUtils::add_to_text_blob(&builder, text, font, 0, 0);
// large
SkRect bounds;
@@ -45,35 +45,35 @@
SkScalar yOffset = bounds.height();
font.setSize(162);
- sk_tool_utils::add_to_text_blob(&builder, text, font, 0, yOffset);
+ ToolUtils::add_to_text_blob(&builder, text, font, 0, yOffset);
// Medium
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
yOffset += bounds.height();
font.setSize(72);
- sk_tool_utils::add_to_text_blob(&builder, text, font, 0, yOffset);
+ ToolUtils::add_to_text_blob(&builder, text, font, 0, yOffset);
// Small
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
yOffset += bounds.height();
font.setSize(32);
- sk_tool_utils::add_to_text_blob(&builder, text, font, 0, yOffset);
+ ToolUtils::add_to_text_blob(&builder, text, font, 0, yOffset);
// micro (will fall out of distance field text even if distance field text is enabled)
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
yOffset += bounds.height();
font.setSize(14);
- sk_tool_utils::add_to_text_blob(&builder, text, font, 0, yOffset);
+ ToolUtils::add_to_text_blob(&builder, text, font, 0, yOffset);
// Zero size.
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
yOffset += bounds.height();
font.setSize(0);
- sk_tool_utils::add_to_text_blob(&builder, text, font, 0, yOffset);
+ ToolUtils::add_to_text_blob(&builder, text, font, 0, yOffset);
// build
fBlob = builder.make();
diff --git a/gm/textblobrandomfont.cpp b/gm/textblobrandomfont.cpp
index 96f0951..cebc0bf 100644
--- a/gm/textblobrandomfont.cpp
+++ b/gm/textblobrandomfont.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "RandomScalerContext.h"
#include "Resources.h"
@@ -42,7 +42,7 @@
font.setEdging(SkFont::Edging::kSubpixelAntiAlias);
// Setup our random scaler context
- auto typeface = sk_tool_utils::create_portable_typeface("sans-serif", SkFontStyle::Bold());
+ auto typeface = ToolUtils::create_portable_typeface("sans-serif", SkFontStyle::Bold());
if (!typeface) {
typeface = SkTypeface::MakeDefault();
}
@@ -52,7 +52,7 @@
SkRect bounds;
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
y -= bounds.fTop;
- sk_tool_utils::add_to_text_blob(&builder, text, font, 0, y);
+ ToolUtils::add_to_text_blob(&builder, text, font, 0, y);
y += bounds.fBottom;
// A8
@@ -63,21 +63,21 @@
font.setEdging(SkFont::Edging::kAntiAlias);
font.measureText(bigtext1, strlen(bigtext1), kUTF8_SkTextEncoding, &bounds);
y -= bounds.fTop;
- sk_tool_utils::add_to_text_blob(&builder, bigtext1, font, 0, y);
+ ToolUtils::add_to_text_blob(&builder, bigtext1, font, 0, y);
y += bounds.fBottom;
font.measureText(bigtext2, strlen(bigtext2), kUTF8_SkTextEncoding, &bounds);
y -= bounds.fTop;
- sk_tool_utils::add_to_text_blob(&builder, bigtext2, font, 0, y);
+ ToolUtils::add_to_text_blob(&builder, bigtext2, font, 0, y);
y += bounds.fBottom;
// color emoji
- if (sk_sp<SkTypeface> origEmoji = sk_tool_utils::emoji_typeface()) {
+ if (sk_sp<SkTypeface> origEmoji = ToolUtils::emoji_typeface()) {
font.setTypeface(sk_make_sp<SkRandomTypeface>(origEmoji, paint, false));
- const char* emojiText = sk_tool_utils::emoji_sample_text();
+ const char* emojiText = ToolUtils::emoji_sample_text();
font.measureText(emojiText, strlen(emojiText), kUTF8_SkTextEncoding, &bounds);
y -= bounds.fTop;
- sk_tool_utils::add_to_text_blob(&builder, emojiText, font, 0, y);
+ ToolUtils::add_to_text_blob(&builder, emojiText, font, 0, y);
y += bounds.fBottom;
}
@@ -96,7 +96,7 @@
DrawResult onDraw(GrContext* context, GrRenderTargetContext*, SkCanvas* canvas,
SkString* errorMsg) override {
// This GM exists to test a specific feature of the GPU backend.
- // This GM uses sk_tool_utils::makeSurface which doesn't work well with vias.
+ // This GM uses ToolUtils::makeSurface which doesn't work well with vias.
// This GM uses SkRandomTypeface which doesn't work well with serialization.
canvas->drawColor(SK_ColorWHITE);
@@ -104,7 +104,7 @@
kPremul_SkAlphaType,
canvas->imageInfo().refColorSpace());
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
- auto surface(sk_tool_utils::makeSurface(canvas, info, &props));
+ auto surface(ToolUtils::makeSurface(canvas, info, &props));
if (!surface) {
*errorMsg = "This test requires a surface";
return DrawResult::kFail;
diff --git a/gm/textblobshader.cpp b/gm/textblobshader.cpp
index 971f628..a4808e0 100644
--- a/gm/textblobshader.cpp
+++ b/gm/textblobshader.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
@@ -24,7 +24,7 @@
private:
void onOnceBeforeDraw() override {
{
- SkFont font(sk_tool_utils::create_portable_typeface());
+ SkFont font(ToolUtils::create_portable_typeface());
const char* txt = "Blobber";
size_t txtLen = strlen(txt);
fGlyphs.append(font.countText(txt, txtLen, kUTF8_SkTextEncoding));
@@ -35,7 +35,7 @@
font.setSubpixel(true);
font.setEdging(SkFont::Edging::kAntiAlias);
font.setSize(30);
- font.setTypeface(sk_tool_utils::create_portable_typeface());
+ font.setTypeface(ToolUtils::create_portable_typeface());
SkTextBlobBuilder builder;
int glyphCount = fGlyphs.count();
diff --git a/gm/textblobtransforms.cpp b/gm/textblobtransforms.cpp
index 24cb564..6977070 100644
--- a/gm/textblobtransforms.cpp
+++ b/gm/textblobtransforms.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "Resources.h"
#include "SkCanvas.h"
@@ -26,19 +26,19 @@
SkTextBlobBuilder builder;
// make textblob. To stress distance fields, we choose sizes appropriately
- SkFont font(sk_tool_utils::create_portable_typeface(), 162);
+ SkFont font(ToolUtils::create_portable_typeface(), 162);
font.setEdging(SkFont::Edging::kAlias);
const char* text = "A";
SkRect bounds;
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
- sk_tool_utils::add_to_text_blob(&builder, text, font, 0, 0);
+ ToolUtils::add_to_text_blob(&builder, text, font, 0, 0);
// Medium
SkScalar xOffset = bounds.width() + 5;
font.setSize(72);
text = "B";
- sk_tool_utils::add_to_text_blob(&builder, text, font, xOffset, 0);
+ ToolUtils::add_to_text_blob(&builder, text, font, xOffset, 0);
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
SkScalar yOffset = bounds.height();
@@ -46,7 +46,7 @@
// Small
font.setSize(32);
text = "C";
- sk_tool_utils::add_to_text_blob(&builder, text, font, xOffset, -yOffset - 10);
+ ToolUtils::add_to_text_blob(&builder, text, font, xOffset, -yOffset - 10);
// build
fBlob = builder.make();
diff --git a/gm/textblobuseaftergpufree.cpp b/gm/textblobuseaftergpufree.cpp
index 075c934..4c70561 100644
--- a/gm/textblobuseaftergpufree.cpp
+++ b/gm/textblobuseaftergpufree.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkSurface.h"
@@ -31,7 +31,7 @@
void onDraw(GrContext* context, GrRenderTargetContext*, SkCanvas* canvas) override {
const char text[] = "Hamburgefons";
- SkFont font(sk_tool_utils::create_portable_typeface(), 20);
+ SkFont font(ToolUtils::create_portable_typeface(), 20);
auto blob = SkTextBlob::MakeFromText(text, strlen(text), font);
// draw textblob
diff --git a/gm/texteffects.cpp b/gm/texteffects.cpp
index 8fdaf8e..eafa0cf 100644
--- a/gm/texteffects.cpp
+++ b/gm/texteffects.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
@@ -106,8 +106,7 @@
for (size_t font = 0; font < SK_ARRAY_COUNT(fam); ++font) {
for (SkScalar textSize = 100; textSize > 10; textSize -= 20) {
- SkFont skFont(
- sk_tool_utils::create_portable_typeface(fam[font], SkFontStyle()), textSize);
+ SkFont skFont(ToolUtils::create_portable_typeface(fam[font], SkFontStyle()), textSize);
const SkScalar uWidth = textSize / 15;
paint.setStrokeWidth(uWidth);
paint.setStyle(SkPaint::kFill_Style);
@@ -230,7 +229,7 @@
const char text[] = "Hyjay {worlp}.";
const size_t length = strlen(text);
SkFont font;
- font.setTypeface(sk_tool_utils::create_portable_typeface());
+ font.setTypeface(ToolUtils::create_portable_typeface());
font.setSize(100);
font.setEdging(SkFont::Edging::kAntiAlias);
const int count = font.countText(text, length, kUTF8_SkTextEncoding);
diff --git a/gm/tileimagefilter.cpp b/gm/tileimagefilter.cpp
index a2a731e..b1789c7 100644
--- a/gm/tileimagefilter.cpp
+++ b/gm/tileimagefilter.cpp
@@ -10,8 +10,8 @@
#include "SkImage.h"
#include "SkImageSource.h"
#include "SkTileImageFilter.h"
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#define WIDTH 400
#define HEIGHT 200
@@ -36,13 +36,10 @@
void onOnceBeforeDraw() override {
fBitmap = SkImage::MakeFromBitmap(
- sk_tool_utils::create_string_bitmap(50, 50, 0xD000D000, 10, 45, 50, "e"));
+ ToolUtils::create_string_bitmap(50, 50, 0xD000D000, 10, 45, 50, "e"));
fCheckerboard = SkImage::MakeFromBitmap(
- sk_tool_utils::create_checkerboard_bitmap(80, 80,
- 0xFFA0A0A0,
- 0xFF404040,
- 8));
+ ToolUtils::create_checkerboard_bitmap(80, 80, 0xFFA0A0A0, 0xFF404040, 8));
}
void onDraw(SkCanvas* canvas) override {
diff --git a/gm/tilemodes.cpp b/gm/tilemodes.cpp
index fa94deb..fe5ae48 100644
--- a/gm/tilemodes.cpp
+++ b/gm/tilemodes.cpp
@@ -4,8 +4,6 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkColorFilter.h"
#include "SkMaskFilter.h"
#include "SkPath.h"
@@ -13,6 +11,8 @@
#include "SkShader.h"
#include "SkTextUtils.h"
#include "SkUTF.h"
+#include "ToolUtils.h"
+#include "gm.h"
// effects
#include "SkGradientShader.h"
#include "SkBlurDrawLooper.h"
@@ -80,7 +80,7 @@
void onDraw(SkCanvas* canvas) override {
SkPaint textPaint;
- SkFont font(sk_tool_utils::create_portable_typeface(), 12);
+ SkFont font(ToolUtils::create_portable_typeface(), 12);
int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize;
@@ -103,7 +103,7 @@
SkPaint p;
p.setDither(true);
SkString str;
- SkFont font(sk_tool_utils::create_portable_typeface());
+ SkFont font(ToolUtils::create_portable_typeface());
str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]);
SkTextUtils::DrawString(canvas, str.c_str(), x + r.width()/2, y, font, p,
@@ -166,7 +166,7 @@
SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(gWidth), SkIntToScalar(gHeight)} };
SkPoint center = { SkIntToScalar(gWidth)/2, SkIntToScalar(gHeight)/2 };
SkScalar rad = SkIntToScalar(gWidth)/2;
- SkColor colors[] = { 0xFFFF0000, sk_tool_utils::color_to_565(0xFF0044FF) };
+ SkColor colors[] = {0xFFFF0000, ToolUtils::color_to_565(0xFF0044FF)};
int index = (int)ty;
switch (index % 3) {
@@ -216,7 +216,7 @@
SkScalar y = SkIntToScalar(24);
SkScalar x = SkIntToScalar(66);
- SkFont font(sk_tool_utils::create_portable_typeface());
+ SkFont font(ToolUtils::create_portable_typeface());
for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) {
SkString str(gModeNames[kx]);
diff --git a/gm/tilemodes_scaled.cpp b/gm/tilemodes_scaled.cpp
index 9366927..28e7949 100644
--- a/gm/tilemodes_scaled.cpp
+++ b/gm/tilemodes_scaled.cpp
@@ -4,8 +4,6 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkColorFilter.h"
#include "SkMaskFilter.h"
#include "SkPath.h"
@@ -13,6 +11,8 @@
#include "SkShader.h"
#include "SkTextUtils.h"
#include "SkUTF.h"
+#include "ToolUtils.h"
+#include "gm.h"
// effects
#include "SkGradientShader.h"
@@ -78,7 +78,7 @@
void onDraw(SkCanvas* canvas) override {
SkPaint textPaint;
- SkFont font(sk_tool_utils::create_portable_typeface(), 12);
+ SkFont font(ToolUtils::create_portable_typeface(), 12);
float scale = 32.f/kPOTSize;
@@ -166,7 +166,7 @@
SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(gWidth), SkIntToScalar(gHeight)} };
SkPoint center = { SkIntToScalar(gWidth)/2, SkIntToScalar(gHeight)/2 };
SkScalar rad = SkIntToScalar(gWidth)/2;
- SkColor colors[] = { 0xFFFF0000, sk_tool_utils::color_to_565(0xFF0044FF) };
+ SkColor colors[] = {0xFFFF0000, ToolUtils::color_to_565(0xFF0044FF)};
int index = (int)ty;
switch (index % 3) {
@@ -216,7 +216,7 @@
SkScalar y = SkIntToScalar(24);
SkScalar x = SkIntToScalar(66);
- SkFont font(sk_tool_utils::create_portable_typeface());
+ SkFont font(ToolUtils::create_portable_typeface());
for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) {
SkString str(gModeNames[kx]);
diff --git a/gm/tinybitmap.cpp b/gm/tinybitmap.cpp
index 84861e5..856d288 100644
--- a/gm/tinybitmap.cpp
+++ b/gm/tinybitmap.cpp
@@ -4,12 +4,12 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
+#include "SkCanvas.h"
#include "SkColorPriv.h"
#include "SkShader.h"
-#include "SkCanvas.h"
#include "SkUTF.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace skiagm {
diff --git a/gm/typeface.cpp b/gm/typeface.cpp
index 792dab2..35aec97 100644
--- a/gm/typeface.cpp
+++ b/gm/typeface.cpp
@@ -5,8 +5,6 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "Resources.h"
#include "SkBlurTypes.h"
#include "SkCanvas.h"
@@ -17,6 +15,8 @@
#include "SkTextBlob.h"
#include "SkTypeface.h"
#include "SkTypes.h"
+#include "ToolUtils.h"
+#include "gm.h"
static void getGlyphPositions(const SkFont& font, const uint16_t glyphs[],
int count, SkScalar x, SkScalar y, SkPoint pos[]) {
diff --git a/gm/variedtext.cpp b/gm/variedtext.cpp
index c11d00e..0aea8d8 100644
--- a/gm/variedtext.cpp
+++ b/gm/variedtext.cpp
@@ -5,12 +5,12 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkPath.h"
-#include "SkTypeface.h"
#include "SkRandom.h"
+#include "SkTypeface.h"
+#include "ToolUtils.h"
+#include "gm.h"
/**
* Draws text with random parameters. The text draws each get their own clip rect. It is also
@@ -53,10 +53,10 @@
SkScalar h = SkIntToScalar(size.fHeight);
static_assert(4 == SK_ARRAY_COUNT(fTypefaces), "typeface_cnt");
- fTypefaces[0] = sk_tool_utils::create_portable_typeface("sans-serif", SkFontStyle());
- fTypefaces[1] = sk_tool_utils::create_portable_typeface("sans-serif", SkFontStyle::Bold());
- fTypefaces[2] = sk_tool_utils::create_portable_typeface("serif", SkFontStyle());
- fTypefaces[3] = sk_tool_utils::create_portable_typeface("serif", SkFontStyle::Bold());
+ fTypefaces[0] = ToolUtils::create_portable_typeface("sans-serif", SkFontStyle());
+ fTypefaces[1] = ToolUtils::create_portable_typeface("sans-serif", SkFontStyle::Bold());
+ fTypefaces[2] = ToolUtils::create_portable_typeface("serif", SkFontStyle());
+ fTypefaces[3] = ToolUtils::create_portable_typeface("serif", SkFontStyle::Bold());
SkRandom random;
for (int i = 0; i < kCnt; ++i) {
@@ -69,7 +69,7 @@
fColors[i] = random.nextU();
fColors[i] |= 0xFF000000;
- fColors[i] = sk_tool_utils::color_to_565(fColors[i]);
+ fColors[i] = ToolUtils::color_to_565(fColors[i]);
constexpr SkScalar kMinPtSize = 8.f;
constexpr SkScalar kMaxPtSize = 32.f;
diff --git a/gm/wacky_yuv_formats.cpp b/gm/wacky_yuv_formats.cpp
index dacfd35..119a335 100644
--- a/gm/wacky_yuv_formats.cpp
+++ b/gm/wacky_yuv_formats.cpp
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
+#include "ToolUtils.h"
#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkColorPriv.h"
#include "SkImageGenerator.h"
@@ -152,9 +152,9 @@
}
static SkBitmap make_bitmap(const SkPath& path, const SkTDArray<SkRect>& circles, bool opaque) {
- const SkColor kGreen = sk_tool_utils::color_to_565(SkColorSetARGB(0xFF, 178, 240, 104));
- const SkColor kBlue = sk_tool_utils::color_to_565(SkColorSetARGB(0xFF, 173, 167, 252));
- const SkColor kYellow = sk_tool_utils::color_to_565(SkColorSetARGB(0xFF, 255, 221, 117));
+ const SkColor kGreen = ToolUtils::color_to_565(SkColorSetARGB(0xFF, 178, 240, 104));
+ const SkColor kBlue = ToolUtils::color_to_565(SkColorSetARGB(0xFF, 173, 167, 252));
+ const SkColor kYellow = ToolUtils::color_to_565(SkColorSetARGB(0xFF, 255, 221, 117));
SkImageInfo ii = SkImageInfo::MakeN32(kTileWidthHeight, kTileWidthHeight, kPremul_SkAlphaType);
@@ -631,7 +631,7 @@
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kYUVColorSpaceNames) == kLastEnum_SkYUVColorSpace+1);
SkPaint paint;
- SkFont font(sk_tool_utils::create_portable_typeface(nullptr, SkFontStyle::Bold()), 16);
+ SkFont font(ToolUtils::create_portable_typeface(nullptr, SkFontStyle::Bold()), 16);
font.setEdging(SkFont::Edging::kAlias);
SkRect textRect;
@@ -656,7 +656,7 @@
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kYUVFormatNames) == kLast_YUVFormat+1);
SkPaint paint;
- SkFont font(sk_tool_utils::create_portable_typeface(nullptr, SkFontStyle::Bold()), 16);
+ SkFont font(ToolUtils::create_portable_typeface(nullptr, SkFontStyle::Bold()), 16);
font.setEdging(SkFont::Edging::kAlias);
SkRect textRect;
diff --git a/gm/windowrectangles.cpp b/gm/windowrectangles.cpp
index 2960b73..d2ec7e6 100644
--- a/gm/windowrectangles.cpp
+++ b/gm/windowrectangles.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkClipStack.h"
#include "SkRRect.h"
#include "SkTextUtils.h"
+#include "ToolUtils.h"
+#include "gm.h"
#include "GrAppliedClip.h"
#include "GrCaps.h"
@@ -38,7 +38,7 @@
};
DrawResult WindowRectanglesBaseGM::onDraw(SkCanvas* canvas, SkString* errorMsg) {
- sk_tool_utils::draw_checkerboard(canvas, 0xffffffff, 0xffc6c3c6, 25);
+ ToolUtils::draw_checkerboard(canvas, 0xffffffff, 0xffc6c3c6, 25);
SkClipStack stack;
stack.clipRect(SkRect::MakeXYWH(370.75, 80.25, 149, 100), SkMatrix::I(),
diff --git a/gm/xfermodeimagefilter.cpp b/gm/xfermodeimagefilter.cpp
index 280400a..a0d1da8 100644
--- a/gm/xfermodeimagefilter.cpp
+++ b/gm/xfermodeimagefilter.cpp
@@ -5,13 +5,13 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkArithmeticImageFilter.h"
#include "SkImage.h"
#include "SkImageSource.h"
#include "SkOffsetImageFilter.h"
#include "SkXfermodeImageFilter.h"
+#include "ToolUtils.h"
+#include "gm.h"
#define WIDTH 600
#define HEIGHT 700
@@ -35,13 +35,10 @@
}
void onOnceBeforeDraw() override {
- fBitmap = sk_tool_utils::create_string_bitmap(80, 80, 0xD000D000, 15, 65, 96, "e");
+ fBitmap = ToolUtils::create_string_bitmap(80, 80, 0xD000D000, 15, 65, 96, "e");
fCheckerboard = SkImage::MakeFromBitmap(
- sk_tool_utils::create_checkerboard_bitmap(80, 80,
- 0xFFA0A0A0,
- 0xFF404040,
- 8));
+ ToolUtils::create_checkerboard_bitmap(80, 80, 0xFFA0A0A0, 0xFF404040, 8));
}
void onDraw(SkCanvas* canvas) override {
diff --git a/gm/xfermodes.cpp b/gm/xfermodes.cpp
index 3af85d2..239555b 100644
--- a/gm/xfermodes.cpp
+++ b/gm/xfermodes.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkBitmap.h"
#include "SkShader.h"
#include "SkTextUtils.h"
+#include "ToolUtils.h"
+#include "gm.h"
enum SrcType {
//! A WxH image with a rectangle in the lower right.
@@ -88,7 +88,7 @@
{
SkCanvas c(*src);
- p.setColor(sk_tool_utils::color_to_565(0xFFFFCC44));
+ p.setColor(ToolUtils::color_to_565(0xFFFFCC44));
r.set(0, 0, ww*3/4, hh*3/4);
c.drawOval(r, p);
}
@@ -98,7 +98,7 @@
{
SkCanvas c(*dst);
- p.setColor(sk_tool_utils::color_to_565(0xFF66AAFF));
+ p.setColor(ToolUtils::color_to_565(0xFF66AAFF));
r.set(ww/3, hh/3, ww*19/20, hh*19/20);
c.drawRect(r, p);
}
@@ -145,11 +145,11 @@
case kQuarterClear_SrcType: {
SkScalar halfW = SkIntToScalar(W) / 2;
SkScalar halfH = SkIntToScalar(H) / 2;
- p.setColor(sk_tool_utils::color_to_565(0xFF66AAFF));
+ p.setColor(ToolUtils::color_to_565(0xFF66AAFF));
SkRect r = SkRect::MakeXYWH(x + halfW, y, halfW,
SkIntToScalar(H));
canvas->drawRect(r, p);
- p.setColor(sk_tool_utils::color_to_565(0xFFAA66FF));
+ p.setColor(ToolUtils::color_to_565(0xFFAA66FF));
r = SkRect::MakeXYWH(x, y + halfH, SkIntToScalar(W), halfH);
canvas->drawRect(r, p);
break;
@@ -168,7 +168,7 @@
SkScalar h = SkIntToScalar(H);
SkRect r = SkRect::MakeXYWH(x + w / 3, y + h / 3,
w * 37 / 60, h * 37 / 60);
- p.setColor(sk_tool_utils::color_to_565(0xFF66AAFF));
+ p.setColor(ToolUtils::color_to_565(0xFF66AAFF));
canvas->drawRect(r, p);
break;
}
@@ -228,7 +228,7 @@
SkPaint labelP;
labelP.setAntiAlias(true);
- SkFont font(sk_tool_utils::create_portable_typeface());
+ SkFont font(ToolUtils::create_portable_typeface());
const int W = 5;
diff --git a/gm/xfermodes2.cpp b/gm/xfermodes2.cpp
index 26de6fe..ebc0db1 100644
--- a/gm/xfermodes2.cpp
+++ b/gm/xfermodes2.cpp
@@ -4,13 +4,13 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
#include "SkBitmap.h"
-#include "SkShader.h"
#include "SkBlendModePriv.h"
#include "SkColorPriv.h"
+#include "SkShader.h"
#include "SkTextUtils.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace skiagm {
@@ -33,7 +33,7 @@
const SkScalar w = SkIntToScalar(kSize);
const SkScalar h = SkIntToScalar(kSize);
- SkFont font(sk_tool_utils::create_portable_typeface());
+ SkFont font(ToolUtils::create_portable_typeface());
const int W = 6;
diff --git a/gm/xfermodes3.cpp b/gm/xfermodes3.cpp
index 86aee17..ec0bba9 100644
--- a/gm/xfermodes3.cpp
+++ b/gm/xfermodes3.cpp
@@ -5,15 +5,15 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "sk_tool_utils.h"
+#include "GrContext.h"
#include "SkBitmap.h"
-#include "SkGradientShader.h"
-#include "SkSurface.h"
#include "SkBlendModePriv.h"
#include "SkColorPriv.h"
+#include "SkGradientShader.h"
+#include "SkSurface.h"
#include "SkTextUtils.h"
-#include "GrContext.h"
+#include "ToolUtils.h"
+#include "gm.h"
namespace skiagm {
@@ -23,7 +23,7 @@
*/
class Xfermodes3GM : public GM {
public:
- Xfermodes3GM() { this->setBGColor(sk_tool_utils::color_to_565(0xFF70D0E0)); }
+ Xfermodes3GM() { this->setBGColor(ToolUtils::color_to_565(0xFF70D0E0)); }
protected:
SkString onShortName() override {
@@ -37,7 +37,7 @@
void onDraw(SkCanvas* canvas) override {
canvas->translate(SkIntToScalar(10), SkIntToScalar(20));
- SkFont font(sk_tool_utils::create_portable_typeface());
+ SkFont font(ToolUtils::create_portable_typeface());
SkPaint labelP;
constexpr SkColor kSolidColors[] = {
diff --git a/include/core/SkImageEncoder.h b/include/core/SkImageEncoder.h
index b01771a..e44b3eb 100644
--- a/include/core/SkImageEncoder.h
+++ b/include/core/SkImageEncoder.h
@@ -31,7 +31,7 @@
* it will use lossy.
*
* For examples of encoding an image to a file or to a block of memory,
- * see tools/sk_tool_utils.h.
+ * see tools/ToolUtils.h.
*/
SK_API bool SkEncodeImage(SkWStream* dst, const SkPixmap& src,
SkEncodedImageFormat format, int quality);
diff --git a/modules/skottie/fuzz/FuzzSkottieJSON.cpp b/modules/skottie/fuzz/FuzzSkottieJSON.cpp
index e765c0e..6c93bce 100644
--- a/modules/skottie/fuzz/FuzzSkottieJSON.cpp
+++ b/modules/skottie/fuzz/FuzzSkottieJSON.cpp
@@ -22,7 +22,7 @@
#if defined(IS_FUZZING_WITH_LIBFUZZER)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- gSkFontMgr_DefaultFactory = &sk_tool_utils::MakePortableFontMgr;
+ gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr;
auto bytes = SkData::MakeWithoutCopy(data, size);
FuzzSkottieJSON(bytes);
return 0;
diff --git a/public.bzl b/public.bzl
index 36757d3..abe0045 100644
--- a/public.bzl
+++ b/public.bzl
@@ -464,7 +464,7 @@
"tools/fonts/TestSVGTypeface.h",
"tools/fonts/TestTypeface.cpp",
"tools/fonts/TestTypeface.h",
- "tools/fonts/sk_tool_utils_font.cpp",
+ "tools/fonts/ToolUtilsFont.cpp",
"tools/fonts/test_font_monospace.inc",
"tools/fonts/test_font_sans_serif.inc",
"tools/fonts/test_font_serif.inc",
@@ -474,8 +474,8 @@
"tools/random_parse_path.cpp",
"tools/random_parse_path.h",
"tools/sk_pixel_iter.h",
- "tools/sk_tool_utils.cpp",
- "tools/sk_tool_utils.h",
+ "tools/ToolUtils.cpp",
+ "tools/ToolUtils.h",
"tools/timer/*.cpp",
"tools/timer/*.h",
"tools/trace/*.cpp",
diff --git a/samplecode/SampleAndroidShadows.cpp b/samplecode/SampleAndroidShadows.cpp
index fff2f94..b367ae9 100644
--- a/samplecode/SampleAndroidShadows.cpp
+++ b/samplecode/SampleAndroidShadows.cpp
@@ -9,15 +9,15 @@
#include "SkAnimTimer.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
-#include "SkColorFilter.h"
#include "SkCamera.h"
#include "SkCanvas.h"
+#include "SkColorFilter.h"
#include "SkPath.h"
#include "SkPathOps.h"
#include "SkPoint3.h"
#include "SkShadowUtils.h"
#include "SkUTF.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
////////////////////////////////////////////////////////////////////////////
diff --git a/samplecode/SampleChineseFling.cpp b/samplecode/SampleChineseFling.cpp
index b123942..d5e2479 100644
--- a/samplecode/SampleChineseFling.cpp
+++ b/samplecode/SampleChineseFling.cpp
@@ -7,7 +7,7 @@
#include "Resources.h"
#include "Sample.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
#include "SkCanvas.h"
#include "SkFontMetrics.h"
@@ -92,8 +92,13 @@
this->createRandomWord(glyphs);
SkTextBlobBuilder builder;
- sk_tool_utils::add_to_text_blob_w_len(&builder, (const char*) glyphs, kWordLength*4,
- kUTF32_SkTextEncoding, font, 0, 0);
+ ToolUtils::add_to_text_blob_w_len(&builder,
+ (const char*)glyphs,
+ kWordLength * 4,
+ kUTF32_SkTextEncoding,
+ font,
+ 0,
+ 0);
fBlobs.emplace_back(builder.make());
}
@@ -216,9 +221,13 @@
auto currentLineLength = SkTMin(45, paragraphLength - 45);
this->createRandomLine(glyphs, currentLineLength);
- sk_tool_utils::add_to_text_blob_w_len(&builder, (const char*) glyphs,
- currentLineLength*4, kUTF32_SkTextEncoding,
- font, 0, y);
+ ToolUtils::add_to_text_blob_w_len(&builder,
+ (const char*)glyphs,
+ currentLineLength * 4,
+ kUTF32_SkTextEncoding,
+ font,
+ 0,
+ y);
y += fMetrics.fDescent - fMetrics.fAscent + fMetrics.fLeading;
paragraphLength -= 45;
}
diff --git a/samplecode/SampleColorFilter.cpp b/samplecode/SampleColorFilter.cpp
index 8a44fc4..d95aad4 100644
--- a/samplecode/SampleColorFilter.cpp
+++ b/samplecode/SampleColorFilter.cpp
@@ -4,12 +4,12 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "sk_tool_utils.h"
#include "Sample.h"
#include "SkCanvas.h"
#include "SkColorFilter.h"
#include "SkPaint.h"
#include "SkShader.h"
+#include "ToolUtils.h"
static int inflate5To8(int x) {
return (x << 3) | (x >> 2);
@@ -116,8 +116,7 @@
protected:
void onOnceBeforeDraw() override {
fBitmap = createBitmap(N);
- fShader = sk_tool_utils::create_checkerboard_shader(
- 0xFFCCCCCC, 0xFFFFFFFF, 12);
+ fShader = ToolUtils::create_checkerboard_shader(0xFFCCCCCC, 0xFFFFFFFF, 12);
if (false) { // avoid bit rot, suppress warning
test_5bits();
diff --git a/samplecode/SampleFatBits.cpp b/samplecode/SampleFatBits.cpp
index 1e988e7..5382af6 100644
--- a/samplecode/SampleFatBits.cpp
+++ b/samplecode/SampleFatBits.cpp
@@ -23,7 +23,7 @@
#include "SkString.h"
#include "SkSurface.h"
#include "SkTypes.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
class SkEvent;
@@ -105,7 +105,7 @@
fBounds.set(0, 0, SkIntToScalar(width * zoom), SkIntToScalar(height * zoom));
fMatrix.setScale(SkIntToScalar(zoom), SkIntToScalar(zoom));
fInverse.setScale(SK_Scalar1 / zoom, SK_Scalar1 / zoom);
- fShader0 = sk_tool_utils::create_checkerboard_shader(0xFFDDDDDD, 0xFFFFFFFF, zoom);
+ fShader0 = ToolUtils::create_checkerboard_shader(0xFFDDDDDD, 0xFFFFFFFF, zoom);
fShader1 = SkShader::MakeColorShader(SK_ColorWHITE);
fShader = fShader0;
diff --git a/samplecode/SampleGlyphTransform.cpp b/samplecode/SampleGlyphTransform.cpp
index ff42251..ecd160c 100644
--- a/samplecode/SampleGlyphTransform.cpp
+++ b/samplecode/SampleGlyphTransform.cpp
@@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
#include "Sample.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
#include "SkAnimTimer.h"
#include "SkCanvas.h"
@@ -26,8 +26,8 @@
protected:
void onOnceBeforeDraw() override {
- fEmojiFont.fTypeface = sk_tool_utils::emoji_typeface();
- fEmojiFont.fText = sk_tool_utils::emoji_sample_text();
+ fEmojiFont.fTypeface = ToolUtils::emoji_typeface();
+ fEmojiFont.fText = ToolUtils::emoji_sample_text();
}
bool onQuery(Sample::Event* evt) override {
diff --git a/samplecode/SampleLitAtlas.cpp b/samplecode/SampleLitAtlas.cpp
index 534b66b..13a2656 100644
--- a/samplecode/SampleLitAtlas.cpp
+++ b/samplecode/SampleLitAtlas.cpp
@@ -16,7 +16,7 @@
#include "SkRandom.h"
#include "SkRSXform.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
// A crude normal mapped asteroids-like sample
class DrawLitAtlasDrawable : public SkDrawable {
@@ -251,9 +251,8 @@
}
}
- sk_tool_utils::create_hemi_normal_map(&atlas,
- SkIRect::MakeXYWH(kNormXOff, kBigYOff,
- kBigSize, kBigSize));
+ ToolUtils::create_hemi_normal_map(
+ &atlas, SkIRect::MakeXYWH(kNormXOff, kBigYOff, kBigSize, kBigSize));
}
// medium asteroid
@@ -264,9 +263,8 @@
}
}
- sk_tool_utils::create_frustum_normal_map(&atlas,
- SkIRect::MakeXYWH(kNormXOff, kMedYOff,
- kMedSize, kMedSize));
+ ToolUtils::create_frustum_normal_map(
+ &atlas, SkIRect::MakeXYWH(kNormXOff, kMedYOff, kMedSize, kMedSize));
}
// small asteroid
@@ -285,9 +283,8 @@
}
}
- sk_tool_utils::create_hemi_normal_map(&atlas,
- SkIRect::MakeXYWH(kNormXOff, kSmYOff,
- kSmSize, kSmSize));
+ ToolUtils::create_hemi_normal_map(
+ &atlas, SkIRect::MakeXYWH(kNormXOff, kSmYOff, kSmSize, kSmSize));
}
// ship
@@ -314,9 +311,8 @@
}
}
- sk_tool_utils::create_tetra_normal_map(&atlas,
- SkIRect::MakeXYWH(kNormXOff, kShipYOff,
- kMedSize, kMedSize));
+ ToolUtils::create_tetra_normal_map(
+ &atlas, SkIRect::MakeXYWH(kNormXOff, kShipYOff, kMedSize, kMedSize));
}
return atlas;
diff --git a/samplecode/SamplePathText.cpp b/samplecode/SamplePathText.cpp
index 8f4b8a1..e9b2be3 100644
--- a/samplecode/SamplePathText.cpp
+++ b/samplecode/SamplePathText.cpp
@@ -14,7 +14,7 @@
#include "SkStrike.h"
#include "SkStrikeCache.h"
#include "SkTaskGroup.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
// Static text from paths.
@@ -106,7 +106,7 @@
Glyph fGlyphs[kNumPaths];
SkRandom fRand{25};
- SkPath fClipPath = sk_tool_utils::make_star(SkRect{0,0,1,1}, 11, 3);
+ SkPath fClipPath = ToolUtils::make_star(SkRect{0, 0, 1, 1}, 11, 3);
bool fDoClip = false;
typedef Sample INHERITED;
diff --git a/samplecode/SampleQuadStroker.cpp b/samplecode/SampleQuadStroker.cpp
index 10e9bbc..6122f4b 100644
--- a/samplecode/SampleQuadStroker.cpp
+++ b/samplecode/SampleQuadStroker.cpp
@@ -30,7 +30,7 @@
#include "SkTemplates.h"
#include "SkTextUtils.h"
#include "SkTypes.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
#include <cfloat>
@@ -282,7 +282,7 @@
fBounds.set(0, 0, SkIntToScalar(width * zoom), SkIntToScalar(height * zoom));
fMatrix.setScale(SkIntToScalar(zoom), SkIntToScalar(zoom));
fInverse.setScale(SK_Scalar1 / zoom, SK_Scalar1 / zoom);
- fShader = sk_tool_utils::create_checkerboard_shader(0xFFCCCCCC, 0xFFFFFFFF, zoom);
+ fShader = ToolUtils::create_checkerboard_shader(0xFFCCCCCC, 0xFFFFFFFF, zoom);
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
fMinSurface = SkSurface::MakeRaster(info);
diff --git a/samplecode/SampleShadowUtils.cpp b/samplecode/SampleShadowUtils.cpp
index c6ae470..5389c38 100644
--- a/samplecode/SampleShadowUtils.cpp
+++ b/samplecode/SampleShadowUtils.cpp
@@ -9,15 +9,15 @@
#include "SkAnimTimer.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
-#include "SkColorFilter.h"
#include "SkCamera.h"
#include "SkCanvas.h"
+#include "SkColorFilter.h"
#include "SkPath.h"
#include "SkPathOps.h"
#include "SkPoint3.h"
#include "SkShadowUtils.h"
#include "SkUTF.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
////////////////////////////////////////////////////////////////////////////
diff --git a/samplecode/SampleSlides.cpp b/samplecode/SampleSlides.cpp
index f581b80..bd2967b 100644
--- a/samplecode/SampleSlides.cpp
+++ b/samplecode/SampleSlides.cpp
@@ -14,7 +14,7 @@
#include "SkPaint.h"
#include "SkVertices.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
#define BG_COLOR 0xFFDDDDDD
@@ -429,7 +429,7 @@
canvas.restore();
SkString str;
str.printf("/skimages/slide_" SK_SIZE_T_SPECIFIER ".png", i);
- sk_tool_utils::EncodeImageToFile(str.c_str(), bm, SkEncodedImageFormat::kPNG, 100);
+ ToolUtils::EncodeImageToFile(str.c_str(), bm, SkEncodedImageFormat::kPNG, 100);
}
this->setBGColor(BG_COLOR);
}
diff --git a/samplecode/SampleUnpremul.cpp b/samplecode/SampleUnpremul.cpp
index da7e42d..e7278ff 100644
--- a/samplecode/SampleUnpremul.cpp
+++ b/samplecode/SampleUnpremul.cpp
@@ -5,12 +5,11 @@
* found in the LICENSE file.
*/
-#include "sk_tool_utils.h"
#include "DecodeFile.h"
#include "Resources.h"
#include "Sample.h"
-#include "SkBlurMask.h"
#include "SkBlurDrawLooper.h"
+#include "SkBlurMask.h"
#include "SkCanvas.h"
#include "SkColorPriv.h"
#include "SkOSFile.h"
@@ -19,6 +18,7 @@
#include "SkString.h"
#include "SkTypes.h"
#include "SkUTF.h"
+#include "ToolUtils.h"
/**
* Interprets c as an unpremultiplied color, and returns the
@@ -69,7 +69,7 @@
}
void onDrawBackground(SkCanvas* canvas) override {
- sk_tool_utils::draw_checkerboard(canvas, 0xFFCCCCCC, 0xFFFFFFFF, 12);
+ ToolUtils::draw_checkerboard(canvas, 0xFFCCCCCC, 0xFFFFFFFF, 12);
}
void onDrawContent(SkCanvas* canvas) override {
diff --git a/site/dev/testing/fonts.md b/site/dev/testing/fonts.md
index cb2a9e5..05fdf1c 100644
--- a/site/dev/testing/fonts.md
+++ b/site/dev/testing/fonts.md
@@ -18,14 +18,14 @@
portable typeface on the paint, call:
~~~~
-sk_tool_utils::set_portable_typeface(SkPaint* , const char* name = nullptr,
+ToolUtils::set_portable_typeface(SkPaint* , const char* name = nullptr,
SkFontStyle style = SkFontStyle());
~~~~
To create a portable typeface, use:
~~~~
-SkTypeface* typeface = sk_tool_utils::create_portable_typeface(const char* name,
+SkTypeface* typeface = ToolUtils::create_portable_typeface(const char* name,
SkFontStyle style);
~~~~
diff --git a/tests/AnimatedImageTest.cpp b/tests/AnimatedImageTest.cpp
index cb4e670..93292d1 100644
--- a/tests/AnimatedImageTest.cpp
+++ b/tests/AnimatedImageTest.cpp
@@ -22,7 +22,7 @@
#include "SkTypes.h"
#include "SkUnPreMultiply.h"
#include "Test.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
#include <algorithm>
#include <memory>
@@ -207,7 +207,7 @@
bm.eraseColor(0);
} else {
const SkBitmap& priorFrame = frames[options.fPriorFrame];
- if (!sk_tool_utils::copy_to(&bm, priorFrame.colorType(), priorFrame)) {
+ if (!ToolUtils::copy_to(&bm, priorFrame.colorType(), priorFrame)) {
ERRORF(r, "Failed to copy %s frame %i", file, options.fPriorFrame);
options.fPriorFrame = SkCodec::kNoFrame;
}
diff --git a/tests/BitmapCopyTest.cpp b/tests/BitmapCopyTest.cpp
index c2a8f25..5b02491 100644
--- a/tests/BitmapCopyTest.cpp
+++ b/tests/BitmapCopyTest.cpp
@@ -15,7 +15,7 @@
#include "SkSize.h"
#include "SkTypes.h"
#include "Test.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
static void init_src(const SkBitmap& bitmap) {
if (bitmap.getPixels()) {
@@ -102,7 +102,7 @@
// Test copying an extracted subset.
for (size_t j = 0; j < SK_ARRAY_COUNT(gPairs); j++) {
SkBitmap copy;
- bool success = sk_tool_utils::copy_to(©, gPairs[j].fColorType, subset);
+ bool success = ToolUtils::copy_to(©, gPairs[j].fColorType, subset);
if (!success) {
// Skip checking that success matches fValid, which is redundant
// with the code below.
diff --git a/tests/BitmapTest.cpp b/tests/BitmapTest.cpp
index d1462f8..be5b972 100644
--- a/tests/BitmapTest.cpp
+++ b/tests/BitmapTest.cpp
@@ -15,7 +15,7 @@
#include "SkRefCnt.h"
#include "SkTypes.h"
#include "Test.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
static void test_peekpixels(skiatest::Reporter* reporter) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10);
@@ -143,7 +143,7 @@
};
for (SkColorType ct : colorTypes) {
SkBitmap copy;
- if (!sk_tool_utils::copy_to(©, ct, source)) {
+ if (!ToolUtils::copy_to(©, ct, source)) {
ERRORF(r, "SkBitmap::copy failed %d", (int)ct);
continue;
}
diff --git a/tests/BlurTest.cpp b/tests/BlurTest.cpp
index 36723f6..963f236 100644
--- a/tests/BlurTest.cpp
+++ b/tests/BlurTest.cpp
@@ -686,7 +686,7 @@
paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, sigma));
surf->getCanvas()->drawRect(r, paint);
- sk_tool_utils::PixelIter iter(surf.get());
+ ToolUtils::PixelIter iter(surf.get());
SkIPoint loc;
while (const SkPMColor* p = (const SkPMColor*)iter.next(&loc)) {
if (ir.contains(loc.fX, loc.fY)) {
diff --git a/tests/CachedDecodingPixelRefTest.cpp b/tests/CachedDecodingPixelRefTest.cpp
index 95f9d8d..a09fe62 100644
--- a/tests/CachedDecodingPixelRefTest.cpp
+++ b/tests/CachedDecodingPixelRefTest.cpp
@@ -17,7 +17,7 @@
#include "SkTypes.h"
#include "SkUtils.h"
#include "Test.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
#include <utility>
@@ -31,7 +31,7 @@
static int Width() { return 10; }
static int Height() { return 10; }
// value choosen so that there is no loss when converting to to RGB565 and back
- static SkColor Color() { return sk_tool_utils::color_to_565(0xffaabbcc); }
+ static SkColor Color() { return ToolUtils::color_to_565(0xffaabbcc); }
static SkPMColor PMColor() { return SkPreMultiplyColor(Color()); }
TestImageGenerator(TestType type, skiatest::Reporter* reporter,
diff --git a/tests/CodecAnimTest.cpp b/tests/CodecAnimTest.cpp
index d3f385e..ec4ca18 100644
--- a/tests/CodecAnimTest.cpp
+++ b/tests/CodecAnimTest.cpp
@@ -20,7 +20,7 @@
#include "SkString.h"
#include "SkTypes.h"
#include "Test.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
#include <cstring>
#include <memory>
@@ -317,8 +317,8 @@
bm->allocPixels(decodeInfo);
if (cachedIndex != SkCodec::kNoFrame) {
// First copy the pixels from the cached frame
- const bool success = sk_tool_utils::copy_to(bm, kN32_SkColorType,
- cachedFrames[cachedIndex]);
+ const bool success =
+ ToolUtils::copy_to(bm, kN32_SkColorType, cachedFrames[cachedIndex]);
REPORTER_ASSERT(r, success);
}
SkCodec::Options opts;
diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp
index 8c918a8..fbbeb4a 100644
--- a/tests/CodecTest.cpp
+++ b/tests/CodecTest.cpp
@@ -41,8 +41,8 @@
#include "SkUnPreMultiply.h"
#include "SkWebpEncoder.h"
#include "Test.h"
+#include "ToolUtils.h"
#include "png.h"
-#include "sk_tool_utils.h"
#include <setjmp.h>
#include <cstring>
@@ -818,7 +818,7 @@
if (decodedBm.colorType() != bm.colorType()) {
SkBitmap tmp;
- bool success = sk_tool_utils::copy_to(&tmp, bm.colorType(), decodedBm);
+ bool success = ToolUtils::copy_to(&tmp, bm.colorType(), decodedBm);
REPORTER_ASSERT(r, success);
if (!success) {
return;
diff --git a/tests/EncodedInfoTest.cpp b/tests/EncodedInfoTest.cpp
index a8b7437..3babbd0 100644
--- a/tests/EncodedInfoTest.cpp
+++ b/tests/EncodedInfoTest.cpp
@@ -7,7 +7,7 @@
#include "Resources.h"
#include "Test.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
#include "SkBitmap.h"
#include "SkCodec.h"
@@ -38,5 +38,5 @@
result = codec->getPixels(bm2.pixmap());
REPORTER_ASSERT(r, result == SkCodec::kSuccess);
- REPORTER_ASSERT(r, sk_tool_utils::equal_pixels(bm.pixmap(), bm2.pixmap()));
+ REPORTER_ASSERT(r, ToolUtils::equal_pixels(bm.pixmap(), bm2.pixmap()));
}
diff --git a/tests/GrCCPRTest.cpp b/tests/GrCCPRTest.cpp
index f65bab6..7cd8f10 100644
--- a/tests/GrCCPRTest.cpp
+++ b/tests/GrCCPRTest.cpp
@@ -11,8 +11,8 @@
#include "GrClip.h"
#include "GrContextPriv.h"
#include "GrDrawingManager.h"
-#include "GrPathRenderer.h"
#include "GrPaint.h"
+#include "GrPathRenderer.h"
#include "GrRecordingContext.h"
#include "GrRecordingContextPriv.h"
#include "GrRenderTargetContext.h"
@@ -23,9 +23,9 @@
#include "SkMatrix.h"
#include "SkPathPriv.h"
#include "SkRect.h"
-#include "sk_tool_utils.h"
-#include "ccpr/GrCoverageCountingPathRenderer.h"
+#include "ToolUtils.h"
#include "ccpr/GrCCPathCache.h"
+#include "ccpr/GrCoverageCountingPathRenderer.h"
#include "mock/GrMockTypes.h"
#include <cmath>
@@ -355,7 +355,7 @@
do {
step = primes[rand.nextU() % SK_ARRAY_COUNT(primes)];
} while (step == numPts);
- fPaths[i] = sk_tool_utils::make_star(SkRect::MakeLTRB(0,0,1,1), numPts, step);
+ fPaths[i] = ToolUtils::make_star(SkRect::MakeLTRB(0, 0, 1, 1), numPts, step);
}
}
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index 26be9ee..10a359d 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "Resources.h"
#include "SkArithmeticImageFilter.h"
#include "SkBitmap.h"
#include "SkBlurImageFilter.h"
@@ -38,9 +39,8 @@
#include "SkTableColorFilter.h"
#include "SkTileImageFilter.h"
#include "SkXfermodeImageFilter.h"
-#include "Resources.h"
#include "Test.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
#include "GrCaps.h"
#include "GrContext.h"
@@ -713,7 +713,7 @@
SkPaint textPaint;
textPaint.setColor(SK_ColorWHITE);
- SkFont font(sk_tool_utils::create_portable_typeface(), height);
+ SkFont font(ToolUtils::create_portable_typeface(), height);
const char* text = "ABC";
const SkScalar yPos = SkIntToScalar(height);
@@ -751,7 +751,7 @@
}
}
- if (!sk_tool_utils::equal_pixels(untiledResult, tiledResult)) {
+ if (!ToolUtils::equal_pixels(untiledResult, tiledResult)) {
REPORTER_ASSERT(reporter, false, filters.getName(i));
break;
}
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index 551c868..e97d36d 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -29,8 +29,8 @@
#include "Test.h"
#include "Resources.h"
+#include "ToolUtils.h"
#include "sk_pixel_iter.h"
-#include "sk_tool_utils.h"
#include "GrContextPriv.h"
#include "GrContextThreadSafeProxy.h"
@@ -1365,7 +1365,7 @@
surf->getCanvas()->drawImageRect(img, dst, &paint);
// we should draw nothing
- sk_tool_utils::PixelIter iter(surf.get());
+ ToolUtils::PixelIter iter(surf.get());
while (void* addr = iter.next()) {
REPORTER_ASSERT(reporter, *(SkPMColor*)addr == 0);
}
diff --git a/tests/IncrTopoSortTest.cpp b/tests/IncrTopoSortTest.cpp
index 849c20a..a950785 100644
--- a/tests/IncrTopoSortTest.cpp
+++ b/tests/IncrTopoSortTest.cpp
@@ -9,7 +9,7 @@
#include "SkTSort.h"
#include "Test.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
// A node in the graph. This corresponds to an opList in the MDB world.
class Node : public SkRefCnt {
diff --git a/tests/OnFlushCallbackTest.cpp b/tests/OnFlushCallbackTest.cpp
index d20458e..4f974408 100644
--- a/tests/OnFlushCallbackTest.cpp
+++ b/tests/OnFlushCallbackTest.cpp
@@ -472,12 +472,12 @@
// Enable this if you want to debug the final draws w/o having the atlasCallback create the
// atlas
#if 0
-#include "SkImageEncoder.h"
#include "SkGrPriv.h"
-#include "sk_tool_utils.h"
+#include "SkImageEncoder.h"
+#include "ToolUtils.h"
static void save_bm(const SkBitmap& bm, const char name[]) {
- bool result = sk_tool_utils::EncodeImageToFile(name, bm, SkEncodedImageFormat::kPNG, 100);
+ bool result = ToolUtils::EncodeImageToFile(name, bm, SkEncodedImageFormat::kPNG, 100);
SkASSERT(result);
}
diff --git a/tests/PDFDocumentTest.cpp b/tests/PDFDocumentTest.cpp
index 95821e8..c3d6ed2 100644
--- a/tests/PDFDocumentTest.cpp
+++ b/tests/PDFDocumentTest.cpp
@@ -14,7 +14,7 @@
#include "SkPDFDocument.h"
#include "SkStream.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
static void test_empty(skiatest::Reporter* reporter) {
SkDynamicMemoryWStream stream;
diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp
index f7ea80a..d89cf03 100644
--- a/tests/PDFPrimitivesTest.cpp
+++ b/tests/PDFPrimitivesTest.cpp
@@ -32,7 +32,7 @@
#include "SkStream.h"
#include "SkTo.h"
#include "SkTypes.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
#include <cstdlib>
#include <cmath>
@@ -314,8 +314,7 @@
REPORTER_ASSERT(reporter,
!SkPDFFont::CanEmbedTypeface(noEmbedTypeface.get(), &doc));
}
- sk_sp<SkTypeface> portableTypeface(
- sk_tool_utils::create_portable_typeface(nullptr, SkFontStyle()));
+ sk_sp<SkTypeface> portableTypeface(ToolUtils::create_portable_typeface(nullptr, SkFontStyle()));
REPORTER_ASSERT(reporter,
SkPDFFont::CanEmbedTypeface(portableTypeface.get(), &doc));
}
diff --git a/tests/PathOpsConicIntersectionTest.cpp b/tests/PathOpsConicIntersectionTest.cpp
index 1de1583..7389556 100644
--- a/tests/PathOpsConicIntersectionTest.cpp
+++ b/tests/PathOpsConicIntersectionTest.cpp
@@ -110,8 +110,7 @@
canvas.drawPath(path, paint);
SkString filename("c:\\Users\\caryclark\\Documents\\");
filename.appendf("%s.png", name);
- sk_tool_utils::EncodeImageToFile(filename.c_str(), bitmap,
- SkEncodedImageFormat::kPNG, 100);
+ ToolUtils::EncodeImageToFile(filename.c_str(), bitmap, SkEncodedImageFormat::kPNG, 100);
}
static void writeDPng(const SkDConic& dC, const char* name) {
@@ -152,8 +151,7 @@
canvas.drawPath(path, paint);
SkString filename("c:\\Users\\caryclark\\Documents\\");
filename.appendf("%s.png", name);
- sk_tool_utils::EncodeImageToFile(filename.c_str(), bitmap,
- SkEncodedImageFormat::kPNG, 100);
+ ToolUtils::EncodeImageToFile(filename.c_str(), bitmap, SkEncodedImageFormat::kPNG, 100);
}
#endif
@@ -290,7 +288,7 @@
}
SkString filename("c:\\Users\\caryclark\\Documents\\");
filename.appendf("f%d.png", index);
- sk_tool_utils::EncodeImageToFile(filename.c_str(), bitmap, SkEncodedImageFormat::kPNG, 100);
+ ToolUtils::EncodeImageToFile(filename.c_str(), bitmap, SkEncodedImageFormat::kPNG, 100);
}
}
#endif
diff --git a/tests/PremulAlphaRoundTripTest.cpp b/tests/PremulAlphaRoundTripTest.cpp
index bc92bd8..e56f612 100644
--- a/tests/PremulAlphaRoundTripTest.cpp
+++ b/tests/PremulAlphaRoundTripTest.cpp
@@ -8,7 +8,7 @@
#include "SkCanvas.h"
#include "SkSurface.h"
#include "Test.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
#include "GrContext.h"
@@ -74,8 +74,8 @@
readBmp2.eraseColor(0);
surf->readPixels(readBmp1, 0, 0);
- sk_tool_utils::write_pixels(surf, readBmp1, 0, 0, gUnpremul[upmaIdx].fColorType,
- kUnpremul_SkAlphaType);
+ ToolUtils::write_pixels(
+ surf, readBmp1, 0, 0, gUnpremul[upmaIdx].fColorType, kUnpremul_SkAlphaType);
surf->readPixels(readBmp2, 0, 0);
bool success = true;
diff --git a/tests/SerialProcsTest.cpp b/tests/SerialProcsTest.cpp
index 6129e0a..6ed362e 100644
--- a/tests/SerialProcsTest.cpp
+++ b/tests/SerialProcsTest.cpp
@@ -5,15 +5,15 @@
* found in the LICENSE file.
*/
-#include "Test.h"
#include "Resources.h"
-#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkImageSource.h"
#include "SkPicture.h"
#include "SkPictureRecorder.h"
#include "SkSerialProcs.h"
#include "SkSurface.h"
+#include "Test.h"
+#include "ToolUtils.h"
static sk_sp<SkImage> picture_to_image(sk_sp<SkPicture> pic) {
SkIRect r = pic->cullRect().round();
@@ -77,7 +77,7 @@
REPORTER_ASSERT(reporter, data);
auto dst_img = picture_to_image(new_pic);
- REPORTER_ASSERT(reporter, sk_tool_utils::equal_pixels(src_img.get(), dst_img.get()));
+ REPORTER_ASSERT(reporter, ToolUtils::equal_pixels(src_img.get(), dst_img.get()));
}
}
diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp
index 6712575..4fee4e4 100644
--- a/tests/SerializationTest.cpp
+++ b/tests/SerializationTest.cpp
@@ -19,9 +19,9 @@
#include "SkMatrixPriv.h"
#include "SkNormalSource.h"
#include "SkOSFile.h"
-#include "SkReadBuffer.h"
#include "SkPicturePriv.h"
#include "SkPictureRecorder.h"
+#include "SkReadBuffer.h"
#include "SkShaderBase.h"
#include "SkTableColorFilter.h"
#include "SkTemplates.h"
@@ -29,8 +29,8 @@
#include "SkTypeface.h"
#include "SkWriteBuffer.h"
#include "SkXfermodeImageFilter.h"
-#include "sk_tool_utils.h"
#include "Test.h"
+#include "ToolUtils.h"
static const uint32_t kArraySize = 64;
static const int kBitmapSize = 256;
@@ -588,11 +588,8 @@
sk_sp<SkLights> fLights = builder.finish();
- SkBitmap diffuse = sk_tool_utils::create_checkerboard_bitmap(
- kTexSize, kTexSize,
- 0x00000000,
- sk_tool_utils::color_to_565(0xFF804020),
- 8);
+ SkBitmap diffuse = ToolUtils::create_checkerboard_bitmap(
+ kTexSize, kTexSize, 0x00000000, ToolUtils::color_to_565(0xFF804020), 8);
SkRect bitmapBounds = SkRect::MakeIWH(diffuse.width(), diffuse.height());
@@ -605,7 +602,7 @@
SkBitmap normals;
normals.allocN32Pixels(kTexSize, kTexSize);
- sk_tool_utils::create_frustum_normal_map(&normals, SkIRect::MakeWH(kTexSize, kTexSize));
+ ToolUtils::create_frustum_normal_map(&normals, SkIRect::MakeWH(kTexSize, kTexSize));
sk_sp<SkShader> normalMap = SkShader::MakeBitmapShader(normals, SkShader::kClamp_TileMode,
SkShader::kClamp_TileMode, &matrix);
sk_sp<SkNormalSource> normalSource = SkNormalSource::MakeFromNormalMap(std::move(normalMap),
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 640b341..f2279b8 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -31,8 +31,7 @@
#include <initializer_list>
#include <vector>
-#include "sk_tool_utils.h"
-
+#include "ToolUtils.h"
static void release_direct_surface_storage(void* pixels, void* context) {
SkASSERT(pixels == context);
@@ -1019,9 +1018,10 @@
auto img = surf->makeImageSnapshot();
if (!img && false) { // change to true to document the differences
SkDebugf("image failed: [%08X %08X] %14s %s\n",
- info.width(), info.height(),
- sk_tool_utils::colortype_name(info.colorType()),
- sk_tool_utils::alphatype_name(info.alphaType()));
+ info.width(),
+ info.height(),
+ ToolUtils::colortype_name(info.colorType()),
+ ToolUtils::alphatype_name(info.alphaType()));
return;
}
REPORTER_ASSERT(reporter, img != nullptr);
diff --git a/tests/TextBlobCacheTest.cpp b/tests/TextBlobCacheTest.cpp
index 3115818..a1a6e78 100644
--- a/tests/TextBlobCacheTest.cpp
+++ b/tests/TextBlobCacheTest.cpp
@@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
#include "RandomScalerContext.h"
#include "SkCanvas.h"
diff --git a/tests/TextBlobTest.cpp b/tests/TextBlobTest.cpp
index 2862208..d18d05b 100644
--- a/tests/TextBlobTest.cpp
+++ b/tests/TextBlobTest.cpp
@@ -13,7 +13,7 @@
#include "SkTypeface.h"
#include "Test.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
class TextBlobTester {
public:
@@ -176,7 +176,7 @@
// Kitchen sink font.
font.setSize(42);
font.setScaleX(4.2f);
- font.setTypeface(sk_tool_utils::create_portable_typeface());
+ font.setTypeface(ToolUtils::create_portable_typeface());
font.setSkewX(0.42f);
font.setHinting(kFull_SkFontHinting);
font.setEdging(SkFont::Edging::kSubpixelAntiAlias);
@@ -429,7 +429,7 @@
sk_sp<SkImage> img0 = render(blob0.get());
sk_sp<SkImage> img1 = render(blob1.get());
if (img0 && img1) {
- REPORTER_ASSERT(reporter, sk_tool_utils::equal_pixels(img0.get(), img1.get()));
+ REPORTER_ASSERT(reporter, ToolUtils::equal_pixels(img0.get(), img1.get()));
}
}
diff --git a/tests/TopoSortTest.cpp b/tests/TopoSortTest.cpp
index 18ad75d..e45b6b8 100644
--- a/tests/TopoSortTest.cpp
+++ b/tests/TopoSortTest.cpp
@@ -9,9 +9,9 @@
#include "SkTTopoSort.h"
#include "Test.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
-typedef void (*CreateGraphPF)(SkTArray<sk_sp<sk_tool_utils::TopoTestNode>>* graph);
+typedef void (*CreateGraphPF)(SkTArray<sk_sp<ToolUtils::TopoTestNode>>* graph);
/* Simple diamond
* 3
@@ -20,8 +20,8 @@
* \ /
* 0
*/
-static void create_graph0(SkTArray<sk_sp<sk_tool_utils::TopoTestNode>>* graph) {
- sk_tool_utils::TopoTestNode::AllocNodes(graph, 4);
+static void create_graph0(SkTArray<sk_sp<ToolUtils::TopoTestNode>>* graph) {
+ ToolUtils::TopoTestNode::AllocNodes(graph, 4);
(*graph)[0]->dependsOn((*graph)[1].get());
(*graph)[0]->dependsOn((*graph)[2].get());
@@ -38,8 +38,8 @@
* |
* 0
*/
-static void create_graph1(SkTArray<sk_sp<sk_tool_utils::TopoTestNode>>* graph) {
- sk_tool_utils::TopoTestNode::AllocNodes(graph, 4);
+static void create_graph1(SkTArray<sk_sp<ToolUtils::TopoTestNode>>* graph) {
+ ToolUtils::TopoTestNode::AllocNodes(graph, 4);
(*graph)[0]->dependsOn((*graph)[1].get());
(*graph)[1]->dependsOn((*graph)[2].get());
@@ -51,8 +51,8 @@
* / \
* 0 --- 1
*/
-static void create_graph2(SkTArray<sk_sp<sk_tool_utils::TopoTestNode>>* graph) {
- sk_tool_utils::TopoTestNode::AllocNodes(graph, 3);
+static void create_graph2(SkTArray<sk_sp<ToolUtils::TopoTestNode>>* graph) {
+ ToolUtils::TopoTestNode::AllocNodes(graph, 3);
(*graph)[0]->dependsOn((*graph)[1].get());
(*graph)[1]->dependsOn((*graph)[2].get());
@@ -70,8 +70,8 @@
* \ /
* 0
*/
-static void create_graph3(SkTArray<sk_sp<sk_tool_utils::TopoTestNode>>* graph) {
- sk_tool_utils::TopoTestNode::AllocNodes(graph, 7);
+static void create_graph3(SkTArray<sk_sp<ToolUtils::TopoTestNode>>* graph) {
+ ToolUtils::TopoTestNode::AllocNodes(graph, 7);
(*graph)[0]->dependsOn((*graph)[1].get());
(*graph)[0]->dependsOn((*graph)[2].get());
@@ -91,8 +91,8 @@
* \ / \ /
* 0 4
*/
-static void create_graph4(SkTArray<sk_sp<sk_tool_utils::TopoTestNode>>* graph) {
- sk_tool_utils::TopoTestNode::AllocNodes(graph, 8);
+static void create_graph4(SkTArray<sk_sp<ToolUtils::TopoTestNode>>* graph) {
+ ToolUtils::TopoTestNode::AllocNodes(graph, 8);
(*graph)[0]->dependsOn((*graph)[1].get());
(*graph)[0]->dependsOn((*graph)[2].get());
@@ -120,13 +120,13 @@
};
for (size_t i = 0; i < SK_ARRAY_COUNT(tests); ++i) {
- SkTArray<sk_sp<sk_tool_utils::TopoTestNode>> graph;
+ SkTArray<sk_sp<ToolUtils::TopoTestNode>> graph;
(tests[i].fCreate)(&graph);
- sk_tool_utils::TopoTestNode::Shuffle(&graph, &rand);
+ ToolUtils::TopoTestNode::Shuffle(&graph, &rand);
- bool actualResult = SkTTopoSort<sk_tool_utils::TopoTestNode>(&graph);
+ bool actualResult = SkTTopoSort<ToolUtils::TopoTestNode>(&graph);
REPORTER_ASSERT(reporter, actualResult == tests[i].fExpectedResult);
if (tests[i].fExpectedResult) {
diff --git a/tests/VerticesTest.cpp b/tests/VerticesTest.cpp
index b38a9de..52c2f33 100644
--- a/tests/VerticesTest.cpp
+++ b/tests/VerticesTest.cpp
@@ -136,7 +136,7 @@
SkPoint pts[] = { { -10, 1 }, { -10, 2 }, { 1e9f, 1.5f } };
fill_triangle(surf->getCanvas(), pts, SK_ColorBLACK);
- sk_tool_utils::PixelIter iter(surf.get());
+ ToolUtils::PixelIter iter(surf.get());
SkIPoint loc;
while (void* addr = iter.next(&loc)) {
SkPMColor c = *(SkPMColor*)addr;
diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp
index a0400bf..297e82b 100644
--- a/tests/WritePixelsTest.cpp
+++ b/tests/WritePixelsTest.cpp
@@ -11,7 +11,7 @@
#include "SkMathPriv.h"
#include "SkSurface.h"
#include "Test.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
#include "GrBackendSurface.h"
#include "GrContext.h"
@@ -396,7 +396,7 @@
rect.height(), SkToBool(tightBmp)));
uint32_t idBefore = surface->generationID();
- // sk_tool_utils::write_pixels(&canvas, bmp, rect.fLeft, rect.fTop, ct, at);
+ // ToolUtils::write_pixels(&canvas, bmp, rect.fLeft, rect.fTop, ct, at);
surface->writePixels(bmp, rect.fLeft, rect.fTop);
uint32_t idAfter = surface->generationID();
diff --git a/tools/ToolUtils.cpp b/tools/ToolUtils.cpp
new file mode 100644
index 0000000..5fc5f22
--- /dev/null
+++ b/tools/ToolUtils.cpp
@@ -0,0 +1,439 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "ToolUtils.h"
+#include "SkBitmap.h"
+#include "SkBlendMode.h"
+#include "SkCanvas.h"
+#include "SkColorData.h"
+#include "SkColorPriv.h"
+#include "SkFloatingPoint.h"
+#include "SkFontPriv.h"
+#include "SkImage.h"
+#include "SkMatrix.h"
+#include "SkPaint.h"
+#include "SkPath.h"
+#include "SkPixelRef.h"
+#include "SkPixmap.h"
+#include "SkPoint3.h"
+#include "SkRRect.h"
+#include "SkShader.h"
+#include "SkSurface.h"
+#include "SkTextBlob.h"
+
+#include <cmath>
+#include <cstring>
+#include <memory>
+
+namespace ToolUtils {
+
+const char* alphatype_name(SkAlphaType at) {
+ switch (at) {
+ case kUnknown_SkAlphaType: return "Unknown";
+ case kOpaque_SkAlphaType: return "Opaque";
+ case kPremul_SkAlphaType: return "Premul";
+ case kUnpremul_SkAlphaType: return "Unpremul";
+ }
+ SkASSERT(false);
+ return "unexpected alphatype";
+}
+
+const char* colortype_name(SkColorType ct) {
+ switch (ct) {
+ case kUnknown_SkColorType: return "Unknown";
+ case kAlpha_8_SkColorType: return "Alpha_8";
+ case kRGB_565_SkColorType: return "RGB_565";
+ case kARGB_4444_SkColorType: return "ARGB_4444";
+ case kRGBA_8888_SkColorType: return "RGBA_8888";
+ case kRGB_888x_SkColorType: return "RGB_888x";
+ case kBGRA_8888_SkColorType: return "BGRA_8888";
+ case kRGBA_1010102_SkColorType: return "RGBA_1010102";
+ case kRGB_101010x_SkColorType: return "RGB_101010x";
+ case kGray_8_SkColorType: return "Gray_8";
+ case kRGBA_F16Norm_SkColorType: return "RGBA_F16Norm";
+ case kRGBA_F16_SkColorType: return "RGBA_F16";
+ case kRGBA_F32_SkColorType: return "RGBA_F32";
+ }
+ SkASSERT(false);
+ return "unexpected colortype";
+}
+
+SkColor color_to_565(SkColor color) {
+ // Not a good idea to use this function for greyscale colors...
+ // it will add an obvious purple or green tint.
+ SkASSERT(SkColorGetR(color) != SkColorGetG(color) || SkColorGetR(color) != SkColorGetB(color) ||
+ SkColorGetG(color) != SkColorGetB(color));
+
+ SkPMColor pmColor = SkPreMultiplyColor(color);
+ U16CPU color16 = SkPixel32ToPixel16(pmColor);
+ return SkPixel16ToColor(color16);
+}
+
+void write_pixels(SkCanvas* canvas,
+ const SkBitmap& bitmap,
+ int x,
+ int y,
+ SkColorType colorType,
+ SkAlphaType alphaType) {
+ SkBitmap tmp(bitmap);
+ const SkImageInfo info = SkImageInfo::Make(tmp.width(), tmp.height(), colorType, alphaType);
+
+ canvas->writePixels(info, tmp.getPixels(), tmp.rowBytes(), x, y);
+}
+
+void write_pixels(SkSurface* surface,
+ const SkBitmap& src,
+ int x,
+ int y,
+ SkColorType colorType,
+ SkAlphaType alphaType) {
+ const SkImageInfo info = SkImageInfo::Make(src.width(), src.height(), colorType, alphaType);
+ surface->writePixels({info, src.getPixels(), src.rowBytes()}, x, y);
+}
+
+sk_sp<SkShader> create_checkerboard_shader(SkColor c1, SkColor c2, int size) {
+ SkBitmap bm;
+ bm.allocPixels(SkImageInfo::MakeS32(2 * size, 2 * size, kPremul_SkAlphaType));
+ bm.eraseColor(c1);
+ bm.eraseArea(SkIRect::MakeLTRB(0, 0, size, size), c2);
+ bm.eraseArea(SkIRect::MakeLTRB(size, size, 2 * size, 2 * size), c2);
+ return SkShader::MakeBitmapShader(bm, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
+}
+
+SkBitmap create_checkerboard_bitmap(int w, int h, SkColor c1, SkColor c2, int checkSize) {
+ SkBitmap bitmap;
+ bitmap.allocPixels(SkImageInfo::MakeS32(w, h, kPremul_SkAlphaType));
+ SkCanvas canvas(bitmap);
+
+ ToolUtils::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));
+ paint.setBlendMode(SkBlendMode::kSrc);
+ 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.setColor(c);
+
+ SkFont font(ToolUtils::create_portable_typeface(), textSize);
+
+ canvas.clear(0x00000000);
+ canvas.drawSimpleText(str,
+ strlen(str),
+ kUTF8_SkTextEncoding,
+ SkIntToScalar(x),
+ SkIntToScalar(y),
+ font,
+ paint);
+
+ // Tag data as sRGB (without doing any color space conversion). Color-space aware configs
+ // will process this correctly but legacy configs will render as if this returned N32.
+ SkBitmap result;
+ result.setInfo(SkImageInfo::MakeS32(w, h, kPremul_SkAlphaType));
+ result.setPixelRef(sk_ref_sp(bitmap.pixelRef()), 0, 0);
+ return result;
+}
+
+void add_to_text_blob_w_len(SkTextBlobBuilder* builder,
+ const char* text,
+ size_t len,
+ SkTextEncoding encoding,
+ const SkFont& font,
+ SkScalar x,
+ SkScalar y) {
+ int count = font.countText(text, len, encoding);
+ auto run = builder->allocRun(font, count, x, y);
+ font.textToGlyphs(text, len, encoding, run.glyphs, count);
+}
+
+void add_to_text_blob(SkTextBlobBuilder* builder,
+ const char* text,
+ const SkFont& font,
+ SkScalar x,
+ SkScalar y) {
+ add_to_text_blob_w_len(builder, text, strlen(text), kUTF8_SkTextEncoding, font, x, y);
+}
+
+void get_text_path(const SkFont& font,
+ const void* text,
+ size_t length,
+ SkTextEncoding encoding,
+ SkPath* dst,
+ const SkPoint pos[]) {
+ SkAutoToGlyphs atg(font, text, length, encoding);
+ const int count = atg.count();
+ SkAutoTArray<SkPoint> computedPos;
+ if (pos == nullptr) {
+ computedPos.reset(count);
+ font.getPos(atg.glyphs(), count, &computedPos[0]);
+ pos = computedPos.get();
+ }
+
+ struct Rec {
+ SkPath* fDst;
+ const SkPoint* fPos;
+ } rec = {dst, pos};
+ font.getPaths(atg.glyphs(),
+ atg.count(),
+ [](const SkPath* src, const SkMatrix& mx, void* ctx) {
+ Rec* rec = (Rec*)ctx;
+ if (src) {
+ SkMatrix tmp(mx);
+ tmp.postTranslate(rec->fPos->fX, rec->fPos->fY);
+ rec->fDst->addPath(*src, tmp);
+ }
+ rec->fPos += 1;
+ },
+ &rec);
+}
+
+SkPath make_star(const SkRect& bounds, int numPts, int step) {
+ SkASSERT(numPts != step);
+ SkPath path;
+ path.setFillType(SkPath::kEvenOdd_FillType);
+ path.moveTo(0, -1);
+ for (int i = 1; i < numPts; ++i) {
+ int idx = i * step % numPts;
+ SkScalar theta = idx * 2 * SK_ScalarPI / numPts + SK_ScalarPI / 2;
+ SkScalar x = SkScalarCos(theta);
+ SkScalar y = -SkScalarSin(theta);
+ path.lineTo(x, y);
+ }
+ path.transform(SkMatrix::MakeRectToRect(path.getBounds(), bounds, SkMatrix::kFill_ScaleToFit));
+ return path;
+}
+
+static inline void norm_to_rgb(SkBitmap* bm, int x, int y, const SkVector3& norm) {
+ SkASSERT(SkScalarNearlyEqual(norm.length(), 1.0f));
+ unsigned char r = static_cast<unsigned char>((0.5f * norm.fX + 0.5f) * 255);
+ unsigned char g = static_cast<unsigned char>((-0.5f * norm.fY + 0.5f) * 255);
+ unsigned char b = static_cast<unsigned char>((0.5f * norm.fZ + 0.5f) * 255);
+ *bm->getAddr32(x, y) = SkPackARGB32(0xFF, r, g, b);
+}
+
+void create_hemi_normal_map(SkBitmap* bm, const SkIRect& dst) {
+ const SkPoint center =
+ SkPoint::Make(dst.fLeft + (dst.width() / 2.0f), dst.fTop + (dst.height() / 2.0f));
+ const SkPoint halfSize = SkPoint::Make(dst.width() / 2.0f, dst.height() / 2.0f);
+
+ SkVector3 norm;
+
+ for (int y = dst.fTop; y < dst.fBottom; ++y) {
+ for (int x = dst.fLeft; x < dst.fRight; ++x) {
+ norm.fX = (x + 0.5f - center.fX) / halfSize.fX;
+ norm.fY = (y + 0.5f - center.fY) / halfSize.fY;
+
+ SkScalar tmp = norm.fX * norm.fX + norm.fY * norm.fY;
+ if (tmp >= 1.0f) {
+ norm.set(0.0f, 0.0f, 1.0f);
+ } else {
+ norm.fZ = sqrtf(1.0f - tmp);
+ }
+
+ norm_to_rgb(bm, x, y, norm);
+ }
+ }
+}
+
+void create_frustum_normal_map(SkBitmap* bm, const SkIRect& dst) {
+ const SkPoint center =
+ SkPoint::Make(dst.fLeft + (dst.width() / 2.0f), dst.fTop + (dst.height() / 2.0f));
+
+ SkIRect inner = dst;
+ inner.inset(dst.width() / 4, dst.height() / 4);
+
+ SkPoint3 norm;
+ const SkPoint3 left = SkPoint3::Make(-SK_ScalarRoot2Over2, 0.0f, SK_ScalarRoot2Over2);
+ const SkPoint3 up = SkPoint3::Make(0.0f, -SK_ScalarRoot2Over2, SK_ScalarRoot2Over2);
+ const SkPoint3 right = SkPoint3::Make(SK_ScalarRoot2Over2, 0.0f, SK_ScalarRoot2Over2);
+ const SkPoint3 down = SkPoint3::Make(0.0f, SK_ScalarRoot2Over2, SK_ScalarRoot2Over2);
+
+ for (int y = dst.fTop; y < dst.fBottom; ++y) {
+ for (int x = dst.fLeft; x < dst.fRight; ++x) {
+ if (inner.contains(x, y)) {
+ norm.set(0.0f, 0.0f, 1.0f);
+ } else {
+ SkScalar locX = x + 0.5f - center.fX;
+ SkScalar locY = y + 0.5f - center.fY;
+
+ if (locX >= 0.0f) {
+ if (locY > 0.0f) {
+ norm = locX >= locY ? right : down; // LR corner
+ } else {
+ norm = locX > -locY ? right : up; // UR corner
+ }
+ } else {
+ if (locY > 0.0f) {
+ norm = -locX > locY ? left : down; // LL corner
+ } else {
+ norm = locX > locY ? up : left; // UL corner
+ }
+ }
+ }
+
+ norm_to_rgb(bm, x, y, norm);
+ }
+ }
+}
+
+void create_tetra_normal_map(SkBitmap* bm, const SkIRect& dst) {
+ const SkPoint center =
+ SkPoint::Make(dst.fLeft + (dst.width() / 2.0f), dst.fTop + (dst.height() / 2.0f));
+
+ static const SkScalar k1OverRoot3 = 0.5773502692f;
+
+ SkPoint3 norm;
+ const SkPoint3 leftUp = SkPoint3::Make(-k1OverRoot3, -k1OverRoot3, k1OverRoot3);
+ const SkPoint3 rightUp = SkPoint3::Make(k1OverRoot3, -k1OverRoot3, k1OverRoot3);
+ const SkPoint3 down = SkPoint3::Make(0.0f, SK_ScalarRoot2Over2, SK_ScalarRoot2Over2);
+
+ for (int y = dst.fTop; y < dst.fBottom; ++y) {
+ for (int x = dst.fLeft; x < dst.fRight; ++x) {
+ SkScalar locX = x + 0.5f - center.fX;
+ SkScalar locY = y + 0.5f - center.fY;
+
+ if (locX >= 0.0f) {
+ if (locY > 0.0f) {
+ norm = locX >= locY ? rightUp : down; // LR corner
+ } else {
+ norm = rightUp;
+ }
+ } else {
+ if (locY > 0.0f) {
+ norm = -locX > locY ? leftUp : down; // LL corner
+ } else {
+ norm = leftUp;
+ }
+ }
+
+ norm_to_rgb(bm, x, y, norm);
+ }
+ }
+}
+
+#if !defined(__clang__) && defined(_MSC_VER)
+// MSVC takes ~2 minutes to compile this function with optimization.
+// We don't really care to wait that long for this function.
+#pragma optimize("", off)
+#endif
+void make_big_path(SkPath& path) {
+#include "BigPathBench.inc" // IWYU pragma: keep
+}
+
+bool copy_to(SkBitmap* dst, SkColorType dstColorType, const SkBitmap& src) {
+ SkPixmap srcPM;
+ if (!src.peekPixels(&srcPM)) {
+ return false;
+ }
+
+ SkBitmap tmpDst;
+ SkImageInfo dstInfo = srcPM.info().makeColorType(dstColorType);
+ if (!tmpDst.setInfo(dstInfo)) {
+ return false;
+ }
+
+ if (!tmpDst.tryAllocPixels()) {
+ return false;
+ }
+
+ SkPixmap dstPM;
+ if (!tmpDst.peekPixels(&dstPM)) {
+ return false;
+ }
+
+ if (!srcPM.readPixels(dstPM)) {
+ return false;
+ }
+
+ dst->swap(tmpDst);
+ return true;
+}
+
+void copy_to_g8(SkBitmap* dst, const SkBitmap& src) {
+ SkASSERT(kBGRA_8888_SkColorType == src.colorType() ||
+ kRGBA_8888_SkColorType == src.colorType());
+
+ SkImageInfo grayInfo = src.info().makeColorType(kGray_8_SkColorType);
+ dst->allocPixels(grayInfo);
+ uint8_t* dst8 = (uint8_t*)dst->getPixels();
+ const uint32_t* src32 = (const uint32_t*)src.getPixels();
+
+ const int w = src.width();
+ const int h = src.height();
+ const bool isBGRA = (kBGRA_8888_SkColorType == src.colorType());
+ for (int y = 0; y < h; ++y) {
+ if (isBGRA) {
+ // BGRA
+ for (int x = 0; x < w; ++x) {
+ uint32_t s = src32[x];
+ dst8[x] = SkComputeLuminance((s >> 16) & 0xFF, (s >> 8) & 0xFF, s & 0xFF);
+ }
+ } else {
+ // RGBA
+ for (int x = 0; x < w; ++x) {
+ uint32_t s = src32[x];
+ dst8[x] = SkComputeLuminance(s & 0xFF, (s >> 8) & 0xFF, (s >> 16) & 0xFF);
+ }
+ }
+ src32 = (const uint32_t*)((const char*)src32 + src.rowBytes());
+ dst8 += dst->rowBytes();
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+bool equal_pixels(const SkPixmap& a, const SkPixmap& b) {
+ if (a.width() != b.width() || a.height() != b.height() || a.colorType() != b.colorType()) {
+ return false;
+ }
+
+ for (int y = 0; y < a.height(); ++y) {
+ const char* aptr = (const char*)a.addr(0, y);
+ const char* bptr = (const char*)b.addr(0, y);
+ if (memcmp(aptr, bptr, a.width() * a.info().bytesPerPixel())) {
+ return false;
+ }
+ aptr += a.rowBytes();
+ bptr += b.rowBytes();
+ }
+ return true;
+}
+
+bool equal_pixels(const SkBitmap& bm0, const SkBitmap& bm1) {
+ SkPixmap pm0, pm1;
+ return bm0.peekPixels(&pm0) && bm1.peekPixels(&pm1) && equal_pixels(pm0, pm1);
+}
+
+bool equal_pixels(const SkImage* a, const SkImage* b) {
+ // ensure that peekPixels will succeed
+ auto imga = a->makeRasterImage();
+ auto imgb = b->makeRasterImage();
+
+ SkPixmap pm0, pm1;
+ return imga->peekPixels(&pm0) && imgb->peekPixels(&pm1) && equal_pixels(pm0, pm1);
+}
+
+sk_sp<SkSurface> makeSurface(SkCanvas* canvas,
+ const SkImageInfo& info,
+ const SkSurfaceProps* props) {
+ auto surf = canvas->makeSurface(info, props);
+ if (!surf) {
+ surf = SkSurface::MakeRaster(info, props);
+ }
+ return surf;
+}
+} // namespace ToolUtils
diff --git a/tools/ToolUtils.h b/tools/ToolUtils.h
new file mode 100644
index 0000000..e236abb
--- /dev/null
+++ b/tools/ToolUtils.h
@@ -0,0 +1,234 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef ToolUtils_DEFINED
+#define ToolUtils_DEFINED
+
+#include "SkColor.h"
+#include "SkData.h"
+#include "SkEncodedImageFormat.h"
+#include "SkFont.h"
+#include "SkFontStyle.h"
+#include "SkFontTypes.h"
+#include "SkImageEncoder.h"
+#include "SkImageInfo.h"
+#include "SkRandom.h"
+#include "SkRect.h"
+#include "SkRefCnt.h"
+#include "SkScalar.h"
+#include "SkStream.h"
+#include "SkTArray.h"
+#include "SkTDArray.h"
+#include "SkTypeface.h"
+#include "SkTypes.h"
+
+class SkBitmap;
+class SkCanvas;
+class SkFontStyle;
+class SkImage;
+class SkPath;
+class SkPixmap;
+class SkRRect;
+class SkShader;
+class SkSurface;
+class SkSurfaceProps;
+class SkTextBlobBuilder;
+class SkTypeface;
+
+namespace ToolUtils {
+
+const char* alphatype_name(SkAlphaType);
+const char* colortype_name(SkColorType);
+
+/**
+ * Map opaque colors from 8888 to 565.
+ */
+SkColor color_to_565(SkColor color);
+
+/* Return a color emoji typeface with planets to scale if available. */
+sk_sp<SkTypeface> planet_typeface();
+
+/** Return a color emoji typeface if available. */
+sk_sp<SkTypeface> emoji_typeface();
+
+/** Sample text for the emoji_typeface font. */
+const char* emoji_sample_text();
+
+/**
+ * Returns a platform-independent text renderer.
+ */
+sk_sp<SkTypeface> create_portable_typeface(const char* name, SkFontStyle style);
+
+static inline sk_sp<SkTypeface> create_portable_typeface() {
+ return create_portable_typeface(nullptr, SkFontStyle());
+}
+
+void get_text_path(const SkFont&,
+ const void* text,
+ size_t length,
+ SkTextEncoding,
+ SkPath*,
+ const SkPoint* positions = nullptr);
+
+/**
+ * Call writePixels() by using the pixels from bitmap, but with an info that claims
+ * the pixels are colorType + alphaType
+ */
+void write_pixels(SkCanvas*, const SkBitmap&, int x, int y, SkColorType, SkAlphaType);
+void write_pixels(SkSurface*, const SkBitmap&, int x, int y, SkColorType, SkAlphaType);
+
+/**
+ * Returns true iff all of the pixels between the two images are identical.
+ *
+ * If the configs differ, return false.
+ */
+bool equal_pixels(const SkPixmap&, const SkPixmap&);
+bool equal_pixels(const SkBitmap&, const SkBitmap&);
+bool equal_pixels(const SkImage* a, const SkImage* b);
+
+/** Returns a newly created CheckerboardShader. */
+sk_sp<SkShader> create_checkerboard_shader(SkColor c1, SkColor c2, int size);
+
+/** Draw a checkerboard pattern in the current canvas, restricted to
+ the current clip, using SkXfermode::kSrc_Mode. */
+void draw_checkerboard(SkCanvas* canvas, SkColor color1, SkColor color2, 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) {
+ ToolUtils::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);
+
+// If the canvas does't make a surface (e.g. recording), make a raster surface
+sk_sp<SkSurface> makeSurface(SkCanvas*, const SkImageInfo&, const SkSurfaceProps* = nullptr);
+
+// A helper for inserting a drawtext call into a SkTextBlobBuilder
+void add_to_text_blob_w_len(SkTextBlobBuilder*,
+ const char* text,
+ size_t len,
+ SkTextEncoding,
+ const SkFont&,
+ SkScalar x,
+ SkScalar y);
+
+void add_to_text_blob(SkTextBlobBuilder*, const char* text, const SkFont&, SkScalar x, SkScalar y);
+
+// Constructs a star by walking a 'numPts'-sided regular polygon with even/odd fill:
+//
+// moveTo(pts[0]);
+// lineTo(pts[step % numPts]);
+// ...
+// lineTo(pts[(step * (N - 1)) % numPts]);
+//
+// numPts=5, step=2 will produce a classic five-point star.
+//
+// numPts and step must be co-prime.
+SkPath make_star(const SkRect& bounds, int numPts = 5, int step = 2);
+
+void create_hemi_normal_map(SkBitmap* bm, const SkIRect& dst);
+
+void create_frustum_normal_map(SkBitmap* bm, const SkIRect& dst);
+
+void create_tetra_normal_map(SkBitmap* bm, const SkIRect& dst);
+
+void make_big_path(SkPath& path);
+
+// A helper object to test the topological sorting code (TopoSortBench.cpp & TopoSortTest.cpp)
+class TopoTestNode : public SkRefCnt {
+public:
+ TopoTestNode(int id) : fID(id), fOutputPos(-1), fTempMark(false) {}
+
+ void dependsOn(TopoTestNode* src) { *fDependencies.append() = src; }
+
+ int id() const { return fID; }
+ void reset() { fOutputPos = -1; }
+
+ int outputPos() const { return fOutputPos; }
+
+ // check that the topological sort is valid for this node
+ bool check() {
+ if (-1 == fOutputPos) {
+ return false;
+ }
+
+ for (int i = 0; i < fDependencies.count(); ++i) {
+ if (-1 == fDependencies[i]->outputPos()) {
+ return false;
+ }
+ // This node should've been output after all the nodes on which it depends
+ if (fOutputPos < fDependencies[i]->outputPos()) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ // The following 7 methods are needed by the topological sort
+ static void SetTempMark(TopoTestNode* node) { node->fTempMark = true; }
+ static void ResetTempMark(TopoTestNode* node) { node->fTempMark = false; }
+ static bool IsTempMarked(TopoTestNode* node) { return node->fTempMark; }
+ static void Output(TopoTestNode* node, int outputPos) {
+ SkASSERT(-1 != outputPos);
+ node->fOutputPos = outputPos;
+ }
+ static bool WasOutput(TopoTestNode* node) { return (-1 != node->fOutputPos); }
+ static int NumDependencies(TopoTestNode* node) { return node->fDependencies.count(); }
+ static TopoTestNode* Dependency(TopoTestNode* node, int index) {
+ return node->fDependencies[index];
+ }
+
+ // Helper functions for TopoSortBench & TopoSortTest
+ static void AllocNodes(SkTArray<sk_sp<ToolUtils::TopoTestNode>>* graph, int num) {
+ graph->reserve(num);
+
+ for (int i = 0; i < num; ++i) {
+ graph->push_back(sk_sp<TopoTestNode>(new TopoTestNode(i)));
+ }
+ }
+
+#ifdef SK_DEBUG
+ static void Print(const SkTArray<TopoTestNode*>& graph) {
+ for (int i = 0; i < graph.count(); ++i) {
+ SkDebugf("%d, ", graph[i]->id());
+ }
+ SkDebugf("\n");
+ }
+#endif
+
+ // randomize the array
+ static void Shuffle(SkTArray<sk_sp<TopoTestNode>>* graph, SkRandom* rand) {
+ for (int i = graph->count() - 1; i > 0; --i) {
+ int swap = rand->nextU() % (i + 1);
+
+ (*graph)[i].swap((*graph)[swap]);
+ }
+ }
+
+private:
+ int fID;
+ int fOutputPos;
+ bool fTempMark;
+
+ SkTDArray<TopoTestNode*> fDependencies;
+};
+
+template <typename T>
+inline bool EncodeImageToFile(const char* path, const T& src, SkEncodedImageFormat f, int q) {
+ SkFILEWStream file(path);
+ return file.isValid() && SkEncodeImage(&file, src, f, q);
+}
+
+bool copy_to(SkBitmap* dst, SkColorType dstCT, const SkBitmap& src);
+void copy_to_g8(SkBitmap* dst, const SkBitmap& src);
+} // namespace ToolUtils
+
+#endif // ToolUtils_DEFINED
diff --git a/tools/fonts/TestFontMgr.cpp b/tools/fonts/TestFontMgr.cpp
index ffb9bf2..2b4daa8 100644
--- a/tools/fonts/TestFontMgr.cpp
+++ b/tools/fonts/TestFontMgr.cpp
@@ -8,7 +8,7 @@
#include "TestFontMgr.h"
#include "SkFontDescriptor.h"
#include "TestTypeface.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
#ifdef SK_XML
#include "TestSVGTypeface.h"
@@ -198,6 +198,6 @@
};
} // namespace
-namespace sk_tool_utils {
+namespace ToolUtils {
sk_sp<SkFontMgr> MakePortableFontMgr() { return sk_make_sp<FontMgr>(); }
-} // namespace sk_tool_utils
+} // namespace ToolUtils
diff --git a/tools/fonts/TestFontMgr.h b/tools/fonts/TestFontMgr.h
index 385ea37..f39766b 100644
--- a/tools/fonts/TestFontMgr.h
+++ b/tools/fonts/TestFontMgr.h
@@ -10,10 +10,10 @@
#include "SkFontMgr.h"
-// An SkFontMgr that always uses sk_tool_utils::create_portable_typeface().
+// An SkFontMgr that always uses ToolUtils::create_portable_typeface().
-namespace sk_tool_utils {
+namespace ToolUtils {
sk_sp<SkFontMgr> MakePortableFontMgr();
-} // namespace sk_tool_utils
+} // namespace ToolUtils
#endif // TestFontMgr_DEFINED
diff --git a/tools/fonts/sk_tool_utils_font.cpp b/tools/fonts/ToolUtilsFont.cpp
similarity index 86%
rename from tools/fonts/sk_tool_utils_font.cpp
rename to tools/fonts/ToolUtilsFont.cpp
index 21b6bfe..d159c51 100644
--- a/tools/fonts/sk_tool_utils_font.cpp
+++ b/tools/fonts/ToolUtilsFont.cpp
@@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
#include "CommonFlags.h"
#include "Resources.h"
@@ -17,10 +17,10 @@
#include "SkUTF.h"
#include "TestFontMgr.h"
-namespace sk_tool_utils {
+namespace ToolUtils {
sk_sp<SkTypeface> planet_typeface() {
- static const sk_sp<SkTypeface> planetTypeface = [](){
+ static const sk_sp<SkTypeface> planetTypeface = []() {
const char* filename;
#if defined(SK_BUILD_FOR_WIN)
filename = "fonts/planetcolr.ttf";
@@ -39,7 +39,7 @@
}
sk_sp<SkTypeface> emoji_typeface() {
- static const sk_sp<SkTypeface> emojiTypeface = [](){
+ static const sk_sp<SkTypeface> emojiTypeface = []() {
const char* filename;
#if defined(SK_BUILD_FOR_WIN)
filename = "fonts/colr.ttf";
@@ -58,7 +58,9 @@
}
const char* emoji_sample_text() {
- return "\xF0\x9F\x98\x80" " " "\xE2\x99\xA2"; // 😀 ♢
+ return "\xF0\x9F\x98\x80"
+ " "
+ "\xE2\x99\xA2"; // 😀 ♢
}
static sk_sp<SkTypeface> create_font(const char* name, SkFontStyle style) {
static sk_sp<SkFontMgr> portableFontMgr = MakePortableFontMgr();
@@ -68,4 +70,4 @@
sk_sp<SkTypeface> create_portable_typeface(const char* name, SkFontStyle style) {
return create_font(name, style);
}
-}
+} // namespace ToolUtils
diff --git a/tools/sk_app/ios/RasterWindowContext_ios.cpp b/tools/sk_app/ios/RasterWindowContext_ios.cpp
index fe76b81..c3d9c74 100644
--- a/tools/sk_app/ios/RasterWindowContext_ios.cpp
+++ b/tools/sk_app/ios/RasterWindowContext_ios.cpp
@@ -9,9 +9,9 @@
#include "../GLWindowContext.h"
#include "SkCanvas.h"
#include "SkColorFilter.h"
+#include "ToolUtils.h"
#include "WindowContextFactory_ios.h"
#include "gl/GrGLInterface.h"
-#include "sk_tool_utils.h"
#include <OpenGLES/ES2/gl.h>
diff --git a/tools/sk_app/mac/RasterWindowContext_mac.mm b/tools/sk_app/mac/RasterWindowContext_mac.mm
index 29e0284..edbbe33 100644
--- a/tools/sk_app/mac/RasterWindowContext_mac.mm
+++ b/tools/sk_app/mac/RasterWindowContext_mac.mm
@@ -9,9 +9,9 @@
#include "../GLWindowContext.h"
#include "SkCanvas.h"
#include "SkColorFilter.h"
+#include "ToolUtils.h"
#include "WindowContextFactory_mac.h"
#include "gl/GrGLInterface.h"
-#include "sk_tool_utils.h"
#include <OpenGL/gl.h>
diff --git a/tools/sk_pixel_iter.h b/tools/sk_pixel_iter.h
index 8bf5a55..d84ebbb 100644
--- a/tools/sk_pixel_iter.h
+++ b/tools/sk_pixel_iter.h
@@ -11,51 +11,49 @@
#include "SkPixmap.h"
#include "SkSurface.h"
-namespace sk_tool_utils {
+namespace ToolUtils {
- class PixelIter {
- public:
- PixelIter();
- PixelIter(SkSurface* surf) {
- SkPixmap pm;
- if (!surf->peekPixels(&pm)) {
- pm.reset();
- }
- this->reset(pm);
+class PixelIter {
+public:
+ PixelIter();
+ PixelIter(SkSurface* surf) {
+ SkPixmap pm;
+ if (!surf->peekPixels(&pm)) {
+ pm.reset();
}
+ this->reset(pm);
+ }
- void reset(const SkPixmap& pm) {
- fPM = pm;
- fLoc = { -1, 0 };
+ void reset(const SkPixmap& pm) {
+ fPM = pm;
+ fLoc = {-1, 0};
+ }
+
+ void* next(SkIPoint* loc = nullptr) {
+ if (!fPM.addr()) {
+ return nullptr;
}
-
- void* next(SkIPoint* loc = nullptr) {
- if (!fPM.addr()) {
+ fLoc.fX += 1;
+ if (fLoc.fX >= fPM.width()) {
+ fLoc.fX = 0;
+ if (++fLoc.fY >= fPM.height()) {
+ this->setDone();
return nullptr;
}
- fLoc.fX += 1;
- if (fLoc.fX >= fPM.width()) {
- fLoc.fX = 0;
- if (++fLoc.fY >= fPM.height()) {
- this->setDone();
- return nullptr;
- }
- }
- if (loc) {
- *loc = fLoc;
- }
- return fPM.writable_addr(fLoc.fX, fLoc.fY);
}
-
- void setDone() {
- fPM.reset();
+ if (loc) {
+ *loc = fLoc;
}
+ return fPM.writable_addr(fLoc.fX, fLoc.fY);
+ }
- private:
- SkPixmap fPM;
- SkIPoint fLoc;
- };
+ void setDone() { fPM.reset(); }
-} // namespace sk_tool_utils
+private:
+ SkPixmap fPM;
+ SkIPoint fLoc;
+};
-#endif // sk_tool_utils_DEFINED
+} // namespace ToolUtils
+
+#endif // ToolUtils_DEFINED
diff --git a/tools/sk_tool_utils.cpp b/tools/sk_tool_utils.cpp
deleted file mode 100644
index c35d122..0000000
--- a/tools/sk_tool_utils.cpp
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkBitmap.h"
-#include "SkBlendMode.h"
-#include "SkCanvas.h"
-#include "SkColorData.h"
-#include "SkColorPriv.h"
-#include "SkFontPriv.h"
-#include "SkFloatingPoint.h"
-#include "SkImage.h"
-#include "SkMatrix.h"
-#include "SkPaint.h"
-#include "SkPath.h"
-#include "SkPixelRef.h"
-#include "SkPixmap.h"
-#include "SkPoint3.h"
-#include "SkRRect.h"
-#include "SkShader.h"
-#include "SkSurface.h"
-#include "SkTextBlob.h"
-#include "sk_tool_utils.h"
-
-#include <cmath>
-#include <cstring>
-#include <memory>
-
-namespace sk_tool_utils {
-
-const char* alphatype_name(SkAlphaType at) {
- switch (at) {
- case kUnknown_SkAlphaType: return "Unknown";
- case kOpaque_SkAlphaType: return "Opaque";
- case kPremul_SkAlphaType: return "Premul";
- case kUnpremul_SkAlphaType: return "Unpremul";
- }
- SkASSERT(false);
- return "unexpected alphatype";
-}
-
-const char* colortype_name(SkColorType ct) {
- switch (ct) {
- case kUnknown_SkColorType: return "Unknown";
- case kAlpha_8_SkColorType: return "Alpha_8";
- case kRGB_565_SkColorType: return "RGB_565";
- case kARGB_4444_SkColorType: return "ARGB_4444";
- case kRGBA_8888_SkColorType: return "RGBA_8888";
- case kRGB_888x_SkColorType: return "RGB_888x";
- case kBGRA_8888_SkColorType: return "BGRA_8888";
- case kRGBA_1010102_SkColorType: return "RGBA_1010102";
- case kRGB_101010x_SkColorType: return "RGB_101010x";
- case kGray_8_SkColorType: return "Gray_8";
- case kRGBA_F16Norm_SkColorType: return "RGBA_F16Norm";
- case kRGBA_F16_SkColorType: return "RGBA_F16";
- case kRGBA_F32_SkColorType: return "RGBA_F32";
- }
- SkASSERT(false);
- return "unexpected colortype";
-}
-
-SkColor color_to_565(SkColor color) {
- // Not a good idea to use this function for greyscale colors...
- // it will add an obvious purple or green tint.
- SkASSERT(SkColorGetR(color) != SkColorGetG(color) ||
- SkColorGetR(color) != SkColorGetB(color) ||
- SkColorGetG(color) != SkColorGetB(color));
-
- SkPMColor pmColor = SkPreMultiplyColor(color);
- U16CPU color16 = SkPixel32ToPixel16(pmColor);
- return SkPixel16ToColor(color16);
-}
-
-void write_pixels(SkCanvas* canvas, const SkBitmap& bitmap, int x, int y,
- SkColorType colorType, SkAlphaType alphaType) {
- SkBitmap tmp(bitmap);
- const SkImageInfo info = SkImageInfo::Make(tmp.width(), tmp.height(), colorType, alphaType);
-
- canvas->writePixels(info, tmp.getPixels(), tmp.rowBytes(), x, y);
-}
-
-void write_pixels(SkSurface* surface, const SkBitmap& src, int x, int y,
- SkColorType colorType, SkAlphaType alphaType) {
- const SkImageInfo info = SkImageInfo::Make(src.width(), src.height(), colorType, alphaType);
- surface->writePixels({info, src.getPixels(), src.rowBytes()}, x, y);
-}
-
-sk_sp<SkShader> create_checkerboard_shader(SkColor c1, SkColor c2, int size) {
- SkBitmap bm;
- bm.allocPixels(SkImageInfo::MakeS32(2 * size, 2 * size, kPremul_SkAlphaType));
- bm.eraseColor(c1);
- bm.eraseArea(SkIRect::MakeLTRB(0, 0, size, size), c2);
- bm.eraseArea(SkIRect::MakeLTRB(size, size, 2 * size, 2 * size), c2);
- return SkShader::MakeBitmapShader(
- bm, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
-}
-
-SkBitmap create_checkerboard_bitmap(int w, int h, SkColor c1, SkColor c2, int checkSize) {
- SkBitmap bitmap;
- bitmap.allocPixels(SkImageInfo::MakeS32(w, h, kPremul_SkAlphaType));
- 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));
- paint.setBlendMode(SkBlendMode::kSrc);
- 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.setColor(c);
-
- SkFont font(sk_tool_utils::create_portable_typeface(), textSize);
-
- canvas.clear(0x00000000);
- canvas.drawSimpleText(str, strlen(str), kUTF8_SkTextEncoding,
- SkIntToScalar(x), SkIntToScalar(y), font, paint);
-
- // Tag data as sRGB (without doing any color space conversion). Color-space aware configs
- // will process this correctly but legacy configs will render as if this returned N32.
- SkBitmap result;
- result.setInfo(SkImageInfo::MakeS32(w, h, kPremul_SkAlphaType));
- result.setPixelRef(sk_ref_sp(bitmap.pixelRef()), 0, 0);
- return result;
-}
-
-void add_to_text_blob_w_len(SkTextBlobBuilder* builder, const char* text, size_t len,
- SkTextEncoding encoding, const SkFont& font, SkScalar x, SkScalar y) {
- int count = font.countText(text, len, encoding);
- auto run = builder->allocRun(font, count, x, y);
- font.textToGlyphs(text, len, encoding, run.glyphs, count);
-}
-
-void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const SkFont& font,
- SkScalar x, SkScalar y) {
- add_to_text_blob_w_len(builder, text, strlen(text), kUTF8_SkTextEncoding, font, x, y);
-}
-
-void get_text_path(const SkFont& font, const void* text, size_t length, SkTextEncoding encoding,
- SkPath* dst, const SkPoint pos[]) {
- SkAutoToGlyphs atg(font, text, length, encoding);
- const int count = atg.count();
- SkAutoTArray<SkPoint> computedPos;
- if (pos == nullptr) {
- computedPos.reset(count);
- font.getPos(atg.glyphs(), count, &computedPos[0]);
- pos = computedPos.get();
- }
-
- struct Rec {
- SkPath* fDst;
- const SkPoint* fPos;
- } rec = { dst, pos };
- font.getPaths(atg.glyphs(), atg.count(), [](const SkPath* src, const SkMatrix& mx, void* ctx) {
- Rec* rec = (Rec*)ctx;
- if (src) {
- SkMatrix tmp(mx);
- tmp.postTranslate(rec->fPos->fX, rec->fPos->fY);
- rec->fDst->addPath(*src, tmp);
- }
- rec->fPos += 1;
- }, &rec);
-}
-
-SkPath make_star(const SkRect& bounds, int numPts, int step) {
- SkASSERT(numPts != step);
- SkPath path;
- path.setFillType(SkPath::kEvenOdd_FillType);
- path.moveTo(0,-1);
- for (int i = 1; i < numPts; ++i) {
- int idx = i*step % numPts;
- SkScalar theta = idx * 2*SK_ScalarPI/numPts + SK_ScalarPI/2;
- SkScalar x = SkScalarCos(theta);
- SkScalar y = -SkScalarSin(theta);
- path.lineTo(x, y);
- }
- path.transform(SkMatrix::MakeRectToRect(path.getBounds(), bounds, SkMatrix::kFill_ScaleToFit));
- return path;
-}
-
-static inline void norm_to_rgb(SkBitmap* bm, int x, int y, const SkVector3& norm) {
- SkASSERT(SkScalarNearlyEqual(norm.length(), 1.0f));
- unsigned char r = static_cast<unsigned char>((0.5f * norm.fX + 0.5f) * 255);
- unsigned char g = static_cast<unsigned char>((-0.5f * norm.fY + 0.5f) * 255);
- unsigned char b = static_cast<unsigned char>((0.5f * norm.fZ + 0.5f) * 255);
- *bm->getAddr32(x, y) = SkPackARGB32(0xFF, r, g, b);
-}
-
-void create_hemi_normal_map(SkBitmap* bm, const SkIRect& dst) {
- const SkPoint center = SkPoint::Make(dst.fLeft + (dst.width() / 2.0f),
- dst.fTop + (dst.height() / 2.0f));
- const SkPoint halfSize = SkPoint::Make(dst.width() / 2.0f, dst.height() / 2.0f);
-
- SkVector3 norm;
-
- for (int y = dst.fTop; y < dst.fBottom; ++y) {
- for (int x = dst.fLeft; x < dst.fRight; ++x) {
- norm.fX = (x + 0.5f - center.fX) / halfSize.fX;
- norm.fY = (y + 0.5f - center.fY) / halfSize.fY;
-
- SkScalar tmp = norm.fX * norm.fX + norm.fY * norm.fY;
- if (tmp >= 1.0f) {
- norm.set(0.0f, 0.0f, 1.0f);
- } else {
- norm.fZ = sqrtf(1.0f - tmp);
- }
-
- norm_to_rgb(bm, x, y, norm);
- }
- }
-}
-
-void create_frustum_normal_map(SkBitmap* bm, const SkIRect& dst) {
- const SkPoint center = SkPoint::Make(dst.fLeft + (dst.width() / 2.0f),
- dst.fTop + (dst.height() / 2.0f));
-
- SkIRect inner = dst;
- inner.inset(dst.width()/4, dst.height()/4);
-
- SkPoint3 norm;
- const SkPoint3 left = SkPoint3::Make(-SK_ScalarRoot2Over2, 0.0f, SK_ScalarRoot2Over2);
- const SkPoint3 up = SkPoint3::Make(0.0f, -SK_ScalarRoot2Over2, SK_ScalarRoot2Over2);
- const SkPoint3 right = SkPoint3::Make(SK_ScalarRoot2Over2, 0.0f, SK_ScalarRoot2Over2);
- const SkPoint3 down = SkPoint3::Make(0.0f, SK_ScalarRoot2Over2, SK_ScalarRoot2Over2);
-
- for (int y = dst.fTop; y < dst.fBottom; ++y) {
- for (int x = dst.fLeft; x < dst.fRight; ++x) {
- if (inner.contains(x, y)) {
- norm.set(0.0f, 0.0f, 1.0f);
- } else {
- SkScalar locX = x + 0.5f - center.fX;
- SkScalar locY = y + 0.5f - center.fY;
-
- if (locX >= 0.0f) {
- if (locY > 0.0f) {
- norm = locX >= locY ? right : down; // LR corner
- } else {
- norm = locX > -locY ? right : up; // UR corner
- }
- } else {
- if (locY > 0.0f) {
- norm = -locX > locY ? left : down; // LL corner
- } else {
- norm = locX > locY ? up : left; // UL corner
- }
- }
- }
-
- norm_to_rgb(bm, x, y, norm);
- }
- }
-}
-
-void create_tetra_normal_map(SkBitmap* bm, const SkIRect& dst) {
- const SkPoint center = SkPoint::Make(dst.fLeft + (dst.width() / 2.0f),
- dst.fTop + (dst.height() / 2.0f));
-
- static const SkScalar k1OverRoot3 = 0.5773502692f;
-
- SkPoint3 norm;
- const SkPoint3 leftUp = SkPoint3::Make(-k1OverRoot3, -k1OverRoot3, k1OverRoot3);
- const SkPoint3 rightUp = SkPoint3::Make(k1OverRoot3, -k1OverRoot3, k1OverRoot3);
- const SkPoint3 down = SkPoint3::Make(0.0f, SK_ScalarRoot2Over2, SK_ScalarRoot2Over2);
-
- for (int y = dst.fTop; y < dst.fBottom; ++y) {
- for (int x = dst.fLeft; x < dst.fRight; ++x) {
- SkScalar locX = x + 0.5f - center.fX;
- SkScalar locY = y + 0.5f - center.fY;
-
- if (locX >= 0.0f) {
- if (locY > 0.0f) {
- norm = locX >= locY ? rightUp : down; // LR corner
- } else {
- norm = rightUp;
- }
- } else {
- if (locY > 0.0f) {
- norm = -locX > locY ? leftUp : down; // LL corner
- } else {
- norm = leftUp;
- }
- }
-
- norm_to_rgb(bm, x, y, norm);
- }
- }
-}
-
-#if !defined(__clang__) && defined(_MSC_VER)
- // MSVC takes ~2 minutes to compile this function with optimization.
- // We don't really care to wait that long for this function.
- #pragma optimize("", off)
-#endif
-void make_big_path(SkPath& path) {
- #include "BigPathBench.inc" // IWYU pragma: keep
-}
-
-bool copy_to(SkBitmap* dst, SkColorType dstColorType, const SkBitmap& src) {
- SkPixmap srcPM;
- if (!src.peekPixels(&srcPM)) {
- return false;
- }
-
- SkBitmap tmpDst;
- SkImageInfo dstInfo = srcPM.info().makeColorType(dstColorType);
- if (!tmpDst.setInfo(dstInfo)) {
- return false;
- }
-
- if (!tmpDst.tryAllocPixels()) {
- return false;
- }
-
- SkPixmap dstPM;
- if (!tmpDst.peekPixels(&dstPM)) {
- return false;
- }
-
- if (!srcPM.readPixels(dstPM)) {
- return false;
- }
-
- dst->swap(tmpDst);
- return true;
-}
-
-void copy_to_g8(SkBitmap* dst, const SkBitmap& src) {
- SkASSERT(kBGRA_8888_SkColorType == src.colorType() ||
- kRGBA_8888_SkColorType == src.colorType());
-
- SkImageInfo grayInfo = src.info().makeColorType(kGray_8_SkColorType);
- dst->allocPixels(grayInfo);
- uint8_t* dst8 = (uint8_t*)dst->getPixels();
- const uint32_t* src32 = (const uint32_t*)src.getPixels();
-
- const int w = src.width();
- const int h = src.height();
- const bool isBGRA = (kBGRA_8888_SkColorType == src.colorType());
- for (int y = 0; y < h; ++y) {
- if (isBGRA) {
- // BGRA
- for (int x = 0; x < w; ++x) {
- uint32_t s = src32[x];
- dst8[x] = SkComputeLuminance((s >> 16) & 0xFF, (s >> 8) & 0xFF, s & 0xFF);
- }
- } else {
- // RGBA
- for (int x = 0; x < w; ++x) {
- uint32_t s = src32[x];
- dst8[x] = SkComputeLuminance(s & 0xFF, (s >> 8) & 0xFF, (s >> 16) & 0xFF);
- }
- }
- src32 = (const uint32_t*)((const char*)src32 + src.rowBytes());
- dst8 += dst->rowBytes();
- }
-}
-
- //////////////////////////////////////////////////////////////////////////////////////////////
-
- bool equal_pixels(const SkPixmap& a, const SkPixmap& b) {
- if (a.width() != b.width() ||
- a.height() != b.height() ||
- a.colorType() != b.colorType())
- {
- return false;
- }
-
- for (int y = 0; y < a.height(); ++y) {
- const char* aptr = (const char*)a.addr(0, y);
- const char* bptr = (const char*)b.addr(0, y);
- if (memcmp(aptr, bptr, a.width() * a.info().bytesPerPixel())) {
- return false;
- }
- aptr += a.rowBytes();
- bptr += b.rowBytes();
- }
- return true;
- }
-
- bool equal_pixels(const SkBitmap& bm0, const SkBitmap& bm1) {
- SkPixmap pm0, pm1;
- return bm0.peekPixels(&pm0) && bm1.peekPixels(&pm1) && equal_pixels(pm0, pm1);
- }
-
- bool equal_pixels(const SkImage* a, const SkImage* b) {
- // ensure that peekPixels will succeed
- auto imga = a->makeRasterImage();
- auto imgb = b->makeRasterImage();
-
- SkPixmap pm0, pm1;
- return imga->peekPixels(&pm0) && imgb->peekPixels(&pm1) && equal_pixels(pm0, pm1);
- }
-
- sk_sp<SkSurface> makeSurface(SkCanvas* canvas, const SkImageInfo& info,
- const SkSurfaceProps* props) {
- auto surf = canvas->makeSurface(info, props);
- if (!surf) {
- surf = SkSurface::MakeRaster(info, props);
- }
- return surf;
- }
-} // namespace sk_tool_utils
diff --git a/tools/sk_tool_utils.h b/tools/sk_tool_utils.h
deleted file mode 100644
index da93872..0000000
--- a/tools/sk_tool_utils.h
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef sk_tool_utils_DEFINED
-#define sk_tool_utils_DEFINED
-
-#include "SkColor.h"
-#include "SkData.h"
-#include "SkEncodedImageFormat.h"
-#include "SkFont.h"
-#include "SkFontStyle.h"
-#include "SkFontTypes.h"
-#include "SkImageEncoder.h"
-#include "SkImageInfo.h"
-#include "SkRandom.h"
-#include "SkRect.h"
-#include "SkRefCnt.h"
-#include "SkScalar.h"
-#include "SkStream.h"
-#include "SkTArray.h"
-#include "SkTDArray.h"
-#include "SkTypeface.h"
-#include "SkTypes.h"
-
-class SkBitmap;
-class SkCanvas;
-class SkFontStyle;
-class SkImage;
-class SkPath;
-class SkPixmap;
-class SkRRect;
-class SkShader;
-class SkSurface;
-class SkSurfaceProps;
-class SkTextBlobBuilder;
-class SkTypeface;
-
-namespace sk_tool_utils {
-
- const char* alphatype_name(SkAlphaType);
- const char* colortype_name(SkColorType);
-
- /**
- * Map opaque colors from 8888 to 565.
- */
- SkColor color_to_565(SkColor color);
-
- /* Return a color emoji typeface with planets to scale if available. */
- sk_sp<SkTypeface> planet_typeface();
-
- /** Return a color emoji typeface if available. */
- sk_sp<SkTypeface> emoji_typeface();
-
- /** Sample text for the emoji_typeface font. */
- const char* emoji_sample_text();
-
- /**
- * Returns a platform-independent text renderer.
- */
- sk_sp<SkTypeface> create_portable_typeface(const char* name, SkFontStyle style);
-
- static inline sk_sp<SkTypeface> create_portable_typeface() {
- return create_portable_typeface(nullptr, SkFontStyle());
- }
-
- void get_text_path(const SkFont&, const void* text, size_t length, SkTextEncoding, SkPath*,
- const SkPoint* positions = nullptr);
-
- /**
- * Call writePixels() by using the pixels from bitmap, but with an info that claims
- * the pixels are colorType + alphaType
- */
- void write_pixels(SkCanvas*, const SkBitmap&, int x, int y, SkColorType, SkAlphaType);
- void write_pixels(SkSurface*, const SkBitmap&, int x, int y, SkColorType, SkAlphaType);
-
- /**
- * Returns true iff all of the pixels between the two images are identical.
- *
- * If the configs differ, return false.
- */
- bool equal_pixels(const SkPixmap&, const SkPixmap&);
- bool equal_pixels(const SkBitmap&, const SkBitmap&);
- bool equal_pixels(const SkImage* a, const SkImage* b);
-
- /** Returns a newly created CheckerboardShader. */
- sk_sp<SkShader> create_checkerboard_shader(SkColor c1, SkColor c2, int size);
-
- /** Draw a checkerboard pattern in the current canvas, restricted to
- the current clip, using SkXfermode::kSrc_Mode. */
- void draw_checkerboard(SkCanvas* canvas,
- SkColor color1,
- SkColor color2,
- 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);
-
- // If the canvas does't make a surface (e.g. recording), make a raster surface
- sk_sp<SkSurface> makeSurface(SkCanvas*, const SkImageInfo&, const SkSurfaceProps* = nullptr);
-
- // A helper for inserting a drawtext call into a SkTextBlobBuilder
- void add_to_text_blob_w_len(SkTextBlobBuilder*, const char* text, size_t len, SkTextEncoding,
- const SkFont&, SkScalar x, SkScalar y);
-
- void add_to_text_blob(SkTextBlobBuilder*, const char* text, const SkFont&,
- SkScalar x, SkScalar y);
-
- // Constructs a star by walking a 'numPts'-sided regular polygon with even/odd fill:
- //
- // moveTo(pts[0]);
- // lineTo(pts[step % numPts]);
- // ...
- // lineTo(pts[(step * (N - 1)) % numPts]);
- //
- // numPts=5, step=2 will produce a classic five-point star.
- //
- // numPts and step must be co-prime.
- SkPath make_star(const SkRect& bounds, int numPts = 5, int step = 2);
-
- void create_hemi_normal_map(SkBitmap* bm, const SkIRect& dst);
-
- void create_frustum_normal_map(SkBitmap* bm, const SkIRect& dst);
-
- void create_tetra_normal_map(SkBitmap* bm, const SkIRect& dst);
-
- void make_big_path(SkPath& path);
-
- // A helper object to test the topological sorting code (TopoSortBench.cpp & TopoSortTest.cpp)
- class TopoTestNode : public SkRefCnt {
- public:
- TopoTestNode(int id) : fID(id), fOutputPos(-1), fTempMark(false) { }
-
- void dependsOn(TopoTestNode* src) {
- *fDependencies.append() = src;
- }
-
- int id() const { return fID; }
- void reset() { fOutputPos = -1; }
-
- int outputPos() const { return fOutputPos; }
-
- // check that the topological sort is valid for this node
- bool check() {
- if (-1 == fOutputPos) {
- return false;
- }
-
- for (int i = 0; i < fDependencies.count(); ++i) {
- if (-1 == fDependencies[i]->outputPos()) {
- return false;
- }
- // This node should've been output after all the nodes on which it depends
- if (fOutputPos < fDependencies[i]->outputPos()) {
- return false;
- }
- }
-
- return true;
- }
-
- // The following 7 methods are needed by the topological sort
- static void SetTempMark(TopoTestNode* node) { node->fTempMark = true; }
- static void ResetTempMark(TopoTestNode* node) { node->fTempMark = false; }
- static bool IsTempMarked(TopoTestNode* node) { return node->fTempMark; }
- static void Output(TopoTestNode* node, int outputPos) {
- SkASSERT(-1 != outputPos);
- node->fOutputPos = outputPos;
- }
- static bool WasOutput(TopoTestNode* node) { return (-1 != node->fOutputPos); }
- static int NumDependencies(TopoTestNode* node) { return node->fDependencies.count(); }
- static TopoTestNode* Dependency(TopoTestNode* node, int index) {
- return node->fDependencies[index];
- }
-
- // Helper functions for TopoSortBench & TopoSortTest
- static void AllocNodes(SkTArray<sk_sp<sk_tool_utils::TopoTestNode>>* graph, int num) {
- graph->reserve(num);
-
- for (int i = 0; i < num; ++i) {
- graph->push_back(sk_sp<TopoTestNode>(new TopoTestNode(i)));
- }
- }
-
-#ifdef SK_DEBUG
- static void Print(const SkTArray<TopoTestNode*>& graph) {
- for (int i = 0; i < graph.count(); ++i) {
- SkDebugf("%d, ", graph[i]->id());
- }
- SkDebugf("\n");
- }
-#endif
-
- // randomize the array
- static void Shuffle(SkTArray<sk_sp<TopoTestNode>>* graph, SkRandom* rand) {
- for (int i = graph->count()-1; i > 0; --i) {
- int swap = rand->nextU() % (i+1);
-
- (*graph)[i].swap((*graph)[swap]);
- }
- }
-
- private:
- int fID;
- int fOutputPos;
- bool fTempMark;
-
- SkTDArray<TopoTestNode*> fDependencies;
- };
-
- template <typename T>
- inline bool EncodeImageToFile(const char* path, const T& src, SkEncodedImageFormat f, int q) {
- SkFILEWStream file(path);
- return file.isValid() && SkEncodeImage(&file, src, f, q);
- }
-
- bool copy_to(SkBitmap* dst, SkColorType dstCT, const SkBitmap& src);
- void copy_to_g8(SkBitmap* dst, const SkBitmap& src);
-} // namespace sk_tool_utils
-
-#endif // sk_tool_utils_DEFINED
diff --git a/tools/skdiff/skdiff_utils.cpp b/tools/skdiff/skdiff_utils.cpp
index 18682c0..342af99 100644
--- a/tools/skdiff/skdiff_utils.cpp
+++ b/tools/skdiff/skdiff_utils.cpp
@@ -4,15 +4,15 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "skdiff.h"
#include "skdiff_utils.h"
-#include "sk_tool_utils.h"
#include "SkBitmap.h"
#include "SkCodec.h"
#include "SkData.h"
#include "SkImageEncoder.h"
#include "SkStream.h"
#include "SkTypes.h"
+#include "ToolUtils.h"
+#include "skdiff.h"
#include <memory>
@@ -92,10 +92,9 @@
bool write_bitmap(const SkString& path, const SkBitmap& bitmap) {
SkBitmap copy;
- sk_tool_utils::copy_to(©, kN32_SkColorType, bitmap);
+ ToolUtils::copy_to(©, kN32_SkColorType, bitmap);
force_all_opaque(copy);
- return sk_tool_utils::EncodeImageToFile(path.c_str(), copy,
- SkEncodedImageFormat::kPNG, 100);
+ return ToolUtils::EncodeImageToFile(path.c_str(), copy, SkEncodedImageFormat::kPNG, 100);
}
/// Return a copy of the "input" string, within which we have replaced all instances
diff --git a/tools/skiaserve/Request.cpp b/tools/skiaserve/Request.cpp
index d1286be..89947e1 100644
--- a/tools/skiaserve/Request.cpp
+++ b/tools/skiaserve/Request.cpp
@@ -9,7 +9,7 @@
#include "SkJSONWriter.h"
#include "SkPictureRecorder.h"
-#include "sk_tool_utils.h"
+#include "ToolUtils.h"
using namespace sk_gpu_test;
diff --git a/tools/skpbench/skpbench.cpp b/tools/skpbench/skpbench.cpp
index b0da85a..442e7dd 100644
--- a/tools/skpbench/skpbench.cpp
+++ b/tools/skpbench/skpbench.cpp
@@ -26,9 +26,9 @@
#include "SkSurface.h"
#include "SkSurfaceProps.h"
#include "SkTaskGroup.h"
+#include "ToolUtils.h"
#include "flags/CommandLineFlags.h"
#include "flags/CommonFlagsConfig.h"
-#include "sk_tool_utils.h"
#ifdef SK_XML
#include "SkDOM.h"
@@ -473,7 +473,7 @@
if (!mkdir_p(SkOSPath::Dirname(FLAGS_png[0]))) {
exitf(ExitErr::kIO, "failed to create directory for png \"%s\"", FLAGS_png[0]);
}
- if (!sk_tool_utils::EncodeImageToFile(FLAGS_png[0], bmp, SkEncodedImageFormat::kPNG, 100)) {
+ if (!ToolUtils::EncodeImageToFile(FLAGS_png[0], bmp, SkEncodedImageFormat::kPNG, 100)) {
exitf(ExitErr::kIO, "failed to save png to \"%s\"", FLAGS_png[0]);
}
}
@@ -500,7 +500,7 @@
// Use a big path to (theoretically) warmup the CPU.
SkPath bigPath;
- sk_tool_utils::make_big_path(bigPath);
+ ToolUtils::make_big_path(bigPath);
recording->drawPath(bigPath, stroke);
// Use a perlin shader to warmup the GPU.
diff --git a/tools/skqp/src/skqp.cpp b/tools/skqp/src/skqp.cpp
index 6cb5a20..4bf57e2 100644
--- a/tools/skqp/src/skqp.cpp
+++ b/tools/skqp/src/skqp.cpp
@@ -245,7 +245,7 @@
fReportDirectory = reportDirectory;
SkGraphics::Init();
- gSkFontMgr_DefaultFactory = &sk_tool_utils::MakePortableFontMgr;
+ gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr;
/* If the file "skqp/rendertests.txt" does not exist or is empty, run all
render tests. Otherwise only run tests mentioned in that file. */
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index be94d9b..e3c6124 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -239,7 +239,7 @@
#endif
if (!FLAGS_nativeFonts) {
- gSkFontMgr_DefaultFactory = &sk_tool_utils::MakePortableFontMgr;
+ gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr;
}
initializeEventTracingForTools();