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