Index: src/core/SkShader.cpp |
diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp |
index 0c954f869b359522263c77804b9fe25e74159da9..ebe1a74cc2e6a7e11c9ec50de104348c79b5e3de 100644 |
--- a/src/core/SkShader.cpp |
+++ b/src/core/SkShader.cpp |
@@ -14,9 +14,30 @@ |
#include "SkPictureShader.h" |
#include "SkScalar.h" |
#include "SkShader.h" |
+#include "SkThread.h" |
#include "SkWriteBuffer.h" |
+//#define SK_TRACK_SHADER_LIFETIME |
+ |
+#ifdef SK_TRACK_SHADER_LIFETIME |
+ static int32_t gShaderCounter; |
+#endif |
+ |
+static inline void inc_shader_counter() { |
+#ifdef SK_TRACK_SHADER_LIFETIME |
+ int32_t prev = sk_atomic_inc(&gShaderCounter); |
+ SkDebugf("+++ shader counter %d\n", prev + 1); |
+#endif |
+} |
+static inline void dec_shader_counter() { |
+#ifdef SK_TRACK_SHADER_LIFETIME |
+ int32_t prev = sk_atomic_dec(&gShaderCounter); |
+ SkDebugf("--- shader counter %d\n", prev - 1); |
+#endif |
+} |
+ |
SkShader::SkShader(const SkMatrix* localMatrix) { |
+ inc_shader_counter(); |
if (localMatrix) { |
fLocalMatrix = *localMatrix; |
} else { |
@@ -24,8 +45,8 @@ SkShader::SkShader(const SkMatrix* localMatrix) { |
} |
} |
-SkShader::SkShader(SkReadBuffer& buffer) |
- : INHERITED(buffer) { |
+SkShader::SkShader(SkReadBuffer& buffer) : INHERITED(buffer) { |
+ inc_shader_counter(); |
if (buffer.readBool()) { |
buffer.readMatrix(&fLocalMatrix); |
} else { |
@@ -34,6 +55,7 @@ SkShader::SkShader(SkReadBuffer& buffer) |
} |
SkShader::~SkShader() { |
+ dec_shader_counter(); |
} |
void SkShader::flatten(SkWriteBuffer& buffer) const { |
@@ -193,6 +215,10 @@ GrEffectRef* SkShader::asNewEffect(GrContext*, const SkPaint&) const { |
return NULL; |
} |
+SkShader* SkShader::refAsALocalMatrixShader(SkMatrix*) const { |
+ return NULL; |
+} |
+ |
SkShader* SkShader::CreateEmptyShader() { |
return SkNEW(SkEmptyShader); |
} |