Blame SOURCES/0006-pixel-buffer-switch-device-rotation-to-an-enum.patch

ff210d
From 555257c74f75bbb1086155fca52c29d71399b305 Mon Sep 17 00:00:00 2001
ff210d
From: Ray Strode <rstrode@redhat.com>
ff210d
Date: Tue, 10 Apr 2018 16:40:06 -0400
ff210d
Subject: [PATCH 6/6] pixel-buffer: switch device rotation to an enum
ff210d
ff210d
Right now device rotation is stored in a bare integer.
ff210d
ff210d
For clarity, switch that to an enum.
ff210d
---
ff210d
 src/libply-splash-core/ply-pixel-buffer.c | 12 +++++++-----
ff210d
 src/libply-splash-core/ply-pixel-buffer.h | 13 ++++++++-----
ff210d
 2 files changed, 15 insertions(+), 10 deletions(-)
ff210d
ff210d
diff --git a/src/libply-splash-core/ply-pixel-buffer.c b/src/libply-splash-core/ply-pixel-buffer.c
ff210d
index a337407..de3b107 100644
ff210d
--- a/src/libply-splash-core/ply-pixel-buffer.c
ff210d
+++ b/src/libply-splash-core/ply-pixel-buffer.c
ff210d
@@ -50,7 +50,8 @@ struct _ply_pixel_buffer
ff210d
         ply_region_t   *updated_areas; /* in device pixels */
ff210d
         uint32_t        is_opaque : 1;
ff210d
         int             device_scale;
ff210d
-        int             device_rotation;
ff210d
+
ff210d
+        ply_pixel_buffer_rotation_t device_rotation;
ff210d
 };
ff210d
 
ff210d
 static inline void ply_pixel_buffer_blend_value_at_pixel (ply_pixel_buffer_t *buffer,
ff210d
@@ -363,13 +364,14 @@ ply_pixel_buffer_new (unsigned long width,
ff210d
 }
ff210d
 
ff210d
 ply_pixel_buffer_t *
ff210d
-ply_pixel_buffer_new_with_device_rotation (unsigned long width,
ff210d
-                                           unsigned long height,
ff210d
-                                           int device_rotation)
ff210d
+ply_pixel_buffer_new_with_device_rotation (unsigned long               width,
ff210d
+                                           unsigned long               height,
ff210d
+                                           ply_pixel_buffer_rotation_t device_rotation)
ff210d
 {
ff210d
         ply_pixel_buffer_t *buffer;
ff210d
 
ff210d
-        if (device_rotation >= PLY_PIXEL_BUFFER_ROTATE_CLOCKWISE) {
ff210d
+        if (device_rotation == PLY_PIXEL_BUFFER_ROTATE_CLOCKWISE ||
ff210d
+            device_rotation == PLY_PIXEL_BUFFER_ROTATE_COUNTER_CLOCKWISE) {
ff210d
                 unsigned long tmp = width;
ff210d
                 width = height;
ff210d
                 height = tmp;
ff210d
diff --git a/src/libply-splash-core/ply-pixel-buffer.h b/src/libply-splash-core/ply-pixel-buffer.h
ff210d
index 7736dd3..ea7f833 100644
ff210d
--- a/src/libply-splash-core/ply-pixel-buffer.h
ff210d
+++ b/src/libply-splash-core/ply-pixel-buffer.h
ff210d
@@ -37,10 +37,13 @@ typedef struct _ply_pixel_buffer ply_pixel_buffer_t;
ff210d
          | ((uint8_t) (CLAMP (g * 255.0, 0.0, 255.0)) << 8)                      \
ff210d
          | ((uint8_t) (CLAMP (b * 255.0, 0.0, 255.0))))
ff210d
 
ff210d
-#define PLY_PIXEL_BUFFER_ROTATE_UPRIGHT             0
ff210d
-#define PLY_PIXEL_BUFFER_ROTATE_UPSIDE_DOWN         1
ff210d
-#define PLY_PIXEL_BUFFER_ROTATE_CLOCKWISE           2
ff210d
-#define PLY_PIXEL_BUFFER_ROTATE_COUNTER_CLOCKWISE   3
ff210d
+typedef enum
ff210d
+{
ff210d
+        PLY_PIXEL_BUFFER_ROTATE_UPRIGHT = 0,
ff210d
+        PLY_PIXEL_BUFFER_ROTATE_UPSIDE_DOWN,
ff210d
+        PLY_PIXEL_BUFFER_ROTATE_CLOCKWISE,
ff210d
+        PLY_PIXEL_BUFFER_ROTATE_COUNTER_CLOCKWISE
ff210d
+} ply_pixel_buffer_rotation_t;
ff210d
 
ff210d
 #ifndef PLY_HIDE_FUNCTION_DECLARATIONS
ff210d
 ply_pixel_buffer_t *ply_pixel_buffer_new (unsigned long width,
ff210d
@@ -48,7 +51,7 @@ ply_pixel_buffer_t *ply_pixel_buffer_new (unsigned long width,
ff210d
 ply_pixel_buffer_t *
ff210d
 ply_pixel_buffer_new_with_device_rotation (unsigned long width,
ff210d
                                            unsigned long height,
ff210d
-                                           int device_rotation);
ff210d
+                                           ply_pixel_buffer_rotation_t device_rotation);
ff210d
 void ply_pixel_buffer_free (ply_pixel_buffer_t *buffer);
ff210d
 void ply_pixel_buffer_get_size (ply_pixel_buffer_t *buffer,
ff210d
                                 ply_rectangle_t    *size);
ff210d
-- 
ff210d
2.17.0
ff210d