OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Test.h" | 8 #include "Test.h" |
9 #if SK_SUPPORT_GPU | 9 #if SK_SUPPORT_GPU |
10 #include "GrCaps.h" | 10 #include "GrCaps.h" |
11 #include "GrContext.h" | 11 #include "GrContext.h" |
12 #include "GrRenderTargetContext.h" | 12 #include "GrRenderTargetContext.h" |
13 #include "gl/GrGLGpu.h" | |
13 #include "SkCanvas.h" | 14 #include "SkCanvas.h" |
14 #include "SkSurface.h" | 15 #include "SkSurface.h" |
15 | 16 |
16 // using anonymous namespace because these functions are used as template params . | 17 // using anonymous namespace because these functions are used as template params . |
17 namespace { | 18 namespace { |
18 /** convert 0..1 srgb value to 0..1 linear */ | 19 /** convert 0..1 srgb value to 0..1 linear */ |
19 float srgb_to_linear(float srgb) { | 20 float srgb_to_linear(float srgb) { |
20 if (srgb <= 0.04045f) { | 21 if (srgb <= 0.04045f) { |
21 return srgb / 12.92f; | 22 return srgb / 12.92f; |
22 } else { | 23 } else { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 | 136 |
136 // 1) Draw texture to S32 surface (should generate/use sRGB mips) | 137 // 1) Draw texture to S32 surface (should generate/use sRGB mips) |
137 paint.setGammaCorrect(true); | 138 paint.setGammaCorrect(true); |
138 s32RenderTargetContext->drawRect(noClip, paint, SkMatrix::I(), rect); | 139 s32RenderTargetContext->drawRect(noClip, paint, SkMatrix::I(), rect); |
139 read_and_check_pixels(reporter, s32RenderTargetContext->asTexture().get(), e xpectedSRGB, error, | 140 read_and_check_pixels(reporter, s32RenderTargetContext->asTexture().get(), e xpectedSRGB, error, |
140 "first render of sRGB"); | 141 "first render of sRGB"); |
141 | 142 |
142 // 2) Draw texture to L32 surface (should generate/use linear mips) | 143 // 2) Draw texture to L32 surface (should generate/use linear mips) |
143 paint.setGammaCorrect(false); | 144 paint.setGammaCorrect(false); |
144 l32RenderTargetContext->drawRect(noClip, paint, SkMatrix::I(), rect); | 145 l32RenderTargetContext->drawRect(noClip, paint, SkMatrix::I(), rect); |
145 read_and_check_pixels(reporter, l32RenderTargetContext->asTexture().get(), e xpectedLinear, | 146 |
146 error, "re-render as linear"); | 147 // Right now, this test only runs on GL (because Vulkan doesn't support lega cy mip-mapping |
148 // skbug.com/5048). On GL, we may not have sRGB decode support. In that case , rendering sRGB | |
149 // textures to a legacy surface produces nonsense, so this part of the test is meaningless. | |
150 GrGLGpu* glGpu = static_cast<GrGLGpu*>(context->getGpu()); | |
151 if (glGpu->glCaps().srgbDecodeSupport()) { | |
bsalomon
2016/11/30 17:00:21
Should we have this on GrCaps rather than GrGLCaps
| |
152 read_and_check_pixels(reporter, l32RenderTargetContext->asTexture().get( ), expectedLinear, | |
153 error, "re-render as linear"); | |
154 } | |
147 | 155 |
148 // 3) Go back to sRGB | 156 // 3) Go back to sRGB |
149 paint.setGammaCorrect(true); | 157 paint.setGammaCorrect(true); |
150 s32RenderTargetContext->drawRect(noClip, paint, SkMatrix::I(), rect); | 158 s32RenderTargetContext->drawRect(noClip, paint, SkMatrix::I(), rect); |
151 read_and_check_pixels(reporter, s32RenderTargetContext->asTexture().get(), e xpectedSRGB, error, | 159 read_and_check_pixels(reporter, s32RenderTargetContext->asTexture().get(), e xpectedSRGB, error, |
152 "re-render as sRGB"); | 160 "re-render as sRGB"); |
153 } | 161 } |
154 #endif | 162 #endif |
OLD | NEW |