2017-10-28 02:10:06 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2015-10-15 18:53:33 +03:00
|
|
|
* 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,
|
2018-05-03 04:20:25 +03:00
|
|
|
LayersBackend aLayersBackend,
|
|
|
|
bool aSupportsTextureDirectMapping);
|
2016-07-09 04:59:59 +03:00
|
|
|
|
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, gfx::IntSize aYSize, uint32_t aYStride,
|
2015-10-15 18:53:33 +03:00
|
|
|
gfx::IntSize aCbCrSize, uint32_t aCbCrStride, StereoMode aStereoMode,
|
2019-04-11 15:41:33 +03:00
|
|
|
gfx::ColorDepth aColorDepth, gfx::YUVColorSpace aYUVColorSpace,
|
2019-07-26 11:40:33 +03:00
|
|
|
TextureFlags aTextureFlags);
|
2015-10-15 18:53:33 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
bool Lock(OpenMode aMode) override { return true; }
|
2015-10-15 18:53:33 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
void Unlock() override {}
|
2015-10-15 18:53:33 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
void FillInfo(TextureData::Info& aInfo) const override;
|
2015-10-15 18:53:33 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() override;
|
2015-10-15 18:53:33 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
bool BorrowMappedData(MappedTextureData& aMap) override;
|
2015-10-15 18:53:33 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
bool BorrowMappedYCbCrData(MappedYCbCrTextureData& aMap) override;
|
2015-10-15 18:53:33 +03:00
|
|
|
|
2015-11-20 16:25:00 +03:00
|
|
|
// use TextureClient's default implementation
|
2019-04-11 15:36:51 +03:00
|
|
|
bool UpdateFromSurface(gfx::SourceSurface* aSurface) override;
|
2015-10-15 18:53:33 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
BufferTextureData* AsBufferTextureData() override { return this; }
|
2016-06-30 05:12:31 +03:00
|
|
|
|
2015-12-16 21:50:58 +03:00
|
|
|
// Don't use this.
|
2018-09-25 15:18:58 +03:00
|
|
|
void SetDescriptor(BufferDescriptor&& aDesc);
|
2015-12-16 21:50:58 +03:00
|
|
|
|
2016-06-30 05:12:31 +03:00
|
|
|
Maybe<gfx::IntSize> GetCbCrSize() const;
|
|
|
|
|
2019-04-11 15:41:33 +03:00
|
|
|
Maybe<gfx::YUVColorSpace> GetYUVColorSpace() const;
|
2016-10-12 05:46:28 +03:00
|
|
|
|
2018-09-25 23:44:55 +03:00
|
|
|
Maybe<gfx::ColorDepth> GetColorDepth() const;
|
2017-09-29 17:37:56 +03:00
|
|
|
|
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)
|
2015-10-15 18:53:33 +03:00
|
|
|
: mDescriptor(aDescriptor), mMoz2DBackend(aMoz2DBackend) {}
|
|
|
|
|
2015-12-16 21:50:58 +03:00
|
|
|
BufferDescriptor mDescriptor;
|
2015-10-15 18:53:33 +03:00
|
|
|
gfx::BackendType mMoz2DBackend;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|