зеркало из https://github.com/mozilla/gecko-dev.git
118 строки
3.9 KiB
C++
118 строки
3.9 KiB
C++
/* -*- 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
|
|
* 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/. */
|
|
|
|
#include "RenderCompositor.h"
|
|
|
|
#include "GLContext.h"
|
|
#include "mozilla/gfx/gfxVars.h"
|
|
#include "mozilla/layers/SyncObject.h"
|
|
#include "mozilla/webrender/RenderCompositorOGL.h"
|
|
#include "mozilla/widget/CompositorWidget.h"
|
|
|
|
#ifdef XP_WIN
|
|
# include "mozilla/webrender/RenderCompositorANGLE.h"
|
|
#endif
|
|
|
|
#if defined(MOZ_WAYLAND) || defined(MOZ_WIDGET_ANDROID)
|
|
# include "mozilla/webrender/RenderCompositorEGL.h"
|
|
#endif
|
|
|
|
namespace mozilla {
|
|
namespace wr {
|
|
|
|
void wr_compositor_add_surface(void* aCompositor, wr::NativeSurfaceId aId,
|
|
wr::DeviceIntPoint aPosition,
|
|
wr::DeviceIntRect aClipRect) {
|
|
RenderCompositor* compositor = static_cast<RenderCompositor*>(aCompositor);
|
|
compositor->AddSurface(aId, aPosition, aClipRect);
|
|
}
|
|
|
|
void wr_compositor_begin_frame(void* aCompositor) {
|
|
RenderCompositor* compositor = static_cast<RenderCompositor*>(aCompositor);
|
|
compositor->CompositorBeginFrame();
|
|
}
|
|
|
|
void wr_compositor_bind(void* aCompositor, wr::NativeTileId aId,
|
|
wr::DeviceIntPoint* aOffset, uint32_t* aFboId,
|
|
wr::DeviceIntRect aDirtyRect) {
|
|
RenderCompositor* compositor = static_cast<RenderCompositor*>(aCompositor);
|
|
compositor->Bind(aId, aOffset, aFboId, aDirtyRect);
|
|
}
|
|
|
|
void wr_compositor_create_surface(void* aCompositor, wr::NativeSurfaceId aId,
|
|
wr::DeviceIntSize aTileSize, bool aIsOpaque) {
|
|
RenderCompositor* compositor = static_cast<RenderCompositor*>(aCompositor);
|
|
compositor->CreateSurface(aId, aTileSize, aIsOpaque);
|
|
}
|
|
|
|
void wr_compositor_create_tile(void* aCompositor, wr::NativeSurfaceId aId,
|
|
int32_t aX, int32_t aY) {
|
|
RenderCompositor* compositor = static_cast<RenderCompositor*>(aCompositor);
|
|
compositor->CreateTile(aId, aX, aY);
|
|
}
|
|
|
|
void wr_compositor_destroy_tile(void* aCompositor, wr::NativeSurfaceId aId,
|
|
int32_t aX, int32_t aY) {
|
|
RenderCompositor* compositor = static_cast<RenderCompositor*>(aCompositor);
|
|
compositor->DestroyTile(aId, aX, aY);
|
|
}
|
|
|
|
void wr_compositor_destroy_surface(void* aCompositor, NativeSurfaceId aId) {
|
|
RenderCompositor* compositor = static_cast<RenderCompositor*>(aCompositor);
|
|
compositor->DestroySurface(aId);
|
|
}
|
|
|
|
void wr_compositor_end_frame(void* aCompositor) {
|
|
RenderCompositor* compositor = static_cast<RenderCompositor*>(aCompositor);
|
|
compositor->CompositorEndFrame();
|
|
}
|
|
|
|
void wr_compositor_unbind(void* aCompositor) {
|
|
RenderCompositor* compositor = static_cast<RenderCompositor*>(aCompositor);
|
|
compositor->Unbind();
|
|
}
|
|
|
|
/* static */
|
|
UniquePtr<RenderCompositor> RenderCompositor::Create(
|
|
RefPtr<widget::CompositorWidget>&& aWidget) {
|
|
#ifdef XP_WIN
|
|
if (gfx::gfxVars::UseWebRenderANGLE()) {
|
|
return RenderCompositorANGLE::Create(std::move(aWidget));
|
|
}
|
|
#endif
|
|
|
|
#if defined(MOZ_WAYLAND) || defined(MOZ_WIDGET_ANDROID)
|
|
UniquePtr<RenderCompositor> eglCompositor =
|
|
RenderCompositorEGL::Create(aWidget);
|
|
if (eglCompositor) {
|
|
return eglCompositor;
|
|
}
|
|
#endif
|
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
|
// RenderCompositorOGL is not used on android
|
|
return nullptr;
|
|
#else
|
|
return RenderCompositorOGL::Create(std::move(aWidget));
|
|
#endif
|
|
}
|
|
|
|
RenderCompositor::RenderCompositor(RefPtr<widget::CompositorWidget>&& aWidget)
|
|
: mWidget(aWidget) {}
|
|
|
|
RenderCompositor::~RenderCompositor() {}
|
|
|
|
bool RenderCompositor::MakeCurrent() { return gl()->MakeCurrent(); }
|
|
|
|
bool RenderCompositor::IsContextLost() {
|
|
// XXX Add glGetGraphicsResetStatus handling for checking rendering context
|
|
// has not been lost
|
|
return false;
|
|
}
|
|
|
|
} // namespace wr
|
|
} // namespace mozilla
|