[Spice-commits] 5 commits - client/red_gdi_canvas.cpp client/windows common/cairo_canvas.c common/canvas_base.c common/canvas_utils.c common/gdi_canvas.c common/gdi_canvas.h common/lines.c common/pixman_utils.c common/pixman_utils.h

Alexander Larsson alexl at kemper.freedesktop.org
Mon Mar 1 07:15:14 PST 2010


 client/red_gdi_canvas.cpp  |   15 ++++++++++++---
 client/windows/redc.vcproj |   16 ++++++++++++----
 common/cairo_canvas.c      |    2 --
 common/canvas_base.c       |    2 +-
 common/canvas_utils.c      |    8 ++++----
 common/gdi_canvas.c        |   31 +++++++++++++++++--------------
 common/gdi_canvas.h        |    4 ++--
 common/lines.c             |   20 ++++++++++----------
 common/pixman_utils.c      |   10 +++++-----
 common/pixman_utils.h      |    2 ++
 10 files changed, 65 insertions(+), 45 deletions(-)

New commits:
commit d425690875dd5c74a8c6fe1b990f61c4343b5a22
Author: Larsson at .(none) <Larsson at .(none)>
Date:   Fri Feb 26 09:25:49 2010 +0100

    Update visual studio project for pixman changes

diff --git a/client/windows/redc.vcproj b/client/windows/redc.vcproj
index 06d93c0..5ad7c42 100644
--- a/client/windows/redc.vcproj
+++ b/client/windows/redc.vcproj
@@ -41,7 +41,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories=".;..;..\..\common;..\..\common\win;&quot;..\..\common\win\my_getopt-1.5&quot;;&quot;$(SPICE_LIBS)\include&quot;;&quot;$(SPICE_LIBS)\include\qcairo&quot;;&quot;$(SPICE_LIBS)\include\ffmpeg&quot;;&quot;$(SPICE_LIBS)\include\CEGUI-0.6.2&quot;"
+				AdditionalIncludeDirectories=".;..;..\..\common;..\..\..\spice-protocol;..\..\common\win;&quot;..\..\common\win\my_getopt-1.5&quot;;&quot;$(SPICE_LIBS)\include&quot;;&quot;$(SPICE_LIBS)\include\pixman-1&quot;;&quot;$(SPICE_LIBS)\include\ffmpeg&quot;;&quot;$(SPICE_LIBS)\include\CEGUI-0.6.2&quot;"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;CAIRO_CANVAS_ACCESS_TEST;CAIRO_CANVAS_CACHE;RED_DEBUG;CAIRO_CANVAS_NO_CHUNKS;_WIN32_WINNT=0x0500;LOG4CPLUS_STATIC;USE_GLZ;PTW32_STATIC_LIB;CEGUI_STATIC"
 				MinimalRebuild="false"
 				BasicRuntimeChecks="3"
@@ -64,7 +64,7 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="log4cppD.lib libqcairo-2.dll.lib libeay32MTd.lib ssleay32MTd.lib ws2_32.lib msimg32.lib winmm.lib avcodec-51.lib avutil-49.lib libcelt_0_5_1D.lib pthreadsD.lib version.lib CEGUIBase_Static_d.lib CEGUITGAImageCodec_Static_d.lib CEGUIExpatParser_Static_d.lib freetype235MT_D.lib libexpatMT_D.lib pcre_D.lib CEGUIFalagardWRBase_Static_d.lib"
+				AdditionalDependencies="log4cppD.lib pixman-1D.lib libeay32MTd.lib ssleay32MTd.lib ws2_32.lib msimg32.lib winmm.lib avcodec-51.lib avutil-49.lib libcelt_0_5_1D.lib pthreadsD.lib version.lib CEGUIBase_Static_d.lib CEGUITGAImageCodec_Static_d.lib CEGUIExpatParser_Static_d.lib freetype235MT_D.lib libexpatMT_D.lib pcre_D.lib CEGUIFalagardWRBase_Static_d.lib"
 				OutputFile="$(OutDir)\spicec.exe"
 				LinkIncremental="2"
 				AdditionalLibraryDirectories="&quot;$(SPICE_LIBS)\lib&quot;"
