OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "sk_canvas.h" | 8 #include "sk_canvas.h" |
9 #include "sk_paint.h" | 9 #include "sk_paint.h" |
10 #include "sk_surface.h" | 10 #include "sk_surface.h" |
11 #include "sk_shader.h" | 11 #include "sk_shader.h" |
12 | 12 |
13 #include "Test.h" | 13 #include "Test.h" |
14 | 14 |
15 | 15 |
16 static void shader_test(skiatest::Reporter* reporter) { | 16 static void shader_test(skiatest::Reporter* reporter) { |
17 sk_imageinfo_t info = | 17 sk_imageinfo_t info = |
18 {64, 64, sk_colortype_get_default_8888(), PREMUL_SK_ALPHATYPE}; | 18 {64, 64, sk_colortype_get_default_8888(), PREMUL_SK_ALPHATYPE}; |
19 sk_surface_t* surface = sk_surface_new_raster(&info, NULL); | 19 sk_surface_t* surface = sk_surface_new_raster(&info, nullptr); |
20 sk_canvas_t* canvas = sk_surface_get_canvas(surface); | 20 sk_canvas_t* canvas = sk_surface_get_canvas(surface); |
21 sk_paint_t* paint = sk_paint_new(); | 21 sk_paint_t* paint = sk_paint_new(); |
22 | 22 |
23 sk_shader_tilemode_t tilemode = CLAMP_SK_SHADER_TILEMODE; | 23 sk_shader_tilemode_t tilemode = CLAMP_SK_SHADER_TILEMODE; |
24 sk_point_t point = {0.0f, 0.0f}; | 24 sk_point_t point = {0.0f, 0.0f}; |
25 sk_point_t point2 = {30.0f, 40.0f}; | 25 sk_point_t point2 = {30.0f, 40.0f}; |
26 sk_color_t colors[] = { | 26 sk_color_t colors[] = { |
27 (sk_color_t)sk_color_set_argb(0xFF, 0x00, 0x00, 0xFF), | 27 (sk_color_t)sk_color_set_argb(0xFF, 0x00, 0x00, 0xFF), |
28 (sk_color_t)sk_color_set_argb(0xFF, 0x00, 0xFF, 0x00) | 28 (sk_color_t)sk_color_set_argb(0xFF, 0x00, 0xFF, 0x00) |
29 }; | 29 }; |
30 sk_shader_t* shader; | 30 sk_shader_t* shader; |
31 | 31 |
32 shader = sk_shader_new_radial_gradient( | 32 shader = sk_shader_new_radial_gradient( |
33 &point, 1.0f, colors, NULL, 2, tilemode, NULL); | 33 &point, 1.0f, colors, nullptr, 2, tilemode, nullptr); |
34 REPORTER_ASSERT(reporter, shader != NULL); | 34 REPORTER_ASSERT(reporter, shader != nullptr); |
35 sk_paint_set_shader(paint, shader); | 35 sk_paint_set_shader(paint, shader); |
36 sk_shader_unref(shader); | 36 sk_shader_unref(shader); |
37 sk_canvas_draw_paint(canvas, paint); | 37 sk_canvas_draw_paint(canvas, paint); |
38 | 38 |
39 shader = sk_shader_new_sweep_gradient(&point, colors, NULL, 2, NULL); | 39 shader = sk_shader_new_sweep_gradient(&point, colors, nullptr, 2, nullptr); |
40 REPORTER_ASSERT(reporter, shader != NULL); | 40 REPORTER_ASSERT(reporter, shader != nullptr); |
41 sk_paint_set_shader(paint, shader); | 41 sk_paint_set_shader(paint, shader); |
42 sk_shader_unref(shader); | 42 sk_shader_unref(shader); |
43 sk_canvas_draw_paint(canvas, paint); | 43 sk_canvas_draw_paint(canvas, paint); |
44 | 44 |
45 shader = sk_shader_new_two_point_conical_gradient( | 45 shader = sk_shader_new_two_point_conical_gradient( |
46 &point, 10.0f, &point2, 50.0f, colors, NULL, 2, tilemode, NULL); | 46 &point, 10.0f, &point2, 50.0f, colors, nullptr, 2, tilemode, nullpt
r); |
47 REPORTER_ASSERT(reporter, shader != NULL); | 47 REPORTER_ASSERT(reporter, shader != nullptr); |
48 sk_paint_set_shader(paint, shader); | 48 sk_paint_set_shader(paint, shader); |
49 sk_shader_unref(shader); | 49 sk_shader_unref(shader); |
50 sk_canvas_draw_paint(canvas, paint); | 50 sk_canvas_draw_paint(canvas, paint); |
51 | 51 |
52 sk_paint_delete(paint); | 52 sk_paint_delete(paint); |
53 sk_surface_unref(surface); | 53 sk_surface_unref(surface); |
54 } | 54 } |
55 | 55 |
56 static void test_c(skiatest::Reporter* reporter) { | 56 static void test_c(skiatest::Reporter* reporter) { |
57 sk_colortype_t ct = sk_colortype_get_default_8888(); | 57 sk_colortype_t ct = sk_colortype_get_default_8888(); |
(...skipping 22 matching lines...) Expand all Loading... |
80 REPORTER_ASSERT(reporter, 0x80404040 == pixel[0]); | 80 REPORTER_ASSERT(reporter, 0x80404040 == pixel[0]); |
81 | 81 |
82 sk_paint_delete(paint); | 82 sk_paint_delete(paint); |
83 sk_surface_unref(surface); | 83 sk_surface_unref(surface); |
84 } | 84 } |
85 | 85 |
86 DEF_TEST(C_API, reporter) { | 86 DEF_TEST(C_API, reporter) { |
87 test_c(reporter); | 87 test_c(reporter); |
88 shader_test(reporter); | 88 shader_test(reporter); |
89 } | 89 } |
OLD | NEW |