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

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

Issue 239993006: Revert of Add flipped gradient branch to two point conical gradient (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 8 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
« no previous file with comments | « include/core/SkPicture.h ('k') | src/effects/gradients/SkGradientShaderPriv.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 if (fColorCount > 2) { 196 if (fColorCount > 2) {
197 Rec* recs = fRecs; 197 Rec* recs = fRecs;
198 for (int i = 1; i < fColorCount; i++) { 198 for (int i = 1; i < fColorCount; i++) {
199 buffer.writeInt(recs[i].fPos); 199 buffer.writeInt(recs[i].fPos);
200 buffer.writeUInt(recs[i].fScale); 200 buffer.writeUInt(recs[i].fScale);
201 } 201 }
202 } 202 }
203 buffer.writeMatrix(fPtsToUnit); 203 buffer.writeMatrix(fPtsToUnit);
204 } 204 }
205 205
206 // V23_COMPATIBILITY_CODE
207 void SkGradientShaderBase::flipGradientColors() {
208 SkAutoSTArray<8, SkColor> colorsTemp(fColorCount);
209 for (int i = 0; i < fColorCount; ++i) {
210 int offset = fColorCount - i - 1;
211 colorsTemp[i] = fOrigColors[offset];
212 }
213 if (fColorCount > 2) {
214 SkAutoSTArray<8, Rec> recsTemp(fColorCount);
215 for (int i = 0; i < fColorCount; ++i) {
216 int offset = fColorCount - i - 1;
217 recsTemp[i].fPos = 1 - fRecs[offset].fPos;
218 recsTemp[i].fScale = fRecs[offset].fScale;
219 }
220 memcpy(fRecs, recsTemp.get(), fColorCount * sizeof(Rec));
221 }
222 memcpy(fOrigColors, colorsTemp.get(), fColorCount * sizeof(SkColor));
223 }
224
225 bool SkGradientShaderBase::isOpaque() const { 206 bool SkGradientShaderBase::isOpaque() const {
226 return fColorsAreOpaque; 207 return fColorsAreOpaque;
227 } 208 }
228 209
229 SkGradientShaderBase::GradientShaderBaseContext::GradientShaderBaseContext( 210 SkGradientShaderBase::GradientShaderBaseContext::GradientShaderBaseContext(
230 const SkGradientShaderBase& shader, const SkBitmap& device, 211 const SkGradientShaderBase& shader, const SkBitmap& device,
231 const SkPaint& paint, const SkMatrix& matrix) 212 const SkPaint& paint, const SkMatrix& matrix)
232 : INHERITED(shader, device, paint, matrix) 213 : INHERITED(shader, device, paint, matrix)
233 , fCache(shader.refCache(getPaintAlpha())) 214 , fCache(shader.refCache(getPaintAlpha()))
234 { 215 {
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 int colorCount, 786 int colorCount,
806 SkShader::TileMode mode, 787 SkShader::TileMode mode,
807 SkUnitMapper* mapper, 788 SkUnitMapper* mapper,
808 uint32_t flags) { 789 uint32_t flags) {
809 if (startRadius < 0 || endRadius < 0 || NULL == colors || colorCount < 1) { 790 if (startRadius < 0 || endRadius < 0 || NULL == colors || colorCount < 1) {
810 return NULL; 791 return NULL;
811 } 792 }
812 if (start == end && startRadius == endRadius) { 793 if (start == end && startRadius == endRadius) {
813 return SkNEW(SkEmptyShader); 794 return SkNEW(SkEmptyShader);
814 } 795 }
815
816 EXPAND_1_COLOR(colorCount); 796 EXPAND_1_COLOR(colorCount);
817 797
818 bool flipGradient = startRadius > endRadius;
819
820 SkGradientShaderBase::Descriptor desc; 798 SkGradientShaderBase::Descriptor desc;
821 799 desc_init(&desc, colors, pos, colorCount, mode, mapper, flags);
822 if (!flipGradient) { 800 return SkNEW_ARGS(SkTwoPointConicalGradient,
823 desc_init(&desc, colors, pos, colorCount, mode, mapper, flags); 801 (start, startRadius, end, endRadius, desc));
824 return SkNEW_ARGS(SkTwoPointConicalGradient,
825 (start, startRadius, end, endRadius, flipGradient, des c));
826 } else {
827 SkAutoSTArray<8, SkColor> colorsNew(colorCount);
828 SkAutoSTArray<8, SkScalar> posNew(colorCount);
829 for (int i = 0; i < colorCount; ++i) {
830 colorsNew[i] = colors[colorCount - i - 1];
831 }
832
833 if (pos) {
834 for (int i = 0; i < colorCount; ++i) {
835 posNew[i] = 1 - pos[colorCount - i - 1];
836 }
837 desc_init(&desc, colorsNew.get(), posNew.get(), colorCount, mode, ma pper, flags);
838 } else {
839 desc_init(&desc, colorsNew.get(), NULL, colorCount, mode, mapper, fl ags);
840 }
841
842 return SkNEW_ARGS(SkTwoPointConicalGradient,
843 (end, endRadius, start, startRadius, flipGradient, des c));
844 }
845 } 802 }
846 803
847 SkShader* SkGradientShader::CreateSweep(SkScalar cx, SkScalar cy, 804 SkShader* SkGradientShader::CreateSweep(SkScalar cx, SkScalar cy,
848 const SkColor colors[], 805 const SkColor colors[],
849 const SkScalar pos[], 806 const SkScalar pos[],
850 int colorCount, SkUnitMapper* mapper, 807 int colorCount, SkUnitMapper* mapper,
851 uint32_t flags) { 808 uint32_t flags) {
852 if (NULL == colors || colorCount < 1) { 809 if (NULL == colors || colorCount < 1) {
853 return NULL; 810 return NULL;
854 } 811 }
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 (*stops)[i] = stop; 1142 (*stops)[i] = stop;
1186 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f; 1143 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f;
1187 } 1144 }
1188 } 1145 }
1189 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount)); 1146 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount));
1190 1147
1191 return outColors; 1148 return outColors;
1192 } 1149 }
1193 1150
1194 #endif 1151 #endif
OLDNEW
« no previous file with comments | « include/core/SkPicture.h ('k') | src/effects/gradients/SkGradientShaderPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698