diff options
-rw-r--r-- | src/gpu/GrProxyProvider.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrProxyProvider.h | 5 | ||||
-rw-r--r-- | src/gpu/SkGr.cpp | 13 |
3 files changed, 12 insertions, 10 deletions
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp index 33a2b0f2ed..b65c3dfe17 100644 --- a/src/gpu/GrProxyProvider.cpp +++ b/src/gpu/GrProxyProvider.cpp @@ -308,8 +308,8 @@ sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxyFromBitmap(const SkBitma // In non-ddl we will always instantiate right away. Thus we never want to copy the SkBitmap // even if its mutable. In ddl, if the bitmap is mutable then we must make a copy since the // upload of the data to the gpu can happen at anytime and the bitmap may change by then. - SkCopyPixelsMode copyMode = this->mutableBitmapsNeedCopy() ? kIfMutable_SkCopyPixelsMode - : kNever_SkCopyPixelsMode; + SkCopyPixelsMode copyMode = this->recordingDDL() ? kIfMutable_SkCopyPixelsMode + : kNever_SkCopyPixelsMode; sk_sp<SkImage> baseLevel = SkMakeImageFromRasterBitmap(bitmap, copyMode); if (!baseLevel) { diff --git a/src/gpu/GrProxyProvider.h b/src/gpu/GrProxyProvider.h index 2f452b4e62..76f0ae963b 100644 --- a/src/gpu/GrProxyProvider.h +++ b/src/gpu/GrProxyProvider.h @@ -236,10 +236,9 @@ public: void removeAllUniqueKeys(); /** - * Helper function for callers who are wrapping a bitmap into an SkImage so they know whether or - * not that bitmap should be copied or not. + * Are we currently recording a DDL? */ - bool mutableBitmapsNeedCopy() const { return !SkToBool(fResourceProvider); } + bool recordingDDL() const { return !SkToBool(fResourceProvider); } private: friend class GrAHardwareBufferImageGenerator; // for createWrapped diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 195d036374..27c9b39f5e 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -84,8 +84,8 @@ sk_sp<GrTextureProxy> GrUploadBitmapToTextureProxy(GrProxyProvider* proxyProvide // In non-ddl we will always instantiate right away. Thus we never want to copy the SkBitmap // even if it's mutable. In ddl, if the bitmap is mutable then we must make a copy since the // upload of the data to the gpu can happen at anytime and the bitmap may change by then. - SkCopyPixelsMode cpyMode = proxyProvider->mutableBitmapsNeedCopy() ? kIfMutable_SkCopyPixelsMode - : kNever_SkCopyPixelsMode; + SkCopyPixelsMode cpyMode = proxyProvider->recordingDDL() ? kIfMutable_SkCopyPixelsMode + : kNever_SkCopyPixelsMode; sk_sp<SkImage> image = SkMakeImageFromRasterBitmap(bitmap, cpyMode); return proxyProvider->createTextureProxy(std::move(image), kNone_GrSurfaceFlags, 1, @@ -160,8 +160,8 @@ sk_sp<GrTextureProxy> GrMakeCachedBitmapProxy(GrProxyProvider* proxyProvider, // In non-ddl we will always instantiate right away. Thus we never want to copy the SkBitmap // even if its mutable. In ddl, if the bitmap is mutable then we must make a copy since the // upload of the data to the gpu can happen at anytime and the bitmap may change by then. - SkCopyPixelsMode cpyMode = proxyProvider->mutableBitmapsNeedCopy() ? kIfMutable_SkCopyPixelsMode - : kNever_SkCopyPixelsMode; + SkCopyPixelsMode cpyMode = proxyProvider->recordingDDL() ? kIfMutable_SkCopyPixelsMode + : kNever_SkCopyPixelsMode; sk_sp<SkImage> image = SkMakeImageFromRasterBitmap(bitmap, cpyMode); if (!image) { @@ -205,7 +205,10 @@ sk_sp<GrTextureProxy> GrMakeCachedImageProxy(GrProxyProvider* proxyProvider, SkBudgeted::kYes, fit); if (proxy && originalKey.isValid()) { proxyProvider->assignUniqueKeyToProxy(originalKey, proxy.get()); - if (const SkBitmap* bm = as_IB(srcImage.get())->onPeekBitmap()) { + const SkBitmap* bm = as_IB(srcImage.get())->onPeekBitmap(); + // When recording DDLs we do not want to install change listeners because doing + // so isn't threadsafe. + if (bm && !proxyProvider->recordingDDL()) { GrInstallBitmapUniqueKeyInvalidator(originalKey, bm->pixelRef()); } } |