| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 "SkGr.h" | 8 #include "SkGr.h" |
| 9 | 9 |
| 10 #include "GrCaps.h" | 10 #include "GrCaps.h" |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 | 400 |
| 401 GrSurfaceDesc yuvDesc; | 401 GrSurfaceDesc yuvDesc; |
| 402 yuvDesc.fConfig = kAlpha_8_GrPixelConfig; | 402 yuvDesc.fConfig = kAlpha_8_GrPixelConfig; |
| 403 SkAutoTUnref<GrTexture> yuvTextures[3]; | 403 SkAutoTUnref<GrTexture> yuvTextures[3]; |
| 404 for (int i = 0; i < 3; ++i) { | 404 for (int i = 0; i < 3; ++i) { |
| 405 yuvDesc.fWidth = yuvInfo.fSize[i].fWidth; | 405 yuvDesc.fWidth = yuvInfo.fSize[i].fWidth; |
| 406 yuvDesc.fHeight = yuvInfo.fSize[i].fHeight; | 406 yuvDesc.fHeight = yuvInfo.fSize[i].fHeight; |
| 407 bool needsExactTexture = | 407 bool needsExactTexture = |
| 408 (yuvDesc.fWidth != yuvInfo.fSize[0].fWidth) || | 408 (yuvDesc.fWidth != yuvInfo.fSize[0].fWidth) || |
| 409 (yuvDesc.fHeight != yuvInfo.fSize[0].fHeight); | 409 (yuvDesc.fHeight != yuvInfo.fSize[0].fHeight); |
| 410 yuvTextures[i].reset(ctx->textureProvider()->refScratchTexture(yuvDesc, | 410 if (needsExactTexture) { |
| 411 needsExactTexture ? GrTextureProvider::kExact_ScratchTexMatch : | 411 yuvTextures[i].reset(ctx->textureProvider()->createTexture(yuvDesc,
true)); |
| 412 GrTextureProvider::kApprox_ScratchTexMatch)); | 412 } else { |
| 413 yuvTextures[i].reset(ctx->textureProvider()->createApproxTexture(yuv
Desc)); |
| 414 } |
| 413 if (!yuvTextures[i] || | 415 if (!yuvTextures[i] || |
| 414 !yuvTextures[i]->writePixels(0, 0, yuvDesc.fWidth, yuvDesc.fHeight, | 416 !yuvTextures[i]->writePixels(0, 0, yuvDesc.fWidth, yuvDesc.fHeight, |
| 415 yuvDesc.fConfig, planes[i], yuvInfo.fRo
wBytes[i])) { | 417 yuvDesc.fConfig, planes[i], yuvInfo.fRo
wBytes[i])) { |
| 416 return NULL; | 418 return NULL; |
| 417 } | 419 } |
| 418 } | 420 } |
| 419 | 421 |
| 420 GrSurfaceDesc rtDesc = desc; | 422 GrSurfaceDesc rtDesc = desc; |
| 421 rtDesc.fFlags = rtDesc.fFlags | kRenderTarget_GrSurfaceFlag; | 423 rtDesc.fFlags = rtDesc.fFlags | kRenderTarget_GrSurfaceFlag; |
| 422 | 424 |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 } | 828 } |
| 827 return SkImageInfo::Make(w, h, ct, at); | 829 return SkImageInfo::Make(w, h, ct, at); |
| 828 } | 830 } |
| 829 | 831 |
| 830 | 832 |
| 831 void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap
* dst) { | 833 void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap
* dst) { |
| 832 const SkImageInfo info = GrMakeInfoFromTexture(src, w, h, isOpaque); | 834 const SkImageInfo info = GrMakeInfoFromTexture(src, w, h, isOpaque); |
| 833 dst->setInfo(info); | 835 dst->setInfo(info); |
| 834 dst->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, src)))->unref(); | 836 dst->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, src)))->unref(); |
| 835 } | 837 } |
| OLD | NEW |