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"
|
|
|
|
|
|
|
|
class SkGraphics {
|
|
|
|
public:
|
2009-03-07 03:39:23 +00:00
|
|
|
static void Init();
|
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);
|
|
|
|
|
|
|
|
// Font Cache routines
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the (approximate) number of bytes used by the font cache.
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
static size_t GetFontCacheUsed();
|
|
|
|
|
2011-11-08 13:48:32 +00:00
|
|
|
/**
|
|
|
|
* Attempt to purge the font cache until <= the specified amount remains
|
|
|
|
* in the cache. Specifying 0 will attempt to purge the entire cache.
|
|
|
|
* Returns true if some amount was purged from the font cache.
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
static bool SetFontCacheUsed(size_t usageInBytes);
|
2010-04-13 13:22:54 +00:00
|
|
|
|
2011-11-08 13:48:32 +00:00
|
|
|
/**
|
|
|
|
* 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();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
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
|
|
|
|
|