[cairo-commit] configure.ac src/skia

Bryce Harrington bryce at kemper.freedesktop.org
Tue Jul 8 11:09:38 PDT 2014


 configure.ac                    |   12 +++----
 src/skia/cairo-skia-context.cpp |   65 +++++++++++++++++++++++++++++-----------
 src/skia/cairo-skia-private.h   |    4 --
 src/skia/cairo-skia-surface.cpp |   13 +++-----
 4 files changed, 60 insertions(+), 34 deletions(-)

New commits:
commit 7bd68b57999bf1564ecbadf6c9aae6bf9f7aa4a7
Author: Ravi Nanjundappa <nravi.n at samsung.com>
Date:   Mon Jun 30 17:05:26 2014 +0530

    skia: update the source to build with the latest skia
    
    This fixes several build related issues for the skia backend
    which is introduced due to skia source up-gradation.
    
    Signed-off-by: Ravi Nanjundappa <nravi.n at samsung.com>
    Reviewed-by: Uli Schlachter <psychon at znc.in>
    Reviewed-by: Bryce Harrington <b.harrington at samsung.com>

diff --git a/configure.ac b/configure.ac
index fdcb2dc..04479ff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -249,16 +249,16 @@ CAIRO_ENABLE_SURFACE_BACKEND(skia, Skia, no, [
 			      [directory to find compiled skia sources])],
 	      [skia_DIR="$withval"],
 	      [skia_DIR="`pwd`/../skia"])
-  AC_ARG_WITH([skia-bulid],
-	      [AS_HELP_STRING([--with-skia-build=(Release|Debug)]
+  AC_ARG_WITH([skia-build-type],
+	      [AS_HELP_STRING([--with-skia-build-type=(Release|Debug)]
 			      [build of skia to link with, default is Release])],
-	      [skia_BUILD="$withval"],
-	      [skia_BUILD="Release"])
+	      [skia_BUILD_TYPE="$withval"],
+	      [skia_BUILD_TYPE="Release"])
   skia_NONPKGCONFIG_CFLAGS="-I$skia_DIR/include/config -I$skia_DIR/include/core -I$skia_DIR/include/effects"
-  if test "x$skia_BUILD" = x"Release"; then
+  if test "x$skia_BUILD_TYPE" = "xRelease"; then
   	skia_NONPKGCONFIG_CFLAGS="-DSK_RELEASE -DSK_CAN_USE_FLOAT $skia_NONPKGCONFIG_CFLAGS"
   fi
-  skia_NONPKGCONFIG_LIBS="--start-group $skia_DIR/out/$skia_BUILD/obj.target/gyp/libeffects.a $skia_DIR/out/$skia_BUILD/obj.target/gyp/libimages.a $skia_DIR/out/$skia_BUILD/obj.target/gyp/libutils.a $skia_DIR/out/$skia_BUILD/obj.target/gyp/libopts.a $skia_DIR/out/$skia_BUILD/obj.target/gyp/libcore.a -end-group"
+  skia_NONPKGCONFIG_LIBS="-L$skia_DIR/out/$skia_BUILD_TYPE/lib.target/ -lskia -lstdc++"
   AC_SUBST(skia_DIR)
 ])
 
diff --git a/src/skia/cairo-skia-context.cpp b/src/skia/cairo-skia-context.cpp
index bbe5507..9ffb8f6 100644
--- a/src/skia/cairo-skia-context.cpp
+++ b/src/skia/cairo-skia-context.cpp
@@ -53,6 +53,7 @@
 #include "cairo-skia-private.h"
 #include "cairo-surface-backend-private.h"
 
+#include <SkPaint.h>
 #include <SkShader.h>
 #include <SkColorShader.h>
 #include <SkGradientShader.h>
