summaryrefslogtreecommitdiff
path: root/platform/gl
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-06-13 12:51:27 +0200
committerRobin Watts <robin.watts@artifex.com>2018-06-22 16:48:47 +0100
commita8f5cda006a0042cbe19a030d6bcb777059f9714 (patch)
tree022a275487ffa6674b4d144b87e22a7d05cbea15 /platform/gl
parent33a521f1f52845d1a056f37afc62336b7bf6081c (diff)
downloadmupdf-a8f5cda006a0042cbe19a030d6bcb777059f9714.tar.xz
gl: Transform rotated pages so that the pixmap origin is always at 0,0.
Diffstat (limited to 'platform/gl')
-rw-r--r--platform/gl/gl-main.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/platform/gl/gl-main.c b/platform/gl/gl-main.c
index 15adb14d..044a41fe 100644
--- a/platform/gl/gl-main.c
+++ b/platform/gl/gl-main.c
@@ -204,13 +204,28 @@ void update_title(void)
glutSetIconTitle(buf);
}
-void load_page(void)
+void transform_page(void)
{
- fz_irect area;
+ fz_rect rect = page_bounds;
+ fz_matrix matrix;
+
+ draw_page_bounds = page_bounds;
fz_scale(&draw_page_ctm, currentzoom / 72, currentzoom / 72);
fz_pre_rotate(&draw_page_ctm, -currentrotate);
+ /* fix the page origin at 0,0 after rotation */
+ fz_transform_rect(&rect, &draw_page_ctm);
+ fz_translate(&matrix, -rect.x0, -rect.y0);
+ fz_concat(&draw_page_ctm, &draw_page_ctm, &matrix);
+
+ fz_transform_rect(&draw_page_bounds, &draw_page_ctm);
+}
+
+void load_page(void)
+{
+ fz_irect area;
+
/* clear all editor selections */
selected_annot = NULL;
@@ -230,8 +245,8 @@ void load_page(void)
/* compute bounds here for initial window size */
fz_bound_page(ctx, fzpage, &page_bounds);
- draw_page_bounds = page_bounds;
- fz_transform_rect(&draw_page_bounds, &draw_page_ctm);
+ transform_page();
+
fz_irect_from_rect(&area, &draw_page_bounds);
page_tex.w = area.x1 - area.x0;
page_tex.h = area.y1 - area.y0;
@@ -241,8 +256,7 @@ void render_page(void)
{
fz_pixmap *pix;
- fz_scale(&draw_page_ctm, currentzoom / 72, currentzoom / 72);
- fz_pre_rotate(&draw_page_ctm, -currentrotate);
+ transform_page();
pix = fz_new_pixmap_from_page(ctx, fzpage, &draw_page_ctm, fz_device_rgb(ctx), 0);
if (currentinvert)