| 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 // |
| 151 // TODO: Once Vulkan supports legacy mip-mapping, we can promote this to GrC
aps. Right now, |
| 152 // Vulkan has most of the functionality, but not the mip-mapping part that's
being tested here. |
| 153 GrGLGpu* glGpu = static_cast<GrGLGpu*>(context->getGpu()); |
| 154 if (glGpu->glCaps().srgbDecodeDisableSupport()) { |
| 155 read_and_check_pixels(reporter, l32RenderTargetContext->asTexture().get(
), expectedLinear, |
| 156 error, "re-render as linear"); |
| 157 } |
| 147 | 158 |
| 148 // 3) Go back to sRGB | 159 // 3) Go back to sRGB |
| 149 paint.setGammaCorrect(true); | 160 paint.setGammaCorrect(true); |
| 150 s32RenderTargetContext->drawRect(noClip, paint, SkMatrix::I(), rect); | 161 s32RenderTargetContext->drawRect(noClip, paint, SkMatrix::I(), rect); |
| 151 read_and_check_pixels(reporter, s32RenderTargetContext->asTexture().get(), e
xpectedSRGB, error, | 162 read_and_check_pixels(reporter, s32RenderTargetContext->asTexture().get(), e
xpectedSRGB, error, |
| 152 "re-render as sRGB"); | 163 "re-render as sRGB"); |
| 153 } | 164 } |
| 154 #endif | 165 #endif |
| OLD | NEW |