Commit 71175f43 authored by Alan Screen's avatar Alan Screen Committed by Commit Bot

Change Print Compositor to composite requests in-order

When adding typeface serialization for out of process metafile
composition the renderer processes will try to cache the typefaces so
that they are transmitted only once instead of on every page they are
used.

This will create a new dependency for internal processing within the
print compositor service.  If a page to be composited requires subframes
and is delayed until they complete, then subsequent pages will also
need to wait since they could be dependent upon typefaces included in
this earlier page's metafile stream.

This change is part of the needed support to eliminate imaging artifacts
from mismatched fonts which can happen when typefaces do not get
serialized with the pictures.

Bug: 1044996
Change-Id: I2730b6130be7fe74da7c2b93f0f52f3995f97dba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2266030Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Alan Screen <awscreen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#783044}
parent ca6e6ad4
......@@ -250,27 +250,31 @@ void PrintCompositorImpl::UpdateRequestsWithSubframeInfo(
if (pending_list.erase(frame_guid)) {
std::copy(pending_subframes.begin(), pending_subframes.end(),
std::inserter(pending_list, pending_list.end()));
if (pending_list.empty()) {
// If the request isn't waiting on any subframes then it is ready.
// Fulfill the request now.
FulfillRequest(std::move(request->serialized_content),
request->subframe_content_map,
std::move(request->callback));
// Check for a collected print preview document that was waiting on
// this page to finish.
if (docinfo_) {
if (docinfo_->page_count &&
(docinfo_->pages_written == docinfo_->page_count)) {
CompleteDocumentRequest(std::move(docinfo_->callback));
}
}
it = requests_.erase(it);
continue;
}
// If the request still has pending frames, or isn't at the front of the
// request queue (and thus could be dependent upon content from their
// data stream), then keep waiting.
const bool fulfill_request =
it == requests_.begin() && pending_list.empty();
if (!fulfill_request) {
++it;
continue;
}
// Fulfill the request now.
FulfillRequest(std::move(request->serialized_content),
request->subframe_content_map, std::move(request->callback));
// Check for a collected print preview document that was waiting on
// this page to finish.
if (docinfo_) {
if (docinfo_->page_count &&
(docinfo_->pages_written == docinfo_->page_count)) {
CompleteDocumentRequest(std::move(docinfo_->callback));
}
}
// If the request still has pending frames, keep waiting.
++it;
it = requests_.erase(it);
}
}
......@@ -321,9 +325,14 @@ void PrintCompositorImpl::HandleCompositionRequest(
base::flat_set<uint64_t> pending_subframes;
if (IsReadyToComposite(frame_guid, subframe_content_map,
&pending_subframes)) {
FulfillRequest(std::move(mapping), subframe_content_map,
std::move(callback));
return;
// This request has all the necessary subframes.
// With sequential request processing need to ensure this request is
// at the front of the line before fulfilling it.
if (requests_.empty()) {
FulfillRequest(std::move(mapping), subframe_content_map,
std::move(callback));
return;
}
}
// When it is not ready yet, keep its information and
......
......@@ -334,10 +334,10 @@ TEST_F(PrintCompositorImplTest, MultiRequestsDepOrder) {
testing::Mock::VerifyAndClearExpectations(&impl);
// When frame 3 and 2 become available, the pending requests should be
// satisfied, thus be fulfilled in order.
// satisfied, thus be fulfilled in page order.
testing::Sequence order;
EXPECT_CALL(impl, OnFulfillRequest(1, 1)).Times(1).InSequence(order);
EXPECT_CALL(impl, OnFulfillRequest(1, 0)).Times(1).InSequence(order);
EXPECT_CALL(impl, OnFulfillRequest(1, 1)).Times(1).InSequence(order);
impl.AddSubframeContent(3, CreateTestData(3, -1), ContentToFrameMap());
impl.AddSubframeContent(2, CreateTestData(2, -1), ContentToFrameMap());
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment