Revise GM infrastructure to not rely on GrSurfaceDrawContext
The SDC will soon be V1-only. Remove it from the generic testing infrastructure and require each V1-specific GM to explicitly retrieve it.
Bug: skia:11837
Change-Id: I4c904b7e333333382062bde4b17a1f9f81bee6a9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/430425
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
diff --git a/gm/bigrrectaaeffect.cpp b/gm/bigrrectaaeffect.cpp
index 3d0431e..2b524f1 100644
--- a/gm/bigrrectaaeffect.cpp
+++ b/gm/bigrrectaaeffect.cpp
@@ -18,6 +18,7 @@
#include "include/core/SkString.h"
#include "include/core/SkTypes.h"
#include "include/private/GrTypesPriv.h"
+#include "src/core/SkCanvasPriv.h"
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrFragmentProcessor.h"
#include "src/gpu/GrPaint.h"
@@ -64,10 +65,15 @@
SkISize onISize() override { return SkISize::Make(fWidth, fHeight); }
- void onDraw(GrRecordingContext* context, GrSurfaceDrawContext* surfaceDrawContext,
- SkCanvas* canvas) override {
+ DrawResult onDraw(GrRecordingContext* rContext, SkCanvas* canvas, SkString* errorMsg) override {
SkPaint paint;
+ auto sdc = SkCanvasPriv::TopDeviceSurfaceDrawContext(canvas);
+ if (!sdc) {
+ *errorMsg = kErrorMsg_DrawSkippedGpuOnly;
+ return DrawResult::kSkip;
+ }
+
int y = kPad;
int x = kPad;
constexpr GrClipEdgeType kEdgeTypes[] = {
@@ -87,7 +93,7 @@
SkRRect rrect = fRRect;
rrect.offset(SkIntToScalar(x + kGap), SkIntToScalar(y + kGap));
- const auto& caps = *surfaceDrawContext->caps()->shaderCaps();
+ const auto& caps = *rContext->priv().caps()->shaderCaps();
auto [success, fp] = GrRRectEffect::Make(/*inputFP=*/nullptr, edgeType, rrect,
caps);
SkASSERT(success);
@@ -101,12 +107,14 @@
SkRect bounds = testBounds;
bounds.offset(SkIntToScalar(x), SkIntToScalar(y));
- surfaceDrawContext->addDrawOp(GrFillRectOp::MakeNonAARect(
- context, std::move(grPaint), SkMatrix::I(), bounds));
+ sdc->addDrawOp(GrFillRectOp::MakeNonAARect(
+ rContext, std::move(grPaint), SkMatrix::I(), bounds));
}
canvas->restore();
x = x + fTestOffsetX;
}
+
+ return DrawResult::kOk;
}
private: