Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkValidationUtils.h
Go to the documentation of this file.
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
13
14/** Returns true if mode's value is in the SkBlendMode enum.
15 */
16static inline bool SkIsValidMode(SkBlendMode mode) {
17 return (unsigned)mode <= (unsigned)SkBlendMode::kLastMode;
18}
19
20/** Returns true if the rect's dimensions are between 0 and SK_MaxS32
21 */
22static inline bool SkIsValidIRect(const SkIRect& rect) {
23 return rect.width() >= 0 && rect.height() >= 0;
24}
25
26/** Returns true if the rect's dimensions are between 0 and SK_ScalarMax
27 */
28static inline bool SkIsValidRect(const SkRect& rect) {
29 return (rect.fLeft <= rect.fRight) &&
30 (rect.fTop <= rect.fBottom) &&
31 SkIsFinite(rect.width(), rect.height());
32}
33
34#endif
SkBlendMode
Definition SkBlendMode.h:38
@ kLastMode
last valid value
static bool SkIsFinite(T x, Pack... values)
static bool SkIsValidRect(const SkRect &rect)
static bool SkIsValidMode(SkBlendMode mode)
static bool SkIsValidIRect(const SkIRect &rect)