| Index: tools/viewer/sk_app/WindowContext.cpp
|
| diff --git a/tools/viewer/sk_app/WindowContext.cpp b/tools/viewer/sk_app/WindowContext.cpp
|
| index ecac2cc0047b44ab2d189dbd4e223148ff3cba40..ba04e7eace9837bd267a6f220346bfaba6d8c74c 100755
|
| --- a/tools/viewer/sk_app/WindowContext.cpp
|
| +++ b/tools/viewer/sk_app/WindowContext.cpp
|
| @@ -21,24 +21,41 @@
|
|
|
| namespace sk_app {
|
|
|
| +sk_sp<SkSurface> WindowContext::createOffscreenSurface(bool forceSRGB) {
|
| + return createSurface(nullptr, 0, true, forceSRGB);
|
| +}
|
| +
|
| sk_sp<SkSurface> WindowContext::createRenderSurface(sk_sp<GrRenderTarget> rt, int colorBits) {
|
| + return createSurface(rt, colorBits, false, false);
|
| +}
|
| +
|
| +sk_sp<SkSurface> WindowContext::createSurface(
|
| + sk_sp<GrRenderTarget> rt, int colorBits, bool offscreen, bool forceSRGB) {
|
| auto flags = (fSurfaceProps.flags() & ~SkSurfaceProps::kGammaCorrect_Flag) |
|
| - (GrPixelConfigIsSRGB(fPixelConfig) ? SkSurfaceProps::kGammaCorrect_Flag : 0);
|
| + (GrPixelConfigIsSRGB(fPixelConfig) || forceSRGB ?
|
| + SkSurfaceProps::kGammaCorrect_Flag : 0);
|
| SkSurfaceProps props(flags, fSurfaceProps.pixelGeometry());
|
|
|
| - if (!this->isGpuContext() || colorBits > 24 ||
|
| + if (!this->isGpuContext() || colorBits > 24 || offscreen ||
|
| kRGBA_F16_SkColorType == fDisplayParams.fColorType) {
|
| // If we're rendering to F16, we need an off-screen surface - the current render
|
| // target is most likely the wrong format.
|
| //
|
| // If we're rendering raster data or using a deep (10-bit or higher) surface, we probably
|
| // need an off-screen surface. 10-bit, in particular, has strange gamma behavior.
|
| - SkImageInfo info = SkImageInfo::Make(fWidth, fHeight,
|
| - fDisplayParams.fColorType,
|
| - kUnknown_SkAlphaType,
|
| - fDisplayParams.fColorSpace);
|
| - return SkSurface::MakeRenderTarget(fContext, SkBudgeted::kNo, info,
|
| - fDisplayParams.fMSAASampleCount, &props);
|
| + SkImageInfo info = SkImageInfo::Make(
|
| + fWidth, fHeight,
|
| + fDisplayParams.fColorType,
|
| + kPremul_SkAlphaType,
|
| + forceSRGB ? SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)
|
| + : fDisplayParams.fColorSpace
|
| + );
|
| + if (this->isGpuContext()) {
|
| + return SkSurface::MakeRenderTarget(fContext, SkBudgeted::kNo, info,
|
| + fDisplayParams.fMSAASampleCount, &props);
|
| + } else {
|
| + return SkSurface::MakeRaster(info, &props);
|
| + }
|
| } else {
|
| return SkSurface::MakeRenderTargetDirect(rt.get(), &props);
|
| }
|
|
|