aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2018-03-09 12:05:04 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-09 18:02:00 +0000
commita8d9211bc3f34fcb3cf331d8fd76e4ea5803fe20 (patch)
tree5e13626cb2fc91f839ecf624953921ee7bf31b1b /include
parent33cb22cb2b60255a2755cc88072490fe8d05b0b9 (diff)
Add promise images for deferred instantiation of wrapped gpu textures
This will allow a client to make an SkImage that "wraps" a gpu texture, however the client does need to supply the actual gpu texture at Image creation time. Instead it is retrieve at flush time via a callback. Bug: skia: Change-Id: I6267a55ab7102101a7bd80a6f547b6a870d2df08 Reviewed-on: https://skia-review.googlesource.com/109021 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Cary Clark <caryclark@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/core/SkDeferredDisplayListRecorder.h59
-rw-r--r--include/gpu/GrBackendSurface.h2
2 files changed, 60 insertions, 1 deletions
diff --git a/include/core/SkDeferredDisplayListRecorder.h b/include/core/SkDeferredDisplayListRecorder.h
index c985e7377d..601cd533b5 100644
--- a/include/core/SkDeferredDisplayListRecorder.h
+++ b/include/core/SkDeferredDisplayListRecorder.h
@@ -8,11 +8,15 @@
#ifndef SkDeferredDisplayListMaker_DEFINED
#define SkDeferredDisplayListMaker_DEFINED
+#include "SkImageInfo.h"
#include "SkRefCnt.h"
#include "SkSurfaceCharacterization.h"
+#include "SkTypes.h"
#include "../private/SkDeferredDisplayList.h"
+class GrBackendFormat;
+class GrBackendTexture;
class GrContext;
class SkCanvas;
@@ -46,6 +50,61 @@ public:
std::unique_ptr<SkDeferredDisplayList> detach();
+ // Matches the defines in SkImage_Gpu.h
+ typedef void* TextureContext;
+ typedef void (*TextureReleaseProc)(TextureContext textureContext);
+ typedef void (*TextureFulfillProc)(TextureContext textureContext, GrBackendTexture* outTexture);
+
+ /**
+ Create a new SkImage that is very similar to an SkImage created by MakeFromTexture. The main
+ difference is that the client doesn't have the backend texture on the gpu yet but they know
+ all the properties of the texture. So instead of passing in a GrBackendTexture the client
+ supplies a GrBackendFormat, width, height, and GrMipMapped state.
+
+ When we actually send the draw calls to the GPU, we will call the textureFulfillProc and
+ the client will return a GrBackendTexture to us. The properties of the GrBackendTexture must
+ match those set during the SkImage creation, and it must have a valid backend gpu texture.
+ The gpu texture supplied by the client must stay valid until we call the textureReleaseProc.
+
+ When we are done with the texture returned by the textureFulfillProc we will call the
+ textureReleaseProc passing in the textureContext. This is a signal to the client that they
+ are free to delete the underlying gpu texture. If future draws also use the same promise
+ image we will call the textureFulfillProc again if we've already called the
+ textureReleaseProc. We will always call textureFulfillProc and textureReleaseProc in pairs.
+ In other words we will never call textureFulfillProc or textureReleaseProc multiple times
+ for the same textureContext before calling the other.
+
+ This call is only valid if the SkDeferredDisplayListRecorder is backed by a gpu context.
+
+ @param backendFormat format of promised gpu texture
+ @param width width of promised gpu texture
+ @param height height of promised gpu texture
+ @param mipMapped mip mapped state of promised gpu texture
+ @param origin one of: kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin
+ @param colorType one of: kUnknown_SkColorType, kAlpha_8_SkColorType,
+ kRGB_565_SkColorType, kARGB_4444_SkColorType,
+ kRGBA_8888_SkColorType, kBGRA_8888_SkColorType,
+ kGray_8_SkColorType, kRGBA_F16_SkColorType
+ @param alphaType one of: kUnknown_SkAlphaType, kOpaque_SkAlphaType,
+ kPremul_SkAlphaType, kUnpremul_SkAlphaType
+ @param colorSpace range of colors; may be nullptr
+ @param textureFulfillProc function called to get actual gpu texture
+ @param textureReleaseProc function called when texture can be released
+ @param textureContext state passed to textureFulfillProc and textureReleaseProc
+ @return created SkImage, or nullptr
+ */
+ sk_sp<SkImage> makePromiseTexture(const GrBackendFormat& backendFormat,
+ int width,
+ int height,
+ GrMipMapped mipMapped,
+ GrSurfaceOrigin origin,
+ SkColorType colorType,
+ SkAlphaType alphaType,
+ sk_sp<SkColorSpace> colorSpace,
+ TextureFulfillProc textureFulfillProc,
+ TextureReleaseProc textureReleaseProc,
+ TextureContext textureContext);
+
private:
bool init();
diff --git a/include/gpu/GrBackendSurface.h b/include/gpu/GrBackendSurface.h
index a2df90cd0d..94ab39aca2 100644
--- a/include/gpu/GrBackendSurface.h
+++ b/include/gpu/GrBackendSurface.h
@@ -26,7 +26,7 @@ public:
}
#ifdef SK_VULKAN
- static GrBackendFormat MakeVK(VkFormat format) {
+ static GrBackendFormat MakeVk(VkFormat format) {
return GrBackendFormat(format);
}
#endif