blob: 9e78dde5e414549575232236145d448870d41f0d [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@android.com8a1c16f2008-12-17 15:59:43 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2006 The Android Open Source Project
reed@android.com8a1c16f2008-12-17 15:59:43 +00004 *
epoger@google.comec3ed6a2011-07-28 14:26:00 +00005 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@android.com8a1c16f2008-12-17 15:59:43 +00007 */
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
reed@android.com8a1c16f2008-12-17 15:59:43 +000010#ifndef SkGraphics_DEFINED
11#define SkGraphics_DEFINED
12
13#include "SkTypes.h"
14
reed@google.comeb9a9bf2012-04-23 13:43:30 +000015class SK_API SkGraphics {
reed@android.com8a1c16f2008-12-17 15:59:43 +000016public:
caryclark@google.comd26147a2011-12-15 14:16:43 +000017 /**
18 * Call this at process initialization time if your environment does not
19 * permit static global initializers that execute code. Note that
20 * Init() is not thread-safe.
21 */
reed@android.com5e5adfd2009-03-07 03:39:23 +000022 static void Init();
caryclark@google.comd26147a2011-12-15 14:16:43 +000023
caryclark@google.comf86ab842011-12-16 17:11:17 +000024 /**
25 * Call this to release any memory held privately, such as the font cache.
26 */
reed@android.com8a1c16f2008-12-17 15:59:43 +000027 static void Term();
28
reed@google.com77407ca2011-11-08 13:48:32 +000029 /**
30 * Return the version numbers for the library. If the parameter is not
31 * null, it is set to the version number.
reed@android.com9aa8b322010-04-13 13:22:54 +000032 */
33 static void GetVersion(int32_t* major, int32_t* minor, int32_t* patch);
34
reed@google.com77407ca2011-11-08 13:48:32 +000035 /**
36 * Return the max number of bytes that should be used by the font cache.
37 * If the cache needs to allocate more, it will purge previous entries.
38 * This max can be changed by calling SetFontCacheLimit().
39 */
40 static size_t GetFontCacheLimit();
41
42 /**
43 * Specify the max number of bytes that should be used by the font cache.
44 * If the cache needs to allocate more, it will purge previous entries.
45 *
46 * This function returns the previous setting, as if GetFontCacheLimit()
47 * had be called before the new limit was set.
48 */
49 static size_t SetFontCacheLimit(size_t bytes);
50
reed@google.com073c9072011-11-08 20:03:48 +000051 /**
52 * For debugging purposes, this will attempt to purge the font cache. It
53 * does not change the limit, but will cause subsequent font measures and
54 * draws to be recreated, since they will no longer be in the cache.
55 */
56 static void PurgeFontCache();
caryclark@google.com54c782c2011-11-21 20:42:14 +000057
58 /**
59 * Applications with command line options may pass optional state, such
60 * as cache sizes, here, for instance:
61 * font-cache-limit=12345678
62 *
63 * The flags format is name=value[;name=value...] with no spaces.
64 * This format is subject to change.
65 */
66 static void SetFlags(const char* flags);
caryclark@google.comd26147a2011-12-15 14:16:43 +000067
reed@android.com8a1c16f2008-12-17 15:59:43 +000068private:
69 /** This is automatically called by SkGraphics::Init(), and must be
70 implemented by the host OS. This allows the host OS to register a callback
71 with the C++ runtime to call SkGraphics::FreeCaches()
72 */
73 static void InstallNewHandler();
74};
75
reed@android.com8015dd82009-06-21 00:49:18 +000076class SkAutoGraphics {
77public:
78 SkAutoGraphics() {
79 SkGraphics::Init();
80 }
81 ~SkAutoGraphics() {
82 SkGraphics::Term();
83 }
84};
85
reed@android.com8a1c16f2008-12-17 15:59:43 +000086#endif
87