From 8cefe66b8d8c28e87b374a2a0779e7744501249b Mon Sep 17 00:00:00 2001 From: Brian Hackett Date: Wed, 17 Oct 2018 13:32:19 -0600 Subject: [PATCH] Bug 1499828 Part 3 - Redraw the overlay when required, r=mccr8. --HG-- extra : rebase_source : dc275641c80c674a9384acc8f101abbf8178be74 --- toolkit/recordreplay/ipc/ParentGraphics.cpp | 25 +++++++++++++++++---- toolkit/recordreplay/ipc/ParentIPC.cpp | 10 +++++++++ toolkit/recordreplay/ipc/ParentInternal.h | 3 +++ 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/toolkit/recordreplay/ipc/ParentGraphics.cpp b/toolkit/recordreplay/ipc/ParentGraphics.cpp index d02aebd8d132..2b7de4ac0c96 100644 --- a/toolkit/recordreplay/ipc/ParentGraphics.cpp +++ b/toolkit/recordreplay/ipc/ParentGraphics.cpp @@ -153,9 +153,6 @@ UpdateGraphicsInUIProcess(const PaintMessage* aMsg) InitGraphicsSandbox(); } - AutoSafeJSContext cx; - JSAutoRealm ar(cx, *gGraphicsSandbox); - size_t width = gLastPaintWidth; size_t height = gLastPaintHeight; size_t stride = layers::ImageDataSerializer::ComputeRGBStride(gSurfaceFormat, width); @@ -184,6 +181,9 @@ UpdateGraphicsInUIProcess(const PaintMessage* aMsg) } } + AutoSafeJSContext cx; + JSAutoRealm ar(cx, *gGraphicsSandbox); + JSObject* bufferObject = JS_NewArrayBufferWithExternalContents(cx, width * height * 4, memory); MOZ_RELEASE_ASSERT(bufferObject); @@ -196,11 +196,28 @@ UpdateGraphicsInUIProcess(const PaintMessage* aMsg) // Call into the graphics module to update the canvas it manages. RootedValue rval(cx); - if (!JS_CallFunctionName(cx, *gGraphicsSandbox, "Update", args, &rval)) { + if (!JS_CallFunctionName(cx, *gGraphicsSandbox, "UpdateCanvas", args, &rval)) { MOZ_CRASH("UpdateGraphicsInUIProcess"); } } +void +UpdateGraphicsOverlay() +{ + if (!gLastPaintWidth || !gLastPaintHeight) { + return; + } + + AutoSafeJSContext cx; + JSAutoRealm ar(cx, *gGraphicsSandbox); + + RootedValue rval(cx); + if (!JS_CallFunctionName(cx, *gGraphicsSandbox, "UpdateOverlay", + JS::HandleValueArray::empty(), &rval)) { + MOZ_CRASH("UpdateGraphicsOverlay"); + } +} + static void MaybeTriggerExplicitPaint() { diff --git a/toolkit/recordreplay/ipc/ParentIPC.cpp b/toolkit/recordreplay/ipc/ParentIPC.cpp index f0babf29a5e7..c541d4c786af 100644 --- a/toolkit/recordreplay/ipc/ParentIPC.cpp +++ b/toolkit/recordreplay/ipc/ParentIPC.cpp @@ -611,6 +611,12 @@ SwitchActiveChild(ChildProcessInfo* aChild, bool aRecoverPosition = true) oldActiveChild->RecoverToCheckpoint(oldActiveChild->MostRecentSavedCheckpoint()); oldActiveChild->SetRole(MakeUnique()); } + + // The graphics overlay is affected when we switch between recording and + // replaying children. + if (aChild->IsRecording() != oldActiveChild->IsRecording()) { + UpdateGraphicsOverlay(); + } } /////////////////////////////////////////////////////////////////////////////// @@ -1181,6 +1187,10 @@ RecvHitCheckpoint(const HitCheckpointMessage& aMsg) UpdateCheckpointTimes(aMsg); MaybeUpdateGraphicsAtCheckpoint(aMsg.mCheckpointId); + if (!gActiveChild->IsRecording()) { + UpdateGraphicsOverlay(); + } + // Resume either forwards or backwards. Break the resume off into a separate // runnable, to avoid starving any code already on the stack and waiting for // the process to pause. Immediately resume if the main thread is blocked. diff --git a/toolkit/recordreplay/ipc/ParentInternal.h b/toolkit/recordreplay/ipc/ParentInternal.h index a41f82cc9b78..51789c46a52e 100644 --- a/toolkit/recordreplay/ipc/ParentInternal.h +++ b/toolkit/recordreplay/ipc/ParentInternal.h @@ -94,6 +94,9 @@ void SendGraphicsMemoryToChild(); // an unhandled recording divergence. void UpdateGraphicsInUIProcess(const PaintMessage* aMsg); +// Update the overlay shown over the tab's graphics. +void UpdateGraphicsOverlay(); + // If necessary, update graphics after the active child sends a paint message // or reaches a checkpoint. void MaybeUpdateGraphicsAtPaint(const PaintMessage& aMsg);