Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
stopwatch_dl.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_FLOW_STOPWATCH_DL_H_
6#define FLUTTER_FLOW_STOPWATCH_DL_H_
7
8#include "flow/stopwatch.h"
9
10namespace flutter {
11
12//------------------------------------------------------------------------------
13/// A stopwatch visualizer that uses DisplayList (|DlCanvas|) to draw.
14///
15/// @note This is the newer non-backend specific version, that works in both
16/// Skia and Impeller. The older Skia-specific version is
17/// |SkStopwatchVisualizer|, which still should be used for Skia-specific
18/// optimizations.
20 public:
21 explicit DlStopwatchVisualizer(const Stopwatch& stopwatch)
22 : StopwatchVisualizer(stopwatch) {}
23
24 void Visualize(DlCanvas* canvas, const SkRect& rect) const override;
25};
26
27/// @brief Provides canvas-like painting methods that actually build vertices.
28///
29/// The goal is minimally invasive rendering for the performance monitor.
30///
31/// The methods in this class are intended to be used by |DlStopwatchVisualizer|
32/// only. The rationale is the creating lines, rectangles, and paths (while OK
33/// for general apps) would cause non-trivial work for the performance monitor
34/// due to tessellation per-frame.
35///
36/// @note A goal of this class was to make updating the performance monitor
37/// (and keeping it in sync with the |SkStopwatchVisualizer|) as easy as
38/// possible (i.e. not having to do triangle-math).
39class DlVertexPainter final {
40 public:
41 /// Draws a rectangle with the given color to a buffer.
42 void DrawRect(const SkRect& rect, const DlColor& color);
43
44 /// Converts the buffered vertices into a |DlVertices| object.
45 ///
46 /// @note This method clears the buffer.
47 std::shared_ptr<DlVertices> IntoVertices();
48
49 private:
50 std::vector<SkPoint> vertices_;
51 std::vector<DlColor> colors_;
52};
53
54} // namespace flutter
55
56#endif // FLUTTER_FLOW_STOPWATCH_DL_H_
SkColor4f color
Developer-facing API for rendering anything within the engine.
Definition dl_canvas.h:37
void Visualize(DlCanvas *canvas, const SkRect &rect) const override
Renders the stopwatch as a graph.
DlStopwatchVisualizer(const Stopwatch &stopwatch)
Provides canvas-like painting methods that actually build vertices.
void DrawRect(const SkRect &rect, const DlColor &color)
Draws a rectangle with the given color to a buffer.
std::shared_ptr< DlVertices > IntoVertices()
Abstract class for visualizing (i.e. drawing) a stopwatch.
Definition stopwatch.h:93