OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrContext.h" | 8 #include "GrContext.h" |
9 #include "GrDrawContext.h" | 9 #include "GrDrawContext.h" |
10 #include "GrYUVProvider.h" | 10 #include "GrYUVProvider.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 114 } |
115 | 115 |
116 sk_sp<GrDrawContext> drawContext(ctx->newDrawContext(SkBackingFit::kExact, | 116 sk_sp<GrDrawContext> drawContext(ctx->newDrawContext(SkBackingFit::kExact, |
117 desc.fWidth, desc.fHeig
ht, | 117 desc.fWidth, desc.fHeig
ht, |
118 desc.fConfig, desc.fSam
pleCnt)); | 118 desc.fConfig, desc.fSam
pleCnt)); |
119 if (!drawContext) { | 119 if (!drawContext) { |
120 return nullptr; | 120 return nullptr; |
121 } | 121 } |
122 | 122 |
123 GrPaint paint; | 123 GrPaint paint; |
124 sk_sp<GrFragmentProcessor> yuvToRgbProcessor(GrYUVEffect::MakeYUVToRGB(yuvTe
xtures[0], | 124 sk_sp<GrFragmentProcessor> yuvToRgbProcessor( |
125 yuvTe
xtures[1], | 125 GrYUVEffect::MakeYUVToRGB(yuvTextures[0], yuvTextures[1], yuvTextures[2]
, |
126 yuvTe
xtures[2], | 126 yuvInfo.fSizeInfo.fSizes, yuvInfo.fColorSpace,
false)); |
127 yuvIn
fo.fSizeInfo.fSizes, | |
128 yuvIn
fo.fColorSpace)); | |
129 paint.addColorFragmentProcessor(std::move(yuvToRgbProcessor)); | 127 paint.addColorFragmentProcessor(std::move(yuvToRgbProcessor)); |
130 | 128 |
131 // If we're decoding an sRGB image, the result of our linear math on the YUV
planes is already | 129 // If we're decoding an sRGB image, the result of our linear math on the YUV
planes is already |
132 // in sRGB. (The encoding is just math on bytes, with no concept of color sp
aces.) So, we need | 130 // in sRGB. (The encoding is just math on bytes, with no concept of color sp
aces.) So, we need |
133 // to output the results of that math directly to the buffer that we will th
en consider sRGB. | 131 // to output the results of that math directly to the buffer that we will th
en consider sRGB. |
134 // If we have sRGB write control, we can just tell the HW not to do the Line
ar -> sRGB step. | 132 // If we have sRGB write control, we can just tell the HW not to do the Line
ar -> sRGB step. |
135 // Otherwise, we do our shader math to go from YUV -> sRGB, manually convert
sRGB -> Linear, | 133 // Otherwise, we do our shader math to go from YUV -> sRGB, manually convert
sRGB -> Linear, |
136 // then let the HW convert Linear -> sRGB. | 134 // then let the HW convert Linear -> sRGB. |
137 if (GrPixelConfigIsSRGB(desc.fConfig)) { | 135 if (GrPixelConfigIsSRGB(desc.fConfig)) { |
138 if (ctx->caps()->srgbWriteControl()) { | 136 if (ctx->caps()->srgbWriteControl()) { |
139 paint.setDisableOutputConversionToSRGB(true); | 137 paint.setDisableOutputConversionToSRGB(true); |
140 } else { | 138 } else { |
141 paint.addColorFragmentProcessor(GrGammaEffect::Make(2.2f)); | 139 paint.addColorFragmentProcessor(GrGammaEffect::Make(2.2f)); |
142 } | 140 } |
143 } | 141 } |
144 | 142 |
145 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 143 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
146 const SkRect r = SkRect::MakeIWH(yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY]
.fWidth, | 144 const SkRect r = SkRect::MakeIWH(yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY]
.fWidth, |
147 yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight); | 145 yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight); |
148 | 146 |
149 drawContext->drawRect(GrNoClip(), paint, SkMatrix::I(), r); | 147 drawContext->drawRect(GrNoClip(), paint, SkMatrix::I(), r); |
150 | 148 |
151 return drawContext->asTexture(); | 149 return drawContext->asTexture(); |
152 } | 150 } |
OLD | NEW |