summaryrefslogtreecommitdiffstats
path: root/gfx/2d/SourceSurfaceSkia.cpp
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-11-18 22:06:11 +0000
committerMoonchild <moonchild@palemoon.org>2020-11-19 22:45:34 +0000
commit95d93b55c9299a9f962b80fd0e32607233cbaf9d (patch)
tree02c69b9e38e60cf7a9dcdb44273ec7e104f475d8 /gfx/2d/SourceSurfaceSkia.cpp
parent693dc6a5fc24fbd7569948fcda58d5c939e474de (diff)
downloadUXP-95d93b55c9299a9f962b80fd0e32607233cbaf9d.tar
UXP-95d93b55c9299a9f962b80fd0e32607233cbaf9d.tar.gz
UXP-95d93b55c9299a9f962b80fd0e32607233cbaf9d.tar.lz
UXP-95d93b55c9299a9f962b80fd0e32607233cbaf9d.tar.xz
UXP-95d93b55c9299a9f962b80fd0e32607233cbaf9d.zip
[gfx][Skia] Hold mutex while accessing shared SkImage data.
Diffstat (limited to 'gfx/2d/SourceSurfaceSkia.cpp')
-rw-r--r--gfx/2d/SourceSurfaceSkia.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/gfx/2d/SourceSurfaceSkia.cpp b/gfx/2d/SourceSurfaceSkia.cpp
index 14cbf6a84..0738f3d39 100644
--- a/gfx/2d/SourceSurfaceSkia.cpp
+++ b/gfx/2d/SourceSurfaceSkia.cpp
@@ -40,6 +40,25 @@ SourceSurfaceSkia::GetFormat() const
return mFormat;
}
+sk_sp<SkImage>
+SourceSurfaceSkia::GetImage(Maybe<MutexAutoLock>* aLock) {
+ // If we were provided a lock object, we can let the caller access
+ // a shared SkImage and we know it won't go away while the lock is held.
+ if (aLock) {
+ // We are locked, so now we can check mDrawTarget.
+ // If it's null, then we're not shared and we can unlock eagerly.
+ if (!mDrawTarget) {
+ aLock->reset();
+ }
+ } else {
+ // Otherwise we need to call DrawTargetWillChange to ensure we have our
+ // own copy of the SkImage.
+ DrawTargetWillChange();
+ }
+ sk_sp<SkImage> image = mImage;
+ return image;
+}
+
static sk_sp<SkData>
MakeSkData(unsigned char* aData, const IntSize& aSize, int32_t aStride)
{