1 /* 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" 9 #include "SkBitmap.h" 10 11 class GrSurfaceContext; 12 class GrSurfaceProxy; 13 typedef uint32_t GrColor; 14 15 // Ensure that reading back from 'srcContext' as RGBA 8888 matches 'expectedPixelValues 16 void test_read_pixels(skiatest::Reporter*, 17 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') 22 void test_write_pixels(skiatest::Reporter*, 23 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). 27 void test_copy_from_surface(skiatest::Reporter*, GrContext*, 28 GrSurfaceProxy* proxy, uint32_t expectedPixelValues[], 29 bool onlyTestRTConfig, const char* testName); 30 31 // Ensure that RGBA 8888 pixels can be copied into 'dstContext' 32 void test_copy_to_surface(skiatest::Reporter*, GrProxyProvider*, 33 GrSurfaceContext* dstContext, const char* testName); 34 35 // Fills data with a red-green gradient 36 void fill_pixel_data(int width, int height, GrColor* data); 37 38 // Checks srcBuffer and dstBuffer contain the same colors 39 bool does_full_buffer_contain_correct_color(GrColor* srcBuffer, GrColor* dstBuffer, int width, 40 int height); 41 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. 44 bool bitmap_to_base64_data_uri(const SkBitmap& bitmap, SkString* dst); 45