/** * Method that removes all the textures from the queue * * @param reload Forces a reload of the queue */ public void emptyTextureQueue(boolean reload) { synchronized (mSync) { // Recycle the textures try { List<GLESTextureInfo> all = mQueue.removeAll(); for (GLESTextureInfo info : all) { if (GLES20.glIsTexture(info.handle)) { int[] textures = new int[] {info.handle}; if (GLESUtil.DEBUG_GL_MEMOBJS) { Log.d(GLESUtil.DEBUG_GL_MEMOBJS_DEL_TAG, "glDeleteTextures: [" + info.handle + "]"); } GLES20.glDeleteTextures(1, textures, 0); GLESUtil.glesCheckError("glDeleteTextures"); } // Return the bitmap info.bitmap.recycle(); info.bitmap = null; } } catch (EmptyQueueException eqex) { // Ignore } // Remove all pictures in the queue try { mQueue.removeAll(); } catch (EmptyQueueException ex) { // Ignore } // Reload the queue if (reload) { synchronized (mBackgroundTask.mLoadSync) { mBackgroundTask.resetAvailableImages(); mBackgroundTask.mLoadSync.notify(); } } } }
@Override public void request(TextureRequestor requestor) { synchronized (mSync) { try { GLESTextureInfo ti = mQueue.remove(); applyToRequestor(requestor, ti); } catch (EmptyQueueException eqex) { // Add to queue of pending request to be notified when // we have a new bitmap in the queue mPendingRequests.add(requestor); } } synchronized (mBackgroundTask.mLoadSync) { mBackgroundTask.mLoadSync.notify(); } }