Flutter Impeller
impeller::RectanglePacker Class Referenceabstract

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

#include <rectangle_packer.h>

Inheritance diagram for impeller::RectanglePacker:
impeller::SkylineRectanglePacker

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< RectanglePackerFactory (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 ( )
inlinevirtual

Definition at line 34 of file rectangle_packer.h.

34 {}

◆ RectanglePacker()

impeller::RectanglePacker::RectanglePacker ( int  width,
int  height 
)
inlineprotected

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  }

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]widthThe width of the rectangle to add.
[in]heightThe height of the rectangle to add.
[out]locIf 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
inlineprotected

◆ 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
inlineprotected

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