Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(990)

Unified Diff: src/c/sk_surface.cpp

Issue 769123002: Add matrix operations to C canvas API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« include/c/sk_canvas.h ('K') | « include/c/sk_canvas.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/c/sk_surface.cpp
diff --git a/src/c/sk_surface.cpp b/src/c/sk_surface.cpp
index c75ab23d55728f67ee0b348ba70bac82a3d24c65..880c00e20a6f3bc899df1f30918783b5582a5470 100644
--- a/src/c/sk_surface.cpp
+++ b/src/c/sk_surface.cpp
@@ -91,6 +91,16 @@ static bool from_c_info(const sk_imageinfo_t& cinfo, SkImageInfo* info) {
return true;
}
+static void from_c_matrix(const sk_matrix_t* cmatrix, SkMatrix* matrix) {
+ if (cmatrix) {
+ matrix->setAll(cmatrix->mat[0], cmatrix->mat[1], cmatrix->mat[2],
+ cmatrix->mat[3], cmatrix->mat[4], cmatrix->mat[5],
+ cmatrix->mat[6], cmatrix->mat[7], cmatrix->mat[8]);
+ } else {
+ matrix->setIdentity();
+ }
+}
+
const struct {
sk_path_direction_t fC;
SkPath::Direction fSk;
@@ -320,6 +330,22 @@ void sk_canvas_skew(sk_canvas_t* ccanvas, float sx, float sy) {
AsCanvas(ccanvas)->skew(sx, sy);
}
+void sk_canvas_concat_matrix(sk_canvas_t* ccanvas, const sk_matrix_t* cmatrix) {
+ SkMatrix matrix;
+ from_c_matrix(cmatrix, &matrix);
+ AsCanvas(ccanvas)->concat(matrix);
+}
+
+void sk_canvas_set_matrix(sk_canvas_t* ccanvas, const sk_matrix_t* cmatrix) {
+ SkMatrix matrix;
+ from_c_matrix(cmatrix, &matrix);
+ AsCanvas(ccanvas)->setMatrix(matrix);
+}
+
+void sk_canvas_reset_matrix(sk_canvas_t* ccanvas) {
+ AsCanvas(ccanvas)->resetMatrix();
+}
+
void sk_canvas_draw_paint(sk_canvas_t* ccanvas, const sk_paint_t* cpaint) {
AsCanvas(ccanvas)->drawPaint(AsPaint(*cpaint));
}
@@ -419,13 +445,7 @@ sk_shader_t* sk_shader_new_linear_gradient(const sk_point_t pts[2],
return NULL;
}
SkMatrix matrix;
- if (cmatrix) {
- matrix.setAll(cmatrix->mat[0], cmatrix->mat[1], cmatrix->mat[2],
- cmatrix->mat[3], cmatrix->mat[4], cmatrix->mat[5],
- cmatrix->mat[6], cmatrix->mat[7], cmatrix->mat[8]);
- } else {
- matrix.setIdentity();
- }
+ from_c_matrix(cmatrix, &matrix);
SkShader* s = SkGradientShader::CreateLinear(reinterpret_cast<const SkPoint*>(pts),
reinterpret_cast<const SkColor*>(colors),
colorPos, colorCount, mode, 0, &matrix);
« include/c/sk_canvas.h ('K') | « include/c/sk_canvas.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698