| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 // If filtering is not desired then we want to ensure all texels in the resa
mpled image are | 236 // If filtering is not desired then we want to ensure all texels in the resa
mpled image are |
| 237 // copies of texels from the original. | 237 // copies of texels from the original. |
| 238 GrTextureParams params(SkShader::kClamp_TileMode, | 238 GrTextureParams params(SkShader::kClamp_TileMode, |
| 239 kBilerp_Stretch == stretch ? GrTextureParams::kBilerp
_FilterMode : | 239 kBilerp_Stretch == stretch ? GrTextureParams::kBilerp
_FilterMode : |
| 240 GrTextureParams::kNone_F
ilterMode); | 240 GrTextureParams::kNone_F
ilterMode); |
| 241 paint.addColorTextureProcessor(inputTexture, SkMatrix::I(), params); | 241 paint.addColorTextureProcessor(inputTexture, SkMatrix::I(), params); |
| 242 | 242 |
| 243 SkRect rect = SkRect::MakeWH(SkIntToScalar(rtDesc.fWidth), SkIntToScalar(rtD
esc.fHeight)); | 243 SkRect rect = SkRect::MakeWH(SkIntToScalar(rtDesc.fWidth), SkIntToScalar(rtD
esc.fHeight)); |
| 244 SkRect localRect = SkRect::MakeWH(1.f, 1.f); | 244 SkRect localRect = SkRect::MakeWH(1.f, 1.f); |
| 245 | 245 |
| 246 context->drawNonAARectToRect(stretched->asRenderTarget(), GrClip::WideOpen()
, paint, | 246 GrContext::AutoClip ac(context, GrContext::AutoClip::kWideOpen_InitialClip); |
| 247 SkMatrix::I(), rect, localRect); | 247 context->drawNonAARectToRect(stretched->asRenderTarget(), paint, SkMatrix::I
(), rect, |
| 248 localRect); |
| 248 | 249 |
| 249 return stretched; | 250 return stretched; |
| 250 } | 251 } |
| 251 | 252 |
| 252 #ifndef SK_IGNORE_ETC1_SUPPORT | 253 #ifndef SK_IGNORE_ETC1_SUPPORT |
| 253 static GrTexture *load_etc1_texture(GrContext* ctx, const GrUniqueKey& optionalK
ey, | 254 static GrTexture *load_etc1_texture(GrContext* ctx, const GrUniqueKey& optionalK
ey, |
| 254 const SkBitmap &bm, GrSurfaceDesc desc) { | 255 const SkBitmap &bm, GrSurfaceDesc desc) { |
| 255 SkAutoTUnref<SkData> data(bm.pixelRef()->refEncodedData()); | 256 SkAutoTUnref<SkData> data(bm.pixelRef()->refEncodedData()); |
| 256 | 257 |
| 257 // Is this even encoded data? | 258 // Is this even encoded data? |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 GrRenderTarget* renderTarget = result->asRenderTarget(); | 385 GrRenderTarget* renderTarget = result->asRenderTarget(); |
| 385 SkASSERT(renderTarget); | 386 SkASSERT(renderTarget); |
| 386 | 387 |
| 387 SkAutoTUnref<GrFragmentProcessor> | 388 SkAutoTUnref<GrFragmentProcessor> |
| 388 yuvToRgbProcessor(GrYUVtoRGBEffect::Create(yuvTextures[0], yuvTextures[1
], yuvTextures[2], | 389 yuvToRgbProcessor(GrYUVtoRGBEffect::Create(yuvTextures[0], yuvTextures[1
], yuvTextures[2], |
| 389 yuvInfo.fSize, yuvInfo.fColor
Space)); | 390 yuvInfo.fSize, yuvInfo.fColor
Space)); |
| 390 GrPaint paint; | 391 GrPaint paint; |
| 391 paint.addColorProcessor(yuvToRgbProcessor); | 392 paint.addColorProcessor(yuvToRgbProcessor); |
| 392 SkRect r = SkRect::MakeWH(SkIntToScalar(yuvInfo.fSize[0].fWidth), | 393 SkRect r = SkRect::MakeWH(SkIntToScalar(yuvInfo.fSize[0].fWidth), |
| 393 SkIntToScalar(yuvInfo.fSize[0].fHeight)); | 394 SkIntToScalar(yuvInfo.fSize[0].fHeight)); |
| 394 | 395 GrContext::AutoClip ac(ctx, GrContext::AutoClip::kWideOpen_InitialClip); |
| 395 ctx->drawRect(renderTarget, GrClip::WideOpen(), paint, SkMatrix::I(), r); | 396 ctx->drawRect(renderTarget, paint, SkMatrix::I(), r); |
| 396 | 397 |
| 397 return result; | 398 return result; |
| 398 } | 399 } |
| 399 | 400 |
| 400 static GrTexture* create_unstretched_bitmap_texture(GrContext* ctx, | 401 static GrTexture* create_unstretched_bitmap_texture(GrContext* ctx, |
| 401 const SkBitmap& origBitmap, | 402 const SkBitmap& origBitmap, |
| 402 const GrUniqueKey& optionalK
ey) { | 403 const GrUniqueKey& optionalK
ey) { |
| 403 SkBitmap tmpBitmap; | 404 SkBitmap tmpBitmap; |
| 404 | 405 |
| 405 const SkBitmap* bitmap = &origBitmap; | 406 const SkBitmap* bitmap = &origBitmap; |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 constantColor, grPaint); | 699 constantColor, grPaint); |
| 699 return; | 700 return; |
| 700 } | 701 } |
| 701 | 702 |
| 702 GrColor paintColor = SkColor2GrColor(skPaint.getColor()); | 703 GrColor paintColor = SkColor2GrColor(skPaint.getColor()); |
| 703 | 704 |
| 704 // Start a new block here in order to preserve our context state after calli
ng | 705 // Start a new block here in order to preserve our context state after calli
ng |
| 705 // asFragmentProcessor(). Since these calls get passed back to the client, w
e don't really | 706 // asFragmentProcessor(). Since these calls get passed back to the client, w
e don't really |
| 706 // want them messing around with the context. | 707 // want them messing around with the context. |
| 707 { | 708 { |
| 709 GrContext::AutoClip ac(context, GrContext::AutoClip::kWideOpen_InitialCl
ip); |
| 710 |
| 708 // Allow the shader to modify paintColor and also create an effect to be
installed as | 711 // Allow the shader to modify paintColor and also create an effect to be
installed as |
| 709 // the first color effect on the GrPaint. | 712 // the first color effect on the GrPaint. |
| 710 GrFragmentProcessor* fp = NULL; | 713 GrFragmentProcessor* fp = NULL; |
| 711 if (shader->asFragmentProcessor(context, skPaint, viewM, NULL, &paintCol
or, &fp) && fp) { | 714 if (shader->asFragmentProcessor(context, skPaint, viewM, NULL, &paintCol
or, &fp) && fp) { |
| 712 grPaint->addColorProcessor(fp)->unref(); | 715 grPaint->addColorProcessor(fp)->unref(); |
| 713 constantColor = false; | 716 constantColor = false; |
| 714 } | 717 } |
| 715 } | 718 } |
| 716 | 719 |
| 717 // The grcolor is automatically set when calling asFragmentProcessor. | 720 // The grcolor is automatically set when calling asFragmentProcessor. |
| 718 // If the shader can be seen as an effect it returns true and adds its effec
t to the grpaint. | 721 // If the shader can be seen as an effect it returns true and adds its effec
t to the grpaint. |
| 719 SkPaint2GrPaintNoShader(context, rt, skPaint, paintColor, constantColor, grP
aint); | 722 SkPaint2GrPaintNoShader(context, rt, skPaint, paintColor, constantColor, grP
aint); |
| 720 } | 723 } |
| OLD | NEW |