Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Unified Diff: src/core/SkShader.cpp

Issue 272593002: add localmatrix-shader (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkLocalMatrixShader.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « src/core/SkLocalMatrixShader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698