Mike McCormack : comctl32: Switch to a Nx4 tiling.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Nov 6 05:48:34 CST 2006
Module: wine
Branch: master
Commit: dfb41b35c47c0217eb08fa643484ae8c55f2b333
URL: http://source.winehq.org/git/wine.git/?a=commit;h=dfb41b35c47c0217eb08fa643484ae8c55f2b333
Author: Mike McCormack <mike at codeweavers.com>
Date: Sun Nov 5 18:02:39 2006 +0900
comctl32: Switch to a Nx4 tiling.
---
dlls/comctl32/imagelist.c | 47 +++++++++++++++++++++++++++++++++++++-------
1 files changed, 39 insertions(+), 8 deletions(-)
diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c
index 20da02f..843654a 100644
--- a/dlls/comctl32/imagelist.c
+++ b/dlls/comctl32/imagelist.c
@@ -84,28 +84,59 @@ static inline BOOL is_valid(HIMAGELIST h
return himl && himl->magic == IMAGELIST_MAGIC;
}
+/*
+ * An imagelist with N images is tiled like this:
+ *
+ * N/4 ->
+ *
+ * 4 048C..
+ * 159D..
+ * | 26AE.N
+ * V 37BF.
+ */
+
+#define TILE_COUNT 4
+
+static inline UINT imagelist_width( UINT count )
+{
+ return ((count + TILE_COUNT - 1)/TILE_COUNT);
+}
+
static inline void imagelist_point_from_index( HIMAGELIST himl, UINT index, LPPOINT pt )
{
- pt->x = index * himl->cx;
- pt->y = 0;
+ pt->x = (index/TILE_COUNT) * himl->cx;
+ pt->y = (index%TILE_COUNT) * himl->cy;
}
static inline void imagelist_get_bitmap_size( HIMAGELIST himl, UINT count, UINT cy, SIZE *sz )
{
- sz->cx = count * himl->cx;
- sz->cy = cy;
+ sz->cx = imagelist_width( count ) * himl->cx;
+ sz->cy = cy*TILE_COUNT;
}
+/*
+ * imagelist_copy_images()
+ *
+ * Copies a block of count images from offset src in the list to offset dest.
+ * Images are copied a row at at time. Assumes hdcSrc and hdcDest are different.
+ */
static inline void imagelist_copy_images( HIMAGELIST himl, HDC hdcSrc, HDC hdcDest,
UINT src, UINT count, UINT dest )
{
POINT ptSrc, ptDest;
SIZE sz;
+ UINT i;
- imagelist_point_from_index( himl, src, &ptSrc );
- imagelist_point_from_index( himl, dest, &ptDest );
- imagelist_get_bitmap_size( himl, count, himl->cy, &sz );
- BitBlt (hdcDest, ptSrc.x, ptSrc.y, sz.cx, sz.cy, hdcSrc, ptDest.x, ptDest.y, SRCCOPY);
+ for ( i=0; i<TILE_COUNT; i++ )
+ {
+ imagelist_point_from_index( himl, src+i, &ptSrc );
+ imagelist_point_from_index( himl, dest+i, &ptDest );
+ sz.cx = himl->cx * imagelist_width( count - i );
+ sz.cy = himl->cy;
+
+ BitBlt( hdcDest, ptDest.x, ptDest.y, sz.cx, sz.cy,
+ hdcSrc, ptSrc.x, ptSrc.y, SRCCOPY );
+ }
}
/*************************************************************************
More information about the wine-cvs
mailing list