Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
flutter::DlVertexPainter Class Referencefinal

Provides canvas-like painting methods that actually build vertices. More...

#include <stopwatch_dl.h>

Public Member Functions

void DrawRect (const SkRect &rect, const DlColor &color)
 Draws a rectangle with the given color to a buffer. More...
 
std::shared_ptr< DlVerticesIntoVertices ()
 

Detailed Description

Provides canvas-like painting methods that actually build vertices.

The goal is minimally invasive rendering for the performance monitor.

The methods in this class are intended to be used by |DlStopwatchVisualizer| only. The rationale is the creating lines, rectangles, and paths (while OK for general apps) would cause non-trivial work for the performance monitor due to tessellation per-frame.

Note
A goal of this class was to make updating the performance monitor (and keeping it in sync with the |SkStopwatchVisualizer|) as easy as possible (i.e. not having to do triangle-math).

Definition at line 39 of file stopwatch_dl.h.

Member Function Documentation

◆ DrawRect()

void flutter::DlVertexPainter::DrawRect ( const SkRect rect,
const DlColor color 
)

Draws a rectangle with the given color to a buffer.

Definition at line 112 of file stopwatch_dl.cc.

112 {
113 // Draw 6 vertices representing 2 triangles.
114 auto const left = rect.x();
115 auto const top = rect.y();
116 auto const right = rect.right();
117 auto const bottom = rect.bottom();
118
119 auto const vertices = std::array<SkPoint, 6>{
120 SkPoint::Make(left, top), // tl tr
121 SkPoint::Make(right, top), // br
122 SkPoint::Make(right, bottom), //
123 SkPoint::Make(right, bottom), // tl
124 SkPoint::Make(left, bottom), // bl br
125 SkPoint::Make(left, top) //
126 };
127
128 auto const colors = std::array<DlColor, 6>{
129 color, // tl tr
130 color, // br
131 color, //
132 color, // tl
133 color, // bl br
134 color //
135 };
136
137 vertices_.insert(vertices_.end(), vertices.begin(), vertices.end());
138 colors_.insert(colors_.end(), colors.begin(), colors.end());
139}
DlColor color
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
PODArray< SkColor > colors
Definition: SkRecords.h:276
static constexpr SkPoint Make(float x, float y)
Definition: SkPoint_impl.h:173

◆ IntoVertices()

std::shared_ptr< DlVertices > flutter::DlVertexPainter::IntoVertices ( )

Converts the buffered vertices into a |DlVertices| object.

Note
This method clears the buffer.

Definition at line 141 of file stopwatch_dl.cc.

141 {
142 auto const result = DlVertices::Make(
144 /*vertex_count=*/vertices_.size(),
145 /*vertices=*/vertices_.data(),
146 /*texture_coordinates=*/nullptr,
147 /*colors=*/colors_.data());
148 vertices_.clear();
149 colors_.clear();
150 return result;
151}
static std::shared_ptr< DlVertices > Make(DlVertexMode mode, int vertex_count, const SkPoint vertices[], const SkPoint texture_coordinates[], const DlColor colors[], int index_count=0, const uint16_t indices[]=nullptr)
Constructs a DlVector with compact inline storage for all of its required and optional lists of data.
Definition: dl_vertices.cc:39
GAsyncResult * result
@ kTriangles
The vertices are taken 3 at a time to form a triangle.

The documentation for this class was generated from the following files: