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

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

Issue 2154753003: Introduce GrColorSpaceXform, for gamut conversion on textures (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: More progress & refactoring Created 4 years, 5 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/GrTextureToYUVPlanes.cpp ('k') | src/gpu/effects/Gr1DKernelEffect.h » ('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 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 bitmap.height() <= fContext->caps()->maxTileSize())); 1138 bitmap.height() <= fContext->caps()->maxTileSize()));
1139 1139
1140 GrTexture* texture; 1140 GrTexture* texture;
1141 SkSourceGammaTreatment gammaTreatment = this->surfaceProps().isGammaCorrect( ) 1141 SkSourceGammaTreatment gammaTreatment = this->surfaceProps().isGammaCorrect( )
1142 ? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore; 1142 ? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore;
1143 AutoBitmapTexture abt(fContext, bitmap, params, gammaTreatment, &texture); 1143 AutoBitmapTexture abt(fContext, bitmap, params, gammaTreatment, &texture);
1144 if (nullptr == texture) { 1144 if (nullptr == texture) {
1145 return; 1145 return;
1146 } 1146 }
1147 1147
1148 SkColorSpace* dstColorSpace = nullptr; // XFORMTODO
1149 sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(bitmap.co lorSpace(),
1150 dstColorS pace);
1148 SkRect dstRect = {0, 0, srcRect.width(), srcRect.height() }; 1151 SkRect dstRect = {0, 0, srcRect.width(), srcRect.height() };
1149 SkRect paintRect; 1152 SkRect paintRect;
1150 SkScalar wInv = SkScalarInvert(SkIntToScalar(texture->width())); 1153 SkScalar wInv = SkScalarInvert(SkIntToScalar(texture->width()));
1151 SkScalar hInv = SkScalarInvert(SkIntToScalar(texture->height())); 1154 SkScalar hInv = SkScalarInvert(SkIntToScalar(texture->height()));
1152 paintRect.setLTRB(SkScalarMul(srcRect.fLeft, wInv), 1155 paintRect.setLTRB(SkScalarMul(srcRect.fLeft, wInv),
1153 SkScalarMul(srcRect.fTop, hInv), 1156 SkScalarMul(srcRect.fTop, hInv),
1154 SkScalarMul(srcRect.fRight, wInv), 1157 SkScalarMul(srcRect.fRight, wInv),
1155 SkScalarMul(srcRect.fBottom, hInv)); 1158 SkScalarMul(srcRect.fBottom, hInv));
1156 1159
1157 SkMatrix texMatrix; 1160 SkMatrix texMatrix;
(...skipping 24 matching lines...) Expand all
1182 } 1185 }
1183 if (srcRect.height() > SK_Scalar1) { 1186 if (srcRect.height() > SK_Scalar1) {
1184 SkScalar border = SK_ScalarHalf / texture->height(); 1187 SkScalar border = SK_ScalarHalf / texture->height();
1185 top = paintRect.top() + border; 1188 top = paintRect.top() + border;
1186 bottom = paintRect.bottom() - border; 1189 bottom = paintRect.bottom() - border;
1187 } else { 1190 } else {
1188 top = bottom = SkScalarHalf(paintRect.top() + paintRect.bottom()); 1191 top = bottom = SkScalarHalf(paintRect.top() + paintRect.bottom());
1189 } 1192 }
1190 textureDomain.setLTRB(left, top, right, bottom); 1193 textureDomain.setLTRB(left, top, right, bottom);
1191 if (bicubic) { 1194 if (bicubic) {
1192 fp = GrBicubicEffect::Make(texture, texMatrix, textureDomain); 1195 fp = GrBicubicEffect::Make(texture, std::move(colorSpaceXform), texM atrix,
1196 textureDomain);
1193 } else { 1197 } else {
1194 fp = GrTextureDomainEffect::Make(texture, texMatrix, textureDomain, 1198 fp = GrTextureDomainEffect::Make(texture, std::move(colorSpaceXform) , texMatrix,
1195 GrTextureDomain::kClamp_Mode, param s.filterMode()); 1199 textureDomain, GrTextureDomain::kCl amp_Mode,
1200 params.filterMode());
1196 } 1201 }
1197 } else if (bicubic) { 1202 } else if (bicubic) {
1198 SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode()); 1203 SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode());
1199 SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTil eModeY() }; 1204 SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTil eModeY() };
1200 fp = GrBicubicEffect::Make(texture, texMatrix, tileModes); 1205 fp = GrBicubicEffect::Make(texture, std::move(colorSpaceXform), texMatri x, tileModes);
1201 } else { 1206 } else {
1202 fp = GrSimpleTextureEffect::Make(texture, texMatrix, params); 1207 fp = GrSimpleTextureEffect::Make(texture, std::move(colorSpaceXform), te xMatrix, params);
1203 } 1208 }
1204 1209
1205 GrPaint grPaint; 1210 GrPaint grPaint;
1206 if (!SkPaintToGrPaintWithTexture(this->context(), paint, viewMatrix, std::mo ve(fp), 1211 if (!SkPaintToGrPaintWithTexture(this->context(), paint, viewMatrix, std::mo ve(fp),
1207 kAlpha_8_SkColorType == bitmap.colorType(), 1212 kAlpha_8_SkColorType == bitmap.colorType(),
1208 this->surfaceProps().isGammaCorrect(), &grP aint)) { 1213 this->surfaceProps().isGammaCorrect(), &grP aint)) {
1209 return; 1214 return;
1210 } 1215 }
1211 1216
1212 if (kAlpha_8_SkColorType == bitmap.colorType() && paint.getShader()) { 1217 if (kAlpha_8_SkColorType == bitmap.colorType() && paint.getShader()) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 result = sk_ref_sp(special1); 1285 result = sk_ref_sp(special1);
1281 } 1286 }
1282 1287
1283 SkASSERT(result->isTextureBacked()); 1288 SkASSERT(result->isTextureBacked());
1284 sk_sp<GrTexture> texture = result->asTextureRef(fContext); 1289 sk_sp<GrTexture> texture = result->asTextureRef(fContext);
1285 1290
1286 SkPaint tmpUnfiltered(paint); 1291 SkPaint tmpUnfiltered(paint);
1287 tmpUnfiltered.setImageFilter(nullptr); 1292 tmpUnfiltered.setImageFilter(nullptr);
1288 1293
1289 GrPaint grPaint; 1294 GrPaint grPaint;
1290 sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(texture.get(), SkM atrix::I())); 1295 sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(texture.get(), nul lptr,
1296 SkMatrix::I()));
1291 if (GrPixelConfigIsAlphaOnly(texture->config())) { 1297 if (GrPixelConfigIsAlphaOnly(texture->config())) {
1292 fp = GrFragmentProcessor::MulOutputByInputUnpremulColor(std::move(fp)); 1298 fp = GrFragmentProcessor::MulOutputByInputUnpremulColor(std::move(fp));
1293 } else { 1299 } else {
1294 fp = GrFragmentProcessor::MulOutputByInputAlpha(std::move(fp)); 1300 fp = GrFragmentProcessor::MulOutputByInputAlpha(std::move(fp));
1295 } 1301 }
1296 if (!SkPaintToGrPaintReplaceShader(this->context(), tmpUnfiltered, std::move (fp), 1302 if (!SkPaintToGrPaintReplaceShader(this->context(), tmpUnfiltered, std::move (fp),
1297 this->surfaceProps().isGammaCorrect(), &g rPaint)) { 1303 this->surfaceProps().isGammaCorrect(), &g rPaint)) {
1298 return; 1304 return;
1299 } 1305 }
1300 1306
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
1860 } 1866 }
1861 1867
1862 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { 1868 SkImageFilterCache* SkGpuDevice::getImageFilterCache() {
1863 ASSERT_SINGLE_OWNER 1869 ASSERT_SINGLE_OWNER
1864 // We always return a transient cache, so it is freed after each 1870 // We always return a transient cache, so it is freed after each
1865 // filter traversal. 1871 // filter traversal.
1866 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); 1872 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize);
1867 } 1873 }
1868 1874
1869 #endif 1875 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrTextureToYUVPlanes.cpp ('k') | src/gpu/effects/Gr1DKernelEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698