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