@@ -236,16 +237,19 @@ surface_to_sk_bitmap (cairo_surface_t *surface, SkBitmap& bitmap)
 {
     cairo_image_surface_t *img = (cairo_image_surface_t *) surface;
     SkBitmap::Config config;
+    SkColorType colorType;
     bool opaque;
 
     if (unlikely (! format_to_sk_config (img->format, config, opaque)))
 	return false;
 
     bitmap.reset ();
-    bitmap.setConfig (config, img->width, img->height, img->stride);
-    bitmap.setIsOpaque (opaque);
+    bitmap.setAlphaType (opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
+    colorType = SkBitmapConfigToColorType(config);
+    bitmap.setInfo (SkImageInfo::Make(img->width, img->height, colorType, kPremul_SkAlphaType), img->stride);
     bitmap.setPixels (img->data);
 
+
     return true;
 }
 
@@ -330,9 +334,18 @@ source_to_sk_shader (cairo_skia_context_t *cr,
 	if (surface->type == CAIRO_SURFACE_TYPE_SKIA) {
 	    cairo_skia_surface_t *esurf = (cairo_skia_surface_t *) surface;
 
-	    shader = SkShader::CreateBitmapShader (*esurf->bitmap,
-						   extend_to_sk (pattern->extend),
-						   extend_to_sk (pattern->extend));
+		if (! _cairo_matrix_is_identity (&pattern->matrix))
+		{
+			SkMatrix localMatrix =  matrix_inverse_to_sk (pattern->matrix);
+			shader = SkShader::CreateBitmapShader (*esurf->bitmap,
+					extend_to_sk (pattern->extend),
+					extend_to_sk (pattern->extend),
+					&localMatrix);
+		} else {
+			shader = SkShader::CreateBitmapShader (*esurf->bitmap,
+					extend_to_sk (pattern->extend),
+					extend_to_sk (pattern->extend));
+		}
 	} else {
 	    SkBitmap bitmap;
 
@@ -351,9 +364,18 @@ source_to_sk_shader (cairo_skia_context_t *cr,
 	    if (unlikely (! surface_to_sk_bitmap (surface, bitmap)))
 		return NULL;
 
-	    shader = SkShader::CreateBitmapShader (bitmap,
-						   extend_to_sk (pattern->extend),
-						   extend_to_sk (pattern->extend));
+		if (! _cairo_matrix_is_identity (&pattern->matrix))
+		{
+			SkMatrix localMatrix = matrix_inverse_to_sk (pattern->matrix);
+			shader = SkShader::CreateBitmapShader (bitmap,
+					extend_to_sk (pattern->extend),
+					extend_to_sk (pattern->extend),
+					&localMatrix);
+		} else {
+			shader = SkShader::CreateBitmapShader (bitmap,
+			extend_to_sk (pattern->extend),
+			extend_to_sk (pattern->extend));
+		}
 	}
     } else if (pattern->type == CAIRO_PATTERN_TYPE_LINEAR
 	       /* || pattern->type == CAIRO_PATTERN_TYPE_RADIAL */)
@@ -382,8 +404,17 @@ source_to_sk_shader (cairo_skia_context_t *cr,
 			   SkFloatToScalar (linear->pd1.y));
 	    points[1].set (SkFloatToScalar (linear->pd2.x),
 			   SkFloatToScalar (linear->pd2.y));
-	    shader = SkGradientShader::CreateLinear (points, colors, pos, gradient->n_stops,
-						     extend_to_sk (pattern->extend));
+
+	    if(! _cairo_matrix_is_identity (&pattern->matrix))
+	    {
+		SkMatrix localMatrix = matrix_inverse_to_sk (pattern->matrix);
+	        shader = SkGradientShader::CreateLinear (points, colors, pos, gradient->n_stops,
+						     extend_to_sk (pattern->extend),
+						     0, &localMatrix);
+	    } else {
+	        shader = SkGradientShader::CreateLinear (points, colors, pos, gradient->n_stops,
+							extend_to_sk (pattern->extend));
+	    }
 	} else {
 	    // XXX todo -- implement real radial shaders in Skia
 	}
@@ -394,9 +425,6 @@ source_to_sk_shader (cairo_skia_context_t *cr,
 	}
     }
 
-    if (shader && ! _cairo_matrix_is_identity (&pattern->matrix))
-	shader->setLocalMatrix (matrix_inverse_to_sk (pattern->matrix));
-
     return shader;
 }
 
