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