2015-10-15 18:53:33 +03:00
|
|
|
/* -*- 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_LAYERS_BUFFERETEXTURE
|
|
|
|
#define MOZILLA_LAYERS_BUFFERETEXTURE
|
|
|
|
|
|
|
|
#include "mozilla/layers/TextureClient.h"
|
|
|
|
#include "mozilla/ipc/SharedMemory.h"
|
|
|
|
#include "mozilla/gfx/Types.h"
|
|
|
|
#include "mozilla/gfx/2D.h"
|
|
|
|
#include "mozilla/RefPtr.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
class BufferTextureData : public TextureData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static BufferTextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
|
|
|
gfx::BackendType aMoz2DBackend,TextureFlags aFlags,
|
|
|
|
TextureAllocationFlags aAllocFlags,
|
2016-03-21 17:18:20 +03:00
|
|
|
ClientIPCAllocator* aAllocator);
|
2015-10-15 18:53:33 +03:00
|
|
|
|
2016-03-21 17:18:20 +03:00
|
|
|
static BufferTextureData* CreateForYCbCr(ClientIPCAllocator* aAllocator,
|
2015-10-15 18:53:33 +03:00
|
|
|
gfx::IntSize aYSize,
|
|
|
|
gfx::IntSize aCbCrSize,
|
|
|
|
StereoMode aStereoMode,
|
|
|
|
TextureFlags aTextureFlags);
|
|
|
|
|
2015-12-16 21:50:58 +03:00
|
|
|
// It is generally better to use CreateForYCbCr instead.
|
|
|
|
// This creates a half-initialized texture since we don't know the sizes and
|
|
|
|
// offsets in the buffer.
|
2016-03-21 17:18:20 +03:00
|
|
|
static BufferTextureData* CreateForYCbCrWithBufferSize(ClientIPCAllocator* aAllocator,
|
2015-12-16 21:50:58 +03:00
|
|
|
gfx::SurfaceFormat aFormat,
|
|
|
|
int32_t aSize,
|
|
|
|
TextureFlags aTextureFlags);
|
|
|
|
|
2015-10-15 18:53:37 +03:00
|
|
|
virtual bool Lock(OpenMode aMode, FenceHandle*) override { return true; }
|
2015-10-15 18:53:33 +03:00
|
|
|
|
|
|
|
virtual void Unlock() override {}
|
|
|
|
|
2015-12-16 21:50:58 +03:00
|
|
|
virtual gfx::IntSize GetSize() const override;
|
2015-10-15 18:53:33 +03:00
|
|
|
|
2015-12-16 21:50:58 +03:00
|
|
|
virtual gfx::SurfaceFormat GetFormat() const override;
|
2015-10-15 18:53:33 +03:00
|
|
|
|
|
|
|
virtual already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() override;
|
|
|
|
|
|
|
|
virtual bool CanExposeMappedData() const override { return true; }
|
|
|
|
|
|
|
|
virtual bool BorrowMappedData(MappedTextureData& aMap) override;
|
|
|
|
|
|
|
|
virtual bool BorrowMappedYCbCrData(MappedYCbCrTextureData& aMap) override;
|
|
|
|
|
|
|
|
virtual bool SupportsMoz2D() const override;
|
|
|
|
|
2016-02-25 16:15:58 +03:00
|
|
|
virtual bool HasIntermediateBuffer() const override;
|
2015-10-15 18:53:33 +03:00
|
|
|
|
2015-11-20 16:25:00 +03:00
|
|
|
// use TextureClient's default implementation
|
2015-10-15 18:53:33 +03:00
|
|
|
virtual bool UpdateFromSurface(gfx::SourceSurface* aSurface) override;
|
|
|
|
|
2015-12-16 21:50:58 +03:00
|
|
|
// Don't use this.
|
|
|
|
void SetDesciptor(const BufferDescriptor& aDesc);
|
|
|
|
|
2015-10-15 18:53:33 +03:00
|
|
|
protected:
|
2016-03-21 17:18:20 +03:00
|
|
|
static BufferTextureData* CreateInternal(ClientIPCAllocator* aAllocator,
|
2015-12-16 21:50:58 +03:00
|
|
|
const BufferDescriptor& aDesc,
|
|
|
|
gfx::BackendType aMoz2DBackend,
|
|
|
|
int32_t aBufferSize,
|
|
|
|
TextureFlags aTextureFlags);
|
|
|
|
|
2015-10-15 18:53:33 +03:00
|
|
|
virtual uint8_t* GetBuffer() = 0;
|
|
|
|
virtual size_t GetBufferSize() = 0;
|
|
|
|
|
2015-12-16 21:50:58 +03:00
|
|
|
BufferTextureData(const BufferDescriptor& aDescriptor, gfx::BackendType aMoz2DBackend)
|
|
|
|
: mDescriptor(aDescriptor)
|
2015-10-15 18:53:33 +03:00
|
|
|
, mMoz2DBackend(aMoz2DBackend)
|
|
|
|
{}
|
|
|
|
|
|
|
|
RefPtr<gfx::DrawTarget> mDrawTarget;
|
2015-12-16 21:50:58 +03:00
|
|
|
BufferDescriptor mDescriptor;
|
2015-10-15 18:53:33 +03:00
|
|
|
gfx::BackendType mMoz2DBackend;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|