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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } else { | 106 } else { |
107 yuvTextures[i].reset(ctx->textureProvider()->createApproxTexture(yuv
Desc)); | 107 yuvTextures[i].reset(ctx->textureProvider()->createApproxTexture(yuv
Desc)); |
108 } | 108 } |
109 if (!yuvTextures[i] || | 109 if (!yuvTextures[i] || |
110 !yuvTextures[i]->writePixels(0, 0, yuvDesc.fWidth, yuvDesc.fHeight,
yuvDesc.fConfig, | 110 !yuvTextures[i]->writePixels(0, 0, yuvDesc.fWidth, yuvDesc.fHeight,
yuvDesc.fConfig, |
111 planes[i], yuvInfo.fSizeInfo.fWidthByte
s[i])) { | 111 planes[i], yuvInfo.fSizeInfo.fWidthByte
s[i])) { |
112 return nullptr; | 112 return nullptr; |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
| 116 // We never want to perform color-space conversion during the decode |
116 sk_sp<GrDrawContext> drawContext(ctx->newDrawContext(SkBackingFit::kExact, | 117 sk_sp<GrDrawContext> drawContext(ctx->newDrawContext(SkBackingFit::kExact, |
117 desc.fWidth, desc.fHeig
ht, | 118 desc.fWidth, desc.fHeig
ht, |
118 desc.fConfig, desc.fSam
pleCnt)); | 119 desc.fConfig, nullptr, |
| 120 desc.fSampleCnt)); |
119 if (!drawContext) { | 121 if (!drawContext) { |
120 return nullptr; | 122 return nullptr; |
121 } | 123 } |
122 | 124 |
123 GrPaint paint; | 125 GrPaint paint; |
124 sk_sp<GrFragmentProcessor> yuvToRgbProcessor( | 126 sk_sp<GrFragmentProcessor> yuvToRgbProcessor( |
125 GrYUVEffect::MakeYUVToRGB(yuvTextures[0], yuvTextures[1], yuvTextures[2]
, | 127 GrYUVEffect::MakeYUVToRGB(yuvTextures[0], yuvTextures[1], yuvTextures[2]
, |
126 yuvInfo.fSizeInfo.fSizes, yuvInfo.fColorSpace,
false)); | 128 yuvInfo.fSizeInfo.fSizes, yuvInfo.fColorSpace,
false)); |
127 paint.addColorFragmentProcessor(std::move(yuvToRgbProcessor)); | 129 paint.addColorFragmentProcessor(std::move(yuvToRgbProcessor)); |
128 | 130 |
(...skipping 12 matching lines...) Expand all Loading... |
141 } | 143 } |
142 | 144 |
143 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 145 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
144 const SkRect r = SkRect::MakeIWH(yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY]
.fWidth, | 146 const SkRect r = SkRect::MakeIWH(yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY]
.fWidth, |
145 yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight); | 147 yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight); |
146 | 148 |
147 drawContext->drawRect(GrNoClip(), paint, SkMatrix::I(), r); | 149 drawContext->drawRect(GrNoClip(), paint, SkMatrix::I(), r); |
148 | 150 |
149 return drawContext->asTexture(); | 151 return drawContext->asTexture(); |
150 } | 152 } |
OLD | NEW |