Add finisehd proc to backend texture creation.
The callback lets the caller know when the data uploads to the texture from the create call are finished. This is important since the caller cannot delete the backend texture till the gpu is finished on vulkan and d3d. This change also removes the hard sync in vulkan during creation. Change-Id: I660d142219474e22b1337d2b0c81cda66fe18a4b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/286517 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
de5003768b
commit
c1ad77cf48
@ -6,7 +6,14 @@ This file includes a list of high level updates for each milestone release.
|
||||
|
||||
Milestone 84
|
||||
|
||||
* <insert new release note here>
|
||||
* GrContext::createBackendTexture functions that initialize the texture no longer
|
||||
guarantee that all the data has been uploaded and the gpu is done with the texture.
|
||||
Instead the client can assume the upload work has been submitted to the gpu and they
|
||||
must wait for that work to finish before deleting the texture. This can be done via
|
||||
their own synchronization or by passing in a finish proc into the create calls which
|
||||
will be called when it is safe to delete the texture (at least in terms of work
|
||||
done during the create).
|
||||
https://review.skia.org/286517
|
||||
|
||||
* Remove unused SkMaskFilter helpers: compbine, compose
|
||||
Note: shadermaskfilter will likely be removed next (clipShader should serve)
|
||||
|
@ -1384,9 +1384,9 @@ sk_sp<SkSurface> GPUSink::createDstSurface(GrContext* context, SkISize size,
|
||||
&props);
|
||||
break;
|
||||
case SkCommandLineConfigGpu::SurfType::kBackendTexture:
|
||||
*backendTexture = context->createBackendTexture(
|
||||
info.width(), info.height(), info.colorType(), SkColors::kTransparent,
|
||||
GrMipMapped::kNo, GrRenderable::kYes, GrProtected::kNo);
|
||||
CreateBackendTexture(context, backendTexture, info.width(), info.height(),
|
||||
info.colorType(), SkColors::kTransparent, GrMipMapped::kNo,
|
||||
GrRenderable::kYes, GrProtected::kNo);
|
||||
surface = SkSurface::MakeFromBackendTexture(context, *backendTexture,
|
||||
kTopLeft_GrSurfaceOrigin, fSampleCount,
|
||||
fColorType, info.refColorSpace(), &props);
|
||||
|
@ -398,7 +398,7 @@ public:
|
||||
// cannot determine the correct size.
|
||||
static size_t ComputeImageSize(sk_sp<SkImage> image, GrMipMapped, bool useNextPow2 = false);
|
||||
|
||||
/*
|
||||
/**
|
||||
* Retrieve the default GrBackendFormat for a given SkColorType and renderability.
|
||||
* It is guaranteed that this backend format will be the one used by the following
|
||||
* SkColorType and SkSurfaceCharacterization-based createBackendTexture methods.
|
||||
@ -409,7 +409,7 @@ public:
|
||||
return INHERITED::defaultBackendFormat(ct, renderable);
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* The explicitly allocated backend texture API allows clients to use Skia to create backend
|
||||
* objects outside of Skia proper (i.e., Skia's caching system will not know about them.)
|
||||
*
|
||||
@ -424,22 +424,26 @@ public:
|
||||
* sychronization on the client's part).
|
||||
*/
|
||||
|
||||
// If possible, create an uninitialized backend texture. The client should ensure that the
|
||||
// returned backend texture is valid.
|
||||
// For the Vulkan backend the layout of the created VkImage will be:
|
||||
// VK_IMAGE_LAYOUT_UNDEFINED.
|
||||
/**
|
||||
* If possible, create an uninitialized backend texture. The client should ensure that the
|
||||
* returned backend texture is valid.
|
||||
* For the Vulkan backend the layout of the created VkImage will be:
|
||||
* VK_IMAGE_LAYOUT_UNDEFINED.
|
||||
*/
|
||||
GrBackendTexture createBackendTexture(int width, int height,
|
||||
const GrBackendFormat&,
|
||||
GrMipMapped,
|
||||
GrRenderable,
|
||||
GrProtected = GrProtected::kNo);
|
||||
|
||||
// If possible, create an uninitialized backend texture. The client should ensure that the
|
||||
// returned backend texture is valid.
|
||||
// If successful, the created backend texture will be compatible with the provided
|
||||
// SkColorType.
|
||||
// For the Vulkan backend the layout of the created VkImage will be:
|
||||
// VK_IMAGE_LAYOUT_UNDEFINED.
|
||||
/**
|
||||
* If possible, create an uninitialized backend texture. The client should ensure that the
|
||||
* returned backend texture is valid.
|
||||
* If successful, the created backend texture will be compatible with the provided
|
||||
* SkColorType.
|
||||
* For the Vulkan backend the layout of the created VkImage will be:
|
||||
* VK_IMAGE_LAYOUT_UNDEFINED.
|
||||
*/
|
||||
GrBackendTexture createBackendTexture(int width, int height,
|
||||
SkColorType,
|
||||
GrMipMapped,
|
||||
@ -447,71 +451,104 @@ public:
|
||||
GrProtected = GrProtected::kNo);
|
||||
|
||||
|
||||
// If possible, create an uninitialized backend texture that is compatible with the
|
||||
// provided characterization. The client should ensure that the returned backend texture
|
||||
// is valid.
|
||||
// For the Vulkan backend the layout of the created VkImage will be:
|
||||
// VK_IMAGE_LAYOUT_UNDEFINED.
|
||||
/**
|
||||
* If possible, create an uninitialized backend texture that is compatible with the
|
||||
* provided characterization. The client should ensure that the returned backend texture
|
||||
* is valid.
|
||||
* For the Vulkan backend the layout of the created VkImage will be:
|
||||
* VK_IMAGE_LAYOUT_UNDEFINED.
|
||||
*/
|
||||
GrBackendTexture createBackendTexture(const SkSurfaceCharacterization& characterization);
|
||||
|
||||
// If possible, create a backend texture initialized to a particular color. The client should
|
||||
// ensure that the returned backend texture is valid.
|
||||
// For the Vulkan backend the layout of the created VkImage will be:
|
||||
// VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL if renderable is kNo
|
||||
// and VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL if renderable is kYes
|
||||
/**
|
||||
* If possible, create a backend texture initialized to a particular color. The client should
|
||||
* ensure that the returned backend texture is valid. The client can pass in a finishedProc
|
||||
* to be notified when the data has been uploaded by the gpu and the texture can be deleted. The
|
||||
* client can assume the upload work has been submitted to the gpu. The finishedProc will always
|
||||
* get called even if we failed to create the GrBackendTexture.
|
||||
* For the Vulkan backend the layout of the created VkImage will be:
|
||||
* VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL if renderable is kNo
|
||||
* and VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL if renderable is kYes
|
||||
*/
|
||||
GrBackendTexture createBackendTexture(int width, int height,
|
||||
const GrBackendFormat&,
|
||||
const SkColor4f& color,
|
||||
GrMipMapped,
|
||||
GrRenderable,
|
||||
GrProtected = GrProtected::kNo);
|
||||
GrProtected = GrProtected::kNo,
|
||||
GrGpuFinishedProc finishedProc = nullptr,
|
||||
GrGpuFinishedContext finishedContext = nullptr);
|
||||
|
||||
// If possible, create a backend texture initialized to a particular color. The client should
|
||||
// ensure that the returned backend texture is valid.
|
||||
// If successful, the created backend texture will be compatible with the provided
|
||||
// SkColorType.
|
||||
// For the Vulkan backend the layout of the created VkImage will be:
|
||||
// VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL if renderable is kNo
|
||||
// and VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL if renderable is kYes
|
||||
/**
|
||||
* If possible, create a backend texture initialized to a particular color. The client should
|
||||
* ensure that the returned backend texture is valid. The client can pass in a finishedProc
|
||||
* to be notified when the data has been uploaded by the gpu and the texture can be deleted. The
|
||||
* client can assume the upload work has been submitted to the gpu. The finishedProc will always
|
||||
* get called even if we failed to create the GrBackendTexture.
|
||||
* If successful, the created backend texture will be compatible with the provided
|
||||
* SkColorType.
|
||||
* For the Vulkan backend the layout of the created VkImage will be:
|
||||
* VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL if renderable is kNo
|
||||
* and VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL if renderable is kYes
|
||||
*/
|
||||
GrBackendTexture createBackendTexture(int width, int height,
|
||||
SkColorType,
|
||||
const SkColor4f& color,
|
||||
GrMipMapped,
|
||||
GrRenderable,
|
||||
GrProtected = GrProtected::kNo);
|
||||
GrProtected = GrProtected::kNo,
|
||||
GrGpuFinishedProc finishedProc = nullptr,
|
||||
GrGpuFinishedContext finishedContext = nullptr);
|
||||
|
||||
// If possible, create a backend texture initialized to a particular color that is
|
||||
// compatible with the provided characterization. The client should ensure that the
|
||||
// returned backend texture is valid.
|
||||
// For the Vulkan backend the layout of the created VkImage will be:
|
||||
// VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
|
||||
/**
|
||||
* If possible, create a backend texture initialized to a particular color that is
|
||||
* compatible with the provided characterization. The client should ensure that the
|
||||
* returned backend texture is valid. The client can pass in a finishedProc to be notified when
|
||||
* the data has been uploaded by the gpu and the texture can be deleted. The client can assume
|
||||
* the upload work has been submitted to the gpu. The finishedProc will always get called even
|
||||
* if we failed to create the GrBackendTexture.
|
||||
* For the Vulkan backend the layout of the created VkImage will be:
|
||||
* VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
|
||||
*/
|
||||
GrBackendTexture createBackendTexture(const SkSurfaceCharacterization& characterization,
|
||||
const SkColor4f& color);
|
||||
const SkColor4f& color,
|
||||
GrGpuFinishedProc finishedProc = nullptr,
|
||||
GrGpuFinishedContext finishedContext = nullptr);
|
||||
|
||||
// If possible, create a backend texture initialized with the provided pixmap data. The client
|
||||
// should ensure that the returned backend texture is valid.
|
||||
// If successful, the created backend texture will be compatible with the provided
|
||||
// pixmap(s). Compatible, in this case, means that the backend format will be the result
|
||||
// of calling defaultBackendFormat on the base pixmap's colortype.
|
||||
// If numLevels is 1 a non-mipMapped texture will result. If a mipMapped texture is desired
|
||||
// the data for all the mipmap levels must be provided. In the mipmapped case all the
|
||||
// colortypes of the provided pixmaps must be the same. Additionally, all the miplevels
|
||||
// must be sized correctly (please see SkMipMap::ComputeLevelSize and ComputeLevelCount).
|
||||
// Note: the pixmap's alphatypes and colorspaces are ignored.
|
||||
// For the Vulkan backend the layout of the created VkImage will be:
|
||||
// VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
|
||||
// regardless of the renderability setting
|
||||
/**
|
||||
* If possible, create a backend texture initialized with the provided pixmap data. The client
|
||||
* should ensure that the returned backend texture is valid. The client can pass in a
|
||||
* finishedProc to be notified when the data has been uploaded by the gpu and the texture can be
|
||||
* deleted. The client can assume the upload work has been submitted to the gpu. The
|
||||
* finishedProc will always get called even if we failed to create the GrBackendTexture.
|
||||
* If successful, the created backend texture will be compatible with the provided
|
||||
* pixmap(s). Compatible, in this case, means that the backend format will be the result
|
||||
* of calling defaultBackendFormat on the base pixmap's colortype.
|
||||
* If numLevels is 1 a non-mipMapped texture will result. If a mipMapped texture is desired
|
||||
* the data for all the mipmap levels must be provided. In the mipmapped case all the
|
||||
* colortypes of the provided pixmaps must be the same. Additionally, all the miplevels
|
||||
* must be sized correctly (please see SkMipMap::ComputeLevelSize and ComputeLevelCount).
|
||||
* Note: the pixmap's alphatypes and colorspaces are ignored.
|
||||
* For the Vulkan backend the layout of the created VkImage will be:
|
||||
* VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
|
||||
* regardless of the renderability setting
|
||||
*/
|
||||
GrBackendTexture createBackendTexture(const SkPixmap srcData[], int numLevels,
|
||||
GrRenderable, GrProtected);
|
||||
GrRenderable, GrProtected,
|
||||
GrGpuFinishedProc finishedProc = nullptr,
|
||||
GrGpuFinishedContext finishedContext = nullptr);
|
||||
|
||||
// Helper version of above for a single level.
|
||||
GrBackendTexture createBackendTexture(const SkPixmap& srcData,
|
||||
GrRenderable renderable,
|
||||
GrProtected isProtected) {
|
||||
return this->createBackendTexture(&srcData, 1, renderable, isProtected);
|
||||
GrProtected isProtected,
|
||||
GrGpuFinishedProc finishedProc = nullptr,
|
||||
GrGpuFinishedContext finishedContext = nullptr) {
|
||||
return this->createBackendTexture(&srcData, 1, renderable, isProtected, finishedProc,
|
||||
finishedContext);
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Retrieve the GrBackendFormat for a given SkImage::CompressionType. This is
|
||||
* guaranteed to match the backend format used by the following
|
||||
* createCompressedsBackendTexture methods that take a CompressionType.
|
||||
@ -521,40 +558,58 @@ public:
|
||||
return INHERITED::compressedBackendFormat(compression);
|
||||
}
|
||||
|
||||
// If possible, create a compressed backend texture initialized to a particular color. The
|
||||
// client should ensure that the returned backend texture is valid.
|
||||
// For the Vulkan backend the layout of the created VkImage will be:
|
||||
// VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
|
||||
/**
|
||||
*If possible, create a compressed backend texture initialized to a particular color. The
|
||||
* client should ensure that the returned backend texture is valid. The client can pass in a
|
||||
* finishedProc to be notified when the data has been uploaded by the gpu and the texture can be
|
||||
* deleted. The client can assume the upload work has been submitted to the gpu. The
|
||||
* finishedProc will always get called even if we failed to create the GrBackendTexture.
|
||||
* For the Vulkan backend the layout of the created VkImage will be:
|
||||
* VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
|
||||
*/
|
||||
GrBackendTexture createCompressedBackendTexture(int width, int height,
|
||||
const GrBackendFormat&,
|
||||
const SkColor4f& color,
|
||||
GrMipMapped,
|
||||
GrProtected = GrProtected::kNo);
|
||||
GrProtected = GrProtected::kNo,
|
||||
GrGpuFinishedProc finishedProc = nullptr,
|
||||
GrGpuFinishedContext finishedContext = nullptr);
|
||||
|
||||
GrBackendTexture createCompressedBackendTexture(int width, int height,
|
||||
SkImage::CompressionType,
|
||||
const SkColor4f& color,
|
||||
GrMipMapped,
|
||||
GrProtected = GrProtected::kNo);
|
||||
GrProtected = GrProtected::kNo,
|
||||
GrGpuFinishedProc finishedProc = nullptr,
|
||||
GrGpuFinishedContext finishedContext = nullptr);
|
||||
|
||||
// If possible, create a backend texture initialized with the provided raw data. The client
|
||||
// should ensure that the returned backend texture is valid.
|
||||
// If numLevels is 1 a non-mipMapped texture will result. If a mipMapped texture is desired
|
||||
// the data for all the mipmap levels must be provided. Additionally, all the miplevels
|
||||
// must be sized correctly (please see SkMipMap::ComputeLevelSize and ComputeLevelCount).
|
||||
// For the Vulkan backend the layout of the created VkImage will be:
|
||||
// VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
|
||||
/**
|
||||
* If possible, create a backend texture initialized with the provided raw data. The client
|
||||
* should ensure that the returned backend texture is valid. The client can pass in a
|
||||
* finishedProc to be notified when the data has been uploaded by the gpu and the texture can be
|
||||
* deleted. The client can assume the upload work has been submitted to the gpu. The
|
||||
* finishedProc will always get called even if we failed to create the GrBackendTexture
|
||||
* If numLevels is 1 a non-mipMapped texture will result. If a mipMapped texture is desired
|
||||
* the data for all the mipmap levels must be provided. Additionally, all the miplevels
|
||||
* must be sized correctly (please see SkMipMap::ComputeLevelSize and ComputeLevelCount).
|
||||
* For the Vulkan backend the layout of the created VkImage will be:
|
||||
* VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
|
||||
*/
|
||||
GrBackendTexture createCompressedBackendTexture(int width, int height,
|
||||
const GrBackendFormat&,
|
||||
const void* data, size_t dataSize,
|
||||
GrMipMapped,
|
||||
GrProtected = GrProtected::kNo);
|
||||
GrProtected = GrProtected::kNo,
|
||||
GrGpuFinishedProc finishedProc = nullptr,
|
||||
GrGpuFinishedContext finishedContext = nullptr);
|
||||
|
||||
GrBackendTexture createCompressedBackendTexture(int width, int height,
|
||||
SkImage::CompressionType,
|
||||
const void* data, size_t dataSize,
|
||||
GrMipMapped,
|
||||
GrProtected = GrProtected::kNo);
|
||||
GrProtected = GrProtected::kNo,
|
||||
GrGpuFinishedProc finishedProc = nullptr,
|
||||
GrGpuFinishedContext finishedContext = nullptr);
|
||||
|
||||
void deleteBackendTexture(GrBackendTexture);
|
||||
|
||||
|
@ -405,7 +405,7 @@ GrBackendTexture GrContext::createBackendTexture(int width, int height,
|
||||
}
|
||||
|
||||
return fGpu->createBackendTexture({width, height}, backendFormat, renderable,
|
||||
mipMapped, isProtected, nullptr);
|
||||
mipMapped, isProtected, nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
||||
GrBackendTexture GrContext::createBackendTexture(int width, int height,
|
||||
@ -458,33 +458,41 @@ GrBackendTexture GrContext::createBackendTexture(const SkSurfaceCharacterization
|
||||
}
|
||||
|
||||
GrBackendTexture GrContext::createBackendTexture(const SkSurfaceCharacterization& c,
|
||||
const SkColor4f& color) {
|
||||
const SkColor4f& color,
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
if (!this->asDirectContext() || !c.isValid()) {
|
||||
return GrBackendTexture();
|
||||
finishedProc(finishedContext);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (this->abandoned()) {
|
||||
return GrBackendTexture();
|
||||
finishedProc(finishedContext);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (c.usesGLFBO0()) {
|
||||
finishedProc(finishedContext);
|
||||
// If we are making the surface we will never use FBO0.
|
||||
return GrBackendTexture();
|
||||
return {};
|
||||
}
|
||||
|
||||
if (c.vulkanSecondaryCBCompatible()) {
|
||||
finishedProc(finishedContext);
|
||||
return {};
|
||||
}
|
||||
|
||||
const GrBackendFormat format = this->defaultBackendFormat(c.colorType(), GrRenderable::kYes);
|
||||
if (!format.isValid()) {
|
||||
return GrBackendTexture();
|
||||
finishedProc(finishedContext);
|
||||
return {};
|
||||
}
|
||||
|
||||
GrBackendTexture result = this->createBackendTexture(c.width(), c.height(), format, color,
|
||||
GrMipMapped(c.isMipMapped()),
|
||||
GrRenderable::kYes,
|
||||
c.isProtected());
|
||||
c.isProtected(), finishedProc,
|
||||
finishedContext);
|
||||
SkASSERT(c.isCompatible(result));
|
||||
return result;
|
||||
}
|
||||
@ -494,19 +502,23 @@ GrBackendTexture GrContext::createBackendTexture(int width, int height,
|
||||
const SkColor4f& color,
|
||||
GrMipMapped mipMapped,
|
||||
GrRenderable renderable,
|
||||
GrProtected isProtected) {
|
||||
GrProtected isProtected,
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
|
||||
if (!this->asDirectContext()) {
|
||||
return GrBackendTexture();
|
||||
finishedProc(finishedContext);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (this->abandoned()) {
|
||||
return GrBackendTexture();
|
||||
finishedProc(finishedContext);
|
||||
return {};
|
||||
}
|
||||
|
||||
GrGpu::BackendTextureData data(color);
|
||||
return fGpu->createBackendTexture({width, height}, backendFormat, renderable,
|
||||
mipMapped, isProtected, &data);
|
||||
mipMapped, isProtected, finishedProc, finishedContext, &data);
|
||||
}
|
||||
|
||||
GrBackendTexture GrContext::createBackendTexture(int width, int height,
|
||||
@ -514,40 +526,50 @@ GrBackendTexture GrContext::createBackendTexture(int width, int height,
|
||||
const SkColor4f& color,
|
||||
GrMipMapped mipMapped,
|
||||
GrRenderable renderable,
|
||||
GrProtected isProtected) {
|
||||
GrProtected isProtected,
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
if (!this->asDirectContext()) {
|
||||
return GrBackendTexture();
|
||||
finishedProc(finishedContext);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (this->abandoned()) {
|
||||
return GrBackendTexture();
|
||||
finishedProc(finishedContext);
|
||||
return {};
|
||||
}
|
||||
|
||||
GrBackendFormat format = this->defaultBackendFormat(skColorType, renderable);
|
||||
if (!format.isValid()) {
|
||||
return GrBackendTexture();
|
||||
finishedProc(finishedContext);
|
||||
return {};
|
||||
}
|
||||
|
||||
GrColorType grColorType = SkColorTypeToGrColorType(skColorType);
|
||||
SkColor4f swizzledColor = this->caps()->getWriteSwizzle(format, grColorType).applyTo(color);
|
||||
|
||||
return this->createBackendTexture(width, height, format, swizzledColor, mipMapped, renderable,
|
||||
isProtected);
|
||||
isProtected, finishedProc, finishedContext);
|
||||
}
|
||||
|
||||
GrBackendTexture GrContext::createBackendTexture(const SkPixmap srcData[], int numProvidedLevels,
|
||||
GrRenderable renderable, GrProtected isProtected) {
|
||||
GrRenderable renderable, GrProtected isProtected,
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
|
||||
|
||||
if (!this->asDirectContext()) {
|
||||
finishedProc(finishedContext);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (this->abandoned()) {
|
||||
finishedProc(finishedContext);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!srcData || numProvidedLevels <= 0) {
|
||||
finishedProc(finishedContext);
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -563,6 +585,7 @@ GrBackendTexture GrContext::createBackendTexture(const SkPixmap srcData[], int n
|
||||
}
|
||||
|
||||
if (numProvidedLevels != numExpectedLevels) {
|
||||
finishedProc(finishedContext);
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -570,7 +593,7 @@ GrBackendTexture GrContext::createBackendTexture(const SkPixmap srcData[], int n
|
||||
|
||||
GrGpu::BackendTextureData data(srcData);
|
||||
return fGpu->createBackendTexture({baseWidth, baseHeight}, backendFormat, renderable,
|
||||
mipMapped, isProtected, &data);
|
||||
mipMapped, isProtected, finishedProc, finishedContext, &data);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -579,38 +602,48 @@ GrBackendTexture GrContext::createCompressedBackendTexture(int width, int height
|
||||
const GrBackendFormat& backendFormat,
|
||||
const SkColor4f& color,
|
||||
GrMipMapped mipMapped,
|
||||
GrProtected isProtected) {
|
||||
GrProtected isProtected,
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
|
||||
if (!this->asDirectContext()) {
|
||||
return GrBackendTexture();
|
||||
finishedProc(finishedContext);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (this->abandoned()) {
|
||||
return GrBackendTexture();
|
||||
finishedProc(finishedContext);
|
||||
return {};
|
||||
}
|
||||
|
||||
GrGpu::BackendTextureData data(color);
|
||||
return fGpu->createCompressedBackendTexture({width, height}, backendFormat,
|
||||
mipMapped, isProtected, &data);
|
||||
mipMapped, isProtected, finishedProc,
|
||||
finishedContext, &data);
|
||||
}
|
||||
|
||||
GrBackendTexture GrContext::createCompressedBackendTexture(int width, int height,
|
||||
SkImage::CompressionType compression,
|
||||
const SkColor4f& color,
|
||||
GrMipMapped mipMapped,
|
||||
GrProtected isProtected) {
|
||||
GrProtected isProtected,
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
|
||||
if (!this->asDirectContext()) {
|
||||
return GrBackendTexture();
|
||||
finishedProc(finishedContext);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (this->abandoned()) {
|
||||
return GrBackendTexture();
|
||||
finishedProc(finishedContext);
|
||||
return {};
|
||||
}
|
||||
|
||||
GrBackendFormat format = this->compressedBackendFormat(compression);
|
||||
return this->createCompressedBackendTexture(width, height, format, color,
|
||||
mipMapped, isProtected);
|
||||
mipMapped, isProtected, finishedProc,
|
||||
finishedContext);
|
||||
}
|
||||
|
||||
GrBackendTexture GrContext::createCompressedBackendTexture(int width, int height,
|
||||
@ -618,38 +651,48 @@ GrBackendTexture GrContext::createCompressedBackendTexture(int width, int height
|
||||
const void* compressedData,
|
||||
size_t dataSize,
|
||||
GrMipMapped mipMapped,
|
||||
GrProtected isProtected) {
|
||||
GrProtected isProtected,
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
|
||||
if (!this->asDirectContext()) {
|
||||
return GrBackendTexture();
|
||||
finishedProc(finishedContext);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (this->abandoned()) {
|
||||
return GrBackendTexture();
|
||||
finishedProc(finishedContext);
|
||||
return {};
|
||||
}
|
||||
|
||||
GrGpu::BackendTextureData data(compressedData, dataSize);
|
||||
return fGpu->createCompressedBackendTexture({width, height}, backendFormat,
|
||||
mipMapped, isProtected, &data);
|
||||
mipMapped, isProtected, finishedProc,
|
||||
finishedContext, &data);
|
||||
}
|
||||
|
||||
GrBackendTexture GrContext::createCompressedBackendTexture(int width, int height,
|
||||
SkImage::CompressionType compression,
|
||||
const void* data, size_t dataSize,
|
||||
GrMipMapped mipMapped,
|
||||
GrProtected isProtected) {
|
||||
GrProtected isProtected,
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
|
||||
if (!this->asDirectContext()) {
|
||||
return GrBackendTexture();
|
||||
finishedProc(finishedContext);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (this->abandoned()) {
|
||||
return GrBackendTexture();
|
||||
finishedProc(finishedContext);
|
||||
return {};
|
||||
}
|
||||
|
||||
GrBackendFormat format = this->compressedBackendFormat(compression);
|
||||
return this->createCompressedBackendTexture(width, height, format, data, dataSize,
|
||||
mipMapped, isProtected);
|
||||
mipMapped, isProtected, finishedProc,
|
||||
finishedContext);
|
||||
}
|
||||
|
||||
void GrContext::deleteBackendTexture(GrBackendTexture backendTex) {
|
||||
|
@ -845,7 +845,15 @@ GrBackendTexture GrGpu::createBackendTexture(SkISize dimensions,
|
||||
GrRenderable renderable,
|
||||
GrMipMapped mipMapped,
|
||||
GrProtected isProtected,
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext,
|
||||
const BackendTextureData* data) {
|
||||
|
||||
sk_sp<GrRefCntedCallback> callback;
|
||||
if (finishedProc) {
|
||||
callback.reset(new GrRefCntedCallback(finishedProc, finishedContext));
|
||||
}
|
||||
|
||||
const GrCaps* caps = this->caps();
|
||||
|
||||
if (!format.isValid()) {
|
||||
@ -878,14 +886,21 @@ GrBackendTexture GrGpu::createBackendTexture(SkISize dimensions,
|
||||
}
|
||||
|
||||
return this->onCreateBackendTexture(dimensions, format, renderable, mipMapped,
|
||||
isProtected, data);
|
||||
isProtected, std::move(callback), data);
|
||||
}
|
||||
|
||||
GrBackendTexture GrGpu::createCompressedBackendTexture(SkISize dimensions,
|
||||
const GrBackendFormat& format,
|
||||
GrMipMapped mipMapped,
|
||||
GrProtected isProtected,
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext,
|
||||
const BackendTextureData* data) {
|
||||
sk_sp<GrRefCntedCallback> callback;
|
||||
if (finishedProc) {
|
||||
callback.reset(new GrRefCntedCallback(finishedProc, finishedContext));
|
||||
}
|
||||
|
||||
const GrCaps* caps = this->caps();
|
||||
|
||||
if (!format.isValid()) {
|
||||
@ -913,7 +928,7 @@ GrBackendTexture GrGpu::createCompressedBackendTexture(SkISize dimensions,
|
||||
}
|
||||
|
||||
return this->onCreateCompressedBackendTexture(dimensions, format, mipMapped,
|
||||
isProtected, data);
|
||||
isProtected, std::move(callback), data);
|
||||
}
|
||||
|
||||
GrStagingBuffer* GrGpu::findStagingBuffer(size_t size) {
|
||||
|
@ -598,6 +598,8 @@ public:
|
||||
GrRenderable,
|
||||
GrMipMapped,
|
||||
GrProtected,
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext,
|
||||
const BackendTextureData*);
|
||||
|
||||
/**
|
||||
@ -608,6 +610,8 @@ public:
|
||||
const GrBackendFormat&,
|
||||
GrMipMapped,
|
||||
GrProtected,
|
||||
GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext,
|
||||
const BackendTextureData*);
|
||||
|
||||
/**
|
||||
@ -716,13 +720,12 @@ private:
|
||||
GrRenderable,
|
||||
GrMipMapped,
|
||||
GrProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData*) = 0;
|
||||
|
||||
virtual GrBackendTexture onCreateCompressedBackendTexture(SkISize dimensions,
|
||||
const GrBackendFormat&,
|
||||
GrMipMapped,
|
||||
GrProtected,
|
||||
const BackendTextureData*) = 0;
|
||||
virtual GrBackendTexture onCreateCompressedBackendTexture(
|
||||
SkISize dimensions, const GrBackendFormat&, GrMipMapped, GrProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback, const BackendTextureData*) = 0;
|
||||
|
||||
// called when the 3D context state is unknown. Subclass should emit any
|
||||
// assumed 3D context state and dirty any state cache.
|
||||
|
@ -788,6 +788,7 @@ bool GrD3DGpu::createTextureResourceForBackendSurface(DXGI_FORMAT dxgiFormat,
|
||||
GrMipMapped mipMapped,
|
||||
GrD3DTextureResourceInfo* info,
|
||||
GrProtected isProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData* data) {
|
||||
SkASSERT(texturable == GrTexturable::kYes || renderable == GrRenderable::kYes);
|
||||
if (texturable == GrTexturable::kNo) {
|
||||
@ -856,7 +857,7 @@ bool GrD3DGpu::createTextureResourceForBackendSurface(DXGI_FORMAT dxgiFormat,
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: upload the data
|
||||
// TODO: upload the data and handle finished callback
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -866,6 +867,7 @@ GrBackendTexture GrD3DGpu::onCreateBackendTexture(SkISize dimensions,
|
||||
GrRenderable renderable,
|
||||
GrMipMapped mipMapped,
|
||||
GrProtected isProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData* data) {
|
||||
this->handleDirtyContext();
|
||||
|
||||
@ -888,18 +890,18 @@ GrBackendTexture GrD3DGpu::onCreateBackendTexture(SkISize dimensions,
|
||||
GrD3DTextureResourceInfo info;
|
||||
if (!this->createTextureResourceForBackendSurface(dxgiFormat, dimensions, GrTexturable::kYes,
|
||||
renderable, mipMapped,
|
||||
&info, isProtected, data)) {
|
||||
&info, isProtected,
|
||||
std::move(finishedCallback), data)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return GrBackendTexture(dimensions.width(), dimensions.height(), info);
|
||||
}
|
||||
|
||||
GrBackendTexture GrD3DGpu::onCreateCompressedBackendTexture(SkISize dimensions,
|
||||
const GrBackendFormat& format,
|
||||
GrMipMapped mipMapped,
|
||||
GrProtected isProtected,
|
||||
const BackendTextureData* data) {
|
||||
GrBackendTexture GrD3DGpu::onCreateCompressedBackendTexture(
|
||||
SkISize dimensions, const GrBackendFormat& format, GrMipMapped mipMapped,
|
||||
GrProtected isProtected, sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData* data) {
|
||||
this->handleDirtyContext();
|
||||
|
||||
const GrD3DCaps& caps = this->d3dCaps();
|
||||
@ -921,7 +923,8 @@ GrBackendTexture GrD3DGpu::onCreateCompressedBackendTexture(SkISize dimensions,
|
||||
GrD3DTextureResourceInfo info;
|
||||
if (!this->createTextureResourceForBackendSurface(dxgiFormat, dimensions, GrTexturable::kYes,
|
||||
GrRenderable::kNo, mipMapped,
|
||||
&info, isProtected, data)) {
|
||||
&info, isProtected,
|
||||
std::move(finishedCallback), data)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -965,7 +968,7 @@ GrBackendRenderTarget GrD3DGpu::createTestingOnlyBackendRenderTarget(int w, int
|
||||
GrD3DTextureResourceInfo info;
|
||||
if (!this->createTextureResourceForBackendSurface(dxgiFormat, { w, h }, GrTexturable::kNo,
|
||||
GrRenderable::kYes, GrMipMapped::kNo,
|
||||
&info, GrProtected::kNo, nullptr)) {
|
||||
&info, GrProtected::kNo, nullptr, nullptr)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -197,11 +197,13 @@ private:
|
||||
GrRenderable,
|
||||
GrMipMapped,
|
||||
GrProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData*) override;
|
||||
GrBackendTexture onCreateCompressedBackendTexture(SkISize dimensions,
|
||||
const GrBackendFormat&,
|
||||
GrMipMapped,
|
||||
GrProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData*) override;
|
||||
|
||||
bool submitDirectCommandList(SyncQueue sync);
|
||||
@ -226,6 +228,7 @@ private:
|
||||
GrMipMapped mipMapped,
|
||||
GrD3DTextureResourceInfo* info,
|
||||
GrProtected isProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData* data);
|
||||
|
||||
gr_cp<ID3D12Device> fDevice;
|
||||
|
@ -303,6 +303,7 @@ GrBackendTexture GrDawnGpu::onCreateBackendTexture(SkISize dimensions,
|
||||
GrRenderable renderable,
|
||||
GrMipMapped mipMapped,
|
||||
GrProtected isProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData* data) {
|
||||
wgpu::TextureFormat format;
|
||||
if (!backendFormat.asDawnFormat(&format)) {
|
||||
@ -387,11 +388,9 @@ GrBackendTexture GrDawnGpu::onCreateBackendTexture(SkISize dimensions,
|
||||
return GrBackendTexture(dimensions.width(), dimensions.height(), info);
|
||||
}
|
||||
|
||||
GrBackendTexture GrDawnGpu::onCreateCompressedBackendTexture(SkISize dimensions,
|
||||
const GrBackendFormat&,
|
||||
GrMipMapped,
|
||||
GrProtected,
|
||||
const BackendTextureData*) {
|
||||
GrBackendTexture GrDawnGpu::onCreateCompressedBackendTexture(
|
||||
SkISize dimensions, const GrBackendFormat&, GrMipMapped, GrProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback, const BackendTextureData*) {
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -418,7 +417,6 @@ bool GrDawnGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const {
|
||||
|
||||
GrBackendRenderTarget GrDawnGpu::createTestingOnlyBackendRenderTarget(int width, int height,
|
||||
GrColorType colorType) {
|
||||
|
||||
if (width > this->caps()->maxTextureSize() || height > this->caps()->maxTextureSize()) {
|
||||
return GrBackendRenderTarget();
|
||||
}
|
||||
|
@ -46,11 +46,13 @@ public:
|
||||
GrRenderable,
|
||||
GrMipMapped,
|
||||
GrProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData*) override;
|
||||
GrBackendTexture onCreateCompressedBackendTexture(SkISize dimensions,
|
||||
const GrBackendFormat&,
|
||||
GrMipMapped,
|
||||
GrProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData*) override;
|
||||
|
||||
void deleteBackendTexture(const GrBackendTexture&) override;
|
||||
|
@ -1370,11 +1370,10 @@ sk_sp<GrTexture> GrGLGpu::onCreateCompressedTexture(SkISize dimensions,
|
||||
return std::move(tex);
|
||||
}
|
||||
|
||||
GrBackendTexture GrGLGpu::onCreateCompressedBackendTexture(SkISize dimensions,
|
||||
const GrBackendFormat& format,
|
||||
GrMipMapped mipMapped,
|
||||
GrProtected isProtected,
|
||||
const BackendTextureData* data) {
|
||||
GrBackendTexture GrGLGpu::onCreateCompressedBackendTexture(
|
||||
SkISize dimensions, const GrBackendFormat& format, GrMipMapped mipMapped,
|
||||
GrProtected isProtected, sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData* data) {
|
||||
// We don't support protected textures in GL.
|
||||
if (isProtected == GrProtected::kYes) {
|
||||
return {};
|
||||
@ -3508,6 +3507,7 @@ GrBackendTexture GrGLGpu::onCreateBackendTexture(SkISize dimensions,
|
||||
GrRenderable renderable,
|
||||
GrMipMapped mipMapped,
|
||||
GrProtected isProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData* data) {
|
||||
// We don't support protected textures in GL.
|
||||
if (isProtected == GrProtected::kYes) {
|
||||
|
@ -194,12 +194,14 @@ private:
|
||||
GrRenderable,
|
||||
GrMipMapped,
|
||||
GrProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData*) override;
|
||||
|
||||
GrBackendTexture onCreateCompressedBackendTexture(SkISize dimensions,
|
||||
const GrBackendFormat&,
|
||||
GrMipMapped,
|
||||
GrProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData*) override;
|
||||
|
||||
void onResetContext(uint32_t resetBits) override;
|
||||
|
@ -277,6 +277,7 @@ GrBackendTexture GrMockGpu::onCreateBackendTexture(SkISize dimensions,
|
||||
GrRenderable,
|
||||
GrMipMapped mipMapped,
|
||||
GrProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData*) {
|
||||
SkImage::CompressionType compression = format.asMockCompressionType();
|
||||
if (compression != SkImage::CompressionType::kNone) {
|
||||
@ -294,11 +295,9 @@ GrBackendTexture GrMockGpu::onCreateBackendTexture(SkISize dimensions,
|
||||
return GrBackendTexture(dimensions.width(), dimensions.height(), mipMapped, info);
|
||||
}
|
||||
|
||||
GrBackendTexture GrMockGpu::onCreateCompressedBackendTexture(SkISize dimensions,
|
||||
const GrBackendFormat& format,
|
||||
GrMipMapped mipMapped,
|
||||
GrProtected,
|
||||
const BackendTextureData*) {
|
||||
GrBackendTexture GrMockGpu::onCreateCompressedBackendTexture(
|
||||
SkISize dimensions, const GrBackendFormat& format, GrMipMapped mipMapped,
|
||||
GrProtected, sk_sp<GrRefCntedCallback> finishedCallback, const BackendTextureData*) {
|
||||
SkImage::CompressionType compression = format.asMockCompressionType();
|
||||
if (compression == SkImage::CompressionType::kNone) {
|
||||
return {}; // should go through onCreateBackendTexture
|
||||
|
@ -148,11 +148,13 @@ private:
|
||||
GrRenderable,
|
||||
GrMipMapped,
|
||||
GrProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData*) override;
|
||||
GrBackendTexture onCreateCompressedBackendTexture(SkISize dimensions,
|
||||
const GrBackendFormat&,
|
||||
GrMipMapped,
|
||||
GrProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData*) override;
|
||||
void deleteBackendTexture(const GrBackendTexture&) override;
|
||||
|
||||
|
@ -131,12 +131,14 @@ private:
|
||||
GrRenderable,
|
||||
GrMipMapped,
|
||||
GrProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData*) override;
|
||||
|
||||
GrBackendTexture onCreateCompressedBackendTexture(SkISize dimensions,
|
||||
const GrBackendFormat&,
|
||||
GrMipMapped,
|
||||
GrProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData*) override;
|
||||
|
||||
sk_sp<GrTexture> onCreateTexture(SkISize,
|
||||
|
@ -948,7 +948,6 @@ bool GrMtlGpu::createMtlTextureForBackendSurface(MTLPixelFormat mtlFormat,
|
||||
|
||||
[blitCmdEncoder endEncoding];
|
||||
[cmdBuffer commit];
|
||||
[cmdBuffer waitUntilCompleted];
|
||||
transferBuffer = nil;
|
||||
|
||||
info->fTexture.reset(GrRetainPtrFromId(testTexture));
|
||||
@ -960,6 +959,7 @@ GrBackendTexture GrMtlGpu::onCreateBackendTexture(SkISize dimensions,
|
||||
GrRenderable renderable,
|
||||
GrMipMapped mipMapped,
|
||||
GrProtected isProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData* data) {
|
||||
const MTLPixelFormat mtlFormat = GrBackendFormatAsMTLPixelFormat(format);
|
||||
|
||||
@ -973,11 +973,10 @@ GrBackendTexture GrMtlGpu::onCreateBackendTexture(SkISize dimensions,
|
||||
return backendTex;
|
||||
}
|
||||
|
||||
GrBackendTexture GrMtlGpu::onCreateCompressedBackendTexture(SkISize dimensions,
|
||||
const GrBackendFormat& format,
|
||||
GrMipMapped mipMapped,
|
||||
GrProtected isProtected,
|
||||
const BackendTextureData* data) {
|
||||
GrBackendTexture GrMtlGpu::onCreateCompressedBackendTexture(
|
||||
SkISize dimensions, const GrBackendFormat& format, GrMipMapped mipMapped,
|
||||
GrProtected isProtected, sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData* data) {
|
||||
const MTLPixelFormat mtlFormat = GrBackendFormatAsMTLPixelFormat(format);
|
||||
|
||||
GrMtlTextureInfo info;
|
||||
|
@ -333,7 +333,7 @@ GrVkPrimaryCommandBuffer* GrVkGpu::getTempCommandBuffer() {
|
||||
return fTempCmdBuffer;
|
||||
}
|
||||
|
||||
bool GrVkGpu::submitTempCommandBuffer(SyncQueue sync) {
|
||||
bool GrVkGpu::submitTempCommandBuffer(SyncQueue sync, sk_sp<GrRefCntedCallback> finishedCallback) {
|
||||
SkASSERT(fTempCmdBuffer);
|
||||
|
||||
fTempCmdBuffer->end(this);
|
||||
@ -341,6 +341,8 @@ bool GrVkGpu::submitTempCommandBuffer(SyncQueue sync) {
|
||||
|
||||
SkASSERT(fMainCmdBuffer->validateNoSharedImageResources(fTempCmdBuffer));
|
||||
|
||||
fTempCmdBuffer->addFinishedProc(std::move(finishedCallback));
|
||||
|
||||
SkTArray<GrVkSemaphore::Resource*, false> fEmptySemaphores;
|
||||
bool didSubmit = fTempCmdBuffer->submitToQueue(this, fQueue, fEmptySemaphores,
|
||||
fEmptySemaphores);
|
||||
@ -1569,6 +1571,7 @@ bool GrVkGpu::createVkImageForBackendSurface(VkFormat vkFormat,
|
||||
GrMipMapped mipMapped,
|
||||
GrVkImageInfo* info,
|
||||
GrProtected isProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData* data) {
|
||||
SkASSERT(texturable == GrTexturable::kYes || renderable == GrRenderable::kYes);
|
||||
if (texturable == GrTexturable::kNo) {
|
||||
@ -1717,7 +1720,7 @@ bool GrVkGpu::createVkImageForBackendSurface(VkFormat vkFormat,
|
||||
false);
|
||||
}
|
||||
info->fImageLayout = layout->getImageLayout();
|
||||
return this->submitTempCommandBuffer(kForce_SyncQueue);
|
||||
return this->submitTempCommandBuffer(kSkip_SyncQueue, std::move(finishedCallback));
|
||||
}
|
||||
|
||||
GrBackendTexture GrVkGpu::onCreateBackendTexture(SkISize dimensions,
|
||||
@ -1725,6 +1728,7 @@ GrBackendTexture GrVkGpu::onCreateBackendTexture(SkISize dimensions,
|
||||
GrRenderable renderable,
|
||||
GrMipMapped mipMapped,
|
||||
GrProtected isProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData* data) {
|
||||
this->handleDirtyContext();
|
||||
|
||||
@ -1751,18 +1755,18 @@ GrBackendTexture GrVkGpu::onCreateBackendTexture(SkISize dimensions,
|
||||
GrVkImageInfo info;
|
||||
if (!this->createVkImageForBackendSurface(vkFormat, dimensions, GrTexturable::kYes,
|
||||
renderable, mipMapped,
|
||||
&info, isProtected, data)) {
|
||||
&info, isProtected, std::move(finishedCallback),
|
||||
data)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return GrBackendTexture(dimensions.width(), dimensions.height(), info);
|
||||
}
|
||||
|
||||
GrBackendTexture GrVkGpu::onCreateCompressedBackendTexture(SkISize dimensions,
|
||||
const GrBackendFormat& format,
|
||||
GrMipMapped mipMapped,
|
||||
GrProtected isProtected,
|
||||
const BackendTextureData* data) {
|
||||
GrBackendTexture GrVkGpu::onCreateCompressedBackendTexture(
|
||||
SkISize dimensions, const GrBackendFormat& format, GrMipMapped mipMapped,
|
||||
GrProtected isProtected, sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData* data) {
|
||||
this->handleDirtyContext();
|
||||
|
||||
const GrVkCaps& caps = this->vkCaps();
|
||||
@ -1788,7 +1792,8 @@ GrBackendTexture GrVkGpu::onCreateCompressedBackendTexture(SkISize dimensions,
|
||||
GrVkImageInfo info;
|
||||
if (!this->createVkImageForBackendSurface(vkFormat, dimensions, GrTexturable::kYes,
|
||||
GrRenderable::kNo, mipMapped,
|
||||
&info, isProtected, data)) {
|
||||
&info, isProtected, std::move(finishedCallback),
|
||||
data)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -1897,8 +1902,8 @@ GrBackendRenderTarget GrVkGpu::createTestingOnlyBackendRenderTarget(int w, int h
|
||||
GrVkImageInfo info;
|
||||
if (!this->createVkImageForBackendSurface(vkFormat, {w, h}, GrTexturable::kNo,
|
||||
GrRenderable::kYes, GrMipMapped::kNo,
|
||||
&info, GrProtected::kNo, nullptr)) {
|
||||
return {};
|
||||
&info, GrProtected::kNo, nullptr, nullptr)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return GrBackendRenderTarget(w, h, 1, 0, info);
|
||||
|
@ -185,11 +185,13 @@ private:
|
||||
GrRenderable,
|
||||
GrMipMapped,
|
||||
GrProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData*) override;
|
||||
GrBackendTexture onCreateCompressedBackendTexture(SkISize dimensions,
|
||||
const GrBackendFormat&,
|
||||
GrMipMapped,
|
||||
GrProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallbacks,
|
||||
const BackendTextureData*) override;
|
||||
|
||||
sk_sp<GrTexture> onCreateTexture(SkISize,
|
||||
@ -292,6 +294,7 @@ private:
|
||||
GrMipMapped,
|
||||
GrVkImageInfo*,
|
||||
GrProtected,
|
||||
sk_sp<GrRefCntedCallback> finishedCallback,
|
||||
const BackendTextureData*);
|
||||
|
||||
// Creates a new temporary primary command buffer that will be target of all subsequent commands
|
||||
@ -304,7 +307,7 @@ private:
|
||||
// updates out of order. It is legal to use a resource on either the temp or main command buffer
|
||||
// that was used on a previously submitted command buffer;
|
||||
GrVkPrimaryCommandBuffer* getTempCommandBuffer();
|
||||
bool submitTempCommandBuffer(SyncQueue sync);
|
||||
bool submitTempCommandBuffer(SyncQueue sync, sk_sp<GrRefCntedCallback> finishedCallback);
|
||||
|
||||
sk_sp<const GrVkInterface> fInterface;
|
||||
sk_sp<GrVkMemoryAllocator> fMemoryAllocator;
|
||||
|
@ -28,12 +28,27 @@
|
||||
#include "src/gpu/mtl/GrMtlCppUtil.h"
|
||||
#endif
|
||||
|
||||
static void delete_backend_texture(GrContext* context, const GrBackendTexture& backendTexture,
|
||||
bool* finishedCreate) {
|
||||
while (finishedCreate && !(*finishedCreate)) {
|
||||
context->checkAsyncWorkCompletion();
|
||||
}
|
||||
if (finishedCreate) {
|
||||
// The same boolean (pointed to by finishedCreate) is often used multiply and sequentially
|
||||
// throughout our tests to create different backend textures.
|
||||
// Reset it here so that it can be use to signal a future backend texture's creation
|
||||
*finishedCreate = false;
|
||||
}
|
||||
context->deleteBackendTexture(backendTexture);
|
||||
}
|
||||
|
||||
// Test wrapping of GrBackendObjects in SkSurfaces and SkImages (non-static since used in Mtl test)
|
||||
void test_wrapping(GrContext* context, skiatest::Reporter* reporter,
|
||||
std::function<GrBackendTexture (GrContext*,
|
||||
GrMipMapped,
|
||||
GrRenderable)> create,
|
||||
GrColorType grColorType, GrMipMapped mipMapped, GrRenderable renderable) {
|
||||
GrColorType grColorType, GrMipMapped mipMapped, GrRenderable renderable,
|
||||
bool* finishedBECreate) {
|
||||
GrResourceCache* cache = context->priv().getResourceCache();
|
||||
|
||||
const int initialCount = cache->getResourceCount();
|
||||
@ -53,7 +68,7 @@ void test_wrapping(GrContext* context, skiatest::Reporter* reporter,
|
||||
|
||||
// Wrapping a backendTexture in an image requires an SkColorType
|
||||
if (kUnknown_SkColorType == skColorType) {
|
||||
context->deleteBackendTexture(backendTex);
|
||||
delete_backend_texture(context, backendTex, finishedBECreate);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -98,7 +113,7 @@ void test_wrapping(GrContext* context, skiatest::Reporter* reporter,
|
||||
|
||||
REPORTER_ASSERT(reporter, initialCount == cache->getResourceCount());
|
||||
|
||||
context->deleteBackendTexture(backendTex);
|
||||
delete_backend_texture(context, backendTex, finishedBECreate);
|
||||
}
|
||||
|
||||
static bool isBGRA8(const GrBackendFormat& format) {
|
||||
@ -282,7 +297,7 @@ void test_color_init(GrContext* context, skiatest::Reporter* reporter,
|
||||
GrMipMapped,
|
||||
GrRenderable)> create,
|
||||
GrColorType grColorType, const SkColor4f& color,
|
||||
GrMipMapped mipMapped, GrRenderable renderable) {
|
||||
GrMipMapped mipMapped, GrRenderable renderable, bool* finishedBECreate) {
|
||||
GrBackendTexture backendTex = create(context, color, mipMapped, renderable);
|
||||
if (!backendTex.isValid()) {
|
||||
// errors here should be reported by the test_wrapping test
|
||||
@ -294,7 +309,7 @@ void test_color_init(GrContext* context, skiatest::Reporter* reporter,
|
||||
// Can't wrap backend textures in images and surfaces w/o an SkColorType
|
||||
if (kUnknown_SkColorType == skColorType) {
|
||||
// TODO: burrow in and scrappily check that data was uploaded!
|
||||
context->deleteBackendTexture(backendTex);
|
||||
delete_backend_texture(context, backendTex, finishedBECreate);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -308,7 +323,7 @@ void test_color_init(GrContext* context, skiatest::Reporter* reporter,
|
||||
// The last step in this test will dirty the mipmaps so do it last
|
||||
check_base_readbacks(context, backendTex, skColorType, renderable, color,
|
||||
reporter, "colorinit");
|
||||
context->deleteBackendTexture(backendTex);
|
||||
delete_backend_texture(context, backendTex, finishedBECreate);
|
||||
}
|
||||
|
||||
// Draw the backend texture (wrapped in an SkImage) into an RGBA surface, attempting to access
|
||||
@ -414,7 +429,7 @@ static void test_pixmap_init(GrContext* context, skiatest::Reporter* reporter,
|
||||
int numLevels,
|
||||
GrRenderable)> create,
|
||||
SkColorType skColorType, GrMipMapped mipMapped,
|
||||
GrRenderable renderable) {
|
||||
GrRenderable renderable, bool* finishedBECreate) {
|
||||
SkAutoPixmapStorage pixmapMem[6];
|
||||
SkColor4f colors[6] = {
|
||||
{ 1.0f, 0.0f, 0.0f, 1.0f }, // R
|
||||
@ -442,6 +457,7 @@ static void test_pixmap_init(GrContext* context, skiatest::Reporter* reporter,
|
||||
|
||||
if (skColorType == kBGRA_8888_SkColorType && !isBGRA8(backendTex.getBackendFormat())) {
|
||||
// When kBGRA is backed by an RGBA something goes wrong in the swizzling
|
||||
delete_backend_texture(context, backendTex, finishedBECreate);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -461,7 +477,7 @@ static void test_pixmap_init(GrContext* context, skiatest::Reporter* reporter,
|
||||
// The last step in this test will dirty the mipmaps so do it last
|
||||
check_base_readbacks(context, backendTex, skColorType, renderable, colors[0],
|
||||
reporter, "pixmap");
|
||||
context->deleteBackendTexture(backendTex);
|
||||
delete_backend_texture(context, backendTex, finishedBECreate);
|
||||
}
|
||||
|
||||
enum class VkLayout {
|
||||
@ -497,6 +513,10 @@ void check_vk_layout(const GrBackendTexture& backendTex, VkLayout layout) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static void mark_signaled(void* context) {
|
||||
*(bool*)context = true;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// This test is a bit different from the others in this file. It is mainly checking that, for any
|
||||
// SkSurface we can create in Ganesh, we can also create a backend texture that is compatible with
|
||||
@ -554,9 +574,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CharacterizationBackendAllocationTest, report
|
||||
}
|
||||
|
||||
// Test out color-initialized path
|
||||
|
||||
{
|
||||
|
||||
bool finished = false;
|
||||
GrBackendTexture backendTex = context->createBackendTexture(c,
|
||||
SkColors::kRed);
|
||||
SkColors::kRed,
|
||||
mark_signaled,
|
||||
&finished);
|
||||
check_vk_layout(backendTex, VkLayout::kColorAttachmentOptimal);
|
||||
REPORTER_ASSERT(reporter, backendTex.isValid());
|
||||
REPORTER_ASSERT(reporter, c.isCompatible(backendTex));
|
||||
@ -574,7 +599,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CharacterizationBackendAllocationTest, report
|
||||
REPORTER_ASSERT(reporter, s2->isCompatible(c));
|
||||
|
||||
s2 = nullptr;
|
||||
context->deleteBackendTexture(backendTex);
|
||||
delete_backend_texture(context, backendTex, &finished);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -650,8 +675,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ColorTypeBackendAllocationTest, reporter, ctx
|
||||
}
|
||||
|
||||
{
|
||||
auto uninitCreateMtd = [colorType](GrContext* context,
|
||||
GrMipMapped mipMapped,
|
||||
auto uninitCreateMtd = [colorType](GrContext* context, GrMipMapped mipMapped,
|
||||
GrRenderable renderable) {
|
||||
auto result = context->createBackendTexture(32, 32, colorType,
|
||||
mipMapped, renderable,
|
||||
@ -670,18 +694,24 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ColorTypeBackendAllocationTest, reporter, ctx
|
||||
};
|
||||
|
||||
test_wrapping(context, reporter, uninitCreateMtd,
|
||||
SkColorTypeToGrColorType(colorType), mipMapped, renderable);
|
||||
SkColorTypeToGrColorType(colorType), mipMapped, renderable,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
bool finishedBackendCreation = false;
|
||||
bool* finishedPtr = &finishedBackendCreation;
|
||||
|
||||
{
|
||||
|
||||
auto createWithColorMtd = [colorType](GrContext* context,
|
||||
const SkColor4f& color,
|
||||
GrMipMapped mipMapped,
|
||||
GrRenderable renderable) {
|
||||
auto createWithColorMtd = [colorType, finishedPtr](GrContext* context,
|
||||
const SkColor4f& color,
|
||||
GrMipMapped mipMapped,
|
||||
GrRenderable renderable) {
|
||||
auto result = context->createBackendTexture(32, 32, colorType, color,
|
||||
mipMapped, renderable,
|
||||
GrProtected::kNo);
|
||||
GrProtected::kNo,
|
||||
mark_signaled,
|
||||
finishedPtr);
|
||||
check_vk_layout(result, GrRenderable::kYes == renderable
|
||||
? VkLayout::kColorAttachmentOptimal
|
||||
: VkLayout::kReadOnlyOptimal);
|
||||
@ -710,17 +740,18 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ColorTypeBackendAllocationTest, reporter, ctx
|
||||
}
|
||||
test_color_init(context, reporter, createWithColorMtd,
|
||||
SkColorTypeToGrColorType(colorType), color, mipMapped,
|
||||
renderable);
|
||||
renderable, finishedPtr);
|
||||
}
|
||||
|
||||
{
|
||||
auto createWithSrcDataMtd = [](GrContext* context,
|
||||
const SkPixmap srcData[],
|
||||
int numLevels,
|
||||
GrRenderable renderable) {
|
||||
auto createWithSrcDataMtd = [finishedPtr](GrContext* context,
|
||||
const SkPixmap srcData[],
|
||||
int numLevels,
|
||||
GrRenderable renderable) {
|
||||
SkASSERT(srcData && numLevels);
|
||||
auto result = context->createBackendTexture(srcData, numLevels, renderable,
|
||||
GrProtected::kNo);
|
||||
GrProtected::kNo, mark_signaled,
|
||||
finishedPtr);
|
||||
check_vk_layout(result, VkLayout::kReadOnlyOptimal);
|
||||
#ifdef SK_DEBUG
|
||||
{
|
||||
@ -733,7 +764,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ColorTypeBackendAllocationTest, reporter, ctx
|
||||
};
|
||||
|
||||
test_pixmap_init(context, reporter, createWithSrcDataMtd, colorType, mipMapped,
|
||||
renderable);
|
||||
renderable, finishedPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -823,8 +854,7 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(GLBackendAllocationTest, reporter, ctxInfo) {
|
||||
}
|
||||
|
||||
{
|
||||
auto uninitCreateMtd = [format](GrContext* context,
|
||||
GrMipMapped mipMapped,
|
||||
auto uninitCreateMtd = [format](GrContext* context, GrMipMapped mipMapped,
|
||||
GrRenderable renderable) {
|
||||
return context->createBackendTexture(32, 32, format,
|
||||
mipMapped, renderable,
|
||||
@ -832,7 +862,7 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(GLBackendAllocationTest, reporter, ctxInfo) {
|
||||
};
|
||||
|
||||
test_wrapping(context, reporter, uninitCreateMtd,
|
||||
combo.fColorType, mipMapped, renderable);
|
||||
combo.fColorType, mipMapped, renderable, nullptr);
|
||||
}
|
||||
|
||||
{
|
||||
@ -859,14 +889,17 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(GLBackendAllocationTest, reporter, ctxInfo) {
|
||||
break;
|
||||
}
|
||||
|
||||
auto createWithColorMtd = [format, swizzle](GrContext* context,
|
||||
const SkColor4f& color,
|
||||
GrMipMapped mipMapped,
|
||||
GrRenderable renderable) {
|
||||
bool finishedBackendCreation = false;
|
||||
bool* finishedPtr = &finishedBackendCreation;
|
||||
|
||||
auto createWithColorMtd = [format, swizzle, finishedPtr](
|
||||
GrContext* context, const SkColor4f& color, GrMipMapped mipMapped,
|
||||
GrRenderable renderable) {
|
||||
auto swizzledColor = swizzle.applyTo(color);
|
||||
return context->createBackendTexture(32, 32, format, swizzledColor,
|
||||
mipMapped, renderable,
|
||||
GrProtected::kNo);
|
||||
GrProtected::kNo, mark_signaled,
|
||||
finishedPtr);
|
||||
};
|
||||
// We make our comparison color using SkPixmap::erase(color) on a pixmap of
|
||||
// combo.fColorType and then calling SkPixmap::readPixels(). erase() will premul
|
||||
@ -882,7 +915,7 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(GLBackendAllocationTest, reporter, ctxInfo) {
|
||||
}
|
||||
|
||||
test_color_init(context, reporter, createWithColorMtd, combo.fColorType, color,
|
||||
mipMapped, renderable);
|
||||
mipMapped, renderable, finishedPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -972,8 +1005,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkBackendAllocationTest, reporter, ctxInfo) {
|
||||
}
|
||||
|
||||
{
|
||||
auto uninitCreateMtd = [format](GrContext* context,
|
||||
GrMipMapped mipMapped,
|
||||
auto uninitCreateMtd = [format](GrContext* context, GrMipMapped mipMapped,
|
||||
GrRenderable renderable) {
|
||||
GrBackendTexture beTex = context->createBackendTexture(32, 32, format,
|
||||
mipMapped,
|
||||
@ -984,7 +1016,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkBackendAllocationTest, reporter, ctxInfo) {
|
||||
};
|
||||
|
||||
test_wrapping(context, reporter, uninitCreateMtd,
|
||||
combo.fColorType, mipMapped, renderable);
|
||||
combo.fColorType, mipMapped, renderable, nullptr);
|
||||
}
|
||||
|
||||
{
|
||||
@ -1019,23 +1051,29 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkBackendAllocationTest, reporter, ctxInfo) {
|
||||
swizzle = GrSwizzle("rgba");
|
||||
break;
|
||||
}
|
||||
auto createWithColorMtd = [format, swizzle](GrContext* context,
|
||||
const SkColor4f& color,
|
||||
GrMipMapped mipMapped,
|
||||
GrRenderable renderable) {
|
||||
|
||||
bool finishedBackendCreation = false;
|
||||
bool* finishedPtr = &finishedBackendCreation;
|
||||
|
||||
auto createWithColorMtd = [format, swizzle, finishedPtr](
|
||||
GrContext* context, const SkColor4f& color, GrMipMapped mipMapped,
|
||||
GrRenderable renderable) {
|
||||
auto swizzledColor = swizzle.applyTo(color);
|
||||
GrBackendTexture beTex = context->createBackendTexture(32, 32, format,
|
||||
swizzledColor,
|
||||
mipMapped,
|
||||
renderable,
|
||||
GrProtected::kNo);
|
||||
GrProtected::kNo,
|
||||
mark_signaled,
|
||||
finishedPtr);
|
||||
check_vk_layout(beTex, GrRenderable::kYes == renderable
|
||||
? VkLayout::kColorAttachmentOptimal
|
||||
: VkLayout::kReadOnlyOptimal);
|
||||
return beTex;
|
||||
};
|
||||
test_color_init(context, reporter, createWithColorMtd,
|
||||
combo.fColorType, combo.fColor, mipMapped, renderable);
|
||||
combo.fColorType, combo.fColor, mipMapped, renderable,
|
||||
finishedPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -212,10 +212,8 @@ public:
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
*backend = context->createBackendTexture(fWidth, fHeight, fColorType,
|
||||
SkColors::kTransparent,
|
||||
mipmapped, GrRenderable::kYes, fIsProtected);
|
||||
CreateBackendTexture(context, backend, fWidth, fHeight, fColorType,
|
||||
SkColors::kTransparent, mipmapped, GrRenderable::kYes, fIsProtected);
|
||||
if (!backend->isValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -866,8 +864,8 @@ enum class DDLStage { kMakeImage, kDrawImage, kDetach, kDrawDDL };
|
||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLWrapBackendTest, reporter, ctxInfo) {
|
||||
GrContext* context = ctxInfo.grContext();
|
||||
|
||||
GrBackendTexture backendTex = context->createBackendTexture(
|
||||
kSize, kSize, kRGBA_8888_SkColorType,
|
||||
GrBackendTexture backendTex;
|
||||
CreateBackendTexture(context, &backendTex, kSize, kSize, kRGBA_8888_SkColorType,
|
||||
SkColors::kTransparent, GrMipMapped::kNo, GrRenderable::kNo, GrProtected::kNo);
|
||||
if (!backendTex.isValid()) {
|
||||
return;
|
||||
|
@ -87,10 +87,10 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
|
||||
// Use GL Context 1 to create a texture unknown to GrContext.
|
||||
context1->flush();
|
||||
static const int kSize = 100;
|
||||
backendTexture1 =
|
||||
context1->createBackendTexture(kSize, kSize, kRGBA_8888_SkColorType,
|
||||
SkColors::kTransparent,
|
||||
GrMipMapped::kNo, GrRenderable::kNo, GrProtected::kNo);
|
||||
|
||||
CreateBackendTexture(context1.get(), &backendTexture1, kSize, kSize, kRGBA_8888_SkColorType,
|
||||
SkColors::kTransparent, GrMipMapped::kNo, GrRenderable::kNo,
|
||||
GrProtected::kNo);
|
||||
|
||||
if (!backendTexture1.isValid()) {
|
||||
ERRORF(reporter, "Error creating texture for EGL Image");
|
||||
|
@ -195,15 +195,24 @@ static void gpu_tests(GrContext* context, skiatest::Reporter* reporter, const Te
|
||||
for (bool fullInit : { false, true }) {
|
||||
GrBackendTexture backendTex;
|
||||
|
||||
bool finishedBECreate = false;
|
||||
auto markFinished = [](void* context) {
|
||||
*(bool*)context = true;
|
||||
};
|
||||
if (fullInit) {
|
||||
backendTex = context->createBackendTexture(&nativeExpected, 1,
|
||||
GrRenderable::kNo, GrProtected::kNo);
|
||||
GrRenderable::kNo, GrProtected::kNo,
|
||||
markFinished, &finishedBECreate);
|
||||
} else {
|
||||
backendTex = context->createBackendTexture(kSize, kSize, test.fColorType,
|
||||
SkColors::kWhite, GrMipMapped::kNo,
|
||||
GrRenderable::kNo, GrProtected::kNo);
|
||||
GrRenderable::kNo, GrProtected::kNo,
|
||||
markFinished, &finishedBECreate);
|
||||
}
|
||||
REPORTER_ASSERT(reporter, backendTex.isValid());
|
||||
while (backendTex.isValid() && !finishedBECreate) {
|
||||
context->checkAsyncWorkCompletion();
|
||||
}
|
||||
|
||||
auto img = SkImage::MakeFromTexture(context, backendTex, kTopLeft_GrSurfaceOrigin,
|
||||
test.fColorType, test.fAlphaType, nullptr);
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "src/image/SkImage_Base.h"
|
||||
#include "src/image/SkSurface_Gpu.h"
|
||||
#include "tests/Test.h"
|
||||
#include "tests/TestUtils.h"
|
||||
|
||||
static constexpr int kSize = 8;
|
||||
|
||||
@ -43,9 +44,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrWrappedMipMappedTest, reporter, ctxInfo) {
|
||||
// createBackendTexture currently doesn't support uploading data to mip maps
|
||||
// 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 = context->createBackendTexture(
|
||||
kSize, kSize, kRGBA_8888_SkColorType,
|
||||
SkColors::kTransparent, mipMapped, renderable, GrProtected::kNo);
|
||||
GrBackendTexture backendTex;
|
||||
CreateBackendTexture(context, &backendTex, kSize, kSize, kRGBA_8888_SkColorType,
|
||||
SkColors::kTransparent, mipMapped, renderable);
|
||||
|
||||
sk_sp<GrTextureProxy> proxy;
|
||||
sk_sp<SkImage> image;
|
||||
@ -115,9 +116,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrBackendTextureImageMipMappedTest, reporter,
|
||||
|
||||
for (auto betMipMapped : {GrMipMapped::kNo, GrMipMapped::kYes}) {
|
||||
for (auto requestMipMapped : {GrMipMapped::kNo, GrMipMapped::kYes}) {
|
||||
GrBackendTexture backendTex = context->createBackendTexture(
|
||||
kSize, kSize, kRGBA_8888_SkColorType, SkColors::kTransparent, betMipMapped,
|
||||
GrRenderable::kNo, GrProtected::kNo);
|
||||
GrBackendTexture backendTex;
|
||||
CreateBackendTexture(context, &backendTex, kSize, kSize, kRGBA_8888_SkColorType,
|
||||
SkColors::kTransparent, betMipMapped, GrRenderable::kNo);
|
||||
|
||||
sk_sp<SkImage> image = SkImage::MakeFromTexture(context, backendTex,
|
||||
kTopLeft_GrSurfaceOrigin,
|
||||
@ -259,9 +260,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrImageSnapshotMipMappedTest, reporter, ctxIn
|
||||
for (auto isWrapped : {false, true}) {
|
||||
GrMipMapped mipMapped = willUseMips ? GrMipMapped::kYes : GrMipMapped::kNo;
|
||||
sk_sp<SkSurface> surface;
|
||||
GrBackendTexture backendTex = context->createBackendTexture(
|
||||
kSize, kSize, kRGBA_8888_SkColorType,
|
||||
SkColors::kTransparent, mipMapped, GrRenderable::kYes, GrProtected::kNo);
|
||||
GrBackendTexture backendTex;
|
||||
CreateBackendTexture(context, &backendTex, kSize, kSize, kRGBA_8888_SkColorType,
|
||||
SkColors::kTransparent, mipMapped, GrRenderable::kYes);
|
||||
if (isWrapped) {
|
||||
surface = SkSurface::MakeFromBackendTexture(context,
|
||||
backendTex,
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "src/gpu/effects/GrPorterDuffXferProcessor.h"
|
||||
#include "src/gpu/gl/GrGLCaps.h"
|
||||
#include "src/gpu/ops/GrMeshDrawOp.h"
|
||||
#include "tests/TestUtils.h"
|
||||
#include "tools/gpu/GrContextFactory.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -997,9 +998,9 @@ DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, options) {
|
||||
SK_ABORT("Mock context failed to honor request for no ARB_blend_func_extended.");
|
||||
}
|
||||
|
||||
GrBackendTexture backendTex =
|
||||
ctx->createBackendTexture(100, 100, kRGBA_8888_SkColorType, SkColors::kTransparent,
|
||||
GrMipMapped::kNo, GrRenderable::kNo, GrProtected::kNo);
|
||||
GrBackendTexture backendTex;
|
||||
CreateBackendTexture(ctx, &backendTex, 100, 100, kRGBA_8888_SkColorType,
|
||||
SkColors::kTransparent, GrMipMapped::kNo, GrRenderable::kNo);
|
||||
|
||||
GrXferProcessor::DstProxyView fakeDstProxyView;
|
||||
{
|
||||
|
@ -433,9 +433,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadOnlyTexture, reporter, context_info) {
|
||||
static const int kSurfSize = 10;
|
||||
|
||||
static sk_sp<GrTexture> make_wrapped_texture(GrContext* context, GrRenderable renderable) {
|
||||
auto backendTexture = context->createBackendTexture(
|
||||
kSurfSize, kSurfSize, kRGBA_8888_SkColorType, SkColors::kTransparent, GrMipMapped::kNo,
|
||||
renderable, GrProtected::kNo);
|
||||
GrBackendTexture backendTexture;
|
||||
CreateBackendTexture(context, &backendTexture, kSurfSize, kSurfSize, kRGBA_8888_SkColorType,
|
||||
SkColors::kTransparent, GrMipMapped::kNo, renderable, GrProtected::kNo);
|
||||
sk_sp<GrTexture> texture;
|
||||
if (GrRenderable::kYes == renderable) {
|
||||
texture = context->priv().resourceProvider()->wrapRenderableBackendTexture(
|
||||
|
@ -483,9 +483,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsImage, reporter
|
||||
SkColorType colorType = static_cast<SkColorType>(ct);
|
||||
bool can = context->colorTypeSupportedAsImage(colorType);
|
||||
|
||||
GrBackendTexture backendTex = context->createBackendTexture(
|
||||
kSize, kSize, colorType, SkColors::kTransparent,
|
||||
GrMipMapped::kNo, GrRenderable::kNo, GrProtected::kNo);
|
||||
GrBackendTexture backendTex;
|
||||
CreateBackendTexture(context, &backendTex, kSize, kSize, colorType, SkColors::kTransparent,
|
||||
GrMipMapped::kNo, GrRenderable::kNo, GrProtected::kNo);
|
||||
|
||||
auto img = SkImage::MakeFromTexture(context, backendTex, kTopLeft_GrSurfaceOrigin,
|
||||
colorType, kOpaque_SkAlphaType, nullptr);
|
||||
@ -822,7 +822,6 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkImage_NewFromTextureRelease, reporter, c
|
||||
SkImageInfo ii = SkImageInfo::Make(kWidth, kHeight, SkColorType::kRGBA_8888_SkColorType,
|
||||
kPremul_SkAlphaType);
|
||||
GrBackendTexture backendTex;
|
||||
|
||||
if (!CreateBackendTexture(ctx, &backendTex, ii, SkColors::kRed, GrMipMapped::kNo,
|
||||
GrRenderable::kNo)) {
|
||||
ERRORF(reporter, "couldn't create backend texture\n");
|
||||
|
@ -17,7 +17,8 @@ void test_wrapping(GrContext* context, skiatest::Reporter* reporter,
|
||||
std::function<GrBackendTexture (GrContext*,
|
||||
GrMipMapped,
|
||||
GrRenderable)> create,
|
||||
GrColorType colorType, GrMipMapped mipMapped, GrRenderable renderable);
|
||||
GrColorType colorType, GrMipMapped mipMapped, GrRenderable renderable,
|
||||
bool* finishedBackendCreation);
|
||||
|
||||
void test_color_init(GrContext* context, skiatest::Reporter* reporter,
|
||||
std::function<GrBackendTexture (GrContext*,
|
||||
@ -25,7 +26,12 @@ void test_color_init(GrContext* context, skiatest::Reporter* reporter,
|
||||
GrMipMapped,
|
||||
GrRenderable)> create,
|
||||
GrColorType colorType, const SkColor4f& color,
|
||||
GrMipMapped mipMapped, GrRenderable renderable);
|
||||
GrMipMapped mipMapped, GrRenderable renderable,
|
||||
bool* finishedBackendCreation);
|
||||
|
||||
static void mark_signaled(void* context) {
|
||||
*(bool*)context = true;
|
||||
}
|
||||
|
||||
DEF_GPUTEST_FOR_METAL_CONTEXT(MtlBackendAllocationTest, reporter, ctxInfo) {
|
||||
GrContext* context = ctxInfo.grContext();
|
||||
@ -115,7 +121,7 @@ DEF_GPUTEST_FOR_METAL_CONTEXT(MtlBackendAllocationTest, reporter, ctxInfo) {
|
||||
};
|
||||
|
||||
test_wrapping(context, reporter, uninitCreateMtd,
|
||||
combo.fColorType, mipMapped, renderable);
|
||||
combo.fColorType, mipMapped, renderable, nullptr);
|
||||
}
|
||||
|
||||
{
|
||||
@ -141,13 +147,18 @@ DEF_GPUTEST_FOR_METAL_CONTEXT(MtlBackendAllocationTest, reporter, ctxInfo) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
auto createWithColorMtd = [format, swizzle](GrContext* context,
|
||||
const SkColor4f& color,
|
||||
GrMipMapped mipMapped,
|
||||
GrRenderable renderable) {
|
||||
|
||||
bool finishedBackendCreation = false;
|
||||
bool* finishedPtr = &finishedBackendCreation;
|
||||
|
||||
auto createWithColorMtd = [format, swizzle, finishedPtr](
|
||||
GrContext* context, const SkColor4f& color, GrMipMapped mipMapped,
|
||||
GrRenderable renderable) {
|
||||
auto swizzledColor = swizzle.applyTo(color);
|
||||
return context->createBackendTexture(32, 32, format, swizzledColor,
|
||||
mipMapped, renderable);
|
||||
mipMapped, renderable,
|
||||
GrProtected::kNo,
|
||||
mark_signaled, finishedPtr);
|
||||
};
|
||||
// We make our comparison color using SkPixmap::erase(color) on a pixmap of
|
||||
// combo.fColorType and then calling SkPixmap::readPixels(). erase() will premul
|
||||
@ -162,7 +173,7 @@ DEF_GPUTEST_FOR_METAL_CONTEXT(MtlBackendAllocationTest, reporter, ctxInfo) {
|
||||
1.f};
|
||||
}
|
||||
test_color_init(context, reporter, createWithColorMtd, combo.fColorType, color,
|
||||
mipMapped, renderable);
|
||||
mipMapped, renderable, finishedPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "src/gpu/GrGpu.h"
|
||||
#include "src/gpu/GrTexture.h"
|
||||
#include "src/image/SkImage_Gpu.h"
|
||||
#include "tests/TestUtils.h"
|
||||
|
||||
using namespace sk_gpu_test;
|
||||
|
||||
@ -265,8 +266,8 @@ DEF_GPUTEST(PromiseImageTextureShutdown, reporter, ctxInfo) {
|
||||
continue;
|
||||
}
|
||||
|
||||
GrBackendTexture backendTex = ctx->createBackendTexture(
|
||||
kWidth, kHeight, kAlpha_8_SkColorType,
|
||||
GrBackendTexture backendTex;
|
||||
CreateBackendTexture(ctx, &backendTex, kWidth, kHeight, kAlpha_8_SkColorType,
|
||||
SkColors::kTransparent, GrMipMapped::kNo, GrRenderable::kNo, GrProtected::kNo);
|
||||
REPORTER_ASSERT(reporter, backendTex.isValid());
|
||||
|
||||
@ -372,9 +373,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageNullFulfill, reporter, ctxInfo) {
|
||||
GrContext* ctx = ctxInfo.grContext();
|
||||
|
||||
// Do all this just to get a valid backend format for the image.
|
||||
GrBackendTexture backendTex = ctx->createBackendTexture(
|
||||
kWidth, kHeight, kRGBA_8888_SkColorType,
|
||||
SkColors::kTransparent, GrMipMapped::kNo, GrRenderable::kYes, GrProtected::kNo);
|
||||
GrBackendTexture backendTex;
|
||||
CreateBackendTexture(ctx, &backendTex, kWidth, kHeight, kRGBA_8888_SkColorType,
|
||||
SkColors::kTransparent, GrMipMapped::kNo, GrRenderable::kYes,
|
||||
GrProtected::kNo);
|
||||
REPORTER_ASSERT(reporter, backendTex.isValid());
|
||||
GrBackendFormat backendFormat = backendTex.getBackendFormat();
|
||||
REPORTER_ASSERT(reporter, backendFormat.isValid());
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "src/gpu/gl/GrGLUtil.h"
|
||||
#endif
|
||||
|
||||
#include "tests/TestUtils.h"
|
||||
|
||||
// Check that the surface proxy's member vars are set as expected
|
||||
static void check_surface(skiatest::Reporter* reporter,
|
||||
GrSurfaceProxy* proxy,
|
||||
@ -260,9 +262,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
|
||||
|
||||
// Tests wrapBackendRenderTarget with a GrBackendTexture
|
||||
{
|
||||
GrBackendTexture backendTex = context->createBackendTexture(
|
||||
kWidthHeight, kWidthHeight, colorType, SkColors::kTransparent,
|
||||
GrMipMapped::kNo, GrRenderable::kYes, GrProtected::kNo);
|
||||
GrBackendTexture backendTex;
|
||||
CreateBackendTexture(context, &backendTex, kWidthHeight, kWidthHeight, colorType,
|
||||
SkColors::kTransparent, GrMipMapped::kNo, GrRenderable::kYes,
|
||||
GrProtected::kNo);
|
||||
sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapBackendTextureAsRenderTarget(
|
||||
backendTex, supportedNumSamples);
|
||||
if (!sProxy) {
|
||||
@ -280,9 +283,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
|
||||
|
||||
// Tests wrapBackendTexture that is only renderable
|
||||
{
|
||||
GrBackendTexture backendTex = context->createBackendTexture(
|
||||
kWidthHeight, kWidthHeight, colorType, SkColors::kTransparent,
|
||||
GrMipMapped::kNo, GrRenderable::kYes, GrProtected::kNo);
|
||||
GrBackendTexture backendTex;
|
||||
CreateBackendTexture(context, &backendTex, kWidthHeight, kWidthHeight, colorType,
|
||||
SkColors::kTransparent, GrMipMapped::kNo, GrRenderable::kYes,
|
||||
GrProtected::kNo);
|
||||
|
||||
sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapRenderableBackendTexture(
|
||||
backendTex, supportedNumSamples, kBorrow_GrWrapOwnership,
|
||||
@ -303,9 +307,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
|
||||
// Tests wrapBackendTexture that is only textureable
|
||||
{
|
||||
// Internal offscreen texture
|
||||
GrBackendTexture backendTex = context->createBackendTexture(
|
||||
kWidthHeight, kWidthHeight, colorType, SkColors::kTransparent,
|
||||
GrMipMapped::kNo, GrRenderable::kNo, GrProtected::kNo);
|
||||
GrBackendTexture backendTex;
|
||||
CreateBackendTexture(context, &backendTex, kWidthHeight, kWidthHeight, colorType,
|
||||
SkColors::kTransparent, GrMipMapped::kNo, GrRenderable::kNo,
|
||||
GrProtected::kNo);
|
||||
|
||||
sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapBackendTexture(
|
||||
backendTex, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kRead_GrIOType);
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "src/gpu/GrTexture.h"
|
||||
#include "src/gpu/GrTextureProxy.h"
|
||||
#include "tests/Test.h"
|
||||
#include "tests/TestUtils.h"
|
||||
|
||||
struct ProxyParams {
|
||||
int fSize;
|
||||
@ -41,10 +42,9 @@ static sk_sp<GrSurfaceProxy> make_backend(GrContext* context, const ProxyParams&
|
||||
SkColorType skColorType = GrColorTypeToSkColorType(p.fColorType);
|
||||
SkASSERT(SkColorType::kUnknown_SkColorType != skColorType);
|
||||
|
||||
*backendTex = context->createBackendTexture(p.fSize, p.fSize, skColorType,
|
||||
SkColors::kTransparent,
|
||||
GrMipMapped::kNo, GrRenderable::kNo,
|
||||
GrProtected::kNo);
|
||||
CreateBackendTexture(context, backendTex, p.fSize, p.fSize, skColorType,
|
||||
SkColors::kTransparent, GrMipMapped::kNo, GrRenderable::kNo);
|
||||
|
||||
if (!backendTex->isValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "src/core/SkMipMap.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "tests/Test.h"
|
||||
#include "tests/TestUtils.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
@ -195,14 +196,12 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheWrappedResources, reporter, ctxI
|
||||
static const int kW = 100;
|
||||
static const int kH = 100;
|
||||
|
||||
backendTextures[0] = context->createBackendTexture(kW, kH, kRGBA_8888_SkColorType,
|
||||
SkColors::kTransparent,
|
||||
GrMipMapped::kNo, GrRenderable::kNo,
|
||||
GrProtected::kNo);
|
||||
backendTextures[1] = context->createBackendTexture(kW, kH, kRGBA_8888_SkColorType,
|
||||
SkColors::kTransparent,
|
||||
GrMipMapped::kNo, GrRenderable::kNo,
|
||||
GrProtected::kNo);
|
||||
CreateBackendTexture(context, &backendTextures[0], kW, kH, kRGBA_8888_SkColorType,
|
||||
SkColors::kTransparent, GrMipMapped::kNo, GrRenderable::kNo,
|
||||
GrProtected::kNo);
|
||||
CreateBackendTexture(context, &backendTextures[1], kW, kH, kRGBA_8888_SkColorType,
|
||||
SkColors::kTransparent, GrMipMapped::kNo, GrRenderable::kNo,
|
||||
GrProtected::kNo);
|
||||
REPORTER_ASSERT(reporter, backendTextures[0].isValid());
|
||||
REPORTER_ASSERT(reporter, backendTextures[1].isValid());
|
||||
if (!backendTextures[0].isValid() || !backendTextures[1].isValid()) {
|
||||
|
@ -105,9 +105,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsSurface, report
|
||||
REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d",
|
||||
colorType, can, SkToBool(surf));
|
||||
|
||||
GrBackendTexture backendTex = context->createBackendTexture(
|
||||
kSize, kSize, colorType,
|
||||
SkColors::kTransparent, GrMipMapped::kNo, GrRenderable::kYes, GrProtected::kNo);
|
||||
GrBackendTexture backendTex;
|
||||
CreateBackendTexture(context, &backendTex, kSize, kSize, colorType,
|
||||
SkColors::kTransparent, GrMipMapped::kNo, GrRenderable::kYes,
|
||||
GrProtected::kNo);
|
||||
surf = SkSurface::MakeFromBackendTexture(context, backendTex,
|
||||
kTopLeft_GrSurfaceOrigin, 0, colorType,
|
||||
nullptr, nullptr);
|
||||
@ -135,11 +136,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsSurface, report
|
||||
REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d",
|
||||
colorType, can, SkToBool(surf));
|
||||
|
||||
GrBackendTexture backendTex = context->createBackendTexture(
|
||||
kSize, kSize, colorType,
|
||||
SkColors::kTransparent,
|
||||
GrMipMapped::kNo, GrRenderable::kYes,
|
||||
GrProtected::kNo);
|
||||
GrBackendTexture backendTex;
|
||||
CreateBackendTexture(context, &backendTex, kSize, kSize, colorType,
|
||||
SkColors::kTransparent, GrMipMapped::kNo, GrRenderable::kYes,
|
||||
GrProtected::kNo);
|
||||
surf = SkSurface::MakeFromBackendTexture(context, backendTex,
|
||||
kTopLeft_GrSurfaceOrigin, kSampleCnt,
|
||||
colorType, nullptr, nullptr);
|
||||
@ -211,9 +211,11 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_maxSurfaceSamplesForColorType, repo
|
||||
if (!max) {
|
||||
continue;
|
||||
}
|
||||
GrBackendTexture backendTex = context->createBackendTexture(
|
||||
kSize, kSize, colorType, SkColors::kTransparent,
|
||||
GrMipMapped::kNo, GrRenderable::kYes, GrProtected::kNo);
|
||||
|
||||
GrBackendTexture backendTex;
|
||||
CreateBackendTexture(context, &backendTex, kSize, kSize, colorType,
|
||||
SkColors::kTransparent, GrMipMapped::kNo, GrRenderable::kYes,
|
||||
GrProtected::kNo);
|
||||
if (!backendTex.isValid()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -104,14 +104,39 @@ void FillPixelData(int width, int height, GrColor* data) {
|
||||
}
|
||||
}
|
||||
|
||||
bool CreateBackendTexture(GrContext* context,
|
||||
GrBackendTexture* backendTex,
|
||||
int width, int height,
|
||||
SkColorType colorType,
|
||||
const SkColor4f& color,
|
||||
GrMipMapped mipMapped,
|
||||
GrRenderable renderable,
|
||||
GrProtected isProtected) {
|
||||
SkImageInfo info = SkImageInfo::Make(width, height, colorType, kPremul_SkAlphaType);
|
||||
return CreateBackendTexture(context, backendTex, info, color, mipMapped, renderable,
|
||||
isProtected);
|
||||
}
|
||||
|
||||
bool CreateBackendTexture(GrContext* context,
|
||||
GrBackendTexture* backendTex,
|
||||
const SkImageInfo& ii,
|
||||
const SkColor4f& color,
|
||||
GrMipMapped mipMapped,
|
||||
GrRenderable renderable) {
|
||||
GrRenderable renderable,
|
||||
GrProtected isProtected) {
|
||||
bool finishedBECreate = false;
|
||||
auto markFinished = [](void* context) {
|
||||
*(bool*)context = true;
|
||||
};
|
||||
|
||||
*backendTex = context->createBackendTexture(ii.width(), ii.height(), ii.colorType(),
|
||||
color, mipMapped, renderable);
|
||||
color, mipMapped, renderable, isProtected,
|
||||
markFinished, &finishedBECreate);
|
||||
if (backendTex->isValid()) {
|
||||
while (!finishedBECreate) {
|
||||
context->checkAsyncWorkCompletion();
|
||||
}
|
||||
}
|
||||
return backendTex->isValid();
|
||||
}
|
||||
|
||||
|
@ -31,13 +31,23 @@ void TestCopyFromSurface(skiatest::Reporter*, GrContext*, GrSurfaceProxy* proxy,
|
||||
// Fills data with a red-green gradient
|
||||
void FillPixelData(int width, int height, GrColor* data);
|
||||
|
||||
// Create a solid colored backend texture
|
||||
// Create a solid colored backend texture and syncs the CPU to wait for upload to finish
|
||||
bool CreateBackendTexture(GrContext* context,
|
||||
GrBackendTexture* backendTex,
|
||||
int width, int height,
|
||||
SkColorType colorType,
|
||||
const SkColor4f& color,
|
||||
GrMipMapped mipMapped,
|
||||
GrRenderable renderable,
|
||||
GrProtected = GrProtected::kNo);
|
||||
|
||||
bool CreateBackendTexture(GrContext*,
|
||||
GrBackendTexture* backendTex,
|
||||
const SkImageInfo& ii,
|
||||
const SkColor4f& color,
|
||||
GrMipMapped,
|
||||
GrRenderable);
|
||||
GrRenderable,
|
||||
GrProtected = GrProtected::kNo);
|
||||
|
||||
void DeleteBackendTexture(GrContext*, const GrBackendTexture& backendTex);
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "include/gpu/vk/GrVkVulkan.h"
|
||||
|
||||
#include "tests/Test.h"
|
||||
#include "tests/TestUtils.h"
|
||||
|
||||
#include "include/core/SkImage.h"
|
||||
#include "include/gpu/GrBackendSurface.h"
|
||||
@ -33,12 +34,9 @@
|
||||
DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkImageLayoutTest, reporter, ctxInfo) {
|
||||
GrContext* context = ctxInfo.grContext();
|
||||
|
||||
GrBackendTexture backendTex = context->createBackendTexture(1, 1,
|
||||
kRGBA_8888_SkColorType,
|
||||
SkColors::kTransparent,
|
||||
GrMipMapped::kNo,
|
||||
GrRenderable::kNo,
|
||||
GrProtected::kNo);
|
||||
GrBackendTexture backendTex;
|
||||
CreateBackendTexture(context, &backendTex, 1, 1, kRGBA_8888_SkColorType, SkColors::kTransparent,
|
||||
GrMipMapped::kNo, GrRenderable::kNo, GrProtected::kNo);
|
||||
REPORTER_ASSERT(reporter, backendTex.isValid());
|
||||
|
||||
GrVkImageInfo info;
|
||||
|
@ -148,7 +148,7 @@ void VulkanTestHelper::cleanup() {
|
||||
sk_sp<SkSurface> VulkanTestHelper::createSkSurface(skiatest::Reporter* reporter) {
|
||||
const int kW = 8;
|
||||
const int kH = 8;
|
||||
GrBackendTexture backendTex = grContext()->createBackendTexture(
|
||||
GrBackendTexture backendTex = this->grContext()->createBackendTexture(
|
||||
kW, kH, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kNo,
|
||||
fIsProtected ? GrProtected::kYes : GrProtected::kNo);
|
||||
REPORTER_ASSERT(reporter, backendTex.isValid());
|
||||
@ -157,7 +157,7 @@ sk_sp<SkSurface> VulkanTestHelper::createSkSurface(skiatest::Reporter* reporter)
|
||||
SkSurfaceProps surfaceProps =
|
||||
SkSurfaceProps(0, SkSurfaceProps::kLegacyFontHost_InitType);
|
||||
sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTextureAsRenderTarget(
|
||||
grContext(), backendTex, kTopLeft_GrSurfaceOrigin, 1,
|
||||
this->grContext(), backendTex, kTopLeft_GrSurfaceOrigin, 1,
|
||||
kRGBA_8888_SkColorType, nullptr, &surfaceProps);
|
||||
REPORTER_ASSERT(reporter, surface);
|
||||
return surface;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "src/gpu/vk/GrVkGpu.h"
|
||||
#include "src/gpu/vk/GrVkMemory.h"
|
||||
#include "tests/Test.h"
|
||||
#include "tests/TestUtils.h"
|
||||
|
||||
using sk_gpu_test::GrContextFactory;
|
||||
|
||||
@ -35,12 +36,10 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
|
||||
GrGpu* gpu = context->priv().getGpu();
|
||||
|
||||
GrBackendTexture origBackendTex = context->createBackendTexture(kW, kH,
|
||||
kColorType,
|
||||
SkColors::kTransparent,
|
||||
GrMipMapped::kNo,
|
||||
GrRenderable::kNo,
|
||||
GrProtected::kNo);
|
||||
GrBackendTexture origBackendTex;
|
||||
CreateBackendTexture(context, &origBackendTex, kW, kH, kColorType, SkColors::kTransparent,
|
||||
GrMipMapped::kNo, GrRenderable::kNo, GrProtected::kNo);
|
||||
|
||||
GrVkImageInfo imageInfo;
|
||||
SkAssertResult(origBackendTex.getVkImageInfo(&imageInfo));
|
||||
|
||||
@ -88,12 +87,9 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
GrGpu* gpu = context->priv().getGpu();
|
||||
|
||||
GrBackendTexture origBackendTex = context->createBackendTexture(kW, kH,
|
||||
kColorType,
|
||||
SkColors::kTransparent,
|
||||
GrMipMapped::kNo,
|
||||
GrRenderable::kYes,
|
||||
GrProtected::kNo);
|
||||
GrBackendTexture origBackendTex;
|
||||
CreateBackendTexture(context, &origBackendTex, kW, kH, kColorType, SkColors::kTransparent,
|
||||
GrMipMapped::kNo, GrRenderable::kYes, GrProtected::kNo);
|
||||
|
||||
GrVkImageInfo imageInfo;
|
||||
SkAssertResult(origBackendTex.getVkImageInfo(&imageInfo));
|
||||
@ -130,12 +126,10 @@ void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
GrGpu* gpu = context->priv().getGpu();
|
||||
|
||||
GrBackendTexture origBackendTex = context->createBackendTexture(kW, kH,
|
||||
kColorType,
|
||||
SkColors::kTransparent,
|
||||
GrMipMapped::kNo,
|
||||
GrRenderable::kYes,
|
||||
GrProtected::kNo);
|
||||
GrBackendTexture origBackendTex;
|
||||
CreateBackendTexture(context, &origBackendTex, kW, kH, kColorType, SkColors::kTransparent,
|
||||
GrMipMapped::kNo, GrRenderable::kYes, GrProtected::kNo);
|
||||
|
||||
GrVkImageInfo imageInfo;
|
||||
SkAssertResult(origBackendTex.getVkImageInfo(&imageInfo));
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "include/private/SkImageInfoPriv.h"
|
||||
#include "src/core/SkMathPriv.h"
|
||||
#include "tests/Test.h"
|
||||
#include "tests/TestUtils.h"
|
||||
#include "tools/ToolUtils.h"
|
||||
|
||||
#include "include/gpu/GrBackendSurface.h"
|
||||
@ -455,8 +456,8 @@ static void test_write_pixels_non_texture(skiatest::Reporter* reporter,
|
||||
int sampleCnt) {
|
||||
|
||||
for (auto& origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) {
|
||||
GrBackendTexture backendTex = context->createBackendTexture(
|
||||
DEV_W, DEV_H, kRGBA_8888_SkColorType,
|
||||
GrBackendTexture backendTex;
|
||||
CreateBackendTexture(context, &backendTex, DEV_W, DEV_H, kRGBA_8888_SkColorType,
|
||||
SkColors::kTransparent, GrMipMapped::kNo, GrRenderable::kYes, GrProtected::kNo);
|
||||
if (!backendTex.isValid()) {
|
||||
continue;
|
||||
|
@ -121,8 +121,18 @@ static GrBackendTexture create_yuva_texture(GrContext* context, const SkPixmap&
|
||||
SkASSERT(kR8G8_unorm_SkColorType == pm.colorType());
|
||||
}
|
||||
#endif
|
||||
|
||||
return context->createBackendTexture(&pm, 1, GrRenderable::kNo, GrProtected::kNo);
|
||||
bool finishedBECreate = false;
|
||||
auto markFinished = [](void* context) {
|
||||
*(bool*)context = true;
|
||||
};
|
||||
auto beTex = context->createBackendTexture(&pm, 1, GrRenderable::kNo, GrProtected::kNo,
|
||||
markFinished, &finishedBECreate);
|
||||
if (beTex.isValid()) {
|
||||
while (!finishedBECreate) {
|
||||
context->checkAsyncWorkCompletion();
|
||||
}
|
||||
}
|
||||
return beTex;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -157,11 +167,17 @@ void DDLPromiseImageHelper::CreateBETexturesForPromiseImage(GrContext* context,
|
||||
|
||||
std::unique_ptr<SkPixmap[]> mipLevels = info->normalMipLevels();
|
||||
|
||||
GrBackendTexture backendTex = context->createBackendTexture(mipLevels.get(),
|
||||
info->numMipLevels(),
|
||||
GrRenderable::kNo,
|
||||
GrProtected::kNo);
|
||||
bool finishedBECreate = false;
|
||||
auto markFinished = [](void* context) {
|
||||
*(bool*)context = true;
|
||||
};
|
||||
auto backendTex = context->createBackendTexture(mipLevels.get(), info->numMipLevels(),
|
||||
GrRenderable::kNo, GrProtected::kNo,
|
||||
markFinished, &finishedBECreate);
|
||||
SkASSERT(backendTex.isValid());
|
||||
while (!finishedBECreate) {
|
||||
context->checkAsyncWorkCompletion();
|
||||
}
|
||||
|
||||
callbackContext->setBackendTexture(backendTex);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user