Android硬件加速后单个Bitmap可以显示的最大尺寸

  |   0 评论   |   36 浏览

    、、、
    private void getGLESTextureLimitBelowLollipop() {
    int[] maxSize = new int[1];
    GLES10.glGetIntegerv(GLES10.GLMAXTEXTURE_SIZE, maxSize, 0);
    Toast.makeText(this," " + maxSize[0],Toast.LENGTH_LONG).show();
    }
    、、、

    、、、
    private void getGLESTextureLimitEqualAboveLollipop() {
    EGL10 egl = (EGL10) EGLContext.getEGL();
    EGLDisplay dpy = egl.eglGetDisplay(EGL10.EGLDEFAULTDISPLAY);
    int[] vers = new int[2];
    egl.eglInitialize(dpy, vers);
    int[] configAttr = {
    EGL10.EGLCOLORBUFFERTYPE, EGL10.EGLRGB_BUFFER,
    EGL10.EGL_LEVEL, 0,
    EGL10.EGL_SURFACETYPE, EGL10.EGLPBUFFER_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 EGLCONTEXTCLIENT_VERSION = 0x3098; // missing in EGL10
    int[] ctxAttrib = {
    EGLCONTEXTCLIENT_VERSION, 1,
    EGL10.EGL_NONE
    };
    EGLContext ctx = egl.eglCreateContext(dpy, config, EGL10.EGLNOCONTEXT, ctxAttrib);
    egl.eglMakeCurrent(dpy, surf, surf, ctx);
    int[] maxSize = new int[1];
    GLES10.glGetIntegerv(GLES10.GLMAXTEXTURE_SIZE, maxSize, 0);
    egl.eglMakeCurrent(dpy, EGL10.EGLNOSURFACE, EGL10.EGLNOSURFACE,
    EGL10.EGLNOCONTEXT);
    egl.eglDestroySurface(dpy, surf);
    egl.eglDestroyContext(dpy, ctx);
    egl.eglTerminate(dpy);

    Toast.makeText(this," " + maxSize[0],Toast.LENGTH_LONG).show();  
    

    }
    、、、

    、、、
    if (Build.VERSION.SDKINT >= Build.VERSIONCODES.LOLLIPOP) {
    getGLESTextureLimitEqualAboveLollipop();
    } else {
    getGLESTextureLimitBelowLollipop();
    }
    、、、

    知识共享许可协议

    评论

    发表评论

    validate