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

michael@0 1
michael@0 2 /*
michael@0 3 * Copyright 2006 The Android Open Source Project
michael@0 4 *
michael@0 5 * Use of this source code is governed by a BSD-style license that can be
michael@0 6 * found in the LICENSE file.
michael@0 7 */
michael@0 8
michael@0 9
michael@0 10 #ifndef SkGraphics_DEFINED
michael@0 11 #define SkGraphics_DEFINED
michael@0 12
michael@0 13 #include "SkTypes.h"
michael@0 14
michael@0 15 class SK_API SkGraphics {
michael@0 16 public:
michael@0 17 /**
michael@0 18 * Call this at process initialization time if your environment does not
michael@0 19 * permit static global initializers that execute code. Note that
michael@0 20 * Init() is not thread-safe.
michael@0 21 */
michael@0 22 static void Init();
michael@0 23
michael@0 24 /**
michael@0 25 * Call this to release any memory held privately, such as the font cache.
michael@0 26 */
michael@0 27 static void Term();
michael@0 28
michael@0 29 /**
michael@0 30 * Return the version numbers for the library. If the parameter is not
michael@0 31 * null, it is set to the version number.
michael@0 32 */
michael@0 33 static void GetVersion(int32_t* major, int32_t* minor, int32_t* patch);
michael@0 34
michael@0 35 /**
michael@0 36 * Return the max number of bytes that should be used by the font cache.
michael@0 37 * If the cache needs to allocate more, it will purge previous entries.
michael@0 38 * This max can be changed by calling SetFontCacheLimit().
michael@0 39 */
michael@0 40 static size_t GetFontCacheLimit();
michael@0 41
michael@0 42 /**
michael@0 43 * Specify the max number of bytes that should be used by the font cache.
michael@0 44 * If the cache needs to allocate more, it will purge previous entries.
michael@0 45 *
michael@0 46 * This function returns the previous setting, as if GetFontCacheLimit()
michael@0 47 * had be called before the new limit was set.
michael@0 48 */
michael@0 49 static size_t SetFontCacheLimit(size_t bytes);
michael@0 50
michael@0 51 /**
michael@0 52 * Return the number of bytes currently used by the font cache.
michael@0 53 */
michael@0 54 static size_t GetFontCacheUsed();
michael@0 55
michael@0 56 /**
michael@0 57 * Return the number of entries in the font cache.
michael@0 58 * A cache "entry" is associated with each typeface + pointSize + matrix.
michael@0 59 */
michael@0 60 static int GetFontCacheCountUsed();
michael@0 61
michael@0 62 /**
michael@0 63 * Return the current limit to the number of entries in the font cache.
michael@0 64 * A cache "entry" is associated with each typeface + pointSize + matrix.
michael@0 65 */
michael@0 66 static int GetFontCacheCountLimit();
michael@0 67
michael@0 68 /**
michael@0 69 * Set the limit to the number of entries in the font cache, and return
michael@0 70 * the previous value. If this new value is lower than the previous,
michael@0 71 * it will automatically try to purge entries to meet the new limit.
michael@0 72 */
michael@0 73 static int SetFontCacheCountLimit(int count);
michael@0 74
michael@0 75 /**
michael@0 76 * For debugging purposes, this will attempt to purge the font cache. It
michael@0 77 * does not change the limit, but will cause subsequent font measures and
michael@0 78 * draws to be recreated, since they will no longer be in the cache.
michael@0 79 */
michael@0 80 static void PurgeFontCache();
michael@0 81
michael@0 82 static size_t GetImageCacheBytesUsed();
michael@0 83 static size_t GetImageCacheByteLimit();
michael@0 84 static size_t SetImageCacheByteLimit(size_t newLimit);
michael@0 85
michael@0 86 /**
michael@0 87 * Applications with command line options may pass optional state, such
michael@0 88 * as cache sizes, here, for instance:
michael@0 89 * font-cache-limit=12345678
michael@0 90 *
michael@0 91 * The flags format is name=value[;name=value...] with no spaces.
michael@0 92 * This format is subject to change.
michael@0 93 */
michael@0 94 static void SetFlags(const char* flags);
michael@0 95
michael@0 96 /**
michael@0 97 * Return the max number of bytes that should be used by the thread-local
michael@0 98 * font cache.
michael@0 99 * If the cache needs to allocate more, it will purge previous entries.
michael@0 100 * This max can be changed by calling SetFontCacheLimit().
michael@0 101 *
michael@0 102 * If this thread has never called SetTLSFontCacheLimit, or has called it
michael@0 103 * with 0, then this thread is using the shared font cache. In that case,
michael@0 104 * this function will always return 0, and the caller may want to call
michael@0 105 * GetFontCacheLimit.
michael@0 106 */
michael@0 107 static size_t GetTLSFontCacheLimit();
michael@0 108
michael@0 109 /**
michael@0 110 * Specify the max number of bytes that should be used by the thread-local
michael@0 111 * font cache. If this value is 0, then this thread will use the shared
michael@0 112 * global font cache.
michael@0 113 */
michael@0 114 static void SetTLSFontCacheLimit(size_t bytes);
michael@0 115
michael@0 116 private:
michael@0 117 /** This is automatically called by SkGraphics::Init(), and must be
michael@0 118 implemented by the host OS. This allows the host OS to register a callback
michael@0 119 with the C++ runtime to call SkGraphics::FreeCaches()
michael@0 120 */
michael@0 121 static void InstallNewHandler();
michael@0 122 };
michael@0 123
michael@0 124 class SkAutoGraphics {
michael@0 125 public:
michael@0 126 SkAutoGraphics() {
michael@0 127 SkGraphics::Init();
michael@0 128 }
michael@0 129 ~SkAutoGraphics() {
michael@0 130 SkGraphics::Term();
michael@0 131 }
michael@0 132 };
michael@0 133
michael@0 134 #endif

mercurial