1 /* libs/graphics/sgl/SkGraphics.cpp 2 ** 3 ** Copyright 2006, The Android Open Source Project 4 ** 5 ** Licensed under the Apache License, Version 2.0 (the "License"); 6 ** you may not use this file except in compliance with the License. 7 ** You may obtain a copy of the License at 8 ** 9 ** http://www.apache.org/licenses/LICENSE-2.0 10 ** 11 ** Unless required by applicable law or agreed to in writing, software 12 ** distributed under the License is distributed on an "AS IS" BASIS, 13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 ** See the License for the specific language governing permissions and 15 ** limitations under the License. 16 */ 17 18 #include "SkGraphics.h" 19 20 #include "Sk64.h" 21 #include "SkBlitter.h" 22 #include "SkCanvas.h" 23 #include "SkFloat.h" 24 #include "SkGeometry.h" 25 #include "SkGlobals.h" 26 #include "SkMath.h" 27 #include "SkMatrix.h" 28 #include "SkPath.h" 29 #include "SkPathEffect.h" 30 #include "SkRandom.h" 31 #include "SkRefCnt.h" 32 #include "SkScalerContext.h" 33 #include "SkShader.h" 34 #include "SkStream.h" 35 #include "SkTSearch.h" 36 #include "SkTime.h" 37 #include "SkUtils.h" 38 #include "SkXfermode.h" 39 40 #define typesizeline(type) { #type , sizeof(type) } 41 42 #ifdef BUILD_EMBOSS_TABLE 43 extern void SkEmbossMask_BuildTable(); 44 #endif 45 46 #ifdef BUILD_RADIALGRADIENT_TABLE 47 extern void SkRadialGradient_BuildTable(); 48 #endif 49 50 void SkGraphics::Init() { 51 SkGlobals::Init(); 52 53 #ifdef BUILD_EMBOSS_TABLE 54 SkEmbossMask_BuildTable(); 55 #endif 56 #ifdef BUILD_RADIALGRADIENT_TABLE 57 SkRadialGradient_BuildTable(); 58 #endif 59 60 #ifdef SK_DEBUGx 61 int i; 62 63 static const struct { 64 const char* fTypeName; 65 size_t fSizeOf; 66 } gTypeSize[] = { 67 typesizeline(char), 68 typesizeline(short), 69 typesizeline(int), 70 typesizeline(long), 71 typesizeline(size_t), 72 typesizeline(void*), 73 74 typesizeline(S8CPU), 75 typesizeline(U8CPU), 76 typesizeline(S16CPU), 77 typesizeline(U16CPU), 78 79 typesizeline(SkPoint), 80 typesizeline(SkRect), 81 typesizeline(SkMatrix), 82 typesizeline(SkPath), 83 typesizeline(SkGlyph), 84 typesizeline(SkRefCnt), 85 86 typesizeline(SkPaint), 87 typesizeline(SkCanvas), 88 typesizeline(SkBlitter), 89 typesizeline(SkShader), 90 typesizeline(SkXfermode), 91 typesizeline(SkPathEffect) 92 }; 93 94 #ifdef SK_CPU_BENDIAN 95 SkDebugf("SkGraphics: big-endian\n"); 96 #else 97 SkDebugf("SkGraphics: little-endian\n"); 98 #endif 99 100 { 101 char test = 0xFF; 102 int itest = test; // promote to int, see if it sign-extended 103 if (itest < 0) 104 SkDebugf("SkGraphics: char is signed\n"); 105 else 106 SkDebugf("SkGraphics: char is unsigned\n"); 107 } 108 for (i = 0; i < (int)SK_ARRAY_COUNT(gTypeSize); i++) { 109 SkDebugf("SkGraphics: sizeof(%s) = %d\n", 110 gTypeSize[i].fTypeName, gTypeSize[i].fSizeOf); 111 } 112 113 #endif 114 } 115 116 /////////////////////////////////////////////////////////////////////////////// 117 118 #include "SkGlyphCache.h" 119 120 void SkGraphics::Term() { 121 SkGraphics::SetFontCacheUsed(0); 122 SkGlobals::Term(); 123 } 124 125 size_t SkGraphics::GetFontCacheUsed() { 126 return SkGlyphCache::GetCacheUsed(); 127 } 128 129 bool SkGraphics::SetFontCacheUsed(size_t usageInBytes) { 130 return SkGlyphCache::SetCacheUsed(usageInBytes); 131 } 132 133 void SkGraphics::GetVersion(int32_t* major, int32_t* minor, int32_t* patch) { 134 if (major) { 135 *major = SKIA_VERSION_MAJOR; 136 } 137 if (minor) { 138 *minor = SKIA_VERSION_MINOR; 139 } 140 if (patch) { 141 *patch = SKIA_VERSION_PATCH; 142 } 143 } 144 145