• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 // angleutils.h: Common ANGLE utilities.
8 
9 #ifndef COMMON_ANGLEUTILS_H_
10 #define COMMON_ANGLEUTILS_H_
11 
12 #include <stddef.h>
13 
14 // A macro to disallow the copy constructor and operator= functions
15 // This must be used in the private: declarations for a class
16 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \
17   TypeName(const TypeName&);               \
18   void operator=(const TypeName&)
19 
20 template <typename T, unsigned int N>
ArraySize(T (&)[N])21 inline unsigned int ArraySize(T(&)[N])
22 {
23     return N;
24 }
25 
26 template <typename T, unsigned int N>
SafeRelease(T (& resourceBlock)[N])27 void SafeRelease(T (&resourceBlock)[N])
28 {
29     for (unsigned int i = 0; i < N; i++)
30     {
31         SafeRelease(resourceBlock[i]);
32     }
33 }
34 
35 template <typename T>
SafeRelease(T & resource)36 void SafeRelease(T& resource)
37 {
38     if (resource)
39     {
40         resource->Release();
41         resource = NULL;
42     }
43 }
44 
45 template <typename T>
SafeDelete(T * & resource)46 void SafeDelete(T*& resource)
47 {
48     delete resource;
49     resource = NULL;
50 }
51 
52 template <typename T>
SafeDeleteArray(T * & resource)53 void SafeDeleteArray(T*& resource)
54 {
55     delete[] resource;
56     resource = NULL;
57 }
58 
59 #if defined(_MSC_VER)
60 #define snprintf _snprintf
61 #endif
62 
63 #define VENDOR_ID_AMD 0x1002
64 #define VENDOR_ID_INTEL 0x8086
65 #define VENDOR_ID_NVIDIA 0x10DE
66 
67 #define GL_BGRA4_ANGLEX 0x6ABC
68 #define GL_BGR5_A1_ANGLEX 0x6ABD
69 
70 #endif // COMMON_ANGLEUTILS_H_
71