blob: e1189ffbfbe46c1d4ba689c3b38ff8de6e9fcce2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/*
* Copyright 2006 The Android Open Source Project
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkGlobals_DEFINED
#define SkGlobals_DEFINED
#include "SkThread.h"
class SkGlobals {
public:
class Rec {
public:
virtual ~Rec();
private:
Rec* fNext;
uint32_t fTag;
friend class SkGlobals;
};
/** Look for a matching Rec for the specified tag. If one is found, return it.
If one is not found, if create_proc is null, return null, else
call the proc, and if it returns a Rec, add it to the global list
and return it.
create_proc can NOT call back into SkGlobals::Find (it would deadlock)
*/
static Rec* Find(uint32_t tag, Rec* (*create_proc)());
/** Helper for Find, when you want to assert that the Rec is already in the list
*/
static Rec* Get(uint32_t tag)
{
Rec* rec = SkGlobals::Find(tag, NULL);
SkASSERT(rec);
return rec;
}
// used by porting layer
struct BootStrap {
SkMutex fMutex;
Rec* fHead;
};
private:
static void Init();
static void Term();
friend class SkGraphics;
// This last function is implemented in the porting layer
static BootStrap& GetBootStrap();
};
#endif
|