blob: 413f629ee3f2f4bfc4f1f24a2b01e4a5817719c3 [file] [log] [blame]
reede3323962014-10-24 11:16:19 -07001/*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
reed73c25012014-11-17 06:15:42 -08008#include "sk_canvas.h"
9#include "sk_paint.h"
reede3323962014-10-24 11:16:19 -070010#include "sk_surface.h"
reed73c25012014-11-17 06:15:42 -080011
reede3323962014-10-24 11:16:19 -070012#include "Test.h"
13
14static void test_c(skiatest::Reporter* reporter) {
15 sk_colortype_t ct = sk_colortype_get_default_8888();
16
17 sk_imageinfo_t info = {
18 1, 1, ct, PREMUL_SK_ALPHATYPE
19 };
20 uint32_t pixel[1] = { 0 };
robertphillips702edbd2015-06-23 06:26:08 -070021 sk_surfaceprops_t surfaceProps = { UNKNOWN_SK_PIXELGEOMETRY };
reede3323962014-10-24 11:16:19 -070022
robertphillips702edbd2015-06-23 06:26:08 -070023 sk_surface_t* surface = sk_surface_new_raster_direct(&info, pixel, sizeof(uint32_t),
24 &surfaceProps);
reede3323962014-10-24 11:16:19 -070025 sk_paint_t* paint = sk_paint_new();
26
27 sk_canvas_t* canvas = sk_surface_get_canvas(surface);
28 sk_canvas_draw_paint(canvas, paint);
29 REPORTER_ASSERT(reporter, 0xFF000000 == pixel[0]);
30
31 sk_paint_set_color(paint, sk_color_set_argb(0xFF, 0xFF, 0xFF, 0xFF));
32 sk_canvas_draw_paint(canvas, paint);
33 REPORTER_ASSERT(reporter, 0xFFFFFFFF == pixel[0]);
34
35 sk_paint_delete(paint);
reedafa278e2014-11-24 19:11:48 -080036 sk_surface_unref(surface);
reede3323962014-10-24 11:16:19 -070037}
38
39DEF_TEST(C_API, reporter) {
40 test_c(reporter);
41}