Skip to content

Commit

Permalink
Bug 1543616 - Call TextureHost::PrepareForUse() when mCompositableCou…
Browse files Browse the repository at this point in the history
…nt becomes from 0 to 1 r=nical

By Bug 1529870, the PrepareForUse() is called in WebRenderImageHost::SetCurrentTextureHost(). It works with single buffer mode android SurfaceTexture for WebGL. But it does not work well with video's SurfaceTexture, since multiple TextureHosts are received and a TextureHost might be skipped. The timing of mCompositableCount becomes from 0 to 1 could be used for calling PrepareForUse().

Differential Revision: https://phabricator.services.mozilla.com/D27044

--HG--
extra : moz-landing-system : lando
  • Loading branch information
sotaro committed Apr 12, 2019
1 parent 1df1c77 commit 82cce30
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
12 changes: 11 additions & 1 deletion gfx/layers/composite/TextureHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,12 @@ class TextureHost : public AtomicRefCountedWithFinalize<TextureHost> {
*/
virtual bool HasIntermediateBuffer() const { return false; }

void AddCompositableRef() { ++mCompositableCount; }
void AddCompositableRef() {
++mCompositableCount;
if (mCompositableCount == 1) {
PrepareForUse();
}
}

void ReleaseCompositableRef() {
--mCompositableCount;
Expand Down Expand Up @@ -681,6 +686,11 @@ class TextureHost : public AtomicRefCountedWithFinalize<TextureHost> {

virtual void UpdatedInternal(const nsIntRegion* Region) {}

/**
* Called when mCompositableCount becomes from 0 to 1.
*/
virtual void PrepareForUse() {}

/**
* Called when mCompositableCount becomes 0.
*/
Expand Down
8 changes: 0 additions & 8 deletions gfx/layers/wr/WebRenderImageHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,6 @@ void WebRenderImageHost::SetCurrentTextureHost(TextureHost* aTexture) {
if (aTexture == mCurrentTextureHost.get()) {
return;
}

if (aTexture && aTexture->AsWebRenderTextureHost()) {
// If WebRenderTextureHost wraps SurfaceTextureHost, it is important to call
// PrepareForUse for each texture that we receive.
// See RenderAndroidSurfaceTextureHostOGL::PrepareForUse.
aTexture->AsWebRenderTextureHost()->PrepareForUse();
}

mCurrentTextureHost = aTexture;
}

Expand Down
2 changes: 1 addition & 1 deletion gfx/layers/wr/WebRenderTextureHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class WebRenderTextureHost : public TextureHost {

WebRenderTextureHost* AsWebRenderTextureHost() override { return this; }

virtual void PrepareForUse();
virtual void PrepareForUse() override;

wr::ExternalImageId GetExternalImageKey() { return mExternalImageId; }

Expand Down

0 comments on commit 82cce30

Please sign in to comment.