Remove GrSurfaceDesc
Replace with SkISize.
Also change some const SkISize& params to just SkISize.
Change-Id: I3c72d961662eefeda545fba17d63e877cd5ca813
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/269374
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/include/core/SkSize.h b/include/core/SkSize.h
index 0fa8f9f..79d6737 100644
--- a/include/core/SkSize.h
+++ b/include/core/SkSize.h
@@ -33,7 +33,7 @@
constexpr int32_t width() const { return fWidth; }
constexpr int32_t height() const { return fHeight; }
- int64_t area() const { return fWidth * fHeight; }
+ constexpr int64_t area() const { return fWidth * fHeight; }
bool equals(int32_t w, int32_t h) const { return fWidth == w && fHeight == h; }
};
diff --git a/include/core/SkSurfaceCharacterization.h b/include/core/SkSurfaceCharacterization.h
index 4588df9..f259fed 100644
--- a/include/core/SkSurfaceCharacterization.h
+++ b/include/core/SkSurfaceCharacterization.h
@@ -79,6 +79,7 @@
const SkImageInfo& imageInfo() const { return fImageInfo; }
const GrBackendFormat& backendFormat() const { return fBackendFormat; }
GrSurfaceOrigin origin() const { return fOrigin; }
+ SkISize dimensions() const { return fImageInfo.dimensions(); }
int width() const { return fImageInfo.width(); }
int height() const { return fImageInfo.height(); }
SkColorType colorType() const { return fImageInfo.colorType(); }
diff --git a/include/gpu/GrBackendSurface.h b/include/gpu/GrBackendSurface.h
index 748325d..6102ac7 100644
--- a/include/gpu/GrBackendSurface.h
+++ b/include/gpu/GrBackendSurface.h
@@ -220,6 +220,7 @@
GrBackendTexture& operator=(const GrBackendTexture& that);
+ SkISize dimensions() const { return {fWidth, fHeight}; }
int width() const { return fWidth; }
int height() const { return fHeight; }
bool hasMipMaps() const { return GrMipMapped::kYes == fMipMapped; }
@@ -367,6 +368,7 @@
GrBackendRenderTarget(const GrBackendRenderTarget& that);
GrBackendRenderTarget& operator=(const GrBackendRenderTarget&);
+ SkISize dimensions() const { return {fWidth, fHeight}; }
int width() const { return fWidth; }
int height() const { return fHeight; }
int sampleCnt() const { return fSampleCnt; }
diff --git a/include/private/GrTypesPriv.h b/include/private/GrTypesPriv.h
index 15e890b..c3504db 100644
--- a/include/private/GrTypesPriv.h
+++ b/include/private/GrTypesPriv.h
@@ -109,16 +109,6 @@
return sBytesPerPixel[(int)format];
}
-/**
- * Describes a surface to be created.
- */
-struct GrSurfaceDesc {
- GrSurfaceDesc() : fWidth(0), fHeight(0) {}
-
- int fWidth; //!< Width of the texture
- int fHeight; //!< Height of the texture
-};
-
/** Ownership rules for external GPU resources imported into Skia. */
enum GrWrapOwnership {
/** Skia will assume the client will keep the resource alive and Skia will not free it. */
diff --git a/src/core/SkDeferredDisplayListRecorder.cpp b/src/core/SkDeferredDisplayListRecorder.cpp
index e9bdcc4..a3f3221 100644
--- a/src/core/SkDeferredDisplayListRecorder.cpp
+++ b/src/core/SkDeferredDisplayListRecorder.cpp
@@ -131,10 +131,6 @@
GrColorType grColorType = SkColorTypeToGrColorType(fCharacterization.colorType());
- GrSurfaceDesc desc;
- desc.fWidth = fCharacterization.width();
- desc.fHeight = fCharacterization.height();
-
sk_sp<SkDeferredDisplayList::LazyProxyData> lazyProxyData = fLazyProxyData;
// What we're doing here is we're creating a lazy proxy to back the SkSurface. The lazy
@@ -164,7 +160,7 @@
return GrSurfaceProxy::LazyCallbackResult(std::move(surface));
},
fCharacterization.backendFormat(),
- desc,
+ fCharacterization.dimensions(),
readSwizzle,
fCharacterization.sampleCount(),
fCharacterization.origin(),
diff --git a/src/gpu/GrAHardwareBufferImageGenerator.cpp b/src/gpu/GrAHardwareBufferImageGenerator.cpp
index 78e1cfc..28d67a2 100644
--- a/src/gpu/GrAHardwareBufferImageGenerator.cpp
+++ b/src/gpu/GrAHardwareBufferImageGenerator.cpp
@@ -100,10 +100,6 @@
int width = this->getInfo().width();
int height = this->getInfo().height();
- GrSurfaceDesc desc;
- desc.fWidth = width;
- desc.fHeight = height;
-
GrTextureType textureType = GrTextureType::k2D;
if (context->backend() == GrBackendApi::kOpenGL) {
textureType = GrTextureType::kExternal;
@@ -183,7 +179,7 @@
return tex;
},
- backendFormat, desc, readSwizzle, GrRenderable::kNo, 1, fSurfaceOrigin,
+ backendFormat, {width, height}, readSwizzle, GrRenderable::kNo, 1, fSurfaceOrigin,
GrMipMapped::kNo, GrMipMapsStatus::kNotAllocated, GrInternalSurfaceFlags::kReadOnly,
SkBackingFit::kExact, SkBudgeted::kNo, GrProtected::kNo,
GrSurfaceProxy::UseAllocator::kYes);
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index f2a10a5..d9cbf6e 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -143,9 +143,6 @@
GrColorType grColorType = SkColorTypeToGrColorType(info.colorType());
- GrSurfaceDesc desc;
- desc.fWidth = fBackendTexture.width();
- desc.fHeight = fBackendTexture.height();
GrMipMapped mipMapped = fBackendTexture.hasMipMaps() ? GrMipMapped::kYes : GrMipMapped::kNo;
// Ganesh assumes that, when wrapping a mipmapped backend texture from a client, that its
@@ -197,15 +194,15 @@
// unrelated to the whatever SkImage key may be assigned to the proxy.
return {std::move(tex), true, GrSurfaceProxy::LazyInstantiationKeyMode::kUnsynced};
},
- backendFormat, desc, readSwizzle, GrRenderable::kNo, 1, fSurfaceOrigin, mipMapped,
- mipMapsStatus, GrInternalSurfaceFlags::kReadOnly, SkBackingFit::kExact, SkBudgeted::kNo,
- GrProtected::kNo, GrSurfaceProxy::UseAllocator::kYes);
+ backendFormat, fBackendTexture.dimensions(), readSwizzle, GrRenderable::kNo, 1,
+ fSurfaceOrigin, mipMapped, mipMapsStatus, GrInternalSurfaceFlags::kReadOnly,
+ SkBackingFit::kExact, SkBudgeted::kNo, GrProtected::kNo,
+ GrSurfaceProxy::UseAllocator::kYes);
if (!proxy) {
return {};
}
- if (0 == origin.fX && 0 == origin.fY &&
- info.width() == fBackendTexture.width() && info.height() == fBackendTexture.height() &&
+ if (origin.isZero() && info.dimensions() == fBackendTexture.dimensions() &&
(!willNeedMipMaps || GrMipMapped::kYes == proxy->mipMapped())) {
// If the caller wants the entire texture and we have the correct mip support, we're done
return GrSurfaceProxyView(std::move(proxy), fSurfaceOrigin, readSwizzle);
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp
index 4bfbf7a..3fc381a 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -479,10 +479,6 @@
if (taskGroup && renderTargetContext) {
// Create our texture proxy
- GrSurfaceDesc desc;
- desc.fWidth = maskSpaceIBounds.width();
- desc.fHeight = maskSpaceIBounds.height();
-
GrBackendFormat format = caps->getDefaultBackendFormat(GrColorType::kAlpha_8,
GrRenderable::kNo);
@@ -491,7 +487,7 @@
// MDB TODO: We're going to fill this proxy with an ASAP upload (which is out of order wrt
// to ops), so it can't have any pending IO.
proxy = proxyProvider->createProxy(format,
- desc,
+ maskSpaceIBounds.size(),
swizzle,
GrRenderable::kNo,
1,
diff --git a/src/gpu/GrDrawOpAtlas.cpp b/src/gpu/GrDrawOpAtlas.cpp
index 18d4972..2ca5e6b 100644
--- a/src/gpu/GrDrawOpAtlas.cpp
+++ b/src/gpu/GrDrawOpAtlas.cpp
@@ -554,9 +554,7 @@
GrProxyProvider* proxyProvider, GenerationCounter* generationCounter) {
SkASSERT(SkIsPow2(fTextureWidth) && SkIsPow2(fTextureHeight));
- GrSurfaceDesc desc;
- desc.fWidth = fTextureWidth;
- desc.fHeight = fTextureHeight;
+ SkISize dims = {fTextureWidth, fTextureHeight};
int numPlotsX = fTextureWidth/fPlotWidth;
int numPlotsY = fTextureHeight/fPlotHeight;
@@ -564,7 +562,7 @@
for (uint32_t i = 0; i < this->maxPages(); ++i) {
GrSwizzle swizzle = proxyProvider->caps()->getReadSwizzle(fFormat, fColorType);
sk_sp<GrSurfaceProxy> proxy = proxyProvider->createProxy(
- fFormat, desc, swizzle, GrRenderable::kNo, 1, kTopLeft_GrSurfaceOrigin,
+ fFormat, dims, swizzle, GrRenderable::kNo, 1, kTopLeft_GrSurfaceOrigin,
GrMipMapped::kNo, SkBackingFit::kExact, SkBudgeted::kYes, GrProtected::kNo,
GrInternalSurfaceFlags::kNone, GrSurfaceProxy::UseAllocator::kNo);
if (!proxy) {
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index b4fa68f..e46052b 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -102,12 +102,14 @@
return false;
}
-static bool validate_texel_levels(int w, int h, GrColorType texelColorType,
+static bool validate_texel_levels(SkISize dimensions, GrColorType texelColorType,
const GrMipLevel* texels, int mipLevelCount, const GrCaps* caps) {
SkASSERT(mipLevelCount > 0);
bool hasBasePixels = texels[0].fPixels;
int levelsWithPixelsCnt = 0;
auto bpp = GrColorTypeBytesPerPixel(texelColorType);
+ int w = dimensions.fWidth;
+ int h = dimensions.fHeight;
for (int currentMipLevel = 0; currentMipLevel < mipLevelCount; ++currentMipLevel) {
if (texels[currentMipLevel].fPixels) {
const size_t minRowBytes = w * bpp;
@@ -145,7 +147,7 @@
return levelsWithPixelsCnt == 1 || levelsWithPixelsCnt == mipLevelCount;
}
-sk_sp<GrTexture> GrGpu::createTextureCommon(const GrSurfaceDesc& desc,
+sk_sp<GrTexture> GrGpu::createTextureCommon(SkISize dimensions,
const GrBackendFormat& format,
GrRenderable renderable,
int renderTargetSampleCnt,
@@ -159,8 +161,8 @@
}
GrMipMapped mipMapped = mipLevelCount > 1 ? GrMipMapped::kYes : GrMipMapped::kNo;
- if (!this->caps()->validateSurfaceParams({desc.fWidth, desc.fHeight}, format, renderable,
- renderTargetSampleCnt, mipMapped)) {
+ if (!this->caps()->validateSurfaceParams(dimensions, format, renderable, renderTargetSampleCnt,
+ mipMapped)) {
return nullptr;
}
@@ -171,7 +173,7 @@
// Attempt to catch un- or wrongly initialized sample counts.
SkASSERT(renderTargetSampleCnt > 0 && renderTargetSampleCnt <= 64);
this->handleDirtyContext();
- auto tex = this->onCreateTexture(desc,
+ auto tex = this->onCreateTexture(dimensions,
format,
renderable,
renderTargetSampleCnt,
@@ -194,7 +196,7 @@
return tex;
}
-sk_sp<GrTexture> GrGpu::createTexture(const GrSurfaceDesc& desc,
+sk_sp<GrTexture> GrGpu::createTexture(SkISize dimensions,
const GrBackendFormat& format,
GrRenderable renderable,
int renderTargetSampleCnt,
@@ -203,19 +205,20 @@
GrProtected isProtected) {
int mipLevelCount = 1;
if (mipMapped == GrMipMapped::kYes) {
- mipLevelCount = 32 - SkCLZ(static_cast<uint32_t>(std::max(desc.fWidth, desc.fHeight)));
+ mipLevelCount =
+ 32 - SkCLZ(static_cast<uint32_t>(std::max(dimensions.fWidth, dimensions.fHeight)));
}
uint32_t levelClearMask =
this->caps()->shouldInitializeTextures() ? (1 << mipLevelCount) - 1 : 0;
- auto tex = this->createTextureCommon(desc, format, renderable, renderTargetSampleCnt, budgeted,
- isProtected, mipLevelCount, levelClearMask);
+ auto tex = this->createTextureCommon(dimensions, format, renderable, renderTargetSampleCnt,
+ budgeted, isProtected, mipLevelCount, levelClearMask);
if (tex && mipMapped == GrMipMapped::kYes && levelClearMask) {
tex->texturePriv().markMipMapsClean();
}
return tex;
}
-sk_sp<GrTexture> GrGpu::createTexture(const GrSurfaceDesc& desc,
+sk_sp<GrTexture> GrGpu::createTexture(SkISize dimensions,
const GrBackendFormat& format,
GrRenderable renderable,
int renderTargetSampleCnt,
@@ -227,7 +230,7 @@
int texelLevelCount) {
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
if (texelLevelCount) {
- if (!validate_texel_levels(desc.fWidth, desc.fHeight, srcColorType, texels, texelLevelCount,
+ if (!validate_texel_levels(dimensions, srcColorType, texels, texelLevelCount,
this->caps())) {
return nullptr;
}
@@ -247,15 +250,15 @@
}
}
- auto tex = this->createTextureCommon(desc, format, renderable, renderTargetSampleCnt, budgeted,
- isProtected, texelLevelCount, levelClearMask);
+ auto tex = this->createTextureCommon(dimensions, format, renderable, renderTargetSampleCnt,
+ budgeted, isProtected, texelLevelCount, levelClearMask);
if (tex) {
bool markMipLevelsClean = false;
// Currently if level 0 does not have pixels then no other level may, as enforced by
// validate_texel_levels.
if (texelLevelCount && texels[0].fPixels) {
- if (!this->writePixels(tex.get(), 0, 0, desc.fWidth, desc.fHeight, textureColorType,
- srcColorType, texels, texelLevelCount)) {
+ if (!this->writePixels(tex.get(), 0, 0, dimensions.fWidth, dimensions.fHeight,
+ textureColorType, srcColorType, texels, texelLevelCount)) {
return nullptr;
}
// Currently if level[1] of mip map has pixel data then so must all other levels.
@@ -512,7 +515,8 @@
return false;
}
- if (!validate_texel_levels(width, height, srcColorType, texels, mipLevelCount, this->caps())) {
+ if (!validate_texel_levels({width, height}, srcColorType, texels, mipLevelCount,
+ this->caps())) {
return false;
}
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index d389f36..0cc7ccf 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -84,7 +84,7 @@
* pixel configs can be used as render targets. Support for configs as textures
* or render targets can be checked using GrCaps.
*
- * @param desc describes the texture to be created.
+ * @param dimensions dimensions of the texture to be created.
* @param format the format for the texture (not currently used).
* @param renderable should the resulting texture be renderable
* @param renderTargetSampleCnt The number of samples to use for rendering if renderable is
@@ -93,7 +93,8 @@
* @param isProtected should the texture be created as protected.
* @param texels array of mipmap levels containing texel data to load.
* If level i has pixels then it is assumed that its dimensions are
- * max(1, floor(desc.fWidth / 2)) by max(1, floor(desc.fHeight / 2)).
+ * max(1, floor(dimensions.fWidth / 2)) by
+ * max(1, floor(dimensions.fHeight / 2)).
* If texels[i].fPixels == nullptr for all i <= mipLevelCount or
* mipLevelCount is 0 then the texture's contents are uninitialized.
* If a level has non-null pixels, its row bytes must be a multiple of the
@@ -106,11 +107,12 @@
* of uploading texel data.
* @param srcColorType The color type of data in texels[].
* @param texelLevelCount the number of levels in 'texels'. May be 0, 1, or
- * floor(max((log2(desc.fWidth), log2(desc.fHeight)))). It must be the
- * latter if GrCaps::createTextureMustSpecifyAllLevels() is true.
+ * floor(max((log2(dimensions.fWidth), log2(dimensions.fHeight)))). It
+ * must be the latter if GrCaps::createTextureMustSpecifyAllLevels() is
+ * true.
* @return The texture object if successful, otherwise nullptr.
*/
- sk_sp<GrTexture> createTexture(const GrSurfaceDesc& desc,
+ sk_sp<GrTexture> createTexture(SkISize dimensions,
const GrBackendFormat& format,
GrRenderable renderable,
int renderTargetSampleCnt,
@@ -124,7 +126,7 @@
/**
* Simplified createTexture() interface for when there is no initial texel data to upload.
*/
- sk_sp<GrTexture> createTexture(const GrSurfaceDesc& desc,
+ sk_sp<GrTexture> createTexture(SkISize dimensions,
const GrBackendFormat& format,
GrRenderable renderable,
int renderTargetSampleCnt,
@@ -665,7 +667,7 @@
// Texture size, renderablility, format support, sample count will have already been validated
// in base class before onCreateTexture is called.
// If the ith bit is set in levelClearMask then the ith MIP level should be cleared.
- virtual sk_sp<GrTexture> onCreateTexture(const GrSurfaceDesc&,
+ virtual sk_sp<GrTexture> onCreateTexture(SkISize dimensions,
const GrBackendFormat&,
GrRenderable,
int renderTargetSampleCnt,
@@ -739,7 +741,7 @@
virtual void onDumpJSON(SkJSONWriter*) const {}
#endif
- sk_sp<GrTexture> createTextureCommon(const GrSurfaceDesc&,
+ sk_sp<GrTexture> createTextureCommon(SkISize,
const GrBackendFormat&,
GrRenderable,
int renderTargetSampleCnt,
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index 24057b0..e6bf834 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -115,7 +115,7 @@
#if GR_TEST_UTILS
sk_sp<GrTextureProxy> GrProxyProvider::testingOnly_createInstantiatedProxy(
- const SkISize& dimensions,
+ SkISize dimensions,
GrColorType colorType,
const GrBackendFormat& format,
GrRenderable renderable,
@@ -138,18 +138,15 @@
// rely on GrColorType to get a swizzle for the proxy.
return nullptr;
}
- GrSurfaceDesc desc;
- desc.fWidth = dimensions.width();
- desc.fHeight = dimensions.height();
GrResourceProvider* resourceProvider = direct->priv().resourceProvider();
sk_sp<GrTexture> tex;
if (SkBackingFit::kApprox == fit) {
- tex = resourceProvider->createApproxTexture(desc, format, renderable, renderTargetSampleCnt,
- isProtected);
+ tex = resourceProvider->createApproxTexture(dimensions, format, renderable,
+ renderTargetSampleCnt, isProtected);
} else {
- tex = resourceProvider->createTexture(desc, format, renderable, renderTargetSampleCnt,
+ tex = resourceProvider->createTexture(dimensions, format, renderable, renderTargetSampleCnt,
GrMipMapped::kNo, budgeted, isProtected);
}
if (!tex) {
@@ -160,7 +157,7 @@
}
sk_sp<GrTextureProxy> GrProxyProvider::testingOnly_createInstantiatedProxy(
- const SkISize& dimensions,
+ SkISize dimensions,
GrColorType colorType,
GrRenderable renderable,
int renderTargetSampleCnt,
@@ -315,30 +312,25 @@
SkBackingFit fit,
const GrBackendFormat& format,
GrColorType colorType) {
- GrSurfaceDesc desc;
- desc.fWidth = bitmap.width();
- desc.fHeight = bitmap.height();
-
GrSwizzle swizzle = this->caps()->getReadSwizzle(format, colorType);
+ auto dims = bitmap.dimensions();
sk_sp<GrTextureProxy> proxy = this->createLazyProxy(
- [desc, format, bitmap, fit, colorType]
- (GrResourceProvider* resourceProvider) {
+ [dims, format, bitmap, fit, colorType](GrResourceProvider* resourceProvider) {
GrMipLevel mipLevel = { bitmap.getPixels(), bitmap.rowBytes() };
return LazyCallbackResult(resourceProvider->createTexture(
- desc, format, colorType, GrRenderable::kNo, 1, SkBudgeted::kYes, fit,
+ dims, format, colorType, GrRenderable::kNo, 1, SkBudgeted::kYes, fit,
GrProtected::kNo, mipLevel));
},
- format, desc, swizzle, GrRenderable::kNo, 1, kTopLeft_GrSurfaceOrigin,
- GrMipMapped::kNo, GrMipMapsStatus::kNotAllocated, GrInternalSurfaceFlags::kNone, fit,
- SkBudgeted::kYes, GrProtected::kNo, UseAllocator::kYes);
+ format, dims, swizzle, GrRenderable::kNo, 1, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo,
+ GrMipMapsStatus::kNotAllocated, GrInternalSurfaceFlags::kNone, fit, SkBudgeted::kYes,
+ GrProtected::kNo, UseAllocator::kYes);
if (!proxy) {
return nullptr;
}
- SkASSERT(proxy->width() == desc.fWidth);
- SkASSERT(proxy->height() == desc.fHeight);
+ SkASSERT(proxy->dimensions() == bitmap.dimensions());
return proxy;
}
@@ -347,7 +339,6 @@
GrColorType colorType) {
SkASSERT(this->caps()->mipMapSupport());
- GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info());
sk_sp<SkMipMap> mipmaps(SkMipMap::Build(bitmap.pixmap(), nullptr));
if (!mipmaps) {
@@ -355,9 +346,10 @@
}
GrSwizzle readSwizzle = this->caps()->getReadSwizzle(format, colorType);
+ auto dims = bitmap.dimensions();
sk_sp<GrTextureProxy> proxy = this->createLazyProxy(
- [desc, format, bitmap, mipmaps](GrResourceProvider* resourceProvider) {
+ [dims, format, bitmap, mipmaps](GrResourceProvider* resourceProvider) {
const int mipLevelCount = mipmaps->countLevels() + 1;
std::unique_ptr<GrMipLevel[]> texels(new GrMipLevel[mipLevelCount]);
@@ -374,10 +366,10 @@
SkASSERT(generatedMipLevel.fPixmap.colorType() == bitmap.colorType());
}
return LazyCallbackResult(resourceProvider->createTexture(
- desc, format, colorType, GrRenderable::kNo, 1, SkBudgeted::kYes,
+ dims, format, colorType, GrRenderable::kNo, 1, SkBudgeted::kYes,
GrProtected::kNo, texels.get(), mipLevelCount));
},
- format, desc, readSwizzle, GrRenderable::kNo, 1, kTopLeft_GrSurfaceOrigin,
+ format, dims, readSwizzle, GrRenderable::kNo, 1, kTopLeft_GrSurfaceOrigin,
GrMipMapped::kYes, GrMipMapsStatus::kValid, GrInternalSurfaceFlags::kNone,
SkBackingFit::kExact, SkBudgeted::kYes, GrProtected::kNo, UseAllocator::kYes);
@@ -385,14 +377,13 @@
return nullptr;
}
- SkASSERT(proxy->width() == desc.fWidth);
- SkASSERT(proxy->height() == desc.fHeight);
+ SkASSERT(proxy->dimensions() == bitmap.dimensions());
return proxy;
}
sk_sp<GrTextureProxy> GrProxyProvider::createProxy(const GrBackendFormat& format,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
GrSwizzle readSwizzle,
GrRenderable renderable,
int renderTargetSampleCnt,
@@ -417,17 +408,16 @@
if (GrMipMapped::kYes == mipMapped) {
// SkMipMap doesn't include the base level in the level count so we have to add 1
- int mipCount = SkMipMap::ComputeLevelCount(desc.fWidth, desc.fHeight) + 1;
+ int mipCount = SkMipMap::ComputeLevelCount(dimensions.fWidth, dimensions.fHeight) + 1;
if (1 == mipCount) {
mipMapped = GrMipMapped::kNo;
}
}
- if (!caps->validateSurfaceParams({desc.fWidth, desc.fHeight}, format, renderable,
- renderTargetSampleCnt, mipMapped)) {
+ if (!caps->validateSurfaceParams(dimensions, format, renderable, renderTargetSampleCnt,
+ mipMapped)) {
return nullptr;
}
- GrSurfaceDesc copyDesc = desc;
GrMipMapsStatus mipMapsStatus = (GrMipMapped::kYes == mipMapped)
? GrMipMapsStatus::kDirty
: GrMipMapsStatus::kNotAllocated;
@@ -438,11 +428,11 @@
// We know anything we instantiate later from this deferred path will be
// both texturable and renderable
return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(
- *caps, format, copyDesc, renderTargetSampleCnt, origin, mipMapped, mipMapsStatus,
+ *caps, format, dimensions, renderTargetSampleCnt, origin, mipMapped, mipMapsStatus,
readSwizzle, fit, budgeted, isProtected, surfaceFlags, useAllocator));
}
- return sk_sp<GrTextureProxy>(new GrTextureProxy(format, copyDesc, origin, mipMapped,
+ return sk_sp<GrTextureProxy>(new GrTextureProxy(format, dimensions, origin, mipMapped,
mipMapsStatus, readSwizzle, fit, budgeted,
isProtected, surfaceFlags, useAllocator));
}
@@ -455,10 +445,6 @@
return nullptr;
}
- GrSurfaceDesc desc;
- desc.fWidth = dimensions.width();
- desc.fHeight = dimensions.height();
-
GrBackendFormat format = this->caps()->getBackendFormatFromCompressionType(compressionType);
if (!this->caps()->isFormatTexturable(format)) {
@@ -470,13 +456,13 @@
: GrMipMapsStatus::kNotAllocated;
sk_sp<GrTextureProxy> proxy = this->createLazyProxy(
- [dimensions, format, budgeted, mipMapped, isProtected, data]
- (GrResourceProvider* resourceProvider) {
+ [dimensions, format, budgeted, mipMapped, isProtected,
+ data](GrResourceProvider* resourceProvider) {
return LazyCallbackResult(resourceProvider->createCompressedTexture(
dimensions, format, budgeted, mipMapped, isProtected, data.get()));
},
- format, desc, GrSwizzle(), GrRenderable::kNo, 1, kTopLeft_GrSurfaceOrigin, mipMapped,
- mipMapsStatus, GrInternalSurfaceFlags::kReadOnly, SkBackingFit::kExact,
+ format, dimensions, GrSwizzle(), GrRenderable::kNo, 1, kTopLeft_GrSurfaceOrigin,
+ mipMapped, mipMapsStatus, GrInternalSurfaceFlags::kReadOnly, SkBackingFit::kExact,
SkBudgeted::kYes, GrProtected::kNo, UseAllocator::kYes);
if (!proxy) {
@@ -740,7 +726,7 @@
sk_sp<GrTextureProxy> GrProxyProvider::createLazyProxy(LazyInstantiateCallback&& callback,
const GrBackendFormat& format,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
GrSwizzle readSwizzle,
GrRenderable renderable,
int renderTargetSampleCnt,
@@ -756,15 +742,15 @@
if (this->isAbandoned()) {
return nullptr;
}
- SkASSERT((desc.fWidth <= 0 && desc.fHeight <= 0) ||
- (desc.fWidth > 0 && desc.fHeight > 0));
+ SkASSERT((dimensions.fWidth <= 0 && dimensions.fHeight <= 0) ||
+ (dimensions.fWidth > 0 && dimensions.fHeight > 0));
if (!format.isValid()) {
return nullptr;
}
- if (desc.fWidth > this->caps()->maxTextureSize() ||
- desc.fHeight > this->caps()->maxTextureSize()) {
+ if (dimensions.fWidth > this->caps()->maxTextureSize() ||
+ dimensions.fHeight > this->caps()->maxTextureSize()) {
return nullptr;
}
@@ -772,7 +758,7 @@
return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(*this->caps(),
std::move(callback),
format,
- desc,
+ dimensions,
renderTargetSampleCnt,
origin,
mipMapped,
@@ -786,7 +772,7 @@
} else {
return sk_sp<GrTextureProxy>(new GrTextureProxy(std::move(callback),
format,
- desc,
+ dimensions,
origin,
mipMapped,
mipMapsStatus,
@@ -802,7 +788,7 @@
sk_sp<GrRenderTargetProxy> GrProxyProvider::createLazyRenderTargetProxy(
LazyInstantiateCallback&& callback,
const GrBackendFormat& format,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
GrSwizzle readSwizzle,
int sampleCnt,
GrSurfaceOrigin origin,
@@ -818,11 +804,11 @@
if (this->isAbandoned()) {
return nullptr;
}
- SkASSERT((desc.fWidth <= 0 && desc.fHeight <= 0) ||
- (desc.fWidth > 0 && desc.fHeight > 0));
+ SkASSERT((dimensions.fWidth <= 0 && dimensions.fHeight <= 0) ||
+ (dimensions.fWidth > 0 && dimensions.fHeight > 0));
- if (desc.fWidth > this->caps()->maxRenderTargetSize() ||
- desc.fHeight > this->caps()->maxRenderTargetSize()) {
+ if (dimensions.fWidth > this->caps()->maxRenderTargetSize() ||
+ dimensions.fHeight > this->caps()->maxRenderTargetSize()) {
return nullptr;
}
@@ -831,7 +817,7 @@
// actual VkImage to texture from.
SkASSERT(!wrapsVkSecondaryCB);
return sk_sp<GrRenderTargetProxy>(new GrTextureRenderTargetProxy(
- *this->caps(), std::move(callback), format, desc, sampleCnt, origin,
+ *this->caps(), std::move(callback), format, dimensions, sampleCnt, origin,
textureInfo->fMipMapped, mipMapsStatus, readSwizzle, fit, budgeted, isProtected,
surfaceFlags, useAllocator));
}
@@ -841,7 +827,7 @@
: GrRenderTargetProxy::WrapsVkSecondaryCB::kNo;
return sk_sp<GrRenderTargetProxy>(new GrRenderTargetProxy(
- std::move(callback), format, desc, sampleCnt, origin, readSwizzle, fit, budgeted,
+ std::move(callback), format, dimensions, sampleCnt, origin, readSwizzle, fit, budgeted,
isProtected, surfaceFlags, useAllocator, vkSCB));
}
@@ -859,19 +845,17 @@
}
SkASSERT(renderTargetSampleCnt == 1 || renderable == GrRenderable::kYes);
- GrSurfaceDesc desc;
GrInternalSurfaceFlags surfaceFlags = GrInternalSurfaceFlags::kNone;
- desc.fWidth = -1;
- desc.fHeight = -1;
+ static constexpr SkISize kLazyDims = {-1, -1};
if (GrRenderable::kYes == renderable) {
return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(
- caps, std::move(callback), format, desc, renderTargetSampleCnt, origin,
+ caps, std::move(callback), format, kLazyDims, renderTargetSampleCnt, origin,
GrMipMapped::kNo, GrMipMapsStatus::kNotAllocated, readSwizzle,
SkBackingFit::kApprox, SkBudgeted::kYes, isProtected, surfaceFlags, useAllocator));
} else {
return sk_sp<GrTextureProxy>(new GrTextureProxy(
- std::move(callback), format, desc, origin, GrMipMapped::kNo,
+ std::move(callback), format, kLazyDims, origin, GrMipMapped::kNo,
GrMipMapsStatus::kNotAllocated, readSwizzle, SkBackingFit::kApprox,
SkBudgeted::kYes, isProtected, surfaceFlags, useAllocator));
}
diff --git a/src/gpu/GrProxyProvider.h b/src/gpu/GrProxyProvider.h
index 6b13d42..3ff5471 100644
--- a/src/gpu/GrProxyProvider.h
+++ b/src/gpu/GrProxyProvider.h
@@ -73,7 +73,7 @@
* Create a GrSurfaceProxy without any data.
*/
sk_sp<GrTextureProxy> createProxy(const GrBackendFormat&,
- const GrSurfaceDesc&,
+ SkISize dimensions,
GrSwizzle readSwizzle,
GrRenderable,
int renderTargetSampleCnt,
@@ -160,7 +160,7 @@
*/
sk_sp<GrTextureProxy> createLazyProxy(LazyInstantiateCallback&&,
const GrBackendFormat&,
- const GrSurfaceDesc&,
+ SkISize dimensions,
GrSwizzle readSwizzle,
GrRenderable,
int renderTargetSampleCnt,
@@ -176,7 +176,7 @@
/** A null TextureInfo indicates a non-textureable render target. */
sk_sp<GrRenderTargetProxy> createLazyRenderTargetProxy(LazyInstantiateCallback&&,
const GrBackendFormat&,
- const GrSurfaceDesc&,
+ SkISize dimensions,
GrSwizzle readSwizzle,
int renderTargetSampleCnt,
GrSurfaceOrigin origin,
@@ -245,7 +245,7 @@
* Create a texture proxy that is backed by an instantiated GrSurface.
* TODO: Remove GrColorType. Currently used to infer a readSwizzle.
*/
- sk_sp<GrTextureProxy> testingOnly_createInstantiatedProxy(const SkISize& dimensions,
+ sk_sp<GrTextureProxy> testingOnly_createInstantiatedProxy(SkISize dimensions,
GrColorType colorType,
const GrBackendFormat& format,
GrRenderable renderable,
@@ -256,7 +256,7 @@
GrProtected isProtected);
/** Version of above that picks the default format for the color type. */
- sk_sp<GrTextureProxy> testingOnly_createInstantiatedProxy(const SkISize& dimensions,
+ sk_sp<GrTextureProxy> testingOnly_createInstantiatedProxy(SkISize dimensions,
GrColorType colorType,
GrRenderable renderable,
int renderTargetSampleCnt,
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index c49927c..a3d5a5d 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -165,7 +165,7 @@
GrColorType colorType,
sk_sp<SkColorSpace> colorSpace,
SkBackingFit fit,
- const SkISize& dimensions,
+ SkISize dimensions,
const GrBackendFormat& format,
int sampleCnt,
GrMipMapped mipMapped,
@@ -180,15 +180,12 @@
if (context->priv().abandoned()) {
return nullptr;
}
- GrSurfaceDesc desc;
- desc.fWidth = dimensions.width();
- desc.fHeight = dimensions.height();
GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(format, colorType);
sk_sp<GrTextureProxy> proxy = context->priv().proxyProvider()->createProxy(
- format, desc, swizzle, GrRenderable::kYes, sampleCnt, origin, mipMapped, fit, budgeted,
- isProtected);
+ format, dimensions, swizzle, GrRenderable::kYes, sampleCnt, origin, mipMapped, fit,
+ budgeted, isProtected);
if (!proxy) {
return nullptr;
}
@@ -207,7 +204,7 @@
GrColorType colorType,
sk_sp<SkColorSpace> colorSpace,
SkBackingFit fit,
- const SkISize& dimensions,
+ SkISize dimensions,
int sampleCnt,
GrMipMapped mipMapped,
GrProtected isProtected,
@@ -250,7 +247,7 @@
GrColorType colorType,
sk_sp<SkColorSpace> colorSpace,
SkBackingFit fit,
- const SkISize& dimensions,
+ SkISize dimensions,
int sampleCnt,
GrMipMapped mipMapped,
GrProtected isProtected,
@@ -1910,7 +1907,7 @@
void GrRenderTargetContext::asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace,
sk_sp<SkColorSpace> dstColorSpace,
const SkIRect& srcRect,
- const SkISize& dstSize,
+ SkISize dstSize,
RescaleGamma rescaleGamma,
SkFilterQuality rescaleQuality,
ReadPixelsCallback callback,
diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h
index 605b6c8..3101fbe 100644
--- a/src/gpu/GrRenderTargetContext.h
+++ b/src/gpu/GrRenderTargetContext.h
@@ -61,27 +61,49 @@
GrRecordingContext*, GrColorType, sk_sp<SkColorSpace>, sk_sp<GrSurfaceProxy>,
GrSurfaceOrigin, const SkSurfaceProps*, bool managedOps = true);
- static std::unique_ptr<GrRenderTargetContext> Make(
- GrRecordingContext*, GrColorType, sk_sp<SkColorSpace>, SkBackingFit,
- const SkISize& dimensions, const GrBackendFormat&, int sampleCnt, GrMipMapped,
- GrProtected, GrSurfaceOrigin, SkBudgeted, const SkSurfaceProps*);
+ static std::unique_ptr<GrRenderTargetContext> Make(GrRecordingContext*,
+ GrColorType,
+ sk_sp<SkColorSpace>,
+ SkBackingFit,
+ SkISize dimensions,
+ const GrBackendFormat&,
+ int sampleCnt,
+ GrMipMapped,
+ GrProtected,
+ GrSurfaceOrigin,
+ SkBudgeted,
+ const SkSurfaceProps*);
// Same as above but will use the default GrBackendFormat for the given GrColorType
static std::unique_ptr<GrRenderTargetContext> Make(
- GrRecordingContext*, GrColorType, sk_sp<SkColorSpace>, SkBackingFit,
- const SkISize& dimensions, int sampleCnt = 1, GrMipMapped = GrMipMapped::kNo,
- GrProtected = GrProtected::kNo, GrSurfaceOrigin = kBottomLeft_GrSurfaceOrigin,
- SkBudgeted = SkBudgeted::kYes, const SkSurfaceProps* = nullptr);
+ GrRecordingContext*,
+ GrColorType,
+ sk_sp<SkColorSpace>,
+ SkBackingFit,
+ SkISize dimensions,
+ int sampleCnt = 1,
+ GrMipMapped = GrMipMapped::kNo,
+ GrProtected = GrProtected::kNo,
+ GrSurfaceOrigin = kBottomLeft_GrSurfaceOrigin,
+ SkBudgeted = SkBudgeted::kYes,
+ const SkSurfaceProps* = nullptr);
// Same as previous factory but will try to use fallback GrColorTypes if the one passed in
// fails. The fallback GrColorType will have at least the number of channels and precision per
// channel as the passed in GrColorType. It may also swizzle the changes (e.g., BGRA -> RGBA).
// SRGB-ness will be preserved.
static std::unique_ptr<GrRenderTargetContext> MakeWithFallback(
- GrRecordingContext*, GrColorType, sk_sp<SkColorSpace>, SkBackingFit,
- const SkISize& dimensions, int sampleCnt = 1, GrMipMapped = GrMipMapped::kNo,
- GrProtected = GrProtected::kNo, GrSurfaceOrigin = kBottomLeft_GrSurfaceOrigin,
- SkBudgeted = SkBudgeted::kYes, const SkSurfaceProps* = nullptr);
+ GrRecordingContext*,
+ GrColorType,
+ sk_sp<SkColorSpace>,
+ SkBackingFit,
+ SkISize dimensions,
+ int sampleCnt = 1,
+ GrMipMapped = GrMipMapped::kNo,
+ GrProtected = GrProtected::kNo,
+ GrSurfaceOrigin = kBottomLeft_GrSurfaceOrigin,
+ SkBudgeted = SkBudgeted::kYes,
+ const SkSurfaceProps* = nullptr);
// These match the definitions in SkSurface & GrSurface.h, for whence they came
typedef void* ReleaseContext;
@@ -515,7 +537,7 @@
void asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace,
sk_sp<SkColorSpace> dstColorSpace,
const SkIRect& srcRect,
- const SkISize& dstSize,
+ SkISize dstSize,
RescaleGamma rescaleGamma,
SkFilterQuality rescaleQuality,
ReadPixelsCallback callback,
diff --git a/src/gpu/GrRenderTargetProxy.cpp b/src/gpu/GrRenderTargetProxy.cpp
index 8268269..e16dba4 100644
--- a/src/gpu/GrRenderTargetProxy.cpp
+++ b/src/gpu/GrRenderTargetProxy.cpp
@@ -23,7 +23,7 @@
// cases to make the sampleConfig/numSamples stuff more rational.
GrRenderTargetProxy::GrRenderTargetProxy(const GrCaps& caps,
const GrBackendFormat& format,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
int sampleCount,
GrSurfaceOrigin origin,
const GrSwizzle& textureSwizzle,
@@ -32,7 +32,7 @@
GrProtected isProtected,
GrInternalSurfaceFlags surfaceFlags,
UseAllocator useAllocator)
- : INHERITED(format, desc, GrRenderable::kYes, origin, textureSwizzle, fit, budgeted,
+ : INHERITED(format, dimensions, GrRenderable::kYes, origin, textureSwizzle, fit, budgeted,
isProtected, surfaceFlags, useAllocator)
, fSampleCnt(sampleCount)
, fWrapsVkSecondaryCB(WrapsVkSecondaryCB::kNo) {}
@@ -40,7 +40,7 @@
// Lazy-callback version
GrRenderTargetProxy::GrRenderTargetProxy(LazyInstantiateCallback&& callback,
const GrBackendFormat& format,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
int sampleCount,
GrSurfaceOrigin origin,
const GrSwizzle& textureSwizzle,
@@ -50,8 +50,8 @@
GrInternalSurfaceFlags surfaceFlags,
UseAllocator useAllocator,
WrapsVkSecondaryCB wrapsVkSecondaryCB)
- : INHERITED(std::move(callback), format, desc, GrRenderable::kYes, origin, textureSwizzle,
- fit, budgeted, isProtected, surfaceFlags, useAllocator)
+ : INHERITED(std::move(callback), format, dimensions, GrRenderable::kYes, origin,
+ textureSwizzle, fit, budgeted, isProtected, surfaceFlags, useAllocator)
, fSampleCnt(sampleCount)
, fWrapsVkSecondaryCB(wrapsVkSecondaryCB) {}
diff --git a/src/gpu/GrRenderTargetProxy.h b/src/gpu/GrRenderTargetProxy.h
index 69c647c..4d68c20 100644
--- a/src/gpu/GrRenderTargetProxy.h
+++ b/src/gpu/GrRenderTargetProxy.h
@@ -90,7 +90,7 @@
// Deferred version
GrRenderTargetProxy(const GrCaps&,
const GrBackendFormat&,
- const GrSurfaceDesc&,
+ SkISize,
int sampleCount,
GrSurfaceOrigin,
const GrSwizzle& textureSwizzle,
@@ -114,7 +114,7 @@
// know the final size until flush time.
GrRenderTargetProxy(LazyInstantiateCallback&&,
const GrBackendFormat&,
- const GrSurfaceDesc&,
+ SkISize,
int sampleCount,
GrSurfaceOrigin,
const GrSwizzle& textureSwizzle,
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index 25835a7..1833748 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -43,7 +43,7 @@
fCaps = sk_ref_sp(fGpu->caps());
}
-sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc,
+sk_sp<GrTexture> GrResourceProvider::createTexture(SkISize dimensions,
const GrBackendFormat& format,
GrColorType colorType,
GrRenderable renderable,
@@ -61,45 +61,44 @@
}
GrMipMapped mipMapped = mipLevelCount > 1 ? GrMipMapped::kYes : GrMipMapped::kNo;
- if (!fCaps->validateSurfaceParams({desc.fWidth, desc.fHeight}, format, renderable,
- renderTargetSampleCnt, mipMapped)) {
+ if (!fCaps->validateSurfaceParams(dimensions, format, renderable, renderTargetSampleCnt,
+ mipMapped)) {
return nullptr;
}
// Current rule is that you can provide no level data, just the base, or all the levels.
bool hasPixels = mipLevelCount && texels[0].fPixels;
- auto scratch = this->getExactScratch(desc, format, renderable, renderTargetSampleCnt, budgeted,
- mipMapped, isProtected);
+ auto scratch = this->getExactScratch(dimensions, format, renderable, renderTargetSampleCnt,
+ budgeted, mipMapped, isProtected);
if (scratch) {
if (!hasPixels) {
return scratch;
}
- return this->writePixels(std::move(scratch), colorType, {desc.fWidth, desc.fHeight}, texels,
- mipLevelCount);
+ return this->writePixels(std::move(scratch), colorType, dimensions, texels, mipLevelCount);
}
SkAutoSTMalloc<14, GrMipLevel> tmpTexels;
SkAutoSTArray<14, std::unique_ptr<char[]>> tmpDatas;
GrColorType tempColorType = GrColorType::kUnknown;
if (hasPixels) {
- tempColorType = this->prepareLevels(format, colorType, {desc.fWidth, desc.fHeight}, texels,
- mipLevelCount, &tmpTexels, &tmpDatas);
+ tempColorType = this->prepareLevels(format, colorType, dimensions, texels, mipLevelCount,
+ &tmpTexels, &tmpDatas);
if (tempColorType == GrColorType::kUnknown) {
return nullptr;
}
}
- return fGpu->createTexture(desc, format, renderable, renderTargetSampleCnt, budgeted,
+ return fGpu->createTexture(dimensions, format, renderable, renderTargetSampleCnt, budgeted,
isProtected, colorType, tempColorType, tmpTexels.get(),
mipLevelCount);
}
-sk_sp<GrTexture> GrResourceProvider::getExactScratch(const GrSurfaceDesc& desc,
+sk_sp<GrTexture> GrResourceProvider::getExactScratch(SkISize dimensions,
const GrBackendFormat& format,
GrRenderable renderable,
int renderTargetSampleCnt,
SkBudgeted budgeted,
GrMipMapped mipMapped,
GrProtected isProtected) {
- sk_sp<GrTexture> tex(this->refScratchTexture(desc, format, renderable, renderTargetSampleCnt,
- mipMapped, isProtected));
+ sk_sp<GrTexture> tex(this->refScratchTexture(dimensions, format, renderable,
+ renderTargetSampleCnt, mipMapped, isProtected));
if (tex && SkBudgeted::kNo == budgeted) {
tex->resourcePriv().makeUnbudgeted();
}
@@ -107,7 +106,7 @@
return tex;
}
-sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc,
+sk_sp<GrTexture> GrResourceProvider::createTexture(SkISize dimensions,
const GrBackendFormat& format,
GrColorType colorType,
GrRenderable renderable,
@@ -126,20 +125,19 @@
if (this->isAbandoned()) {
return nullptr;
}
- if (!fCaps->validateSurfaceParams({desc.fWidth, desc.fHeight}, format, renderable,
- renderTargetSampleCnt, GrMipMapped::kNo)) {
+ if (!fCaps->validateSurfaceParams(dimensions, format, renderable, renderTargetSampleCnt,
+ GrMipMapped::kNo)) {
return nullptr;
}
- auto tex = this->createApproxTexture(desc, format, renderable, renderTargetSampleCnt,
+ auto tex = this->createApproxTexture(dimensions, format, renderable, renderTargetSampleCnt,
isProtected);
if (!tex) {
return nullptr;
}
- return this->writePixels(std::move(tex), colorType, {desc.fWidth, desc.fHeight}, &mipLevel,
- 1);
+ return this->writePixels(std::move(tex), colorType, dimensions, &mipLevel, 1);
} else {
- return this->createTexture(desc, format, colorType, renderable, renderTargetSampleCnt,
+ return this->createTexture(dimensions, format, colorType, renderable, renderTargetSampleCnt,
budgeted, isProtected, &mipLevel, 1);
}
}
@@ -158,7 +156,7 @@
isProtected, data->data(), data->size());
}
-sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc,
+sk_sp<GrTexture> GrResourceProvider::createTexture(SkISize dimensions,
const GrBackendFormat& format,
GrRenderable renderable,
int renderTargetSampleCnt,
@@ -170,8 +168,8 @@
return nullptr;
}
- if (!fCaps->validateSurfaceParams({desc.fWidth, desc.fHeight}, format, renderable,
- renderTargetSampleCnt, mipMapped)) {
+ if (!fCaps->validateSurfaceParams(dimensions, format, renderable, renderTargetSampleCnt,
+ mipMapped)) {
return nullptr;
}
@@ -180,14 +178,15 @@
SkASSERT(!this->caps()->isFormatCompressed(format));
// TODO: Support GrMipMapped::kYes in scratch texture lookup here.
- sk_sp<GrTexture> tex = this->getExactScratch(
- desc, format, renderable, renderTargetSampleCnt, budgeted, mipMapped, isProtected);
+ sk_sp<GrTexture> tex =
+ this->getExactScratch(dimensions, format, renderable, renderTargetSampleCnt, budgeted,
+ mipMapped, isProtected);
if (tex) {
return tex;
}
- return fGpu->createTexture(desc, format, renderable, renderTargetSampleCnt, mipMapped, budgeted,
- isProtected);
+ return fGpu->createTexture(dimensions, format, renderable, renderTargetSampleCnt, mipMapped,
+ budgeted, isProtected);
}
// Map 'value' to a larger multiple of 2. Values <= 'kMagicTol' will pop up to
@@ -219,7 +218,7 @@
return {adjust(dimensions.width()), adjust(dimensions.height())};
}
-sk_sp<GrTexture> GrResourceProvider::createApproxTexture(const GrSurfaceDesc& desc,
+sk_sp<GrTexture> GrResourceProvider::createApproxTexture(SkISize dimensions,
const GrBackendFormat& format,
GrRenderable renderable,
int renderTargetSampleCnt,
@@ -234,27 +233,23 @@
// textures should be created through the createCompressedTexture function.
SkASSERT(!this->caps()->isFormatCompressed(format));
- if (!fCaps->validateSurfaceParams({desc.fWidth, desc.fHeight}, format, renderable,
- renderTargetSampleCnt, GrMipMapped::kNo)) {
+ if (!fCaps->validateSurfaceParams(dimensions, format, renderable, renderTargetSampleCnt,
+ GrMipMapped::kNo)) {
return nullptr;
}
- // bin by some multiple or power of 2 with a reasonable min
- GrSurfaceDesc copyDesc(desc);
- auto size = MakeApprox({desc.fWidth, desc.fHeight});
- copyDesc.fWidth = size.width();
- copyDesc.fHeight = size.height();
+ auto copyDimensions = MakeApprox(dimensions);
- if (auto tex = this->refScratchTexture(copyDesc, format, renderable, renderTargetSampleCnt,
- GrMipMapped::kNo, isProtected)) {
+ if (auto tex = this->refScratchTexture(copyDimensions, format, renderable,
+ renderTargetSampleCnt, GrMipMapped::kNo, isProtected)) {
return tex;
}
- return fGpu->createTexture(copyDesc, format, renderable, renderTargetSampleCnt,
+ return fGpu->createTexture(copyDimensions, format, renderable, renderTargetSampleCnt,
GrMipMapped::kNo, SkBudgeted::kYes, isProtected);
}
-sk_sp<GrTexture> GrResourceProvider::refScratchTexture(const GrSurfaceDesc& desc,
+sk_sp<GrTexture> GrResourceProvider::refScratchTexture(SkISize dimensions,
const GrBackendFormat& format,
GrRenderable renderable,
int renderTargetSampleCnt,
@@ -263,16 +258,15 @@
ASSERT_SINGLE_OWNER
SkASSERT(!this->isAbandoned());
SkASSERT(!this->caps()->isFormatCompressed(format));
- SkASSERT(fCaps->validateSurfaceParams({desc.fWidth, desc.fHeight}, format, renderable,
- renderTargetSampleCnt, GrMipMapped::kNo));
+ SkASSERT(fCaps->validateSurfaceParams(dimensions, format, renderable, renderTargetSampleCnt,
+ GrMipMapped::kNo));
// We could make initial clears work with scratch textures but it is a rare case so we just opt
// to fall back to making a new texture.
if (fGpu->caps()->reuseScratchTextures() || renderable == GrRenderable::kYes) {
GrScratchKey key;
- GrTexturePriv::ComputeScratchKey(*this->caps(), format, {desc.fWidth, desc.fHeight},
- renderable, renderTargetSampleCnt, mipMapped, isProtected,
- &key);
+ GrTexturePriv::ComputeScratchKey(*this->caps(), format, dimensions, renderable,
+ renderTargetSampleCnt, mipMapped, isProtected, &key);
GrGpuResource* resource = fCache->findAndRefScratchResource(key);
if (resource) {
fGpu->stats()->incNumScratchTexturesReused();
@@ -562,7 +556,7 @@
// Ensures the row bytes are populated (not 0) and makes a copy to a temporary
// to make the row bytes tight if necessary. Returns false if the input row bytes are invalid.
static bool prepare_level(const GrMipLevel& inLevel,
- const SkISize& dimensions,
+ SkISize dimensions,
bool rowBytesSupport,
GrColorType origColorType,
GrColorType allowedColorType,
@@ -594,7 +588,7 @@
GrColorType GrResourceProvider::prepareLevels(const GrBackendFormat& format,
GrColorType colorType,
- const SkISize& baseSize,
+ SkISize baseSize,
const GrMipLevel texels[],
int mipLevelCount,
TempLevels* tempLevels,
@@ -622,7 +616,7 @@
sk_sp<GrTexture> GrResourceProvider::writePixels(sk_sp<GrTexture> texture,
GrColorType colorType,
- const SkISize& baseSize,
+ SkISize baseSize,
const GrMipLevel texels[],
int mipLevelCount) const {
SkASSERT(!this->isAbandoned());
diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h
index bb4e460..5aa14e9 100644
--- a/src/gpu/GrResourceProvider.h
+++ b/src/gpu/GrResourceProvider.h
@@ -59,14 +59,14 @@
* GrRenderTarget. The texture's format and sample count will always match the request.
* The contents of the texture are undefined.
*/
- sk_sp<GrTexture> createApproxTexture(const GrSurfaceDesc& desc,
+ sk_sp<GrTexture> createApproxTexture(SkISize dimensions,
const GrBackendFormat& format,
GrRenderable renderable,
int renderTargetSampleCnt,
GrProtected isProtected);
/** Create an exact fit texture with no initial data to upload. */
- sk_sp<GrTexture> createTexture(const GrSurfaceDesc& desc,
+ sk_sp<GrTexture> createTexture(SkISize dimensions,
const GrBackendFormat& format,
GrRenderable renderable,
int renderTargetSampleCnt,
@@ -79,7 +79,7 @@
* for the format and also describe the texel data. This will ensure any conversions that
* need to get applied to the data before upload are applied.
*/
- sk_sp<GrTexture> createTexture(const GrSurfaceDesc& desc,
+ sk_sp<GrTexture> createTexture(SkISize dimensions,
const GrBackendFormat& format,
GrColorType colorType,
GrRenderable renderable,
@@ -94,7 +94,7 @@
* for the format and also describe the texel data. This will ensure any conversions that
* need to get applied to the data before upload are applied.
*/
- sk_sp<GrTexture> createTexture(const GrSurfaceDesc&,
+ sk_sp<GrTexture> createTexture(SkISize dimensions,
const GrBackendFormat&,
GrColorType srcColorType,
GrRenderable,
@@ -310,9 +310,9 @@
private:
sk_sp<GrGpuResource> findResourceByUniqueKey(const GrUniqueKey&);
- // Attempts to find a resource in the cache that exactly matches the GrSurfaceDesc. Failing that
+ // Attempts to find a resource in the cache that exactly matches the SkISize. Failing that
// it returns null. If non-null, the resulting texture is always budgeted.
- sk_sp<GrTexture> refScratchTexture(const GrSurfaceDesc&,
+ sk_sp<GrTexture> refScratchTexture(SkISize dimensions,
const GrBackendFormat&,
GrRenderable,
int renderTargetSampleCnt,
@@ -323,7 +323,7 @@
* Try to find an existing scratch texture that exactly matches 'desc'. If successful
* update the budgeting accordingly.
*/
- sk_sp<GrTexture> getExactScratch(const GrSurfaceDesc&,
+ sk_sp<GrTexture> getExactScratch(SkISize dimensions,
const GrBackendFormat&,
GrRenderable,
int renderTargetSampleCnt,
@@ -337,7 +337,7 @@
using TempLevelDatas = SkAutoSTArray<14, std::unique_ptr<char[]>>;
GrColorType prepareLevels(const GrBackendFormat& format,
GrColorType,
- const SkISize& baseSize,
+ SkISize baseSize,
const GrMipLevel texels[],
int mipLevelCount,
TempLevels*,
@@ -350,7 +350,7 @@
// on failure.
sk_sp<GrTexture> writePixels(sk_sp<GrTexture> texture,
GrColorType colorType,
- const SkISize& baseSize,
+ SkISize baseSize,
const GrMipLevel texels[],
int mipLevelCount) const;
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp
index 8b50c2a..7ea30e2 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -175,20 +175,16 @@
static sk_sp<GrTextureProxy> make_deferred_mask_texture_proxy(GrRecordingContext* context,
SkBackingFit fit,
- int width, int height) {
+ SkISize dimensions) {
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
const GrCaps* caps = context->priv().caps();
- GrSurfaceDesc desc;
- desc.fWidth = width;
- desc.fHeight = height;
-
const GrBackendFormat format = caps->getDefaultBackendFormat(GrColorType::kAlpha_8,
GrRenderable::kNo);
GrSwizzle swizzle = caps->getReadSwizzle(format, GrColorType::kAlpha_8);
- return proxyProvider->createProxy(format, desc, swizzle, GrRenderable::kNo, 1,
+ return proxyProvider->createProxy(format, dimensions, swizzle, GrRenderable::kNo, 1,
kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, fit,
SkBudgeted::kYes, GrProtected::kNo);
}
@@ -341,9 +337,7 @@
}
if (taskGroup) {
- proxy = make_deferred_mask_texture_proxy(args.fContext, fit,
- boundsForMask->width(),
- boundsForMask->height());
+ proxy = make_deferred_mask_texture_proxy(args.fContext, fit, boundsForMask->size());
if (!proxy) {
return false;
}
diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp
index a742c17..9822462 100644
--- a/src/gpu/GrSurfaceContext.cpp
+++ b/src/gpu/GrSurfaceContext.cpp
@@ -61,28 +61,23 @@
return surfaceContext;
}
-std::unique_ptr<GrSurfaceContext> GrSurfaceContext::Make(
- GrRecordingContext* context,
- const SkISize& dimensions,
- const GrBackendFormat& format,
- GrRenderable renderable,
- int renderTargetSampleCnt,
- GrMipMapped mipMapped,
- GrProtected isProtected,
- GrSurfaceOrigin origin,
- GrColorType colorType,
- SkAlphaType alphaType,
- sk_sp<SkColorSpace> colorSpace,
- SkBackingFit fit,
- SkBudgeted budgeted) {
- GrSurfaceDesc desc;
- desc.fWidth = dimensions.width();
- desc.fHeight = dimensions.height();
-
+std::unique_ptr<GrSurfaceContext> GrSurfaceContext::Make(GrRecordingContext* context,
+ SkISize dimensions,
+ const GrBackendFormat& format,
+ GrRenderable renderable,
+ int renderTargetSampleCnt,
+ GrMipMapped mipMapped,
+ GrProtected isProtected,
+ GrSurfaceOrigin origin,
+ GrColorType colorType,
+ SkAlphaType alphaType,
+ sk_sp<SkColorSpace> colorSpace,
+ SkBackingFit fit,
+ SkBudgeted budgeted) {
GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(format, colorType);
sk_sp<GrTextureProxy> proxy = context->priv().proxyProvider()->createProxy(
- format, desc, swizzle, renderable, renderTargetSampleCnt, origin, mipMapped, fit,
+ format, dimensions, swizzle, renderable, renderTargetSampleCnt, origin, mipMapped, fit,
budgeted, isProtected);
if (!proxy) {
return nullptr;
@@ -93,7 +88,6 @@
std::move(colorSpace));
}
-
// In MDB mode the reffing of the 'getLastOpsTask' call's result allows in-progress
// GrOpsTasks to be picked up and added to by renderTargetContexts lower in the call
// stack. When this occurs with a closed GrOpsTask, a new one will be allocated
@@ -359,9 +353,6 @@
direct->priv().validPMUPMConversionExists();
if (!caps->surfaceSupportsWritePixels(dstSurface) || canvas2DFastPath) {
- GrSurfaceDesc desc;
- desc.fWidth = srcInfo.width();
- desc.fHeight = srcInfo.height();
GrColorType colorType;
GrBackendFormat format;
@@ -389,8 +380,8 @@
GrSurfaceOrigin tempOrigin =
this->asRenderTargetContext() ? kTopLeft_GrSurfaceOrigin : dstProxy->origin();
auto tempProxy = direct->priv().proxyProvider()->createProxy(
- format, desc, tempReadSwizzle, GrRenderable::kNo, 1, tempOrigin, GrMipMapped::kNo,
- SkBackingFit::kApprox, SkBudgeted::kYes, GrProtected::kNo);
+ format, srcInfo.dimensions(), tempReadSwizzle, GrRenderable::kNo, 1, tempOrigin,
+ GrMipMapped::kNo, SkBackingFit::kApprox, SkBudgeted::kYes, GrProtected::kNo);
if (!tempProxy) {
return false;
}
diff --git a/src/gpu/GrSurfaceContext.h b/src/gpu/GrSurfaceContext.h
index 4173ea3..4bb1f2d 100644
--- a/src/gpu/GrSurfaceContext.h
+++ b/src/gpu/GrSurfaceContext.h
@@ -42,7 +42,7 @@
GrSurfaceProxyView readView,
GrColorType, SkAlphaType, sk_sp<SkColorSpace>);
- static std::unique_ptr<GrSurfaceContext> Make(GrRecordingContext*, const SkISize& dimensions,
+ static std::unique_ptr<GrSurfaceContext> Make(GrRecordingContext*, SkISize dimensions,
const GrBackendFormat&, GrRenderable,
int renderTargetSampleCnt, GrMipMapped,
GrProtected, GrSurfaceOrigin, GrColorType,
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index b2cee1d..7391c01 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -29,23 +29,23 @@
#include "src/gpu/GrRenderTarget.h"
#include "src/gpu/GrRenderTargetPriv.h"
-static bool is_valid_lazy(const GrSurfaceDesc& desc, SkBackingFit fit) {
+static bool is_valid_lazy(const SkISize& dimensions, SkBackingFit fit) {
// A "fully" lazy proxy's width and height are not known until instantiation time.
// So fully lazy proxies are created with width and height < 0. Regular lazy proxies must be
// created with positive widths and heights. The width and height are set to 0 only after a
// failed instantiation. The former must be "approximate" fit while the latter can be either.
- return ((desc.fWidth < 0 && desc.fHeight < 0 && SkBackingFit::kApprox == fit) ||
- (desc.fWidth > 0 && desc.fHeight > 0));
+ return ((dimensions.fWidth < 0 && dimensions.fHeight < 0 && SkBackingFit::kApprox == fit) ||
+ (dimensions.fWidth > 0 && dimensions.fHeight > 0));
}
-static bool is_valid_non_lazy(const GrSurfaceDesc& desc) {
- return desc.fWidth > 0 && desc.fHeight > 0;
+static bool is_valid_non_lazy(SkISize dimensions) {
+ return dimensions.fWidth > 0 && dimensions.fHeight > 0;
}
#endif
// Deferred version
GrSurfaceProxy::GrSurfaceProxy(const GrBackendFormat& format,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
GrRenderable renderable,
GrSurfaceOrigin origin,
const GrSwizzle& textureSwizzle,
@@ -56,7 +56,7 @@
UseAllocator useAllocator)
: fSurfaceFlags(surfaceFlags)
, fFormat(format)
- , fDimensions{desc.fWidth, desc.fHeight}
+ , fDimensions(dimensions)
, fOrigin(origin)
, fTextureSwizzle(textureSwizzle)
, fFit(fit)
@@ -65,13 +65,13 @@
, fIsProtected(isProtected)
, fGpuMemorySize(kInvalidGpuMemorySize) {
SkASSERT(fFormat.isValid());
- SkASSERT(is_valid_non_lazy(desc));
+ SkASSERT(is_valid_non_lazy(dimensions));
}
// Lazy-callback version
GrSurfaceProxy::GrSurfaceProxy(LazyInstantiateCallback&& callback,
const GrBackendFormat& format,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
GrRenderable renderable,
GrSurfaceOrigin origin,
const GrSwizzle& textureSwizzle,
@@ -82,7 +82,7 @@
UseAllocator useAllocator)
: fSurfaceFlags(surfaceFlags)
, fFormat(format)
- , fDimensions{desc.fWidth, desc.fHeight}
+ , fDimensions(dimensions)
, fOrigin(origin)
, fTextureSwizzle(textureSwizzle)
, fFit(fit)
@@ -93,7 +93,7 @@
, fGpuMemorySize(kInvalidGpuMemorySize) {
SkASSERT(fFormat.isValid());
SkASSERT(fLazyInstantiateCallback);
- SkASSERT(is_valid_lazy(desc, fit));
+ SkASSERT(is_valid_lazy(dimensions, fit));
}
// Wrapped version
@@ -132,17 +132,14 @@
SkASSERT(mipMapped == GrMipMapped::kNo || fFit == SkBackingFit::kExact);
SkASSERT(!this->isLazy());
SkASSERT(!fTarget);
- GrSurfaceDesc desc;
- desc.fWidth = fDimensions.width();
- desc.fHeight = fDimensions.height();
sk_sp<GrSurface> surface;
if (SkBackingFit::kApprox == fFit) {
- surface = resourceProvider->createApproxTexture(desc, fFormat, renderable, sampleCnt,
+ surface = resourceProvider->createApproxTexture(fDimensions, fFormat, renderable, sampleCnt,
fIsProtected);
} else {
- surface = resourceProvider->createTexture(desc, fFormat, renderable, sampleCnt, mipMapped,
- fBudgeted, fIsProtected);
+ surface = resourceProvider->createTexture(fDimensions, fFormat, renderable, sampleCnt,
+ mipMapped, fBudgeted, fIsProtected);
}
if (!surface) {
return nullptr;
diff --git a/src/gpu/GrSurfaceProxy.h b/src/gpu/GrSurfaceProxy.h
index 46af8d7..99cc181 100644
--- a/src/gpu/GrSurfaceProxy.h
+++ b/src/gpu/GrSurfaceProxy.h
@@ -327,7 +327,7 @@
protected:
// Deferred version - takes a new UniqueID from the shared resource/proxy pool.
GrSurfaceProxy(const GrBackendFormat&,
- const GrSurfaceDesc&,
+ SkISize,
GrRenderable,
GrSurfaceOrigin,
const GrSwizzle& textureSwizzle,
@@ -339,7 +339,7 @@
// Lazy-callback version - takes a new UniqueID from the shared resource/proxy pool.
GrSurfaceProxy(LazyInstantiateCallback&&,
const GrBackendFormat&,
- const GrSurfaceDesc&,
+ SkISize,
GrRenderable,
GrSurfaceOrigin,
const GrSwizzle& textureSwizzle,
diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp
index 6b5d3f0..d15e2f0 100644
--- a/src/gpu/GrTextureProxy.cpp
+++ b/src/gpu/GrTextureProxy.cpp
@@ -17,7 +17,7 @@
// Deferred version - no data
GrTextureProxy::GrTextureProxy(const GrBackendFormat& format,
- const GrSurfaceDesc& srcDesc,
+ SkISize dimensions,
GrSurfaceOrigin origin,
GrMipMapped mipMapped,
GrMipMapsStatus mipMapsStatus,
@@ -27,7 +27,7 @@
GrProtected isProtected,
GrInternalSurfaceFlags surfaceFlags,
UseAllocator useAllocator)
- : INHERITED(format, srcDesc, GrRenderable::kNo, origin, textureSwizzle, fit, budgeted,
+ : INHERITED(format, dimensions, GrRenderable::kNo, origin, textureSwizzle, fit, budgeted,
isProtected, surfaceFlags, useAllocator)
, fMipMapped(mipMapped)
, fMipMapsStatus(mipMapsStatus) SkDEBUGCODE(, fInitialMipMapsStatus(fMipMapsStatus))
@@ -39,7 +39,7 @@
// Lazy-callback version
GrTextureProxy::GrTextureProxy(LazyInstantiateCallback&& callback,
const GrBackendFormat& format,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
GrSurfaceOrigin origin,
GrMipMapped mipMapped,
GrMipMapsStatus mipMapsStatus,
@@ -49,8 +49,8 @@
GrProtected isProtected,
GrInternalSurfaceFlags surfaceFlags,
UseAllocator useAllocator)
- : INHERITED(std::move(callback), format, desc, GrRenderable::kNo, origin, texSwizzle, fit,
- budgeted, isProtected, surfaceFlags, useAllocator)
+ : INHERITED(std::move(callback), format, dimensions, GrRenderable::kNo, origin, texSwizzle,
+ fit, budgeted, isProtected, surfaceFlags, useAllocator)
, fMipMapped(mipMapped)
, fMipMapsStatus(mipMapsStatus) SkDEBUGCODE(, fInitialMipMapsStatus(fMipMapsStatus))
, fProxyProvider(nullptr)
diff --git a/src/gpu/GrTextureProxy.h b/src/gpu/GrTextureProxy.h
index 8c23a58..186e2a0 100644
--- a/src/gpu/GrTextureProxy.h
+++ b/src/gpu/GrTextureProxy.h
@@ -109,7 +109,7 @@
// Deferred version - no data.
GrTextureProxy(const GrBackendFormat&,
- const GrSurfaceDesc&,
+ SkISize,
GrSurfaceOrigin,
GrMipMapped,
GrMipMapsStatus,
@@ -132,7 +132,7 @@
// know the final size until flush time.
GrTextureProxy(LazyInstantiateCallback&&,
const GrBackendFormat&,
- const GrSurfaceDesc& desc,
+ SkISize,
GrSurfaceOrigin,
GrMipMapped,
GrMipMapsStatus,
diff --git a/src/gpu/GrTextureRenderTargetProxy.cpp b/src/gpu/GrTextureRenderTargetProxy.cpp
index 6675884..1fa3da1 100644
--- a/src/gpu/GrTextureRenderTargetProxy.cpp
+++ b/src/gpu/GrTextureRenderTargetProxy.cpp
@@ -22,7 +22,7 @@
// GrRenderTargetProxy) so its constructor must be explicitly called.
GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(const GrCaps& caps,
const GrBackendFormat& format,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
int sampleCnt,
GrSurfaceOrigin origin,
GrMipMapped mipMapped,
@@ -33,13 +33,13 @@
GrProtected isProtected,
GrInternalSurfaceFlags surfaceFlags,
UseAllocator useAllocator)
- : GrSurfaceProxy(format, desc, GrRenderable::kYes, origin, texSwizzle, fit, budgeted,
+ : GrSurfaceProxy(format, dimensions, GrRenderable::kYes, origin, texSwizzle, fit, budgeted,
isProtected, surfaceFlags, useAllocator)
// for now textures w/ data are always wrapped
- , GrRenderTargetProxy(caps, format, desc, sampleCnt, origin, texSwizzle, fit, budgeted,
- isProtected, surfaceFlags, useAllocator)
- , GrTextureProxy(format, desc, origin, mipMapped, mipMapsStatus, texSwizzle, fit, budgeted,
- isProtected, surfaceFlags, useAllocator) {
+ , GrRenderTargetProxy(caps, format, dimensions, sampleCnt, origin, texSwizzle, fit,
+ budgeted, isProtected, surfaceFlags, useAllocator)
+ , GrTextureProxy(format, dimensions, origin, mipMapped, mipMapsStatus, texSwizzle, fit,
+ budgeted, isProtected, surfaceFlags, useAllocator) {
this->initSurfaceFlags(caps);
}
@@ -47,7 +47,7 @@
GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(const GrCaps& caps,
LazyInstantiateCallback&& callback,
const GrBackendFormat& format,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
int sampleCnt,
GrSurfaceOrigin origin,
GrMipMapped mipMapped,
@@ -58,15 +58,16 @@
GrProtected isProtected,
GrInternalSurfaceFlags surfaceFlags,
UseAllocator useAllocator)
- : GrSurfaceProxy(std::move(callback), format, desc, GrRenderable::kYes, origin, texSwizzle,
- fit, budgeted, isProtected, surfaceFlags, useAllocator)
+ : GrSurfaceProxy(std::move(callback), format, dimensions, GrRenderable::kYes, origin,
+ texSwizzle, fit, budgeted, isProtected, surfaceFlags, useAllocator)
// Since we have virtual inheritance, we initialize GrSurfaceProxy directly. Send null
// callbacks to the texture and RT proxies simply to route to the appropriate constructors.
- , GrRenderTargetProxy(LazyInstantiateCallback(), format, desc, sampleCnt, origin,
+ , GrRenderTargetProxy(LazyInstantiateCallback(), format, dimensions, sampleCnt, origin,
texSwizzle, fit, budgeted, isProtected, surfaceFlags, useAllocator,
WrapsVkSecondaryCB::kNo)
- , GrTextureProxy(LazyInstantiateCallback(), format, desc, origin, mipMapped, mipMapsStatus,
- texSwizzle, fit, budgeted, isProtected, surfaceFlags, useAllocator) {
+ , GrTextureProxy(LazyInstantiateCallback(), format, dimensions, origin, mipMapped,
+ mipMapsStatus, texSwizzle, fit, budgeted, isProtected, surfaceFlags,
+ useAllocator) {
this->initSurfaceFlags(caps);
}
diff --git a/src/gpu/GrTextureRenderTargetProxy.h b/src/gpu/GrTextureRenderTargetProxy.h
index 68e68f7..d795685 100644
--- a/src/gpu/GrTextureRenderTargetProxy.h
+++ b/src/gpu/GrTextureRenderTargetProxy.h
@@ -30,7 +30,7 @@
// Deferred version
GrTextureRenderTargetProxy(const GrCaps&,
const GrBackendFormat&,
- const GrSurfaceDesc&,
+ SkISize,
int sampleCnt,
GrSurfaceOrigin,
GrMipMapped,
@@ -46,7 +46,7 @@
GrTextureRenderTargetProxy(const GrCaps&,
LazyInstantiateCallback&&,
const GrBackendFormat&,
- const GrSurfaceDesc& desc,
+ SkISize,
int sampleCnt,
GrSurfaceOrigin,
GrMipMapped,
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index 26074ac..470bf2a 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -105,7 +105,7 @@
}
GrSurfaceProxyView GrYUVProvider::refAsTextureProxyView(GrRecordingContext* ctx,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
GrColorType colorType,
SkColorSpace* srcColorSpace,
SkColorSpace* dstColorSpace) {
@@ -164,8 +164,8 @@
// TODO: investigate preallocating mip maps here
auto renderTargetContext = GrRenderTargetContext::Make(
- ctx, colorType, nullptr, SkBackingFit::kExact, {desc.fWidth, desc.fHeight}, 1,
- GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
+ ctx, colorType, nullptr, SkBackingFit::kExact, dimensions, 1, GrMipMapped::kNo,
+ GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
if (!renderTargetContext) {
return {};
}
diff --git a/src/gpu/GrYUVProvider.h b/src/gpu/GrYUVProvider.h
index 521ec48..6e3af05 100644
--- a/src/gpu/GrYUVProvider.h
+++ b/src/gpu/GrYUVProvider.h
@@ -16,7 +16,6 @@
class GrBackendFormat;
class GrRecordingContext;
-struct GrSurfaceDesc;
class GrSurfaceProxyView;
class SkCachedData;
@@ -42,7 +41,7 @@
* On failure (e.g. the provider had no data), this returns NULL.
*/
GrSurfaceProxyView refAsTextureProxyView(GrRecordingContext*,
- const GrSurfaceDesc&,
+ SkISize,
GrColorType colorType,
SkColorSpace* srcColorSpace,
SkColorSpace* dstColorSpace);
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 7579e28..8216270 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -86,13 +86,6 @@
}
)";
-GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo& info) {
- GrSurfaceDesc desc;
- desc.fWidth = info.width();
- desc.fHeight = info.height();
- return desc;
-}
-
void GrMakeKeyFromImageID(GrUniqueKey* key, uint32_t imageID, const SkIRect& imageBounds) {
SkASSERT(key);
SkASSERT(imageID);
diff --git a/src/gpu/SkGr.h b/src/gpu/SkGr.h
index 9613d4a..0d97169 100644
--- a/src/gpu/SkGr.h
+++ b/src/gpu/SkGr.h
@@ -125,8 +125,6 @@
////////////////////////////////////////////////////////////////////////////////
// Misc Sk to Gr type conversions
-GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&);
-
GrSamplerState::Filter GrSkFilterQualityToGrFilterMode(int imageWidth, int imageHeight,
SkFilterQuality paintFilterQuality,
const SkMatrix& viewM,
diff --git a/src/gpu/ccpr/GrCCAtlas.cpp b/src/gpu/ccpr/GrCCAtlas.cpp
index 37f5d65..82f89a6 100644
--- a/src/gpu/ccpr/GrCCAtlas.cpp
+++ b/src/gpu/ccpr/GrCCAtlas.cpp
@@ -114,12 +114,9 @@
[this](GrResourceProvider* resourceProvider,const GrBackendFormat& format,
int sampleCount) {
if (!fBackingTexture) {
- GrSurfaceDesc desc;
- desc.fWidth = fWidth;
- desc.fHeight = fHeight;
fBackingTexture = resourceProvider->createTexture(
- desc, format, GrRenderable::kYes, sampleCount, GrMipMapped::kNo,
- SkBudgeted::kYes, GrProtected::kNo);
+ {fWidth, fHeight}, format, GrRenderable::kYes, sampleCount,
+ GrMipMapped::kNo, SkBudgeted::kYes, GrProtected::kNo);
}
return GrSurfaceProxy::LazyCallbackResult(fBackingTexture);
},
diff --git a/src/gpu/dawn/GrDawnGpu.cpp b/src/gpu/dawn/GrDawnGpu.cpp
index 1d364e2..e80d7b6 100644
--- a/src/gpu/dawn/GrDawnGpu.cpp
+++ b/src/gpu/dawn/GrDawnGpu.cpp
@@ -148,7 +148,7 @@
}
////////////////////////////////////////////////////////////////////////////////
-sk_sp<GrTexture> GrDawnGpu::onCreateTexture(const GrSurfaceDesc& desc,
+sk_sp<GrTexture> GrDawnGpu::onCreateTexture(SkISize dimensions,
const GrBackendFormat& backendFormat,
GrRenderable renderable,
int renderTargetSampleCnt,
@@ -165,10 +165,8 @@
GrMipMapsStatus mipMapsStatus =
mipLevelCount > 1 ? GrMipMapsStatus::kDirty : GrMipMapsStatus::kNotAllocated;
- return GrDawnTexture::Make(this, { desc.fWidth, desc.fHeight },
- format, renderable,
- renderTargetSampleCnt, budgeted, mipLevelCount,
- mipMapsStatus);
+ return GrDawnTexture::Make(this, dimensions, format, renderable, renderTargetSampleCnt,
+ budgeted, mipLevelCount, mipMapsStatus);
}
sk_sp<GrTexture> GrDawnGpu::onCreateCompressedTexture(SkISize dimensions, const GrBackendFormat&,
diff --git a/src/gpu/dawn/GrDawnGpu.h b/src/gpu/dawn/GrDawnGpu.h
index 682e336..8ce14d2 100644
--- a/src/gpu/dawn/GrDawnGpu.h
+++ b/src/gpu/dawn/GrDawnGpu.h
@@ -110,7 +110,7 @@
virtual void querySampleLocations(GrRenderTarget*, SkTArray<SkPoint>*) override {}
- sk_sp<GrTexture> onCreateTexture(const GrSurfaceDesc&,
+ sk_sp<GrTexture> onCreateTexture(SkISize,
const GrBackendFormat&,
GrRenderable,
int renderTargetSampleCnt,
diff --git a/src/gpu/dawn/GrDawnRenderTarget.h b/src/gpu/dawn/GrDawnRenderTarget.h
index 16d498d..fca5508 100644
--- a/src/gpu/dawn/GrDawnRenderTarget.h
+++ b/src/gpu/dawn/GrDawnRenderTarget.h
@@ -43,9 +43,6 @@
// This accounts for the texture's memory and any MSAA renderbuffer's memory.
size_t onGpuMemorySize() const override;
- static GrDawnRenderTarget* Create(GrDawnGpu*, const GrSurfaceDesc&, int sampleCnt,
- const GrDawnRenderTargetInfo&);
-
bool completeStencilAttachment() override;
GrDawnRenderTargetInfo fInfo;
typedef GrRenderTarget INHERITED;
diff --git a/src/gpu/dawn/GrDawnTexture.h b/src/gpu/dawn/GrDawnTexture.h
index df3801f..118ad8f 100644
--- a/src/gpu/dawn/GrDawnTexture.h
+++ b/src/gpu/dawn/GrDawnTexture.h
@@ -52,8 +52,6 @@
}
private:
- GrDawnTexture(GrDawnGpu*, const GrSurfaceDesc&, const GrDawnTextureInfo&, GrMipMapsStatus);
-
GrDawnTextureInfo fInfo;
wgpu::TextureView fTextureView;
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 7697ebb..2cf0032 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -833,10 +833,9 @@
rtIDs.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID;
rtIDs.fRTFBOOwnership = GrBackendObjectOwnership::kBorrowed;
- const auto size = SkISize::Make(backendRT.width(), backendRT.height());
int sampleCount = this->glCaps().getRenderTargetSampleCount(backendRT.sampleCnt(), format);
- return GrGLRenderTarget::MakeWrapped(this, size, format, sampleCount, rtIDs,
+ return GrGLRenderTarget::MakeWrapped(this, backendRT.dimensions(), format, sampleCount, rtIDs,
backendRT.stencilBits());
}
@@ -1296,7 +1295,7 @@
return state;
}
-sk_sp<GrTexture> GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc,
+sk_sp<GrTexture> GrGLGpu::onCreateTexture(SkISize dimensions,
const GrBackendFormat& format,
GrRenderable renderable,
int renderTargetSampleCnt,
@@ -1315,15 +1314,15 @@
mipLevelCount > 1 ? GrMipMapsStatus::kDirty : GrMipMapsStatus::kNotAllocated;
GrGLTextureParameters::SamplerOverriddenState initialState;
GrGLTexture::Desc texDesc;
- texDesc.fSize = {desc.fWidth, desc.fHeight};
+ texDesc.fSize = dimensions;
texDesc.fTarget = GR_GL_TEXTURE_2D;
texDesc.fFormat = format.asGLFormat();
texDesc.fOwnership = GrBackendObjectOwnership::kOwned;
SkASSERT(texDesc.fFormat != GrGLFormat::kUnknown);
SkASSERT(!GrGLFormatIsCompressed(texDesc.fFormat));
- texDesc.fID = this->createTexture2D({desc.fWidth, desc.fHeight}, texDesc.fFormat, renderable,
- &initialState, mipLevelCount);
+ texDesc.fID = this->createTexture2D(dimensions, texDesc.fFormat, renderable, &initialState,
+ mipLevelCount);
if (!texDesc.fID) {
return return_null_texture();
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 3f63fb6..8668363 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -191,7 +191,7 @@
void xferBarrier(GrRenderTarget*, GrXferBarrierType) override;
- sk_sp<GrTexture> onCreateTexture(const GrSurfaceDesc&,
+ sk_sp<GrTexture> onCreateTexture(SkISize dimensions,
const GrBackendFormat&,
GrRenderable,
int renderTargetSampleCnt,
diff --git a/src/gpu/mock/GrMockGpu.cpp b/src/gpu/mock/GrMockGpu.cpp
index 7f0075e..ba2d7fb 100644
--- a/src/gpu/mock/GrMockGpu.cpp
+++ b/src/gpu/mock/GrMockGpu.cpp
@@ -131,7 +131,7 @@
}
}
-sk_sp<GrTexture> GrMockGpu::onCreateTexture(const GrSurfaceDesc& desc,
+sk_sp<GrTexture> GrMockGpu::onCreateTexture(SkISize dimensions,
const GrBackendFormat& format,
GrRenderable renderable,
int renderTargetSampleCnt,
@@ -154,12 +154,12 @@
GrMockTextureInfo texInfo(ct, SkImage::CompressionType::kNone, NextInternalTextureID());
if (renderable == GrRenderable::kYes) {
GrMockRenderTargetInfo rtInfo(ct, NextInternalRenderTargetID());
- return sk_sp<GrTexture>(new GrMockTextureRenderTarget(this, budgeted, desc,
+ return sk_sp<GrTexture>(new GrMockTextureRenderTarget(this, budgeted, dimensions,
renderTargetSampleCnt, isProtected,
mipMapsStatus, texInfo, rtInfo));
}
return sk_sp<GrTexture>(
- new GrMockTexture(this, budgeted, desc, isProtected, mipMapsStatus, texInfo));
+ new GrMockTexture(this, budgeted, dimensions, isProtected, mipMapsStatus, texInfo));
}
// TODO: why no 'isProtected' ?!
@@ -179,10 +179,6 @@
SkASSERT(compression != SkImage::CompressionType::kNone);
#endif
- GrSurfaceDesc desc;
- desc.fWidth = dimensions.width();
- desc.fHeight = dimensions.height();
-
GrMipMapsStatus mipMapsStatus = (mipMapped == GrMipMapped::kYes)
? GrMipMapsStatus::kValid
: GrMipMapsStatus::kNotAllocated;
@@ -190,8 +186,8 @@
format.asMockCompressionType(),
NextInternalTextureID());
- return sk_sp<GrTexture>(new GrMockTexture(this, budgeted, desc, isProtected,
- mipMapsStatus, texInfo));
+ return sk_sp<GrTexture>(
+ new GrMockTexture(this, budgeted, dimensions, isProtected, mipMapsStatus, texInfo));
}
sk_sp<GrTexture> GrMockGpu::onWrapBackendTexture(const GrBackendTexture& tex, GrColorType colorType,
@@ -207,15 +203,11 @@
SkASSERT(colorType == texInfo.colorType());
- GrSurfaceDesc desc;
- desc.fWidth = tex.width();
- desc.fHeight = tex.height();
-
GrMipMapsStatus mipMapsStatus = tex.hasMipMaps() ? GrMipMapsStatus::kValid
: GrMipMapsStatus::kNotAllocated;
auto isProtected = GrProtected(tex.isProtected());
- return sk_sp<GrTexture>(
- new GrMockTexture(this, desc, isProtected, mipMapsStatus, texInfo, wrapType, ioType));
+ return sk_sp<GrTexture>(new GrMockTexture(this, tex.dimensions(), isProtected, mipMapsStatus,
+ texInfo, wrapType, ioType));
}
sk_sp<GrTexture> GrMockGpu::onWrapCompressedBackendTexture(const GrBackendTexture& tex,
@@ -234,9 +226,6 @@
SkASSERT(texInfo.compressionType() == SkImage::CompressionType::kNone);
SkASSERT(colorType == texInfo.colorType());
- GrSurfaceDesc desc;
- desc.fWidth = tex.width();
- desc.fHeight = tex.height();
GrMipMapsStatus mipMapsStatus =
tex.hasMipMaps() ? GrMipMapsStatus::kValid : GrMipMapsStatus::kNotAllocated;
@@ -245,8 +234,9 @@
GrMockRenderTargetInfo rtInfo(texInfo.colorType(), NextInternalRenderTargetID());
auto isProtected = GrProtected(tex.isProtected());
- return sk_sp<GrTexture>(new GrMockTextureRenderTarget(
- this, desc, sampleCnt, isProtected, mipMapsStatus, texInfo, rtInfo, cacheable));
+ return sk_sp<GrTexture>(new GrMockTextureRenderTarget(this, tex.dimensions(), sampleCnt,
+ isProtected, mipMapsStatus, texInfo,
+ rtInfo, cacheable));
}
sk_sp<GrRenderTarget> GrMockGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& rt,
@@ -255,13 +245,11 @@
SkAssertResult(rt.getMockRenderTargetInfo(&info));
SkASSERT(colorType == info.colorType());
- GrSurfaceDesc desc;
- desc.fWidth = rt.width();
- desc.fHeight = rt.height();
auto isProtected = GrProtected(rt.isProtected());
- return sk_sp<GrRenderTarget>(new GrMockRenderTarget(this, GrMockRenderTarget::kWrapped, desc,
- rt.sampleCnt(), isProtected, info));
+ return sk_sp<GrRenderTarget>(new GrMockRenderTarget(this, GrMockRenderTarget::kWrapped,
+ rt.dimensions(), rt.sampleCnt(),
+ isProtected, info));
}
sk_sp<GrRenderTarget> GrMockGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTexture& tex,
@@ -272,16 +260,13 @@
SkASSERT(texInfo.compressionType() == SkImage::CompressionType::kNone);
SkASSERT(colorType == texInfo.colorType());
- GrSurfaceDesc desc;
- desc.fWidth = tex.width();
- desc.fHeight = tex.height();
// The client gave us the texture ID but we supply the render target ID.
GrMockRenderTargetInfo rtInfo(texInfo.colorType(), NextInternalRenderTargetID());
auto isProtected = GrProtected(tex.isProtected());
- return sk_sp<GrRenderTarget>(new GrMockRenderTarget(this, GrMockRenderTarget::kWrapped, desc,
- sampleCnt, isProtected, rtInfo));
+ return sk_sp<GrRenderTarget>(new GrMockRenderTarget(
+ this, GrMockRenderTarget::kWrapped, tex.dimensions(), sampleCnt, isProtected, rtInfo));
}
sk_sp<GrGpuBuffer> GrMockGpu::onCreateBuffer(size_t sizeInBytes, GrGpuBufferType type,
diff --git a/src/gpu/mock/GrMockGpu.h b/src/gpu/mock/GrMockGpu.h
index 3333bb7..a6c0c6c 100644
--- a/src/gpu/mock/GrMockGpu.h
+++ b/src/gpu/mock/GrMockGpu.h
@@ -62,7 +62,7 @@
void xferBarrier(GrRenderTarget*, GrXferBarrierType) override {}
- sk_sp<GrTexture> onCreateTexture(const GrSurfaceDesc&,
+ sk_sp<GrTexture> onCreateTexture(SkISize,
const GrBackendFormat&,
GrRenderable,
int renderTargetSampleCnt,
diff --git a/src/gpu/mock/GrMockTexture.h b/src/gpu/mock/GrMockTexture.h
index b1beab4..640e41b 100644
--- a/src/gpu/mock/GrMockTexture.h
+++ b/src/gpu/mock/GrMockTexture.h
@@ -17,17 +17,24 @@
class GrMockTexture : public GrTexture {
public:
- GrMockTexture(GrMockGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc& desc,
- GrProtected isProtected, GrMipMapsStatus mipMapsStatus,
+ GrMockTexture(GrMockGpu* gpu,
+ SkBudgeted budgeted,
+ SkISize dimensions,
+ GrProtected isProtected,
+ GrMipMapsStatus mipMapsStatus,
const GrMockTextureInfo& info)
- : GrMockTexture(gpu, desc, isProtected, mipMapsStatus, info) {
+ : GrMockTexture(gpu, dimensions, isProtected, mipMapsStatus, info) {
this->registerWithCache(budgeted);
}
- GrMockTexture(GrMockGpu* gpu, const GrSurfaceDesc& desc, GrProtected isProtected,
- GrMipMapsStatus mipMapsStatus, const GrMockTextureInfo& info,
- GrWrapCacheable cacheable, GrIOType ioType)
- : GrMockTexture(gpu, desc, isProtected, mipMapsStatus, info) {
+ GrMockTexture(GrMockGpu* gpu,
+ SkISize dimensions,
+ GrProtected isProtected,
+ GrMipMapsStatus mipMapsStatus,
+ const GrMockTextureInfo& info,
+ GrWrapCacheable cacheable,
+ GrIOType ioType)
+ : GrMockTexture(gpu, dimensions, isProtected, mipMapsStatus, info) {
if (ioType == kRead_GrIOType) {
this->setReadOnly();
}
@@ -49,11 +56,10 @@
protected:
// constructor for subclasses
- GrMockTexture(GrMockGpu* gpu, const GrSurfaceDesc& desc, GrProtected isProtected,
+ GrMockTexture(GrMockGpu* gpu, const SkISize& dimensions, GrProtected isProtected,
GrMipMapsStatus mipMapsStatus, const GrMockTextureInfo& info)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, isProtected)
- , INHERITED(gpu, {desc.fWidth, desc.fHeight}, isProtected, GrTextureType::k2D,
- mipMapsStatus)
+ : GrSurface(gpu, dimensions, isProtected)
+ , INHERITED(gpu, dimensions, isProtected, GrTextureType::k2D, mipMapsStatus)
, fInfo(info) {}
void onRelease() override {
@@ -76,19 +82,23 @@
class GrMockRenderTarget : public GrRenderTarget {
public:
- GrMockRenderTarget(GrMockGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc& desc,
- int sampleCnt, GrProtected isProtected, const GrMockRenderTargetInfo& info)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, isProtected)
- , INHERITED(gpu, {desc.fWidth, desc.fHeight}, sampleCnt, isProtected)
+ GrMockRenderTarget(GrMockGpu* gpu,
+ SkBudgeted budgeted,
+ SkISize dimensions,
+ int sampleCnt,
+ GrProtected isProtected,
+ const GrMockRenderTargetInfo& info)
+ : GrSurface(gpu, dimensions, isProtected)
+ , INHERITED(gpu, dimensions, sampleCnt, isProtected)
, fInfo(info) {
this->registerWithCache(budgeted);
}
enum Wrapped { kWrapped };
- GrMockRenderTarget(GrMockGpu* gpu, Wrapped, const GrSurfaceDesc& desc, int sampleCnt,
+ GrMockRenderTarget(GrMockGpu* gpu, Wrapped, SkISize dimensions, int sampleCnt,
GrProtected isProtected, const GrMockRenderTargetInfo& info)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, isProtected)
- , INHERITED(gpu, {desc.fWidth, desc.fHeight}, sampleCnt, isProtected)
+ : GrSurface(gpu, dimensions, isProtected)
+ , INHERITED(gpu, dimensions, sampleCnt, isProtected)
, fInfo(info) {
this->registerWithCacheWrapped(GrWrapCacheable::kNo);
}
@@ -121,10 +131,13 @@
protected:
// constructor for subclasses
- GrMockRenderTarget(GrMockGpu* gpu, const GrSurfaceDesc& desc, int sampleCnt,
- GrProtected isProtected, const GrMockRenderTargetInfo& info)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, isProtected)
- , INHERITED(gpu, {desc.fWidth, desc.fHeight}, sampleCnt, isProtected)
+ GrMockRenderTarget(GrMockGpu* gpu,
+ SkISize dimensions,
+ int sampleCnt,
+ GrProtected isProtected,
+ const GrMockRenderTargetInfo& info)
+ : GrSurface(gpu, dimensions, isProtected)
+ , INHERITED(gpu, dimensions, sampleCnt, isProtected)
, fInfo(info) {}
private:
@@ -136,25 +149,33 @@
class GrMockTextureRenderTarget : public GrMockTexture, public GrMockRenderTarget {
public:
// Internally created.
- GrMockTextureRenderTarget(GrMockGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc& desc,
- int sampleCnt, GrProtected isProtected, GrMipMapsStatus mipMapsStatus,
+ GrMockTextureRenderTarget(GrMockGpu* gpu,
+ SkBudgeted budgeted,
+ SkISize dimensions,
+ int sampleCnt,
+ GrProtected isProtected,
+ GrMipMapsStatus mipMapsStatus,
const GrMockTextureInfo& texInfo,
const GrMockRenderTargetInfo& rtInfo)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, isProtected)
- , GrMockTexture(gpu, desc, isProtected, mipMapsStatus, texInfo)
- , GrMockRenderTarget(gpu, desc, sampleCnt, isProtected, rtInfo) {
+ : GrSurface(gpu, dimensions, isProtected)
+ , GrMockTexture(gpu, dimensions, isProtected, mipMapsStatus, texInfo)
+ , GrMockRenderTarget(gpu, dimensions, sampleCnt, isProtected, rtInfo) {
this->registerWithCache(budgeted);
}
// Renderable wrapped backend texture.
- GrMockTextureRenderTarget(GrMockGpu* gpu, const GrSurfaceDesc& desc, int sampleCnt,
- GrProtected isProtected, GrMipMapsStatus mipMapsStatus,
+ GrMockTextureRenderTarget(GrMockGpu* gpu,
+ SkISize dimensions,
+ int sampleCnt,
+ GrProtected isProtected,
+ GrMipMapsStatus mipMapsStatus,
const GrMockTextureInfo& texInfo,
- const GrMockRenderTargetInfo& rtInfo, GrWrapCacheable cacheble)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, isProtected)
- , GrMockTexture(gpu, desc, isProtected, mipMapsStatus, texInfo)
- , GrMockRenderTarget(gpu, desc, sampleCnt, isProtected, rtInfo) {
- this->registerWithCacheWrapped(cacheble);
+ const GrMockRenderTargetInfo& rtInfo,
+ GrWrapCacheable cacheable)
+ : GrSurface(gpu, dimensions, isProtected)
+ , GrMockTexture(gpu, dimensions, isProtected, mipMapsStatus, texInfo)
+ , GrMockRenderTarget(gpu, dimensions, sampleCnt, isProtected, rtInfo) {
+ this->registerWithCacheWrapped(cacheable);
}
GrTexture* asTexture() override { return this; }
diff --git a/src/gpu/mtl/GrMtlGpu.h b/src/gpu/mtl/GrMtlGpu.h
index 535ec46..d26170c 100644
--- a/src/gpu/mtl/GrMtlGpu.h
+++ b/src/gpu/mtl/GrMtlGpu.h
@@ -139,7 +139,7 @@
GrProtected,
const BackendTextureData*) override;
- sk_sp<GrTexture> onCreateTexture(const GrSurfaceDesc&,
+ sk_sp<GrTexture> onCreateTexture(SkISize,
const GrBackendFormat&,
GrRenderable,
int renderTargetSampleCnt,
diff --git a/src/gpu/mtl/GrMtlGpu.mm b/src/gpu/mtl/GrMtlGpu.mm
index 1d467d5..2d1d072 100644
--- a/src/gpu/mtl/GrMtlGpu.mm
+++ b/src/gpu/mtl/GrMtlGpu.mm
@@ -440,7 +440,7 @@
return stencil;
}
-sk_sp<GrTexture> GrMtlGpu::onCreateTexture(const GrSurfaceDesc& desc,
+sk_sp<GrTexture> GrMtlGpu::onCreateTexture(SkISize dimensions,
const GrBackendFormat& format,
GrRenderable renderable,
int renderTargetSampleCnt,
@@ -465,8 +465,8 @@
MTLTextureDescriptor* texDesc = [[MTLTextureDescriptor alloc] init];
texDesc.textureType = MTLTextureType2D;
texDesc.pixelFormat = mtlPixelFormat;
- texDesc.width = desc.fWidth;
- texDesc.height = desc.fHeight;
+ texDesc.width = dimensions.fWidth;
+ texDesc.height = dimensions.fHeight;
texDesc.depth = 1;
texDesc.mipmapLevelCount = mipLevelCount;
texDesc.sampleCount = 1;
@@ -482,11 +482,10 @@
GrMipMapsStatus mipMapsStatus =
mipLevelCount > 1 ? GrMipMapsStatus::kDirty : GrMipMapsStatus::kNotAllocated;
if (renderable == GrRenderable::kYes) {
- tex = GrMtlTextureRenderTarget::MakeNewTextureRenderTarget(this, budgeted,
- desc, renderTargetSampleCnt,
- texDesc, mipMapsStatus);
+ tex = GrMtlTextureRenderTarget::MakeNewTextureRenderTarget(
+ this, budgeted, dimensions, renderTargetSampleCnt, texDesc, mipMapsStatus);
} else {
- tex = GrMtlTexture::MakeNewTexture(this, budgeted, desc, texDesc, mipMapsStatus);
+ tex = GrMtlTexture::MakeNewTexture(this, budgeted, dimensions, texDesc, mipMapsStatus);
}
if (!tex) {
@@ -551,10 +550,7 @@
? GrMipMapsStatus::kValid
: GrMipMapsStatus::kNotAllocated;
- GrSurfaceDesc desc;
- desc.fWidth = dimensions.width();
- desc.fHeight = dimensions.height();
- auto tex = GrMtlTexture::MakeNewTexture(this, budgeted, desc, texDesc, mipMapsStatus);
+ auto tex = GrMtlTexture::MakeNewTexture(this, budgeted, dimensions, texDesc, mipMapsStatus);
if (!tex) {
return nullptr;
}
@@ -631,17 +627,6 @@
return GrGetMTLTexture(textureInfo.fTexture.get());
}
-static inline void init_surface_desc(GrSurfaceDesc* surfaceDesc, id<MTLTexture> mtlTexture,
- GrRenderable renderable) {
- if (@available(macOS 10.11, iOS 9.0, *)) {
- if (renderable == GrRenderable::kYes) {
- SkASSERT(MTLTextureUsageRenderTarget & mtlTexture.usage);
- }
- }
- surfaceDesc->fWidth = mtlTexture.width;
- surfaceDesc->fHeight = mtlTexture.height;
-}
-
sk_sp<GrTexture> GrMtlGpu::onWrapBackendTexture(const GrBackendTexture& backendTex,
GrColorType grColorType,
GrWrapOwnership,
@@ -652,10 +637,8 @@
return nullptr;
}
- GrSurfaceDesc surfDesc;
- init_surface_desc(&surfDesc, mtlTexture, GrRenderable::kNo);
-
- return GrMtlTexture::MakeWrappedTexture(this, surfDesc, mtlTexture, cacheable, ioType);
+ return GrMtlTexture::MakeWrappedTexture(this, backendTex.dimensions(), mtlTexture, cacheable,
+ ioType);
}
sk_sp<GrTexture> GrMtlGpu::onWrapCompressedBackendTexture(const GrBackendTexture& backendTex,
@@ -666,10 +649,8 @@
return nullptr;
}
- GrSurfaceDesc surfDesc;
- init_surface_desc(&surfDesc, mtlTexture, GrRenderable::kNo);
-
- return GrMtlTexture::MakeWrappedTexture(this, surfDesc, mtlTexture, cacheable, kRead_GrIOType);
+ return GrMtlTexture::MakeWrappedTexture(this, backendTex.dimensions(), mtlTexture, cacheable,
+ kRead_GrIOType);
}
sk_sp<GrTexture> GrMtlGpu::onWrapRenderableBackendTexture(const GrBackendTexture& backendTex,
@@ -689,14 +670,15 @@
return nullptr;
}
- GrSurfaceDesc surfDesc;
- init_surface_desc(&surfDesc, mtlTexture, GrRenderable::kYes);
+ if (@available(macOS 10.11, iOS 9.0, *)) {
+ SkASSERT(MTLTextureUsageRenderTarget & mtlTexture.usage);
+ }
sampleCnt = caps.getRenderTargetSampleCount(sampleCnt, format);
SkASSERT(sampleCnt);
- return GrMtlTextureRenderTarget::MakeWrappedTextureRenderTarget(this, surfDesc, sampleCnt,
- mtlTexture, cacheable);
+ return GrMtlTextureRenderTarget::MakeWrappedTextureRenderTarget(
+ this, backendTex.dimensions(), sampleCnt, mtlTexture, cacheable);
}
sk_sp<GrRenderTarget> GrMtlGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& backendRT,
@@ -710,11 +692,12 @@
return nullptr;
}
- GrSurfaceDesc surfDesc;
- init_surface_desc(&surfDesc, mtlTexture, GrRenderable::kYes);
+ if (@available(macOS 10.11, iOS 9.0, *)) {
+ SkASSERT(MTLTextureUsageRenderTarget & mtlTexture.usage);
+ }
- return GrMtlRenderTarget::MakeWrappedRenderTarget(this, surfDesc, backendRT.sampleCnt(),
- mtlTexture);
+ return GrMtlRenderTarget::MakeWrappedRenderTarget(this, backendRT.dimensions(),
+ backendRT.sampleCnt(), mtlTexture);
}
sk_sp<GrRenderTarget> GrMtlGpu::onWrapBackendTextureAsRenderTarget(
@@ -729,14 +712,17 @@
return nullptr;
}
- GrSurfaceDesc surfDesc;
- init_surface_desc(&surfDesc, mtlTexture, GrRenderable::kYes);
+ if (@available(macOS 10.11, iOS 9.0, *)) {
+ SkASSERT(MTLTextureUsageRenderTarget & mtlTexture.usage);
+ }
+
sampleCnt = this->mtlCaps().getRenderTargetSampleCount(sampleCnt, format);
if (!sampleCnt) {
return nullptr;
}
- return GrMtlRenderTarget::MakeWrappedRenderTarget(this, surfDesc, sampleCnt, mtlTexture);
+ return GrMtlRenderTarget::MakeWrappedRenderTarget(this, backendTex.dimensions(), sampleCnt,
+ mtlTexture);
}
bool GrMtlGpu::onRegenerateMipMapLevels(GrTexture* texture) {
diff --git a/src/gpu/mtl/GrMtlRenderTarget.h b/src/gpu/mtl/GrMtlRenderTarget.h
index 0ef1bcc..cae6a9d 100644
--- a/src/gpu/mtl/GrMtlRenderTarget.h
+++ b/src/gpu/mtl/GrMtlRenderTarget.h
@@ -20,7 +20,7 @@
class GrMtlRenderTarget: public GrRenderTarget {
public:
static sk_sp<GrMtlRenderTarget> MakeWrappedRenderTarget(GrMtlGpu*,
- const GrSurfaceDesc&,
+ SkISize,
int sampleCnt,
id<MTLTexture>);
@@ -39,14 +39,12 @@
protected:
GrMtlRenderTarget(GrMtlGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize,
int sampleCnt,
id<MTLTexture> colorTexture,
id<MTLTexture> resolveTexture);
- GrMtlRenderTarget(GrMtlGpu* gpu,
- const GrSurfaceDesc& desc,
- id<MTLTexture> colorTexture);
+ GrMtlRenderTarget(GrMtlGpu* gpu, SkISize, id<MTLTexture> colorTexture);
GrMtlGpu* getMtlGpu() const;
@@ -74,15 +72,12 @@
// Extra param to disambiguate from constructor used by subclasses.
enum Wrapped { kWrapped };
GrMtlRenderTarget(GrMtlGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize,
int sampleCnt,
id<MTLTexture> colorTexture,
id<MTLTexture> resolveTexture,
Wrapped);
- GrMtlRenderTarget(GrMtlGpu* gpu,
- const GrSurfaceDesc& desc,
- id<MTLTexture> colorTexture,
- Wrapped);
+ GrMtlRenderTarget(GrMtlGpu* gpu, SkISize, id<MTLTexture> colorTexture, Wrapped);
bool completeStencilAttachment() override;
diff --git a/src/gpu/mtl/GrMtlRenderTarget.mm b/src/gpu/mtl/GrMtlRenderTarget.mm
index bc1cb73..f773280 100644
--- a/src/gpu/mtl/GrMtlRenderTarget.mm
+++ b/src/gpu/mtl/GrMtlRenderTarget.mm
@@ -16,14 +16,13 @@
// Called for wrapped non-texture render targets.
GrMtlRenderTarget::GrMtlRenderTarget(GrMtlGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
int sampleCnt,
id<MTLTexture> colorTexture,
id<MTLTexture> resolveTexture,
Wrapped)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo)
- , GrRenderTarget(
- gpu, {desc.fWidth, desc.fHeight}, sampleCnt, GrProtected::kNo)
+ : GrSurface(gpu, dimensions, GrProtected::kNo)
+ , GrRenderTarget(gpu, dimensions, sampleCnt, GrProtected::kNo)
, fColorTexture(colorTexture)
, fResolveTexture(resolveTexture) {
SkASSERT(sampleCnt > 1);
@@ -31,11 +30,11 @@
}
GrMtlRenderTarget::GrMtlRenderTarget(GrMtlGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
id<MTLTexture> colorTexture,
Wrapped)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo)
- , GrRenderTarget(gpu, {desc.fWidth, desc.fHeight}, 1, GrProtected::kNo)
+ : GrSurface(gpu, dimensions, GrProtected::kNo)
+ , GrRenderTarget(gpu, dimensions, 1, GrProtected::kNo)
, fColorTexture(colorTexture)
, fResolveTexture(nil) {
this->registerWithCacheWrapped(GrWrapCacheable::kNo);
@@ -43,28 +42,25 @@
// Called by subclass constructors.
GrMtlRenderTarget::GrMtlRenderTarget(GrMtlGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
int sampleCnt,
id<MTLTexture> colorTexture,
id<MTLTexture> resolveTexture)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo)
- , GrRenderTarget(
- gpu, {desc.fWidth, desc.fHeight}, sampleCnt, GrProtected::kNo)
+ : GrSurface(gpu, dimensions, GrProtected::kNo)
+ , GrRenderTarget(gpu, dimensions, sampleCnt, GrProtected::kNo)
, fColorTexture(colorTexture)
, fResolveTexture(resolveTexture) {
SkASSERT(sampleCnt > 1);
}
-GrMtlRenderTarget::GrMtlRenderTarget(GrMtlGpu* gpu,
- const GrSurfaceDesc& desc,
- id<MTLTexture> colorTexture)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo)
- , GrRenderTarget(gpu, {desc.fWidth, desc.fHeight}, 1, GrProtected::kNo)
+GrMtlRenderTarget::GrMtlRenderTarget(GrMtlGpu* gpu, SkISize dimensions, id<MTLTexture> colorTexture)
+ : GrSurface(gpu, dimensions, GrProtected::kNo)
+ , GrRenderTarget(gpu, dimensions, 1, GrProtected::kNo)
, fColorTexture(colorTexture)
, fResolveTexture(nil) {}
sk_sp<GrMtlRenderTarget> GrMtlRenderTarget::MakeWrappedRenderTarget(GrMtlGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
int sampleCnt,
id<MTLTexture> texture) {
SkASSERT(nil != texture);
@@ -82,8 +78,8 @@
MTLTextureDescriptor* texDesc = [[MTLTextureDescriptor alloc] init];
texDesc.textureType = MTLTextureType2DMultisample;
texDesc.pixelFormat = format;
- texDesc.width = desc.fWidth;
- texDesc.height = desc.fHeight;
+ texDesc.width = dimensions.fWidth;
+ texDesc.height = dimensions.fHeight;
texDesc.depth = 1;
texDesc.mipmapLevelCount = 1;
texDesc.sampleCount = sampleCnt;
@@ -100,9 +96,9 @@
if (@available(macOS 10.11, iOS 9.0, *)) {
SkASSERT((MTLTextureUsageShaderRead|MTLTextureUsageRenderTarget) & colorTexture.usage);
}
- mtlRT = new GrMtlRenderTarget(gpu, desc, sampleCnt, colorTexture, texture, kWrapped);
+ mtlRT = new GrMtlRenderTarget(gpu, dimensions, sampleCnt, colorTexture, texture, kWrapped);
} else {
- mtlRT = new GrMtlRenderTarget(gpu, desc, texture, kWrapped);
+ mtlRT = new GrMtlRenderTarget(gpu, dimensions, texture, kWrapped);
}
return sk_sp<GrMtlRenderTarget>(mtlRT);
diff --git a/src/gpu/mtl/GrMtlTexture.h b/src/gpu/mtl/GrMtlTexture.h
index c81aef0..6478e7a 100644
--- a/src/gpu/mtl/GrMtlTexture.h
+++ b/src/gpu/mtl/GrMtlTexture.h
@@ -16,13 +16,17 @@
class GrMtlTexture : public GrTexture {
public:
- static sk_sp<GrMtlTexture> MakeNewTexture(GrMtlGpu*, SkBudgeted budgeted,
- const GrSurfaceDesc&,
+ static sk_sp<GrMtlTexture> MakeNewTexture(GrMtlGpu*,
+ SkBudgeted budgeted,
+ SkISize,
MTLTextureDescriptor*,
GrMipMapsStatus);
- static sk_sp<GrMtlTexture> MakeWrappedTexture(GrMtlGpu*, const GrSurfaceDesc&, id<MTLTexture>,
- GrWrapCacheable, GrIOType);
+ static sk_sp<GrMtlTexture> MakeWrappedTexture(GrMtlGpu*,
+ SkISize,
+ id<MTLTexture>,
+ GrWrapCacheable,
+ GrIOType);
~GrMtlTexture() override;
@@ -37,7 +41,7 @@
bool reallocForMipmap(GrMtlGpu* gpu, uint32_t mipLevels);
protected:
- GrMtlTexture(GrMtlGpu*, const GrSurfaceDesc&, id<MTLTexture>, GrMipMapsStatus);
+ GrMtlTexture(GrMtlGpu*, SkISize, id<MTLTexture>, GrMipMapsStatus);
GrMtlGpu* getMtlGpu() const;
@@ -57,11 +61,15 @@
private:
enum Wrapped { kWrapped };
- GrMtlTexture(GrMtlGpu*, SkBudgeted, const GrSurfaceDesc&, id<MTLTexture>,
- GrMipMapsStatus);
+ GrMtlTexture(GrMtlGpu*, SkBudgeted, SkISize, id<MTLTexture>, GrMipMapsStatus);
- GrMtlTexture(GrMtlGpu*, Wrapped, const GrSurfaceDesc&, id<MTLTexture>, GrMipMapsStatus,
- GrWrapCacheable, GrIOType);
+ GrMtlTexture(GrMtlGpu*,
+ Wrapped,
+ SkISize,
+ id<MTLTexture>,
+ GrMipMapsStatus,
+ GrWrapCacheable,
+ GrIOType);
id<MTLTexture> fTexture;
diff --git a/src/gpu/mtl/GrMtlTexture.mm b/src/gpu/mtl/GrMtlTexture.mm
index aa252ab..fc98ad8 100644
--- a/src/gpu/mtl/GrMtlTexture.mm
+++ b/src/gpu/mtl/GrMtlTexture.mm
@@ -17,12 +17,11 @@
GrMtlTexture::GrMtlTexture(GrMtlGpu* gpu,
SkBudgeted budgeted,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
id<MTLTexture> texture,
GrMipMapsStatus mipMapsStatus)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo)
- , INHERITED(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo,
- GrTextureType::k2D, mipMapsStatus)
+ : GrSurface(gpu, dimensions, GrProtected::kNo)
+ , INHERITED(gpu, dimensions, GrProtected::kNo, GrTextureType::k2D, mipMapsStatus)
, fTexture(texture) {
SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == texture.mipmapLevelCount));
if (@available(macOS 10.11, iOS 9.0, *)) {
@@ -37,14 +36,13 @@
GrMtlTexture::GrMtlTexture(GrMtlGpu* gpu,
Wrapped,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
id<MTLTexture> texture,
GrMipMapsStatus mipMapsStatus,
GrWrapCacheable cacheable,
GrIOType ioType)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo)
- , INHERITED(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo,
- GrTextureType::k2D, mipMapsStatus)
+ : GrSurface(gpu, dimensions, GrProtected::kNo)
+ , INHERITED(gpu, dimensions, GrProtected::kNo, GrTextureType::k2D, mipMapsStatus)
, fTexture(texture) {
SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == texture.mipmapLevelCount));
if (@available(macOS 10.11, iOS 9.0, *)) {
@@ -58,12 +56,11 @@
}
GrMtlTexture::GrMtlTexture(GrMtlGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
id<MTLTexture> texture,
GrMipMapsStatus mipMapsStatus)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo)
- , INHERITED(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo,
- GrTextureType::k2D, mipMapsStatus)
+ : GrSurface(gpu, dimensions, GrProtected::kNo)
+ , INHERITED(gpu, dimensions, GrProtected::kNo, GrTextureType::k2D, mipMapsStatus)
, fTexture(texture) {
SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == texture.mipmapLevelCount));
if (@available(macOS 10.11, iOS 9.0, *)) {
@@ -72,10 +69,11 @@
SkASSERT(!texture.framebufferOnly);
}
-sk_sp<GrMtlTexture> GrMtlTexture::MakeNewTexture(GrMtlGpu* gpu, SkBudgeted budgeted,
- const GrSurfaceDesc& desc,
- MTLTextureDescriptor* texDesc,
- GrMipMapsStatus mipMapsStatus) {
+sk_sp<GrMtlTexture> GrMtlTexture::MakeNewTexture(GrMtlGpu* gpu,
+ SkBudgeted budgeted,
+ SkISize dimensions,
+ MTLTextureDescriptor* texDesc,
+ GrMipMapsStatus mipMapsStatus) {
id<MTLTexture> texture = [gpu->device() newTextureWithDescriptor:texDesc];
if (!texture) {
return nullptr;
@@ -83,11 +81,11 @@
if (@available(macOS 10.11, iOS 9.0, *)) {
SkASSERT(SkToBool(texture.usage & MTLTextureUsageShaderRead));
}
- return sk_sp<GrMtlTexture>(new GrMtlTexture(gpu, budgeted, desc, texture, mipMapsStatus));
+ return sk_sp<GrMtlTexture>(new GrMtlTexture(gpu, budgeted, dimensions, texture, mipMapsStatus));
}
sk_sp<GrMtlTexture> GrMtlTexture::MakeWrappedTexture(GrMtlGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
id<MTLTexture> texture,
GrWrapCacheable cacheable,
GrIOType ioType) {
@@ -97,8 +95,8 @@
}
GrMipMapsStatus mipMapsStatus = texture.mipmapLevelCount > 1 ? GrMipMapsStatus::kValid
: GrMipMapsStatus::kNotAllocated;
- return sk_sp<GrMtlTexture>(new GrMtlTexture(gpu, kWrapped, desc, texture, mipMapsStatus,
- cacheable, ioType));
+ return sk_sp<GrMtlTexture>(
+ new GrMtlTexture(gpu, kWrapped, dimensions, texture, mipMapsStatus, cacheable, ioType));
}
GrMtlTexture::~GrMtlTexture() {
diff --git a/src/gpu/mtl/GrMtlTextureRenderTarget.h b/src/gpu/mtl/GrMtlTextureRenderTarget.h
index 2e1bda7..bb10e5b 100644
--- a/src/gpu/mtl/GrMtlTextureRenderTarget.h
+++ b/src/gpu/mtl/GrMtlTextureRenderTarget.h
@@ -15,13 +15,13 @@
public:
static sk_sp<GrMtlTextureRenderTarget> MakeNewTextureRenderTarget(GrMtlGpu*,
SkBudgeted,
- const GrSurfaceDesc&,
+ SkISize,
int sampleCnt,
MTLTextureDescriptor*,
GrMipMapsStatus);
static sk_sp<GrMtlTextureRenderTarget> MakeWrappedTextureRenderTarget(GrMtlGpu*,
- const GrSurfaceDesc&,
+ SkISize,
int sampleCnt,
id<MTLTexture>,
GrWrapCacheable);
@@ -43,7 +43,7 @@
private:
GrMtlTextureRenderTarget(GrMtlGpu* gpu,
SkBudgeted budgeted,
- const GrSurfaceDesc& desc,
+ SkISize,
int sampleCnt,
id<MTLTexture> colorTexture,
id<MTLTexture> resolveTexture,
@@ -51,12 +51,12 @@
GrMtlTextureRenderTarget(GrMtlGpu* gpu,
SkBudgeted budgeted,
- const GrSurfaceDesc& desc,
+ SkISize,
id<MTLTexture> colorTexture,
GrMipMapsStatus);
GrMtlTextureRenderTarget(GrMtlGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize,
int sampleCnt,
id<MTLTexture> colorTexture,
id<MTLTexture> resolveTexture,
@@ -64,7 +64,7 @@
GrWrapCacheable cacheable);
GrMtlTextureRenderTarget(GrMtlGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize,
id<MTLTexture> colorTexture,
GrMipMapsStatus,
GrWrapCacheable cacheable);
diff --git a/src/gpu/mtl/GrMtlTextureRenderTarget.mm b/src/gpu/mtl/GrMtlTextureRenderTarget.mm
index b6dc2ec..57f2b4b 100644
--- a/src/gpu/mtl/GrMtlTextureRenderTarget.mm
+++ b/src/gpu/mtl/GrMtlTextureRenderTarget.mm
@@ -15,53 +15,53 @@
GrMtlTextureRenderTarget::GrMtlTextureRenderTarget(GrMtlGpu* gpu,
SkBudgeted budgeted,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
int sampleCnt,
id<MTLTexture> colorTexture,
id<MTLTexture> resolveTexture,
GrMipMapsStatus mipMapsStatus)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo)
- , GrMtlTexture(gpu, desc, resolveTexture, mipMapsStatus)
- , GrMtlRenderTarget(gpu, desc, sampleCnt, colorTexture, resolveTexture) {
+ : GrSurface(gpu, dimensions, GrProtected::kNo)
+ , GrMtlTexture(gpu, dimensions, resolveTexture, mipMapsStatus)
+ , GrMtlRenderTarget(gpu, dimensions, sampleCnt, colorTexture, resolveTexture) {
this->registerWithCache(budgeted);
}
GrMtlTextureRenderTarget::GrMtlTextureRenderTarget(GrMtlGpu* gpu,
SkBudgeted budgeted,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
id<MTLTexture> colorTexture,
GrMipMapsStatus mipMapsStatus)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo)
- , GrMtlTexture(gpu, desc, colorTexture, mipMapsStatus)
- , GrMtlRenderTarget(gpu, desc, colorTexture) {
+ : GrSurface(gpu, dimensions, GrProtected::kNo)
+ , GrMtlTexture(gpu, dimensions, colorTexture, mipMapsStatus)
+ , GrMtlRenderTarget(gpu, dimensions, colorTexture) {
this->registerWithCache(budgeted);
}
GrMtlTextureRenderTarget::GrMtlTextureRenderTarget(GrMtlGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
int sampleCnt,
id<MTLTexture> colorTexture,
id<MTLTexture> resolveTexture,
GrMipMapsStatus mipMapsStatus,
GrWrapCacheable cacheable)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo)
- , GrMtlTexture(gpu, desc, resolveTexture, mipMapsStatus)
- , GrMtlRenderTarget(gpu, desc, sampleCnt, colorTexture, resolveTexture) {
+ : GrSurface(gpu, dimensions, GrProtected::kNo)
+ , GrMtlTexture(gpu, dimensions, resolveTexture, mipMapsStatus)
+ , GrMtlRenderTarget(gpu, dimensions, sampleCnt, colorTexture, resolveTexture) {
this->registerWithCacheWrapped(cacheable);
}
GrMtlTextureRenderTarget::GrMtlTextureRenderTarget(GrMtlGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
id<MTLTexture> colorTexture,
GrMipMapsStatus mipMapsStatus,
GrWrapCacheable cacheable)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, GrProtected::kNo)
- , GrMtlTexture(gpu, desc, colorTexture, mipMapsStatus)
- , GrMtlRenderTarget(gpu, desc, colorTexture) {
+ : GrSurface(gpu, dimensions, GrProtected::kNo)
+ , GrMtlTexture(gpu, dimensions, colorTexture, mipMapsStatus)
+ , GrMtlRenderTarget(gpu, dimensions, colorTexture) {
this->registerWithCacheWrapped(cacheable);
}
-id<MTLTexture> create_msaa_texture(GrMtlGpu* gpu, const GrSurfaceDesc& desc, MTLPixelFormat format,
+id<MTLTexture> create_msaa_texture(GrMtlGpu* gpu, SkISize dimensions, MTLPixelFormat format,
int sampleCnt) {
if (!gpu->mtlCaps().isFormatRenderable(format, sampleCnt)) {
return nullptr;
@@ -69,8 +69,8 @@
MTLTextureDescriptor* texDesc = [[MTLTextureDescriptor alloc] init];
texDesc.textureType = MTLTextureType2DMultisample;
texDesc.pixelFormat = format;
- texDesc.width = desc.fWidth;
- texDesc.height = desc.fHeight;
+ texDesc.width = dimensions.fWidth;
+ texDesc.height = dimensions.fHeight;
texDesc.depth = 1;
texDesc.mipmapLevelCount = 1;
texDesc.sampleCount = sampleCnt;
@@ -86,7 +86,7 @@
sk_sp<GrMtlTextureRenderTarget> GrMtlTextureRenderTarget::MakeNewTextureRenderTarget(
GrMtlGpu* gpu,
SkBudgeted budgeted,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
int sampleCnt,
MTLTextureDescriptor* texDesc,
GrMipMapsStatus mipMapsStatus) {
@@ -99,8 +99,8 @@
}
if (sampleCnt > 1) {
- id<MTLTexture> colorTexture = create_msaa_texture(gpu, desc, texture.pixelFormat,
- sampleCnt);
+ id<MTLTexture> colorTexture =
+ create_msaa_texture(gpu, dimensions, texture.pixelFormat, sampleCnt);
if (!colorTexture) {
return nullptr;
}
@@ -108,16 +108,16 @@
SkASSERT((MTLTextureUsageShaderRead|MTLTextureUsageRenderTarget) & colorTexture.usage);
}
return sk_sp<GrMtlTextureRenderTarget>(new GrMtlTextureRenderTarget(
- gpu, budgeted, desc, sampleCnt, colorTexture, texture, mipMapsStatus));
+ gpu, budgeted, dimensions, sampleCnt, colorTexture, texture, mipMapsStatus));
} else {
return sk_sp<GrMtlTextureRenderTarget>(
- new GrMtlTextureRenderTarget(gpu, budgeted, desc, texture, mipMapsStatus));
+ new GrMtlTextureRenderTarget(gpu, budgeted, dimensions, texture, mipMapsStatus));
}
}
sk_sp<GrMtlTextureRenderTarget> GrMtlTextureRenderTarget::MakeWrappedTextureRenderTarget(
GrMtlGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
int sampleCnt,
id<MTLTexture> texture,
GrWrapCacheable cacheable) {
@@ -129,8 +129,8 @@
? GrMipMapsStatus::kDirty
: GrMipMapsStatus::kNotAllocated;
if (sampleCnt > 1) {
- id<MTLTexture> colorTexture = create_msaa_texture(gpu, desc, texture.pixelFormat,
- sampleCnt);
+ id<MTLTexture> colorTexture =
+ create_msaa_texture(gpu, dimensions, texture.pixelFormat, sampleCnt);
if (!colorTexture) {
return nullptr;
}
@@ -138,9 +138,9 @@
SkASSERT((MTLTextureUsageShaderRead|MTLTextureUsageRenderTarget) & colorTexture.usage);
}
return sk_sp<GrMtlTextureRenderTarget>(new GrMtlTextureRenderTarget(
- gpu, desc, sampleCnt, colorTexture, texture, mipMapsStatus, cacheable));
+ gpu, dimensions, sampleCnt, colorTexture, texture, mipMapsStatus, cacheable));
} else {
return sk_sp<GrMtlTextureRenderTarget>(
- new GrMtlTextureRenderTarget(gpu, desc, texture, mipMapsStatus, cacheable));
+ new GrMtlTextureRenderTarget(gpu, dimensions, texture, mipMapsStatus, cacheable));
}
}
diff --git a/src/gpu/ops/GrLatticeOp.cpp b/src/gpu/ops/GrLatticeOp.cpp
index 9944693..77f60ee 100644
--- a/src/gpu/ops/GrLatticeOp.cpp
+++ b/src/gpu/ops/GrLatticeOp.cpp
@@ -402,9 +402,9 @@
std::unique_ptr<SkCanvas::Lattice::RectType[]> flags;
std::unique_ptr<SkColor[]> colors;
SkIRect subset;
- GrSurfaceDesc desc;
- desc.fWidth = random->nextRangeU(1, 1000);
- desc.fHeight = random->nextRangeU(1, 1000);
+ SkISize dims;
+ dims.fWidth = random->nextRangeU(1, 1000);
+ dims.fHeight = random->nextRangeU(1, 1000);
GrSurfaceOrigin origin = random->nextBool() ? kTopLeft_GrSurfaceOrigin
: kBottomLeft_GrSurfaceOrigin;
const GrBackendFormat format =
@@ -413,7 +413,7 @@
GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(format, GrColorType::kRGBA_8888);
auto proxy = context->priv().proxyProvider()->createProxy(format,
- desc,
+ dims,
swizzle,
GrRenderable::kNo,
1,
@@ -425,12 +425,12 @@
do {
if (random->nextBool()) {
- subset.fLeft = random->nextULessThan(desc.fWidth);
- subset.fRight = random->nextRangeU(subset.fLeft + 1, desc.fWidth);
- subset.fTop = random->nextULessThan(desc.fHeight);
- subset.fBottom = random->nextRangeU(subset.fTop + 1, desc.fHeight);
+ subset.fLeft = random->nextULessThan(dims.fWidth);
+ subset.fRight = random->nextRangeU(subset.fLeft + 1, dims.fWidth);
+ subset.fTop = random->nextULessThan(dims.fHeight);
+ subset.fBottom = random->nextRangeU(subset.fTop + 1, dims.fHeight);
} else {
- subset.setXYWH(0, 0, desc.fWidth, desc.fHeight);
+ subset.setXYWH(0, 0, dims.fWidth, dims.fHeight);
}
// SkCanvas::Lattice allows bounds to be null. However, SkCanvas creates a temp Lattice with
// a non-null bounds before creating a SkLatticeIter since SkLatticeIter requires a bounds.
@@ -458,7 +458,7 @@
lattice.fRectTypes = nullptr;
lattice.fColors = nullptr;
}
- } while (!SkLatticeIter::Valid(desc.fWidth, desc.fHeight, lattice));
+ } while (!SkLatticeIter::Valid(dims.fWidth, dims.fHeight, lattice));
SkRect dst;
dst.fLeft = random->nextRangeScalar(-2000.5f, 1000.f);
dst.fTop = random->nextRangeScalar(-2000.5f, 1000.f);
diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp
index 7cf6eab..d6b05be 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -1275,9 +1275,9 @@
#include "src/gpu/GrRecordingContextPriv.h"
GR_DRAW_OP_TEST_DEFINE(TextureOp) {
- GrSurfaceDesc desc;
- desc.fHeight = random->nextULessThan(90) + 10;
- desc.fWidth = random->nextULessThan(90) + 10;
+ SkISize dims;
+ dims.fHeight = random->nextULessThan(90) + 10;
+ dims.fWidth = random->nextULessThan(90) + 10;
auto origin = random->nextBool() ? kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin;
GrMipMapped mipMapped = random->nextBool() ? GrMipMapped::kYes : GrMipMapped::kNo;
SkBackingFit fit = SkBackingFit::kExact;
@@ -1291,7 +1291,7 @@
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
- format, desc, swizzle, GrRenderable::kNo, 1, origin, mipMapped, fit, SkBudgeted::kNo,
+ format, dims, swizzle, GrRenderable::kNo, 1, origin, mipMapped, fit, SkBudgeted::kNo,
GrProtected::kNo, GrInternalSurfaceFlags::kNone);
SkRect rect = GrTest::TestRect(random);
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index ae15986..ff5f8ff 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -838,9 +838,6 @@
VK_FORMAT_R8G8B8A8_UNORM, 1, false, false)) {
return false;
}
- GrSurfaceDesc surfDesc;
- surfDesc.fWidth = width;
- surfDesc.fHeight = height;
VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_SAMPLED_BIT |
VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
@@ -857,8 +854,8 @@
imageDesc.fUsageFlags = usageFlags;
imageDesc.fMemProps = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
- copyTexture = GrVkTexture::MakeNewTexture(this, SkBudgeted::kYes, surfDesc, imageDesc,
- GrMipMapsStatus::kNotAllocated);
+ copyTexture = GrVkTexture::MakeNewTexture(this, SkBudgeted::kYes, {width, height},
+ imageDesc, GrMipMapsStatus::kNotAllocated);
if (!copyTexture) {
return false;
}
@@ -995,7 +992,7 @@
////////////////////////////////////////////////////////////////////////////////
// TODO: make this take a GrMipMapped
-sk_sp<GrTexture> GrVkGpu::onCreateTexture(const GrSurfaceDesc& desc,
+sk_sp<GrTexture> GrVkGpu::onCreateTexture(SkISize dimensions,
const GrBackendFormat& format,
GrRenderable renderable,
int renderTargetSampleCnt,
@@ -1027,8 +1024,8 @@
GrVkImage::ImageDesc imageDesc;
imageDesc.fImageType = VK_IMAGE_TYPE_2D;
imageDesc.fFormat = pixelFormat;
- imageDesc.fWidth = desc.fWidth;
- imageDesc.fHeight = desc.fHeight;
+ imageDesc.fWidth = dimensions.fWidth;
+ imageDesc.fHeight = dimensions.fHeight;
imageDesc.fLevels = mipLevelCount;
imageDesc.fSamples = 1;
imageDesc.fImageTiling = VK_IMAGE_TILING_OPTIMAL;
@@ -1041,9 +1038,9 @@
sk_sp<GrVkTexture> tex;
if (renderable == GrRenderable::kYes) {
tex = GrVkTextureRenderTarget::MakeNewTextureRenderTarget(
- this, budgeted, desc, renderTargetSampleCnt, imageDesc, mipMapsStatus);
+ this, budgeted, dimensions, renderTargetSampleCnt, imageDesc, mipMapsStatus);
} else {
- tex = GrVkTexture::MakeNewTexture(this, budgeted, desc, imageDesc, mipMapsStatus);
+ tex = GrVkTexture::MakeNewTexture(this, budgeted, dimensions, imageDesc, mipMapsStatus);
}
if (!tex) {
@@ -1121,11 +1118,7 @@
? GrMipMapsStatus::kValid
: GrMipMapsStatus::kNotAllocated;
- GrSurfaceDesc desc;
- desc.fWidth = dimensions.width();
- desc.fHeight = dimensions.height();
- auto tex = GrVkTexture::MakeNewTexture(this, budgeted, desc, imageDesc,
- mipMapsStatus);
+ auto tex = GrVkTexture::MakeNewTexture(this, budgeted, dimensions, imageDesc, mipMapsStatus);
if (!tex) {
return nullptr;
}
@@ -1236,14 +1229,10 @@
return nullptr;
}
- GrSurfaceDesc surfDesc;
- surfDesc.fWidth = backendTex.width();
- surfDesc.fHeight = backendTex.height();
-
sk_sp<GrVkImageLayout> layout = backendTex.getGrVkImageLayout();
SkASSERT(layout);
- return GrVkTexture::MakeWrappedTexture(this, surfDesc, ownership, cacheable, ioType, imageInfo,
- std::move(layout));
+ return GrVkTexture::MakeWrappedTexture(this, backendTex.dimensions(), ownership, cacheable,
+ ioType, imageInfo, std::move(layout));
}
sk_sp<GrTexture> GrVkGpu::onWrapCompressedBackendTexture(const GrBackendTexture& beTex,
@@ -1267,13 +1256,9 @@
return nullptr;
}
- GrSurfaceDesc surfDesc;
- surfDesc.fWidth = beTex.width();
- surfDesc.fHeight = beTex.height();
-
sk_sp<GrVkImageLayout> layout = beTex.getGrVkImageLayout();
SkASSERT(layout);
- return GrVkTexture::MakeWrappedTexture(this, surfDesc, ownership, cacheable,
+ return GrVkTexture::MakeWrappedTexture(this, beTex.dimensions(), ownership, cacheable,
kRead_GrIOType, imageInfo, std::move(layout));
}
@@ -1303,16 +1288,14 @@
return nullptr;
}
- GrSurfaceDesc surfDesc;
- surfDesc.fWidth = backendTex.width();
- surfDesc.fHeight = backendTex.height();
sampleCnt = this->vkCaps().getRenderTargetSampleCount(sampleCnt, imageInfo.fFormat);
sk_sp<GrVkImageLayout> layout = backendTex.getGrVkImageLayout();
SkASSERT(layout);
- return GrVkTextureRenderTarget::MakeWrappedTextureRenderTarget(
- this, surfDesc, sampleCnt, ownership, cacheable, imageInfo, std::move(layout));
+ return GrVkTextureRenderTarget::MakeWrappedTextureRenderTarget(this, backendTex.dimensions(),
+ sampleCnt, ownership, cacheable,
+ imageInfo, std::move(layout));
}
sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& backendRT,
@@ -1342,14 +1325,10 @@
return nullptr;
}
- GrSurfaceDesc desc;
- desc.fWidth = backendRT.width();
- desc.fHeight = backendRT.height();
-
sk_sp<GrVkImageLayout> layout = backendRT.getGrVkImageLayout();
- sk_sp<GrVkRenderTarget> tgt =
- GrVkRenderTarget::MakeWrappedRenderTarget(this, desc, 1, info, std::move(layout));
+ sk_sp<GrVkRenderTarget> tgt = GrVkRenderTarget::MakeWrappedRenderTarget(
+ this, backendRT.dimensions(), 1, info, std::move(layout));
// We don't allow the client to supply a premade stencil buffer. We always create one if needed.
SkASSERT(!backendRT.stencilBits());
@@ -1380,10 +1359,6 @@
return nullptr;
}
- GrSurfaceDesc desc;
- desc.fWidth = tex.width();
- desc.fHeight = tex.height();
-
sampleCnt = this->vkCaps().getRenderTargetSampleCount(sampleCnt, imageInfo.fFormat);
if (!sampleCnt) {
return nullptr;
@@ -1392,7 +1367,7 @@
sk_sp<GrVkImageLayout> layout = tex.getGrVkImageLayout();
SkASSERT(layout);
- return GrVkRenderTarget::MakeWrappedRenderTarget(this, desc, sampleCnt, imageInfo,
+ return GrVkRenderTarget::MakeWrappedRenderTarget(this, tex.dimensions(), sampleCnt, imageInfo,
std::move(layout));
}
@@ -1412,11 +1387,7 @@
return nullptr;
}
- GrSurfaceDesc desc;
- desc.fWidth = imageInfo.width();
- desc.fHeight = imageInfo.height();
-
- return GrVkRenderTarget::MakeSecondaryCBRenderTarget(this, desc, vkInfo);
+ return GrVkRenderTarget::MakeSecondaryCBRenderTarget(this, imageInfo.dimensions(), vkInfo);
}
bool GrVkGpu::onRegenerateMipMapLevels(GrTexture* tex) {
@@ -2465,10 +2436,6 @@
}
// Make a new surface that is RGBA to copy the RGB surface into.
- GrSurfaceDesc surfDesc;
- surfDesc.fWidth = width;
- surfDesc.fHeight = height;
-
VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
VK_IMAGE_USAGE_SAMPLED_BIT |
VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
@@ -2486,7 +2453,8 @@
imageDesc.fMemProps = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
copySurface = GrVkTextureRenderTarget::MakeNewTextureRenderTarget(
- this, SkBudgeted::kYes, surfDesc, 1, imageDesc, GrMipMapsStatus::kNotAllocated);
+ this, SkBudgeted::kYes, {width, height}, 1, imageDesc,
+ GrMipMapsStatus::kNotAllocated);
if (!copySurface) {
return false;
}
diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h
index 9b0b583..3007ec1 100644
--- a/src/gpu/vk/GrVkGpu.h
+++ b/src/gpu/vk/GrVkGpu.h
@@ -185,7 +185,7 @@
GrProtected,
const BackendTextureData*) override;
- sk_sp<GrTexture> onCreateTexture(const GrSurfaceDesc&,
+ sk_sp<GrTexture> onCreateTexture(SkISize,
const GrBackendFormat&,
GrRenderable,
int renderTargetSampleCnt,
diff --git a/src/gpu/vk/GrVkRenderTarget.cpp b/src/gpu/vk/GrVkRenderTarget.cpp
index 4c7a327..cf136f3 100644
--- a/src/gpu/vk/GrVkRenderTarget.cpp
+++ b/src/gpu/vk/GrVkRenderTarget.cpp
@@ -23,7 +23,7 @@
// We're virtually derived from GrSurface (via GrRenderTarget) so its
// constructor must be explicitly called.
GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
int sampleCnt,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout,
@@ -31,10 +31,10 @@
sk_sp<GrVkImageLayout> msaaLayout,
const GrVkImageView* colorAttachmentView,
const GrVkImageView* resolveAttachmentView)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
+ : GrSurface(gpu, dimensions, info.fProtected)
, GrVkImage(info, std::move(layout), GrBackendObjectOwnership::kBorrowed)
// for the moment we only support 1:1 color to stencil
- , GrRenderTarget(gpu, {desc.fWidth, desc.fHeight}, sampleCnt, info.fProtected)
+ , GrRenderTarget(gpu, dimensions, sampleCnt, info.fProtected)
, fColorAttachmentView(colorAttachmentView)
, fMSAAImage(new GrVkImage(msaaInfo, std::move(msaaLayout),
GrBackendObjectOwnership::kOwned))
@@ -49,7 +49,7 @@
// We're virtually derived from GrSurface (via GrRenderTarget) so its
// constructor must be explicitly called.
GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
int sampleCnt,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout,
@@ -58,10 +58,10 @@
const GrVkImageView* colorAttachmentView,
const GrVkImageView* resolveAttachmentView,
GrBackendObjectOwnership ownership)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
+ : GrSurface(gpu, dimensions, info.fProtected)
, GrVkImage(info, std::move(layout), ownership)
// for the moment we only support 1:1 color to stencil
- , GrRenderTarget(gpu, {desc.fWidth, desc.fHeight}, sampleCnt, info.fProtected)
+ , GrRenderTarget(gpu, dimensions, sampleCnt, info.fProtected)
, fColorAttachmentView(colorAttachmentView)
, fMSAAImage(
new GrVkImage(msaaInfo, std::move(msaaLayout), GrBackendObjectOwnership::kOwned))
@@ -75,13 +75,13 @@
// We're virtually derived from GrSurface (via GrRenderTarget) so its
// constructor must be explicitly called.
GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout,
const GrVkImageView* colorAttachmentView)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
+ : GrSurface(gpu, dimensions, info.fProtected)
, GrVkImage(info, std::move(layout), GrBackendObjectOwnership::kBorrowed)
- , GrRenderTarget(gpu, {desc.fWidth, desc.fHeight}, 1, info.fProtected)
+ , GrRenderTarget(gpu, dimensions, 1, info.fProtected)
, fColorAttachmentView(colorAttachmentView)
, fMSAAImage(nullptr)
, fResolveAttachmentView(nullptr)
@@ -93,30 +93,29 @@
// We're virtually derived from GrSurface (via GrRenderTarget) so its
// constructor must be explicitly called.
GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout,
const GrVkImageView* colorAttachmentView,
GrBackendObjectOwnership ownership)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
+ : GrSurface(gpu, dimensions, info.fProtected)
, GrVkImage(info, std::move(layout), ownership)
- , GrRenderTarget(gpu, {desc.fWidth, desc.fHeight}, 1, info.fProtected)
+ , GrRenderTarget(gpu, dimensions, 1, info.fProtected)
, fColorAttachmentView(colorAttachmentView)
, fMSAAImage(nullptr)
, fResolveAttachmentView(nullptr)
, fCachedFramebuffer(nullptr)
- , fCachedSimpleRenderPass(nullptr) {
-}
+ , fCachedSimpleRenderPass(nullptr) {}
GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout,
const GrVkRenderPass* renderPass,
VkCommandBuffer secondaryCommandBuffer)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
+ : GrSurface(gpu, dimensions, info.fProtected)
, GrVkImage(info, std::move(layout), GrBackendObjectOwnership::kBorrowed, true)
- , GrRenderTarget(gpu, {desc.fWidth, desc.fHeight}, 1, info.fProtected)
+ , GrRenderTarget(gpu, dimensions, 1, info.fProtected)
, fColorAttachmentView(nullptr)
, fMSAAImage(nullptr)
, fResolveAttachmentView(nullptr)
@@ -128,7 +127,7 @@
}
sk_sp<GrVkRenderTarget> GrVkRenderTarget::MakeWrappedRenderTarget(GrVkGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
int sampleCnt,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout) {
@@ -147,8 +146,8 @@
GrVkImage::ImageDesc msImageDesc;
msImageDesc.fImageType = VK_IMAGE_TYPE_2D;
msImageDesc.fFormat = pixelFormat;
- msImageDesc.fWidth = desc.fWidth;
- msImageDesc.fHeight = desc.fHeight;
+ msImageDesc.fWidth = dimensions.fWidth;
+ msImageDesc.fHeight = dimensions.fHeight;
msImageDesc.fLevels = 1;
msImageDesc.fSamples = sampleCnt;
msImageDesc.fImageTiling = VK_IMAGE_TILING_OPTIMAL;
@@ -193,18 +192,18 @@
GrVkRenderTarget* vkRT;
if (sampleCnt > 1) {
- vkRT = new GrVkRenderTarget(gpu, desc, sampleCnt, info, std::move(layout), msInfo,
+ vkRT = new GrVkRenderTarget(gpu, dimensions, sampleCnt, info, std::move(layout), msInfo,
std::move(msLayout), colorAttachmentView,
resolveAttachmentView);
} else {
- vkRT = new GrVkRenderTarget(gpu, desc, info, std::move(layout), colorAttachmentView);
+ vkRT = new GrVkRenderTarget(gpu, dimensions, info, std::move(layout), colorAttachmentView);
}
return sk_sp<GrVkRenderTarget>(vkRT);
}
sk_sp<GrVkRenderTarget> GrVkRenderTarget::MakeSecondaryCBRenderTarget(
- GrVkGpu* gpu, const GrSurfaceDesc& desc, const GrVkDrawableInfo& vkInfo) {
+ GrVkGpu* gpu, SkISize dimensions, const GrVkDrawableInfo& vkInfo) {
// We only set the few properties of the GrVkImageInfo that we know like layout and format. The
// others we keep at the default "null" values.
GrVkImageInfo info;
@@ -224,7 +223,7 @@
return nullptr;
}
- GrVkRenderTarget* vkRT = new GrVkRenderTarget(gpu, desc, info, std::move(layout), rp,
+ GrVkRenderTarget* vkRT = new GrVkRenderTarget(gpu, dimensions, info, std::move(layout), rp,
vkInfo.fSecondaryCommandBuffer);
return sk_sp<GrVkRenderTarget>(vkRT);
diff --git a/src/gpu/vk/GrVkRenderTarget.h b/src/gpu/vk/GrVkRenderTarget.h
index 8224183..224c40c 100644
--- a/src/gpu/vk/GrVkRenderTarget.h
+++ b/src/gpu/vk/GrVkRenderTarget.h
@@ -32,11 +32,11 @@
class GrVkRenderTarget: public GrRenderTarget, public virtual GrVkImage {
public:
- static sk_sp<GrVkRenderTarget> MakeWrappedRenderTarget(GrVkGpu*, const GrSurfaceDesc&,
- int sampleCnt, const GrVkImageInfo&,
+ static sk_sp<GrVkRenderTarget> MakeWrappedRenderTarget(GrVkGpu*, SkISize, int sampleCnt,
+ const GrVkImageInfo&,
sk_sp<GrVkImageLayout>);
- static sk_sp<GrVkRenderTarget> MakeSecondaryCBRenderTarget(GrVkGpu*, const GrSurfaceDesc&,
+ static sk_sp<GrVkRenderTarget> MakeSecondaryCBRenderTarget(GrVkGpu*, SkISize,
const GrVkDrawableInfo& vkInfo);
~GrVkRenderTarget() override;
@@ -96,7 +96,7 @@
protected:
GrVkRenderTarget(GrVkGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
int sampleCnt,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout,
@@ -107,7 +107,7 @@
GrBackendObjectOwnership);
GrVkRenderTarget(GrVkGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout,
const GrVkImageView* colorAttachmentView,
@@ -130,7 +130,7 @@
private:
GrVkRenderTarget(GrVkGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
int sampleCnt,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout,
@@ -140,14 +140,13 @@
const GrVkImageView* resolveAttachmentView);
GrVkRenderTarget(GrVkGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout,
const GrVkImageView* colorAttachmentView);
-
GrVkRenderTarget(GrVkGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout,
const GrVkRenderPass* renderPass,
diff --git a/src/gpu/vk/GrVkTexture.cpp b/src/gpu/vk/GrVkTexture.cpp
index b12411d..ca8a2ce 100644
--- a/src/gpu/vk/GrVkTexture.cpp
+++ b/src/gpu/vk/GrVkTexture.cpp
@@ -21,15 +21,14 @@
// Because this class is virtually derived from GrSurface we must explicitly call its constructor.
GrVkTexture::GrVkTexture(GrVkGpu* gpu,
SkBudgeted budgeted,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout,
const GrVkImageView* view,
GrMipMapsStatus mipMapsStatus)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
+ : GrSurface(gpu, dimensions, info.fProtected)
, GrVkImage(info, std::move(layout), GrBackendObjectOwnership::kOwned)
- , INHERITED(gpu, {desc.fWidth, desc.fHeight}, info.fProtected,
- GrTextureType::k2D, mipMapsStatus)
+ , INHERITED(gpu, dimensions, info.fProtected, GrTextureType::k2D, mipMapsStatus)
, fTextureView(view)
, fDescSetCache(kMaxCachedDescSets) {
SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == info.fLevelCount));
@@ -41,13 +40,13 @@
}
}
-GrVkTexture::GrVkTexture(GrVkGpu* gpu, const GrSurfaceDesc& desc, const GrVkImageInfo& info,
+GrVkTexture::GrVkTexture(GrVkGpu* gpu, SkISize dimensions, const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout, const GrVkImageView* view,
GrMipMapsStatus mipMapsStatus, GrBackendObjectOwnership ownership,
GrWrapCacheable cacheable, GrIOType ioType, bool isExternal)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
+ : GrSurface(gpu, dimensions, info.fProtected)
, GrVkImage(info, std::move(layout), ownership)
- , INHERITED(gpu, {desc.fWidth, desc.fHeight}, info.fProtected,
+ , INHERITED(gpu, dimensions, info.fProtected,
isExternal ? GrTextureType::kExternal : GrTextureType::k2D, mipMapsStatus)
, fTextureView(view)
, fDescSetCache(kMaxCachedDescSets) {
@@ -60,16 +59,15 @@
// Because this class is virtually derived from GrSurface we must explicitly call its constructor.
GrVkTexture::GrVkTexture(GrVkGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout,
const GrVkImageView* view,
GrMipMapsStatus mipMapsStatus,
GrBackendObjectOwnership ownership)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
+ : GrSurface(gpu, dimensions, info.fProtected)
, GrVkImage(info, layout, ownership)
- , INHERITED(gpu, {desc.fWidth, desc.fHeight}, info.fProtected, GrTextureType::k2D,
- mipMapsStatus)
+ , INHERITED(gpu, dimensions, info.fProtected, GrTextureType::k2D, mipMapsStatus)
, fTextureView(view)
, fDescSetCache(kMaxCachedDescSets) {
SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == info.fLevelCount));
@@ -79,7 +77,7 @@
}
sk_sp<GrVkTexture> GrVkTexture::MakeNewTexture(GrVkGpu* gpu, SkBudgeted budgeted,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
const GrVkImage::ImageDesc& imageDesc,
GrMipMapsStatus mipMapsStatus) {
SkASSERT(imageDesc.fUsageFlags & VK_IMAGE_USAGE_SAMPLED_BIT);
@@ -98,12 +96,12 @@
}
sk_sp<GrVkImageLayout> layout(new GrVkImageLayout(info.fImageLayout));
- return sk_sp<GrVkTexture>(new GrVkTexture(gpu, budgeted, desc, info, std::move(layout),
+ return sk_sp<GrVkTexture>(new GrVkTexture(gpu, budgeted, dimensions, info, std::move(layout),
imageView, mipMapsStatus));
}
sk_sp<GrVkTexture> GrVkTexture::MakeWrappedTexture(GrVkGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
GrWrapOwnership wrapOwnership,
GrWrapCacheable cacheable,
GrIOType ioType,
@@ -127,7 +125,7 @@
? GrBackendObjectOwnership::kBorrowed : GrBackendObjectOwnership::kOwned;
bool isExternal = info.fYcbcrConversionInfo.isValid() &&
(info.fYcbcrConversionInfo.fExternalFormat != 0);
- return sk_sp<GrVkTexture>(new GrVkTexture(gpu, desc, info, std::move(layout), imageView,
+ return sk_sp<GrVkTexture>(new GrVkTexture(gpu, dimensions, info, std::move(layout), imageView,
mipMapsStatus, ownership, cacheable, ioType,
isExternal));
}
diff --git a/src/gpu/vk/GrVkTexture.h b/src/gpu/vk/GrVkTexture.h
index 558eb4d..12e0dec 100644
--- a/src/gpu/vk/GrVkTexture.h
+++ b/src/gpu/vk/GrVkTexture.h
@@ -23,12 +23,16 @@
public:
static sk_sp<GrVkTexture> MakeNewTexture(GrVkGpu*,
SkBudgeted budgeted,
- const GrSurfaceDesc&,
+ SkISize dimensions,
const GrVkImage::ImageDesc&,
GrMipMapsStatus);
- static sk_sp<GrVkTexture> MakeWrappedTexture(GrVkGpu*, const GrSurfaceDesc&, GrWrapOwnership,
- GrWrapCacheable, GrIOType, const GrVkImageInfo&,
+ static sk_sp<GrVkTexture> MakeWrappedTexture(GrVkGpu*,
+ SkISize dimensions,
+ GrWrapOwnership,
+ GrWrapCacheable,
+ GrIOType,
+ const GrVkImageInfo&,
sk_sp<GrVkImageLayout>);
~GrVkTexture() override;
@@ -54,8 +58,13 @@
void addDescriptorSetToCache(const GrVkDescriptorSet*, GrSamplerState);
protected:
- GrVkTexture(GrVkGpu*, const GrSurfaceDesc&, const GrVkImageInfo&, sk_sp<GrVkImageLayout>,
- const GrVkImageView*, GrMipMapsStatus, GrBackendObjectOwnership);
+ GrVkTexture(GrVkGpu*,
+ SkISize dimensions,
+ const GrVkImageInfo&,
+ sk_sp<GrVkImageLayout>,
+ const GrVkImageView*,
+ GrMipMapsStatus,
+ GrBackendObjectOwnership);
GrVkGpu* getVkGpu() const;
@@ -69,10 +78,9 @@
void willRemoveLastRef() override;
private:
- GrVkTexture(GrVkGpu*, SkBudgeted, const GrSurfaceDesc&, const GrVkImageInfo&,
- sk_sp<GrVkImageLayout> layout, const GrVkImageView* imageView,
- GrMipMapsStatus);
- GrVkTexture(GrVkGpu*, const GrSurfaceDesc&, const GrVkImageInfo&, sk_sp<GrVkImageLayout>,
+ GrVkTexture(GrVkGpu*, SkBudgeted, SkISize, const GrVkImageInfo&, sk_sp<GrVkImageLayout> layout,
+ const GrVkImageView* imageView, GrMipMapsStatus);
+ GrVkTexture(GrVkGpu*, SkISize, const GrVkImageInfo&, sk_sp<GrVkImageLayout>,
const GrVkImageView*, GrMipMapsStatus, GrBackendObjectOwnership, GrWrapCacheable,
GrIOType, bool isExternal);
diff --git a/src/gpu/vk/GrVkTextureRenderTarget.cpp b/src/gpu/vk/GrVkTextureRenderTarget.cpp
index bb51197..c7c2bdd 100644
--- a/src/gpu/vk/GrVkTextureRenderTarget.cpp
+++ b/src/gpu/vk/GrVkTextureRenderTarget.cpp
@@ -20,7 +20,7 @@
GrVkTextureRenderTarget::GrVkTextureRenderTarget(GrVkGpu* gpu,
SkBudgeted budgeted,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
int sampleCnt,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout,
@@ -30,12 +30,12 @@
const GrVkImageView* colorAttachmentView,
const GrVkImageView* resolveAttachmentView,
GrMipMapsStatus mipMapsStatus)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
+ : GrSurface(gpu, dimensions, info.fProtected)
, GrVkImage(info, layout, GrBackendObjectOwnership::kOwned)
- , GrVkTexture(gpu, desc, info, layout, texView, mipMapsStatus,
+ , GrVkTexture(gpu, dimensions, info, layout, texView, mipMapsStatus,
GrBackendObjectOwnership::kOwned)
- , GrVkRenderTarget(gpu, desc, sampleCnt, info, layout, msaaInfo, std::move(msaaLayout),
- colorAttachmentView, resolveAttachmentView,
+ , GrVkRenderTarget(gpu, dimensions, sampleCnt, info, layout, msaaInfo,
+ std::move(msaaLayout), colorAttachmentView, resolveAttachmentView,
GrBackendObjectOwnership::kOwned) {
SkASSERT(info.fProtected == msaaInfo.fProtected);
this->registerWithCache(budgeted);
@@ -43,23 +43,23 @@
GrVkTextureRenderTarget::GrVkTextureRenderTarget(GrVkGpu* gpu,
SkBudgeted budgeted,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout,
const GrVkImageView* texView,
const GrVkImageView* colorAttachmentView,
GrMipMapsStatus mipMapsStatus)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
+ : GrSurface(gpu, dimensions, info.fProtected)
, GrVkImage(info, layout, GrBackendObjectOwnership::kOwned)
- , GrVkTexture(gpu, desc, info, layout, texView, mipMapsStatus,
+ , GrVkTexture(gpu, dimensions, info, layout, texView, mipMapsStatus,
GrBackendObjectOwnership::kOwned)
- , GrVkRenderTarget(gpu, desc, info, layout, colorAttachmentView,
+ , GrVkRenderTarget(gpu, dimensions, info, layout, colorAttachmentView,
GrBackendObjectOwnership::kOwned) {
this->registerWithCache(budgeted);
}
GrVkTextureRenderTarget::GrVkTextureRenderTarget(GrVkGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
int sampleCnt,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout,
@@ -71,17 +71,18 @@
GrMipMapsStatus mipMapsStatus,
GrBackendObjectOwnership ownership,
GrWrapCacheable cacheable)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
+ : GrSurface(gpu, dimensions, info.fProtected)
, GrVkImage(info, layout, ownership)
- , GrVkTexture(gpu, desc, info, layout, texView, mipMapsStatus, ownership)
- , GrVkRenderTarget(gpu, desc, sampleCnt, info, layout, msaaInfo, std::move(msaaLayout),
- colorAttachmentView, resolveAttachmentView, ownership) {
+ , GrVkTexture(gpu, dimensions, info, layout, texView, mipMapsStatus, ownership)
+ , GrVkRenderTarget(gpu, dimensions, sampleCnt, info, layout, msaaInfo,
+ std::move(msaaLayout), colorAttachmentView, resolveAttachmentView,
+ ownership) {
SkASSERT(info.fProtected == msaaInfo.fProtected);
this->registerWithCacheWrapped(cacheable);
}
GrVkTextureRenderTarget::GrVkTextureRenderTarget(GrVkGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout,
const GrVkImageView* texView,
@@ -89,10 +90,10 @@
GrMipMapsStatus mipMapsStatus,
GrBackendObjectOwnership ownership,
GrWrapCacheable cacheable)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, info.fProtected)
+ : GrSurface(gpu, dimensions, info.fProtected)
, GrVkImage(info, layout, ownership)
- , GrVkTexture(gpu, desc, info, layout, texView, mipMapsStatus, ownership)
- , GrVkRenderTarget(gpu, desc, info, layout, colorAttachmentView, ownership) {
+ , GrVkTexture(gpu, dimensions, info, layout, texView, mipMapsStatus, ownership)
+ , GrVkRenderTarget(gpu, dimensions, info, layout, colorAttachmentView, ownership) {
this->registerWithCacheWrapped(cacheable);
}
@@ -106,7 +107,7 @@
};
} // anonymous namespace
-static Views create_views(GrVkGpu* gpu, const GrSurfaceDesc& desc, int sampleCnt,
+static Views create_views(GrVkGpu* gpu, SkISize dimensions, int sampleCnt,
const GrVkImageInfo& info) {
VkImage image = info.fImage;
// Create the texture ImageView
@@ -126,8 +127,8 @@
GrVkImage::ImageDesc msImageDesc;
msImageDesc.fImageType = VK_IMAGE_TYPE_2D;
msImageDesc.fFormat = pixelFormat;
- msImageDesc.fWidth = desc.fWidth;
- msImageDesc.fHeight = desc.fHeight;
+ msImageDesc.fWidth = dimensions.fWidth;
+ msImageDesc.fHeight = dimensions.fHeight;
msImageDesc.fLevels = 1;
msImageDesc.fSamples = sampleCnt;
msImageDesc.fImageTiling = VK_IMAGE_TILING_OPTIMAL;
@@ -175,7 +176,7 @@
sk_sp<GrVkTextureRenderTarget> GrVkTextureRenderTarget::MakeNewTextureRenderTarget(
GrVkGpu* gpu,
SkBudgeted budgeted,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
int sampleCnt,
const GrVkImage::ImageDesc& imageDesc,
GrMipMapsStatus mipMapsStatus) {
@@ -188,26 +189,26 @@
}
sk_sp<GrVkImageLayout> layout(new GrVkImageLayout(info.fImageLayout));
- Views views = create_views(gpu, desc, sampleCnt, info);
+ Views views = create_views(gpu, dimensions, sampleCnt, info);
if (!views.colorAttachmentView) {
GrVkImage::DestroyImageInfo(gpu, &info);
return nullptr;
}
if (sampleCnt > 1) {
return sk_sp<GrVkTextureRenderTarget>(new GrVkTextureRenderTarget(
- gpu, budgeted, desc, sampleCnt, info, std::move(layout), views.imageView,
+ gpu, budgeted, dimensions, sampleCnt, info, std::move(layout), views.imageView,
views.msInfo, std::move(views.msLayout), views.colorAttachmentView,
views.resolveAttachmentView, mipMapsStatus));
} else {
return sk_sp<GrVkTextureRenderTarget>(new GrVkTextureRenderTarget(
- gpu, budgeted, desc, info, std::move(layout), views.imageView,
+ gpu, budgeted, dimensions, info, std::move(layout), views.imageView,
views.colorAttachmentView, mipMapsStatus));
}
}
sk_sp<GrVkTextureRenderTarget> GrVkTextureRenderTarget::MakeWrappedTextureRenderTarget(
GrVkGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
int sampleCnt,
GrWrapOwnership wrapOwnership,
GrWrapCacheable cacheable,
@@ -222,19 +223,19 @@
GrBackendObjectOwnership ownership = kBorrow_GrWrapOwnership == wrapOwnership
? GrBackendObjectOwnership::kBorrowed : GrBackendObjectOwnership::kOwned;
- Views views = create_views(gpu, desc, sampleCnt, info);
+ Views views = create_views(gpu, dimensions, sampleCnt, info);
if (!views.colorAttachmentView) {
return nullptr;
}
if (sampleCnt > 1) {
return sk_sp<GrVkTextureRenderTarget>(new GrVkTextureRenderTarget(
- gpu, desc, sampleCnt, info, std::move(layout), views.imageView, views.msInfo,
+ gpu, dimensions, sampleCnt, info, std::move(layout), views.imageView, views.msInfo,
std::move(views.msLayout), views.colorAttachmentView, views.resolveAttachmentView,
mipMapsStatus, ownership, cacheable));
} else {
return sk_sp<GrVkTextureRenderTarget>(new GrVkTextureRenderTarget(
- gpu, desc, info, std::move(layout), views.imageView, views.colorAttachmentView,
- mipMapsStatus, ownership, cacheable));
+ gpu, dimensions, info, std::move(layout), views.imageView,
+ views.colorAttachmentView, mipMapsStatus, ownership, cacheable));
}
}
diff --git a/src/gpu/vk/GrVkTextureRenderTarget.h b/src/gpu/vk/GrVkTextureRenderTarget.h
index 0771431..e319175 100644
--- a/src/gpu/vk/GrVkTextureRenderTarget.h
+++ b/src/gpu/vk/GrVkTextureRenderTarget.h
@@ -27,13 +27,13 @@
class GrVkTextureRenderTarget: public GrVkTexture, public GrVkRenderTarget {
public:
static sk_sp<GrVkTextureRenderTarget> MakeNewTextureRenderTarget(GrVkGpu*, SkBudgeted,
- const GrSurfaceDesc&,
+ SkISize dimensions,
int sampleCnt,
const GrVkImage::ImageDesc&,
GrMipMapsStatus);
static sk_sp<GrVkTextureRenderTarget> MakeWrappedTextureRenderTarget(GrVkGpu*,
- const GrSurfaceDesc&,
+ SkISize dimensions,
int sampleCnt,
GrWrapOwnership,
GrWrapCacheable,
@@ -59,7 +59,7 @@
// MSAA, not-wrapped
GrVkTextureRenderTarget(GrVkGpu* gpu,
SkBudgeted budgeted,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
int sampleCnt,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout,
@@ -73,7 +73,7 @@
// non-MSAA, not-wrapped
GrVkTextureRenderTarget(GrVkGpu* gpu,
SkBudgeted budgeted,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout,
const GrVkImageView* texView,
@@ -82,7 +82,7 @@
// MSAA, wrapped
GrVkTextureRenderTarget(GrVkGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
int sampleCnt,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout,
@@ -97,7 +97,7 @@
// non-MSAA, wrapped
GrVkTextureRenderTarget(GrVkGpu* gpu,
- const GrSurfaceDesc& desc,
+ SkISize dimensions,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout,
const GrVkImageView* texView,
diff --git a/src/image/SkImage_GpuBase.cpp b/src/image/SkImage_GpuBase.cpp
index eded6b2..563d290 100644
--- a/src/image/SkImage_GpuBase.cpp
+++ b/src/image/SkImage_GpuBase.cpp
@@ -522,10 +522,6 @@
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
- GrSurfaceDesc desc;
- desc.fWidth = width;
- desc.fHeight = height;
-
// Ganesh assumes that, when wrapping a mipmapped backend texture from a client, that its
// mipmaps are fully fleshed out.
GrMipMapsStatus mipMapsStatus = (GrMipMapped::kYes == mipMapped)
@@ -535,8 +531,9 @@
// We pass kReadOnly here since we should treat content of the client's texture as immutable.
// The promise API provides no way for the client to indicated that the texture is protected.
- return proxyProvider->createLazyProxy(
- std::move(callback), backendFormat, desc, readSwizzle, GrRenderable::kNo, 1, origin,
- mipMapped, mipMapsStatus, GrInternalSurfaceFlags::kReadOnly, SkBackingFit::kExact,
- SkBudgeted::kNo, GrProtected::kNo, GrSurfaceProxy::UseAllocator::kYes);
+ return proxyProvider->createLazyProxy(std::move(callback), backendFormat, {width, height},
+ readSwizzle, GrRenderable::kNo, 1, origin, mipMapped,
+ mipMapsStatus, GrInternalSurfaceFlags::kReadOnly,
+ SkBackingFit::kExact, SkBudgeted::kNo, GrProtected::kNo,
+ GrSurfaceProxy::UseAllocator::kYes);
}
diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp
index abf5547..e3d000d 100644
--- a/src/image/SkImage_Lazy.cpp
+++ b/src/image/SkImage_Lazy.cpp
@@ -494,8 +494,6 @@
// 3. Ask the generator to return YUV planes, which the GPU can convert. If we will be mipping
// the texture we fall through here and have the CPU generate the mip maps for us.
if (!view.proxy() && !willBeMipped && !ctx->priv().options().fDisableGpuYUVConversion) {
- const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(this->imageInfo());
-
SkColorType colorType = this->colorType();
ScopedGenerator generator(fSharedGenerator);
@@ -510,8 +508,9 @@
// TODO: Update to create the mipped surface in the YUV generator and draw the base
// layer directly into the mipped surface.
- view = provider.refAsTextureProxyView(ctx, desc, SkColorTypeToGrColorType(colorType),
- generatorColorSpace, thisColorSpace);
+ view = provider.refAsTextureProxyView(ctx, this->imageInfo().dimensions(),
+ SkColorTypeToGrColorType(colorType),
+ generatorColorSpace, thisColorSpace);
if (view.proxy()) {
SK_HISTOGRAM_ENUMERATION("LockTexturePath", kYUV_LockTexturePath,
kLockTexturePathCount);
diff --git a/src/image/SkSurface_GpuMtl.mm b/src/image/SkSurface_GpuMtl.mm
index e18bfd8..53786fa 100644
--- a/src/image/SkSurface_GpuMtl.mm
+++ b/src/image/SkSurface_GpuMtl.mm
@@ -43,9 +43,7 @@
GrColorType grColorType = SkColorTypeToGrColorType(colorType);
- GrSurfaceDesc desc;
- desc.fWidth = metalLayer.drawableSize.width;
- desc.fHeight = metalLayer.drawableSize.height;
+ SkISize dims = {(int)metalLayer.drawableSize.width, (int)metalLayer.drawableSize.height};
GrProxyProvider::TextureInfo texInfo;
texInfo.fMipMapped = GrMipMapped::kNo;
@@ -58,19 +56,17 @@
CAMetalLayer* metalLayer = (__bridge CAMetalLayer*)layer;
id<CAMetalDrawable> currentDrawable = [metalLayer nextDrawable];
- GrSurfaceDesc desc;
- desc.fWidth = metalLayer.drawableSize.width;
- desc.fHeight = metalLayer.drawableSize.height;
+ SkISize dims = {(int)metalLayer.drawableSize.width,
+ (int)metalLayer.drawableSize.height};
GrMtlGpu* mtlGpu = (GrMtlGpu*) resourceProvider->priv().gpu();
sk_sp<GrRenderTarget> surface;
if (metalLayer.framebufferOnly) {
- surface = GrMtlRenderTarget::MakeWrappedRenderTarget(
- mtlGpu, desc, sampleCnt, currentDrawable.texture);
+ surface = GrMtlRenderTarget::MakeWrappedRenderTarget(mtlGpu, dims, sampleCnt,
+ currentDrawable.texture);
} else {
surface = GrMtlTextureRenderTarget::MakeWrappedTextureRenderTarget(
- mtlGpu, desc, sampleCnt, currentDrawable.texture,
- GrWrapCacheable::kNo);
+ mtlGpu, dims, sampleCnt, currentDrawable.texture, GrWrapCacheable::kNo);
}
if (surface && sampleCnt > 1) {
surface->setRequiresManualMSAAResolve();
@@ -80,7 +76,7 @@
return GrSurfaceProxy::LazyCallbackResult(std::move(surface));
},
backendFormat,
- desc,
+ dims,
readSwizzle,
sampleCnt,
origin,
@@ -124,9 +120,7 @@
GrColorType grColorType = SkColorTypeToGrColorType(colorType);
- GrSurfaceDesc desc;
- desc.fWidth = mtkView.drawableSize.width;
- desc.fHeight = mtkView.drawableSize.height;
+ SkISize dims = {(int)mtkView.drawableSize.width, (int)mtkView.drawableSize.height};
GrProxyProvider::TextureInfo texInfo;
texInfo.fMipMapped = GrMipMapped::kNo;
@@ -139,19 +133,16 @@
MTKView* mtkView = (__bridge MTKView*)view;
id<CAMetalDrawable> currentDrawable = [mtkView currentDrawable];
- GrSurfaceDesc desc;
- desc.fWidth = mtkView.drawableSize.width;
- desc.fHeight = mtkView.drawableSize.height;
+ SkISize dims = {(int)mtkView.drawableSize.width, (int)mtkView.drawableSize.height};
GrMtlGpu* mtlGpu = (GrMtlGpu*) resourceProvider->priv().gpu();
sk_sp<GrRenderTarget> surface;
if (mtkView.framebufferOnly) {
- surface = GrMtlRenderTarget::MakeWrappedRenderTarget(
- mtlGpu, desc, sampleCnt, currentDrawable.texture);
+ surface = GrMtlRenderTarget::MakeWrappedRenderTarget(mtlGpu, dims, sampleCnt,
+ currentDrawable.texture);
} else {
surface = GrMtlTextureRenderTarget::MakeWrappedTextureRenderTarget(
- mtlGpu, desc, sampleCnt, currentDrawable.texture,
- GrWrapCacheable::kNo);
+ mtlGpu, dims, sampleCnt, currentDrawable.texture, GrWrapCacheable::kNo);
}
if (surface && sampleCnt > 1) {
surface->setRequiresManualMSAAResolve();
@@ -160,7 +151,7 @@
return GrSurfaceProxy::LazyCallbackResult(std::move(surface));
},
backendFormat,
- desc,
+ dims,
readSwizzle,
sampleCnt,
origin,
diff --git a/tests/ApplyGammaTest.cpp b/tests/ApplyGammaTest.cpp
index afc49f3..396b254 100644
--- a/tests/ApplyGammaTest.cpp
+++ b/tests/ApplyGammaTest.cpp
@@ -95,27 +95,22 @@
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ApplyGamma, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
- static const int kW = 256;
- static const int kH = 256;
- static const size_t kRowBytes = sizeof(uint32_t) * kW;
+ static constexpr SkISize kBaseSize{256, 256};
+ static const size_t kRowBytes = sizeof(uint32_t) * kBaseSize.fWidth;
- GrSurfaceDesc baseDesc;
- baseDesc.fWidth = kW;
- baseDesc.fHeight = kH;
+ const SkImageInfo ii = SkImageInfo::MakeN32Premul(kBaseSize);
- const SkImageInfo ii = SkImageInfo::MakeN32Premul(kW, kH);
-
- SkAutoTMalloc<uint32_t> srcPixels(kW * kH);
- for (int y = 0; y < kH; ++y) {
- for (int x = 0; x < kW; ++x) {
- srcPixels.get()[y*kW+x] = SkPreMultiplyARGB(x, y, x, 0xFF);
+ SkAutoTMalloc<uint32_t> srcPixels(kBaseSize.area());
+ for (int y = 0; y < kBaseSize.fHeight; ++y) {
+ for (int x = 0; x < kBaseSize.fWidth; ++x) {
+ srcPixels.get()[y*kBaseSize.fWidth+x] = SkPreMultiplyARGB(x, y, x, 0xFF);
}
}
SkBitmap bm;
bm.installPixels(ii, srcPixels.get(), kRowBytes);
- SkAutoTMalloc<uint32_t> read(kW * kH);
+ SkAutoTMalloc<uint32_t> read(kBaseSize.area());
// We allow more error on GPUs with lower precision shader variables.
float error = context->priv().caps()->shaderCaps()->halfIs32Bits() ? 0.5f : 1.2f;
@@ -141,7 +136,7 @@
dstCanvas->drawBitmap(bm, 0, 0, &gammaPaint);
dst->flush();
- sk_memset32(read.get(), 0, kW * kH);
+ sk_memset32(read.get(), 0, kBaseSize.fWidth * kBaseSize.fHeight);
if (!dst->readPixels(ii, read.get(), kRowBytes, 0, 0)) {
ERRORF(reporter, "Error calling readPixels");
continue;
@@ -149,10 +144,10 @@
bool abort = false;
// Validate that pixels were copied/transformed correctly.
- for (int y = 0; y < kH && !abort; ++y) {
- for (int x = 0; x < kW && !abort; ++x) {
- uint32_t r = read.get()[y * kW + x];
- uint32_t s = srcPixels.get()[y * kW + x];
+ for (int y = 0; y < kBaseSize.fHeight && !abort; ++y) {
+ for (int x = 0; x < kBaseSize.fWidth && !abort; ++x) {
+ uint32_t r = read.get()[y * kBaseSize.fWidth + x];
+ uint32_t s = srcPixels.get()[y * kBaseSize.fWidth + x];
uint32_t expected;
if (!check_gamma(s, r, toSRGB, error, &expected)) {
ERRORF(reporter, "Expected dst %d,%d to contain 0x%08x "
diff --git a/tests/BlendTest.cpp b/tests/BlendTest.cpp
index d77c22f..c75eddf 100644
--- a/tests/BlendTest.cpp
+++ b/tests/BlendTest.cpp
@@ -88,18 +88,15 @@
namespace {
static sk_sp<SkSurface> create_gpu_surface_backend_texture_as_render_target(
- GrContext* context, int sampleCnt, int width, int height, SkColorType colorType,
+ GrContext* context, int sampleCnt, SkISize dimensions, SkColorType colorType,
GrSurfaceOrigin origin, sk_sp<GrTexture>* backingSurface) {
- GrSurfaceDesc backingDesc;
- backingDesc.fWidth = width;
- backingDesc.fHeight = height;
auto ct = SkColorTypeToGrColorType(colorType);
auto format = context->priv().caps()->getDefaultBackendFormat(ct, GrRenderable::kYes);
auto resourceProvider = context->priv().resourceProvider();
*backingSurface =
- resourceProvider->createTexture(backingDesc, format, GrRenderable::kYes, sampleCnt,
+ resourceProvider->createTexture(dimensions, format, GrRenderable::kYes, sampleCnt,
GrMipMapped::kNo, SkBudgeted::kNo, GrProtected::kNo);
if (!(*backingSurface)) {
return nullptr;
@@ -118,8 +115,7 @@
// Tests blending to a surface with no texture available.
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ES2BlendWithNoTexture, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
- const int kWidth = 10;
- const int kHeight = 10;
+ static constexpr SkISize kDimensions{10, 10};
const SkColorType kColorType = kRGBA_8888_SkColorType;
// Build our test cases:
@@ -162,7 +158,7 @@
sk_sp<GrTexture> backingSurface;
// BGRA forces a framebuffer blit on ES2.
sk_sp<SkSurface> surface = create_gpu_surface_backend_texture_as_render_target(
- context, sampleCnt, kWidth, kHeight, kColorType, origin, &backingSurface);
+ context, sampleCnt, kDimensions, kColorType, origin, &backingSurface);
if (!surface && sampleCnt > 1) {
// Some platforms don't support MSAA.
@@ -175,7 +171,7 @@
canvas->clipRect(testCase.fClip, false);
SkPaint black_paint;
black_paint.setColor(SkColorSetRGB(0xFF, 0xFF, 0x80));
- canvas->drawRect(SkRect::MakeXYWH(0, 0, kWidth, kHeight), black_paint);
+ canvas->drawRect(SkRect::Make(kDimensions), black_paint);
// Blend 2x2 pixels at 5,5 with 0x80FFFF. Use multiply blend mode as this will trigger
// a copy of the destination.
@@ -186,8 +182,8 @@
// Read the result into a bitmap.
SkBitmap bitmap;
- REPORTER_ASSERT(reporter, bitmap.tryAllocPixels(SkImageInfo::Make(
- kWidth, kHeight, kColorType, kPremul_SkAlphaType)));
+ REPORTER_ASSERT(reporter, bitmap.tryAllocPixels(SkImageInfo::Make(kDimensions, kColorType,
+ kPremul_SkAlphaType)));
REPORTER_ASSERT(
reporter,
surface->readPixels(bitmap.info(), bitmap.getPixels(), bitmap.rowBytes(), 0, 0));
diff --git a/tests/BulkRectTest.cpp b/tests/BulkRectTest.cpp
index edfd53f..fb8ae627 100644
--- a/tests/BulkRectTest.cpp
+++ b/tests/BulkRectTest.cpp
@@ -18,9 +18,7 @@
}
sk_sp<GrSurfaceProxy> create_proxy(GrContext* context) {
- GrSurfaceDesc desc;
- desc.fWidth = 128;
- desc.fHeight = 128;
+ static constexpr SkISize kDimensions = {128, 128};
const GrBackendFormat format = context->priv().caps()->getDefaultBackendFormat(
GrColorType::kRGBA_8888,
@@ -28,8 +26,9 @@
GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(format, GrColorType::kRGBA_8888);
return context->priv().proxyProvider()->createProxy(
- format, desc, swizzle, GrRenderable::kYes, 1, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo,
- SkBackingFit::kExact, SkBudgeted::kNo, GrProtected::kNo, GrInternalSurfaceFlags::kNone);
+ format, kDimensions, swizzle, GrRenderable::kYes, 1, kTopLeft_GrSurfaceOrigin,
+ GrMipMapped::kNo, SkBackingFit::kExact, SkBudgeted::kNo, GrProtected::kNo,
+ GrInternalSurfaceFlags::kNone);
}
typedef GrQuadAAFlags (*PerQuadAAFunc)(int i);
diff --git a/tests/DetermineDomainModeTest.cpp b/tests/DetermineDomainModeTest.cpp
index d1b1cd8..d59258d 100644
--- a/tests/DetermineDomainModeTest.cpp
+++ b/tests/DetermineDomainModeTest.cpp
@@ -130,10 +130,6 @@
int size = isPowerOfTwo ? 128 : 100;
SkBackingFit fit = isExact ? SkBackingFit::kExact : SkBackingFit::kApprox;
- GrSurfaceDesc desc;
- desc.fWidth = size;
- desc.fHeight = size;
-
GrBackendFormat format = caps->getDefaultBackendFormat(GrColorType::kRGBA_8888,
GrRenderable::kNo);
@@ -149,7 +145,7 @@
GrSwizzle swizzle = caps->getReadSwizzle(format, GrColorType::kRGBA_8888);
- return proxyProvider->createProxy(format, desc, swizzle, GrRenderable::kNo, 1,
+ return proxyProvider->createProxy(format, {size, size}, swizzle, GrRenderable::kNo, 1,
kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, fit,
SkBudgeted::kYes, GrProtected::kNo);
}
diff --git a/tests/GrMipMappedTest.cpp b/tests/GrMipMappedTest.cpp
index 8d15582..3ba8ba0 100644
--- a/tests/GrMipMappedTest.cpp
+++ b/tests/GrMipMappedTest.cpp
@@ -349,12 +349,9 @@
static std::unique_ptr<GrRenderTargetContext> draw_mipmap_into_new_render_target(
GrRecordingContext* context, GrProxyProvider* proxyProvider, GrColorType colorType,
SkAlphaType alphaType, GrSurfaceProxyView mipmapView, GrSamplerState::Filter filter) {
- GrSurfaceDesc desc;
- desc.fWidth = 1;
- desc.fHeight = 1;
sk_sp<GrSurfaceProxy> renderTarget = proxyProvider->createProxy(
- mipmapView.proxy()->backendFormat(), desc, mipmapView.swizzle(), GrRenderable::kYes, 1,
- mipmapView.origin(), GrMipMapped::kNo, SkBackingFit::kApprox, SkBudgeted::kYes,
+ mipmapView.proxy()->backendFormat(), {1, 1}, mipmapView.swizzle(), GrRenderable::kYes,
+ 1, mipmapView.origin(), GrMipMapped::kNo, SkBackingFit::kApprox, SkBudgeted::kYes,
GrProtected::kNo);
auto rtc = GrRenderTargetContext::Make(
@@ -396,14 +393,11 @@
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
// Create a mipmapped render target.
- GrSurfaceDesc desc;
- desc.fWidth = 4;
- desc.fHeight = 4;
GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(format, colorType);
sk_sp<GrTextureProxy> mipmapProxy = proxyProvider->createProxy(
- format, desc, swizzle, GrRenderable::kYes, 1, kTopLeft_GrSurfaceOrigin,
+ format, {4, 4}, swizzle, GrRenderable::kYes, 1, kTopLeft_GrSurfaceOrigin,
GrMipMapped::kYes, SkBackingFit::kExact, SkBudgeted::kYes, GrProtected::kNo);
// Mark the mipmaps clean to ensure things still work properly when they won't be marked
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index 985f38f..9361ef1 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -29,13 +29,11 @@
GrContext* context = ctxInfo.grContext();
auto resourceProvider = context->priv().resourceProvider();
- GrSurfaceDesc desc;
- desc.fWidth = 256;
- desc.fHeight = 256;
+ static constexpr SkISize kDesc = {256, 256};
auto format = context->priv().caps()->getDefaultBackendFormat(GrColorType::kRGBA_8888,
GrRenderable::kYes);
sk_sp<GrSurface> texRT1 =
- resourceProvider->createTexture(desc, format, GrRenderable::kYes, 1, GrMipMapped::kNo,
+ resourceProvider->createTexture(kDesc, format, GrRenderable::kYes, 1, GrMipMapped::kNo,
SkBudgeted::kNo, GrProtected::kNo);
REPORTER_ASSERT(reporter, texRT1.get() == texRT1->asRenderTarget());
@@ -48,7 +46,7 @@
static_cast<GrSurface*>(texRT1->asTexture()));
sk_sp<GrTexture> tex1 =
- resourceProvider->createTexture(desc, format, GrRenderable::kNo, 1, GrMipMapped::kNo,
+ resourceProvider->createTexture(kDesc, format, GrRenderable::kNo, 1, GrMipMapped::kNo,
SkBudgeted::kNo, GrProtected::kNo);
REPORTER_ASSERT(reporter, nullptr == tex1->asRenderTarget());
REPORTER_ASSERT(reporter, tex1.get() == tex1->asTexture());
@@ -99,16 +97,12 @@
return rp->createCompressedTexture(dimensions, format, SkBudgeted::kNo,
GrMipMapped::kNo, GrProtected::kNo, data.get());
} else {
- GrSurfaceDesc desc;
- desc.fWidth = dimensions.width();
- desc.fHeight = dimensions.height();
- return rp->createTexture(desc, format, renderable, 1, GrMipMapped::kNo, SkBudgeted::kNo,
- GrProtected::kNo);
+ return rp->createTexture(dimensions, format, renderable, 1, GrMipMapped::kNo,
+ SkBudgeted::kNo, GrProtected::kNo);
}
};
- static constexpr int kW = 64;
- static constexpr int kH = 64;
+ static constexpr SkISize kDims = {64, 64};
const std::vector<GrCaps::TestFormatColorTypeCombination>& combos =
caps->getTestingCombinations();
@@ -126,9 +120,6 @@
}
for (GrSurfaceOrigin origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) {
- GrSurfaceDesc desc;
- desc.fWidth = kW;
- desc.fHeight = kH;
// Check if 'isFormatTexturable' agrees with 'createTexture' and that the mipmap
// support check is working
@@ -143,7 +134,7 @@
combo.fFormat);
}
- sk_sp<GrSurface> tex = createTexture({kW, kH}, combo.fColorType, combo.fFormat,
+ sk_sp<GrSurface> tex = createTexture(kDims, combo.fColorType, combo.fFormat,
GrRenderable::kNo, resourceProvider);
REPORTER_ASSERT(reporter, SkToBool(tex) == isTexturable,
"ct:%s format:%s, tex:%d, isTexturable:%d",
@@ -159,7 +150,7 @@
GrSwizzle swizzle = caps->getReadSwizzle(combo.fFormat, combo.fColorType);
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
- combo.fFormat, desc, swizzle, GrRenderable::kNo, 1, origin,
+ combo.fFormat, kDims, swizzle, GrRenderable::kNo, 1, origin,
GrMipMapped::kYes, SkBackingFit::kExact, SkBudgeted::kNo, GrProtected::kNo);
REPORTER_ASSERT(reporter, SkToBool(proxy.get()) == expectedMipMapability,
"ct:%s format:%s, tex:%d, expectedMipMapability:%d",
@@ -173,7 +164,7 @@
bool isRenderable = caps->isFormatRenderable(combo.fFormat, 1);
sk_sp<GrSurface> tex = resourceProvider->createTexture(
- desc, combo.fFormat, GrRenderable::kYes, 1, GrMipMapped::kNo,
+ kDims, combo.fFormat, GrRenderable::kYes, 1, GrMipMapped::kNo,
SkBudgeted::kNo, GrProtected::kNo);
REPORTER_ASSERT(reporter, SkToBool(tex) == isRenderable,
"ct:%s format:%s, tex:%d, isRenderable:%d",
@@ -187,7 +178,7 @@
bool isRenderable = caps->isFormatRenderable(combo.fFormat, 2);
sk_sp<GrSurface> tex = resourceProvider->createTexture(
- desc, combo.fFormat, GrRenderable::kYes, 2, GrMipMapped::kNo,
+ kDims, combo.fFormat, GrRenderable::kYes, 2, GrMipMapped::kNo,
SkBudgeted::kNo, GrProtected::kNo);
REPORTER_ASSERT(reporter, SkToBool(tex) == isRenderable,
"ct:%s format:%s, tex:%d, isRenderable:%d",
@@ -217,7 +208,7 @@
SkAutoPixmapStorage readback;
readback.alloc(info);
- GrSurfaceDesc desc;
+ SkISize desc;
desc.fWidth = desc.fHeight = kSize;
for (int ct = 0; ct < sk_gpu_test::GrContextFactory::kContextTypeCnt; ++ct) {
@@ -491,7 +482,7 @@
}
static sk_sp<GrTexture> make_normal_texture(GrContext* context, GrRenderable renderable) {
- GrSurfaceDesc desc;
+ SkISize desc;
desc.fWidth = desc.fHeight = kSurfSize;
auto format =
context->priv().caps()->getDefaultBackendFormat(GrColorType::kRGBA_8888, renderable);
@@ -582,7 +573,7 @@
}
return GrSurfaceProxy::LazyCallbackResult{std::move(texture), true, mode};
};
- GrSurfaceDesc desc;
+ SkISize desc;
desc.fWidth = w;
desc.fHeight = h;
SkBudgeted budgeted;
diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp
index aac72c8..341286e 100644
--- a/tests/LazyProxyTest.cpp
+++ b/tests/LazyProxyTest.cpp
@@ -92,11 +92,9 @@
if (nullTexture) {
return {};
} else {
- GrSurfaceDesc desc;
- desc.fWidth = 1234;
- desc.fHeight = 567;
+ static constexpr SkISize kDimensions = {1234, 567};
sk_sp<GrTexture> texture = rp->createTexture(
- desc, format, GrRenderable::kNo, 1, GrMipMapped::kNo,
+ kDimensions, format, GrRenderable::kNo, 1, GrMipMapped::kNo,
SkBudgeted::kYes, GrProtected::kNo);
REPORTER_ASSERT(fTest->fReporter, texture);
return texture;
@@ -231,16 +229,12 @@
auto proxyProvider = ctx->priv().proxyProvider();
const GrCaps* caps = ctx->priv().caps();
- GrSurfaceDesc desc;
- desc.fWidth = kSize;
- desc.fHeight = kSize;
-
GrBackendFormat format = caps->getDefaultBackendFormat(GrColorType::kRGBA_8888,
GrRenderable::kNo);
- auto tex = ctx->priv().resourceProvider()->createTexture(desc, format, GrRenderable::kNo, 1,
- GrMipMapped::kNo, SkBudgeted::kNo,
- GrProtected::kNo);
+ auto tex = ctx->priv().resourceProvider()->createTexture({kSize, kSize}, format,
+ GrRenderable::kNo, 1, GrMipMapped::kNo,
+ SkBudgeted::kNo, GrProtected::kNo);
using LazyInstantiationResult = GrSurfaceProxy::LazyCallbackResult;
for (bool doInstantiate : {true, false}) {
for (bool releaseCallback : {false, true}) {
@@ -280,8 +274,8 @@
};
GrSwizzle readSwizzle = caps->getReadSwizzle(format, GrColorType::kRGBA_8888);
sk_sp<GrTextureProxy> proxy = proxyProvider->createLazyProxy(
- TestCallback(&testCount, releaseCallback, tex), format, desc, readSwizzle,
- GrRenderable::kNo, 1, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo,
+ TestCallback(&testCount, releaseCallback, tex), format, {kSize, kSize},
+ readSwizzle, GrRenderable::kNo, 1, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo,
GrMipMapsStatus::kNotAllocated, GrInternalSurfaceFlags::kNone,
SkBackingFit::kExact, SkBudgeted::kNo, GrProtected::kNo,
GrSurfaceProxy::UseAllocator::kYes);
@@ -334,7 +328,7 @@
int* testExecuteValue, bool shouldFailInstantiation)
: INHERITED(ClassID())
, fTestExecuteValue(testExecuteValue) {
- GrSurfaceDesc desc;
+ SkISize desc;
desc.fWidth = kSize;
desc.fHeight = kSize;
GrBackendFormat format =
diff --git a/tests/MtlCopySurfaceTest.mm b/tests/MtlCopySurfaceTest.mm
index d20c770..9a716f1 100644
--- a/tests/MtlCopySurfaceTest.mm
+++ b/tests/MtlCopySurfaceTest.mm
@@ -59,14 +59,11 @@
}
// Try direct copy via GPU (should fail)
- GrSurfaceDesc desc;
- desc.fWidth = kWidth;
- desc.fHeight = kHeight;
GrBackendFormat backendFormat = GrBackendFormat::MakeMtl(drawable.texture.pixelFormat);
GrSurface* src = srcProxy->peekSurface();
- sk_sp<GrTexture> dst = gpu->createTexture(desc, backendFormat, GrRenderable::kNo,
- 1, GrMipMapped::kNo, SkBudgeted::kNo,
- GrProtected::kNo);
+ sk_sp<GrTexture> dst =
+ gpu->createTexture({kWidth, kHeight}, backendFormat, GrRenderable::kNo, 1,
+ GrMipMapped::kNo, SkBudgeted::kNo, GrProtected::kNo);
bool result = gpu->copySurface(dst.get(), src, SkIRect::MakeXYWH(0, 0, kWidth, kHeight),
SkIPoint::Make(0, 0));
diff --git a/tests/OnFlushCallbackTest.cpp b/tests/OnFlushCallbackTest.cpp
index e38f5a6..124f221 100644
--- a/tests/OnFlushCallbackTest.cpp
+++ b/tests/OnFlushCallbackTest.cpp
@@ -315,13 +315,13 @@
fAtlasProxy = GrProxyProvider::MakeFullyLazyProxy(
[format](GrResourceProvider* resourceProvider)
-> GrSurfaceProxy::LazyCallbackResult {
- GrSurfaceDesc desc;
+ SkISize dims;
// TODO: until partial flushes in MDB lands we're stuck having
// all 9 atlas draws occur
- desc.fWidth = 9 /*this->numOps()*/ * kAtlasTileSize;
- desc.fHeight = kAtlasTileSize;
+ dims.fWidth = 9 /*this->numOps()*/ * kAtlasTileSize;
+ dims.fHeight = kAtlasTileSize;
- return resourceProvider->createTexture(desc, format, GrRenderable::kYes, 1,
+ return resourceProvider->createTexture(dims, format, GrRenderable::kYes, 1,
GrMipMapped::kNo, SkBudgeted::kYes,
GrProtected::kNo);
},
@@ -501,12 +501,11 @@
save_bm(bm, "atlas-fake.png");
#endif
- GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bm.info());
desc.fFlags |= kRenderTarget_GrSurfaceFlag;
sk_sp<GrSurfaceProxy> tmp = GrSurfaceProxy::MakeDeferred(*context->caps(),
context->textureProvider(),
- desc, SkBudgeted::kYes,
+ dm.dimensions(), SkBudgeted::kYes,
bm.getPixels(), bm.rowBytes());
return sk_ref_sp(tmp->asTextureProxy());
diff --git a/tests/OpChainTest.cpp b/tests/OpChainTest.cpp
index b02d3ef..dcce574 100644
--- a/tests/OpChainTest.cpp
+++ b/tests/OpChainTest.cpp
@@ -166,9 +166,7 @@
DEF_GPUTEST(OpChainTest, reporter, /*ctxInfo*/) {
auto context = GrContext::MakeMock(nullptr);
SkASSERT(context);
- GrSurfaceDesc desc;
- desc.fWidth = kNumOps + 1;
- desc.fHeight = 1;
+ static constexpr SkISize kDims = {kNumOps + 1, 1};
const GrBackendFormat format =
context->priv().caps()->getDefaultBackendFormat(GrColorType::kRGBA_8888,
@@ -177,7 +175,7 @@
static const GrSurfaceOrigin kOrigin = kTopLeft_GrSurfaceOrigin;
auto proxy = context->priv().proxyProvider()->createProxy(
- format, desc, swizzle, GrRenderable::kYes, 1, kOrigin, GrMipMapped::kNo,
+ format, kDims, swizzle, GrRenderable::kYes, 1, kOrigin, GrMipMapped::kNo,
SkBackingFit::kExact, SkBudgeted::kNo, GrProtected::kNo, GrInternalSurfaceFlags::kNone);
SkASSERT(proxy);
proxy->instantiate(context->priv().resourceProvider());
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index 529eb1e..2b52fbb 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -149,9 +149,7 @@
GrContext* context = ctxInfo.grContext();
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
- GrSurfaceDesc desc;
- desc.fWidth = 10;
- desc.fHeight = 10;
+ static constexpr SkISize kDims = {10, 10};
const GrBackendFormat format =
context->priv().caps()->getDefaultBackendFormat(GrColorType::kRGBA_8888,
@@ -164,7 +162,7 @@
context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox, {1, 1});
{
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
- format, desc, swizzle, GrRenderable::kNo, 1, kTopLeft_GrSurfaceOrigin,
+ format, kDims, swizzle, GrRenderable::kNo, 1, kTopLeft_GrSurfaceOrigin,
GrMipMapped::kNo, SkBackingFit::kExact, SkBudgeted::kYes, GrProtected::kNo);
{
diff --git a/tests/ProgramsTest.cpp b/tests/ProgramsTest.cpp
index b979f31..e462407 100644
--- a/tests/ProgramsTest.cpp
+++ b/tests/ProgramsTest.cpp
@@ -262,36 +262,28 @@
// setup dummy textures
GrMipMapped mipMapped = GrMipMapped(context->priv().caps()->mipMapSupport());
{
- GrSurfaceDesc dummyDesc;
- dummyDesc.fWidth = 34;
- dummyDesc.fHeight = 18;
+ static constexpr SkISize kDummyDims = {34, 18};
const GrBackendFormat format =
context->priv().caps()->getDefaultBackendFormat(GrColorType::kRGBA_8888,
GrRenderable::kYes);
GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(format, GrColorType::kRGBA_8888);
- proxies[0] = {proxyProvider->createProxy(format, dummyDesc, swizzle, GrRenderable::kYes, 1,
+ proxies[0] = {proxyProvider->createProxy(format, kDummyDims, swizzle, GrRenderable::kYes, 1,
kBottomLeft_GrSurfaceOrigin, mipMapped,
SkBackingFit::kExact, SkBudgeted::kNo,
GrProtected::kNo, GrInternalSurfaceFlags::kNone),
- GrColorType::kRGBA_8888,
- kPremul_SkAlphaType
- };
+ GrColorType::kRGBA_8888, kPremul_SkAlphaType};
}
{
- GrSurfaceDesc dummyDesc;
- dummyDesc.fWidth = 16;
- dummyDesc.fHeight = 22;
+ static constexpr SkISize kDummyDims = {16, 22};
const GrBackendFormat format =
context->priv().caps()->getDefaultBackendFormat(GrColorType::kAlpha_8,
GrRenderable::kNo);
GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(format, GrColorType::kAlpha_8);
- proxies[1] = {proxyProvider->createProxy(format, dummyDesc, swizzle, GrRenderable::kNo, 1,
+ proxies[1] = {proxyProvider->createProxy(format, kDummyDims, swizzle, GrRenderable::kNo, 1,
kTopLeft_GrSurfaceOrigin, mipMapped,
SkBackingFit::kExact, SkBudgeted::kNo,
GrProtected::kNo, GrInternalSurfaceFlags::kNone),
- GrColorType::kAlpha_8,
- kPremul_SkAlphaType
- };
+ GrColorType::kAlpha_8, kPremul_SkAlphaType};
}
if (!std::get<0>(proxies[0]) || !std::get<0>(proxies[1])) {
diff --git a/tests/PromiseImageTest.cpp b/tests/PromiseImageTest.cpp
index 3e47b66..3728a49 100644
--- a/tests/PromiseImageTest.cpp
+++ b/tests/PromiseImageTest.cpp
@@ -420,12 +420,10 @@
ctx->setResourceCacheLimit(kMaxBytes);
SkTArray<sk_sp<GrTexture>> textures;
for (int i = 0; i < 5; ++i) {
- GrSurfaceDesc desc;
- desc.fWidth = desc.fHeight = 100;
auto format = ctx->priv().caps()->getDefaultBackendFormat(GrColorType::kRGBA_8888,
GrRenderable::kNo);
textures.emplace_back(ctx->priv().resourceProvider()->createTexture(
- desc, format, GrRenderable::kNo, 1, GrMipMapped::kNo, SkBudgeted::kYes,
+ {100, 100}, format, GrRenderable::kNo, 1, GrMipMapped::kNo, SkBudgeted::kYes,
GrProtected::kNo));
REPORTER_ASSERT(reporter, textures[i]);
}
diff --git a/tests/ProxyConversionTest.cpp b/tests/ProxyConversionTest.cpp
index aaf96ba..fb0fdfa 100644
--- a/tests/ProxyConversionTest.cpp
+++ b/tests/ProxyConversionTest.cpp
@@ -39,22 +39,22 @@
}
static sk_sp<GrSurfaceProxy> make_offscreen_rt(GrProxyProvider* provider,
- const SkISize& size,
+ SkISize dimensions,
GrColorType colorType,
GrSurfaceOrigin origin) {
- return provider->testingOnly_createInstantiatedProxy(size, colorType, GrRenderable::kYes, 1,
- origin, SkBackingFit::kExact,
+ return provider->testingOnly_createInstantiatedProxy(dimensions, colorType, GrRenderable::kYes,
+ 1, origin, SkBackingFit::kExact,
SkBudgeted::kYes, GrProtected::kNo);
}
static sk_sp<GrSurfaceProxy> make_texture(GrProxyProvider* provider,
- const SkISize& size,
+ SkISize dimensions,
GrColorType colorType,
GrRenderable renderable,
GrSurfaceOrigin origin) {
- return provider->testingOnly_createInstantiatedProxy(size, colorType, renderable, 1, origin,
- SkBackingFit::kExact, SkBudgeted::kYes,
- GrProtected::kNo);
+ return provider->testingOnly_createInstantiatedProxy(dimensions, colorType, renderable, 1,
+ origin, SkBackingFit::kExact,
+ SkBudgeted::kYes, GrProtected::kNo);
}
// Test converting between RenderTargetProxies and TextureProxies for preinstantiated Proxies
@@ -130,9 +130,7 @@
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
const GrCaps* caps = context->priv().caps();
- GrSurfaceDesc desc;
- desc.fWidth = 64;
- desc.fHeight = 64;
+ static constexpr SkISize kDims = {64, 64};
const GrBackendFormat format = caps->getDefaultBackendFormat(GrColorType::kRGBA_8888,
GrRenderable::kYes);
@@ -140,7 +138,7 @@
{
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
- format, desc, swizzle, GrRenderable::kYes, 1, kBottomLeft_GrSurfaceOrigin,
+ format, kDims, swizzle, GrRenderable::kYes, 1, kBottomLeft_GrSurfaceOrigin,
GrMipMapped::kNo, SkBackingFit::kApprox, SkBudgeted::kYes, GrProtected::kNo);
// Both RenderTarget and Texture
@@ -154,7 +152,7 @@
{
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
- format, desc, swizzle, GrRenderable::kYes, 1, kBottomLeft_GrSurfaceOrigin,
+ format, kDims, swizzle, GrRenderable::kYes, 1, kBottomLeft_GrSurfaceOrigin,
GrMipMapped::kNo, SkBackingFit::kApprox, SkBudgeted::kYes, GrProtected::kNo);
// Both RenderTarget and Texture - but via GrTextureProxy
@@ -168,7 +166,7 @@
{
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
- format, desc, swizzle, GrRenderable::kNo, 1, kTopLeft_GrSurfaceOrigin,
+ format, kDims, swizzle, GrRenderable::kNo, 1, kTopLeft_GrSurfaceOrigin,
GrMipMapped::kNo, SkBackingFit::kApprox, SkBudgeted::kYes, GrProtected::kNo);
// Texture-only
GrTextureProxy* tProxy = proxy->asTextureProxy();
diff --git a/tests/ProxyRefTest.cpp b/tests/ProxyRefTest.cpp
index aa6a8ea..4354378 100644
--- a/tests/ProxyRefTest.cpp
+++ b/tests/ProxyRefTest.cpp
@@ -24,16 +24,13 @@
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
const GrCaps* caps = context->priv().caps();
- GrSurfaceDesc desc;
- desc.fWidth = kWidthHeight;
- desc.fHeight = kWidthHeight;
-
const GrBackendFormat format = caps->getDefaultBackendFormat(GrColorType::kRGBA_8888,
GrRenderable::kYes);
GrSwizzle swizzle = caps->getReadSwizzle(format, GrColorType::kRGBA_8888);
- return proxyProvider->createProxy(format, desc, swizzle, GrRenderable::kYes, 1,
- kBottomLeft_GrSurfaceOrigin, GrMipMapped::kNo,
- SkBackingFit::kApprox, SkBudgeted::kYes, GrProtected::kNo);
+ return proxyProvider->createProxy(format, {kWidthHeight, kWidthHeight}, swizzle,
+ GrRenderable::kYes, 1, kBottomLeft_GrSurfaceOrigin,
+ GrMipMapped::kNo, SkBackingFit::kApprox, SkBudgeted::kYes,
+ GrProtected::kNo);
}
static sk_sp<GrTextureProxy> make_wrapped(GrContext* context) {
diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp
index 695f729..4d3e663 100644
--- a/tests/ProxyTest.cpp
+++ b/tests/ProxyTest.cpp
@@ -122,9 +122,7 @@
for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) {
for (auto numSamples : {1, 4, 16, 128}) {
- GrSurfaceDesc desc;
- desc.fWidth = widthHeight;
- desc.fHeight = widthHeight;
+ SkISize dims = {widthHeight, widthHeight};
auto format = caps.getDefaultBackendFormat(ct, GrRenderable::kYes);
if (!format.isValid()) {
@@ -137,16 +135,16 @@
sk_sp<GrTexture> tex;
if (SkBackingFit::kApprox == fit) {
tex = resourceProvider->createApproxTexture(
- desc, format, GrRenderable::kYes, numSamples,
+ dims, format, GrRenderable::kYes, numSamples,
GrProtected::kNo);
} else {
tex = resourceProvider->createTexture(
- desc, format, GrRenderable::kYes, numSamples,
+ dims, format, GrRenderable::kYes, numSamples,
GrMipMapped::kNo, budgeted, GrProtected::kNo);
}
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
- format, desc, swizzle, GrRenderable::kYes, numSamples,
+ format, dims, swizzle, GrRenderable::kYes, numSamples,
origin, GrMipMapped::kNo, fit, budgeted, GrProtected::kNo);
REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy));
if (proxy) {
@@ -174,16 +172,16 @@
sk_sp<GrTexture> tex;
if (SkBackingFit::kApprox == fit) {
tex = resourceProvider->createApproxTexture(
- desc, format, GrRenderable::kNo, numSamples,
+ dims, format, GrRenderable::kNo, numSamples,
GrProtected::kNo);
} else {
tex = resourceProvider->createTexture(
- desc, format, GrRenderable::kNo, numSamples,
+ dims, format, GrRenderable::kNo, numSamples,
GrMipMapped::kNo, budgeted, GrProtected::kNo);
}
sk_sp<GrTextureProxy> proxy(proxyProvider->createProxy(
- format, desc, swizzle, GrRenderable::kNo, numSamples,
+ format, dims, swizzle, GrRenderable::kNo, numSamples,
origin, GrMipMapped::kNo, fit, budgeted, GrProtected::kNo));
REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy));
if (proxy) {
@@ -370,10 +368,6 @@
continue; // not zero-sized
}
- GrSurfaceDesc desc;
- desc.fWidth = width;
- desc.fHeight = height;
-
const GrBackendFormat format =
context->priv().caps()->getDefaultBackendFormat(
GrColorType::kRGBA_8888,
@@ -381,9 +375,10 @@
GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(
format, GrColorType::kRGBA_8888);
- sk_sp<GrTextureProxy> proxy = provider->createProxy(
- format, desc, swizzle, renderable, 1, kBottomLeft_GrSurfaceOrigin,
- GrMipMapped::kNo, fit, SkBudgeted::kNo, GrProtected::kNo);
+ sk_sp<GrTextureProxy> proxy =
+ provider->createProxy(format, {width, height}, swizzle, renderable, 1,
+ kBottomLeft_GrSurfaceOrigin, GrMipMapped::kNo,
+ fit, SkBudgeted::kNo, GrProtected::kNo);
REPORTER_ASSERT(reporter, !proxy);
}
}
diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp
index 8b927f0..6435742 100644
--- a/tests/ReadWriteAlphaTest.cpp
+++ b/tests/ReadWriteAlphaTest.cpp
@@ -56,10 +56,6 @@
bool match;
static const size_t kRowBytes[] = {0, X_SIZE, X_SIZE + 1, 2 * X_SIZE - 1};
{
- GrSurfaceDesc desc;
- desc.fWidth = X_SIZE;
- desc.fHeight = Y_SIZE;
-
// We are initializing the texture with zeros here
memset(alphaData, 0, X_SIZE * Y_SIZE);
unsigned char alphaDataCopy[X_SIZE * Y_SIZE];
diff --git a/tests/ResourceAllocatorTest.cpp b/tests/ResourceAllocatorTest.cpp
index f0d0990..ef9039a 100644
--- a/tests/ResourceAllocatorTest.cpp
+++ b/tests/ResourceAllocatorTest.cpp
@@ -33,15 +33,12 @@
static sk_sp<GrSurfaceProxy> make_deferred(GrProxyProvider* proxyProvider, const GrCaps* caps,
const ProxyParams& p) {
- GrSurfaceDesc desc;
- desc.fWidth = p.fSize;
- desc.fHeight = p.fSize;
-
const GrBackendFormat format = caps->getDefaultBackendFormat(p.fColorType, p.fRenderable);
GrSwizzle swizzle = caps->getReadSwizzle(format, p.fColorType);
- return proxyProvider->createProxy(format, desc, swizzle, p.fRenderable, p.fSampleCnt, p.fOrigin,
- GrMipMapped::kNo, p.fFit, p.fBudgeted, GrProtected::kNo);
+ return proxyProvider->createProxy(format, {p.fSize, p.fSize}, swizzle, p.fRenderable,
+ p.fSampleCnt, p.fOrigin, GrMipMapped::kNo, p.fFit,
+ p.fBudgeted, GrProtected::kNo);
}
static sk_sp<GrSurfaceProxy> make_backend(GrContext* context, const ProxyParams& p,
@@ -265,18 +262,15 @@
const ProxyParams& p) {
const auto format = caps->getDefaultBackendFormat(p.fColorType, p.fRenderable);
- GrSurfaceDesc desc;
- desc.fWidth = p.fSize;
- desc.fHeight = p.fSize;
-
SkBackingFit fit = p.fFit;
- auto callback = [fit, desc, format, p](GrResourceProvider* resourceProvider) {
+ SkISize dims = {p.fSize, p.fSize};
+ auto callback = [fit, dims, format, p](GrResourceProvider* resourceProvider) {
sk_sp<GrTexture> texture;
if (fit == SkBackingFit::kApprox) {
- texture = resourceProvider->createApproxTexture(
- desc, format, p.fRenderable, p.fSampleCnt, GrProtected::kNo);
+ texture = resourceProvider->createApproxTexture(dims, format, p.fRenderable,
+ p.fSampleCnt, GrProtected::kNo);
} else {
- texture = resourceProvider->createTexture(desc, format, p.fRenderable, p.fSampleCnt,
+ texture = resourceProvider->createTexture(dims, format, p.fRenderable, p.fSampleCnt,
GrMipMapped::kNo, SkBudgeted::kNo,
GrProtected::kNo);
}
@@ -285,7 +279,7 @@
GrInternalSurfaceFlags flags = GrInternalSurfaceFlags::kNone;
GrSwizzle readSwizzle = caps->getReadSwizzle(format, p.fColorType);
return proxyProvider->createLazyProxy(
- callback, format, desc, readSwizzle, p.fRenderable, p.fSampleCnt, p.fOrigin,
+ callback, format, dims, readSwizzle, p.fRenderable, p.fSampleCnt, p.fOrigin,
GrMipMapped::kNo, GrMipMapsStatus::kNotAllocated, flags, p.fFit, p.fBudgeted,
GrProtected::kNo, GrSurfaceProxy::UseAllocator::kYes);
}
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index 8f79140..3eb5308 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -89,14 +89,11 @@
static sk_sp<GrRenderTarget> create_RT_with_SB(GrResourceProvider* provider,
int size, int sampleCount, SkBudgeted budgeted) {
- GrSurfaceDesc desc;
- desc.fWidth = size;
- desc.fHeight = size;
-
auto format =
provider->caps()->getDefaultBackendFormat(GrColorType::kRGBA_8888, GrRenderable::kYes);
- sk_sp<GrTexture> tex(provider->createTexture(desc, format, GrRenderable::kYes, sampleCount,
- GrMipMapped::kNo, budgeted, GrProtected::kNo));
+ sk_sp<GrTexture> tex(provider->createTexture({size, size}, format, GrRenderable::kYes,
+ sampleCount, GrMipMapped::kNo, budgeted,
+ GrProtected::kNo));
if (!tex || !tex->asRenderTarget()) {
return nullptr;
}
@@ -1610,26 +1607,20 @@
////////////////////////////////////////////////////////////////////////////////
static sk_sp<GrTexture> make_normal_texture(GrResourceProvider* provider,
GrRenderable renderable,
- int width, int height,
+ SkISize dims,
int sampleCnt) {
- GrSurfaceDesc desc;
- desc.fWidth = width;
- desc.fHeight = height;
auto format = provider->caps()->getDefaultBackendFormat(GrColorType::kRGBA_8888, renderable);
- return provider->createTexture(desc, format, renderable, sampleCnt, GrMipMapped::kNo,
+ return provider->createTexture(dims, format, renderable, sampleCnt, GrMipMapped::kNo,
SkBudgeted::kYes, GrProtected::kNo);
}
-static sk_sp<GrTextureProxy> make_mipmap_proxy(GrContext * context,
+static sk_sp<GrTextureProxy> make_mipmap_proxy(GrContext* context,
GrRenderable renderable,
- int width, int height,
+ SkISize dims,
int sampleCnt) {
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
const GrCaps* caps = context->priv().caps();
- GrSurfaceDesc desc;
- desc.fWidth = width;
- desc.fHeight = height;
const GrBackendFormat format = caps->getDefaultBackendFormat(GrColorType::kRGBA_8888,
GrRenderable::kNo);
@@ -1637,7 +1628,7 @@
: kTopLeft_GrSurfaceOrigin;
GrSwizzle swizzle = caps->getReadSwizzle(format, GrColorType::kRGBA_8888);
- return proxyProvider->createProxy(format, desc, swizzle, renderable, sampleCnt, origin,
+ return proxyProvider->createProxy(format, dims, swizzle, renderable, sampleCnt, origin,
GrMipMapped::kYes, SkBackingFit::kExact, SkBudgeted::kYes,
GrProtected::kNo);
}
@@ -1649,53 +1640,53 @@
GrResourceProvider* resourceProvider = context->priv().resourceProvider();
const GrCaps* caps = context->priv().caps();
- static const int kSize = 64;
+ static constexpr SkISize kSize = {64, 64};
+ static constexpr auto kArea = kSize.area();
// Normal versions
{
sk_sp<GrTexture> tex;
- tex = make_normal_texture(resourceProvider, GrRenderable::kYes, kSize, kSize, 1);
+ tex = make_normal_texture(resourceProvider, GrRenderable::kYes, kSize, 1);
size_t size = tex->gpuMemorySize();
- REPORTER_ASSERT(reporter, kSize*kSize*4 == size);
+ REPORTER_ASSERT(reporter, kArea*4 == size);
size_t sampleCount = (size_t)caps->getRenderTargetSampleCount(4, tex->backendFormat());
if (sampleCount >= 4) {
- tex = make_normal_texture(resourceProvider, GrRenderable::kYes, kSize, kSize,
- sampleCount);
+ tex = make_normal_texture(resourceProvider, GrRenderable::kYes, kSize, sampleCount);
size = tex->gpuMemorySize();
REPORTER_ASSERT(reporter,
- kSize*kSize*4 == size || // msaa4 failed
- kSize*kSize*4*sampleCount == size || // auto-resolving
- kSize*kSize*4*(sampleCount+1) == size); // explicit resolve buffer
+ kArea*4 == size || // msaa4 failed
+ kArea*4*sampleCount == size || // auto-resolving
+ kArea*4*(sampleCount+1) == size); // explicit resolve buffer
}
- tex = make_normal_texture(resourceProvider, GrRenderable::kNo, kSize, kSize, 1);
+ tex = make_normal_texture(resourceProvider, GrRenderable::kNo, kSize, 1);
size = tex->gpuMemorySize();
- REPORTER_ASSERT(reporter, kSize*kSize*4 == size);
+ REPORTER_ASSERT(reporter, kArea*4 == size);
}
// Mipmapped versions
if (caps->mipMapSupport()) {
sk_sp<GrTextureProxy> proxy;
- proxy = make_mipmap_proxy(context, GrRenderable::kYes, kSize, kSize, 1);
+ proxy = make_mipmap_proxy(context, GrRenderable::kYes, kSize, 1);
size_t size = proxy->gpuMemorySize(*caps);
- REPORTER_ASSERT(reporter, kSize*kSize*4+(kSize*kSize*4)/3 == size);
+ REPORTER_ASSERT(reporter, kArea*4 + (kArea*4)/3 == size);
size_t sampleCount = (size_t)caps->getRenderTargetSampleCount(4, proxy->backendFormat());
if (sampleCount >= 4) {
- proxy = make_mipmap_proxy(context, GrRenderable::kYes, kSize, kSize, sampleCount);
+ proxy = make_mipmap_proxy(context, GrRenderable::kYes, kSize, sampleCount);
size = proxy->gpuMemorySize(*caps);
REPORTER_ASSERT(reporter,
- kSize*kSize*4+(kSize*kSize*4)/3 == size || // msaa4 failed
- kSize*kSize*4*sampleCount+(kSize*kSize*4)/3 == size || // auto-resolving
- kSize*kSize*4*(sampleCount+1)+(kSize*kSize*4)/3 == size); // explicit resolve buffer
+ kArea*4 + (kArea*4)/3 == size || // msaa4 failed
+ kArea*4*sampleCount + (kArea*4)/3 == size || // auto-resolving
+ kArea*4*(sampleCount+1) + (kArea*4)/3 == size); // explicit resolve buffer
}
- proxy = make_mipmap_proxy(context, GrRenderable::kNo, kSize, kSize, 1);
+ proxy = make_mipmap_proxy(context, GrRenderable::kNo, kSize, 1);
size = proxy->gpuMemorySize(*caps);
- REPORTER_ASSERT(reporter, kSize*kSize*4+(kSize*kSize*4)/3 == size);
+ REPORTER_ASSERT(reporter, kArea*4 + (kArea*4)/3 == size);
}
}
diff --git a/tests/TextureBindingsResetTest.cpp b/tests/TextureBindingsResetTest.cpp
index 1c15026..4429948 100644
--- a/tests/TextureBindingsResetTest.cpp
+++ b/tests/TextureBindingsResetTest.cpp
@@ -73,10 +73,9 @@
context->resetContext();
// Test creating a texture and then resetting bindings.
- GrSurfaceDesc desc;
- desc.fWidth = desc.fHeight = 10;
+ static constexpr SkISize kDims = {10, 10};
auto format = gpu->caps()->getDefaultBackendFormat(GrColorType::kRGBA_8888, GrRenderable::kNo);
- auto tex = gpu->createTexture(desc, format, GrRenderable::kNo, 1, GrMipMapped::kNo,
+ auto tex = gpu->createTexture(kDims, format, GrRenderable::kNo, 1, GrMipMapped::kNo,
SkBudgeted::kNo, GrProtected::kNo);
REPORTER_ASSERT(reporter, tex);
context->resetGLTextureBindings();
diff --git a/tests/TextureProxyTest.cpp b/tests/TextureProxyTest.cpp
index 1818051..1a503eb 100644
--- a/tests/TextureProxyTest.cpp
+++ b/tests/TextureProxyTest.cpp
@@ -26,12 +26,6 @@
static constexpr auto kColorType = GrColorType::kRGBA_8888;
static constexpr auto kSize = SkISize::Make(64, 64);
-static GrSurfaceDesc make_desc() {
- GrSurfaceDesc desc;
- desc.fWidth = kSize.width();
- desc.fHeight = kSize.height();
- return desc;
-}
///////////////////////////////////////////////////////////////////////////////////////////////////
// Basic test
@@ -40,12 +34,11 @@
GrProxyProvider* proxyProvider, SkBackingFit fit) {
const GrCaps* caps = ctx->priv().caps();
- const GrSurfaceDesc desc = make_desc();
GrBackendFormat format = caps->getDefaultBackendFormat(kColorType, GrRenderable::kNo);
GrSwizzle swizzle = caps->getReadSwizzle(format, kColorType);
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
- format, desc, swizzle, GrRenderable::kNo, 1, kBottomLeft_GrSurfaceOrigin,
+ format, kSize, swizzle, GrRenderable::kNo, 1, kBottomLeft_GrSurfaceOrigin,
GrMipMapped::kNo, fit, SkBudgeted::kYes, GrProtected::kNo);
// Only budgeted & wrapped external proxies get to carry uniqueKeys
REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
@@ -56,13 +49,11 @@
GrProxyProvider* proxyProvider, SkBackingFit fit) {
const GrCaps* caps = ctx->priv().caps();
- const GrSurfaceDesc desc = make_desc();
-
GrBackendFormat format = caps->getDefaultBackendFormat(kColorType, GrRenderable::kYes);
GrSwizzle swizzle = caps->getReadSwizzle(format, kColorType);
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
- format, desc, swizzle, GrRenderable::kYes, 1, kBottomLeft_GrSurfaceOrigin,
+ format, kSize, swizzle, GrRenderable::kYes, 1, kBottomLeft_GrSurfaceOrigin,
GrMipMapped::kNo, fit, SkBudgeted::kYes, GrProtected::kNo);
// Only budgeted & wrapped external proxies get to carry uniqueKeys
REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
@@ -104,12 +95,11 @@
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
GrResourceProvider* resourceProvider = context->priv().resourceProvider();
- const GrSurfaceDesc desc = make_desc();
GrBackendFormat format =
proxyProvider->caps()->getDefaultBackendFormat(kColorType, GrRenderable::kYes);
*backingSurface =
- resourceProvider->createTexture(desc, format, GrRenderable::kNo, 1, GrMipMapped::kNo,
+ resourceProvider->createTexture(kSize, format, GrRenderable::kNo, 1, GrMipMapped::kNo,
SkBudgeted::kNo, GrProtected::kNo);
if (!(*backingSurface)) {
return nullptr;
diff --git a/tests/TransferPixelsTest.cpp b/tests/TransferPixelsTest.cpp
index e23b7ec..f49368e 100644
--- a/tests/TransferPixelsTest.cpp
+++ b/tests/TransferPixelsTest.cpp
@@ -109,18 +109,13 @@
auto resourceProvider = context->priv().resourceProvider();
GrGpu* gpu = context->priv().getGpu();
- const int kTextureWidth = 16;
- const int kTextureHeight = 16;
+ static constexpr SkISize kTexDims = {16, 16};
int srcBufferWidth = caps->writePixelsRowBytesSupport() ? 20 : 16;
const int kBufferHeight = 16;
- GrSurfaceDesc desc;
- desc.fWidth = kTextureWidth;
- desc.fHeight = kTextureHeight;
-
sk_sp<GrTexture> tex =
- resourceProvider->createTexture(desc, backendFormat, renderable, 1, GrMipMapped::kNo,
- SkBudgeted::kNo, GrProtected::kNo);
+ resourceProvider->createTexture(kTexDims, backendFormat, renderable, 1,
+ GrMipMapped::kNo, SkBudgeted::kNo, GrProtected::kNo);
if (!tex) {
ERRORF(reporter, "Could not create texture");
return;
@@ -145,10 +140,10 @@
GrCaps::SupportedWrite allowedSrc =
caps->supportedWritePixelsColorType(colorType, tex->backendFormat(), colorType);
size_t srcRowBytes = GrColorTypeBytesPerPixel(allowedSrc.fColorType) * srcBufferWidth;
- std::unique_ptr<char[]> srcData(new char[kTextureHeight * srcRowBytes]);
+ std::unique_ptr<char[]> srcData(new char[kTexDims.fHeight * srcRowBytes]);
- fill_transfer_data(0, 0, kTextureWidth, kTextureHeight, srcBufferWidth, allowedSrc.fColorType,
- srcData.get());
+ fill_transfer_data(0, 0, kTexDims.fWidth, kTexDims.fHeight, srcBufferWidth,
+ allowedSrc.fColorType, srcData.get());
// create and fill transfer buffer
size_t size = srcRowBytes * kBufferHeight;
@@ -169,12 +164,12 @@
// transfer full data
bool result;
- result = gpu->transferPixelsTo(tex.get(), 0, 0, kTextureWidth, kTextureHeight, colorType,
+ result = gpu->transferPixelsTo(tex.get(), 0, 0, kTexDims.fWidth, kTexDims.fHeight, colorType,
allowedSrc.fColorType, buffer.get(), 0, srcRowBytes);
REPORTER_ASSERT(reporter, result);
- size_t dstRowBytes = GrColorTypeBytesPerPixel(colorType) * kTextureWidth;
- std::unique_ptr<char[]> dstBuffer(new char[dstRowBytes * kTextureHeight]());
+ size_t dstRowBytes = GrColorTypeBytesPerPixel(colorType) * kTexDims.fWidth;
+ std::unique_ptr<char[]> dstBuffer(new char[dstRowBytes * kTexDims.fHeight]());
float compareTolerances[4] = {};
result = read_pixels_from_texture(tex.get(), colorType, dstBuffer.get(), compareTolerances);
@@ -258,8 +253,7 @@
auto resourceProvider = context->priv().resourceProvider();
GrGpu* gpu = context->priv().getGpu();
- const int kTextureWidth = 16;
- const int kTextureHeight = 16;
+ static constexpr SkISize kTexDims = {16, 16};
// We'll do a full texture read into the buffer followed by a partial read. These values
// describe the partial read subrect.
@@ -269,25 +263,22 @@
const int kPartialHeight = 2;
// create texture
- GrSurfaceDesc desc;
- desc.fWidth = kTextureWidth;
- desc.fHeight = kTextureHeight;
-
auto format = context->priv().caps()->getDefaultBackendFormat(colorType, renderable);
if (!format.isValid()) {
return;
}
size_t textureDataBpp = GrColorTypeBytesPerPixel(colorType);
- size_t textureDataRowBytes = kTextureWidth * textureDataBpp;
- std::unique_ptr<char[]> textureData(new char[kTextureHeight * textureDataRowBytes]);
- fill_transfer_data(0, 0, kTextureWidth, kTextureHeight, kTextureWidth, colorType,
+ size_t textureDataRowBytes = kTexDims.fWidth * textureDataBpp;
+ std::unique_ptr<char[]> textureData(new char[kTexDims.fHeight * textureDataRowBytes]);
+ fill_transfer_data(0, 0, kTexDims.fWidth, kTexDims.fHeight, kTexDims.fHeight, colorType,
textureData.get());
GrMipLevel data;
data.fPixels = textureData.get();
data.fRowBytes = textureDataRowBytes;
- sk_sp<GrTexture> tex = resourceProvider->createTexture(
- desc, format, colorType, renderable, 1, SkBudgeted::kNo, GrProtected::kNo, &data, 1);
+ sk_sp<GrTexture> tex =
+ resourceProvider->createTexture(kTexDims, format, colorType, renderable, 1,
+ SkBudgeted::kNo, GrProtected::kNo, &data, 1);
if (!tex) {
return;
}
@@ -306,16 +297,15 @@
// Create the transfer buffer.
auto allowedRead =
caps->supportedReadPixelsColorType(colorType, tex->backendFormat(), colorType);
- GrImageInfo readInfo(allowedRead.fColorType, kUnpremul_SkAlphaType, nullptr, kTextureWidth,
- kTextureHeight);
+ GrImageInfo readInfo(allowedRead.fColorType, kUnpremul_SkAlphaType, nullptr, kTexDims);
size_t bpp = GrColorTypeBytesPerPixel(allowedRead.fColorType);
- size_t fullBufferRowBytes = kTextureWidth * bpp;
+ size_t fullBufferRowBytes = kTexDims.fWidth * bpp;
size_t partialBufferRowBytes = kPartialWidth * bpp;
size_t offsetAlignment = allowedRead.fOffsetAlignmentForTransferBuffer;
SkASSERT(offsetAlignment);
- size_t bufferSize = fullBufferRowBytes * kTextureHeight;
+ size_t bufferSize = fullBufferRowBytes * kTexDims.fHeight;
// Arbitrary starting offset for the partial read.
size_t partialReadOffset = GrAlignTo(11, offsetAlignment);
bufferSize = std::max(bufferSize, partialReadOffset + partialBufferRowBytes * kPartialHeight);
@@ -332,8 +322,8 @@
//////////////////////////
// transfer full data
- bool result = gpu->transferPixelsFrom(tex.get(), 0, 0, kTextureWidth, kTextureHeight, colorType,
- allowedRead.fColorType, buffer.get(), 0);
+ bool result = gpu->transferPixelsFrom(tex.get(), 0, 0, kTexDims.fWidth, kTexDims.fHeight,
+ colorType, allowedRead.fColorType, buffer.get(), 0);
if (!result) {
ERRORF(reporter, "transferPixelsFrom failed.");
return;
@@ -354,12 +344,11 @@
ERRORF(reporter, "Failed to map transfer buffer.");
return;
}
- std::unique_ptr<char[]> transferData(new char[kTextureHeight * fullBufferRowBytes]);
- memcpy(transferData.get(), map, fullBufferRowBytes * kTextureHeight);
+ std::unique_ptr<char[]> transferData(new char[kTexDims.fHeight * fullBufferRowBytes]);
+ memcpy(transferData.get(), map, fullBufferRowBytes * kTexDims.fHeight);
buffer->unmap();
- GrImageInfo transferInfo(allowedRead.fColorType, kUnpremul_SkAlphaType, nullptr, kTextureWidth,
- kTextureHeight);
+ GrImageInfo transferInfo(allowedRead.fColorType, kUnpremul_SkAlphaType, nullptr, kTexDims);
float tol[4];
determine_tolerances(allowedRead.fColorType, colorType, tol);
@@ -369,8 +358,7 @@
"Error at (%d %d) in transfer, color type: %d, diffs: (%f, %f, %f, %f)", x,
y, colorType, diffs[0], diffs[1], diffs[2], diffs[3]);
});
- GrImageInfo textureDataInfo(colorType, kUnpremul_SkAlphaType, nullptr, kTextureWidth,
- kTextureHeight);
+ GrImageInfo textureDataInfo(colorType, kUnpremul_SkAlphaType, nullptr, kTexDims);
ComparePixels(textureDataInfo, textureData.get(), textureDataRowBytes, transferInfo,
transferData.get(), fullBufferRowBytes, tol, error);
@@ -397,7 +385,7 @@
return;
}
const char* bufferStart = reinterpret_cast<const char*>(map) + partialReadOffset;
- memcpy(transferData.get(), bufferStart, partialBufferRowBytes * kTextureHeight);
+ memcpy(transferData.get(), bufferStart, partialBufferRowBytes * kTexDims.fHeight);
buffer->unmap();
transferInfo = transferInfo.makeWH(kPartialWidth, kPartialHeight);
diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp
index f019724..c11bd69 100644
--- a/tests/WritePixelsTest.cpp
+++ b/tests/WritePixelsTest.cpp
@@ -523,9 +523,7 @@
{
// Seed the resource cached with a scratch texture that will be reused by writePixels
- GrSurfaceDesc desc;
- desc.fWidth = 32;
- desc.fHeight = 64;
+ static constexpr SkISize kDims = {32, 64};
const GrBackendFormat format = caps->getDefaultBackendFormat(GrColorType::kRGBA_8888,
GrRenderable::kNo);
@@ -533,7 +531,7 @@
GrSwizzle swizzle = caps->getReadSwizzle(format, GrColorType::kRGBA_8888);
sk_sp<GrTextureProxy> temp = proxyProvider->createProxy(
- format, desc, swizzle, GrRenderable::kNo, 1, kTopLeft_GrSurfaceOrigin,
+ format, kDims, swizzle, GrRenderable::kNo, 1, kTopLeft_GrSurfaceOrigin,
GrMipMapped::kNo, SkBackingFit::kApprox, SkBudgeted::kYes, GrProtected::kNo);
temp->instantiate(context->priv().resourceProvider());
}
diff --git a/tools/fiddle/fiddle_main.cpp b/tools/fiddle/fiddle_main.cpp
index 98fd723..0015512 100644
--- a/tools/fiddle/fiddle_main.cpp
+++ b/tools/fiddle/fiddle_main.cpp
@@ -127,9 +127,6 @@
auto resourceProvider = context->priv().resourceProvider();
- GrSurfaceDesc backingDesc;
- backingDesc.fWidth = bm.width();
- backingDesc.fHeight = bm.height();
// This config must match the SkColorType used in draw.cpp in the SkImage and Surface factories
auto format = resourceProvider->caps()->getDefaultBackendFormat(
SkColorTypeToGrColorType(kRGBA_8888_SkColorType), GrRenderable::kNo);
@@ -167,8 +164,8 @@
}
backingTexture = resourceProvider->createTexture(
- backingDesc, format, GrColorType::kRGBA_8888, GrRenderable::kNo, 1, SkBudgeted::kNo,
- GrProtected::kNo, texels.get(), mipLevelCount);
+ bm.dimensions(), format, GrColorType::kRGBA_8888, GrRenderable::kNo, 1,
+ SkBudgeted::kNo, GrProtected::kNo, texels.get(), mipLevelCount);
if (!backingTexture) {
return false;
}
@@ -179,21 +176,17 @@
}
}
- backingDesc.fWidth = options.fOffScreenWidth;
- backingDesc.fHeight = options.fOffScreenHeight;
-
- SkAutoTMalloc<uint32_t> data(backingDesc.fWidth * backingDesc.fHeight);
- sk_memset32(data.get(), 0, backingDesc.fWidth * backingDesc.fHeight);
-
+ SkAutoTMalloc<uint32_t> data(bm.dimensions().area());
+ sk_memset32(data.get(), 0, bm.dimensions().area());
{
// This backend object should be renderable but not textureable. Given the limitations
// of how we're creating it though it will wind up being secretly textureable.
// We use this fact to initialize it with data but don't allow mipmaps
- GrMipLevel level0 = { data.get(), backingDesc.fWidth*sizeof(uint32_t) };
+ GrMipLevel level0 = { data.get(), bm.width()*sizeof(uint32_t) };
sk_sp<GrTexture> tmp = resourceProvider->createTexture(
- backingDesc, renderableFormat, GrColorType::kRGBA_8888, GrRenderable::kYes,
+ bm.dimensions(), renderableFormat, GrColorType::kRGBA_8888, GrRenderable::kYes,
options.fOffScreenSampleCount, SkBudgeted::kNo, GrProtected::kNo, &level0, 1);
if (!tmp || !tmp->asRenderTarget()) {
return false;
@@ -209,12 +202,12 @@
{
int mipLevelCount = GrMipMapped::kYes == options.fOffScreenMipMapping
- ? SkMipMap::ComputeLevelCount(backingDesc.fWidth, backingDesc.fHeight)
- : 1;
+ ? SkMipMap::ComputeLevelCount(bm.width(), bm.height())
+ : 1;
std::unique_ptr<GrMipLevel[]> texels(new GrMipLevel[mipLevelCount]);
texels[0].fPixels = data.get();
- texels[0].fRowBytes = backingDesc.fWidth*sizeof(uint32_t);
+ texels[0].fRowBytes = bm.width()*sizeof(uint32_t);
for (int i = 1; i < mipLevelCount; i++) {
texels[i].fPixels = nullptr;
@@ -222,7 +215,7 @@
}
backingTextureRenderTarget = resourceProvider->createTexture(
- backingDesc, renderableFormat, GrColorType::kRGBA_8888, GrRenderable::kYes,
+ bm.dimensions(), renderableFormat, GrColorType::kRGBA_8888, GrRenderable::kYes,
options.fOffScreenSampleCount, SkBudgeted::kNo, GrProtected::kNo, texels.get(),
mipLevelCount);
if (!backingTextureRenderTarget || !backingTextureRenderTarget->asRenderTarget()) {
diff --git a/tools/gpu/ProxyUtils.cpp b/tools/gpu/ProxyUtils.cpp
index 9b6e1bc..1a72f82 100644
--- a/tools/gpu/ProxyUtils.cpp
+++ b/tools/gpu/ProxyUtils.cpp
@@ -37,13 +37,9 @@
GrSwizzle swizzle = caps->getReadSwizzle(format, imageInfo.colorType());
sk_sp<GrTextureProxy> proxy;
- GrSurfaceDesc desc;
- desc.fWidth = imageInfo.width();
- desc.fHeight = imageInfo.height();
- proxy = context->priv().proxyProvider()->createProxy(format, desc, swizzle, renderable, 1,
- origin, GrMipMapped::kNo,
- SkBackingFit::kExact, SkBudgeted::kYes,
- GrProtected::kNo);
+ proxy = context->priv().proxyProvider()->createProxy(
+ format, imageInfo.dimensions(), swizzle, renderable, 1, origin, GrMipMapped::kNo,
+ SkBackingFit::kExact, SkBudgeted::kYes, GrProtected::kNo);
if (!proxy) {
return nullptr;
}