@@ -446,6 +474,7 @@ _cairo_skia_context_set_source (void *abstract_cr,
 	cr->paint->setColor (color);
     } else {
 	SkShader *shader = source_to_sk_shader (cr, source);
+	bool fLevel = pattern_filter_to_sk (source);
 	if (shader == NULL) {
 	    UNSUPPORTED;
 	    return CAIRO_STATUS_SUCCESS;
@@ -454,7 +483,8 @@ _cairo_skia_context_set_source (void *abstract_cr,
 	cr->paint->setShader (shader);
 	shader->unref ();
 
-	cr->paint->setFilterBitmap (pattern_filter_to_sk (source));
+	cr->paint->setFilterLevel (fLevel ?
+				(SkPaint::kLow_FilterLevel) : (SkPaint::kNone_FilterLevel));
     }
 
     /* XXX change notification */
@@ -496,7 +526,8 @@ _cairo_skia_context_set_source_surface (void *abstract_cr,
 	cr->paint->setShader (shader);
 	shader->unref ();
 
-	cr->paint->setFilterBitmap (true);
+	cr->paint->setFilterLevel (true ?
+		(SkPaint::kLow_FilterLevel) : (SkPaint::kNone_FilterLevel));
 
 	return CAIRO_STATUS_SUCCESS;
     }
@@ -682,7 +713,7 @@ _cairo_skia_context_set_dash (void *abstract_cr,
 	    intervals[i++] = SkFloatToScalar (dashes[j]);
     } while (loop--);
 
-    SkDashPathEffect *dash = new SkDashPathEffect (intervals, num_dashes, SkFloatToScalar (offset));
+    SkDashPathEffect *dash = SkDashPathEffect::Create (intervals, num_dashes, SkFloatToScalar (offset));
 
     cr->paint->setPathEffect (dash);
     dash->unref ();
@@ -1264,7 +1295,7 @@ _cairo_skia_context_paint_with_alpha (void *abstract_cr,
     if (CAIRO_ALPHA_IS_OPAQUE (alpha))
 	return _cairo_skia_context_paint (cr);
 
-    cr->paint->setAlpha(SkScalarRound(255*alpha));
+    cr->paint->setAlpha(SkScalarRoundToInt(255*alpha));
     status = _cairo_skia_context_paint (cr);
     cr->paint->setAlpha(255);
 
diff --git a/src/skia/cairo-skia-private.h b/src/skia/cairo-skia-private.h
index de3897b..f538b48 100644
--- a/src/skia/cairo-skia-private.h
+++ b/src/skia/cairo-skia-private.h
@@ -111,11 +111,9 @@ format_to_sk_config (cairo_format_t format,
     case CAIRO_FORMAT_A8:
 	config = SkBitmap::kA8_Config;
 	break;
-    case CAIRO_FORMAT_A1:
-	config = SkBitmap::kA1_Config;
-	break;
     case CAIRO_FORMAT_RGB30:
     case CAIRO_FORMAT_INVALID:
+    case CAIRO_FORMAT_A1:
     default:
 	return false;
     }
diff --git a/src/skia/cairo-skia-surface.cpp b/src/skia/cairo-skia-surface.cpp
index bb785e1..9b16bd2 100644
--- a/src/skia/cairo-skia-surface.cpp
+++ b/src/skia/cairo-skia-surface.cpp
@@ -64,7 +64,7 @@ _cairo_skia_surface_create_similar (void *asurface,
 
     if (content == surface->image.base.content)
     {
-	config = surface->bitmap->getConfig ();
+	config = surface->bitmap->config ();
 	opaque = surface->bitmap->isOpaque ();
     }
     else if (! format_to_sk_config (_cairo_format_from_content (content),
@@ -207,9 +207,6 @@ sk_config_to_pixman_format_code (SkBitmap::Config config,
 
     case SkBitmap::kA8_Config:
 	return PIXMAN_a8;
-
-    case SkBitmap::kA1_Config:
-	return PIXMAN_a1;
     case SkBitmap::kRGB_565_Config:
 	return PIXMAN_r5g6b5;
     case SkBitmap::kARGB_4444_Config:
@@ -217,8 +214,6 @@ sk_config_to_pixman_format_code (SkBitmap::Config config,
 
     case SkBitmap::kNo_Config:
     case SkBitmap::kIndex8_Config:
-    case SkBitmap::kRLE_Index8_Config:
-    case SkBitmap::kConfigCount:
     default:
 	ASSERT_NOT_REACHED;
 	return (pixman_format_code_t) -1;
@@ -236,6 +231,7 @@ _cairo_skia_surface_create_internal (SkBitmap::Config config,
     cairo_skia_surface_t *surface;
     pixman_image_t *pixman_image;
     pixman_format_code_t pixman_format;
+    SkColorType colorType;
 
     surface = (cairo_skia_surface_t *) malloc (sizeof (cairo_skia_surface_t));
     if (unlikely (surface == NULL))
@@ -256,8 +252,9 @@ _cairo_skia_surface_create_internal (SkBitmap::Config config,
     _cairo_image_surface_init (&surface->image, pixman_image, pixman_format);
 
     surface->bitmap = new SkBitmap;
-    surface->bitmap->setConfig (config, width, height, surface->image.stride);
-    surface->bitmap->setIsOpaque (opaque);
+    colorType = SkBitmapConfigToColorType(config);
+    surface->bitmap->setAlphaType (opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
+    surface->bitmap->setInfo (SkImageInfo::Make(width, height, colorType, kPremul_SkAlphaType), surface->image.stride);
     surface->bitmap->setPixels (surface->image.data);
 
     surface->image.base.is_clear = data == NULL;


More information about the cairo-commit mailing list