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" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 desc.fWidth = texS; | 116 desc.fWidth = texS; |
117 desc.fHeight = texS; | 117 desc.fHeight = texS; |
118 | 118 |
119 GrTextureProvider* texProvider = context->textureProvider(); | 119 GrTextureProvider* texProvider = context->textureProvider(); |
120 SkAutoTUnref<GrTexture> texture(texProvider->createTexture(desc, SkBudgeted:
:kNo, texData, 0)); | 120 SkAutoTUnref<GrTexture> texture(texProvider->createTexture(desc, SkBudgeted:
:kNo, texData, 0)); |
121 | 121 |
122 // Create two draw contexts (L32 and S32) | 122 // Create two draw contexts (L32 and S32) |
123 SkSurfaceProps l32Props(SkSurfaceProps::kLegacyFontHost_InitType); | 123 SkSurfaceProps l32Props(SkSurfaceProps::kLegacyFontHost_InitType); |
124 SkSurfaceProps s32Props(SkSurfaceProps::kGammaCorrect_Flag, | 124 SkSurfaceProps s32Props(SkSurfaceProps::kGammaCorrect_Flag, |
125 SkSurfaceProps::kLegacyFontHost_InitType); | 125 SkSurfaceProps::kLegacyFontHost_InitType); |
| 126 sk_sp<SkColorSpace> srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kS
RGB_Named); |
126 sk_sp<GrDrawContext> l32DrawContext = context->newDrawContext(SkBackingFit::
kExact, rtS, rtS, | 127 sk_sp<GrDrawContext> l32DrawContext = context->newDrawContext(SkBackingFit::
kExact, rtS, rtS, |
127 kSkia8888_GrPi
xelConfig, 0, | 128 kSkia8888_GrPi
xelConfig, |
| 129 nullptr, |
| 130 0, |
128 kDefault_GrSur
faceOrigin, | 131 kDefault_GrSur
faceOrigin, |
129 &l32Props); | 132 &l32Props); |
130 sk_sp<GrDrawContext> s32DrawContext = context->newDrawContext(SkBackingFit::
kExact, rtS, rtS, | 133 sk_sp<GrDrawContext> s32DrawContext = context->newDrawContext(SkBackingFit::
kExact, rtS, rtS, |
131 kSkiaGamma8888
_GrPixelConfig, 0, | 134 kSkiaGamma8888
_GrPixelConfig, |
| 135 std::move(srgb
ColorSpace), |
| 136 0, |
132 kDefault_GrSur
faceOrigin, | 137 kDefault_GrSur
faceOrigin, |
133 &s32Props); | 138 &s32Props); |
134 | 139 |
135 SkRect rect = SkRect::MakeWH(SkIntToScalar(rtS), SkIntToScalar(rtS)); | 140 SkRect rect = SkRect::MakeWH(SkIntToScalar(rtS), SkIntToScalar(rtS)); |
136 GrNoClip noClip; | 141 GrNoClip noClip; |
137 GrPaint paint; | 142 GrPaint paint; |
138 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 143 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
139 GrTextureParams mipMapParams(SkShader::kRepeat_TileMode, GrTextureParams::kM
ipMap_FilterMode); | 144 GrTextureParams mipMapParams(SkShader::kRepeat_TileMode, GrTextureParams::kM
ipMap_FilterMode); |
140 paint.addColorTextureProcessor(texture, nullptr, SkMatrix::MakeScale(0.5f),
mipMapParams); | 145 paint.addColorTextureProcessor(texture, nullptr, SkMatrix::MakeScale(0.5f),
mipMapParams); |
141 | 146 |
142 // 1) Draw texture to S32 surface (should generate/use sRGB mips) | 147 // 1) Draw texture to S32 surface (should generate/use sRGB mips) |
143 paint.setGammaCorrect(true); | 148 paint.setGammaCorrect(true); |
144 s32DrawContext->drawRect(noClip, paint, SkMatrix::I(), rect); | 149 s32DrawContext->drawRect(noClip, paint, SkMatrix::I(), rect); |
145 read_and_check_pixels(reporter, s32DrawContext->asTexture().get(), expectedS
RGB, error, | 150 read_and_check_pixels(reporter, s32DrawContext->asTexture().get(), expectedS
RGB, error, |
146 "first render of sRGB"); | 151 "first render of sRGB"); |
147 | 152 |
148 // 2) Draw texture to L32 surface (should generate/use linear mips) | 153 // 2) Draw texture to L32 surface (should generate/use linear mips) |
149 paint.setGammaCorrect(false); | 154 paint.setGammaCorrect(false); |
150 l32DrawContext->drawRect(noClip, paint, SkMatrix::I(), rect); | 155 l32DrawContext->drawRect(noClip, paint, SkMatrix::I(), rect); |
151 read_and_check_pixels(reporter, l32DrawContext->asTexture().get(), expectedL
inear, error, | 156 read_and_check_pixels(reporter, l32DrawContext->asTexture().get(), expectedL
inear, error, |
152 "re-render as linear"); | 157 "re-render as linear"); |
153 | 158 |
154 // 3) Go back to sRGB | 159 // 3) Go back to sRGB |
155 paint.setGammaCorrect(true); | 160 paint.setGammaCorrect(true); |
156 s32DrawContext->drawRect(noClip, paint, SkMatrix::I(), rect); | 161 s32DrawContext->drawRect(noClip, paint, SkMatrix::I(), rect); |
157 read_and_check_pixels(reporter, s32DrawContext->asTexture().get(), expectedS
RGB, error, | 162 read_and_check_pixels(reporter, s32DrawContext->asTexture().get(), expectedS
RGB, error, |
158 "re-render as sRGB"); | 163 "re-render as sRGB"); |
159 } | 164 } |
160 #endif | 165 #endif |
OLD | NEW |