зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1579794 - [Wayland] Copy pixel data for cached images, r=jhorak
Differential Revision: https://phabricator.services.mozilla.com/D45165 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
f447bc4951
Коммит
7a6c6dc9d7
|
@ -890,8 +890,12 @@ void WindowImageSurface::Draw(gfx::DrawTarget* aDest,
|
|||
}
|
||||
|
||||
WindowImageSurface::WindowImageSurface(
|
||||
gfx::SourceSurface* aSurface, const LayoutDeviceIntRegion& aUpdateRegion)
|
||||
: mSurface(aSurface), mUpdateRegion(aUpdateRegion){};
|
||||
gfxImageSurface* aImageSurface, const LayoutDeviceIntRegion& aUpdateRegion)
|
||||
: mImageSurface(aImageSurface), mUpdateRegion(aUpdateRegion) {
|
||||
mSurface = gfx::Factory::CreateSourceSurfaceForCairoSurface(
|
||||
mImageSurface->CairoSurface(), mImageSurface->GetSize(),
|
||||
mImageSurface->Format());
|
||||
}
|
||||
|
||||
void WindowSurfaceWayland::DrawDelayedImageCommits(
|
||||
gfx::DrawTarget* aDrawTarget, LayoutDeviceIntRegion& aWaylandBufferDamage) {
|
||||
|
@ -915,36 +919,24 @@ bool WindowSurfaceWayland::CommitImageSurfaceToWaylandBuffer(
|
|||
LOGWAYLAND(("%s [%p] screenSize [%d x %d]\n", __PRETTY_FUNCTION__,
|
||||
(void*)this, mBufferScreenRect.width, mBufferScreenRect.height));
|
||||
|
||||
RefPtr<gfx::SourceSurface> surf =
|
||||
gfx::Factory::CreateSourceSurfaceForCairoSurface(
|
||||
mImageSurface->CairoSurface(), mImageSurface->GetSize(),
|
||||
mImageSurface->Format());
|
||||
if (!surf) {
|
||||
NS_WARNING("Failed to create source cairo surface!");
|
||||
return false;
|
||||
}
|
||||
mDelayedImageCommits.AppendElement(
|
||||
WindowImageSurface(mImageSurface, aRegion));
|
||||
// mImageSurface is owned by mDelayedImageCommits
|
||||
mImageSurface = nullptr;
|
||||
|
||||
RefPtr<gfx::DrawTarget> dt = LockWaylandBuffer(
|
||||
/* aCanSwitchBuffer */ mWholeWindowBufferDamage);
|
||||
if (dt) {
|
||||
LOGWAYLAND(
|
||||
(" Flushing %ld cached WindowImageSurfaces to Wayland buffer\n",
|
||||
long(mDelayedImageCommits.Length() + 1)));
|
||||
|
||||
// Draw any delayed image commits first
|
||||
DrawDelayedImageCommits(dt, aWaylandBufferDamage);
|
||||
// Draw image from recent WindowSurfaceWayland::Lock().
|
||||
WindowImageSurface::Draw(surf, dt, aRegion);
|
||||
// Submit all drawing to final Wayland buffer upload
|
||||
aWaylandBufferDamage.OrWith(aRegion);
|
||||
UnlockWaylandBuffer();
|
||||
} else {
|
||||
mDelayedImageCommits.AppendElement(WindowImageSurface(surf, aRegion));
|
||||
LOGWAYLAND((" Added WindowImageSurfaces, cached surfaces %ld\n",
|
||||
long(mDelayedImageCommits.Length())));
|
||||
if (!dt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LOGWAYLAND((" Flushing %ld cached WindowImageSurfaces to Wayland buffer\n",
|
||||
long(mDelayedImageCommits.Length() + 1)));
|
||||
|
||||
// Draw any delayed image commits first
|
||||
DrawDelayedImageCommits(dt, aWaylandBufferDamage);
|
||||
UnlockWaylandBuffer();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -980,23 +972,6 @@ void WindowSurfaceWayland::CommitWaylandBuffer() {
|
|||
LOGWAYLAND((" mFrameCallback = %p\n", mFrameCallback));
|
||||
LOGWAYLAND((" mLastCommittedSurface = %p\n", mLastCommittedSurface));
|
||||
|
||||
if (!mDrawToWaylandBufferDirectly) {
|
||||
MOZ_ASSERT(mDelayedImageCommits.Length(),
|
||||
"Indirect drawing without any image?");
|
||||
|
||||
// There's some cached drawings - try to flush them now.
|
||||
RefPtr<gfx::DrawTarget> dt = LockWaylandBuffer(
|
||||
/* aCanSwitchBuffer */ mWholeWindowBufferDamage);
|
||||
|
||||
if (dt) {
|
||||
LOGWAYLAND(("%s [%p] flushed indirect drawing\n", __PRETTY_FUNCTION__,
|
||||
(void*)this));
|
||||
DrawDelayedImageCommits(dt, mWaylandBufferDamage);
|
||||
UnlockWaylandBuffer();
|
||||
mDrawToWaylandBufferDirectly = true;
|
||||
}
|
||||
}
|
||||
|
||||
wl_surface* waylandSurface = mWindow->GetWaylandSurface();
|
||||
if (!waylandSurface) {
|
||||
LOGWAYLAND(("%s [%p] mWindow->GetWaylandSurface() failed, delay commit.\n",
|
||||
|
@ -1105,6 +1080,7 @@ void WindowSurfaceWayland::Commit(const LayoutDeviceIntRegion& aInvalidRegion) {
|
|||
mWaylandBufferDamage.OrWith(aInvalidRegion);
|
||||
}
|
||||
UnlockWaylandBuffer();
|
||||
mPendingCommit = true;
|
||||
} else {
|
||||
MOZ_ASSERT(!mWaylandBuffer->IsLocked(),
|
||||
"Drawing to already locked buffer?");
|
||||
|
@ -1112,12 +1088,13 @@ void WindowSurfaceWayland::Commit(const LayoutDeviceIntRegion& aInvalidRegion) {
|
|||
mWaylandBufferDamage)) {
|
||||
// Our cached drawing is flushed, we can draw fullscreen again.
|
||||
mDrawToWaylandBufferDirectly = true;
|
||||
mPendingCommit = true;
|
||||
}
|
||||
}
|
||||
|
||||
// We're ready to commit.
|
||||
mPendingCommit = true;
|
||||
CommitWaylandBuffer();
|
||||
if (mPendingCommit) {
|
||||
CommitWaylandBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
void WindowSurfaceWayland::FrameCallbackHandler() {
|
||||
|
|
|
@ -154,11 +154,12 @@ class WindowImageSurface {
|
|||
void Draw(gfx::DrawTarget* aDest,
|
||||
LayoutDeviceIntRegion& aWaylandBufferDamage);
|
||||
|
||||
WindowImageSurface(gfx::SourceSurface* aSurface,
|
||||
WindowImageSurface(gfxImageSurface* aImageSurface,
|
||||
const LayoutDeviceIntRegion& aUpdateRegion);
|
||||
|
||||
private:
|
||||
RefPtr<gfx::SourceSurface> mSurface;
|
||||
RefPtr<gfxImageSurface> mImageSurface;
|
||||
const LayoutDeviceIntRegion mUpdateRegion;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче