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 | 8 |
9 #include "SkGr.h" | 9 #include "SkGr.h" |
10 | 10 |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 bool SkPaintToGrPaintWithXfermode(GrContext* context, | 538 bool SkPaintToGrPaintWithXfermode(GrContext* context, |
539 const SkPaint& skPaint, | 539 const SkPaint& skPaint, |
540 const SkMatrix& viewM, | 540 const SkMatrix& viewM, |
541 SkXfermode::Mode primColorMode, | 541 SkXfermode::Mode primColorMode, |
542 bool primitiveIsSrc, | 542 bool primitiveIsSrc, |
543 GrPaint* grPaint) { | 543 GrPaint* grPaint) { |
544 return skpaint_to_grpaint_impl(context, skPaint, viewM, nullptr, &primColorM
ode, primitiveIsSrc, | 544 return skpaint_to_grpaint_impl(context, skPaint, viewM, nullptr, &primColorM
ode, primitiveIsSrc, |
545 grPaint); | 545 grPaint); |
546 } | 546 } |
547 | 547 |
| 548 bool SkPaintToGrPaintWithTexture(GrContext* context, |
| 549 const SkPaint& paint, |
| 550 const SkMatrix& viewM, |
| 551 const GrFragmentProcessor* fp, |
| 552 bool textureIsAlphaOnly, |
| 553 GrPaint* grPaint) { |
| 554 SkAutoTUnref<const GrFragmentProcessor> shaderFP; |
| 555 if (textureIsAlphaOnly) { |
| 556 if (const SkShader* shader = paint.getShader()) { |
| 557 shaderFP.reset(shader->asFragmentProcessor(context, |
| 558 viewM, |
| 559 nullptr, |
| 560 paint.getFilterQuality())
); |
| 561 if (!shaderFP) { |
| 562 return false; |
| 563 } |
| 564 const GrFragmentProcessor* fpSeries[] = { shaderFP.get(), fp }; |
| 565 shaderFP.reset(GrFragmentProcessor::RunInSeries(fpSeries, 2)); |
| 566 } else { |
| 567 shaderFP.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp
)); |
| 568 } |
| 569 } else { |
| 570 shaderFP.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp)); |
| 571 } |
| 572 |
| 573 return SkPaintToGrPaintReplaceShader(context, paint, shaderFP.get(), grPaint
); |
| 574 } |
| 575 |
548 | 576 |
549 ////////////////////////////////////////////////////////////////////////////////
//////////////// | 577 ////////////////////////////////////////////////////////////////////////////////
//////////////// |
550 | 578 |
551 SkImageInfo GrMakeInfoFromTexture(GrTexture* tex, int w, int h, bool isOpaque) { | 579 SkImageInfo GrMakeInfoFromTexture(GrTexture* tex, int w, int h, bool isOpaque) { |
552 #ifdef SK_DEBUG | 580 #ifdef SK_DEBUG |
553 const GrSurfaceDesc& desc = tex->desc(); | 581 const GrSurfaceDesc& desc = tex->desc(); |
554 SkASSERT(w <= desc.fWidth); | 582 SkASSERT(w <= desc.fWidth); |
555 SkASSERT(h <= desc.fHeight); | 583 SkASSERT(h <= desc.fHeight); |
556 #endif | 584 #endif |
557 const GrPixelConfig config = tex->config(); | 585 const GrPixelConfig config = tex->config(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 SkErrorInternals::SetError( kInvalidPaint_SkError, | 632 SkErrorInternals::SetError( kInvalidPaint_SkError, |
605 "Sorry, I don't understand the filtering
" | 633 "Sorry, I don't understand the filtering
" |
606 "mode you asked for. Falling back to " | 634 "mode you asked for. Falling back to " |
607 "MIPMaps."); | 635 "MIPMaps."); |
608 textureFilterMode = GrTextureParams::kMipMap_FilterMode; | 636 textureFilterMode = GrTextureParams::kMipMap_FilterMode; |
609 break; | 637 break; |
610 | 638 |
611 } | 639 } |
612 return textureFilterMode; | 640 return textureFilterMode; |
613 } | 641 } |
OLD | NEW |