gfx/skia/trunk/include/core/SkUnPreMultiply.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.

     2 /*
     3  * Copyright 2008 The Android Open Source Project
     4  *
     5  * Use of this source code is governed by a BSD-style license that can be
     6  * found in the LICENSE file.
     7  */
    13 #ifndef SkUnPreMultiply_DEFINED
    14 #define SkUnPreMultiply_DEFINED
    16 #include "SkColor.h"
    18 class SK_API SkUnPreMultiply {
    19 public:
    20     typedef uint32_t Scale;
    22     // index this table with alpha [0..255]
    23     static const Scale* GetScaleTable() {
    24         return gTable;
    25     }
    27     static Scale GetScale(U8CPU alpha) {
    28         SkASSERT(alpha <= 255);
    29         return gTable[alpha];
    30     }
    32     /** Usage:
    34         const Scale* table = SkUnPreMultiply::GetScaleTable();
    36         for (...) {
    37             unsigned a = ...
    38             SkUnPreMultiply::Scale scale = table[a];
    40             red = SkUnPreMultiply::ApplyScale(scale, red);
    41             ...
    42             // now red is unpremultiplied
    43         }
    44     */
    45     static U8CPU ApplyScale(Scale scale, U8CPU component) {
    46         SkASSERT(component <= 255);
    47         return (scale * component + (1 << 23)) >> 24;
    48     }
    50     static SkColor PMColorToColor(SkPMColor c);
    52     static uint32_t UnPreMultiplyPreservingByteOrder(SkPMColor c);
    54 private:
    55     static const uint32_t gTable[256];
    56 };
    58 #endif

mercurial