Skip to content

Commit

Permalink
Bug 1662336 - Pass print recording dependency list across to parent p…
Browse files Browse the repository at this point in the history
…rocess and use CrossProcessPaint to resolve it. r=bobowen

Differential Revision: https://phabricator.services.mozilla.com/D90807
  • Loading branch information
mattwoodrow committed Oct 8, 2020
1 parent 2786819 commit 92c3e52
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 12 deletions.
2 changes: 1 addition & 1 deletion layout/printing/ipc/PRemotePrintJob.ipdl
Expand Up @@ -24,7 +24,7 @@ parent:

// Translate the page recording writen into |fd| and play back the events to
// the real print device.
async ProcessPage();
async ProcessPage(uint64_t[] deps);

// This informs the real print device that we've finished, so it can trigger
// the actual print.
Expand Down
4 changes: 2 additions & 2 deletions layout/printing/ipc/RemotePrintJobChild.cpp
Expand Up @@ -54,12 +54,12 @@ void RemotePrintJobChild::SetNextPageFD(
mNextPageFD = PR_ImportFile(PROsfd(handle.release()));
}

void RemotePrintJobChild::ProcessPage() {
void RemotePrintJobChild::ProcessPage(nsTArray<uint64_t>&& aDeps) {
MOZ_ASSERT(mPagePrintTimer);

mPagePrintTimer->WaitForRemotePrint();
if (!mDestroyed) {
Unused << SendProcessPage();
Unused << SendProcessPage(std::move(aDeps));
}
}

Expand Down
2 changes: 1 addition & 1 deletion layout/printing/ipc/RemotePrintJobChild.h
Expand Up @@ -35,7 +35,7 @@ class RemotePrintJobChild final : public PRemotePrintJobChild,
mozilla::ipc::IPCResult RecvPrintInitializationResult(
const nsresult& aRv, const FileDescriptor& aFd) final;

void ProcessPage();
void ProcessPage(nsTArray<uint64_t>&& aDeps);

mozilla::ipc::IPCResult RecvPageProcessed(const FileDescriptor& aFd) final;

Expand Down
42 changes: 37 additions & 5 deletions layout/printing/ipc/RemotePrintJobParent.cpp
Expand Up @@ -109,29 +109,61 @@ nsresult RemotePrintJobParent::PrepareNextPageFD(FileDescriptor* aFd) {
return NS_OK;
}

mozilla::ipc::IPCResult RemotePrintJobParent::RecvProcessPage() {
mozilla::ipc::IPCResult RemotePrintJobParent::RecvProcessPage(
nsTArray<uint64_t>&& aDeps) {
if (!mCurrentPageStream.IsOpen()) {
Unused << SendAbortPrint(NS_ERROR_FAILURE);
return IPC_OK();
}
mCurrentPageStream.Seek(0, PR_SEEK_SET);
nsresult rv = PrintPage(mCurrentPageStream);

if (aDeps.IsEmpty()) {
FinishProcessingPage();
return IPC_OK();
}

nsTHashtable<nsUint64HashKey> deps;
for (auto i : aDeps) {
deps.PutEntry(i);
}

gfx::CrossProcessPaint::Start(std::move(deps))
->Then(
GetCurrentSerialEventTarget(), __func__,
[self = RefPtr{this}](
gfx::CrossProcessPaint::ResolvedFragmentMap&& aFragments) {
self->FinishProcessingPage(&aFragments);
},
[self = RefPtr{this}](const nsresult& aRv) {
self->FinishProcessingPage();
});

return IPC_OK();
}

void RemotePrintJobParent::FinishProcessingPage(
gfx::CrossProcessPaint::ResolvedFragmentMap* aFragments) {
nsresult rv = PrintPage(mCurrentPageStream, aFragments);

mCurrentPageStream.Close();

if (mPrintDeviceContext->IsSyncPagePrinting()) {
PageDone(rv);
}

return IPC_OK();
}

nsresult RemotePrintJobParent::PrintPage(PRFileDescStream& aRecording) {
nsresult RemotePrintJobParent::PrintPage(
PRFileDescStream& aRecording,
gfx::CrossProcessPaint::ResolvedFragmentMap* aFragments) {
MOZ_ASSERT(mPrintDeviceContext);

nsresult rv = mPrintDeviceContext->BeginPage();
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
if (aFragments) {
mPrintTranslator->SetDependentSurfaces(std::move(*aFragments));
}
if (!mPrintTranslator->TranslateRecording(aRecording)) {
return NS_ERROR_FAILURE;
}
Expand Down
9 changes: 7 additions & 2 deletions layout/printing/ipc/RemotePrintJobParent.h
Expand Up @@ -15,6 +15,7 @@
#include "mozilla/RefPtr.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/gfx/RecordedEvent.h"
#include "mozilla/gfx/CrossProcessPaint.h"

class nsDeviceContext;
class nsIPrintSettings;
Expand All @@ -38,7 +39,7 @@ class RemotePrintJobParent final : public PRemotePrintJobParent {
const int32_t& aStartPage,
const int32_t& aEndPage) final;

mozilla::ipc::IPCResult RecvProcessPage() final;
mozilla::ipc::IPCResult RecvProcessPage(nsTArray<uint64_t>&& aDeps) final;

mozilla::ipc::IPCResult RecvFinalizePrint() final;

Expand Down Expand Up @@ -75,7 +76,11 @@ class RemotePrintJobParent final : public PRemotePrintJobParent {

nsresult PrepareNextPageFD(FileDescriptor* aFd);

nsresult PrintPage(PRFileDescStream& aRecording);
nsresult PrintPage(
PRFileDescStream& aRecording,
gfx::CrossProcessPaint::ResolvedFragmentMap* aFragments = nullptr);
void FinishProcessingPage(
gfx::CrossProcessPaint::ResolvedFragmentMap* aFragments = nullptr);

/**
* Called to notify our corresponding RemotePrintJobChild once we've
Expand Down
2 changes: 1 addition & 1 deletion widget/nsDeviceContextSpecProxy.cpp
Expand Up @@ -176,7 +176,7 @@ NS_IMETHODIMP
nsDeviceContextSpecProxy::EndPage() {
// Send the page recording to the parent.
mRecorder->Close();
mRemotePrintJob->ProcessPage();
mRemotePrintJob->ProcessPage(std::move(mRecorder->TakeDependentSurfaces()));

return NS_OK;
}

0 comments on commit 92c3e52

Please sign in to comment.