[m-rev.] [PATCH 03/11] mercury_cairo: Fix swapped width, height arguments on create_surface.

Peter Wang novalazy at gmail.com
Fri Sep 4 12:00:51 AEST 2015


extras/graphics/mercury_cairo/cairo.image.m:
extras/graphics/mercury_cairo/cairo.pdf.m:
extras/graphics/mercury_cairo/cairo.ps.m:
extras/graphics/mercury_cairo/cairo.region.m:
extras/graphics/mercury_cairo/cairo.svg.m:
	Fix swapped width, height arguments on create_surface
	predicates.
---
 extras/graphics/mercury_cairo/cairo.image.m  | 10 +++++-----
 extras/graphics/mercury_cairo/cairo.pdf.m    | 20 ++++++++++----------
 extras/graphics/mercury_cairo/cairo.ps.m     | 12 ++++++------
 extras/graphics/mercury_cairo/cairo.region.m |  4 ++--
 extras/graphics/mercury_cairo/cairo.svg.m    |  8 ++++----
 5 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/extras/graphics/mercury_cairo/cairo.image.m b/extras/graphics/mercury_cairo/cairo.image.m
index 291faad..7aa59c7 100644
--- a/extras/graphics/mercury_cairo/cairo.image.m
+++ b/extras/graphics/mercury_cairo/cairo.image.m
@@ -24,7 +24,7 @@
 
 %---------------------------------------------------------------------------%
 
-    % image.create_surface(Format, Height, Width, Surface, !IO):
+    % image.create_surface(Format, Width, Height, Surface, !IO):
     % Surface is a new image surface.
     % Throws a cairo.error/0 exception if the surface cannot be created.
     %
@@ -68,8 +68,8 @@
 % Image surface creation
 %
 
