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 #include "SkGrPriv.h" | 10 #include "SkGrPriv.h" |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 shaderFP = GrFragmentProcessor::MulOutputByInputAlpha(fp); | 735 shaderFP = GrFragmentProcessor::MulOutputByInputAlpha(fp); |
736 } | 736 } |
737 | 737 |
738 return SkPaintToGrPaintReplaceShader(context, paint, std::move(shaderFP), al
lowSRGBInputs, | 738 return SkPaintToGrPaintReplaceShader(context, paint, std::move(shaderFP), al
lowSRGBInputs, |
739 grPaint); | 739 grPaint); |
740 } | 740 } |
741 | 741 |
742 | 742 |
743 ////////////////////////////////////////////////////////////////////////////////
//////////////// | 743 ////////////////////////////////////////////////////////////////////////////////
//////////////// |
744 | 744 |
745 SkImageInfo GrMakeInfoFromTexture(GrTexture* tex, int w, int h, bool isOpaque) { | 745 SkImageInfo GrMakeInfoFromTexture(GrTexture* tex, int w, int h, bool isOpaque, |
| 746 sk_sp<SkColorSpace> colorSpace) { |
746 #ifdef SK_DEBUG | 747 #ifdef SK_DEBUG |
747 const GrSurfaceDesc& desc = tex->desc(); | 748 const GrSurfaceDesc& desc = tex->desc(); |
748 SkASSERT(w <= desc.fWidth); | 749 SkASSERT(w <= desc.fWidth); |
749 SkASSERT(h <= desc.fHeight); | 750 SkASSERT(h <= desc.fHeight); |
750 #endif | 751 #endif |
751 const GrPixelConfig config = tex->config(); | 752 const GrPixelConfig config = tex->config(); |
752 SkColorType ct = kUnknown_SkColorType; | 753 SkColorType ct = kUnknown_SkColorType; |
753 SkAlphaType at = isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType; | 754 SkAlphaType at = isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType; |
754 if (!GrPixelConfigToColorAndColorSpace(config, &ct, nullptr)) { | 755 if (!GrPixelConfigToColorAndColorSpace(config, &ct, nullptr)) { |
755 ct = kUnknown_SkColorType; | 756 ct = kUnknown_SkColorType; |
756 } | 757 } |
757 return SkImageInfo::Make(w, h, ct, at); | 758 return SkImageInfo::Make(w, h, ct, at, std::move(colorSpace)); |
758 } | 759 } |
759 | 760 |
760 | 761 |
761 void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap
* dst) { | 762 void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap
* dst) { |
762 const SkImageInfo info = GrMakeInfoFromTexture(src, w, h, isOpaque); | 763 const SkImageInfo info = GrMakeInfoFromTexture(src, w, h, isOpaque); |
763 dst->setInfo(info); | 764 dst->setInfo(info); |
764 dst->setPixelRef(new SkGrPixelRef(info, src))->unref(); | 765 dst->setPixelRef(new SkGrPixelRef(info, src))->unref(); |
765 } | 766 } |
766 | 767 |
767 GrTextureParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality pain
tFilterQuality, | 768 GrTextureParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality pain
tFilterQuality, |
(...skipping 30 matching lines...) Expand all Loading... |
798 SkErrorInternals::SetError( kInvalidPaint_SkError, | 799 SkErrorInternals::SetError( kInvalidPaint_SkError, |
799 "Sorry, I don't understand the filtering
" | 800 "Sorry, I don't understand the filtering
" |
800 "mode you asked for. Falling back to " | 801 "mode you asked for. Falling back to " |
801 "MIPMaps."); | 802 "MIPMaps."); |
802 textureFilterMode = GrTextureParams::kMipMap_FilterMode; | 803 textureFilterMode = GrTextureParams::kMipMap_FilterMode; |
803 break; | 804 break; |
804 | 805 |
805 } | 806 } |
806 return textureFilterMode; | 807 return textureFilterMode; |
807 } | 808 } |
OLD | NEW |