SkGraphics.h revision ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976e
1 2/* 3 * Copyright 2006 The Android Open Source Project 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9 10#ifndef SkGraphics_DEFINED 11#define SkGraphics_DEFINED 12 13#include "SkTypes.h" 14 15class SkGraphics { 16public: 17 static void Init(); 18 static void Term(); 19 20 /** Return the (approximate) number of bytes used by the font cache. 21 */ 22 static size_t GetFontCacheUsed(); 23 24 /** Attempt to purge the font cache until <= the specified amount remains 25 in the cache. Specifying 0 will attempt to purge the entire cache. 26 Returns true if some amount was purged from the font cache. 27 */ 28 static bool SetFontCacheUsed(size_t usageInBytes); 29 30 /** Return the version numbers for the library. If the parameter is not 31 null, it is set to the version number. 32 */ 33 static void GetVersion(int32_t* major, int32_t* minor, int32_t* patch); 34 35private: 36 /** This is automatically called by SkGraphics::Init(), and must be 37 implemented by the host OS. This allows the host OS to register a callback 38 with the C++ runtime to call SkGraphics::FreeCaches() 39 */ 40 static void InstallNewHandler(); 41}; 42 43class SkAutoGraphics { 44public: 45 SkAutoGraphics() { 46 SkGraphics::Init(); 47 } 48 ~SkAutoGraphics() { 49 SkGraphics::Term(); 50 } 51}; 52 53#endif 54 55