aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Eric Karl <ericrk@chromium.org>2017-12-15 23:37:45 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-15 23:57:41 +0000
commitaae533e418f37d788cdb1a1177e882d0f8868b62 (patch)
tree6e2b29d025b4058f86fb834c83b037efec0d5232 /include
parentb2e3a3ada25301a2141b800c9b9278d6d07975f7 (diff)
Revert "Remove SkImage deferred texture image data APIs."
This reverts commit 4f5e1d4ff3fa9f240398c9a08be94beb1c16dad0. Reason for revert: Unfortunately, we need this in Chrome for a bit longer. Working on understanding why the new path led to regressions. Will re-land this once the new path sticks. Original change's description: > Remove SkImage deferred texture image data APIs. > > These APIs existed for Chrome. Chrome is no longer using them. > > Change-Id: I15a5e2f88c7e8d1356188748fc68d4658f6f1849 > Reviewed-on: https://skia-review.googlesource.com/81021 > Reviewed-by: Brian Osman <brianosman@google.com> > Reviewed-by: Cary Clark <caryclark@google.com> > Commit-Queue: Brian Salomon <bsalomon@google.com> TBR=bsalomon@google.com,brianosman@google.com,caryclark@google.com,caryclark@skia.org # Not skipping CQ checks because original CL landed > 1 day ago. Change-Id: Ic9f683f262f2e1d0469156360f5ffaee977ca44a Reviewed-on: https://skia-review.googlesource.com/86280 Reviewed-by: Eric Karl <ericrk@chromium.org> Commit-Queue: Eric Karl <ericrk@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/core/SkImage.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/include/core/SkImage.h b/include/core/SkImage.h
index 454c5e4b7b..c0f8272c48 100644
--- a/include/core/SkImage.h
+++ b/include/core/SkImage.h
@@ -436,6 +436,60 @@ public:
const SkIRect& clipBounds, SkIRect* outSubset,
SkIPoint* offset) const;
+ /** Drawing params for which a deferred texture image data should be optimized. */
+ struct DeferredTextureImageUsageParams {
+ DeferredTextureImageUsageParams(const SkMatrix matrix, const SkFilterQuality quality,
+ int preScaleMipLevel)
+ : fMatrix(matrix), fQuality(quality), fPreScaleMipLevel(preScaleMipLevel) {}
+ SkMatrix fMatrix;
+ SkFilterQuality fQuality;
+ int fPreScaleMipLevel;
+ };
+
+ /**
+ * This method allows clients to capture the data necessary to turn a SkImage into a texture-
+ * backed image. If the original image is codec-backed this will decode into a format optimized
+ * for the context represented by the proxy. This method is thread safe with respect to the
+ * GrContext whence the proxy came. Clients allocate and manage the storage of the deferred
+ * texture data and control its lifetime. No cleanup is required, thus it is safe to simply free
+ * the memory out from under the data.
+ *
+ * The same method is used both for getting the size necessary for pre-uploaded texture data
+ * and for retrieving the data. The params array represents the set of draws over which to
+ * optimize the pre-upload data.
+ *
+ * When called with a null buffer this returns the size that the client must allocate in order
+ * to create deferred texture data for this image (or zero if this is an inappropriate
+ * candidate). The buffer allocated by the client should be 8 byte aligned.
+ *
+ * When buffer is not null this fills in the deferred texture data for this image in the
+ * provided buffer (assuming this is an appropriate candidate image and the buffer is
+ * appropriately aligned). Upon success the size written is returned, otherwise 0.
+ *
+ * dstColorSpace is the color space of the surface where this texture will ultimately be used.
+ * If the method determines that mip-maps are needed, this helps determine the correct strategy
+ * for building them (gamma-correct or not).
+ *
+ * dstColorType is the color type of the surface where this texture will ultimately be used.
+ * This determines the format with which the image will be uploaded to the GPU. If dstColorType
+ * does not support color spaces (low bit depth types such as ARGB_4444), then dstColorSpace
+ * must be null.
+ */
+ size_t getDeferredTextureImageData(const GrContextThreadSafeProxy& contextThreadSafeProxy,
+ const DeferredTextureImageUsageParams deferredTextureImageUsageParams[],
+ int paramCnt,
+ void* buffer,
+ SkColorSpace* dstColorSpace = nullptr,
+ SkColorType dstColorType = kN32_SkColorType) const;
+
+ /**
+ * Returns a texture-backed image from data produced in SkImage::getDeferredTextureImageData.
+ * The context must be the context that provided the proxy passed to
+ * getDeferredTextureImageData.
+ */
+ static sk_sp<SkImage> MakeFromDeferredTextureImageData(GrContext* context, const void* data,
+ SkBudgeted budgeted);
+
typedef std::function<void(GrBackendTexture)> BackendTextureReleaseProc;
/**