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

Side by Side Diff: src/effects/gradients/SkGradientShader.cpp

Issue 1789663002: sRGB support in Ganesh. Several pieces: (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Squelch clang warnings about GrPixelConfig < kGrPixelConfigCnt Created 4 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "Sk4fLinearGradient.h" 8 #include "Sk4fLinearGradient.h"
9 #include "SkGradientShaderPriv.h" 9 #include "SkGradientShaderPriv.h"
10 #include "SkLinearGradient.h" 10 #include "SkLinearGradient.h"
11 #include "SkRadialGradient.h" 11 #include "SkRadialGradient.h"
12 #include "SkTwoPointConicalGradient.h" 12 #include "SkTwoPointConicalGradient.h"
13 #include "SkSweepGradient.h" 13 #include "SkSweepGradient.h"
14 14
15 #include "GrContext.h"
16
15 void SkGradientShaderBase::Descriptor::flatten(SkWriteBuffer& buffer) const { 17 void SkGradientShaderBase::Descriptor::flatten(SkWriteBuffer& buffer) const {
16 buffer.writeColorArray(fColors, fCount); 18 buffer.writeColorArray(fColors, fCount);
17 if (fPos) { 19 if (fPos) {
18 buffer.writeBool(true); 20 buffer.writeBool(true);
19 buffer.writeScalarArray(fPos, fCount); 21 buffer.writeScalarArray(fPos, fCount);
20 } else { 22 } else {
21 buffer.writeBool(false); 23 buffer.writeBool(false);
22 } 24 }
23 buffer.write32(fTileMode); 25 buffer.write32(fTileMode);
24 buffer.write32(fGradFlags); 26 buffer.write32(fGradFlags);
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 // doesn't matter how this is set, just be consistent because it is part of the effect key. 1112 // doesn't matter how this is set, just be consistent because it is part of the effect key.
1111 fPremulType = kBeforeInterp_PremulType; 1113 fPremulType = kBeforeInterp_PremulType;
1112 SkBitmap bitmap; 1114 SkBitmap bitmap;
1113 shader.getGradientTableBitmap(&bitmap); 1115 shader.getGradientTableBitmap(&bitmap);
1114 1116
1115 GrTextureStripAtlas::Desc desc; 1117 GrTextureStripAtlas::Desc desc;
1116 desc.fWidth = bitmap.width(); 1118 desc.fWidth = bitmap.width();
1117 desc.fHeight = 32; 1119 desc.fHeight = 32;
1118 desc.fRowHeight = bitmap.height(); 1120 desc.fRowHeight = bitmap.height();
1119 desc.fContext = ctx; 1121 desc.fContext = ctx;
1120 desc.fConfig = SkImageInfo2GrPixelConfig(bitmap.info()); 1122 desc.fConfig = SkImageInfo2GrPixelConfig(bitmap.info(), *ctx->caps());
1121 fAtlas = GrTextureStripAtlas::GetAtlas(desc); 1123 fAtlas = GrTextureStripAtlas::GetAtlas(desc);
1122 SkASSERT(fAtlas); 1124 SkASSERT(fAtlas);
1123 1125
1124 // We always filter the gradient table. Each table is one row of a textu re, always y-clamp. 1126 // We always filter the gradient table. Each table is one row of a textu re, always y-clamp.
1125 GrTextureParams params; 1127 GrTextureParams params;
1126 params.setFilterMode(GrTextureParams::kBilerp_FilterMode); 1128 params.setFilterMode(GrTextureParams::kBilerp_FilterMode);
1127 params.setTileModeX(tileMode); 1129 params.setTileModeX(tileMode);
1128 1130
1129 fRow = fAtlas->lockRow(bitmap); 1131 fRow = fAtlas->lockRow(bitmap);
1130 if (-1 != fRow) { 1132 if (-1 != fRow) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 (*stops)[i] = stop; 1208 (*stops)[i] = stop;
1207 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f; 1209 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f;
1208 } 1210 }
1209 } 1211 }
1210 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount)); 1212 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount));
1211 1213
1212 return outColors; 1214 return outColors;
1213 } 1215 }
1214 1216
1215 #endif 1217 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698