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

Side by Side Diff: include/core/SkMatrix.h

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
« no previous file with comments | « no previous file | src/effects/gradients/Sk4fGradientBase.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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkMatrix_DEFINED 10 #ifndef SkMatrix_DEFINED
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 unsigned mask = 0; 729 unsigned mask = 0;
730 if (sx != 1 || sy != 1) { 730 if (sx != 1 || sy != 1) {
731 mask |= kScale_Mask; 731 mask |= kScale_Mask;
732 } 732 }
733 if (tx || ty) { 733 if (tx || ty) {
734 mask |= kTranslate_Mask; 734 mask |= kTranslate_Mask;
735 } 735 }
736 this->setTypeMask(mask | kRectStaysRect_Mask); 736 this->setTypeMask(mask | kRectStaysRect_Mask);
737 } 737 }
738 738
739 /**
740 * Are all elements of the matrix finite?
741 */
742 bool isFinite() const { return SkScalarsAreFinite(fMat, 9); }
743
739 private: 744 private:
740 enum { 745 enum {
741 /** Set if the matrix will map a rectangle to another rectangle. This 746 /** Set if the matrix will map a rectangle to another rectangle. This
742 can be true if the matrix is scale-only, or rotates a multiple of 747 can be true if the matrix is scale-only, or rotates a multiple of
743 90 degrees. 748 90 degrees.
744 749
745 This bit will be set on identity matrices 750 This bit will be set on identity matrices
746 */ 751 */
747 kRectStaysRect_Mask = 0x10, 752 kRectStaysRect_Mask = 0x10,
748 753
(...skipping 12 matching lines...) Expand all
761 kAllMasks = kTranslate_Mask | 766 kAllMasks = kTranslate_Mask |
762 kScale_Mask | 767 kScale_Mask |
763 kAffine_Mask | 768 kAffine_Mask |
764 kPerspective_Mask | 769 kPerspective_Mask |
765 kRectStaysRect_Mask 770 kRectStaysRect_Mask
766 }; 771 };
767 772
768 SkScalar fMat[9]; 773 SkScalar fMat[9];
769 mutable uint32_t fTypeMask; 774 mutable uint32_t fTypeMask;
770 775
771 /** Are all elements of the matrix finite?
772 */
773 bool isFinite() const { return SkScalarsAreFinite(fMat, 9); }
774
775 static void ComputeInv(SkScalar dst[9], const SkScalar src[9], double invDet , bool isPersp); 776 static void ComputeInv(SkScalar dst[9], const SkScalar src[9], double invDet , bool isPersp);
776 777
777 uint8_t computeTypeMask() const; 778 uint8_t computeTypeMask() const;
778 uint8_t computePerspectiveTypeMask() const; 779 uint8_t computePerspectiveTypeMask() const;
779 780
780 void setTypeMask(int mask) { 781 void setTypeMask(int mask) {
781 // allow kUnknown or a valid mask 782 // allow kUnknown or a valid mask
782 SkASSERT(kUnknown_Mask == mask || (mask & kAllMasks) == mask || 783 SkASSERT(kUnknown_Mask == mask || (mask & kAllMasks) == mask ||
783 ((kUnknown_Mask | kOnlyPerspectiveValid_Mask) & mask) 784 ((kUnknown_Mask | kOnlyPerspectiveValid_Mask) & mask)
784 == (kUnknown_Mask | kOnlyPerspectiveValid_Mask)); 785 == (kUnknown_Mask | kOnlyPerspectiveValid_Mask));
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 static void Affine_vpts(const SkMatrix&, SkPoint dst[], const SkPoint[], int ); 841 static void Affine_vpts(const SkMatrix&, SkPoint dst[], const SkPoint[], int );
841 842
842 static const MapPtsProc gMapPtsProcs[]; 843 static const MapPtsProc gMapPtsProcs[];
843 844
844 friend class SkPerspIter; 845 friend class SkPerspIter;
845 friend class SkMatrixPriv; 846 friend class SkMatrixPriv;
846 }; 847 };
847 SK_END_REQUIRE_DENSE 848 SK_END_REQUIRE_DENSE
848 849
849 #endif 850 #endif
OLDNEW
« no previous file with comments | « no previous file | src/effects/gradients/Sk4fGradientBase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698