aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-15 13:24:09 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-15 13:24:09 +0000
commit129ec22cb054592261e001294c430c9dd4e90ff4 (patch)
treef8740d78c5502042e083065f898b0798189ae657 /src/core
parent9f63667ff221b72e96fa6a044ccb0dde12af6ebe (diff)
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
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkCanvas.cpp63
1 files changed, 37 insertions, 26 deletions
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