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 |
11 #include "GrRectanizer.h" | 11 #include "GrRectanizer.h" |
12 #include "GrTBSearch.h" | 12 #include "GrTBSearch.h" |
13 | 13 |
14 #define MIN_HEIGHT_POW2 2 | 14 #define MIN_HEIGHT_POW2 2 |
15 | 15 |
16 class GrRectanizerPow2 : public GrRectanizer { | 16 class GrRectanizerPow2 : public GrRectanizer { |
17 public: | 17 public: |
18 GrRectanizerPow2(int w, int h) : GrRectanizer(w, h) { | 18 GrRectanizerPow2(int w, int h) : GrRectanizer(w, h) { |
19 fNextStripY = 0; | 19 fNextStripY = 0; |
20 fAreaSoFar = 0; | 20 fAreaSoFar = 0; |
21 sk_bzero(fRows, sizeof(fRows)); | 21 sk_bzero(fRows, sizeof(fRows)); |
22 } | 22 } |
23 | 23 |
24 virtual ~GrRectanizerPow2() { | 24 virtual ~GrRectanizerPow2() { |
25 } | 25 } |
26 | 26 |
| 27 virtual void reset() { |
| 28 fNextStripY = 0; |
| 29 fAreaSoFar = 0; |
| 30 sk_bzero(fRows, sizeof(fRows)); |
| 31 } |
| 32 |
27 virtual bool addRect(int w, int h, GrIPoint16* loc); | 33 virtual bool addRect(int w, int h, GrIPoint16* loc); |
28 | 34 |
29 virtual float percentFull() const { | 35 virtual float percentFull() const { |
30 return fAreaSoFar / ((float)this->width() * this->height()); | 36 return fAreaSoFar / ((float)this->width() * this->height()); |
31 } | 37 } |
32 | 38 |
33 virtual int stripToPurge(int height) const { return -1; } | 39 virtual int stripToPurge(int height) const { return -1; } |
34 virtual void purgeStripAtY(int yCoord) { } | 40 virtual void purgeStripAtY(int yCoord) { } |
35 | 41 |
36 /////////////////////////////////////////////////////////////////////////// | 42 /////////////////////////////////////////////////////////////////////////// |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 SkASSERT(fNextStripY <= this->height()); | 118 SkASSERT(fNextStripY <= this->height()); |
113 fAreaSoFar += area; | 119 fAreaSoFar += area; |
114 return true; | 120 return true; |
115 } | 121 } |
116 | 122 |
117 /////////////////////////////////////////////////////////////////////////////// | 123 /////////////////////////////////////////////////////////////////////////////// |
118 | 124 |
119 GrRectanizer* GrRectanizer::Factory(int width, int height) { | 125 GrRectanizer* GrRectanizer::Factory(int width, int height) { |
120 return SkNEW_ARGS(GrRectanizerPow2, (width, height)); | 126 return SkNEW_ARGS(GrRectanizerPow2, (width, height)); |
121 } | 127 } |
OLD | NEW |