Flutter Impeller
uber_sdf_geometry.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_IMPELLER_ENTITY_GEOMETRY_UBER_SDF_GEOMETRY_H_
6 #define FLUTTER_IMPELLER_ENTITY_GEOMETRY_UBER_SDF_GEOMETRY_H_
7 
10 
11 namespace impeller {
12 
13 /// Geometry for rendering shapes using the UberSDF shader.
14 class UberSDFGeometry final : public Geometry {
15  public:
16  explicit UberSDFGeometry(const UberSDFParameters& params);
17 
18  ~UberSDFGeometry() override;
19 
20  // |Geometry|
21  // Returns the mesh that the SDF is drawn onto. This is a superset of the
22  // drawn SDF shape, and is not necessarily "tight" around the drawn shape. In
23  // other words, this is a bounding container mesh onto which the smaller SDF
24  // shape is drawn.
26  const Entity& entity,
27  RenderPass& pass) const override;
28 
29  // |Geometry|
30  std::optional<Rect> GetCoverage(const Matrix& transform) const override;
31 
32  // |Geometry|
33  bool CoversArea(const Matrix& transform, const IRect& rect) const override;
34 
35  // |Geometry|
36  bool IsAxisAlignedRect() const override;
37 
38  private:
39  UberSDFParameters params_;
40 
41  // Returns the bounds rectangle of the SDF, expanded to account for stroke
42  // width and AA.
43  //
44  // The `transform` argument is used to determine the exact stroke width and AA
45  // padding to apply. But the returned rectangle is in local space;
46  // `transform` is not applied to the returned bounds rectangle.
47  Rect GetExpandedBounds(const Matrix& transform) const;
48 };
49 
50 } // namespace impeller
51 
52 #endif // FLUTTER_IMPELLER_ENTITY_GEOMETRY_UBER_SDF_GEOMETRY_H_
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:30
Geometry for rendering shapes using the UberSDF shader.
GeometryResult GetPositionBuffer(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
bool IsAxisAlignedRect() const override
bool CoversArea(const Matrix &transform, const IRect &rect) const override
Determines if this geometry, transformed by the given transform, will completely cover all of the pix...
UberSDFGeometry(const UberSDFParameters &params)
std::optional< Rect > GetCoverage(const Matrix &transform) const override
The coverage rectangle of this geometry, transformed by the transform argument.
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
Parameters for rendering shapes using the UberSDF shader.