extend GPUSink::onDraw with a canvas wrapper function

Change-Id: Id504947e3533c5cf2c9e91de9737959e0440dbec
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/524317
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
Herb Derby 2022-03-24 10:56:44 -04:00 committed by SkCQ
parent dae0b24b21
commit 6ccc3b0658
2 changed files with 10 additions and 3 deletions

View File

@ -1488,7 +1488,8 @@ 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(GrDirectContext*)> initContext) const {
std::function<void(GrDirectContext*)> initContext,
std::function<SkCanvas*(SkCanvas*)> wrapCanvas) const {
GrContextOptions grOptions = baseOptions;
// We don't expect the src to mess with the persistent cache or the executor.
@ -1517,7 +1518,12 @@ Result GPUSink::onDraw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log,
factory.abandonContexts();
}
Result result = src.draw(direct, surface->getCanvas());
auto canvas = surface->getCanvas();
if (wrapCanvas != nullptr) {
canvas = wrapCanvas(canvas);
}
Result result = src.draw(direct, canvas);
if (!result.isOk()) {
return result;
}

View File

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