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

Side by Side Diff: src/gpu/GrRectanizer_pow2.h

Issue 309683002: Move GrIPoint16 to SkIPoint16 (and remove GrPoint.h) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update to ToT Created 6 years, 6 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 unified diff | Download patch
« no previous file with comments | « src/gpu/GrRectanizer.h ('k') | src/gpu/GrRectanizer_pow2.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrRectanizer_pow2_DEFINED 8 #ifndef GrRectanizer_pow2_DEFINED
9 #define GrRectanizer_pow2_DEFINED 9 #define GrRectanizer_pow2_DEFINED
10 10
11 #include "GrRectanizer.h" 11 #include "GrRectanizer.h"
12 #include "SkPoint.h"
12 13
13 // This Rectanizer quantizes the incoming rects to powers of 2. Each power 14 // This Rectanizer quantizes the incoming rects to powers of 2. Each power
14 // of two can have, at most, one active row/shelf. Once a row/shelf for 15 // of two can have, at most, one active row/shelf. Once a row/shelf for
15 // a particular power of two gets full its fRows entry is recycled to point 16 // a particular power of two gets full its fRows entry is recycled to point
16 // to a new row. 17 // to a new row.
17 // The skyline algorithm almost always provides a better packing. 18 // The skyline algorithm almost always provides a better packing.
18 class GrRectanizerPow2 : public GrRectanizer { 19 class GrRectanizerPow2 : public GrRectanizer {
19 public: 20 public:
20 GrRectanizerPow2(int w, int h) : INHERITED(w, h) { 21 GrRectanizerPow2(int w, int h) : INHERITED(w, h) {
21 this->reset(); 22 this->reset();
22 } 23 }
23 24
24 virtual ~GrRectanizerPow2() { } 25 virtual ~GrRectanizerPow2() { }
25 26
26 virtual void reset() SK_OVERRIDE { 27 virtual void reset() SK_OVERRIDE {
27 fNextStripY = 0; 28 fNextStripY = 0;
28 fAreaSoFar = 0; 29 fAreaSoFar = 0;
29 sk_bzero(fRows, sizeof(fRows)); 30 sk_bzero(fRows, sizeof(fRows));
30 } 31 }
31 32
32 virtual bool addRect(int w, int h, GrIPoint16* loc) SK_OVERRIDE; 33 virtual bool addRect(int w, int h, SkIPoint16* loc) SK_OVERRIDE;
33 34
34 virtual float percentFull() const SK_OVERRIDE { 35 virtual float percentFull() const SK_OVERRIDE {
35 return fAreaSoFar / ((float)this->width() * this->height()); 36 return fAreaSoFar / ((float)this->width() * this->height());
36 } 37 }
37 38
38 private: 39 private:
39 static const int kMIN_HEIGHT_POW2 = 2; 40 static const int kMIN_HEIGHT_POW2 = 2;
40 static const int kMaxExponent = 16; 41 static const int kMaxExponent = 16;
41 42
42 struct Row { 43 struct Row {
43 GrIPoint16 fLoc; 44 SkIPoint16 fLoc;
44 // fRowHeight is actually known by this struct's position in fRows 45 // fRowHeight is actually known by this struct's position in fRows
45 // but it is used to signal if there exists an open row of this height 46 // but it is used to signal if there exists an open row of this height
46 int fRowHeight; 47 int fRowHeight;
47 48
48 bool canAddWidth(int width, int containerWidth) const { 49 bool canAddWidth(int width, int containerWidth) const {
49 return fLoc.fX + width <= containerWidth; 50 return fLoc.fX + width <= containerWidth;
50 } 51 }
51 }; 52 };
52 53
53 Row fRows[kMaxExponent]; // 0-th entry will be unused 54 Row fRows[kMaxExponent]; // 0-th entry will be unused
(...skipping 15 matching lines...) Expand all
69 void initRow(Row* row, int rowHeight) { 70 void initRow(Row* row, int rowHeight) {
70 row->fLoc.set(0, fNextStripY); 71 row->fLoc.set(0, fNextStripY);
71 row->fRowHeight = rowHeight; 72 row->fRowHeight = rowHeight;
72 fNextStripY += rowHeight; 73 fNextStripY += rowHeight;
73 } 74 }
74 75
75 typedef GrRectanizer INHERITED; 76 typedef GrRectanizer INHERITED;
76 }; 77 };
77 78
78 #endif 79 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrRectanizer.h ('k') | src/gpu/GrRectanizer_pow2.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698