-
Notifications
You must be signed in to change notification settings - Fork 0
/
0006-pixel-buffer-switch-device-rotation-to-an-enum.patch
80 lines (71 loc) · 3.49 KB
/
0006-pixel-buffer-switch-device-rotation-to-an-enum.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
From 555257c74f75bbb1086155fca52c29d71399b305 Mon Sep 17 00:00:00 2001
From: Ray Strode <[email protected]>
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