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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // We never want to perform color-space conversion during the decode |
117 sk_sp<GrDrawContext> drawContext(ctx->newDrawContext(SkBackingFit::kExact, | 117 sk_sp<GrDrawContext> drawContext(ctx->makeDrawContext(SkBackingFit::kExact, |
118 desc.fWidth, desc.fHeig
ht, | 118 desc.fWidth, desc.fHei
ght, |
119 desc.fConfig, nullptr, | 119 desc.fConfig, nullptr, |
120 desc.fSampleCnt)); | 120 desc.fSampleCnt)); |
121 if (!drawContext) { | 121 if (!drawContext) { |
122 return nullptr; | 122 return nullptr; |
123 } | 123 } |
124 | 124 |
125 GrPaint paint; | 125 GrPaint paint; |
126 sk_sp<GrFragmentProcessor> yuvToRgbProcessor( | 126 sk_sp<GrFragmentProcessor> yuvToRgbProcessor( |
127 GrYUVEffect::MakeYUVToRGB(yuvTextures[0], yuvTextures[1], yuvTextures[2]
, | 127 GrYUVEffect::MakeYUVToRGB(yuvTextures[0], yuvTextures[1], yuvTextures[2]
, |
128 yuvInfo.fSizeInfo.fSizes, yuvInfo.fColorSpace,
false)); | 128 yuvInfo.fSizeInfo.fSizes, yuvInfo.fColorSpace,
false)); |
129 paint.addColorFragmentProcessor(std::move(yuvToRgbProcessor)); | 129 paint.addColorFragmentProcessor(std::move(yuvToRgbProcessor)); |
130 | 130 |
(...skipping 12 matching lines...) Expand all Loading... |
143 } | 143 } |
144 | 144 |
145 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 145 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
146 const SkRect r = SkRect::MakeIWH(yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY]
.fWidth, | 146 const SkRect r = SkRect::MakeIWH(yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY]
.fWidth, |
147 yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight); | 147 yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight); |
148 | 148 |
149 drawContext->drawRect(GrNoClip(), paint, SkMatrix::I(), r); | 149 drawContext->drawRect(GrNoClip(), paint, SkMatrix::I(), r); |
150 | 150 |
151 return drawContext->asTexture(); | 151 return drawContext->asTexture(); |
152 } | 152 } |
OLD | NEW |