gfx/skia/trunk/src/core/SkValidationUtils.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /*
michael@0 2 * Copyright 2013 Google Inc.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license that can be
michael@0 5 * found in the LICENSE file.
michael@0 6 */
michael@0 7
michael@0 8 #ifndef SkValidationUtils_DEFINED
michael@0 9 #define SkValidationUtils_DEFINED
michael@0 10
michael@0 11 #include "SkBitmap.h"
michael@0 12 #include "SkXfermode.h"
michael@0 13
michael@0 14 /** Returns true if coeff's value is in the SkXfermode::Coeff enum.
michael@0 15 */
michael@0 16 static inline bool SkIsValidCoeff(SkXfermode::Coeff coeff) {
michael@0 17 return coeff >= 0 && coeff < SkXfermode::kCoeffCount;
michael@0 18 }
michael@0 19
michael@0 20 /** Returns true if mode's value is in the SkXfermode::Mode enum.
michael@0 21 */
michael@0 22 static inline bool SkIsValidMode(SkXfermode::Mode mode) {
michael@0 23 return (mode >= 0) && (mode <= SkXfermode::kLastMode);
michael@0 24 }
michael@0 25
michael@0 26 /** Returns true if config's value is in the SkBitmap::Config enum.
michael@0 27 */
michael@0 28 static inline bool SkIsValidConfig(SkBitmap::Config config) {
michael@0 29 return (config >= 0) && (config <= static_cast<int>(SkBitmap::kConfigCount));
michael@0 30 }
michael@0 31
michael@0 32 /** Returns true if the rect's dimensions are between 0 and SK_MaxS32
michael@0 33 */
michael@0 34 static inline bool SkIsValidIRect(const SkIRect& rect) {
michael@0 35 return rect.width() >= 0 && rect.height() >= 0;
michael@0 36 }
michael@0 37
michael@0 38 /** Returns true if the rect's dimensions are between 0 and SK_ScalarMax
michael@0 39 */
michael@0 40 static inline bool SkIsValidRect(const SkRect& rect) {
michael@0 41 return (rect.fLeft <= rect.fRight) &&
michael@0 42 (rect.fTop <= rect.fBottom) &&
michael@0 43 SkScalarIsFinite(rect.width()) &&
michael@0 44 SkScalarIsFinite(rect.height());
michael@0 45 }
michael@0 46
michael@0 47 #endif

mercurial