[Spice-commits] 5 commits - display/driver.c display/res.c display/rop.c display/surface.c display/surface.h
Alexander Larsson
alexl at kemper.freedesktop.org
Fri Apr 23 07:55:48 PDT 2010
display/driver.c | 16 ++++++-----
display/res.c | 27 ++++++++++++++++++
display/rop.c | 78 ++++--------------------------------------------------
display/surface.c | 55 +++++++++++++++-----------------------
display/surface.h | 2 -
5 files changed, 65 insertions(+), 113 deletions(-)
New commits:
commit ce4d7b746bffea5a051e6e28236c122ae9ba824a
Author: Alexander Larsson <alexl at redhat.com>
Date: Fri Apr 23 12:51:06 2010 +0200
Revert disabling of alpha blend from surfaces
diff --git a/display/surface.c b/display/surface.c
index fb10985..552b756 100644
--- a/display/surface.c
+++ b/display/surface.c
@@ -111,30 +111,16 @@ HBITMAP CreateDeviceBitmap(PDev *pdev, SIZEL size, ULONG format, QXLPHYSICAL *ph
goto out_error1;
}
- if (allocation_type == DEVICE_BITMAP_ALLOCATION_TYPE_SURF0) {
- if (!EngAssociateSurface((HSURF)surf, pdev->eng, HOOK_SYNCHRONIZE | HOOK_COPYBITS |
- HOOK_BITBLT | HOOK_TEXTOUT | HOOK_STROKEPATH | HOOK_STRETCHBLT |
- HOOK_STRETCHBLTROP | HOOK_TRANSPARENTBLT
+ if (!EngAssociateSurface((HSURF)surf, pdev->eng, HOOK_SYNCHRONIZE | HOOK_COPYBITS |
+ HOOK_BITBLT | HOOK_TEXTOUT | HOOK_STROKEPATH | HOOK_STRETCHBLT |
+ HOOK_STRETCHBLTROP | HOOK_TRANSPARENTBLT | HOOK_ALPHABLEND
#ifdef CALL_TEST
- | HOOK_PLGBLT | HOOK_FILLPATH | HOOK_STROKEANDFILLPATH | HOOK_LINETO |
- HOOK_GRADIENTFILL
+ | HOOK_PLGBLT | HOOK_FILLPATH | HOOK_STROKEANDFILLPATH | HOOK_LINETO |
+ HOOK_GRADIENTFILL
#endif
- )) {
- DEBUG_PRINT((pdev, 0, "%s: EngAssociateSurface failed\n", __FUNCTION__));
- goto out_error2;
- }
- } else {
- if (!EngAssociateSurface((HSURF)surf, pdev->eng, HOOK_SYNCHRONIZE | HOOK_COPYBITS |
- HOOK_BITBLT | HOOK_TEXTOUT | HOOK_STROKEPATH | HOOK_STRETCHBLT |
- HOOK_STRETCHBLTROP | HOOK_TRANSPARENTBLT | HOOK_ALPHABLEND
- #ifdef CALL_TEST
- | HOOK_PLGBLT | HOOK_FILLPATH | HOOK_STROKEANDFILLPATH | HOOK_LINETO |
- HOOK_GRADIENTFILL
- #endif
- )) {
- DEBUG_PRINT((pdev, 0, "%s: EngAssociateSurface failed\n", __FUNCTION__));
- goto out_error2;
- }
+ )) {
+ DEBUG_PRINT((pdev, 0, "%s: EngAssociateSurface failed\n", __FUNCTION__));
+ goto out_error2;
}
pdev->surfaces_info[surface_id].pdev = pdev;
commit 041d23e8829dcc83514f4235374e70d80412c044
Author: Alexander Larsson <alexl at redhat.com>
Date: Fri Apr 23 15:27:19 2010 +0200
Always send 32bpp as rgba if any alpha byte is non-zero
diff --git a/display/res.c b/display/res.c
index 2ea9565..c5a381e 100644
--- a/display/res.c
+++ b/display/res.c
@@ -1946,6 +1946,25 @@ static _inline UINT32 get_image_serial()
return ret;
}
+static int rgb32_data_has_alpha(int width, int height, int stride,
+ UINT8 *data)
+{
+ UINT32 *line, *end;
+
+ while (height-- > 0) {
+ line = (UINT32 *)data;
+ end = line + width;
+ data += stride;
+ while (line != end) {
+ if ((*line & 0xff000000) != 0) {
+ return 1;
+ }
+ line++;
+ }
+ }
+ return 0;
+}
+
BOOL QXLGetBitmap(PDev *pdev, QXLDrawable *drawable, QXLPHYSICAL *image_phys, SURFOBJ *surf,
SpiceRect *area, XLATEOBJ *color_trans, UINT32 *hash_key, BOOL use_cache,
INT32 *surface_dest)
@@ -1994,6 +2013,14 @@ BOOL QXLGetBitmap(PDev *pdev, QXLDrawable *drawable, QXLPHYSICAL *image_phys, SU
return FALSE;
}
+ if (surf->iBitmapFormat == BMF_32BPP) {
+ if (rgb32_data_has_alpha(width, height, surf->lDelta,
+ (UINT8 *)surf->pvScan0 + area->left * 4)) {
+ return QXLGetAlphaBitmap(pdev, drawable, image_phys,
+ surf, area, surface_dest);
+ }
+ }
+
DEBUG_PRINT((pdev, 11, "%s: iUniq=%x DONTCACHE=%x w=%d h=%d cx=%d cy=%d "
"hsurf=%x ctiUniq=%x XO_TABLE=%u format=%u\n", __FUNCTION__,
surf->iUniq, surf->fjBitmap & BMF_DONTCACHE, width, height,
commit cd8815fe377387b7930c19246df67bbca77a8f84
Author: Alexander Larsson <alexl at redhat.com>
Date: Fri Apr 23 12:48:23 2010 +0200
Support source alpha flag for surfaces
diff --git a/display/rop.c b/display/rop.c
index 2696371..524f80f 100644
--- a/display/rop.c
+++ b/display/rop.c
@@ -1645,6 +1645,11 @@ BOOL APIENTRY DrvAlphaBlend(SURFOBJ *dest, SURFOBJ *src, CLIPOBJ *clip, XLATEOBJ
return FALSE;
}
}
+ drawable->u.alpha_blend.alpha_flags = 0;
+ if (src->iType != STYPE_BITMAP &&
+ bland->BlendFunction.AlphaFormat == AC_SRC_ALPHA)
+ drawable->u.alpha_blend.alpha_flags |= SPICE_ALPHA_FLAGS_SRC_SURFACE_HAS_ALPHA;
+
drawable->u.alpha_blend.alpha = bland->BlendFunction.SourceConstantAlpha;
drawable->effect = QXL_EFFECT_BLEND;
commit 321c436e3d794139ad82ec65a37f65e1c7335cd7
Author: Alexander Larsson <alexl at redhat.com>
Date: Fri Apr 23 12:34:27 2010 +0200
Handle surfaces being in their "normal" format in spice, not 32bit
diff --git a/display/rop.c b/display/rop.c
index 59b63d5..2696371 100644
--- a/display/rop.c
+++ b/display/rop.c
@@ -940,61 +940,6 @@ static BOOL DoROP3(PDev *pdev, UINT32 surface_id, RECTL *area, CLIPOBJ *clip, SU
return TRUE;
}
-static SURFOBJ *Copy16bppArea(PDev *pdev, SURFOBJ *src, RECTL *area)
-{
- SIZEL size;
- HSURF bitmap;
- SURFOBJ *surf_obj;
- UINT8 *dest_line;
- UINT8 *dest_end_line;
- LONG src_stride;
- UINT8 *src_line;
- SurfaceInfo *surface;
-
- surface = (SurfaceInfo *)src->dhsurf;
-
- size.cx = area->right - area->left;
- size.cy = area->bottom - area->top;
-
- if (!(bitmap = (HSURF)EngCreateBitmap(size, 0, BMF_16BPP, 0, NULL))) {
- DEBUG_PRINT((pdev, 0, "%s: EngCreateBitmap failed\n", __FUNCTION__));
- return NULL;
- }
-
- if (!EngAssociateSurface(bitmap, pdev->eng, 0)) {
- DEBUG_PRINT((pdev, 0, "%s: EngAssociateSurface failed\n", __FUNCTION__));
- goto error;
- }
-
- if (!(surf_obj = EngLockSurface(bitmap))) {
- DEBUG_PRINT((pdev, 0, "%s: EngLockSurface failed\n", __FUNCTION__));
- goto error;
- }
-
- dest_line = surf_obj->pvScan0;
- dest_end_line = dest_line + surf_obj->lDelta * surf_obj->sizlBitmap.cy;
- src_stride = surface->draw_area.surf_obj->lDelta;
- src_line = (UINT8 *)surface->draw_area.surf_obj->pvScan0 + area->top * src_stride +
- (area->left << 2);
-
- for (; dest_line != dest_end_line; dest_line += surf_obj->lDelta, src_line += src_stride) {
- UINT16 *dest = (UINT16 *)dest_line;
- UINT16 *end = dest + surf_obj->sizlBitmap.cx;
- UINT32 *src = (UINT32 *)src_line;
- for (; dest < end; dest++, src++) {
- *dest = ((*src & 0x00f80000) >> 9) |
- ((*src & 0x0000f800) >> 6) |
- ((*src & 0x000000f8) >> 3);
- }
- }
- return surf_obj;
-
-error:
- EngDeleteSurface(bitmap);
- return NULL;
-
-}
-
BOOL BitBltFromDev(PDev *pdev, SURFOBJ *src, SURFOBJ *dest, SURFOBJ *mask, CLIPOBJ *clip,
XLATEOBJ *color_trans, RECTL *dest_rect, POINTL src_pos,
POINTL *mask_pos, BRUSHOBJ *brush, POINTL *brush_pos, ROP4 rop4)
@@ -1019,16 +964,7 @@ BOOL BitBltFromDev(PDev *pdev, SURFOBJ *src, SURFOBJ *dest, SURFOBJ *mask, CLIPO
UpdateArea(pdev, &area, surface_id);
- if (pdev->bitmap_format == BMF_16BPP) {
- surf_obj = Copy16bppArea(pdev, src, &area);
- if (!surf_obj) {
- return FALSE;
- }
- src_pos.y = src_pos.y - area.top;
- src_pos.x = src_pos.x - area.left;
- } else {
- surf_obj = surface->draw_area.surf_obj;
- }
+ surf_obj = surface->draw_area.surf_obj;
if (rop4 == 0xcccc) {
ret = EngCopyBits(dest, surf_obj, clip, color_trans, dest_rect, &src_pos);
@@ -1037,13 +973,6 @@ BOOL BitBltFromDev(PDev *pdev, SURFOBJ *src, SURFOBJ *dest, SURFOBJ *mask, CLIPO
mask_pos, brush, brush_pos, rop4);
}
- if (pdev->bitmap_format == BMF_16BPP) {
- HSURF surf = surf_obj->hsurf;
-
- EngUnlockSurface(surf_obj);
- EngDeleteSurface(surf);
- }
-
return ret;
}
diff --git a/display/surface.c b/display/surface.c
index 41e8a7e..fb10985 100644
--- a/display/surface.c
+++ b/display/surface.c
@@ -145,7 +145,7 @@ HBITMAP CreateDeviceBitmap(PDev *pdev, SIZEL size, ULONG format, QXLPHYSICAL *ph
goto out_error2;
}
- if (!CreateDrawArea(pdev, *base_mem, size.cx, size.cy, stride, surface_id)) {
+ if (!CreateDrawArea(pdev, *base_mem, format, size.cx, size.cy, stride, surface_id)) {
goto out_error3;
}
diff --git a/display/surface.h b/display/surface.h
index e0ecc57..ca1ffec 100644
--- a/display/surface.h
+++ b/display/surface.h
@@ -43,7 +43,7 @@ enum {
DEVICE_BITMAP_ALLOCATION_TYPE_VRAM,
};
-BOOL CreateDrawArea(PDev *pdev, UINT8 *base_mem, UINT32 cx, UINT32 cy, UINT32 stride,
+BOOL CreateDrawArea(PDev *pdev, UINT8 *base_mem, ULONG format, UINT32 cx, UINT32 cy, UINT32 stride,
UINT32 surface_id);
VOID FreeDrawArea(DrawArea *drawarea);
commit 6703559dbb0de40c6d5c513b78a54846e105f2ab
Author: Alexander Larsson <alexl at redhat.com>
Date: Fri Apr 16 11:44:25 2010 +0200
Initial format work
diff --git a/display/driver.c b/display/driver.c
index 13eeabe..89814e5 100644
--- a/display/driver.c
+++ b/display/driver.c
@@ -586,13 +586,14 @@ static VOID HideMouse(PDev *pdev)
PushCursorCmd(pdev, cursor_cmd);
}
-static VOID CreatePrimarySurface(PDev *pdev, UINT32 depth, UINT32 width, UINT32 height,
+static VOID CreatePrimarySurface(PDev *pdev, UINT32 depth, UINT32 format,
+ UINT32 width, UINT32 height,
QXLPHYSICAL phys_mem)
{
- pdev->primary_surface_create->depth = depth;
+ pdev->primary_surface_create->format = format;
pdev->primary_surface_create->width = width;
pdev->primary_surface_create->height = height;
- pdev->primary_surface_create->stride = -(INT32)width * 4;
+ pdev->primary_surface_create->stride = -(INT32)width * (depth / 8);
pdev->primary_surface_create->mem = phys_mem;
pdev->primary_surface_create->flags = 0;
@@ -834,25 +835,26 @@ static VOID UnmapFB(PDev *pdev)
VOID EnableQXLPrimarySurface(PDev *pdev)
{
- UINT32 depth;
+ UINT32 depth, format;
switch (pdev->bitmap_format) {
case BMF_8BPP:
PANIC(pdev, "bad formart type 8bpp\n");
case BMF_16BPP:
depth = 16;
+ format = SPICE_SURFACE_FMT_16_555;
break;
case BMF_24BPP:
- depth = 32;
- break;
case BMF_32BPP:
depth = 32;
+ format = SPICE_SURFACE_FMT_32_xRGB;
break;
default:
PANIC(pdev, "bad formart type\n");
};
- CreatePrimarySurface(pdev, depth, pdev->resolution.cx, pdev->resolution.cy, pdev->surf_phys);
+ CreatePrimarySurface(pdev, depth, format,
+ pdev->resolution.cx, pdev->resolution.cy, pdev->surf_phys);
pdev->surf_enable = TRUE;
}
diff --git a/display/surface.c b/display/surface.c
index f6f8b22..41e8a7e 100644
--- a/display/surface.c
+++ b/display/surface.c
@@ -36,7 +36,7 @@
#include "res.h"
#include "surface.h"
-BOOL CreateDrawArea(PDev *pdev, UINT8 *base_mem, UINT32 cx, UINT32 cy, UINT32 stride,
+BOOL CreateDrawArea(PDev *pdev, UINT8 *base_mem, ULONG format, UINT32 cx, UINT32 cy, UINT32 stride,
UINT32 surface_id)
{
SIZEL size;
@@ -47,7 +47,7 @@ BOOL CreateDrawArea(PDev *pdev, UINT8 *base_mem, UINT32 cx, UINT32 cy, UINT32 st
drawarea = &pdev->surfaces_info[surface_id].draw_area;
- if (!(drawarea->bitmap = (HSURF)EngCreateBitmap(size, stride, BMF_32BPP, 0, base_mem))) {
+ if (!(drawarea->bitmap = (HSURF)EngCreateBitmap(size, stride, format, 0, base_mem))) {
DEBUG_PRINT((pdev, 0, "%s: EngCreateBitmap failed\n", __FUNCTION__));
return FALSE;
}
@@ -82,23 +82,25 @@ VOID FreeDrawArea(DrawArea *drawarea)
HBITMAP CreateDeviceBitmap(PDev *pdev, SIZEL size, ULONG format, QXLPHYSICAL *phys_mem,
UINT8 **base_mem, UINT32 surface_id, UINT8 allocation_type)
{
- UINT8 depth;
+ UINT32 surface_format, depth;
HBITMAP surf;
UINT32 stride;
switch (format) {
- case BMF_8BPP:
- return 0;
- break;
case BMF_16BPP:
+ surface_format = SPICE_SURFACE_FMT_16_555;
depth = 16;
break;
case BMF_24BPP:
- depth = 32;
- break;
case BMF_32BPP:
+ if (allocation_type == DEVICE_BITMAP_ALLOCATION_TYPE_SURF0) {
+ surface_format = SPICE_SURFACE_FMT_32_xRGB;
+ } else {
+ surface_format = SPICE_SURFACE_FMT_32_ARGB;
+ }
depth = 32;
break;
+ case BMF_8BPP:
default:
return 0;
};
@@ -137,7 +139,8 @@ HBITMAP CreateDeviceBitmap(PDev *pdev, SIZEL size, ULONG format, QXLPHYSICAL *ph
pdev->surfaces_info[surface_id].pdev = pdev;
- QXLGetSurface(pdev, phys_mem, size.cx, size.cy, 32, &stride, base_mem, allocation_type);
+ QXLGetSurface(pdev, phys_mem, size.cx, size.cy, depth,
+ &stride, base_mem, allocation_type);
if (!*base_mem) {
goto out_error2;
}
@@ -150,7 +153,7 @@ HBITMAP CreateDeviceBitmap(PDev *pdev, SIZEL size, ULONG format, QXLPHYSICAL *ph
QXLSurfaceCmd *surface;
surface = SurfaceCmd(pdev, QXL_SURFACE_CMD_CREATE, surface_id);
- surface->u.surface_create.depth = depth;
+ surface->u.surface_create.format = surface_format;
surface->u.surface_create.width = size.cx;
surface->u.surface_create.height = size.cy;
surface->u.surface_create.stride = -(INT32)stride;
More information about the Spice-commits
mailing list