Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
skgpu::RectanizerPow2 Class Referencefinal

#include <RectanizerPow2.h>

Inheritance diagram for skgpu::RectanizerPow2:
skgpu::Rectanizer

Public Member Functions

 RectanizerPow2 (int w, int h)
 
 ~RectanizerPow2 () final
 
void reset () final
 
bool addRect (int w, int h, SkIPoint16 *loc) final
 
float percentFull () const final
 
- Public Member Functions inherited from skgpu::Rectanizer
 Rectanizer (int width, int height)
 
virtual ~Rectanizer ()
 
int width () const
 
int height () const
 
bool addPaddedRect (int width, int height, int16_t padding, SkIPoint16 *loc)
 

Additional Inherited Members

- Static Public Member Functions inherited from skgpu::Rectanizer
static RectanizerFactory (int width, int height)
 

Detailed Description

Definition at line 28 of file RectanizerPow2.h.

Constructor & Destructor Documentation

◆ RectanizerPow2()

skgpu::RectanizerPow2::RectanizerPow2 ( int  w,
int  h 
)
inline

Definition at line 30 of file RectanizerPow2.h.

30 : Rectanizer(w, h) {
31 this->reset();
32 }
Rectanizer(int width, int height)
Definition Rectanizer.h:17
SkScalar w
SkScalar h

◆ ~RectanizerPow2()

skgpu::RectanizerPow2::~RectanizerPow2 ( )
inlinefinal

Definition at line 34 of file RectanizerPow2.h.

34{}

Member Function Documentation

◆ addRect()

bool skgpu::RectanizerPow2::addRect ( int  w,
int  h,
SkIPoint16 loc 
)
finalvirtual

Implements skgpu::Rectanizer.

Definition at line 12 of file RectanizerPow2.cpp.

12 {
13 if ((unsigned)width > (unsigned)this->width() ||
14 (unsigned)height > (unsigned)this->height()) {
15 return false;
16 }
17
18 int32_t area = width * height; // computed here since height will be modified
19
21 if (height < kMIN_HEIGHT_POW2) {
22 height = kMIN_HEIGHT_POW2;
23 }
24
25 Row* row = &fRows[HeightToRowIndex(height)];
26 SkASSERT(row->fRowHeight == 0 || row->fRowHeight == height);
27
28 if (0 == row->fRowHeight) {
29 if (!this->canAddStrip(height)) {
30 return false;
31 }
32 this->initRow(row, height);
33 } else {
34 if (!row->canAddWidth(width, this->width())) {
35 if (!this->canAddStrip(height)) {
36 return false;
37 }
38 // that row is now "full", so retarget our Row record for
39 // another one
40 this->initRow(row, height);
41 }
42 }
43
44 SkASSERT(row->fRowHeight == height);
45 SkASSERT(row->canAddWidth(width, this->width()));
46 *loc = row->fLoc;
47 row->fLoc.fX += width;
48
49 SkASSERT(row->fLoc.fX <= this->width());
50 SkASSERT(row->fLoc.fY <= this->height());
51 SkASSERT(fNextStripY <= this->height());
52 fAreaSoFar += area;
53 return true;
54}
#define SkASSERT(cond)
Definition SkAssert.h:116
static uint32_t GrNextPow2(uint32_t n)
Definition SkMathPriv.h:302
int width() const
Definition Rectanizer.h:26
int height() const
Definition Rectanizer.h:27
int16_t fX
x-axis value used by SkIPoint16
Definition SkIPoint16.h:18

◆ percentFull()

float skgpu::RectanizerPow2::percentFull ( ) const
inlinefinalvirtual

Implements skgpu::Rectanizer.

Definition at line 44 of file RectanizerPow2.h.

44 {
45 return fAreaSoFar / ((float)this->width() * this->height());
46 }

◆ reset()

void skgpu::RectanizerPow2::reset ( )
inlinefinalvirtual

Implements skgpu::Rectanizer.

Definition at line 36 of file RectanizerPow2.h.

36 {
37 fNextStripY = 0;
38 fAreaSoFar = 0;
39 sk_bzero(fRows, sizeof(fRows));
40 }
static void sk_bzero(void *buffer, size_t size)
Definition SkMalloc.h:105

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