aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode
diff options
context:
space:
mode:
authorGravatar brianosman <brianosman@google.com>2016-04-14 12:39:00 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-14 12:39:00 -0700
commit6b08652abff788a251db82ca2b5f6b359ffe2590 (patch)
treeb8a879ed17887fc61be769611b30f42d46ea8979 /samplecode
parentcbe3c1af987d622ea67ef560d855b41bb14a0ce9 (diff)
Several fixes for fp 16 rendering:
With the GPU backend, allow F16 render targets to be created (along with any other renderable format). We were previously just falling back to 8888. In SampleApp, if the window configuration is F16, don't render directly to the primary surface (which is actually sRGB 8888). Intead, make an off-screen F16 surface, then blit it back to the framebuffer when we're done. In DM, clamp values outside of [0,1]. These were wrapping, producing very incorrect images. (Many filters can trigger out-of-range values due to ringing). BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1890923003 Review URL: https://codereview.chromium.org/1890923003
Diffstat (limited to 'samplecode')
-rw-r--r--samplecode/SampleApp.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index d4cf1cccb9..b7ba6f9580 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -294,7 +294,14 @@ public:
#if SK_SUPPORT_GPU
if (IsGpuDeviceType(dType) && fCurContext) {
SkSurfaceProps props(win->getSurfaceProps());
- return SkSurface::MakeRenderTargetDirect(fCurRenderTarget, &props).release();
+ if (kRGBA_F16_SkColorType == win->info().colorType()) {
+ // Need to make an off-screen F16 surface - the current render target is
+ // (probably) the wrong format.
+ return SkSurface::MakeRenderTarget(fCurContext, SkBudgeted::kNo, win->info(),
+ fMSAASampleCount, &props).release();
+ } else {
+ return SkSurface::MakeRenderTargetDirect(fCurRenderTarget, &props).release();
+ }
}
#endif
return nullptr;
@@ -318,6 +325,16 @@ public:
bm.getPixels(),
bm.rowBytes(),
GrContext::kFlushWrites_PixelOp);
+ } else if (kRGBA_F16_SkColorType == win->info().colorType()) {
+ SkBitmap bm;
+ bm.allocPixels(win->info());
+ canvas->readPixels(&bm, 0, 0);
+ fCurRenderTarget->writePixels(0, 0, bm.width(), bm.height(),
+ SkImageInfo2GrPixelConfig(bm.info(),
+ *fCurContext->caps()),
+ bm.getPixels(),
+ bm.rowBytes(),
+ GrContext::kFlushWrites_PixelOp);
}
}
#endif