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