Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
* License, v. 2.0. If a copy of the MPL was not distributed with this
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef MOZILLA_GFX_TEXTUREDIB_H
8
#define MOZILLA_GFX_TEXTUREDIB_H
9
10
#include "mozilla/layers/Compositor.h"
11
#include "mozilla/layers/TextureClient.h"
12
#include "mozilla/layers/TextureHost.h"
13
#include "mozilla/GfxMessageUtils.h"
14
#include "gfxWindowsPlatform.h"
15
16
namespace mozilla {
17
namespace layers {
18
19
class DIBTextureData : public TextureData {
20
public:
21
bool Lock(OpenMode) override { return true; }
22
23
void Unlock() override {}
24
25
void FillInfo(TextureData::Info& aInfo) const override;
26
27
already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() override;
28
29
static DIBTextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
30
LayersIPCChannel* aAllocator);
31
32
protected:
33
DIBTextureData(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
34
gfxWindowsSurface* aSurface)
35
: mSurface(aSurface), mSize(aSize), mFormat(aFormat) {
36
MOZ_ASSERT(aSurface);
37
}
38
39
RefPtr<gfxWindowsSurface> mSurface;
40
gfx::IntSize mSize;
41
gfx::SurfaceFormat mFormat;
42
};
43
44
/**
45
* This is meant for a texture host which does a direct upload from
46
* Updated to a Compositor specific DataTextureSource and therefor doesn't
47
* need any specific Lock/Unlock magic.
48
*/
49
class TextureHostDirectUpload : public TextureHost {
50
public:
51
TextureHostDirectUpload(TextureFlags aFlags, gfx::SurfaceFormat aFormat,
52
gfx::IntSize aSize)
53
: TextureHost(aFlags), mFormat(aFormat), mSize(aSize), mIsLocked(false) {}
54
55
void DeallocateDeviceData() override;
56
57
void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
58
59
gfx::SurfaceFormat GetFormat() const override { return mFormat; }
60
61
gfx::IntSize GetSize() const override { return mSize; }
62
63
bool Lock() override;
64
65
void Unlock() override;
66
67
bool HasIntermediateBuffer() const { return true; }
68
69
bool BindTextureSource(CompositableTextureSourceRef& aTexture) override;
70
bool AcquireTextureSource(CompositableTextureSourceRef& aTexture) override;
71
72
protected:
73
RefPtr<TextureSourceProvider> mProvider;
74
RefPtr<DataTextureSource> mTextureSource;
75
gfx::SurfaceFormat mFormat;
76
gfx::IntSize mSize;
77
bool mIsLocked;
78
};
79
80
class DIBTextureHost : public TextureHostDirectUpload {
81
public:
82
DIBTextureHost(TextureFlags aFlags, const SurfaceDescriptorDIB& aDescriptor);
83
84
already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override {
85
return nullptr; // TODO: cf bug 872568
86
}
87
88
protected:
89
void UpdatedInternal(const nsIntRegion* aRegion = nullptr) override;
90
91
RefPtr<gfxWindowsSurface> mSurface;
92
};
93
94
class TextureHostFileMapping : public TextureHostDirectUpload {
95
public:
96
TextureHostFileMapping(TextureFlags aFlags,
97
const SurfaceDescriptorFileMapping& aDescriptor);
98
~TextureHostFileMapping();
99
100
already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override {
101
MOZ_CRASH("GFX: TextureHostFileMapping::GetAsSurface not implemented");
102
// Not implemented! It would be tricky to keep track of the
103
// scope of the file mapping. We could do this through UserData
104
// on the DataSourceSurface but we don't need this right now.
105
}
106
107
protected:
108
void UpdatedInternal(const nsIntRegion* aRegion = nullptr) override;
109
110
HANDLE mFileMapping;
111
};
112
113
} // namespace layers
114
} // namespace mozilla
115
116
#endif /* MOZILLA_GFX_TEXTUREDIB_H */