aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar reed <reed@chromium.org>2014-11-24 19:11:48 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-24 19:11:48 -0800
commitafa278e250034186497722b1bc49ced885770249 (patch)
tree5ec792754f789938c07fcf57e5691da199f14831 /gm
parent0674fc7cafb6c416db2e339d5240a0f53a718f24 (diff)
more c
BUG=skia: TBR= Review URL: https://codereview.chromium.org/736133006
Diffstat (limited to 'gm')
-rw-r--r--gm/cgm.c48
-rw-r--r--gm/cgms.cpp35
2 files changed, 83 insertions, 0 deletions
diff --git a/gm/cgm.c b/gm/cgm.c
new file mode 100644
index 0000000000..cddb2c14e2
--- /dev/null
+++ b/gm/cgm.c
@@ -0,0 +1,48 @@
+/*
+ * 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
+
+#include "sk_canvas.h"
+#include "sk_paint.h"
+#include "sk_shader.h"
+#include "sk_surface.h"
+
+extern void sk_test_c_api(sk_canvas_t*);
+
+#define W 256
+#define H 256
+
+static sk_shader_t* make_shader() {
+ sk_point_t pts[] = { { 0, 0 }, { W, H } };
+ sk_color_t colors[] = { 0xFF00FF00, 0xFF0000FF };
+ return sk_shader_new_linear_gradient(pts, colors, NULL, 2, CLAMP_SK_SHADER_TILEMODE, NULL);
+}
+
+void sk_test_c_api(sk_canvas_t* canvas) {
+ sk_paint_t* paint = sk_paint_new();
+ sk_paint_set_antialias(paint, true);
+
+ sk_paint_set_color(paint, 0xFFFFFFFF);
+ sk_canvas_draw_paint(canvas, paint);
+
+ sk_rect_t r = { 10, 10, W - 10, H - 10 };
+
+ sk_paint_set_color(paint, 0xFFFF0000);
+ sk_canvas_draw_rect(canvas, &r, paint);
+
+ sk_shader_t* shader = make_shader();
+ sk_paint_set_shader(paint, shader);
+ sk_shader_unref(shader);
+
+ sk_canvas_draw_oval(canvas, &r, paint);
+
+ sk_paint_delete(paint);
+}
+
+
diff --git a/gm/cgms.cpp b/gm/cgms.cpp
new file mode 100644
index 0000000000..4f2c1b1822
--- /dev/null
+++ b/gm/cgms.cpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gm.h"
+#include "sk_types.h"
+
+extern "C" void sk_test_c_api(sk_canvas_t*);
+
+class C_GM : public skiagm::GM {
+public:
+ C_GM() {}
+
+protected:
+ SkString onShortName() SK_OVERRIDE {
+ return SkString("c_gms");
+ }
+
+ SkISize onISize() SK_OVERRIDE {
+ return SkISize::Make(640, 480);
+ }
+
+ void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ sk_test_c_api((sk_canvas_t*)canvas);
+ }
+
+private:
+ typedef GM INHERITED;
+};
+
+DEF_GM( return new C_GM; )
+