Bug 1092294 - Use SurfaceTextures for painted content on android (preffed off). r=nical,snorp

Add a new TextureClientData type, AndroidNativeWindowTextureData,
backed by a SurfaceTexture in single-buffer mode. It uses the
NativeWindow API, which provides producer-side access to the buffer.
This provides a DrawTarget which can be used to paint directly in to
the SurfaceTexture, which can then be composited using a SurfaceTextureHost.

Due to API restrictions it is not possible to read from a NativeWindow
while the corresponding SurfaceTexture has ownership of the
buffer. TiledContentClient now handles that by painting the additional
region that it cannot copy from the front buffer, if required.

MozReview-Commit-ID: 1NZq6MQqwFq
This commit is contained in:
Jamie Nicol
2017-10-28 11:59:58 +01:00
parent 0ea06a312c
commit 5376706d27
15 changed files with 345 additions and 64 deletions

View File

@@ -62,7 +62,9 @@ CreateTextureHostOGL(const SurfaceDescriptor& aDesc,
result = new SurfaceTextureHost(aFlags,
surfaceTexture,
desc.size(),
desc.continuous());
desc.format(),
desc.continuous(),
desc.ignoreTransform());
break;
}
#endif
@@ -343,13 +345,15 @@ SurfaceTextureSource::SurfaceTextureSource(TextureSourceProvider* aProvider,
gfx::SurfaceFormat aFormat,
GLenum aTarget,
GLenum aWrapMode,
gfx::IntSize aSize)
gfx::IntSize aSize,
bool aIgnoreTransform)
: mGL(aProvider->GetGLContext())
, mSurfTex(aSurfTex)
, mFormat(aFormat)
, mTextureTarget(aTarget)
, mWrapMode(aWrapMode)
, mSize(aSize)
, mIgnoreTransform(aIgnoreTransform)
{
}
@@ -395,8 +399,14 @@ SurfaceTextureSource::GetTextureTransform()
gfx::Matrix4x4 ret;
const auto& surf = java::sdk::SurfaceTexture::LocalRef(java::sdk::SurfaceTexture::Ref::From(mSurfTex));
AndroidSurfaceTexture::GetTransformMatrix(surf, ret);
// GetTransformMatrix() returns the transform set by the producer side of
// the SurfaceTexture. We should ignore this if we know the transform should
// be identity but the producer couldn't set it correctly, like is the
// case for AndroidNativeWindowTextureData.
if (!mIgnoreTransform) {
const auto& surf = java::sdk::SurfaceTexture::LocalRef(java::sdk::SurfaceTexture::Ref::From(mSurfTex));
AndroidSurfaceTexture::GetTransformMatrix(surf, ret);
}
return ret;
}
@@ -412,11 +422,15 @@ SurfaceTextureSource::DeallocateDeviceData()
SurfaceTextureHost::SurfaceTextureHost(TextureFlags aFlags,
mozilla::java::GeckoSurfaceTexture::Ref& aSurfTex,
gfx::IntSize aSize,
bool aContinuousUpdate)
gfx::SurfaceFormat aFormat,
bool aContinuousUpdate,
bool aIgnoreTransform)
: TextureHost(aFlags)
, mSurfTex(aSurfTex)
, mSize(aSize)
, mFormat(aFormat)
, mContinuousUpdate(aContinuousUpdate)
, mIgnoreTransform(aIgnoreTransform)
{
if (!mSurfTex) {
return;
@@ -476,15 +490,15 @@ SurfaceTextureHost::Lock()
}
if (!mTextureSource) {
gfx::SurfaceFormat format = gfx::SurfaceFormat::R8G8B8A8;
GLenum target = LOCAL_GL_TEXTURE_EXTERNAL; // This is required by SurfaceTexture
GLenum wrapMode = LOCAL_GL_CLAMP_TO_EDGE;
mTextureSource = new SurfaceTextureSource(mProvider,
mSurfTex,
format,
mFormat,
target,
wrapMode,
mSize);
mSize,
mIgnoreTransform);
}
return true;
@@ -519,7 +533,7 @@ SurfaceTextureHost::NotifyNotUsed()
gfx::SurfaceFormat
SurfaceTextureHost::GetFormat() const
{
return mTextureSource ? mTextureSource->GetFormat() : gfx::SurfaceFormat::UNKNOWN;
return mFormat;
}
void