From e4c98ff48da46c61b73b72301a1811ad1c45a617 Mon Sep 17 00:00:00 2001 From: "senorblanco@chromium.org" Date: Fri, 20 May 2011 19:06:10 +0000 Subject: [PATCH] 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 --- src/effects/SkTransparentShader.cpp | 10 ++++++++-- 1 file 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); + } }