1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/animator/SkGetCondensedInfo.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,121 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2006 The Android Open Source Project 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 + 1.12 + 1.13 +#include "SkMemberInfo.h" 1.14 + 1.15 +#if SK_USE_CONDENSED_INFO == 1 1.16 + 1.17 +// SkCondensed.cpp is auto-generated 1.18 +// To generate it, execute SkDisplayType::BuildCondensedInfo() 1.19 +#ifdef SK_DEBUG 1.20 +#include "SkCondensedDebug.cpp" 1.21 +#else 1.22 +#include "SkCondensedRelease.cpp" 1.23 +#endif 1.24 + 1.25 +static int _searchByName(const unsigned char* lengths, int count, const char* strings, const char target[]) { 1.26 + int lo = 0; 1.27 + int hi = count - 1; 1.28 + while (lo < hi) { 1.29 + int mid = (hi + lo) >> 1; 1.30 + if (strcmp(&strings[lengths[mid << 2]], target) < 0) 1.31 + lo = mid + 1; 1.32 + else 1.33 + hi = mid; 1.34 + } 1.35 + if (strcmp(&strings[lengths[hi << 2]], target) != 0) 1.36 + return -1; 1.37 + return hi; 1.38 +} 1.39 + 1.40 +static int _searchByType(SkDisplayTypes type) { 1.41 + unsigned char match = (unsigned char) type; 1.42 + int lo = 0; 1.43 + int hi = kTypeIDs - 1; 1.44 + while (lo < hi) { 1.45 + int mid = (hi + lo) >> 1; 1.46 + if (gTypeIDs[mid] < match) 1.47 + lo = mid + 1; 1.48 + else 1.49 + hi = mid; 1.50 + } 1.51 + if (gTypeIDs[hi] != type) 1.52 + return -1; 1.53 + return hi; 1.54 +} 1.55 + 1.56 +const SkMemberInfo* SkDisplayType::GetMembers(SkAnimateMaker* , SkDisplayTypes type, int* infoCountPtr) { 1.57 + int lookup = _searchByType(type); 1.58 + if (lookup < 0) 1.59 + return NULL; 1.60 + if (infoCountPtr) 1.61 + *infoCountPtr = gInfoCounts[lookup]; 1.62 + return gInfoTables[lookup]; 1.63 +} 1.64 + 1.65 +// !!! replace with inline 1.66 +const SkMemberInfo* SkDisplayType::GetMember(SkAnimateMaker* , SkDisplayTypes type, const char** matchPtr ) { 1.67 + const SkMemberInfo* info = SkMemberInfo::Find(type, matchPtr); 1.68 + SkASSERT(info); 1.69 + return info; 1.70 +} 1.71 + 1.72 +static const SkMemberInfo* _lookup(int lookup, const char** matchPtr) { 1.73 + int count = gInfoCounts[lookup]; 1.74 + const SkMemberInfo* info = gInfoTables[lookup]; 1.75 + if (info->fType == SkType_BaseClassInfo) { 1.76 + int baseTypeLookup = info->fOffset; 1.77 + const SkMemberInfo* result = _lookup(baseTypeLookup, matchPtr); 1.78 + if (result != NULL) 1.79 + return result; 1.80 + if (--count == 0) 1.81 + return NULL; 1.82 + info++; 1.83 + } 1.84 + SkASSERT(info->fType != SkType_BaseClassInfo); 1.85 + const char* match = *matchPtr; 1.86 + const char* strings = gInfoNames[lookup]; 1.87 + int index = _searchByName(&info->fName, count, strings, match); 1.88 + if (index < 0) 1.89 + return NULL; 1.90 + return &info[index]; 1.91 +} 1.92 + 1.93 +const SkMemberInfo* SkMemberInfo::Find(SkDisplayTypes type, int* index) { 1.94 + int count = gInfoCounts[lookup]; 1.95 + const SkMemberInfo* info = gInfoTables[lookup]; 1.96 + if (info->fType == SkType_BaseClassInfo) { 1.97 + int baseTypeLookup = info->fOffset; 1.98 + const SkMemberInfo* result = Find(baseTypeLookup, index); 1.99 + if (result != NULL) 1.100 + return result; 1.101 + if (--count == 0) 1.102 + return NULL; 1.103 + info++; 1.104 + } 1.105 + SkASSERT(info->fType != SkType_BaseClassInfo); 1.106 + if (*index >= count) { 1.107 + *index -= count; 1.108 + return NULL; 1.109 + } 1.110 + return &info[index]; 1.111 +} 1.112 + 1.113 +const SkMemberInfo* SkMemberInfo::Find(SkDisplayTypes type, const char** matchPtr) { 1.114 + int lookup = _searchByType(type); 1.115 + SkASSERT(lookup >= 0); 1.116 + return _lookup(lookup, matchPtr); 1.117 +} 1.118 + 1.119 +const SkMemberInfo* SkMemberInfo::getInherited() const { 1.120 + int baseTypeLookup = fOffset; 1.121 + return gInfoTables[baseTypeLookup]; 1.122 +} 1.123 + 1.124 +#endif