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

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

Issue 2397473003: Harden degenerate gradient context handling (Closed)
Patch Set: Created 4 years, 2 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 "Sk4fLinearGradient.h" 8 #include "Sk4fLinearGradient.h"
9 #include "SkGradientShaderPriv.h" 9 #include "SkGradientShaderPriv.h"
10 #include "SkHalf.h" 10 #include "SkHalf.h"
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 390
391 // now convert our colors in to PMColors 391 // now convert our colors in to PMColors
392 unsigned paintAlpha = this->getPaintAlpha(); 392 unsigned paintAlpha = this->getPaintAlpha();
393 393
394 fFlags = this->INHERITED::getFlags(); 394 fFlags = this->INHERITED::getFlags();
395 if (shader.fColorsAreOpaque && paintAlpha == 0xFF) { 395 if (shader.fColorsAreOpaque && paintAlpha == 0xFF) {
396 fFlags |= kOpaqueAlpha_Flag; 396 fFlags |= kOpaqueAlpha_Flag;
397 } 397 }
398 } 398 }
399 399
400 bool SkGradientShaderBase::GradientShaderBaseContext::isValid() const {
401 return fDstToIndex.isFinite();
402 }
403
400 SkGradientShaderBase::GradientShaderCache::GradientShaderCache( 404 SkGradientShaderBase::GradientShaderCache::GradientShaderCache(
401 U8CPU alpha, bool dither, const SkGradientShaderBase& shader) 405 U8CPU alpha, bool dither, const SkGradientShaderBase& shader)
402 : fCacheAlpha(alpha) 406 : fCacheAlpha(alpha)
403 , fCacheDither(dither) 407 , fCacheDither(dither)
404 , fShader(shader) 408 , fShader(shader)
405 { 409 {
406 // Only initialize the cache in getCache32. 410 // Only initialize the cache in getCache32.
407 fCache32 = nullptr; 411 fCache32 = nullptr;
408 fCache32PixelRef = nullptr; 412 fCache32PixelRef = nullptr;
409 } 413 }
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 (*stops)[i] = stop; 1741 (*stops)[i] = stop;
1738 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f; 1742 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f;
1739 } 1743 }
1740 } 1744 }
1741 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount)); 1745 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount));
1742 1746
1743 return outColors; 1747 return outColors;
1744 } 1748 }
1745 1749
1746 #endif 1750 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/Sk4fGradientBase.cpp ('k') | src/effects/gradients/SkGradientShaderPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698