Bug 1543621 - Move Y flip handling to AsyncImagePipelineManager::ApplyAsyncImageForPipeline() r=nical

With webrender, current gecko does not handle SurfaceTexture.getTransformMatrix() yet. SurfaceTexture is used for video decoding and WebGL. On both usages, when getTransformMatrix() is not handled, it actually worked as bottom left origin. Then gecko need to ignore y flip. AsyncImagePipelineManager::ApplyAsyncImageForPipeline() is a good place to handle the situations, since it handles canvas and video frame rendering. Long term solution is going to be handled by Bug 1507076.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
sotaro 2019-04-23 12:29:24 +00:00
Родитель 521898a03e
Коммит 601b513435
6 изменённых файлов: 29 добавлений и 6 удалений

Просмотреть файл

@ -648,6 +648,10 @@ void TextureHost::ReadUnlock() {
}
}
bool TextureHost::NeedsYFlip() const {
return bool(mFlags & TextureFlags::ORIGIN_BOTTOM_LEFT);
}
bool BufferTextureHost::EnsureWrappingTextureSource() {
MOZ_ASSERT(!mHasIntermediateBuffer);

Просмотреть файл

@ -677,6 +677,8 @@ class TextureHost : public AtomicRefCountedWithFinalize<TextureHost> {
virtual bool SupportsWrNativeTexture() { return false; }
virtual bool NeedsYFlip() const;
protected:
virtual void ReadUnlock();

Просмотреть файл

@ -261,6 +261,7 @@ Maybe<TextureHost::ResourceUpdateOp> AsyncImagePipelineManager::UpdateImageKeys(
bool canUpdate = !!previousTexture &&
previousTexture->GetSize() == texture->GetSize() &&
previousTexture->GetFormat() == texture->GetFormat() &&
previousTexture->NeedsYFlip() == texture->NeedsYFlip() &&
aPipeline->mKeys.Length() == numKeys;
// Check if WebRenderTextureHostWrapper could be reused.
@ -410,6 +411,12 @@ void AsyncImagePipelineManager::ApplyAsyncImageForPipeline(
aPipeline->mIsChanged = false;
gfx::Matrix4x4 scTransform = aPipeline->mScTransform;
if (aPipeline->mCurrentTexture && aPipeline->mCurrentTexture->NeedsYFlip()) {
scTransform.PreTranslate(0, aPipeline->mCurrentTexture->GetSize().height, 0)
.PreScale(1, -1, 1);
}
wr::LayoutSize contentSize{aPipeline->mScBounds.Width(),
aPipeline->mScBounds.Height()};
wr::DisplayListBuilder builder(aPipelineId, contentSize);
@ -417,8 +424,7 @@ void AsyncImagePipelineManager::ApplyAsyncImageForPipeline(
float opacity = 1.0f;
wr::StackingContextParams params;
params.opacity = &opacity;
params.mTransformPtr =
aPipeline->mScTransform.IsIdentity() ? nullptr : &aPipeline->mScTransform;
params.mTransformPtr = scTransform.IsIdentity() ? nullptr : &scTransform;
params.mix_blend_mode = aPipeline->mMixBlendMode;
Maybe<wr::WrSpatialId> referenceFrameId = builder.PushStackingContext(

Просмотреть файл

@ -169,5 +169,18 @@ bool WebRenderTextureHost::SupportsWrNativeTexture() {
return mWrappedTextureHost->SupportsWrNativeTexture();
}
bool WebRenderTextureHost::NeedsYFlip() const {
bool yFlip = TextureHost::NeedsYFlip();
if (mWrappedTextureHost->AsSurfaceTextureHost()) {
MOZ_ASSERT(yFlip);
// With WebRender, SurfaceTextureHost always requests y-flip.
// But y-flip should not be handled, since
// SurfaceTexture.getTransformMatrix() is not handled yet.
// See Bug 1507076.
yFlip = false;
}
return yFlip;
}
} // namespace layers
} // namespace mozilla

Просмотреть файл

@ -82,6 +82,8 @@ class WebRenderTextureHost : public TextureHost {
bool SupportsWrNativeTexture() override;
bool NeedsYFlip() const override;
protected:
void CreateRenderTextureHost(const SurfaceDescriptor& aDesc,
TextureHost* aTexture);

Просмотреть файл

@ -175,10 +175,6 @@ class nsDisplayCanvas final : public nsDisplayItem {
scTransform.PreScale(destGFXRect.Width() / canvasSizeInPx.width,
destGFXRect.Height() / canvasSizeInPx.height,
1.0f);
if (data->NeedsYFlip()) {
scTransform = scTransform.PreTranslate(0, data->GetSize().height, 0)
.PreScale(1, -1, 1);
}
MaybeIntSize scaleToSize;
LayoutDeviceRect scBounds(LayoutDevicePoint(0, 0), bounds.Size());