Create test case to repro skia:12212.
Change-Id: I2dde12b262f51b00a95eb26f87b85c3f5a19b45b
Bug: skia:12212
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/428961
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/gm/skbug_12212.cpp b/gm/skbug_12212.cpp
new file mode 100644
index 0000000..51caff7
--- /dev/null
+++ b/gm/skbug_12212.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2021 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gm/gm.h"
+#include "include/core/SkCanvas.h"
+#include "include/core/SkFont.h"
+#include "include/core/SkPaint.h"
+#include "include/core/SkRect.h"
+#include "include/core/SkSurface.h"
+#include "include/core/SkTextBlob.h"
+
+DEF_SIMPLE_GM_BG(skbug_12212, canvas, 400, 400, SK_ColorCYAN) {
+ // Create an Alpha_8 surface to draw into (strangely, with RGB pixel geometry).
+ auto imageInfo = SkImageInfo::Make(/*width=*/400, /*height=*/400, kAlpha_8_SkColorType,
+ kPremul_SkAlphaType);
+ SkSurfaceProps props(/*flags=*/0, kRGB_H_SkPixelGeometry);
+ sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(
+ canvas->recordingContext(), SkBudgeted::kNo, imageInfo, /*sampleCount=*/0, &props);
+ if (!surface) {
+ surface = SkSurface::MakeRaster(imageInfo, &props);
+ }
+
+ // Draw text into the surface using LCD antialiasing.
+ SkPaint p;
+ p.setAntiAlias(true);
+ p.setBlendMode(SkBlendMode::kSrc);
+ p.setAlpha(0x80);
+ SkFont font{};
+ font = font.makeWithSize(170);
+ font.setEdging(SkFont::Edging::kSubpixelAntiAlias);
+ auto textBlob = SkTextBlob::MakeFromText("text", /*byteLength=*/4, font);
+ surface->getCanvas()->drawTextBlob(textBlob, /*x=*/50, /*y=*/350, p);
+
+ // Draw the surface on our main canvas.
+ surface->draw(canvas, /*x=*/0, /*y=*/0);
+}
diff --git a/gn/gm.gni b/gn/gm.gni
index 302a69b..97cb065 100644
--- a/gn/gm.gni
+++ b/gn/gm.gni
@@ -331,6 +331,7 @@
"$_gm/simpleaaclip.cpp",
"$_gm/simplerect.cpp",
"$_gm/skbug1719.cpp",
+ "$_gm/skbug_12212.cpp",
"$_gm/skbug_257.cpp",
"$_gm/skbug_4868.cpp",
"$_gm/skbug_5321.cpp",