diff options
author | robertphillips <robertphillips@google.com> | 2014-06-02 07:15:18 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-06-02 07:15:18 -0700 |
commit | 901e96df6916e6f8ba95a4ea85a2ceac31e7d633 (patch) | |
tree | cd71e8f7860295756a76c2bfe351be2e791f67ac /src/gpu/GrRectanizer_pow2.h | |
parent | a6a8f00a3977e71dbce9da50a32c5e9a51c49285 (diff) |
Add Sample slide for Rectanizers
R=jvanverth@google.com, bsalomon@google.com
Author: robertphillips@google.com
Review URL: https://codereview.chromium.org/303263005
Diffstat (limited to 'src/gpu/GrRectanizer_pow2.h')
-rw-r--r-- | src/gpu/GrRectanizer_pow2.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/gpu/GrRectanizer_pow2.h b/src/gpu/GrRectanizer_pow2.h index c2e45655f1..e9d9d02b0a 100644 --- a/src/gpu/GrRectanizer_pow2.h +++ b/src/gpu/GrRectanizer_pow2.h @@ -10,6 +10,11 @@ #include "GrRectanizer.h" +// This Rectanizer quantizes the incoming rects to powers of 2. Each power +// of two can have, at most, one active row/shelf. Once a row/shelf for +// a particular power of two gets full its fRows entry is recycled to point +// to a new row. +// The skyline algorithm almost always provides a better packing. class GrRectanizerPow2 : public GrRectanizer { public: GrRectanizerPow2(int w, int h) : INHERITED(w, h) { @@ -32,9 +37,12 @@ public: private: static const int kMIN_HEIGHT_POW2 = 2; + static const int kMaxExponent = 16; struct Row { GrIPoint16 fLoc; + // fRowHeight is actually known by this struct's position in fRows + // but it is used to signal if there exists an open row of this height int fRowHeight; bool canAddWidth(int width, int containerWidth) const { @@ -42,14 +50,16 @@ private: } }; - Row fRows[16]; + Row fRows[kMaxExponent]; // 0-th entry will be unused int fNextStripY; int32_t fAreaSoFar; static int HeightToRowIndex(int height) { SkASSERT(height >= kMIN_HEIGHT_POW2); - return 32 - SkCLZ(height - 1); + int index = 32 - SkCLZ(height - 1); + SkASSERT(index < kMaxExponent); + return index; } bool canAddStrip(int height) const { |