Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: tools/viewer/sk_app/WindowContext.cpp

Issue 2069173002: Lots of progress switching to SkColorSpace rather than SkColorProfileType (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix bad assert Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 18 matching lines...) Expand all
29 if (!this->isGpuContext() || colorBits > 24 || 29 if (!this->isGpuContext() || colorBits > 24 ||
30 kRGBA_F16_SkColorType == fDisplayParams.fColorType) { 30 kRGBA_F16_SkColorType == fDisplayParams.fColorType) {
31 // If we're rendering to F16, we need an off-screen surface - the curren t render 31 // If we're rendering to F16, we need an off-screen surface - the curren t render
32 // target is most likely the wrong format. 32 // target is most likely the wrong format.
33 // 33 //
34 // If we're rendering raster data or using a deep (10-bit or higher) sur face, we probably 34 // If we're rendering raster data or using a deep (10-bit or higher) sur face, we probably
35 // need an off-screen surface. 10-bit, in particular, has strange gamma behavior. 35 // need an off-screen surface. 10-bit, in particular, has strange gamma behavior.
36 SkImageInfo info = SkImageInfo::Make(fWidth, fHeight, 36 SkImageInfo info = SkImageInfo::Make(fWidth, fHeight,
37 fDisplayParams.fColorType, 37 fDisplayParams.fColorType,
38 kUnknown_SkAlphaType, 38 kUnknown_SkAlphaType,
39 fDisplayParams.fProfileType); 39 fDisplayParams.fColorSpace);
40 return SkSurface::MakeRenderTarget(fContext, SkBudgeted::kNo, info, 40 return SkSurface::MakeRenderTarget(fContext, SkBudgeted::kNo, info,
41 fDisplayParams.fMSAASampleCount, &pro ps); 41 fDisplayParams.fMSAASampleCount, &pro ps);
42 } else { 42 } else {
43 return SkSurface::MakeRenderTargetDirect(rt.get(), &props); 43 return SkSurface::MakeRenderTargetDirect(rt.get(), &props);
44 } 44 }
45 } 45 }
46 46
47 void WindowContext::presentRenderSurface(sk_sp<SkSurface> renderSurface, sk_sp<G rRenderTarget> rt, 47 void WindowContext::presentRenderSurface(sk_sp<SkSurface> renderSurface, sk_sp<G rRenderTarget> rt,
48 int colorBits) { 48 int colorBits) {
49 if (!this->isGpuContext() || colorBits > 24 || 49 if (!this->isGpuContext() || colorBits > 24 ||
50 kRGBA_F16_SkColorType == fDisplayParams.fColorType) { 50 kRGBA_F16_SkColorType == fDisplayParams.fColorType) {
51 // We made/have an off-screen surface. Get the contents as an SkImage: 51 // We made/have an off-screen surface. Get the contents as an SkImage:
52 SkImageInfo info = SkImageInfo::Make(fWidth, fHeight, 52 SkImageInfo info = SkImageInfo::Make(fWidth, fHeight,
53 fDisplayParams.fColorType, 53 fDisplayParams.fColorType,
54 kUnknown_SkAlphaType, 54 kUnknown_SkAlphaType,
55 fDisplayParams.fProfileType); 55 fDisplayParams.fColorSpace);
56 SkBitmap bm; 56 SkBitmap bm;
57 bm.allocPixels(info); 57 bm.allocPixels(info);
58 renderSurface->getCanvas()->readPixels(&bm, 0, 0); 58 renderSurface->getCanvas()->readPixels(&bm, 0, 0);
59 SkPixmap pm; 59 SkPixmap pm;
60 bm.peekPixels(&pm); 60 bm.peekPixels(&pm);
61 sk_sp<SkImage> image(SkImage::MakeTextureFromPixmap(fContext, pm, 61 sk_sp<SkImage> image(SkImage::MakeTextureFromPixmap(fContext, pm,
62 SkBudgeted::kNo)); 62 SkBudgeted::kNo));
63 GrTexture* texture = as_IB(image)->peekTexture(); 63 GrTexture* texture = as_IB(image)->peekTexture();
64 SkASSERT(texture); 64 SkASSERT(texture);
65 65
66 // With ten-bit output, we need to manually apply the gamma of the outpu t device 66 // With ten-bit output, we need to manually apply the gamma of the outpu t device
67 // (unless we're in non-gamma correct mode, in which case our data is al ready 67 // (unless we're in non-gamma correct mode, in which case our data is al ready
68 // fake-sRGB, like we're expected to put in the 10-bit buffer): 68 // fake-sRGB, like we're expected to put in the 10-bit buffer):
69 bool doGamma = (colorBits == 30) && SkImageInfoIsGammaCorrect(info); 69 bool doGamma = (colorBits == 30) && SkImageInfoIsGammaCorrect(info);
70 fContext->applyGamma(rt.get(), texture, doGamma ? 1.0f / 2.2f : 1.0f); 70 fContext->applyGamma(rt.get(), texture, doGamma ? 1.0f / 2.2f : 1.0f);
71 } 71 }
72 } 72 }
73 73
74 } //namespace sk_app 74 } //namespace sk_app
OLDNEW
« no previous file with comments | « tools/viewer/sk_app/VulkanWindowContext.cpp ('k') | tools/viewer/sk_app/android/GLWindowContext_android.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698