OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkGpuDevice.h" | 8 #include "SkGpuDevice.h" |
9 | 9 |
10 #include "GrBlurUtils.h" | 10 #include "GrBlurUtils.h" |
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 SkASSERT(bitmap.width() <= fContext->caps()->maxTileSize() && | 1003 SkASSERT(bitmap.width() <= fContext->caps()->maxTileSize() && |
1004 bitmap.height() <= fContext->caps()->maxTileSize()); | 1004 bitmap.height() <= fContext->caps()->maxTileSize()); |
1005 | 1005 |
1006 sk_sp<GrTexture> texture = GrMakeCachedBitmapTexture(fContext, bitmap, param
s, | 1006 sk_sp<GrTexture> texture = GrMakeCachedBitmapTexture(fContext, bitmap, param
s, |
1007 fDrawContext->sourceGam
maTreatment()); | 1007 fDrawContext->sourceGam
maTreatment()); |
1008 if (nullptr == texture) { | 1008 if (nullptr == texture) { |
1009 return; | 1009 return; |
1010 } | 1010 } |
1011 | 1011 |
1012 sk_sp<GrColorSpaceXform> colorSpaceXform = | 1012 sk_sp<GrColorSpaceXform> colorSpaceXform = |
1013 GrColorSpaceXform::Make(bitmap.colorSpace(), fDrawContext->getColorSpace
()); | 1013 GrColorSpaceXform::Make(bitmap.colorSpace(), fDrawContext->getColorSpace
(), |
| 1014 bitmap.alphaType()); |
1014 | 1015 |
1015 SkScalar iw = 1.f / texture->width(); | 1016 SkScalar iw = 1.f / texture->width(); |
1016 SkScalar ih = 1.f / texture->height(); | 1017 SkScalar ih = 1.f / texture->height(); |
1017 | 1018 |
1018 SkMatrix texMatrix; | 1019 SkMatrix texMatrix; |
1019 // Compute a matrix that maps the rect we will draw to the src rect. | 1020 // Compute a matrix that maps the rect we will draw to the src rect. |
1020 texMatrix.setRectToRect(dstRect, srcRect, SkMatrix::kStart_ScaleToFit); | 1021 texMatrix.setRectToRect(dstRect, srcRect, SkMatrix::kStart_ScaleToFit); |
1021 texMatrix.postScale(iw, ih); | 1022 texMatrix.postScale(iw, ih); |
1022 | 1023 |
1023 // Construct a GrPaint by setting the bitmap texture as the first effect and
then configuring | 1024 // Construct a GrPaint by setting the bitmap texture as the first effect and
then configuring |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 } else { | 1128 } else { |
1128 result = sk_ref_sp(special1); | 1129 result = sk_ref_sp(special1); |
1129 } | 1130 } |
1130 | 1131 |
1131 SkASSERT(result->isTextureBacked()); | 1132 SkASSERT(result->isTextureBacked()); |
1132 sk_sp<GrTexture> texture = result->asTextureRef(fContext); | 1133 sk_sp<GrTexture> texture = result->asTextureRef(fContext); |
1133 | 1134 |
1134 SkPaint tmpUnfiltered(paint); | 1135 SkPaint tmpUnfiltered(paint); |
1135 tmpUnfiltered.setImageFilter(nullptr); | 1136 tmpUnfiltered.setImageFilter(nullptr); |
1136 | 1137 |
| 1138 sk_sp<GrColorSpaceXform> colorSpaceXform = |
| 1139 GrColorSpaceXform::Make(result->getColorSpace(), fDrawContext->getColorS
pace(), |
| 1140 result->alphaType()); |
1137 GrPaint grPaint; | 1141 GrPaint grPaint; |
1138 sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(texture.get(), nul
lptr, | 1142 sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(texture.get(), |
| 1143 std::move(colorSpa
ceXform), |
1139 SkMatrix::I())); | 1144 SkMatrix::I())); |
1140 if (GrPixelConfigIsAlphaOnly(texture->config())) { | 1145 if (GrPixelConfigIsAlphaOnly(texture->config())) { |
1141 fp = GrFragmentProcessor::MulOutputByInputUnpremulColor(std::move(fp)); | 1146 fp = GrFragmentProcessor::MulOutputByInputUnpremulColor(std::move(fp)); |
1142 } else { | 1147 } else { |
1143 fp = GrFragmentProcessor::MulOutputByInputAlpha(std::move(fp)); | 1148 fp = GrFragmentProcessor::MulOutputByInputAlpha(std::move(fp)); |
1144 } | 1149 } |
1145 if (!SkPaintToGrPaintReplaceShader(this->context(), fDrawContext.get(), tmpU
nfiltered, | 1150 if (!SkPaintToGrPaintReplaceShader(this->context(), fDrawContext.get(), tmpU
nfiltered, |
1146 std::move(fp), &grPaint)) { | 1151 std::move(fp), &grPaint)) { |
1147 return; | 1152 return; |
1148 } | 1153 } |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1794 } | 1799 } |
1795 | 1800 |
1796 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { | 1801 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { |
1797 ASSERT_SINGLE_OWNER | 1802 ASSERT_SINGLE_OWNER |
1798 // We always return a transient cache, so it is freed after each | 1803 // We always return a transient cache, so it is freed after each |
1799 // filter traversal. | 1804 // filter traversal. |
1800 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); | 1805 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); |
1801 } | 1806 } |
1802 | 1807 |
1803 #endif | 1808 #endif |
OLD | NEW |