allow GMs to fail in DM
And mark atlastext as GPU-only, so it's skipped instead of running and failing on non-GPU --configs. Change-Id: I9b41873bed14e20f2e086a04f57b247994e9266e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/205347 Commit-Queue: Mike Klein <mtklein@google.com> Auto-Submit: Mike Klein <mtklein@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
f7cdb682bd
commit
16b1efb871
@ -95,7 +95,7 @@ Error GMSrc::draw(SkCanvas* canvas) const {
|
||||
if (skiagm::DrawResult::kSkip == drawResult) {
|
||||
return Error::Nonfatal(std::move(errorMsg)); // Cause this test to be skipped.
|
||||
}
|
||||
return "";
|
||||
return errorMsg;
|
||||
}
|
||||
|
||||
SkISize GMSrc::size() const {
|
||||
|
@ -54,7 +54,7 @@ static SkScalar draw_string(SkAtlasTextTarget* target, const SkString& text, SkS
|
||||
return positions[cnt - 1].fX + widths[cnt - 1] - positions[0].fX;
|
||||
}
|
||||
|
||||
class AtlasTextGM : public skiagm::GM {
|
||||
class AtlasTextGM : public skiagm::GpuGM {
|
||||
public:
|
||||
AtlasTextGM() = default;
|
||||
|
||||
@ -84,9 +84,16 @@ protected:
|
||||
fTypefaces[5] = ToolUtils::create_portable_typeface("sans-serif", SkFontStyle::Bold());
|
||||
}
|
||||
|
||||
DrawResult onDraw(SkCanvas* canvas, SkString* errorMsg) override {
|
||||
if (!fRenderer || !fTarget || !fTarget->handle()) {
|
||||
*errorMsg = "No renderer and/or target.";
|
||||
DrawResult onDraw(GrContext*,
|
||||
GrRenderTargetContext*,
|
||||
SkCanvas* canvas,
|
||||
SkString* errorMsg) override {
|
||||
if (!fRenderer) {
|
||||
*errorMsg = "No renderer... probably not supported.";
|
||||
return DrawResult::kSkip;
|
||||
}
|
||||
if (!fTarget || !fTarget->handle()) {
|
||||
*errorMsg = "No target... we can't continue.";
|
||||
return DrawResult::kFail;
|
||||
}
|
||||
fRenderer->clearTarget(fTarget->handle(), 0xFF808080);
|
||||
|
@ -52,8 +52,7 @@ protected:
|
||||
SkIntToScalar(width + height) / 5, paint);
|
||||
}
|
||||
|
||||
sk_sp<SkImage> createRectangleTextureImg(GrContext* context, GrSurfaceOrigin origin, int width,
|
||||
int height, const uint32_t* pixels) {
|
||||
static const GrGLContext* GetGLContextIfSupported(GrContext* context) {
|
||||
GrGpu* gpu = context->priv().getGpu();
|
||||
if (!gpu) {
|
||||
return nullptr;
|
||||
@ -68,6 +67,15 @@ protected:
|
||||
glCtx->hasExtension("GL_ANGLE_texture_rectangle"))) {
|
||||
return nullptr;
|
||||
}
|
||||
return glCtx;
|
||||
}
|
||||
|
||||
sk_sp<SkImage> createRectangleTextureImg(GrContext* context, GrSurfaceOrigin origin, int width,
|
||||
int height, const uint32_t* pixels) {
|
||||
const GrGLContext* glCtx = GetGLContextIfSupported(context);
|
||||
if (!glCtx) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// We will always create the GL texture as GL_RGBA, however the pixels uploaded may be
|
||||
// be RGBA or BGRA, depending on how SkPMColor was compiled.
|
||||
@ -119,6 +127,11 @@ protected:
|
||||
|
||||
DrawResult onDraw(GrContext* context, GrRenderTargetContext*, SkCanvas* canvas,
|
||||
SkString* errorMsg) override {
|
||||
if (!GetGLContextIfSupported(context)) {
|
||||
*errorMsg = "this GM requires an OpenGL 3.1+ context";
|
||||
return DrawResult::kSkip;
|
||||
}
|
||||
|
||||
constexpr int kWidth = 50;
|
||||
constexpr int kHeight = 50;
|
||||
constexpr SkScalar kPad = 5.f;
|
||||
|
Loading…
Reference in New Issue
Block a user