diff options
author | Matt Sarett <msarett@google.com> | 2016-11-29 17:14:58 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-12-01 18:12:57 +0000 |
commit | a2f7126ed4e705f0fec8227daed651fcdd3ba445 (patch) | |
tree | a2cb476f2be60e48097c98c09939a1c69375213d /tools/fiddle | |
parent | a4d861a5b44d2139678291d7ab3b1da3a8d6252d (diff) |
Add srgb and f16 modes to fiddle
BUG=skia:5945
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4546
Change-Id: I29b87a3b2eb20b8d28f8fb970b5192807bebdc48
Reviewed-on: https://skia-review.googlesource.com/4546
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Commit-Queue: Matt Sarett <msarett@google.com>
Diffstat (limited to 'tools/fiddle')
-rw-r--r-- | tools/fiddle/draw.cpp | 2 | ||||
-rw-r--r-- | tools/fiddle/fiddle_main.cpp | 19 | ||||
-rw-r--r-- | tools/fiddle/fiddle_main.h | 12 |
3 files changed, 24 insertions, 9 deletions
diff --git a/tools/fiddle/draw.cpp b/tools/fiddle/draw.cpp index 68cbbdf8d6..efab8b4f5b 100644 --- a/tools/fiddle/draw.cpp +++ b/tools/fiddle/draw.cpp @@ -13,7 +13,7 @@ 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); diff --git a/tools/fiddle/fiddle_main.cpp b/tools/fiddle/fiddle_main.cpp index 9e39292912..2e3d37b08f 100644 --- a/tools/fiddle/fiddle_main.cpp +++ b/tools/fiddle/fiddle_main.cpp @@ -105,9 +105,19 @@ int main() { } } 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)); @@ -117,10 +127,7 @@ int main() { 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); diff --git a/tools/fiddle/fiddle_main.h b/tools/fiddle/fiddle_main.h index 0f36ad7804..a03eebca6c 100644 --- a/tools/fiddle/fiddle_main.h +++ b/tools/fiddle/fiddle_main.h @@ -24,18 +24,26 @@ extern SkBitmap source; 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; }; |