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 {
|
|
|
|
|
2016-07-09 04:59:59 +03:00
|
|
|
bool ComputeHasIntermediateBuffer(gfx::SurfaceFormat aFormat,
|
|
|
|
LayersBackend aLayersBackend);
|
|
|
|
|
2015-10-15 18:53:33 +03:00
|
|
|
class BufferTextureData : public TextureData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static BufferTextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
2016-08-23 05:30:14 +03:00
|
|
|
gfx::BackendType aMoz2DBackend,
|
|
|
|
LayersBackend aLayersBackend,
|
|
|
|
TextureFlags aFlags,
|
2015-10-15 18:53:33 +03:00
|
|
|
TextureAllocationFlags aAllocFlags,
|
2016-09-27 06:22:20 +03:00
|
|
|
LayersIPCChannel* aAllocator);
|
2015-10-15 18:53:33 +03:00
|
|
|
|
2016-09-27 06:22:20 +03:00
|
|
|
static BufferTextureData* CreateForYCbCr(KnowsCompositor* aAllocator,
|
2015-10-15 18:53:33 +03:00
|
|
|
gfx::IntSize aYSize,
|
|
|
|
gfx::IntSize aCbCrSize,
|
|
|
|
StereoMode aStereoMode,
|
2016-10-12 05:46:28 +03:00
|
|
|
YUVColorSpace aYUVColorSpace,
|
2015-10-15 18:53:33 +03:00
|
|
|
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-09-27 06:22:20 +03:00
|
|
|
static BufferTextureData* CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator,
|
2015-12-16 21:50:58 +03:00
|
|
|
int32_t aSize,
|
2016-10-12 05:46:28 +03:00
|
|
|
YUVColorSpace aYUVColorSpace,
|
2015-12-16 21:50:58 +03:00
|
|
|
TextureFlags aTextureFlags);
|
|
|
|
|
2016-10-27 11:02:09 +03:00
|
|
|
virtual bool Lock(OpenMode aMode) override { return true; }
|
2015-10-15 18:53:33 +03:00
|
|
|
|
|
|
|
virtual void Unlock() override {}
|
|
|
|
|
2016-04-22 19:05:26 +03:00
|
|
|
virtual void FillInfo(TextureData::Info& aInfo) const override;
|
2015-10-15 18:53:33 +03:00
|
|
|
|
|
|
|
virtual already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() override;
|
|
|
|
|
|
|
|
virtual bool BorrowMappedData(MappedTextureData& aMap) override;
|
|
|
|
|
|
|
|
virtual bool BorrowMappedYCbCrData(MappedYCbCrTextureData& aMap) override;
|
|
|
|
|
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;
|
|
|
|
|
2016-06-30 05:12:31 +03:00
|
|
|
virtual BufferTextureData* AsBufferTextureData() override { return this; }
|
|
|
|
|
2015-12-16 21:50:58 +03:00
|
|
|
// Don't use this.
|
|
|
|
void SetDesciptor(const BufferDescriptor& aDesc);
|
|
|
|
|
2016-06-30 05:12:31 +03:00
|
|
|
Maybe<gfx::IntSize> GetCbCrSize() const;
|
|
|
|
|
2016-10-12 05:46:28 +03:00
|
|
|
Maybe<YUVColorSpace> GetYUVColorSpace() const;
|
|
|
|
|
2016-06-30 05:12:31 +03:00
|
|
|
Maybe<StereoMode> GetStereoMode() const;
|
|
|
|
|
2015-10-15 18:53:33 +03:00
|
|
|
protected:
|
2016-04-22 19:05:26 +03:00
|
|
|
gfx::IntSize GetSize() const;
|
|
|
|
|
|
|
|
gfx::SurfaceFormat GetFormat() const;
|
|
|
|
|
2016-09-27 06:22:20 +03:00
|
|
|
static BufferTextureData* CreateInternal(LayersIPCChannel* 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
|