LCOV - code coverage report
Current view: directory - gfx/skia/src/core - SkGlobals.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 38 0 0.0 %
Date: 2012-06-02 Functions: 5 0 0.0 %

       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                 : #include "SkGlobals.h"
      11                 : #include "SkThread.h"
      12                 : 
      13               0 : SkGlobals::Rec::~Rec()
      14                 : {
      15               0 : }
      16                 : 
      17               0 : SkGlobals::Rec* SkGlobals::Find(uint32_t tag, Rec* (*create_proc)())
      18                 : {
      19               0 :     SkGlobals::BootStrap&   bootstrap = SkGlobals::GetBootStrap();
      20                 : 
      21               0 :     Rec* rec = bootstrap.fHead;
      22               0 :     while (rec)
      23                 :     {
      24               0 :         if (rec->fTag == tag)
      25               0 :             return rec;
      26               0 :         rec = rec->fNext;
      27                 :     }
      28                 : 
      29               0 :     if (create_proc == NULL) // no create proc, just return not found
      30               0 :         return NULL;
      31                 : 
      32                 :     // if we get here, we may need to create one. First grab the mutex, and
      33                 :     // search again, creating one if its not found the 2nd time.
      34                 : 
      35               0 :     bootstrap.fMutex.acquire();
      36                 : 
      37                 :     // search again, now that we have the mutex. Odds are it won't be there, but we check again
      38                 :     // just in case it was added by another thread before we grabbed the mutex
      39                 : 
      40               0 :     Rec*& head = bootstrap.fHead;
      41               0 :     rec = head;
      42               0 :     while (rec)
      43                 :     {
      44               0 :         if (rec->fTag == tag)
      45               0 :             break;
      46               0 :         rec = rec->fNext;
      47                 :     }
      48                 : 
      49               0 :     if (rec == NULL && (rec = create_proc()) != NULL)
      50                 :     {
      51               0 :         rec->fTag = tag;
      52               0 :         rec->fNext = head;
      53               0 :         bootstrap.fHead = rec;
      54                 :     }
      55                 : 
      56               0 :     bootstrap.fMutex.release();
      57               0 :     return rec;
      58                 : }
      59                 : 
      60               0 : void SkGlobals::Init()
      61                 : {
      62               0 : }
      63                 : 
      64               0 : void SkGlobals::Term()
      65                 : {
      66               0 :     SkGlobals::BootStrap&   bootstrap = SkGlobals::GetBootStrap();
      67                 : 
      68               0 :     bootstrap.fMutex.acquire();
      69                 : 
      70               0 :     Rec*&   head = bootstrap.fHead;
      71               0 :     Rec*    rec = head;
      72                 : 
      73               0 :     while (rec)
      74                 :     {
      75               0 :         Rec* next = rec->fNext;
      76               0 :         SkDELETE(rec);
      77               0 :         rec = next;
      78                 :     }
      79                 : 
      80               0 :     bootstrap.fHead = NULL;
      81               0 :     bootstrap.fMutex.release();
      82               0 : }
      83                 : 
      84                 : 

Generated by: LCOV version 1.7