aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkDraw.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-07-25 21:16:22 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-07-25 21:16:22 +0000
commitfd4236ecc1d5eb1bb48ca9dc33df5e9051c3036e (patch)
tree0afb65349c7be8b05d1838bc99da4f626122dddb /src/core/SkDraw.cpp
parent40c2ba27b6e5c6a4b6c073264f8c0a7c86355abe (diff)
don't modify const SkDraw, since multiple threads may be watching it...
git-svn-id: http://skia.googlecode.com/svn/trunk@1954 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkDraw.cpp')
-rw-r--r--src/core/SkDraw.cpp67
1 files changed, 23 insertions, 44 deletions
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index 235c61fb63..5001296049 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -38,40 +38,10 @@
//#define TRACE_BITMAP_DRAWS
-static bool hasCustomD1GProc(const SkDraw& draw) {
- return draw.fProcs && draw.fProcs->fD1GProc;
-}
-
-static bool needsRasterTextBlit(const SkDraw& draw) {
- return !hasCustomD1GProc(draw);
-}
-
-class SkAutoRestoreBounder : SkNoncopyable {
-public:
- // note: initializing fBounder is done only to fix a warning
- SkAutoRestoreBounder() : fDraw(NULL), fBounder(NULL) {}
- ~SkAutoRestoreBounder() {
- if (fDraw) {
- fDraw->fBounder = fBounder;
- }
- }
-
- void clearBounder(const SkDraw* draw) {
- fDraw = const_cast<SkDraw*>(draw);
- fBounder = draw->fBounder;
- fDraw->fBounder = NULL;
- }
-
-private:
- SkDraw* fDraw;
- SkBounder* fBounder;
-};
-
-/** Helper for allocating small blitters on the stack.
-*/
-
#define kBlitterStorageLongCount (sizeof(SkBitmapProcShader) >> 2)
+/** Helper for allocating small blitters on the stack.
+ */
class SkAutoBlitterChoose : SkNoncopyable {
public:
SkAutoBlitterChoose() {
@@ -561,18 +531,6 @@ void SkDraw::drawPoints(SkCanvas::PointMode mode, size_t count,
return;
}
- SkAutoRestoreBounder arb;
-
- if (fBounder) {
- if (!bounder_points(fBounder, mode, count, pts, paint, *fMatrix)) {
- return;
- }
- // clear the bounder for the rest of this function, so we don't call it
- // again later if we happen to call ourselves for drawRect, drawPath,
- // etc.
- arb.clearBounder(this);
- }
-
SkASSERT(pts != NULL);
SkDEBUGCODE(this->validate();)
@@ -582,6 +540,19 @@ void SkDraw::drawPoints(SkCanvas::PointMode mode, size_t count,
return;
}
+ if (fBounder) {
+ if (!bounder_points(fBounder, mode, count, pts, paint, *fMatrix)) {
+ return;
+ }
+
+ // clear the bounder and call this again, so we don't invoke the bounder
+ // later if we happen to call ourselves for drawRect, drawPath, etc.
+ SkDraw noBounder(*this);
+ noBounder.fBounder = NULL;
+ noBounder.drawPoints(mode, count, pts, paint, forceUseDevice);
+ return;
+ }
+
PtProcRec rec;
if (!forceUseDevice && rec.init(mode, paint, fMatrix, fClip)) {
SkAutoBlitterChoose blitter(*fBitmap, *fMatrix, paint);
@@ -1498,6 +1469,14 @@ static void D1G_Bounder(const SkDraw1Glyph& state,
}
}
+static bool hasCustomD1GProc(const SkDraw& draw) {
+ return draw.fProcs && draw.fProcs->fD1GProc;
+}
+
+static bool needsRasterTextBlit(const SkDraw& draw) {
+ return !hasCustomD1GProc(draw);
+}
+
SkDraw1Glyph::Proc SkDraw1Glyph::init(const SkDraw* draw, SkBlitter* blitter,
SkGlyphCache* cache) {
fDraw = draw;