mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 870211 - Make TextureHosts support updating from partial surfaces. r=Bas
This commit is contained in:
parent
09f575f155
commit
614b6071f2
@ -34,7 +34,8 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion *aRegion) MOZ_OVERRIDE
|
||||
nsIntRegion *aRegion,
|
||||
nsIntPoint*) MOZ_OVERRIDE
|
||||
{
|
||||
AutoOpenSurface surf(OPEN_READ_ONLY, aImage);
|
||||
mFormat =
|
||||
|
@ -89,9 +89,10 @@ TextureHost::~TextureHost()
|
||||
|
||||
void
|
||||
TextureHost::Update(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion* aRegion)
|
||||
nsIntRegion* aRegion,
|
||||
nsIntPoint* aOffset)
|
||||
{
|
||||
UpdateImpl(aImage, aRegion);
|
||||
UpdateImpl(aImage, aRegion, aOffset);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -174,9 +174,14 @@ public:
|
||||
|
||||
/**
|
||||
* Update the texture host using the data from aSurfaceDescriptor.
|
||||
*
|
||||
* @param aImage Source image to update with.
|
||||
* @param aRegion Region of the texture host to update.
|
||||
* @param aOffset Offset in the source to update from
|
||||
*/
|
||||
void Update(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion *aRegion = nullptr);
|
||||
nsIntRegion *aRegion = nullptr,
|
||||
nsIntPoint* aOffset = nullptr);
|
||||
|
||||
/**
|
||||
* Change the current surface of the texture host to aImage. aResult will return
|
||||
@ -247,8 +252,35 @@ public:
|
||||
virtual void PrintInfo(nsACString& aTo, const char* aPrefix);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* TEMPORARY.
|
||||
*
|
||||
* Ensure that a buffer of the given size/type has been allocated so that
|
||||
* we can update it using Update and/or CopyTo.
|
||||
*/
|
||||
virtual void EnsureBuffer(const nsIntSize& aSize, gfxASurface::gfxContentType aType)
|
||||
{
|
||||
NS_RUNTIMEABORT("TextureHost doesn't support EnsureBuffer");
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the contents of this TextureHost to aDest. aDest must already
|
||||
* have a suitable buffer allocated using EnsureBuffer.
|
||||
*
|
||||
* @param aSourceRect Area of this texture host to copy.
|
||||
* @param aDest Destination texture host.
|
||||
* @param aDestRect Destination rect.
|
||||
*/
|
||||
virtual void CopyTo(const nsIntRect& aSourceRect,
|
||||
TextureHost *aDest,
|
||||
const nsIntRect& aDestRect)
|
||||
{
|
||||
NS_RUNTIMEABORT("TextureHost doesn't support CopyTo");
|
||||
}
|
||||
|
||||
|
||||
SurfaceDescriptor* GetBuffer() const { return mBuffer; }
|
||||
|
||||
/**
|
||||
* Set a SurfaceDescriptor for this texture host. By setting a buffer and
|
||||
* allocator/de-allocator for the TextureHost, you cause the TextureHost to
|
||||
@ -276,7 +308,8 @@ protected:
|
||||
* to be thread-safe.
|
||||
*/
|
||||
virtual void UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion *aRegion)
|
||||
nsIntRegion *aRegion,
|
||||
nsIntPoint *aOffset = nullptr)
|
||||
{
|
||||
NS_RUNTIMEABORT("Should not be reached");
|
||||
}
|
||||
@ -293,7 +326,7 @@ protected:
|
||||
virtual void SwapTexturesImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion *aRegion)
|
||||
{
|
||||
UpdateImpl(aImage, aRegion);
|
||||
UpdateImpl(aImage, aRegion, nullptr);
|
||||
}
|
||||
|
||||
// An internal identifier for this texture host. Two texture hosts
|
||||
|
@ -295,7 +295,9 @@ TextureHostShmemD3D11::SetCompositor(Compositor* aCompositor)
|
||||
}
|
||||
|
||||
void
|
||||
TextureHostShmemD3D11::UpdateImpl(const SurfaceDescriptor& aImage, nsIntRegion *aRegion)
|
||||
TextureHostShmemD3D11::UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion *aRegion,
|
||||
nsIntPoint *aOffset)
|
||||
{
|
||||
MOZ_ASSERT(aImage.type() == SurfaceDescriptor::TShmem);
|
||||
|
||||
@ -404,7 +406,9 @@ TextureHostDXGID3D11::Unlock()
|
||||
}
|
||||
|
||||
void
|
||||
TextureHostDXGID3D11::UpdateImpl(const SurfaceDescriptor& aImage, nsIntRegion *aRegion)
|
||||
TextureHostDXGID3D11::UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion *aRegion,
|
||||
nsIntPoint *aOffset)
|
||||
{
|
||||
MOZ_ASSERT(aImage.type() == SurfaceDescriptor::TSurfaceDescriptorD3D10);
|
||||
|
||||
@ -450,7 +454,9 @@ TextureHostYCbCrD3D11::GetSize() const
|
||||
}
|
||||
|
||||
void
|
||||
TextureHostYCbCrD3D11::UpdateImpl(const SurfaceDescriptor& aImage, nsIntRegion *aRegion)
|
||||
TextureHostYCbCrD3D11::UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion *aRegion,
|
||||
nsIntPoint *aOffset)
|
||||
{
|
||||
MOZ_ASSERT(aImage.type() == SurfaceDescriptor::TYCbCrImage);
|
||||
|
||||
|
@ -144,7 +144,8 @@ public:
|
||||
}
|
||||
protected:
|
||||
virtual void UpdateImpl(const SurfaceDescriptor& aSurface,
|
||||
nsIntRegion* aRegion) MOZ_OVERRIDE;
|
||||
nsIntRegion* aRegion,
|
||||
nsIntPoint *aOffset = nullptr) MOZ_OVERRIDE;
|
||||
private:
|
||||
|
||||
gfx::IntRect GetTileRect(uint32_t aID) const;
|
||||
@ -180,7 +181,8 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void UpdateImpl(const SurfaceDescriptor& aSurface,
|
||||
nsIntRegion* aRegion) MOZ_OVERRIDE;
|
||||
nsIntRegion* aRegion,
|
||||
nsIntPoint* aOffset = nullptr) MOZ_OVERRIDE;
|
||||
private:
|
||||
void LockTexture();
|
||||
void ReleaseTexture();
|
||||
@ -214,7 +216,8 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void UpdateImpl(const SurfaceDescriptor& aSurface,
|
||||
nsIntRegion* aRegion) MOZ_OVERRIDE;
|
||||
nsIntRegion* aRegion,
|
||||
nsIntPoint* aOffset = nullptr) MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
RefPtr<ID3D11Device> mDevice;
|
||||
|
@ -159,9 +159,40 @@ TextureImageTextureHostOGL::SetCompositor(Compositor* aCompositor)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TextureImageTextureHostOGL::EnsureBuffer(const nsIntSize& aSize,
|
||||
gfxContentType aContentType)
|
||||
{
|
||||
if (!mTexture ||
|
||||
mTexture->GetSize() != aSize ||
|
||||
mTexture->GetContentType() != aContentType) {
|
||||
mTexture = mGL->CreateTextureImage(aSize,
|
||||
aContentType,
|
||||
WrapMode(mGL, mFlags & AllowRepeat),
|
||||
FlagsToGLFlags(mFlags));
|
||||
}
|
||||
mTexture->Resize(aSize);
|
||||
}
|
||||
|
||||
void
|
||||
TextureImageTextureHostOGL::CopyTo(const nsIntRect& aSourceRect,
|
||||
TextureHost *aDest,
|
||||
const nsIntRect& aDestRect)
|
||||
{
|
||||
MOZ_ASSERT(aDest->AsSourceOGL(), "Incompatible destination type!");
|
||||
TextureImageTextureHostOGL *dest =
|
||||
aDest->AsSourceOGL()->AsTextureImageTextureHost();
|
||||
MOZ_ASSERT(dest, "Incompatible destination type!");
|
||||
|
||||
mGL->BlitTextureImage(mTexture, aSourceRect,
|
||||
dest->mTexture, aDestRect);
|
||||
dest->mTexture->MarkValid();
|
||||
}
|
||||
|
||||
void
|
||||
TextureImageTextureHostOGL::UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion* aRegion)
|
||||
nsIntRegion* aRegion,
|
||||
nsIntPoint* aOffset)
|
||||
{
|
||||
if (!mGL) {
|
||||
NS_WARNING("trying to update TextureImageTextureHostOGL without a compositor?");
|
||||
@ -171,7 +202,7 @@ TextureImageTextureHostOGL::UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntSize size = surf.Size();
|
||||
|
||||
if (!mTexture ||
|
||||
mTexture->GetSize() != size ||
|
||||
(mTexture->GetSize() != size && !aOffset) ||
|
||||
mTexture->GetContentType() != surf.ContentType()) {
|
||||
mTexture = mGL->CreateTextureImage(size,
|
||||
surf.ContentType(),
|
||||
@ -187,7 +218,12 @@ TextureImageTextureHostOGL::UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
} else {
|
||||
updateRegion = *aRegion;
|
||||
}
|
||||
mTexture->DirectUpdate(surf.Get(), updateRegion);
|
||||
nsIntPoint offset;
|
||||
if (aOffset) {
|
||||
offset = *aOffset;
|
||||
}
|
||||
mTexture->DirectUpdate(surf.Get(), updateRegion, offset);
|
||||
mFormat = FormatFromShaderType(mTexture->GetShaderProgramType());
|
||||
|
||||
if (mTexture->InUpdate()) {
|
||||
mTexture->EndUpdate();
|
||||
@ -237,7 +273,8 @@ SharedTextureHostOGL::DeleteTextures()
|
||||
|
||||
void
|
||||
SharedTextureHostOGL::UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion* aRegion)
|
||||
nsIntRegion* aRegion,
|
||||
nsIntPoint* aOffset)
|
||||
{
|
||||
SwapTexturesImpl(aImage, aRegion);
|
||||
}
|
||||
@ -446,7 +483,8 @@ YCbCrTextureHostOGL::SetCompositor(Compositor* aCompositor)
|
||||
|
||||
void
|
||||
YCbCrTextureHostOGL::UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion* aRegion)
|
||||
nsIntRegion* aRegion,
|
||||
nsIntPoint* aOffset)
|
||||
{
|
||||
if (!mGL) {
|
||||
return;
|
||||
@ -701,7 +739,8 @@ RegisterTextureHostAtGrallocBufferActor(TextureHost* aTextureHost, const Surface
|
||||
|
||||
void
|
||||
GrallocTextureHostOGL::UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion* aRegion)
|
||||
nsIntRegion* aRegion,
|
||||
nsIntPoint* aOffset)
|
||||
{
|
||||
SwapTexturesImpl(aImage, aRegion);
|
||||
}
|
||||
|
@ -20,6 +20,8 @@
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
class TextureImageTextureHostOGL;
|
||||
|
||||
/*
|
||||
* TextureHost implementations for the OpenGL backend.
|
||||
*
|
||||
@ -52,6 +54,8 @@ public:
|
||||
virtual GLenum GetTextureTarget() const { return LOCAL_GL_TEXTURE_2D; }
|
||||
virtual GLenum GetWrapMode() const = 0;// { return LOCAL_GL_CLAMP_TO_EDGE; } // default
|
||||
virtual gfx3DMatrix GetTextureTransform() { return gfx3DMatrix(); }
|
||||
|
||||
virtual TextureImageTextureHostOGL* AsTextureImageTextureHost() { return nullptr; }
|
||||
};
|
||||
|
||||
inline gl::ShaderProgramType
|
||||
@ -94,6 +98,11 @@ public:
|
||||
return this;
|
||||
}
|
||||
|
||||
virtual TextureImageTextureHostOGL* AsTextureImageTextureHost() MOZ_OVERRIDE
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
// This is a hack that is here to not break on-main-thread ThebesLayerBuffer
|
||||
// please do not use it anywhere else, use SetCompositor instead.
|
||||
void SetGLContext(gl::GLContext* aGL)
|
||||
@ -104,10 +113,17 @@ public:
|
||||
// TextureHost
|
||||
|
||||
void UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion* aRegion = nullptr) MOZ_OVERRIDE;
|
||||
nsIntRegion* aRegion = nullptr,
|
||||
nsIntPoint* aOffset = nullptr) MOZ_OVERRIDE;
|
||||
|
||||
virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
|
||||
|
||||
virtual void EnsureBuffer(const nsIntSize& aSize, gfxContentType aType) MOZ_OVERRIDE;
|
||||
|
||||
virtual void CopyTo(const nsIntRect& aSourceRect,
|
||||
TextureHost *aDest,
|
||||
const nsIntRect& aDestRect) MOZ_OVERRIDE;
|
||||
|
||||
bool IsValid() const MOZ_OVERRIDE
|
||||
{
|
||||
return !!mTexture;
|
||||
@ -219,7 +235,8 @@ public:
|
||||
virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
|
||||
|
||||
virtual void UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion* aRegion = nullptr) MOZ_OVERRIDE;
|
||||
nsIntRegion* aRegion = nullptr,
|
||||
nsIntPoint* aOffset = nullptr) MOZ_OVERRIDE;
|
||||
|
||||
virtual bool Lock() MOZ_OVERRIDE;
|
||||
|
||||
@ -327,7 +344,8 @@ public:
|
||||
// override from TextureHost, we support both buffered
|
||||
// and unbuffered operation.
|
||||
virtual void UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion* aRegion = nullptr) MOZ_OVERRIDE;
|
||||
nsIntRegion* aRegion = nullptr,
|
||||
nsIntPoint* aOffset = nullptr) MOZ_OVERRIDE;
|
||||
virtual void SwapTexturesImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion* aRegion = nullptr) MOZ_OVERRIDE;
|
||||
virtual bool Lock() MOZ_OVERRIDE;
|
||||
@ -559,7 +577,8 @@ public:
|
||||
}
|
||||
|
||||
virtual void UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion* aRegion = nullptr) MOZ_OVERRIDE;
|
||||
nsIntRegion* aRegion = nullptr,
|
||||
nsIntPoint* aOffset = nullptr) MOZ_OVERRIDE;
|
||||
virtual void SwapTexturesImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion* aRegion = nullptr) MOZ_OVERRIDE;
|
||||
virtual bool Lock() MOZ_OVERRIDE;
|
||||
|
Loading…
Reference in New Issue
Block a user