Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
RectanizerPow2.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2010 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
9
10namespace skgpu {
11
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}
55
56///////////////////////////////////////////////////////////////////////////////
57
58// factory is now in RectanizerSkyline.cpp
59//Rectanizer* Rectanizer::Factory(int width, int height) {
60// return new RectanizerPow2(width, height);
61//}
62
63} // End of namespace skgpu
#define SkASSERT(cond)
Definition SkAssert.h:116
static uint32_t GrNextPow2(uint32_t n)
Definition SkMathPriv.h:302
bool addRect(int w, int h, SkIPoint16 *loc) final
int width() const
Definition Rectanizer.h:26
int height() const
Definition Rectanizer.h:27
int32_t height
int32_t width
int16_t fX
x-axis value used by SkIPoint16
Definition SkIPoint16.h:18