2 * Copyright 2010 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #include "src/gpu/RectanizerPow2.h"
12 bool RectanizerPow2::addRect(int width, int height, SkIPoint16* loc) {
13 if ((unsigned)width > (unsigned)this->width() ||
14 (unsigned)height > (unsigned)this->height()) {
18 int32_t area = width * height; // computed here since height will be modified
20 height = GrNextPow2(height);
21 if (height < kMIN_HEIGHT_POW2) {
22 height = kMIN_HEIGHT_POW2;
25 Row* row = &fRows[HeightToRowIndex(height)];
26 SkASSERT(row->fRowHeight == 0 || row->fRowHeight == height);
28 if (0 == row->fRowHeight) {
29 if (!this->canAddStrip(height)) {
32 this->initRow(row, height);
34 if (!row->canAddWidth(width, this->width())) {
35 if (!this->canAddStrip(height)) {
38 // that row is now "full", so retarget our Row record for
40 this->initRow(row, height);
44 SkASSERT(row->fRowHeight == height);
45 SkASSERT(row->canAddWidth(width, this->width()));
47 row->fLoc.fX += width;
49 SkASSERT(row->fLoc.fX <= this->width());
50 SkASSERT(row->fLoc.fY <= this->height());
51 SkASSERT(fNextStripY <= this->height());
56 ///////////////////////////////////////////////////////////////////////////////
58 // factory is now in RectanizerSkyline.cpp
59 //Rectanizer* Rectanizer::Factory(int width, int height) {
60 // return new RectanizerPow2(width, height);
63 } // End of namespace skgpu