1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #ifndef GL_UTILS_H 17 #define GL_UTILS_H 18 19 #include <inttypes.h> 20 #include <assert.h> 21 22 typedef enum{ 23 GLES_1_1 = 1, 24 GLES_2_0 = 2, 25 MAX_GLES_VERSION //Must be last 26 }GLESVersion; 27 28 template <class T> 29 void swap(T& x,T& y) { 30 T temp; 31 temp=x; 32 x=y; 33 y=temp; 34 } 35 36 bool isPowerOf2(int num); 37 38 inline 39 unsigned int ToTargetCompatibleHandle(uintptr_t hostHandle) 40 { 41 // The host and target handles can have different sizes (e.g. 32-bit 42 // target handle for ARM, and 64-bit host handle on x86_64). 43 // This function checks that the input host handle value can be 44 // converted into a target handle one without losing any bits. 45 // 46 unsigned int targetHandle = (unsigned int)hostHandle; 47 assert(sizeof(targetHandle) == sizeof(hostHandle) || targetHandle == hostHandle); 48 return targetHandle; 49 } 50 51 #endif 52