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

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

Issue 2069653002: Use Offscreen Surface for Split Screen (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: More fixes 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"
11 #include "WindowContext.h" 11 #include "WindowContext.h"
12 12
13 #include "gl/GrGLDefines.h" 13 #include "gl/GrGLDefines.h"
14 14
15 #include "gl/GrGLUtil.h" 15 #include "gl/GrGLUtil.h"
16 #include "GrRenderTarget.h" 16 #include "GrRenderTarget.h"
17 #include "GrContext.h" 17 #include "GrContext.h"
18 18
19 #include "SkCanvas.h" 19 #include "SkCanvas.h"
20 #include "SkImage_Base.h" 20 #include "SkImage_Base.h"
21 21
22 namespace sk_app { 22 namespace sk_app {
23 23
24 sk_sp<SkSurface> WindowContext::createRenderSurface(sk_sp<GrRenderTarget> rt, in t colorBits) { 24 sk_sp<SkSurface> WindowContext::createRenderSurface(
25 sk_sp<GrRenderTarget> rt, int colorBits, bool offscreen, bool sRGB) {
25 auto flags = (fSurfaceProps.flags() & ~SkSurfaceProps::kGammaCorrect_Flag) | 26 auto flags = (fSurfaceProps.flags() & ~SkSurfaceProps::kGammaCorrect_Flag) |
26 (GrPixelConfigIsSRGB(fPixelConfig) ? SkSurfaceProps::kGammaCorr ect_Flag : 0); 27 (GrPixelConfigIsSRGB(fPixelConfig) || sRGB ?
28 SkSurfaceProps::kGammaCorrect_Flag : 0);
27 SkSurfaceProps props(flags, fSurfaceProps.pixelGeometry()); 29 SkSurfaceProps props(flags, fSurfaceProps.pixelGeometry());
28 30
29 if (!this->isGpuContext() || colorBits > 24 || 31 if (!this->isGpuContext() || colorBits > 24 || offscreen ||
30 kRGBA_F16_SkColorType == fDisplayParams.fColorType) { 32 kRGBA_F16_SkColorType == fDisplayParams.fColorType) {
31 // If we're rendering to F16, we need an off-screen surface - the curren t render 33 // If we're rendering to F16, we need an off-screen surface - the curren t render
32 // target is most likely the wrong format. 34 // target is most likely the wrong format.
33 // 35 //
34 // If we're rendering raster data or using a deep (10-bit or higher) sur face, we probably 36 // 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. 37 // need an off-screen surface. 10-bit, in particular, has strange gamma behavior.
36 SkImageInfo info = SkImageInfo::Make(fWidth, fHeight, 38 SkImageInfo info = SkImageInfo::Make(
37 fDisplayParams.fColorType, 39 fWidth, fHeight,
38 kUnknown_SkAlphaType, 40 fDisplayParams.fColorType,
39 fDisplayParams.fProfileType); 41 kPremul_SkAlphaType,
40 return SkSurface::MakeRenderTarget(fContext, SkBudgeted::kNo, info, 42 (sRGB || fDisplayParams.fProfileType == kSRGB_SkColorProfileType ) ?
41 fDisplayParams.fMSAASampleCount, &pro ps); 43 SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) : nullptr
44 );
45 if (this->isGpuContext()) {
46 return SkSurface::MakeRenderTarget(fContext, SkBudgeted::kNo, info,
47 fDisplayParams.fMSAASampleCount, &props);
48 } else {
49 return SkSurface::MakeRaster(info, &props);
50 }
42 } else { 51 } else {
43 return SkSurface::MakeRenderTargetDirect(rt.get(), &props); 52 return SkSurface::MakeRenderTargetDirect(rt.get(), &props);
44 } 53 }
45 } 54 }
46 55
47 void WindowContext::presentRenderSurface(sk_sp<SkSurface> renderSurface, sk_sp<G rRenderTarget> rt, 56 void WindowContext::presentRenderSurface(sk_sp<SkSurface> renderSurface, sk_sp<G rRenderTarget> rt,
48 int colorBits) { 57 int colorBits) {
49 if (!this->isGpuContext() || colorBits > 24 || 58 if (!this->isGpuContext() || colorBits > 24 ||
50 kRGBA_F16_SkColorType == fDisplayParams.fColorType) { 59 kRGBA_F16_SkColorType == fDisplayParams.fColorType) {
51 // We made/have an off-screen surface. Get the contents as an SkImage: 60 // We made/have an off-screen surface. Get the contents as an SkImage:
(...skipping 13 matching lines...) Expand all
65 74
66 // With ten-bit output, we need to manually apply the gamma of the outpu t device 75 // 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 76 // (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): 77 // fake-sRGB, like we're expected to put in the 10-bit buffer):
69 bool doGamma = (colorBits == 30) && SkImageInfoIsGammaCorrect(info); 78 bool doGamma = (colorBits == 30) && SkImageInfoIsGammaCorrect(info);
70 fContext->applyGamma(rt.get(), texture, doGamma ? 1.0f / 2.2f : 1.0f); 79 fContext->applyGamma(rt.get(), texture, doGamma ? 1.0f / 2.2f : 1.0f);
71 } 80 }
72 } 81 }
73 82
74 } //namespace sk_app 83 } //namespace sk_app
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698