From 129ec22cb054592261e001294c430c9dd4e90ff4 Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Tue, 15 May 2012 13:24:09 +0000 Subject: inline the fast case for AutoDrawLoop::next() so we don't slow down simple draws like drawRect (with no fancy effects) git-svn-id: http://skia.googlecode.com/svn/trunk@3933 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/core/SkCanvas.cpp | 63 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 26 deletions(-) (limited to 'src/core') diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index b0f85d968b..90de54a4e8 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -300,6 +300,10 @@ public: if (fLooper) { fLooper->init(canvas); + fIsSimple = false; + } else { + // can we be marked as simple? + fIsSimple = !fFilter && !fDoClearImageFilter; } } @@ -315,7 +319,17 @@ public: return *fPaint; } - bool next(SkDrawFilter::Type drawType); + bool next(SkDrawFilter::Type drawType) { + if (fDone) { + return false; + } else if (fIsSimple) { + fDone = true; + fPaint = &fOrigPaint; + return !fPaint->nothingToDraw(); + } else { + return this->doNext(drawType); + } + } private: SkLazyPaint fLazyPaint; @@ -327,41 +341,38 @@ private: int fSaveCount; bool fDoClearImageFilter; bool fDone; + bool fIsSimple; + + bool doNext(SkDrawFilter::Type drawType); }; -bool AutoDrawLooper::next(SkDrawFilter::Type drawType) { +bool AutoDrawLooper::doNext(SkDrawFilter::Type drawType) { fPaint = NULL; - if (fDone) { - return false; - } + SkASSERT(!fIsSimple); + SkASSERT(fLooper || fFilter || fDoClearImageFilter); - if (fLooper || fFilter || fDoClearImageFilter) { - SkPaint* paint = fLazyPaint.set(fOrigPaint); + SkPaint* paint = fLazyPaint.set(fOrigPaint); - if (fDoClearImageFilter) { - paint->setImageFilter(NULL); - } + if (fDoClearImageFilter) { + paint->setImageFilter(NULL); + } - if (fLooper && !fLooper->next(fCanvas, paint)) { + if (fLooper && !fLooper->next(fCanvas, paint)) { + fDone = true; + return false; + } + if (fFilter) { + fFilter->filter(paint, drawType); + if (NULL == fLooper) { + // no looper means we only draw once fDone = true; - return false; - } - if (fFilter) { - fFilter->filter(paint, drawType); - if (NULL == fLooper) { - // no looper means we only draw once - fDone = true; - } } - fPaint = paint; + } + fPaint = paint; - // if we only came in here for the imagefilter, mark us as done - if (!fLooper && !fFilter) { - fDone = true; - } - } else { + // if we only came in here for the imagefilter, mark us as done + if (!fLooper && !fFilter) { fDone = true; - fPaint = &fOrigPaint; } // call this after any possible paint modifiers -- cgit v1.2.3