summaryrefslogtreecommitdiffstats
path: root/client/windows
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-04-19 16:19:43 +0200
committerAlexander Larsson <alexl@redhat.com>2010-04-23 16:36:35 +0200
commit98d91203c5d2f6f7249f38941466857b6a566f5d (patch)
treecdc2b54152f0be3d668ed49b903a35886fcc1c99 /client/windows
parent619c37af17406f77c7cb76f3b72bbfc268383d91 (diff)
downloadspice-98d91203c5d2f6f7249f38941466857b6a566f5d.tar.gz
spice-98d91203c5d2f6f7249f38941466857b6a566f5d.tar.xz
spice-98d91203c5d2f6f7249f38941466857b6a566f5d.zip
Make client canvas and pixmaps handle more formats and simplify
We now support 16bit format pixmaps as well as the old ones. Including both 555 and 565 modes. We drop the palette argument for pixmap construction as it was only used for black/white anyway. Canvas creation is simplified so that there is no separate set_mode state. Canvases are already created in the right mode and never change.
Diffstat (limited to 'client/windows')
-rw-r--r--client/windows/red_pixmap.cpp4
-rw-r--r--client/windows/red_pixmap_cairo.cpp24
-rw-r--r--client/windows/red_pixmap_gdi.cpp21
3 files changed, 20 insertions, 29 deletions
diff --git a/client/windows/red_pixmap.cpp b/client/windows/red_pixmap.cpp
index 1ec41faf..574d2851 100644
--- a/client/windows/red_pixmap.cpp
+++ b/client/windows/red_pixmap.cpp
@@ -21,11 +21,11 @@
#include "utils.h"
RedPixmap::RedPixmap(int width, int height, RedPixmap::Format format,
- bool top_bottom, rgb32_t* pallet)
+ bool top_bottom)
: _format (format)
, _width (width)
, _height (height)
- , _stride (SPICE_ALIGN(width * (_format == RedPixmap::A1 ? 1: 32), 32) / 8)
+ , _stride (SPICE_ALIGN(width * format_to_bpp(format), 32) / 8)
, _top_bottom (top_bottom)
, _data (NULL)
{
diff --git a/client/windows/red_pixmap_cairo.cpp b/client/windows/red_pixmap_cairo.cpp
index 6ed58068..793d21ed 100644
--- a/client/windows/red_pixmap_cairo.cpp
+++ b/client/windows/red_pixmap_cairo.cpp
@@ -29,14 +29,9 @@ struct RedPixmap_p {
HBITMAP prev_bitmap;
};
-static inline int format_to_bpp(RedPixmap::Format format)
-{
- return ((format == RedPixmap::A1) ? 1 : 32);
-}
-
-RedPixmapCairo::RedPixmapCairo(int width, int height, RedPixmap::Format format, bool top_bottom,
- rgb32_t* pallet, RedWindow *win)
- : RedPixmap(width, height, format, top_bottom, pallet)
+RedPixmapCairo::RedPixmapCairo(int width, int height, RedPixmap::Format format,
+ bool top_bottom, RedWindow *win)
+ : RedPixmap(width, height, format, top_bottom)
{
ASSERT(format == RedPixmap::ARGB32 || format == RedPixmap::RGB32 || format == RedPixmap::A1);
ASSERT(sizeof(RedPixmap_p) <= PIXELES_SOURCE_OPAQUE_SIZE);
@@ -65,15 +60,16 @@ RedPixmapCairo::RedPixmapCairo(int width, int height, RedPixmap::Format format,
#endif*/
bitmap_info.inf.bmiHeader.biPlanes = 1;
- bitmap_info.inf.bmiHeader.biBitCount = format_to_bpp(format);
+ bitmap_info.inf.bmiHeader.biBitCount = RedPixmap::format_to_bpp(format);
bitmap_info.inf.bmiHeader.biCompression = BI_RGB;
switch (format) {
case RedPixmap::A1:
- for (int i = 0; i < (1 << format_to_bpp(format)); i++) {
- bitmap_info.inf.bmiColors[i].rgbRed = rgb32_get_red(pallet[i]);
- bitmap_info.inf.bmiColors[i].rgbGreen = rgb32_get_green(pallet[i]);
- bitmap_info.inf.bmiColors[i].rgbBlue = rgb32_get_blue(pallet[i]);
- }
+ bitmap_info.inf.bmiColors[0].rgbRed = 0;
+ bitmap_info.inf.bmiColors[0].rgbGreen = 0;
+ bitmap_info.inf.bmiColors[0].rgbBlue = 0;
+ bitmap_info.inf.bmiColors[1].rgbRed = 0xff;
+ bitmap_info.inf.bmiColors[1].rgbGreen = 0xff;
+ bitmap_info.inf.bmiColors[1].rgbBlue = 0xff;
break;
}
AutoDC dc(create_compatible_dc());
diff --git a/client/windows/red_pixmap_gdi.cpp b/client/windows/red_pixmap_gdi.cpp
index d4913c49..1c90f3d5 100644
--- a/client/windows/red_pixmap_gdi.cpp
+++ b/client/windows/red_pixmap_gdi.cpp
@@ -29,13 +29,7 @@ struct RedPixmap_p {
HBITMAP prev_bitmap;
};
-static inline int format_to_bpp(RedPixmap::Format format)
-{
- return ((format == RedPixmap::A1) ? 1 : 32);
-}
-
-RedPixmapGdi::RedPixmapGdi(int width, int height, RedPixmap::Format format, bool top_bottom,
- rgb32_t* pallet)
+RedPixmapGdi::RedPixmapGdi(int width, int height, RedPixmap::Format format, bool top_bottom)
: RedPixmap(width, height, format, top_bottom, pallet)
{
ASSERT(format == RedPixmap::ARGB32 || format == RedPixmap::RGB32 || format == RedPixmap::A1);
@@ -52,15 +46,16 @@ RedPixmapGdi::RedPixmapGdi(int width, int height, RedPixmap::Format format, bool
bitmap_info.inf.bmiHeader.biHeight = top_bottom ? -_height : _height;
bitmap_info.inf.bmiHeader.biPlanes = 1;
- bitmap_info.inf.bmiHeader.biBitCount = format_to_bpp(format);
+ bitmap_info.inf.bmiHeader.biBitCount = RedPixmap::format_to_bpp(format);
bitmap_info.inf.bmiHeader.biCompression = BI_RGB;
switch (format) {
case RedPixmap::A1:
- for (int i = 0; i < (1 << format_to_bpp(format)); i++) {
- bitmap_info.inf.bmiColors[i].rgbRed = rgb32_get_red(pallet[i]);
- bitmap_info.inf.bmiColors[i].rgbGreen = rgb32_get_green(pallet[i]);
- bitmap_info.inf.bmiColors[i].rgbBlue = rgb32_get_blue(pallet[i]);
- }
+ bitmap_info.inf.bmiColors[0].rgbRed = 0;
+ bitmap_info.inf.bmiColors[0].rgbGreen = 0;
+ bitmap_info.inf.bmiColors[0].rgbBlue = 0;
+ bitmap_info.inf.bmiColors[1].rgbRed = 0xff;
+ bitmap_info.inf.bmiColors[1].rgbGreen = 0xff;
+ bitmap_info.inf.bmiColors[1].rgbBlue = 0xff;
break;
}
AutoDC dc(create_compatible_dc());