aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2017-12-18 14:48:15 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-18 21:17:46 +0000
commitf5d8758f29390fd5c135df12bc8a5e196854eda2 (patch)
treea7de0b54b030dda4549bc9feb0a0e2ff65ded7d6 /include
parent4fafedd33add9948db1147c60d681ed9340984fd (diff)
Add new SkImage factory to create from GrBackendTexture with SkColorType
Bug: skia: Change-Id: I46bdc54b6d9cdacc8f5a06644aa6b110837879f0 Reviewed-on: https://skia-review.googlesource.com/84342 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/core/SkImage.h66
-rw-r--r--include/gpu/GrBackendSurface.h6
-rw-r--r--include/gpu/GrCaps.h10
3 files changed, 82 insertions, 0 deletions
diff --git a/include/core/SkImage.h b/include/core/SkImage.h
index 03d463d098..2a196aac41 100644
--- a/include/core/SkImage.h
+++ b/include/core/SkImage.h
@@ -96,6 +96,9 @@ public:
* managing the lifetime of the underlying platform texture.
*
* Will return NULL if the specified backend texture is unsupported.
+ *
+ * DEPRECATED: This factory is deprecated and clients should use the factory below which takes
+ * an SkColorType.
*/
static sk_sp<SkImage> MakeFromTexture(GrContext* context,
const GrBackendTexture& backendTexture,
@@ -112,10 +115,53 @@ public:
* no longer is holding a reference to it.
*
* Will return NULL if the specified backend texture is unsupported.
+ *
+ * DEPRECATED: This factory is deprecated and clients should use the factory below which takes
+ * an SkColorType.
+ */
+ static sk_sp<SkImage> MakeFromTexture(GrContext* context,
+ const GrBackendTexture& backendTexture,
+ GrSurfaceOrigin origin,
+ SkAlphaType alphaType,
+ sk_sp<SkColorSpace> colorSpace,
+ TextureReleaseProc textureReleaseProc,
+ ReleaseContext releaseContext);
+
+ /**
+ * Create a new image from the specified descriptor. Note - the caller is responsible for
+ * managing the lifetime of the underlying platform texture.
+ *
+ * The GrBackendTexture mush have a valid backed format supplied (GrGLTextureInfo::fFormat,
+ * GrVkImageInfo::fFormat, etc.) in it. The passed in SkColorType informs skia how it should
+ * interpret the backend format supplied by the GrBackendTexture. If the format in the
+ * GrBackendTexture is not compitable with the SkColorType, SkAlphaType, and SkColorSpace we
+ * will return nullptr.
+ */
+ static sk_sp<SkImage> MakeFromTexture(GrContext* context,
+ const GrBackendTexture& backendTexture,
+ GrSurfaceOrigin origin,
+ SkColorType colorType,
+ SkAlphaType alphaType,
+ sk_sp<SkColorSpace> colorSpace) {
+ return MakeFromTexture(context, backendTexture, origin, colorType, alphaType, colorSpace,
+ nullptr, nullptr);
+ }
+
+ /**
+ * Create a new image from the GrBackendTexture. The underlying platform texture must stay
+ * valid and unaltered until the specified release-proc is invoked, indicating that Skia
+ * no longer is holding a reference to it.
+ *
+ * The GrBackendTexture mush have a valid backed format supplied (GrGLTextureInfo::fFormat,
+ * GrVkImageInfo::fFormat, etc.) in it. The passed in SkColorType informs skia how it should
+ * interpret the backend format supplied by the GrBackendTexture. If the format in the
+ * GrBackendTexture is not compitable with the SkColorType, SkAlphaType, and SkColorSpace we
+ * will return nullptr.
*/
static sk_sp<SkImage> MakeFromTexture(GrContext* context,
const GrBackendTexture& backendTexture,
GrSurfaceOrigin origin,
+ SkColorType colorType,
SkAlphaType alphaType,
sk_sp<SkColorSpace> colorSpace,
TextureReleaseProc textureReleaseProc,
@@ -158,10 +204,30 @@ public:
* texture when the image is released.
*
* Will return NULL if the specified backend texture is unsupported.
+ *
+ * DEPRECATED: This factory is deprecated and clients should use the factory below which takes
+ * an SkColorType.
+ */
+ static sk_sp<SkImage> MakeFromAdoptedTexture(GrContext* context,
+ const GrBackendTexture& backendTexture,
+ GrSurfaceOrigin surfaceOrigin,
+ SkAlphaType alphaType = kPremul_SkAlphaType,
+ sk_sp<SkColorSpace> colorSpace = nullptr);
+
+ /**
+ * Create a new image from the specified descriptor. Note - Skia will delete or recycle the
+ * texture when the image is released.
+ *
+ * The GrBackendTexture mush have a valid backed format supplied (GrGLTextureInfo::fFormat,
+ * GrVkImageInfo::fFormat, etc.) in it. The passed in SkColorType informs skia how it should
+ * interpret the backend format supplied by the GrBackendTexture. If the format in the
+ * GrBackendTexture is not compitable with the SkColorType, SkAlphaType, and SkColorSpace we
+ * will return nullptr.
*/
static sk_sp<SkImage> MakeFromAdoptedTexture(GrContext* context,
const GrBackendTexture& backendTexture,
GrSurfaceOrigin surfaceOrigin,
+ SkColorType colorType,
SkAlphaType alphaType = kPremul_SkAlphaType,
sk_sp<SkColorSpace> colorSpace = nullptr);
diff --git a/include/gpu/GrBackendSurface.h b/include/gpu/GrBackendSurface.h
index 1eab3577b1..9f77155e39 100644
--- a/include/gpu/GrBackendSurface.h
+++ b/include/gpu/GrBackendSurface.h
@@ -84,8 +84,11 @@ public:
private:
// Friending for access to the GrPixelConfig
friend class SkSurface;
+ friend class GrCaps;
friend class GrGpu;
+ friend class GrGLCaps;
friend class GrGLGpu;
+ friend class GrVkCaps;
friend class GrVkGpu;
GrPixelConfig config() const { return fConfig; }
@@ -146,8 +149,11 @@ public:
private:
// Friending for access to the GrPixelConfig
friend class SkSurface;
+ friend class GrCaps;
friend class GrGpu;
+ friend class GrGLCaps;
friend class GrGLGpu;
+ friend class GrVkCaps;
friend class GrVkGpu;
GrPixelConfig config() const { return fConfig; }
diff --git a/include/gpu/GrCaps.h b/include/gpu/GrCaps.h
index 6cdc0e3ff6..59e0528a23 100644
--- a/include/gpu/GrCaps.h
+++ b/include/gpu/GrCaps.h
@@ -11,9 +11,11 @@
#include "../private/GrTypesPriv.h"
#include "GrBlend.h"
#include "GrShaderCaps.h"
+#include "SkImageInfo.h"
#include "SkRefCnt.h"
#include "SkString.h"
+class GrBackendTexture;
struct GrContextOptions;
class GrRenderTargetProxy;
class SkJSONWriter;
@@ -170,6 +172,13 @@ public:
virtual bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc,
bool* rectsMustMatch, bool* disallowSubrect) const = 0;
+ /**
+ * Returns true if the GrBackendTexutre can we used with the supplied SkColorType. If it is
+ * compatible, the GrPixelConfig on the GrBackendTexture will be set to a config that matches
+ * the backend format and requested SkColorType.
+ */
+ bool validateBackendTexture(GrBackendTexture* tex, SkColorType ct) const;
+
protected:
/** Subclasses must call this at the end of their constructors in order to apply caps
overrides requested by the client. Note that overrides will only reduce the caps never
@@ -229,6 +238,7 @@ protected:
int fMaxClipAnalyticFPs;
private:
+ virtual bool onValidateBackendTexture(GrBackendTexture* tex, SkColorType ct) const = 0;
virtual void onApplyOptionsOverrides(const GrContextOptions&) {}
virtual void onDumpJSON(SkJSONWriter*) const {}