aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects/SkGradientShader.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-10 22:56:42 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-10 22:56:42 +0000
commitf2eb5ab7806a62e89b8cb572b1b33b70b83b13ab (patch)
tree2d2fc402c1260cdc01ed3c03f1444bc16cff97e1 /src/effects/SkGradientShader.cpp
parentcc4dac3dac215dc0dd56f7b30d07cc304671b033 (diff)
fix bug where we wrote uninitialized data to the flatten stream for shaders.
Both shader and gradient_shader write matrices to the flatten stream. However, they were just calling write(&matrix, sizeof(SkMatrix)) and the matrix can contain lazily-computed function ptrs as part of its internal cache. Thus two matrices that are logically the same may write different bytes. This is a problem because picture relies on flattening objects and then using the flatten stream as a key into its cache. This matrix-write bug effectively kills the effectiveness of the cache for shaders. The fix is to write proper read/write functions for matrix (and region btw). These call through to the existing low-level flatten routines (which just write into a memory ptr). git-svn-id: http://skia.googlecode.com/svn/trunk@1290 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/effects/SkGradientShader.cpp')
-rw-r--r--src/effects/SkGradientShader.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/effects/SkGradientShader.cpp b/src/effects/SkGradientShader.cpp
index 4eeeb68704..cfe444edd2 100644
--- a/src/effects/SkGradientShader.cpp
+++ b/src/effects/SkGradientShader.cpp
@@ -342,7 +342,7 @@ Gradient_Shader::Gradient_Shader(SkFlattenableReadBuffer& buffer) :
recs[i].fScale = buffer.readU32();
}
}
- buffer.read(&fPtsToUnit, sizeof(SkMatrix));
+ SkReadMatrix(&buffer, &fPtsToUnit);
fFlags = 0;
}
@@ -370,7 +370,7 @@ void Gradient_Shader::flatten(SkFlattenableWriteBuffer& buffer) {
buffer.write32(recs[i].fScale);
}
}
- buffer.writeMul4(&fPtsToUnit, sizeof(SkMatrix));
+ SkWriteMatrix(&buffer, fPtsToUnit);
}
bool Gradient_Shader::setContext(const SkBitmap& device,