Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: src/gpu/SkGpuDevice.cpp

Issue 2329553002: Cleanup GPU gamut transformation code (Closed)
Patch Set: Switch from float[16] to SkMatrix44 Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrTextureParamsAdjuster.cpp ('k') | src/gpu/effects/GrBicubicEffect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 // We should be respecting the max tile size by the time we get here. 1002 // We should be respecting the max tile size by the time we get here.
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 sk_sp<GrColorSpaceXform> colorSpaceXform = 1011 sk_sp<GrColorSpaceXform> colorSpaceXform =
1012 GrColorSpaceXform::Make(bitmap.colorSpace(), fDrawContext->getColorSpace (), 1012 GrColorSpaceXform::Make(bitmap.colorSpace(), fDrawContext->getColorSpace ());
1013 bitmap.alphaType());
1014 1013
1015 SkScalar iw = 1.f / texture->width(); 1014 SkScalar iw = 1.f / texture->width();
1016 SkScalar ih = 1.f / texture->height(); 1015 SkScalar ih = 1.f / texture->height();
1017 1016
1018 SkMatrix texMatrix; 1017 SkMatrix texMatrix;
1019 // Compute a matrix that maps the rect we will draw to the src rect. 1018 // Compute a matrix that maps the rect we will draw to the src rect.
1020 texMatrix.setRectToRect(dstRect, srcRect, SkMatrix::kStart_ScaleToFit); 1019 texMatrix.setRectToRect(dstRect, srcRect, SkMatrix::kStart_ScaleToFit);
1021 texMatrix.postScale(iw, ih); 1020 texMatrix.postScale(iw, ih);
1022 1021
1023 // Construct a GrPaint by setting the bitmap texture as the first effect and then configuring 1022 // Construct a GrPaint by setting the bitmap texture as the first effect and then configuring
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 result = sk_ref_sp(special1); 1127 result = sk_ref_sp(special1);
1129 } 1128 }
1130 1129
1131 SkASSERT(result->isTextureBacked()); 1130 SkASSERT(result->isTextureBacked());
1132 sk_sp<GrTexture> texture = result->asTextureRef(fContext); 1131 sk_sp<GrTexture> texture = result->asTextureRef(fContext);
1133 1132
1134 SkPaint tmpUnfiltered(paint); 1133 SkPaint tmpUnfiltered(paint);
1135 tmpUnfiltered.setImageFilter(nullptr); 1134 tmpUnfiltered.setImageFilter(nullptr);
1136 1135
1137 sk_sp<GrColorSpaceXform> colorSpaceXform = 1136 sk_sp<GrColorSpaceXform> colorSpaceXform =
1138 GrColorSpaceXform::Make(result->getColorSpace(), fDrawContext->getColorS pace(), 1137 GrColorSpaceXform::Make(result->getColorSpace(), fDrawContext->getColorS pace());
1139 result->alphaType());
1140 GrPaint grPaint; 1138 GrPaint grPaint;
1141 sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(texture.get(), 1139 sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(texture.get(),
1142 std::move(colorSpa ceXform), 1140 std::move(colorSpa ceXform),
1143 SkMatrix::I())); 1141 SkMatrix::I()));
1144 if (GrPixelConfigIsAlphaOnly(texture->config())) { 1142 if (GrPixelConfigIsAlphaOnly(texture->config())) {
1145 fp = GrFragmentProcessor::MulOutputByInputUnpremulColor(std::move(fp)); 1143 fp = GrFragmentProcessor::MulOutputByInputUnpremulColor(std::move(fp));
1146 } else { 1144 } else {
1147 fp = GrFragmentProcessor::MulOutputByInputAlpha(std::move(fp)); 1145 fp = GrFragmentProcessor::MulOutputByInputAlpha(std::move(fp));
1148 } 1146 }
1149 if (!SkPaintToGrPaintReplaceShader(this->context(), fDrawContext.get(), tmpU nfiltered, 1147 if (!SkPaintToGrPaintReplaceShader(this->context(), fDrawContext.get(), tmpU nfiltered,
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
1798 } 1796 }
1799 1797
1800 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { 1798 SkImageFilterCache* SkGpuDevice::getImageFilterCache() {
1801 ASSERT_SINGLE_OWNER 1799 ASSERT_SINGLE_OWNER
1802 // We always return a transient cache, so it is freed after each 1800 // We always return a transient cache, so it is freed after each
1803 // filter traversal. 1801 // filter traversal.
1804 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); 1802 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize);
1805 } 1803 }
1806 1804
1807 #endif 1805 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrTextureParamsAdjuster.cpp ('k') | src/gpu/effects/GrBicubicEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698