blob: 7efbe94d56b1d45ffbcccbd5b2082232ed45c7c9 [file] [log] [blame]
Robert Phillips3500b772017-01-27 10:11:42 -05001/*
2 * Copyright 2017 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
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "include/core/SkBitmap.h"
9#include "tests/Test.h"
Robert Phillips3500b772017-01-27 10:11:42 -050010
Robert Phillips3500b772017-01-27 10:11:42 -050011class GrSurfaceContext;
12class GrSurfaceProxy;
Timothy Liang760dbc42018-07-17 13:28:20 -040013typedef uint32_t GrColor;
Robert Phillips3500b772017-01-27 10:11:42 -050014
15// Ensure that reading back from 'srcContext' as RGBA 8888 matches 'expectedPixelValues
Robert Phillips26c90e02017-03-14 14:39:29 -040016void test_read_pixels(skiatest::Reporter*,
Robert Phillips3500b772017-01-27 10:11:42 -050017 GrSurfaceContext* srcContext, uint32_t expectedPixelValues[],
18 const char* testName);
19
20// See if trying to write RGBA 8888 pixels to 'dstContext' matches matches the
21// expectation ('expectedToWork')
Robert Phillips26c90e02017-03-14 14:39:29 -040022void test_write_pixels(skiatest::Reporter*,
Robert Phillips3500b772017-01-27 10:11:42 -050023 GrSurfaceContext* srcContext, bool expectedToWork, const char* testName);
24
25// Ensure that the pixels can be copied from 'proxy' to an RGBA 8888 destination (both
26// texture-backed and rendertarget-backed).
Robert Phillips26c90e02017-03-14 14:39:29 -040027void test_copy_from_surface(skiatest::Reporter*, GrContext*,
Robert Phillips3500b772017-01-27 10:11:42 -050028 GrSurfaceProxy* proxy, uint32_t expectedPixelValues[],
Greg Daniel46cfbc62019-06-07 11:43:30 -040029 const char* testName);
Timothy Liang760dbc42018-07-17 13:28:20 -040030
31// Fills data with a red-green gradient
32void fill_pixel_data(int width, int height, GrColor* data);
33
Robert Phillipsee5fd132019-05-07 13:29:22 -040034// Create a solid colored backend texture
35bool create_backend_texture(GrContext*, GrBackendTexture* backendTex,
36 const SkImageInfo& ii, GrMipMapped mipMapped, SkColor color,
Robert Phillips9dbcdcc2019-05-13 10:40:06 -040037 GrRenderable);
Robert Phillipsee5fd132019-05-07 13:29:22 -040038
39void delete_backend_texture(GrContext*, const GrBackendTexture& backendTex);
40
Timothy Liang760dbc42018-07-17 13:28:20 -040041// Checks srcBuffer and dstBuffer contain the same colors
42bool does_full_buffer_contain_correct_color(GrColor* srcBuffer, GrColor* dstBuffer, int width,
43 int height);
Michael Ludwige8e10752018-10-01 12:42:53 -040044
45// Encodes the bitmap into a data:/image/png;base64,... url suitable to view in a browser after
46// printing to a log. If false is returned, dst holds an error message instead of a URI.
47bool bitmap_to_base64_data_uri(const SkBitmap& bitmap, SkString* dst);