aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrSurfaceProxy.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/GrSurfaceProxy.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/GrSurfaceProxy.cpp')
-rw-r--r--src/gpu/GrSurfaceProxy.cpp71
1 files changed, 25 insertions, 46 deletions
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index 43a650fb4e..a9abb16ea9 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -21,15 +21,17 @@
#include "SkMathPriv.h"
GrSurfaceProxy::GrSurfaceProxy(sk_sp<GrSurface> surface, SkBackingFit fit)
- : INHERITED(std::move(surface))
- , fDesc(fTarget->desc())
- , fFit(fit)
- , fBudgeted(fTarget->resourcePriv().isBudgeted())
- , fFlags(0)
- , fUniqueID(fTarget->uniqueID()) // Note: converting from unique resource ID to a proxy ID!
- , fGpuMemorySize(kInvalidGpuMemorySize)
- , fLastOpList(nullptr) {
-}
+ : INHERITED(std::move(surface))
+ , fConfig(fTarget->config())
+ , fWidth(fTarget->width())
+ , fHeight(fTarget->height())
+ , fOrigin(fTarget->origin())
+ , fFit(fit)
+ , fBudgeted(fTarget->resourcePriv().isBudgeted())
+ , fFlags(0)
+ , fUniqueID(fTarget->uniqueID()) // Note: converting from unique resource ID to a proxy ID!
+ , fGpuMemorySize(kInvalidGpuMemorySize)
+ , fLastOpList(nullptr) {}
GrSurfaceProxy::~GrSurfaceProxy() {
// For this to be deleted the opList that held a ref on it (if there was one) must have been
@@ -37,15 +39,24 @@ GrSurfaceProxy::~GrSurfaceProxy() {
SkASSERT(!fLastOpList);
}
-GrSurface* GrSurfaceProxy::instantiate(GrResourceProvider* resourceProvider) {
+GrSurface* GrSurfaceProxy::instantiateImpl(GrResourceProvider* resourceProvider, int sampleCnt,
+ GrSurfaceFlags flags, bool isMipMapped) {
if (fTarget) {
return fTarget;
}
+ GrSurfaceDesc desc;
+ desc.fConfig = fConfig;
+ desc.fWidth = fWidth;
+ desc.fHeight = fHeight;
+ desc.fOrigin = fOrigin;
+ desc.fSampleCnt = sampleCnt;
+ desc.fIsMipMapped = isMipMapped;
+ desc.fFlags = flags;
if (SkBackingFit::kApprox == fFit) {
- fTarget = resourceProvider->createApproxTexture(fDesc, fFlags);
+ fTarget = resourceProvider->createApproxTexture(desc, fFlags);
} else {
- fTarget = resourceProvider->createTexture(fDesc, fBudgeted, fFlags).release();
+ fTarget = resourceProvider->createTexture(desc, fBudgeted, fFlags).release();
}
if (!fTarget) {
return nullptr;
@@ -63,38 +74,6 @@ GrSurface* GrSurfaceProxy::instantiate(GrResourceProvider* resourceProvider) {
return fTarget;
}
-int GrSurfaceProxy::worstCaseWidth(const GrCaps& caps) const {
- if (fTarget) {
- return fTarget->width();
- }
-
- if (SkBackingFit::kExact == fFit) {
- return fDesc.fWidth;
- }
-
- if (caps.reuseScratchTextures() || fDesc.fFlags & kRenderTarget_GrSurfaceFlag) {
- return SkTMax(GrResourceProvider::kMinScratchTextureSize, GrNextPow2(fDesc.fWidth));
- }
-
- return fDesc.fWidth;
-}
-
-int GrSurfaceProxy::worstCaseHeight(const GrCaps& caps) const {
- if (fTarget) {
- return fTarget->height();
- }
-
- if (SkBackingFit::kExact == fFit) {
- return fDesc.fHeight;
- }
-
- if (caps.reuseScratchTextures() || fDesc.fFlags & kRenderTarget_GrSurfaceFlag) {
- return SkTMax(GrResourceProvider::kMinScratchTextureSize, GrNextPow2(fDesc.fHeight));
- }
-
- return fDesc.fHeight;
-}
-
void GrSurfaceProxy::setLastOpList(GrOpList* opList) {
#ifdef SK_DEBUG
if (fLastOpList) {
@@ -303,8 +282,8 @@ void GrSurfaceProxyPriv::exactify() {
// obliterating the area of interest information. This call (exactify) only used
// when converting an SkSpecialImage to an SkImage so the proxy shouldn't be
// used for additional draws.
- fProxy->fDesc.fWidth = fProxy->fTarget->width();
- fProxy->fDesc.fHeight = fProxy->fTarget->height();
+ fProxy->fWidth = fProxy->fTarget->width();
+ fProxy->fHeight = fProxy->fTarget->height();
return;
}