| 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 "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 void SkGradientShaderBase::Descriptor::flatten(SkWriteBuffer& buffer) const { | 15 void SkGradientShaderBase::Descriptor::flatten(SkWriteBuffer& buffer) const { |
| 16 buffer.writeColorArray(fColors, fCount); | 16 buffer.writeColorArray("fColors", fColors, fCount); |
| 17 if (fPos) { | 17 if (fPos) { |
| 18 buffer.writeBool(true); | 18 buffer.writeBool("posValid", true); |
| 19 buffer.writeScalarArray(fPos, fCount); | 19 buffer.writeScalarArray("fPos", fPos, fCount); |
| 20 } else { | 20 } else { |
| 21 buffer.writeBool(false); | 21 buffer.writeBool("posValid", false); |
| 22 } | 22 } |
| 23 buffer.write32(fTileMode); | 23 buffer.write32("fTileMode", fTileMode); |
| 24 buffer.write32(fGradFlags); | 24 buffer.write32("fGradFlags", fGradFlags); |
| 25 if (fLocalMatrix) { | 25 if (fLocalMatrix) { |
| 26 buffer.writeBool(true); | 26 buffer.writeBool("hasLocalMatrix", true); |
| 27 buffer.writeMatrix(*fLocalMatrix); | 27 buffer.writeMatrix("fLocalMatrix", *fLocalMatrix); |
| 28 } else { | 28 } else { |
| 29 buffer.writeBool(false); | 29 buffer.writeBool("hasLocalMatrix", false); |
| 30 } | 30 } |
| 31 } | 31 } |
| 32 | 32 |
| 33 bool SkGradientShaderBase::DescriptorScope::unflatten(SkReadBuffer& buffer) { | 33 bool SkGradientShaderBase::DescriptorScope::unflatten(SkReadBuffer& buffer) { |
| 34 fCount = buffer.getArrayCount(); | 34 fCount = buffer.getArrayCount(); |
| 35 if (fCount > kStorageCount) { | 35 if (fCount > kStorageCount) { |
| 36 size_t allocSize = (sizeof(SkColor) + sizeof(SkScalar)) * fCount; | 36 size_t allocSize = (sizeof(SkColor) + sizeof(SkScalar)) * fCount; |
| 37 fDynamicStorage.reset(allocSize); | 37 fDynamicStorage.reset(allocSize); |
| 38 fColors = (SkColor*)fDynamicStorage.get(); | 38 fColors = (SkColor*)fDynamicStorage.get(); |
| 39 fPos = (SkScalar*)(fColors + fCount); | 39 fPos = (SkScalar*)(fColors + fCount); |
| (...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1203 (*stops)[i] = stop; | 1203 (*stops)[i] = stop; |
| 1204 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; | 1204 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; |
| 1205 } | 1205 } |
| 1206 } | 1206 } |
| 1207 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); | 1207 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); |
| 1208 | 1208 |
| 1209 return outColors; | 1209 return outColors; |
| 1210 } | 1210 } |
| 1211 | 1211 |
| 1212 #endif | 1212 #endif |
| OLD | NEW |