Add rowBytes to createTestingOnlyBackendTexture
This is pulled out of: https://skia-review.googlesource.com/c/skia/+/151983 (Test YUV images in DDL) The YUV images seem to like to have row padding. Change-Id: I517d2b63678beeafef88f86148fca15862176780 Reviewed-on: https://skia-review.googlesource.com/156367 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
parent
0098ccbab5
commit
646f637f4c
@ -108,7 +108,7 @@ protected:
|
||||
yuvTextures[i] = gpu->createTestingOnlyBackendTexture(fYUVBmps[i].getPixels(),
|
||||
fYUVBmps[i].width(),
|
||||
fYUVBmps[i].height(),
|
||||
kAlpha_8_GrPixelConfig,
|
||||
GrColorType::kAlpha_8,
|
||||
false, GrMipMapped::kNo);
|
||||
}
|
||||
context->resetContext();
|
||||
@ -126,7 +126,7 @@ protected:
|
||||
}
|
||||
|
||||
*resultTexture = gpu->createTestingOnlyBackendTexture(
|
||||
nullptr, width, height, kRGBA_8888_GrPixelConfig, true, GrMipMapped::kNo);
|
||||
nullptr, width, height, GrColorType::kRGBA_8888, true, GrMipMapped::kNo);
|
||||
|
||||
context->resetContext();
|
||||
}
|
||||
|
@ -17,16 +17,16 @@ void SkConvertPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowB
|
||||
const SkImageInfo& srcInfo, const void* srcPixels, size_t srcRowBytes);
|
||||
|
||||
static inline void SkRectMemcpy(void* dst, size_t dstRB, const void* src, size_t srcRB,
|
||||
size_t bytesPerRow, int rowCount) {
|
||||
SkASSERT(bytesPerRow <= dstRB);
|
||||
SkASSERT(bytesPerRow <= srcRB);
|
||||
if (bytesPerRow == dstRB && bytesPerRow == srcRB) {
|
||||
memcpy(dst, src, bytesPerRow * rowCount);
|
||||
size_t trimRowBytes, int rowCount) {
|
||||
SkASSERT(trimRowBytes <= dstRB);
|
||||
SkASSERT(trimRowBytes <= srcRB);
|
||||
if (trimRowBytes == dstRB && trimRowBytes == srcRB) {
|
||||
memcpy(dst, src, trimRowBytes * rowCount);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < rowCount; ++i) {
|
||||
memcpy(dst, src, bytesPerRow);
|
||||
memcpy(dst, src, trimRowBytes);
|
||||
dst = SkTAddOffset<void>(dst, dstRB);
|
||||
src = SkTAddOffset<const void>(src, srcRB);
|
||||
}
|
||||
|
@ -366,3 +366,14 @@ void GrGpu::dumpJSON(SkJSONWriter* writer) const {
|
||||
|
||||
writer->endObject();
|
||||
}
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
GrBackendTexture GrGpu::createTestingOnlyBackendTexture(const void* pixels, int w, int h,
|
||||
SkColorType colorType, bool isRenderTarget,
|
||||
GrMipMapped isMipped, size_t rowBytes) {
|
||||
GrColorType grCT = SkColorTypeToGrColorType(colorType);
|
||||
|
||||
return this->createTestingOnlyBackendTexture(pixels, w, h, grCT, isRenderTarget, isMipped,
|
||||
rowBytes);
|
||||
}
|
||||
#endif
|
||||
|
@ -339,16 +339,17 @@ public:
|
||||
void dumpJSON(SkJSONWriter*) const;
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
GrBackendTexture createTestingOnlyBackendTexture(const void* pixels, int w, int h,
|
||||
SkColorType, bool isRenderTarget,
|
||||
GrMipMapped, size_t rowBytes = 0);
|
||||
|
||||
/** Creates a texture directly in the backend API without wrapping it in a GrTexture. This is
|
||||
only to be used for testing (particularly for testing the methods that import an externally
|
||||
created texture into Skia. Must be matched with a call to deleteTestingOnlyTexture(). */
|
||||
GrBackendTexture createTestingOnlyBackendTexture(const void* pixels, int w, int h, SkColorType,
|
||||
bool isRenderTarget, GrMipMapped);
|
||||
/** Older version based on GrPixelConfig. Currently the preferred one above devolves to this. */
|
||||
virtual GrBackendTexture createTestingOnlyBackendTexture(const void* pixels, int w, int h,
|
||||
GrPixelConfig config,
|
||||
bool isRenderTarget,
|
||||
GrMipMapped mipMapped) = 0;
|
||||
GrColorType, bool isRenderTarget,
|
||||
GrMipMapped, size_t rowBytes = 0) = 0;
|
||||
|
||||
/** Check a handle represents an actual texture in the backend API that has not been freed. */
|
||||
virtual bool isTestingOnlyBackendTexture(const GrBackendTexture&) const = 0;
|
||||
/**
|
||||
|
@ -3921,9 +3921,12 @@ void GrGLGpu::xferBarrier(GrRenderTarget* rt, GrXferBarrierType type) {
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
GrBackendTexture GrGLGpu::createTestingOnlyBackendTexture(const void* pixels, int w, int h,
|
||||
GrPixelConfig config, bool /*isRT*/,
|
||||
GrMipMapped mipMapped) {
|
||||
GrColorType colorType, bool /*isRT*/,
|
||||
GrMipMapped mipMapped,
|
||||
size_t rowBytes) {
|
||||
this->handleDirtyContext();
|
||||
|
||||
GrPixelConfig config = GrColorTypeToPixelConfig(colorType, GrSRGBEncoded::kNo);
|
||||
if (!this->caps()->isConfigTexturable(config)) {
|
||||
return GrBackendTexture(); // invalid
|
||||
}
|
||||
@ -3937,6 +3940,12 @@ GrBackendTexture GrGLGpu::createTestingOnlyBackendTexture(const void* pixels, in
|
||||
return GrBackendTexture(); // invalid
|
||||
}
|
||||
|
||||
int bpp = GrColorTypeBytesPerPixel(colorType);
|
||||
const size_t trimRowBytes = w * bpp;
|
||||
if (!rowBytes) {
|
||||
rowBytes = trimRowBytes;
|
||||
}
|
||||
|
||||
GrGLTextureInfo info;
|
||||
info.fTarget = GR_GL_TEXTURE_2D;
|
||||
info.fID = 0;
|
||||
@ -3950,6 +3959,12 @@ GrBackendTexture GrGLGpu::createTestingOnlyBackendTexture(const void* pixels, in
|
||||
GL_CALL(TexParameteri(info.fTarget, GR_GL_TEXTURE_WRAP_S, GR_GL_CLAMP_TO_EDGE));
|
||||
GL_CALL(TexParameteri(info.fTarget, GR_GL_TEXTURE_WRAP_T, GR_GL_CLAMP_TO_EDGE));
|
||||
|
||||
bool restoreGLRowLength = false;
|
||||
if (trimRowBytes != rowBytes && this->glCaps().unpackRowLengthSupport()) {
|
||||
GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, rowBytes / bpp));
|
||||
restoreGLRowLength = true;
|
||||
}
|
||||
|
||||
GrGLenum internalFormat;
|
||||
GrGLenum externalFormat;
|
||||
GrGLenum externalType;
|
||||
@ -3969,13 +3984,19 @@ GrBackendTexture GrGLGpu::createTestingOnlyBackendTexture(const void* pixels, in
|
||||
mipLevels = SkMipMap::ComputeLevelCount(w, h) + 1;
|
||||
}
|
||||
|
||||
size_t bpp = GrBytesPerPixel(config);
|
||||
size_t baseLayerSize = bpp * w * h;
|
||||
SkAutoMalloc defaultStorage(baseLayerSize);
|
||||
if (!pixels) {
|
||||
// Fill in the texture with all zeros so we don't have random garbage
|
||||
pixels = defaultStorage.get();
|
||||
memset(defaultStorage.get(), 0, baseLayerSize);
|
||||
} else if (trimRowBytes != rowBytes && !restoreGLRowLength) {
|
||||
// We weren't able to use GR_GL_UNPACK_ROW_LENGTH so make a copy
|
||||
char* copy = (char*) defaultStorage.get();
|
||||
for (int y = 0; y < h; ++y) {
|
||||
memcpy(©[y*trimRowBytes], &((const char*)pixels)[y*rowBytes], trimRowBytes);
|
||||
}
|
||||
pixels = copy;
|
||||
}
|
||||
|
||||
int width = w;
|
||||
@ -3990,6 +4011,10 @@ GrBackendTexture GrGLGpu::createTestingOnlyBackendTexture(const void* pixels, in
|
||||
// unbind the texture from the texture unit to avoid asserts
|
||||
GL_CALL(BindTexture(info.fTarget, 0));
|
||||
|
||||
if (restoreGLRowLength) {
|
||||
GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
|
||||
}
|
||||
|
||||
GrBackendTexture beTex = GrBackendTexture(w, h, mipMapped, info);
|
||||
// Lots of tests don't go through Skia's public interface which will set the config so for
|
||||
// testing we make sure we set a config here.
|
||||
|
@ -136,8 +136,9 @@ public:
|
||||
int height) override;
|
||||
#if GR_TEST_UTILS
|
||||
GrBackendTexture createTestingOnlyBackendTexture(const void* pixels, int w, int h,
|
||||
GrPixelConfig config, bool isRenderTarget,
|
||||
GrMipMapped mipMapped) override;
|
||||
GrColorType colorType, bool isRenderTarget,
|
||||
GrMipMapped mipMapped,
|
||||
size_t rowBytes = 0) override;
|
||||
bool isTestingOnlyBackendTexture(const GrBackendTexture&) const override;
|
||||
void deleteTestingOnlyBackendTexture(const GrBackendTexture&) override;
|
||||
|
||||
|
@ -192,8 +192,15 @@ GrStencilAttachment* GrMockGpu::createStencilAttachmentForRenderTarget(const GrR
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
GrBackendTexture GrMockGpu::createTestingOnlyBackendTexture(const void* pixels, int w, int h,
|
||||
GrPixelConfig config, bool isRT,
|
||||
GrMipMapped mipMapped) {
|
||||
GrColorType colorType, bool isRT,
|
||||
GrMipMapped mipMapped,
|
||||
size_t rowBytes) {
|
||||
|
||||
GrPixelConfig config = GrColorTypeToPixelConfig(colorType, GrSRGBEncoded::kNo);
|
||||
if (!this->caps()->isConfigTexturable(config)) {
|
||||
return GrBackendTexture(); // invalid
|
||||
}
|
||||
|
||||
GrMockTextureInfo info;
|
||||
info.fConfig = config;
|
||||
info.fID = NextExternalTextureID();
|
||||
|
@ -107,8 +107,8 @@ private:
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
GrBackendTexture createTestingOnlyBackendTexture(const void* pixels, int w, int h,
|
||||
GrPixelConfig, bool isRT,
|
||||
GrMipMapped) override;
|
||||
GrColorType, bool isRT,
|
||||
GrMipMapped, size_t rowBytes = 0) override;
|
||||
bool isTestingOnlyBackendTexture(const GrBackendTexture&) const override;
|
||||
void deleteTestingOnlyBackendTexture(const GrBackendTexture&) override;
|
||||
|
||||
|
@ -54,8 +54,8 @@ public:
|
||||
|
||||
#ifdef GR_TEST_UTILS
|
||||
GrBackendTexture createTestingOnlyBackendTexture(const void* pixels, int w, int h,
|
||||
GrPixelConfig config, bool isRT,
|
||||
GrMipMapped) override;
|
||||
GrColorType colorType, bool isRT,
|
||||
GrMipMapped, size_t rowBytes = 0) override;
|
||||
|
||||
bool isTestingOnlyBackendTexture(const GrBackendTexture&) const override;
|
||||
|
||||
@ -177,9 +177,10 @@ private:
|
||||
void clearStencil(GrRenderTarget* target, int clearValue) override {}
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
bool createTestingOnlyMtlTextureInfo(GrPixelConfig config, int w, int h, bool texturable,
|
||||
bool createTestingOnlyMtlTextureInfo(GrColorType colorType, int w, int h, bool texturable,
|
||||
bool renderable, GrMipMapped mipMapped,
|
||||
const void* srcData, GrMtlTextureInfo* info);
|
||||
const void* srcData, size_t rowBytes,
|
||||
GrMtlTextureInfo* info);
|
||||
#endif
|
||||
|
||||
sk_sp<GrMtlCaps> fMtlCaps;
|
||||
|
@ -383,15 +383,18 @@ sk_sp<GrRenderTarget> GrMtlGpu::onWrapBackendTextureAsRenderTarget(
|
||||
}
|
||||
|
||||
#ifdef GR_TEST_UTILS
|
||||
bool GrMtlGpu::createTestingOnlyMtlTextureInfo(GrPixelConfig config, int w, int h, bool texturable,
|
||||
bool renderable, GrMipMapped mipMapped,
|
||||
const void* srcData, GrMtlTextureInfo* info) {
|
||||
bool GrMtlGpu::createTestingOnlyMtlTextureInfo(GrColorType colorType, int w, int h, bool texturable,
|
||||
bool renderable, GrMipMapped mipMapped,
|
||||
const void* srcData, size_t srcRowBytes,
|
||||
GrMtlTextureInfo* info) {
|
||||
SkASSERT(texturable || renderable);
|
||||
if (!texturable) {
|
||||
SkASSERT(GrMipMapped::kNo == mipMapped);
|
||||
SkASSERT(!srcData);
|
||||
}
|
||||
|
||||
GrPixelConfig config = GrColorTypeToPixelConfig(colorType, GrSRGBEncoded::kNo);
|
||||
|
||||
MTLPixelFormat format;
|
||||
if (!GrPixelConfigToMTLFormat(config, &format)) {
|
||||
return false;
|
||||
@ -435,8 +438,11 @@ bool GrMtlGpu::createTestingOnlyMtlTextureInfo(GrPixelConfig config, int w, int
|
||||
desc.storageMode = MTLStorageModeShared;
|
||||
#endif
|
||||
id<MTLTexture> transferTexture = [fDevice newTextureWithDescriptor: desc];
|
||||
auto colorType = GrPixelConfigToColorType(config);
|
||||
int rowBytes = w * GrColorTypeBytesPerPixel(colorType);
|
||||
size_t trimRowBytes = w * GrColorTypeBytesPerPixel(colorType);
|
||||
if (!srcRowBytes) {
|
||||
srcRowBytes = trimRowBytes;
|
||||
}
|
||||
|
||||
MTLOrigin origin = MTLOriginMake(0, 0, 0);
|
||||
|
||||
SkASSERT(testTexture.pixelFormat == transferTexture.pixelFormat);
|
||||
@ -450,7 +456,7 @@ bool GrMtlGpu::createTestingOnlyMtlTextureInfo(GrPixelConfig config, int w, int
|
||||
[transferTexture replaceRegion: MTLRegionMake2D(0, 0, currentWidth, currentHeight)
|
||||
mipmapLevel: mipLevel
|
||||
withBytes: srcData
|
||||
bytesPerRow: rowBytes];
|
||||
bytesPerRow: srcRowBytes];
|
||||
|
||||
[blitCmdEncoder copyFromTexture: transferTexture
|
||||
sourceSlice: 0
|
||||
@ -473,17 +479,19 @@ bool GrMtlGpu::createTestingOnlyMtlTextureInfo(GrPixelConfig config, int w, int
|
||||
}
|
||||
|
||||
GrBackendTexture GrMtlGpu::createTestingOnlyBackendTexture(const void* pixels, int w, int h,
|
||||
GrPixelConfig config, bool isRT,
|
||||
GrMipMapped mipMapped) {
|
||||
GrColorType colorType, bool isRT,
|
||||
GrMipMapped mipMapped, size_t rowBytes) {
|
||||
if (w > this->caps()->maxTextureSize() || h > this->caps()->maxTextureSize()) {
|
||||
return GrBackendTexture();
|
||||
}
|
||||
GrMtlTextureInfo info;
|
||||
if (!this->createTestingOnlyMtlTextureInfo(config, w, h, true, isRT, mipMapped, pixels,
|
||||
&info)) {
|
||||
if (!this->createTestingOnlyMtlTextureInfo(colorType, w, h, true, isRT, mipMapped, pixels,
|
||||
rowBytes, &info)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
GrPixelConfig config = GrColorTypeToPixelConfig(colorType, GrSRGBEncoded::kNo);
|
||||
|
||||
GrBackendTexture backendTex(w, h, mipMapped, info);
|
||||
backendTex.fConfig = config;
|
||||
return backendTex;
|
||||
@ -518,16 +526,15 @@ GrBackendRenderTarget GrMtlGpu::createTestingOnlyBackendRenderTarget(int w, int
|
||||
if (w > this->caps()->maxRenderTargetSize() || h > this->caps()->maxRenderTargetSize()) {
|
||||
return GrBackendRenderTarget();
|
||||
}
|
||||
auto config = GrColorTypeToPixelConfig(ct, GrSRGBEncoded::kNo);
|
||||
if (kUnknown_GrPixelConfig == config) {
|
||||
return {};
|
||||
}
|
||||
|
||||
GrMtlTextureInfo info;
|
||||
if (!this->createTestingOnlyMtlTextureInfo(config, w, h, false, true, GrMipMapped::kNo, nullptr,
|
||||
&info)) {
|
||||
if (!this->createTestingOnlyMtlTextureInfo(ct, w, h, false, true, GrMipMapped::kNo, nullptr,
|
||||
0, &info)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
GrPixelConfig config = GrColorTypeToPixelConfig(ct, GrSRGBEncoded::kNo);
|
||||
|
||||
GrBackendRenderTarget backendRT(w, h, 1, info);
|
||||
backendRT.fConfig = config;
|
||||
return backendRT;
|
||||
|
@ -1044,7 +1044,8 @@ GrStencilAttachment* GrVkGpu::createStencilAttachmentForRenderTarget(const GrRen
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool copy_testing_data(GrVkGpu* gpu, const void* srcData, const GrVkAlloc& alloc,
|
||||
size_t bufferOffset, size_t srcRowBytes, size_t dstRowBytes, int h) {
|
||||
size_t bufferOffset, size_t srcRowBytes, size_t dstRowBytes,
|
||||
size_t trimRowBytes, int h) {
|
||||
VkDeviceSize size = dstRowBytes * h;
|
||||
VkDeviceSize offset = bufferOffset;
|
||||
SkASSERT(size + offset <= alloc.fSize);
|
||||
@ -1057,19 +1058,11 @@ bool copy_testing_data(GrVkGpu* gpu, const void* srcData, const GrVkAlloc& alloc
|
||||
if (srcData) {
|
||||
// If there is no padding on dst we can do a single memcopy.
|
||||
// This assumes the srcData comes in with no padding.
|
||||
SkRectMemcpy(mapPtr, static_cast<size_t>(dstRowBytes),
|
||||
srcData, srcRowBytes, srcRowBytes, h);
|
||||
SkRectMemcpy(mapPtr, dstRowBytes, srcData, srcRowBytes, trimRowBytes, h);
|
||||
} else {
|
||||
// If there is no srcdata we always copy 0's into the textures so that it is initialized
|
||||
// with some data.
|
||||
if (srcRowBytes == static_cast<size_t>(dstRowBytes)) {
|
||||
memset(mapPtr, 0, srcRowBytes * h);
|
||||
} else {
|
||||
for (int i = 0; i < h; ++i) {
|
||||
memset(mapPtr, 0, srcRowBytes);
|
||||
mapPtr = SkTAddOffset<void>(mapPtr, static_cast<size_t>(dstRowBytes));
|
||||
}
|
||||
}
|
||||
memset(mapPtr, 0, dstRowBytes * h);
|
||||
}
|
||||
GrVkMemory::FlushMappedAlloc(gpu, alloc, offset, size);
|
||||
GrVkMemory::UnmapAlloc(gpu, alloc);
|
||||
@ -1079,7 +1072,7 @@ bool copy_testing_data(GrVkGpu* gpu, const void* srcData, const GrVkAlloc& alloc
|
||||
#if GR_TEST_UTILS
|
||||
bool GrVkGpu::createTestingOnlyVkImage(GrPixelConfig config, int w, int h, bool texturable,
|
||||
bool renderable, GrMipMapped mipMapped, const void* srcData,
|
||||
GrVkImageInfo* info) {
|
||||
size_t srcRowBytes, GrVkImageInfo* info) {
|
||||
SkASSERT(texturable || renderable);
|
||||
if (!texturable) {
|
||||
SkASSERT(GrMipMapped::kNo == mipMapped);
|
||||
@ -1189,6 +1182,11 @@ bool GrVkGpu::createTestingOnlyVkImage(GrPixelConfig config, int w, int h, bool
|
||||
size_t bpp = GrBytesPerPixel(config);
|
||||
SkASSERT(w && h);
|
||||
|
||||
const size_t trimRowBytes = w * bpp;
|
||||
if (!srcRowBytes) {
|
||||
srcRowBytes = trimRowBytes;
|
||||
}
|
||||
|
||||
SkTArray<size_t> individualMipOffsets(mipLevels);
|
||||
individualMipOffsets.push_back(0);
|
||||
size_t combinedBufferSize = w * bpp * h;
|
||||
@ -1247,8 +1245,8 @@ bool GrVkGpu::createTestingOnlyVkImage(GrPixelConfig config, int w, int h, bool
|
||||
SkASSERT(0 == currentMipLevel || !srcData);
|
||||
size_t currentRowBytes = bpp * currentWidth;
|
||||
size_t bufferOffset = individualMipOffsets[currentMipLevel];
|
||||
if (!copy_testing_data(this, srcData, bufferAlloc, bufferOffset, currentRowBytes,
|
||||
currentRowBytes, currentHeight)) {
|
||||
if (!copy_testing_data(this, srcData, bufferAlloc, bufferOffset, srcRowBytes,
|
||||
currentRowBytes, trimRowBytes, currentHeight)) {
|
||||
GrVkMemory::FreeImageMemory(this, false, alloc);
|
||||
VK_CALL(DestroyImage(fDevice, image, nullptr));
|
||||
GrVkMemory::FreeBufferMemory(this, GrVkBuffer::kCopyRead_Type, bufferAlloc);
|
||||
@ -1384,17 +1382,23 @@ bool GrVkGpu::createTestingOnlyVkImage(GrPixelConfig config, int w, int h, bool
|
||||
}
|
||||
|
||||
GrBackendTexture GrVkGpu::createTestingOnlyBackendTexture(const void* srcData, int w, int h,
|
||||
GrPixelConfig config, bool isRenderTarget,
|
||||
GrMipMapped mipMapped) {
|
||||
GrColorType colorType,
|
||||
bool isRenderTarget,
|
||||
GrMipMapped mipMapped, size_t rowBytes) {
|
||||
this->handleDirtyContext();
|
||||
|
||||
if (w > this->caps()->maxTextureSize() || h > this->caps()->maxTextureSize()) {
|
||||
return GrBackendTexture();
|
||||
}
|
||||
|
||||
GrPixelConfig config = GrColorTypeToPixelConfig(colorType, GrSRGBEncoded::kNo);
|
||||
if (!this->caps()->isConfigTexturable(config)) {
|
||||
return GrBackendTexture();
|
||||
}
|
||||
|
||||
GrVkImageInfo info;
|
||||
if (!this->createTestingOnlyVkImage(config, w, h, true, isRenderTarget, mipMapped, srcData,
|
||||
&info)) {
|
||||
rowBytes, &info)) {
|
||||
return {};
|
||||
}
|
||||
GrBackendTexture beTex = GrBackendTexture(w, h, info);
|
||||
@ -1446,7 +1450,7 @@ GrBackendRenderTarget GrVkGpu::createTestingOnlyBackendRenderTarget(int w, int h
|
||||
if (kUnknown_GrPixelConfig == config) {
|
||||
return {};
|
||||
}
|
||||
if (!this->createTestingOnlyVkImage(config, w, h, false, true, GrMipMapped::kNo, nullptr,
|
||||
if (!this->createTestingOnlyVkImage(config, w, h, false, true, GrMipMapped::kNo, nullptr, 0,
|
||||
&info)) {
|
||||
return {};
|
||||
}
|
||||
|
@ -76,8 +76,8 @@ public:
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
GrBackendTexture createTestingOnlyBackendTexture(const void* pixels, int w, int h,
|
||||
GrPixelConfig config, bool isRenderTarget,
|
||||
GrMipMapped) override;
|
||||
GrColorType colorType, bool isRenderTarget,
|
||||
GrMipMapped, size_t rowBytes = 0) override;
|
||||
bool isTestingOnlyBackendTexture(const GrBackendTexture&) const override;
|
||||
void deleteTestingOnlyBackendTexture(const GrBackendTexture&) override;
|
||||
|
||||
@ -226,7 +226,7 @@ private:
|
||||
#if GR_TEST_UTILS
|
||||
bool createTestingOnlyVkImage(GrPixelConfig config, int w, int h, bool texturable,
|
||||
bool renderable, GrMipMapped mipMapped, const void* srcData,
|
||||
GrVkImageInfo* info);
|
||||
size_t srcRowBytes, GrVkImageInfo* info);
|
||||
#endif
|
||||
|
||||
sk_sp<const GrVkInterface> fInterface;
|
||||
|
@ -359,7 +359,7 @@ public:
|
||||
: GrMipMapped(fShouldCreateMipMaps);
|
||||
|
||||
*backend = gpu->createTestingOnlyBackendTexture(nullptr, fWidth, fHeight,
|
||||
fConfig, true, mipmapped);
|
||||
fColorType, true, mipmapped);
|
||||
if (!backend->isValid() || !gpu->isTestingOnlyBackendTexture(*backend)) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -686,7 +686,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLWrapBackendTest, reporter, ctxInfo) {
|
||||
GrContext* context = ctxInfo.grContext();
|
||||
GrGpu* gpu = context->contextPriv().getGpu();
|
||||
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
|
||||
nullptr, kSize, kSize, kRGBA_8888_GrPixelConfig, false, GrMipMapped::kNo);
|
||||
nullptr, kSize, kSize, GrColorType::kRGBA_8888, false, GrMipMapped::kNo);
|
||||
if (!backendTex.isValid()) {
|
||||
return;
|
||||
}
|
||||
@ -848,14 +848,14 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(DDLTextureFlagsTest, reporter, ctxInfo) {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Exhaustively test colorType and pixelConfig compatibility.
|
||||
// Test colorType and pixelConfig compatibility.
|
||||
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(DDLCompatibilityTest, reporter, ctxInfo) {
|
||||
GrContext* context = ctxInfo.grContext();
|
||||
|
||||
for (int ct = 0; ct <= kLastEnum_SkColorType; ++ct) {
|
||||
SkColorType colorType = static_cast<SkColorType>(ct);
|
||||
|
||||
for (int config = 0; config < kGrPixelConfigCnt; ++config) {
|
||||
for (int config = 0; config < kPrivateConfig1_GrPixelConfig; ++config) {
|
||||
GrPixelConfig pixelConfig = static_cast<GrPixelConfig>(config);
|
||||
|
||||
SurfaceParameters params(context->contextPriv().caps());
|
||||
|
@ -88,7 +88,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
|
||||
GrGpu* gpu1 = context1->contextPriv().getGpu();
|
||||
static const int kSize = 100;
|
||||
backendTexture1 =
|
||||
gpu1->createTestingOnlyBackendTexture(nullptr, kSize, kSize, kRGBA_8888_GrPixelConfig,
|
||||
gpu1->createTestingOnlyBackendTexture(nullptr, kSize, kSize, GrColorType::kRGBA_8888,
|
||||
false, GrMipMapped::kNo);
|
||||
|
||||
if (!backendTexture1.isValid() || !gpu1->isTestingOnlyBackendTexture(backendTexture1)) {
|
||||
|
@ -42,7 +42,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrWrappedMipMappedTest, reporter, ctxInfo) {
|
||||
// so we don't send any. However, we pretend there is data for the checks below which is
|
||||
// fine since we are never actually using these textures for any work on the gpu.
|
||||
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
|
||||
nullptr, kSize, kSize, kRGBA_8888_GrPixelConfig, isRT, mipMapped);
|
||||
nullptr, kSize, kSize, GrColorType::kRGBA_8888, isRT, mipMapped);
|
||||
|
||||
sk_sp<GrTextureProxy> proxy;
|
||||
sk_sp<SkImage> image;
|
||||
@ -108,7 +108,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrBackendTextureImageMipMappedTest, reporter,
|
||||
for (auto mipMapped : {GrMipMapped::kNo, GrMipMapped::kYes}) {
|
||||
for (auto willUseMips : {false, true}) {
|
||||
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
|
||||
nullptr, kSize, kSize, kRGBA_8888_GrPixelConfig, false, mipMapped);
|
||||
nullptr, kSize, kSize, GrColorType::kRGBA_8888, false, mipMapped);
|
||||
|
||||
sk_sp<SkImage> image = SkImage::MakeFromTexture(context, backendTex,
|
||||
kTopLeft_GrSurfaceOrigin,
|
||||
@ -234,7 +234,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrImageSnapshotMipMappedTest, reporter, ctxIn
|
||||
GrMipMapped mipMapped = willUseMips ? GrMipMapped::kYes : GrMipMapped::kNo;
|
||||
sk_sp<SkSurface> surface;
|
||||
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
|
||||
nullptr, kSize, kSize, kRGBA_8888_GrPixelConfig, true, mipMapped);
|
||||
nullptr, kSize, kSize, GrColorType::kRGBA_8888, true, mipMapped);
|
||||
if (isWrapped) {
|
||||
surface = SkSurface::MakeFromBackendTexture(context,
|
||||
backendTex,
|
||||
|
@ -1062,7 +1062,7 @@ DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, options) {
|
||||
}
|
||||
|
||||
GrBackendTexture backendTex =
|
||||
gpu->createTestingOnlyBackendTexture(nullptr, 100, 100, kRGBA_8888_GrPixelConfig,
|
||||
gpu->createTestingOnlyBackendTexture(nullptr, 100, 100, GrColorType::kRGBA_8888,
|
||||
false, GrMipMapped::kNo);
|
||||
|
||||
GrXferProcessor::DstProxy fakeDstProxy;
|
||||
|
@ -48,7 +48,7 @@ DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrSurface, reporter, ctxInfo) {
|
||||
REPORTER_ASSERT(reporter, static_cast<GrSurface*>(tex1.get()) == tex1->asTexture());
|
||||
|
||||
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
|
||||
nullptr, 256, 256, kRGBA_8888_GrPixelConfig, false, GrMipMapped::kNo);
|
||||
nullptr, 256, 256, GrColorType::kRGBA_8888, false, GrMipMapped::kNo);
|
||||
|
||||
sk_sp<GrSurface> texRT2 =
|
||||
resourceProvider->wrapRenderableBackendTexture(backendTex, 1, kBorrow_GrWrapOwnership);
|
||||
|
@ -38,9 +38,13 @@ void testing_only_texture_test(skiatest::Reporter* reporter, GrContext* context,
|
||||
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(srcBuffer,
|
||||
kWidth,
|
||||
kHeight,
|
||||
config,
|
||||
ct,
|
||||
renderTarget,
|
||||
mipMapped);
|
||||
if (!backendTex.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
sk_sp<GrTexture> wrappedTex;
|
||||
if (renderTarget) {
|
||||
wrappedTex = gpu->wrapRenderableBackendTexture(backendTex, 1,
|
||||
@ -67,7 +71,7 @@ void testing_only_texture_test(skiatest::Reporter* reporter, GrContext* context,
|
||||
}
|
||||
|
||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrTestingBackendTextureUploadTest, reporter, ctxInfo) {
|
||||
for (auto colorType: {GrColorType::kRGBA_8888, GrColorType::kBGRA_8888}) {
|
||||
for (auto colorType: { GrColorType::kRGBA_8888, GrColorType::kBGRA_8888 }) {
|
||||
for (bool renderable: {true, false}) {
|
||||
for (bool doDataUpload: {true, false}) {
|
||||
testing_only_texture_test(reporter, ctxInfo.grContext(), colorType,
|
||||
|
@ -842,7 +842,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkImage_NewFromTextureRelease, reporter, c
|
||||
GrGpu* gpu = ctx->contextPriv().getGpu();
|
||||
|
||||
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
|
||||
pixels.get(), kWidth, kHeight, kRGBA_8888_GrPixelConfig, true, GrMipMapped::kNo);
|
||||
pixels.get(), kWidth, kHeight, GrColorType::kRGBA_8888, true, GrMipMapped::kNo);
|
||||
|
||||
TextureReleaseChecker releaseChecker;
|
||||
GrSurfaceOrigin texOrigin = kBottomLeft_GrSurfaceOrigin;
|
||||
|
@ -435,7 +435,7 @@ DEF_GPUTEST(LazyProxyUninstantiateTest, reporter, /* options */) {
|
||||
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
||||
|
||||
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
|
||||
nullptr, kSize, kSize, kRGBA_8888_GrPixelConfig, false, GrMipMapped::kNo);
|
||||
nullptr, kSize, kSize, GrColorType::kRGBA_8888, false, GrMipMapped::kNo);
|
||||
|
||||
sk_sp<GrTextureProxy> lazyProxy = proxyProvider->createLazyProxy(
|
||||
[instantiatePtr, releasePtr, backendTex](GrResourceProvider* rp) {
|
||||
|
@ -113,7 +113,7 @@ static void run_test(skiatest::Reporter* reporter, GrContext* context, int array
|
||||
|
||||
for (auto origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) {
|
||||
auto proxy = sk_gpu_test::MakeTextureProxyFromData(context, false, DEV_W, DEV_H,
|
||||
SkColorTypeToGrColorType(colorType),
|
||||
colorType,
|
||||
origin, controlPixelData.begin(), 0);
|
||||
SkASSERT(proxy);
|
||||
|
||||
|
@ -101,7 +101,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageTest, reporter, ctxInfo) {
|
||||
|
||||
for (bool releaseImageEarly : {true, false}) {
|
||||
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
|
||||
nullptr, kWidth, kHeight, kRGBA_8888_GrPixelConfig, true, GrMipMapped::kNo);
|
||||
nullptr, kWidth, kHeight, GrColorType::kRGBA_8888, true, GrMipMapped::kNo);
|
||||
REPORTER_ASSERT(reporter, backendTex.isValid());
|
||||
|
||||
GrBackendFormat backendFormat = gpu->caps()->createFormatFromBackendTexture(backendTex);
|
||||
|
@ -24,7 +24,7 @@
|
||||
struct ProxyParams {
|
||||
int fSize;
|
||||
bool fIsRT;
|
||||
GrPixelConfig fConfig;
|
||||
SkColorType fColorType;
|
||||
SkBackingFit fFit;
|
||||
int fSampleCnt;
|
||||
GrSurfaceOrigin fOrigin;
|
||||
@ -32,11 +32,14 @@ struct ProxyParams {
|
||||
};
|
||||
|
||||
static GrSurfaceProxy* make_deferred(GrProxyProvider* proxyProvider, const ProxyParams& p) {
|
||||
GrColorType grCT = SkColorTypeToGrColorType(p.fColorType);
|
||||
GrPixelConfig config = GrColorTypeToPixelConfig(grCT, GrSRGBEncoded::kNo);
|
||||
|
||||
GrSurfaceDesc desc;
|
||||
desc.fFlags = p.fIsRT ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags;
|
||||
desc.fWidth = p.fSize;
|
||||
desc.fHeight = p.fSize;
|
||||
desc.fConfig = p.fConfig;
|
||||
desc.fConfig = config;
|
||||
desc.fSampleCnt = p.fSampleCnt;
|
||||
|
||||
auto tmp = proxyProvider->createProxy(desc, p.fOrigin, p.fFit, SkBudgeted::kNo);
|
||||
@ -57,8 +60,11 @@ static GrSurfaceProxy* make_backend(GrContext* context, const ProxyParams& p,
|
||||
GrGpu* gpu = context->contextPriv().getGpu();
|
||||
|
||||
*backendTex = gpu->createTestingOnlyBackendTexture(nullptr, p.fSize, p.fSize,
|
||||
p.fConfig, false,
|
||||
p.fColorType, false,
|
||||
GrMipMapped::kNo);
|
||||
if (!backendTex->isValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto tmp = proxyProvider->wrapBackendTexture(*backendTex, p.fOrigin);
|
||||
if (!tmp) {
|
||||
@ -147,8 +153,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceAllocatorTest, reporter, ctxInfo) {
|
||||
// Non-RT GrSurfaces are never recycled on some platforms.
|
||||
bool kConditionallyShare = resourceProvider->caps()->reuseScratchTextures();
|
||||
|
||||
const GrPixelConfig kRGBA = kRGBA_8888_GrPixelConfig;
|
||||
const GrPixelConfig kBGRA = kBGRA_8888_GrPixelConfig;
|
||||
const SkColorType kRGBA = kRGBA_8888_SkColorType;
|
||||
const SkColorType kBGRA = kBGRA_8888_SkColorType;
|
||||
|
||||
const SkBackingFit kE = SkBackingFit::kExact;
|
||||
const SkBackingFit kA = SkBackingFit::kApprox;
|
||||
@ -174,8 +180,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceAllocatorTest, reporter, ctxInfo) {
|
||||
p2->completedRead();
|
||||
}
|
||||
|
||||
int k2 = ctxInfo.grContext()->contextPriv().caps()->getRenderTargetSampleCount(2, kRGBA);
|
||||
int k4 = ctxInfo.grContext()->contextPriv().caps()->getRenderTargetSampleCount(4, kRGBA);
|
||||
int k2 = ctxInfo.grContext()->contextPriv().caps()->getRenderTargetSampleCount(
|
||||
2, kRGBA_8888_GrPixelConfig);
|
||||
int k4 = ctxInfo.grContext()->contextPriv().caps()->getRenderTargetSampleCount(
|
||||
4, kRGBA_8888_GrPixelConfig);
|
||||
|
||||
//--------------------------------------------------------------------------------------------
|
||||
TestCase gNonOverlappingTests[] = {
|
||||
|
@ -209,10 +209,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheWrappedResources, reporter, ctxI
|
||||
static const int kH = 100;
|
||||
|
||||
backendTextures[0] = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH,
|
||||
kRGBA_8888_GrPixelConfig,
|
||||
GrColorType::kRGBA_8888,
|
||||
false, GrMipMapped::kNo);
|
||||
backendTextures[1] = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH,
|
||||
kRGBA_8888_GrPixelConfig,
|
||||
GrColorType::kRGBA_8888,
|
||||
false, GrMipMapped::kNo);
|
||||
REPORTER_ASSERT(reporter, backendTextures[0].isValid());
|
||||
REPORTER_ASSERT(reporter, backendTextures[1].isValid());
|
||||
|
@ -685,7 +685,7 @@ static sk_sp<SkSurface> create_gpu_surface_backend_texture(
|
||||
sk_memset32(pixels.get(), color, kWidth * kHeight);
|
||||
|
||||
*outTexture = gpu->createTestingOnlyBackendTexture(
|
||||
pixels.get(), kWidth, kHeight, kRGBA_8888_GrPixelConfig, true, GrMipMapped::kNo);
|
||||
pixels.get(), kWidth, kHeight, GrColorType::kRGBA_8888, true, GrMipMapped::kNo);
|
||||
|
||||
if (!outTexture->isValid() || !gpu->isTestingOnlyBackendTexture(*outTexture)) {
|
||||
return nullptr;
|
||||
@ -712,7 +712,7 @@ static sk_sp<SkSurface> create_gpu_surface_backend_texture_as_render_target(
|
||||
sk_memset32(pixels.get(), color, kWidth * kHeight);
|
||||
|
||||
*outTexture = gpu->createTestingOnlyBackendTexture(
|
||||
pixels.get(), kWidth, kHeight, kRGBA_8888_GrPixelConfig, true, GrMipMapped::kNo);
|
||||
pixels.get(), kWidth, kHeight, GrColorType::kRGBA_8888, true, GrMipMapped::kNo, 0);
|
||||
|
||||
if (!outTexture->isValid() || !gpu->isTestingOnlyBackendTexture(*outTexture)) {
|
||||
return nullptr;
|
||||
@ -994,11 +994,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCreationWithColorSpace_Gpu, reporter,
|
||||
GrGpu* gpu = context->contextPriv().getGpu();
|
||||
|
||||
static const int kSize = 10;
|
||||
GrPixelConfig config = SkImageInfo2GrPixelConfig(info);
|
||||
SkASSERT(kUnknown_GrPixelConfig != config);
|
||||
|
||||
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
|
||||
nullptr, kSize, kSize, config, true, GrMipMapped::kNo);
|
||||
nullptr, kSize, kSize, info.colorType(), true, GrMipMapped::kNo);
|
||||
|
||||
if (!backendTex.isValid() ||
|
||||
!gpu->isTestingOnlyBackendTexture(backendTex)) {
|
||||
|
@ -29,7 +29,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkImageLayoutTest, reporter, ctxInfo) {
|
||||
GrVkGpu* gpu = static_cast<GrVkGpu*>(context->contextPriv().getGpu());
|
||||
|
||||
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(nullptr, 1, 1,
|
||||
kRGBA_8888_GrPixelConfig,
|
||||
GrColorType::kRGBA_8888,
|
||||
false,
|
||||
GrMipMapped::kNo);
|
||||
REPORTER_ASSERT(reporter, backendTex.isValid());
|
||||
|
@ -28,13 +28,14 @@ using sk_gpu_test::GrContextFactory;
|
||||
const int kW = 1024;
|
||||
const int kH = 1024;
|
||||
const GrPixelConfig kPixelConfig = kRGBA_8888_GrPixelConfig;
|
||||
const GrColorType kColorType = GrColorType::kRGBA_8888;
|
||||
|
||||
void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
|
||||
GrVkGpu* gpu = static_cast<GrVkGpu*>(context->contextPriv().getGpu());
|
||||
|
||||
GrBackendTexture origBackendTex = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH,
|
||||
kPixelConfig, false,
|
||||
kColorType, false,
|
||||
GrMipMapped::kNo);
|
||||
GrVkImageInfo imageInfo;
|
||||
SkAssertResult(origBackendTex.getVkImageInfo(&imageInfo));
|
||||
@ -81,7 +82,7 @@ void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
GrVkGpu* gpu = static_cast<GrVkGpu*>(context->contextPriv().getGpu());
|
||||
|
||||
GrBackendTexture origBackendTex = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH,
|
||||
kPixelConfig, true,
|
||||
kColorType, true,
|
||||
GrMipMapped::kNo);
|
||||
|
||||
GrVkImageInfo imageInfo;
|
||||
@ -123,7 +124,7 @@ void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
GrVkGpu* gpu = static_cast<GrVkGpu*>(context->contextPriv().getGpu());
|
||||
|
||||
GrBackendTexture origBackendTex = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH,
|
||||
kPixelConfig, true,
|
||||
kColorType, true,
|
||||
GrMipMapped::kNo);
|
||||
GrVkImageInfo imageInfo;
|
||||
SkAssertResult(origBackendTex.getVkImageInfo(&imageInfo));
|
||||
|
@ -457,7 +457,7 @@ static void test_write_pixels_non_texture(skiatest::Reporter* reporter, GrContex
|
||||
|
||||
for (auto& origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) {
|
||||
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
|
||||
nullptr, DEV_W, DEV_H, kSkia8888_GrPixelConfig, true, GrMipMapped::kNo);
|
||||
nullptr, DEV_W, DEV_H, GrColorType::kRGBA_8888, true, GrMipMapped::kNo);
|
||||
if (!backendTex.isValid()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "GrBackendSurface.h"
|
||||
#include "GrClip.h"
|
||||
#include "GrContextOptions.h"
|
||||
#include "GrContextPriv.h"
|
||||
#include "GrDrawOpAtlas.h"
|
||||
@ -134,16 +135,6 @@ void GrGpu::Stats::dumpKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>*
|
||||
|
||||
#endif
|
||||
|
||||
GrBackendTexture GrGpu::createTestingOnlyBackendTexture(const void* pixels, int w, int h,
|
||||
SkColorType colorType, bool isRenderTarget,
|
||||
GrMipMapped mipMapped) {
|
||||
GrPixelConfig config = SkColorType2GrPixelConfig(colorType);
|
||||
if (kUnknown_GrPixelConfig == config) {
|
||||
return GrBackendTexture();
|
||||
}
|
||||
return this->createTestingOnlyBackendTexture(pixels, w, h, config, isRenderTarget, mipMapped);
|
||||
}
|
||||
|
||||
#if GR_CACHE_STATS
|
||||
void GrResourceCache::getStats(Stats* stats) const {
|
||||
stats->reset();
|
||||
|
@ -15,19 +15,18 @@
|
||||
namespace sk_gpu_test {
|
||||
|
||||
sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context, bool isRT, int width, int height,
|
||||
GrColorType ct, GrSRGBEncoded srgbEncoded,
|
||||
GrColorType colorType, GrSRGBEncoded srgbEncoded,
|
||||
GrSurfaceOrigin origin, const void* data,
|
||||
size_t rowBytes) {
|
||||
if (context->abandoned()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto config = GrColorTypeToPixelConfig(ct, srgbEncoded);
|
||||
sk_sp<GrTextureProxy> proxy;
|
||||
if (kBottomLeft_GrSurfaceOrigin == origin) {
|
||||
// We (soon will) only support using kBottomLeft with wrapped textures.
|
||||
auto backendTex = context->contextPriv().getGpu()->createTestingOnlyBackendTexture(
|
||||
nullptr, width, height, config, isRT, GrMipMapped::kNo);
|
||||
nullptr, width, height, colorType, isRT, GrMipMapped::kNo);
|
||||
if (!backendTex.isValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -46,6 +45,11 @@ sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context, bool isRT, in
|
||||
}
|
||||
|
||||
} else {
|
||||
GrPixelConfig config = GrColorTypeToPixelConfig(colorType, srgbEncoded);
|
||||
if (!context->contextPriv().caps()->isConfigTexturable(config)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GrSurfaceDesc desc;
|
||||
desc.fConfig = config;
|
||||
desc.fWidth = width;
|
||||
@ -61,8 +65,8 @@ sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context, bool isRT, in
|
||||
if (!sContext) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!context->contextPriv().writeSurfacePixels(sContext.get(), 0, 0, width, height, ct, nullptr,
|
||||
data, rowBytes)) {
|
||||
if (!context->contextPriv().writeSurfacePixels(sContext.get(), 0, 0, width, height, colorType,
|
||||
nullptr, data, rowBytes)) {
|
||||
return nullptr;
|
||||
}
|
||||
return proxy;
|
||||
|
Loading…
Reference in New Issue
Block a user