You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2019/06/24 06:46:00 UTC

[GitHub] [incubator-weex] YorkShen commented on a change in pull request #2603: [Android] solve components exceed gpu limit problem

YorkShen commented on a change in pull request #2603: [Android] solve components exceed gpu limit problem
URL: https://github.com/apache/incubator-weex/pull/2603#discussion_r296571333
 
 

 ##########
 File path: android/sdk/src/main/java/com/taobao/weex/ui/WXRenderManager.java
 ##########
 @@ -81,6 +93,51 @@ public WXSDKInstance getWXSDKInstance(String instanceId) {
     return statement.getWXSDKInstance();
   }
 
+    public static int getOpenGLRenderLimitValue() {
+        int maxsize ;
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+            EGL10 egl = (EGL10) EGLContext.getEGL();
+            EGLDisplay dpy = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
+            int[] vers = new int[2];
+            egl.eglInitialize(dpy, vers);
+            int[] configAttr = {
+                    EGL10.EGL_COLOR_BUFFER_TYPE, EGL10.EGL_RGB_BUFFER,
+                    EGL10.EGL_LEVEL,0,
+                    EGL10.EGL_SURFACE_TYPE, EGL10.EGL_PBUFFER_BIT,
+                    EGL10.EGL_NONE};
+            EGLConfig[] configs =new EGLConfig[1];
+            int[] numConfig =new int[1];
+            egl.eglChooseConfig(dpy, configAttr, configs,1, numConfig);
+            if (numConfig[0] ==0) {// TROUBLE! No config found.
+            }
+            EGLConfig config = configs[0];
+            int[] surfAttr = {
+                    EGL10.EGL_WIDTH,64,
+                    EGL10.EGL_HEIGHT,64,
+                    EGL10.EGL_NONE};
+            EGLSurface surf = egl.eglCreatePbufferSurface(dpy, config, surfAttr);
+            final int EGL_CONTEXT_CLIENT_VERSION =0x3098;// missing in EGL10
+            int[] ctxAttrib = {
+                    EGL_CONTEXT_CLIENT_VERSION,1,
+                    EGL10.EGL_NONE};
+            EGLContext ctx = egl.eglCreateContext(dpy, config, EGL10.EGL_NO_CONTEXT, ctxAttrib);
+            egl.eglMakeCurrent(dpy, surf, surf, ctx);
+            int[] maxSize =new int[1];
+            GLES10.glGetIntegerv(GLES10.GL_MAX_TEXTURE_SIZE, maxSize,0);
+            egl.eglMakeCurrent(dpy, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE,
+                    EGL10.EGL_NO_CONTEXT);
+            egl.eglDestroySurface(dpy, surf);
+            egl.eglDestroyContext(dpy, ctx);
+            egl.eglTerminate(dpy);
+            maxsize =  maxSize[0];
+        }else {
+            int[] maxSize =new int[1];
+            GLES10.glGetIntegerv(GLES10.GL_MAX_TEXTURE_SIZE, maxSize,0);
+            maxsize =  maxSize[0];
+        }
+        return maxsize == 0 ? 4096 : maxsize;
 
 Review comment:
   According to my knowledge maxSize is a vector contains [width, height], not a scalar.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services