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> 21 inline unsigned int ArraySize(T(&)[N]) 22 { 23 return N; 24 } 25 26 template <typename T, unsigned int 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> 36 void SafeRelease(T& resource) 37 { 38 if (resource) 39 { 40 resource->Release(); 41 resource = NULL; 42 } 43 } 44 45 #if defined(_MSC_VER) 46 #define snprintf _snprintf 47 #endif 48 49 #define VENDOR_ID_AMD 0x1002 50 #define VENDOR_ID_INTEL 0x8086 51 #define VENDOR_ID_NVIDIA 0x10DE 52 53 #define GL_BGRA4_ANGLEX 0x6ABC 54 #define GL_BGR5_A1_ANGLEX 0x6ABD 55 56 #endif // COMMON_ANGLEUTILS_H_ 57