Add SurfaceProxyView support to Surface/TextureContext.
Bug: skia:9556
Change-Id: I8dfe0a053690acdfdc487cf478e20ea9595d0121
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/249880
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 7002ce1..6b2990d 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -941,6 +941,10 @@
sk_sp<GrTextureProxy> textureProxy(sk_ref_sp(sProxy->asTextureProxy()));
+ GrSurfaceOrigin origin = textureProxy->origin();
+ GrSwizzle texSwizzle = textureProxy->textureSwizzle();
+
return std::unique_ptr<GrTextureContext>(new GrTextureContext(
- fContext, std::move(textureProxy), colorType, alphaType, std::move(colorSpace)));
+ fContext, std::move(textureProxy), colorType, alphaType, std::move(colorSpace), origin,
+ texSwizzle));
}
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 5f63f9e..911ab7e 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -151,10 +151,9 @@
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* surfaceProps,
bool managedOpsTask)
- : GrSurfaceContext(context, colorType, kPremul_SkAlphaType, std::move(colorSpace))
+ : GrSurfaceContext(context, colorType, kPremul_SkAlphaType, std::move(colorSpace), origin,
+ texSwizzle)
, fRenderTargetProxy(std::move(rtp))
- , fOrigin(origin)
- , fTextureSwizzle(texSwizzle)
, fOutputSwizzle(outSwizzle)
, fOpsTask(sk_ref_sp(fRenderTargetProxy->getLastOpsTask()))
, fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps))
diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h
index d0bd523..286bff5 100644
--- a/src/gpu/GrRenderTargetContext.h
+++ b/src/gpu/GrRenderTargetContext.h
@@ -481,16 +481,12 @@
int height() const { return fRenderTargetProxy->height(); }
int numSamples() const { return fRenderTargetProxy->numSamples(); }
const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; }
- GrSurfaceOrigin origin() const { return fOrigin; }
bool wrapsVkSecondaryCB() const { return fRenderTargetProxy->wrapsVkSecondaryCB(); }
GrMipMapped mipMapped() const;
GrSurfaceProxyView outputSurfaceView() {
return { fRenderTargetProxy, fOrigin, fOutputSwizzle };
}
- GrSurfaceProxyView textureSurfaceView() {
- return { fRenderTargetProxy, fOrigin, fTextureSwizzle };
- }
// This entry point should only be called if the backing GPU object is known to be
// instantiated.
@@ -648,8 +644,6 @@
std::unique_ptr<GrTextTarget> fTextTarget;
sk_sp<GrRenderTargetProxy> fRenderTargetProxy;
- GrSurfaceOrigin fOrigin;
- GrSwizzle fTextureSwizzle;
GrSwizzle fOutputSwizzle;
// In MDB-mode the GrOpsTask can be closed by some other renderTargetContext that has picked
diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp
index 4b5e0a8..f427478 100644
--- a/src/gpu/GrSurfaceContext.cpp
+++ b/src/gpu/GrSurfaceContext.cpp
@@ -35,8 +35,13 @@
GrSurfaceContext::GrSurfaceContext(GrRecordingContext* context,
GrColorType colorType,
SkAlphaType alphaType,
- sk_sp<SkColorSpace> colorSpace)
- : fContext(context), fColorInfo(colorType, alphaType, std::move(colorSpace)) {}
+ sk_sp<SkColorSpace> colorSpace,
+ GrSurfaceOrigin origin,
+ GrSwizzle texSwizzle)
+ : fContext(context)
+ , fOrigin(origin)
+ , fColorInfo(colorType, alphaType, std::move(colorSpace))
+ , fTextureSwizzle(texSwizzle) {}
const GrCaps* GrSurfaceContext::caps() const { return fContext->priv().caps(); }
diff --git a/src/gpu/GrSurfaceContext.h b/src/gpu/GrSurfaceContext.h
index c9de7d0..0bcf6a6 100644
--- a/src/gpu/GrSurfaceContext.h
+++ b/src/gpu/GrSurfaceContext.h
@@ -16,6 +16,7 @@
#include "src/gpu/GrColorInfo.h"
#include "src/gpu/GrDataUtils.h"
#include "src/gpu/GrSurfaceProxy.h"
+#include "src/gpu/GrSurfaceProxyView.h"
class GrAuditTrail;
class GrDrawingManager;
@@ -38,6 +39,10 @@
virtual ~GrSurfaceContext() = default;
const GrColorInfo& colorInfo() const { return fColorInfo; }
+ GrSurfaceOrigin origin() const { return fOrigin; }
+ GrSurfaceProxyView textureSurfaceView() {
+ return { this->asSurfaceProxyRef(), fOrigin, fTextureSwizzle };
+ }
// TODO: these two calls would be way cooler if this object had a GrSurfaceProxy pointer
int width() const { return this->asSurfaceProxy()->width(); }
@@ -104,7 +109,8 @@
protected:
friend class GrSurfaceContextPriv;
- GrSurfaceContext(GrRecordingContext*, GrColorType, SkAlphaType, sk_sp<SkColorSpace>);
+ GrSurfaceContext(GrRecordingContext*, GrColorType, SkAlphaType, sk_sp<SkColorSpace>,
+ GrSurfaceOrigin, GrSwizzle texSwizzle);
GrDrawingManager* drawingManager();
const GrDrawingManager* drawingManager() const;
@@ -115,6 +121,8 @@
GrRecordingContext* fContext;
+ GrSurfaceOrigin fOrigin;
+
// The rescaling step of asyncRescaleAndReadPixels[YUV420]().
std::unique_ptr<GrRenderTargetContext> rescale(const SkImageInfo& info, const SkIRect& srcRect,
SkSurface::RescaleGamma rescaleGamma,
@@ -159,6 +167,7 @@
}
GrColorInfo fColorInfo;
+ GrSwizzle fTextureSwizzle;
typedef SkRefCnt INHERITED;
};
diff --git a/src/gpu/GrTextureContext.cpp b/src/gpu/GrTextureContext.cpp
index ccdcc80..6aa7cfa 100644
--- a/src/gpu/GrTextureContext.cpp
+++ b/src/gpu/GrTextureContext.cpp
@@ -20,8 +20,10 @@
sk_sp<GrTextureProxy> textureProxy,
GrColorType colorType,
SkAlphaType alphaType,
- sk_sp<SkColorSpace> colorSpace)
- : GrSurfaceContext(context, colorType, alphaType, std::move(colorSpace))
+ sk_sp<SkColorSpace> colorSpace,
+ GrSurfaceOrigin origin,
+ GrSwizzle texSwizzle)
+ : GrSurfaceContext(context, colorType, alphaType, std::move(colorSpace), origin, texSwizzle)
, fTextureProxy(std::move(textureProxy)) {
SkDEBUGCODE(this->validate();)
}
diff --git a/src/gpu/GrTextureContext.h b/src/gpu/GrTextureContext.h
index 626c2d3..97bf72a 100644
--- a/src/gpu/GrTextureContext.h
+++ b/src/gpu/GrTextureContext.h
@@ -42,7 +42,9 @@
sk_sp<GrTextureProxy>,
GrColorType,
SkAlphaType,
- sk_sp<SkColorSpace>);
+ sk_sp<SkColorSpace>,
+ GrSurfaceOrigin origin,
+ GrSwizzle texSwizzle);
SkDEBUGCODE(void validate() const override;)