37#include <initializer_list>
50 return { 0, 0, 0,
a };
55 return { 1, 1, 1, 1 };
58 float r = 1, g = 1,
b = 1;
69 return { r, g,
b, 1.0f };
138 srcPM.
alloc(nativeII);
144 readbackPM.
alloc(nativeII);
157 srcPM.
alloc(nativeII);
166 auto c =
s->getCanvas();
167 c->drawImage(i, 0, 0);
171 readbackPM.
alloc(f32Unpremul);
185 const float tols[4] = {0.0f, 0.0f, 0.0f, 0};
187 auto error = std::function<ComparePixmapsErrorReporter>(
188 [
reporter, ct, label](
int x,
int y,
const float diffs[4]) {
192 diffs[0], diffs[1], diffs[2], diffs[3]);
201 using namespace skgpu;
208 if (!
test.fGpuCanMakeSurfaces) {
220 nativeExpected.
alloc(nativeII);
223 for (
bool fullInit : {
false,
true }) {
226 bool finishedBECreate =
false;
227 auto markFinished = [](
void* context) {
228 *(
bool*)context =
true;
232 GrRenderable::kNo, isProtected,
233 markFinished, &finishedBECreate);
247 while (backendTex.
isValid() && !finishedBECreate) {
261 nativeActual.
alloc(nativeII);
264 if (img->readPixels(dContext, nativeActual, 0, 0)) {
266 test.fColorType,
"SkImage::readPixels to native CT");
284 test.fColorType,
"SkSurface::readPixels to native CT");
290 f32Expected.
alloc(f32Unpremul);
296 f32Actual.
alloc(f32Unpremul);
298 if (img->readPixels(dContext, f32Actual, 0, 0)) {
300 test.fColorType,
"SkImage::readPixels to F32");
320 f32Actual.
alloc(f32Unpremul);
325 test.fColorType,
"SkSurface::drawn to RGBA8888");
336 for (
size_t i = 0; i < std::size(
gTests); ++i) {
345 auto context = ctxInfo.directContext();
347 for (
size_t i = 0; i < std::size(
gTests); ++i) {
static void raster_tests(skiatest::Reporter *reporter, const TestCase &test)
static constexpr int kSize
static SkColor4f get_trans_black_expected_color(SkColorChannelFlag channels)
static SkColor4f get_opaque_white_expected_color(SkColorChannelFlag channels)
static const TestCase gTests[]
static void gpu_tests(GrDirectContext *dContext, skiatest::Reporter *reporter, const TestCase &test)
static void compare_pixmaps(skiatest::Reporter *reporter, const SkPixmap &expected, const SkPixmap &actual, SkColorType ct, const char *label)
@ kTopLeft_GrSurfaceOrigin
skgpu::Protected Protected
@ kOpaque_SkAlphaType
pixel is opaque
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kR16G16B16A16_unorm_SkColorType
pixel with a little endian uint16_t for red, green, blue
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
@ kR8G8_unorm_SkColorType
pixel with a uint8_t for red and green
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
@ kA16_unorm_SkColorType
pixel with a little endian uint16_t for alpha
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
@ kRGB_101010x_SkColorType
pixel with 10 bits each for red, green, blue; in 32-bit word
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ kRGB_888x_SkColorType
pixel with 8 bits each for red, green, blue; in 32-bit word
@ kA16_float_SkColorType
pixel with a half float for alpha
@ kRGBA_F32_SkColorType
pixel using C float for red, green, blue, alpha; in 128-bit word
@ kRGBA_1010102_SkColorType
10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
@ kR16G16_unorm_SkColorType
pixel with a little endian uint16_t for red and green
@ kRGBA_F16Norm_SkColorType
pixel with half floats in [0,1] for red, green, blue, alpha;
@ kR16G16_float_SkColorType
pixel with a half float for red and green
@ kRGB_SkColorChannelFlags
@ kRGBA_SkColorChannelFlags
@ kRed_SkColorChannelFlag
@ kRG_SkColorChannelFlags
@ kGreen_SkColorChannelFlag
@ kAlpha_SkColorChannelFlag
@ kGray_SkColorChannelFlag
@ kBlue_SkColorChannelFlag
static uint32_t SkColorTypeChannelFlags(SkColorType ct)
static constexpr bool SkToBool(const T &x)
bool ComparePixels(const GrCPixmap &a, const GrCPixmap &b, const float tolRGBA[4], std::function< ComparePixmapsErrorReporter > &error)
#define DEF_TEST(name, reporter)
#define REPORTER_ASSERT(r, cond,...)
#define DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(name, reporter, context_info, ctsEnforcement)
const GrCaps * caps() const
bool supportsProtectedContent() const
SK_API bool colorTypeSupportedAsSurface(SkColorType colorType) const
void checkAsyncWorkCompletion()
SK_API bool colorTypeSupportedAsImage(SkColorType) const
bool submit(GrSyncCpu sync=GrSyncCpu::kNo)
void flushAndSubmit(GrSyncCpu sync=GrSyncCpu::kNo)
void deleteBackendTexture(const GrBackendTexture &)
GrBackendTexture createBackendTexture(int width, int height, const GrBackendFormat &, skgpu::Mipmapped, GrRenderable, GrProtected=GrProtected::kNo, std::string_view label={})
GrDirectContextPriv priv()
void alloc(const SkImageInfo &)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
SkColor getColor(int x, int y) const
bool erase(SkColor color, const SkIRect &subset) const
const uint8_t uint32_t uint32_t GError ** error
constexpr SkColor4f kWhite
constexpr SkColor4f kTransparent
SK_API sk_sp< SkImage > RasterFromPixmap(const SkPixmap &pixmap, RasterReleaseProc rasterReleaseProc, ReleaseContext releaseContext)
SK_API sk_sp< SkImage > BorrowTextureFrom(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
SkColorChannelFlag fChannels