| OLD | NEW |
| 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 "SkGradientShaderPriv.h" | 8 #include "SkGradientShaderPriv.h" |
| 9 #include "SkLinearGradient.h" | 9 #include "SkLinearGradient.h" |
| 10 #include "SkRadialGradient.h" | 10 #include "SkRadialGradient.h" |
| (...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 SkBitmap bitmap; | 1143 SkBitmap bitmap; |
| 1144 shader.getGradientTableBitmap(&bitmap); | 1144 shader.getGradientTableBitmap(&bitmap); |
| 1145 | 1145 |
| 1146 GrTextureStripAtlas::Desc desc; | 1146 GrTextureStripAtlas::Desc desc; |
| 1147 desc.fWidth = bitmap.width(); | 1147 desc.fWidth = bitmap.width(); |
| 1148 desc.fHeight = 32; | 1148 desc.fHeight = 32; |
| 1149 desc.fRowHeight = bitmap.height(); | 1149 desc.fRowHeight = bitmap.height(); |
| 1150 desc.fContext = ctx; | 1150 desc.fContext = ctx; |
| 1151 desc.fConfig = SkImageInfo2GrPixelConfig(bitmap.info()); | 1151 desc.fConfig = SkImageInfo2GrPixelConfig(bitmap.info()); |
| 1152 fAtlas = GrTextureStripAtlas::GetAtlas(desc); | 1152 fAtlas = GrTextureStripAtlas::GetAtlas(desc); |
| 1153 SkASSERT(NULL != fAtlas); | 1153 SkASSERT(fAtlas); |
| 1154 | 1154 |
| 1155 // We always filter the gradient table. Each table is one row of a textu
re, always y-clamp. | 1155 // We always filter the gradient table. Each table is one row of a textu
re, always y-clamp. |
| 1156 GrTextureParams params; | 1156 GrTextureParams params; |
| 1157 params.setFilterMode(GrTextureParams::kBilerp_FilterMode); | 1157 params.setFilterMode(GrTextureParams::kBilerp_FilterMode); |
| 1158 params.setTileModeX(tileMode); | 1158 params.setTileModeX(tileMode); |
| 1159 | 1159 |
| 1160 fRow = fAtlas->lockRow(bitmap); | 1160 fRow = fAtlas->lockRow(bitmap); |
| 1161 if (-1 != fRow) { | 1161 if (-1 != fRow) { |
| 1162 fYCoord = fAtlas->getYOffset(fRow) + SK_ScalarHalf * | 1162 fYCoord = fAtlas->getYOffset(fRow) + SK_ScalarHalf * |
| 1163 fAtlas->getVerticalScaleFactor(); | 1163 fAtlas->getVerticalScaleFactor(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1232 int outColors = random->nextRangeU(1, kMaxRandomGradientColors); | 1232 int outColors = random->nextRangeU(1, kMaxRandomGradientColors); |
| 1233 | 1233 |
| 1234 // if one color, omit stops, otherwise randomly decide whether or not to | 1234 // if one color, omit stops, otherwise randomly decide whether or not to |
| 1235 if (outColors == 1 || (outColors >= 2 && random->nextBool())) { | 1235 if (outColors == 1 || (outColors >= 2 && random->nextBool())) { |
| 1236 *stops = NULL; | 1236 *stops = NULL; |
| 1237 } | 1237 } |
| 1238 | 1238 |
| 1239 SkScalar stop = 0.f; | 1239 SkScalar stop = 0.f; |
| 1240 for (int i = 0; i < outColors; ++i) { | 1240 for (int i = 0; i < outColors; ++i) { |
| 1241 colors[i] = random->nextU(); | 1241 colors[i] = random->nextU(); |
| 1242 if (NULL != *stops) { | 1242 if (*stops) { |
| 1243 (*stops)[i] = stop; | 1243 (*stops)[i] = stop; |
| 1244 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; | 1244 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; |
| 1245 } | 1245 } |
| 1246 } | 1246 } |
| 1247 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); | 1247 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); |
| 1248 | 1248 |
| 1249 return outColors; | 1249 return outColors; |
| 1250 } | 1250 } |
| 1251 | 1251 |
| 1252 #endif | 1252 #endif |
| OLD | NEW |