@@ -124,7 +124,7 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories=".;..;..\..\common;..\..\common\win;&quot;..\..\common\win\my_getopt-1.5&quot;;&quot;$(SPICE_LIBS)\include&quot;;&quot;$(SPICE_LIBS)\include\qcairo&quot;;&quot;$(SPICE_LIBS)\include\ffmpeg&quot;;&quot;$(SPICE_LIBS)\include\CEGUI-0.6.2&quot;"
+				AdditionalIncludeDirectories=".;..;..\..\..\spice-protocol;..\..\common;..\..\common\win;&quot;..\..\common\win\my_getopt-1.5&quot;;&quot;$(SPICE_LIBS)\include&quot;;&quot;$(SPICE_LIBS)\include\pixman-1&quot;;&quot;$(SPICE_LIBS)\include\ffmpeg&quot;;&quot;$(SPICE_LIBS)\include\CEGUI-0.6.2&quot;"
 				PreprocessorDefinitions="WIN32;_WINDOWS;CAIRO_CANVAS_ACCESS_TEST;CAIRO_CANVAS_CACHE;CAIRO_CANVAS_NO_CHUNKS;_WIN32_WINNT=0x0500;LOG4CPLUS_STATIC;USE_GLZ;PTW32_STATIC_LIB;CEGUI_STATIC"
 				RuntimeLibrary="0"
 				UsePrecompiledHeader="0"
@@ -144,7 +144,7 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="log4cpp.lib libqcairo-2.dll.lib libeay32MT.lib ssleay32MT.lib ws2_32.lib msimg32.lib winmm.lib avcodec-51.lib avutil-49.lib libcelt_0_5_1.lib pthreads.lib version.lib CEGUIBase_Static.lib CEGUITGAImageCodec_Static.lib CEGUIExpatParser_Static.lib freetype235MT.lib libexpatMT.lib pcre.lib CEGUIFalagardWRBase_Static.lib"
+				AdditionalDependencies="log4cpp.lib pixman-1.lib libeay32MT.lib ssleay32MT.lib ws2_32.lib msimg32.lib winmm.lib avcodec-51.lib avutil-49.lib libcelt_0_5_1.lib pthreads.lib version.lib CEGUIBase_Static.lib CEGUITGAImageCodec_Static.lib CEGUIExpatParser_Static.lib freetype235MT.lib libexpatMT.lib pcre.lib CEGUIFalagardWRBase_Static.lib"
 				OutputFile="$(OutDir)\spicec.exe"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="&quot;$(SPICE_LIBS)\lib&quot;"
@@ -253,6 +253,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\lines.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\lz.cpp"
 				>
 			</File>
@@ -299,6 +303,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\pixman_utils.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\platform.cpp"
 				>
 			</File>
commit c28169976a9050a9a05cbb3dd4543edd34d3c82e
Author: Larsson at .(none) <Larsson at .(none)>
Date:   Fri Feb 26 08:58:07 2010 +0100

    Make gdi canvas build in the new pixman world

