@Override public void run() { if (DEBUG_ATLAS) Log.d(LOG_TAG, "Running " + Thread.currentThread().getName()); Atlas.Entry entry = new Atlas.Entry(); for (Atlas.Type type : Atlas.Type.values()) { for (int width = mEnd; width > mStart; width -= mStep) { for (int height = MAX_SIZE; height > MIN_SIZE; height -= STEP) { // If the atlas is not big enough, skip it if (width * height <= mThreshold) continue; final int count = packBitmaps(type, width, height, entry); if (count > 0) { mResults.add(new WorkerResult(type, width, height, count)); // If we were able to pack everything let's stop here // Increasing the height further won't make things better if (count == mBitmaps.size()) { break; } } } } } if (mSignal != null) { mSignal.countDown(); } }