ブログトップ 記事一覧 ログイン 無料ブログ開設

のねの日記 - human brain programing

2014-12-22

setDefault

| 09:24 | setDefaultを含むブックマーク setDefaultのブックマークコメント

     84     private static void setDefault(Typeface t) {
     85         sDefaultTypeface = t;
     86         nativeSetDefault(t.native_instance);
     87     }
Cross Reference: /frameworks/base/graphics/java/android/graphics/Typeface.java
     65 static void Typeface_setDefault(JNIEnv *env, jobject, jlong faceHandle) {
     66     TypefaceImpl* face = reinterpret_cast<TypefaceImpl*>(faceHandle);
     67     return TypefaceImpl_setDefault(face);
     68 }
Cross Reference: /frameworks/base/core/jni/android/graphics/Typeface.cpp
    177 void TypefaceImpl_setDefault(TypefaceImpl* face) {
    178     gDefaultTypeface = face;
    179 }
  55 TypefaceImpl* gDefaultTypeface = NULL;
Cross Reference: /frameworks/base/core/jni/android/graphics/TypefaceImpl.cpp
    102 TypefaceImpl* TypefaceImpl_resolveDefault(TypefaceImpl* src) {
    103     if (src == NULL) {
    104         pthread_once(&gDefaultTypefaceOnce, getDefaultTypefaceOnce);
    105         return gDefaultTypeface;
    106     } else {
    107         return src;
    108     }
    109 }
     89 static void getDefaultTypefaceOnce() {
     90     Layout::init();
     91     if (gDefaultTypeface == NULL) {
     92         // We expect the client to set a default typeface, but provide a
     93         // default so we can make progress before that happens.
     94         gDefaultTypeface = new TypefaceImpl;
     95         gDefaultTypeface->fFontCollection = makeFontCollection();
     96         gDefaultTypeface->fSkiaStyle = SkTypeface::kNormal;
     97         gDefaultTypeface->fBaseWeight = 400;
     98         resolveStyle(gDefaultTypeface);
     99     }
    100 }
Cross Reference: /frameworks/base/core/jni/android/graphics/TypefaceImpl.cpp

2014-12-18

PurgeFontCache

23:02 | PurgeFontCacheを含むブックマーク PurgeFontCacheのブックマークコメント

    129 void SkGraphics::Term() {
    130     PurgeFontCache();
    131     SkPaint::Term();
    132 }
Cross Reference: /external/skia/src/core/SkGraphics.cpp
    750 void SkGraphics::PurgeFontCache() {
    751     getSharedGlobals().purgeAll();
    752     SkTypefaceCache::PurgeAll();
    753 }
Cross Reference: /external/skia/src/core/SkGlyphCache.cpp

ConfigurationChanged

22:56 | ConfigurationChangedを含むブックマーク ConfigurationChangedのブックマークコメント

   4098     final void handleActivityConfigurationChanged(IBinder token) {
   4099         ActivityClientRecord r = mActivities.get(token);
   4100         if (r == null || r.activity == null) {
   4101             return;
   4102         }
   4103 
   4104         if (DEBUG_CONFIGURATION) Slog.v(TAG, "Handle activity config changed: "
   4105                 + r.activityInfo.name);
   4106 
   4107         performConfigurationChanged(r.activity, mCompatConfiguration);
   4108 
   4109         freeTextLayoutCachesIfNeeded(r.activity.mCurrentConfig.diff(mCompatConfiguration));
   4110 
   4111         mSomeActivitiesChanged = true;
   4112     }
 4087     static void freeTextLayoutCachesIfNeeded(int configDiff) {
   4088         if (configDiff != 0) {
   4089             // Ask text layout engine to free its caches if there is a locale change
   4090             boolean hasLocaleConfigChange = ((configDiff & ActivityInfo.CONFIG_LOCALE) != 0);
   4091             if (hasLocaleConfigChange) {
   4092                 Canvas.freeTextLayoutCaches();
   4093                 if (DEBUG_CONFIGURATION) Slog.v(TAG, "Cleared TextLayout Caches");
   4094             }
   4095         }
   4096     }
Cross Reference: /frameworks/base/core/java/android/app/ActivityThread.java

Cache

