Flutter Engine
 
Loading...
Searching...
No Matches
dl_complexity_helper.cc
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
6
8
9namespace {
10
13
14class DlComplexityPathReceiver : public flutter::DlPathReceiver {
15 public:
16 void MoveTo(const DlPoint& p2, bool will_be_closed) override {}
17 void LineTo(const DlPoint& p2) override { line_verb_count++; }
18 void QuadTo(const DlPoint& cp, const DlPoint& p2) override {
19 quad_verb_count++;
20 }
21 bool ConicTo(const DlPoint& cp, const DlPoint& p2, DlScalar weight) override {
22 conic_verb_count++;
23 return true;
24 }
25 void CubicTo(const DlPoint& cp1,
26 const DlPoint& cp2,
27 const DlPoint& p2) override {
28 cubic_verb_count++;
29 }
30 void Close() override {}
31
32 uint32_t line_verb_count;
33 uint32_t quad_verb_count;
34 uint32_t conic_verb_count;
35 uint32_t cubic_verb_count;
36};
37
38} // namespace
39
40namespace flutter {
41
43 const DlPath& dl_path,
44 unsigned int line_verb_cost,
45 unsigned int quad_verb_cost,
46 unsigned int conic_verb_cost,
47 unsigned int cubic_verb_cost) {
48 DlComplexityPathReceiver receiver;
49 dl_path.Dispatch(receiver);
50 return (line_verb_cost * receiver.line_verb_count) +
51 (quad_verb_cost * receiver.quad_verb_count) +
52 (conic_verb_cost * receiver.conic_verb_count) +
53 (cubic_verb_cost * receiver.cubic_verb_count);
54}
55
56} // namespace flutter
unsigned int CalculatePathComplexity(const DlPath &dl_path, unsigned int line_verb_cost, unsigned int quad_verb_cost, unsigned int conic_verb_cost, unsigned int cubic_verb_cost)
void Dispatch(DlPathReceiver &receiver) const override
Definition dl_path.cc:120
Collection of functions to receive path segments from the underlying path representation via the DlPa...
Definition path_source.h:42
virtual void CubicTo(const Point &cp1, const Point &cp2, const Point &p2)=0
virtual void LineTo(const Point &p2)=0
virtual void QuadTo(const Point &cp, const Point &p2)=0
virtual void Close()=0
virtual void MoveTo(const Point &p2, bool will_be_closed)=0
virtual bool ConicTo(const Point &cp, const Point &p2, Scalar weight)
Definition path_source.h:48
impeller::Scalar DlScalar
impeller::Point DlPoint