Revert "Make rest of GrGpu::wrapBackend* methods take a GrColorType"
This reverts commit 9725638fb1aed02cd7e6b2945d0a42e620724f76.
Reason for revert: Chrome roll
Original change's description:
> Make rest of GrGpu::wrapBackend* methods take a GrColorType
>
> This CL is intended to further wean Ganesh off of using the GrBackendTexture's pixel config
>
> Bug: skia:6718
> Change-Id: I593c0c73922fb76045e379214e20adb1f17ea215
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/227780
> Commit-Queue: Robert Phillips <robertphillips@google.com>
> Reviewed-by: Greg Daniel <egdaniel@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
Change-Id: Id71acf1dec63c288a858fccd7109c84cf3cc6f0a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:6718
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/228337
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/include/gpu/GrBackendSurface.h b/include/gpu/GrBackendSurface.h
index e14aede..8573626 100644
--- a/include/gpu/GrBackendSurface.h
+++ b/include/gpu/GrBackendSurface.h
@@ -216,9 +216,10 @@
bool isSameTexture(const GrBackendTexture&);
#if GR_TEST_UTILS
- // We can remove the pixelConfig setter once we remove the GrPixelConfig from the
- // GrBackendTexture and plumb the GrPixelConfig manually throughout our code (or remove all use
+ // We can remove the pixelConfig getter and setter once we remove the GrPixelConfig from the
+ // GrBackendTexture and plumb the GrPixelconfig manually throughout our code (or remove all use
// of GrPixelConfig in general).
+ GrPixelConfig pixelConfig() const { return fConfig; }
void setPixelConfig(GrPixelConfig config) { fConfig = config; }
static bool TestingOnly_Equals(const GrBackendTexture& , const GrBackendTexture&);
@@ -370,9 +371,10 @@
#if GR_TEST_UTILS
- // We can remove the pixelConfig setter once we remove the pixel config from the
+ // We can remove the pixelConfig getter and setter once we remove the pixel config from the
// GrBackendRenderTarget and plumb the pixel config manually throughout our code (or remove all
// use of GrPixelConfig in general).
+ GrPixelConfig pixelConfig() const { return fConfig; }
void setPixelConfig(GrPixelConfig config) { fConfig = config; }
static bool TestingOnly_Equals(const GrBackendRenderTarget&, const GrBackendRenderTarget&);
diff --git a/include/gpu/mock/GrMockTypes.h b/include/gpu/mock/GrMockTypes.h
index 6060f95..ccdda50 100644
--- a/include/gpu/mock/GrMockTypes.h
+++ b/include/gpu/mock/GrMockTypes.h
@@ -61,8 +61,6 @@
GrBackendFormat getBackendFormat() const;
- GrColorType colorType() const { return fColorType; }
-
private:
GrColorType fColorType;
int fID;
diff --git a/include/private/GrTypesPriv.h b/include/private/GrTypesPriv.h
index 29c9cd9..3f899cc 100644
--- a/include/private/GrTypesPriv.h
+++ b/include/private/GrTypesPriv.h
@@ -18,7 +18,6 @@
#include "include/private/SkImageInfoPriv.h"
#include "include/private/SkWeakRefCnt.h"
-class GrBackendFormat;
class GrCaps;
// The old libstdc++ uses the draft name "monotonic_clock" rather than "steady_clock". This might
@@ -1190,12 +1189,6 @@
SkUNREACHABLE;
}
-// This is a temporary means of mapping an SkColorType and format to a
-// GrColorType::kRGBA_8888_SRGB. Once we have an SRGB SkColorType this can go away.
-GrColorType SkColorTypeAndFormatToGrColorType(const GrCaps* caps,
- SkColorType skCT,
- const GrBackendFormat& format);
-
static constexpr uint32_t GrColorTypeComponentFlags(GrColorType ct) {
switch (ct) {
case GrColorType::kUnknown: return 0;
diff --git a/src/gpu/GrAHardwareBufferImageGenerator.cpp b/src/gpu/GrAHardwareBufferImageGenerator.cpp
index e5a2b3b..9008436 100644
--- a/src/gpu/GrAHardwareBufferImageGenerator.cpp
+++ b/src/gpu/GrAHardwareBufferImageGenerator.cpp
@@ -95,9 +95,8 @@
fBufferFormat,
false);
- GrColorType grColorType = SkColorTypeToGrColorType(this->getInfo().colorType());
- GrPixelConfig pixelConfig = context->priv().caps()->getConfigFromBackendFormat(backendFormat,
- grColorType);
+ GrPixelConfig pixelConfig = context->priv().caps()->getConfigFromBackendFormat(
+ backendFormat, SkColorTypeToGrColorType(this->getInfo().colorType()));
if (pixelConfig == kUnknown_GrPixelConfig) {
return nullptr;
@@ -151,7 +150,7 @@
sk_sp<GrTextureProxy> texProxy = proxyProvider->createLazyProxy(
[direct, buffer = AutoAHBRelease(hardwareBuffer), width, height, pixelConfig,
- isProtectedContent, backendFormat, grColorType](GrResourceProvider* resourceProvider)
+ isProtectedContent, backendFormat](GrResourceProvider* resourceProvider)
-> GrSurfaceProxy::LazyInstantiationResult {
GrAHardwareBufferUtils::DeleteImageProc deleteImageProc = nullptr;
GrAHardwareBufferUtils::DeleteImageCtx deleteImageCtx = nullptr;
@@ -174,8 +173,7 @@
// is invoked. We know the owning SkIamge will send an invalidation message when the
// image is destroyed, so the texture will be removed at that time.
sk_sp<GrTexture> tex = resourceProvider->wrapBackendTexture(
- backendTex, grColorType, kBorrow_GrWrapOwnership, GrWrapCacheable::kYes,
- kRead_GrIOType);
+ backendTex, kBorrow_GrWrapOwnership, GrWrapCacheable::kYes, kRead_GrIOType);
if (!tex) {
deleteImageProc(deleteImageCtx);
return {};
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index 56e91a2..a62dfab 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -51,20 +51,15 @@
context->priv().getResourceCache()->insertDelayedResourceUnref(texture.get());
GrBackendTexture backendTexture = texture->getBackendTexture();
-
- // TODO: delete this block
- {
- GrBackendFormat backendFormat = backendTexture.getBackendFormat();
- if (!backendFormat.isValid()) {
- return nullptr;
- }
-
- backendTexture.fConfig = context->priv().caps()->getConfigFromBackendFormat(
- backendFormat,
- SkColorTypeToGrColorType(colorType));
- if (backendTexture.fConfig == kUnknown_GrPixelConfig) {
- return nullptr;
- }
+ GrBackendFormat backendFormat = backendTexture.getBackendFormat();
+ if (!backendFormat.isValid()) {
+ return nullptr;
+ }
+ backendTexture.fConfig =
+ context->priv().caps()->getConfigFromBackendFormat(backendFormat,
+ SkColorTypeToGrColorType(colorType));
+ if (backendTexture.fConfig == kUnknown_GrPixelConfig) {
+ return nullptr;
}
SkImageInfo info = SkImageInfo::Make(texture->width(), texture->height(), colorType, alphaType,
@@ -84,6 +79,7 @@
, fRefHelper(new RefHelper(texture, owningContextID))
, fSemaphore(std::move(semaphore))
, fBackendTexture(backendTex)
+ , fConfig(backendTex.config())
, fSurfaceOrigin(origin) {}
GrBackendTextureImageGenerator::~GrBackendTextureImageGenerator() {
@@ -114,7 +110,6 @@
}
auto proxyProvider = context->priv().proxyProvider();
- const GrCaps* caps = context->priv().caps();
fBorrowingMutex.acquire();
sk_sp<GrRefCntedCallback> releaseProcHelper;
@@ -146,32 +141,20 @@
SkASSERT(fRefHelper->fBorrowingContextID == context->priv().contextID());
-
- GrBackendFormat backendFormat = fBackendTexture.getBackendFormat();
- SkASSERT(backendFormat.isValid());
-
- GrColorType grColorType = SkColorTypeToGrColorType(info.colorType());
-
- GrPixelConfig config = caps->getConfigFromBackendFormat(backendFormat, grColorType);
- if (kUnknown_GrPixelConfig == config) {
- return nullptr;
- }
-
- SkASSERT(GrCaps::AreConfigsCompatible(fBackendTexture.config(),
- caps->getConfigFromBackendFormat(backendFormat,
- grColorType)));
-
GrSurfaceDesc desc;
desc.fWidth = fBackendTexture.width();
desc.fHeight = fBackendTexture.height();
- desc.fConfig = config;
+ desc.fConfig = fConfig;
GrMipMapped mipMapped = fBackendTexture.hasMipMaps() ? GrMipMapped::kYes : GrMipMapped::kNo;
+ GrBackendFormat format = fBackendTexture.getBackendFormat();
+ SkASSERT(format.isValid());
+
// Must make copies of member variables to capture in the lambda since this image generator may
// be deleted before we actually execute the lambda.
sk_sp<GrTextureProxy> proxy = proxyProvider->createLazyProxy(
[refHelper = fRefHelper, releaseProcHelper, semaphore = fSemaphore,
- backendTexture = fBackendTexture, grColorType](GrResourceProvider* resourceProvider)
+ backendTexture = fBackendTexture](GrResourceProvider* resourceProvider)
-> GrSurfaceProxy::LazyInstantiationResult {
if (semaphore) {
resourceProvider->priv().gpu()->waitSemaphore(semaphore);
@@ -197,8 +180,8 @@
// ever see the original texture, so this should be safe.
// We make the texture uncacheable so that the release proc is called ASAP.
tex = resourceProvider->wrapBackendTexture(
- backendTexture, grColorType, kBorrow_GrWrapOwnership,
- GrWrapCacheable::kNo, kRead_GrIOType);
+ backendTexture, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
+ kRead_GrIOType);
if (!tex) {
return {};
}
@@ -209,8 +192,9 @@
// unrelated to the whatever SkImage key may be assigned to the proxy.
return {std::move(tex), GrSurfaceProxy::LazyInstantiationKeyMode::kUnsynced};
},
- backendFormat, desc, GrRenderable::kNo, fSurfaceOrigin, mipMapped,
+ format, desc, GrRenderable::kNo, fSurfaceOrigin, mipMapped,
GrInternalSurfaceFlags::kReadOnly, SkBackingFit::kExact, SkBudgeted::kNo);
+
if (!proxy) {
return nullptr;
}
diff --git a/src/gpu/GrBackendTextureImageGenerator.h b/src/gpu/GrBackendTextureImageGenerator.h
index 8a82c5c..13616a3 100644
--- a/src/gpu/GrBackendTextureImageGenerator.h
+++ b/src/gpu/GrBackendTextureImageGenerator.h
@@ -80,6 +80,7 @@
sk_sp<GrSemaphore> fSemaphore;
GrBackendTexture fBackendTexture;
+ GrPixelConfig fConfig;
GrSurfaceOrigin fSurfaceOrigin;
typedef SkImageGenerator INHERITED;
diff --git a/src/gpu/GrCaps.h b/src/gpu/GrCaps.h
index 10f930f..5492663 100644
--- a/src/gpu/GrCaps.h
+++ b/src/gpu/GrCaps.h
@@ -396,8 +396,7 @@
* Special method only for YUVA images. Returns a config that matches the backend format or
* kUnknown if a config could not be determined.
*/
- virtual GrPixelConfig getYUVAConfigFromBackendFormat(const GrBackendFormat&) const = 0;
- virtual GrColorType getYUVAColorTypeFromBackendFormat(const GrBackendFormat&) const = 0;
+ virtual GrPixelConfig getYUVAConfigFromBackendFormat(const GrBackendFormat& format) const = 0;
/** These are used when creating a new texture internally. */
virtual GrBackendFormat getBackendFormatFromColorType(GrColorType ct) const = 0;
diff --git a/src/gpu/GrContextPriv.cpp b/src/gpu/GrContextPriv.cpp
index 721f02d..ad6d8ab 100644
--- a/src/gpu/GrContextPriv.cpp
+++ b/src/gpu/GrContextPriv.cpp
@@ -106,7 +106,7 @@
ASSERT_SINGLE_OWNER
sk_sp<GrSurfaceProxy> proxy = this->proxyProvider()->wrapBackendTexture(
- tex, colorType, origin, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kRW_GrIOType);
+ tex, origin, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kRW_GrIOType);
if (!proxy) {
return nullptr;
}
@@ -149,7 +149,7 @@
ASSERT_SINGLE_OWNER
sk_sp<GrSurfaceProxy> proxy = this->proxyProvider()->wrapBackendRenderTarget(
- backendRT, colorType, origin, releaseProc, releaseCtx);
+ backendRT, origin, releaseProc, releaseCtx);
if (!proxy) {
return nullptr;
}
@@ -168,8 +168,7 @@
ASSERT_SINGLE_OWNER
SkASSERT(sampleCnt > 0);
sk_sp<GrSurfaceProxy> proxy(
- this->proxyProvider()->wrapBackendTextureAsRenderTarget(tex, colorType,
- origin, sampleCnt));
+ this->proxyProvider()->wrapBackendTextureAsRenderTarget(tex, origin, sampleCnt));
if (!proxy) {
return nullptr;
}
diff --git a/src/gpu/GrDataUtils.cpp b/src/gpu/GrDataUtils.cpp
index 0bfb27d..0ac04f8 100644
--- a/src/gpu/GrDataUtils.cpp
+++ b/src/gpu/GrDataUtils.cpp
@@ -581,19 +581,3 @@
}
return true;
}
-
-
-GrColorType SkColorTypeAndFormatToGrColorType(const GrCaps* caps,
- SkColorType skCT,
- const GrBackendFormat& format) {
- GrColorType grCT = SkColorTypeToGrColorType(skCT);
- // Until we support SRGB in the SkColorType we have to do this manual check here to make sure
- // we use the correct GrColorType.
- if (caps->isFormatSRGB(format)) {
- if (grCT != GrColorType::kRGBA_8888) {
- return GrColorType::kUnknown;
- }
- grCT = GrColorType::kRGBA_8888_SRGB;
- }
- return grCT;
-}
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 6664ca1..ce2c840 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -221,29 +221,19 @@
}
sk_sp<GrTexture> GrGpu::wrapBackendTexture(const GrBackendTexture& backendTex,
- GrColorType colorType,
GrWrapOwnership ownership, GrWrapCacheable cacheable,
GrIOType ioType) {
SkASSERT(ioType != kWrite_GrIOType);
this->handleDirtyContext();
-
- const GrCaps* caps = this->caps();
- SkASSERT(caps);
-
- if (!caps->isFormatTexturable(colorType, backendTex.getBackendFormat())) {
+ SkASSERT(this->caps());
+ if (!this->caps()->isConfigTexturable(backendTex.config())) {
return nullptr;
}
- if (backendTex.width() > caps->maxTextureSize() ||
- backendTex.height() > caps->maxTextureSize()) {
+ if (backendTex.width() > this->caps()->maxTextureSize() ||
+ backendTex.height() > this->caps()->maxTextureSize()) {
return nullptr;
}
-
- SkASSERT(GrCaps::AreConfigsCompatible(backendTex.config(),
- caps->getConfigFromBackendFormat(
- backendTex.getBackendFormat(),
- colorType)));
-
- return this->onWrapBackendTexture(backendTex, colorType, ownership, cacheable, ioType);
+ return this->onWrapBackendTexture(backendTex, ownership, cacheable, ioType);
}
sk_sp<GrTexture> GrGpu::wrapRenderableBackendTexture(const GrBackendTexture& backendTex,
@@ -277,47 +267,25 @@
return tex;
}
-sk_sp<GrRenderTarget> GrGpu::wrapBackendRenderTarget(const GrBackendRenderTarget& backendRT,
- GrColorType colorType) {
- this->handleDirtyContext();
-
- const GrCaps* caps = this->caps();
-
- SkASSERT(GrCaps::AreConfigsCompatible(backendRT.config(),
- caps->getConfigFromBackendFormat(
- backendRT.getBackendFormat(),
- colorType)));
-
- if (0 == caps->getRenderTargetSampleCount(backendRT.sampleCnt(), colorType,
- backendRT.getBackendFormat())) {
+sk_sp<GrRenderTarget> GrGpu::wrapBackendRenderTarget(const GrBackendRenderTarget& backendRT) {
+ if (0 == this->caps()->getRenderTargetSampleCount(backendRT.sampleCnt(), backendRT.config())) {
return nullptr;
}
-
- return this->onWrapBackendRenderTarget(backendRT, colorType);
+ this->handleDirtyContext();
+ return this->onWrapBackendRenderTarget(backendRT);
}
-sk_sp<GrRenderTarget> GrGpu::wrapBackendTextureAsRenderTarget(const GrBackendTexture& backendTex,
- int sampleCnt,
- GrColorType colorType) {
+sk_sp<GrRenderTarget> GrGpu::wrapBackendTextureAsRenderTarget(const GrBackendTexture& tex,
+ int sampleCnt) {
+ if (0 == this->caps()->getRenderTargetSampleCount(sampleCnt, tex.config())) {
+ return nullptr;
+ }
+ int maxSize = this->caps()->maxTextureSize();
+ if (tex.width() > maxSize || tex.height() > maxSize) {
+ return nullptr;
+ }
this->handleDirtyContext();
-
- const GrCaps* caps = this->caps();
-
- int maxSize = caps->maxTextureSize();
- if (backendTex.width() > maxSize || backendTex.height() > maxSize) {
- return nullptr;
- }
-
- SkASSERT(GrCaps::AreConfigsCompatible(backendTex.config(),
- caps->getConfigFromBackendFormat(
- backendTex.getBackendFormat(),
- colorType)));
-
- if (0 == caps->getRenderTargetSampleCount(sampleCnt, colorType,
- backendTex.getBackendFormat())) {
- return nullptr;
- }
- return this->onWrapBackendTextureAsRenderTarget(backendTex, sampleCnt, colorType);
+ return this->onWrapBackendTextureAsRenderTarget(tex, sampleCnt);
}
sk_sp<GrRenderTarget> GrGpu::wrapVulkanSecondaryCBAsRenderTarget(const SkImageInfo& imageInfo,
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index 7d6b7ec..27a1941 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -118,8 +118,8 @@
/**
* Implements GrResourceProvider::wrapBackendTexture
*/
- sk_sp<GrTexture> wrapBackendTexture(const GrBackendTexture&, GrColorType,
- GrWrapOwnership, GrWrapCacheable, GrIOType);
+ sk_sp<GrTexture> wrapBackendTexture(const GrBackendTexture&, GrWrapOwnership, GrWrapCacheable,
+ GrIOType);
/**
* Implements GrResourceProvider::wrapRenderableBackendTexture
@@ -130,15 +130,13 @@
/**
* Implements GrResourceProvider::wrapBackendRenderTarget
*/
- sk_sp<GrRenderTarget> wrapBackendRenderTarget(const GrBackendRenderTarget&,
- GrColorType colorType);
+ sk_sp<GrRenderTarget> wrapBackendRenderTarget(const GrBackendRenderTarget&);
/**
* Implements GrResourceProvider::wrapBackendTextureAsRenderTarget
*/
sk_sp<GrRenderTarget> wrapBackendTextureAsRenderTarget(const GrBackendTexture&,
- int sampleCnt,
- GrColorType colorType);
+ int sampleCnt);
/**
* Implements GrResourceProvider::wrapVulkanSecondaryCBAsRenderTarget
@@ -534,16 +532,14 @@
virtual sk_sp<GrTexture> onCreateCompressedTexture(int width, int height,
SkImage::CompressionType, SkBudgeted,
const void* data) = 0;
- virtual sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrColorType,
- GrWrapOwnership, GrWrapCacheable, GrIOType) = 0;
+ virtual sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrWrapOwnership,
+ GrWrapCacheable, GrIOType) = 0;
virtual sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&, int sampleCnt,
GrColorType, GrWrapOwnership,
GrWrapCacheable) = 0;
- virtual sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&,
- GrColorType) = 0;
+ virtual sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&) = 0;
virtual sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTexture&,
- int sampleCnt,
- GrColorType) = 0;
+ int sampleCnt) = 0;
virtual sk_sp<GrRenderTarget> onWrapVulkanSecondaryCBAsRenderTarget(const SkImageInfo&,
const GrVkDrawableInfo&);
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index d4b811b..5e0fd0e 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -521,7 +521,6 @@
}
sk_sp<GrTextureProxy> GrProxyProvider::wrapBackendTexture(const GrBackendTexture& backendTex,
- GrColorType grColorType,
GrSurfaceOrigin origin,
GrWrapOwnership ownership,
GrWrapCacheable cacheable,
@@ -539,21 +538,13 @@
return nullptr;
}
- const GrCaps* caps = this->caps();
-
- SkASSERT(GrCaps::AreConfigsCompatible(backendTex.config(),
- caps->getConfigFromBackendFormat(
- backendTex.getBackendFormat(),
- grColorType)));
-
- SkASSERT(validate_backend_format_and_colortype(caps, grColorType,
- backendTex.getBackendFormat()));
+ SkASSERT(validate_backend_format_and_config(this->caps(), backendTex.getBackendFormat(),
+ backendTex.config()));
GrResourceProvider* resourceProvider = direct->priv().resourceProvider();
sk_sp<GrTexture> tex =
- resourceProvider->wrapBackendTexture(backendTex, grColorType,
- ownership, cacheable, ioType);
+ resourceProvider->wrapBackendTexture(backendTex, ownership, cacheable, ioType);
if (!tex) {
return nullptr;
}
@@ -566,7 +557,8 @@
// Make sure we match how we created the proxy with SkBudgeted::kNo
SkASSERT(GrBudgetedType::kBudgeted != tex->resourcePriv().budgetedType());
- GrSwizzle texSwizzle = caps->getTextureSwizzle(tex->backendFormat(), grColorType);
+ GrColorType colorType = GrPixelConfigToColorType(tex->config());
+ GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(tex->backendFormat(), colorType);
return sk_sp<GrTextureProxy>(new GrTextureProxy(std::move(tex), origin, texSwizzle));
}
@@ -624,8 +616,8 @@
}
sk_sp<GrSurfaceProxy> GrProxyProvider::wrapBackendRenderTarget(
- const GrBackendRenderTarget& backendRT, GrColorType grColorType,
- GrSurfaceOrigin origin, ReleaseProc releaseProc, ReleaseContext releaseCtx) {
+ const GrBackendRenderTarget& backendRT, GrSurfaceOrigin origin, ReleaseProc releaseProc,
+ ReleaseContext releaseCtx) {
if (this->isAbandoned()) {
return nullptr;
}
@@ -636,15 +628,16 @@
return nullptr;
}
+ GrColorType colorType = GrPixelConfigToColorType(backendRT.config());
#ifdef SK_DEBUG
GrPixelConfig testConfig =
- this->caps()->validateBackendRenderTarget(backendRT, grColorType);
+ this->caps()->validateBackendRenderTarget(backendRT, colorType);
SkASSERT(testConfig != kUnknown_GrPixelConfig);
#endif
GrResourceProvider* resourceProvider = direct->priv().resourceProvider();
- sk_sp<GrRenderTarget> rt = resourceProvider->wrapBackendRenderTarget(backendRT, grColorType);
+ sk_sp<GrRenderTarget> rt = resourceProvider->wrapBackendRenderTarget(backendRT);
if (!rt) {
return nullptr;
}
@@ -658,16 +651,15 @@
// Make sure we match how we created the proxy with SkBudgeted::kNo
SkASSERT(GrBudgetedType::kBudgeted != rt->resourcePriv().budgetedType());
- GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(rt->backendFormat(), grColorType);
- GrSwizzle outSwizzle = this->caps()->getOutputSwizzle(rt->backendFormat(), grColorType);
+ GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(rt->backendFormat(), colorType);
+ GrSwizzle outSwizzle = this->caps()->getOutputSwizzle(rt->backendFormat(), colorType);
return sk_sp<GrRenderTargetProxy>(new GrRenderTargetProxy(std::move(rt), origin, texSwizzle,
outSwizzle));
}
sk_sp<GrSurfaceProxy> GrProxyProvider::wrapBackendTextureAsRenderTarget(
- const GrBackendTexture& backendTex, GrColorType grColorType,
- GrSurfaceOrigin origin, int sampleCnt) {
+ const GrBackendTexture& backendTex, GrSurfaceOrigin origin, int sampleCnt) {
if (this->isAbandoned()) {
return nullptr;
}
@@ -678,20 +670,13 @@
return nullptr;
}
- const GrCaps* caps = this->caps();
-
- SkASSERT(GrCaps::AreConfigsCompatible(backendTex.config(),
- caps->getConfigFromBackendFormat(
- backendTex.getBackendFormat(),
- grColorType)));
-
- SkASSERT(validate_backend_format_and_colortype(caps, grColorType,
- backendTex.getBackendFormat()));
+ SkASSERT(validate_backend_format_and_config(this->caps(), backendTex.getBackendFormat(),
+ backendTex.config()));
GrResourceProvider* resourceProvider = direct->priv().resourceProvider();
sk_sp<GrRenderTarget> rt =
- resourceProvider->wrapBackendTextureAsRenderTarget(backendTex, sampleCnt, grColorType);
+ resourceProvider->wrapBackendTextureAsRenderTarget(backendTex, sampleCnt);
if (!rt) {
return nullptr;
}
@@ -700,8 +685,9 @@
// This proxy should be unbudgeted because we're just wrapping an external resource
SkASSERT(GrBudgetedType::kBudgeted != rt->resourcePriv().budgetedType());
- GrSwizzle texSwizzle = caps->getTextureSwizzle(rt->backendFormat(), grColorType);
- GrSwizzle outSwizzle = caps->getOutputSwizzle(rt->backendFormat(), grColorType);
+ GrColorType colorType = GrPixelConfigToColorType(rt->config());
+ GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(rt->backendFormat(), colorType);
+ GrSwizzle outSwizzle = this->caps()->getOutputSwizzle(rt->backendFormat(), colorType);
return sk_sp<GrSurfaceProxy>(new GrRenderTargetProxy(std::move(rt), origin, texSwizzle,
outSwizzle));
diff --git a/src/gpu/GrProxyProvider.h b/src/gpu/GrProxyProvider.h
index d216aab..a4b07f9 100644
--- a/src/gpu/GrProxyProvider.h
+++ b/src/gpu/GrProxyProvider.h
@@ -110,7 +110,7 @@
* Create a texture proxy that wraps a (non-renderable) backend texture. GrIOType must be
* kRead or kRW.
*/
- sk_sp<GrTextureProxy> wrapBackendTexture(const GrBackendTexture&, GrColorType, GrSurfaceOrigin,
+ sk_sp<GrTextureProxy> wrapBackendTexture(const GrBackendTexture&, GrSurfaceOrigin,
GrWrapOwnership, GrWrapCacheable, GrIOType,
ReleaseProc = nullptr, ReleaseContext = nullptr);
@@ -126,16 +126,14 @@
/*
* Create a render target proxy that wraps a backend render target
*/
- sk_sp<GrSurfaceProxy> wrapBackendRenderTarget(const GrBackendRenderTarget&, GrColorType,
- GrSurfaceOrigin,
+ sk_sp<GrSurfaceProxy> wrapBackendRenderTarget(const GrBackendRenderTarget&, GrSurfaceOrigin,
ReleaseProc = nullptr, ReleaseContext = nullptr);
/*
* Create a render target proxy that wraps a backend texture
*/
- sk_sp<GrSurfaceProxy> wrapBackendTextureAsRenderTarget(const GrBackendTexture&,
- GrColorType,
- GrSurfaceOrigin,
+ sk_sp<GrSurfaceProxy> wrapBackendTextureAsRenderTarget(const GrBackendTexture& backendTex,
+ GrSurfaceOrigin origin,
int sampleCnt);
sk_sp<GrRenderTargetProxy> wrapVulkanSecondaryCBAsRenderTarget(const SkImageInfo&,
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index b80f9f1..d49721c 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -334,7 +334,6 @@
}
sk_sp<GrTexture> GrResourceProvider::wrapBackendTexture(const GrBackendTexture& tex,
- GrColorType colorType,
GrWrapOwnership ownership,
GrWrapCacheable cacheable,
GrIOType ioType) {
@@ -342,7 +341,7 @@
if (this->isAbandoned()) {
return nullptr;
}
- return fGpu->wrapBackendTexture(tex, colorType, ownership, cacheable, ioType);
+ return fGpu->wrapBackendTexture(tex, ownership, cacheable, ioType);
}
sk_sp<GrTexture> GrResourceProvider::wrapRenderableBackendTexture(const GrBackendTexture& tex,
@@ -358,10 +357,10 @@
}
sk_sp<GrRenderTarget> GrResourceProvider::wrapBackendRenderTarget(
- const GrBackendRenderTarget& backendRT, GrColorType colorType)
+ const GrBackendRenderTarget& backendRT)
{
ASSERT_SINGLE_OWNER
- return this->isAbandoned() ? nullptr : fGpu->wrapBackendRenderTarget(backendRT, colorType);
+ return this->isAbandoned() ? nullptr : fGpu->wrapBackendRenderTarget(backendRT);
}
sk_sp<GrRenderTarget> GrResourceProvider::wrapVulkanSecondaryCBAsRenderTarget(
@@ -534,12 +533,12 @@
}
sk_sp<GrRenderTarget> GrResourceProvider::wrapBackendTextureAsRenderTarget(
- const GrBackendTexture& tex, int sampleCnt, GrColorType colorType)
+ const GrBackendTexture& tex, int sampleCnt)
{
if (this->isAbandoned()) {
return nullptr;
}
- return fGpu->wrapBackendTextureAsRenderTarget(tex, sampleCnt, colorType);
+ return fGpu->wrapBackendTextureAsRenderTarget(tex, sampleCnt);
}
sk_sp<GrSemaphore> SK_WARN_UNUSED_RESULT GrResourceProvider::makeSemaphore(bool isOwned) {
diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h
index c0b0219..3447fd4 100644
--- a/src/gpu/GrResourceProvider.h
+++ b/src/gpu/GrResourceProvider.h
@@ -109,7 +109,7 @@
*
* @return GrTexture object or NULL on failure.
*/
- sk_sp<GrTexture> wrapBackendTexture(const GrBackendTexture& tex, GrColorType, GrWrapOwnership,
+ sk_sp<GrTexture> wrapBackendTexture(const GrBackendTexture& tex, GrWrapOwnership,
GrWrapCacheable, GrIOType);
/**
@@ -132,8 +132,7 @@
*
* @return GrRenderTarget object or NULL on failure.
*/
- sk_sp<GrRenderTarget> wrapBackendRenderTarget(const GrBackendRenderTarget&,
- GrColorType colorType);
+ sk_sp<GrRenderTarget> wrapBackendRenderTarget(const GrBackendRenderTarget&);
sk_sp<GrRenderTarget> wrapVulkanSecondaryCBAsRenderTarget(const SkImageInfo&,
const GrVkDrawableInfo&);
@@ -229,8 +228,7 @@
* @return GrRenderTarget object or NULL on failure.
*/
sk_sp<GrRenderTarget> wrapBackendTextureAsRenderTarget(const GrBackendTexture&,
- int sampleCnt,
- GrColorType);
+ int sampleCnt);
/**
* Assigns a unique key to a resource. If the key is associated with another resource that
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index c4355f3..9741210 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -3653,29 +3653,6 @@
return get_yuva_config(*glFormat);
}
-GrColorType GrGLCaps::getYUVAColorTypeFromBackendFormat(const GrBackendFormat& format) const {
- GrGLFormat grGLFormat = GrGLBackendFormatToGLFormat(format);
-
- switch (grGLFormat) {
- case GrGLFormat::kALPHA8: // fall through
- case GrGLFormat::kR8: return GrColorType::kAlpha_8;
- case GrGLFormat::kRG8: return GrColorType::kRG_88;
- case GrGLFormat::kRGBA8: return GrColorType::kRGBA_8888;
- case GrGLFormat::kRGB8: return GrColorType::kRGB_888x;
- case GrGLFormat::kBGRA8: return GrColorType::kBGRA_8888;
- case GrGLFormat::kRGB10_A2: return GrColorType::kRGBA_1010102;
- case GrGLFormat::kR16F: return GrColorType::kAlpha_F16;
- case GrGLFormat::kR16: return GrColorType::kR_16;
- case GrGLFormat::kRG16: return GrColorType::kRG_1616;
- // Experimental (for Y416 and mutant P016/P010)
- case GrGLFormat::kRGBA16: return GrColorType::kRGBA_16161616;
- case GrGLFormat::kRG16F: return GrColorType::kRG_F16;
- default: return GrColorType::kUnknown;
- }
-
- SkUNREACHABLE;
-}
-
GrBackendFormat GrGLCaps::getBackendFormatFromColorType(GrColorType ct) const {
auto format = this->getFormatFromColorType(ct);
if (format == GrGLFormat::kUnknown) {
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index 40afa9f..f99641c 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -447,7 +447,6 @@
GrColorType) const override;
GrPixelConfig getYUVAConfigFromBackendFormat(const GrBackendFormat&) const override;
- GrColorType getYUVAColorTypeFromBackendFormat(const GrBackendFormat&) const override;
GrBackendFormat getBackendFormatFromColorType(GrColorType ct) const override;
GrBackendFormat getBackendFormatFromCompressionType(SkImage::CompressionType) const override;
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 0d4f666..4508af7 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -680,8 +680,8 @@
}
sk_sp<GrTexture> GrGLGpu::onWrapBackendTexture(const GrBackendTexture& backendTex,
- GrColorType grColorType, GrWrapOwnership ownership,
- GrWrapCacheable cacheable, GrIOType ioType) {
+ GrWrapOwnership ownership, GrWrapCacheable cacheable,
+ GrIOType ioType) {
GrGLTexture::IDDesc idDesc;
if (!check_backend_texture(backendTex, this->glCaps(), &idDesc)) {
return nullptr;
@@ -695,14 +695,10 @@
idDesc.fOwnership = GrBackendObjectOwnership::kOwned;
}
- GrPixelConfig config = this->caps()->getConfigFromBackendFormat(backendTex.getBackendFormat(),
- grColorType);
- SkASSERT(kUnknown_GrPixelConfig != config);
-
GrSurfaceDesc surfDesc;
surfDesc.fWidth = backendTex.width();
surfDesc.fHeight = backendTex.height();
- surfDesc.fConfig = config;
+ surfDesc.fConfig = backendTex.config();
surfDesc.fSampleCnt = 1;
GrMipMapsStatus mipMapsStatus = backendTex.hasMipMaps() ? GrMipMapsStatus::kValid
@@ -741,14 +737,10 @@
const GrCaps* caps = this->caps();
- GrPixelConfig config = caps->getConfigFromBackendFormat(backendTex.getBackendFormat(),
- colorType);
- SkASSERT(kUnknown_GrPixelConfig != config);
-
GrSurfaceDesc surfDesc;
surfDesc.fWidth = backendTex.width();
surfDesc.fHeight = backendTex.height();
- surfDesc.fConfig = config;
+ surfDesc.fConfig = backendTex.config();
surfDesc.fSampleCnt = caps->getRenderTargetSampleCount(sampleCnt, colorType,
backendTex.getBackendFormat());
if (surfDesc.fSampleCnt < 1) {
@@ -772,8 +764,7 @@
return std::move(texRT);
}
-sk_sp<GrRenderTarget> GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& backendRT,
- GrColorType grColorType) {
+sk_sp<GrRenderTarget> GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& backendRT) {
GrGLFramebufferInfo info;
if (!backendRT.getGLFramebufferInfo(&info)) {
return nullptr;
@@ -785,23 +776,18 @@
idDesc.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID;
idDesc.fRTFBOOwnership = GrBackendObjectOwnership::kBorrowed;
- GrPixelConfig config = this->caps()->getConfigFromBackendFormat(backendRT.getBackendFormat(),
- grColorType);
- SkASSERT(kUnknown_GrPixelConfig != config);
-
GrSurfaceDesc desc;
desc.fWidth = backendRT.width();
desc.fHeight = backendRT.height();
- desc.fConfig = config;
- desc.fSampleCnt = this->caps()->getRenderTargetSampleCount(backendRT.sampleCnt(), grColorType,
- backendRT.getBackendFormat());
+ desc.fConfig = backendRT.config();
+ desc.fSampleCnt =
+ this->caps()->getRenderTargetSampleCount(backendRT.sampleCnt(), backendRT.config());
return GrGLRenderTarget::MakeWrapped(this, desc, info.fFormat, idDesc, backendRT.stencilBits());
}
sk_sp<GrRenderTarget> GrGLGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTexture& tex,
- int sampleCnt,
- GrColorType grColorType) {
+ int sampleCnt) {
GrGLTextureInfo info;
if (!tex.getGLTextureInfo(&info) || !info.fID) {
return nullptr;
@@ -815,16 +801,11 @@
return nullptr;
}
- GrPixelConfig config = this->caps()->getConfigFromBackendFormat(tex.getBackendFormat(),
- grColorType);
- SkASSERT(kUnknown_GrPixelConfig != config);
-
GrSurfaceDesc surfDesc;
surfDesc.fWidth = tex.width();
surfDesc.fHeight = tex.height();
- surfDesc.fConfig = config;
- surfDesc.fSampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, grColorType,
- tex.getBackendFormat());
+ surfDesc.fConfig = tex.config();
+ surfDesc.fSampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, tex.config());
GrGLRenderTarget::IDDesc rtIDDesc;
if (!this->createRenderTargetObjects(surfDesc, info, &rtIDDesc)) {
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 42b657f..fb5c196 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -200,15 +200,14 @@
sk_sp<GrGpuBuffer> onCreateBuffer(size_t size, GrGpuBufferType intendedType, GrAccessPattern,
const void* data) override;
- sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrColorType, GrWrapOwnership,
- GrWrapCacheable, GrIOType) override;
+ sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrWrapOwnership, GrWrapCacheable,
+ GrIOType) override;
sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&, int sampleCnt,
GrColorType, GrWrapOwnership,
GrWrapCacheable) override;
- sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&,
- GrColorType) override;
+ sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&) override;
sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTexture&,
- int sampleCnt, GrColorType) override;
+ int sampleCnt) override;
// Given a GL format return the index into the stencil format array on GrGLCaps to a
// compatible stencil format, or negative if there is no compatible stencil format.
diff --git a/src/gpu/mock/GrMockCaps.h b/src/gpu/mock/GrMockCaps.h
index 1f9e2d2..4e82f19 100644
--- a/src/gpu/mock/GrMockCaps.h
+++ b/src/gpu/mock/GrMockCaps.h
@@ -137,14 +137,6 @@
return GrColorTypeToPixelConfig(*format.getMockColorType());
}
- GrColorType getYUVAColorTypeFromBackendFormat(const GrBackendFormat& format) const override {
- if (!format.getMockColorType()) {
- return GrColorType::kUnknown;
- }
-
- return *format.getMockColorType();
- }
-
GrBackendFormat getBackendFormatFromColorType(GrColorType ct) const override {
return GrBackendFormat::MakeMock(ct);
}
diff --git a/src/gpu/mock/GrMockGpu.cpp b/src/gpu/mock/GrMockGpu.cpp
index 4c9f5c0..e6f0a62 100644
--- a/src/gpu/mock/GrMockGpu.cpp
+++ b/src/gpu/mock/GrMockGpu.cpp
@@ -114,23 +114,21 @@
return nullptr;
}
-sk_sp<GrTexture> GrMockGpu::onWrapBackendTexture(const GrBackendTexture& tex, GrColorType colorType,
+sk_sp<GrTexture> GrMockGpu::onWrapBackendTexture(const GrBackendTexture& tex,
GrWrapOwnership ownership,
GrWrapCacheable wrapType, GrIOType ioType) {
- GrMockTextureInfo texInfo;
- SkAssertResult(tex.getMockTextureInfo(&texInfo));
+ GrMockTextureInfo info;
+ SkAssertResult(tex.getMockTextureInfo(&info));
- SkASSERT(colorType == texInfo.fColorType);
GrSurfaceDesc desc;
desc.fWidth = tex.width();
desc.fHeight = tex.height();
- desc.fConfig = texInfo.pixelConfig();
+ desc.fConfig = info.pixelConfig();
GrMipMapsStatus mipMapsStatus = tex.hasMipMaps() ? GrMipMapsStatus::kValid
: GrMipMapsStatus::kNotAllocated;
- return sk_sp<GrTexture>(new GrMockTexture(this, desc, mipMapsStatus, texInfo,
- wrapType, ioType));
+ return sk_sp<GrTexture>(new GrMockTexture(this, desc, mipMapsStatus, info, wrapType, ioType));
}
sk_sp<GrTexture> GrMockGpu::onWrapRenderableBackendTexture(const GrBackendTexture& tex,
@@ -157,12 +155,10 @@
new GrMockTextureRenderTarget(this, desc, mipMapsStatus, texInfo, rtInfo, cacheable));
}
-sk_sp<GrRenderTarget> GrMockGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& rt,
- GrColorType colorType) {
+sk_sp<GrRenderTarget> GrMockGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& rt) {
GrMockRenderTargetInfo info;
SkAssertResult(rt.getMockRenderTargetInfo(&info));
- SkASSERT(colorType == info.colorType());
GrSurfaceDesc desc;
desc.fWidth = rt.width();
desc.fHeight = rt.height();
@@ -173,12 +169,10 @@
}
sk_sp<GrRenderTarget> GrMockGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTexture& tex,
- int sampleCnt,
- GrColorType colorType) {
+ int sampleCnt) {
GrMockTextureInfo texInfo;
SkAssertResult(tex.getMockTextureInfo(&texInfo));
- SkASSERT(colorType == texInfo.fColorType);
GrSurfaceDesc desc;
desc.fWidth = tex.width();
desc.fHeight = tex.height();
diff --git a/src/gpu/mock/GrMockGpu.h b/src/gpu/mock/GrMockGpu.h
index 9bdd28f..1459637 100644
--- a/src/gpu/mock/GrMockGpu.h
+++ b/src/gpu/mock/GrMockGpu.h
@@ -69,8 +69,8 @@
sk_sp<GrTexture> onCreateCompressedTexture(int width, int height, SkImage::CompressionType,
SkBudgeted, const void* data) override;
- sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrColorType, GrWrapOwnership,
- GrWrapCacheable, GrIOType) override;
+ sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrWrapOwnership, GrWrapCacheable,
+ GrIOType) override;
sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&,
int sampleCnt,
@@ -78,11 +78,10 @@
GrWrapOwnership,
GrWrapCacheable) override;
- sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&,
- GrColorType) override;
+ sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&) override;
sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTexture&,
- int sampleCnt, GrColorType) override;
+ int sampleCnt) override;
sk_sp<GrGpuBuffer> onCreateBuffer(size_t sizeInBytes, GrGpuBufferType, GrAccessPattern,
const void*) override;
diff --git a/src/gpu/mtl/GrMtlCaps.h b/src/gpu/mtl/GrMtlCaps.h
index 28bfea5..efdbd8f 100644
--- a/src/gpu/mtl/GrMtlCaps.h
+++ b/src/gpu/mtl/GrMtlCaps.h
@@ -72,7 +72,6 @@
GrColorType) const override;
GrPixelConfig getYUVAConfigFromBackendFormat(const GrBackendFormat&) const override;
- GrColorType getYUVAColorTypeFromBackendFormat(const GrBackendFormat&) const override;
GrBackendFormat getBackendFormatFromColorType(GrColorType ct) const override;
GrBackendFormat getBackendFormatFromCompressionType(SkImage::CompressionType) const override;
diff --git a/src/gpu/mtl/GrMtlCaps.mm b/src/gpu/mtl/GrMtlCaps.mm
index ef6f7ce..85b2082 100644
--- a/src/gpu/mtl/GrMtlCaps.mm
+++ b/src/gpu/mtl/GrMtlCaps.mm
@@ -765,32 +765,6 @@
return get_yuva_config(*mtlFormat);
}
-GrColorType GrMtlCaps::getYUVAColorTypeFromBackendFormat(const GrBackendFormat& format) const {
- const GrMTLPixelFormat* grMtlFormat = format.getMtlFormat();
- if (!grMtlFormat) {
- return GrColorType::kUnknown;
- }
-
- MTLPixelFormat mtlFormat = static_cast<MTLPixelFormat>(*grMtlFormat);
-
- switch (mtlFormat) {
- case MTLPixelFormatA8Unorm: // fall through
- case MTLPixelFormatR8Unorm: return GrColorType::kAlpha_8;
- case MTLPixelFormatRG8Unorm: return GrColorType::kRG_88;
- case MTLPixelFormatRGBA8Unorm: return GrColorType::kRGBA_8888;
- case MTLPixelFormatBGRA8Unorm: return GrColorType::kBGRA_8888;
- case MTLPixelFormatRGB10A2Unorm: return GrColorType::kRGBA_1010102;
- case MTLPixelFormatR16Unorm: return GrColorType::kR_16;
- case MTLPixelFormatRG16Unorm: return GrColorType::kRG_1616;
- // Experimental (for Y416 and mutant P016/P010)
- case MTLPixelFormatRGBA16Unorm: return GrColorType::kRGBA_16161616;
- case MTLPixelFormatRG16Float: return GrColorType::kRG_F16;
- default: return GrColorType::kUnknown;
- }
-
- SkUNREACHABLE;
-}
-
GrBackendFormat GrMtlCaps::getBackendFormatFromColorType(GrColorType ct) const {
GrPixelConfig config = GrColorTypeToPixelConfig(ct);
if (config == kUnknown_GrPixelConfig) {
diff --git a/src/gpu/mtl/GrMtlGpu.h b/src/gpu/mtl/GrMtlGpu.h
index 15ae380..16f35fc 100644
--- a/src/gpu/mtl/GrMtlGpu.h
+++ b/src/gpu/mtl/GrMtlGpu.h
@@ -142,19 +142,17 @@
return nullptr;
}
- sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrColorType,
- GrWrapOwnership, GrWrapCacheable, GrIOType) override;
+ sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrWrapOwnership, GrWrapCacheable,
+ GrIOType) override;
sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&, int sampleCnt,
GrColorType, GrWrapOwnership,
GrWrapCacheable) override;
- sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&,
- GrColorType) override;
+ sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&) override;
sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTexture&,
- int sampleCnt,
- GrColorType) override;
+ int sampleCnt) override;
sk_sp<GrGpuBuffer> onCreateBuffer(size_t, GrGpuBufferType, GrAccessPattern,
const void*) override;
diff --git a/src/gpu/mtl/GrMtlGpu.mm b/src/gpu/mtl/GrMtlGpu.mm
index c196552..ab7ea8a 100644
--- a/src/gpu/mtl/GrMtlGpu.mm
+++ b/src/gpu/mtl/GrMtlGpu.mm
@@ -516,7 +516,6 @@
}
sk_sp<GrTexture> GrMtlGpu::onWrapBackendTexture(const GrBackendTexture& backendTex,
- GrColorType grColorType,
GrWrapOwnership,
GrWrapCacheable cacheable, GrIOType ioType) {
id<MTLTexture> mtlTexture = get_texture_from_backend(backendTex);
@@ -524,12 +523,8 @@
return nullptr;
}
- GrPixelConfig config = this->caps()->getConfigFromBackendFormat(backendTex.getBackendFormat(),
- grColorType);
- SkASSERT(kUnknown_GrPixelConfig != config);
-
GrSurfaceDesc surfDesc;
- init_surface_desc(&surfDesc, mtlTexture, GrRenderable::kNo, config);
+ init_surface_desc(&surfDesc, mtlTexture, GrRenderable::kNo, backendTex.config());
return GrMtlTexture::MakeWrappedTexture(this, surfDesc, mtlTexture, cacheable, ioType);
}
@@ -544,17 +539,11 @@
return nullptr;
}
- const GrCaps* caps = this->caps();
-
- GrPixelConfig config = caps->getConfigFromBackendFormat(backendTex.getBackendFormat(),
- colorType);
- SkASSERT(kUnknown_GrPixelConfig != config);
-
GrSurfaceDesc surfDesc;
- init_surface_desc(&surfDesc, mtlTexture, GrRenderable::kYes, config);
+ init_surface_desc(&surfDesc, mtlTexture, GrRenderable::kYes, backendTex.config());
- surfDesc.fSampleCnt = caps->getRenderTargetSampleCount(sampleCnt, colorType,
- backendTex.getBackendFormat());
+ surfDesc.fSampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, colorType,
+ backendTex.getBackendFormat());
if (!surfDesc.fSampleCnt) {
return nullptr;
}
@@ -563,8 +552,7 @@
cacheable);
}
-sk_sp<GrRenderTarget> GrMtlGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& backendRT,
- GrColorType grColorType) {
+sk_sp<GrRenderTarget> GrMtlGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& backendRT) {
// TODO: Revisit this when the Metal backend is completed. It may support MSAA render targets.
if (backendRT.sampleCnt() > 1) {
return nullptr;
@@ -574,31 +562,22 @@
return nullptr;
}
- GrPixelConfig config = this->caps()->getConfigFromBackendFormat(backendRT.getBackendFormat(),
- grColorType);
- SkASSERT(kUnknown_GrPixelConfig != config);
-
GrSurfaceDesc surfDesc;
- init_surface_desc(&surfDesc, mtlTexture, GrRenderable::kYes, config);
+ init_surface_desc(&surfDesc, mtlTexture, GrRenderable::kYes, backendRT.config());
return GrMtlRenderTarget::MakeWrappedRenderTarget(this, surfDesc, mtlTexture);
}
sk_sp<GrRenderTarget> GrMtlGpu::onWrapBackendTextureAsRenderTarget(
- const GrBackendTexture& backendTex, int sampleCnt, GrColorType grColorType) {
+ const GrBackendTexture& backendTex, int sampleCnt) {
id<MTLTexture> mtlTexture = get_texture_from_backend(backendTex);
if (!mtlTexture) {
return nullptr;
}
- GrPixelConfig config = this->caps()->getConfigFromBackendFormat(backendTex.getBackendFormat(),
- grColorType);
- SkASSERT(kUnknown_GrPixelConfig != config);
-
GrSurfaceDesc surfDesc;
- init_surface_desc(&surfDesc, mtlTexture, GrRenderable::kYes, config);
- surfDesc.fSampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, grColorType,
- backendTex.getBackendFormat());
+ init_surface_desc(&surfDesc, mtlTexture, GrRenderable::kYes, backendTex.config());
+ surfDesc.fSampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, surfDesc.fConfig);
if (!surfDesc.fSampleCnt) {
return nullptr;
}
diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp
index 3da7ad5..568df88 100644
--- a/src/gpu/vk/GrVkCaps.cpp
+++ b/src/gpu/vk/GrVkCaps.cpp
@@ -1118,30 +1118,6 @@
return get_yuva_config(*vkFormat);
}
-GrColorType GrVkCaps::getYUVAColorTypeFromBackendFormat(const GrBackendFormat& format) const {
- const VkFormat* vkFormat = format.getVkFormat();
- if (!vkFormat) {
- return GrColorType::kUnknown;
- }
-
- switch (*vkFormat) {
- case VK_FORMAT_R8_UNORM: return GrColorType::kAlpha_8;
- case VK_FORMAT_R8G8B8A8_UNORM: return GrColorType::kRGBA_8888;
- case VK_FORMAT_R8G8B8_UNORM: return GrColorType::kRGB_888x;
- case VK_FORMAT_R8G8_UNORM: return GrColorType::kRG_88;
- case VK_FORMAT_B8G8R8A8_UNORM: return GrColorType::kBGRA_8888;
- case VK_FORMAT_A2B10G10R10_UNORM_PACK32: return GrColorType::kRGBA_1010102;
- case VK_FORMAT_R16_UNORM: return GrColorType::kR_16;
- case VK_FORMAT_R16G16_UNORM: return GrColorType::kRG_1616;
- // Experimental (for Y416 and mutant P016/P010)
- case VK_FORMAT_R16G16B16A16_UNORM: return GrColorType::kRGBA_16161616;
- case VK_FORMAT_R16G16_SFLOAT: return GrColorType::kRG_F16;
- default: return GrColorType::kUnknown;
- }
-
- SkUNREACHABLE;
-}
-
GrBackendFormat GrVkCaps::getBackendFormatFromColorType(GrColorType ct) const {
GrPixelConfig config = GrColorTypeToPixelConfig(ct);
if (config == kUnknown_GrPixelConfig) {
diff --git a/src/gpu/vk/GrVkCaps.h b/src/gpu/vk/GrVkCaps.h
index 1a89a89..cca10b0 100644
--- a/src/gpu/vk/GrVkCaps.h
+++ b/src/gpu/vk/GrVkCaps.h
@@ -166,7 +166,6 @@
GrColorType) const override;
GrPixelConfig getYUVAConfigFromBackendFormat(const GrBackendFormat&) const override;
- GrColorType getYUVAColorTypeFromBackendFormat(const GrBackendFormat&) const override;
GrBackendFormat getBackendFormatFromColorType(GrColorType ct) const override;
GrBackendFormat getBackendFormatFromCompressionType(SkImage::CompressionType) const override;
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index 9a8aeb8..c62a033 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -1120,7 +1120,7 @@
static bool check_image_info(const GrVkCaps& caps,
const GrVkImageInfo& info,
- GrColorType colorType,
+ GrPixelConfig config,
bool needsAllocation) {
if (VK_NULL_HANDLE == info.fImage) {
return false;
@@ -1140,7 +1140,7 @@
return false;
}
- SkASSERT(GrVkFormatColorTypePairIsValid(info.fFormat, colorType));
+ SkASSERT(GrVkFormatPixelConfigPairIsValid(info.fFormat, config));
return true;
}
@@ -1166,14 +1166,14 @@
}
sk_sp<GrTexture> GrVkGpu::onWrapBackendTexture(const GrBackendTexture& backendTex,
- GrColorType colorType, GrWrapOwnership ownership,
- GrWrapCacheable cacheable, GrIOType ioType) {
+ GrWrapOwnership ownership, GrWrapCacheable cacheable,
+ GrIOType ioType) {
GrVkImageInfo imageInfo;
if (!backendTex.getVkImageInfo(&imageInfo)) {
return nullptr;
}
- if (!check_image_info(this->vkCaps(), imageInfo, colorType,
+ if (!check_image_info(this->vkCaps(), imageInfo, backendTex.config(),
kAdopt_GrWrapOwnership == ownership)) {
return nullptr;
}
@@ -1185,14 +1185,10 @@
return nullptr;
}
- GrPixelConfig config = this->caps()->getConfigFromBackendFormat(backendTex.getBackendFormat(),
- colorType);
- SkASSERT(kUnknown_GrPixelConfig != config);
-
GrSurfaceDesc surfDesc;
surfDesc.fWidth = backendTex.width();
surfDesc.fHeight = backendTex.height();
- surfDesc.fConfig = config;
+ surfDesc.fConfig = backendTex.config();
surfDesc.fSampleCnt = 1;
surfDesc.fIsProtected = backendTex.isProtected() ? GrProtected::kYes : GrProtected::kNo;
@@ -1212,7 +1208,7 @@
return nullptr;
}
- if (!check_image_info(this->vkCaps(), imageInfo, colorType,
+ if (!check_image_info(this->vkCaps(), imageInfo, backendTex.config(),
kAdopt_GrWrapOwnership == ownership)) {
return nullptr;
}
@@ -1227,16 +1223,16 @@
return nullptr;
}
-
- GrPixelConfig config = this->caps()->getConfigFromBackendFormat(backendTex.getBackendFormat(),
- colorType);
- SkASSERT(kUnknown_GrPixelConfig != config);
+ SkASSERT(GrCaps::AreConfigsCompatible(backendTex.config(),
+ this->caps()->getConfigFromBackendFormat(
+ backendTex.getBackendFormat(),
+ colorType)));
GrSurfaceDesc surfDesc;
surfDesc.fWidth = backendTex.width();
surfDesc.fHeight = backendTex.height();
surfDesc.fIsProtected = backendTex.isProtected() ? GrProtected::kYes : GrProtected::kNo;
- surfDesc.fConfig = config;
+ surfDesc.fConfig = backendTex.config();
surfDesc.fSampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, colorType,
backendTex.getBackendFormat());
@@ -1247,8 +1243,7 @@
this, surfDesc, ownership, cacheable, imageInfo, std::move(layout));
}
-sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& backendRT,
- GrColorType colorType) {
+sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& backendRT){
// Currently the Vulkan backend does not support wrapping of msaa render targets directly. In
// general this is not an issue since swapchain images in vulkan are never multisampled. Thus if
// you want a multisampled RT it is best to wrap the swapchain images and then let Skia handle
@@ -1262,11 +1257,7 @@
return nullptr;
}
- GrPixelConfig config = this->caps()->getConfigFromBackendFormat(backendRT.getBackendFormat(),
- colorType);
- SkASSERT(kUnknown_GrPixelConfig != config);
-
- if (!check_image_info(this->vkCaps(), info, colorType, false)) {
+ if (!check_image_info(this->vkCaps(), info, backendRT.config(), false)) {
return nullptr;
}
if (!check_rt_image_info(this->vkCaps(), info)) {
@@ -1281,7 +1272,7 @@
desc.fWidth = backendRT.width();
desc.fHeight = backendRT.height();
desc.fIsProtected = backendRT.isProtected() ? GrProtected::kYes : GrProtected::kNo;
- desc.fConfig = config;
+ desc.fConfig = backendRT.config();
desc.fSampleCnt = 1;
sk_sp<GrVkImageLayout> layout = backendRT.getGrVkImageLayout();
@@ -1299,14 +1290,13 @@
}
sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTexture& tex,
- int sampleCnt,
- GrColorType grColorType) {
+ int sampleCnt) {
GrVkImageInfo imageInfo;
if (!tex.getVkImageInfo(&imageInfo)) {
return nullptr;
}
- if (!check_image_info(this->vkCaps(), imageInfo, grColorType, false)) {
+ if (!check_image_info(this->vkCaps(), imageInfo, tex.config(), false)) {
return nullptr;
}
if (!check_rt_image_info(this->vkCaps(), imageInfo)) {
@@ -1317,17 +1307,12 @@
return nullptr;
}
- GrPixelConfig config = this->caps()->getConfigFromBackendFormat(tex.getBackendFormat(),
- grColorType);
- SkASSERT(kUnknown_GrPixelConfig != config);
-
GrSurfaceDesc desc;
desc.fWidth = tex.width();
desc.fHeight = tex.height();
desc.fIsProtected = tex.isProtected() ? GrProtected::kYes : GrProtected::kNo;
- desc.fConfig = config;
- desc.fSampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, grColorType,
- tex.getBackendFormat());
+ desc.fConfig = tex.config();
+ desc.fSampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, tex.config());
if (!desc.fSampleCnt) {
return nullptr;
}
diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h
index 6b1c3f3..45b0090 100644
--- a/src/gpu/vk/GrVkGpu.h
+++ b/src/gpu/vk/GrVkGpu.h
@@ -196,18 +196,17 @@
sk_sp<GrTexture> onCreateCompressedTexture(int width, int height, SkImage::CompressionType,
SkBudgeted, const void* data) override;
- sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrColorType, GrWrapOwnership,
- GrWrapCacheable, GrIOType) override;
+ sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrWrapOwnership, GrWrapCacheable,
+ GrIOType) override;
sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&,
int sampleCnt,
GrColorType colorType,
GrWrapOwnership,
GrWrapCacheable) override;
- sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&,
- GrColorType) override;
+ sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&) override;
sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTexture&,
- int sampleCnt, GrColorType) override;
+ int sampleCnt) override;
sk_sp<GrRenderTarget> onWrapVulkanSecondaryCBAsRenderTarget(const SkImageInfo&,
const GrVkDrawableInfo&) override;
diff --git a/src/gpu/vk/GrVkUtil.cpp b/src/gpu/vk/GrVkUtil.cpp
index 205f44c..7101201 100644
--- a/src/gpu/vk/GrVkUtil.cpp
+++ b/src/gpu/vk/GrVkUtil.cpp
@@ -97,35 +97,56 @@
}
#ifdef SK_DEBUG
-bool GrVkFormatColorTypePairIsValid(VkFormat format, GrColorType colorType) {
+bool GrVkFormatPixelConfigPairIsValid(VkFormat format, GrPixelConfig config) {
switch (format) {
- case VK_FORMAT_R8G8B8A8_UNORM: return GrColorType::kRGBA_8888 == colorType ||
- GrColorType::kRGB_888x == colorType;
- case VK_FORMAT_B8G8R8A8_UNORM: return GrColorType::kBGRA_8888 == colorType;
- case VK_FORMAT_R8G8B8A8_SRGB: return GrColorType::kRGBA_8888_SRGB == colorType;
- case VK_FORMAT_R8G8B8_UNORM: return GrColorType::kRGB_888x == colorType;
- case VK_FORMAT_R8G8_UNORM: return GrColorType::kRG_88 == colorType;
- case VK_FORMAT_A2B10G10R10_UNORM_PACK32: return GrColorType::kRGBA_1010102 == colorType;
- case VK_FORMAT_R5G6B5_UNORM_PACK16: return GrColorType::kBGR_565 == colorType;
- // R4G4B4A4 is not required to be supported so we actually
- // store RGBA_4444 data as B4G4R4A4.
- case VK_FORMAT_B4G4R4A4_UNORM_PACK16: return GrColorType::kABGR_4444 == colorType;
- case VK_FORMAT_R4G4B4A4_UNORM_PACK16: return GrColorType::kABGR_4444 == colorType;
- case VK_FORMAT_R8_UNORM: return GrColorType::kAlpha_8 == colorType ||
- GrColorType::kGray_8 == colorType;
- case VK_FORMAT_R32G32B32A32_SFLOAT: return GrColorType::kRGBA_F32 == colorType;
- case VK_FORMAT_R16G16B16A16_SFLOAT: return GrColorType::kRGBA_F16 == colorType ||
- GrColorType::kRGBA_F16_Clamped == colorType;
- case VK_FORMAT_R16_SFLOAT: return GrColorType::kAlpha_F16 == colorType;
- case VK_FORMAT_R16_UNORM: return GrColorType::kR_16 == colorType;
- case VK_FORMAT_R16G16_UNORM: return GrColorType::kRG_1616 == colorType;
+ case VK_FORMAT_R8G8B8A8_UNORM:
+ return kRGBA_8888_GrPixelConfig == config ||
+ kRGB_888X_GrPixelConfig == config;
+ case VK_FORMAT_B8G8R8A8_UNORM:
+ return kBGRA_8888_GrPixelConfig == config;
+ case VK_FORMAT_R8G8B8A8_SRGB:
+ return kSRGBA_8888_GrPixelConfig == config;
+ case VK_FORMAT_R8G8B8_UNORM:
+ return kRGB_888_GrPixelConfig == config;
+ case VK_FORMAT_R8G8_UNORM:
+ return kRG_88_GrPixelConfig == config;
+ case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
+ return kRGBA_1010102_GrPixelConfig == config;
+ case VK_FORMAT_R5G6B5_UNORM_PACK16:
+ return kRGB_565_GrPixelConfig == config;
+ case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
+ // R4G4B4A4 is not required to be supported so we actually
+ // store RGBA_4444 data as B4G4R4A4.
+ return kRGBA_4444_GrPixelConfig == config;
+ case VK_FORMAT_R4G4B4A4_UNORM_PACK16:
+ return kRGBA_4444_GrPixelConfig == config;
+ case VK_FORMAT_R8_UNORM:
+ return kAlpha_8_GrPixelConfig == config ||
+ kAlpha_8_as_Red_GrPixelConfig == config ||
+ kGray_8_GrPixelConfig == config ||
+ kGray_8_as_Red_GrPixelConfig == config;
+ case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK:
+ return kRGB_ETC1_GrPixelConfig == config;
+ case VK_FORMAT_R32G32B32A32_SFLOAT:
+ return kRGBA_float_GrPixelConfig == config;
+ case VK_FORMAT_R16G16B16A16_SFLOAT:
+ return kRGBA_half_GrPixelConfig == config ||
+ kRGBA_half_Clamped_GrPixelConfig == config;
+ case VK_FORMAT_R16_SFLOAT:
+ return kAlpha_half_GrPixelConfig == config ||
+ kAlpha_half_as_Red_GrPixelConfig == config;
+ case VK_FORMAT_R16_UNORM:
+ return kR_16_GrPixelConfig == config;
+ case VK_FORMAT_R16G16_UNORM:
+ return kRG_1616_GrPixelConfig == config;
// Experimental (for Y416 and mutant P016/P010)
- case VK_FORMAT_R16G16B16A16_UNORM: return GrColorType::kRGBA_16161616 == colorType;
- case VK_FORMAT_R16G16_SFLOAT: return GrColorType::kRG_F16 == colorType;
- default: return false;
+ case VK_FORMAT_R16G16B16A16_UNORM:
+ return kRGBA_16161616_GrPixelConfig == config;
+ case VK_FORMAT_R16G16_SFLOAT:
+ return kRG_half_GrPixelConfig == config;
+ default:
+ return false;
}
-
- SkUNREACHABLE;
}
#endif
diff --git a/src/gpu/vk/GrVkUtil.h b/src/gpu/vk/GrVkUtil.h
index 04c1acd..6c77c74 100644
--- a/src/gpu/vk/GrVkUtil.h
+++ b/src/gpu/vk/GrVkUtil.h
@@ -38,9 +38,9 @@
#ifdef SK_DEBUG
/**
- * Returns true if the passed in VkFormat and GrColorType are compatible with each other.
+ * Returns true if the passed in VkFormat and GrPixelConfig are compatible with each other.
*/
-bool GrVkFormatColorTypePairIsValid(VkFormat, GrColorType);
+bool GrVkFormatPixelConfigPairIsValid(VkFormat, GrPixelConfig);
#endif
bool GrSampleCountToVkSampleCount(uint32_t samples, VkSampleCountFlagBits* vkSamples);
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 011a6de..70b36c7 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -116,7 +116,7 @@
static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx,
const GrBackendTexture& backendTex,
- GrColorType colorType, GrSurfaceOrigin origin,
+ GrSurfaceOrigin origin,
SkAlphaType at, sk_sp<SkColorSpace> colorSpace,
GrWrapOwnership ownership,
SkImage::TextureReleaseProc releaseProc,
@@ -127,9 +127,8 @@
GrProxyProvider* proxyProvider = ctx->priv().proxyProvider();
sk_sp<GrTextureProxy> proxy =
- proxyProvider->wrapBackendTexture(backendTex, colorType, origin, ownership,
- GrWrapCacheable::kNo, kRead_GrIOType,
- releaseProc, releaseCtx);
+ proxyProvider->wrapBackendTexture(backendTex, origin, ownership, GrWrapCacheable::kNo,
+ kRead_GrIOType, releaseProc, releaseCtx);
if (!proxy) {
return nullptr;
}
@@ -144,20 +143,11 @@
if (!ctx) {
return nullptr;
}
-
- GrColorType grColorType = SkColorTypeAndFormatToGrColorType(ctx->priv().caps(), ct,
- tex.getBackendFormat());
- if (GrColorType::kUnknown == grColorType) {
- return nullptr;
- }
-
GrBackendTexture texCopy = tex;
- if (!SkImage_GpuBase::ValidateBackendTexture(ctx, texCopy, &texCopy.fConfig, grColorType,
- ct, at, cs)) {
+ if (!SkImage_GpuBase::ValidateBackendTexture(ctx, texCopy, &texCopy.fConfig, ct, at, cs)) {
return nullptr;
}
-
- return new_wrapped_texture_common(ctx, texCopy, grColorType, origin, at, std::move(cs),
+ return new_wrapped_texture_common(ctx, texCopy, origin, at, std::move(cs),
kBorrow_GrWrapOwnership, releaseP, releaseC);
}
@@ -169,20 +159,11 @@
// We have a DDL context and we don't support adopted textures for them.
return nullptr;
}
-
- GrColorType grColorType = SkColorTypeAndFormatToGrColorType(ctx->priv().caps(), ct,
- tex.getBackendFormat());
- if (GrColorType::kUnknown == grColorType) {
- return nullptr;
- }
-
GrBackendTexture texCopy = tex;
- if (!SkImage_GpuBase::ValidateBackendTexture(ctx, texCopy, &texCopy.fConfig, grColorType,
- ct, at, cs)) {
+ if (!SkImage_GpuBase::ValidateBackendTexture(ctx, texCopy, &texCopy.fConfig, ct, at, cs)) {
return nullptr;
}
-
- return new_wrapped_texture_common(ctx, texCopy, grColorType, origin, at, std::move(cs),
+ return new_wrapped_texture_common(ctx, texCopy, origin, at, std::move(cs),
kAdopt_GrWrapOwnership, nullptr, nullptr);
}
@@ -262,18 +243,11 @@
GrSurfaceOrigin imageOrigin,
const GrBackendTexture& backendTexture,
sk_sp<SkColorSpace> imageColorSpace) {
-
- GrColorType grColorType = SkColorTypeAndFormatToGrColorType(ctx->priv().caps(),
- kRGBA_8888_SkColorType,
- backendTexture.getBackendFormat());
- if (GrColorType::kUnknown == grColorType) {
- return nullptr;
- }
-
GrBackendTexture backendTextureCopy = backendTexture;
+
SkAlphaType at = SkImage_GpuBase::GetAlphaTypeFromYUVAIndices(yuvaIndices);
if (!SkImage_Gpu::ValidateBackendTexture(ctx, backendTextureCopy, &backendTextureCopy.fConfig,
- grColorType, kRGBA_8888_SkColorType, at, nullptr)) {
+ kRGBA_8888_SkColorType, at, nullptr)) {
return nullptr;
}
@@ -281,7 +255,7 @@
// in order to draw to it for the yuv->rgb conversion.
sk_sp<GrRenderTargetContext> renderTargetContext(
ctx->priv().makeBackendTextureRenderTargetContext(backendTextureCopy, imageOrigin, 1,
- grColorType,
+ GrColorType::kRGBA_8888,
std::move(imageColorSpace)));
if (!renderTargetContext) {
@@ -440,16 +414,15 @@
return nullptr;
}
- GrColorType grColorType = SkColorTypeAndFormatToGrColorType(context->priv().caps(),
- colorType,
- backendFormat);
- if (GrColorType::kUnknown == grColorType) {
+ GrPixelConfig config =
+ context->priv().caps()->getConfigFromBackendFormat(backendFormat,
+ SkColorTypeToGrColorType(colorType));
+ if (config == kUnknown_GrPixelConfig) {
return nullptr;
}
callDone.clear();
- auto proxy = MakePromiseImageLazyProxy(context, width, height, origin,
- grColorType, backendFormat,
+ auto proxy = MakePromiseImageLazyProxy(context, width, height, origin, config, backendFormat,
mipMapped, textureFulfillProc, textureReleaseProc,
textureDoneProc, textureContext, version);
if (!proxy) {
@@ -628,9 +601,8 @@
SkColorType colorType =
GrAHardwareBufferUtils::GetSkColorTypeFromBufferFormat(bufferDesc.format);
- GrColorType grColorType = SkColorTypeToGrColorType(colorType);
backendTexture.fConfig = context->priv().caps()->getConfigFromBackendFormat(
- backendFormat, grColorType);
+ backendFormat, SkColorTypeToGrColorType(colorType));
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
if (!proxyProvider) {
@@ -639,7 +611,7 @@
}
sk_sp<GrTextureProxy> proxy =
- proxyProvider->wrapBackendTexture(backendTexture, grColorType, surfaceOrigin,
+ proxyProvider->wrapBackendTexture(backendTexture, surfaceOrigin,
kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
kRW_GrIOType, deleteImageProc, deleteImageCtx);
if (!proxy) {
diff --git a/src/image/SkImage_GpuBase.cpp b/src/image/SkImage_GpuBase.cpp
index 595ca3c..efce01d 100644
--- a/src/image/SkImage_GpuBase.cpp
+++ b/src/image/SkImage_GpuBase.cpp
@@ -39,8 +39,7 @@
#endif
bool SkImage_GpuBase::ValidateBackendTexture(GrContext* ctx, const GrBackendTexture& tex,
- GrPixelConfig* config, GrColorType grCT,
- SkColorType ct, SkAlphaType at,
+ GrPixelConfig* config, SkColorType ct, SkAlphaType at,
sk_sp<SkColorSpace> cs) {
if (!tex.isValid()) {
return false;
@@ -56,6 +55,16 @@
return false;
}
+ GrColorType grCT = SkColorTypeToGrColorType(ct);
+ // Until we support SRGB in the SkColorType we have to do this manual check here to make sure
+ // we use the correct GrColorType.
+ if (ctx->priv().caps()->isFormatSRGB(backendFormat)) {
+ if (grCT != GrColorType::kRGBA_8888) {
+ return false;
+ }
+ grCT = GrColorType::kRGBA_8888_SRGB;
+ }
+
*config = ctx->priv().caps()->getConfigFromBackendFormat(backendFormat, grCT);
return *config != kUnknown_GrPixelConfig;
}
@@ -238,7 +247,6 @@
GrSurfaceOrigin imageOrigin,
sk_sp<GrTextureProxy> tempTextureProxies[4]) {
GrProxyProvider* proxyProvider = ctx->priv().proxyProvider();
- const GrCaps* caps = ctx->priv().caps();
// We need to make a copy of the input backend textures because we need to preserve the result
// of validate_backend_texture.
@@ -250,46 +258,39 @@
return false;
}
yuvaTexturesCopy[textureIndex].fConfig =
- caps->getYUVAConfigFromBackendFormat(backendFormat);
+ ctx->priv().caps()->getYUVAConfigFromBackendFormat(backendFormat);
if (yuvaTexturesCopy[textureIndex].fConfig == kUnknown_GrPixelConfig) {
return false;
}
- GrColorType grColorType = caps->getYUVAColorTypeFromBackendFormat(backendFormat);
- if (GrColorType::kUnknown == grColorType) {
- return false;
- }
-
SkASSERT(yuvaTexturesCopy[textureIndex].isValid());
tempTextureProxies[textureIndex] = proxyProvider->wrapBackendTexture(
- yuvaTexturesCopy[textureIndex], grColorType, imageOrigin, kBorrow_GrWrapOwnership,
+ yuvaTexturesCopy[textureIndex], imageOrigin, kBorrow_GrWrapOwnership,
GrWrapCacheable::kNo, kRead_GrIOType);
if (!tempTextureProxies[textureIndex]) {
return false;
}
// Check that each texture contains the channel data for the corresponding YUVA index
- auto componentFlags = GrColorTypeComponentFlags(grColorType);
+ GrPixelConfig config = yuvaTexturesCopy[textureIndex].fConfig;
for (int yuvaIndex = 0; yuvaIndex < SkYUVAIndex::kIndexCount; ++yuvaIndex) {
if (yuvaIndices[yuvaIndex].fIndex == textureIndex) {
switch (yuvaIndices[yuvaIndex].fChannel) {
case SkColorChannel::kR:
- if (!(kRed_SkColorTypeComponentFlag & componentFlags)) {
+ if (kAlpha_8_as_Alpha_GrPixelConfig == config) {
return false;
}
break;
case SkColorChannel::kG:
- if (!(kGreen_SkColorTypeComponentFlag & componentFlags)) {
- return false;
- }
- break;
case SkColorChannel::kB:
- if (!(kBlue_SkColorTypeComponentFlag & componentFlags)) {
+ if (kAlpha_8_as_Alpha_GrPixelConfig == config ||
+ kAlpha_8_as_Red_GrPixelConfig == config) {
return false;
}
break;
case SkColorChannel::kA:
- if (!(kAlpha_SkColorTypeComponentFlag & componentFlags)) {
+ default:
+ if (kRGB_888_GrPixelConfig == config) {
return false;
}
break;
@@ -326,7 +327,7 @@
}
sk_sp<GrTextureProxy> SkImage_GpuBase::MakePromiseImageLazyProxy(
- GrContext* context, int width, int height, GrSurfaceOrigin origin, GrColorType colorType,
+ GrContext* context, int width, int height, GrSurfaceOrigin origin, GrPixelConfig config,
GrBackendFormat backendFormat, GrMipMapped mipMapped,
PromiseImageTextureFulfillProc fulfillProc,
PromiseImageTextureReleaseProc releaseProc,
@@ -336,7 +337,7 @@
SkASSERT(context);
SkASSERT(width > 0 && height > 0);
SkASSERT(doneProc);
- SkASSERT(colorType != GrColorType::kUnknown);
+ SkASSERT(config != kUnknown_GrPixelConfig);
if (!fulfillProc || !releaseProc) {
doneProc(textureContext);
@@ -371,11 +372,11 @@
PromiseImageTextureReleaseProc releaseProc,
PromiseImageTextureDoneProc doneProc,
PromiseImageTextureContext context,
- GrColorType colorType,
+ GrPixelConfig config,
PromiseImageApiVersion version)
: fFulfillProc(fulfillProc)
, fReleaseProc(releaseProc)
- , fColorType(colorType)
+ , fConfig(config)
, fVersion(version) {
fDoneCallback = sk_make_sp<GrRefCntedCallback>(doneProc, context);
}
@@ -408,7 +409,7 @@
// Fulfill once. So return our cached result.
if (fTexture) {
return {sk_ref_sp(fTexture), kKeySyncMode};
- } else if (fColorType == GrColorType::kUnknown) {
+ } else if (fConfig == kUnknown_GrPixelConfig) {
// We've already called fulfill and it failed. Our contract says that we should only
// call each callback once.
return {};
@@ -421,30 +422,22 @@
auto releaseCallback = sk_make_sp<GrRefCntedCallback>(fReleaseProc, textureContext);
if (!promiseTexture) {
// This records that we have failed.
- fColorType = GrColorType::kUnknown;
+ fConfig = kUnknown_GrPixelConfig;
return {};
}
auto backendTexture = promiseTexture->backendTexture();
+ backendTexture.fConfig = fConfig;
if (!backendTexture.isValid()) {
return {};
}
- // TODO: delete this block
- {
- GrPixelConfig config = resourceProvider->caps()->getConfigFromBackendFormat(
- backendTexture.getBackendFormat(),
- fColorType);
- SkASSERT(kUnknown_GrPixelConfig != config);
- backendTexture.fConfig = config;
- }
-
sk_sp<GrTexture> tex;
static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
GrUniqueKey key;
GrUniqueKey::Builder builder(&key, kDomain, 2, "promise");
builder[0] = promiseTexture->uniqueID();
- builder[1] = (uint32_t) fColorType;
+ builder[1] = fConfig;
builder.finish();
// A texture with this key may already exist from a different instance of this lazy
// callback. This could happen if the client fulfills a promise image with a texture
@@ -454,8 +447,8 @@
SkASSERT(tex);
} else {
if ((tex = resourceProvider->wrapBackendTexture(
- backendTexture, fColorType, kBorrow_GrWrapOwnership,
- GrWrapCacheable::kYes, kRead_GrIOType))) {
+ backendTexture, kBorrow_GrWrapOwnership, GrWrapCacheable::kYes,
+ kRead_GrIOType))) {
tex->resourcePriv().setUniqueKey(key);
} else {
return {};
@@ -484,16 +477,12 @@
sk_sp<GrRefCntedCallback> fDoneCallback;
GrTexture* fTexture = nullptr;
uint32_t fTextureContextID = SK_InvalidUniqueID;
- GrColorType fColorType;
+ GrPixelConfig fConfig;
PromiseImageApiVersion fVersion;
- } callback(fulfillProc, releaseProc, doneProc, textureContext, colorType, version);
+ } callback(fulfillProc, releaseProc, doneProc, textureContext, config, version);
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
- GrPixelConfig config = context->priv().caps()->getConfigFromBackendFormat(
- backendFormat,
- colorType);
-
GrSurfaceDesc desc;
desc.fWidth = width;
desc.fHeight = height;
diff --git a/src/image/SkImage_GpuBase.h b/src/image/SkImage_GpuBase.h
index 6a3c516..c48c48e 100644
--- a/src/image/SkImage_GpuBase.h
+++ b/src/image/SkImage_GpuBase.h
@@ -58,8 +58,7 @@
#endif
static bool ValidateBackendTexture(GrContext* ctx, const GrBackendTexture& tex,
- GrPixelConfig* config, GrColorType grCT,
- SkColorType ct, SkAlphaType at,
+ GrPixelConfig* config, SkColorType ct, SkAlphaType at,
sk_sp<SkColorSpace> cs);
static bool MakeTempTextureProxies(GrContext* ctx, const GrBackendTexture yuvaTextures[],
int numTextures, const SkYUVAIndex [4],
@@ -85,7 +84,7 @@
// proxy along with the TextureFulfillProc and TextureReleaseProc. PromiseDoneProc must not
// be null.
static sk_sp<GrTextureProxy> MakePromiseImageLazyProxy(
- GrContext*, int width, int height, GrSurfaceOrigin, GrColorType, GrBackendFormat,
+ GrContext*, int width, int height, GrSurfaceOrigin, GrPixelConfig, GrBackendFormat,
GrMipMapped, PromiseImageTextureFulfillProc, PromiseImageTextureReleaseProc,
PromiseImageTextureDoneProc, PromiseImageTextureContext, PromiseImageApiVersion);
diff --git a/src/image/SkImage_GpuYUVA.cpp b/src/image/SkImage_GpuYUVA.cpp
index 7eef716..7b938dd 100644
--- a/src/image/SkImage_GpuYUVA.cpp
+++ b/src/image/SkImage_GpuYUVA.cpp
@@ -354,16 +354,15 @@
// Get lazy proxies
sk_sp<GrTextureProxy> proxies[4];
for (int texIdx = 0; texIdx < numTextures; ++texIdx) {
- GrColorType colorType = context->priv().caps()->getYUVAColorTypeFromBackendFormat(
- yuvaFormats[texIdx]);
- if (GrColorType::kUnknown == colorType) {
+ GrPixelConfig config =
+ context->priv().caps()->getYUVAConfigFromBackendFormat(yuvaFormats[texIdx]);
+ if (config == kUnknown_GrPixelConfig) {
return nullptr;
}
-
proxies[texIdx] = MakePromiseImageLazyProxy(
- context, yuvaSizes[texIdx].width(), yuvaSizes[texIdx].height(), imageOrigin,
- colorType, yuvaFormats[texIdx], GrMipMapped::kNo, textureFulfillProc,
- textureReleaseProc, promiseDoneProc, textureContexts[texIdx], version);
+ context, yuvaSizes[texIdx].width(), yuvaSizes[texIdx].height(), imageOrigin, config,
+ yuvaFormats[texIdx], GrMipMapped::kNo, textureFulfillProc, textureReleaseProc,
+ promiseDoneProc, textureContexts[texIdx], version);
++proxiesCreated;
if (!proxies[texIdx]) {
return nullptr;
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 1487328..6bc6d3d 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -426,6 +426,21 @@
return true;
}
+static GrColorType get_grcolortype_from_skcolortype_and_format(const GrCaps* caps,
+ SkColorType skCT,
+ const GrBackendFormat& format) {
+ GrColorType grCT = SkColorTypeToGrColorType(skCT);
+ // Until we support SRGB in the SkColorType we have to do this manual check here to make sure
+ // we use the correct GrColorType.
+ if (caps->isFormatSRGB(format)) {
+ if (grCT != GrColorType::kRGBA_8888) {
+ return GrColorType::kUnknown;
+ }
+ grCT = GrColorType::kRGBA_8888_SRGB;
+ }
+ return grCT;
+}
+
sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext* context,
const SkSurfaceCharacterization& c,
const GrBackendTexture& backendTexture,
@@ -444,8 +459,8 @@
return nullptr;
}
- GrColorType grCT = SkColorTypeAndFormatToGrColorType(context->priv().caps(), c.colorType(),
- backendTexture.getBackendFormat());
+ GrColorType grCT = get_grcolortype_from_skcolortype_and_format(
+ context->priv().caps(), c.colorType(), backendTexture.getBackendFormat());
if (grCT == GrColorType::kUnknown) {
return nullptr;
}
@@ -536,8 +551,8 @@
}
sampleCnt = SkTMax(1, sampleCnt);
- GrColorType grColorType = SkColorTypeAndFormatToGrColorType(context->priv().caps(), colorType,
- tex.getBackendFormat());
+ GrColorType grColorType = get_grcolortype_from_skcolortype_and_format(
+ context->priv().caps(), colorType, tex.getBackendFormat());
if (grColorType == GrColorType::kUnknown) {
return nullptr;
}
@@ -657,8 +672,8 @@
return nullptr;
}
- GrColorType grColorType = SkColorTypeAndFormatToGrColorType(context->priv().caps(), colorType,
- rt.getBackendFormat());
+ GrColorType grColorType = get_grcolortype_from_skcolortype_and_format(
+ context->priv().caps(), colorType, rt.getBackendFormat());
if (grColorType == GrColorType::kUnknown) {
return nullptr;
}
@@ -703,8 +718,8 @@
}
sampleCnt = SkTMax(1, sampleCnt);
- GrColorType grColorType = SkColorTypeAndFormatToGrColorType(context->priv().caps(), colorType,
- tex.getBackendFormat());
+ GrColorType grColorType = get_grcolortype_from_skcolortype_and_format(
+ context->priv().caps(), colorType, tex.getBackendFormat());
if (grColorType == GrColorType::kUnknown) {
return nullptr;
}
diff --git a/tests/BackendAllocationTest.cpp b/tests/BackendAllocationTest.cpp
index b4a2baa..88dca15 100644
--- a/tests/BackendAllocationTest.cpp
+++ b/tests/BackendAllocationTest.cpp
@@ -591,9 +591,13 @@
continue;
}
- GrColorType grCT = SkColorTypeAndFormatToGrColorType(glCaps, combo.fColorType, format);
- if (GrColorType::kUnknown == grCT) {
- continue;
+ GrColorType grCT = SkColorTypeToGrColorType(combo.fColorType);
+ // TODO: Once SkColorType has an SRGB type we can remove this manual setting.
+ if (glCaps->isFormatSRGB(format)) {
+ if (grCT != GrColorType::kRGBA_8888) {
+ continue;
+ }
+ grCT = GrColorType::kRGBA_8888_SRGB;
}
if (!glCaps->isFormatTexturable(grCT, format)) {
diff --git a/tests/GrPorterDuffTest.cpp b/tests/GrPorterDuffTest.cpp
index 7e399f0..362962d 100644
--- a/tests/GrPorterDuffTest.cpp
+++ b/tests/GrPorterDuffTest.cpp
@@ -1004,8 +1004,8 @@
GrXferProcessor::DstProxy fakeDstProxy;
{
sk_sp<GrTextureProxy> proxy = proxyProvider->wrapBackendTexture(
- backendTex, GrColorType::kRGBA_8888, kTopLeft_GrSurfaceOrigin,
- kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kRead_GrIOType);
+ backendTex, kTopLeft_GrSurfaceOrigin, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
+ kRead_GrIOType);
fakeDstProxy.setProxy(std::move(proxy));
}
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index 723e9a8..e08bbc4 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -350,8 +350,7 @@
GrRenderable::kYes,
GrProtected::kNo);
- auto proxy = proxyProvider->wrapBackendTexture(backendTex, GrColorType::kRGBA_8888,
- kTopLeft_GrSurfaceOrigin,
+ auto proxy = proxyProvider->wrapBackendTexture(backendTex, kTopLeft_GrSurfaceOrigin,
kBorrow_GrWrapOwnership,
GrWrapCacheable::kNo, ioType);
auto surfContext = context->priv().makeWrappedSurfaceContext(proxy, GrColorType::kRGBA_8888,
@@ -400,8 +399,7 @@
kSize, kSize, kRGBA_8888_SkColorType,
SkColors::kTransparent, GrMipMapped::kYes, GrRenderable::kYes,
GrProtected::kNo);
- proxy = proxyProvider->wrapBackendTexture(backendTex, GrColorType::kRGBA_8888,
- kTopLeft_GrSurfaceOrigin,
+ proxy = proxyProvider->wrapBackendTexture(backendTex, kTopLeft_GrSurfaceOrigin,
kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
ioType);
context->flush();
@@ -427,8 +425,7 @@
GrWrapCacheable::kNo);
} else {
texture = context->priv().resourceProvider()->wrapBackendTexture(
- backendTexture, GrColorType::kRGBA_8888, kBorrow_GrWrapOwnership,
- GrWrapCacheable::kNo, kRW_GrIOType);
+ backendTexture, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kRW_GrIOType);
}
// Add a release proc that deletes the GrBackendTexture.
struct ReleaseContext {
diff --git a/tests/GrTestingBackendTextureUploadTest.cpp b/tests/GrTestingBackendTextureUploadTest.cpp
index 96a7f8c..ec073b3 100644
--- a/tests/GrTestingBackendTextureUploadTest.cpp
+++ b/tests/GrTestingBackendTextureUploadTest.cpp
@@ -72,8 +72,8 @@
GrWrapCacheable::kNo);
} else {
wrappedProxy = context->priv().proxyProvider()->wrapBackendTexture(
- backendTex, grCT, kTopLeft_GrSurfaceOrigin, kAdopt_GrWrapOwnership,
- GrWrapCacheable::kNo, GrIOType::kRW_GrIOType);
+ backendTex, kTopLeft_GrSurfaceOrigin, kAdopt_GrWrapOwnership, GrWrapCacheable::kNo,
+ GrIOType::kRW_GrIOType);
}
REPORTER_ASSERT(reporter, wrappedProxy);
diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp
index ef4dcb4..6067e1f 100644
--- a/tests/LazyProxyTest.cpp
+++ b/tests/LazyProxyTest.cpp
@@ -462,9 +462,8 @@
[instantiatePtr, releasePtr,
backendTex](GrResourceProvider* rp) -> GrSurfaceProxy::LazyInstantiationResult {
sk_sp<GrTexture> texture =
- rp->wrapBackendTexture(backendTex, GrColorType::kRGBA_8888,
- kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
- kRead_GrIOType);
+ rp->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership,
+ GrWrapCacheable::kNo, kRead_GrIOType);
if (!texture) {
return {};
}
diff --git a/tests/ProxyConversionTest.cpp b/tests/ProxyConversionTest.cpp
index b366416..daf983d 100644
--- a/tests/ProxyConversionTest.cpp
+++ b/tests/ProxyConversionTest.cpp
@@ -28,7 +28,7 @@
SkASSERT(1 == desc.fSampleCnt);
auto ct = GrPixelConfigToColorType(desc.fConfig);
auto backendRT = gpu->createTestingOnlyBackendRenderTarget(desc.fWidth, desc.fHeight, ct);
- return provider->wrapBackendRenderTarget(backendRT, ct, origin, nullptr, nullptr);
+ return provider->wrapBackendRenderTarget(backendRT, origin, nullptr, nullptr);
}
void clean_up_wrapped_rt(GrGpu* gpu, sk_sp<GrSurfaceProxy> proxy) {
diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp
index 77b85fb..7e3c040 100644
--- a/tests/ProxyTest.cpp
+++ b/tests/ProxyTest.cpp
@@ -32,9 +32,7 @@
REPORTER_ASSERT(reporter, proxy->origin() == origin);
REPORTER_ASSERT(reporter, proxy->width() == width);
REPORTER_ASSERT(reporter, proxy->height() == height);
-#ifdef SK_DEBUG
- REPORTER_ASSERT(reporter, GrCaps::AreConfigsCompatible(config, proxy->config()));
-#endif
+ REPORTER_ASSERT(reporter, proxy->config() == config);
REPORTER_ASSERT(reporter, !proxy->uniqueID().isInvalid());
REPORTER_ASSERT(reporter, proxy->isBudgeted() == budgeted);
}
@@ -222,9 +220,6 @@
for (auto colorType : { kAlpha_8_SkColorType, kRGBA_8888_SkColorType,
kRGBA_1010102_SkColorType }) {
GrColorType grColorType = SkColorTypeToGrColorType(colorType);
- GrPixelConfig config = GrColorTypeToPixelConfig(grColorType);
- SkASSERT(kUnknown_GrPixelConfig != config);
-
// External on-screen render target.
// Tests wrapBackendRenderTarget with a GrBackendRenderTarget
// Our test-only function that creates a backend render target doesn't currently support
@@ -233,10 +228,10 @@
GrBackendRenderTarget backendRT = gpu->createTestingOnlyBackendRenderTarget(
kWidthHeight, kWidthHeight, grColorType);
sk_sp<GrSurfaceProxy> sProxy(
- proxyProvider->wrapBackendRenderTarget(backendRT, grColorType,
- origin, nullptr, nullptr));
+ proxyProvider->wrapBackendRenderTarget(backendRT, origin, nullptr,
+ nullptr));
check_surface(reporter, sProxy.get(), origin, kWidthHeight, kWidthHeight,
- config, SkBudgeted::kNo);
+ backendRT.pixelConfig(), SkBudgeted::kNo);
static constexpr int kExpectedNumSamples = 1;
check_rendertarget(reporter, caps, resourceProvider, sProxy->asRenderTargetProxy(),
kExpectedNumSamples, SkBackingFit::kExact,
@@ -245,6 +240,8 @@
}
for (auto numSamples : {1, 4}) {
+ GrPixelConfig config = GrColorTypeToPixelConfig(grColorType);
+ SkASSERT(kUnknown_GrPixelConfig != config);
int supportedNumSamples = caps.getRenderTargetSampleCount(numSamples, config);
if (!supportedNumSamples) {
@@ -264,11 +261,11 @@
kStencilBits, fboInfo);
backendRT.setPixelConfig(config);
sk_sp<GrSurfaceProxy> sProxy(
- proxyProvider->wrapBackendRenderTarget(backendRT, grColorType,
- origin, nullptr, nullptr));
+ proxyProvider->wrapBackendRenderTarget(backendRT, origin, nullptr,
+ nullptr));
check_surface(reporter, sProxy.get(), origin,
kWidthHeight, kWidthHeight,
- config, SkBudgeted::kNo);
+ backendRT.pixelConfig(), SkBudgeted::kNo);
check_rendertarget(reporter, caps, resourceProvider,
sProxy->asRenderTargetProxy(),
supportedNumSamples, SkBackingFit::kExact, 0);
@@ -284,7 +281,7 @@
GrRenderable::kYes,
GrProtected::kNo);
sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapBackendTextureAsRenderTarget(
- backendTex, grColorType, origin, supportedNumSamples);
+ backendTex, origin, supportedNumSamples);
if (!sProxy) {
context->deleteBackendTexture(backendTex);
continue; // This can fail on Mesa
@@ -292,7 +289,7 @@
check_surface(reporter, sProxy.get(), origin,
kWidthHeight, kWidthHeight,
- config, SkBudgeted::kNo);
+ backendTex.pixelConfig(), SkBudgeted::kNo);
check_rendertarget(reporter, caps, resourceProvider,
sProxy->asRenderTargetProxy(),
supportedNumSamples, SkBackingFit::kExact,
@@ -322,7 +319,7 @@
check_surface(reporter, sProxy.get(), origin,
kWidthHeight, kWidthHeight,
- config, SkBudgeted::kNo);
+ backendTex.pixelConfig(), SkBudgeted::kNo);
check_rendertarget(reporter, caps, resourceProvider,
sProxy->asRenderTargetProxy(),
supportedNumSamples, SkBackingFit::kExact,
@@ -343,8 +340,8 @@
GrProtected::kNo);
sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapBackendTexture(
- backendTex, grColorType, origin, kBorrow_GrWrapOwnership,
- GrWrapCacheable::kNo, kRead_GrIOType);
+ backendTex, origin, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
+ kRead_GrIOType);
if (!sProxy) {
context->deleteBackendTexture(backendTex);
continue;
@@ -352,7 +349,7 @@
check_surface(reporter, sProxy.get(), origin,
kWidthHeight, kWidthHeight,
- config, SkBudgeted::kNo);
+ backendTex.pixelConfig(), SkBudgeted::kNo);
check_texture(reporter, resourceProvider, sProxy->asTextureProxy(),
SkBackingFit::kExact);
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index 3fe450a..4b8f0f7 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -161,8 +161,7 @@
}
sk_sp<GrTextureProxy> rectProxy = proxyProvider->wrapBackendTexture(
- rectangleTex, GrColorType::kRGBA_8888, origin,
- kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kRW_GrIOType);
+ rectangleTex, origin, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kRW_GrIOType);
if (!rectProxy) {
ERRORF(reporter, "Error creating proxy for rectangle texture.");
diff --git a/tests/ResourceAllocatorTest.cpp b/tests/ResourceAllocatorTest.cpp
index 390abdc..db3eab5 100644
--- a/tests/ResourceAllocatorTest.cpp
+++ b/tests/ResourceAllocatorTest.cpp
@@ -24,7 +24,7 @@
struct ProxyParams {
int fSize;
GrRenderable fRenderable;
- GrColorType fColorType;
+ SkColorType fColorType;
SkBackingFit fFit;
int fSampleCnt;
GrSurfaceOrigin fOrigin;
@@ -34,7 +34,8 @@
static sk_sp<GrSurfaceProxy> make_deferred(GrProxyProvider* proxyProvider, const GrCaps* caps,
const ProxyParams& p) {
- GrPixelConfig config = GrColorTypeToPixelConfig(p.fColorType);
+ GrColorType grCT = SkColorTypeToGrColorType(p.fColorType);
+ GrPixelConfig config = GrColorTypeToPixelConfig(grCT);
GrSurfaceDesc desc;
desc.fWidth = p.fSize;
@@ -42,7 +43,7 @@
desc.fConfig = config;
desc.fSampleCnt = p.fSampleCnt;
- const GrBackendFormat format = caps->getBackendFormatFromColorType(p.fColorType);
+ const GrBackendFormat format = caps->getBackendFormatFromColorType(grCT);
return proxyProvider->createProxy(format, desc, p.fRenderable, p.fOrigin, p.fFit, p.fBudgeted);
}
@@ -51,10 +52,7 @@
GrBackendTexture* backendTex) {
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
- SkColorType skColorType = GrColorTypeToSkColorType(p.fColorType);
- SkASSERT(SkColorType::kUnknown_SkColorType != skColorType);
-
- *backendTex = context->createBackendTexture(p.fSize, p.fSize, skColorType,
+ *backendTex = context->createBackendTexture(p.fSize, p.fSize, p.fColorType,
SkColors::kTransparent,
GrMipMapped::kNo, GrRenderable::kNo,
GrProtected::kNo);
@@ -62,9 +60,8 @@
return nullptr;
}
- return proxyProvider->wrapBackendTexture(*backendTex, p.fColorType, p.fOrigin,
- kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
- kRead_GrIOType);
+ return proxyProvider->wrapBackendTexture(*backendTex, p.fOrigin, kBorrow_GrWrapOwnership,
+ GrWrapCacheable::kNo, kRead_GrIOType);
}
static void cleanup_backend(GrContext* context, const GrBackendTexture& backendTex) {
@@ -149,8 +146,8 @@
// Non-RT GrSurfaces are never recycled on some platforms.
bool kConditionallyShare = resourceProvider->caps()->reuseScratchTextures();
- const GrColorType kRGBA = GrColorType::kRGBA_8888;
- const GrColorType kBGRA = GrColorType::kBGRA_8888;
+ const SkColorType kRGBA = kRGBA_8888_SkColorType;
+ const SkColorType kBGRA = kBGRA_8888_SkColorType;
const SkBackingFit kE = SkBackingFit::kExact;
const SkBackingFit kA = SkBackingFit::kApprox;
@@ -271,7 +268,8 @@
sk_sp<GrSurfaceProxy> make_lazy(GrProxyProvider* proxyProvider, const GrCaps* caps,
const ProxyParams& p, bool deinstantiate) {
- GrPixelConfig config = GrColorTypeToPixelConfig(p.fColorType);
+ GrColorType grCT = SkColorTypeToGrColorType(p.fColorType);
+ GrPixelConfig config = GrColorTypeToPixelConfig(grCT);
GrSurfaceDesc desc;
desc.fWidth = p.fSize;
@@ -291,7 +289,7 @@
}
return GrSurfaceProxy::LazyInstantiationResult(std::move(texture));
};
- const GrBackendFormat format = caps->getBackendFormatFromColorType(p.fColorType);
+ const GrBackendFormat format = caps->getBackendFormatFromColorType(grCT);
auto lazyType = deinstantiate ? GrSurfaceProxy::LazyInstantiationType ::kDeinstantiate
: GrSurfaceProxy::LazyInstantiationType ::kSingleUse;
GrInternalSurfaceFlags flags = GrInternalSurfaceFlags::kNone;
@@ -305,7 +303,7 @@
ProxyParams texParams;
texParams.fFit = SkBackingFit::kExact;
texParams.fOrigin = kTopLeft_GrSurfaceOrigin;
- texParams.fColorType = GrColorType::kRGBA_8888;
+ texParams.fColorType = kRGBA_8888_SkColorType;
texParams.fRenderable = GrRenderable::kNo;
texParams.fSampleCnt = 1;
texParams.fSize = 100;
@@ -359,7 +357,7 @@
// Force the resource allocator to always believe it is over budget
context->setResourceCacheLimits(0, 0);
- const ProxyParams params = { 64, GrRenderable::kNo, GrColorType::kRGBA_8888,
+ const ProxyParams params = { 64, GrRenderable::kNo, kRGBA_8888_SkColorType,
SkBackingFit::kExact, 0, kTopLeft_GrSurfaceOrigin,
SkBudgeted::kYes };
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index c50ad71..da9f7da 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -218,12 +218,10 @@
context->resetContext();
sk_sp<GrTexture> borrowed(resourceProvider->wrapBackendTexture(
- backendTextures[0], GrColorType::kRGBA_8888,
- kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kRead_GrIOType));
+ backendTextures[0], kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kRead_GrIOType));
sk_sp<GrTexture> adopted(resourceProvider->wrapBackendTexture(
- backendTextures[1], GrColorType::kRGBA_8888,
- kAdopt_GrWrapOwnership, GrWrapCacheable::kNo, kRead_GrIOType));
+ backendTextures[1], kAdopt_GrWrapOwnership, GrWrapCacheable::kNo, kRead_GrIOType));
REPORTER_ASSERT(reporter, borrowed != nullptr && adopted != nullptr);
if (!borrowed || !adopted) {
diff --git a/tests/TextureProxyTest.cpp b/tests/TextureProxyTest.cpp
index bd0e5d1..e4f1104 100644
--- a/tests/TextureProxyTest.cpp
+++ b/tests/TextureProxyTest.cpp
@@ -111,9 +111,9 @@
GrBackendTexture backendTex = (*backingSurface)->getBackendTexture();
backendTex.setPixelConfig(desc.fConfig);
- return proxyProvider->wrapBackendTexture(backendTex, GrColorType::kRGBA_8888,
- kBottomLeft_GrSurfaceOrigin, kBorrow_GrWrapOwnership,
- GrWrapCacheable::kYes, kRead_GrIOType);
+ return proxyProvider->wrapBackendTexture(backendTex, kBottomLeft_GrSurfaceOrigin,
+ kBorrow_GrWrapOwnership, GrWrapCacheable::kYes,
+ kRead_GrIOType);
}
diff --git a/tests/VkWrapTests.cpp b/tests/VkWrapTests.cpp
index 09a1d4f..97917c6 100644
--- a/tests/VkWrapTests.cpp
+++ b/tests/VkWrapTests.cpp
@@ -46,9 +46,8 @@
GrVkImageInfo imageInfo;
SkAssertResult(origBackendTex.getVkImageInfo(&imageInfo));
- sk_sp<GrTexture> tex = gpu->wrapBackendTexture(origBackendTex, kGrColorType,
- kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
- kRead_GrIOType);
+ sk_sp<GrTexture> tex = gpu->wrapBackendTexture(origBackendTex, kBorrow_GrWrapOwnership,
+ GrWrapCacheable::kNo, kRead_GrIOType);
REPORTER_ASSERT(reporter, tex);
// image is null
@@ -57,11 +56,11 @@
backendCopy.fImage = VK_NULL_HANDLE;
GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy);
backendTex.setPixelConfig(kPixelConfig);
- tex = gpu->wrapBackendTexture(backendTex, kGrColorType, kBorrow_GrWrapOwnership,
- GrWrapCacheable::kNo, kRead_GrIOType);
+ tex = gpu->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
+ kRead_GrIOType);
REPORTER_ASSERT(reporter, !tex);
- tex = gpu->wrapBackendTexture(backendTex, kGrColorType, kAdopt_GrWrapOwnership,
- GrWrapCacheable::kNo, kRead_GrIOType);
+ tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership, GrWrapCacheable::kNo,
+ kRead_GrIOType);
REPORTER_ASSERT(reporter, !tex);
}
@@ -71,11 +70,11 @@
backendCopy.fAlloc = GrVkAlloc();
GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy);
backendTex.setPixelConfig(kPixelConfig);
- tex = gpu->wrapBackendTexture(backendTex, kGrColorType, kBorrow_GrWrapOwnership,
- GrWrapCacheable::kNo, kRead_GrIOType);
+ tex = gpu->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
+ kRead_GrIOType);
REPORTER_ASSERT(reporter, tex);
- tex = gpu->wrapBackendTexture(backendTex, kGrColorType, kAdopt_GrWrapOwnership,
- GrWrapCacheable::kNo, kRead_GrIOType);
+ tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership, GrWrapCacheable::kNo,
+ kRead_GrIOType);
REPORTER_ASSERT(reporter, !tex);
}
@@ -84,8 +83,8 @@
GrVkImageInfo backendCopy = imageInfo;
GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy);
backendTex.setPixelConfig(kPixelConfig);
- tex = gpu->wrapBackendTexture(backendTex, kGrColorType, kAdopt_GrWrapOwnership,
- GrWrapCacheable::kNo, kRead_GrIOType);
+ tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership, GrWrapCacheable::kNo,
+ kRead_GrIOType);
REPORTER_ASSERT(reporter, tex);
}
@@ -107,7 +106,7 @@
GrBackendRenderTarget origBackendRT(kW, kH, 1, 0, imageInfo);
origBackendRT.setPixelConfig(kPixelConfig);
- sk_sp<GrRenderTarget> rt = gpu->wrapBackendRenderTarget(origBackendRT, kGrColorType);
+ sk_sp<GrRenderTarget> rt = gpu->wrapBackendRenderTarget(origBackendRT);
REPORTER_ASSERT(reporter, rt);
// image is null
@@ -116,7 +115,7 @@
backendCopy.fImage = VK_NULL_HANDLE;
GrBackendRenderTarget backendRT(kW, kH, 1, 0, backendCopy);
backendRT.setPixelConfig(kPixelConfig);
- rt = gpu->wrapBackendRenderTarget(backendRT, kGrColorType);
+ rt = gpu->wrapBackendRenderTarget(backendRT);
REPORTER_ASSERT(reporter, !rt);
}
@@ -127,7 +126,7 @@
// can wrap null alloc
GrBackendRenderTarget backendRT(kW, kH, 1, 0, backendCopy);
backendRT.setPixelConfig(kPixelConfig);
- rt = gpu->wrapBackendRenderTarget(backendRT, kGrColorType);
+ rt = gpu->wrapBackendRenderTarget(backendRT);
REPORTER_ASSERT(reporter, rt);
}
diff --git a/tools/gpu/ProxyUtils.cpp b/tools/gpu/ProxyUtils.cpp
index c63fcc2..6a2fe74 100644
--- a/tools/gpu/ProxyUtils.cpp
+++ b/tools/gpu/ProxyUtils.cpp
@@ -50,8 +50,7 @@
nullptr, nullptr);
} else {
proxy = context->priv().proxyProvider()->wrapBackendTexture(
- backendTex, colorType, origin, kAdopt_GrWrapOwnership,
- GrWrapCacheable::kNo, kRW_GrIOType);
+ backendTex, origin, kAdopt_GrWrapOwnership, GrWrapCacheable::kNo, kRW_GrIOType);
}
if (!proxy) {