Search in sources :

Example 1 with TiledScreenNail

use of com.android.gallery3d.ui.TiledScreenNail in project android_packages_apps_Gallery2 by LineageOS.

the class PhotoDataAdapter method updateScreenNail.

private void updateScreenNail(Path path, Future<ScreenNail> future) {
    ImageEntry entry = mImageCache.get(path);
    ScreenNail screenNail = future.get();
    if (entry == null || entry.screenNailTask != future) {
        if (screenNail != null)
            screenNail.recycle();
        return;
    }
    entry.screenNailTask = null;
    // Combine the ScreenNails if we already have a BitmapScreenNail
    if (entry.screenNail instanceof TiledScreenNail) {
        TiledScreenNail original = (TiledScreenNail) entry.screenNail;
        screenNail = original.combine(screenNail);
    }
    if (screenNail == null) {
        entry.failToLoad = true;
    } else {
        entry.failToLoad = false;
        entry.screenNail = screenNail;
    }
    for (int i = -SCREEN_NAIL_MAX; i <= SCREEN_NAIL_MAX; ++i) {
        if (path == getPath(mCurrentIndex + i)) {
            if (i == 0)
                updateTileProvider(entry);
            mPhotoView.notifyImageChange(i);
            break;
        }
    }
    updateImageRequests();
    updateScreenNailUploadQueue();
}
Also used : TiledScreenNail(com.android.gallery3d.ui.TiledScreenNail) BitmapScreenNail(com.android.gallery3d.ui.BitmapScreenNail) ScreenNail(com.android.gallery3d.ui.ScreenNail) TiledScreenNail(com.android.gallery3d.ui.TiledScreenNail)

Example 2 with TiledScreenNail

use of com.android.gallery3d.ui.TiledScreenNail in project android_packages_apps_Gallery2 by LineageOS.

the class PhotoDataAdapter method uploadScreenNail.

private void uploadScreenNail(int offset) {
    int index = mCurrentIndex + offset;
    if (index < mActiveStart || index >= mActiveEnd)
        return;
    MediaItem item = getItem(index);
    if (item == null)
        return;
    ImageEntry e = mImageCache.get(item.getPath());
    if (e == null)
        return;
    ScreenNail s = e.screenNail;
    if (s instanceof TiledScreenNail) {
        TiledTexture t = ((TiledScreenNail) s).getTexture();
        if (t != null && !t.isReady())
            mUploader.addTexture(t);
    }
}
Also used : MediaItem(com.android.gallery3d.data.MediaItem) LocalMediaItem(com.android.gallery3d.data.LocalMediaItem) TiledTexture(com.android.gallery3d.glrenderer.TiledTexture) TiledScreenNail(com.android.gallery3d.ui.TiledScreenNail) BitmapScreenNail(com.android.gallery3d.ui.BitmapScreenNail) ScreenNail(com.android.gallery3d.ui.ScreenNail) TiledScreenNail(com.android.gallery3d.ui.TiledScreenNail)

Example 3 with TiledScreenNail

use of com.android.gallery3d.ui.TiledScreenNail in project android_packages_apps_Gallery2 by LineageOS.

the class PhotoDataAdapter method updateImageCache.

private void updateImageCache() {
    HashSet<Path> toBeRemoved = new HashSet<Path>(mImageCache.keySet());
    for (int i = mActiveStart; i < mActiveEnd; ++i) {
        MediaItem item = mData[i % DATA_CACHE_SIZE];
        if (item == null)
            continue;
        Path path = item.getPath();
        ImageEntry entry = mImageCache.get(path);
        toBeRemoved.remove(path);
        if (entry != null) {
            if (Math.abs(i - mCurrentIndex) > 1) {
                if (entry.fullImageTask != null) {
                    entry.fullImageTask.cancel();
                    entry.fullImageTask = null;
                }
                entry.fullImage = null;
                entry.requestedFullImage = MediaObject.INVALID_DATA_VERSION;
            }
            if (entry.requestedScreenNail != item.getDataVersion()) {
                // still a placeholder.
                if (entry.screenNail instanceof TiledScreenNail) {
                    TiledScreenNail s = (TiledScreenNail) entry.screenNail;
                    s.updatePlaceholderSize(item.getWidth(), item.getHeight());
                }
            }
            if (Math.abs(i - mCurrentIndex) > 0) {
                if (entry.gifDecoderTask != null) {
                    entry.gifDecoderTask.cancel();
                    entry.gifDecoderTask = null;
                }
                entry.gifDecoder = null;
                entry.requestedGif = MediaItem.INVALID_DATA_VERSION;
                if (null != entry.currentGifFrame) {
                    // recycle cached gif frame
                    entry.currentGifFrame.recycle();
                    entry.currentGifFrame = null;
                }
            }
        } else {
            entry = new ImageEntry();
            mImageCache.put(path, entry);
        }
    }
    // Clear the data and requests for ImageEntries outside the new window.
    for (Path path : toBeRemoved) {
        ImageEntry entry = mImageCache.remove(path);
        if (entry.fullImageTask != null)
            entry.fullImageTask.cancel();
        if (entry.screenNailTask != null)
            entry.screenNailTask.cancel();
        if (entry.screenNail != null)
            entry.screenNail.recycle();
    }
    updateScreenNailUploadQueue();
}
Also used : Path(com.android.gallery3d.data.Path) MediaItem(com.android.gallery3d.data.MediaItem) LocalMediaItem(com.android.gallery3d.data.LocalMediaItem) HashSet(java.util.HashSet) TiledScreenNail(com.android.gallery3d.ui.TiledScreenNail)

Aggregations

TiledScreenNail (com.android.gallery3d.ui.TiledScreenNail)3 LocalMediaItem (com.android.gallery3d.data.LocalMediaItem)2 MediaItem (com.android.gallery3d.data.MediaItem)2 BitmapScreenNail (com.android.gallery3d.ui.BitmapScreenNail)2 ScreenNail (com.android.gallery3d.ui.ScreenNail)2 Path (com.android.gallery3d.data.Path)1 TiledTexture (com.android.gallery3d.glrenderer.TiledTexture)1 HashSet (java.util.HashSet)1