NetSurf
plotters.c
Go to the documentation of this file.
1/*
2 * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/**
20 * \file
21 * RISC OS screen plotter implementation.
22 */
23
24#include <stdbool.h>
25#include <math.h>
26#include "oslib/colourtrans.h"
27#include "oslib/draw.h"
28#include "oslib/os.h"
29
30#include "utils/log.h"
31#include "netsurf/plotters.h"
32
33#include "riscos/bitmap.h"
34#include "riscos/image.h"
35#include "riscos/gui.h"
36#include "riscos/font.h"
37#include "riscos/oslib_pre7.h"
38
39
43
44/** One version of the A9home OS is incapable of drawing patterned lines */
46
47/**
48 * plot a path on RISC OS
49 */
50static nserror
51ro_plot_draw_path(const draw_path * const path,
52 int width,
53 colour c,
54 bool dotted,
55 bool dashed)
56{
57 static const draw_line_style line_style = {
58 draw_JOIN_MITRED,
59 draw_CAP_BUTT,
60 draw_CAP_BUTT,
61 0, 0x7fffffff,
62 0, 0, 0, 0
63 };
64 draw_dash_pattern dash = { 0, 1, { 512 } };
65 const draw_dash_pattern *dash_pattern = 0;
66 os_error *error;
67
68 if (width < 1)
69 width = 1;
70
72 if (dotted) {
73 dash.elements[0] = 512 * width;
74 dash_pattern = &dash;
75 } else if (dashed) {
76 dash.elements[0] = 1536 * width;
77 dash_pattern = &dash;
78 }
79 }
80
81 error = xcolourtrans_set_gcol(c << 8, 0, os_ACTION_OVERWRITE, 0, 0);
82 if (error) {
83 NSLOG(netsurf, INFO, "xcolourtrans_set_gcol: 0x%x: %s",
84 error->errnum, error->errmess);
85 return NSERROR_INVALID;
86 }
87
88 error = xdraw_stroke(path, 0, 0, 0, width * 2 * 256,
89 &line_style, dash_pattern);
90 if (error) {
91 NSLOG(netsurf, INFO, "xdraw_stroke: 0x%x: %s", error->errnum,
92 error->errmess);
93 return NSERROR_INVALID;
94 }
95
96 return NSERROR_OK;
97}
98
99
100/**
101 * \brief Sets a clip rectangle for subsequent plot operations.
102 *
103 * \param ctx The current redraw context.
104 * \param clip The rectangle to limit all subsequent plot
105 * operations within.
106 * \return NSERROR_OK on success else error code.
107 */
108static nserror
109ro_plot_clip(const struct redraw_context *ctx, const struct rect *clip)
110{
111 os_error *error;
112 char buf[12];
113
114 int clip_x0 = clip->x0 * 2;
115 int clip_y0 = clip->y1 * 2;
116 int clip_x1 = clip->x1 * 2;
117 int clip_y1 = clip->y0 * 2;
118
119 /* Avoid artefacts due to clip rectangle offsetting in EX0 EY0 modes.
120 * The area the WIMP asked us to draw might have dimensions that are
121 * not a multiple of 2. */
122 if (clip_x0 < ro_plot_clip_rect.x0) clip_x0 = ro_plot_clip_rect.x0;
123 if (clip_x1 > ro_plot_clip_rect.x1) clip_x1 = ro_plot_clip_rect.x1;
124 if (clip_y0 > ro_plot_clip_rect.y0) clip_y0 = ro_plot_clip_rect.y0;
125 if (clip_y1 < ro_plot_clip_rect.y1) clip_y1 = ro_plot_clip_rect.y1;
126
127 clip_x0 = ro_plot_origin_x + clip_x0;
128 clip_y0 = ro_plot_origin_y - clip_y0;
129 clip_x1 = ro_plot_origin_x + clip_x1 - 1;
130 clip_y1 = ro_plot_origin_y - clip_y1 - 1;
131
132 if (clip_x1 < clip_x0 || clip_y1 < clip_y0) {
133 NSLOG(netsurf, INFO, "bad clip rectangle %i %i %i %i",
134 clip_x0, clip_y0, clip_x1, clip_y1);
135 return NSERROR_BAD_SIZE;
136 }
137
138 buf[0] = os_VDU_SET_GRAPHICS_WINDOW;
139 buf[1] = clip_x0;
140 buf[2] = clip_x0 >> 8;
141 buf[3] = clip_y0;
142 buf[4] = clip_y0 >> 8;
143 buf[5] = clip_x1;
144 buf[6] = clip_x1 >> 8;
145 buf[7] = clip_y1;
146 buf[8] = clip_y1 >> 8;
147
148 error = xos_writen(buf, 9);
149 if (error) {
150 NSLOG(netsurf, INFO, "xos_writen: 0x%x: %s", error->errnum,
151 error->errmess);
152 return NSERROR_INVALID;
153 }
154
155 return NSERROR_OK;
156}
157
158
159/**
160 * Plots an arc
161 *
162 * plot an arc segment around (x,y), anticlockwise from angle1
163 * to angle2. Angles are measured anticlockwise from
164 * horizontal, in degrees.
165 *
166 * \param ctx The current redraw context.
167 * \param style Style controlling the arc plot.
168 * \param x The x coordinate of the arc.
169 * \param y The y coordinate of the arc.
170 * \param radius The radius of the arc.
171 * \param angle1 The start angle of the arc.
172 * \param angle2 The finish angle of the arc.
173 * \return NSERROR_OK on success else error code.
174 */
175static nserror
176ro_plot_arc(const struct redraw_context *ctx,
177 const plot_style_t *style,
178 int x, int y, int radius, int angle1, int angle2)
179{
180 os_error *error;
181 int sx, sy, ex, ey;
182 double t;
183
184 x = ro_plot_origin_x + x * 2;
185 y = ro_plot_origin_y - y * 2;
186 radius <<= 1;
187
188 error = xcolourtrans_set_gcol(style->fill_colour << 8, 0,
189 os_ACTION_OVERWRITE, 0, 0);
190
191 if (error) {
192 NSLOG(netsurf, INFO, "xcolourtrans_set_gcol: 0x%x: %s",
193 error->errnum, error->errmess);
194 return NSERROR_INVALID;
195 }
196
197 t = ((double)angle1 * M_PI) / 180.0;
198 sx = (x + (int)(radius * cos(t)));
199 sy = (y + (int)(radius * sin(t)));
200
201 t = ((double)angle2 * M_PI) / 180.0;
202 ex = (x + (int)(radius * cos(t)));
203 ey = (y + (int)(radius * sin(t)));
204
205 error = xos_plot(os_MOVE_TO, x, y); /* move to centre */
206 if (error) {
207 NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s", error->errnum,
208 error->errmess);
209 return NSERROR_INVALID;
210 }
211
212 error = xos_plot(os_MOVE_TO, sx, sy); /* move to start */
213 if (error) {
214 NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s", error->errnum,
215 error->errmess);
216 return NSERROR_INVALID;
217 }
218
219 error = xos_plot(os_PLOT_ARC | os_PLOT_TO, ex, ey); /* arc to end */
220 if (error) {
221 NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s", error->errnum,
222 error->errmess);
223 return NSERROR_INVALID;
224 }
225
226 return NSERROR_OK;
227}
228
229
230/**
231 * Plots a circle
232 *
233 * Plot a circle centered on (x,y), which is optionally filled.
234 *
235 * \param ctx The current redraw context.
236 * \param style Style controlling the circle plot.
237 * \param x The x coordinate of the circle.
238 * \param y The y coordinate of the circle.
239 * \param radius The radius of the circle.
240 * \return NSERROR_OK on success else error code.
241 */
242static nserror
243ro_plot_disc(const struct redraw_context *ctx,
244 const plot_style_t *style,
245 int x, int y, int radius)
246{
247 os_error *error;
248 if (style->fill_type != PLOT_OP_TYPE_NONE) {
249 error = xcolourtrans_set_gcol(style->fill_colour << 8, 0,
250 os_ACTION_OVERWRITE, 0, 0);
251 if (error) {
252 NSLOG(netsurf, INFO,
253 "xcolourtrans_set_gcol: 0x%x: %s",
254 error->errnum,
255 error->errmess);
256 return NSERROR_INVALID;
257 }
258 error = xos_plot(os_MOVE_TO,
259 ro_plot_origin_x + x * 2,
260 ro_plot_origin_y - y * 2);
261 if (error) {
262 NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s",
263 error->errnum, error->errmess);
264 return NSERROR_INVALID;
265 }
266 error = xos_plot(os_PLOT_CIRCLE | os_PLOT_BY, radius * 2, 0);
267 if (error) {
268 NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s",
269 error->errnum, error->errmess);
270 return NSERROR_INVALID;
271 }
272 }
273
274 if (style->stroke_type != PLOT_OP_TYPE_NONE) {
275
276 error = xcolourtrans_set_gcol(style->stroke_colour << 8, 0,
277 os_ACTION_OVERWRITE, 0, 0);
278 if (error) {
279 NSLOG(netsurf, INFO,
280 "xcolourtrans_set_gcol: 0x%x: %s",
281 error->errnum,
282 error->errmess);
283 return NSERROR_INVALID;
284 }
285 error = xos_plot(os_MOVE_TO,
286 ro_plot_origin_x + x * 2,
287 ro_plot_origin_y - y * 2);
288 if (error) {
289 NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s",
290 error->errnum, error->errmess);
291 return NSERROR_INVALID;
292 }
293 error = xos_plot(os_PLOT_CIRCLE_OUTLINE | os_PLOT_BY,
294 radius * 2, 0);
295
296 if (error) {
297 NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s",
298 error->errnum, error->errmess);
299 return NSERROR_INVALID;
300 }
301 }
302 return NSERROR_OK;
303}
304
305
306/**
307 * Plots a line
308 *
309 * plot a line from (x0,y0) to (x1,y1). Coordinates are at
310 * centre of line width/thickness.
311 *
312 * \param ctx The current redraw context.
313 * \param style Style controlling the line plot.
314 * \param line A rectangle defining the line to be drawn
315 * \return NSERROR_OK on success else error code.
316 */
317static nserror
318ro_plot_line(const struct redraw_context *ctx,
319 const plot_style_t *style,
320 const struct rect *line)
321{
322 if (style->stroke_type != PLOT_OP_TYPE_NONE) {
323 const int path[] = {
324 draw_MOVE_TO,
325 (ro_plot_origin_x + line->x0 * 2) * 256,
326 (ro_plot_origin_y - line->y0 * 2 - 1) * 256,
327 draw_LINE_TO,
328 (ro_plot_origin_x + line->x1 * 2) * 256,
329 (ro_plot_origin_y - line->y1 * 2 - 1) * 256,
330 draw_END_PATH };
331 bool dotted = false;
332 bool dashed = false;
333
334 if (style->stroke_type == PLOT_OP_TYPE_DOT)
335 dotted = true;
336
337 if (style->stroke_type == PLOT_OP_TYPE_DASH)
338 dashed = true;
339
340 return ro_plot_draw_path((const draw_path *)path,
342 style->stroke_colour,
343 dotted, dashed);
344 }
345 return NSERROR_OK;
346}
347
348
349/**
350 * Plots a rectangle.
351 *
352 * The rectangle can be filled an outline or both controlled
353 * by the plot style The line can be solid, dotted or
354 * dashed. Top left corner at (x0,y0) and rectangle has given
355 * width and height.
356 *
357 * \param ctx The current redraw context.
358 * \param style Style controlling the rectangle plot.
359 * \param rect A rectangle defining the line to be drawn
360 * \return NSERROR_OK on success else error code.
361 */
362static nserror
364 const plot_style_t *style,
365 const struct rect *rect)
366{
367 if (style->fill_type != PLOT_OP_TYPE_NONE) {
368 os_error *error;
369 error = xcolourtrans_set_gcol(style->fill_colour << 8,
371 os_ACTION_OVERWRITE, 0, 0);
372 if (error) {
373 NSLOG(netsurf, INFO,
374 "xcolourtrans_set_gcol: 0x%x: %s",
375 error->errnum,
376 error->errmess);
377 return NSERROR_INVALID;
378 }
379
380 error = xos_plot(os_MOVE_TO,
381 ro_plot_origin_x + rect->x0 * 2,
382 ro_plot_origin_y - rect->y1 * 2);
383 if (error) {
384 NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s",
385 error->errnum, error->errmess);
386 return NSERROR_INVALID;
387 }
388
389 error = xos_plot(os_PLOT_RECTANGLE | os_PLOT_TO,
390 ro_plot_origin_x + rect->x1 * 2 - 1,
391 ro_plot_origin_y - rect->y0 * 2 - 1);
392 if (error) {
393 NSLOG(netsurf, INFO, "xos_plot: 0x%x: %s",
394 error->errnum, error->errmess);
395 return NSERROR_INVALID;
396 }
397 }
398
399 if (style->stroke_type != PLOT_OP_TYPE_NONE) {
400 bool dotted = false;
401 bool dashed = false;
402
403 const int path[] = {
404 draw_MOVE_TO,
405 (ro_plot_origin_x + rect->x0 * 2) * 256,
406 (ro_plot_origin_y - rect->y0 * 2 - 1) * 256,
407 draw_LINE_TO,
408 (ro_plot_origin_x + (rect->x1) * 2) * 256,
409 (ro_plot_origin_y - rect->y0 * 2 - 1) * 256,
410 draw_LINE_TO,
411 (ro_plot_origin_x + (rect->x1) * 2) * 256,
412 (ro_plot_origin_y - (rect->y1) * 2 - 1) * 256,
413 draw_LINE_TO,
414 (ro_plot_origin_x + rect->x0 * 2) * 256,
415 (ro_plot_origin_y - (rect->y1) * 2 - 1) * 256,
416 draw_CLOSE_LINE,
417 (ro_plot_origin_x + rect->x0 * 2) * 256,
418 (ro_plot_origin_y - rect->y0 * 2 - 1) * 256,
419 draw_END_PATH
420 };
421
422 if (style->stroke_type == PLOT_OP_TYPE_DOT)
423 dotted = true;
424
425 if (style->stroke_type == PLOT_OP_TYPE_DASH)
426 dashed = true;
427
428 ro_plot_draw_path((const draw_path *)path,
430 style->stroke_colour,
431 dotted,
432 dashed);
433 }
434
435 return NSERROR_OK;
436}
437
438
439/**
440 * Plot a polygon
441 *
442 * Plots a filled polygon with straight lines between
443 * points. The lines around the edge of the ploygon are not
444 * plotted. The polygon is filled with the non-zero winding
445 * rule.
446 *
447 * \param ctx The current redraw context.
448 * \param style Style controlling the polygon plot.
449 * \param p verticies of polygon
450 * \param n number of verticies.
451 * \return NSERROR_OK on success else error code.
452 */
453static nserror
455 const plot_style_t *style,
456 const int *p,
457 unsigned int n)
458{
459 int path[n * 3 + 2];
460 unsigned int i;
461 os_error *error;
462
463 for (i = 0; i != n; i++) {
464 path[i * 3 + 0] = draw_LINE_TO;
465 path[i * 3 + 1] = (ro_plot_origin_x + p[i * 2 + 0] * 2) * 256;
466 path[i * 3 + 2] = (ro_plot_origin_y - p[i * 2 + 1] * 2) * 256;
467 }
468 path[0] = draw_MOVE_TO;
469 path[n * 3] = draw_END_PATH;
470 path[n * 3 + 1] = 0;
471
472 error = xcolourtrans_set_gcol(style->fill_colour << 8,
473 0, os_ACTION_OVERWRITE, 0, 0);
474 if (error) {
475 NSLOG(netsurf, INFO, "xcolourtrans_set_gcol: 0x%x: %s",
476 error->errnum, error->errmess);
477 return NSERROR_INVALID;
478 }
479 error = xdraw_fill((draw_path *) path, 0, 0, 0);
480 if (error) {
481 NSLOG(netsurf, INFO, "xdraw_fill: 0x%x: %s", error->errnum,
482 error->errmess);
483 return NSERROR_INVALID;
484 }
485
486 return NSERROR_OK;
487}
488
489
490/**
491 * Plots a path.
492 *
493 * Path plot consisting of cubic Bezier curves. Line and fill colour is
494 * controlled by the plot style.
495 *
496 * \param ctx The current redraw context.
497 * \param pstyle Style controlling the path plot.
498 * \param p elements of path
499 * \param n nunber of elements on path
500 * \param transform A transform to apply to the path.
501 * \return NSERROR_OK on success else error code.
502 */
503static nserror
504ro_plot_path(const struct redraw_context *ctx,
505 const plot_style_t *pstyle,
506 const float *p,
507 unsigned int n,
508 const float transform[6])
509{
510 static const draw_line_style line_style = {
511 draw_JOIN_MITRED,
512 draw_CAP_BUTT,
513 draw_CAP_BUTT,
514 0, 0x7fffffff,
515 0, 0, 0, 0
516 };
517 int *path = 0;
518 unsigned int i;
519 os_trfm trfm;
520 os_error *error;
521
522 if (n == 0) {
523 return NSERROR_OK;
524 }
525
526 if (p[0] != PLOTTER_PATH_MOVE) {
527 NSLOG(netsurf, INFO, "path doesn't start with a move");
528 goto error;
529 }
530
531 path = malloc(sizeof *path * (n + 10));
532 if (!path) {
533 NSLOG(netsurf, INFO, "out of memory");
534 goto error;
535 }
536
537 for (i = 0; i < n; ) {
538 if (p[i] == PLOTTER_PATH_MOVE) {
539 path[i] = draw_MOVE_TO;
540 path[i + 1] = p[i + 1] * 2 * 256;
541 path[i + 2] = -p[i + 2] * 2 * 256;
542 i += 3;
543 } else if (p[i] == PLOTTER_PATH_CLOSE) {
544 path[i] = draw_CLOSE_LINE;
545 i++;
546 } else if (p[i] == PLOTTER_PATH_LINE) {
547 path[i] = draw_LINE_TO;
548 path[i + 1] = p[i + 1] * 2 * 256;
549 path[i + 2] = -p[i + 2] * 2 * 256;
550 i += 3;
551 } else if (p[i] == PLOTTER_PATH_BEZIER) {
552 path[i] = draw_BEZIER_TO;
553 path[i + 1] = p[i + 1] * 2 * 256;
554 path[i + 2] = -p[i + 2] * 2 * 256;
555 path[i + 3] = p[i + 3] * 2 * 256;
556 path[i + 4] = -p[i + 4] * 2 * 256;
557 path[i + 5] = p[i + 5] * 2 * 256;
558 path[i + 6] = -p[i + 6] * 2 * 256;
559 i += 7;
560 } else {
561 NSLOG(netsurf, INFO, "bad path command %f", p[i]);
562 goto error;
563 }
564 }
565 path[i] = draw_END_PATH;
566 path[i + 1] = 0;
567
568 trfm.entries[0][0] = transform[0] * 0x10000;
569 trfm.entries[0][1] = transform[1] * 0x10000;
570 trfm.entries[1][0] = transform[2] * 0x10000;
571 trfm.entries[1][1] = transform[3] * 0x10000;
572 trfm.entries[2][0] = (ro_plot_origin_x + transform[4] * 2) * 256;
573 trfm.entries[2][1] = (ro_plot_origin_y - transform[5] * 2) * 256;
574
575 if (pstyle->fill_colour != NS_TRANSPARENT) {
576 error = xcolourtrans_set_gcol(pstyle->fill_colour << 8, 0,
577 os_ACTION_OVERWRITE, 0, 0);
578 if (error) {
579 NSLOG(netsurf, INFO,
580 "xcolourtrans_set_gcol: 0x%x: %s",
581 error->errnum,
582 error->errmess);
583 goto error;
584 }
585
586 error = xdraw_fill((draw_path *) path, 0, &trfm, 0);
587 if (error) {
588 NSLOG(netsurf, INFO, "xdraw_stroke: 0x%x: %s",
589 error->errnum, error->errmess);
590 goto error;
591 }
592 }
593
594 if (pstyle->stroke_colour != NS_TRANSPARENT) {
595 error = xcolourtrans_set_gcol(pstyle->stroke_colour << 8, 0,
596 os_ACTION_OVERWRITE, 0, 0);
597 if (error) {
598 NSLOG(netsurf, INFO,
599 "xcolourtrans_set_gcol: 0x%x: %s",
600 error->errnum,
601 error->errmess);
602 goto error;
603 }
604
605 error = xdraw_stroke((draw_path *) path, 0, &trfm, 0,
607 pstyle->stroke_width) * 2 * 256,
608 &line_style, 0);
609 if (error) {
610 NSLOG(netsurf, INFO, "xdraw_stroke: 0x%x: %s",
611 error->errnum, error->errmess);
612 goto error;
613 }
614 }
615
616 free(path);
617 return NSERROR_OK;
618
619error:
620 free(path);
621 return NSERROR_INVALID;
622}
623
624
625/**
626 * Plot a bitmap
627 *
628 * Tiled plot of a bitmap image. (x,y) gives the top left
629 * coordinate of an explicitly placed tile. From this tile the
630 * image can repeat in all four directions -- up, down, left
631 * and right -- to the extents given by the current clip
632 * rectangle.
633 *
634 * The bitmap_flags say whether to tile in the x and y
635 * directions. If not tiling in x or y directions, the single
636 * image is plotted. The width and height give the dimensions
637 * the image is to be scaled to.
638 *
639 * \param ctx The current redraw context.
640 * \param bitmap The bitmap to plot
641 * \param x The x coordinate to plot the bitmap
642 * \param y The y coordiante to plot the bitmap
643 * \param width The width of area to plot the bitmap into
644 * \param height The height of area to plot the bitmap into
645 * \param bg the background colour to alpha blend into
646 * \param flags the flags controlling the type of plot operation
647 * \return NSERROR_OK on success else error code.
648 */
649static nserror
651 struct bitmap *bitmap,
652 int x, int y,
653 int width,
654 int height,
655 colour bg,
656 bitmap_flags_t flags)
657{
658 const uint8_t *buffer;
659
661 if (!buffer) {
662 NSLOG(netsurf, INFO, "bitmap_get_buffer failed");
663 return NSERROR_INVALID;
664 }
665
667 ro_plot_origin_x + x * 2,
668 ro_plot_origin_y - y * 2,
669 width, height,
670 bitmap->width,
671 bitmap->height,
672 bg,
673 flags & BITMAPF_REPEAT_X, flags & BITMAPF_REPEAT_Y,
674 flags & BITMAPF_REPEAT_X || flags & BITMAPF_REPEAT_Y,
677 return NSERROR_INVALID;
678 }
679 return NSERROR_OK;
680}
681
682
683/**
684 * Text plotting.
685 *
686 * \param ctx The current redraw context.
687 * \param fstyle plot style for this text
688 * \param x x coordinate
689 * \param y y coordinate
690 * \param text UTF-8 string to plot
691 * \param length length of string, in bytes
692 * \return NSERROR_OK on success else error code.
693 */
694static nserror
695ro_plot_text(const struct redraw_context *ctx,
696 const struct plot_font_style *fstyle,
697 int x,
698 int y,
699 const char *text,
700 size_t length)
701{
702 os_error *error;
703
704 error = xcolourtrans_set_font_colours(font_CURRENT,
705 fstyle->background << 8, fstyle->foreground << 8,
706 14, 0, 0, 0);
707 if (error) {
708 NSLOG(netsurf, INFO,
709 "xcolourtrans_set_font_colours: 0x%x: %s",
710 error->errnum,
711 error->errmess);
712 return NSERROR_INVALID;
713 }
714
715 if (!nsfont_paint(fstyle, text, length,
716 ro_plot_origin_x + x * 2,
717 ro_plot_origin_y - y * 2)) {
718 return NSERROR_INVALID;
719 }
720 return NSERROR_OK;
721}
722
723
724/**
725 * RISC OS plotter operation table
726 */
729 .line = ro_plot_line,
730 .polygon = ro_plot_polygon,
731 .clip = ro_plot_clip,
732 .text = ro_plot_text,
733 .disc = ro_plot_disc,
734 .arc = ro_plot_arc,
735 .bitmap = ro_plot_bitmap,
736 .path = ro_plot_path,
737 .option_knockout = true,
738};
#define M_PI
Definition: plotters.c:101
static osspriteop_area * buffer
The buffer characteristics.
Definition: buffer.c:55
nserror
Enumeration of error codes.
Definition: errors.h:29
@ NSERROR_BAD_SIZE
Bad size.
Definition: errors.h:60
@ NSERROR_INVALID
Invalid data.
Definition: errors.h:49
@ NSERROR_OK
No error.
Definition: errors.h:30
bool nsfont_paint(const plot_font_style_t *fstyle, const char *string, size_t length, int x, int y)
Render a string.
Definition: font.cpp:312
unsigned char * riscos_bitmap_get_buffer(void *vbitmap)
Return a pointer to the pixel data in a bitmap.
Definition: bitmap.c:145
bool riscos_bitmap_get_opaque(void *vbitmap)
Gets whether a bitmap should be plotted opaque.
Definition: bitmap.c:193
RISC OS font interface.
bool image_redraw(osspriteop_area *area, int x, int y, int req_width, int req_height, int width, int height, colour background_colour, bool repeatx, bool repeaty, bool background, image_type type)
Plot an image at the given coordinates using the method specified.
Definition: image.c:209
@ IMAGE_PLOT_TINCT_OPAQUE
Definition: image.h:30
@ IMAGE_PLOT_TINCT_ALPHA
Definition: image.h:29
Target independent plotting interface.
#define BITMAPF_REPEAT_X
Definition: plotters.h:38
#define BITMAPF_REPEAT_Y
Definition: plotters.h:39
unsigned long bitmap_flags_t
Definition: plotters.h:36
@ PLOTTER_PATH_MOVE
Definition: plotters.h:42
@ PLOTTER_PATH_CLOSE
Definition: plotters.h:43
@ PLOTTER_PATH_LINE
Definition: plotters.h:44
@ PLOTTER_PATH_BEZIER
Definition: plotters.h:45
#define NSLOG(catname, level, logmsg, args...)
Definition: log.h:116
Backward compatible defines to make NetSurf buildable with pre-OSLib 7 releases.
#define colourtrans_USE_ECFS_GCOL
Definition: oslib_pre7.h:39
#define plot_style_fixed_to_int(v)
Definition: plot_style.h:54
@ PLOT_OP_TYPE_NONE
No operation.
Definition: plot_style.h:66
@ PLOT_OP_TYPE_DASH
Dashed plot.
Definition: plot_style.h:69
@ PLOT_OP_TYPE_DOT
Dotted plot.
Definition: plot_style.h:68
#define NS_TRANSPARENT
Transparent colour value.
Definition: plot_style.h:39
int width
Definition: gui.c:160
int height
Definition: gui.c:161
static nserror ro_plot_path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
Definition: plotters.c:504
int ro_plot_origin_x
Definition: plotters.c:40
static nserror ro_plot_clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plotters.c:109
int ro_plot_origin_y
Definition: plotters.c:41
struct rect ro_plot_clip_rect
Definition: plotters.c:42
static nserror ro_plot_arc(const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius, int angle1, int angle2)
Plots an arc.
Definition: plotters.c:176
const struct plotter_table ro_plotters
RISC OS plotter operation table.
Definition: plotters.c:727
bool ro_plot_patterned_lines
One version of the A9home OS is incapable of drawing patterned lines.
Definition: plotters.c:45
static nserror ro_plot_line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.
Definition: plotters.c:318
static nserror ro_plot_polygon(const struct redraw_context *ctx, const plot_style_t *style, const int *p, unsigned int n)
Plot a polygon.
Definition: plotters.c:454
static nserror ro_plot_bitmap(const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y, int width, int height, colour bg, bitmap_flags_t flags)
Plot a bitmap.
Definition: plotters.c:650
static nserror ro_plot_rectangle(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *rect)
Plots a rectangle.
Definition: plotters.c:363
static nserror ro_plot_disc(const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius)
Plots a circle.
Definition: plotters.c:243
static nserror ro_plot_text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
Definition: plotters.c:695
static nserror ro_plot_draw_path(const draw_path *const path, int width, colour c, bool dotted, bool dashed)
plot a path on RISC OS
Definition: plotters.c:51
RISC OS wimp toolkit bitmap.
Definition: bitmap.c:68
struct osspriteop_area * sprite_area
Uncompressed data, or NULL.
Definition: bitmap.h:45
int width
width of bitmap
Definition: bitmap.c:69
int height
height of bitmap
Definition: bitmap.c:70
Font style for plotting.
Definition: plot_style.h:111
colour foreground
Colour of text.
Definition: plot_style.h:123
colour background
Background colour to blend to, if appropriate.
Definition: plot_style.h:122
Plot style for stroke/fill plotters.
Definition: plot_style.h:76
colour fill_colour
Colour of fill.
Definition: plot_style.h:81
plot_style_fixed stroke_width
Width of stroke, in pixels.
Definition: plot_style.h:78
plot_operation_type_t fill_type
Fill plot type.
Definition: plot_style.h:80
colour stroke_colour
Colour of stroke.
Definition: plot_style.h:79
plot_operation_type_t stroke_type
Stroke plot type.
Definition: plot_style.h:77
Plotter operations table.
Definition: plotters.h:102
nserror(* rectangle)(const struct redraw_context *ctx, const plot_style_t *pstyle, const struct rect *rectangle)
Plots a rectangle.
Definition: plotters.h:188
Rectangle coordinates.
Definition: types.h:40
int x0
Definition: types.h:41
int y0
Top left.
Definition: types.h:41
int x1
Definition: types.h:42
int y1
Bottom right.
Definition: types.h:42
Redraw context.
Definition: plotters.h:51
uint32_t colour
Colour type: XBGR.
Definition: types.h:35
static nserror path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
Definition: plot.c:821
static nserror line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.
Definition: plot.c:579
static nserror text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
Definition: plot.c:978
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plot.c:357