Flutter Engine
 
Loading...
Searching...
No Matches
flutter::DlVertexPainter Class Referencefinal

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

#include <stopwatch_dl.h>

Public Member Functions

 DlVertexPainter (std::vector< DlPoint > &vertices_storage, std::vector< DlColor > &color_storage)
 
void DrawRect (const DlRect &rect, const DlColor &color)
 Draws a rectangle with the given color to a buffer.
 
std::shared_ptr< DlVerticesIntoVertices (const DlRect &bounds_rect)
 

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 47 of file stopwatch_dl.h.

Constructor & Destructor Documentation

◆ DlVertexPainter()

flutter::DlVertexPainter::DlVertexPainter ( std::vector< DlPoint > &  vertices_storage,
std::vector< DlColor > &  color_storage 
)

Definition at line 123 of file stopwatch_dl.cc.

125 : vertices_(vertices_storage), colors_(color_storage) {}

Member Function Documentation

◆ DrawRect()

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

Draws a rectangle with the given color to a buffer.

Definition at line 127 of file stopwatch_dl.cc.

127 {
128 const DlScalar left = rect.GetLeft();
129 const DlScalar top = rect.GetTop();
130 const DlScalar right = rect.GetRight();
131 const DlScalar bottom = rect.GetBottom();
132
133 FML_DCHECK(6 + colors_offset_ <= vertices_.size());
134 FML_DCHECK(6 + colors_offset_ <= colors_.size());
135
136 // Draw 6 vertices representing 2 triangles.
137 vertices_[vertices_offset_++] = DlPoint(left, top); // tl tr
138 vertices_[vertices_offset_++] = DlPoint(right, top); // br
139 vertices_[vertices_offset_++] = DlPoint(right, bottom); //
140 vertices_[vertices_offset_++] = DlPoint(right, bottom); // tl
141 vertices_[vertices_offset_++] = DlPoint(left, bottom); // bl br
142 vertices_[vertices_offset_++] = DlPoint(left, top); //
143 for (size_t i = 0u; i < 6u; i++) {
144 colors_[colors_offset_++] = color;
145 }
146}
#define FML_DCHECK(condition)
Definition logging.h:122
impeller::Scalar DlScalar
impeller::Point DlPoint

References FML_DCHECK, impeller::TRect< T >::GetBottom(), impeller::TRect< T >::GetLeft(), impeller::TRect< T >::GetRight(), impeller::TRect< T >::GetTop(), and i.

Referenced by flutter::DlStopwatchVisualizer::Visualize().

◆ IntoVertices()

std::shared_ptr< DlVertices > flutter::DlVertexPainter::IntoVertices ( const DlRect bounds_rect)

Converts the buffered vertices into a |DlVertices| object.

Note
This method clears the buffer.

Definition at line 148 of file stopwatch_dl.cc.

149 {
150 return DlVertices::Make(
152 /*vertex_count=*/vertices_.size(),
153 /*vertices=*/vertices_.data(),
154 /*texture_coordinates=*/nullptr,
155 /*colors=*/colors_.data(),
156 /*index_count=*/0,
157 /*indices=*/nullptr,
158 /*bounds=*/&bounds_rect);
159}
static std::shared_ptr< DlVertices > Make(DlVertexMode mode, int vertex_count, const DlPoint vertices[], const DlPoint texture_coordinates[], const DlColor colors[], int index_count=0, const uint16_t indices[]=nullptr, const DlRect *bounds=nullptr)
Constructs a DlVector with compact inline storage for all of its required and optional lists of data.
@ kTriangles
The vertices are taken 3 at a time to form a triangle.

References flutter::kTriangles, and flutter::DlVertices::Make().

Referenced by flutter::DlStopwatchVisualizer::Visualize().


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