Update GrSurfaceProxy::Copy to return a view.
Additionally this changes updates GrRenderTargetContext drawTexture to take
a view. This was done since there were a bunch of places where the result
of the copy goes straight to the drawTexture call.
Bug: skia:9556
Change-Id: If7094eb51ed343620011d03b86d603e3c6289c17
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/267856
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrAHardwareBufferImageGenerator.cpp b/src/gpu/GrAHardwareBufferImageGenerator.cpp
index ca4c344..33e482a 100644
--- a/src/gpu/GrAHardwareBufferImageGenerator.cpp
+++ b/src/gpu/GrAHardwareBufferImageGenerator.cpp
@@ -80,14 +80,14 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
-sk_sp<GrTextureProxy> GrAHardwareBufferImageGenerator::makeProxy(GrRecordingContext* context) {
+GrSurfaceProxyView GrAHardwareBufferImageGenerator::makeView(GrRecordingContext* context) {
if (context->priv().abandoned()) {
- return nullptr;
+ return {};
}
auto direct = context->priv().asDirectContext();
if (!direct) {
- return nullptr;
+ return {};
}
GrBackendFormat backendFormat = GrAHardwareBufferUtils::GetBackendFormat(direct,
@@ -188,14 +188,14 @@
SkBackingFit::kExact, SkBudgeted::kNo, GrProtected::kNo,
GrSurfaceProxy::UseAllocator::kYes);
- return texProxy;
+ return GrSurfaceProxyView(std::move(texProxy), fSurfaceOrigin, readSwizzle);
}
sk_sp<GrTextureProxy> GrAHardwareBufferImageGenerator::onGenerateTexture(
GrRecordingContext* context, const SkImageInfo& info,
const SkIPoint& origin, bool willNeedMipMaps) {
- sk_sp<GrTextureProxy> texProxy = this->makeProxy(context);
- if (!texProxy) {
+ GrSurfaceProxyView texProxyView = this->makeView(context);
+ if (!texProxyView.proxy()) {
return nullptr;
}
@@ -203,7 +203,7 @@
info.width() == this->getInfo().width() && info.height() == this->getInfo().height()) {
// If the caller wants the full texture we're done. The caller will handle making a copy for
// mip maps if that is required.
- return texProxy;
+ return texProxyView.asTextureProxyRef();
}
// Otherwise, make a copy for the requested subset.
SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, info.width(), info.height());
@@ -211,8 +211,9 @@
GrMipMapped mipMapped = willNeedMipMaps ? GrMipMapped::kYes : GrMipMapped::kNo;
GrColorType grColorType = SkColorTypeToGrColorType(this->getInfo().colorType());
- return GrSurfaceProxy::Copy(context, texProxy.get(), grColorType, mipMapped, subset,
- SkBackingFit::kExact, SkBudgeted::kYes);
+ return GrSurfaceProxy::Copy(context, texProxyView.proxy(), texProxyView.origin(), grColorType,
+ mipMapped, subset, SkBackingFit::kExact,
+ SkBudgeted::kYes).asTextureProxyRef();
}
bool GrAHardwareBufferImageGenerator::onIsValid(GrContext* context) const {