Bug 1265824 - handle the texture uploading and readLock related things for direct mapping texture source r?mattwoodrow
MozReview-Commit-ID: BC065h1Ac6k
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -882,21 +882,32 @@ BufferTextureHost::AcquireTextureSource(
if (!UploadIfNeeded()) {
return false;
}
aTexture = mFirstSource;
return !!mFirstSource;
}
void
+BufferTextureHost::ReadUnlock()
+{
+ if (mFirstSource) {
+ mFirstSource->Sync();
+ }
+
+ TextureHost::ReadUnlock();
+}
+
+void
BufferTextureHost::UnbindTextureSource()
{
if (mFirstSource && mFirstSource->IsOwnedBy(this)) {
mFirstSource->Unbind();
}
+
// This texture is not used by any layer anymore.
// If the texture doesn't have an intermediate buffer, it means we are
// compositing synchronously on the CPU, so we don't need to wait until
// the end of the next composition to ReadUnlock (which other textures do
// by default).
// If the texture has an intermediate buffer we don't care either because
// texture uploads are also performed synchronously for BufferTextureHost.
ReadUnlock();
@@ -990,17 +1001,19 @@ BufferTextureHost::Upload(nsIntRegion *a
return false;
}
if (!mProvider) {
// This can happen if we send textures to a compositable that isn't yet
// attached to a layer.
return false;
}
if (!mHasIntermediateBuffer && EnsureWrappingTextureSource()) {
- return true;
+ if (!mFirstSource || !mFirstSource->IsDirectMap()) {
+ return true;
+ }
}
if (mFormat == gfx::SurfaceFormat::UNKNOWN) {
NS_WARNING("BufferTextureHost: unsupported format!");
return false;
} else if (mFormat == gfx::SurfaceFormat::YUV) {
const YCbCrDescriptor& desc = mDescriptor.get_YCbCrDescriptor();
--- a/gfx/layers/composite/TextureHost.h
+++ b/gfx/layers/composite/TextureHost.h
@@ -666,17 +666,17 @@ public:
}
/**
* Some API's can use the cross-process IOSurface directly, such as OpenVR
*/
virtual MacIOSurface* GetMacIOSurface() { return nullptr; }
protected:
- void ReadUnlock();
+ virtual void ReadUnlock();
void RecycleTexture(TextureFlags aFlags);
virtual void UpdatedInternal(const nsIntRegion *Region) {}
/**
* Called when mCompositableCount becomes 0.
*/
@@ -771,16 +771,18 @@ public:
const wr::ExternalImageId& aExtID) override;
virtual void PushDisplayItems(wr::DisplayListBuilder& aBuilder,
const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageRendering aFilter,
const Range<wr::ImageKey>& aImageKeys) override;
+ virtual void ReadUnlock() override;
+
protected:
bool Upload(nsIntRegion *aRegion = nullptr);
bool UploadIfNeeded();
bool MaybeUpload(nsIntRegion *aRegion);
bool EnsureWrappingTextureSource();
virtual void UpdatedInternal(const nsIntRegion* aRegion = nullptr) override;