| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 return nullptr; | 246 return nullptr; |
| 247 } | 247 } |
| 248 | 248 |
| 249 const int width = yuvSizes[0].fWidth; | 249 const int width = yuvSizes[0].fWidth; |
| 250 const int height = yuvSizes[0].fHeight; | 250 const int height = yuvSizes[0].fHeight; |
| 251 | 251 |
| 252 // Needs to be a render target in order to draw to it for the yuv->rgb conve
rsion. | 252 // Needs to be a render target in order to draw to it for the yuv->rgb conve
rsion. |
| 253 sk_sp<GrDrawContext> drawContext(ctx->newDrawContext(SkBackingFit::kExact, | 253 sk_sp<GrDrawContext> drawContext(ctx->newDrawContext(SkBackingFit::kExact, |
| 254 width, height, | 254 width, height, |
| 255 kRGBA_8888_GrPixelConfi
g, | 255 kRGBA_8888_GrPixelConfi
g, |
| 256 std::move(imageColorSpa
ce), |
| 256 0, | 257 0, |
| 257 origin)); | 258 origin)); |
| 258 if (!drawContext) { | 259 if (!drawContext) { |
| 259 return nullptr; | 260 return nullptr; |
| 260 } | 261 } |
| 261 | 262 |
| 262 GrPaint paint; | 263 GrPaint paint; |
| 263 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 264 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
| 264 paint.addColorFragmentProcessor( | 265 paint.addColorFragmentProcessor( |
| 265 GrYUVEffect::MakeYUVToRGB(yTex.get(), uTex.get(), vTex.get(), yuvSizes,
colorSpace, nv12)); | 266 GrYUVEffect::MakeYUVToRGB(yTex.get(), uTex.get(), vTex.get(), yuvSizes,
colorSpace, nv12)); |
| 266 | 267 |
| 267 const SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(heigh
t)); | 268 const SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(heigh
t)); |
| 268 | 269 |
| 269 drawContext->drawRect(GrNoClip(), paint, SkMatrix::I(), rect); | 270 drawContext->drawRect(GrNoClip(), paint, SkMatrix::I(), rect); |
| 270 ctx->flushSurfaceWrites(drawContext->accessRenderTarget()); | 271 ctx->flushSurfaceWrites(drawContext->accessRenderTarget()); |
| 271 return sk_make_sp<SkImage_Gpu>(width, height, kNeedNewImageUniqueID, | 272 return sk_make_sp<SkImage_Gpu>(width, height, kNeedNewImageUniqueID, |
| 272 kOpaque_SkAlphaType, drawContext->asTexture()
.get(), | 273 kOpaque_SkAlphaType, drawContext->asTexture()
.get(), |
| 273 std::move(imageColorSpace), budgeted); | 274 sk_ref_sp(drawContext->getColorSpace()), budg
eted); |
| 274 } | 275 } |
| 275 | 276 |
| 276 sk_sp<SkImage> SkImage::MakeFromYUVTexturesCopy(GrContext* ctx, SkYUVColorSpace
colorSpace, | 277 sk_sp<SkImage> SkImage::MakeFromYUVTexturesCopy(GrContext* ctx, SkYUVColorSpace
colorSpace, |
| 277 const GrBackendObject yuvTexture
Handles[3], | 278 const GrBackendObject yuvTexture
Handles[3], |
| 278 const SkISize yuvSizes[3], GrSur
faceOrigin origin, | 279 const SkISize yuvSizes[3], GrSur
faceOrigin origin, |
| 279 sk_sp<SkColorSpace> imageColorSp
ace) { | 280 sk_sp<SkColorSpace> imageColorSp
ace) { |
| 280 return make_from_yuv_textures_copy(ctx, colorSpace, false, yuvTextureHandles
, yuvSizes, origin, | 281 return make_from_yuv_textures_copy(ctx, colorSpace, false, yuvTextureHandles
, yuvSizes, origin, |
| 281 std::move(imageColorSpace)); | 282 std::move(imageColorSpace)); |
| 282 } | 283 } |
| 283 | 284 |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 return nullptr; | 553 return nullptr; |
| 553 } | 554 } |
| 554 SkAutoTUnref<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, m
ipLevelCount)); | 555 SkAutoTUnref<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, m
ipLevelCount)); |
| 555 if (!texture) { | 556 if (!texture) { |
| 556 return nullptr; | 557 return nullptr; |
| 557 } | 558 } |
| 558 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew
ImageUniqueID, | 559 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew
ImageUniqueID, |
| 559 info.alphaType(), texture, sk_ref_sp(info.col
orSpace()), | 560 info.alphaType(), texture, sk_ref_sp(info.col
orSpace()), |
| 560 budgeted); | 561 budgeted); |
| 561 } | 562 } |
| OLD | NEW |