1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci * Copyright 2014 Google Inc. 3cb93a386Sopenharmony_ci * 4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be 5cb93a386Sopenharmony_ci * found in the LICENSE file. 6cb93a386Sopenharmony_ci */ 7cb93a386Sopenharmony_ci 8cb93a386Sopenharmony_ci// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL 9cb93a386Sopenharmony_ci// DO NOT USE -- FOR INTERNAL TESTING ONLY 10cb93a386Sopenharmony_ci 11cb93a386Sopenharmony_ci#ifndef sk_canvas_DEFINED 12cb93a386Sopenharmony_ci#define sk_canvas_DEFINED 13cb93a386Sopenharmony_ci 14cb93a386Sopenharmony_ci#include "include/c/sk_types.h" 15cb93a386Sopenharmony_ci 16cb93a386Sopenharmony_ciSK_C_PLUS_PLUS_BEGIN_GUARD 17cb93a386Sopenharmony_ci 18cb93a386Sopenharmony_ci/** 19cb93a386Sopenharmony_ci Save the current matrix and clip on the canvas. When the 20cb93a386Sopenharmony_ci balancing call to sk_canvas_restore() is made, the previous matrix 21cb93a386Sopenharmony_ci and clip are restored. 22cb93a386Sopenharmony_ci*/ 23cb93a386Sopenharmony_ciSK_API void sk_canvas_save(sk_canvas_t*); 24cb93a386Sopenharmony_ci/** 25cb93a386Sopenharmony_ci This behaves the same as sk_canvas_save(), but in addition it 26cb93a386Sopenharmony_ci allocates an offscreen surface. All drawing calls are directed 27cb93a386Sopenharmony_ci there, and only when the balancing call to sk_canvas_restore() is 28cb93a386Sopenharmony_ci made is that offscreen transfered to the canvas (or the previous 29cb93a386Sopenharmony_ci layer). 30cb93a386Sopenharmony_ci 31cb93a386Sopenharmony_ci @param sk_rect_t* (may be null) This rect, if non-null, is used as 32cb93a386Sopenharmony_ci a hint to limit the size of the offscreen, and 33cb93a386Sopenharmony_ci thus drawing may be clipped to it, though that 34cb93a386Sopenharmony_ci clipping is not guaranteed to happen. If exact 35cb93a386Sopenharmony_ci clipping is desired, use sk_canvas_clip_rect(). 36cb93a386Sopenharmony_ci @param sk_paint_t* (may be null) The paint is copied, and is applied 37cb93a386Sopenharmony_ci to the offscreen when sk_canvas_restore() is 38cb93a386Sopenharmony_ci called. 39cb93a386Sopenharmony_ci*/ 40cb93a386Sopenharmony_ciSK_API void sk_canvas_save_layer(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*); 41cb93a386Sopenharmony_ci/** 42cb93a386Sopenharmony_ci This call balances a previous call to sk_canvas_save() or 43cb93a386Sopenharmony_ci sk_canvas_save_layer(), and is used to remove all modifications to 44cb93a386Sopenharmony_ci the matrix and clip state since the last save call. It is an 45cb93a386Sopenharmony_ci error to call sk_canvas_restore() more times than save and 46cb93a386Sopenharmony_ci save_layer were called. 47cb93a386Sopenharmony_ci*/ 48cb93a386Sopenharmony_ciSK_API void sk_canvas_restore(sk_canvas_t*); 49cb93a386Sopenharmony_ci 50cb93a386Sopenharmony_ci/** 51cb93a386Sopenharmony_ci Preconcat the current coordinate transformation matrix with the 52cb93a386Sopenharmony_ci specified translation. 53cb93a386Sopenharmony_ci*/ 54cb93a386Sopenharmony_ciSK_API void sk_canvas_translate(sk_canvas_t*, float dx, float dy); 55cb93a386Sopenharmony_ci/** 56cb93a386Sopenharmony_ci Preconcat the current coordinate transformation matrix with the 57cb93a386Sopenharmony_ci specified scale. 58cb93a386Sopenharmony_ci*/ 59cb93a386Sopenharmony_ciSK_API void sk_canvas_scale(sk_canvas_t*, float sx, float sy); 60cb93a386Sopenharmony_ci/** 61cb93a386Sopenharmony_ci Preconcat the current coordinate transformation matrix with the 62cb93a386Sopenharmony_ci specified rotation in degrees. 63cb93a386Sopenharmony_ci*/ 64cb93a386Sopenharmony_ciSK_API void sk_canvas_rotate_degrees(sk_canvas_t*, float degrees); 65cb93a386Sopenharmony_ci/** 66cb93a386Sopenharmony_ci Preconcat the current coordinate transformation matrix with the 67cb93a386Sopenharmony_ci specified rotation in radians. 68cb93a386Sopenharmony_ci*/ 69cb93a386Sopenharmony_ciSK_API void sk_canvas_rotate_radians(sk_canvas_t*, float radians); 70cb93a386Sopenharmony_ci/** 71cb93a386Sopenharmony_ci Preconcat the current coordinate transformation matrix with the 72cb93a386Sopenharmony_ci specified skew. 73cb93a386Sopenharmony_ci*/ 74cb93a386Sopenharmony_ciSK_API void sk_canvas_skew(sk_canvas_t*, float sx, float sy); 75cb93a386Sopenharmony_ci/** 76cb93a386Sopenharmony_ci Preconcat the current coordinate transformation matrix with the 77cb93a386Sopenharmony_ci specified matrix. 78cb93a386Sopenharmony_ci*/ 79cb93a386Sopenharmony_ciSK_API void sk_canvas_concat(sk_canvas_t*, const sk_matrix_t*); 80cb93a386Sopenharmony_ci 81cb93a386Sopenharmony_ci/** 82cb93a386Sopenharmony_ci Modify the current clip with the specified rectangle. The new 83cb93a386Sopenharmony_ci current clip will be the intersection of the old clip and the 84cb93a386Sopenharmony_ci rectange. 85cb93a386Sopenharmony_ci*/ 86cb93a386Sopenharmony_ciSK_API void sk_canvas_clip_rect(sk_canvas_t*, const sk_rect_t*); 87cb93a386Sopenharmony_ci/** 88cb93a386Sopenharmony_ci Modify the current clip with the specified path. The new 89cb93a386Sopenharmony_ci current clip will be the intersection of the old clip and the 90cb93a386Sopenharmony_ci path. 91cb93a386Sopenharmony_ci*/ 92cb93a386Sopenharmony_ciSK_API void sk_canvas_clip_path(sk_canvas_t*, const sk_path_t*); 93cb93a386Sopenharmony_ci 94cb93a386Sopenharmony_ci/** 95cb93a386Sopenharmony_ci Fill the entire canvas (restricted to the current clip) with the 96cb93a386Sopenharmony_ci specified paint. 97cb93a386Sopenharmony_ci*/ 98cb93a386Sopenharmony_ciSK_API void sk_canvas_draw_paint(sk_canvas_t*, const sk_paint_t*); 99cb93a386Sopenharmony_ci/** 100cb93a386Sopenharmony_ci Draw the specified rectangle using the specified paint. The 101cb93a386Sopenharmony_ci rectangle will be filled or stroked based on the style in the 102cb93a386Sopenharmony_ci paint. 103cb93a386Sopenharmony_ci*/ 104cb93a386Sopenharmony_ciSK_API void sk_canvas_draw_rect(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*); 105cb93a386Sopenharmony_ci/** 106cb93a386Sopenharmony_ci * Draw the circle centered at (cx, cy) with radius rad using the specified paint. 107cb93a386Sopenharmony_ci * The circle will be filled or framed based on the style in the paint 108cb93a386Sopenharmony_ci */ 109cb93a386Sopenharmony_ciSK_API void sk_canvas_draw_circle(sk_canvas_t*, float cx, float cy, float rad, const sk_paint_t*); 110cb93a386Sopenharmony_ci/** 111cb93a386Sopenharmony_ci Draw the specified oval using the specified paint. The oval will be 112cb93a386Sopenharmony_ci filled or framed based on the style in the paint 113cb93a386Sopenharmony_ci*/ 114cb93a386Sopenharmony_ciSK_API void sk_canvas_draw_oval(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*); 115cb93a386Sopenharmony_ci/** 116cb93a386Sopenharmony_ci Draw the specified path using the specified paint. The path will be 117cb93a386Sopenharmony_ci filled or framed based on the style in the paint 118cb93a386Sopenharmony_ci*/ 119cb93a386Sopenharmony_ciSK_API void sk_canvas_draw_path(sk_canvas_t*, const sk_path_t*, const sk_paint_t*); 120cb93a386Sopenharmony_ci/** 121cb93a386Sopenharmony_ci Draw the specified image, with its top/left corner at (x,y), using 122cb93a386Sopenharmony_ci the specified paint, transformed by the current matrix. 123cb93a386Sopenharmony_ci 124cb93a386Sopenharmony_ci @param sk_paint_t* (may be NULL) the paint used to draw the image. 125cb93a386Sopenharmony_ci*/ 126cb93a386Sopenharmony_ciSK_API void sk_canvas_draw_image(sk_canvas_t*, const sk_image_t*, float x, float y, 127cb93a386Sopenharmony_ci const sk_sampling_options_t*, const sk_paint_t*); 128cb93a386Sopenharmony_ci/** 129cb93a386Sopenharmony_ci Draw the specified image, scaling and translating so that it fills 130cb93a386Sopenharmony_ci the specified dst rect. If the src rect is non-null, only that 131cb93a386Sopenharmony_ci subset of the image is transformed and drawn. 132cb93a386Sopenharmony_ci 133cb93a386Sopenharmony_ci @param sk_paint_t* (may be NULL) The paint used to draw the image. 134cb93a386Sopenharmony_ci*/ 135cb93a386Sopenharmony_ciSK_API void sk_canvas_draw_image_rect(sk_canvas_t*, const sk_image_t*, 136cb93a386Sopenharmony_ci const sk_rect_t* src, const sk_rect_t* dst, 137cb93a386Sopenharmony_ci const sk_sampling_options_t*, const sk_paint_t*); 138cb93a386Sopenharmony_ci 139cb93a386Sopenharmony_ci/** 140cb93a386Sopenharmony_ci Draw the picture into this canvas (replay the pciture's drawing commands). 141cb93a386Sopenharmony_ci 142cb93a386Sopenharmony_ci @param sk_matrix_t* If non-null, apply that matrix to the CTM when 143cb93a386Sopenharmony_ci drawing this picture. This is logically 144cb93a386Sopenharmony_ci equivalent to: save, concat, draw_picture, 145cb93a386Sopenharmony_ci restore. 146cb93a386Sopenharmony_ci 147cb93a386Sopenharmony_ci @param sk_paint_t* If non-null, draw the picture into a temporary 148cb93a386Sopenharmony_ci buffer, and then apply the paint's alpha, 149cb93a386Sopenharmony_ci colorfilter, imagefilter, and xfermode to that 150cb93a386Sopenharmony_ci buffer as it is drawn to the canvas. This is 151cb93a386Sopenharmony_ci logically equivalent to save_layer(paint), 152cb93a386Sopenharmony_ci draw_picture, restore. 153cb93a386Sopenharmony_ci*/ 154cb93a386Sopenharmony_ciSK_API void sk_canvas_draw_picture(sk_canvas_t*, const sk_picture_t*, 155cb93a386Sopenharmony_ci const sk_matrix_t*, const sk_paint_t*); 156cb93a386Sopenharmony_ci 157cb93a386Sopenharmony_ciSK_C_PLUS_PLUS_END_GUARD 158cb93a386Sopenharmony_ci 159cb93a386Sopenharmony_ci#endif 160