From 13dddce65fd87a8175a209a49f35615735a2886a Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Tue, 9 May 2017 13:19:50 -0400 Subject: Added SkImage::MakeCrossContextFromEncoded Designed for Flutter's threading architecture, with an eye to being useful to other clients. Under the hood, uses a new image generator class to lazily wrap a texture for multiple GrContexts. Re-land of https://skia-review.googlesource.com/c/14180/ Bug: skia: Change-Id: I3dd382640629b79b3058f18fee68d043566e43e5 Reviewed-on: https://skia-review.googlesource.com/15895 Reviewed-by: Brian Salomon Commit-Queue: Brian Osman --- src/gpu/gl/GrGLGpu.cpp | 8 ++++++++ src/gpu/gl/GrGLGpu.h | 2 ++ 2 files changed, 10 insertions(+) (limited to 'src/gpu/gl') diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index e842ddc4f5..a2eabe4e46 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -4476,3 +4476,11 @@ void GrGLGpu::waitSemaphore(sk_sp semaphore) { void GrGLGpu::deleteSync(GrGLsync sync) const { GL_CALL(DeleteSync(sync)); } + +sk_sp GrGLGpu::prepareTextureForCrossContextUsage(GrTexture* texture) { + // Set up a semaphore to be signaled once the data is ready, and flush GL + sk_sp semaphore = this->makeSemaphore(); + this->insertSemaphore(semaphore, true); + + return semaphore; +} diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index 04929f89fa..041ecfb5ce 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -149,6 +149,8 @@ public: void insertSemaphore(sk_sp semaphore, bool flush) override; void waitSemaphore(sk_sp semaphore) override; + sk_sp prepareTextureForCrossContextUsage(GrTexture*) override; + void deleteSync(GrGLsync) const; private: -- cgit v1.2.3