2011-07-28 14:26:00 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Copyright 2006 The Android Open Source Project
|
2008-12-17 15:59:43 +00:00
|
|
|
*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
|
2011-07-28 14:26:00 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
#ifndef SkGraphics_DEFINED
|
|
|
|
#define SkGraphics_DEFINED
|
|
|
|
|
|
|
|
#include "SkTypes.h"
|
|
|
|
|
2012-04-23 13:43:30 +00:00
|
|
|
class SK_API SkGraphics {
|
2008-12-17 15:59:43 +00:00
|
|
|
public:
|
2011-12-15 14:16:43 +00:00
|
|
|
/**
|
|
|
|
* Call this at process initialization time if your environment does not
|
2012-08-23 18:09:54 +00:00
|
|
|
* permit static global initializers that execute code. Note that
|
2011-12-15 14:16:43 +00:00
|
|
|
* Init() is not thread-safe.
|
|
|
|
*/
|
2009-03-07 03:39:23 +00:00
|
|
|
static void Init();
|
2011-12-15 14:16:43 +00:00
|
|
|
|
2011-12-16 17:11:17 +00:00
|
|
|
/**
|
|
|
|
* Call this to release any memory held privately, such as the font cache.
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
static void Term();
|
|
|
|
|
2011-11-08 13:48:32 +00:00
|
|
|
/**
|
|
|
|
* Return the version numbers for the library. If the parameter is not
|
|
|
|
* null, it is set to the version number.
|
|
|
|
*/
|
|
|
|
static void GetVersion(int32_t* major, int32_t* minor, int32_t* patch);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the max number of bytes that should be used by the font cache.
|
|
|
|
* If the cache needs to allocate more, it will purge previous entries.
|
|
|
|
* This max can be changed by calling SetFontCacheLimit().
|
2010-04-13 13:22:54 +00:00
|
|
|
*/
|
2011-11-08 13:48:32 +00:00
|
|
|
static size_t GetFontCacheLimit();
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2011-11-08 13:48:32 +00:00
|
|
|
/**
|
|
|
|
* Specify the max number of bytes that should be used by the font cache.
|
|
|
|
* If the cache needs to allocate more, it will purge previous entries.
|
|
|
|
*
|
|
|
|
* This function returns the previous setting, as if GetFontCacheLimit()
|
|
|
|
* had be called before the new limit was set.
|
|
|
|
*/
|
|
|
|
static size_t SetFontCacheLimit(size_t bytes);
|
2010-04-13 13:22:54 +00:00
|
|
|
|
2012-07-30 13:08:01 +00:00
|
|
|
/**
|
|
|
|
* Return the number of bytes currently used by the font cache.
|
|
|
|
*/
|
|
|
|
static size_t GetFontCacheUsed();
|
|
|
|
|
2011-11-08 20:03:48 +00:00
|
|
|
/**
|
|
|
|
* For debugging purposes, this will attempt to purge the font cache. It
|
|
|
|
* does not change the limit, but will cause subsequent font measures and
|
|
|
|
* draws to be recreated, since they will no longer be in the cache.
|
|
|
|
*/
|
|
|
|
static void PurgeFontCache();
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2011-11-21 20:42:14 +00:00
|
|
|
/**
|
|
|
|
* Applications with command line options may pass optional state, such
|
|
|
|
* as cache sizes, here, for instance:
|
|
|
|
* font-cache-limit=12345678
|
|
|
|
*
|
|
|
|
* The flags format is name=value[;name=value...] with no spaces.
|
|
|
|
* This format is subject to change.
|
|
|
|
*/
|
|
|
|
static void SetFlags(const char* flags);
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2012-05-17 13:38:03 +00:00
|
|
|
/**
|
|
|
|
* Return the max number of bytes that should be used by the thread-local
|
|
|
|
* font cache.
|
|
|
|
* If the cache needs to allocate more, it will purge previous entries.
|
|
|
|
* This max can be changed by calling SetFontCacheLimit().
|
|
|
|
*
|
|
|
|
* If this thread has never called SetTLSFontCacheLimit, or has called it
|
|
|
|
* with 0, then this thread is using the shared font cache. In that case,
|
|
|
|
* this function will always return 0, and the caller may want to call
|
|
|
|
* GetFontCacheLimit.
|
|
|
|
*/
|
|
|
|
static size_t GetTLSFontCacheLimit();
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2012-05-17 13:38:03 +00:00
|
|
|
/**
|
|
|
|
* Specify the max number of bytes that should be used by the thread-local
|
2012-05-17 13:50:36 +00:00
|
|
|
* font cache. If this value is 0, then this thread will use the shared
|
|
|
|
* global font cache.
|
2012-05-17 13:38:03 +00:00
|
|
|
*/
|
2012-05-17 13:50:36 +00:00
|
|
|
static void SetTLSFontCacheLimit(size_t bytes);
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
private:
|
|
|
|
/** This is automatically called by SkGraphics::Init(), and must be
|
|
|
|
implemented by the host OS. This allows the host OS to register a callback
|
|
|
|
with the C++ runtime to call SkGraphics::FreeCaches()
|
|
|
|
*/
|
|
|
|
static void InstallNewHandler();
|
|
|
|
};
|
|
|
|
|
2009-06-21 00:49:18 +00:00
|
|
|
class SkAutoGraphics {
|
|
|
|
public:
|
|
|
|
SkAutoGraphics() {
|
|
|
|
SkGraphics::Init();
|
|
|
|
}
|
|
|
|
~SkAutoGraphics() {
|
|
|
|
SkGraphics::Term();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
#endif
|