skia2/gm/skbug_12212.cpp
John Stiles 68c9325263 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>
2021-07-30 17:41:13 +00:00

41 lines
1.5 KiB
C++

/*
* 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);
}