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
|
2014-07-11 01:29:40 +04: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_GFX_TEXTUREDIB_H
|
|
|
|
#define MOZILLA_GFX_TEXTUREDIB_H
|
|
|
|
|
|
|
|
#include "mozilla/layers/Compositor.h"
|
|
|
|
#include "mozilla/layers/TextureClient.h"
|
|
|
|
#include "mozilla/layers/TextureHost.h"
|
|
|
|
#include "mozilla/GfxMessageUtils.h"
|
|
|
|
#include "gfxWindowsPlatform.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2015-11-20 16:24:58 +03:00
|
|
|
class DIBTextureData : public TextureData {
|
2015-05-22 18:54:24 +03:00
|
|
|
public:
|
2019-04-11 15:36:51 +03:00
|
|
|
bool Lock(OpenMode) override { return true; }
|
2015-05-22 18:54:24 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
void Unlock() override {}
|
2015-05-22 18:54:24 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
void FillInfo(TextureData::Info& aInfo) const override;
|
2015-05-22 18:54:24 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() override;
|
2015-05-22 18:54:24 +03:00
|
|
|
|
2015-11-20 16:24:58 +03:00
|
|
|
static DIBTextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
2016-09-27 06:22:20 +03:00
|
|
|
LayersIPCChannel* aAllocator);
|
2015-11-20 16:24:58 +03:00
|
|
|
|
2015-05-22 18:54:24 +03:00
|
|
|
protected:
|
2015-11-20 16:24:58 +03:00
|
|
|
DIBTextureData(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
|
|
|
gfxWindowsSurface* aSurface)
|
|
|
|
: mSurface(aSurface), mSize(aSize), mFormat(aFormat) {
|
|
|
|
MOZ_ASSERT(aSurface);
|
|
|
|
}
|
2015-05-22 18:54:24 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfxWindowsSurface> mSurface;
|
2015-05-22 18:54:24 +03:00
|
|
|
gfx::IntSize mSize;
|
|
|
|
gfx::SurfaceFormat mFormat;
|
2014-07-11 01:29:40 +04:00
|
|
|
};
|
|
|
|
|
2015-05-22 18:54:24 +03:00
|
|
|
/**
|
|
|
|
* This is meant for a texture host which does a direct upload from
|
|
|
|
* Updated to a Compositor specific DataTextureSource and therefor doesn't
|
|
|
|
* need any specific Lock/Unlock magic.
|
|
|
|
*/
|
|
|
|
class TextureHostDirectUpload : public TextureHost {
|
2014-07-11 01:29:40 +04:00
|
|
|
public:
|
2015-05-22 18:54:24 +03:00
|
|
|
TextureHostDirectUpload(TextureFlags aFlags, gfx::SurfaceFormat aFormat,
|
|
|
|
gfx::IntSize aSize)
|
|
|
|
: TextureHost(aFlags), mFormat(aFormat), mSize(aSize), mIsLocked(false) {}
|
2014-07-11 01:29:40 +04:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
void DeallocateDeviceData() override;
|
2014-07-11 01:29:40 +04:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
2016-06-02 12:00:21 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
gfx::SurfaceFormat GetFormat() const override { return mFormat; }
|
2014-07-11 01:29:40 +04:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
gfx::IntSize GetSize() const override { return mSize; }
|
2014-07-11 01:29:40 +04:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
bool Lock() override;
|
2014-07-11 01:29:40 +04:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
void Unlock() override;
|
2014-07-11 01:29:40 +04:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
bool HasIntermediateBuffer() const { return true; }
|
2015-06-19 02:07:22 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
bool BindTextureSource(CompositableTextureSourceRef& aTexture) override;
|
|
|
|
bool AcquireTextureSource(CompositableTextureSourceRef& aTexture) override;
|
2015-05-22 18:54:24 +03:00
|
|
|
|
|
|
|
protected:
|
2017-03-22 06:32:54 +03:00
|
|
|
RefPtr<TextureSourceProvider> mProvider;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DataTextureSource> mTextureSource;
|
2015-05-22 18:54:24 +03:00
|
|
|
gfx::SurfaceFormat mFormat;
|
|
|
|
gfx::IntSize mSize;
|
|
|
|
bool mIsLocked;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DIBTextureHost : public TextureHostDirectUpload {
|
|
|
|
public:
|
|
|
|
DIBTextureHost(TextureFlags aFlags, const SurfaceDescriptorDIB& aDescriptor);
|
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override {
|
2014-07-11 01:29:40 +04:00
|
|
|
return nullptr; // TODO: cf bug 872568
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2019-04-11 15:36:51 +03:00
|
|
|
void UpdatedInternal(const nsIntRegion* aRegion = nullptr) override;
|
2015-06-02 13:21:00 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfxWindowsSurface> mSurface;
|
2015-05-22 18:54:24 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class TextureHostFileMapping : public TextureHostDirectUpload {
|
|
|
|
public:
|
|
|
|
TextureHostFileMapping(TextureFlags aFlags,
|
|
|
|
const SurfaceDescriptorFileMapping& aDescriptor);
|
|
|
|
~TextureHostFileMapping();
|
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override {
|
2016-05-13 23:34:41 +03:00
|
|
|
MOZ_CRASH("GFX: TextureHostFileMapping::GetAsSurface not implemented");
|
|
|
|
// Not implemented! It would be tricky to keep track of the
|
2015-05-22 18:54:24 +03:00
|
|
|
// scope of the file mapping. We could do this through UserData
|
|
|
|
// on the DataSourceSurface but we don't need this right now.
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2019-04-11 15:36:51 +03:00
|
|
|
void UpdatedInternal(const nsIntRegion* aRegion = nullptr) override;
|
2015-06-02 13:21:00 +03:00
|
|
|
|
2015-05-22 18:54:24 +03:00
|
|
|
HANDLE mFileMapping;
|
2014-07-11 01:29:40 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* MOZILLA_GFX_TEXTUREDIB_H */
|