diff --git a/client/red_gdi_canvas.cpp b/client/red_gdi_canvas.cpp
index e30845e..671fe82 100644
--- a/client/red_gdi_canvas.cpp
+++ b/client/red_gdi_canvas.cpp
@@ -64,9 +64,18 @@ void GDICanvas::create_pixmap(int width, int height)
 
 void GDICanvas::copy_pixels(const QRegion& region, RedDrawable& dest_dc)
 {
-    for (int i = 0; i < (int)region.num_rects; i++) {
-        SpiceRect* r = &region.rects[i];
-        dest_dc.copy_pixels(*_pixmap, r->left, r->top, *r);
+    pixman_box32_t *rects;
+    int num_rects;
+
+    rects = pixman_region32_rectangles((pixman_region32_t *)&region, &num_rects);
+	for (int i = 0; i < num_rects; i++) {
+        SpiceRect r;
+
+        r.left = rects[i].x1;
+        r.top = rects[i].y1;
+        r.right = rects[i].x2;
+        r.bottom = rects[i].y2;
+        dest_dc.copy_pixels(*_pixmap, r.left, r.top, r);
     }
 }
 
diff --git a/common/canvas_utils.c b/common/canvas_utils.c
index b70b17b..89ebe12 100644
--- a/common/canvas_utils.c
+++ b/common/canvas_utils.c
@@ -173,7 +173,7 @@ pixman_image_t * surface_create(pixman_format_code_t format, int width, int heig
 
         bitmap = CreateDIBSection(dc, &bitmap_info.inf, 0, (VOID **)&data, NULL, 0);
         if (!bitmap) {
-            CloseHandle(bitmap_cache->mutex);
+            CloseHandle(mutex);
             CANVAS_ERROR("Unable to CreateDIBSection");
         }
 
@@ -184,15 +184,15 @@ pixman_image_t * surface_create(pixman_format_code_t format, int width, int heig
             nstride = -nstride;
         }
 
-        surface = pixman_image_create_bits(format, width, height, (uint32_t *)src, stride);
+        surface = pixman_image_create_bits(format, width, height, (uint32_t *)src, nstride);
         if (surface == NULL) {
             CloseHandle(mutex);
             DeleteObject(bitmap);
             CANVAS_ERROR("create surface failed, out of memory");
         }
         pixman_data = pixman_image_add_data(surface);
-        pixman_data.bitmap = bitmap;
-        pixman_data.mutex = mutex;
+        pixman_data->bitmap = bitmap;
+        pixman_data->mutex = mutex;
         gdi_handlers++;
         return surface;
     } else {
diff --git a/common/gdi_canvas.c b/common/gdi_canvas.c
index 83c5f05..ae477db 100644
--- a/common/gdi_canvas.c
+++ b/common/gdi_canvas.c
@@ -307,13 +307,13 @@ uint32_t raster_ops[] = {
 
 static inline void surface_to_image(pixman_image_t *surface, GdiImage *image)
 {
-    int depth = pixman_image_surface_get_depth(surface);
+    int depth = pixman_image_get_depth(surface);
 
     ASSERT(depth == 32 || depth == 24);
     image->width = pixman_image_get_width(surface);
     image->height = pixman_image_get_height(surface);
     image->stride = pixman_image_get_stride(surface);
-    image->pixels = pixman_image_get_data(surface);
+    image->pixels = (uint8_t *)pixman_image_get_data(surface);
 }
 
 static void set_path(GdiCanvas *canvas, void *addr)
@@ -788,7 +788,7 @@ static struct BitmapData get_mask_bitmap(struct GdiCanvas *canvas, struct SpiceQ
         return bitmap;
     }
 
-    pixman_data = pixman_image_get_destroy_data (surface);
+    pixman_data = (PixmanData *)pixman_image_get_destroy_data (surface);
     if (pixman_data && (WaitForSingleObject(pixman_data->mutex, INFINITE) != WAIT_FAILED)) {
         bitmap.dc = create_compatible_dc();
         bitmap.prev_hbitmap = (HBITMAP)SelectObject(bitmap.dc, pixman_data->bitmap);
@@ -796,7 +796,7 @@ static struct BitmapData get_mask_bitmap(struct GdiCanvas *canvas, struct SpiceQ
         ReleaseMutex(pixman_data->mutex);
         bitmap.cache = 1;
     } else if (!create_bitmap(&bitmap.hbitmap, &bitmap.prev_hbitmap, &bitmap.dc,
-                              pixman_image_get_data(surface),
+                              (uint8_t *)pixman_image_get_data(surface),
                               pixman_image_get_width(surface),
                               pixman_image_get_height(surface),
                               pixman_image_get_stride(surface), 1, 0)) {
@@ -926,7 +926,7 @@ static void draw_str_mask_bitmap(struct GdiCanvas *canvas,
 
     unset_brush(bitmap.dc, prev_hbrush);
 
-    copy_bitmap_alpha(pixman_image_get_data(surface),
+    copy_bitmap_alpha((uint8_t *)pixman_image_get_data(surface),
                       pixman_image_get_height(surface),
                       pixman_image_get_width(surface),
                       pixman_image_get_stride(surface),
@@ -1045,28 +1045,31 @@ void gdi_canvas_put_image(GdiCanvas *canvas, HDC dc, const SpiceRect *dest, cons
     src.bottom = src_height;
     src.left = 0;
     src.right = src_width;
+    int num_rects;
+    pixman_box32_t *rects;
 
     Lock lock(*canvas->lock);
     set_scale_mode(canvas, SPICE_IMAGE_SCALE_MODE_NEAREST);
     if (clip) {
-        if (clip->num_rects == 0) {
+        rects = pixman_region32_rectangles((pixman_region32_t*)clip, &num_rects);
+        if (num_rects == 0) {
             return;
         } else {
             HRGN main_hrgn;
-            uint32_t i;
+            int i;
 
-            main_hrgn = CreateRectRgn(clip->rects[0].left, clip->rects[0].top, clip->rects[0].right,
-                                      clip->rects[0].bottom);
+            main_hrgn = CreateRectRgn(rects[0].x1, rects[0].y1, rects[0].x2,
+                                      rects[0].y2);
             if (!main_hrgn) {
                 return;
             }
 
-            for (i = 1; i < clip->num_rects; i++) {
+            for (i = 1; i < num_rects; i++) {
                 HRGN combaine_hrgn;
 
-                combaine_hrgn = CreateRectRgn(clip->rects[i].left, clip->rects[i].top,
-                                              clip->rects[i].right,
-                                              clip->rects[i].bottom);
+                combaine_hrgn = CreateRectRgn(rects[i].x1, rects[i].y1,
+                                              rects[i].x2,
+                                              rects[i].y2);
                 if (!combaine_hrgn) {
                     CANVAS_ERROR("CreateRectRgn failed");
                     DeleteObject(main_hrgn);
@@ -1695,7 +1698,7 @@ void gdi_canvas_destroy(GdiCanvas *canvas)
 static int need_init = 1;
 
 #ifdef CAIRO_CANVAS_CACHE
-GdiCanvas *gdi_canvas_create(HDC dc, Mutex* lock, int bits, void *bits_cache_opaque,
+GdiCanvas *gdi_canvas_create(HDC dc, Mutex* lock, int bits,
                              SpiceImageCache *bits_cache,
                              SpicePaletteCache *palette_cache
 #elif defined(CAIRO_CANVAS_IMAGE_CACHE)
diff --git a/common/gdi_canvas.h b/common/gdi_canvas.h
index febd967..d9b8d21 100644
--- a/common/gdi_canvas.h
+++ b/common/gdi_canvas.h
@@ -59,9 +59,9 @@ void gdi_canvas_set_access_params(GdiCanvas *canvas, unsigned long base, unsigne
 #endif
 
 
-GdiCanvas *gdi_canvas_create(HDC dc, class Mutex *lock, int bits, void *bits_cache_opaque,
+GdiCanvas *gdi_canvas_create(HDC dc, class Mutex *lock, int bits,
                              SpiceImageCache *bits_cache,
-                             SpicePaletteCache *palette_cache
+                             SpicePaletteCache *palette_cache,
                              void *glz_decoder_opaque,
                              glz_decode_fn_t glz_decode);
 
commit 98f7d96336d2e05f770918f8977f5909f2fac44a
Author: Larsson at .(none) <Larsson at .(none)>
Date:   Fri Feb 26 08:56:15 2010 +0100

    Always include spice/types.h before pixman so standard int types exist

diff --git a/common/pixman_utils.h b/common/pixman_utils.h
index fb8dd02..ef0cb2b 100644
--- a/common/pixman_utils.h
+++ b/common/pixman_utils.h
@@ -19,6 +19,8 @@
 #ifndef _H__PIXMAN_UTILS
 #define _H__PIXMAN_UTILS
 
+#include <spice/types.h>
+
 #include <pixman.h>
 
 #include <spice/draw.h>
commit ea92e6c063eb667f1eb69ce1103987c461d56219
Author: Larsson at .(none) <Larsson at .(none)>
Date:   Fri Feb 26 08:55:36 2010 +0100

    Fix warnings from visual studio compiler

diff --git a/common/lines.c b/common/lines.c
index 8e44ac3..e02f3d6 100644
--- a/common/lines.c
+++ b/common/lines.c
@@ -77,7 +77,7 @@ SOFTWARE.
 #define xrealloc(a,b) realloc(a,b)
 #define xfree(i) free(i)
 
-typedef uint32_t CARD32;
+typedef unsigned int CARD32;
 typedef int Boolean;
 typedef pixman_rectangle32_t xRectangle;
 typedef SpicePoint DDXPointRec;
@@ -89,7 +89,7 @@ typedef struct lineGC *GCPtr;
  * a signed type.
  */
 #define MAX_COORDINATE 2147483647
-#define MIN_COORDINATE -2147483648
+#define MIN_COORDINATE -2147483647
 
 #define miZeroLine spice_canvas_zero_line
 #define miZeroDashLine spice_canvas_zero_dash_line
@@ -99,7 +99,7 @@ typedef struct lineGC *GCPtr;
 static int inline
 ICEIL (double x)
 {
-    int _cTmp = x;
+    int _cTmp = (int)x;
     return ((x == _cTmp) || (x < 0.0)) ? _cTmp : _cTmp + 1;
 }
 
@@ -1420,7 +1420,7 @@ miZeroClipLine (int xmin, int ymin, int xmax, int ymax,
                 utmp++;
 
             if (negslope)
-                utmp = -utmp;
+                utmp = (uint32_t)(-(int32_t)utmp);
 
             if (eqn & T_2NDX)   /* We are calculating X steps */
                 x1 = anchorval + utmp;
@@ -2114,8 +2114,8 @@ miLineJoin (GCPtr pGC, Boolean foreground, SpanDataPtr spanData, LineFacePtr pLe
         scale = ady;
         if (adx > ady)
             scale = adx;
-        slopes[2].dx = (dx * 65536) / scale;
-        slopes[2].dy = (dy * 65536) / scale;
+        slopes[2].dx = (int) ((dx * 65536) / scale);
+        slopes[2].dy = (int) ((dy * 65536) / scale);
         slopes[2].k = ((pLeft->xa + pRight->xa) * slopes[2].dy -
                        (pLeft->ya + pRight->ya) * slopes[2].dx) / 2.0;
         edgecount = 3;
@@ -2217,7 +2217,7 @@ miLineArcD (GCPtr pGC,
 
     pts = points;
     wids = widths;
-    xbase = floor (xorg);
+    xbase = (int)floor (xorg);
     x0 = xorg - xbase;
     ybase = ICEIL (yorg);
     y0 = yorg - ybase;
@@ -2225,7 +2225,7 @@ miLineArcD (GCPtr pGC,
     xrk = x0 + x0 - 1.0;
     yk = y0 + y0 - 1.0;
     radius = ((double) pGC->lineWidth) / 2.0;
-    y = floor (radius - y0 + 1.0);
+    y = (int)floor (radius - y0 + 1.0);
     ybase -= y;
     ymin = ybase;
     ymax = 65536;
@@ -2303,7 +2303,7 @@ miLineArcD (GCPtr pGC,
     }
     er = xrk - (xr << 1) - er;
     el = (xl << 1) - xlk - el;
-    boty = floor (-y0 - radius + 1.0);
+    boty = (int)floor (-y0 - radius + 1.0);
     if (ybase + y - boty > ymax)
         boty = ymax - ybase - y;
     while (y > boty) {
@@ -3251,7 +3251,7 @@ miWideDashSegment (GCPtr pGC,
                        &lcapFace, (LineFacePtr) NULL, rcenterx, rcentery, FALSE);
         }
     }
-    dashRemain = ((double) dashRemain) - LRemain;
+    dashRemain = (int)(((double) dashRemain) - LRemain);
     if (dashRemain == 0) {
         dashIndex++;
         if (dashIndex == pGC->numInDashList)
diff --git a/common/pixman_utils.c b/common/pixman_utils.c
index 27257f7..30e8919 100644
--- a/common/pixman_utils.c
+++ b/common/pixman_utils.c
@@ -43,7 +43,7 @@ solid_rop_ ## _name ## _ ## _size (_type *ptr, int len, _type src)  \
 {                                                  \
     while (len--) {                                \
         _type dst = *ptr;                          \
-        if (dst) /* avoid unused warning */;       \
+        if (dst) /* avoid unused warning */{};       \
         *ptr = (_type)(_equation);                 \
         ptr++;                                     \
     }                                              \
@@ -56,8 +56,8 @@ tiled_rop_ ## _name ## _ ## _size (_type *ptr, int len, _type *tile, _type *tile
     while (len--) {                                \
         _type src = *tile;                         \
         _type dst = *ptr;                          \
-        if (src) /* avoid unused warning */;       \
-        if (dst) /* avoid unused warning */;       \
+        if (src) /* avoid unused warning */{};       \
+        if (dst) /* avoid unused warning */{};       \
         *ptr = (_type)(_equation);                 \
         ptr++;                                     \
         tile++;                                    \
@@ -73,8 +73,8 @@ static void                                        \
     while (len--) {                                \
         _type src = *src_line;                     \
         _type dst = *ptr;                          \
-        if (src) /* avoid unused warning */;       \
-        if (dst) /* avoid unused warning */;       \
+        if (src) /* avoid unused warning */ {};       \
+        if (dst) /* avoid unused warning */{};       \
         *ptr = (_type)(_equation);                 \
         ptr++;                                     \
         src_line++;                                \
commit bb77edf6435af599830e9500c13b8ef9d196e9c0
Author: Larsson at .(none) <Larsson at .(none)>
Date:   Fri Feb 26 08:52:38 2010 +0100

    Have only one copy of ROUND macro and cast to int explicitly

diff --git a/common/cairo_canvas.c b/common/cairo_canvas.c
index 15e4e24..addb3d4 100644
--- a/common/cairo_canvas.c
+++ b/common/cairo_canvas.c
@@ -26,8 +26,6 @@
 #include "lines.h"
 #include "pixman_utils.h"
 
-#define ROUND(_x) floor((_x) + 0.5)
-
 struct CairoCanvas {
     CanvasBase base;
     uint32_t *private_data;
diff --git a/common/canvas_base.c b/common/canvas_base.c
index 09fdca0..23039eb 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -76,7 +76,7 @@
 #define MAX(x, y) (((x) >= (y)) ? (x) : (y))
 #endif
 
-#define ROUND(_x) floor((_x) + 0.5)
+#define ROUND(_x) ((int)floor((_x) + 0.5))
 
 #ifdef WIN32
 typedef struct  __declspec (align(1)) LZImage {


More information about the Spice-commits mailing list