From 9154eb08ec1f0d51688a6eb55c54111cf6ec5fbb Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Mon, 31 Oct 2011 16:07:28 +0000 Subject: implement blitRect for aaclip builder. This speeds up setRect by 15x (for 640x480) git-svn-id: http://skia.googlecode.com/svn/trunk@2566 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/core/SkAAClip.cpp | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/core/SkAAClip.cpp b/src/core/SkAAClip.cpp index 9225061aa2..05742487b8 100644 --- a/src/core/SkAAClip.cpp +++ b/src/core/SkAAClip.cpp @@ -846,6 +846,19 @@ public: SkASSERT(row->fWidth <= fBounds.width()); } + void addRectRun(int x, int y, int width, int height) { + SkASSERT(fBounds.contains(x + width - 1, y + height - 1)); + this->addRun(x, y, 0xFF, width); + + // we assum the rect must be all we'll see for these scanlines + // so we ensure our row goes all the way to our right + this->flushRowH(fCurrRow); + + y -= fBounds.fTop; + SkASSERT(y == fCurrRow->fY); + fCurrRow->fY = y + height - 1; + } + bool finish(SkAAClip* target) { this->flushRow(false); @@ -947,17 +960,19 @@ public: } private: + void flushRowH(Row* row) { + // flush current row if needed + if (row->fWidth < fWidth) { + AppendRun(*row->fData, 0, fWidth - row->fWidth); + row->fWidth = fWidth; + } + } Row* flushRow(bool readyForAnother) { Row* next = NULL; int count = fRows.count(); if (count > 0) { - // flush current row if needed - Row* curr = &fRows[count - 1]; - if (curr->fWidth < fWidth) { - AppendRun(*curr->fData, 0, fWidth - curr->fWidth); - curr->fWidth = fWidth; - } + this->flushRowH(&fRows[count - 1]); } if (count > 1) { // are our last two runs the same? @@ -1022,10 +1037,8 @@ public: { unexpected(); } virtual void blitRect(int x, int y, int width, int height) SK_OVERRIDE { -// SkDebugf("blitRect Y:%d H:%d\n", y, height); - while (--height >= 0) { - this->blitH(x, y++, width); - } + this->recordMinY(y); + fBuilder->addRectRun(x, y, width, height); } virtual void blitMask(const SkMask&, const SkIRect& clip) SK_OVERRIDE -- cgit v1.2.3