Loading src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java +14 −7 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.os.Message; public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener { private static final String TAG = "GallerySlidingWindow"; private static final int MSG_LOAD_BITMAP_DONE = 0; private static final int PLACEHOLDER_COLOR = 0xFF222222; public static interface Listener { public void onSizeChanged(int size); Loading Loading @@ -85,7 +86,7 @@ public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener { mData = new MyAlbumSetItem[cacheSize]; mSize = source.size(); mWaitLoadingTexture = new ColorTexture(Color.TRANSPARENT); mWaitLoadingTexture = new ColorTexture(PLACEHOLDER_COLOR); mWaitLoadingTexture.setSize(1, 1); mHandler = new SynchronizedHandler(activity.getGLRoot()) { Loading Loading @@ -359,7 +360,7 @@ public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener { if (bitmap != null) { BitmapTexture texture = new BitmapTexture(bitmap, true); texture.setThrottled(true); updateContent(texture); updateContent(new FadeInTexture(PLACEHOLDER_COLOR, texture)); if (mListener != null) mListener.onContentInvalidated(); } } Loading @@ -369,7 +370,7 @@ public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener { } @Override public boolean render(GLCanvas canvas, int pass) { public int render(GLCanvas canvas, int pass) { // Fit the content into the box int width = mContent.getWidth(); int height = mContent.getHeight(); Loading @@ -394,12 +395,18 @@ public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener { } mSelectionDrawer.draw(canvas, mContent, width, height, getRotation(), path, mCoverIndex, sourceType, mMediaType, getRotation(), path, sourceType, mMediaType, mIsPanorama, mLabelSpec.labelBackgroundHeight, cacheFlag == MediaSet.CACHE_FLAG_FULL, (cacheFlag == MediaSet.CACHE_FLAG_FULL) && (cacheStatus != MediaSet.CACHE_STATUS_CACHED_FULL)); return false; if (mContent != mWaitLoadingTexture && ((FadeInTexture) mContent).isAnimating()) { return RENDER_MORE_FRAME; } else { return 0; } } @Override Loading Loading @@ -519,7 +526,7 @@ public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener { } @Override public boolean render(GLCanvas canvas, int pass) { public int render(GLCanvas canvas, int pass) { if (mBoxWidth != mLastWidth) { updateContent(); } Loading @@ -532,7 +539,7 @@ public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener { y += s.titleFontSize + s.countOffset; x += mHasIcon ? s.iconSize : s.leftMargin; mTextureCount.draw(canvas, x, y); return false; return 0; } @Override Loading src/com/android/gallery3d/ui/AlbumSlidingWindow.java +14 −5 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener { private static final int MSG_LOAD_BITMAP_DONE = 0; private static final int MSG_UPDATE_SLOT = 1; private static final int JOB_LIMIT = 2; private static final int PLACEHOLDER_COLOR = 0xFF222222; public static interface Listener { public void onSizeChanged(int size); Loading Loading @@ -81,7 +82,7 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener { mData = new AlbumDisplayItem[cacheSize]; mSize = source.size(); mWaitLoadingTexture = new ColorTexture(Color.TRANSPARENT); mWaitLoadingTexture = new ColorTexture(PLACEHOLDER_COLOR); mWaitLoadingTexture.setSize(1, 1); mHandler = new SynchronizedHandler(activity.getGLRoot()) { Loading Loading @@ -306,7 +307,7 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener { if (bitmap != null) { BitmapTexture texture = new BitmapTexture(bitmap, true); texture.setThrottled(true); updateContent(texture); updateContent(new FadeInTexture(PLACEHOLDER_COLOR, texture)); if (mListener != null && isActiveSlot) { mListener.onContentInvalidated(); } Loading @@ -318,7 +319,7 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener { } @Override public boolean render(GLCanvas canvas, int pass) { public int render(GLCanvas canvas, int pass) { // Fit the content into the box int width = mContent.getWidth(); int height = mContent.getHeight(); Loading @@ -336,11 +337,19 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener { if (mMediaItem != null) path = mMediaItem.getPath(); mSelectionDrawer.draw(canvas, mContent, width, height, getRotation(), path, mMediaType, mIsPanorama); return (mFocusIndex == mSlotIndex); int result = 0; if (mFocusIndex == mSlotIndex) { result |= RENDER_MORE_PASS; } if (mContent != mWaitLoadingTexture && ((FadeInTexture) mContent).isAnimating()) { result |= RENDER_MORE_FRAME; } return result; } else if (pass == 1) { mSelectionDrawer.drawFocus(canvas, width, height); } return false; return 0; } @Override Loading src/com/android/gallery3d/ui/DisplayItem.java +7 −2 Original line number Diff line number Diff line Loading @@ -29,8 +29,13 @@ public abstract class DisplayItem { mBoxHeight = height; } // returns true if more pass is needed public abstract boolean render(GLCanvas canvas, int pass); // Return values of render(): // RENDER_MORE_PASS: more pass is needed for this item // RENDER_MORE_FRAME: need to render next frame (used for animation) public static final int RENDER_MORE_PASS = 1; public static final int RENDER_MORE_FRAME = 2; public abstract int render(GLCanvas canvas, int pass); public abstract long getIdentity(); Loading src/com/android/gallery3d/ui/FadeInTexture.java 0 → 100644 +90 −0 Original line number Diff line number Diff line /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.gallery3d.ui; import com.android.gallery3d.common.Utils; import android.os.SystemClock; // FadeInTexture is a texture which begins with a color, then gradually animates // into a given texture. public class FadeInTexture implements Texture { private static final String TAG = "FadeInTexture"; // The duration of the animation in milliseconds private static final int DURATION = 180; private final BasicTexture mTexture; private final int mColor; private final long mStartTime; private final int mWidth; private final int mHeight; private final boolean mIsOpaque; private boolean mIsAnimating; public FadeInTexture(int color, BasicTexture texture) { mColor = color; mTexture = texture; mWidth = mTexture.getWidth(); mHeight = mTexture.getHeight(); mIsOpaque = mTexture.isOpaque(); mStartTime = now(); mIsAnimating = true; } public void draw(GLCanvas canvas, int x, int y) { draw(canvas, x, y, mWidth, mHeight); } public void draw(GLCanvas canvas, int x, int y, int w, int h) { if (isAnimating()) { canvas.drawMixed(mTexture, mColor, getRatio(), x, y, w, h); } else { mTexture.draw(canvas, x, y, w, h); } } public boolean isOpaque() { return mIsOpaque; } public int getWidth() { return mWidth; } public int getHeight() { return mHeight; } public boolean isAnimating() { if (mIsAnimating) { if (now() - mStartTime >= DURATION) { mIsAnimating = false; } } return mIsAnimating; } private float getRatio() { float r = (float)(now() - mStartTime) / DURATION; return Utils.clamp(1.0f - r, 0.0f, 1.0f); } private long now() { return SystemClock.uptimeMillis(); } } src/com/android/gallery3d/ui/GridDrawer.java +7 −12 Original line number Diff line number Diff line Loading @@ -46,15 +46,14 @@ public class GridDrawer extends IconDrawer { @Override public void draw(GLCanvas canvas, Texture content, int width, int height, int rotation, Path path, int topIndex, int height, int rotation, Path path, int dataSourceType, int mediaType, boolean isPanorama, int labelBackgroundHeight, boolean wantCache, boolean isCaching) { int x = -width / 2; int y = -height / 2; drawWithRotationAndGray(canvas, content, x, y, width, height, rotation, topIndex); drawWithRotation(canvas, content, x, y, width, height, rotation); if (((rotation / 90) & 0x01) == 1) { int temp = width; Loading @@ -64,16 +63,12 @@ public class GridDrawer extends IconDrawer { y = -height / 2; } drawMediaTypeOverlay(canvas, mediaType, isPanorama, x, y, width, height, topIndex); if (topIndex == 0) { drawMediaTypeOverlay(canvas, mediaType, isPanorama, x, y, width, height); drawLabelBackground(canvas, width, height, labelBackgroundHeight); drawIcon(canvas, width, height, dataSourceType); if (dataSourceType == DATASOURCE_TYPE_MTP) { drawImportLabel(canvas, width, height); } } if (mSelectionManager.isPressedPath(path)) { drawPressedFrame(canvas, x, y, width, height); Loading Loading
src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java +14 −7 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.os.Message; public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener { private static final String TAG = "GallerySlidingWindow"; private static final int MSG_LOAD_BITMAP_DONE = 0; private static final int PLACEHOLDER_COLOR = 0xFF222222; public static interface Listener { public void onSizeChanged(int size); Loading Loading @@ -85,7 +86,7 @@ public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener { mData = new MyAlbumSetItem[cacheSize]; mSize = source.size(); mWaitLoadingTexture = new ColorTexture(Color.TRANSPARENT); mWaitLoadingTexture = new ColorTexture(PLACEHOLDER_COLOR); mWaitLoadingTexture.setSize(1, 1); mHandler = new SynchronizedHandler(activity.getGLRoot()) { Loading Loading @@ -359,7 +360,7 @@ public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener { if (bitmap != null) { BitmapTexture texture = new BitmapTexture(bitmap, true); texture.setThrottled(true); updateContent(texture); updateContent(new FadeInTexture(PLACEHOLDER_COLOR, texture)); if (mListener != null) mListener.onContentInvalidated(); } } Loading @@ -369,7 +370,7 @@ public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener { } @Override public boolean render(GLCanvas canvas, int pass) { public int render(GLCanvas canvas, int pass) { // Fit the content into the box int width = mContent.getWidth(); int height = mContent.getHeight(); Loading @@ -394,12 +395,18 @@ public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener { } mSelectionDrawer.draw(canvas, mContent, width, height, getRotation(), path, mCoverIndex, sourceType, mMediaType, getRotation(), path, sourceType, mMediaType, mIsPanorama, mLabelSpec.labelBackgroundHeight, cacheFlag == MediaSet.CACHE_FLAG_FULL, (cacheFlag == MediaSet.CACHE_FLAG_FULL) && (cacheStatus != MediaSet.CACHE_STATUS_CACHED_FULL)); return false; if (mContent != mWaitLoadingTexture && ((FadeInTexture) mContent).isAnimating()) { return RENDER_MORE_FRAME; } else { return 0; } } @Override Loading Loading @@ -519,7 +526,7 @@ public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener { } @Override public boolean render(GLCanvas canvas, int pass) { public int render(GLCanvas canvas, int pass) { if (mBoxWidth != mLastWidth) { updateContent(); } Loading @@ -532,7 +539,7 @@ public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener { y += s.titleFontSize + s.countOffset; x += mHasIcon ? s.iconSize : s.leftMargin; mTextureCount.draw(canvas, x, y); return false; return 0; } @Override Loading
src/com/android/gallery3d/ui/AlbumSlidingWindow.java +14 −5 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener { private static final int MSG_LOAD_BITMAP_DONE = 0; private static final int MSG_UPDATE_SLOT = 1; private static final int JOB_LIMIT = 2; private static final int PLACEHOLDER_COLOR = 0xFF222222; public static interface Listener { public void onSizeChanged(int size); Loading Loading @@ -81,7 +82,7 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener { mData = new AlbumDisplayItem[cacheSize]; mSize = source.size(); mWaitLoadingTexture = new ColorTexture(Color.TRANSPARENT); mWaitLoadingTexture = new ColorTexture(PLACEHOLDER_COLOR); mWaitLoadingTexture.setSize(1, 1); mHandler = new SynchronizedHandler(activity.getGLRoot()) { Loading Loading @@ -306,7 +307,7 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener { if (bitmap != null) { BitmapTexture texture = new BitmapTexture(bitmap, true); texture.setThrottled(true); updateContent(texture); updateContent(new FadeInTexture(PLACEHOLDER_COLOR, texture)); if (mListener != null && isActiveSlot) { mListener.onContentInvalidated(); } Loading @@ -318,7 +319,7 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener { } @Override public boolean render(GLCanvas canvas, int pass) { public int render(GLCanvas canvas, int pass) { // Fit the content into the box int width = mContent.getWidth(); int height = mContent.getHeight(); Loading @@ -336,11 +337,19 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener { if (mMediaItem != null) path = mMediaItem.getPath(); mSelectionDrawer.draw(canvas, mContent, width, height, getRotation(), path, mMediaType, mIsPanorama); return (mFocusIndex == mSlotIndex); int result = 0; if (mFocusIndex == mSlotIndex) { result |= RENDER_MORE_PASS; } if (mContent != mWaitLoadingTexture && ((FadeInTexture) mContent).isAnimating()) { result |= RENDER_MORE_FRAME; } return result; } else if (pass == 1) { mSelectionDrawer.drawFocus(canvas, width, height); } return false; return 0; } @Override Loading
src/com/android/gallery3d/ui/DisplayItem.java +7 −2 Original line number Diff line number Diff line Loading @@ -29,8 +29,13 @@ public abstract class DisplayItem { mBoxHeight = height; } // returns true if more pass is needed public abstract boolean render(GLCanvas canvas, int pass); // Return values of render(): // RENDER_MORE_PASS: more pass is needed for this item // RENDER_MORE_FRAME: need to render next frame (used for animation) public static final int RENDER_MORE_PASS = 1; public static final int RENDER_MORE_FRAME = 2; public abstract int render(GLCanvas canvas, int pass); public abstract long getIdentity(); Loading
src/com/android/gallery3d/ui/FadeInTexture.java 0 → 100644 +90 −0 Original line number Diff line number Diff line /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.gallery3d.ui; import com.android.gallery3d.common.Utils; import android.os.SystemClock; // FadeInTexture is a texture which begins with a color, then gradually animates // into a given texture. public class FadeInTexture implements Texture { private static final String TAG = "FadeInTexture"; // The duration of the animation in milliseconds private static final int DURATION = 180; private final BasicTexture mTexture; private final int mColor; private final long mStartTime; private final int mWidth; private final int mHeight; private final boolean mIsOpaque; private boolean mIsAnimating; public FadeInTexture(int color, BasicTexture texture) { mColor = color; mTexture = texture; mWidth = mTexture.getWidth(); mHeight = mTexture.getHeight(); mIsOpaque = mTexture.isOpaque(); mStartTime = now(); mIsAnimating = true; } public void draw(GLCanvas canvas, int x, int y) { draw(canvas, x, y, mWidth, mHeight); } public void draw(GLCanvas canvas, int x, int y, int w, int h) { if (isAnimating()) { canvas.drawMixed(mTexture, mColor, getRatio(), x, y, w, h); } else { mTexture.draw(canvas, x, y, w, h); } } public boolean isOpaque() { return mIsOpaque; } public int getWidth() { return mWidth; } public int getHeight() { return mHeight; } public boolean isAnimating() { if (mIsAnimating) { if (now() - mStartTime >= DURATION) { mIsAnimating = false; } } return mIsAnimating; } private float getRatio() { float r = (float)(now() - mStartTime) / DURATION; return Utils.clamp(1.0f - r, 0.0f, 1.0f); } private long now() { return SystemClock.uptimeMillis(); } }
src/com/android/gallery3d/ui/GridDrawer.java +7 −12 Original line number Diff line number Diff line Loading @@ -46,15 +46,14 @@ public class GridDrawer extends IconDrawer { @Override public void draw(GLCanvas canvas, Texture content, int width, int height, int rotation, Path path, int topIndex, int height, int rotation, Path path, int dataSourceType, int mediaType, boolean isPanorama, int labelBackgroundHeight, boolean wantCache, boolean isCaching) { int x = -width / 2; int y = -height / 2; drawWithRotationAndGray(canvas, content, x, y, width, height, rotation, topIndex); drawWithRotation(canvas, content, x, y, width, height, rotation); if (((rotation / 90) & 0x01) == 1) { int temp = width; Loading @@ -64,16 +63,12 @@ public class GridDrawer extends IconDrawer { y = -height / 2; } drawMediaTypeOverlay(canvas, mediaType, isPanorama, x, y, width, height, topIndex); if (topIndex == 0) { drawMediaTypeOverlay(canvas, mediaType, isPanorama, x, y, width, height); drawLabelBackground(canvas, width, height, labelBackgroundHeight); drawIcon(canvas, width, height, dataSourceType); if (dataSourceType == DATASOURCE_TYPE_MTP) { drawImportLabel(canvas, width, height); } } if (mSelectionManager.isPressedPath(path)) { drawPressedFrame(canvas, x, y, width, height); Loading