Fix flippity GM for *ooprddl configs
The flippity GM doesn't create backend textures but it does perform some custom proxy creation (i.e., using MakeTextureProxyFromData to set the origin) that requires a direct context. This work must be done in onGpuSetup but doesn't entail any fancy lifetime management. Change-Id: Ica4f4f7476778cdf934c3be9ef8c9a28d0d4ba2e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/297445 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
75c9c5bd26
commit
ddca6ab54a
@ -1738,20 +1738,11 @@ Result GPUDDLSink::ddlDraw(const Src& src,
|
||||
SkSurfaceCharacterization dstCharacterization;
|
||||
SkAssertResult(dstSurface->characterize(&dstCharacterization));
|
||||
|
||||
// 'gpuTestCtx/gpuThreadCtx' is being shifted to the gpuThread. Leave the main (this)
|
||||
// thread w/o a context.
|
||||
gpuTestCtx->makeNotCurrent();
|
||||
|
||||
// Job one for the GPU thread is to make 'gpuTestCtx' current!
|
||||
gpuTaskGroup->add([gpuTestCtx] { gpuTestCtx->makeCurrent(); });
|
||||
|
||||
auto size = src.size();
|
||||
SkPictureRecorder recorder;
|
||||
Result result = src.draw(gpuThreadCtx, recorder.beginRecording(SkIntToScalar(size.width()),
|
||||
SkIntToScalar(size.height())));
|
||||
if (!result.isOk()) {
|
||||
gpuTaskGroup->add([gpuTestCtx] { gpuTestCtx->makeNotCurrent(); });
|
||||
gpuTaskGroup->wait();
|
||||
return result;
|
||||
}
|
||||
sk_sp<SkPicture> inputPicture(recorder.finishRecordingAsPicture());
|
||||
@ -1762,13 +1753,18 @@ Result GPUDDLSink::ddlDraw(const Src& src,
|
||||
DDLPromiseImageHelper promiseImageHelper;
|
||||
sk_sp<SkData> compressedPictureData = promiseImageHelper.deflateSKP(inputPicture.get());
|
||||
if (!compressedPictureData) {
|
||||
gpuTaskGroup->add([gpuTestCtx] { gpuTestCtx->makeNotCurrent(); });
|
||||
gpuTaskGroup->wait();
|
||||
return Result::Fatal("GPUDDLSink: Couldn't deflate SkPicture");
|
||||
}
|
||||
|
||||
promiseImageHelper.createCallbackContexts(gpuThreadCtx);
|
||||
|
||||
// 'gpuTestCtx/gpuThreadCtx' is being shifted to the gpuThread. Leave the main (this)
|
||||
// thread w/o a context.
|
||||
gpuTestCtx->makeNotCurrent();
|
||||
|
||||
// Job one for the GPU thread is to make 'gpuTestCtx' current!
|
||||
gpuTaskGroup->add([gpuTestCtx] { gpuTestCtx->makeCurrent(); });
|
||||
|
||||
// TODO: move the image upload to the utility thread
|
||||
promiseImageHelper.uploadAllToGPU(gpuTaskGroup, gpuThreadCtx);
|
||||
|
||||
|
@ -217,17 +217,14 @@ private:
|
||||
canvas->restore();
|
||||
}
|
||||
|
||||
void drawRow(GrContext* context, SkCanvas* canvas,
|
||||
bool bottomLeftImage, bool drawSubset, bool drawScaled) {
|
||||
|
||||
sk_sp<SkImage> referenceImage = make_reference_image(context, fLabels, bottomLeftImage);
|
||||
void drawRow(SkCanvas* canvas, bool bottomLeftImage, bool drawSubset, bool drawScaled) {
|
||||
|
||||
canvas->save();
|
||||
canvas->translate(kLabelSize, kLabelSize);
|
||||
|
||||
for (int i = 0; i < kNumMatrices; ++i) {
|
||||
this->drawImageWithMatrixAndLabels(canvas, referenceImage.get(), i,
|
||||
drawSubset, drawScaled);
|
||||
this->drawImageWithMatrixAndLabels(canvas, fReferenceImages[bottomLeftImage].get(),
|
||||
i, drawSubset, drawScaled);
|
||||
canvas->translate(kCellSize, 0);
|
||||
}
|
||||
canvas->restore();
|
||||
@ -253,28 +250,46 @@ private:
|
||||
SkASSERT(kNumLabels == fLabels.count());
|
||||
}
|
||||
|
||||
void onDraw(GrContext* context, GrRenderTargetContext*, SkCanvas* canvas) override {
|
||||
DrawResult onGpuSetup(GrContext* context, SkString* errorMsg) override {
|
||||
if (!context) {
|
||||
return DrawResult::kSkip;
|
||||
}
|
||||
|
||||
SkASSERT(context->priv().asDirectContext());
|
||||
|
||||
this->makeLabels(context);
|
||||
fReferenceImages[0] = make_reference_image(context, fLabels, false);
|
||||
fReferenceImages[1] = make_reference_image(context, fLabels, true);
|
||||
if (!fReferenceImages[0] || !fReferenceImages[1]) {
|
||||
*errorMsg = "Failed to create reference images.";
|
||||
return DrawResult::kFail;
|
||||
}
|
||||
|
||||
return DrawResult::kOk;
|
||||
}
|
||||
|
||||
void onDraw(GrContext*, GrRenderTargetContext*, SkCanvas* canvas) override {
|
||||
SkASSERT(fReferenceImages[0] && fReferenceImages[1]);
|
||||
|
||||
canvas->save();
|
||||
|
||||
// Top row gets TL image
|
||||
this->drawRow(context, canvas, false, false, false);
|
||||
this->drawRow(canvas, false, false, false);
|
||||
|
||||
canvas->translate(0, kCellSize);
|
||||
|
||||
// Bottom row gets BL image
|
||||
this->drawRow(context, canvas, true, false, false);
|
||||
this->drawRow(canvas, true, false, false);
|
||||
|
||||
canvas->translate(0, kCellSize);
|
||||
|
||||
// Third row gets subsets of BL images
|
||||
this->drawRow(context, canvas, true, true, false);
|
||||
this->drawRow(canvas, true, true, false);
|
||||
|
||||
canvas->translate(0, kCellSize);
|
||||
|
||||
// Fourth row gets scaled subsets of BL images
|
||||
this->drawRow(context, canvas, true, true, true);
|
||||
this->drawRow(canvas, true, true, true);
|
||||
|
||||
canvas->restore();
|
||||
|
||||
@ -289,6 +304,7 @@ private:
|
||||
|
||||
private:
|
||||
SkTArray<sk_sp<SkImage>> fLabels;
|
||||
sk_sp<SkImage> fReferenceImages[2];
|
||||
|
||||
typedef GM INHERITED;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user