22:48 | Cacheを含むブックマーク Cacheのブックマークコメント

   4186     final void handleLowMemory() {
   4187         ArrayList<ComponentCallbacks2> callbacks = collectComponentCallbacks(true, null);
   4188 
   4189         final int N = callbacks.size();
   4190         for (int i=0; i<N; i++) {
   4191             callbacks.get(i).onLowMemory();
   4192         }
   4193 
   4194         // Ask SQLite to free up as much memory as it can, mostly from its page caches.
   4195         if (Process.myUid() != Process.SYSTEM_UID) {
   4196             int sqliteReleased = SQLiteDatabase.releaseMemory();
   4197             EventLog.writeEvent(SQLITE_MEM_RELEASED_EVENT_LOG_TAG, sqliteReleased);
   4198         }
   4199 
   4200         // Ask graphics to free up as much as possible (font/image caches)
   4201         Canvas.freeCaches();
   4202 
   4203         // Ask text layout engine to free also as much as possible
   4204         Canvas.freeTextLayoutCaches();
   4205 
   4206         BinderInternal.forceGc("mem");
   4207     }
Cross Reference: /frameworks/base/core/java/android/app/ActivityThread.java
    673 static void freeCaches(JNIEnv* env, jobject) {
    674     SkGraphics::PurgeFontCache();
    675 }
    677 static void freeTextLayoutCaches(JNIEnv* env, jobject) {
    678     Layout::purgeCaches();
    679 }
    683 static JNINativeMethod gMethods[] = {
    734     {"freeCaches", "()V", (void*) CanvasJNI::freeCaches},
    735     {"freeTextLayoutCaches", "()V", (void*) CanvasJNI::freeTextLayoutCaches}
    736 };
Cross Reference: /frameworks/base/core/jni/android_graphics_Canvas.cpp

2014-12-17

PTHREAD_ONCE_INIT

10:41 | PTHREAD_ONCE_INITを含むブックマーク PTHREAD_ONCE_INITのブックマークコメント

    125 #define PTHREAD_ONCE_INIT 0
Cross Reference: /bionic/libc/include/pthread.h
    37 /* NOTE: this implementation doesn't support a init function that throws a C++ exception
     38  *       or calls fork()
     39  */
     40 int pthread_once(pthread_once_t* once_control, void (*init_routine)(void)) {
     41   volatile pthread_once_t* once_control_ptr = once_control;
     42 
     43   // PTHREAD_ONCE_INIT is 0, we use the following bit flags
     44   //   bit 0 set  -> initialization is under way
     45   //   bit 1 set  -> initialization is complete
     46 
     47   // First check if the once is already initialized. This will be the common
     48   // case and we want to make this as fast as possible. Note that this still
     49   // requires a load_acquire operation here to ensure that all the
     50   // stores performed by the initialization function are observable on
     51   // this CPU after we exit.
     52   if (__predict_true((*once_control_ptr & ONCE_COMPLETED) != 0)) {
     53     ANDROID_MEMBAR_FULL();
     54     return 0;
     55   }
     56 
     57   while (true) {
     58     // Try to atomically set the INITIALIZING flag.
     59     // This requires a cmpxchg loop, and we may need
     60     // to exit prematurely if we detect that
     61     // COMPLETED is now set.
     62     int32_t  old_value, new_value;
     63 
     64     do {
     65       old_value = *once_control_ptr;
     66       if ((old_value & ONCE_COMPLETED) != 0) {
     67         break;
     68       }
     69 
     70       new_value = old_value | ONCE_INITIALIZING;
     71     } while (__bionic_cmpxchg(old_value, new_value, once_control_ptr) != 0);
     72 
     73     if ((old_value & ONCE_COMPLETED) != 0) {
     74       // We detected that COMPLETED was set while in our loop.
     75       ANDROID_MEMBAR_FULL();
     76       return 0;
     77     }
     78 
     79     if ((old_value & ONCE_INITIALIZING) == 0) {
     80       // We got there first, we can jump out of the loop to handle the initialization.
     81       break;
     82     }
     83 
     84     // Another thread is running the initialization and hasn't completed
     85     // yet, so wait for it, then try again.
     86     __futex_wait_ex(once_control_ptr, 0, old_value, NULL);
     87   }
     88 
     89   // Call the initialization function.
     90   (*init_routine)();
     91 
     92   // Do a store_release indicating that initialization is complete.
     93   ANDROID_MEMBAR_FULL();
     94   *once_control_ptr = ONCE_COMPLETED;
     95 
     96   // Wake up any waiters, if any.
     97   __futex_wake_ex(once_control_ptr, 0, INT_MAX);
     98 
     99   return 0;
    100 }
Cross Reference: /bionic/libc/bionic/pthread_once.cpp