mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-25 03:49:42 +00:00
Bug 907792 - Use SharedTextureClientOG for SharedTextureImage. r=nical
This commit is contained in:
parent
64e549b0dc
commit
709eb0737a
@ -26,6 +26,7 @@
|
||||
#include "mozilla/layers/SharedPlanarYCbCrImage.h"
|
||||
#include "mozilla/layers/SharedRGBImage.h"
|
||||
#include "mozilla/layers/TextureClient.h" // for TextureClient, etc
|
||||
#include "mozilla/layers/TextureClientOGL.h" // for SharedTextureClientOGL
|
||||
#include "mozilla/mozalloc.h" // for operator delete, etc
|
||||
#include "nsAutoPtr.h" // for nsRefPtr
|
||||
#include "nsCOMPtr.h" // for already_AddRefed
|
||||
@ -164,6 +165,22 @@ ImageClientSingle::UpdateImage(ImageContainer* aContainer,
|
||||
return false;
|
||||
}
|
||||
|
||||
} else if (image->GetFormat() == SHARED_TEXTURE) {
|
||||
SharedTextureImage* sharedImage = static_cast<SharedTextureImage*>(image);
|
||||
const SharedTextureImage::Data *data = sharedImage->GetData();
|
||||
gfx::IntSize size = gfx::IntSize(image->GetSize().width, image->GetSize().height);
|
||||
|
||||
if (mFrontBuffer) {
|
||||
RemoveTextureClient(mFrontBuffer);
|
||||
mFrontBuffer = nullptr;
|
||||
}
|
||||
|
||||
RefPtr<SharedTextureClientOGL> buffer = new SharedTextureClientOGL(mTextureFlags);
|
||||
buffer->InitWith(data->mHandle, size, data->mShareType, data->mInverted);
|
||||
mFrontBuffer = buffer;
|
||||
|
||||
AddTextureClient(mFrontBuffer);
|
||||
GetForwarder()->UseTexture(this, mFrontBuffer);
|
||||
} else {
|
||||
nsRefPtr<gfxASurface> surface = image->GetAsSurface();
|
||||
MOZ_ASSERT(surface);
|
||||
|
@ -292,7 +292,6 @@ protected:
|
||||
size_t mBufSize;
|
||||
};
|
||||
|
||||
|
||||
struct TextureClientAutoUnlock
|
||||
{
|
||||
TextureClient* mTexture;
|
||||
|
@ -16,16 +16,18 @@ namespace layers {
|
||||
|
||||
class CompositableForwarder;
|
||||
|
||||
SharedTextureClientOGL::SharedTextureClientOGL()
|
||||
: mHandle(0)
|
||||
, mIsCrossProcess(false)
|
||||
SharedTextureClientOGL::SharedTextureClientOGL(TextureFlags aFlags)
|
||||
: TextureClient(aFlags)
|
||||
, mHandle(0)
|
||||
, mInverted(false)
|
||||
{
|
||||
MOZ_ASSERT(!(aFlags & (TEXTURE_DEALLOCATE_CLIENT|TEXTURE_DEALLOCATE_HOST)),
|
||||
"SharedTextureClientOGL doesn't know how to release textures!");
|
||||
}
|
||||
|
||||
SharedTextureClientOGL::~SharedTextureClientOGL()
|
||||
{
|
||||
// the data is released by the host
|
||||
// the data is owned externally.
|
||||
}
|
||||
|
||||
|
||||
@ -36,22 +38,20 @@ SharedTextureClientOGL::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
|
||||
return false;
|
||||
}
|
||||
nsIntSize nsSize(mSize.width, mSize.height);
|
||||
aOutDescriptor = SharedTextureDescriptor(mIsCrossProcess ? gl::GLContext::CrossProcess
|
||||
: gl::GLContext::SameProcess,
|
||||
mHandle, nsSize, mInverted);
|
||||
aOutDescriptor = SharedTextureDescriptor(mShareType, mHandle, nsSize, mInverted);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
SharedTextureClientOGL::InitWith(gl::SharedTextureHandle aHandle,
|
||||
gfx::IntSize aSize,
|
||||
bool aIsCrossProcess,
|
||||
gl::GLContext::SharedTextureShareType aShareType,
|
||||
bool aInverted)
|
||||
{
|
||||
MOZ_ASSERT(!IsAllocated());
|
||||
mHandle = aHandle;
|
||||
mSize = aSize;
|
||||
mIsCrossProcess = aIsCrossProcess;
|
||||
mShareType = aShareType;
|
||||
mInverted = aInverted;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ class CompositableForwarder;
|
||||
class SharedTextureClientOGL : public TextureClient
|
||||
{
|
||||
public:
|
||||
SharedTextureClientOGL();
|
||||
SharedTextureClientOGL(TextureFlags aFlags);
|
||||
|
||||
~SharedTextureClientOGL();
|
||||
|
||||
@ -36,15 +36,15 @@ public:
|
||||
|
||||
void InitWith(gl::SharedTextureHandle aHandle,
|
||||
gfx::IntSize aSize,
|
||||
bool aIsCrossProcess = false,
|
||||
gl::GLContext::SharedTextureShareType aShareType,
|
||||
bool aInverted = false);
|
||||
|
||||
virtual gfx::IntSize GetSize() const { return mSize; }
|
||||
|
||||
protected:
|
||||
gfx::IntSize mSize;
|
||||
gl::SharedTextureHandle mHandle;
|
||||
bool mIsCrossProcess;
|
||||
gfx::IntSize mSize;
|
||||
gl::GLContext::SharedTextureShareType mShareType;
|
||||
bool mInverted;
|
||||
};
|
||||
|
||||
|
@ -349,6 +349,7 @@ void
|
||||
SharedTextureHostOGL::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
CompositorOGL* glCompositor = static_cast<CompositorOGL*>(aCompositor);
|
||||
mCompositor = glCompositor;
|
||||
if (mTextureSource) {
|
||||
mTextureSource->SetCompositor(glCompositor);
|
||||
}
|
||||
|
@ -242,6 +242,8 @@ public:
|
||||
|
||||
virtual gfx3DMatrix GetTextureTransform() MOZ_OVERRIDE { return mTextureTransform; }
|
||||
|
||||
virtual GLenum GetTextureTarget() const { return mTextureTarget; }
|
||||
|
||||
virtual GLenum GetWrapMode() const MOZ_OVERRIDE { return mWrapMode; }
|
||||
|
||||
virtual void UnbindTexture() MOZ_OVERRIDE {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user