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

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 #ifndef SkBitmapProcState_utils_DEFINED
     2 #define SkBitmapProcState_utils_DEFINED
     4 // Helper to ensure that when we shift down, we do it w/o sign-extension
     5 // so the caller doesn't have to manually mask off the top 16 bits
     6 //
     7 static unsigned SK_USHIFT16(unsigned x) {
     8     return x >> 16;
     9 }
    11 /*
    12  *  The decal_ functions require that
    13  *  1. dx > 0
    14  *  2. [fx, fx+dx, fx+2dx, fx+3dx, ... fx+(count-1)dx] are all <= maxX
    15  *
    16  *  In addition, we use SkFractionalInt to keep more fractional precision than
    17  *  just SkFixed, so we will abort the decal_ call if dx is very small, since
    18  *  the decal_ function just operates on SkFixed. If that were changed, we could
    19  *  skip the very_small test here.
    20  */
    21 static inline bool can_truncate_to_fixed_for_decal(SkFractionalInt frX,
    22                                                    SkFractionalInt frDx,
    23                                                    int count, unsigned max) {
    24     SkFixed dx = SkFractionalIntToFixed(frDx);
    26     // if decal_ kept SkFractionalInt precision, this would just be dx <= 0
    27     // I just made up the 1/256. Just don't want to perceive accumulated error
    28     // if we truncate frDx and lose its low bits.
    29     if (dx <= SK_Fixed1 / 256) {
    30         return false;
    31     }
    33     // We cast to unsigned so we don't have to check for negative values, which
    34     // will now appear as very large positive values, and thus fail our test!
    35     SkFixed fx = SkFractionalIntToFixed(frX);
    36     return (unsigned)SkFixedFloorToInt(fx) <= max &&
    37            (unsigned)SkFixedFloorToInt(fx + dx * (count - 1)) < max;
    38 }
    40 #endif /* #ifndef SkBitmapProcState_utils_DEFINED */

mercurial