OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkAutoPixmapStorage.h" | 8 #include "SkAutoPixmapStorage.h" |
9 #include "GrCaps.h" | 9 #include "GrCaps.h" |
10 #include "GrContext.h" | 10 #include "GrContext.h" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 return nullptr; | 238 return nullptr; |
239 } | 239 } |
240 | 240 |
241 const int width = yuvSizes[0].fWidth; | 241 const int width = yuvSizes[0].fWidth; |
242 const int height = yuvSizes[0].fHeight; | 242 const int height = yuvSizes[0].fHeight; |
243 | 243 |
244 // Needs to be a render target in order to draw to it for the yuv->rgb conve
rsion. | 244 // Needs to be a render target in order to draw to it for the yuv->rgb conve
rsion. |
245 sk_sp<GrDrawContext> drawContext(ctx->newDrawContext(SkBackingFit::kExact, | 245 sk_sp<GrDrawContext> drawContext(ctx->newDrawContext(SkBackingFit::kExact, |
246 width, height, | 246 width, height, |
247 kRGBA_8888_GrPixelConfi
g, | 247 kRGBA_8888_GrPixelConfi
g, |
| 248 std::move(imageColorSpa
ce), |
248 0, | 249 0, |
249 origin)); | 250 origin)); |
250 if (!drawContext) { | 251 if (!drawContext) { |
251 return nullptr; | 252 return nullptr; |
252 } | 253 } |
253 | 254 |
254 GrPaint paint; | 255 GrPaint paint; |
255 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 256 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
256 paint.addColorFragmentProcessor( | 257 paint.addColorFragmentProcessor( |
257 GrYUVEffect::MakeYUVToRGB(yTex.get(), uTex.get(), vTex.get(), yuvSizes,
colorSpace, nv12)); | 258 GrYUVEffect::MakeYUVToRGB(yTex.get(), uTex.get(), vTex.get(), yuvSizes,
colorSpace, nv12)); |
258 | 259 |
259 const SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(heigh
t)); | 260 const SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(heigh
t)); |
260 | 261 |
261 drawContext->drawRect(GrNoClip(), paint, SkMatrix::I(), rect); | 262 drawContext->drawRect(GrNoClip(), paint, SkMatrix::I(), rect); |
262 ctx->flushSurfaceWrites(drawContext->accessRenderTarget()); | 263 ctx->flushSurfaceWrites(drawContext->accessRenderTarget()); |
263 return sk_make_sp<SkImage_Gpu>(width, height, kNeedNewImageUniqueID, | 264 return sk_make_sp<SkImage_Gpu>(width, height, kNeedNewImageUniqueID, |
264 kOpaque_SkAlphaType, drawContext->asTexture()
.get(), | 265 kOpaque_SkAlphaType, drawContext->asTexture()
.get(), |
265 std::move(imageColorSpace), budgeted); | 266 sk_ref_sp(drawContext->getColorSpace()), budg
eted); |
266 } | 267 } |
267 | 268 |
268 sk_sp<SkImage> SkImage::MakeFromYUVTexturesCopy(GrContext* ctx, SkYUVColorSpace
colorSpace, | 269 sk_sp<SkImage> SkImage::MakeFromYUVTexturesCopy(GrContext* ctx, SkYUVColorSpace
colorSpace, |
269 const GrBackendObject yuvTexture
Handles[3], | 270 const GrBackendObject yuvTexture
Handles[3], |
270 const SkISize yuvSizes[3], GrSur
faceOrigin origin, | 271 const SkISize yuvSizes[3], GrSur
faceOrigin origin, |
271 sk_sp<SkColorSpace> imageColorSp
ace) { | 272 sk_sp<SkColorSpace> imageColorSp
ace) { |
272 return make_from_yuv_textures_copy(ctx, colorSpace, false, yuvTextureHandles
, yuvSizes, origin, | 273 return make_from_yuv_textures_copy(ctx, colorSpace, false, yuvTextureHandles
, yuvSizes, origin, |
273 std::move(imageColorSpace)); | 274 std::move(imageColorSpace)); |
274 } | 275 } |
275 | 276 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 return nullptr; | 545 return nullptr; |
545 } | 546 } |
546 SkAutoTUnref<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, m
ipLevelCount)); | 547 SkAutoTUnref<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, m
ipLevelCount)); |
547 if (!texture) { | 548 if (!texture) { |
548 return nullptr; | 549 return nullptr; |
549 } | 550 } |
550 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew
ImageUniqueID, | 551 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew
ImageUniqueID, |
551 info.alphaType(), texture, sk_ref_sp(info.col
orSpace()), | 552 info.alphaType(), texture, sk_ref_sp(info.col
orSpace()), |
552 budgeted); | 553 budgeted); |
553 } | 554 } |
OLD | NEW |