Revert "Make rest of GrGpu::wrapBackend* methods take a GrColorType"
This reverts commit 9725638fb1
.
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>
This commit is contained in:
parent
82bd511527
commit
dd39980115
@ -216,9 +216,10 @@ public:
|
||||
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 @@ public:
|
||||
|
||||
|
||||
#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&);
|
||||
|
@ -61,8 +61,6 @@ struct GrMockRenderTargetInfo {
|
||||
|
||||
GrBackendFormat getBackendFormat() const;
|
||||
|
||||
GrColorType colorType() const { return fColorType; }
|
||||
|
||||
private:
|
||||
GrColorType fColorType;
|
||||
int fID;
|
||||
|
@ -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 @@ static constexpr GrColorType SkColorTypeToGrColorType(SkColorType ct) {
|
||||
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;
|
||||
|
@ -95,9 +95,8 @@ sk_sp<GrTextureProxy> GrAHardwareBufferImageGenerator::makeProxy(GrRecordingCont
|
||||
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> GrAHardwareBufferImageGenerator::makeProxy(GrRecordingCont
|
||||
|
||||
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 @@ sk_sp<GrTextureProxy> GrAHardwareBufferImageGenerator::makeProxy(GrRecordingCont
|
||||
// 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 {};
|
||||
|
@ -51,20 +51,15 @@ GrBackendTextureImageGenerator::Make(sk_sp<GrTexture> texture, GrSurfaceOrigin o
|
||||
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 @@ GrBackendTextureImageGenerator::GrBackendTextureImageGenerator(const SkImageInfo
|
||||
, fRefHelper(new RefHelper(texture, owningContextID))
|
||||
, fSemaphore(std::move(semaphore))
|
||||
, fBackendTexture(backendTex)
|
||||
, fConfig(backendTex.config())
|
||||
, fSurfaceOrigin(origin) {}
|
||||
|
||||
GrBackendTextureImageGenerator::~GrBackendTextureImageGenerator() {
|
||||
@ -114,7 +110,6 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
|
||||
}
|
||||
|
||||
auto proxyProvider = context->priv().proxyProvider();
|
||||
const GrCaps* caps = context->priv().caps();
|
||||
|
||||
fBorrowingMutex.acquire();
|
||||
sk_sp<GrRefCntedCallback> releaseProcHelper;
|
||||
@ -146,32 +141,20 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
|
||||
|
||||
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 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
|
||||
// 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 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
|
||||
// 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;
|
||||
}
|
||||
|
@ -80,6 +80,7 @@ private:
|
||||
sk_sp<GrSemaphore> fSemaphore;
|
||||
|
||||
GrBackendTexture fBackendTexture;
|
||||
GrPixelConfig fConfig;
|
||||
GrSurfaceOrigin fSurfaceOrigin;
|
||||
|
||||
typedef SkImageGenerator INHERITED;
|
||||
|
@ -396,8 +396,7 @@ public:
|
||||
* 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;
|
||||
|
@ -106,7 +106,7 @@ sk_sp<GrTextureContext> GrContextPriv::makeBackendTextureContext(const GrBackend
|
||||
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 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendRenderTargetRenderTargetC
|
||||
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 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureAsRenderTargetRend
|
||||
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;
|
||||
}
|
||||
|
@ -581,19 +581,3 @@ bool GrConvertPixels(const GrPixelInfo& dstInfo, void* dst, size_t dstRB,
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
@ -221,29 +221,19 @@ sk_sp<GrTexture> GrGpu::createCompressedTexture(int width, int height,
|
||||
}
|
||||
|
||||
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 @@ sk_sp<GrTexture> GrGpu::wrapRenderableBackendTexture(const GrBackendTexture& bac
|
||||
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,
|
||||
|
@ -118,8 +118,8 @@ public:
|
||||
/**
|
||||
* 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 @@ public:
|
||||
/**
|
||||
* 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 @@ private:
|
||||
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&);
|
||||
|
||||
|
@ -521,7 +521,6 @@ sk_sp<GrTextureProxy> GrProxyProvider::createCompressedTextureProxy(
|
||||
}
|
||||
|
||||
sk_sp<GrTextureProxy> GrProxyProvider::wrapBackendTexture(const GrBackendTexture& backendTex,
|
||||
GrColorType grColorType,
|
||||
GrSurfaceOrigin origin,
|
||||
GrWrapOwnership ownership,
|
||||
GrWrapCacheable cacheable,
|
||||
@ -539,21 +538,13 @@ sk_sp<GrTextureProxy> GrProxyProvider::wrapBackendTexture(const GrBackendTexture
|
||||
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 @@ sk_sp<GrTextureProxy> GrProxyProvider::wrapBackendTexture(const GrBackendTexture
|
||||
// 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<GrTextureProxy> GrProxyProvider::wrapRenderableBackendTexture(
|
||||
}
|
||||
|
||||
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 @@ sk_sp<GrSurfaceProxy> GrProxyProvider::wrapBackendRenderTarget(
|
||||
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 @@ sk_sp<GrSurfaceProxy> GrProxyProvider::wrapBackendRenderTarget(
|
||||
// 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 @@ sk_sp<GrSurfaceProxy> GrProxyProvider::wrapBackendTextureAsRenderTarget(
|
||||
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 @@ sk_sp<GrSurfaceProxy> GrProxyProvider::wrapBackendTextureAsRenderTarget(
|
||||
// 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));
|
||||
|
@ -110,7 +110,7 @@ public:
|
||||
* 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 @@ public:
|
||||
/*
|
||||
* 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&,
|
||||
|
@ -334,7 +334,6 @@ sk_sp<GrTexture> GrResourceProvider::refScratchTexture(const GrSurfaceDesc& desc
|
||||
}
|
||||
|
||||
sk_sp<GrTexture> GrResourceProvider::wrapBackendTexture(const GrBackendTexture& tex,
|
||||
GrColorType colorType,
|
||||
GrWrapOwnership ownership,
|
||||
GrWrapCacheable cacheable,
|
||||
GrIOType ioType) {
|
||||
@ -342,7 +341,7 @@ sk_sp<GrTexture> GrResourceProvider::wrapBackendTexture(const GrBackendTexture&
|
||||
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<GrTexture> GrResourceProvider::wrapRenderableBackendTexture(const GrBacken
|
||||
}
|
||||
|
||||
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 @@ bool GrResourceProvider::attachStencilAttachment(GrRenderTarget* rt, int minSten
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -109,7 +109,7 @@ public:
|
||||
*
|
||||
* @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 @@ public:
|
||||
*
|
||||
* @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 @@ public:
|
||||
* @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
|
||||
|
@ -3653,29 +3653,6 @@ GrPixelConfig GrGLCaps::getYUVAConfigFromBackendFormat(const GrBackendFormat& fo
|
||||
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) {
|
||||
|
@ -447,7 +447,6 @@ public:
|
||||
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;
|
||||
|
@ -680,8 +680,8 @@ static bool check_backend_texture(const GrBackendTexture& backendTex, const GrGL
|
||||
}
|
||||
|
||||
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 @@ sk_sp<GrTexture> GrGLGpu::onWrapBackendTexture(const GrBackendTexture& backendTe
|
||||
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 @@ sk_sp<GrTexture> GrGLGpu::onWrapRenderableBackendTexture(const GrBackendTexture&
|
||||
|
||||
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 @@ sk_sp<GrTexture> GrGLGpu::onWrapRenderableBackendTexture(const GrBackendTexture&
|
||||
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 @@ sk_sp<GrRenderTarget> GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTa
|
||||
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 @@ sk_sp<GrRenderTarget> GrGLGpu::onWrapBackendTextureAsRenderTarget(const GrBacken
|
||||
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)) {
|
||||
|
@ -200,15 +200,14 @@ private:
|
||||
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.
|
||||
|
@ -137,14 +137,6 @@ public:
|
||||
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);
|
||||
}
|
||||
|
@ -114,23 +114,21 @@ sk_sp<GrTexture> GrMockGpu::onCreateCompressedTexture(int width, int height,
|
||||
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 @@ sk_sp<GrTexture> GrMockGpu::onWrapRenderableBackendTexture(const GrBackendTextur
|
||||
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::onWrapBackendRenderTarget(const GrBackendRender
|
||||
}
|
||||
|
||||
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();
|
||||
|
@ -69,8 +69,8 @@ private:
|
||||
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 @@ private:
|
||||
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;
|
||||
|
@ -72,7 +72,6 @@ public:
|
||||
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;
|
||||
|
@ -765,32 +765,6 @@ GrPixelConfig GrMtlCaps::getYUVAConfigFromBackendFormat(const GrBackendFormat& f
|
||||
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) {
|
||||
|
@ -142,19 +142,17 @@ private:
|
||||
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;
|
||||
|
@ -516,7 +516,6 @@ static inline void init_surface_desc(GrSurfaceDesc* surfaceDesc, id<MTLTexture>
|
||||
}
|
||||
|
||||
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 @@ sk_sp<GrTexture> GrMtlGpu::onWrapBackendTexture(const GrBackendTexture& backendT
|
||||
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 @@ sk_sp<GrTexture> GrMtlGpu::onWrapRenderableBackendTexture(const GrBackendTexture
|
||||
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 @@ sk_sp<GrTexture> GrMtlGpu::onWrapRenderableBackendTexture(const GrBackendTexture
|
||||
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 @@ sk_sp<GrRenderTarget> GrMtlGpu::onWrapBackendRenderTarget(const GrBackendRenderT
|
||||
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;
|
||||
}
|
||||
|
@ -1118,30 +1118,6 @@ GrPixelConfig GrVkCaps::getYUVAConfigFromBackendFormat(const GrBackendFormat& fo
|
||||
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) {
|
||||
|
@ -166,7 +166,6 @@ public:
|
||||
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;
|
||||
|
@ -1120,7 +1120,7 @@ bool GrVkGpu::updateBuffer(GrVkBuffer* buffer, const void* src,
|
||||
|
||||
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 @@ static bool check_image_info(const GrVkCaps& caps,
|
||||
return false;
|
||||
}
|
||||
|
||||
SkASSERT(GrVkFormatColorTypePairIsValid(info.fFormat, colorType));
|
||||
SkASSERT(GrVkFormatPixelConfigPairIsValid(info.fFormat, config));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1166,14 +1166,14 @@ static bool check_rt_image_info(const GrVkCaps& caps, const GrVkImageInfo& info)
|
||||
}
|
||||
|
||||
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 @@ sk_sp<GrTexture> GrVkGpu::onWrapBackendTexture(const GrBackendTexture& backendTe
|
||||
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 @@ sk_sp<GrTexture> GrVkGpu::onWrapRenderableBackendTexture(const GrBackendTexture&
|
||||
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 @@ sk_sp<GrTexture> GrVkGpu::onWrapRenderableBackendTexture(const GrBackendTexture&
|
||||
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 @@ sk_sp<GrTexture> GrVkGpu::onWrapRenderableBackendTexture(const GrBackendTexture&
|
||||
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 @@ sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTa
|
||||
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 @@ sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTa
|
||||
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::onWrapBackendRenderTarget(const GrBackendRenderTa
|
||||
}
|
||||
|
||||
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 @@ sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendTextureAsRenderTarget(const GrBacken
|
||||
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;
|
||||
}
|
||||
|
@ -196,18 +196,17 @@ private:
|
||||
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;
|
||||
|
@ -97,35 +97,56 @@ bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format) {
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
|
@ -38,9 +38,9 @@ bool GrVkFormatIsSupported(VkFormat);
|
||||
|
||||
#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);
|
||||
|
@ -116,7 +116,7 @@ sk_sp<SkImage> SkImage_Gpu::onMakeColorTypeAndColorSpace(GrRecordingContext* con
|
||||
|
||||
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 @@ static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx,
|
||||
|
||||
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 @@ sk_sp<SkImage> SkImage::MakeFromTexture(GrContext* ctx,
|
||||
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 @@ sk_sp<SkImage> SkImage::MakeFromAdoptedTexture(GrContext* ctx,
|
||||
// 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 @@ sk_sp<SkImage> SkImage::MakeFromYUVATexturesCopyWithExternalBackend(
|
||||
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 @@ sk_sp<SkImage> SkImage::MakeFromYUVATexturesCopyWithExternalBackend(
|
||||
// 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 @@ sk_sp<SkImage> SkImage_Gpu::MakePromiseTexture(GrContext* context,
|
||||
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 @@ sk_sp<SkImage> SkImage::MakeFromAHardwareBufferWithData(GrContext* context,
|
||||
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<SkImage> SkImage::MakeFromAHardwareBufferWithData(GrContext* context,
|
||||
}
|
||||
|
||||
sk_sp<GrTextureProxy> proxy =
|
||||
proxyProvider->wrapBackendTexture(backendTexture, grColorType, surfaceOrigin,
|
||||
proxyProvider->wrapBackendTexture(backendTexture, surfaceOrigin,
|
||||
kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
|
||||
kRW_GrIOType, deleteImageProc, deleteImageCtx);
|
||||
if (!proxy) {
|
||||
|
@ -39,8 +39,7 @@ void SkImage_GpuBase::resetContext(sk_sp<GrContext> newContext) {
|
||||
#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 @@ bool SkImage_GpuBase::ValidateBackendTexture(GrContext* ctx, const GrBackendText
|
||||
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 @@ bool SkImage_GpuBase::MakeTempTextureProxies(GrContext* ctx, const GrBackendText
|
||||
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 @@ bool SkImage_GpuBase::MakeTempTextureProxies(GrContext* ctx, const GrBackendText
|
||||
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 @@ bool SkImage_GpuBase::RenderYUVAToRGBA(GrContext* ctx, GrRenderTargetContext* re
|
||||
}
|
||||
|
||||
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 @@ sk_sp<GrTextureProxy> SkImage_GpuBase::MakePromiseImageLazyProxy(
|
||||
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 @@ sk_sp<GrTextureProxy> SkImage_GpuBase::MakePromiseImageLazyProxy(
|
||||
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 @@ sk_sp<GrTextureProxy> SkImage_GpuBase::MakePromiseImageLazyProxy(
|
||||
// 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 @@ sk_sp<GrTextureProxy> SkImage_GpuBase::MakePromiseImageLazyProxy(
|
||||
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 @@ sk_sp<GrTextureProxy> SkImage_GpuBase::MakePromiseImageLazyProxy(
|
||||
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<GrTextureProxy> SkImage_GpuBase::MakePromiseImageLazyProxy(
|
||||
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;
|
||||
|
@ -58,8 +58,7 @@ public:
|
||||
#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 @@ protected:
|
||||
// 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);
|
||||
|
||||
|
@ -354,16 +354,15 @@ sk_sp<SkImage> SkImage_GpuYUVA::MakePromiseYUVATexture(
|
||||
// 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;
|
||||
|
@ -426,6 +426,21 @@ static bool validate_backend_texture(GrContext* ctx, const GrBackendTexture& tex
|
||||
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 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext* context,
|
||||
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 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext* context, const GrB
|
||||
}
|
||||
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 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext* context,
|
||||
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 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendTextureAsRenderTarget(GrContext* cont
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -591,9 +591,13 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(GLBackendAllocationTest, reporter, ctxInfo) {
|
||||
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)) {
|
||||
|
@ -1004,8 +1004,8 @@ DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, options) {
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -350,8 +350,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadOnlyTexture, reporter, context_info) {
|
||||
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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadOnlyTexture, reporter, context_info) {
|
||||
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 @@ static sk_sp<GrTexture> make_wrapped_texture(GrContext* context, GrRenderable re
|
||||
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 {
|
||||
|
@ -72,8 +72,8 @@ void testing_only_texture_test(skiatest::Reporter* reporter, GrContext* context,
|
||||
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);
|
||||
|
||||
|
@ -462,9 +462,8 @@ DEF_GPUTEST(LazyProxyDeinstantiateTest, reporter, /* options */) {
|
||||
[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 {};
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ static sk_sp<GrSurfaceProxy> make_wrapped_rt(GrProxyProvider* provider,
|
||||
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) {
|
||||
|
@ -32,9 +32,7 @@ static void check_surface(skiatest::Reporter* reporter,
|
||||
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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
|
||||
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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
|
||||
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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
|
||||
}
|
||||
|
||||
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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
|
||||
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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
|
||||
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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
|
||||
|
||||
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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
|
||||
|
||||
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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
|
||||
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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
|
||||
|
||||
check_surface(reporter, sProxy.get(), origin,
|
||||
kWidthHeight, kWidthHeight,
|
||||
config, SkBudgeted::kNo);
|
||||
backendTex.pixelConfig(), SkBudgeted::kNo);
|
||||
check_texture(reporter, resourceProvider, sProxy->asTextureProxy(),
|
||||
SkBackingFit::kExact);
|
||||
|
||||
|
@ -161,8 +161,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(RectangleTexture, reporter, ctxInfo) {
|
||||
}
|
||||
|
||||
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.");
|
||||
|
@ -24,7 +24,7 @@
|
||||
struct ProxyParams {
|
||||
int fSize;
|
||||
GrRenderable fRenderable;
|
||||
GrColorType fColorType;
|
||||
SkColorType fColorType;
|
||||
SkBackingFit fFit;
|
||||
int fSampleCnt;
|
||||
GrSurfaceOrigin fOrigin;
|
||||
@ -34,7 +34,8 @@ struct ProxyParams {
|
||||
|
||||
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 @@ static sk_sp<GrSurfaceProxy> make_deferred(GrProxyProvider* proxyProvider, const
|
||||
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 @@ static sk_sp<GrSurfaceProxy> make_backend(GrContext* context, const ProxyParams&
|
||||
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 @@ static sk_sp<GrSurfaceProxy> make_backend(GrContext* context, const ProxyParams&
|
||||
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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceAllocatorTest, reporter, ctxInfo) {
|
||||
// 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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceAllocatorStressTest, reporter, ctxInf
|
||||
|
||||
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 @@ sk_sp<GrSurfaceProxy> make_lazy(GrProxyProvider* proxyProvider, const GrCaps* ca
|
||||
}
|
||||
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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(LazyDeinstantiation, reporter, ctxInfo) {
|
||||
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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceAllocatorOverBudgetTest, reporter, ct
|
||||
// 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 };
|
||||
|
||||
|
@ -218,12 +218,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheWrappedResources, reporter, ctxI
|
||||
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) {
|
||||
|
@ -111,9 +111,9 @@ static sk_sp<GrTextureProxy> create_wrapped_backend(GrContext* context, SkBackin
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,9 +46,8 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
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 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
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 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
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 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
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 @@ void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
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 @@ void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
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 @@ void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
@ -50,8 +50,7 @@ sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context,
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user