private synchronized void updateLayers() { mLayers = new Layer[mLayerList.size()]; int numRenderLayers = 0; for (int i = 0, n = mLayerList.size(); i < n; i++) { Layer o = mLayerList.get(i); if (o.getRenderer() != null) numRenderLayers++; mLayers[i] = o; } mLayerRenderer = new LayerRenderer[numRenderLayers]; for (int i = 0, cnt = 0, n = mLayerList.size(); i < n; i++) { Layer o = mLayerList.get(i); LayerRenderer l = o.getRenderer(); if (l != null) mLayerRenderer[cnt++] = l; } mDirtyLayers = false; }
void destroy() { if (mDirtyLayers) updateLayers(); for (Layer o : mLayers) o.onDetach(); }