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

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

Issue 395603002: Simplify flattening to just write enough to call the factory (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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
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 "SkGradientShaderPriv.h" 8 #include "SkGradientShaderPriv.h"
9 #include "SkLinearGradient.h" 9 #include "SkLinearGradient.h"
10 #include "SkRadialGradient.h" 10 #include "SkRadialGradient.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 132 }
133 133
134 static SkShader::TileMode unpack_mode(uint32_t packed) { 134 static SkShader::TileMode unpack_mode(uint32_t packed) {
135 return (SkShader::TileMode)(packed & 0xF); 135 return (SkShader::TileMode)(packed & 0xF);
136 } 136 }
137 137
138 static uint32_t unpack_flags(uint32_t packed) { 138 static uint32_t unpack_flags(uint32_t packed) {
139 return packed >> 4; 139 return packed >> 4;
140 } 140 }
141 141
142 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
142 SkGradientShaderBase::SkGradientShaderBase(SkReadBuffer& buffer) : INHERITED(buf fer) { 143 SkGradientShaderBase::SkGradientShaderBase(SkReadBuffer& buffer) : INHERITED(buf fer) {
143 if (buffer.isVersionLT(SkReadBuffer::kNoUnitMappers_Version)) { 144 if (buffer.isVersionLT(SkReadBuffer::kNoUnitMappers_Version)) {
144 // skip the old SkUnitMapper slot 145 // skip the old SkUnitMapper slot
145 buffer.skipFlattenable(); 146 buffer.skipFlattenable();
146 } 147 }
147 148
148 int colorCount = fColorCount = buffer.getArrayCount(); 149 int colorCount = fColorCount = buffer.getArrayCount();
149 if (colorCount > kColorStorageCount) { 150 if (colorCount > kColorStorageCount) {
150 size_t allocSize = (sizeof(SkColor) + sizeof(SkPMColor) + sizeof(Rec)) * colorCount; 151 size_t allocSize = (sizeof(SkColor) + sizeof(SkPMColor) + sizeof(Rec)) * colorCount;
151 if (buffer.validateAvailable(allocSize)) { 152 if (buffer.validateAvailable(allocSize)) {
(...skipping 18 matching lines...) Expand all
170 Rec* recs = fRecs; 171 Rec* recs = fRecs;
171 recs[0].fPos = 0; 172 recs[0].fPos = 0;
172 for (int i = 1; i < colorCount; i++) { 173 for (int i = 1; i < colorCount; i++) {
173 recs[i].fPos = buffer.readInt(); 174 recs[i].fPos = buffer.readInt();
174 recs[i].fScale = buffer.readUInt(); 175 recs[i].fScale = buffer.readUInt();
175 } 176 }
176 } 177 }
177 buffer.readMatrix(&fPtsToUnit); 178 buffer.readMatrix(&fPtsToUnit);
178 this->initCommon(); 179 this->initCommon();
179 } 180 }
181 #endif
180 182
181 SkGradientShaderBase::~SkGradientShaderBase() { 183 SkGradientShaderBase::~SkGradientShaderBase() {
182 if (fOrigColors != fStorage) { 184 if (fOrigColors != fStorage) {
183 sk_free(fOrigColors); 185 sk_free(fOrigColors);
184 } 186 }
185 } 187 }
186 188
187 void SkGradientShaderBase::initCommon() { 189 void SkGradientShaderBase::initCommon() {
188 unsigned colorAlpha = 0xFF; 190 unsigned colorAlpha = 0xFF;
189 for (int i = 0; i < fColorCount; i++) { 191 for (int i = 0; i < fColorCount; i++) {
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 (*stops)[i] = stop; 1150 (*stops)[i] = stop;
1149 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f; 1151 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f;
1150 } 1152 }
1151 } 1153 }
1152 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount)); 1154 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount));
1153 1155
1154 return outColors; 1156 return outColors;
1155 } 1157 }
1156 1158
1157 #endif 1159 #endif
OLDNEW
« src/effects/SkColorFilterImageFilter.cpp ('K') | « src/effects/SkTableMaskFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698