Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3015)

Unified Diff: content/shell/browser/layout_test/blink_test_controller.cc

Issue 2962073002: OOPIF support for layout test pixel dumps.
Patch Set: Rebasing on top of 8bc8e844008b (still works locally). Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/shell/browser/layout_test/blink_test_controller.h ('k') | content/shell/common/layout_test.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/browser/layout_test/blink_test_controller.cc
diff --git a/content/shell/browser/layout_test/blink_test_controller.cc b/content/shell/browser/layout_test/blink_test_controller.cc
index 03ed2f2d83f2d19ff90896d60f88efa7633db529..f99b93c14dcee364c8964ccaffa5f7cdaab0eaae 100644
--- a/content/shell/browser/layout_test/blink_test_controller.cc
+++ b/content/shell/browser/layout_test/blink_test_controller.cc
@@ -492,6 +492,8 @@ bool BlinkTestController::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ShellViewHostMsg_TextDump, OnTextDump)
IPC_MESSAGE_HANDLER(ShellViewHostMsg_InitiateLayoutDump,
OnInitiateLayoutDump)
+ IPC_MESSAGE_HANDLER(ShellViewHostMsg_InitiatePixelsDump,
+ OnInitiatePixelsDump)
IPC_MESSAGE_HANDLER(ShellViewHostMsg_ImageDump, OnImageDump)
IPC_MESSAGE_HANDLER(ShellViewHostMsg_AudioDump, OnAudioDump)
IPC_MESSAGE_HANDLER(ShellViewHostMsg_OverridePreferences,
@@ -786,6 +788,77 @@ void BlinkTestController::OnInitiateLayoutDump() {
pending_layout_dumps_ = number_of_messages;
}
+void BlinkTestController::OnInitiatePixelsDump() {
+ // DO NOT SUBMIT - remove ad-hoc logs.
+ LOG(ERROR) << "OnInitiatePixelsDump";
+ composited_frames_.clear();
+ TriggerCompositingIfAllChildrenHaveBeenComposited();
+}
+
+void BlinkTestController::TriggerCompositingIfAllChildrenHaveBeenComposited() {
+ for (RenderFrameHost* rfh : main_window_->web_contents()->GetAllFrames()) {
+ // Skip the frame if it already was composited.
+ if (0 != composited_frames_.count(rfh->GetFrameTreeNodeId()))
+ continue;
+
+ // Ignore non-live frames / pretend that they are ready for a pixel dump.
+ if (!rfh->IsRenderFrameLive()) {
+ composited_frames_.insert(rfh->GetFrameTreeNodeId());
+ continue;
+ }
+
+ // Check if all child frames of |rfh| have been composited.
+ bool are_all_children_composited = true;
+ for (RenderFrameHost* child :
+ main_window_->web_contents()->GetAllFrames()) {
+ if (child->GetParent() != rfh)
+ continue;
+ if (0 == composited_frames_.count(child->GetFrameTreeNodeId())) {
+ are_all_children_composited = false;
+ break;
+ }
+ }
+ if (!are_all_children_composited)
+ continue;
+
+ // At this point we know that |rfh| is ready for compositing.
+ TriggerCompositing(rfh);
+ }
+}
+
+void BlinkTestController::TriggerCompositing(RenderFrameHost* frame) {
+ LOG(ERROR) << "TriggerCompositing"
+ << "; frame->GetLastCommittedURL() = "
+ << frame->GetLastCommittedURL();
+
+ GetLayoutTestControlPtr(frame)->TriggerCompositing(
+ base::Bind(&BlinkTestController::OnTriggerCompositingResponse,
+ base::Unretained(this), frame->GetFrameTreeNodeId(),
+ frame->GetProcess()->GetID()));
+}
+
+void BlinkTestController::OnTriggerCompositingResponse(
+ int frame_tree_node_id,
+ // DO NOT SUBMIT - use |process_id|?
+ int process_id) {
+ LOG(ERROR) << "OnTriggerCompositingResponse";
+ composited_frames_.insert(frame_tree_node_id);
+
+ if (0 ==
+ composited_frames_.count(
+ main_window_->web_contents()->GetMainFrame()->GetFrameTreeNodeId())) {
+ TriggerCompositingIfAllChildrenHaveBeenComposited();
+ return;
+ }
+
+ LOG(ERROR) << "OnTriggerCompositingResponse - all frames were composited";
+ main_window_->web_contents()->GetRenderWidgetHostView()->CopyFromSurface(
+ gfx::Rect(), gfx::Size(),
+ base::Bind(&BlinkTestController::OnPixelsDumpCaptured,
+ base::Unretained(this)),
+ kN32_SkColorType);
+}
+
void BlinkTestController::OnLayoutTestRuntimeFlagsChanged(
int sender_process_host_id,
const base::DictionaryValue& changed_layout_test_runtime_flags) {
@@ -838,6 +911,15 @@ void BlinkTestController::OnDumpFrameLayoutResponse(int frame_tree_node_id,
render_view_host->GetRoutingID(), stitched_layout_dump));
}
+void BlinkTestController::OnPixelsDumpCaptured(const SkBitmap& dump,
+ ReadbackResponse response) {
+ DCHECK_EQ(READBACK_SUCCESS, response);
+ RenderViewHost* render_view_host =
+ main_window_->web_contents()->GetRenderViewHost();
+ render_view_host->Send(new ShellViewMsg_PixelsDumpResult(
+ render_view_host->GetRoutingID(), dump));
+}
+
void BlinkTestController::OnPrintMessage(const std::string& message) {
printer_->AddMessageRaw(message);
}
« no previous file with comments | « content/shell/browser/layout_test/blink_test_controller.h ('k') | content/shell/common/layout_test.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698