Take origin when creating/updating backend texture using pixmaps.
Bug: skia:11042
Change-Id: I511c7556f97f19d7f162031c245019d2da33c129
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/341005
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/include/gpu/GrDirectContext.h b/include/gpu/GrDirectContext.h
index 57f35f7..5a57ad0 100644
--- a/include/gpu/GrDirectContext.h
+++ b/include/gpu/GrDirectContext.h
@@ -506,26 +506,61 @@
* 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).
+ * must be sized correctly (please see SkMipmap::ComputeLevelSize and ComputeLevelCount). The
+ * GrSurfaceOrigin controls whether the pixmap data is vertically flipped in the texture.
* 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
*/
- GrBackendTexture createBackendTexture(const SkPixmap srcData[], int numLevels,
- GrRenderable, GrProtected,
+ GrBackendTexture createBackendTexture(const SkPixmap srcData[],
+ int numLevels,
+ GrSurfaceOrigin,
+ GrRenderable,
+ GrProtected,
GrGpuFinishedProc finishedProc = nullptr,
GrGpuFinishedContext finishedContext = nullptr);
- // Helper version of above for a single level.
+ /**
+ * Convenience version createBackendTexture() that takes just a base level pixmap.
+ */
GrBackendTexture createBackendTexture(const SkPixmap& srcData,
+ GrSurfaceOrigin textureOrigin,
GrRenderable renderable,
GrProtected isProtected,
GrGpuFinishedProc finishedProc = nullptr,
GrGpuFinishedContext finishedContext = nullptr) {
- return this->createBackendTexture(&srcData, 1, renderable, isProtected, finishedProc,
- finishedContext);
+ return this->createBackendTexture(&srcData, 1, textureOrigin, renderable, isProtected,
+ finishedProc, finishedContext);
}
+ // Deprecated versions that do not take origin and assume top-left.
+ GrBackendTexture createBackendTexture(const SkPixmap srcData[],
+ int numLevels,
+ GrRenderable renderable,
+ GrProtected isProtected,
+ GrGpuFinishedProc finishedProc = nullptr,
+ GrGpuFinishedContext finishedContext = nullptr) {
+ return this->createBackendTexture(srcData,
+ numLevels,
+ kTopLeft_GrSurfaceOrigin,
+ renderable,
+ isProtected,
+ finishedProc,
+ finishedContext);
+ }
+ GrBackendTexture createBackendTexture(const SkPixmap& srcData,
+ GrRenderable renderable,
+ GrProtected isProtected,
+ GrGpuFinishedProc finishedProc = nullptr,
+ GrGpuFinishedContext finishedContext = nullptr) {
+ return this->createBackendTexture(&srcData,
+ 1,
+ renderable,
+ isProtected,
+ finishedProc,
+ finishedContext);
+ }
+
/**
* If possible, updates a backend texture to be filled to a particular color. The client should
* check the return value to see if the update was successful. The client can pass in a
@@ -569,7 +604,8 @@
* If the backend texture is mip mapped, 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).
+ * SkMipmap::ComputeLevelSize and ComputeLevelCount). The GrSurfaceOrigin controls whether the
+ * pixmap data is vertically flipped in the texture.
* Note: the pixmap's alphatypes and colorspaces are ignored.
* For the Vulkan backend after a successful update the layout of the created VkImage will be:
* VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
@@ -577,8 +613,39 @@
bool updateBackendTexture(const GrBackendTexture&,
const SkPixmap srcData[],
int numLevels,
- GrGpuFinishedProc finishedProc,
- GrGpuFinishedContext finishedContext);
+ GrSurfaceOrigin = kTopLeft_GrSurfaceOrigin,
+ GrGpuFinishedProc finishedProc = nullptr,
+ GrGpuFinishedContext finishedContext = nullptr);
+
+ /**
+ * Convenience version of updateBackendTexture that takes just a base level pixmap.
+ */
+ bool updateBackendTexture(const GrBackendTexture& texture,
+ const SkPixmap& srcData,
+ GrSurfaceOrigin textureOrigin = kTopLeft_GrSurfaceOrigin,
+ GrGpuFinishedProc finishedProc = nullptr,
+ GrGpuFinishedContext finishedContext = nullptr) {
+ return this->updateBackendTexture(texture,
+ &srcData,
+ 1,
+ textureOrigin,
+ finishedProc,
+ finishedContext);
+ }
+
+ // Deprecated version that does not take origin and assumes top-left.
+ bool updateBackendTexture(const GrBackendTexture& texture,
+ const SkPixmap srcData[],
+ int numLevels,
+ GrGpuFinishedProc finishedProc,
+ GrGpuFinishedContext finishedContext) {
+ return this->updateBackendTexture(texture,
+ srcData,
+ numLevels,
+ kTopLeft_GrSurfaceOrigin,
+ finishedProc,
+ finishedContext);
+ }
/**
* Retrieve the GrBackendFormat for a given SkImage::CompressionType. This is