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

Unified 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: Better merge 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/viewer/sk_app/WindowContext.h ('k') | tools/viewer/sk_app/android/RasterWindowContext_android.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/viewer/sk_app/WindowContext.cpp
diff --git a/tools/viewer/sk_app/WindowContext.cpp b/tools/viewer/sk_app/WindowContext.cpp
index ecac2cc0047b44ab2d189dbd4e223148ff3cba40..ba04e7eace9837bd267a6f220346bfaba6d8c74c 100755
--- a/tools/viewer/sk_app/WindowContext.cpp
+++ b/tools/viewer/sk_app/WindowContext.cpp
@@ -21,24 +21,41 @@
namespace sk_app {
+sk_sp<SkSurface> WindowContext::createOffscreenSurface(bool forceSRGB) {
+ return createSurface(nullptr, 0, true, forceSRGB);
+}
+
sk_sp<SkSurface> WindowContext::createRenderSurface(sk_sp<GrRenderTarget> rt, int colorBits) {
+ return createSurface(rt, colorBits, false, false);
+}
+
+sk_sp<SkSurface> WindowContext::createSurface(
+ sk_sp<GrRenderTarget> rt, int colorBits, bool offscreen, bool forceSRGB) {
auto flags = (fSurfaceProps.flags() & ~SkSurfaceProps::kGammaCorrect_Flag) |
- (GrPixelConfigIsSRGB(fPixelConfig) ? SkSurfaceProps::kGammaCorrect_Flag : 0);
+ (GrPixelConfigIsSRGB(fPixelConfig) || forceSRGB ?
+ 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.
//
// If we're rendering raster data or using a deep (10-bit or higher) surface, we probably
// need an off-screen surface. 10-bit, in particular, has strange gamma behavior.
- SkImageInfo info = SkImageInfo::Make(fWidth, fHeight,
- fDisplayParams.fColorType,
- kUnknown_SkAlphaType,
- fDisplayParams.fColorSpace);
- return SkSurface::MakeRenderTarget(fContext, SkBudgeted::kNo, info,
- fDisplayParams.fMSAASampleCount, &props);
+ SkImageInfo info = SkImageInfo::Make(
+ fWidth, fHeight,
+ fDisplayParams.fColorType,
+ kPremul_SkAlphaType,
+ forceSRGB ? SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)
+ : fDisplayParams.fColorSpace
+ );
+ 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);
}
« no previous file with comments | « tools/viewer/sk_app/WindowContext.h ('k') | tools/viewer/sk_app/android/RasterWindowContext_android.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698