| 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 SkAutoTUnref<const GrFragmentProcessor> yuvToRgbProcessor( | 124 sk_sp<GrFragmentProcessor> yuvToRgbProcessor(GrYUVEffect::MakeYUVToRGB(yuvTe
xtures[0], |
| 125 GrYUVEffect::CreateYUVToRGB(yuvTextures[
0], | 125 yuvTe
xtures[1], |
| 126 yuvTextures[
1], | 126 yuvTe
xtures[2], |
| 127 yuvTextures[
2], | 127 yuvIn
fo.fSizeInfo.fSizes, |
| 128 yuvInfo.fSiz
eInfo.fSizes, | 128 yuvIn
fo.fColorSpace)); |
| 129 yuvInfo.fCol
orSpace)); | 129 paint.addColorFragmentProcessor(std::move(yuvToRgbProcessor)); |
| 130 paint.addColorFragmentProcessor(yuvToRgbProcessor); | |
| 131 | 130 |
| 132 // If we're decoding an sRGB image, the result of our linear math on the YUV
planes is already | 131 // If we're decoding an sRGB image, the result of our linear math on the YUV
planes is already |
| 133 // in sRGB. (The encoding is just math on bytes, with no concept of color sp
aces.) So, we need | 132 // in sRGB. (The encoding is just math on bytes, with no concept of color sp
aces.) So, we need |
| 134 // to output the results of that math directly to the buffer that we will th
en consider sRGB. | 133 // to output the results of that math directly to the buffer that we will th
en consider sRGB. |
| 135 // If we have sRGB write control, we can just tell the HW not to do the Line
ar -> sRGB step. | 134 // If we have sRGB write control, we can just tell the HW not to do the Line
ar -> sRGB step. |
| 136 // Otherwise, we do our shader math to go from YUV -> sRGB, manually convert
sRGB -> Linear, | 135 // Otherwise, we do our shader math to go from YUV -> sRGB, manually convert
sRGB -> Linear, |
| 137 // then let the HW convert Linear -> sRGB. | 136 // then let the HW convert Linear -> sRGB. |
| 138 if (GrPixelConfigIsSRGB(desc.fConfig)) { | 137 if (GrPixelConfigIsSRGB(desc.fConfig)) { |
| 139 if (ctx->caps()->srgbWriteControl()) { | 138 if (ctx->caps()->srgbWriteControl()) { |
| 140 paint.setDisableOutputConversionToSRGB(true); | 139 paint.setDisableOutputConversionToSRGB(true); |
| 141 } else { | 140 } else { |
| 142 paint.addColorFragmentProcessor(GrGammaEffect::Create(2.2f))->unref(
); | 141 paint.addColorFragmentProcessor(GrGammaEffect::Make(2.2f)); |
| 143 } | 142 } |
| 144 } | 143 } |
| 145 | 144 |
| 146 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 145 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
| 147 const SkRect r = SkRect::MakeIWH(yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY]
.fWidth, | 146 const SkRect r = SkRect::MakeIWH(yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY]
.fWidth, |
| 148 yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight); | 147 yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight); |
| 149 | 148 |
| 150 drawContext->drawRect(GrNoClip(), paint, SkMatrix::I(), r); | 149 drawContext->drawRect(GrNoClip(), paint, SkMatrix::I(), r); |
| 151 | 150 |
| 152 return drawContext->asTexture(); | 151 return drawContext->asTexture(); |
| 153 } | 152 } |
| OLD | NEW |