| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } | 58 } |
| 59 } else { | 59 } else { |
| 60 return SkSurface::MakeFromBackendRenderTarget(fContext, *rtDesc, &props)
; | 60 return SkSurface::MakeFromBackendRenderTarget(fContext, *rtDesc, &props)
; |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 | 63 |
| 64 void WindowContext::presentRenderSurface(sk_sp<SkSurface> renderSurface, sk_sp<G
rRenderTarget> rt, | 64 void WindowContext::presentRenderSurface(sk_sp<SkSurface> renderSurface, sk_sp<G
rRenderTarget> rt, |
| 65 int colorBits) { | 65 int colorBits) { |
| 66 if (!this->isGpuContext() || colorBits > 24 || | 66 if (!this->isGpuContext() || colorBits > 24 || |
| 67 kRGBA_F16_SkColorType == fDisplayParams.fColorType) { | 67 kRGBA_F16_SkColorType == fDisplayParams.fColorType) { |
| 68 sk_sp<SkImage> image = renderSurface->makeImageSnapshot(); |
| 69 |
| 68 // We made/have an off-screen surface. Get the contents as an SkImage: | 70 // We made/have an off-screen surface. Get the contents as an SkImage: |
| 69 SkImageInfo info = SkImageInfo::Make(fWidth, fHeight, | 71 SkImageInfo info = SkImageInfo::Make(fWidth, fHeight, |
| 70 fDisplayParams.fColorType, | 72 fDisplayParams.fColorType, |
| 71 kUnknown_SkAlphaType, | 73 kUnknown_SkAlphaType, |
| 72 fDisplayParams.fColorSpace); | 74 fDisplayParams.fColorSpace); |
| 73 SkBitmap bm; | 75 SkBitmap bm; |
| 74 bm.allocPixels(info); | 76 bm.allocPixels(info); |
| 75 renderSurface->getCanvas()->readPixels(&bm, 0, 0); | 77 renderSurface->getCanvas()->readPixels(&bm, 0, 0); |
| 76 SkPixmap pm; | 78 SkPixmap pm; |
| 77 bm.peekPixels(&pm); | 79 bm.peekPixels(&pm); |
| 78 sk_sp<SkImage> image(SkImage::MakeTextureFromPixmap(fContext, pm, | 80 sk_sp<SkImage> image(SkImage::MakeTextureFromPixmap(fContext, pm, |
| 79 SkBudgeted::kNo)); | 81 SkBudgeted::kNo)); |
| 80 GrTexture* texture = as_IB(image)->peekTexture(); | 82 GrTexture* texture = as_IB(image)->peekTexture(); |
| 81 SkASSERT(texture); | 83 SkASSERT(texture); |
| 82 | 84 |
| 83 // With ten-bit output, we need to manually apply the gamma of the outpu
t device | 85 // With ten-bit output, we need to manually apply the gamma of the outpu
t device |
| 84 // (unless we're in non-gamma correct mode, in which case our data is al
ready | 86 // (unless we're in non-gamma correct mode, in which case our data is al
ready |
| 85 // fake-sRGB, like we're expected to put in the 10-bit buffer): | 87 // fake-sRGB, like we're expected to put in the 10-bit buffer): |
| 86 bool doGamma = (colorBits == 30) && SkImageInfoIsGammaCorrect(info); | 88 bool doGamma = (colorBits == 30) && SkImageInfoIsGammaCorrect(info); |
| 87 fContext->applyGamma(rt.get(), texture, doGamma ? 1.0f / 2.2f : 1.0f); | 89 fContext->applyGamma(rt.get(), texture, doGamma ? 1.0f / 2.2f : 1.0f); |
| 88 } | 90 } |
| 89 } | 91 } |
| 90 | 92 |
| 91 } //namespace sk_app | 93 } //namespace sk_app |
| OLD | NEW |