зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1657747 [Wayland] Remove DMABuf backend from SW compositor, r=jhorak
Differential Revision: https://phabricator.services.mozilla.com/D86342
This commit is contained in:
Родитель
aed118e1f6
Коммит
432226521b
|
@ -9811,13 +9811,6 @@
|
||||||
# Keep those pref hidden on non-nightly builds to avoid people accidentally
|
# Keep those pref hidden on non-nightly builds to avoid people accidentally
|
||||||
# turning it on.
|
# turning it on.
|
||||||
|
|
||||||
# Use DMABuf backend for Basic compositor.
|
|
||||||
# For testing purposes only.
|
|
||||||
- name: widget.wayland-dmabuf-basic-compositor.enabled
|
|
||||||
type: RelaxedAtomicBool
|
|
||||||
value: false
|
|
||||||
mirror: always
|
|
||||||
|
|
||||||
# Use DMABuf for content textures.
|
# Use DMABuf for content textures.
|
||||||
# For testing purposes only.
|
# For testing purposes only.
|
||||||
- name: widget.dmabuf-textures.enabled
|
- name: widget.dmabuf-textures.enabled
|
||||||
|
|
|
@ -165,7 +165,6 @@ bool nsDMABufDevice::IsDMABufEnabled() {
|
||||||
mIsDMABufConfigured = true;
|
mIsDMABufConfigured = true;
|
||||||
bool isDMABufUsed = (
|
bool isDMABufUsed = (
|
||||||
#ifdef NIGHTLY_BUILD
|
#ifdef NIGHTLY_BUILD
|
||||||
StaticPrefs::widget_wayland_dmabuf_basic_compositor_enabled() ||
|
|
||||||
StaticPrefs::widget_dmabuf_textures_enabled() ||
|
StaticPrefs::widget_dmabuf_textures_enabled() ||
|
||||||
#endif
|
#endif
|
||||||
StaticPrefs::widget_dmabuf_webgl_enabled() ||
|
StaticPrefs::widget_dmabuf_webgl_enabled() ||
|
||||||
|
@ -189,10 +188,6 @@ bool nsDMABufDevice::IsDMABufEnabled() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NIGHTLY_BUILD
|
#ifdef NIGHTLY_BUILD
|
||||||
bool nsDMABufDevice::IsDMABufBasicEnabled() {
|
|
||||||
return IsDMABufEnabled() &&
|
|
||||||
StaticPrefs::widget_wayland_dmabuf_basic_compositor_enabled();
|
|
||||||
}
|
|
||||||
bool nsDMABufDevice::IsDMABufTexturesEnabled() {
|
bool nsDMABufDevice::IsDMABufTexturesEnabled() {
|
||||||
return gfx::gfxVars::UseEGL() && IsDMABufEnabled() &&
|
return gfx::gfxVars::UseEGL() && IsDMABufEnabled() &&
|
||||||
StaticPrefs::widget_dmabuf_textures_enabled();
|
StaticPrefs::widget_dmabuf_textures_enabled();
|
||||||
|
|
|
@ -134,7 +134,6 @@ class nsDMABufDevice {
|
||||||
int GetGbmDeviceFd();
|
int GetGbmDeviceFd();
|
||||||
|
|
||||||
bool IsDMABufEnabled();
|
bool IsDMABufEnabled();
|
||||||
bool IsDMABufBasicEnabled();
|
|
||||||
bool IsDMABufTexturesEnabled();
|
bool IsDMABufTexturesEnabled();
|
||||||
bool IsDMABufVideoTexturesEnabled();
|
bool IsDMABufVideoTexturesEnabled();
|
||||||
bool IsDMABufWebGLEnabled();
|
bool IsDMABufWebGLEnabled();
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include "nsWaylandDisplay.h"
|
#include "nsWaylandDisplay.h"
|
||||||
#include "WindowSurfaceWayland.h"
|
#include "WindowSurfaceWayland.h"
|
||||||
#include "DMABufLibWrapper.h"
|
|
||||||
|
|
||||||
#include "nsPrintfCString.h"
|
#include "nsPrintfCString.h"
|
||||||
#include "mozilla/gfx/2D.h"
|
#include "mozilla/gfx/2D.h"
|
||||||
|
@ -40,9 +39,6 @@ extern mozilla::LazyLogModule gWidgetWaylandLog;
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
|
|
||||||
bool WindowSurfaceWayland::mUseDMABuf = false;
|
|
||||||
bool WindowSurfaceWayland::mUseDMABufInitialized = false;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Wayland multi-thread rendering scheme
|
Wayland multi-thread rendering scheme
|
||||||
|
|
||||||
|
@ -104,33 +100,6 @@ bool WindowSurfaceWayland::mUseDMABufInitialized = false;
|
||||||
| ----------------------- |
|
| ----------------------- |
|
||||||
---------------------------------
|
---------------------------------
|
||||||
|
|
||||||
----------------------------------------------------------------
|
|
||||||
When WindowBackBufferDMABuf is used it's similar to
|
|
||||||
WindowBackBufferShm scheme:
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
|
||||||
|
|
|
||||||
----------------------------------- ------------------
|
|
||||||
| WindowSurfaceWayland |<------>| nsWindow |
|
|
||||||
| | ------------------
|
|
||||||
| -------------------------- |
|
|
||||||
| |WindowBackBufferDMABuf | |
|
|
||||||
| | | |
|
|
||||||
| | ---------------------- | |
|
|
||||||
| | |DMABufSurface | |
|
|
||||||
| | ---------------------- | |
|
|
||||||
| -------------------------- |
|
|
||||||
| |
|
|
||||||
| -------------------------- |
|
|
||||||
| |WindowBackBufferDMABuf | |
|
|
||||||
| | | |
|
|
||||||
| | ---------------------- | |
|
|
||||||
| | |DMABufSurface | |
|
|
||||||
| | ---------------------- | |
|
|
||||||
| -------------------------- |
|
|
||||||
-----------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
nsWaylandDisplay
|
nsWaylandDisplay
|
||||||
|
|
||||||
|
@ -187,15 +156,6 @@ between us and wayland compositor. We draw our graphics data to the shm and
|
||||||
handle to wayland compositor by WindowBackBuffer/WindowSurfaceWayland
|
handle to wayland compositor by WindowBackBuffer/WindowSurfaceWayland
|
||||||
(wl_buffer/wl_surface).
|
(wl_buffer/wl_surface).
|
||||||
|
|
||||||
WindowBackBufferDMABuf
|
|
||||||
|
|
||||||
It's WindowBackBuffer implementation based on DMA Buffer.
|
|
||||||
It owns wl_buffer object, owns DMABufSurface
|
|
||||||
(which provides the DMA Buffer) and ties them together.
|
|
||||||
|
|
||||||
WindowBackBufferDMABuf backend is used only when DMABufSurface is
|
|
||||||
available and widget.wayland_dmabuf_backend.enabled preference is set.
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define EVENT_LOOP_DELAY (1000 / 240)
|
#define EVENT_LOOP_DELAY (1000 / 240)
|
||||||
|
@ -419,72 +379,6 @@ already_AddRefed<gfx::DrawTarget> WindowBackBufferShm::Lock() {
|
||||||
BUFFER_BPP * mWidth, GetSurfaceFormat());
|
BUFFER_BPP * mWidth, GetSurfaceFormat());
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowBackBufferDMABuf::WindowBackBufferDMABuf(
|
|
||||||
WindowSurfaceWayland* aWindowSurfaceWayland, int aWidth, int aHeight)
|
|
||||||
: WindowBackBuffer(aWindowSurfaceWayland) {
|
|
||||||
mDMAbufSurface = DMABufSurfaceRGBA::CreateDMABufSurface(
|
|
||||||
aWidth, aHeight, DMABUF_ALPHA | DMABUF_CREATE_WL_BUFFER);
|
|
||||||
LOGWAYLAND(
|
|
||||||
("WindowBackBufferDMABuf::WindowBackBufferDMABuf [%p] Created DMABuf "
|
|
||||||
"buffer [%d x %d]\n",
|
|
||||||
(void*)this, aWidth, aHeight));
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowBackBufferDMABuf::~WindowBackBufferDMABuf() = default;
|
|
||||||
|
|
||||||
already_AddRefed<gfx::DrawTarget> WindowBackBufferDMABuf::Lock() {
|
|
||||||
LOGWAYLAND(
|
|
||||||
("WindowBackBufferDMABuf::Lock [%p] [%d x %d] wl_buffer %p ID %d\n",
|
|
||||||
(void*)this, GetWidth(), GetHeight(), (void*)GetWlBuffer(),
|
|
||||||
GetWlBuffer() ? wl_proxy_get_id((struct wl_proxy*)GetWlBuffer()) : -1));
|
|
||||||
|
|
||||||
uint32_t stride;
|
|
||||||
void* pixels = mDMAbufSurface->Map(&stride);
|
|
||||||
gfx::IntSize lockSize(GetWidth(), GetHeight());
|
|
||||||
return gfxPlatform::CreateDrawTargetForData(
|
|
||||||
static_cast<unsigned char*>(pixels), lockSize, stride,
|
|
||||||
GetSurfaceFormat());
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowBackBufferDMABuf::Unlock() { mDMAbufSurface->Unmap(); }
|
|
||||||
|
|
||||||
bool WindowBackBufferDMABuf::IsAttached() {
|
|
||||||
return mDMAbufSurface->WLBufferIsAttached();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowBackBufferDMABuf::SetAttached() {
|
|
||||||
return mDMAbufSurface->WLBufferSetAttached();
|
|
||||||
}
|
|
||||||
|
|
||||||
int WindowBackBufferDMABuf::GetWidth() { return mDMAbufSurface->GetWidth(); }
|
|
||||||
|
|
||||||
int WindowBackBufferDMABuf::GetHeight() { return mDMAbufSurface->GetHeight(); }
|
|
||||||
|
|
||||||
wl_buffer* WindowBackBufferDMABuf::GetWlBuffer() {
|
|
||||||
return mDMAbufSurface->GetWLBuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WindowBackBufferDMABuf::IsLocked() { return mDMAbufSurface->IsMapped(); }
|
|
||||||
|
|
||||||
bool WindowBackBufferDMABuf::Resize(int aWidth, int aHeight) {
|
|
||||||
return mDMAbufSurface->Resize(aWidth, aHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WindowBackBufferDMABuf::SetImageDataFromBuffer(
|
|
||||||
class WindowBackBuffer* aSourceBuffer) {
|
|
||||||
NS_WARNING("WindowBackBufferDMABuf copy is not implemented!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowBackBufferDMABuf::Detach(wl_buffer* aBuffer) {
|
|
||||||
mDMAbufSurface->WLBufferDetach();
|
|
||||||
|
|
||||||
// Commit any potential cached drawings from latest Lock()/Commit() cycle.
|
|
||||||
mWindowSurfaceWayland->CommitWaylandBuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowBackBufferDMABuf::Clear() { mDMAbufSurface->Clear(); }
|
|
||||||
|
|
||||||
static void frame_callback_handler(void* data, struct wl_callback* callback,
|
static void frame_callback_handler(void* data, struct wl_callback* callback,
|
||||||
uint32_t time) {
|
uint32_t time) {
|
||||||
auto surface = reinterpret_cast<WindowSurfaceWayland*>(data);
|
auto surface = reinterpret_cast<WindowSurfaceWayland*>(data);
|
||||||
|
@ -512,7 +406,6 @@ WindowSurfaceWayland::WindowSurfaceWayland(nsWindow* aWindow)
|
||||||
mIsMainThread(NS_IsMainThread()) {
|
mIsMainThread(NS_IsMainThread()) {
|
||||||
for (int i = 0; i < BACK_BUFFER_NUM; i++) {
|
for (int i = 0; i < BACK_BUFFER_NUM; i++) {
|
||||||
mShmBackupBuffer[i] = nullptr;
|
mShmBackupBuffer[i] = nullptr;
|
||||||
mDMABackupBuffer[i] = nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,51 +431,15 @@ WindowSurfaceWayland::~WindowSurfaceWayland() {
|
||||||
if (mShmBackupBuffer[i]) {
|
if (mShmBackupBuffer[i]) {
|
||||||
delete mShmBackupBuffer[i];
|
delete mShmBackupBuffer[i];
|
||||||
}
|
}
|
||||||
if (mDMABackupBuffer[i]) {
|
|
||||||
delete mDMABackupBuffer[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WindowSurfaceWayland::UseDMABufBackend() {
|
WindowBackBuffer* WindowSurfaceWayland::CreateWaylandBuffer(int aWidth,
|
||||||
if (!mUseDMABufInitialized) {
|
int aHeight) {
|
||||||
mUseDMABuf = GetDMABufDevice()->IsDMABufBasicEnabled();
|
|
||||||
LOGWAYLAND(("WindowSurfaceWayland::UseDMABufBackend DMABuf state %d\n",
|
|
||||||
mUseDMABuf));
|
|
||||||
mUseDMABufInitialized = true;
|
|
||||||
}
|
|
||||||
return mUseDMABuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowBackBuffer* WindowSurfaceWayland::CreateWaylandBufferInternal(
|
|
||||||
int aWidth, int aHeight, bool aAllowDMABufBackend) {
|
|
||||||
if (aAllowDMABufBackend && UseDMABufBackend()) {
|
|
||||||
WindowBackBuffer* buffer =
|
|
||||||
new WindowBackBufferDMABuf(this, aWidth, aHeight);
|
|
||||||
|
|
||||||
if (buffer && buffer->GetWlBuffer() != nullptr) {
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Buffer was created as incomplete, delete it.
|
|
||||||
delete buffer;
|
|
||||||
|
|
||||||
NS_WARNING("Wayland DMABuf failed, switched back to Shm backend!");
|
|
||||||
mUseDMABuf = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new WindowBackBufferShm(this, aWidth, aHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowBackBuffer* WindowSurfaceWayland::CreateWaylandBuffer(
|
|
||||||
int aWidth, int aHeight, bool aAllowDMABufBackend) {
|
|
||||||
bool createDMABufBuffer = aAllowDMABufBackend && UseDMABufBackend();
|
|
||||||
WindowBackBuffer** backBufferStore =
|
|
||||||
createDMABufBuffer ? mDMABackupBuffer : mShmBackupBuffer;
|
|
||||||
int availableBuffer;
|
int availableBuffer;
|
||||||
for (availableBuffer = 0; availableBuffer < BACK_BUFFER_NUM;
|
for (availableBuffer = 0; availableBuffer < BACK_BUFFER_NUM;
|
||||||
availableBuffer++) {
|
availableBuffer++) {
|
||||||
if (!backBufferStore[availableBuffer]) {
|
if (!mShmBackupBuffer[availableBuffer]) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -592,25 +449,21 @@ WindowBackBuffer* WindowSurfaceWayland::CreateWaylandBuffer(
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowBackBuffer* buffer =
|
WindowBackBuffer* buffer = new WindowBackBufferShm(this, aWidth, aHeight);
|
||||||
CreateWaylandBufferInternal(aWidth, aHeight, aAllowDMABufBackend);
|
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
backBufferStore[availableBuffer] = buffer;
|
mShmBackupBuffer[availableBuffer] = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowBackBuffer* WindowSurfaceWayland::WaylandBufferFindAvailable(
|
WindowBackBuffer* WindowSurfaceWayland::WaylandBufferFindAvailable(
|
||||||
int aWidth, int aHeight, bool aUseDMABufBackend) {
|
int aWidth, int aHeight) {
|
||||||
int availableBuffer;
|
int availableBuffer;
|
||||||
WindowBackBuffer** backBufferStore =
|
|
||||||
aUseDMABufBackend ? mDMABackupBuffer : mShmBackupBuffer;
|
|
||||||
|
|
||||||
// Try to find a buffer which matches the size
|
// Try to find a buffer which matches the size
|
||||||
for (availableBuffer = 0; availableBuffer < BACK_BUFFER_NUM;
|
for (availableBuffer = 0; availableBuffer < BACK_BUFFER_NUM;
|
||||||
availableBuffer++) {
|
availableBuffer++) {
|
||||||
WindowBackBuffer* buffer = backBufferStore[availableBuffer];
|
WindowBackBuffer* buffer = mShmBackupBuffer[availableBuffer];
|
||||||
if (buffer && !buffer->IsAttached() &&
|
if (buffer && !buffer->IsAttached() &&
|
||||||
buffer->IsMatchingSize(aWidth, aHeight)) {
|
buffer->IsMatchingSize(aWidth, aHeight)) {
|
||||||
return buffer;
|
return buffer;
|
||||||
|
@ -620,7 +473,7 @@ WindowBackBuffer* WindowSurfaceWayland::WaylandBufferFindAvailable(
|
||||||
// Try to find any buffer
|
// Try to find any buffer
|
||||||
for (availableBuffer = 0; availableBuffer < BACK_BUFFER_NUM;
|
for (availableBuffer = 0; availableBuffer < BACK_BUFFER_NUM;
|
||||||
availableBuffer++) {
|
availableBuffer++) {
|
||||||
WindowBackBuffer* buffer = backBufferStore[availableBuffer];
|
WindowBackBuffer* buffer = mShmBackupBuffer[availableBuffer];
|
||||||
if (buffer && !buffer->IsAttached()) {
|
if (buffer && !buffer->IsAttached()) {
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
@ -629,21 +482,18 @@ WindowBackBuffer* WindowSurfaceWayland::WaylandBufferFindAvailable(
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowBackBuffer* WindowSurfaceWayland::SetNewWaylandBuffer(
|
WindowBackBuffer* WindowSurfaceWayland::SetNewWaylandBuffer() {
|
||||||
bool aUseDMABufBackend) {
|
|
||||||
LOGWAYLAND(
|
LOGWAYLAND(
|
||||||
("WindowSurfaceWayland::NewWaylandBuffer [%p] Requested buffer [%d "
|
("WindowSurfaceWayland::NewWaylandBuffer [%p] Requested buffer [%d "
|
||||||
"x %d] DMABuf %d\n",
|
"x %d]\n",
|
||||||
(void*)this, mWLBufferRect.width, mWLBufferRect.height,
|
(void*)this, mWLBufferRect.width, mWLBufferRect.height));
|
||||||
aUseDMABufBackend));
|
|
||||||
|
|
||||||
mWaylandBuffer = WaylandBufferFindAvailable(
|
mWaylandBuffer =
|
||||||
mWLBufferRect.width, mWLBufferRect.height, aUseDMABufBackend);
|
WaylandBufferFindAvailable(mWLBufferRect.width, mWLBufferRect.height);
|
||||||
if (!mWaylandBuffer) {
|
if (!mWaylandBuffer) {
|
||||||
mWaylandBuffer = CreateWaylandBuffer(
|
mWaylandBuffer =
|
||||||
mWLBufferRect.width, mWLBufferRect.height, aUseDMABufBackend);
|
CreateWaylandBuffer(mWLBufferRect.width, mWLBufferRect.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mWaylandBuffer;
|
return mWaylandBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -655,7 +505,7 @@ WindowBackBuffer* WindowSurfaceWayland::GetWaylandBufferRecent() {
|
||||||
|
|
||||||
// There's no buffer created yet, create a new one for partial screen updates.
|
// There's no buffer created yet, create a new one for partial screen updates.
|
||||||
if (!mWaylandBuffer) {
|
if (!mWaylandBuffer) {
|
||||||
return SetNewWaylandBuffer(/* aAllowDMABufBackend */ false);
|
return SetNewWaylandBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mWaylandBuffer->IsAttached()) {
|
if (mWaylandBuffer->IsAttached()) {
|
||||||
|
@ -684,9 +534,8 @@ WindowBackBuffer* WindowSurfaceWayland::GetWaylandBufferWithSwitch() {
|
||||||
(void*)this, mWLBufferRect.width, mWLBufferRect.height));
|
(void*)this, mWLBufferRect.width, mWLBufferRect.height));
|
||||||
|
|
||||||
// There's no buffer created yet or actual buffer is attached, get a new one.
|
// There's no buffer created yet or actual buffer is attached, get a new one.
|
||||||
// Use DMABuf for fullscreen updates only.
|
|
||||||
if (!mWaylandBuffer || mWaylandBuffer->IsAttached()) {
|
if (!mWaylandBuffer || mWaylandBuffer->IsAttached()) {
|
||||||
return SetNewWaylandBuffer(UseDMABufBackend() && mWaylandFullscreenDamage);
|
return SetNewWaylandBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reuse existing buffer
|
// Reuse existing buffer
|
||||||
|
@ -707,7 +556,7 @@ already_AddRefed<gfx::DrawTarget> WindowSurfaceWayland::LockWaylandBuffer() {
|
||||||
mWLBufferRect = LayoutDeviceIntRect(region.GetBounds());
|
mWLBufferRect = LayoutDeviceIntRect(region.GetBounds());
|
||||||
|
|
||||||
// mCanSwitchWaylandBuffer set means we're getting buffer for fullscreen
|
// mCanSwitchWaylandBuffer set means we're getting buffer for fullscreen
|
||||||
// update. We can use DMABuf and we can get a new buffer for drawing.
|
// update.
|
||||||
WindowBackBuffer* buffer = mCanSwitchWaylandBuffer
|
WindowBackBuffer* buffer = mCanSwitchWaylandBuffer
|
||||||
? GetWaylandBufferWithSwitch()
|
? GetWaylandBufferWithSwitch()
|
||||||
: GetWaylandBufferRecent();
|
: GetWaylandBufferRecent();
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "mozilla/gfx/Types.h"
|
#include "mozilla/gfx/Types.h"
|
||||||
#include "nsWaylandDisplay.h"
|
#include "nsWaylandDisplay.h"
|
||||||
#include "nsWindow.h"
|
#include "nsWindow.h"
|
||||||
#include "DMABufSurface.h"
|
|
||||||
#include "WindowSurface.h"
|
#include "WindowSurface.h"
|
||||||
|
|
||||||
#define BACK_BUFFER_NUM 3
|
#define BACK_BUFFER_NUM 3
|
||||||
|
@ -45,8 +44,6 @@ class WaylandShmPool {
|
||||||
// Holds actual graphics data for wl_surface
|
// Holds actual graphics data for wl_surface
|
||||||
class WindowBackBuffer {
|
class WindowBackBuffer {
|
||||||
public:
|
public:
|
||||||
virtual bool IsDMABufBuffer() { return false; };
|
|
||||||
|
|
||||||
virtual already_AddRefed<gfx::DrawTarget> Lock() = 0;
|
virtual already_AddRefed<gfx::DrawTarget> Lock() = 0;
|
||||||
virtual void Unlock() = 0;
|
virtual void Unlock() = 0;
|
||||||
virtual bool IsLocked() = 0;
|
virtual bool IsLocked() = 0;
|
||||||
|
@ -127,35 +124,6 @@ class WindowBackBufferShm : public WindowBackBuffer {
|
||||||
bool mIsLocked;
|
bool mIsLocked;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WindowBackBufferDMABuf : public WindowBackBuffer {
|
|
||||||
public:
|
|
||||||
WindowBackBufferDMABuf(WindowSurfaceWayland* aWindowSurfaceWayland,
|
|
||||||
int aWidth, int aHeight);
|
|
||||||
~WindowBackBufferDMABuf();
|
|
||||||
|
|
||||||
bool IsDMABufBuffer() { return true; };
|
|
||||||
|
|
||||||
bool IsAttached();
|
|
||||||
void SetAttached();
|
|
||||||
|
|
||||||
int GetWidth();
|
|
||||||
int GetHeight();
|
|
||||||
wl_buffer* GetWlBuffer();
|
|
||||||
|
|
||||||
bool SetImageDataFromBuffer(class WindowBackBuffer* aSourceBuffer);
|
|
||||||
|
|
||||||
already_AddRefed<gfx::DrawTarget> Lock();
|
|
||||||
bool IsLocked();
|
|
||||||
void Unlock();
|
|
||||||
|
|
||||||
void Clear();
|
|
||||||
void Detach(wl_buffer* aBuffer);
|
|
||||||
bool Resize(int aWidth, int aHeight);
|
|
||||||
|
|
||||||
private:
|
|
||||||
RefPtr<DMABufSurfaceRGBA> mDMAbufSurface;
|
|
||||||
};
|
|
||||||
|
|
||||||
class WindowImageSurface {
|
class WindowImageSurface {
|
||||||
public:
|
public:
|
||||||
static void Draw(gfx::SourceSurface* aSurface, gfx::DrawTarget* aDest,
|
static void Draw(gfx::SourceSurface* aSurface, gfx::DrawTarget* aDest,
|
||||||
|
@ -227,21 +195,15 @@ class WindowSurfaceWayland : public WindowSurface {
|
||||||
// is rendered.
|
// is rendered.
|
||||||
CACHE_MISSING = 1,
|
CACHE_MISSING = 1,
|
||||||
// Don't cache anything, draw only when back buffer is available.
|
// Don't cache anything, draw only when back buffer is available.
|
||||||
// Suitable for fullscreen content only like fullscreen video playback and
|
|
||||||
// may work well with dmabuf backend.
|
|
||||||
CACHE_NONE = 2
|
CACHE_NONE = 2
|
||||||
} RenderingCacheMode;
|
} RenderingCacheMode;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WindowBackBuffer* GetWaylandBufferWithSwitch();
|
WindowBackBuffer* GetWaylandBufferWithSwitch();
|
||||||
WindowBackBuffer* GetWaylandBufferRecent();
|
WindowBackBuffer* GetWaylandBufferRecent();
|
||||||
WindowBackBuffer* SetNewWaylandBuffer(bool aAllowDMABufBackend);
|
WindowBackBuffer* SetNewWaylandBuffer();
|
||||||
WindowBackBuffer* CreateWaylandBuffer(int aWidth, int aHeight,
|
WindowBackBuffer* CreateWaylandBuffer(int aWidth, int aHeight);
|
||||||
bool aUseDMABufBackend);
|
WindowBackBuffer* WaylandBufferFindAvailable(int aWidth, int aHeight);
|
||||||
WindowBackBuffer* CreateWaylandBufferInternal(int aWidth, int aHeight,
|
|
||||||
bool aUseDMABufBackend);
|
|
||||||
WindowBackBuffer* WaylandBufferFindAvailable(int aWidth, int aHeight,
|
|
||||||
bool aUseDMABufBackend);
|
|
||||||
|
|
||||||
already_AddRefed<gfx::DrawTarget> LockWaylandBuffer();
|
already_AddRefed<gfx::DrawTarget> LockWaylandBuffer();
|
||||||
void UnlockWaylandBuffer();
|
void UnlockWaylandBuffer();
|
||||||
|
@ -275,7 +237,6 @@ class WindowSurfaceWayland : public WindowSurface {
|
||||||
// the mBufferPendingCommit is set.
|
// the mBufferPendingCommit is set.
|
||||||
WindowBackBuffer* mWaylandBuffer;
|
WindowBackBuffer* mWaylandBuffer;
|
||||||
WindowBackBuffer* mShmBackupBuffer[BACK_BUFFER_NUM];
|
WindowBackBuffer* mShmBackupBuffer[BACK_BUFFER_NUM];
|
||||||
WindowBackBuffer* mDMABackupBuffer[BACK_BUFFER_NUM];
|
|
||||||
|
|
||||||
// When mWaylandFullscreenDamage we invalidate whole surface,
|
// When mWaylandFullscreenDamage we invalidate whole surface,
|
||||||
// otherwise partial screen updates (mWaylandBufferDamage) are used.
|
// otherwise partial screen updates (mWaylandBufferDamage) are used.
|
||||||
|
@ -334,10 +295,6 @@ class WindowSurfaceWayland : public WindowSurface {
|
||||||
bool mSmoothRendering;
|
bool mSmoothRendering;
|
||||||
|
|
||||||
bool mIsMainThread;
|
bool mIsMainThread;
|
||||||
|
|
||||||
static bool UseDMABufBackend();
|
|
||||||
static bool mUseDMABufInitialized;
|
|
||||||
static bool mUseDMABuf;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace widget
|
} // namespace widget
|
||||||
|
|
Загрузка…
Ссылка в новой задаче