aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2017-05-18 18:13:40 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-18 18:13:48 +0000
commit4b30a96a3e96b7f051e25025f4f17f3c54e04153 (patch)
tree72e0561a19df0db0ca111ee58e4730b2068adb28
parent14d54c207d7a175d14d34f5527af7cbfd579f4d5 (diff)
Revert "Remove GrSurfaceDesc member from GrSurface."
This reverts commit 84911546b9535a2fff6c5e07f588f175d5a04f45. Reason for revert: Breaking bots possibly? Original change's description: > Remove GrSurfaceDesc member from GrSurface. > > Change-Id: I0fe979994e1e3fc457b952dfb5e0090c45fad771 > Reviewed-on: https://skia-review.googlesource.com/17273 > Commit-Queue: Brian Salomon <bsalomon@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> > TBR=bsalomon@google.com,robertphillips@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I404e509fcd3e3d5527b3bc6e286b7d436c12e879 Reviewed-on: https://skia-review.googlesource.com/17364 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
-rw-r--r--include/gpu/GrRenderTarget.h9
-rw-r--r--include/gpu/GrSurface.h25
-rw-r--r--include/gpu/GrTexture.h3
-rw-r--r--src/gpu/GrRenderTarget.cpp12
-rw-r--r--src/gpu/GrTexture.cpp52
-rw-r--r--src/gpu/GrTexturePriv.h16
-rw-r--r--src/gpu/gl/GrGLGpu.cpp6
-rw-r--r--src/gpu/gl/GrGLRenderTarget.cpp2
-rw-r--r--src/gpu/vk/GrVkTexture.cpp6
-rw-r--r--src/gpu/vk/GrVkTextureRenderTarget.cpp4
10 files changed, 67 insertions, 68 deletions
diff --git a/include/gpu/GrRenderTarget.h b/include/gpu/GrRenderTarget.h
index bd25f4fc0e..fdf6f9cddc 100644
--- a/include/gpu/GrRenderTarget.h
+++ b/include/gpu/GrRenderTarget.h
@@ -30,10 +30,10 @@ public:
const GrRenderTarget* asRenderTarget() const override { return this; }
// GrRenderTarget
- bool isStencilBufferMultisampled() const { return fSampleCnt > 0; }
+ bool isStencilBufferMultisampled() const { return fDesc.fSampleCnt > 0; }
GrFSAAType fsaaType() const {
- if (!fSampleCnt) {
+ if (!fDesc.fSampleCnt) {
SkASSERT(!(fFlags & Flags::kMixedSampled));
return GrFSAAType::kNone;
}
@@ -44,13 +44,13 @@ public:
/**
* Returns the number of samples/pixel in the stencil buffer (Zero if non-MSAA).
*/
- int numStencilSamples() const { return fSampleCnt; }
+ int numStencilSamples() const { return fDesc.fSampleCnt; }
/**
* Returns the number of samples/pixel in the color buffer (Zero if non-MSAA or mixed sampled).
*/
int numColorSamples() const {
- return GrFSAAType::kMixedSamples == this->fsaaType() ? 0 : fSampleCnt;
+ return GrFSAAType::kMixedSamples == this->fsaaType() ? 0 : fDesc.fSampleCnt;
}
/**
@@ -135,7 +135,6 @@ private:
friend class GrRenderTargetPriv;
friend class GrRenderTargetProxy; // for Flags
- int fSampleCnt;
GrStencilAttachment* fStencilAttachment;
uint8_t fMultisampleSpecsID;
Flags fFlags;
diff --git a/include/gpu/GrSurface.h b/include/gpu/GrSurface.h
index 4caa842b4a..6626765d6a 100644
--- a/include/gpu/GrSurface.h
+++ b/include/gpu/GrSurface.h
@@ -23,12 +23,12 @@ public:
/**
* Retrieves the width of the surface.
*/
- int width() const { return fWidth; }
+ int width() const { return fDesc.fWidth; }
/**
* Retrieves the height of the surface.
*/
- int height() const { return fHeight; }
+ int height() const { return fDesc.fHeight; }
/**
* Helper that gets the width and height of the surface as a bounding rectangle.
@@ -36,8 +36,9 @@ public:
SkRect getBoundsRect() const { return SkRect::MakeIWH(this->width(), this->height()); }
GrSurfaceOrigin origin() const {
- SkASSERT(kTopLeft_GrSurfaceOrigin == fOrigin || kBottomLeft_GrSurfaceOrigin == fOrigin);
- return fOrigin;
+ SkASSERT(kTopLeft_GrSurfaceOrigin == fDesc.fOrigin ||
+ kBottomLeft_GrSurfaceOrigin == fDesc.fOrigin);
+ return fDesc.fOrigin;
}
/**
@@ -46,7 +47,7 @@ public:
* if client asked us to render to a target that has a pixel
* config that isn't equivalent with one of our configs.
*/
- GrPixelConfig config() const { return fConfig; }
+ GrPixelConfig config() const { return fDesc.fConfig; }
/**
* @return the texture associated with the surface, may be null.
@@ -78,23 +79,17 @@ protected:
friend class GrSurfacePriv;
GrSurface(GrGpu* gpu, const GrSurfaceDesc& desc)
- : INHERITED(gpu)
- , fConfig(desc.fConfig)
- , fWidth(desc.fWidth)
- , fHeight(desc.fHeight)
- , fOrigin(desc.fOrigin) {}
+ : INHERITED(gpu)
+ , fDesc(desc) {
+ }
~GrSurface() override {}
+ GrSurfaceDesc fDesc;
void onRelease() override;
void onAbandon() override;
private:
- GrPixelConfig fConfig;
- int fWidth;
- int fHeight;
- GrSurfaceOrigin fOrigin;
-
typedef GrGpuResource INHERITED;
};
diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h
index a7adc05d0c..0edcbd0e13 100644
--- a/include/gpu/GrTexture.h
+++ b/include/gpu/GrTexture.h
@@ -36,6 +36,7 @@ public:
#ifdef SK_DEBUG
void validate() const {
this->INHERITED::validate();
+ this->validateDesc();
}
#endif
@@ -53,6 +54,8 @@ protected:
GrTexture(GrGpu*, const GrSurfaceDesc&, GrSLType samplerType,
GrSamplerParams::FilterMode highestFilterMode, bool wasMipMapDataProvided);
+ void validateDesc() const;
+
private:
void computeScratchKey(GrScratchKey*) const override;
size_t onGpuMemorySize() const override;
diff --git a/src/gpu/GrRenderTarget.cpp b/src/gpu/GrRenderTarget.cpp
index 8b1fde6b46..61a6f92f22 100644
--- a/src/gpu/GrRenderTarget.cpp
+++ b/src/gpu/GrRenderTarget.cpp
@@ -19,13 +19,11 @@
GrRenderTarget::GrRenderTarget(GrGpu* gpu, const GrSurfaceDesc& desc, Flags flags,
GrStencilAttachment* stencil)
- : INHERITED(gpu, desc)
- , fSampleCnt(desc.fSampleCnt)
- , fStencilAttachment(stencil)
- , fMultisampleSpecsID(0)
- , fFlags(flags) {
- SkASSERT(desc.fFlags & kRenderTarget_GrSurfaceFlag);
- SkASSERT(!(fFlags & Flags::kMixedSampled) || fSampleCnt > 0);
+ : INHERITED(gpu, desc)
+ , fStencilAttachment(stencil)
+ , fMultisampleSpecsID(0)
+ , fFlags(flags) {
+ SkASSERT(!(fFlags & Flags::kMixedSampled) || fDesc.fSampleCnt > 0);
SkASSERT(!(fFlags & Flags::kWindowRectsSupport) || gpu->caps()->maxWindowRectangles() > 0);
fResolveRect.setLargestInverted();
}
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp
index cbab5f0f60..0aa1ac07a6 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -40,7 +40,18 @@ size_t GrTexture::onGpuMemorySize() const {
this->texturePriv().hasMipMaps(), false);
}
-/////////////////////////////////////////////////////////////////////////////
+void GrTexture::validateDesc() const {
+ if (this->asRenderTarget()) {
+ // This texture has a render target
+ SkASSERT(0 != (fDesc.fFlags & kRenderTarget_GrSurfaceFlag));
+ SkASSERT(fDesc.fSampleCnt == this->asRenderTarget()->numColorSamples());
+ } else {
+ SkASSERT(0 == (fDesc.fFlags & kRenderTarget_GrSurfaceFlag));
+ SkASSERT(0 == fDesc.fSampleCnt);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
namespace {
@@ -68,7 +79,7 @@ GrTexture::GrTexture(GrGpu* gpu, const GrSurfaceDesc& desc, GrSLType samplerType
, fMipColorMode(SkDestinationSurfaceColorMode::kLegacy) {
if (wasMipMapDataProvided) {
fMipMapsStatus = kValid_MipMapsStatus;
- fMaxMipMapLevel = SkMipMap::ComputeLevelCount(this->width(), this->height());
+ fMaxMipMapLevel = SkMipMap::ComputeLevelCount(fDesc.fWidth, fDesc.fHeight);
} else {
fMipMapsStatus = kNotAllocated_MipMapsStatus;
fMaxMipMapLevel = 0;
@@ -76,42 +87,27 @@ GrTexture::GrTexture(GrGpu* gpu, const GrSurfaceDesc& desc, GrSLType samplerType
}
void GrTexture::computeScratchKey(GrScratchKey* key) const {
- if (!GrPixelConfigIsCompressed(this->config())) {
- const GrRenderTarget* rt = this->asRenderTarget();
- int sampleCount = 0;
- if (rt) {
- sampleCount = rt->numStencilSamples();
- }
- GrTexturePriv::ComputeScratchKey(this->config(), this->width(), this->height(),
- this->origin(), SkToBool(rt), sampleCount,
- this->texturePriv().hasMipMaps(), key);
+ if (!GrPixelConfigIsCompressed(fDesc.fConfig)) {
+ GrTexturePriv::ComputeScratchKey(fDesc, key);
}
}
-void GrTexturePriv::ComputeScratchKey(GrPixelConfig config, int width, int height,
- GrSurfaceOrigin origin, bool isRenderTarget, int sampleCnt,
- bool isMipMapped, GrScratchKey* key) {
+void GrTexturePriv::ComputeScratchKey(const GrSurfaceDesc& desc, GrScratchKey* key) {
static const GrScratchKey::ResourceType kType = GrScratchKey::GenerateResourceType();
- uint32_t flags = isRenderTarget;
- SkASSERT(0 == sampleCnt || isRenderTarget);
+ GrSurfaceOrigin origin = resolve_origin(desc);
+ uint32_t flags = desc.fFlags;
// make sure desc.fConfig fits in 5 bits
SkASSERT(sk_float_log2(kLast_GrPixelConfig) <= 5);
- SkASSERT(static_cast<int>(config) < (1 << 5));
- SkASSERT(sampleCnt < (1 << 8));
+ SkASSERT(static_cast<int>(desc.fConfig) < (1 << 5));
+ SkASSERT(desc.fSampleCnt < (1 << 8));
SkASSERT(flags < (1 << 10));
SkASSERT(static_cast<int>(origin) < (1 << 8));
GrScratchKey::Builder builder(key, kType, 3);
- builder[0] = width;
- builder[1] = height;
- builder[2] = config | (isMipMapped << 5) | (sampleCnt << 6) | (flags << 14) | (origin << 24);
-}
-
-void GrTexturePriv::ComputeScratchKey(const GrSurfaceDesc& desc, GrScratchKey* key) {
- GrSurfaceOrigin origin = resolve_origin(desc);
- return ComputeScratchKey(desc.fConfig, desc.fWidth, desc.fHeight, origin,
- SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag), desc.fSampleCnt,
- desc.fIsMipMapped, key);
+ builder[0] = desc.fWidth;
+ builder[1] = desc.fHeight;
+ builder[2] = desc.fConfig | (desc.fIsMipMapped << 5) | (desc.fSampleCnt << 6) | (flags << 14)
+ | (origin << 24);
}
diff --git a/src/gpu/GrTexturePriv.h b/src/gpu/GrTexturePriv.h
index 67631fc2c4..042061129d 100644
--- a/src/gpu/GrTexturePriv.h
+++ b/src/gpu/GrTexturePriv.h
@@ -17,6 +17,18 @@
implemented privately in GrTexture with a inline public method here). */
class GrTexturePriv {
public:
+ void setFlag(GrSurfaceFlags flags) {
+ fTexture->fDesc.fFlags = fTexture->fDesc.fFlags | flags;
+ }
+
+ void resetFlag(GrSurfaceFlags flags) {
+ fTexture->fDesc.fFlags = fTexture->fDesc.fFlags & ~flags;
+ }
+
+ bool isSetFlag(GrSurfaceFlags flags) const {
+ return 0 != (fTexture->fDesc.fFlags & flags);
+ }
+
void dirtyMipMaps(bool mipMapsDirty) {
fTexture->dirtyMipMaps(mipMapsDirty);
}
@@ -58,10 +70,6 @@ public:
static void ComputeScratchKey(const GrSurfaceDesc&, GrScratchKey*);
private:
- static void ComputeScratchKey(GrPixelConfig config, int width, int height,
- GrSurfaceOrigin origin, bool isRenderTarget, int sampleCnt,
- bool isMipMapped, GrScratchKey* key);
-
GrTexturePriv(GrTexture* texture) : fTexture(texture) { }
GrTexturePriv(const GrTexturePriv& that) : fTexture(that.fTexture) { }
GrTexturePriv& operator=(const GrTexturePriv&); // unimpl
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 5119b6397e..c52d1d141f 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -1524,12 +1524,12 @@ GrTexture* GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc,
return return_null_texture();
}
- bool isRenderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag);
+ bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag);
GrGLTexture::IDDesc idDesc;
idDesc.fOwnership = GrBackendObjectOwnership::kOwned;
GrGLTexture::TexParams initialTexParams;
- if (!this->createTextureImpl(desc, &idDesc.fInfo, isRenderTarget, &initialTexParams, texels)) {
+ if (!this->createTextureImpl(desc, &idDesc.fInfo, renderTarget, &initialTexParams, texels)) {
return return_null_texture();
}
@@ -1539,7 +1539,7 @@ GrTexture* GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc,
}
GrGLTexture* tex;
- if (isRenderTarget) {
+ if (renderTarget) {
// unbind the texture from the texture unit before binding it to the frame buffer
GL_CALL(BindTexture(idDesc.fInfo.fTarget, 0));
GrGLRenderTarget::IDDesc rtIDDesc;
diff --git a/src/gpu/gl/GrGLRenderTarget.cpp b/src/gpu/gl/GrGLRenderTarget.cpp
index 00a78408d2..7d45ceb619 100644
--- a/src/gpu/gl/GrGLRenderTarget.cpp
+++ b/src/gpu/gl/GrGLRenderTarget.cpp
@@ -215,7 +215,7 @@ int GrGLRenderTarget::msaaSamples() const {
if (fTexFBOID == kUnresolvableFBOID || fTexFBOID != fRTFBOID) {
// If the render target's FBO is external (fTexFBOID == kUnresolvableFBOID), or if we own
// the render target's FBO (fTexFBOID == fRTFBOID) then we use the provided sample count.
- return SkTMax(1, this->numStencilSamples());
+ return SkTMax(1, fDesc.fSampleCnt);
}
// When fTexFBOID == fRTFBOID, we either are not using MSAA, or MSAA is auto resolving, so use
diff --git a/src/gpu/vk/GrVkTexture.cpp b/src/gpu/vk/GrVkTexture.cpp
index 826f091ebe..4857db6f13 100644
--- a/src/gpu/vk/GrVkTexture.cpp
+++ b/src/gpu/vk/GrVkTexture.cpp
@@ -186,7 +186,7 @@ bool GrVkTexture::reallocForMipmap(GrVkGpu* gpu, uint32_t mipLevels) {
return false;
}
- bool renderTarget = SkToBool(this->asRenderTarget());
+ bool renderTarget = SkToBool(fDesc.fFlags & kRenderTarget_GrSurfaceFlag);
VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_SAMPLED_BIT;
if (renderTarget) {
@@ -197,8 +197,8 @@ bool GrVkTexture::reallocForMipmap(GrVkGpu* gpu, uint32_t mipLevels) {
GrVkImage::ImageDesc imageDesc;
imageDesc.fImageType = VK_IMAGE_TYPE_2D;
imageDesc.fFormat = fInfo.fFormat;
- imageDesc.fWidth = this->width();
- imageDesc.fHeight = this->height();
+ imageDesc.fWidth = fDesc.fWidth;
+ imageDesc.fHeight = fDesc.fHeight;
imageDesc.fLevels = mipLevels;
imageDesc.fSamples = 1;
imageDesc.fImageTiling = VK_IMAGE_TILING_OPTIMAL;
diff --git a/src/gpu/vk/GrVkTextureRenderTarget.cpp b/src/gpu/vk/GrVkTextureRenderTarget.cpp
index 2a6810d209..cfa63be8af 100644
--- a/src/gpu/vk/GrVkTextureRenderTarget.cpp
+++ b/src/gpu/vk/GrVkTextureRenderTarget.cpp
@@ -152,8 +152,8 @@ GrVkTextureRenderTarget::MakeWrappedTextureRenderTarget(GrVkGpu* gpu,
bool GrVkTextureRenderTarget::updateForMipmap(GrVkGpu* gpu, const GrVkImageInfo& newInfo) {
VkFormat pixelFormat;
- GrPixelConfigToVkFormat(this->config(), &pixelFormat);
- if (this->numStencilSamples()) {
+ GrPixelConfigToVkFormat(fDesc.fConfig, &pixelFormat);
+ if (fDesc.fSampleCnt) {
const GrVkImageView* resolveAttachmentView =
GrVkImageView::Create(gpu,
newInfo.fImage,