michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: // * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef MOZILLA_GFX_TEXTURECLIENTOGL_H michael@0: #define MOZILLA_GFX_TEXTURECLIENTOGL_H michael@0: michael@0: #include "GLContextTypes.h" // for SharedTextureHandle, etc michael@0: #include "gfxTypes.h" michael@0: #include "mozilla/Attributes.h" // for MOZ_OVERRIDE michael@0: #include "mozilla/gfx/Point.h" // for IntSize michael@0: #include "mozilla/layers/CompositorTypes.h" michael@0: #include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor michael@0: #include "mozilla/layers/TextureClient.h" // for TextureClient, etc michael@0: michael@0: namespace mozilla { michael@0: namespace gfx { michael@0: class SurfaceStream; michael@0: } michael@0: } michael@0: michael@0: namespace mozilla { michael@0: namespace layers { michael@0: michael@0: class CompositableForwarder; michael@0: michael@0: /** michael@0: * A TextureClient implementation to share TextureMemory that is already michael@0: * on the GPU, for the OpenGL backend. michael@0: */ michael@0: class SharedTextureClientOGL : public TextureClient michael@0: { michael@0: public: michael@0: SharedTextureClientOGL(TextureFlags aFlags); michael@0: michael@0: ~SharedTextureClientOGL(); michael@0: michael@0: virtual bool IsAllocated() const MOZ_OVERRIDE; michael@0: michael@0: virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE; michael@0: michael@0: virtual bool Lock(OpenMode mode) MOZ_OVERRIDE; michael@0: michael@0: virtual void Unlock() MOZ_OVERRIDE; michael@0: michael@0: virtual bool IsLocked() const MOZ_OVERRIDE { return mIsLocked; } michael@0: michael@0: virtual bool HasInternalBuffer() const MOZ_OVERRIDE { return false; } michael@0: michael@0: void InitWith(gl::SharedTextureHandle aHandle, michael@0: gfx::IntSize aSize, michael@0: gl::SharedTextureShareType aShareType, michael@0: bool aInverted = false); michael@0: michael@0: virtual gfx::IntSize GetSize() const { return mSize; } michael@0: michael@0: virtual TextureClientData* DropTextureData() MOZ_OVERRIDE michael@0: { michael@0: // XXX - right now the code paths using this are managing the shared texture michael@0: // data, although they should use a TextureClientData for this to ensure that michael@0: // the destruction sequence is race-free. michael@0: MarkInvalid(); michael@0: return nullptr; michael@0: } michael@0: michael@0: virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE michael@0: { michael@0: return gfx::SurfaceFormat::UNKNOWN; michael@0: } michael@0: michael@0: virtual bool AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags) MOZ_OVERRIDE michael@0: { michael@0: return false; michael@0: } michael@0: michael@0: protected: michael@0: gl::SharedTextureHandle mHandle; michael@0: gfx::IntSize mSize; michael@0: gl::SharedTextureShareType mShareType; michael@0: bool mInverted; michael@0: bool mIsLocked; michael@0: }; michael@0: michael@0: /** michael@0: * A TextureClient implementation to share SurfaceStream. michael@0: */ michael@0: class StreamTextureClientOGL : public TextureClient michael@0: { michael@0: public: michael@0: StreamTextureClientOGL(TextureFlags aFlags); michael@0: michael@0: ~StreamTextureClientOGL(); michael@0: michael@0: virtual bool IsAllocated() const MOZ_OVERRIDE; michael@0: michael@0: virtual bool Lock(OpenMode mode) MOZ_OVERRIDE; michael@0: michael@0: virtual void Unlock() MOZ_OVERRIDE; michael@0: michael@0: virtual bool IsLocked() const MOZ_OVERRIDE { return mIsLocked; } michael@0: michael@0: virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE; michael@0: michael@0: virtual TextureClientData* DropTextureData() MOZ_OVERRIDE { return nullptr; } michael@0: michael@0: virtual bool HasInternalBuffer() const MOZ_OVERRIDE { return false; } michael@0: michael@0: void InitWith(gfx::SurfaceStream* aStream); michael@0: michael@0: virtual gfx::IntSize GetSize() const { return gfx::IntSize(); } michael@0: michael@0: virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE michael@0: { michael@0: return gfx::SurfaceFormat::UNKNOWN; michael@0: } michael@0: michael@0: virtual bool AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags) MOZ_OVERRIDE michael@0: { michael@0: return false; michael@0: } michael@0: michael@0: protected: michael@0: bool mIsLocked; michael@0: RefPtr mStream; michael@0: RefPtr mGL; michael@0: }; michael@0: michael@0: } // namespace michael@0: } // namespace michael@0: michael@0: #endif