OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2013 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 | |
8 #ifndef SkValidationUtils_DEFINED | |
9 #define SkValidationUtils_DEFINED | |
10 | |
11 #include "SkBitmap.h" | |
12 #include "SkXfermode.h" | |
13 | |
14 /** Returns true if coeff's value is in the SkXfermode::Coeff enum. | |
15 */ | |
16 static inline bool SkIsValidCoeff(SkXfermode::Coeff coeff) { | |
17 return coeff >= 0 && coeff < SkXfermode::kCoeffCount; | |
18 } | |
19 | |
20 /** Returns true if mode's value is in the SkXfermode::Mode enum. | |
21 */ | |
22 static inline bool SkIsValidMode(SkXfermode::Mode mode) { | |
23 return (mode >= 0) && (mode <= SkXfermode::kLastMode); | |
24 } | |
25 | |
26 /** Returns true if config's value is in the SkBitmap::Config enum. | |
27 */ | |
28 static inline bool SkIsValidConfig(SkBitmap::Config config) { | |
29 return (config >= 0) && (config <= SkBitmap::kLastConfig); | |
30 } | |
31 | |
32 /** Returns true if the rect's dimensions are between 0 and SK_MaxS32 | |
33 */ | |
34 static inline bool SkIsValidRect(const SkIRect& rect) { | |
35 return !rect.isInverted() && | |
36 // Make sure width() and height() are also valid | |
37 ((rect.fLeft >= 0) || (rect.fRight <= 0) || | |
reed1
2013/09/04 20:37:41
Is this section the same as
rect.width() >= 0 &&
| |
38 ((rect.fRight - SK_MaxS32) <= rect.fLeft)) && | |
39 ((rect.fTop >= 0) || (rect.fBottom <= 0) || | |
40 ((rect.fBottom - SK_MaxS32) <= rect.fTop)); | |
41 } | |
42 | |
43 /** Returns true if the rect's dimensions are between 0 and SK_ScalarMax | |
44 */ | |
45 static inline bool SkIsValidRect(const SkRect& rect) { | |
46 return SkScalarIsFinite(rect.fLeft) && | |
reed1
2013/09/04 20:37:41
Is all of this the same as
return !rect.inverted(
| |
47 SkScalarIsFinite(rect.fTop) && | |
48 SkScalarIsFinite(rect.fRight) && | |
49 SkScalarIsFinite(rect.fBottom) && | |
50 !rect.isInverted() && | |
51 // Make sure width() and height() are also valid | |
52 ((rect.fLeft >= 0) || (rect.fRight <= 0) || | |
53 ((rect.fRight - SK_ScalarMax) <= rect.fLeft)) && | |
54 ((rect.fTop >= 0) || (rect.fBottom <= 0) || | |
55 ((rect.fBottom - SK_ScalarMax) <= rect.fTop)); | |
56 } | |
57 | |
58 #endif | |
OLD | NEW |