Make GrDrawContext be GrRenderTargetProxy-backed
This is split out of https://codereview.chromium.org/2215323003/ (Start using RenderTargetProxy (omnibus))
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3841
CQ_INCLUDE_TRYBOTS=master.client.skia.android:Test-Android-Clang-Nexus5-GPU-Adreno330-arm-Debug-GN_Android-Trybot
Change-Id: I1a47f19ed1ac0c249e6ccac8db74095d7f456db4
Reviewed-on: https://skia-review.googlesource.com/3841
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrRenderTargetProxy.cpp b/src/gpu/GrRenderTargetProxy.cpp
index 5ea43d6..50d79f4 100644
--- a/src/gpu/GrRenderTargetProxy.cpp
+++ b/src/gpu/GrRenderTargetProxy.cpp
@@ -8,8 +8,8 @@
#include "GrRenderTargetProxy.h"
#include "GrCaps.h"
-#include "GrGpuResourcePriv.h"
#include "GrRenderTargetOpList.h"
+#include "GrRenderTargetPriv.h"
#include "GrTextureProvider.h"
// Deferred version
@@ -18,53 +18,58 @@
GrRenderTargetProxy::GrRenderTargetProxy(const GrCaps& caps, const GrSurfaceDesc& desc,
SkBackingFit fit, SkBudgeted budgeted)
: INHERITED(desc, fit, budgeted)
- , fTarget(nullptr)
- , fFlags(GrRenderTargetPriv::Flags::kNone) {
+ , fFlags(GrRenderTarget::Flags::kNone) {
// Since we know the newly created render target will be internal, we are able to precompute
// what the flags will ultimately end up being.
if (caps.usesMixedSamples() && fDesc.fSampleCnt > 0) {
- fFlags |= GrRenderTargetPriv::Flags::kMixedSampled;
+ fFlags |= GrRenderTarget::Flags::kMixedSampled;
}
if (caps.maxWindowRectangles() > 0) {
- fFlags |= GrRenderTargetPriv::Flags::kWindowRectsSupport;
+ fFlags |= GrRenderTarget::Flags::kWindowRectsSupport;
}
}
// Wrapped version
GrRenderTargetProxy::GrRenderTargetProxy(const GrCaps& caps, sk_sp<GrRenderTarget> rt)
- : INHERITED(rt->desc(), SkBackingFit::kExact,
- rt->resourcePriv().isBudgeted(), rt->uniqueID())
- , fTarget(std::move(rt))
- , fFlags(fTarget->renderTargetPriv().flags()) {
+ : INHERITED(std::move(rt), SkBackingFit::kExact)
+ , fFlags(fTarget->asRenderTarget()->renderTargetPriv().flags()) {
}
GrRenderTarget* GrRenderTargetProxy::instantiate(GrTextureProvider* texProvider) {
if (fTarget) {
- return fTarget.get();
+ return fTarget->asRenderTarget();
}
// TODO: it would be nice to not have to copy the desc here
GrSurfaceDesc desc = fDesc;
desc.fFlags |= GrSurfaceFlags::kRenderTarget_GrSurfaceFlag;
- sk_sp<GrTexture> tex;
if (SkBackingFit::kApprox == fFit) {
- tex.reset(texProvider->createApproxTexture(desc));
+ fTarget = texProvider->createApproxTexture(desc);
} else {
- tex.reset(texProvider->createTexture(desc, fBudgeted));
+ fTarget = texProvider->createTexture(desc, fBudgeted);
}
- if (!tex || !tex->asRenderTarget()) {
+ if (!fTarget) {
return nullptr;
}
- fTarget = sk_ref_sp(tex->asRenderTarget());
-
// Check that our a priori computation matched the ultimate reality
- SkASSERT(fFlags == fTarget->renderTargetPriv().flags());
+ SkASSERT(fFlags == fTarget->asRenderTarget()->renderTargetPriv().flags());
- return fTarget.get();
+ return fTarget->asRenderTarget();
}
+
+#ifdef SK_DEBUG
+void GrRenderTargetProxy::validate(GrContext* context) const {
+ if (fTarget) {
+ SkASSERT(fTarget->getContext() == context);
+ }
+
+ INHERITED::validate();
+}
+#endif
+
sk_sp<GrRenderTargetProxy> GrRenderTargetProxy::Make(const GrCaps& caps,
const GrSurfaceDesc& desc,
SkBackingFit fit,