alternate textblobgeometrychange fix... just make our own surface if needed
This should decopple fixing the replay modes from revising the API.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1868553005
Review URL: https://codereview.chromium.org/1868553005
diff --git a/gm/textblobgeometrychange.cpp b/gm/textblobgeometrychange.cpp
index b1c5b17..b02bc07 100644
--- a/gm/textblobgeometrychange.cpp
+++ b/gm/textblobgeometrychange.cpp
@@ -47,28 +47,24 @@
uint32_t allowSRGBInputs = canvas->getProps(&canvasProps)
? canvasProps.flags() & SkSurfaceProps::kAllowSRGBInputs_Flag : 0;
SkSurfaceProps props(allowSRGBInputs, kUnknown_SkPixelGeometry);
- auto surface(canvas->makeSurface(info, &props));
- if (surface) {
- SkCanvas* c = surface->getCanvas();
-
- // LCD text on white background
- SkRect rect = SkRect::MakeLTRB(0.f, 0.f, SkIntToScalar(kWidth), kHeight / 2.f);
- SkPaint rectPaint;
- rectPaint.setColor(0xffffffff);
- canvas->drawRect(rect, rectPaint);
- canvas->drawTextBlob(blob.get(), 10, 50, paint);
-
- // This should not look garbled since we should disable LCD text in this case
- // (i.e., unknown pixel geometry)
- c->clear(0x00ffffff);
- c->drawTextBlob(blob.get(), 10, 150, paint);
- surface->draw(canvas, 0, 0, nullptr);
- } else {
- const char* text = "This test requires a surface";
- size_t len = strlen(text);
- SkPaint paint;
- canvas->drawText(text, len, 10, 100, paint);
+ auto surface = canvas->makeSurface(info, &props);
+ if (!surface) {
+ surface = SkSurface::MakeRaster(info, &props);
}
+ SkCanvas* c = surface->getCanvas();
+
+ // LCD text on white background
+ SkRect rect = SkRect::MakeLTRB(0.f, 0.f, SkIntToScalar(kWidth), kHeight / 2.f);
+ SkPaint rectPaint;
+ rectPaint.setColor(0xffffffff);
+ canvas->drawRect(rect, rectPaint);
+ canvas->drawTextBlob(blob.get(), 10, 50, paint);
+
+ // This should not look garbled since we should disable LCD text in this case
+ // (i.e., unknown pixel geometry)
+ c->clear(0x00ffffff);
+ c->drawTextBlob(blob.get(), 10, 150, paint);
+ surface->draw(canvas, 0, 0, nullptr);
}
private: