aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrRenderTargetProxy.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-05-17 13:49:59 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-17 18:17:50 +0000
commitbb5711a5e4b9c83f0fc49f2d4ee19ca1e4592e14 (patch)
treee743c265e75a1dad32c1425bf3b9ed88abad2c52 /src/gpu/GrRenderTargetProxy.cpp
parent9f1c403362d8de6038328c7238b6ac56be552324 (diff)
Remove GrSurfaceDesc member from GrSurfaceProxy.
Stores the config, origin, and dimensions in GrSurfaceProxy, sample count in GrRenderTargetProxy, and "was constructed with mip maps" in GrTextureProxy. Change-Id: Iee058674dce49107a991cca9d083cd33e3572809 Reviewed-on: https://skia-review.googlesource.com/17209 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrRenderTargetProxy.cpp')
-rw-r--r--src/gpu/GrRenderTargetProxy.cpp53
1 files changed, 38 insertions, 15 deletions
diff --git a/src/gpu/GrRenderTargetProxy.cpp b/src/gpu/GrRenderTargetProxy.cpp
index 44f23d484b..099f7e5f8d 100644
--- a/src/gpu/GrRenderTargetProxy.cpp
+++ b/src/gpu/GrRenderTargetProxy.cpp
@@ -13,17 +13,19 @@
#include "GrRenderTargetPriv.h"
#include "GrResourceProvider.h"
#include "GrTextureRenderTargetProxy.h"
+#include "SkMathPriv.h"
// 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, uint32_t flags)
- : INHERITED(desc, fit, budgeted, flags)
- , fRenderTargetFlags(GrRenderTarget::Flags::kNone) {
+ : INHERITED(desc, fit, budgeted, flags)
+ , fSampleCnt(desc.fSampleCnt)
+ , fRenderTargetFlags(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) {
+ if (caps.usesMixedSamples() && fSampleCnt > 0) {
fRenderTargetFlags |= GrRenderTarget::Flags::kMixedSampled;
}
if (caps.maxWindowRectangles() > 0) {
@@ -33,9 +35,9 @@ GrRenderTargetProxy::GrRenderTargetProxy(const GrCaps& caps, const GrSurfaceDesc
// Wrapped version
GrRenderTargetProxy::GrRenderTargetProxy(sk_sp<GrSurface> surf)
- : INHERITED(std::move(surf), SkBackingFit::kExact)
- , fRenderTargetFlags(fTarget->asRenderTarget()->renderTargetPriv().flags()) {
-}
+ : INHERITED(std::move(surf), SkBackingFit::kExact)
+ , fSampleCnt(fTarget->asRenderTarget()->numStencilSamples())
+ , fRenderTargetFlags(fTarget->asRenderTarget()->renderTargetPriv().flags()) {}
int GrRenderTargetProxy::maxWindowRectangles(const GrCaps& caps) const {
return (fRenderTargetFlags & GrRenderTarget::Flags::kWindowRectsSupport)
@@ -43,27 +45,48 @@ int GrRenderTargetProxy::maxWindowRectangles(const GrCaps& caps) const {
: 0;
}
-GrRenderTarget* GrRenderTargetProxy::instantiate(GrResourceProvider* resourceProvider) {
- SkASSERT(fDesc.fFlags & GrSurfaceFlags::kRenderTarget_GrSurfaceFlag);
+GrSurface* GrRenderTargetProxy::instantiate(GrResourceProvider* resourceProvider) {
+ static constexpr GrSurfaceFlags kFlags = kRenderTarget_GrSurfaceFlag;
- GrSurface* surf = INHERITED::instantiate(resourceProvider);
- if (!surf || !surf->asRenderTarget()) {
+ GrSurface* surf = this->instantiateImpl(resourceProvider, fSampleCnt, kFlags,
+ /* isMipped = */ false);
+ if (!surf) {
return nullptr;
}
-
+ SkASSERT(surf->asRenderTarget());
// Check that our a priori computation matched the ultimate reality
SkASSERT(fRenderTargetFlags == surf->asRenderTarget()->renderTargetPriv().flags());
- return surf->asRenderTarget();
+ return surf;
}
-size_t GrRenderTargetProxy::onGpuMemorySize() const {
+int GrRenderTargetProxy::worstCaseWidth() const {
if (fTarget) {
- return fTarget->gpuMemorySize();
+ return fTarget->width();
+ }
+
+ if (SkBackingFit::kExact == fFit) {
+ return fWidth;
}
+ return SkTMax(GrResourceProvider::kMinScratchTextureSize, GrNextPow2(fWidth));
+}
+
+int GrRenderTargetProxy::worstCaseHeight() const {
+ if (fTarget) {
+ return fTarget->height();
+ }
+
+ if (SkBackingFit::kExact == fFit) {
+ return fHeight;
+ }
+ return SkTMax(GrResourceProvider::kMinScratchTextureSize, GrNextPow2(fHeight));
+}
+size_t GrRenderTargetProxy::onUninstantiatedGpuMemorySize() const {
+ int colorSamplesPerPixel = this->numColorSamples() + 1;
// TODO: do we have enough information to improve this worst case estimate?
- return GrSurface::ComputeSize(fDesc, fDesc.fSampleCnt+1, false, SkBackingFit::kApprox == fFit);
+ return GrSurface::ComputeSize(fConfig, fWidth, fHeight, colorSamplesPerPixel, false,
+ SkBackingFit::kApprox == fFit);
}
bool GrRenderTargetProxy::refsWrappedObjects() const {