Add an arg to SkImage::makeSubset to take a direct context
This is part of a larger effort to force users to provide a context
when manipulating GPU images which may be shared, instead of having
images themselves retain powerful context pointers.
Chrome flag landed in Chrome CL 2292800
Bug: skia:10466
Change-Id: Ic530a2c5eb1f4399db899d243ea944760fdf2055
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/300707
Commit-Queue: Adlai Holler <adlai@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/gm/drawbitmaprect.cpp b/gm/drawbitmaprect.cpp
index 36e16bd..7eb4fe9 100644
--- a/gm/drawbitmaprect.cpp
+++ b/gm/drawbitmaprect.cpp
@@ -29,6 +29,7 @@
#include "include/core/SkTypeface.h"
#include "include/core/SkTypes.h"
#include "include/effects/SkGradientShader.h"
+#include "include/gpu/GrDirectContext.h"
#include "src/core/SkBlurMask.h"
#include "src/core/SkMathPriv.h"
#include "tools/ToolUtils.h"
@@ -133,7 +134,8 @@
return;
}
- if (sk_sp<SkImage> subset = image->makeSubset(srcR)) {
+ auto direct = GrAsDirectContext(canvas->recordingContext());
+ if (sk_sp<SkImage> subset = image->makeSubset(srcR, direct)) {
canvas->drawImageRect(subset, dstR, paint);
}
}