OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrRectanizer_pow2.h" | 9 #include "GrRectanizer_pow2.h" |
10 #include "GrTBSearch.h" | |
11 | 10 |
12 bool GrRectanizerPow2::addRect(int width, int height, GrIPoint16* loc) { | 11 bool GrRectanizerPow2::addRect(int width, int height, GrIPoint16* loc) { |
13 if ((unsigned)width > (unsigned)this->width() || | 12 if ((unsigned)width > (unsigned)this->width() || |
14 (unsigned)height > (unsigned)this->height()) { | 13 (unsigned)height > (unsigned)this->height()) { |
15 return false; | 14 return false; |
16 } | 15 } |
17 | 16 |
18 int32_t area = width * height; | 17 int32_t area = width * height; // computed here since height will be modifie
d |
19 | 18 |
20 /* | |
21 We use bsearch, but there may be more than one row with the same height, | |
22 so we actually search for height-1, which can only be a pow2 itself if | |
23 height == 2. Thus we set a minimum height. | |
24 */ | |
25 height = GrNextPow2(height); | 19 height = GrNextPow2(height); |
26 if (height < kMIN_HEIGHT_POW2) { | 20 if (height < kMIN_HEIGHT_POW2) { |
27 height = kMIN_HEIGHT_POW2; | 21 height = kMIN_HEIGHT_POW2; |
28 } | 22 } |
29 | 23 |
30 Row* row = &fRows[HeightToRowIndex(height)]; | 24 Row* row = &fRows[HeightToRowIndex(height)]; |
31 SkASSERT(row->fRowHeight == 0 || row->fRowHeight == height); | 25 SkASSERT(row->fRowHeight == 0 || row->fRowHeight == height); |
32 | 26 |
33 if (0 == row->fRowHeight) { | 27 if (0 == row->fRowHeight) { |
34 if (!this->canAddStrip(height)) { | 28 if (!this->canAddStrip(height)) { |
(...skipping 22 matching lines...) Expand all Loading... |
57 fAreaSoFar += area; | 51 fAreaSoFar += area; |
58 return true; | 52 return true; |
59 } | 53 } |
60 | 54 |
61 /////////////////////////////////////////////////////////////////////////////// | 55 /////////////////////////////////////////////////////////////////////////////// |
62 | 56 |
63 // factory is now in GrRectanizer_skyline.cpp | 57 // factory is now in GrRectanizer_skyline.cpp |
64 //GrRectanizer* GrRectanizer::Factory(int width, int height) { | 58 //GrRectanizer* GrRectanizer::Factory(int width, int height) { |
65 // return SkNEW_ARGS(GrRectanizerPow2, (width, height)); | 59 // return SkNEW_ARGS(GrRectanizerPow2, (width, height)); |
66 //} | 60 //} |
OLD | NEW |