Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Unified Diff: src/gpu/GrRectanizer_pow2.cpp

Issue 304313002: Add testing for Rectanizer-derived classes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Renaming file Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrRectanizer_pow2.h ('k') | src/gpu/GrRectanizer_skyline.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrRectanizer_pow2.cpp
diff --git a/src/gpu/GrRectanizer.cpp b/src/gpu/GrRectanizer_pow2.cpp
similarity index 54%
rename from src/gpu/GrRectanizer.cpp
rename to src/gpu/GrRectanizer_pow2.cpp
index 9f0d846e6c986d73fae36b765d51c7a4f8803ad6..d92e80c2d55bb2a6167a7f734ccf360a191b724f 100644
--- a/src/gpu/GrRectanizer.cpp
+++ b/src/gpu/GrRectanizer_pow2.cpp
@@ -6,71 +6,9 @@
* found in the LICENSE file.
*/
-
-
-#include "GrRectanizer.h"
+#include "GrRectanizer_pow2.h"
#include "GrTBSearch.h"
-#define MIN_HEIGHT_POW2 2
-
-class GrRectanizerPow2 : public GrRectanizer {
-public:
- GrRectanizerPow2(int w, int h) : GrRectanizer(w, h) {
- fNextStripY = 0;
- fAreaSoFar = 0;
- sk_bzero(fRows, sizeof(fRows));
- }
-
- virtual ~GrRectanizerPow2() {
- }
-
- virtual void reset() {
- fNextStripY = 0;
- fAreaSoFar = 0;
- sk_bzero(fRows, sizeof(fRows));
- }
-
- virtual bool addRect(int w, int h, GrIPoint16* loc);
-
- virtual float percentFull() const {
- return fAreaSoFar / ((float)this->width() * this->height());
- }
-
- virtual int stripToPurge(int height) const { return -1; }
- virtual void purgeStripAtY(int yCoord) { }
-
- ///////////////////////////////////////////////////////////////////////////
-
- struct Row {
- GrIPoint16 fLoc;
- int fRowHeight;
-
- bool canAddWidth(int width, int containerWidth) const {
- return fLoc.fX + width <= containerWidth;
- }
- };
-
- Row fRows[16];
-
- static int HeightToRowIndex(int height) {
- SkASSERT(height >= MIN_HEIGHT_POW2);
- return 32 - SkCLZ(height - 1);
- }
-
- int fNextStripY;
- int32_t fAreaSoFar;
-
- bool canAddStrip(int height) const {
- return fNextStripY + height <= this->height();
- }
-
- void initRow(Row* row, int rowHeight) {
- row->fLoc.set(0, fNextStripY);
- row->fRowHeight = rowHeight;
- fNextStripY += rowHeight;
- }
-};
-
bool GrRectanizerPow2::addRect(int width, int height, GrIPoint16* loc) {
if ((unsigned)width > (unsigned)this->width() ||
(unsigned)height > (unsigned)this->height()) {
@@ -85,8 +23,8 @@ bool GrRectanizerPow2::addRect(int width, int height, GrIPoint16* loc) {
height == 2. Thus we set a minimum height.
*/
height = GrNextPow2(height);
- if (height < MIN_HEIGHT_POW2) {
- height = MIN_HEIGHT_POW2;
+ if (height < kMIN_HEIGHT_POW2) {
+ height = kMIN_HEIGHT_POW2;
}
Row* row = &fRows[HeightToRowIndex(height)];
« no previous file with comments | « src/gpu/GrRectanizer_pow2.h ('k') | src/gpu/GrRectanizer_skyline.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698