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