Chromium Code Reviews| Index: src/core/SkScan_AntiPath.cpp |
| diff --git a/src/core/SkScan_AntiPath.cpp b/src/core/SkScan_AntiPath.cpp |
| index e5c67a958af2ef2069ff7ec1fff2a75e402a3e39..5d46d254eb141329c23ebcd240ef3672fee0986a 100644 |
| --- a/src/core/SkScan_AntiPath.cpp |
| +++ b/src/core/SkScan_AntiPath.cpp |
| @@ -108,7 +108,7 @@ public: |
| virtual ~SuperBlitter() { |
| this->flush(); |
| - sk_free(fRuns.fRuns); |
| + sk_free(fRunsBuffer); |
| } |
| /// Once fRuns contains a complete supersampled row, flush() blits |
| @@ -123,31 +123,49 @@ public: |
| virtual void blitRect(int x, int y, int width, int height) SK_OVERRIDE; |
| private: |
|
robertphillips
2014/07/16 12:33:11
Move this comment down into getRunsSz ?
krajcevski
2014/07/16 16:36:03
Done.
|
| + // extra one to store the zero at the end |
|
robertphillips
2014/07/16 12:33:11
// The next 3 variables implement a circular buffe
krajcevski
2014/07/16 16:36:03
Done.
|
| + int fRunsToBuffer; |
|
robertphillips
2014/07/16 12:50:33
void* ?
krajcevski
2014/07/16 16:36:03
Done.
|
| + void * fRunsBuffer; |
| + int fCurrentRun; |
| SkAlphaRuns fRuns; |
| + |
| + int getRunsSz() const { return (fWidth + 1 + (fWidth + 2)/2) * sizeof(int16_t); } |
| + |
|
robertphillips
2014/07/16 12:33:11
// This updates 'fRuns' to point to the current bu
krajcevski
2014/07/16 16:36:03
Done.
|
| + void advanceRuns() { |
| + const size_t kRunsSz = this->getRunsSz(); |
| + fCurrentRun = (fCurrentRun + 1) % fRunsToBuffer; |
| + fRuns.fRuns = reinterpret_cast<int16_t*>( |
| + reinterpret_cast<uint8_t*>(fRunsBuffer) + fCurrentRun * kRunsSz); |
| + fRuns.fAlpha = reinterpret_cast<SkAlpha*>(fRuns.fRuns + fWidth + 1); |
| + fRuns.reset(fWidth); |
| + } |
| + |
| int fOffsetX; |
| }; |
| SuperBlitter::SuperBlitter(SkBlitter* realBlitter, const SkIRect& ir, |
| const SkRegion& clip) |
| : BaseSuperBlitter(realBlitter, ir, clip) { |
| - const int width = fWidth; |
| + fRunsToBuffer = realBlitter->requestRowsPreserved(); |
| + fRunsBuffer = sk_malloc_throw(fRunsToBuffer * this->getRunsSz()); |
| + fCurrentRun = -1; |
| - // extra one to store the zero at the end |
| - fRuns.fRuns = (int16_t*)sk_malloc_throw((width + 1 + (width + 2)/2) * sizeof(int16_t)); |
| - fRuns.fAlpha = (uint8_t*)(fRuns.fRuns + width + 1); |
| - fRuns.reset(width); |
| + this->advanceRuns(); |
| fOffsetX = 0; |
| } |
| void SuperBlitter::flush() { |
| if (fCurrIY >= fTop) { |
| + |
| + SkASSERT(fCurrentRun < fRunsToBuffer); |
| if (!fRuns.empty()) { |
|
robertphillips
2014/07/16 12:33:11
Usually we put the ';' inside the ')' of the SkDEB
krajcevski
2014/07/16 16:36:03
Done.
|
| - // SkDEBUGCODE(fRuns.dump();) |
| + // SkDEBUGCODE(fRuns.dump()); |
| fRealBlitter->blitAntiH(fLeft, fCurrIY, fRuns.fAlpha, fRuns.fRuns); |
| - fRuns.reset(fWidth); |
| + this->advanceRuns(); |
| fOffsetX = 0; |
| } |
| + |
| fCurrIY = fTop - 1; |
| SkDEBUGCODE(fCurrX = -1;) |
| } |