skin: no need to set SWT interpolation on Windows/MacOS 18/12618/1
authorGiWoong Kim <giwoong.kim@samsung.com>
Tue, 19 Nov 2013 05:24:09 +0000 (14:24 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Wed, 20 Nov 2013 07:28:00 +0000 (16:28 +0900)
On Ubuntu, when drawing the skin image stretched with an
interpolation algorithm, the edges of the image are faded.
This problem is not occured at Windows or MacOS.

Change-Id: I4b38ab3cf53c30ff41a039e878b326ef557aafe6
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/SkinPatches.java

index 85876803d3e3610242371856a04e7f4c8a8f1046..7d44500c074fbb57d14d082b4da20fd063eb959f 100644 (file)
@@ -37,6 +37,7 @@ import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.RGB;
 import org.eclipse.swt.widgets.Display;
 import org.tizen.emulator.skin.log.SkinLogger;
+import org.tizen.emulator.skin.util.SwtUtil;
 
 public class SkinPatches {
        private Logger logger =
@@ -99,14 +100,28 @@ public class SkinPatches {
                Image patchedImage = new Image(display,
                                patchedImageWidth, patchedImageHeight);
 
-               // TODO: copy alphaData
                GC gc = new GC(patchedImage);
-               gc.setInterpolation(SWT.NONE);
+               if (SwtUtil.isLinuxPlatform() == true) {
+                       /*
+                       * Bug in Cairo.  When drawing the image stretched with an interpolation
+                       * algorithm, the edges of the image are faded.  This is not a bug, but
+                       * it is not desired.  To avoid the faded edges, it should be possible to
+                       * use cairo_pattern_set_extend() to set the pattern extend to either
+                       * CAIRO_EXTEND_REFLECT or CAIRO_EXTEND_PAD, but these are not implemented
+                       * in some versions of cairo (1.2.x) and have bugs in others (in 1.4.2 it
+                       * draws with black edges).  The fix is to implement CAIRO_EXTEND_REFLECT
+                       * by creating an image that is 3 times bigger than the original, drawing
+                       * the original image in every quadrant (with an appropriate transform) and
+                       * use this image as the pattern.
+                       */
+                       gc.setInterpolation(SWT.NONE);
+               }
 
                gc.setBackground(display.getSystemColor(SWT.COLOR_MAGENTA));
                gc.fillRectangle(0, 0, patchedImageWidth, patchedImageHeight);
 
                /* top side */
+               // TODO: copy alphaData
                gc.drawImage(imageLT, 0, 0);
                gc.drawImage(imageT, 0, 0, imageT.getImageData().width, imageT.getImageData().height,
                                patchWidth, 0, centerPatchWidth, patchHeight);