2014-11-17 14:15:42 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2014 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
|
|
|
|
// DO NOT USE -- FOR INTERNAL TESTING ONLY
|
|
|
|
|
|
|
|
#ifndef sk_canvas_DEFINED
|
|
|
|
#define sk_canvas_DEFINED
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/c/sk_types.h"
|
2014-11-17 14:15:42 +00:00
|
|
|
|
|
|
|
SK_C_PLUS_PLUS_BEGIN_GUARD
|
|
|
|
|
2015-09-01 17:45:09 +00:00
|
|
|
/**
|
|
|
|
Save the current matrix and clip on the canvas. When the
|
|
|
|
balancing call to sk_canvas_restore() is made, the previous matrix
|
|
|
|
and clip are restored.
|
|
|
|
*/
|
2015-09-01 17:01:38 +00:00
|
|
|
SK_API void sk_canvas_save(sk_canvas_t*);
|
2015-09-01 17:45:09 +00:00
|
|
|
/**
|
|
|
|
This behaves the same as sk_canvas_save(), but in addition it
|
|
|
|
allocates an offscreen surface. All drawing calls are directed
|
|
|
|
there, and only when the balancing call to sk_canvas_restore() is
|
|
|
|
made is that offscreen transfered to the canvas (or the previous
|
|
|
|
layer).
|
|
|
|
|
|
|
|
@param sk_rect_t* (may be null) This rect, if non-null, is used as
|
|
|
|
a hint to limit the size of the offscreen, and
|
|
|
|
thus drawing may be clipped to it, though that
|
|
|
|
clipping is not guaranteed to happen. If exact
|
|
|
|
clipping is desired, use sk_canvas_clip_rect().
|
|
|
|
@param sk_paint_t* (may be null) The paint is copied, and is applied
|
|
|
|
to the offscreen when sk_canvas_restore() is
|
|
|
|
called.
|
|
|
|
*/
|
2015-09-01 17:01:38 +00:00
|
|
|
SK_API void sk_canvas_save_layer(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*);
|
2015-09-01 17:45:09 +00:00
|
|
|
/**
|
|
|
|
This call balances a previous call to sk_canvas_save() or
|
|
|
|
sk_canvas_save_layer(), and is used to remove all modifications to
|
|
|
|
the matrix and clip state since the last save call. It is an
|
|
|
|
error to call sk_canvas_restore() more times than save and
|
|
|
|
save_layer were called.
|
|
|
|
*/
|
2015-09-01 17:01:38 +00:00
|
|
|
SK_API void sk_canvas_restore(sk_canvas_t*);
|
|
|
|
|
2015-09-01 17:45:09 +00:00
|
|
|
/**
|
|
|
|
Preconcat the current coordinate transformation matrix with the
|
|
|
|
specified translation.
|
|
|
|
*/
|
2015-09-01 17:01:38 +00:00
|
|
|
SK_API void sk_canvas_translate(sk_canvas_t*, float dx, float dy);
|
2015-09-01 17:45:09 +00:00
|
|
|
/**
|
|
|
|
Preconcat the current coordinate transformation matrix with the
|
|
|
|
specified scale.
|
|
|
|
*/
|
2015-09-01 17:01:38 +00:00
|
|
|
SK_API void sk_canvas_scale(sk_canvas_t*, float sx, float sy);
|
2015-09-01 17:45:09 +00:00
|
|
|
/**
|
|
|
|
Preconcat the current coordinate transformation matrix with the
|
|
|
|
specified rotation in degrees.
|
|
|
|
*/
|
2015-09-01 17:01:38 +00:00
|
|
|
SK_API void sk_canvas_rotate_degrees(sk_canvas_t*, float degrees);
|
2015-09-01 17:45:09 +00:00
|
|
|
/**
|
|
|
|
Preconcat the current coordinate transformation matrix with the
|
|
|
|
specified rotation in radians.
|
|
|
|
*/
|
2015-09-01 17:01:38 +00:00
|
|
|
SK_API void sk_canvas_rotate_radians(sk_canvas_t*, float radians);
|
2015-09-01 17:45:09 +00:00
|
|
|
/**
|
|
|
|
Preconcat the current coordinate transformation matrix with the
|
|
|
|
specified skew.
|
|
|
|
*/
|
2015-09-01 17:01:38 +00:00
|
|
|
SK_API void sk_canvas_skew(sk_canvas_t*, float sx, float sy);
|
2015-09-01 17:45:09 +00:00
|
|
|
/**
|
|
|
|
Preconcat the current coordinate transformation matrix with the
|
|
|
|
specified matrix.
|
|
|
|
*/
|
2015-09-01 17:01:38 +00:00
|
|
|
SK_API void sk_canvas_concat(sk_canvas_t*, const sk_matrix_t*);
|
|
|
|
|
2015-09-01 17:45:09 +00:00
|
|
|
/**
|
|
|
|
Modify the current clip with the specified rectangle. The new
|
|
|
|
current clip will be the intersection of the old clip and the
|
|
|
|
rectange.
|
|
|
|
*/
|
2015-09-01 17:01:38 +00:00
|
|
|
SK_API void sk_canvas_clip_rect(sk_canvas_t*, const sk_rect_t*);
|
2015-09-01 17:45:09 +00:00
|
|
|
/**
|
|
|
|
Modify the current clip with the specified path. The new
|
|
|
|
current clip will be the intersection of the old clip and the
|
|
|
|
path.
|
|
|
|
*/
|
2015-09-01 17:01:38 +00:00
|
|
|
SK_API void sk_canvas_clip_path(sk_canvas_t*, const sk_path_t*);
|
|
|
|
|
2015-09-01 17:45:09 +00:00
|
|
|
/**
|
|
|
|
Fill the entire canvas (restricted to the current clip) with the
|
|
|
|
specified paint.
|
|
|
|
*/
|
2015-09-01 17:01:38 +00:00
|
|
|
SK_API void sk_canvas_draw_paint(sk_canvas_t*, const sk_paint_t*);
|
2015-09-01 17:45:09 +00:00
|
|
|
/**
|
|
|
|
Draw the specified rectangle using the specified paint. The
|
|
|
|
rectangle will be filled or stroked based on the style in the
|
|
|
|
paint.
|
|
|
|
*/
|
2015-09-01 17:01:38 +00:00
|
|
|
SK_API void sk_canvas_draw_rect(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*);
|
2016-02-09 21:25:51 +00:00
|
|
|
/**
|
|
|
|
* Draw the circle centered at (cx, cy) with radius rad using the specified paint.
|
|
|
|
* The circle will be filled or framed based on the style in the paint
|
|
|
|
*/
|
|
|
|
SK_API void sk_canvas_draw_circle(sk_canvas_t*, float cx, float cy, float rad, const sk_paint_t*);
|
2015-09-01 17:45:09 +00:00
|
|
|
/**
|
|
|
|
Draw the specified oval using the specified paint. The oval will be
|
|
|
|
filled or framed based on the style in the paint
|
|
|
|
*/
|
2015-09-01 17:01:38 +00:00
|
|
|
SK_API void sk_canvas_draw_oval(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*);
|
2015-09-01 17:45:09 +00:00
|
|
|
/**
|
|
|
|
Draw the specified path using the specified paint. The path will be
|
|
|
|
filled or framed based on the style in the paint
|
|
|
|
*/
|
2015-09-01 17:01:38 +00:00
|
|
|
SK_API void sk_canvas_draw_path(sk_canvas_t*, const sk_path_t*, const sk_paint_t*);
|
2015-09-01 17:45:09 +00:00
|
|
|
/**
|
|
|
|
Draw the specified image, with its top/left corner at (x,y), using
|
|
|
|
the specified paint, transformed by the current matrix.
|
|
|
|
|
|
|
|
@param sk_paint_t* (may be NULL) the paint used to draw the image.
|
|
|
|
*/
|
2015-09-01 17:01:38 +00:00
|
|
|
SK_API void sk_canvas_draw_image(sk_canvas_t*, const sk_image_t*,
|
|
|
|
float x, float y, const sk_paint_t*);
|
2015-09-01 17:45:09 +00:00
|
|
|
/**
|
|
|
|
Draw the specified image, scaling and translating so that it fills
|
|
|
|
the specified dst rect. If the src rect is non-null, only that
|
|
|
|
subset of the image is transformed and drawn.
|
|
|
|
|
|
|
|
@param sk_paint_t* (may be NULL) The paint used to draw the image.
|
|
|
|
*/
|
2015-09-01 17:01:38 +00:00
|
|
|
SK_API void sk_canvas_draw_image_rect(sk_canvas_t*, const sk_image_t*,
|
|
|
|
const sk_rect_t* src,
|
|
|
|
const sk_rect_t* dst, const sk_paint_t*);
|
2015-09-01 17:45:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Draw the picture into this canvas (replay the pciture's drawing commands).
|
|
|
|
|
|
|
|
@param sk_matrix_t* If non-null, apply that matrix to the CTM when
|
|
|
|
drawing this picture. This is logically
|
|
|
|
equivalent to: save, concat, draw_picture,
|
|
|
|
restore.
|
|
|
|
|
|
|
|
@param sk_paint_t* If non-null, draw the picture into a temporary
|
|
|
|
buffer, and then apply the paint's alpha,
|
|
|
|
colorfilter, imagefilter, and xfermode to that
|
|
|
|
buffer as it is drawn to the canvas. This is
|
|
|
|
logically equivalent to save_layer(paint),
|
|
|
|
draw_picture, restore.
|
|
|
|
*/
|
2015-09-01 17:01:38 +00:00
|
|
|
SK_API void sk_canvas_draw_picture(sk_canvas_t*, const sk_picture_t*,
|
|
|
|
const sk_matrix_t*, const sk_paint_t*);
|
2014-11-17 14:15:42 +00:00
|
|
|
|
|
|
|
SK_C_PLUS_PLUS_END_GUARD
|
|
|
|
|
|
|
|
#endif
|