aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-20 19:06:10 +0000
committerGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-20 19:06:10 +0000
commite4c98ff48da46c61b73b72301a1811ad1c45a617 (patch)
treec1086699fa8a98d9723e5631956e9f50f8a70327
parent0251b2fe99bd6f3aa3f459196c382a4b22bfd8b7 (diff)
Clean up some valgrind errors in SkTransparentShader. Valgrind complains
about overlapping memcpy(). In fact, it seems that src and dest are the same, so we should be able to skip the copy in this case. Review URL: http://codereview.appspot.com/4535085/ git-svn-id: http://skia.googlecode.com/svn/trunk@1393 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--src/effects/SkTransparentShader.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/effects/SkTransparentShader.cpp b/src/effects/SkTransparentShader.cpp
index c6caba3165..6e68b5e9ef 100644
--- a/src/effects/SkTransparentShader.cpp
+++ b/src/effects/SkTransparentShader.cpp
@@ -53,7 +53,10 @@ void SkTransparentShader::shadeSpan(int x, int y, SkPMColor span[], int count) {
switch (fDevice->getConfig()) {
case SkBitmap::kARGB_8888_Config:
if (scale == 256) {
- memcpy(span, fDevice->getAddr32(x, y), count * sizeof(SkPMColor));
+ SkPMColor* src = fDevice->getAddr32(x, y);
+ if (src != span) {
+ memcpy(span, src, count * sizeof(SkPMColor));
+ }
} else {
const SkPMColor* src = fDevice->getAddr32(x, y);
for (int i = count - 1; i >= 0; --i) {
@@ -125,6 +128,9 @@ void SkTransparentShader::shadeSpan(int x, int y, SkPMColor span[], int count) {
void SkTransparentShader::shadeSpan16(int x, int y, uint16_t span[], int count) {
SkASSERT(fDevice->getConfig() == SkBitmap::kRGB_565_Config);
- memcpy(span, fDevice->getAddr16(x, y), count << 1);
+ uint16_t* src = fDevice->getAddr16(x, y);
+ if (src != span) {
+ memcpy(span, src, count << 1);
+ }
}