Home | History | Annotate | Download | only in core
      1 /*
      2  * Copyright (C) 2006 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef SkGraphics_DEFINED
     18 #define SkGraphics_DEFINED
     19 
     20 #include "SkTypes.h"
     21 
     22 class SkGraphics {
     23 public:
     24     static void Init();
     25     static void Term();
     26 
     27     /** Return the (approximate) number of bytes used by the font cache.
     28     */
     29     static size_t GetFontCacheUsed();
     30 
     31     /** Attempt to purge the font cache until <= the specified amount remains
     32         in the cache. Specifying 0 will attempt to purge the entire cache.
     33         Returns true if some amount was purged from the font cache.
     34     */
     35     static bool SetFontCacheUsed(size_t usageInBytes);
     36 
     37     /** Return the version numbers for the library. If the parameter is not
     38         null, it is set to the version number.
     39      */
     40     static void GetVersion(int32_t* major, int32_t* minor, int32_t* patch);
     41 
     42 private:
     43     /** This is automatically called by SkGraphics::Init(), and must be
     44         implemented by the host OS. This allows the host OS to register a callback
     45         with the C++ runtime to call SkGraphics::FreeCaches()
     46     */
     47     static void InstallNewHandler();
     48 };
     49 
     50 class SkAutoGraphics {
     51 public:
     52     SkAutoGraphics() {
     53         SkGraphics::Init();
     54     }
     55     ~SkAutoGraphics() {
     56         SkGraphics::Term();
     57     }
     58 };
     59 
     60 #endif
     61 
     62