summaryrefslogtreecommitdiffstats
path: root/qemu/pixman/demos/linear-gradient.c
diff options
context:
space:
mode:
authorYang Zhang <yang.z.zhang@intel.com>2015-08-28 09:58:54 +0800
committerYang Zhang <yang.z.zhang@intel.com>2015-09-01 12:44:00 +0800
commite44e3482bdb4d0ebde2d8b41830ac2cdb07948fb (patch)
tree66b09f592c55df2878107a468a91d21506104d3f /qemu/pixman/demos/linear-gradient.c
parent9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00 (diff)
Add qemu 2.4.0
Change-Id: Ic99cbad4b61f8b127b7dc74d04576c0bcbaaf4f5 Signed-off-by: Yang Zhang <yang.z.zhang@intel.com>
Diffstat (limited to 'qemu/pixman/demos/linear-gradient.c')
-rw-r--r--qemu/pixman/demos/linear-gradient.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/qemu/pixman/demos/linear-gradient.c b/qemu/pixman/demos/linear-gradient.c
new file mode 100644
index 000000000..46433a6e5
--- /dev/null
+++ b/qemu/pixman/demos/linear-gradient.c
@@ -0,0 +1,50 @@
+#include "../test/utils.h"
+#include "gtk-utils.h"
+
+#define WIDTH 1024
+#define HEIGHT 640
+
+int
+main (int argc, char **argv)
+{
+ pixman_image_t *src_img, *dest_img;
+ pixman_gradient_stop_t stops[] = {
+ { 0x00000, { 0x0000, 0x0000, 0x4444, 0xdddd } },
+ { 0x10000, { 0xeeee, 0xeeee, 0x8888, 0xdddd } },
+#if 0
+ /* These colors make it very obvious that dithering
+ * is useful even for 8-bit gradients
+ */
+ { 0x00000, { 0x6666, 0x3333, 0x3333, 0xffff } },
+ { 0x10000, { 0x3333, 0x6666, 0x6666, 0xffff } },
+#endif
+ };
+ pixman_point_fixed_t p1, p2;
+
+ enable_divbyzero_exceptions ();
+
+ dest_img = pixman_image_create_bits (PIXMAN_x8r8g8b8,
+ WIDTH, HEIGHT,
+ NULL, 0);
+
+ p1.x = p1.y = 0x0000;
+ p2.x = WIDTH << 16;
+ p2.y = HEIGHT << 16;
+
+ src_img = pixman_image_create_linear_gradient (&p1, &p2, stops, ARRAY_LENGTH (stops));
+
+ pixman_image_composite32 (PIXMAN_OP_OVER,
+ src_img,
+ NULL,
+ dest_img,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ WIDTH, HEIGHT);
+
+ show_image (dest_img);
+
+ pixman_image_unref (dest_img);
+
+ return 0;
+}