blob: 5fc9afdff379e11c9b8fd3b16e8316e25d38fea9 [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
8#include "Test.h"
Michael Ludwige8e10752018-10-01 12:42:53 -04009#include "SkBitmap.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[],
29 bool onlyTestRTConfig, const char* testName);
30
31// Ensure that RGBA 8888 pixels can be copied into 'dstContext'
Robert Phillips1afd4cd2018-01-08 13:40:32 -050032void test_copy_to_surface(skiatest::Reporter*, GrProxyProvider*,
Robert Phillips3500b772017-01-27 10:11:42 -050033 GrSurfaceContext* dstContext, const char* testName);
Timothy Liang760dbc42018-07-17 13:28:20 -040034
35// Fills data with a red-green gradient
36void fill_pixel_data(int width, int height, GrColor* data);
37
38// Checks srcBuffer and dstBuffer contain the same colors
39bool does_full_buffer_contain_correct_color(GrColor* srcBuffer, GrColor* dstBuffer, int width,
40 int height);
Michael Ludwige8e10752018-10-01 12:42:53 -040041
42// Encodes the bitmap into a data:/image/png;base64,... url suitable to view in a browser after
43// printing to a log. If false is returned, dst holds an error message instead of a URI.
44bool bitmap_to_base64_data_uri(const SkBitmap& bitmap, SkString* dst);