| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 } | 136 } |
| 137 | 137 |
| 138 static SkShader::TileMode unpack_mode(uint32_t packed) { | 138 static SkShader::TileMode unpack_mode(uint32_t packed) { |
| 139 return (SkShader::TileMode)(packed & 0xF); | 139 return (SkShader::TileMode)(packed & 0xF); |
| 140 } | 140 } |
| 141 | 141 |
| 142 static uint32_t unpack_flags(uint32_t packed) { | 142 static uint32_t unpack_flags(uint32_t packed) { |
| 143 return packed >> 4; | 143 return packed >> 4; |
| 144 } | 144 } |
| 145 | 145 |
| 146 SkGradientShaderBase::SkGradientShaderBase(SkFlattenableReadBuffer& buffer) : IN
HERITED(buffer) { | 146 SkGradientShaderBase::SkGradientShaderBase(SkReadBuffer& buffer) : INHERITED(buf
fer) { |
| 147 fCacheAlpha = 256; | 147 fCacheAlpha = 256; |
| 148 | 148 |
| 149 fMapper = buffer.readUnitMapper(); | 149 fMapper = buffer.readUnitMapper(); |
| 150 | 150 |
| 151 fCache16 = fCache16Storage = NULL; | 151 fCache16 = fCache16Storage = NULL; |
| 152 fCache32 = NULL; | 152 fCache32 = NULL; |
| 153 fCache32PixelRef = NULL; | 153 fCache32PixelRef = NULL; |
| 154 | 154 |
| 155 int colorCount = fColorCount = buffer.getArrayCount(); | 155 int colorCount = fColorCount = buffer.getArrayCount(); |
| 156 if (colorCount > kColorStorageCount) { | 156 if (colorCount > kColorStorageCount) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 198 |
| 199 void SkGradientShaderBase::initCommon() { | 199 void SkGradientShaderBase::initCommon() { |
| 200 fFlags = 0; | 200 fFlags = 0; |
| 201 unsigned colorAlpha = 0xFF; | 201 unsigned colorAlpha = 0xFF; |
| 202 for (int i = 0; i < fColorCount; i++) { | 202 for (int i = 0; i < fColorCount; i++) { |
| 203 colorAlpha &= SkColorGetA(fOrigColors[i]); | 203 colorAlpha &= SkColorGetA(fOrigColors[i]); |
| 204 } | 204 } |
| 205 fColorsAreOpaque = colorAlpha == 0xFF; | 205 fColorsAreOpaque = colorAlpha == 0xFF; |
| 206 } | 206 } |
| 207 | 207 |
| 208 void SkGradientShaderBase::flatten(SkFlattenableWriteBuffer& buffer) const { | 208 void SkGradientShaderBase::flatten(SkWriteBuffer& buffer) const { |
| 209 this->INHERITED::flatten(buffer); | 209 this->INHERITED::flatten(buffer); |
| 210 buffer.writeFlattenable(fMapper); | 210 buffer.writeFlattenable(fMapper); |
| 211 buffer.writeColorArray(fOrigColors, fColorCount); | 211 buffer.writeColorArray(fOrigColors, fColorCount); |
| 212 buffer.writeUInt(pack_mode_flags(fTileMode, fGradFlags)); | 212 buffer.writeUInt(pack_mode_flags(fTileMode, fGradFlags)); |
| 213 if (fColorCount > 2) { | 213 if (fColorCount > 2) { |
| 214 Rec* recs = fRecs; | 214 Rec* recs = fRecs; |
| 215 for (int i = 1; i < fColorCount; i++) { | 215 for (int i = 1; i < fColorCount; i++) { |
| 216 buffer.writeInt(recs[i].fPos); | 216 buffer.writeInt(recs[i].fPos); |
| 217 buffer.writeUInt(recs[i].fScale); | 217 buffer.writeUInt(recs[i].fScale); |
| 218 } | 218 } |
| (...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 (*stops)[i] = stop; | 1138 (*stops)[i] = stop; |
| 1139 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; | 1139 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; |
| 1140 } | 1140 } |
| 1141 } | 1141 } |
| 1142 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); | 1142 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); |
| 1143 | 1143 |
| 1144 return outColors; | 1144 return outColors; |
| 1145 } | 1145 } |
| 1146 | 1146 |
| 1147 #endif | 1147 #endif |
| OLD | NEW |