Retract the SDC from GMs where possible

In the future, the SDC won't be return by SkCanvas/SkDevices and gms/tests that rely on it won't be run. These GMs don't actually require the SDC.

There is also some opportunistic renaming going on.

Change-Id: Ib137232f4352fce586105298cda00a697d2efade
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/414902
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
This commit is contained in:
Robert Phillips 2021-06-02 16:32:40 -04:00 committed by Skia Commit-Bot
parent 0d41b1f52d
commit b8416d27be
16 changed files with 130 additions and 112 deletions

View File

@ -243,15 +243,15 @@ private:
////////////////////////////////////////////////////////////////////////////////////////////////////
// Test.
void ClockwiseGM::onDraw(GrRecordingContext* ctx, GrSurfaceDrawContext* rtc, SkCanvas* canvas) {
rtc->clear(SK_PMColor4fBLACK);
void ClockwiseGM::onDraw(GrRecordingContext* ctx, GrSurfaceDrawContext* sdc, SkCanvas* canvas) {
sdc->clear(SK_PMColor4fBLACK);
// Draw the test directly to the frame buffer.
rtc->addDrawOp(ClockwiseTestOp::Make(ctx, false, 0));
rtc->addDrawOp(ClockwiseTestOp::Make(ctx, true, 100));
sdc->addDrawOp(ClockwiseTestOp::Make(ctx, false, 0));
sdc->addDrawOp(ClockwiseTestOp::Make(ctx, true, 100));
// Draw the test to an off-screen, top-down render target.
GrColorType rtcColorType = rtc->colorInfo().colorType();
GrColorType rtcColorType = sdc->colorInfo().colorType();
if (auto topLeftRTC = GrSurfaceDrawContext::Make(
ctx, rtcColorType, nullptr, SkBackingFit::kExact, {100, 200}, SkSurfaceProps(),
1, GrMipmapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin,
@ -259,9 +259,9 @@ void ClockwiseGM::onDraw(GrRecordingContext* ctx, GrSurfaceDrawContext* rtc, SkC
topLeftRTC->clear(SK_PMColor4fTRANSPARENT);
topLeftRTC->addDrawOp(ClockwiseTestOp::Make(ctx, false, 0));
topLeftRTC->addDrawOp(ClockwiseTestOp::Make(ctx, true, 100));
rtc->drawTexture(nullptr,
sdc->drawTexture(nullptr,
topLeftRTC->readSurfaceView(),
rtc->colorInfo().alphaType(),
sdc->colorInfo().alphaType(),
GrSamplerState::Filter::kNearest,
GrSamplerState::MipmapMode::kNone,
SkBlendMode::kSrcOver,
@ -283,9 +283,9 @@ void ClockwiseGM::onDraw(GrRecordingContext* ctx, GrSurfaceDrawContext* rtc, SkC
topLeftRTC->clear(SK_PMColor4fTRANSPARENT);
topLeftRTC->addDrawOp(ClockwiseTestOp::Make(ctx, false, 0));
topLeftRTC->addDrawOp(ClockwiseTestOp::Make(ctx, true, 100));
rtc->drawTexture(nullptr,
sdc->drawTexture(nullptr,
topLeftRTC->readSurfaceView(),
rtc->colorInfo().alphaType(),
sdc->colorInfo().alphaType(),
GrSamplerState::Filter::kNearest,
GrSamplerState::MipmapMode::kNone,
SkBlendMode::kSrcOver,

View File

@ -29,7 +29,7 @@ namespace skiagm {
* This GM exercises SkCanvas::discard() by creating an offscreen SkSurface and repeatedly
* discarding it, drawing to it, and then drawing it to the main canvas.
*/
class DiscardGM : public GpuGM {
class DiscardGM : public GM {
public:
DiscardGM() {}
@ -43,10 +43,9 @@ protected:
return SkISize::Make(100, 100);
}
DrawResult onDraw(GrRecordingContext* context, GrSurfaceDrawContext*, SkCanvas* canvas,
SkString* errorMsg) override {
auto direct = context->asDirectContext();
if (!direct) {
DrawResult onDraw(SkCanvas* canvas, SkString* errorMsg) override {
auto dContext = GrAsDirectContext(canvas->recordingContext());
if (!dContext) {
*errorMsg = "GM relies on having access to a live direct context.";
return DrawResult::kSkip;
}
@ -55,7 +54,7 @@ protected:
size.fWidth /= 10;
size.fHeight /= 10;
SkImageInfo info = SkImageInfo::MakeN32Premul(size);
sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(direct, SkBudgeted::kNo, info);
sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(dContext, SkBudgeted::kNo, info);
if (nullptr == surface) {
*errorMsg = "Could not create render target.";
return DrawResult::kFail;

View File

@ -82,7 +82,7 @@ static const SkMatrix kUVMatrices[kNumMatrices] = {
// Create a fixed size text label like "LL" or "LR".
static sk_sp<SkImage> make_text_image(GrDirectContext* direct, const char* text, SkColor color) {
static sk_sp<SkImage> make_text_image(GrDirectContext* dContext, const char* text, SkColor color) {
SkPaint paint;
paint.setAntiAlias(true);
paint.setColor(color);
@ -107,12 +107,12 @@ static sk_sp<SkImage> make_text_image(GrDirectContext* direct, const char* text,
sk_sp<SkImage> image = surf->makeImageSnapshot();
return image->makeTextureImage(direct);
return image->makeTextureImage(dContext);
}
// Create an image with each corner marked w/ "LL", "LR", etc., with the origin either bottom-left
// or top-left.
static sk_sp<SkImage> make_reference_image(GrDirectContext* context,
static sk_sp<SkImage> make_reference_image(GrDirectContext* dContext,
const SkTArray<sk_sp<SkImage>>& labels,
bool bottomLeftOrigin) {
SkASSERT(kNumLabels == labels.count());
@ -132,13 +132,13 @@ static sk_sp<SkImage> make_reference_image(GrDirectContext* context,
auto origin = bottomLeftOrigin ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin;
auto view = sk_gpu_test::MakeTextureProxyViewFromData(context, GrRenderable::kNo, origin,
auto view = sk_gpu_test::MakeTextureProxyViewFromData(dContext, GrRenderable::kNo, origin,
bm.pixmap());
if (!view) {
return nullptr;
}
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(context),
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(dContext),
kNeedNewImageUniqueID,
std::move(view),
ii.colorInfo());
@ -164,7 +164,7 @@ static bool UVMatToGeomMatForImage(SkMatrix* geomMat, const SkMatrix& uvMat) {
// This GM exercises drawImage with a set of matrices that use an unusual amount of flips and
// rotates.
class FlippityGM : public skiagm::GpuGM {
class FlippityGM : public skiagm::GM {
public:
FlippityGM() {
this->setBGColor(0xFFCCCCCC);
@ -230,7 +230,7 @@ private:
canvas->restore();
}
void makeLabels(GrDirectContext* direct) {
void makeLabels(GrDirectContext* dContext) {
if (fLabels.count()) {
return;
}
@ -245,19 +245,20 @@ private:
};
for (int i = 0; i < kNumLabels; ++i) {
fLabels.push_back(make_text_image(direct, kLabelText[i], kLabelColors[i]));
fLabels.push_back(make_text_image(dContext, kLabelText[i], kLabelColors[i]));
}
SkASSERT(kNumLabels == fLabels.count());
}
DrawResult onGpuSetup(GrDirectContext* context, SkString* errorMsg) override {
if (!context || context->abandoned()) {
DrawResult onGpuSetup(GrDirectContext* dContext, SkString* errorMsg) override {
if (!dContext || dContext->abandoned()) {
*errorMsg = "DirectContext required to create reference images";
return DrawResult::kSkip;
}
this->makeLabels(context);
fReferenceImages[0] = make_reference_image(context, fLabels, false);
fReferenceImages[1] = make_reference_image(context, fLabels, true);
this->makeLabels(dContext);
fReferenceImages[0] = make_reference_image(dContext, fLabels, false);
fReferenceImages[1] = make_reference_image(dContext, fLabels, true);
if (!fReferenceImages[0] || !fReferenceImages[1]) {
*errorMsg = "Failed to create reference images.";
return DrawResult::kFail;
@ -271,7 +272,7 @@ private:
fReferenceImages[0] = fReferenceImages[1] = nullptr;
}
void onDraw(GrRecordingContext*, GrSurfaceDrawContext*, SkCanvas* canvas) override {
void onDraw(SkCanvas* canvas) override {
SkASSERT(fReferenceImages[0] && fReferenceImages[1]);
canvas->save();

View File

@ -35,7 +35,7 @@ static SkScalar draw_string(SkCanvas* canvas, const SkString& text, SkScalar x,
return x + font.measureText(text.c_str(), text.size(), SkTextEncoding::kUTF8);
}
class FontCacheGM : public skiagm::GpuGM {
class FontCacheGM : public skiagm::GM {
public:
FontCacheGM(GrContextOptions::Enable allowMultipleTextures)
: fAllowMultipleTextures(allowMultipleTextures) {
@ -67,13 +67,13 @@ protected:
fTypefaces[5] = ToolUtils::create_portable_typeface("sans-serif", SkFontStyle::Bold());
}
void onDraw(GrRecordingContext*, GrSurfaceDrawContext*, SkCanvas* canvas) override {
void onDraw(SkCanvas* canvas) override {
this->drawText(canvas);
// Debugging tool for GPU.
static const bool kShowAtlas = false;
if (kShowAtlas) {
if (auto direct = GrAsDirectContext(canvas->recordingContext())) {
auto img = direct->priv().testingOnly_getFontAtlasImage(kA8_GrMaskFormat);
if (auto dContext = GrAsDirectContext(canvas->recordingContext())) {
auto img = dContext->priv().testingOnly_getFontAtlasImage(kA8_GrMaskFormat);
canvas->drawImage(img, 0, 0);
}
}

View File

@ -48,7 +48,7 @@ static sk_sp<SkTextBlob> make_blob(const SkString& text, const SkFont& font) {
return SkTextBlob::MakeFromPosTextH(text.c_str(), len, pos.get(), 0, font);
}
class FontRegenGM : public skiagm::GpuGM {
class FontRegenGM : public skiagm::GM {
void modifyGrContextOptions(GrContextOptions* options) override {
options->fGlyphCacheTextureMaximumBytes = 0;
@ -82,17 +82,18 @@ class FontRegenGM : public skiagm::GpuGM {
fBlobs[2] = make_blob(kTexts[2], font);
}
void onDraw(GrRecordingContext* context, GrSurfaceDrawContext*, SkCanvas* canvas) override {
auto direct = context->asDirectContext();
if (!direct) {
return;
DrawResult onDraw(SkCanvas* canvas, SkString* errorMsg) override {
auto dContext = GrAsDirectContext(canvas->recordingContext());
if (!dContext) {
*errorMsg = "GPU-specific";
return DrawResult::kSkip;
}
SkPaint paint;
paint.setColor(SK_ColorBLACK);
canvas->drawTextBlob(fBlobs[0], 10, 80, paint);
canvas->drawTextBlob(fBlobs[1], 10, 225, paint);
direct->flushAndSubmit();
dContext->flushAndSubmit();
paint.setColor(0xFF010101);
canvas->drawTextBlob(fBlobs[0], 10, 305, paint);
@ -101,9 +102,11 @@ class FontRegenGM : public skiagm::GpuGM {
// Debugging tool for GPU.
static const bool kShowAtlas = false;
if (kShowAtlas) {
auto img = direct->priv().testingOnly_getFontAtlasImage(kA8_GrMaskFormat);
auto img = dContext->priv().testingOnly_getFontAtlasImage(kA8_GrMaskFormat);
canvas->drawImage(img, 200, 0);
}
return DrawResult::kOk;
}
private:
@ -119,7 +122,7 @@ DEF_GM(return new FontRegenGM())
///////////////////////////////////////////////////////////////////////////////
class BadAppleGM : public skiagm::GpuGM {
class BadAppleGM : public skiagm::GM {
SkString onShortName() override { return SkString("badapple"); }
@ -143,7 +146,7 @@ class BadAppleGM : public skiagm::GpuGM {
fBlobs[1] = make_blob(kTexts[1], font);
}
void onDraw(GrRecordingContext* context, GrSurfaceDrawContext*, SkCanvas* canvas) override {
void onDraw(SkCanvas* canvas) override {
SkPaint paint;
paint.setColor(0xFF111111);
canvas->drawTextBlob(fBlobs[0], 10, 260, paint);

View File

@ -144,9 +144,9 @@ DrawResult SimpleGM::onDraw(SkCanvas* canvas, SkString* errorMsg) {
SkISize SimpleGpuGM::onISize() { return fSize; }
SkString SimpleGpuGM::onShortName() { return fName; }
DrawResult SimpleGpuGM::onDraw(GrRecordingContext* ctx, GrSurfaceDrawContext* rtc,
DrawResult SimpleGpuGM::onDraw(GrRecordingContext* rContext, GrSurfaceDrawContext* sdc,
SkCanvas* canvas, SkString* errorMsg) {
return fDrawProc(ctx, rtc, canvas, errorMsg);
return fDrawProc(rContext, sdc, canvas, errorMsg);
}
const char* GM::getName() {
@ -189,9 +189,9 @@ void GM::drawSizeBounds(SkCanvas* canvas, SkColor color) {
// need to explicitly declare this, or we get some weird infinite loop llist
template GMRegistry* GMRegistry::gHead;
DrawResult GpuGM::onDraw(GrRecordingContext* ctx, GrSurfaceDrawContext* rtc, SkCanvas* canvas,
DrawResult GpuGM::onDraw(GrRecordingContext* rContext, GrSurfaceDrawContext* sdc, SkCanvas* canvas,
SkString* errorMsg) {
this->onDraw(ctx, rtc, canvas);
this->onDraw(rContext, sdc, canvas);
return DrawResult::kOk;
}
void GpuGM::onDraw(GrRecordingContext*, GrSurfaceDrawContext*, SkCanvas*) {

View File

@ -244,7 +244,7 @@ namespace skiagm {
private:
SkISize onISize() override;
SkString onShortName() override;
DrawResult onDraw(GrRecordingContext* ctx, GrSurfaceDrawContext* rtc, SkCanvas* canvas,
DrawResult onDraw(GrRecordingContext*, GrSurfaceDrawContext*, SkCanvas*,
SkString* errorMsg) override;
const SkString fName;

View File

@ -34,7 +34,7 @@
class GrSurfaceDrawContext;
namespace skiagm {
class ImageFromYUVTextures : public GpuGM {
class ImageFromYUVTextures : public GM {
public:
ImageFromYUVTextures() {
this->setBGColor(0xFFFFFFFF);
@ -148,8 +148,9 @@ protected:
return resultSurface->makeImageSnapshot();
}
DrawResult onGpuSetup(GrDirectContext* context, SkString* errorMsg) override {
if (!context || context->abandoned()) {
DrawResult onGpuSetup(GrDirectContext* dContext, SkString* errorMsg) override {
if (!dContext || dContext->abandoned()) {
*errorMsg = "DirectContext required to create YUV images";
return DrawResult::kSkip;
}
@ -160,14 +161,14 @@ protected:
// We make a version of this image for each draw because, if any draw flattens it to
// RGBA, then all subsequent draws would use the RGBA texture.
for (int i = 0; i < kNumImages; ++i) {
fYUVAImages[i] = this->makeYUVAImage(context);
fYUVAImages[i] = this->makeYUVAImage(dContext);
if (!fYUVAImages[i]) {
*errorMsg = "Couldn't create src YUVA image.";
return DrawResult::kFail;
}
}
fReferenceImage = this->createReferenceImage(context);
fReferenceImage = this->createReferenceImage(dContext);
if (!fReferenceImage) {
*errorMsg = "Couldn't create reference YUVA image.";
return DrawResult::kFail;
@ -176,8 +177,8 @@ protected:
// Some backends (e.g., Vulkan) require all work be completed for backend textures
// before they are deleted. Since we don't know when we'll next have access to a
// direct context, flush all the work now.
context->flush();
context->submit(true);
dContext->flush();
dContext->submit(true);
return DrawResult::kOk;
}
@ -194,7 +195,7 @@ protected:
return fYUVAImages[index].get();
}
void onDraw(GrRecordingContext*, GrSurfaceDrawContext*, SkCanvas* canvas) override {
void onDraw(SkCanvas* canvas) override {
auto draw_image = [canvas](SkImage* image, const SkSamplingOptions& sampling) -> SkSize {
if (!image) {
return {0, 0};

View File

@ -43,7 +43,7 @@
class GrSurfaceDrawContext;
namespace skiagm {
class RectangleTexture : public GpuGM {
class RectangleTexture : public GM {
public:
RectangleTexture() {
this->setBGColor(0xFFFFFFFF);
@ -147,8 +147,7 @@ private:
fSmallImg = nullptr;
}
DrawResult onDraw(GrRecordingContext*, GrSurfaceDrawContext*, SkCanvas* canvas,
SkString*) override {
DrawResult onDraw(SkCanvas* canvas, SkString* errorMsg) override {
SkASSERT(fGradImgs[0] && fGradImgs[1] && fSmallImg);
static constexpr SkScalar kPad = 5.f;

View File

@ -357,13 +357,13 @@ static SkPath build_outset_triangle(const std::array<float, 3>* tri) {
return outset;
}
DrawResult TessellationGM::onDraw(GrRecordingContext* ctx, GrSurfaceDrawContext* rtc,
DrawResult TessellationGM::onDraw(GrRecordingContext* rContext, GrSurfaceDrawContext* sdc,
SkCanvas* canvas, SkString* errorMsg) {
if (!ctx->priv().caps()->shaderCaps()->tessellationSupport()) {
if (!rContext->priv().caps()->shaderCaps()->tessellationSupport()) {
*errorMsg = "Requires GPU tessellation support.";
return DrawResult::kSkip;
}
if (!ctx->priv().caps()->shaderCaps()->shaderDerivativeSupport()) {
if (!rContext->priv().caps()->shaderCaps()->shaderDerivativeSupport()) {
*errorMsg = "Requires shader derivatives."
"(These are expected to always be present when there is tessellation!!)";
return DrawResult::kFail;
@ -379,9 +379,9 @@ DrawResult TessellationGM::onDraw(GrRecordingContext* ctx, GrSurfaceDrawContext*
borderPaint.setColor4f({1,0,1,1});
canvas->drawRect(kRect.makeOutset(1.5f, 1.5f), borderPaint);
rtc->addDrawOp(GrOp::Make<TessellationTestOp>(ctx, canvas->getTotalMatrix(), kTri1));
rtc->addDrawOp(GrOp::Make<TessellationTestOp>(ctx, canvas->getTotalMatrix(), kTri2));
rtc->addDrawOp(GrOp::Make<TessellationTestOp>(ctx, canvas->getTotalMatrix(), nullptr));
sdc->addDrawOp(GrOp::Make<TessellationTestOp>(rContext, canvas->getTotalMatrix(), kTri1));
sdc->addDrawOp(GrOp::Make<TessellationTestOp>(rContext, canvas->getTotalMatrix(), kTri2));
sdc->addDrawOp(GrOp::Make<TessellationTestOp>(rContext, canvas->getTotalMatrix(), nullptr));
return skiagm::DrawResult::kOk;
}

View File

@ -34,7 +34,7 @@
class GrSurfaceDrawContext;
namespace skiagm {
class TextBlobRandomFont : public GpuGM {
class TextBlobRandomFont : public GM {
public:
// This gm tests that textblobs can be translated and scaled with a font that returns random
// but deterministic masks
@ -107,9 +107,14 @@ protected:
return SkISize::Make(kWidth, kHeight);
}
DrawResult onDraw(GrRecordingContext* context,
GrSurfaceDrawContext*, SkCanvas* canvas,
SkString* errorMsg) override {
DrawResult onDraw(SkCanvas* canvas, SkString* errorMsg) override {
if (!canvas->recordingContext()) {
*errorMsg = "Active context required to create SkSurface";
return DrawResult::kSkip;
}
auto dContext = GrAsDirectContext(canvas->recordingContext());
// This GM exists to test a specific feature of the GPU backend.
// This GM uses ToolUtils::makeSurface which doesn't work well with vias.
// This GM uses SkRandomTypeface which doesn't work well with serialization.
@ -149,9 +154,9 @@ protected:
surface->draw(canvas, 0, 0);
yOffset += stride;
if (auto direct = context->asDirectContext()) {
if (dContext) {
// free gpu resources and verify
direct->freeGpuResources();
dContext->freeGpuResources();
}
canvas->rotate(-0.05f);

View File

@ -24,7 +24,7 @@ class GrSurfaceDrawContext;
// This tests that we correctly regenerate textblobs after freeing all gpu resources crbug/491350
namespace skiagm {
class TextBlobUseAfterGpuFree : public GpuGM {
class TextBlobUseAfterGpuFree : public GM {
public:
TextBlobUseAfterGpuFree() { }
@ -37,7 +37,9 @@ protected:
return SkISize::Make(kWidth, kHeight);
}
void onDraw(GrRecordingContext* context, GrSurfaceDrawContext*, SkCanvas* canvas) override {
void onDraw(SkCanvas* canvas) override {
auto dContext = GrAsDirectContext(canvas->recordingContext());
const char text[] = "Hamburgefons";
SkFont font(ToolUtils::create_portable_typeface(), 20);
@ -51,8 +53,8 @@ protected:
canvas->drawTextBlob(blob, 20, 60, SkPaint());
// This text should look fine
if (auto direct = context->asDirectContext()) {
direct->freeGpuResources();
if (dContext) {
dContext->freeGpuResources();
}
canvas->drawTextBlob(blob, 20, 160, SkPaint());
}

View File

@ -17,10 +17,10 @@
#include "include/core/SkString.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrRecordingContext.h"
#include "include/gpu/GrDirectContext.h"
#include "src/core/SkGeometry.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrDrawingManager.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/tessellate/GrTessellationPathRenderer.h"
static constexpr float kStrokeWidth = 30;
@ -179,7 +179,7 @@ DEF_SIMPLE_GM(trickycubicstrokes_roundcaps, canvas, kTestWidth, kTestHeight) {
draw_test(canvas, SkPaint::kRound_Cap, SkPaint::kRound_Join);
}
class TrickyCubicStrokes_tess_segs_5 : public skiagm::GpuGM {
class TrickyCubicStrokes_tess_segs_5 : public skiagm::GM {
SkString onShortName() override {
return SkString("trickycubicstrokes_tess_segs_5");
}
@ -205,26 +205,31 @@ class TrickyCubicStrokes_tess_segs_5 : public skiagm::GpuGM {
(int)GpuPathRenderers::kTessellation);
}
DrawResult onDraw(GrRecordingContext* context, GrSurfaceDrawContext*, SkCanvas* canvas,
SkString* errorMsg) override {
if (!context->priv().caps()->shaderCaps()->tessellationSupport() ||
!GrTessellationPathRenderer::IsSupported(*context->priv().caps())) {
DrawResult onDraw(SkCanvas* canvas, SkString* errorMsg) override {
auto dContext = GrAsDirectContext(canvas->recordingContext());
if (!dContext) {
*errorMsg = "GM relies on having access to a live direct context.";
return DrawResult::kSkip;
}
if (!dContext->priv().caps()->shaderCaps()->tessellationSupport() ||
!GrTessellationPathRenderer::IsSupported(*dContext->priv().caps())) {
errorMsg->set("Tessellation not supported.");
return DrawResult::kSkip;
}
auto opts = context->priv().drawingManager()->testingOnly_getOptionsForPathRendererChain();
auto opts = dContext->priv().drawingManager()->testingOnly_getOptionsForPathRendererChain();
if (!(opts.fGpuPathRenderers & GpuPathRenderers::kTessellation)) {
errorMsg->set("GrTessellationPathRenderer disabled.");
return DrawResult::kSkip;
}
if (context->priv().caps()->shaderCaps()->maxTessellationSegments() !=
if (dContext->priv().caps()->shaderCaps()->maxTessellationSegments() !=
kMaxTessellationSegmentsOverride) {
errorMsg->set("modifyGrContextOptions did not affect maxTessellationSegments. "
"(Are you running viewer? If so use '--maxTessellationSegments 5'.)");
return DrawResult::kFail;
}
// Suppress a tessellator warning message that caps.maxTessellationSegments is too small.
GrRecordingContextPriv::AutoSuppressWarningMessages aswm(context);
GrRecordingContextPriv::AutoSuppressWarningMessages aswm(dContext);
draw_test(canvas, SkPaint::kButt_Cap, SkPaint::kMiter_Join);
return DrawResult::kOk;
}

View File

@ -989,7 +989,7 @@ DEF_GM(return new WackyYUVFormatsGM(/* target cs */ false,
/* subset */ false,
WackyYUVFormatsGM::Type::kFromPixmaps);)
class YUVMakeColorSpaceGM : public GpuGM {
class YUVMakeColorSpaceGM : public GM {
public:
YUVMakeColorSpaceGM() {
this->setBGColor(0xFFCCCCCC);
@ -1068,13 +1068,14 @@ protected:
return true;
}
DrawResult onGpuSetup(GrDirectContext* context, SkString* errorMsg) override {
if (!context || context->abandoned()) {
DrawResult onGpuSetup(GrDirectContext* dContext, SkString* errorMsg) override {
if (!dContext || dContext->abandoned()) {
*errorMsg = "DirectContext required to create YUV images";
return DrawResult::kSkip;
}
this->createBitmaps();
if (!this->createImages(context)) {
if (!this->createImages(dContext)) {
*errorMsg = "Failed to create YUV images";
return DrawResult::kFail;
}
@ -1086,12 +1087,11 @@ protected:
fImages[0][0] = fImages[0][1] = fImages[1][0] = fImages[1][1] = nullptr;
}
DrawResult onDraw(GrRecordingContext* rContext, GrSurfaceDrawContext*,
SkCanvas* canvas, SkString* msg) override {
DrawResult onDraw(SkCanvas* canvas, SkString* msg) override {
SkASSERT(fImages[0][0] && fImages[0][1] && fImages[1][0] && fImages[1][1]);
auto dContext = GrAsDirectContext(rContext);
if (rContext && !dContext) {
auto dContext = GrAsDirectContext(canvas->recordingContext());
if (!dContext) {
*msg = "YUV ColorSpace image creation requires a direct context.";
return DrawResult::kSkip;
}
@ -1101,8 +1101,8 @@ protected:
for (int opaque : { 0, 1 }) {
int y = kPad;
auto raster = fOriginalBMs[opaque].asImage()
->makeColorSpace(fTargetColorSpace, nullptr);
auto raster = fOriginalBMs[opaque].asImage()->makeColorSpace(fTargetColorSpace,
nullptr);
canvas->drawImage(raster, x, y);
y += kTileWidthHeight + kPad;

View File

@ -10,9 +10,9 @@
#include "include/core/SkPath.h"
#include "include/core/SkPoint.h"
#include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrRecordingContext.h"
#include "include/gpu/GrDirectContext.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrDrawingManager.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/tessellate/GrTessellationPathRenderer.h"
static constexpr float kStrokeWidth = 100;
@ -88,7 +88,7 @@ DEF_SIMPLE_GM(widebuttcaps, canvas, kTestWidth, kTestHeight) {
draw_test(canvas);
}
class WideButtCaps_tess_segs_5 : public skiagm::GpuGM {
class WideButtCaps_tess_segs_5 : public skiagm::GM {
SkString onShortName() override {
return SkString("widebuttcaps_tess_segs_5");
}
@ -114,27 +114,31 @@ class WideButtCaps_tess_segs_5 : public skiagm::GpuGM {
(int)GpuPathRenderers::kTessellation);
}
DrawResult onDraw(GrRecordingContext* context,
GrSurfaceDrawContext* rtc, SkCanvas* canvas,
SkString* errorMsg) override {
if (!context->priv().caps()->shaderCaps()->tessellationSupport() ||
!GrTessellationPathRenderer::IsSupported(*context->priv().caps())) {
DrawResult onDraw(SkCanvas* canvas, SkString* errorMsg) override {
auto dContext = GrAsDirectContext(canvas->recordingContext());
if (!dContext) {
*errorMsg = "GM relies on having access to a live direct context.";
return DrawResult::kSkip;
}
if (!dContext->priv().caps()->shaderCaps()->tessellationSupport() ||
!GrTessellationPathRenderer::IsSupported(*dContext->priv().caps())) {
errorMsg->set("Tessellation not supported.");
return DrawResult::kSkip;
}
auto opts = context->priv().drawingManager()->testingOnly_getOptionsForPathRendererChain();
auto opts = dContext->priv().drawingManager()->testingOnly_getOptionsForPathRendererChain();
if (!(opts.fGpuPathRenderers & GpuPathRenderers::kTessellation)) {
errorMsg->set("GrTessellationPathRenderer disabled.");
return DrawResult::kSkip;
}
if (context->priv().caps()->shaderCaps()->maxTessellationSegments() !=
if (dContext->priv().caps()->shaderCaps()->maxTessellationSegments() !=
kMaxTessellationSegmentsOverride) {
errorMsg->set("modifyGrContextOptions() did not limit maxTessellationSegments. "
"(Are you running viewer? If so use '--maxTessellationSegments 5'.)");
return DrawResult::kFail;
}
// Suppress a tessellator warning message that caps.maxTessellationSegments is too small.
GrRecordingContextPriv::AutoSuppressWarningMessages aswm(context);
GrRecordingContextPriv::AutoSuppressWarningMessages aswm(dContext);
draw_test(canvas);
return DrawResult::kOk;
}

View File

@ -26,7 +26,7 @@ static void release_ycbcrhelper(void* releaseContext) {
namespace skiagm {
// This GM exercises the native YCbCr image format on Vulkan
class YCbCrImageGM : public GpuGM {
class YCbCrImageGM : public GM {
public:
YCbCrImageGM() {
this->setBGColor(0xFFCCCCCC);
@ -69,17 +69,17 @@ protected:
return DrawResult::kOk;
}
DrawResult onGpuSetup(GrDirectContext* context, SkString* errorMsg) override {
if (!context || context->abandoned()) {
DrawResult onGpuSetup(GrDirectContext* dContext, SkString* errorMsg) override {
if (!dContext || dContext->abandoned()) {
return DrawResult::kSkip;
}
if (context->backend() != GrBackendApi::kVulkan) {
if (dContext->backend() != GrBackendApi::kVulkan) {
*errorMsg = "This GM requires a Vulkan context.";
return DrawResult::kSkip;
}
DrawResult result = this->createYCbCrImage(context, errorMsg);
DrawResult result = this->createYCbCrImage(dContext, errorMsg);
if (result != DrawResult::kOk) {
return result;
}
@ -91,8 +91,7 @@ protected:
fYCbCrImage = nullptr;
}
DrawResult onDraw(GrRecordingContext*, GrSurfaceDrawContext*,
SkCanvas* canvas, SkString*) override {
DrawResult onDraw(SkCanvas* canvas, SkString*) override {
SkASSERT(fYCbCrImage);
canvas->drawImage(fYCbCrImage, kPad, kPad, SkSamplingOptions(SkFilterMode::kLinear));