Index: src/core/SkCanvas.cpp |
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp |
index c1d2726d8c3a9b5ffc853a3adfc27a924758422d..569e9e59baca8bf97886536b51cf5f3d0f93bd2a 100644 |
--- a/src/core/SkCanvas.cpp |
+++ b/src/core/SkCanvas.cpp |
@@ -91,10 +91,32 @@ |
}; |
#endif |
+class AutoCheckNoSetContext { |
+public: |
+ AutoCheckNoSetContext(const SkPaint& paint) : fPaint(paint) { |
+ this->assertNoSetContext(fPaint); |
+ } |
+ ~AutoCheckNoSetContext() { |
+ this->assertNoSetContext(fPaint); |
+ } |
+ |
+private: |
+ const SkPaint& fPaint; |
+ |
+ void assertNoSetContext(const SkPaint& paint) { |
+ SkShader* s = paint.getShader(); |
+ if (s) { |
+ SkASSERT(!s->setContextHasBeenCalled()); |
+ } |
+ } |
+}; |
+ |
#define CHECK_LOCKCOUNT_BALANCE(bitmap) AutoCheckLockCountBalance clcb(bitmap) |
+#define CHECK_SHADER_NOSETCONTEXT(paint) AutoCheckNoSetContext cshsc(paint) |
#else |
#define CHECK_LOCKCOUNT_BALANCE(bitmap) |
+ #define CHECK_SHADER_NOSETCONTEXT(paint) |
#endif |
typedef SkTLazy<SkPaint> SkLazyPaint; |
@@ -1913,6 +1935,8 @@ |
} |
void SkCanvas::internalDrawPaint(const SkPaint& paint) { |
+ CHECK_SHADER_NOSETCONTEXT(paint); |
+ |
LOOPER_BEGIN(paint, SkDrawFilter::kPaint_Type, NULL) |
while (iter.next()) { |
@@ -1927,6 +1951,8 @@ |
if ((long)count <= 0) { |
return; |
} |
+ |
+ CHECK_SHADER_NOSETCONTEXT(paint); |
SkRect r, storage; |
const SkRect* bounds = NULL; |
@@ -1955,6 +1981,8 @@ |
} |
void SkCanvas::drawRect(const SkRect& r, const SkPaint& paint) { |
+ CHECK_SHADER_NOSETCONTEXT(paint); |
+ |
SkRect storage; |
const SkRect* bounds = NULL; |
if (paint.canComputeFastBounds()) { |
@@ -1974,6 +2002,8 @@ |
} |
void SkCanvas::drawOval(const SkRect& oval, const SkPaint& paint) { |
+ CHECK_SHADER_NOSETCONTEXT(paint); |
+ |
SkRect storage; |
const SkRect* bounds = NULL; |
if (paint.canComputeFastBounds()) { |
@@ -1993,6 +2023,8 @@ |
} |
void SkCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) { |
+ CHECK_SHADER_NOSETCONTEXT(paint); |
+ |
SkRect storage; |
const SkRect* bounds = NULL; |
if (paint.canComputeFastBounds()) { |
@@ -2023,6 +2055,8 @@ |
void SkCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, |
const SkPaint& paint) { |
+ CHECK_SHADER_NOSETCONTEXT(paint); |
+ |
SkRect storage; |
const SkRect* bounds = NULL; |
if (paint.canComputeFastBounds()) { |
@@ -2042,6 +2076,8 @@ |
} |
void SkCanvas::drawPath(const SkPath& path, const SkPaint& paint) { |
+ CHECK_SHADER_NOSETCONTEXT(paint); |
+ |
if (!path.isFinite()) { |
return; |
} |
@@ -2317,6 +2353,8 @@ |
void SkCanvas::drawText(const void* text, size_t byteLength, |
SkScalar x, SkScalar y, const SkPaint& paint) { |
+ CHECK_SHADER_NOSETCONTEXT(paint); |
+ |
LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL) |
while (iter.next()) { |
@@ -2331,6 +2369,8 @@ |
void SkCanvas::drawPosText(const void* text, size_t byteLength, |
const SkPoint pos[], const SkPaint& paint) { |
+ CHECK_SHADER_NOSETCONTEXT(paint); |
+ |
LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL) |
while (iter.next()) { |
@@ -2345,6 +2385,8 @@ |
void SkCanvas::drawPosTextH(const void* text, size_t byteLength, |
const SkScalar xpos[], SkScalar constY, |
const SkPaint& paint) { |
+ CHECK_SHADER_NOSETCONTEXT(paint); |
+ |
LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL) |
while (iter.next()) { |
@@ -2359,6 +2401,8 @@ |
void SkCanvas::drawTextOnPath(const void* text, size_t byteLength, |
const SkPath& path, const SkMatrix* matrix, |
const SkPaint& paint) { |
+ CHECK_SHADER_NOSETCONTEXT(paint); |
+ |
LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL) |
while (iter.next()) { |
@@ -2374,6 +2418,8 @@ |
const SkColor colors[], SkXfermode* xmode, |
const uint16_t indices[], int indexCount, |
const SkPaint& paint) { |
+ CHECK_SHADER_NOSETCONTEXT(paint); |
+ |
LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, NULL) |
while (iter.next()) { |