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 "GrXferProcessor.h" | 10 #include "GrXferProcessor.h" |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 SkYUVPlanesCache::Add(pixelRef->getGenerationID(), cachedData, &yuvI
nfo); | 358 SkYUVPlanesCache::Add(pixelRef->getGenerationID(), cachedData, &yuvI
nfo); |
359 } | 359 } |
360 } | 360 } |
361 | 361 |
362 GrSurfaceDesc yuvDesc; | 362 GrSurfaceDesc yuvDesc; |
363 yuvDesc.fConfig = kAlpha_8_GrPixelConfig; | 363 yuvDesc.fConfig = kAlpha_8_GrPixelConfig; |
364 SkAutoTUnref<GrTexture> yuvTextures[3]; | 364 SkAutoTUnref<GrTexture> yuvTextures[3]; |
365 for (int i = 0; i < 3; ++i) { | 365 for (int i = 0; i < 3; ++i) { |
366 yuvDesc.fWidth = yuvInfo.fSize[i].fWidth; | 366 yuvDesc.fWidth = yuvInfo.fSize[i].fWidth; |
367 yuvDesc.fHeight = yuvInfo.fSize[i].fHeight; | 367 yuvDesc.fHeight = yuvInfo.fSize[i].fHeight; |
368 yuvTextures[i].reset( | 368 bool needsExactTexture = |
369 ctx->refScratchTexture(yuvDesc, GrContext::kApprox_ScratchTexMatch))
; | 369 (yuvDesc.fWidth != yuvInfo.fSize[0].fWidth) || |
| 370 (yuvDesc.fHeight != yuvInfo.fSize[0].fHeight); |
| 371 yuvTextures[i].reset(ctx->refScratchTexture(yuvDesc, |
| 372 needsExactTexture ? GrContext::kExact_ScratchTexMatch : |
| 373 GrContext::kApprox_ScratchTexMatch)); |
370 if (!yuvTextures[i] || | 374 if (!yuvTextures[i] || |
371 !yuvTextures[i]->writePixels(0, 0, yuvDesc.fWidth, yuvDesc.fHeight, | 375 !yuvTextures[i]->writePixels(0, 0, yuvDesc.fWidth, yuvDesc.fHeight, |
372 yuvDesc.fConfig, planes[i], yuvInfo.fRo
wBytes[i])) { | 376 yuvDesc.fConfig, planes[i], yuvInfo.fRo
wBytes[i])) { |
373 return NULL; | 377 return NULL; |
374 } | 378 } |
375 } | 379 } |
376 | 380 |
377 GrSurfaceDesc rtDesc = desc; | 381 GrSurfaceDesc rtDesc = desc; |
378 rtDesc.fFlags = rtDesc.fFlags | kRenderTarget_GrSurfaceFlag; | 382 rtDesc.fFlags = rtDesc.fFlags | kRenderTarget_GrSurfaceFlag; |
379 | 383 |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 if (shader->asFragmentProcessor(context, skPaint, viewM, NULL, &paintCol
or, &fp) && fp) { | 720 if (shader->asFragmentProcessor(context, skPaint, viewM, NULL, &paintCol
or, &fp) && fp) { |
717 grPaint->addColorProcessor(fp)->unref(); | 721 grPaint->addColorProcessor(fp)->unref(); |
718 constantColor = false; | 722 constantColor = false; |
719 } | 723 } |
720 } | 724 } |
721 | 725 |
722 // The grcolor is automatically set when calling asFragmentProcessor. | 726 // The grcolor is automatically set when calling asFragmentProcessor. |
723 // If the shader can be seen as an effect it returns true and adds its effec
t to the grpaint. | 727 // If the shader can be seen as an effect it returns true and adds its effec
t to the grpaint. |
724 SkPaint2GrPaintNoShader(context, rt, skPaint, paintColor, constantColor, grP
aint); | 728 SkPaint2GrPaintNoShader(context, rt, skPaint, paintColor, constantColor, grP
aint); |
725 } | 729 } |
OLD | NEW |