fix odd-pixel bug in mipmap downsamplers (thanks brett)
authorreed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 8 Jun 2009 12:05:31 +0000 (12:05 +0000)
committerreed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 8 Jun 2009 12:05:31 +0000 (12:05 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@204 2bbb7eff-a529-9590-31e7-b0007b416f81

src/core/SkBitmap.cpp
xcode/sampleapp_sdl/SDLApp.xcodeproj/project.pbxproj

index 4f44286..2513b51 100644 (file)
@@ -813,6 +813,7 @@ static void downsampleby2_proc32(SkBitmap* dst, int x, int y,
     x <<= 1;
     y <<= 1;
     const SkPMColor* p = src.getAddr32(x, y);
+    const SkPMColor* baseP = p;
     SkPMColor c, ag, rb;
 
     c = *p; ag = (c >> 8) & 0xFF00FF; rb = c & 0xFF00FF;
@@ -821,8 +822,9 @@ static void downsampleby2_proc32(SkBitmap* dst, int x, int y,
     }
     c = *p; ag += (c >> 8) & 0xFF00FF; rb += c & 0xFF00FF;
 
+    p = baseP;
     if (y < src.height() - 1) {
-        p = src.getAddr32(x, y + 1);
+        p += src.rowBytes() >> 2;
     }
     c = *p; ag += (c >> 8) & 0xFF00FF; rb += c & 0xFF00FF;
     if (x < src.width() - 1) {
@@ -849,19 +851,21 @@ static void downsampleby2_proc16(SkBitmap* dst, int x, int y,
     x <<= 1;
     y <<= 1;
     const uint16_t* p = src.getAddr16(x, y);
+    const uint16_t* baseP = p;
     SkPMColor       c;
 
     c = expand16(*p);
-    if (x < (int)src.width() - 1) {
+    if (x < src.width() - 1) {
         p += 1;
     }
     c += expand16(*p);
 
-    if (y < (int)src.height() - 1) {
-        p = src.getAddr16(x, y + 1);
+    p = baseP;
+    if (y < src.height() - 1) {
+        p += src.rowBytes() >> 1;
     }
     c += expand16(*p);
-    if (x < (int)src.width() - 1) {
+    if (x < src.width() - 1) {
         p += 1;
     }
     c += expand16(*p);
@@ -882,6 +886,7 @@ static void downsampleby2_proc4444(SkBitmap* dst, int x, int y,
     x <<= 1;
     y <<= 1;
     const uint16_t* p = src.getAddr16(x, y);
+    const uint16_t* baseP = p;
     uint32_t        c;
 
     c = expand4444(*p);
@@ -890,8 +895,9 @@ static void downsampleby2_proc4444(SkBitmap* dst, int x, int y,
     }
     c += expand4444(*p);
 
+    p = baseP;
     if (y < src.height() - 1) {
-        p = src.getAddr16(x, y + 1);
+        p += src.rowBytes() >> 1;
     }
     c += expand4444(*p);
     if (x < src.width() - 1) {
index b3a38f1..88dac6b 100644 (file)
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
+               000A99D20FDD3530007E45BD /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = 0096583F0FC71CA700C3AE15 /* core.xcodeproj */;
+                       proxyType = 1;
+                       remoteGlobalIDString = D2AAC045055464E500DB518D /* core */;
+                       remoteInfo = core;
+               };
+               000A99D40FDD3534007E45BD /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = 0064EE5E0FC72C9600D71FB0 /* effects.xcodeproj */;
+                       proxyType = 1;
+                       remoteGlobalIDString = D2AAC045055464E500DB518D /* effects */;
+                       remoteInfo = effects;
+               };
+               000A99D60FDD3538007E45BD /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = 0096585B0FC7201800C3AE15 /* maccore.xcodeproj */;
+                       proxyType = 1;
+                       remoteGlobalIDString = D2AAC045055464E500DB518D /* maccore */;
+                       remoteInfo = maccore;
+               };
                006DC7D80FC7475400BF5F45 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                        containerPortal = 0064EE5E0FC72C9600D71FB0 /* effects.xcodeproj */;
                        buildRules = (
                        );
                        dependencies = (
+                               000A99D30FDD3530007E45BD /* PBXTargetDependency */,
+                               000A99D50FDD3534007E45BD /* PBXTargetDependency */,
+                               000A99D70FDD3538007E45BD /* PBXTargetDependency */,
                        );
                        name = "«PROJECTNAME»";
                        productInstallPath = "$(HOME)/Applications";
                };
 /* End PBXSourcesBuildPhase section */
 
+/* Begin PBXTargetDependency section */
+               000A99D30FDD3530007E45BD /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       name = core;
+                       targetProxy = 000A99D20FDD3530007E45BD /* PBXContainerItemProxy */;
+               };
+               000A99D50FDD3534007E45BD /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       name = effects;
+                       targetProxy = 000A99D40FDD3534007E45BD /* PBXContainerItemProxy */;
+               };
+               000A99D70FDD3538007E45BD /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       name = maccore;
+                       targetProxy = 000A99D60FDD3538007E45BD /* PBXContainerItemProxy */;
+               };
+/* End PBXTargetDependency section */
+
 /* Begin PBXVariantGroup section */
                089C165CFE840E0CC02AAC07 /* InfoPlist.strings */ = {
                        isa = PBXVariantGroup;