| 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 "SkBitmapCache.h" | 8 #include "SkBitmapCache.h" |
| 9 #include "SkImage_Gpu.h" | 9 #include "SkImage_Gpu.h" |
| 10 #include "GrContext.h" | 10 #include "GrContext.h" |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 dstDesc.fConfig = kRGBA_8888_GrPixelConfig; | 243 dstDesc.fConfig = kRGBA_8888_GrPixelConfig; |
| 244 dstDesc.fSampleCnt = 0; | 244 dstDesc.fSampleCnt = 0; |
| 245 | 245 |
| 246 SkAutoTUnref<GrTexture> dst(ctx->textureProvider()->createTexture(dstDesc, t
rue)); | 246 SkAutoTUnref<GrTexture> dst(ctx->textureProvider()->createTexture(dstDesc, t
rue)); |
| 247 if (!dst) { | 247 if (!dst) { |
| 248 return NULL; | 248 return NULL; |
| 249 } | 249 } |
| 250 | 250 |
| 251 GrPaint paint; | 251 GrPaint paint; |
| 252 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 252 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
| 253 paint.addColorFragmentProcessor(GrYUVtoRGBEffect::Create(paint.getProcessorD
ataManager(), | 253 paint.addColorProcessor(GrYUVtoRGBEffect::Create(paint.getProcessorDataManag
er(), yTex, uTex, |
| 254 yTex, uTex, vTex, y
uvSizes, | 254 vTex, yuvSizes, colorSpace)
)->unref(); |
| 255 colorSpace))->unref
(); | |
| 256 | 255 |
| 257 const SkRect rect = SkRect::MakeWH(SkIntToScalar(dstDesc.fWidth), | 256 const SkRect rect = SkRect::MakeWH(SkIntToScalar(dstDesc.fWidth), |
| 258 SkIntToScalar(dstDesc.fHeight)); | 257 SkIntToScalar(dstDesc.fHeight)); |
| 259 GrDrawContext* drawContext = ctx->drawContext(); | 258 GrDrawContext* drawContext = ctx->drawContext(); |
| 260 drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, SkMa
trix::I(), rect); | 259 drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, SkMa
trix::I(), rect); |
| 261 ctx->flushSurfaceWrites(dst); | 260 ctx->flushSurfaceWrites(dst); |
| 262 return SkNEW_ARGS(SkImage_Gpu, (dstDesc.fWidth, dstDesc.fHeight, kNeedNewIma
geUniqueID, | 261 return SkNEW_ARGS(SkImage_Gpu, (dstDesc.fWidth, dstDesc.fHeight, kNeedNewIma
geUniqueID, |
| 263 kOpaque_SkAlphaType, dst, 0, budgeted)); | 262 kOpaque_SkAlphaType, dst, 0, budgeted)); |
| 264 } | 263 } |
| 265 | 264 |
| 266 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 265 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 267 | 266 |
| 268 GrTexture* GrDeepCopyTexture(GrTexture* src, bool budgeted) { | 267 GrTexture* GrDeepCopyTexture(GrTexture* src, bool budgeted) { |
| 269 GrContext* ctx = src->getContext(); | 268 GrContext* ctx = src->getContext(); |
| 270 | 269 |
| 271 GrSurfaceDesc desc = src->desc(); | 270 GrSurfaceDesc desc = src->desc(); |
| 272 GrTexture* dst = ctx->textureProvider()->createTexture(desc, budgeted, NULL,
0); | 271 GrTexture* dst = ctx->textureProvider()->createTexture(desc, budgeted, NULL,
0); |
| 273 if (!dst) { | 272 if (!dst) { |
| 274 return NULL; | 273 return NULL; |
| 275 } | 274 } |
| 276 | 275 |
| 277 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); | 276 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); |
| 278 const SkIPoint dstP = SkIPoint::Make(0, 0); | 277 const SkIPoint dstP = SkIPoint::Make(0, 0); |
| 279 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp); | 278 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp); |
| 280 return dst; | 279 return dst; |
| 281 } | 280 } |
| 282 | 281 |
| OLD | NEW |