Require a direct context to precompile shaders in DM

Change-Id: I44051f0e00ac47c53631084e2221594ec30bddfc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/310067
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2020-08-13 15:58:29 -04:00 committed by Skia Commit-Bot
parent 1cf2c8d6ec
commit e219c7ed37
2 changed files with 8 additions and 6 deletions

View File

@ -1515,7 +1515,7 @@ bool GPUSink::readBack(SkSurface* surface, SkBitmap* dst) const {
Result GPUSink::onDraw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log,
const GrContextOptions& baseOptions,
std::function<void(GrContext*)> initContext) const {
std::function<void(GrDirectContext*)> initContext) const {
GrContextOptions grOptions = baseOptions;
// We don't expect the src to mess with the persistent cache or the executor.
@ -1675,9 +1675,11 @@ Result GPUPrecompileTestingSink::draw(const Src& src, SkBitmap* dst, SkWStream*
return result;
}
auto precompileShaders = [&memoryCache](GrContext* context) {
memoryCache.foreach([context](sk_sp<const SkData> key, sk_sp<SkData> data, int /*count*/) {
SkAssertResult(context->precompileShader(*key, *data));
auto precompileShaders = [&memoryCache](GrDirectContext* dContext) {
memoryCache.foreach([dContext](sk_sp<const SkData> key,
sk_sp<SkData> data,
int /*count*/) {
SkAssertResult(dContext->precompileShader(*key, *data));
});
};
@ -1911,7 +1913,7 @@ Result GPUDDLSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log
// with the main context
ContextInfo otherCtxInfo = factory.getSharedContextInfo(mainCtx);
sk_gpu_test::TestContext* otherTestCtx = otherCtxInfo.testContext();
GrContext* otherCtx = otherCtxInfo.grContext();
auto otherCtx = otherCtxInfo.directContext();
if (!otherCtx) {
return Result::Fatal("Cound not create shared context.");
}

View File

@ -386,7 +386,7 @@ public:
Result draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
Result onDraw(const Src&, SkBitmap*, SkWStream*, SkString*,
const GrContextOptions& baseOptions,
std::function<void(GrContext*)> initContext = nullptr) const;
std::function<void(GrDirectContext*)> initContext = nullptr) const;
sk_gpu_test::GrContextFactory::ContextType contextType() const { return fContextType; }
const sk_gpu_test::GrContextFactory::ContextOverrides& contextOverrides() const {