зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1262601 - Handle video content as opaque in PostProcessLayers() r=mattwoodrow
This commit is contained in:
Родитель
28a90df677
Коммит
0c6a8d0ef6
|
@ -1931,7 +1931,7 @@ Layer::PrintInfo(std::stringstream& aStream, const char* aPrefix)
|
|||
if (1.0 != mOpacity) {
|
||||
aStream << nsPrintfCString(" [opacity=%g]", mOpacity).get();
|
||||
}
|
||||
if (GetContentFlags() & CONTENT_OPAQUE) {
|
||||
if (IsOpaque()) {
|
||||
aStream << " [opaqueContent]";
|
||||
}
|
||||
if (GetContentFlags() & CONTENT_COMPONENT_ALPHA) {
|
||||
|
|
|
@ -1501,6 +1501,12 @@ public:
|
|||
return !GetLocalVisibleRegion().IsEmpty() || Extend3DContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if current layer content is opaque.
|
||||
* It does not guarantee that layer content is always opaque.
|
||||
*/
|
||||
virtual bool IsOpaque() { return GetContentFlags() & CONTENT_OPAQUE; }
|
||||
|
||||
/**
|
||||
* Returns the product of the opacities of this layer and all ancestors up
|
||||
* to and excluding the nearest ancestor that has UseIntermediateSurface() set.
|
||||
|
|
|
@ -581,6 +581,27 @@ ImageHost::GetImageSize() const
|
|||
return IntSize();
|
||||
}
|
||||
|
||||
bool
|
||||
ImageHost::IsOpaque()
|
||||
{
|
||||
const TimedImage* img = ChooseImage();
|
||||
if (!img) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (img->mPictureRect.width == 0 ||
|
||||
img->mPictureRect.height == 0 ||
|
||||
!img->mTextureHost) {
|
||||
return false;
|
||||
}
|
||||
|
||||
gfx::SurfaceFormat format = img->mTextureHost->GetFormat();
|
||||
if (gfx::IsOpaque(format)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
already_AddRefed<TexturedEffect>
|
||||
ImageHost::GenEffect(const gfx::Filter& aFilter)
|
||||
{
|
||||
|
|
|
@ -115,6 +115,8 @@ public:
|
|||
BIAS_POSITIVE,
|
||||
};
|
||||
|
||||
bool IsOpaque();
|
||||
|
||||
protected:
|
||||
struct TimedImage {
|
||||
RefPtr<TextureHost> mTextureHost;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "mozilla/gfx/Rect.h" // for Rect
|
||||
#include "mozilla/layers/Compositor.h" // for Compositor
|
||||
#include "mozilla/layers/Effects.h" // for EffectChain
|
||||
#include "mozilla/layers/ImageHost.h" // for ImageHost
|
||||
#include "mozilla/layers/TextureHost.h" // for TextureHost, etc
|
||||
#include "mozilla/mozalloc.h" // for operator delete
|
||||
#include "nsAString.h"
|
||||
|
@ -50,7 +51,7 @@ ImageLayerComposite::SetCompositableHost(CompositableHost* aHost)
|
|||
{
|
||||
switch (aHost->GetType()) {
|
||||
case CompositableType::IMAGE:
|
||||
mImageHost = aHost;
|
||||
mImageHost = static_cast<ImageHost*>(aHost);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -78,6 +79,16 @@ ImageLayerComposite::GetLayer()
|
|||
return this;
|
||||
}
|
||||
|
||||
void
|
||||
ImageLayerComposite::SetLayerManager(LayerManagerComposite* aManager)
|
||||
{
|
||||
LayerComposite::SetLayerManager(aManager);
|
||||
mManager = aManager;
|
||||
if (mImageHost) {
|
||||
mImageHost->SetCompositor(mCompositor);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ImageLayerComposite::RenderLayer(const IntRect& aClipRect)
|
||||
{
|
||||
|
@ -143,6 +154,20 @@ ImageLayerComposite::ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransform
|
|||
ComputeEffectiveTransformForMaskLayers(aTransformToSurface);
|
||||
}
|
||||
|
||||
bool
|
||||
ImageLayerComposite::IsOpaque()
|
||||
{
|
||||
if (!mImageHost ||
|
||||
!mImageHost->IsAttached()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mScaleMode == ScaleMode::STRETCH) {
|
||||
return mImageHost->IsOpaque();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
CompositableHost*
|
||||
ImageLayerComposite::GetCompositableHost()
|
||||
{
|
||||
|
|
|
@ -43,14 +43,7 @@ public:
|
|||
|
||||
virtual Layer* GetLayer() override;
|
||||
|
||||
virtual void SetLayerManager(LayerManagerComposite* aManager) override
|
||||
{
|
||||
LayerComposite::SetLayerManager(aManager);
|
||||
mManager = aManager;
|
||||
if (mImageHost) {
|
||||
mImageHost->SetCompositor(mCompositor);
|
||||
}
|
||||
}
|
||||
virtual void SetLayerManager(LayerManagerComposite* aManager) override;
|
||||
|
||||
virtual void RenderLayer(const gfx::IntRect& aClipRect) override;
|
||||
|
||||
|
@ -66,6 +59,8 @@ public:
|
|||
|
||||
virtual const char* Name() const override { return "ImageLayerComposite"; }
|
||||
|
||||
virtual bool IsOpaque() override;
|
||||
|
||||
protected:
|
||||
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
|
||||
|
||||
|
@ -73,7 +68,7 @@ private:
|
|||
gfx::Filter GetEffectFilter();
|
||||
|
||||
private:
|
||||
RefPtr<CompositableHost> mImageHost;
|
||||
RefPtr<ImageHost> mImageHost;
|
||||
};
|
||||
|
||||
} // namespace layers
|
||||
|
|
|
@ -362,7 +362,7 @@ LayerManagerComposite::PostProcessLayers(Layer* aLayer,
|
|||
if (integerTranslation &&
|
||||
!aLayer->HasMaskLayers() &&
|
||||
aLayer->IsOpaqueForVisibility()) {
|
||||
if (aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE) {
|
||||
if (aLayer->IsOpaque()) {
|
||||
localOpaque.OrWith(composite->GetFullyRenderedRegion());
|
||||
}
|
||||
localOpaque.MoveBy(*integerTranslation);
|
||||
|
|
|
@ -531,7 +531,6 @@ SurfaceTextureHost::SetCompositor(Compositor* aCompositor)
|
|||
gfx::SurfaceFormat
|
||||
SurfaceTextureHost::GetFormat() const
|
||||
{
|
||||
MOZ_ASSERT(mTextureSource);
|
||||
return mTextureSource ? mTextureSource->GetFormat() : gfx::SurfaceFormat::UNKNOWN;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче