Add GM::gpuTeardown entry point
This call will bookend gpuSetup calls. Any GM that implements onGpuSetup should also implement onGpuTeardown. This is pulled out of the gpuSetup refactoring. Change-Id: If55599dc26370f589c5cafd20a7ccb9019b424cc Reviewed-on: https://skia-review.googlesource.com/c/skia/+/299138 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
83b749a706
commit
b795bea220
@ -268,6 +268,11 @@ private:
|
||||
return DrawResult::kOk;
|
||||
}
|
||||
|
||||
void onGpuTeardown() override {
|
||||
fLabels.reset();
|
||||
fReferenceImages[0] = fReferenceImages[1] = nullptr;
|
||||
}
|
||||
|
||||
void onDraw(GrContext*, GrRenderTargetContext*, SkCanvas* canvas) override {
|
||||
SkASSERT(fReferenceImages[0] && fReferenceImages[1]);
|
||||
|
||||
|
@ -76,6 +76,10 @@ DrawResult GM::gpuSetup(GrContext* context, SkString* errorMsg) {
|
||||
return this->onGpuSetup(context, errorMsg);
|
||||
}
|
||||
|
||||
void GM::gpuTeardown() {
|
||||
this->onGpuTeardown();
|
||||
}
|
||||
|
||||
DrawResult GM::draw(SkCanvas* canvas, SkString* errorMsg) {
|
||||
TRACE_EVENT1("GM", TRACE_FUNC, "name", TRACE_STR_COPY(this->getName()));
|
||||
this->drawBackground(canvas);
|
||||
|
2
gm/gm.h
2
gm/gm.h
@ -111,6 +111,7 @@ namespace skiagm {
|
||||
static constexpr char kErrorMsg_DrawSkippedGpuOnly[] = "This test is for GPU configs only.";
|
||||
|
||||
DrawResult gpuSetup(GrContext*, SkString* errorMsg);
|
||||
void gpuTeardown();
|
||||
|
||||
void onceBeforeDraw() {
|
||||
if (!fHaveCalledOnceBeforeDraw) {
|
||||
@ -163,6 +164,7 @@ namespace skiagm {
|
||||
protected:
|
||||
// onGpuSetup is called once before any other processing with a direct context.
|
||||
virtual DrawResult onGpuSetup(GrContext*, SkString*) { return DrawResult::kOk; }
|
||||
virtual void onGpuTeardown() {}
|
||||
virtual void onOnceBeforeDraw();
|
||||
virtual DrawResult onDraw(SkCanvas*, SkString* errorMsg);
|
||||
virtual void onDraw(SkCanvas*);
|
||||
|
@ -241,6 +241,13 @@ protected:
|
||||
return DrawResult::kOk;
|
||||
}
|
||||
|
||||
void onGpuTeardown() override {
|
||||
for (sk_sp<SkImage>& image : fYUVAImages) {
|
||||
image.reset();
|
||||
}
|
||||
fReferenceImage.reset();
|
||||
}
|
||||
|
||||
SkImage* getYUVAImage(int index) {
|
||||
SkASSERT(index >= 0 && index < kNumImages);
|
||||
return fYUVAImages[index].get();
|
||||
|
@ -1383,6 +1383,16 @@ protected:
|
||||
return DrawResult::kOk;
|
||||
}
|
||||
|
||||
void onGpuTeardown() override {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
for (int j = 0; j <= kLastEnum_SkYUVColorSpace; ++j) {
|
||||
for (int k = 0; k <= kLast_YUVFormat; ++k) {
|
||||
fImages[i][j][k] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
float cellWidth = kTileWidthHeight, cellHeight = kTileWidthHeight;
|
||||
if (fUseDomain) {
|
||||
@ -1599,6 +1609,10 @@ protected:
|
||||
return DrawResult::kOk;
|
||||
}
|
||||
|
||||
void onGpuTeardown() override {
|
||||
fImages[0][0] = fImages[0][1] = fImages[1][0] = fImages[1][1] = nullptr;
|
||||
}
|
||||
|
||||
void onDraw(GrContext* context, GrRenderTargetContext*, SkCanvas* canvas) override {
|
||||
SkASSERT(fImages[0][0] && fImages[0][1] && fImages[1][0] && fImages[1][1]);
|
||||
|
||||
|
@ -90,6 +90,10 @@ protected:
|
||||
return DrawResult::kOk;
|
||||
}
|
||||
|
||||
void onGpuTeardown() override {
|
||||
fYCbCrImage = nullptr;
|
||||
}
|
||||
|
||||
DrawResult onDraw(GrContext*, GrRenderTargetContext*, SkCanvas* canvas, SkString*) override {
|
||||
SkASSERT(fYCbCrImage);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user