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 "SkImage_Gpu.h" | 8 #include "SkImage_Gpu.h" |
9 #include "GrContext.h" | 9 #include "GrContext.h" |
10 #include "GrDrawContext.h" | 10 #include "GrDrawContext.h" |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 return NULL; | 228 return NULL; |
229 } | 229 } |
230 | 230 |
231 GrPaint paint; | 231 GrPaint paint; |
232 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 232 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
233 paint.addColorProcessor(GrYUVtoRGBEffect::Create(yTex, uTex, vTex, yuvSizes, | 233 paint.addColorProcessor(GrYUVtoRGBEffect::Create(yTex, uTex, vTex, yuvSizes, |
234 colorSpace))->unref(); | 234 colorSpace))->unref(); |
235 | 235 |
236 const SkRect rect = SkRect::MakeWH(SkIntToScalar(dstDesc.fWidth), | 236 const SkRect rect = SkRect::MakeWH(SkIntToScalar(dstDesc.fWidth), |
237 SkIntToScalar(dstDesc.fHeight)); | 237 SkIntToScalar(dstDesc.fHeight)); |
238 GrDrawContext* drawContext = ctx->drawContext(); | 238 GrDrawContext* drawContext = ctx->drawContext(dst->asRenderTarget()); |
| 239 // nothing to "use" in this case |
239 drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, SkMa
trix::I(), rect); | 240 drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, SkMa
trix::I(), rect); |
240 ctx->flushSurfaceWrites(dst); | 241 ctx->flushSurfaceWrites(dst); |
241 return SkNEW_ARGS(SkImage_Gpu, (dstDesc.fWidth, dstDesc.fHeight, kOpaque_SkA
lphaType, dst, 0, | 242 return SkNEW_ARGS(SkImage_Gpu, (dstDesc.fWidth, dstDesc.fHeight, kOpaque_SkA
lphaType, dst, 0, |
242 budgeted)); | 243 budgeted)); |
243 } | 244 } |
244 | 245 |
245 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 246 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
246 | 247 |
247 GrTexture* GrDeepCopyTexture(GrTexture* src, bool budgeted) { | 248 GrTexture* GrDeepCopyTexture(GrTexture* src, bool budgeted) { |
248 GrContext* ctx = src->getContext(); | 249 GrContext* ctx = src->getContext(); |
249 | 250 |
250 GrSurfaceDesc desc = src->desc(); | 251 GrSurfaceDesc desc = src->desc(); |
251 // need to be a rendertarget for readpixels to work, instead of kNone_GrSurf
aceFlags | 252 // need to be a rendertarget for readpixels to work, instead of kNone_GrSurf
aceFlags |
252 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 253 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
253 GrTexture* dst = ctx->textureProvider()->createTexture(desc, budgeted, NULL,
0); | 254 GrTexture* dst = ctx->textureProvider()->createTexture(desc, budgeted, NULL,
0); |
254 if (!dst) { | 255 if (!dst) { |
255 return NULL; | 256 return NULL; |
256 } | 257 } |
257 | 258 |
258 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); | 259 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); |
259 const SkIPoint dstP = SkIPoint::Make(0, 0); | 260 const SkIPoint dstP = SkIPoint::Make(0, 0); |
260 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp); | 261 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp); |
261 return dst; | 262 return dst; |
262 } | 263 } |
263 | 264 |
OLD | NEW |