| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "GrContext.h" | 9 #include "GrContext.h" |
| 10 #include "SkSurface.h" | 10 #include "SkSurface.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 return SkSurface::MakeRenderTarget(fContext, SkBudgeted::kNo, info, | 49 return SkSurface::MakeRenderTarget(fContext, SkBudgeted::kNo, info, |
| 50 fDisplayParams.fMSAASampleCount,
&fSurfaceProps); | 50 fDisplayParams.fMSAASampleCount,
&fSurfaceProps); |
| 51 } else { | 51 } else { |
| 52 return SkSurface::MakeRaster(info, &fSurfaceProps); | 52 return SkSurface::MakeRaster(info, &fSurfaceProps); |
| 53 } | 53 } |
| 54 } else { | 54 } else { |
| 55 return SkSurface::MakeFromBackendRenderTarget(fContext, *rtDesc, &fSurfa
ceProps); | 55 return SkSurface::MakeFromBackendRenderTarget(fContext, *rtDesc, &fSurfa
ceProps); |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 | 58 |
| 59 void WindowContext::presentRenderSurface(sk_sp<SkSurface> renderSurface, sk_sp<G
rRenderTarget> rt, | |
| 60 int colorBits) { | |
| 61 if (!this->isGpuContext() || colorBits > 24 || | |
| 62 kRGBA_F16_SkColorType == fDisplayParams.fColorType) { | |
| 63 // We made/have an off-screen surface. Get the contents as an SkImage: | |
| 64 SkImageInfo info = SkImageInfo::Make(fWidth, fHeight, | |
| 65 fDisplayParams.fColorType, | |
| 66 kUnknown_SkAlphaType, | |
| 67 fDisplayParams.fColorSpace); | |
| 68 SkBitmap bm; | |
| 69 bm.allocPixels(info); | |
| 70 renderSurface->getCanvas()->readPixels(&bm, 0, 0); | |
| 71 SkPixmap pm; | |
| 72 bm.peekPixels(&pm); | |
| 73 sk_sp<SkImage> image(SkImage::MakeTextureFromPixmap(fContext, pm, | |
| 74 SkBudgeted::kNo)); | |
| 75 GrTexture* texture = as_IB(image)->peekTexture(); | |
| 76 SkASSERT(texture); | |
| 77 | |
| 78 // With ten-bit output, we need to manually apply the gamma of the outpu
t device | |
| 79 // (unless we're in non-gamma correct mode, in which case our data is al
ready | |
| 80 // fake-sRGB, like we're expected to put in the 10-bit buffer): | |
| 81 bool doGamma = (colorBits == 30) && SkImageInfoIsGammaCorrect(info); | |
| 82 fContext->applyGamma(rt.get(), texture, doGamma ? 1.0f / 2.2f : 1.0f); | |
| 83 } | |
| 84 } | |
| 85 | |
| 86 } //namespace sk_app | 59 } //namespace sk_app |
| OLD | NEW |