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

Unified Diff: src/c/sk_surface.cpp

Issue 728323002: separate c headers (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « include/c/sk_types.h ('k') | tests/CTest.cpp » ('j') | 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 ec16fc27fbd7054fbe41ef014839f7af98dc0108..45a1ef9c3274ee2a19d9b1487d6459e5ef998cd7 100644
--- a/src/c/sk_surface.cpp
+++ b/src/c/sk_surface.cpp
@@ -5,6 +5,10 @@
* found in the LICENSE file.
*/
+#include "sk_canvas.h"
+#include "sk_image.h"
+#include "sk_paint.h"
+#include "sk_path.h"
#include "sk_surface.h"
#include "SkCanvas.h"
@@ -87,10 +91,34 @@ static bool from_c_info(const sk_imageinfo_t& cinfo, SkImageInfo* info) {
return true;
}
+const struct {
+ sk_path_direction_t fC;
+ SkPath::Direction fSk;
+} gPathDirMap[] = {
+ { CW_SK_PATH_DIRECTION, SkPath::kCW_Direction },
+ { CCW_SK_PATH_DIRECTION, SkPath::kCCW_Direction },
+};
+
+static bool from_c_path_direction(sk_path_direction_t cdir, SkPath::Direction* dir) {
+ for (size_t i = 0; i < SK_ARRAY_COUNT(gPathDirMap); ++i) {
+ if (gPathDirMap[i].fC == cdir) {
+ if (dir) {
+ *dir = gPathDirMap[i].fSk;
+ }
+ return true;
+ }
+ }
+ return false;
+}
+
static const SkRect& AsRect(const sk_rect_t& crect) {
return reinterpret_cast<const SkRect&>(crect);
}
+static SkRect* as_rect(sk_rect_t* crect) {
+ return reinterpret_cast<SkRect*>(crect);
+}
+
static const SkPath& AsPath(const sk_path_t& cpath) {
return reinterpret_cast<const SkPath&>(cpath);
}
@@ -208,10 +236,48 @@ void sk_path_quad_to(sk_path_t* cpath, float x0, float y0, float x1, float y1) {
as_path(cpath)->quadTo(x0, y0, x1, y1);
}
+void sk_path_conic_to(sk_path_t* cpath, float x0, float y0, float x1, float y1, float w) {
+ as_path(cpath)->conicTo(x0, y0, x1, y1, w);
+}
+
+void sk_path_cubic_to(sk_path_t* cpath, float x0, float y0, float x1, float y1, float x2, float y2) {
+ as_path(cpath)->cubicTo(x0, y0, x1, y1, x2, y2);
+}
+
void sk_path_close(sk_path_t* cpath) {
as_path(cpath)->close();
}
+void sk_path_add_rect(sk_path_t* cpath, const sk_rect_t* crect, sk_path_direction_t cdir) {
+ SkPath::Direction dir;
+ if (!from_c_path_direction(cdir, &dir)) {
+ return;
+ }
+ as_path(cpath)->addRect(AsRect(*crect), dir);
+}
+
+void sk_path_add_oval(sk_path_t* cpath, const sk_rect_t* crect, sk_path_direction_t cdir) {
+ SkPath::Direction dir;
+ if (!from_c_path_direction(cdir, &dir)) {
+ return;
+ }
+ as_path(cpath)->addOval(AsRect(*crect), dir);
+}
+
+bool sk_path_get_bounds(const sk_path_t* cpath, sk_rect_t* crect) {
+ const SkPath& path = AsPath(*cpath);
+ SkRect* rect = as_rect(crect);
+
+ if (path.isEmpty()) {
+ if (rect) {
+ rect->setEmpty();
+ }
+ return false;
+ }
+ *rect = path.getBounds();
+ return true;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////
void sk_canvas_save(sk_canvas_t* ccanvas) {
« no previous file with comments | « include/c/sk_types.h ('k') | tests/CTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698