diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-08-30 10:22:43 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-08-30 12:36:28 +0000 |
commit | 271a6c3487a14599023a9106329505597638d793 (patch) | |
tree | e040d58ffc86c1480b79ca8528020ca9ec919bf8 /chromium/third_party/blink/renderer/core/paint/paint_timing_visualizer.cc | |
parent | 7b2ffa587235a47d4094787d72f38102089f402a (diff) | |
download | qtwebengine-chromium-271a6c3487a14599023a9106329505597638d793.tar.gz |
BASELINE: Update Chromium to 77.0.3865.59
Change-Id: I1e89a5f3b009a9519a6705102ad65c92fe736f21
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/third_party/blink/renderer/core/paint/paint_timing_visualizer.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/core/paint/paint_timing_visualizer.cc | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/chromium/third_party/blink/renderer/core/paint/paint_timing_visualizer.cc b/chromium/third_party/blink/renderer/core/paint/paint_timing_visualizer.cc new file mode 100644 index 00000000000..a9bb39c9396 --- /dev/null +++ b/chromium/third_party/blink/renderer/core/paint/paint_timing_visualizer.cc @@ -0,0 +1,111 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "third_party/blink/renderer/core/paint/paint_timing_visualizer.h" + +#include "third_party/blink/public/platform/web_float_rect.h" +#include "third_party/blink/renderer/core/dom/dom_node_ids.h" +#include "third_party/blink/renderer/core/frame/local_frame_view.h" +#include "third_party/blink/renderer/core/layout/layout_object.h" +#include "third_party/blink/renderer/core/loader/resource/image_resource_content.h" +#include "third_party/blink/renderer/core/paint/paint_timing_detector.h" +#include "third_party/blink/renderer/core/scroll/scrollable_area.h" +#include "third_party/blink/renderer/platform/geometry/int_rect.h" +#include "third_party/blink/renderer/platform/instrumentation/tracing/traced_value.h" + +namespace blink { + +namespace { +static void CreateQuad(TracedValue* value, + const char* name, + const FloatQuad& quad) { + value->BeginArray(name); + value->PushDouble(quad.P1().X()); + value->PushDouble(quad.P1().Y()); + value->PushDouble(quad.P2().X()); + value->PushDouble(quad.P2().Y()); + value->PushDouble(quad.P3().X()); + value->PushDouble(quad.P3().Y()); + value->PushDouble(quad.P4().X()); + value->PushDouble(quad.P4().Y()); + value->EndArray(); +} + +} // namespace + +void PaintTimingVisualizer::RecordRects(const IntRect& rect, + std::unique_ptr<TracedValue>& value) { + CreateQuad(value.get(), "rect", FloatRect(rect)); +} +void PaintTimingVisualizer::RecordObject(const LayoutObject& object, + std::unique_ptr<TracedValue>& value) { + value->SetString("object_name", object.GetName()); + DCHECK(object.GetFrame()); + value->SetString("frame", String::FromUTF8(ToTraceValue(object.GetFrame()))); + value->SetBoolean("is_in_main_frame", object.GetFrame()->IsMainFrame()); + if (object.GetNode()) + value->SetInteger("dom_node_id", DOMNodeIds::IdForNode(object.GetNode())); +} + +void PaintTimingVisualizer::DumpTextDebuggingRect(const LayoutObject& object, + const FloatRect& rect) { + std::unique_ptr<TracedValue> value = std::make_unique<TracedValue>(); + RecordObject(object, value); + RecordRects(RoundedIntRect(rect), value); + value->SetBoolean("is_aggregation_text", true); + value->SetBoolean("is_svg", object.IsSVG()); + DumpTrace(std::move(value)); +} + +void PaintTimingVisualizer::DumpImageDebuggingRect( + const LayoutObject& object, + const FloatRect& rect, + const ImageResourceContent& cached_image) { + std::unique_ptr<TracedValue> value = std::make_unique<TracedValue>(); + RecordObject(object, value); + RecordRects(RoundedIntRect(rect), value); + value->SetBoolean("is_image", true); + value->SetBoolean("is_svg", object.IsSVG()); + value->SetBoolean("is_image_loaded", cached_image.IsLoaded()); + value->SetString("image_url", + String(cached_image.Url().StrippedForUseAsReferrer())); + DumpTrace(std::move(value)); +} + +void PaintTimingVisualizer::DumpTrace(std::unique_ptr<TracedValue> value) { + TRACE_EVENT_INSTANT1("loading", "PaintTimingVisualizer::LayoutObjectPainted", + TRACE_EVENT_SCOPE_THREAD, "data", std::move(value)); +} + +void PaintTimingVisualizer::RecordMainFrameViewport( + LocalFrameView& frame_view) { + if (!need_recording_viewport) + return; + if (!frame_view.GetFrame().IsMainFrame()) + return; + ScrollableArea* scrollable_area = frame_view.GetScrollableArea(); + DCHECK(scrollable_area); + IntRect viewport_rect = scrollable_area->VisibleContentRect(); + + FloatClipRect float_clip_visual_rect = + FloatClipRect(FloatRect(viewport_rect)); + WebFloatRect float_visual_rect = float_clip_visual_rect.Rect(); + frame_view.GetPaintTimingDetector().ConvertViewportToWindow( + &float_visual_rect); + + std::unique_ptr<TracedValue> value = std::make_unique<TracedValue>(); + CreateQuad(value.get(), "viewport_rect", FloatQuad(float_visual_rect)); + TRACE_EVENT_INSTANT1("loading", "PaintTimingVisualizer::Viewport", + TRACE_EVENT_SCOPE_THREAD, "data", std::move(value)); + need_recording_viewport = false; +} + +// static +bool PaintTimingVisualizer::IsTracingEnabled() { + bool enabled; + TRACE_EVENT_CATEGORY_GROUP_ENABLED("loading", &enabled); + return enabled; +} + +} // namespace blink |