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 | 9 |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 int fRowHeight; | 40 int fRowHeight; |
41 | 41 |
42 bool canAddWidth(int width, int containerWidth) const { | 42 bool canAddWidth(int width, int containerWidth) const { |
43 return fLoc.fX + width <= containerWidth; | 43 return fLoc.fX + width <= containerWidth; |
44 } | 44 } |
45 }; | 45 }; |
46 | 46 |
47 Row fRows[16]; | 47 Row fRows[16]; |
48 | 48 |
49 static int HeightToRowIndex(int height) { | 49 static int HeightToRowIndex(int height) { |
50 GrAssert(height >= MIN_HEIGHT_POW2); | 50 SkASSERT(height >= MIN_HEIGHT_POW2); |
51 return 32 - Gr_clz(height - 1); | 51 return 32 - Gr_clz(height - 1); |
52 } | 52 } |
53 | 53 |
54 int fNextStripY; | 54 int fNextStripY; |
55 int32_t fAreaSoFar; | 55 int32_t fAreaSoFar; |
56 | 56 |
57 bool canAddStrip(int height) const { | 57 bool canAddStrip(int height) const { |
58 return fNextStripY + height <= this->height(); | 58 return fNextStripY + height <= this->height(); |
59 } | 59 } |
60 | 60 |
(...skipping 16 matching lines...) Expand all Loading... |
77 We use bsearch, but there may be more than one row with the same height, | 77 We use bsearch, but there may be more than one row with the same height, |
78 so we actually search for height-1, which can only be a pow2 itself if | 78 so we actually search for height-1, which can only be a pow2 itself if |
79 height == 2. Thus we set a minimum height. | 79 height == 2. Thus we set a minimum height. |
80 */ | 80 */ |
81 height = GrNextPow2(height); | 81 height = GrNextPow2(height); |
82 if (height < MIN_HEIGHT_POW2) { | 82 if (height < MIN_HEIGHT_POW2) { |
83 height = MIN_HEIGHT_POW2; | 83 height = MIN_HEIGHT_POW2; |
84 } | 84 } |
85 | 85 |
86 Row* row = &fRows[HeightToRowIndex(height)]; | 86 Row* row = &fRows[HeightToRowIndex(height)]; |
87 GrAssert(row->fRowHeight == 0 || row->fRowHeight == height); | 87 SkASSERT(row->fRowHeight == 0 || row->fRowHeight == height); |
88 | 88 |
89 if (0 == row->fRowHeight) { | 89 if (0 == row->fRowHeight) { |
90 if (!this->canAddStrip(height)) { | 90 if (!this->canAddStrip(height)) { |
91 return false; | 91 return false; |
92 } | 92 } |
93 this->initRow(row, height); | 93 this->initRow(row, height); |
94 } else { | 94 } else { |
95 if (!row->canAddWidth(width, this->width())) { | 95 if (!row->canAddWidth(width, this->width())) { |
96 if (!this->canAddStrip(height)) { | 96 if (!this->canAddStrip(height)) { |
97 return false; | 97 return false; |
98 } | 98 } |
99 // that row is now "full", so retarget our Row record for | 99 // that row is now "full", so retarget our Row record for |
100 // another one | 100 // another one |
101 this->initRow(row, height); | 101 this->initRow(row, height); |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 GrAssert(row->fRowHeight == height); | 105 SkASSERT(row->fRowHeight == height); |
106 GrAssert(row->canAddWidth(width, this->width())); | 106 SkASSERT(row->canAddWidth(width, this->width())); |
107 *loc = row->fLoc; | 107 *loc = row->fLoc; |
108 row->fLoc.fX += width; | 108 row->fLoc.fX += width; |
109 | 109 |
110 GrAssert(row->fLoc.fX <= this->width()); | 110 SkASSERT(row->fLoc.fX <= this->width()); |
111 GrAssert(row->fLoc.fY <= this->height()); | 111 SkASSERT(row->fLoc.fY <= this->height()); |
112 GrAssert(fNextStripY <= this->height()); | 112 SkASSERT(fNextStripY <= this->height()); |
113 fAreaSoFar += area; | 113 fAreaSoFar += area; |
114 return true; | 114 return true; |
115 } | 115 } |
116 | 116 |
117 /////////////////////////////////////////////////////////////////////////////// | 117 /////////////////////////////////////////////////////////////////////////////// |
118 | 118 |
119 GrRectanizer* GrRectanizer::Factory(int width, int height) { | 119 GrRectanizer* GrRectanizer::Factory(int width, int height) { |
120 return SkNEW_ARGS(GrRectanizerFIFO, (width, height)); | 120 return SkNEW_ARGS(GrRectanizerFIFO, (width, height)); |
121 } | 121 } |
OLD | NEW |