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 WAYLAND_SURFACE_DMABUF_H
8
#define WAYLAND_SURFACE_DMABUF_H
9
10
#include "ImageContainer.h"
11
#include "mozilla/widget/WaylandDMABufSurface.h"
12
#include "mozilla/gfx/Point.h"
13
#include "mozilla/layers/TextureClient.h"
14
15
namespace mozilla {
16
class VAAPIFrameHolder;
17
}
18
19
namespace mozilla {
20
namespace layers {
21
22
typedef void (*AVFrameReleaseCallback)(VAAPIFrameHolder* aFrameHolder);
23
24
class WaylandDMABUFSurfaceImage : public Image {
25
public:
26
explicit WaylandDMABUFSurfaceImage(WaylandDMABufSurface* aSurface,
27
AVFrameReleaseCallback aReleaseCallback,
28
VAAPIFrameHolder* aFrameHolder)
29
: Image(nullptr, ImageFormat::WAYLAND_DMABUF),
30
mSurface(aSurface),
31
mReleaseCallback(aReleaseCallback),
32
mFrameHolder(aFrameHolder) {}
33
34
~WaylandDMABUFSurfaceImage() {
35
if (mReleaseCallback) {
36
mReleaseCallback(mFrameHolder);
37
}
38
}
39
40
WaylandDMABufSurface* GetSurface() { return mSurface; }
41
42
gfx::IntSize GetSize() const override {
43
return gfx::IntSize::Truncate(mSurface->GetWidth(), mSurface->GetHeight());
44
}
45
46
already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override {
47
return nullptr;
48
}
49
50
TextureClient* GetTextureClient(KnowsCompositor* aKnowsCompositor) override;
51
52
private:
53
RefPtr<WaylandDMABufSurface> mSurface;
54
RefPtr<TextureClient> mTextureClient;
55
56
// When WaylandDMABUFSurfaceImage is created on top of ffmpeg frame located at
57
// GPU memory we need to keep it until painting of the frame is finished.
58
AVFrameReleaseCallback mReleaseCallback;
59
VAAPIFrameHolder* mFrameHolder;
60
};
61
62
} // namespace layers
63
} // namespace mozilla
64
65
#endif // WAYLAND_SURFACE_DMABUF_H