зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 6 changesets (bug 1343814) for bustage
Backed out changeset 64c73abd4190 (bug 1343814) Backed out changeset 3bf615dfeba0 (bug 1343814) Backed out changeset d55f871c503d (bug 1343814) Backed out changeset 11811b48bbbe (bug 1343814) Backed out changeset 53c6fa699fa7 (bug 1343814) Backed out changeset 4768fe2f6131 (bug 1343814)
This commit is contained in:
Родитель
9b04b94de9
Коммит
554a65e406
|
@ -48,7 +48,7 @@ Compositor::~Compositor()
|
|||
void
|
||||
Compositor::Destroy()
|
||||
{
|
||||
TextureSourceProvider::Destroy();
|
||||
ReadUnlockTextures();
|
||||
FlushPendingNotifyNotUsed();
|
||||
mIsDestroyed = true;
|
||||
}
|
||||
|
@ -60,6 +60,50 @@ Compositor::EndFrame()
|
|||
mLastCompositionEndTime = TimeStamp::Now();
|
||||
}
|
||||
|
||||
void
|
||||
Compositor::ReadUnlockTextures()
|
||||
{
|
||||
for (auto& texture : mUnlockAfterComposition) {
|
||||
texture->ReadUnlock();
|
||||
}
|
||||
mUnlockAfterComposition.Clear();
|
||||
}
|
||||
|
||||
void
|
||||
Compositor::UnlockAfterComposition(TextureHost* aTexture)
|
||||
{
|
||||
mUnlockAfterComposition.AppendElement(aTexture);
|
||||
}
|
||||
|
||||
void
|
||||
Compositor::NotifyNotUsedAfterComposition(TextureHost* aTextureHost)
|
||||
{
|
||||
MOZ_ASSERT(!mIsDestroyed);
|
||||
|
||||
mNotifyNotUsedAfterComposition.AppendElement(aTextureHost);
|
||||
|
||||
// If Compositor holds many TextureHosts without compositing,
|
||||
// the TextureHosts should be flushed to reduce memory consumption.
|
||||
const int thresholdCount = 5;
|
||||
const double thresholdSec = 2.0f;
|
||||
if (mNotifyNotUsedAfterComposition.Length() > thresholdCount) {
|
||||
TimeDuration duration = mLastCompositionEndTime ? TimeStamp::Now() - mLastCompositionEndTime : TimeDuration();
|
||||
// Check if we could flush
|
||||
if (duration.ToSeconds() > thresholdSec) {
|
||||
FlushPendingNotifyNotUsed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Compositor::FlushPendingNotifyNotUsed()
|
||||
{
|
||||
for (auto& textureHost : mNotifyNotUsedAfterComposition) {
|
||||
textureHost->CallNotifyNotUsed();
|
||||
}
|
||||
mNotifyNotUsedAfterComposition.Clear();
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
Compositor::AssertOnCompositorThread()
|
||||
{
|
||||
|
@ -630,14 +674,5 @@ Compositor::SetDispAcquireFence(Layer* aLayer)
|
|||
{
|
||||
}
|
||||
|
||||
bool
|
||||
Compositor::NotifyNotUsedAfterComposition(TextureHost* aTextureHost)
|
||||
{
|
||||
if (IsDestroyed() || AsBasicCompositor()) {
|
||||
return false;
|
||||
}
|
||||
return TextureSourceProvider::NotifyNotUsedAfterComposition(aTextureHost);
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "mozilla/gfx/Triangle.h" // for Triangle, TexturedTriangle
|
||||
#include "mozilla/layers/CompositorTypes.h" // for DiagnosticTypes, etc
|
||||
#include "mozilla/layers/LayersTypes.h" // for LayersBackend
|
||||
#include "mozilla/layers/TextureSourceProvider.h"
|
||||
#include "mozilla/widget/CompositorWidget.h"
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
|
||||
#include "nsRegion.h"
|
||||
|
@ -133,6 +132,7 @@ class LayerManagerComposite;
|
|||
class CompositorOGL;
|
||||
class CompositorD3D11;
|
||||
class BasicCompositor;
|
||||
class TextureHost;
|
||||
class TextureReadLock;
|
||||
|
||||
enum SurfaceInitMode
|
||||
|
@ -179,21 +179,40 @@ enum SurfaceInitMode
|
|||
* The target and viewport methods can be called before any DrawQuad call and
|
||||
* affect any subsequent DrawQuad calls.
|
||||
*/
|
||||
class Compositor : public TextureSourceProvider
|
||||
class Compositor
|
||||
{
|
||||
protected:
|
||||
virtual ~Compositor();
|
||||
|
||||
public:
|
||||
NS_INLINE_DECL_REFCOUNTING(Compositor)
|
||||
|
||||
explicit Compositor(widget::CompositorWidget* aWidget,
|
||||
CompositorBridgeParent* aParent = nullptr);
|
||||
|
||||
virtual already_AddRefed<DataTextureSource> CreateDataTextureSource(TextureFlags aFlags = TextureFlags::NO_FLAGS) = 0;
|
||||
|
||||
virtual already_AddRefed<DataTextureSource>
|
||||
CreateDataTextureSourceAround(gfx::DataSourceSurface* aSurface) { return nullptr; }
|
||||
|
||||
virtual already_AddRefed<DataTextureSource>
|
||||
CreateDataTextureSourceAroundYCbCr(TextureHost* aTexture) { return nullptr; }
|
||||
|
||||
virtual bool Initialize(nsCString* const out_failureReason) = 0;
|
||||
virtual void Destroy() override;
|
||||
virtual void Destroy();
|
||||
bool IsDestroyed() const { return mIsDestroyed; }
|
||||
|
||||
virtual void DetachWidget() { mWidget = nullptr; }
|
||||
|
||||
/**
|
||||
* Return true if the effect type is supported.
|
||||
*
|
||||
* By default Compositor implementations should support all effects but in
|
||||
* some rare cases it is not possible to support an effect efficiently.
|
||||
* This is the case for BasicCompositor with EffectYCbCr.
|
||||
*/
|
||||
virtual bool SupportsEffect(EffectTypes aEffect) { return true; }
|
||||
|
||||
/**
|
||||
* Request a texture host identifier that may be used for creating textures
|
||||
* across process or thread boundaries that are compatible with this
|
||||
|
@ -205,6 +224,7 @@ public:
|
|||
* Properties of the compositor.
|
||||
*/
|
||||
virtual bool CanUseCanvasLayerForSize(const gfx::IntSize& aSize) = 0;
|
||||
virtual int32_t GetMaxTextureSize() const = 0;
|
||||
|
||||
/**
|
||||
* Set the target for rendering. Results will have been written to aTarget by
|
||||
|
@ -452,16 +472,6 @@ public:
|
|||
virtual CompositorD3D11* AsCompositorD3D11() { return nullptr; }
|
||||
virtual BasicCompositor* AsBasicCompositor() { return nullptr; }
|
||||
|
||||
virtual Compositor* AsCompositor() override {
|
||||
return this;
|
||||
}
|
||||
|
||||
TimeStamp GetLastCompositionEndTime() const override {
|
||||
return mLastCompositionEndTime;
|
||||
}
|
||||
|
||||
bool NotifyNotUsedAfterComposition(TextureHost* aTextureHost) override;
|
||||
|
||||
/**
|
||||
* Each Compositor has a unique ID.
|
||||
* This ID is used to keep references to each Compositor in a map accessed
|
||||
|
@ -533,11 +543,29 @@ public:
|
|||
// A stale Compositor has no CompositorBridgeParent; it will not process
|
||||
// frames and should not be used.
|
||||
void SetInvalid();
|
||||
virtual bool IsValid() const override;
|
||||
virtual bool IsValid() const;
|
||||
CompositorBridgeParent* GetCompositorBridgeParent() const {
|
||||
return mParent;
|
||||
}
|
||||
|
||||
/// Most compositor backends operate asynchronously under the hood. This
|
||||
/// means that when a layer stops using a texture it is often desirable to
|
||||
/// wait for the end of the next composition before releasing the texture's
|
||||
/// ReadLock.
|
||||
/// This function provides a convenient way to do this delayed unlocking, if
|
||||
/// the texture itself requires it.
|
||||
void UnlockAfterComposition(TextureHost* aTexture);
|
||||
|
||||
/// Most compositor backends operate asynchronously under the hood. This
|
||||
/// means that when a layer stops using a texture it is often desirable to
|
||||
/// wait for the end of the next composition before NotifyNotUsed() call.
|
||||
/// This function provides a convenient way to do this delayed NotifyNotUsed()
|
||||
/// call, if the texture itself requires it.
|
||||
/// See bug 1260611 and bug 1252835
|
||||
void NotifyNotUsedAfterComposition(TextureHost* aTextureHost);
|
||||
|
||||
void FlushPendingNotifyNotUsed();
|
||||
|
||||
protected:
|
||||
void DrawDiagnosticsInternal(DiagnosticFlags aFlags,
|
||||
const gfx::Rect& aVisibleRect,
|
||||
|
@ -547,6 +575,9 @@ protected:
|
|||
|
||||
bool ShouldDrawDiagnostics(DiagnosticFlags);
|
||||
|
||||
// Should be called at the end of each composition.
|
||||
void ReadUnlockTextures();
|
||||
|
||||
/**
|
||||
* Given a layer rect, clip, and transform, compute the area of the backdrop that
|
||||
* needs to be copied for mix-blending. The output transform translates from 0..1
|
||||
|
@ -583,6 +614,16 @@ protected:
|
|||
const gfx::Matrix4x4& aTransform,
|
||||
const gfx::Rect& aVisibleRect);
|
||||
|
||||
/**
|
||||
* An array of locks that will need to be unlocked after the next composition.
|
||||
*/
|
||||
nsTArray<RefPtr<TextureHost>> mUnlockAfterComposition;
|
||||
|
||||
/**
|
||||
* An array of TextureHosts that will need to call NotifyNotUsed() after the next composition.
|
||||
*/
|
||||
nsTArray<RefPtr<TextureHost>> mNotifyNotUsedAfterComposition;
|
||||
|
||||
/**
|
||||
* Last Composition end time.
|
||||
*/
|
||||
|
|
|
@ -918,8 +918,7 @@ SenderHelper::SendLayer(LayerComposite* aLayer,
|
|||
case Layer::TYPE_PAINTED: {
|
||||
// Get CompositableHost and Compositor
|
||||
CompositableHost* compHost = aLayer->GetCompositableHost();
|
||||
TextureSourceProvider* provider = compHost->GetTextureSourceProvider();
|
||||
Compositor* comp = provider->AsCompositor();
|
||||
Compositor* comp = compHost->GetCompositor();
|
||||
// Send EffectChain only for CompositorOGL
|
||||
if (LayersBackend::LAYERS_OPENGL == comp->GetBackendType()) {
|
||||
CompositorOGL* compOGL = comp->AsCompositorOGL();
|
||||
|
|
|
@ -379,9 +379,9 @@ TextureHostDirectUpload::Unlock()
|
|||
}
|
||||
|
||||
void
|
||||
TextureHostDirectUpload::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
TextureHostDirectUpload::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
mProvider = aProvider;
|
||||
mCompositor = aCompositor;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -419,14 +419,14 @@ DIBTextureHost::DIBTextureHost(TextureFlags aFlags,
|
|||
void
|
||||
DIBTextureHost::UpdatedInternal(const nsIntRegion* aRegion)
|
||||
{
|
||||
if (!mProvider) {
|
||||
if (!mCompositor) {
|
||||
// This can happen if we send textures to a compositable that isn't yet
|
||||
// attached to a layer.
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mTextureSource) {
|
||||
mTextureSource = mProvider->CreateDataTextureSource(mFlags);
|
||||
mTextureSource = mCompositor->CreateDataTextureSource(mFlags);
|
||||
}
|
||||
|
||||
if (mSurface->CairoStatus()) {
|
||||
|
@ -468,14 +468,14 @@ static void UnmapFileData(void* aData)
|
|||
void
|
||||
TextureHostFileMapping::UpdatedInternal(const nsIntRegion* aRegion)
|
||||
{
|
||||
if (!mProvider) {
|
||||
if (!mCompositor) {
|
||||
// This can happen if we send textures to a compositable that isn't yet
|
||||
// attached to a layer.
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mTextureSource) {
|
||||
mTextureSource = mProvider->CreateDataTextureSource(mFlags);
|
||||
mTextureSource = mCompositor->CreateDataTextureSource(mFlags);
|
||||
}
|
||||
|
||||
uint8_t* data = nullptr;
|
||||
|
|
|
@ -64,7 +64,9 @@ public:
|
|||
|
||||
virtual void DeallocateDeviceData() override;
|
||||
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
virtual Compositor* GetCompositor() override { return mCompositor; }
|
||||
|
||||
virtual gfx::SurfaceFormat GetFormat() const override { return mFormat; }
|
||||
|
||||
|
@ -79,8 +81,8 @@ public:
|
|||
virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override;
|
||||
|
||||
protected:
|
||||
RefPtr<TextureSourceProvider> mProvider;
|
||||
RefPtr<DataTextureSource> mTextureSource;
|
||||
RefPtr<Compositor> mCompositor;
|
||||
gfx::SurfaceFormat mFormat;
|
||||
gfx::IntSize mSize;
|
||||
bool mIsLocked;
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/layers/TextureSourceProvider.h"
|
||||
#include "mozilla/layers/TextureHost.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
TextureSourceProvider::~TextureSourceProvider()
|
||||
{
|
||||
ReadUnlockTextures();
|
||||
}
|
||||
|
||||
void
|
||||
TextureSourceProvider::ReadUnlockTextures()
|
||||
{
|
||||
for (auto& texture : mUnlockAfterComposition) {
|
||||
texture->ReadUnlock();
|
||||
}
|
||||
mUnlockAfterComposition.Clear();
|
||||
}
|
||||
|
||||
void
|
||||
TextureSourceProvider::UnlockAfterComposition(TextureHost* aTexture)
|
||||
{
|
||||
mUnlockAfterComposition.AppendElement(aTexture);
|
||||
}
|
||||
|
||||
bool
|
||||
TextureSourceProvider::NotifyNotUsedAfterComposition(TextureHost* aTextureHost)
|
||||
{
|
||||
mNotifyNotUsedAfterComposition.AppendElement(aTextureHost);
|
||||
|
||||
// If Compositor holds many TextureHosts without compositing,
|
||||
// the TextureHosts should be flushed to reduce memory consumption.
|
||||
const int thresholdCount = 5;
|
||||
const double thresholdSec = 2.0f;
|
||||
if (mNotifyNotUsedAfterComposition.Length() > thresholdCount) {
|
||||
TimeStamp lastCompositionEndTime = GetLastCompositionEndTime();
|
||||
TimeDuration duration = lastCompositionEndTime ? TimeStamp::Now() - lastCompositionEndTime : TimeDuration();
|
||||
// Check if we could flush
|
||||
if (duration.ToSeconds() > thresholdSec) {
|
||||
FlushPendingNotifyNotUsed();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
TextureSourceProvider::FlushPendingNotifyNotUsed()
|
||||
{
|
||||
for (auto& textureHost : mNotifyNotUsedAfterComposition) {
|
||||
textureHost->CallNotifyNotUsed();
|
||||
}
|
||||
mNotifyNotUsedAfterComposition.Clear();
|
||||
}
|
||||
|
||||
void
|
||||
TextureSourceProvider::Destroy()
|
||||
{
|
||||
ReadUnlockTextures();
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
|
@ -1,123 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#ifndef mozilla_gfx_layers_TextureSourceProvider_h
|
||||
#define mozilla_gfx_layers_TextureSourceProvider_h
|
||||
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "mozilla/AlreadyAddRefed.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/layers/CompositorTypes.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
struct ID3D11Device;
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
class DataSourceSurface;
|
||||
} // namespace gfx
|
||||
namespace gl {
|
||||
class GLContext;
|
||||
} // namespace gl
|
||||
namespace layers {
|
||||
|
||||
class TextureHost;
|
||||
class DataTextureSource;
|
||||
class Compositor;
|
||||
|
||||
// Provided by a HostLayerManager or Compositor for allocating backend-specific
|
||||
// texture types.
|
||||
class TextureSourceProvider
|
||||
{
|
||||
public:
|
||||
NS_INLINE_DECL_REFCOUNTING(TextureSourceProvider)
|
||||
|
||||
virtual already_AddRefed<DataTextureSource>
|
||||
CreateDataTextureSource(TextureFlags aFlags = TextureFlags::NO_FLAGS) = 0;
|
||||
|
||||
virtual already_AddRefed<DataTextureSource>
|
||||
CreateDataTextureSourceAround(gfx::DataSourceSurface* aSurface) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual already_AddRefed<DataTextureSource>
|
||||
CreateDataTextureSourceAroundYCbCr(TextureHost* aTexture) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual TimeStamp GetLastCompositionEndTime() const = 0;
|
||||
|
||||
// Return true if the effect type is supported.
|
||||
//
|
||||
// By default Compositor implementations should support all effects but in
|
||||
// some rare cases it is not possible to support an effect efficiently.
|
||||
// This is the case for BasicCompositor with EffectYCbCr.
|
||||
virtual bool SupportsEffect(EffectTypes aEffect) { return true; }
|
||||
|
||||
/// Most compositor backends operate asynchronously under the hood. This
|
||||
/// means that when a layer stops using a texture it is often desirable to
|
||||
/// wait for the end of the next composition before releasing the texture's
|
||||
/// ReadLock.
|
||||
/// This function provides a convenient way to do this delayed unlocking, if
|
||||
/// the texture itself requires it.
|
||||
void UnlockAfterComposition(TextureHost* aTexture);
|
||||
|
||||
/// Most compositor backends operate asynchronously under the hood. This
|
||||
/// means that when a layer stops using a texture it is often desirable to
|
||||
/// wait for the end of the next composition before NotifyNotUsed() call.
|
||||
/// This function provides a convenient way to do this delayed NotifyNotUsed()
|
||||
/// call, if the texture itself requires it.
|
||||
/// See bug 1260611 and bug 1252835
|
||||
///
|
||||
/// Returns true if notified, false otherwise.
|
||||
virtual bool NotifyNotUsedAfterComposition(TextureHost* aTextureHost);
|
||||
|
||||
// If overridden, make sure to call the base function.
|
||||
virtual void Destroy();
|
||||
|
||||
void FlushPendingNotifyNotUsed();
|
||||
|
||||
// If this provider is also a Compositor, return the compositor. Otherwise return
|
||||
// null.
|
||||
virtual Compositor* AsCompositor() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
// On Windows, if this provides Direct3D textures, it must expose the device.
|
||||
virtual ID3D11Device* GetD3D11Device() const {
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
// If this provides OpenGL textures, it must expose the GLContext.
|
||||
virtual gl::GLContext* GetGLContext() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual int32_t GetMaxTextureSize() const = 0;
|
||||
|
||||
// Return whether or not this provider is still valid (i.e., is still being
|
||||
// used to composite).
|
||||
virtual bool IsValid() const = 0;
|
||||
|
||||
protected:
|
||||
// Should be called at the end of each composition.
|
||||
void ReadUnlockTextures();
|
||||
|
||||
protected:
|
||||
virtual ~TextureSourceProvider();
|
||||
|
||||
private:
|
||||
// An array of locks that will need to be unlocked after the next composition.
|
||||
nsTArray<RefPtr<TextureHost>> mUnlockAfterComposition;
|
||||
|
||||
// An array of TextureHosts that will need to call NotifyNotUsed() after the next composition.
|
||||
nsTArray<RefPtr<TextureHost>> mNotifyNotUsedAfterComposition;
|
||||
};
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_gfx_layers_TextureSourceProvider_h
|
|
@ -1086,5 +1086,14 @@ BasicCompositor::FinishPendingComposite()
|
|||
TryToEndRemoteDrawing(/* aForceToEnd */ true);
|
||||
}
|
||||
|
||||
BasicCompositor*
|
||||
AssertBasicCompositor(Compositor* aCompositor)
|
||||
{
|
||||
BasicCompositor* compositor = aCompositor ? aCompositor->AsBasicCompositor()
|
||||
: nullptr;
|
||||
MOZ_DIAGNOSTIC_ASSERT(!!compositor);
|
||||
return compositor;
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -10,8 +10,11 @@
|
|||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
MacIOSurfaceTextureSourceBasic::MacIOSurfaceTextureSourceBasic(MacIOSurface* aSurface)
|
||||
: mSurface(aSurface)
|
||||
MacIOSurfaceTextureSourceBasic::MacIOSurfaceTextureSourceBasic(
|
||||
BasicCompositor* aCompositor,
|
||||
MacIOSurface* aSurface)
|
||||
: mCompositor(aCompositor)
|
||||
, mSurface(aSurface)
|
||||
{
|
||||
MOZ_COUNT_CTOR(MacIOSurfaceTextureSourceBasic);
|
||||
}
|
||||
|
@ -56,31 +59,36 @@ MacIOSurfaceTextureSourceBasic::GetSurface(gfx::DrawTarget* aTarget)
|
|||
return mSourceSurface;
|
||||
}
|
||||
|
||||
void
|
||||
MacIOSurfaceTextureSourceBasic::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
mCompositor = AssertBasicCompositor(aCompositor);
|
||||
}
|
||||
|
||||
bool
|
||||
MacIOSurfaceTextureHostBasic::Lock()
|
||||
{
|
||||
if (!mProvider) {
|
||||
if (!mCompositor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mTextureSource) {
|
||||
mTextureSource = new MacIOSurfaceTextureSourceBasic(mSurface);
|
||||
mTextureSource = new MacIOSurfaceTextureSourceBasic(mCompositor, mSurface);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
MacIOSurfaceTextureHostBasic::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
MacIOSurfaceTextureHostBasic::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
if (!aProvider->AsCompositor() || !aProvider->AsCompositor()->AsBasicCompositor()) {
|
||||
BasicCompositor* compositor = AssertBasicCompositor(aCompositor);
|
||||
if (!compositor) {
|
||||
mTextureSource = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
mProvider = aProvider;
|
||||
|
||||
mCompositor = compositor;
|
||||
if (mTextureSource) {
|
||||
mTextureSource->SetTextureSourceProvider(aProvider);
|
||||
mTextureSource->SetCompositor(compositor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,8 @@ class MacIOSurfaceTextureSourceBasic
|
|||
public TextureSource
|
||||
{
|
||||
public:
|
||||
MacIOSurfaceTextureSourceBasic(MacIOSurface* aSurface);
|
||||
MacIOSurfaceTextureSourceBasic(BasicCompositor* aCompositor,
|
||||
MacIOSurface* aSurface);
|
||||
virtual ~MacIOSurfaceTextureSourceBasic();
|
||||
|
||||
virtual const char* Name() const override { return "MacIOSurfaceTextureSourceBasic"; }
|
||||
|
@ -40,7 +41,10 @@ public:
|
|||
|
||||
virtual void DeallocateDeviceData() override { }
|
||||
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
protected:
|
||||
RefPtr<BasicCompositor> mCompositor;
|
||||
RefPtr<MacIOSurface> mSurface;
|
||||
RefPtr<gfx::SourceSurface> mSourceSurface;
|
||||
};
|
||||
|
@ -56,7 +60,9 @@ public:
|
|||
MacIOSurfaceTextureHostBasic(TextureFlags aFlags,
|
||||
const SurfaceDescriptorMacIOSurface& aDescriptor);
|
||||
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
virtual Compositor* GetCompositor() override { return mCompositor; }
|
||||
|
||||
virtual bool Lock() override;
|
||||
|
||||
|
@ -80,6 +86,7 @@ public:
|
|||
#endif
|
||||
|
||||
protected:
|
||||
RefPtr<BasicCompositor> mCompositor;
|
||||
RefPtr<MacIOSurfaceTextureSourceBasic> mTextureSource;
|
||||
RefPtr<MacIOSurface> mSurface;
|
||||
};
|
||||
|
|
|
@ -13,7 +13,8 @@ namespace layers {
|
|||
using namespace mozilla::gfx;
|
||||
|
||||
X11TextureSourceBasic::X11TextureSourceBasic(BasicCompositor* aCompositor, gfxXlibSurface* aSurface)
|
||||
: mSurface(aSurface)
|
||||
: mCompositor(aCompositor),
|
||||
mSurface(aSurface)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -41,6 +42,12 @@ X11TextureSourceBasic::GetSurface(DrawTarget* aTarget)
|
|||
return mSourceSurface;
|
||||
}
|
||||
|
||||
void
|
||||
X11TextureSourceBasic::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
mCompositor = AssertBasicCompositor(aCompositor);
|
||||
}
|
||||
|
||||
SurfaceFormat
|
||||
X11TextureSourceBasic::ContentTypeToSurfaceFormat(gfxContentType aType)
|
||||
{
|
||||
|
|
|
@ -36,11 +36,14 @@ public:
|
|||
|
||||
virtual void DeallocateDeviceData() override { }
|
||||
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
virtual void Updated() override { }
|
||||
|
||||
static gfx::SurfaceFormat ContentTypeToSurfaceFormat(gfxContentType aType);
|
||||
|
||||
protected:
|
||||
RefPtr<BasicCompositor> mCompositor;
|
||||
RefPtr<gfxXlibSurface> mSurface;
|
||||
RefPtr<gfx::SourceSurface> mSourceSurface;
|
||||
};
|
||||
|
|
|
@ -64,7 +64,7 @@ CanvasLayerComposite::SetLayerManager(HostLayerManager* aManager)
|
|||
LayerComposite::SetLayerManager(aManager);
|
||||
mManager = aManager;
|
||||
if (mCompositableHost && mCompositor) {
|
||||
mCompositableHost->SetTextureSourceProvider(mCompositor);
|
||||
mCompositableHost->SetCompositor(mCompositor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ CanvasLayerComposite::RenderLayer(const IntRect& aClipRect,
|
|||
|
||||
RenderWithAllMasks(this, mCompositor, aClipRect,
|
||||
[&](EffectChain& effectChain, const IntRect& clipRect) {
|
||||
mCompositableHost->Composite(mCompositor, this, effectChain,
|
||||
mCompositableHost->Composite(this, effectChain,
|
||||
GetEffectiveOpacity(),
|
||||
GetEffectiveTransform(),
|
||||
GetSamplingFilter(),
|
||||
|
|
|
@ -32,6 +32,7 @@ class Compositor;
|
|||
CompositableHost::CompositableHost(const TextureInfo& aTextureInfo)
|
||||
: mTextureInfo(aTextureInfo)
|
||||
, mCompositorID(0)
|
||||
, mCompositor(nullptr)
|
||||
, mLayer(nullptr)
|
||||
, mFlashCounter(0)
|
||||
, mAttached(false)
|
||||
|
@ -48,9 +49,9 @@ CompositableHost::~CompositableHost()
|
|||
void
|
||||
CompositableHost::UseTextureHost(const nsTArray<TimedTexture>& aTextures)
|
||||
{
|
||||
if (mTextureSourceProvider) {
|
||||
if (GetCompositor()) {
|
||||
for (auto& texture : aTextures) {
|
||||
texture.mTexture->SetTextureSourceProvider(mTextureSourceProvider);
|
||||
texture.mTexture->SetCompositor(GetCompositor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,9 +61,9 @@ CompositableHost::UseComponentAlphaTextures(TextureHost* aTextureOnBlack,
|
|||
TextureHost* aTextureOnWhite)
|
||||
{
|
||||
MOZ_ASSERT(aTextureOnBlack && aTextureOnWhite);
|
||||
if (mTextureSourceProvider) {
|
||||
aTextureOnBlack->SetTextureSourceProvider(mTextureSourceProvider);
|
||||
aTextureOnWhite->SetTextureSourceProvider(mTextureSourceProvider);
|
||||
if (GetCompositor()) {
|
||||
aTextureOnBlack->SetCompositor(GetCompositor());
|
||||
aTextureOnWhite->SetCompositor(GetCompositor());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,10 +72,10 @@ CompositableHost::RemoveTextureHost(TextureHost* aTexture)
|
|||
{}
|
||||
|
||||
void
|
||||
CompositableHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
CompositableHost::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
MOZ_ASSERT(aProvider);
|
||||
mTextureSourceProvider = aProvider;
|
||||
MOZ_ASSERT(aCompositor);
|
||||
mCompositor = aCompositor;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -174,11 +175,5 @@ CompositableHost::GetLayerManager() const
|
|||
return mLayer->Manager()->AsHostLayerManager();
|
||||
}
|
||||
|
||||
TextureSourceProvider*
|
||||
CompositableHost::GetTextureSourceProvider() const
|
||||
{
|
||||
return mTextureSourceProvider;
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -91,11 +91,10 @@ public:
|
|||
virtual CompositableType GetType() = 0;
|
||||
|
||||
// If base class overrides, it should still call the parent implementation
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider);
|
||||
virtual void SetCompositor(Compositor* aCompositor);
|
||||
|
||||
// composite the contents of this buffer host to the compositor's surface
|
||||
virtual void Composite(Compositor* aCompositor,
|
||||
LayerComposite* aLayer,
|
||||
virtual void Composite(LayerComposite* aLayer,
|
||||
EffectChain& aEffectChain,
|
||||
float aOpacity,
|
||||
const gfx::Matrix4x4& aTransform,
|
||||
|
@ -140,7 +139,10 @@ public:
|
|||
|
||||
void RemoveMaskEffect();
|
||||
|
||||
TextureSourceProvider* GetTextureSourceProvider() const;
|
||||
Compositor* GetCompositor() const
|
||||
{
|
||||
return mCompositor;
|
||||
}
|
||||
|
||||
Layer* GetLayer() const { return mLayer; }
|
||||
void SetLayer(Layer* aLayer) { mLayer = aLayer; }
|
||||
|
@ -154,13 +156,13 @@ public:
|
|||
static const AttachFlags FORCE_DETACH = 2;
|
||||
|
||||
virtual void Attach(Layer* aLayer,
|
||||
TextureSourceProvider* aProvider,
|
||||
Compositor* aCompositor,
|
||||
AttachFlags aFlags = NO_FLAGS)
|
||||
{
|
||||
MOZ_ASSERT(aProvider);
|
||||
MOZ_ASSERT(aCompositor, "Compositor is required");
|
||||
NS_ASSERTION(aFlags & ALLOW_REATTACH || !mAttached,
|
||||
"Re-attaching compositables must be explicitly authorised");
|
||||
SetTextureSourceProvider(aProvider);
|
||||
SetCompositor(aCompositor);
|
||||
SetLayer(aLayer);
|
||||
mAttached = true;
|
||||
mKeepAttached = aFlags & KEEP_ATTACHED;
|
||||
|
@ -241,7 +243,7 @@ protected:
|
|||
TextureInfo mTextureInfo;
|
||||
AsyncCompositableRef mAsyncRef;
|
||||
uint64_t mCompositorID;
|
||||
RefPtr<TextureSourceProvider> mTextureSourceProvider;
|
||||
RefPtr<Compositor> mCompositor;
|
||||
Layer* mLayer;
|
||||
uint32_t mFlashCounter; // used when the pref "layers.flash-borders" is true.
|
||||
bool mAttached;
|
||||
|
|
|
@ -32,8 +32,7 @@ ContentHostBase::~ContentHostBase()
|
|||
}
|
||||
|
||||
void
|
||||
ContentHostTexture::Composite(Compositor* aCompositor,
|
||||
LayerComposite* aLayer,
|
||||
ContentHostTexture::Composite(LayerComposite* aLayer,
|
||||
EffectChain& aEffectChain,
|
||||
float aOpacity,
|
||||
const gfx::Matrix4x4& aTransform,
|
||||
|
@ -182,16 +181,16 @@ ContentHostTexture::Composite(Compositor* aCompositor,
|
|||
Float(tileRegionRect.width) / texRect.width,
|
||||
Float(tileRegionRect.height) / texRect.height);
|
||||
|
||||
aCompositor->DrawGeometry(rect, aClipRect, aEffectChain,
|
||||
aOpacity, aTransform, aGeometry);
|
||||
GetCompositor()->DrawGeometry(rect, aClipRect, aEffectChain,
|
||||
aOpacity, aTransform, aGeometry);
|
||||
|
||||
if (usingTiles) {
|
||||
DiagnosticFlags diagnostics = DiagnosticFlags::CONTENT | DiagnosticFlags::BIGIMAGE;
|
||||
if (iterOnWhite) {
|
||||
diagnostics |= DiagnosticFlags::COMPONENT_ALPHA;
|
||||
}
|
||||
aCompositor->DrawDiagnostics(diagnostics, rect, aClipRect,
|
||||
aTransform, mFlashCounter);
|
||||
GetCompositor()->DrawDiagnostics(diagnostics, rect, aClipRect,
|
||||
aTransform, mFlashCounter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -213,8 +212,8 @@ ContentHostTexture::Composite(Compositor* aCompositor,
|
|||
if (iterOnWhite) {
|
||||
diagnostics |= DiagnosticFlags::COMPONENT_ALPHA;
|
||||
}
|
||||
aCompositor->DrawDiagnostics(diagnostics, nsIntRegion(mBufferRect), aClipRect,
|
||||
aTransform, mFlashCounter);
|
||||
GetCompositor()->DrawDiagnostics(diagnostics, nsIntRegion(mBufferRect), aClipRect,
|
||||
aTransform, mFlashCounter);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -255,14 +254,14 @@ ContentHostTexture::UseComponentAlphaTextures(TextureHost* aTextureOnBlack,
|
|||
}
|
||||
|
||||
void
|
||||
ContentHostTexture::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
ContentHostTexture::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
ContentHostBase::SetTextureSourceProvider(aProvider);
|
||||
ContentHostBase::SetCompositor(aCompositor);
|
||||
if (mTextureHost) {
|
||||
mTextureHost->SetTextureSourceProvider(aProvider);
|
||||
mTextureHost->SetCompositor(aCompositor);
|
||||
}
|
||||
if (mTextureHostOnWhite) {
|
||||
mTextureHostOnWhite->SetTextureSourceProvider(aProvider);
|
||||
mTextureHostOnWhite->SetCompositor(aCompositor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -117,8 +117,7 @@ public:
|
|||
, mReceivedNewHost(false)
|
||||
{ }
|
||||
|
||||
virtual void Composite(Compositor* aCompositor,
|
||||
LayerComposite* aLayer,
|
||||
virtual void Composite(LayerComposite* aLayer,
|
||||
EffectChain& aEffectChain,
|
||||
float aOpacity,
|
||||
const gfx::Matrix4x4& aTransform,
|
||||
|
@ -127,7 +126,7 @@ public:
|
|||
const nsIntRegion* aVisibleRegion = nullptr,
|
||||
const Maybe<gfx::Polygon>& aGeometry = Nothing()) override;
|
||||
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider);
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override;
|
||||
|
||||
|
|
|
@ -51,11 +51,20 @@ GPUVideoTextureHost::BindTextureSource(CompositableTextureSourceRef& aTexture)
|
|||
return mWrappedTextureHost->BindTextureSource(aTexture);
|
||||
}
|
||||
|
||||
Compositor*
|
||||
GPUVideoTextureHost::GetCompositor()
|
||||
{
|
||||
if (!mWrappedTextureHost) {
|
||||
return nullptr;
|
||||
}
|
||||
return mWrappedTextureHost->GetCompositor();
|
||||
}
|
||||
|
||||
void
|
||||
GPUVideoTextureHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
GPUVideoTextureHost::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
if (mWrappedTextureHost) {
|
||||
mWrappedTextureHost->SetTextureSourceProvider(aProvider);
|
||||
mWrappedTextureHost->SetCompositor(aCompositor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,9 @@ public:
|
|||
|
||||
virtual void DeallocateDeviceData() override {}
|
||||
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
virtual Compositor* GetCompositor() override;
|
||||
|
||||
virtual bool Lock() override;
|
||||
|
||||
|
|
|
@ -177,19 +177,20 @@ ImageHost::GetAsTextureHost(IntRect* aPictureRect)
|
|||
}
|
||||
|
||||
void ImageHost::Attach(Layer* aLayer,
|
||||
TextureSourceProvider* aProvider,
|
||||
Compositor* aCompositor,
|
||||
AttachFlags aFlags)
|
||||
{
|
||||
CompositableHost::Attach(aLayer, aProvider, aFlags);
|
||||
CompositableHost::Attach(aLayer, aCompositor, aFlags);
|
||||
for (auto& img : mImages) {
|
||||
img.mTextureHost->SetTextureSourceProvider(aProvider);
|
||||
if (GetCompositor()) {
|
||||
img.mTextureHost->SetCompositor(GetCompositor());
|
||||
}
|
||||
img.mTextureHost->Updated();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ImageHost::Composite(Compositor* aCompositor,
|
||||
LayerComposite* aLayer,
|
||||
ImageHost::Composite(LayerComposite* aLayer,
|
||||
EffectChain& aEffectChain,
|
||||
float aOpacity,
|
||||
const gfx::Matrix4x4& aTransform,
|
||||
|
@ -213,7 +214,7 @@ ImageHost::Composite(Compositor* aCompositor,
|
|||
}
|
||||
|
||||
TimedImage* img = &mImages[imageIndex];
|
||||
img->mTextureHost->SetTextureSourceProvider(aCompositor);
|
||||
img->mTextureHost->SetCompositor(GetCompositor());
|
||||
SetCurrentTextureHost(img->mTextureHost);
|
||||
|
||||
{
|
||||
|
@ -242,7 +243,7 @@ ImageHost::Composite(Compositor* aCompositor,
|
|||
return;
|
||||
}
|
||||
|
||||
if (!aCompositor->SupportsEffect(effect->mType)) {
|
||||
if (!GetCompositor()->SupportsEffect(effect->mType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -301,15 +302,15 @@ ImageHost::Composite(Compositor* aCompositor,
|
|||
effect->mTextureCoords.y = effect->mTextureCoords.YMost();
|
||||
effect->mTextureCoords.height = -effect->mTextureCoords.height;
|
||||
}
|
||||
aCompositor->DrawGeometry(rect, aClipRect, aEffectChain,
|
||||
aOpacity, aTransform, aGeometry);
|
||||
aCompositor->DrawDiagnostics(diagnosticFlags | DiagnosticFlags::BIGIMAGE,
|
||||
rect, aClipRect, aTransform, mFlashCounter);
|
||||
GetCompositor()->DrawGeometry(rect, aClipRect, aEffectChain,
|
||||
aOpacity, aTransform, aGeometry);
|
||||
GetCompositor()->DrawDiagnostics(diagnosticFlags | DiagnosticFlags::BIGIMAGE,
|
||||
rect, aClipRect, aTransform, mFlashCounter);
|
||||
} while (it->NextTile());
|
||||
it->EndBigImageIteration();
|
||||
// layer border
|
||||
aCompositor->DrawDiagnostics(diagnosticFlags, pictureRect,
|
||||
aClipRect, aTransform, mFlashCounter);
|
||||
GetCompositor()->DrawDiagnostics(diagnosticFlags, pictureRect,
|
||||
aClipRect, aTransform, mFlashCounter);
|
||||
} else {
|
||||
IntSize textureSize = mCurrentTextureSource->GetSize();
|
||||
effect->mTextureCoords = Rect(Float(img->mPictureRect.x) / textureSize.width,
|
||||
|
@ -322,11 +323,11 @@ ImageHost::Composite(Compositor* aCompositor,
|
|||
effect->mTextureCoords.height = -effect->mTextureCoords.height;
|
||||
}
|
||||
|
||||
aCompositor->DrawGeometry(pictureRect, aClipRect, aEffectChain,
|
||||
aOpacity, aTransform, aGeometry);
|
||||
aCompositor->DrawDiagnostics(diagnosticFlags,
|
||||
pictureRect, aClipRect,
|
||||
aTransform, mFlashCounter);
|
||||
GetCompositor()->DrawGeometry(pictureRect, aClipRect, aEffectChain,
|
||||
aOpacity, aTransform, aGeometry);
|
||||
GetCompositor()->DrawDiagnostics(diagnosticFlags,
|
||||
pictureRect, aClipRect,
|
||||
aTransform, mFlashCounter);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -343,14 +344,14 @@ ImageHost::Composite(Compositor* aCompositor,
|
|||
}
|
||||
|
||||
void
|
||||
ImageHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
ImageHost::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
if (mTextureSourceProvider != aProvider) {
|
||||
if (mCompositor != aCompositor) {
|
||||
for (auto& img : mImages) {
|
||||
img.mTextureHost->SetTextureSourceProvider(aProvider);
|
||||
img.mTextureHost->SetCompositor(aCompositor);
|
||||
}
|
||||
}
|
||||
CompositableHost::SetTextureSourceProvider(aProvider);
|
||||
CompositableHost::SetCompositor(aCompositor);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -45,8 +45,7 @@ public:
|
|||
|
||||
virtual CompositableType GetType() override { return mTextureInfo.mCompositableType; }
|
||||
|
||||
virtual void Composite(Compositor* aCompositor,
|
||||
LayerComposite* aLayer,
|
||||
virtual void Composite(LayerComposite* aLayer,
|
||||
EffectChain& aEffectChain,
|
||||
float aOpacity,
|
||||
const gfx::Matrix4x4& aTransform,
|
||||
|
@ -62,10 +61,10 @@ public:
|
|||
virtual TextureHost* GetAsTextureHost(gfx::IntRect* aPictureRect = nullptr) override;
|
||||
|
||||
virtual void Attach(Layer* aLayer,
|
||||
TextureSourceProvider* aProvider,
|
||||
Compositor* aCompositor,
|
||||
AttachFlags aFlags = NO_FLAGS) override;
|
||||
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
gfx::IntSize GetImageSize() const override;
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ ImageLayerComposite::SetLayerManager(HostLayerManager* aManager)
|
|||
LayerComposite::SetLayerManager(aManager);
|
||||
mManager = aManager;
|
||||
if (mImageHost) {
|
||||
mImageHost->SetTextureSourceProvider(mCompositor);
|
||||
mImageHost->SetCompositor(mCompositor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,8 +101,8 @@ ImageLayerComposite::RenderLayer(const IntRect& aClipRect,
|
|||
|
||||
RenderWithAllMasks(this, mCompositor, aClipRect,
|
||||
[&](EffectChain& effectChain, const IntRect& clipRect) {
|
||||
mImageHost->SetTextureSourceProvider(mCompositor);
|
||||
mImageHost->Composite(mCompositor, this, effectChain,
|
||||
mImageHost->SetCompositor(mCompositor);
|
||||
mImageHost->Composite(this, effectChain,
|
||||
GetEffectiveOpacity(),
|
||||
GetEffectiveTransformForBuffer(),
|
||||
GetSamplingFilter(),
|
||||
|
|
|
@ -116,7 +116,6 @@ public:
|
|||
virtual void BeginTransactionWithDrawTarget(gfx::DrawTarget* aTarget,
|
||||
const gfx::IntRect& aRect) = 0;
|
||||
virtual Compositor* GetCompositor() const = 0;
|
||||
virtual TextureSourceProvider* GetTextureSourceProvider() const = 0;
|
||||
virtual void EndTransaction(const TimeStamp& aTimeStamp,
|
||||
EndTransactionFlags aFlags = END_DEFAULT) = 0;
|
||||
virtual void UpdateRenderBounds(const gfx::IntRect& aRect) {}
|
||||
|
@ -358,10 +357,8 @@ public:
|
|||
return mVisibleRegions.Get(aGuid);
|
||||
}
|
||||
|
||||
Compositor* GetCompositor() const override {
|
||||
return mCompositor;
|
||||
}
|
||||
TextureSourceProvider* GetTextureSourceProvider() const override {
|
||||
Compositor* GetCompositor() const override
|
||||
{
|
||||
return mCompositor;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ PaintedLayerComposite::SetLayerManager(HostLayerManager* aManager)
|
|||
LayerComposite::SetLayerManager(aManager);
|
||||
mManager = aManager;
|
||||
if (mBuffer && mCompositor) {
|
||||
mBuffer->SetTextureSourceProvider(mCompositor);
|
||||
mBuffer->SetCompositor(mCompositor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ PaintedLayerComposite::RenderLayer(const gfx::IntRect& aClipRect,
|
|||
|
||||
Compositor* compositor = mCompositeManager->GetCompositor();
|
||||
|
||||
MOZ_ASSERT(mBuffer->GetTextureSourceProvider() == compositor &&
|
||||
MOZ_ASSERT(mBuffer->GetCompositor() == compositor &&
|
||||
mBuffer->GetLayer() == this,
|
||||
"buffer is corrupted");
|
||||
|
||||
|
@ -121,7 +121,7 @@ PaintedLayerComposite::RenderLayer(const gfx::IntRect& aClipRect,
|
|||
const gfx::IntRect& clipRect) {
|
||||
mBuffer->SetPaintWillResample(MayResample());
|
||||
|
||||
mBuffer->Composite(compositor, this, effectChain, GetEffectiveOpacity(),
|
||||
mBuffer->Composite(this, effectChain, GetEffectiveOpacity(),
|
||||
GetEffectiveTransform(), GetSamplingFilter(),
|
||||
clipRect, &visibleRegion, aGeometry);
|
||||
});
|
||||
|
|
|
@ -297,13 +297,14 @@ void
|
|||
TextureHost::UnbindTextureSource()
|
||||
{
|
||||
if (mReadLock) {
|
||||
auto compositor = GetCompositor();
|
||||
// This TextureHost is not used anymore. Since most compositor backends are
|
||||
// working asynchronously under the hood a compositor could still be using
|
||||
// this texture, so it is generally best to wait until the end of the next
|
||||
// composition before calling ReadUnlock. We ask the compositor to take care
|
||||
// of that for us.
|
||||
if (mProvider) {
|
||||
mProvider->UnlockAfterComposition(this);
|
||||
if (compositor) {
|
||||
compositor->UnlockAfterComposition(this);
|
||||
} else {
|
||||
// GetCompositor returned null which means no compositor can be using this
|
||||
// texture. We can ReadUnlock right away.
|
||||
|
@ -333,18 +334,21 @@ TextureHost::NotifyNotUsed()
|
|||
return;
|
||||
}
|
||||
|
||||
auto compositor = GetCompositor();
|
||||
// The following cases do not need to defer NotifyNotUsed until next Composite.
|
||||
// - TextureHost does not have Compositor.
|
||||
// - Compositor is BasicCompositor.
|
||||
// - TextureHost has intermediate buffer.
|
||||
// end of buffer usage.
|
||||
if (!mProvider ||
|
||||
HasIntermediateBuffer() ||
|
||||
!mProvider->NotifyNotUsedAfterComposition(this))
|
||||
{
|
||||
if (!compositor ||
|
||||
compositor->IsDestroyed() ||
|
||||
compositor->AsBasicCompositor() ||
|
||||
HasIntermediateBuffer()) {
|
||||
static_cast<TextureParent*>(mActor)->NotifyNotUsed(mFwdTransactionId);
|
||||
return;
|
||||
}
|
||||
|
||||
compositor->NotifyNotUsedAfterComposition(this);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -411,6 +415,7 @@ TextureSource::Name() const
|
|||
BufferTextureHost::BufferTextureHost(const BufferDescriptor& aDesc,
|
||||
TextureFlags aFlags)
|
||||
: TextureHost(aFlags)
|
||||
, mCompositor(nullptr)
|
||||
, mUpdateSerial(1)
|
||||
, mLocked(false)
|
||||
, mNeedsFullUpdate(false)
|
||||
|
@ -464,11 +469,20 @@ BufferTextureHost::UpdatedInternal(const nsIntRegion* aRegion)
|
|||
}
|
||||
|
||||
void
|
||||
BufferTextureHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
BufferTextureHost::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
if (mProvider == aProvider) {
|
||||
MOZ_ASSERT(aCompositor);
|
||||
if (mCompositor == aCompositor) {
|
||||
return;
|
||||
}
|
||||
if (aCompositor && mCompositor &&
|
||||
aCompositor->GetBackendType() == mCompositor->GetBackendType()) {
|
||||
RefPtr<TextureSource> it = mFirstSource;
|
||||
while (it) {
|
||||
it->SetCompositor(aCompositor);
|
||||
it = it->GetNextSibling();
|
||||
}
|
||||
}
|
||||
if (mFirstSource && mFirstSource->IsOwnedBy(this)) {
|
||||
mFirstSource->SetOwner(nullptr);
|
||||
}
|
||||
|
@ -476,7 +490,7 @@ BufferTextureHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
|||
mFirstSource = nullptr;
|
||||
mNeedsFullUpdate = true;
|
||||
}
|
||||
mProvider = aProvider;
|
||||
mCompositor = aCompositor;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -568,12 +582,12 @@ BufferTextureHost::EnsureWrappingTextureSource()
|
|||
mFirstSource = nullptr;
|
||||
}
|
||||
|
||||
if (!mProvider) {
|
||||
if (!mCompositor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mFormat == gfx::SurfaceFormat::YUV) {
|
||||
mFirstSource = mProvider->CreateDataTextureSourceAroundYCbCr(this);
|
||||
mFirstSource = mCompositor->CreateDataTextureSourceAroundYCbCr(this);
|
||||
} else {
|
||||
RefPtr<gfx::DataSourceSurface> surf =
|
||||
gfx::Factory::CreateWrappingDataSourceSurface(GetBuffer(),
|
||||
|
@ -581,7 +595,7 @@ BufferTextureHost::EnsureWrappingTextureSource()
|
|||
if (!surf) {
|
||||
return false;
|
||||
}
|
||||
mFirstSource = mProvider->CreateDataTextureSourceAround(surf);
|
||||
mFirstSource = mCompositor->CreateDataTextureSourceAround(surf);
|
||||
}
|
||||
|
||||
if (!mFirstSource) {
|
||||
|
@ -603,9 +617,9 @@ BufferTextureHost::EnsureWrappingTextureSource()
|
|||
static
|
||||
bool IsCompatibleTextureSource(TextureSource* aTexture,
|
||||
const BufferDescriptor& aDescriptor,
|
||||
TextureSourceProvider* aProvider)
|
||||
Compositor* aCompositor)
|
||||
{
|
||||
if (!aProvider) {
|
||||
if (!aCompositor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -613,7 +627,7 @@ bool IsCompatibleTextureSource(TextureSource* aTexture,
|
|||
case BufferDescriptor::TYCbCrDescriptor: {
|
||||
const YCbCrDescriptor& ycbcr = aDescriptor.get_YCbCrDescriptor();
|
||||
|
||||
if (!aProvider->SupportsEffect(EffectTypes::YCBCR)) {
|
||||
if (!aCompositor->SupportsEffect(EffectTypes::YCBCR)) {
|
||||
return aTexture->GetFormat() == gfx::SurfaceFormat::B8G8R8X8
|
||||
&& aTexture->GetSize() == ycbcr.ySize();
|
||||
}
|
||||
|
@ -687,7 +701,7 @@ BufferTextureHost::PrepareTextureSource(CompositableTextureSourceRef& aTexture)
|
|||
|
||||
bool compatibleFormats = texture && IsCompatibleTextureSource(texture,
|
||||
mDescriptor,
|
||||
mProvider);
|
||||
mCompositor);
|
||||
|
||||
bool shouldCreateTexture = !compatibleFormats
|
||||
|| texture->NumCompositableRefs() > 1
|
||||
|
@ -703,7 +717,7 @@ BufferTextureHost::PrepareTextureSource(CompositableTextureSourceRef& aTexture)
|
|||
// current one.
|
||||
RefPtr<TextureSource> it = mFirstSource;
|
||||
while (it) {
|
||||
it->SetTextureSourceProvider(mProvider);
|
||||
it->SetCompositor(mCompositor);
|
||||
it = it->GetNextSibling();
|
||||
}
|
||||
}
|
||||
|
@ -743,8 +757,8 @@ BufferTextureHost::GetFormat() const
|
|||
// if the compositor does not support YCbCr effects, we give it a RGBX texture
|
||||
// instead (see BufferTextureHost::Upload)
|
||||
if (mFormat == gfx::SurfaceFormat::YUV &&
|
||||
mProvider &&
|
||||
!mProvider->SupportsEffect(EffectTypes::YCBCR)) {
|
||||
mCompositor &&
|
||||
!mCompositor->SupportsEffect(EffectTypes::YCBCR)) {
|
||||
return gfx::SurfaceFormat::R8G8B8X8;
|
||||
}
|
||||
return mFormat;
|
||||
|
@ -805,7 +819,7 @@ BufferTextureHost::Upload(nsIntRegion *aRegion)
|
|||
// deserializing it.
|
||||
return false;
|
||||
}
|
||||
if (!mProvider) {
|
||||
if (!mCompositor) {
|
||||
// This can happen if we send textures to a compositable that isn't yet
|
||||
// attached to a layer.
|
||||
return false;
|
||||
|
@ -820,14 +834,14 @@ BufferTextureHost::Upload(nsIntRegion *aRegion)
|
|||
} else if (mFormat == gfx::SurfaceFormat::YUV) {
|
||||
const YCbCrDescriptor& desc = mDescriptor.get_YCbCrDescriptor();
|
||||
|
||||
if (!mProvider->SupportsEffect(EffectTypes::YCBCR)) {
|
||||
if (!mCompositor->SupportsEffect(EffectTypes::YCBCR)) {
|
||||
RefPtr<gfx::DataSourceSurface> surf =
|
||||
ImageDataSerializer::DataSourceSurfaceFromYCbCrDescriptor(buf, mDescriptor.get_YCbCrDescriptor());
|
||||
if (NS_WARN_IF(!surf)) {
|
||||
return false;
|
||||
}
|
||||
if (!mFirstSource) {
|
||||
mFirstSource = mProvider->CreateDataTextureSource(mFlags|TextureFlags::RGB_FROM_YCBCR);
|
||||
mFirstSource = mCompositor->CreateDataTextureSource(mFlags|TextureFlags::RGB_FROM_YCBCR);
|
||||
mFirstSource->SetOwner(this);
|
||||
}
|
||||
mFirstSource->Update(surf, aRegion);
|
||||
|
@ -839,9 +853,9 @@ BufferTextureHost::Upload(nsIntRegion *aRegion)
|
|||
RefPtr<DataTextureSource> srcV;
|
||||
if (!mFirstSource) {
|
||||
// We don't support BigImages for YCbCr compositing.
|
||||
srcY = mProvider->CreateDataTextureSource(mFlags|TextureFlags::DISALLOW_BIGIMAGE);
|
||||
srcU = mProvider->CreateDataTextureSource(mFlags|TextureFlags::DISALLOW_BIGIMAGE);
|
||||
srcV = mProvider->CreateDataTextureSource(mFlags|TextureFlags::DISALLOW_BIGIMAGE);
|
||||
srcY = mCompositor->CreateDataTextureSource(mFlags|TextureFlags::DISALLOW_BIGIMAGE);
|
||||
srcU = mCompositor->CreateDataTextureSource(mFlags|TextureFlags::DISALLOW_BIGIMAGE);
|
||||
srcV = mCompositor->CreateDataTextureSource(mFlags|TextureFlags::DISALLOW_BIGIMAGE);
|
||||
mFirstSource = srcY;
|
||||
mFirstSource->SetOwner(this);
|
||||
srcY->SetNextSibling(srcU);
|
||||
|
@ -888,7 +902,7 @@ BufferTextureHost::Upload(nsIntRegion *aRegion)
|
|||
// non-YCbCr case
|
||||
nsIntRegion* regionToUpdate = aRegion;
|
||||
if (!mFirstSource) {
|
||||
mFirstSource = mProvider->CreateDataTextureSource(mFlags);
|
||||
mFirstSource = mCompositor->CreateDataTextureSource(mFlags);
|
||||
mFirstSource->SetOwner(this);
|
||||
if (mFlags & TextureFlags::COMPONENT_ALPHA) {
|
||||
// Update the full region the first time for component alpha textures.
|
||||
|
|
|
@ -133,7 +133,7 @@ public:
|
|||
*/
|
||||
virtual BigImageIterator* AsBigImageIterator() { return nullptr; }
|
||||
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) {}
|
||||
virtual void SetCompositor(Compositor* aCompositor) {}
|
||||
|
||||
virtual void Unbind() {}
|
||||
|
||||
|
@ -450,15 +450,13 @@ public:
|
|||
void Updated(const nsIntRegion* aRegion = nullptr);
|
||||
|
||||
/**
|
||||
* Sets this TextureHost's compositor. A TextureHost can change compositor
|
||||
* on certain occasions, in particular if it belongs to an async Compositable.
|
||||
* Sets this TextureHost's compositor.
|
||||
* A TextureHost can change compositor on certain occasions, in particular if
|
||||
* it belongs to an async Compositable.
|
||||
* aCompositor can be null, in which case the TextureHost must cleanup all
|
||||
* of its device textures.
|
||||
*
|
||||
* Setting mProvider from this callback implicitly causes the texture to
|
||||
* be locked for an extra frame after being detached from a compositable.
|
||||
* of it's device textures.
|
||||
*/
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) {}
|
||||
virtual void SetCompositor(Compositor* aCompositor) {}
|
||||
|
||||
/**
|
||||
* Should be overridden in order to deallocate the data that is associated
|
||||
|
@ -582,6 +580,8 @@ public:
|
|||
|
||||
TextureReadLock* GetReadLock() { return mReadLock; }
|
||||
|
||||
virtual Compositor* GetCompositor() = 0;
|
||||
|
||||
virtual BufferTextureHost* AsBufferTextureHost() { return nullptr; }
|
||||
|
||||
protected:
|
||||
|
@ -600,7 +600,6 @@ protected:
|
|||
void CallNotifyNotUsed();
|
||||
|
||||
PTextureParent* mActor;
|
||||
RefPtr<TextureSourceProvider> mProvider;
|
||||
RefPtr<TextureReadLock> mReadLock;
|
||||
TextureFlags mFlags;
|
||||
int mCompositableCount;
|
||||
|
@ -609,7 +608,6 @@ protected:
|
|||
friend class Compositor;
|
||||
friend class TextureParent;
|
||||
friend class TiledLayerBufferComposite;
|
||||
friend class TextureSourceProvider;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -648,7 +646,9 @@ public:
|
|||
|
||||
virtual void DeallocateDeviceData() override;
|
||||
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
virtual Compositor* GetCompositor() override { return mCompositor; }
|
||||
|
||||
/**
|
||||
* Return the format that is exposed to the compositor when calling
|
||||
|
|
|
@ -57,14 +57,14 @@ TiledLayerBufferComposite::~TiledLayerBufferComposite()
|
|||
}
|
||||
|
||||
void
|
||||
TiledLayerBufferComposite::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
TiledLayerBufferComposite::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
MOZ_ASSERT(aProvider);
|
||||
MOZ_ASSERT(aCompositor);
|
||||
for (TileHost& tile : mRetainedTiles) {
|
||||
if (tile.IsPlaceholderTile()) continue;
|
||||
tile.mTextureHost->SetTextureSourceProvider(aProvider);
|
||||
tile.mTextureHost->SetCompositor(aCompositor);
|
||||
if (tile.mTextureHostOnWhite) {
|
||||
tile.mTextureHostOnWhite->SetTextureSourceProvider(aProvider);
|
||||
tile.mTextureHostOnWhite->SetCompositor(aCompositor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -116,10 +116,10 @@ TiledContentHost::GenEffect(const gfx::SamplingFilter aSamplingFilter)
|
|||
|
||||
void
|
||||
TiledContentHost::Attach(Layer* aLayer,
|
||||
TextureSourceProvider* aProvider,
|
||||
Compositor* aCompositor,
|
||||
AttachFlags aFlags /* = NO_FLAGS */)
|
||||
{
|
||||
CompositableHost::Attach(aLayer, aProvider, aFlags);
|
||||
CompositableHost::Attach(aLayer, aCompositor, aFlags);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -168,7 +168,7 @@ UseTileTexture(CompositableTextureHostRef& aTexture,
|
|||
}
|
||||
|
||||
if (aCompositor) {
|
||||
aTexture->SetTextureSourceProvider(aCompositor);
|
||||
aTexture->SetCompositor(aCompositor);
|
||||
}
|
||||
|
||||
if (!aUpdateRect.IsEmpty()) {
|
||||
|
@ -299,7 +299,7 @@ TiledLayerBufferComposite::UseTiles(const SurfaceDescriptorTiles& aTiles,
|
|||
const TexturedTileDescriptor& texturedDesc = tileDesc.get_TexturedTileDescriptor();
|
||||
|
||||
tile.mTextureHost = TextureHost::AsTextureHost(texturedDesc.textureParent());
|
||||
tile.mTextureHost->SetTextureSourceProvider(aLayerManager->GetCompositor());
|
||||
tile.mTextureHost->SetCompositor(aLayerManager->GetCompositor());
|
||||
tile.mTextureHost->DeserializeReadLock(texturedDesc.sharedLock(), aAllocator);
|
||||
|
||||
if (texturedDesc.textureOnWhite().type() == MaybeTexture::TPTextureParent) {
|
||||
|
@ -389,8 +389,7 @@ TiledLayerBufferComposite::Clear()
|
|||
}
|
||||
|
||||
void
|
||||
TiledContentHost::Composite(Compositor* aCompositor,
|
||||
LayerComposite* aLayer,
|
||||
TiledContentHost::Composite(LayerComposite* aLayer,
|
||||
EffectChain& aEffectChain,
|
||||
float aOpacity,
|
||||
const gfx::Matrix4x4& aTransform,
|
||||
|
@ -399,6 +398,7 @@ TiledContentHost::Composite(Compositor* aCompositor,
|
|||
const nsIntRegion* aVisibleRegion /* = nullptr */,
|
||||
const Maybe<gfx::Polygon>& aGeometry)
|
||||
{
|
||||
MOZ_ASSERT(mCompositor);
|
||||
// Reduce the opacity of the low-precision buffer to make it a
|
||||
// little more subtle and less jarring. In particular, text
|
||||
// rendered at low-resolution and scaled tends to look pretty
|
||||
|
@ -438,19 +438,18 @@ TiledContentHost::Composite(Compositor* aCompositor,
|
|||
#endif
|
||||
|
||||
// Render the low and high precision buffers.
|
||||
RenderLayerBuffer(mLowPrecisionTiledBuffer, aCompositor,
|
||||
RenderLayerBuffer(mLowPrecisionTiledBuffer,
|
||||
lowPrecisionOpacityReduction < 1.0f ? &backgroundColor : nullptr,
|
||||
aEffectChain, lowPrecisionOpacityReduction * aOpacity,
|
||||
aSamplingFilter, aClipRect, *renderRegion, aTransform, aGeometry);
|
||||
|
||||
RenderLayerBuffer(mTiledBuffer, aCompositor, nullptr, aEffectChain, aOpacity, aSamplingFilter,
|
||||
RenderLayerBuffer(mTiledBuffer, nullptr, aEffectChain, aOpacity, aSamplingFilter,
|
||||
aClipRect, *renderRegion, aTransform, aGeometry);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TiledContentHost::RenderTile(TileHost& aTile,
|
||||
Compositor* aCompositor,
|
||||
EffectChain& aEffectChain,
|
||||
float aOpacity,
|
||||
const gfx::Matrix4x4& aTransform,
|
||||
|
@ -503,7 +502,7 @@ TiledContentHost::RenderTile(TileHost& aTile,
|
|||
textureRect.width / aTextureBounds.width,
|
||||
textureRect.height / aTextureBounds.height);
|
||||
|
||||
aCompositor->DrawGeometry(graphicsRect, aClipRect, aEffectChain, opacity,
|
||||
mCompositor->DrawGeometry(graphicsRect, aClipRect, aEffectChain, opacity,
|
||||
aTransform, aVisibleRect, aGeometry);
|
||||
}
|
||||
|
||||
|
@ -511,13 +510,12 @@ TiledContentHost::RenderTile(TileHost& aTile,
|
|||
if (aTile.mTextureHostOnWhite) {
|
||||
flags |= DiagnosticFlags::COMPONENT_ALPHA;
|
||||
}
|
||||
aCompositor->DrawDiagnostics(flags,
|
||||
mCompositor->DrawDiagnostics(flags,
|
||||
aScreenRegion, aClipRect, aTransform, mFlashCounter);
|
||||
}
|
||||
|
||||
void
|
||||
TiledContentHost::RenderLayerBuffer(TiledLayerBufferComposite& aLayerBuffer,
|
||||
Compositor* aCompositor,
|
||||
const Color* aBackgroundColor,
|
||||
EffectChain& aEffectChain,
|
||||
float aOpacity,
|
||||
|
@ -527,6 +525,10 @@ TiledContentHost::RenderLayerBuffer(TiledLayerBufferComposite& aLayerBuffer,
|
|||
gfx::Matrix4x4 aTransform,
|
||||
const Maybe<Polygon>& aGeometry)
|
||||
{
|
||||
if (!mCompositor) {
|
||||
NS_WARNING("Can't render tiled content host - no compositor");
|
||||
return;
|
||||
}
|
||||
float resolution = aLayerBuffer.GetResolution();
|
||||
gfx::Size layerScale(1, 1);
|
||||
|
||||
|
@ -577,7 +579,7 @@ TiledContentHost::RenderLayerBuffer(TiledLayerBufferComposite& aLayerBuffer,
|
|||
for (auto iter = backgroundRegion.RectIter(); !iter.Done(); iter.Next()) {
|
||||
const IntRect& rect = iter.Get();
|
||||
Rect graphicsRect(rect.x, rect.y, rect.width, rect.height);
|
||||
aCompositor->DrawGeometry(graphicsRect, aClipRect, effect,
|
||||
mCompositor->DrawGeometry(graphicsRect, aClipRect, effect,
|
||||
1.0, aTransform, aGeometry);
|
||||
}
|
||||
}
|
||||
|
@ -601,7 +603,7 @@ TiledContentHost::RenderLayerBuffer(TiledLayerBufferComposite& aLayerBuffer,
|
|||
}
|
||||
|
||||
tileDrawRegion.ScaleRoundOut(resolution, resolution);
|
||||
RenderTile(tile, aCompositor, aEffectChain, aOpacity,
|
||||
RenderTile(tile, aEffectChain, aOpacity,
|
||||
aTransform, aSamplingFilter, aClipRect, tileDrawRegion,
|
||||
tileOffset * resolution, aLayerBuffer.GetTileSize(),
|
||||
gfx::Rect(visibleRect.x, visibleRect.y,
|
||||
|
@ -615,8 +617,8 @@ TiledContentHost::RenderLayerBuffer(TiledLayerBufferComposite& aLayerBuffer,
|
|||
|
||||
gfx::Rect rect(visibleRect.x, visibleRect.y,
|
||||
visibleRect.width, visibleRect.height);
|
||||
aCompositor->DrawDiagnostics(DiagnosticFlags::CONTENT | componentAlphaDiagnostic,
|
||||
rect, aClipRect, aTransform, mFlashCounter);
|
||||
GetCompositor()->DrawDiagnostics(DiagnosticFlags::CONTENT | componentAlphaDiagnostic,
|
||||
rect, aClipRect, aTransform, mFlashCounter);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -136,7 +136,7 @@ public:
|
|||
// by the sum of the resolutions of all parent layers' FrameMetrics.
|
||||
const CSSToParentLayerScale2D& GetFrameResolution() { return mFrameResolution; }
|
||||
|
||||
void SetTextureSourceProvider(TextureSourceProvider* aProvider);
|
||||
void SetCompositor(Compositor* aCompositor);
|
||||
|
||||
void AddAnimationInvalidation(nsIntRegion& aRegion);
|
||||
protected:
|
||||
|
@ -194,18 +194,18 @@ public:
|
|||
return mTiledBuffer.GetValidRegion();
|
||||
}
|
||||
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override
|
||||
virtual void SetCompositor(Compositor* aCompositor) override
|
||||
{
|
||||
CompositableHost::SetTextureSourceProvider(aProvider);
|
||||
mTiledBuffer.SetTextureSourceProvider(aProvider);
|
||||
mLowPrecisionTiledBuffer.SetTextureSourceProvider(aProvider);
|
||||
MOZ_ASSERT(aCompositor);
|
||||
CompositableHost::SetCompositor(aCompositor);
|
||||
mTiledBuffer.SetCompositor(aCompositor);
|
||||
mLowPrecisionTiledBuffer.SetCompositor(aCompositor);
|
||||
}
|
||||
|
||||
bool UseTiledLayerBuffer(ISurfaceAllocator* aAllocator,
|
||||
const SurfaceDescriptorTiles& aTiledDescriptor);
|
||||
|
||||
virtual void Composite(Compositor* aCompositor,
|
||||
LayerComposite* aLayer,
|
||||
virtual void Composite(LayerComposite* aLayer,
|
||||
EffectChain& aEffectChain,
|
||||
float aOpacity,
|
||||
const gfx::Matrix4x4& aTransform,
|
||||
|
@ -219,7 +219,7 @@ public:
|
|||
virtual TiledContentHost* AsTiledContentHost() override { return this; }
|
||||
|
||||
virtual void Attach(Layer* aLayer,
|
||||
TextureSourceProvider* aProvider,
|
||||
Compositor* aCompositor,
|
||||
AttachFlags aFlags = NO_FLAGS) override;
|
||||
|
||||
virtual void Detach(Layer* aLayer = nullptr,
|
||||
|
@ -236,7 +236,6 @@ public:
|
|||
private:
|
||||
|
||||
void RenderLayerBuffer(TiledLayerBufferComposite& aLayerBuffer,
|
||||
Compositor* aCompositor,
|
||||
const gfx::Color* aBackgroundColor,
|
||||
EffectChain& aEffectChain,
|
||||
float aOpacity,
|
||||
|
@ -248,7 +247,6 @@ private:
|
|||
|
||||
// Renders a single given tile.
|
||||
void RenderTile(TileHost& aTile,
|
||||
Compositor* aCompositor,
|
||||
EffectChain& aEffectChain,
|
||||
float aOpacity,
|
||||
const gfx::Matrix4x4& aTransform,
|
||||
|
|
|
@ -58,16 +58,11 @@ X11TextureHost::Lock()
|
|||
}
|
||||
|
||||
void
|
||||
X11TextureHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
X11TextureHost::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
mProvider = aProvider;
|
||||
if (mProvider) {
|
||||
mCompositor = mProvider->AsCompositor();
|
||||
} else {
|
||||
mCompositor = nullptr;
|
||||
}
|
||||
mCompositor = aCompositor;
|
||||
if (mTextureSource) {
|
||||
mTextureSource->SetTextureSourceProvider(aProvider);
|
||||
mTextureSource->SetCompositor(aCompositor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,9 @@ public:
|
|||
X11TextureHost(TextureFlags aFlags,
|
||||
const SurfaceDescriptorX11& aDescriptor);
|
||||
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
virtual Compositor* GetCompositor() override { return mCompositor; }
|
||||
|
||||
virtual bool Lock() override;
|
||||
|
||||
|
|
|
@ -139,9 +139,6 @@ public:
|
|||
|
||||
virtual void ForcePresent();
|
||||
|
||||
// For TextureSourceProvider.
|
||||
ID3D11Device* GetD3D11Device() const override { return mDevice; }
|
||||
|
||||
ID3D11Device* GetDevice() { return mDevice; }
|
||||
|
||||
ID3D11DeviceContext* GetDC() { return mContext; }
|
||||
|
|
|
@ -153,10 +153,10 @@ TextureSourceD3D11::GetShaderResourceView()
|
|||
return mSRV;
|
||||
}
|
||||
|
||||
DataTextureSourceD3D11::DataTextureSourceD3D11(ID3D11Device* aDevice,
|
||||
SurfaceFormat aFormat,
|
||||
DataTextureSourceD3D11::DataTextureSourceD3D11(SurfaceFormat aFormat,
|
||||
CompositorD3D11* aCompositor,
|
||||
TextureFlags aFlags)
|
||||
: mDevice(aDevice)
|
||||
: mCompositor(aCompositor)
|
||||
, mFormat(aFormat)
|
||||
, mFlags(aFlags)
|
||||
, mCurrentTile(0)
|
||||
|
@ -167,10 +167,10 @@ DataTextureSourceD3D11::DataTextureSourceD3D11(ID3D11Device* aDevice,
|
|||
MOZ_COUNT_CTOR(DataTextureSourceD3D11);
|
||||
}
|
||||
|
||||
DataTextureSourceD3D11::DataTextureSourceD3D11(ID3D11Device* aDevice,
|
||||
SurfaceFormat aFormat,
|
||||
DataTextureSourceD3D11::DataTextureSourceD3D11(SurfaceFormat aFormat,
|
||||
CompositorD3D11* aCompositor,
|
||||
ID3D11Texture2D* aTexture)
|
||||
: mDevice(aDevice)
|
||||
: mCompositor(aCompositor)
|
||||
, mFormat(aFormat)
|
||||
, mFlags(TextureFlags::NO_FLAGS)
|
||||
, mCurrentTile(0)
|
||||
|
@ -187,15 +187,7 @@ DataTextureSourceD3D11::DataTextureSourceD3D11(ID3D11Device* aDevice,
|
|||
mSize = IntSize(desc.Width, desc.Height);
|
||||
}
|
||||
|
||||
DataTextureSourceD3D11::DataTextureSourceD3D11(gfx::SurfaceFormat aFormat, TextureSourceProvider* aProvider, ID3D11Texture2D* aTexture)
|
||||
: DataTextureSourceD3D11(aProvider->GetD3D11Device(), aFormat, aTexture)
|
||||
{
|
||||
}
|
||||
|
||||
DataTextureSourceD3D11::DataTextureSourceD3D11(gfx::SurfaceFormat aFormat, TextureSourceProvider* aProvider, TextureFlags aFlags)
|
||||
: DataTextureSourceD3D11(aProvider->GetD3D11Device(), aFormat, aFlags)
|
||||
{
|
||||
}
|
||||
|
||||
DataTextureSourceD3D11::~DataTextureSourceD3D11()
|
||||
{
|
||||
|
@ -732,29 +724,44 @@ DXGITextureHostD3D11::GetDevice()
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return mProvider->GetD3D11Device();
|
||||
return DeviceManagerDx::Get()->GetCompositorDevice();
|
||||
}
|
||||
|
||||
static CompositorD3D11* AssertD3D11Compositor(Compositor* aCompositor)
|
||||
{
|
||||
CompositorD3D11* compositor = aCompositor ? aCompositor->AsCompositorD3D11()
|
||||
: nullptr;
|
||||
if (!compositor) {
|
||||
gfxCriticalNote << "[D3D11] Attempt to set an incompatible compositor";
|
||||
}
|
||||
return compositor;
|
||||
}
|
||||
|
||||
void
|
||||
DXGITextureHostD3D11::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
DXGITextureHostD3D11::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
if (!aProvider || !aProvider->GetD3D11Device()) {
|
||||
mProvider = nullptr;
|
||||
CompositorD3D11* d3dCompositor = AssertD3D11Compositor(aCompositor);
|
||||
if (!d3dCompositor) {
|
||||
mCompositor = nullptr;
|
||||
mTextureSource = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
mProvider = aProvider;
|
||||
|
||||
mCompositor = d3dCompositor;
|
||||
if (mTextureSource) {
|
||||
mTextureSource->SetTextureSourceProvider(aProvider);
|
||||
mTextureSource->SetCompositor(aCompositor);
|
||||
}
|
||||
}
|
||||
|
||||
Compositor*
|
||||
DXGITextureHostD3D11::GetCompositor()
|
||||
{
|
||||
return mCompositor;
|
||||
}
|
||||
|
||||
bool
|
||||
DXGITextureHostD3D11::Lock()
|
||||
{
|
||||
if (!mProvider) {
|
||||
if (!mCompositor) {
|
||||
// Make an early return here if we call SetCompositor() with an incompatible
|
||||
// compositor. This check tries to prevent the problem where we use that
|
||||
// incompatible compositor to compose this texture.
|
||||
|
@ -799,7 +806,7 @@ DXGITextureHostD3D11::LockInternal()
|
|||
return false;
|
||||
}
|
||||
|
||||
mTextureSource = new DataTextureSourceD3D11(mFormat, mProvider, mTexture);
|
||||
mTextureSource = new DataTextureSourceD3D11(mFormat, mCompositor, mTexture);
|
||||
}
|
||||
|
||||
mIsLocked = LockD3DTexture(mTextureSource->GetD3D11Texture());
|
||||
|
@ -882,13 +889,14 @@ DXGIYCbCrTextureHostD3D11::GetDevice()
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return mProvider->GetD3D11Device();
|
||||
return DeviceManagerDx::Get()->GetCompositorDevice();
|
||||
}
|
||||
|
||||
void
|
||||
DXGIYCbCrTextureHostD3D11::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
DXGIYCbCrTextureHostD3D11::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
if (!aProvider || !aProvider->GetD3D11Device()) {
|
||||
mCompositor = AssertD3D11Compositor(aCompositor);
|
||||
if (!mCompositor) {
|
||||
mTextureSources[0] = nullptr;
|
||||
mTextureSources[1] = nullptr;
|
||||
mTextureSources[2] = nullptr;
|
||||
|
@ -896,14 +904,20 @@ DXGIYCbCrTextureHostD3D11::SetTextureSourceProvider(TextureSourceProvider* aProv
|
|||
}
|
||||
|
||||
if (mTextureSources[0]) {
|
||||
mTextureSources[0]->SetTextureSourceProvider(aProvider);
|
||||
mTextureSources[0]->SetCompositor(aCompositor);
|
||||
}
|
||||
}
|
||||
|
||||
Compositor*
|
||||
DXGIYCbCrTextureHostD3D11::GetCompositor()
|
||||
{
|
||||
return mCompositor;
|
||||
}
|
||||
|
||||
bool
|
||||
DXGIYCbCrTextureHostD3D11::Lock()
|
||||
{
|
||||
if (!mProvider) {
|
||||
if (!mCompositor) {
|
||||
NS_WARNING("no suitable compositor");
|
||||
return false;
|
||||
}
|
||||
|
@ -919,9 +933,9 @@ DXGIYCbCrTextureHostD3D11::Lock()
|
|||
|
||||
MOZ_ASSERT(mTextures[1] && mTextures[2]);
|
||||
|
||||
mTextureSources[0] = new DataTextureSourceD3D11(SurfaceFormat::A8, mProvider, mTextures[0]);
|
||||
mTextureSources[1] = new DataTextureSourceD3D11(SurfaceFormat::A8, mProvider, mTextures[1]);
|
||||
mTextureSources[2] = new DataTextureSourceD3D11(SurfaceFormat::A8, mProvider, mTextures[2]);
|
||||
mTextureSources[0] = new DataTextureSourceD3D11(SurfaceFormat::A8, mCompositor, mTextures[0]);
|
||||
mTextureSources[1] = new DataTextureSourceD3D11(SurfaceFormat::A8, mCompositor, mTextures[1]);
|
||||
mTextureSources[2] = new DataTextureSourceD3D11(SurfaceFormat::A8, mCompositor, mTextures[2]);
|
||||
mTextureSources[0]->SetNextSibling(mTextureSources[1]);
|
||||
mTextureSources[1]->SetNextSibling(mTextureSources[2]);
|
||||
}
|
||||
|
@ -970,7 +984,7 @@ DataTextureSourceD3D11::Update(DataSourceSurface* aSurface,
|
|||
|
||||
HRESULT hr;
|
||||
|
||||
if (!mDevice) {
|
||||
if (!mCompositor || !mCompositor->GetDevice()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -982,7 +996,7 @@ DataTextureSourceD3D11::Update(DataSourceSurface* aSurface,
|
|||
|
||||
CD3D11_TEXTURE2D_DESC desc(dxgiFormat, mSize.width, mSize.height, 1, 1);
|
||||
|
||||
int32_t maxSize = GetMaxTextureSizeFromDevice(mDevice);
|
||||
int32_t maxSize = mCompositor->GetMaxTextureSize();
|
||||
if ((mSize.width <= maxSize && mSize.height <= maxSize) ||
|
||||
(mFlags & TextureFlags::DISALLOW_BIGIMAGE)) {
|
||||
|
||||
|
@ -1001,7 +1015,7 @@ DataTextureSourceD3D11::Update(DataSourceSurface* aSurface,
|
|||
|
||||
nsIntRegion *regionToUpdate = aDestRegion;
|
||||
if (!mTexture) {
|
||||
hr = mDevice->CreateTexture2D(&desc, nullptr, getter_AddRefs(mTexture));
|
||||
hr = mCompositor->GetDevice()->CreateTexture2D(&desc, nullptr, getter_AddRefs(mTexture));
|
||||
mIsTiled = false;
|
||||
if (FAILED(hr) || !mTexture) {
|
||||
Reset();
|
||||
|
@ -1020,9 +1034,6 @@ DataTextureSourceD3D11::Update(DataSourceSurface* aSurface,
|
|||
return false;
|
||||
}
|
||||
|
||||
RefPtr<ID3D11DeviceContext> context;
|
||||
mDevice->GetImmediateContext(getter_AddRefs(context));
|
||||
|
||||
if (regionToUpdate) {
|
||||
for (auto iter = regionToUpdate->RectIter(); !iter.Done(); iter.Next()) {
|
||||
const IntRect& rect = iter.Get();
|
||||
|
@ -1036,11 +1047,11 @@ DataTextureSourceD3D11::Update(DataSourceSurface* aSurface,
|
|||
|
||||
void* data = map.mData + map.mStride * rect.y + BytesPerPixel(aSurface->GetFormat()) * rect.x;
|
||||
|
||||
context->UpdateSubresource(mTexture, 0, &box, data, map.mStride, map.mStride * rect.height);
|
||||
mCompositor->GetDC()->UpdateSubresource(mTexture, 0, &box, data, map.mStride, map.mStride * rect.height);
|
||||
}
|
||||
} else {
|
||||
context->UpdateSubresource(mTexture, 0, nullptr, aSurface->GetData(),
|
||||
aSurface->Stride(), aSurface->Stride() * mSize.height);
|
||||
mCompositor->GetDC()->UpdateSubresource(mTexture, 0, nullptr, aSurface->GetData(),
|
||||
aSurface->Stride(), aSurface->Stride() * mSize.height);
|
||||
}
|
||||
|
||||
aSurface->Unmap();
|
||||
|
@ -1066,7 +1077,7 @@ DataTextureSourceD3D11::Update(DataSourceSurface* aSurface,
|
|||
tileRect.x * bpp;
|
||||
initData.SysMemPitch = aSurface->Stride();
|
||||
|
||||
hr = mDevice->CreateTexture2D(&desc, &initData, getter_AddRefs(mTileTextures[i]));
|
||||
hr = mCompositor->GetDevice()->CreateTexture2D(&desc, &initData, getter_AddRefs(mTileTextures[i]));
|
||||
if (FAILED(hr) || !mTileTextures[i]) {
|
||||
Reset();
|
||||
return false;
|
||||
|
@ -1120,7 +1131,7 @@ DataTextureSourceD3D11::Reset()
|
|||
IntRect
|
||||
DataTextureSourceD3D11::GetTileRect(uint32_t aIndex) const
|
||||
{
|
||||
return GetTileRectD3D11(aIndex, mSize, GetMaxTextureSizeFromDevice(mDevice));
|
||||
return GetTileRectD3D11(aIndex, mSize, mCompositor->GetMaxTextureSize());
|
||||
}
|
||||
|
||||
IntRect
|
||||
|
@ -1131,19 +1142,15 @@ DataTextureSourceD3D11::GetTileRect()
|
|||
}
|
||||
|
||||
void
|
||||
DataTextureSourceD3D11::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
DataTextureSourceD3D11::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
ID3D11Device* newDevice = aProvider ? aProvider->GetD3D11Device() : nullptr;
|
||||
if (!mDevice) {
|
||||
mDevice = newDevice;
|
||||
} else if (mDevice != newDevice) {
|
||||
// We do not support switching devices.
|
||||
Reset();
|
||||
mDevice = nullptr;
|
||||
CompositorD3D11* d3dCompositor = AssertD3D11Compositor(aCompositor);
|
||||
if (!d3dCompositor) {
|
||||
return;
|
||||
}
|
||||
|
||||
mCompositor = d3dCompositor;
|
||||
if (mNextSibling) {
|
||||
mNextSibling->SetTextureSourceProvider(aProvider);
|
||||
mNextSibling->SetCompositor(aCompositor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1301,11 +1308,5 @@ SyncObjectD3D11::FinalizeFrame()
|
|||
mD3D11SyncedTextures.clear();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GetMaxTextureSizeFromDevice(ID3D11Device* aDevice)
|
||||
{
|
||||
return GetMaxTextureSizeForFeatureLevel(aDevice->GetFeatureLevel());
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
}
|
||||
|
|
|
@ -208,16 +208,15 @@ public:
|
|||
/// Constructor allowing the texture to perform texture uploads.
|
||||
///
|
||||
/// The texture can be used as an actual DataTextureSource.
|
||||
DataTextureSourceD3D11(ID3D11Device* aDevice, gfx::SurfaceFormat aFormat, TextureFlags aFlags);
|
||||
DataTextureSourceD3D11(gfx::SurfaceFormat aFormat, CompositorD3D11* aCompositor,
|
||||
TextureFlags aFlags);
|
||||
|
||||
/// Constructor for textures created around DXGI shared handles, disallowing
|
||||
/// texture uploads.
|
||||
///
|
||||
/// The texture CANNOT be used as a DataTextureSource.
|
||||
DataTextureSourceD3D11(ID3D11Device* aDevice, gfx::SurfaceFormat aFormat, ID3D11Texture2D* aTexture);
|
||||
|
||||
DataTextureSourceD3D11(gfx::SurfaceFormat aFormat, TextureSourceProvider* aProvider, ID3D11Texture2D* aTexture);
|
||||
DataTextureSourceD3D11(gfx::SurfaceFormat aFormat, TextureSourceProvider* aProvider, TextureFlags aFlags);
|
||||
DataTextureSourceD3D11(gfx::SurfaceFormat aFormat, CompositorD3D11* aCompositor,
|
||||
ID3D11Texture2D* aTexture);
|
||||
|
||||
virtual ~DataTextureSourceD3D11();
|
||||
|
||||
|
@ -246,7 +245,7 @@ public:
|
|||
|
||||
virtual gfx::SurfaceFormat GetFormat() const override { return mFormat; }
|
||||
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
// BigImageIterator
|
||||
|
||||
|
@ -273,7 +272,7 @@ protected:
|
|||
|
||||
std::vector< RefPtr<ID3D11Texture2D> > mTileTextures;
|
||||
std::vector< RefPtr<ID3D11ShaderResourceView> > mTileSRVs;
|
||||
RefPtr<ID3D11Device> mDevice;
|
||||
RefPtr<CompositorD3D11> mCompositor;
|
||||
gfx::SurfaceFormat mFormat;
|
||||
TextureFlags mFlags;
|
||||
uint32_t mCurrentTile;
|
||||
|
@ -308,7 +307,9 @@ public:
|
|||
|
||||
virtual void DeallocateDeviceData() override {}
|
||||
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
virtual Compositor* GetCompositor() override;
|
||||
|
||||
virtual gfx::SurfaceFormat GetFormat() const override { return mFormat; }
|
||||
|
||||
|
@ -335,6 +336,7 @@ protected:
|
|||
|
||||
RefPtr<ID3D11Texture2D> mTexture;
|
||||
RefPtr<DataTextureSourceD3D11> mTextureSource;
|
||||
RefPtr<CompositorD3D11> mCompositor;
|
||||
gfx::IntSize mSize;
|
||||
WindowsHandle mHandle;
|
||||
gfx::SurfaceFormat mFormat;
|
||||
|
@ -351,7 +353,9 @@ public:
|
|||
|
||||
virtual void DeallocateDeviceData() override{}
|
||||
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
virtual Compositor* GetCompositor() override;
|
||||
|
||||
virtual gfx::SurfaceFormat GetFormat() const override{ return gfx::SurfaceFormat::YUV; }
|
||||
|
||||
|
@ -377,6 +381,7 @@ protected:
|
|||
RefPtr<ID3D11Texture2D> mTextures[3];
|
||||
RefPtr<DataTextureSourceD3D11> mTextureSources[3];
|
||||
|
||||
RefPtr<CompositorD3D11> mCompositor;
|
||||
gfx::IntSize mSize;
|
||||
WindowsHandle mHandles[3];
|
||||
bool mIsLocked;
|
||||
|
@ -448,9 +453,7 @@ inline uint32_t GetMaxTextureSizeForFeatureLevel(D3D_FEATURE_LEVEL aFeatureLevel
|
|||
return maxTextureSize;
|
||||
}
|
||||
|
||||
uint32_t GetMaxTextureSizeFromDevice(ID3D11Device* aDevice);
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_GFX_TEXTURED3D11_H */
|
||||
|
|
|
@ -69,10 +69,8 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
|
|||
if (!compositable) {
|
||||
return false;
|
||||
}
|
||||
if (TextureSourceProvider* provider = compositable->GetTextureSourceProvider()) {
|
||||
if (!provider->IsValid()) {
|
||||
return false;
|
||||
}
|
||||
if (compositable->GetCompositor() && !compositable->GetCompositor()->IsValid()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (aEdit.detail().type()) {
|
||||
|
|
|
@ -873,15 +873,15 @@ LayerTransactionParent::Attach(Layer* aLayer,
|
|||
return false;
|
||||
}
|
||||
|
||||
TextureSourceProvider* provider =
|
||||
static_cast<HostLayerManager*>(aLayer->Manager())->GetTextureSourceProvider();
|
||||
Compositor* compositor
|
||||
= static_cast<HostLayerManager*>(aLayer->Manager())->GetCompositor();
|
||||
|
||||
if (!layer->SetCompositableHost(aCompositable)) {
|
||||
// not all layer types accept a compositable, see bug 967824
|
||||
return false;
|
||||
}
|
||||
aCompositable->Attach(aLayer,
|
||||
provider,
|
||||
compositor,
|
||||
aIsAsync
|
||||
? CompositableHost::ALLOW_REATTACH
|
||||
| CompositableHost::KEEP_ATTACHED
|
||||
|
|
|
@ -189,7 +189,6 @@ EXPORTS.mozilla.layers += [
|
|||
'RenderTrace.h',
|
||||
'SourceSurfaceSharedData.h',
|
||||
'SourceSurfaceVolatileData.h',
|
||||
'TextureSourceProvider.h',
|
||||
'TextureWrapperImage.h',
|
||||
'TransactionIdAllocator.h',
|
||||
'wr/WebRenderBridgeChild.h',
|
||||
|
@ -375,7 +374,6 @@ UNIFIED_SOURCES += [
|
|||
'ShareableCanvasLayer.cpp',
|
||||
'SourceSurfaceSharedData.cpp',
|
||||
'SourceSurfaceVolatileData.cpp',
|
||||
'TextureSourceProvider.cpp',
|
||||
'TextureWrapperImage.cpp',
|
||||
'wr/WebRenderBorderLayer.cpp',
|
||||
'wr/WebRenderBridgeChild.cpp',
|
||||
|
|
|
@ -212,8 +212,6 @@ public:
|
|||
virtual bool Resume() override;
|
||||
|
||||
GLContext* gl() const { return mGLContext; }
|
||||
GLContext* GetGLContext() const override { return mGLContext; }
|
||||
|
||||
/**
|
||||
* Clear the program state. This must be called
|
||||
* before operating on the GLContext directly. */
|
||||
|
|
|
@ -29,7 +29,7 @@ GLTextureSource*
|
|||
MacIOSurfaceTextureHostOGL::CreateTextureSourceForPlane(size_t aPlane)
|
||||
{
|
||||
GLuint textureHandle;
|
||||
gl::GLContext* gl = mProvider->GetGLContext();
|
||||
gl::GLContext* gl = mCompositor->gl();
|
||||
gl->fGenTextures(1, &textureHandle);
|
||||
gl->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, textureHandle);
|
||||
gl->fTexParameteri(LOCAL_GL_TEXTURE_RECTANGLE_ARB, LOCAL_GL_TEXTURE_WRAP_T, LOCAL_GL_CLAMP_TO_EDGE);
|
||||
|
@ -37,7 +37,7 @@ MacIOSurfaceTextureHostOGL::CreateTextureSourceForPlane(size_t aPlane)
|
|||
|
||||
mSurface->CGLTexImageIOSurface2D(gl::GLContextCGL::Cast(gl)->GetCGLContext(), aPlane);
|
||||
|
||||
return new GLTextureSource(mProvider, textureHandle, LOCAL_GL_TEXTURE_RECTANGLE_ARB,
|
||||
return new GLTextureSource(mCompositor, textureHandle, LOCAL_GL_TEXTURE_RECTANGLE_ARB,
|
||||
gfx::IntSize(mSurface->GetDevicePixelWidth(aPlane),
|
||||
mSurface->GetDevicePixelHeight(aPlane)),
|
||||
// XXX: This isn't really correct (but isn't used), we should be using the
|
||||
|
@ -66,20 +66,20 @@ MacIOSurfaceTextureHostOGL::Lock()
|
|||
}
|
||||
|
||||
void
|
||||
MacIOSurfaceTextureHostOGL::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
MacIOSurfaceTextureHostOGL::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
if (!aProvider || !aProvider->GetGLContext()) {
|
||||
CompositorOGL* glCompositor = AssertGLCompositor(aCompositor);
|
||||
if (!glCompositor) {
|
||||
mTextureSource = nullptr;
|
||||
mProvider = nullptr;
|
||||
mCompositor = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
if (mProvider != aProvider) {
|
||||
if (mCompositor != glCompositor) {
|
||||
// Cannot share GL texture identifiers across compositors.
|
||||
mTextureSource = nullptr;
|
||||
}
|
||||
|
||||
mProvider = aProvider;
|
||||
mCompositor = glCompositor;
|
||||
}
|
||||
|
||||
gfx::SurfaceFormat
|
||||
|
@ -104,7 +104,7 @@ MacIOSurfaceTextureHostOGL::GetSize() const {
|
|||
gl::GLContext*
|
||||
MacIOSurfaceTextureHostOGL::gl() const
|
||||
{
|
||||
return mProvider ? mProvider->GetGLContext() : nullptr;
|
||||
return mCompositor ? mCompositor->gl() : nullptr;
|
||||
}
|
||||
|
||||
MacIOSurfaceTextureSourceOGL::MacIOSurfaceTextureSourceOGL(
|
||||
|
@ -154,16 +154,11 @@ MacIOSurfaceTextureSourceOGL::BindTexture(GLenum aTextureUnit,
|
|||
}
|
||||
|
||||
void
|
||||
MacIOSurfaceTextureSourceOGL::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
MacIOSurfaceTextureSourceOGL::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
CompositorOGL* ogl = nullptr;
|
||||
if (Compositor* compositor = aProvider->AsCompositor()) {
|
||||
ogl = compositor->AsCompositorOGL();
|
||||
}
|
||||
|
||||
mCompositor = ogl;
|
||||
mCompositor = AssertGLCompositor(aCompositor);
|
||||
if (mCompositor && mNextSibling) {
|
||||
mNextSibling->SetTextureSourceProvider(aProvider);
|
||||
mNextSibling->SetCompositor(aCompositor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
// MacIOSurfaceTextureSourceOGL doesn't own any gl texture
|
||||
virtual void DeallocateDeviceData() override {}
|
||||
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
gl::GLContext* gl() const;
|
||||
|
||||
|
@ -72,7 +72,9 @@ public:
|
|||
// MacIOSurfaceTextureSourceOGL doesn't own any GL texture
|
||||
virtual void DeallocateDeviceData() override {}
|
||||
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
virtual Compositor* GetCompositor() override { return mCompositor; }
|
||||
|
||||
virtual bool Lock() override;
|
||||
|
||||
|
@ -101,6 +103,7 @@ public:
|
|||
protected:
|
||||
GLTextureSource* CreateTextureSourceForPlane(size_t aPlane);
|
||||
|
||||
RefPtr<CompositorOGL> mCompositor;
|
||||
RefPtr<GLTextureSource> mTextureSource;
|
||||
RefPtr<MacIOSurface> mSurface;
|
||||
};
|
||||
|
|
|
@ -121,7 +121,7 @@ TextureImageTextureSourceOGL::Update(gfx::DataSourceSurface* aSurface,
|
|||
nsIntRegion* aDestRegion,
|
||||
gfx::IntPoint* aSrcOffset)
|
||||
{
|
||||
GLContext *gl = mGL;
|
||||
GLContext *gl = mCompositor->gl();
|
||||
MOZ_ASSERT(gl);
|
||||
if (!gl || !gl->MakeCurrent()) {
|
||||
NS_WARNING("trying to update TextureImageTextureSourceOGL without a GLContext");
|
||||
|
@ -188,7 +188,7 @@ TextureImageTextureSourceOGL::EnsureBuffer(const IntSize& aSize,
|
|||
if (!mTexImage ||
|
||||
mTexImage->GetSize() != aSize ||
|
||||
mTexImage->GetContentType() != aContentType) {
|
||||
mTexImage = CreateTextureImage(mGL,
|
||||
mTexImage = CreateTextureImage(mCompositor->gl(),
|
||||
aSize,
|
||||
aContentType,
|
||||
LOCAL_GL_CLAMP_TO_EDGE,
|
||||
|
@ -198,13 +198,39 @@ TextureImageTextureSourceOGL::EnsureBuffer(const IntSize& aSize,
|
|||
}
|
||||
|
||||
void
|
||||
TextureImageTextureSourceOGL::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
TextureImageTextureSourceOGL::CopyTo(const gfx::IntRect& aSourceRect,
|
||||
DataTextureSource *aDest,
|
||||
const gfx::IntRect& aDestRect)
|
||||
{
|
||||
GLContext* newGL = aProvider ? aProvider->GetGLContext() : nullptr;
|
||||
if (!mGL) {
|
||||
mGL = newGL;
|
||||
} else if (mGL != newGL) {
|
||||
MOZ_ASSERT(aDest->AsSourceOGL(), "Incompatible destination type!");
|
||||
TextureImageTextureSourceOGL *dest =
|
||||
aDest->AsSourceOGL()->AsTextureImageTextureSource();
|
||||
MOZ_ASSERT(dest, "Incompatible destination type!");
|
||||
|
||||
mCompositor->BlitTextureImageHelper()->BlitTextureImage(mTexImage, aSourceRect,
|
||||
dest->mTexImage, aDestRect);
|
||||
dest->mTexImage->MarkValid();
|
||||
}
|
||||
|
||||
CompositorOGL* AssertGLCompositor(Compositor* aCompositor)
|
||||
{
|
||||
CompositorOGL* compositor = aCompositor ? aCompositor->AsCompositorOGL()
|
||||
: nullptr;
|
||||
MOZ_ASSERT(!!compositor);
|
||||
return compositor;
|
||||
}
|
||||
|
||||
void
|
||||
TextureImageTextureSourceOGL::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
CompositorOGL* glCompositor = AssertGLCompositor(aCompositor);
|
||||
if (!glCompositor) {
|
||||
DeallocateDeviceData();
|
||||
return;
|
||||
}
|
||||
if (mCompositor != glCompositor) {
|
||||
DeallocateDeviceData();
|
||||
mCompositor = glCompositor;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,19 +269,19 @@ TextureImageTextureSourceOGL::BindTexture(GLenum aTextureUnit,
|
|||
MOZ_ASSERT(mTexImage,
|
||||
"Trying to bind a TextureSource that does not have an underlying GL texture.");
|
||||
mTexImage->BindTexture(aTextureUnit);
|
||||
SetSamplingFilter(mGL, aSamplingFilter);
|
||||
SetSamplingFilter(mCompositor->gl(), aSamplingFilter);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// GLTextureSource
|
||||
|
||||
GLTextureSource::GLTextureSource(TextureSourceProvider* aProvider,
|
||||
GLTextureSource::GLTextureSource(CompositorOGL* aCompositor,
|
||||
GLuint aTextureHandle,
|
||||
GLenum aTarget,
|
||||
gfx::IntSize aSize,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
bool aExternallyOwned)
|
||||
: mGL(aProvider->GetGLContext())
|
||||
: mCompositor(aCompositor)
|
||||
, mTextureHandle(aTextureHandle)
|
||||
, mTextureTarget(aTarget)
|
||||
, mSize(aSize)
|
||||
|
@ -306,17 +332,20 @@ GLTextureSource::BindTexture(GLenum aTextureUnit,
|
|||
}
|
||||
|
||||
void
|
||||
GLTextureSource::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
GLTextureSource::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
GLContext* newGL = aProvider ? aProvider->GetGLContext() : nullptr;
|
||||
if (!newGL) {
|
||||
mGL = newGL;
|
||||
} else if (mGL != newGL) {
|
||||
gfxCriticalError() << "GLTextureSource does not support changing compositors";
|
||||
CompositorOGL* glCompositor = AssertGLCompositor(aCompositor);
|
||||
if (!glCompositor) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mCompositor && mCompositor != glCompositor) {
|
||||
gfxCriticalError() << "GLTextureSource does not support changing compositors";
|
||||
}
|
||||
mCompositor = glCompositor;
|
||||
|
||||
if (mNextSibling) {
|
||||
mNextSibling->SetTextureSourceProvider(aProvider);
|
||||
mNextSibling->SetCompositor(aCompositor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -326,19 +355,25 @@ GLTextureSource::IsValid() const
|
|||
return !!gl() && mTextureHandle != 0;
|
||||
}
|
||||
|
||||
gl::GLContext*
|
||||
GLTextureSource::gl() const
|
||||
{
|
||||
return mCompositor ? mCompositor->gl() : nullptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// SurfaceTextureHost
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
|
||||
SurfaceTextureSource::SurfaceTextureSource(TextureSourceProvider* aProvider,
|
||||
SurfaceTextureSource::SurfaceTextureSource(CompositorOGL* aCompositor,
|
||||
AndroidSurfaceTexture* aSurfTex,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
GLenum aTarget,
|
||||
GLenum aWrapMode,
|
||||
gfx::IntSize aSize)
|
||||
: mGL(aProvider->GetGLContext())
|
||||
: mCompositor(aCompositor)
|
||||
, mSurfTex(aSurfTex)
|
||||
, mFormat(aFormat)
|
||||
, mTextureTarget(aTarget)
|
||||
|
@ -370,15 +405,18 @@ SurfaceTextureSource::BindTexture(GLenum aTextureUnit,
|
|||
}
|
||||
|
||||
void
|
||||
SurfaceTextureSource::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
SurfaceTextureSource::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
GLContext* newGL = aProvider->GetGLContext();
|
||||
if (!newGL || mGL != newGL) {
|
||||
CompositorOGL* glCompositor = AssertGLCompositor(aCompositor);
|
||||
if (!glCompositor) {
|
||||
DeallocateDeviceData();
|
||||
return;
|
||||
}
|
||||
if (mCompositor != glCompositor) {
|
||||
DeallocateDeviceData();
|
||||
}
|
||||
|
||||
mGL = newGL;
|
||||
mCompositor = glCompositor;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -387,6 +425,12 @@ SurfaceTextureSource::IsValid() const
|
|||
return !!gl();
|
||||
}
|
||||
|
||||
gl::GLContext*
|
||||
SurfaceTextureSource::gl() const
|
||||
{
|
||||
return mCompositor ? mCompositor->gl() : nullptr;
|
||||
}
|
||||
|
||||
gfx::Matrix4x4
|
||||
SurfaceTextureSource::GetTextureTransform()
|
||||
{
|
||||
|
@ -412,6 +456,7 @@ SurfaceTextureHost::SurfaceTextureHost(TextureFlags aFlags,
|
|||
: TextureHost(aFlags)
|
||||
, mSurfTex(aSurfTex)
|
||||
, mSize(aSize)
|
||||
, mCompositor(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -422,7 +467,7 @@ SurfaceTextureHost::~SurfaceTextureHost()
|
|||
gl::GLContext*
|
||||
SurfaceTextureHost::gl() const
|
||||
{
|
||||
return mProvider ? mProvider->GetGLContext() : nullptr;
|
||||
return mCompositor ? mCompositor->gl() : nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -438,7 +483,7 @@ SurfaceTextureHost::Lock()
|
|||
gfx::SurfaceFormat format = gfx::SurfaceFormat::R8G8B8A8;
|
||||
GLenum target = LOCAL_GL_TEXTURE_EXTERNAL;
|
||||
GLenum wrapMode = LOCAL_GL_CLAMP_TO_EDGE;
|
||||
mTextureSource = new SurfaceTextureSource(mProvider,
|
||||
mTextureSource = new SurfaceTextureSource(mCompositor,
|
||||
mSurfTex,
|
||||
format,
|
||||
target,
|
||||
|
@ -457,18 +502,16 @@ SurfaceTextureHost::Unlock()
|
|||
}
|
||||
|
||||
void
|
||||
SurfaceTextureHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
SurfaceTextureHost::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
if (mProvider != aProvider) {
|
||||
if (!aProvider || !aProvider->GetGLContext()) {
|
||||
DeallocateDeviceData();
|
||||
return;
|
||||
}
|
||||
mProvider = aProvider;
|
||||
CompositorOGL* glCompositor = AssertGLCompositor(aCompositor);
|
||||
if (!glCompositor) {
|
||||
DeallocateDeviceData();
|
||||
return;
|
||||
}
|
||||
|
||||
mCompositor = glCompositor;
|
||||
if (mTextureSource) {
|
||||
mTextureSource->SetTextureSourceProvider(aProvider);
|
||||
mTextureSource->SetCompositor(glCompositor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -493,13 +536,14 @@ SurfaceTextureHost::DeallocateDeviceData()
|
|||
////////////////////////////////////////////////////////////////////////
|
||||
// EGLImage
|
||||
|
||||
EGLImageTextureSource::EGLImageTextureSource(TextureSourceProvider* aProvider,
|
||||
EGLImageTextureSource::EGLImageTextureSource(CompositorOGL* aCompositor,
|
||||
EGLImage aImage,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
GLenum aTarget,
|
||||
GLenum aWrapMode,
|
||||
gfx::IntSize aSize)
|
||||
: mImage(aImage)
|
||||
: mCompositor(aCompositor)
|
||||
, mImage(aImage)
|
||||
, mFormat(aFormat)
|
||||
, mTextureTarget(aTarget)
|
||||
, mWrapMode(aWrapMode)
|
||||
|
@ -507,7 +551,6 @@ EGLImageTextureSource::EGLImageTextureSource(TextureSourceProvider* aProvider,
|
|||
{
|
||||
MOZ_ASSERT(mTextureTarget == LOCAL_GL_TEXTURE_2D ||
|
||||
mTextureTarget == LOCAL_GL_TEXTURE_EXTERNAL);
|
||||
SetTextureSourceProvider(aProvider);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -534,22 +577,9 @@ EGLImageTextureSource::BindTexture(GLenum aTextureUnit,
|
|||
}
|
||||
|
||||
void
|
||||
EGLImageTextureSource::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
EGLImageTextureSource::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
if (mCompositor == aProvider) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!aProvider) {
|
||||
mGL = nullptr;
|
||||
mCompositor = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
mGL = aProvider->GetGLContext();
|
||||
if (Compositor* compositor = aProvider->AsCompositor()) {
|
||||
mCompositor = compositor->AsCompositorOGL();
|
||||
}
|
||||
mCompositor = AssertGLCompositor(aCompositor);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -558,6 +588,12 @@ EGLImageTextureSource::IsValid() const
|
|||
return !!gl();
|
||||
}
|
||||
|
||||
gl::GLContext*
|
||||
EGLImageTextureSource::gl() const
|
||||
{
|
||||
return mCompositor ? mCompositor->gl() : nullptr;
|
||||
}
|
||||
|
||||
gfx::Matrix4x4
|
||||
EGLImageTextureSource::GetTextureTransform()
|
||||
{
|
||||
|
@ -577,6 +613,7 @@ EGLImageTextureHost::EGLImageTextureHost(TextureFlags aFlags,
|
|||
, mSync(aSync)
|
||||
, mSize(aSize)
|
||||
, mHasAlpha(hasAlpha)
|
||||
, mCompositor(nullptr)
|
||||
{}
|
||||
|
||||
EGLImageTextureHost::~EGLImageTextureHost()
|
||||
|
@ -585,7 +622,7 @@ EGLImageTextureHost::~EGLImageTextureHost()
|
|||
gl::GLContext*
|
||||
EGLImageTextureHost::gl() const
|
||||
{
|
||||
return mProvider ? mProvider ->GetGLContext() : nullptr;
|
||||
return mCompositor ? mCompositor->gl() : nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -614,7 +651,7 @@ EGLImageTextureHost::Lock()
|
|||
: gfx::SurfaceFormat::R8G8B8X8;
|
||||
GLenum target = gl->GetPreferredEGLImageTextureTarget();
|
||||
GLenum wrapMode = LOCAL_GL_CLAMP_TO_EDGE;
|
||||
mTextureSource = new EGLImageTextureSource(mProvider,
|
||||
mTextureSource = new EGLImageTextureSource(mCompositor,
|
||||
mImage,
|
||||
format,
|
||||
target,
|
||||
|
@ -631,19 +668,17 @@ EGLImageTextureHost::Unlock()
|
|||
}
|
||||
|
||||
void
|
||||
EGLImageTextureHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
EGLImageTextureHost::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
if (mProvider != aProvider) {
|
||||
if (!aProvider || !aProvider->GetGLContext()) {
|
||||
mProvider = nullptr;
|
||||
mTextureSource = nullptr;
|
||||
return;
|
||||
}
|
||||
mProvider = aProvider;
|
||||
CompositorOGL* glCompositor = AssertGLCompositor(aCompositor);
|
||||
if (!glCompositor) {
|
||||
mCompositor = nullptr;
|
||||
mTextureSource = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
mCompositor = glCompositor;
|
||||
if (mTextureSource) {
|
||||
mTextureSource->SetTextureSourceProvider(aProvider);
|
||||
mTextureSource->SetCompositor(glCompositor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -668,6 +703,7 @@ GLTextureHost::GLTextureHost(TextureFlags aFlags,
|
|||
, mSync(aSync)
|
||||
, mSize(aSize)
|
||||
, mHasAlpha(aHasAlpha)
|
||||
, mCompositor(nullptr)
|
||||
{}
|
||||
|
||||
GLTextureHost::~GLTextureHost()
|
||||
|
@ -676,7 +712,7 @@ GLTextureHost::~GLTextureHost()
|
|||
gl::GLContext*
|
||||
GLTextureHost::gl() const
|
||||
{
|
||||
return mProvider ? mProvider->GetGLContext() : nullptr;
|
||||
return mCompositor ? mCompositor->gl() : nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -699,7 +735,7 @@ GLTextureHost::Lock()
|
|||
if (!mTextureSource) {
|
||||
gfx::SurfaceFormat format = mHasAlpha ? gfx::SurfaceFormat::R8G8B8A8
|
||||
: gfx::SurfaceFormat::R8G8B8X8;
|
||||
mTextureSource = new GLTextureSource(mProvider,
|
||||
mTextureSource = new GLTextureSource(mCompositor,
|
||||
mTexture,
|
||||
mTarget,
|
||||
mSize,
|
||||
|
@ -709,21 +745,18 @@ GLTextureHost::Lock()
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
GLTextureHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
GLTextureHost::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
if (mProvider != aProvider) {
|
||||
if (!aProvider || !aProvider->GetGLContext()) {
|
||||
mProvider = nullptr;
|
||||
mTextureSource = nullptr;
|
||||
return;
|
||||
}
|
||||
mProvider = aProvider;
|
||||
CompositorOGL* glCompositor = AssertGLCompositor(aCompositor);
|
||||
if (!glCompositor) {
|
||||
mCompositor = nullptr;
|
||||
mTextureSource = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
mCompositor = glCompositor;
|
||||
if (mTextureSource) {
|
||||
mTextureSource->SetTextureSourceProvider(aProvider);
|
||||
mTextureSource->SetCompositor(glCompositor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ class TextureImageTextureSourceOGL final : public DataTextureSource
|
|||
public:
|
||||
explicit TextureImageTextureSourceOGL(CompositorOGL *aCompositor,
|
||||
TextureFlags aFlags = TextureFlags::DEFAULT)
|
||||
: mGL(aCompositor->gl())
|
||||
: mCompositor(aCompositor)
|
||||
, mFlags(aFlags)
|
||||
, mIterating(false)
|
||||
{}
|
||||
|
@ -152,6 +152,10 @@ public:
|
|||
void EnsureBuffer(const gfx::IntSize& aSize,
|
||||
gfxContentType aContentType);
|
||||
|
||||
void CopyTo(const gfx::IntRect& aSourceRect,
|
||||
DataTextureSource* aDest,
|
||||
const gfx::IntRect& aDestRect);
|
||||
|
||||
virtual TextureImageTextureSourceOGL* AsTextureImageTextureSource() override { return this; }
|
||||
|
||||
// TextureSource
|
||||
|
@ -173,7 +177,7 @@ public:
|
|||
|
||||
virtual bool IsValid() const override { return !!mTexImage; }
|
||||
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
virtual GLenum GetWrapMode() const override
|
||||
{
|
||||
|
@ -209,7 +213,7 @@ public:
|
|||
|
||||
protected:
|
||||
RefPtr<gl::TextureImage> mTexImage;
|
||||
RefPtr<gl::GLContext> mGL;
|
||||
RefPtr<CompositorOGL> mCompositor;
|
||||
TextureFlags mFlags;
|
||||
bool mIterating;
|
||||
};
|
||||
|
@ -226,7 +230,7 @@ class GLTextureSource : public TextureSource
|
|||
, public TextureSourceOGL
|
||||
{
|
||||
public:
|
||||
GLTextureSource(TextureSourceProvider* aProvider,
|
||||
GLTextureSource(CompositorOGL* aCompositor,
|
||||
GLuint aTextureHandle,
|
||||
GLenum aTarget,
|
||||
gfx::IntSize aSize,
|
||||
|
@ -256,7 +260,7 @@ public:
|
|||
|
||||
virtual void DeallocateDeviceData() override;
|
||||
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
void SetSize(gfx::IntSize aSize) { mSize = aSize; }
|
||||
|
||||
|
@ -264,14 +268,11 @@ public:
|
|||
|
||||
GLuint GetTextureHandle() const { return mTextureHandle; }
|
||||
|
||||
gl::GLContext* gl() const {
|
||||
return mGL;
|
||||
}
|
||||
gl::GLContext* gl() const;
|
||||
|
||||
protected:
|
||||
void DeleteTextureHandle();
|
||||
|
||||
RefPtr<gl::GLContext> mGL;
|
||||
RefPtr<CompositorOGL> mCompositor;
|
||||
GLuint mTextureHandle;
|
||||
GLenum mTextureTarget;
|
||||
|
@ -297,7 +298,9 @@ public:
|
|||
// We don't own anything.
|
||||
virtual void DeallocateDeviceData() override {}
|
||||
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
virtual Compositor* GetCompositor() override { return mCompositor; }
|
||||
|
||||
virtual bool Lock() override;
|
||||
|
||||
|
@ -328,6 +331,7 @@ protected:
|
|||
GLsync mSync;
|
||||
const gfx::IntSize mSize;
|
||||
const bool mHasAlpha;
|
||||
RefPtr<CompositorOGL> mCompositor;
|
||||
RefPtr<GLTextureSource> mTextureSource;
|
||||
};
|
||||
|
||||
|
@ -340,7 +344,7 @@ class SurfaceTextureSource : public TextureSource
|
|||
, public TextureSourceOGL
|
||||
{
|
||||
public:
|
||||
SurfaceTextureSource(TextureSourceProvider* aProvider,
|
||||
SurfaceTextureSource(CompositorOGL* aCompositor,
|
||||
mozilla::gl::AndroidSurfaceTexture* aSurfTex,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
GLenum aTarget,
|
||||
|
@ -368,14 +372,12 @@ public:
|
|||
|
||||
virtual void DeallocateDeviceData() override;
|
||||
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
gl::GLContext* gl() const {
|
||||
return mGL;
|
||||
}
|
||||
gl::GLContext* gl() const;
|
||||
|
||||
protected:
|
||||
RefPtr<gl::GLContext> mGL;
|
||||
RefPtr<CompositorOGL> mCompositor;
|
||||
RefPtr<gl::AndroidSurfaceTexture> mSurfTex;
|
||||
const gfx::SurfaceFormat mFormat;
|
||||
const GLenum mTextureTarget;
|
||||
|
@ -394,7 +396,9 @@ public:
|
|||
|
||||
virtual void DeallocateDeviceData() override;
|
||||
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
virtual Compositor* GetCompositor() override { return mCompositor; }
|
||||
|
||||
virtual bool Lock() override;
|
||||
|
||||
|
@ -435,7 +439,7 @@ class EGLImageTextureSource : public TextureSource
|
|||
, public TextureSourceOGL
|
||||
{
|
||||
public:
|
||||
EGLImageTextureSource(TextureSourceProvider* aProvider,
|
||||
EGLImageTextureSource(CompositorOGL* aCompositor,
|
||||
EGLImage aImage,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
GLenum aTarget,
|
||||
|
@ -464,14 +468,11 @@ public:
|
|||
// We don't own anything.
|
||||
virtual void DeallocateDeviceData() override {}
|
||||
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
gl::GLContext* gl() const {
|
||||
return mGL;
|
||||
}
|
||||
gl::GLContext* gl() const;
|
||||
|
||||
protected:
|
||||
RefPtr<gl::GLContext> mGL;
|
||||
RefPtr<CompositorOGL> mCompositor;
|
||||
const EGLImage mImage;
|
||||
const gfx::SurfaceFormat mFormat;
|
||||
|
@ -480,7 +481,7 @@ protected:
|
|||
const gfx::IntSize mSize;
|
||||
};
|
||||
|
||||
class EGLImageTextureHost final : public TextureHost
|
||||
class EGLImageTextureHost : public TextureHost
|
||||
{
|
||||
public:
|
||||
EGLImageTextureHost(TextureFlags aFlags,
|
||||
|
@ -494,7 +495,9 @@ public:
|
|||
// We don't own anything.
|
||||
virtual void DeallocateDeviceData() override {}
|
||||
|
||||
void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
virtual Compositor* GetCompositor() override { return mCompositor; }
|
||||
|
||||
virtual bool Lock() override;
|
||||
|
||||
|
@ -524,9 +527,12 @@ protected:
|
|||
const EGLSync mSync;
|
||||
const gfx::IntSize mSize;
|
||||
const bool mHasAlpha;
|
||||
RefPtr<CompositorOGL> mCompositor;
|
||||
RefPtr<EGLImageTextureSource> mTextureSource;
|
||||
};
|
||||
|
||||
CompositorOGL* AssertGLCompositor(Compositor* aCompositor);
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace layers {
|
|||
using namespace mozilla::gfx;
|
||||
|
||||
X11TextureSourceOGL::X11TextureSourceOGL(CompositorOGL* aCompositor, gfxXlibSurface* aSurface)
|
||||
: mGL(aCompositor->gl())
|
||||
: mCompositor(aCompositor)
|
||||
, mSurface(aSurface)
|
||||
, mTexture(0)
|
||||
, mUpdated(false)
|
||||
|
@ -75,13 +75,22 @@ X11TextureSourceOGL::GetFormat() const {
|
|||
}
|
||||
|
||||
void
|
||||
X11TextureSourceOGL::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
X11TextureSourceOGL::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
gl::GLContext* newGL = aProvider ? aProvider->GetGLContext() : nullptr;
|
||||
if (mGL != newGL) {
|
||||
DeallocateDeviceData();
|
||||
CompositorOGL* glCompositor = AssertGLCompositor(aCompositor);
|
||||
if (mCompositor == glCompositor) {
|
||||
return;
|
||||
}
|
||||
mGL = newGL;
|
||||
DeallocateDeviceData();
|
||||
if (glCompositor) {
|
||||
mCompositor = glCompositor;
|
||||
}
|
||||
}
|
||||
|
||||
gl::GLContext*
|
||||
X11TextureSourceOGL::gl() const
|
||||
{
|
||||
return mCompositor ? mCompositor->gl() : nullptr;
|
||||
}
|
||||
|
||||
SurfaceFormat
|
||||
|
|
|
@ -41,18 +41,16 @@ public:
|
|||
|
||||
virtual void DeallocateDeviceData() override;
|
||||
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
virtual void Updated() override { mUpdated = true; }
|
||||
|
||||
gl::GLContext* gl() const {
|
||||
return mGL;
|
||||
}
|
||||
gl::GLContext* gl() const;
|
||||
|
||||
static gfx::SurfaceFormat ContentTypeToSurfaceFormat(gfxContentType aType);
|
||||
|
||||
protected:
|
||||
RefPtr<gl::GLContext> mGL;
|
||||
RefPtr<CompositorOGL> mCompositor;
|
||||
RefPtr<gfxXlibSurface> mSurface;
|
||||
RefPtr<gfx::SourceSurface> mSourceSurface;
|
||||
GLuint mTexture;
|
||||
|
|
|
@ -107,15 +107,14 @@ WebRenderImageHost::GetAsTextureHost(IntRect* aPictureRect)
|
|||
}
|
||||
|
||||
void WebRenderImageHost::Attach(Layer* aLayer,
|
||||
TextureSourceProvider* aProvider,
|
||||
Compositor* aCompositor,
|
||||
AttachFlags aFlags)
|
||||
{
|
||||
MOZ_ASSERT_UNREACHABLE("unexpected to be called");
|
||||
}
|
||||
|
||||
void
|
||||
WebRenderImageHost::Composite(Compositor* aCompositor,
|
||||
LayerComposite* aLayer,
|
||||
WebRenderImageHost::Composite(LayerComposite* aLayer,
|
||||
EffectChain& aEffectChain,
|
||||
float aOpacity,
|
||||
const gfx::Matrix4x4& aTransform,
|
||||
|
@ -128,14 +127,14 @@ WebRenderImageHost::Composite(Compositor* aCompositor,
|
|||
}
|
||||
|
||||
void
|
||||
WebRenderImageHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
||||
WebRenderImageHost::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
if (mTextureSourceProvider != aProvider) {
|
||||
if (mCompositor != aCompositor) {
|
||||
for (auto& img : mImages) {
|
||||
img.mTextureHost->SetTextureSourceProvider(aProvider);
|
||||
img.mTextureHost->SetCompositor(aCompositor);
|
||||
}
|
||||
}
|
||||
CompositableHost::SetTextureSourceProvider(aProvider);
|
||||
CompositableHost::SetCompositor(aCompositor);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -24,8 +24,7 @@ public:
|
|||
|
||||
virtual CompositableType GetType() override { return mTextureInfo.mCompositableType; }
|
||||
|
||||
virtual void Composite(Compositor* aCompositor,
|
||||
LayerComposite* aLayer,
|
||||
virtual void Composite(LayerComposite* aLayer,
|
||||
EffectChain& aEffectChain,
|
||||
float aOpacity,
|
||||
const gfx::Matrix4x4& aTransform,
|
||||
|
@ -42,10 +41,10 @@ public:
|
|||
virtual TextureHost* GetAsTextureHost(gfx::IntRect* aPictureRect = nullptr) override;
|
||||
|
||||
virtual void Attach(Layer* aLayer,
|
||||
TextureSourceProvider* aProvider,
|
||||
Compositor* aCompositor,
|
||||
AttachFlags aFlags = NO_FLAGS) override;
|
||||
|
||||
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
gfx::IntSize GetImageSize() const override;
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ CheckCompatibilityWithBasicCompositor(LayersBackend aBackends,
|
|||
if (!aTextures[i]) {
|
||||
continue;
|
||||
}
|
||||
aTextures[i]->SetTextureSourceProvider(compositor);
|
||||
aTextures[i]->SetCompositor(compositor);
|
||||
|
||||
// The lock function will fail if the texture is not compatible with
|
||||
// BasicCompositor.
|
||||
|
|
Загрузка…
Ссылка в новой задаче