-create_surface(Format, Height, Width, Surface, !IO) :-
-    create_surface_2(Format, Height, Width, Status, Surface, !IO),
+create_surface(Format, Width, Height, Surface, !IO) :-
+    create_surface_2(Format, Width, Height, Status, Surface, !IO),
     ( Status = status_success ->
         true
     ;
@@ -80,14 +80,14 @@ create_surface(Format, Height, Width, Surface, !IO) :-
     image_surface::out, io::di, io::uo) is det.
 
 :- pragma foreign_proc("C",
-    create_surface_2(Fmt::in, H::in, W::in, Status::out, Surface::out,
+    create_surface_2(Fmt::in, W::in, H::in, Status::out, Surface::out,
         _IO0::di, _IO::uo), 
     [promise_pure, will_not_call_mercury],
 "
     cairo_surface_t		*raw_surface;
 
     raw_surface = cairo_image_surface_create((cairo_format_t)Fmt,
-		(int)H, (int)W);
+		(int)W, (int)H);
     Status = cairo_surface_status(raw_surface);
 
     switch (Status) {
diff --git a/extras/graphics/mercury_cairo/cairo.pdf.m b/extras/graphics/mercury_cairo/cairo.pdf.m
index 75e0917..a6f3e56 100644
--- a/extras/graphics/mercury_cairo/cairo.pdf.m
+++ b/extras/graphics/mercury_cairo/cairo.pdf.m
@@ -28,8 +28,8 @@
     %
 :- pred have_pdf_surface is semidet.
 
-    % pdf.create_surface(FileName, Height, Width, Surface, !IO):
-    % Surface is a PDF surface of the specified Height and Width in points
+    % pdf.create_surface(FileName, Width, Height, Surface, !IO):
+    % Surface is a PDF surface of the specified Width and Height in points
     % to be written to FileName. 
     % Throws an unsupported_surface_error/0 exception if PDF surfaces are
     % not supported by this implementation.  Throws a cairo.error/0 exception
@@ -38,10 +38,10 @@
 :- pred create_surface(string::in, float::in, float::in, pdf_surface::out,
 	io::di, io::uo) is det.
 
-    % pdf.set_size(Surface, Height, Width, !IO):
+    % pdf.set_size(Surface, Width, Height, !IO):
     % Change the size of a PDF surface for the current (and subsequent) pages.
     %
-:- pred set_size(pdf_surface::in, float/*height*/::in, float/*width*/::in,
+:- pred set_size(pdf_surface::in, float::in, float::in,
     io::di, io::uo) is det.
 
 %---------------------------------------------------------------------------%
@@ -82,8 +82,8 @@
 % PDF surface creation
 %
 
-create_surface(FileName, Height, Width, Surface, !IO) :-
-    create_surface_2(FileName, Height, Width, Supported, Status, Surface, !IO),
+create_surface(FileName, Width, Height, Surface, !IO) :-
+    create_surface_2(FileName, Width, Height, Supported, Status, Surface, !IO),
     (
         Supported = yes,
         ( Status = status_success ->
@@ -100,7 +100,7 @@ create_surface(FileName, Height, Width, Surface, !IO) :-
     bool::out, cairo.status::out, pdf_surface::out, io::di, io::uo) is det.
 
 :- pragma foreign_proc("C",
-	create_surface_2(FileName::in, H::in, W::in,
+	create_surface_2(FileName::in, W::in, H::in,
         Supported::out, Status::out, Surface::out, _IO0::di, _IO::uo),
 	[promise_pure, will_not_call_mercury, tabled_for_io],
 "
@@ -109,7 +109,7 @@ create_surface(FileName, Height, Width, Surface, !IO) :-
     cairo_surface_t		*raw_surface;
 
     Supported = MR_YES;
-    raw_surface = cairo_pdf_surface_create(FileName, H, W);
+    raw_surface = cairo_pdf_surface_create(FileName, W, H);
     Status = cairo_surface_status(raw_surface);
 
     switch (Status) {
@@ -140,12 +140,12 @@ create_surface(FileName, Height, Width, Surface, !IO) :-
 ").
 
 :- pragma foreign_proc("C",
-    set_size(Surface::in, Height::in, Width::in, _IO0::di, _IO::uo),
+    set_size(Surface::in, Width::in, Height::in, _IO0::di, _IO::uo),
     [promise_pure, will_not_call_mercury, tabled_for_io],
 "
 #if defined(CAIRO_HAS_PDF_SURFACE)
     cairo_pdf_surface_set_size(Surface->mcairo_raw_surface,
-        Height, Width);
+        Width, Height);
 #else
     MR_external_fatal_error(\"Mercury cairo\",
         \"PDF surfaces not supported by this installation\");
diff --git a/extras/graphics/mercury_cairo/cairo.ps.m b/extras/graphics/mercury_cairo/cairo.ps.m
index 5a4fea8..f3ecf46 100644
--- a/extras/graphics/mercury_cairo/cairo.ps.m
+++ b/extras/graphics/mercury_cairo/cairo.ps.m
@@ -39,8 +39,8 @@
     %
 :- pred have_ps_surface is semidet.
 
-    % ps.create_surface(FileName, Height, Width, Surface, !IO):
-    % Surface is a PostScript surface of the specified Height and Width in
+    % ps.create_surface(FileName, Width, Height, Surface, !IO):
+    % Surface is a PostScript surface of the specified Width and Height in
     % in points to be written to FileName.
     % Throw an unsupported_surface_error/0 exception if PostScript surfaces
     % are not supported by this implementation.  Throws a cairo.error/0
@@ -128,8 +128,8 @@
 % PostScript surface creation
 %
 
-create_surface(FileName, Height, Width, Surface, !IO) :-
-    create_surface_2(FileName, Height, Width, Supported, Status, Surface, !IO),
+create_surface(FileName, Width, Height, Surface, !IO) :-
+    create_surface_2(FileName, Width, Height, Supported, Status, Surface, !IO),
     (
         Supported = yes,
         ( Status = status_success ->
@@ -146,7 +146,7 @@ create_surface(FileName, Height, Width, Surface, !IO) :-
     bool::out, cairo.status::out, ps_surface::out, io::di, io::uo) is det.
 
 :- pragma foreign_proc("C",
-	create_surface_2(FileName::in, H::in, W::in,
+	create_surface_2(FileName::in, W::in, H::in,
         Supported::out, Status::out, Surface::out, _IO0::di, _IO::uo),
 	[promise_pure, will_not_call_mercury, tabled_for_io],
 "
@@ -155,7 +155,7 @@ create_surface(FileName, Height, Width, Surface, !IO) :-
     cairo_surface_t		*raw_surface;
 
     Supported = MR_YES;
-    raw_surface = cairo_ps_surface_create(FileName, H, W);
+    raw_surface = cairo_ps_surface_create(FileName, W, H);
     Status = cairo_surface_status(raw_surface);
     
     switch (Status) {
diff --git a/extras/graphics/mercury_cairo/cairo.region.m b/extras/graphics/mercury_cairo/cairo.region.m
index f7fe719..d86090f 100644
--- a/extras/graphics/mercury_cairo/cairo.region.m
+++ b/extras/graphics/mercury_cairo/cairo.region.m
@@ -228,8 +228,8 @@ get_extents(Region, Rectangle, !IO) :-
 ").
 
 get_rectangle(Region, N, Rectangle, !IO) :-
-    get_rectangle_2(Region, N, X, Y, Height, Width, !IO),
-    Rectangle = rectangle(X, Y, Height, Width).
+    get_rectangle_2(Region, N, X, Y, Width, Height, !IO),
+    Rectangle = rectangle(X, Y, Width, Height).
 
 :- pred get_rectangle_2(region::in, int::in, int::out, int::out,
     int::out, int::out, io::di, io::uo) is det.
diff --git a/extras/graphics/mercury_cairo/cairo.svg.m b/extras/graphics/mercury_cairo/cairo.svg.m
index bfbfb60..acf66b1 100644
--- a/extras/graphics/mercury_cairo/cairo.svg.m
+++ b/extras/graphics/mercury_cairo/cairo.svg.m
@@ -90,8 +90,8 @@
 % SVG surface creation
 %
 
-create_surface(FileName, Height, Width, Surface, !IO) :-
-    create_surface_2(FileName, Height, Width, Supported, Status, Surface, !IO),
+create_surface(FileName, Width, Height, Surface, !IO) :-
+    create_surface_2(FileName, Width, Height, Supported, Status, Surface, !IO),
     (
         Supported = yes,
         ( Status = status_success ->
@@ -108,7 +108,7 @@ create_surface(FileName, Height, Width, Surface, !IO) :-
     cairo.status::out, svg_surface::out, io::di, io::uo) is det.
 
 :- pragma foreign_proc("C",
-    create_surface_2(FileName::in, H::in, W::in,
+    create_surface_2(FileName::in, W::in, H::in,
         Supported::out, Status::out, Surface::out, _IO0::di, _IO::uo),
     [promise_pure, will_not_call_mercury, tabled_for_io],
 "
@@ -117,7 +117,7 @@ create_surface(FileName, Height, Width, Surface, !IO) :-
     cairo_surface_t		*raw_surface;
 
     Supported = MR_YES;
-    raw_surface = cairo_svg_surface_create(FileName, (int)H, (int)W);
+    raw_surface = cairo_svg_surface_create(FileName, (int)W, (int)H);
     Status = cairo_surface_status(raw_surface);
 
     switch (Status) {
-- 
2.1.2




More information about the reviews mailing list