gfx/skia/trunk/src/core/SkDeviceProfile.cpp

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 /*
     2  * Copyright 2012 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  */
     9 #include "SkDeviceProfile.h"
    10 #include "SkThread.h"
    12 #define DEFAULT_GAMMAEXP        2.2f
    13 #define DEFAULT_CONTRASTSCALE   0.5f
    14 #define DEFAULT_LCDCONFIG       SkDeviceProfile::kNone_LCDConfig
    15 #define DEFAULT_FONTHINTLEVEL   SkDeviceProfile::kSlight_FontHintLevel
    17 static float pin(float value, float min, float max) {
    18     if (value < min) {
    19         value = min;
    20     } else if (value > max) {
    21         value = max;
    22     }
    23     return value;
    24 }
    26 SkDeviceProfile::SkDeviceProfile(float gammaExp, float contrast,
    27                                  LCDConfig config, FontHintLevel level) {
    28     fGammaExponent = pin(gammaExp, 0, 10);
    29     fContrastScale = pin(contrast, 0, 1);
    30     fLCDConfig = config;
    31     fFontHintLevel = level;
    32 }
    34 void SkDeviceProfile::generateTableForLuminanceByte(U8CPU lumByte,
    35                                                     uint8_t table[256]) const {
    36 }
    38 ///////////////////////////////////////////////////////////////////////////////
    40 SkDeviceProfile* SkDeviceProfile::Create(float gammaExp,
    41                                          float contrast,
    42                                          LCDConfig config,
    43                                          FontHintLevel level) {
    44     return SkNEW_ARGS(SkDeviceProfile, (gammaExp, contrast, config, level));
    45 }
    47 SK_DECLARE_STATIC_MUTEX(gMutex);
    48 static SkDeviceProfile* gDefaultProfile;
    49 static SkDeviceProfile* gGlobalProfile;
    51 SkDeviceProfile* SkDeviceProfile::GetDefault() {
    52     SkAutoMutexAcquire amc(gMutex);
    54     if (NULL == gDefaultProfile) {
    55         gDefaultProfile = SkDeviceProfile::Create(DEFAULT_GAMMAEXP,
    56                                                   DEFAULT_CONTRASTSCALE,
    57                                                   DEFAULT_LCDCONFIG,
    58                                                   DEFAULT_FONTHINTLEVEL);
    59     }
    60     return gDefaultProfile;
    61 }
    63 SkDeviceProfile* SkDeviceProfile::RefGlobal() {
    64     SkAutoMutexAcquire amc(gMutex);
    66     if (NULL == gGlobalProfile) {
    67         gGlobalProfile = SkDeviceProfile::GetDefault();
    68     }
    69     gGlobalProfile->ref();
    70     return gGlobalProfile;
    71 }
    73 void SkDeviceProfile::SetGlobal(SkDeviceProfile* profile) {
    74     SkAutoMutexAcquire amc(gMutex);
    76     SkRefCnt_SafeAssign(gGlobalProfile, profile);
    77 }

mercurial