DrawOptions GetDrawOptions() {
// path *should* be absolute.
static const char path[] = "resources/color_wheel.png";
- return DrawOptions(256, 256, true, true, true, true, path);
+ return DrawOptions(256, 256, true, true, true, true, true, true, path);
}
void draw(SkCanvas* canvas) {
canvas->clear(SK_ColorWHITE);
}
}
sk_sp<SkData> rasterData, gpuData, pdfData, skpData;
+ SkColorType colorType = kN32_SkColorType;
+ sk_sp<SkColorSpace> colorSpace = nullptr;
+ if (options.f16) {
+ SkASSERT(options.srgb);
+ colorType = kRGBA_F16_SkColorType;
+ colorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named);
+ } else if (options.srgb) {
+ colorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named);
+ }
+ SkImageInfo info = SkImageInfo::Make(options.size.width(), options.size.height(), colorType,
+ kPremul_SkAlphaType, colorSpace);
if (options.raster) {
- auto rasterSurface =
- SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(options.size));
+ auto rasterSurface = SkSurface::MakeRaster(info);
srand(0);
draw(rasterSurface->getCanvas());
rasterData.reset(encode_snapshot(rasterSurface));
if (!grContext) {
fputs("Unable to get GrContext.\n", stderr);
} else {
- auto surface = SkSurface::MakeRenderTarget(
- grContext.get(),
- SkBudgeted::kNo,
- SkImageInfo::MakeN32Premul(options.size));
+ auto surface = SkSurface::MakeRenderTarget(grContext.get(), SkBudgeted::kNo, info);
if (!surface) {
fputs("Unable to get render surface.\n", stderr);
exit(1);
extern sk_sp<SkImage> image;
struct DrawOptions {
- DrawOptions(int w, int h, bool r, bool g, bool p, bool k, const char* s)
+ DrawOptions(int w, int h, bool r, bool g, bool p, bool k, bool srgb, bool f16, const char* s)
: size(SkISize::Make(w, h))
, raster(r)
, gpu(g)
, pdf(p)
, skp(k)
- , source(s) {}
+ , srgb(srgb)
+ , f16(f16)
+ , source(s)
+ {
+ // F16 mode is only valid for color correct backends.
+ SkASSERT(srgb || !f16);
+ }
SkISize size;
bool raster;
bool gpu;
bool pdf;
bool skp;
+ bool srgb;
+ bool f16;
const char* source;
};