| Flutter Impeller |

Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
impeller::RectanglePacker Class Referenceabstract

Packs rectangles into a specified area without rotating them. More...

`#include <rectangle_packer.h>`

Inheritance diagram for impeller::RectanglePacker:

## Public Member Functions
virtual | ~RectanglePacker ()
virtual bool | AddRect (int width, int height, IPoint16 *loc)=0
| Attempt to add a rect without moving already placed rectangles. More...
virtual Scalar | PercentFull () const =0
| Returns how much area has been filled with rectangles. More...
virtual void | Reset ()=0
| Empty out all previously added rectangles. More...

## Static Public Member Functions
static std::shared_ptr< RectanglePacker > | Factory (int width, int height)
| Return an empty packer with area specified by width and height. More...

## Protected Member Functions
| RectanglePacker (int width, int height)
int | width () const
int | height () const

## Detailed Description

Packs rectangles into a specified area without rotating them.

Definition at line 27 of file rectangle_packer.h.

## Constructor & Destructor Documentation

## ◆ ~RectanglePacker()

virtual impeller::RectanglePacker::~RectanglePacker | ( |  | ) |
| inline virtual

Definition at line 34 of file rectangle_packer.h.

34 {}

## ◆ RectanglePacker()

impeller::RectanglePacker::RectanglePacker | ( | int | width,
|  | int | height
| ) |  |
| inline protected

Definition at line 61 of file rectangle_packer.h.

61 : width_(width), height_(height) {
62 FML_DCHECK(width >= 0);
63 FML_DCHECK(height >= 0);
64 }
impeller::RectanglePacker::width
int width() const
Definition: rectangle_packer.h:66
impeller::RectanglePacker::height
int height() const
Definition: rectangle_packer.h:67

References height(), and width().

## Member Function Documentation

## ◆ AddRect()

virtual bool impeller::RectanglePacker::AddRect | ( | int | width,
|  | int | height,
|  | IPoint16 * | loc
| ) |  |
| pure virtual

Attempt to add a rect without moving already placed rectangles.

Parameters

  [in] | width | The width of the rectangle to add.
  [in] | height | The height of the rectangle to add.
  [out] | loc | If successful, will be set to the position of the upper-left corner of the rectangle.

Returns
  Return true on success; false on failure.

Implemented in impeller::SkylineRectanglePacker.

## ◆ Factory()

std::shared_ptr< RectanglePacker > impeller::RectanglePacker::Factory | ( | int | width,
|  | int | height
| ) |  |
| static

Return an empty packer with area specified by width and height.

Definition at line 175 of file rectangle_packer.cc.

176 {
177 return std::make_shared<SkylineRectanglePacker>(width, height);
178 }

References height(), and width().

Referenced by impeller::ComputeNextAtlasSize(), impeller::testing::TEST(), and impeller::testing::TEST_P().

## ◆ height()

int impeller::RectanglePacker::height | ( |  | ) | const
| inline protected

Definition at line 67 of file rectangle_packer.h.

67 { return height_; }

Referenced by impeller::SkylineRectanglePacker::AddRect(), Factory(), impeller::SkylineRectanglePacker::PercentFull(), and RectanglePacker().

## ◆ PercentFull()

virtual Scalar impeller::RectanglePacker::PercentFull | ( |  | ) | const
| pure virtual

Returns how much area has been filled with rectangles.

Returns
  Percentage as a decimal between 0.0 and 1.0

Implemented in impeller::SkylineRectanglePacker.

## ◆ Reset()

virtual void impeller::RectanglePacker::Reset | ( |  | ) |
| pure virtual

Empty out all previously added rectangles.

Implemented in impeller::SkylineRectanglePacker.

## ◆ width()

int impeller::RectanglePacker::width | ( |  | ) | const
| inline protected

Definition at line 66 of file rectangle_packer.h.

66 { return width_; }

Referenced by impeller::SkylineRectanglePacker::AddRect(), Factory(), impeller::SkylineRectanglePacker::PercentFull(), RectanglePacker(), and impeller::SkylineRectanglePacker::Reset().

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

- impeller/typographer/rectangle_packer.h
- impeller/typographer/rectangle_packer.cc