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