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

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

Issue 247433002: Use GradFlags for gradient Flags in SkGradientShader (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 | « no previous file | 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"
11 #include "SkTwoPointRadialGradient.h" 11 #include "SkTwoPointRadialGradient.h"
12 #include "SkTwoPointConicalGradient.h" 12 #include "SkTwoPointConicalGradient.h"
13 #include "SkSweepGradient.h" 13 #include "SkSweepGradient.h"
14 14
15 SkGradientShaderBase::SkGradientShaderBase(const Descriptor& desc) { 15 SkGradientShaderBase::SkGradientShaderBase(const Descriptor& desc) {
16 SkASSERT(desc.fCount > 1); 16 SkASSERT(desc.fCount > 1);
17 17
18 fCacheAlpha = 256; // init to a value that paint.getAlpha() can't return 18 fCacheAlpha = 256; // init to a value that paint.getAlpha() can't return
19 19
20 fMapper = desc.fMapper; 20 fMapper = desc.fMapper;
21 SkSafeRef(fMapper); 21 SkSafeRef(fMapper);
22 fGradFlags = SkToU8(desc.fFlags); 22 fGradFlags = SkToU8(desc.fGradFlags);
23 23
24 SkASSERT((unsigned)desc.fTileMode < SkShader::kTileModeCount); 24 SkASSERT((unsigned)desc.fTileMode < SkShader::kTileModeCount);
25 SkASSERT(SkShader::kTileModeCount == SK_ARRAY_COUNT(gTileProcs)); 25 SkASSERT(SkShader::kTileModeCount == SK_ARRAY_COUNT(gTileProcs));
26 fTileMode = desc.fTileMode; 26 fTileMode = desc.fTileMode;
27 fTileProc = gTileProcs[desc.fTileMode]; 27 fTileProc = gTileProcs[desc.fTileMode];
28 28
29 fCache16 = fCache16Storage = NULL; 29 fCache16 = fCache16Storage = NULL;
30 fCache32 = NULL; 30 fCache32 = NULL;
31 fCache32PixelRef = NULL; 31 fCache32PixelRef = NULL;
32 32
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 pos = NULL; \ 755 pos = NULL; \
756 count = 2; \ 756 count = 2; \
757 } \ 757 } \
758 } while (0) 758 } while (0)
759 759
760 static void desc_init(SkGradientShaderBase::Descriptor* desc, 760 static void desc_init(SkGradientShaderBase::Descriptor* desc,
761 const SkColor colors[], 761 const SkColor colors[],
762 const SkScalar pos[], int colorCount, 762 const SkScalar pos[], int colorCount,
763 SkShader::TileMode mode, 763 SkShader::TileMode mode,
764 SkUnitMapper* mapper, uint32_t flags) { 764 SkUnitMapper* mapper, uint32_t flags) {
765 desc->fColors = colors; 765 desc->fColors = colors;
766 desc->fPos = pos; 766 desc->fPos = pos;
767 desc->fCount = colorCount; 767 desc->fCount = colorCount;
768 desc->fTileMode = mode; 768 desc->fTileMode = mode;
769 desc->fMapper = mapper; 769 desc->fMapper = mapper;
770 desc->fFlags = flags; 770 desc->fGradFlags = flags;
771 } 771 }
772 772
773 SkShader* SkGradientShader::CreateLinear(const SkPoint pts[2], 773 SkShader* SkGradientShader::CreateLinear(const SkPoint pts[2],
774 const SkColor colors[], 774 const SkColor colors[],
775 const SkScalar pos[], int colorCount, 775 const SkScalar pos[], int colorCount,
776 SkShader::TileMode mode, 776 SkShader::TileMode mode,
777 SkUnitMapper* mapper, 777 SkUnitMapper* mapper,
778 uint32_t flags) { 778 uint32_t flags) {
779 if (NULL == pts || NULL == colors || colorCount < 1) { 779 if (NULL == pts || NULL == colors || colorCount < 1) {
780 return NULL; 780 return NULL;
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 1076
1077 fIsOpaque = shader.isOpaque(); 1077 fIsOpaque = shader.isOpaque();
1078 1078
1079 fColorType = shader.getGpuColorType(&fColors[0]); 1079 fColorType = shader.getGpuColorType(&fColors[0]);
1080 1080
1081 // The two and three color specializations do not currently support tiling. 1081 // The two and three color specializations do not currently support tiling.
1082 if (SkGradientShaderBase::kTwo_GpuColorType == fColorType || 1082 if (SkGradientShaderBase::kTwo_GpuColorType == fColorType ||
1083 SkGradientShaderBase::kThree_GpuColorType == fColorType) { 1083 SkGradientShaderBase::kThree_GpuColorType == fColorType) {
1084 fRow = -1; 1084 fRow = -1;
1085 1085
1086 if (SkGradientShader::kInterpolateColorsInPremul_Flag & shader.getFlags( )) { 1086 if (SkGradientShader::kInterpolateColorsInPremul_Flag & shader.getGradFl ags()) {
1087 fPremulType = kBeforeInterp_PremulType; 1087 fPremulType = kBeforeInterp_PremulType;
1088 } else { 1088 } else {
1089 fPremulType = kAfterInterp_PremulType; 1089 fPremulType = kAfterInterp_PremulType;
1090 } 1090 }
1091 fCoordTransform.reset(kCoordSet, matrix); 1091 fCoordTransform.reset(kCoordSet, matrix);
1092 } else { 1092 } else {
1093 // doesn't matter how this is set, just be consistent because it is part of the effect key. 1093 // doesn't matter how this is set, just be consistent because it is part of the effect key.
1094 fPremulType = kBeforeInterp_PremulType; 1094 fPremulType = kBeforeInterp_PremulType;
1095 SkBitmap bitmap; 1095 SkBitmap bitmap;
1096 shader.getGradientTableBitmap(&bitmap); 1096 shader.getGradientTableBitmap(&bitmap);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 (*stops)[i] = stop; 1195 (*stops)[i] = stop;
1196 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f; 1196 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f;
1197 } 1197 }
1198 } 1198 }
1199 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount)); 1199 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount));
1200 1200
1201 return outColors; 1201 return outColors;
1202 } 1202 }
1203 1203
1204 #endif 1204 #endif
OLDNEW
« no previous file with comments | « no previous file | src/effects/gradients/SkGradientShaderPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698