1313// 引用stb库
1414#define STB_IMAGE_IMPLEMENTATION
1515#include " src/main/cpp/utils/stb_image.h"
16-
16+ #include < android/log.h>
17+ #include < cinttypes>
1718
1819#define LOG_TAG " OpenglUtils"
1920#define LOGE (...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
@@ -111,8 +112,11 @@ GLuint loadTextureFromFile(const char *fileName, int *w, int *h,int *n){
111112 glTexParameteri (GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE);
112113 glTexParameteri (GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE);
113114
115+ int64_t getDataBefore = getTimeMise ();
114116 // 读取图片长宽高数据
115117 unsigned char * data = stbi_load (fileName, w, h, n, 0 );
118+ int64_t getDataAfter = getTimeMise ();
119+ ALOGV (" getTime:getImageData Time = %" PRId64 " " ,getDataAfter - getDataBefore);
116120
117121 ALOGV (" loadTexture fileName = %s,width = %d,height=%d,n=%d" ,fileName,*w,*h,*n);
118122
@@ -124,6 +128,7 @@ GLuint loadTextureFromFile(const char *fileName, int *w, int *h,int *n){
124128 } else {
125129 glTexImage2D (GL_TEXTURE_2D, 0 , GL_RGB, *w, *h, 0 , GL_RGB, GL_UNSIGNED_BYTE, data);
126130 }
131+ ALOGV (" getTime:glTexImage2D Time = %" PRId64 " " ,getTimeMise () - getDataAfter);
127132 stbi_image_free (data);
128133 return textureHandler;
129134 } else {
@@ -136,6 +141,17 @@ GLuint loadTextureFromFile(const char *fileName, int *w, int *h,int *n){
136141 return textureHandler;
137142}
138143
144+ int64_t getTimeNesc (){
145+ struct timespec now;
146+ clock_gettime (CLOCK_MONOTONIC,&now);
147+ return (int64_t ) now.tv_sec * 1000000000LL + now.tv_nsec ;
148+ }
149+
150+ int64_t getTimeMise (){
151+ struct timespec now;
152+ clock_gettime (CLOCK_MONOTONIC,&now);
153+ return (int64_t ) now.tv_sec *1000LL + now.tv_nsec /1000000 ;
154+ }
139155
140156GLuint loadTextureFromAssetsRepeat (AAssetManager *manager, const char *fileName){
141157 GLuint textureHandler=0 ;
0 commit comments