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

Unified Diff: tests/CTest.cpp

Issue 1263773006: C API: add radial, sweep, and two-point conical gradient shaders (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: pass by const* Created 5 years, 4 months 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 | « src/c/sk_surface.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/CTest.cpp
diff --git a/tests/CTest.cpp b/tests/CTest.cpp
index 413f629ee3f2f4bfc4f1f24a2b01e4a5817719c3..194b8f04f2366fb06e183aee975d90e8f42ddd32 100644
--- a/tests/CTest.cpp
+++ b/tests/CTest.cpp
@@ -8,9 +8,51 @@
#include "sk_canvas.h"
#include "sk_paint.h"
#include "sk_surface.h"
+#include "sk_shader.h"
#include "Test.h"
+
+static void shader_test(skiatest::Reporter* reporter) {
+ sk_imageinfo_t info =
+ {64, 64, sk_colortype_get_default_8888(), PREMUL_SK_ALPHATYPE};
+ sk_surface_t* surface = sk_surface_new_raster(&info, NULL);
+ sk_canvas_t* canvas = sk_surface_get_canvas(surface);
+ sk_paint_t* paint = sk_paint_new();
+
+ sk_shader_tilemode_t tilemode = CLAMP_SK_SHADER_TILEMODE;
+ sk_point_t point = {0.0f, 0.0f};
+ sk_point_t point2 = {30.0f, 40.0f};
+ sk_color_t colors[] = {
+ (sk_color_t)sk_color_set_argb(0xFF, 0x00, 0x00, 0xFF),
+ (sk_color_t)sk_color_set_argb(0xFF, 0x00, 0xFF, 0x00)
+ };
+ sk_shader_t* shader;
+
+ shader = sk_shader_new_radial_gradient(
+ &point, 1.0f, colors, NULL, 2, tilemode, NULL);
+ REPORTER_ASSERT(reporter, shader != NULL);
+ sk_paint_set_shader(paint, shader);
+ sk_shader_unref(shader);
+ sk_canvas_draw_paint(canvas, paint);
+
+ shader = sk_shader_new_sweep_gradient(&point, colors, NULL, 2, NULL);
+ REPORTER_ASSERT(reporter, shader != NULL);
+ sk_paint_set_shader(paint, shader);
+ sk_shader_unref(shader);
+ sk_canvas_draw_paint(canvas, paint);
+
+ shader = sk_shader_new_two_point_conical_gradient(
+ &point, 10.0f, &point2, 50.0f, colors, NULL, 2, tilemode, NULL);
+ REPORTER_ASSERT(reporter, shader != NULL);
+ sk_paint_set_shader(paint, shader);
+ sk_shader_unref(shader);
+ sk_canvas_draw_paint(canvas, paint);
+
+ sk_paint_delete(paint);
+ sk_surface_unref(surface);
+}
+
static void test_c(skiatest::Reporter* reporter) {
sk_colortype_t ct = sk_colortype_get_default_8888();
@@ -38,4 +80,5 @@ static void test_c(skiatest::Reporter* reporter) {
DEF_TEST(C_API, reporter) {
test_c(reporter);
+ shader_test(reporter);
}
« no previous file with comments | « src/c/sk_surface.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698