Add flag for window rectangles to GrRenderTarget
Adds a flag to GrRenderTarget that indicates whether it can be used
with window rectangles. Also attempts to clean up some of the mixed
samples API.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2225303002
Review-Url: https://codereview.chromium.org/2225303002
diff --git a/src/gpu/GrRenderTargetProxy.cpp b/src/gpu/GrRenderTargetProxy.cpp
index 6c422c0..3d6587f 100644
--- a/src/gpu/GrRenderTargetProxy.cpp
+++ b/src/gpu/GrRenderTargetProxy.cpp
@@ -7,14 +7,34 @@
#include "GrRenderTargetProxy.h"
+#include "GrCaps.h"
#include "GrDrawTarget.h"
#include "GrGpuResourcePriv.h"
-#include "GrRenderTargetPriv.h"
-GrRenderTargetProxy::GrRenderTargetProxy(sk_sp<GrRenderTarget> rt)
+// Deferred version
+// TODO: we can probably munge the 'desc' in both the wrapped and deferred
+// cases to make the sampleConfig/numSamples stuff more rational.
+GrRenderTargetProxy::GrRenderTargetProxy(const GrCaps& caps, const GrSurfaceDesc& desc,
+ SkBackingFit fit, SkBudgeted budgeted)
+ : INHERITED(desc, fit, budgeted)
+ , fTarget(nullptr)
+ , fFlags(GrRenderTargetPriv::Flags::kNone)
+ , fLastDrawTarget(nullptr) {
+ // 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;
+ }
+ if (caps.maxWindowRectangles() > 0) {
+ fFlags |= GrRenderTargetPriv::Flags::kWindowRectsSupport;
+ }
+}
+
+// Wrapped version
+GrRenderTargetProxy::GrRenderTargetProxy(const GrCaps& caps, sk_sp<GrRenderTarget> rt)
: INHERITED(rt->desc(), SkBackingFit::kExact, rt->resourcePriv().isBudgeted())
, fTarget(std::move(rt))
- , fSampleConfig(fTarget->renderTargetPriv().sampleConfig())
+ , fFlags(fTarget->renderTargetPriv().flags())
, fLastDrawTarget(nullptr) {
}
@@ -47,7 +67,7 @@
fTarget = sk_ref_sp(tex->asRenderTarget());
// Check that our a priori computation matched the ultimate reality
- SkASSERT(fSampleConfig == fTarget->renderTargetPriv().sampleConfig());
+ SkASSERT(fFlags == fTarget->renderTargetPriv().flags());
return fTarget.get();
}
@@ -71,7 +91,7 @@
return sk_sp<GrRenderTargetProxy>(new GrRenderTargetProxy(caps, desc, fit, budgeted));
}
-sk_sp<GrRenderTargetProxy> GrRenderTargetProxy::Make(sk_sp<GrRenderTarget> rt) {
- return sk_sp<GrRenderTargetProxy>(new GrRenderTargetProxy(rt));
+sk_sp<GrRenderTargetProxy> GrRenderTargetProxy::Make(const GrCaps& caps, sk_sp<GrRenderTarget> rt) {
+ return sk_sp<GrRenderTargetProxy>(new GrRenderTargetProxy(caps, rt));
}