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

Side by Side Diff: tests/SRGBMipMapTest.cpp

Issue 2546783005: Revert of Enable sRGB on iOS, make sRGB decode support optional (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « src/gpu/gl/GrGLGpu.cpp ('k') | tools/flags/SkCommonFlagsConfig.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
14 #include "SkCanvas.h" 13 #include "SkCanvas.h"
15 #include "SkSurface.h" 14 #include "SkSurface.h"
16 15
17 // using anonymous namespace because these functions are used as template params . 16 // using anonymous namespace because these functions are used as template params .
18 namespace { 17 namespace {
19 /** convert 0..1 srgb value to 0..1 linear */ 18 /** convert 0..1 srgb value to 0..1 linear */
20 float srgb_to_linear(float srgb) { 19 float srgb_to_linear(float srgb) {
21 if (srgb <= 0.04045f) { 20 if (srgb <= 0.04045f) {
22 return srgb / 12.92f; 21 return srgb / 12.92f;
23 } else { 22 } else {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 135
137 // 1) Draw texture to S32 surface (should generate/use sRGB mips) 136 // 1) Draw texture to S32 surface (should generate/use sRGB mips)
138 paint.setGammaCorrect(true); 137 paint.setGammaCorrect(true);
139 s32RenderTargetContext->drawRect(noClip, paint, SkMatrix::I(), rect); 138 s32RenderTargetContext->drawRect(noClip, paint, SkMatrix::I(), rect);
140 read_and_check_pixels(reporter, s32RenderTargetContext->asTexture().get(), e xpectedSRGB, error, 139 read_and_check_pixels(reporter, s32RenderTargetContext->asTexture().get(), e xpectedSRGB, error,
141 "first render of sRGB"); 140 "first render of sRGB");
142 141
143 // 2) Draw texture to L32 surface (should generate/use linear mips) 142 // 2) Draw texture to L32 surface (should generate/use linear mips)
144 paint.setGammaCorrect(false); 143 paint.setGammaCorrect(false);
145 l32RenderTargetContext->drawRect(noClip, paint, SkMatrix::I(), rect); 144 l32RenderTargetContext->drawRect(noClip, paint, SkMatrix::I(), rect);
146 145 read_and_check_pixels(reporter, l32RenderTargetContext->asTexture().get(), e xpectedLinear,
147 // Right now, this test only runs on GL (because Vulkan doesn't support lega cy mip-mapping 146 error, "re-render as linear");
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 }
158 147
159 // 3) Go back to sRGB 148 // 3) Go back to sRGB
160 paint.setGammaCorrect(true); 149 paint.setGammaCorrect(true);
161 s32RenderTargetContext->drawRect(noClip, paint, SkMatrix::I(), rect); 150 s32RenderTargetContext->drawRect(noClip, paint, SkMatrix::I(), rect);
162 read_and_check_pixels(reporter, s32RenderTargetContext->asTexture().get(), e xpectedSRGB, error, 151 read_and_check_pixels(reporter, s32RenderTargetContext->asTexture().get(), e xpectedSRGB, error,
163 "re-render as sRGB"); 152 "re-render as sRGB");
164 } 153 }
165 #endif 154 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLGpu.cpp ('k') | tools/flags/SkCommonFlagsConfig.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698