Chromium Code Reviews| Index: tools/viewer/sk_app/WindowContext.cpp |
| diff --git a/tools/viewer/sk_app/WindowContext.cpp b/tools/viewer/sk_app/WindowContext.cpp |
| index 41bbd14576b37f604c8f65d7001b8de076932553..44fd91458f9326b8a9c9d233ebd151a4bd042f65 100755 |
| --- a/tools/viewer/sk_app/WindowContext.cpp |
| +++ b/tools/viewer/sk_app/WindowContext.cpp |
| @@ -21,12 +21,14 @@ |
| namespace sk_app { |
| -sk_sp<SkSurface> WindowContext::createRenderSurface(sk_sp<GrRenderTarget> rt, int colorBits) { |
| +sk_sp<SkSurface> WindowContext::createRenderSurface( |
| + sk_sp<GrRenderTarget> rt, int colorBits, bool offscreen, bool sRGB) { |
| auto flags = (fSurfaceProps.flags() & ~SkSurfaceProps::kGammaCorrect_Flag) | |
| - (GrPixelConfigIsSRGB(fPixelConfig) ? SkSurfaceProps::kGammaCorrect_Flag : 0); |
| + (GrPixelConfigIsSRGB(fPixelConfig) || sRGB ? |
| + 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. |
| @@ -35,10 +37,17 @@ sk_sp<SkSurface> WindowContext::createRenderSurface(sk_sp<GrRenderTarget> rt, in |
| // need an off-screen surface. 10-bit, in particular, has strange gamma behavior. |
| SkImageInfo info = SkImageInfo::Make(fWidth, fHeight, |
| fDisplayParams.fColorType, |
| - kUnknown_SkAlphaType, |
| - fDisplayParams.fProfileType); |
| - return SkSurface::MakeRenderTarget(fContext, SkBudgeted::kNo, info, |
| - fDisplayParams.fMSAASampleCount, &props); |
| + // kUnknown_SkAlphaType won't pass |
| + // CheckAlphaTypeAndGetFlags |
| + kOpaque_SkAlphaType, |
|
Brian Osman
2016/06/15 15:32:03
kOpaque is probably okay, although kPremul is prob
liyuqian
2016/06/15 16:43:12
Done. Ok, I'll change both kOpaque to kPremul.
|
| + sRGB ? kSRGB_SkColorProfileType |
| + : fDisplayParams.fProfileType); |
| + 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); |
| } |