diff options
63 files changed, 19 insertions, 1907 deletions
diff --git a/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java b/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java index 67aa6d77b..75ae25fc1 100644 --- a/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java +++ b/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java @@ -113,15 +113,6 @@ public class BitmapUtils { : (initialSize + 7) / 8 * 8; } - public static Bitmap resizeDownToPixels( - Bitmap bitmap, int targetPixels, boolean recycle) { - int width = bitmap.getWidth(); - int height = bitmap.getHeight(); - float scale = FloatMath.sqrt((float) targetPixels / (width * height)); - if (scale >= 1.0f) return bitmap; - return resizeBitmapByScale(bitmap, scale, recycle); - } - public static Bitmap resizeBitmapByScale( Bitmap bitmap, float scale, boolean recycle) { int width = Math.round(bitmap.getWidth() * scale); @@ -166,22 +157,6 @@ public class BitmapUtils { return resizeBitmapByScale(bitmap, scale, recycle); } - // Crops a square from the center of the original image. - public static Bitmap cropCenter(Bitmap bitmap, boolean recycle) { - int width = bitmap.getWidth(); - int height = bitmap.getHeight(); - if (width == height) return bitmap; - int size = Math.min(width, height); - - Bitmap target = Bitmap.createBitmap(size, size, getConfig(bitmap)); - Canvas canvas = new Canvas(target); - canvas.translate((size - width) / 2, (size - height) / 2); - Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG); - canvas.drawBitmap(bitmap, 0, 0, paint); - if (recycle) bitmap.recycle(); - return target; - } - public static Bitmap resizeDownAndCropCenter(Bitmap bitmap, int size, boolean recycle) { int w = bitmap.getWidth(); diff --git a/gallerycommon/src/com/android/gallery3d/common/Utils.java b/gallerycommon/src/com/android/gallery3d/common/Utils.java index 6996015a3..bbe2a5d55 100644 --- a/gallerycommon/src/com/android/gallery3d/common/Utils.java +++ b/gallerycommon/src/com/android/gallery3d/common/Utils.java @@ -76,13 +76,6 @@ public class Utils { return (a == b) || (a == null ? false : a.equals(b)); } - // Returns true if the input is power of 2. - // Throws IllegalArgumentException if the input is <= 0. - public static boolean isPowerOf2(int n) { - if (n <= 0) throw new IllegalArgumentException(); - return (n & -n) == n; - } - // Returns the next power of two. // Returns the input if it is already power of 2. // Throws IllegalArgumentException if the input is <= 0 or @@ -106,13 +99,6 @@ public class Utils { return Integer.highestOneBit(n); } - // Returns the euclidean distance between (x, y) and (sx, sy). - public static float distance(float x, float y, float sx, float sy) { - float dx = x - sx; - float dy = y - sy; - return (float) Math.hypot(dx, dy); - } - // Returns the input value x clamped to the range [min, max]. public static int clamp(int x, int min, int max) { if (x > max) return max; @@ -138,12 +124,6 @@ public class Utils { return color >>> 24 == 0xFF; } - public static <T> void swap(T[] array, int i, int j) { - T temp = array[i]; - array[i] = array[j]; - array[j] = temp; - } - public static void swap(int[] array, int i, int j) { int temp = array[i]; array[i] = array[j]; @@ -261,15 +241,6 @@ public class Utils { return value == null ? "" : value; } - // Used for debugging. Should be removed before submitting. - public static void debug(String format, Object ... args) { - if (args.length == 0) { - Log.d(DEBUG_TAG, format); - } else { - Log.d(DEBUG_TAG, String.format(format, args)); - } - } - public static float parseFloatSafely(String content, float defaultValue) { if (content == null) return defaultValue; try { @@ -292,22 +263,6 @@ public class Utils { return TextUtils.isEmpty(exifMake); } - public static boolean hasSpaceForSize(long size) { - String state = Environment.getExternalStorageState(); - if (!Environment.MEDIA_MOUNTED.equals(state)) { - return false; - } - - String path = Environment.getExternalStorageDirectory().getPath(); - try { - StatFs stat = new StatFs(path); - return stat.getAvailableBlocks() * (long) stat.getBlockSize() > size; - } catch (Exception e) { - Log.i(TAG, "Fail to access external storage", e); - } - return false; - } - public static void waitWithoutInterrupt(Object object) { try { object.wait(); @@ -316,16 +271,6 @@ public class Utils { } } - public static void shuffle(int array[], Random random) { - for (int i = array.length; i > 0; --i) { - int t = random.nextInt(i); - if (t == i - 1) continue; - int tmp = array[i - 1]; - array[i - 1] = array[t]; - array[t] = tmp; - } - } - public static boolean handleInterrruptedException(Throwable e) { // A helper to deal with the interrupt exception // If an interrupt detected, we will setup the bit again. @@ -382,34 +327,6 @@ public class Utils { return result; } - public static PendingIntent deserializePendingIntent(byte[] rawPendingIntent) { - Parcel parcel = null; - try { - if (rawPendingIntent != null) { - parcel = Parcel.obtain(); - parcel.unmarshall(rawPendingIntent, 0, rawPendingIntent.length); - return PendingIntent.readPendingIntentOrNullFromParcel(parcel); - } else { - return null; - } - } catch (Exception e) { - throw new IllegalArgumentException("error parsing PendingIntent"); - } finally { - if (parcel != null) parcel.recycle(); - } - } - - public static byte[] serializePendingIntent(PendingIntent pendingIntent) { - Parcel parcel = null; - try { - parcel = Parcel.obtain(); - PendingIntent.writePendingIntentOrNullToParcel(pendingIntent, parcel); - return parcel.marshall(); - } finally { - if (parcel != null) parcel.recycle(); - } - } - // Mask information for debugging only. It returns <code>info.toString()</code> directly // for debugging build (i.e., 'eng' and 'userdebug') and returns a mask ("****") // in release build to protect the information (e.g. for privacy issue). diff --git a/src/com/android/gallery3d/anim/AnimationSet.java b/src/com/android/gallery3d/anim/AnimationSet.java deleted file mode 100644 index 773cb4314..000000000 --- a/src/com/android/gallery3d/anim/AnimationSet.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2010 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.anim; - -import com.android.gallery3d.ui.GLCanvas; - -import java.util.ArrayList; - -public class AnimationSet extends CanvasAnimation { - - private final ArrayList<CanvasAnimation> mAnimations = - new ArrayList<CanvasAnimation>(); - private int mSaveFlags = 0; - - - public void addAnimation(CanvasAnimation anim) { - mAnimations.add(anim); - mSaveFlags |= anim.getCanvasSaveFlags(); - } - - @Override - public void apply(GLCanvas canvas) { - for (int i = 0, n = mAnimations.size(); i < n; i++) { - mAnimations.get(i).apply(canvas); - } - } - - @Override - public int getCanvasSaveFlags() { - return mSaveFlags; - } - - @Override - protected void onCalculate(float progress) { - // DO NOTHING - } - - @Override - public boolean calculate(long currentTimeMillis) { - boolean more = false; - for (CanvasAnimation anim : mAnimations) { - more |= anim.calculate(currentTimeMillis); - } - return more; - } - - @Override - public void start() { - for (CanvasAnimation anim : mAnimations) { - anim.start(); - } - } - - @Override - public boolean isActive() { - for (CanvasAnimation anim : mAnimations) { - if (anim.isActive()) return true; - } - return false; - } - -} diff --git a/src/com/android/gallery3d/app/AbstractGalleryActivity.java b/src/com/android/gallery3d/app/AbstractGalleryActivity.java index ac9774af1..f3e60cee9 100644 --- a/src/com/android/gallery3d/app/AbstractGalleryActivity.java +++ b/src/com/android/gallery3d/app/AbstractGalleryActivity.java @@ -44,7 +44,6 @@ public class AbstractGalleryActivity extends Activity implements GalleryActivity private static final String TAG = "AbstractGalleryActivity"; private GLRootView mGLRootView; private StateManager mStateManager; - private PositionRepository mPositionRepository = new PositionRepository(); private AlertDialog mAlertDialog = null; private BroadcastReceiver mMountReceiver = new BroadcastReceiver() { @@ -84,10 +83,6 @@ public class AbstractGalleryActivity extends Activity implements GalleryActivity return this; } - public ImageCacheService getImageCacheService() { - return ((GalleryApp) getApplication()).getImageCacheService(); - } - public DataManager getDataManager() { return ((GalleryApp) getApplication()).getDataManager(); } @@ -96,10 +91,6 @@ public class AbstractGalleryActivity extends Activity implements GalleryActivity return ((GalleryApp) getApplication()).getThreadPool(); } - public GalleryApp getGalleryApplication() { - return (GalleryApp) getApplication(); - } - public synchronized StateManager getStateManager() { if (mStateManager == null) { mStateManager = new StateManager(this); @@ -111,21 +102,12 @@ public class AbstractGalleryActivity extends Activity implements GalleryActivity return mGLRootView; } - public PositionRepository getPositionRepository() { - return mPositionRepository; - } - @Override public void setContentView(int resId) { super.setContentView(resId); mGLRootView = (GLRootView) findViewById(R.id.gl_root_view); } - public int getActionBarHeight() { - ActionBar actionBar = getActionBar(); - return actionBar != null ? actionBar.getHeight() : 0; - } - protected void onStorageReady() { if (mAlertDialog != null) { mAlertDialog.dismiss(); diff --git a/src/com/android/gallery3d/app/ActivityState.java b/src/com/android/gallery3d/app/ActivityState.java index 48ee9fecc..e49c502f2 100644 --- a/src/com/android/gallery3d/app/ActivityState.java +++ b/src/com/android/gallery3d/app/ActivityState.java @@ -56,7 +56,6 @@ abstract public class ActivityState { public int requestCode; public int resultCode = Activity.RESULT_CANCELED; public Intent resultData; - ResultEntry next; } private boolean mDestroyed = false; diff --git a/src/com/android/gallery3d/app/AlbumDataAdapter.java b/src/com/android/gallery3d/app/AlbumDataAdapter.java index 6711786e5..1d10b89f4 100644 --- a/src/com/android/gallery3d/app/AlbumDataAdapter.java +++ b/src/com/android/gallery3d/app/AlbumDataAdapter.java @@ -119,10 +119,6 @@ public class AlbumDataAdapter implements AlbumView.Model { return mActiveStart; } - public int getActiveEnd() { - return mActiveEnd; - } - public boolean isActive(int index) { return index >= mActiveStart && index < mActiveEnd; } diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java index 99d86f525..ead2a2005 100644 --- a/src/com/android/gallery3d/app/AlbumPage.java +++ b/src/com/android/gallery3d/app/AlbumPage.java @@ -249,20 +249,6 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster AlbumSetPage.class, REQUEST_DO_ANIMATION, data); } - public void doFilter(int filterType) { - String basePath = mMediaSet.getPath().toString(); - String newPath = FilterUtils.switchFilterPath(basePath, filterType); - Bundle data = new Bundle(getData()); - data.putString(AlbumPage.KEY_MEDIA_PATH, newPath); - mAlbumView.savePositions(PositionRepository.getInstance(mActivity)); - mActivity.getStateManager().switchState(this, AlbumPage.class, data); - } - - public void onOperationComplete() { - mAlbumView.invalidate(); - // TODO: enable animation - } - @Override protected void onCreate(Bundle data, Bundle restoreState) { mUserDistance = GalleryUtils.meterToPixel(USER_DISTANCE_METER); diff --git a/src/com/android/gallery3d/app/AlbumSetDataAdapter.java b/src/com/android/gallery3d/app/AlbumSetDataAdapter.java index 5318a61bc..262778aa8 100644 --- a/src/com/android/gallery3d/app/AlbumSetDataAdapter.java +++ b/src/com/android/gallery3d/app/AlbumSetDataAdapter.java @@ -133,10 +133,6 @@ public class AlbumSetDataAdapter implements AlbumSetView.Model { return mActiveStart; } - public int getActiveEnd() { - return mActiveEnd; - } - public boolean isActive(int index) { return index >= mActiveStart && index < mActiveEnd; } diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java index 118b7d5aa..080d1ae6f 100644 --- a/src/com/android/gallery3d/app/AlbumSetPage.java +++ b/src/com/android/gallery3d/app/AlbumSetPage.java @@ -258,20 +258,6 @@ public class AlbumSetPage extends ActivityState implements mActivity.getStateManager().switchState(this, AlbumSetPage.class, data); } - public void doFilter(int filterType) { - String basePath = mMediaSet.getPath().toString(); - String newPath = FilterUtils.switchFilterPath(basePath, filterType); - Bundle data = new Bundle(getData()); - data.putString(AlbumSetPage.KEY_MEDIA_PATH, newPath); - mAlbumSetView.savePositions(PositionRepository.getInstance(mActivity)); - mActivity.getStateManager().switchState(this, AlbumSetPage.class, data); - } - - public void onOperationComplete() { - mAlbumSetView.invalidate(); - // TODO: enable animation - } - @Override public void onCreate(Bundle data, Bundle restoreState) { initializeViews(); diff --git a/src/com/android/gallery3d/app/ControllerOverlay.java b/src/com/android/gallery3d/app/ControllerOverlay.java index 847d9e60c..03472134d 100644 --- a/src/com/android/gallery3d/app/ControllerOverlay.java +++ b/src/com/android/gallery3d/app/ControllerOverlay.java @@ -51,10 +51,5 @@ public interface ControllerOverlay { void showErrorMessage(String message); - void hide(); - void setTimes(int currentTime, int totalTime); - - void resetTime(); - } diff --git a/src/com/android/gallery3d/app/FilterUtils.java b/src/com/android/gallery3d/app/FilterUtils.java index 9b8ea2d62..c15457e7e 100644 --- a/src/com/android/gallery3d/app/FilterUtils.java +++ b/src/com/android/gallery3d/app/FilterUtils.java @@ -214,11 +214,6 @@ public class FilterUtils { return "/cluster/{" + base + "}/" + kind; } - // Change the topmost filter to the specified type. - public static String switchFilterPath(String base, int filterType) { - return newFilterPath(removeOneFilterFromPath(base), filterType); - } - // Change the topmost clustering to the specified type. public static String switchClusterPath(String base, int clusterType) { return newClusterPath(removeOneClusterFromPath(base), clusterType); @@ -258,39 +253,4 @@ public class FilterUtils { } return sb.toString(); } - - // Remove the topmost filter (if any) from the path. - private static String removeOneFilterFromPath(String base) { - boolean[] done = new boolean[1]; - return removeOneFilterFromPath(base, done); - } - - private static String removeOneFilterFromPath(String base, boolean[] done) { - if (done[0]) return base; - - String[] segments = Path.split(base); - if (segments[0].equals("filter") && segments[1].equals("mediatype")) { - done[0] = true; - return Path.splitSequence(segments[3])[0]; - } - - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < segments.length; i++) { - sb.append("/"); - if (segments[i].startsWith("{")) { - sb.append("{"); - String[] sets = Path.splitSequence(segments[i]); - for (int j = 0; j < sets.length; j++) { - if (j > 0) { - sb.append(","); - } - sb.append(removeOneFilterFromPath(sets[j], done)); - } - sb.append("}"); - } else { - sb.append(segments[i]); - } - } - return sb.toString(); - } } diff --git a/src/com/android/gallery3d/app/GalleryActionBar.java b/src/com/android/gallery3d/app/GalleryActionBar.java index 717f16c6f..72b27c3f6 100644 --- a/src/com/android/gallery3d/app/GalleryActionBar.java +++ b/src/com/android/gallery3d/app/GalleryActionBar.java @@ -217,14 +217,6 @@ public class GalleryActionBar implements ActionBar.OnNavigationListener { if (mActionBar != null) mActionBar.setSubtitle(title); } - public void setNavigationMode(int mode) { - if (mActionBar != null) mActionBar.setNavigationMode(mode); - } - - public int getHeight() { - return mActionBar == null ? 0 : mActionBar.getHeight(); - } - public boolean setSelectedAction(int type) { for (int i = 0, n = sClusterItems.length; i < n; i++) { ActionItem item = sClusterItems[i]; diff --git a/src/com/android/gallery3d/app/GalleryActivity.java b/src/com/android/gallery3d/app/GalleryActivity.java index 02f2f72f3..a5e21eae0 100644 --- a/src/com/android/gallery3d/app/GalleryActivity.java +++ b/src/com/android/gallery3d/app/GalleryActivity.java @@ -22,7 +22,5 @@ import com.android.gallery3d.ui.PositionRepository; public interface GalleryActivity extends GalleryContext { public StateManager getStateManager(); public GLRoot getGLRoot(); - public PositionRepository getPositionRepository(); - public GalleryApp getGalleryApplication(); public GalleryActionBar getGalleryActionBar(); } diff --git a/src/com/android/gallery3d/app/GalleryContext.java b/src/com/android/gallery3d/app/GalleryContext.java index 022b4a704..7721b7d5e 100644 --- a/src/com/android/gallery3d/app/GalleryContext.java +++ b/src/com/android/gallery3d/app/GalleryContext.java @@ -26,13 +26,11 @@ import android.content.res.Resources; import android.os.Looper; public interface GalleryContext { - public ImageCacheService getImageCacheService(); public DataManager getDataManager(); public Context getAndroidContext(); public Looper getMainLooper(); public Resources getResources(); - public ContentResolver getContentResolver(); public ThreadPool getThreadPool(); } diff --git a/src/com/android/gallery3d/app/MovieControllerOverlay.java b/src/com/android/gallery3d/app/MovieControllerOverlay.java index 752213e4b..9dde98037 100644 --- a/src/com/android/gallery3d/app/MovieControllerOverlay.java +++ b/src/com/android/gallery3d/app/MovieControllerOverlay.java @@ -176,10 +176,6 @@ public class MovieControllerOverlay extends FrameLayout implements showMainView(errorView); } - public void resetTime() { - timeBar.resetTime(); - } - public void setTimes(int currentTime, int totalTime) { timeBar.setTime(currentTime, totalTime); } diff --git a/src/com/android/gallery3d/data/ChangeNotifier.java b/src/com/android/gallery3d/data/ChangeNotifier.java index e1e601dd6..4f9f56b07 100644 --- a/src/com/android/gallery3d/data/ChangeNotifier.java +++ b/src/com/android/gallery3d/data/ChangeNotifier.java @@ -38,14 +38,11 @@ public class ChangeNotifier { return mContentDirty.compareAndSet(true, false); } + // For debugging only. public void fakeChange() { onChange(false); } - public void clearDirty() { - mContentDirty.set(false); - } - protected void onChange(boolean selfChange) { if (mContentDirty.compareAndSet(false, true)) { mMediaSet.notifyContentChanged(); diff --git a/src/com/android/gallery3d/data/DataManager.java b/src/com/android/gallery3d/data/DataManager.java index 51d4af9eb..e08fdedb6 100644 --- a/src/com/android/gallery3d/data/DataManager.java +++ b/src/com/android/gallery3d/data/DataManager.java @@ -145,10 +145,6 @@ public class DataManager { return path.getObject(); } - public MediaSet peekMediaSet(Path path) { - return (MediaSet) path.getObject(); - } - public MediaObject getMediaObject(Path path) { MediaObject obj = path.getObject(); if (obj != null) return obj; @@ -245,14 +241,6 @@ public class DataManager { return getMediaObject(path).getMediaType(); } - public MediaDetails getDetails(Path path) { - return getMediaObject(path).getDetails(); - } - - public void cache(Path path, int flag) { - getMediaObject(path).cache(flag); - } - public Path findPathByUri(Uri uri) { if (uri == null) return null; for (MediaSource source : mSourceMap.values()) { diff --git a/src/com/android/gallery3d/data/DecodeUtils.java b/src/com/android/gallery3d/data/DecodeUtils.java index b205576cd..969fd9854 100644 --- a/src/com/android/gallery3d/data/DecodeUtils.java +++ b/src/com/android/gallery3d/data/DecodeUtils.java @@ -48,14 +48,6 @@ public class DecodeUtils { } } - public static Bitmap requestDecode(JobContext jc, final String filePath, - Options options) { - if (options == null) options = new Options(); - jc.setCancelListener(new DecodeCanceller(options)); - return ensureGLCompatibleBitmap( - BitmapFactory.decodeFile(filePath, options)); - } - public static Bitmap requestDecode(JobContext jc, FileDescriptor fd, Options options) { if (options == null) options = new Options(); jc.setCancelListener(new DecodeCanceller(options)); @@ -136,14 +128,6 @@ public class DecodeUtils { BitmapFactory.decodeByteArray(data, 0, data.length, options)); } - public static Bitmap requestDecode(JobContext jc, - FileDescriptor fileDescriptor, Rect paddings, Options options) { - if (options == null) options = new Options(); - jc.setCancelListener(new DecodeCanceller(options)); - return ensureGLCompatibleBitmap(BitmapFactory.decodeFileDescriptor - (fileDescriptor, paddings, options)); - } - // TODO: This function should not be called directly from // DecodeUtils.requestDecode(...), since we don't have the knowledge // if the bitmap will be uploaded to GL. @@ -203,20 +187,4 @@ public class DecodeUtils { return null; } } - - public static BitmapRegionDecoder requestCreateBitmapRegionDecoder( - JobContext jc, Uri uri, ContentResolver resolver, - boolean shareable) { - ParcelFileDescriptor pfd = null; - try { - pfd = resolver.openFileDescriptor(uri, "r"); - return BitmapRegionDecoder.newInstance( - pfd.getFileDescriptor(), shareable); - } catch (Throwable t) { - Log.w(TAG, t); - return null; - } finally { - Utils.closeSilently(pfd); - } - } } diff --git a/src/com/android/gallery3d/data/DownloadCache.java b/src/com/android/gallery3d/data/DownloadCache.java index 30ba668c3..9646a6383 100644 --- a/src/com/android/gallery3d/data/DownloadCache.java +++ b/src/com/android/gallery3d/data/DownloadCache.java @@ -78,7 +78,6 @@ public class DownloadCache { private long mTotalBytes = 0; private boolean mInitialized = false; - private WeakHashMap<Object, Entry> mAssociateMap = new WeakHashMap<Object, Entry>(); public DownloadCache(GalleryApp application, File root, long capacity) { mRoot = Utils.checkNotNull(root); @@ -113,31 +112,6 @@ public class DownloadCache { return null; } - public Entry lookup(URL url) { - if (!mInitialized) initialize(); - String stringUrl = url.toString(); - - // First find in the entry-pool - synchronized (mEntryMap) { - Entry entry = mEntryMap.get(stringUrl); - if (entry != null) { - updateLastAccess(entry.mId); - return entry; - } - } - - // Then, find it in database - TaskProxy proxy = new TaskProxy(); - synchronized (mTaskMap) { - Entry entry = findEntryInDatabase(stringUrl); - if (entry != null) { - updateLastAccess(entry.mId); - return entry; - } - } - return null; - } - public Entry download(JobContext jc, URL url) { if (!mInitialized) initialize(); @@ -282,10 +256,6 @@ public class DownloadCache { mId = id; this.cacheFile = Utils.checkNotNull(cacheFile); } - - public void associateWith(Object object) { - mAssociateMap.put(Utils.checkNotNull(object), this); - } } private class DownloadTask implements Job<File>, FutureListener<File> { diff --git a/src/com/android/gallery3d/data/DownloadUtils.java b/src/com/android/gallery3d/data/DownloadUtils.java index 9632db984..e055c442f 100644 --- a/src/com/android/gallery3d/data/DownloadUtils.java +++ b/src/com/android/gallery3d/data/DownloadUtils.java @@ -44,22 +44,6 @@ public class DownloadUtils { } } - public static byte[] requestDownload(JobContext jc, URL url) { - ByteArrayOutputStream baos = null; - try { - baos = new ByteArrayOutputStream(); - if (!download(jc, url, baos)) { - return null; - } - return baos.toByteArray(); - } catch (Throwable t) { - Log.w(TAG, t); - return null; - } finally { - Utils.closeSilently(baos); - } - } - public static void dump(JobContext jc, InputStream is, OutputStream os) throws IOException { byte buffer[] = new byte[4096]; diff --git a/src/com/android/gallery3d/data/Face.java b/src/com/android/gallery3d/data/Face.java index c5fd131ae..29af27f15 100644 --- a/src/com/android/gallery3d/data/Face.java +++ b/src/com/android/gallery3d/data/Face.java @@ -45,22 +45,10 @@ public class Face implements Comparable<Face> { return mPosition; } - public int getWidth() { - return mPosition.right - mPosition.left; - } - - public int getHeight() { - return mPosition.bottom - mPosition.top; - } - public String getName() { return mName; } - public String getPersonId() { - return mPersonId; - } - @Override public boolean equals(Object obj) { if (obj instanceof Face) { diff --git a/src/com/android/gallery3d/data/LocalVideo.java b/src/com/android/gallery3d/data/LocalVideo.java index ca379c35a..d68072bec 100644 --- a/src/com/android/gallery3d/data/LocalVideo.java +++ b/src/com/android/gallery3d/data/LocalVideo.java @@ -73,7 +73,6 @@ public class LocalVideo extends LocalMediaItem { }; private final GalleryApp mApplication; - private static Bitmap sOverlay; public int durationInSec; diff --git a/src/com/android/gallery3d/data/MediaDetails.java b/src/com/android/gallery3d/data/MediaDetails.java index 1b56ac42e..8f0ca7d7b 100644 --- a/src/com/android/gallery3d/data/MediaDetails.java +++ b/src/com/android/gallery3d/data/MediaDetails.java @@ -73,22 +73,6 @@ public class MediaDetails implements Iterable<Entry<Integer, Object>> { public boolean isFlashFired() { return (mState & FLASH_FIRED_MASK) != 0; } - - public int getFlashReturn() { - return (mState & FLASH_RETURN_MASK) >> 1; - } - - public int getFlashMode() { - return (mState & FLASH_MODE_MASK) >> 3; - } - - public boolean isFlashPresent() { - return (mState & FLASH_FUNCTION_MASK) != 0; - } - - public boolean isRedEyeModePresent() { - return (mState & FLASH_RED_EYE_MASK) != 0; - } } public void addDetail(int index, Object value) { diff --git a/src/com/android/gallery3d/data/Path.java b/src/com/android/gallery3d/data/Path.java index 3de1c7c76..a09df10ad 100644 --- a/src/com/android/gallery3d/data/Path.java +++ b/src/com/android/gallery3d/data/Path.java @@ -190,15 +190,6 @@ public class Path { return mSegment; } - public String getSuffix(int level) { - // We don't need lock because mSegment and mParent are final. - Path p = this; - while (level-- != 0) { - p = p.mParent; - } - return p.mSegment; - } - // Below are for testing/debugging only static void clearAll() { synchronized (Path.class) { diff --git a/src/com/android/gallery3d/provider/GalleryProvider.java b/src/com/android/gallery3d/provider/GalleryProvider.java index 7cc4d5c09..28fd6b843 100644 --- a/src/com/android/gallery3d/provider/GalleryProvider.java +++ b/src/com/android/gallery3d/provider/GalleryProvider.java @@ -66,7 +66,6 @@ public class GalleryProvider extends ContentProvider { ImageColumns.ORIENTATION}; private DataManager mDataManager; - private DownloadCache mDownloadCache; private static Uri sBaseUri; public static String getAuthority(Context context) { @@ -112,14 +111,6 @@ public class GalleryProvider extends ContentProvider { return true; } - private DownloadCache getDownloadCache() { - if (mDownloadCache == null) { - GalleryApp app = (GalleryApp) getContext().getApplicationContext(); - mDownloadCache = app.getDownloadCache(); - } - return mDownloadCache; - } - // TODO: consider concurrent access @Override public Cursor query(Uri uri, String[] projection, diff --git a/src/com/android/gallery3d/ui/AdaptiveBackground.java b/src/com/android/gallery3d/ui/AdaptiveBackground.java deleted file mode 100644 index d7c99063d..000000000 --- a/src/com/android/gallery3d/ui/AdaptiveBackground.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2010 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 android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.LightingColorFilter; -import android.graphics.Paint; - -import com.android.gallery3d.anim.FloatAnimation; - -public class AdaptiveBackground extends GLView { - - private static final int BACKGROUND_WIDTH = 128; - private static final int BACKGROUND_HEIGHT = 64; - private static final int FILTERED_COLOR = 0xffaaaaaa; - private static final int ANIMATION_DURATION = 500; - - private BasicTexture mOldBackground; - private BasicTexture mBackground; - - private final Paint mPaint; - private Bitmap mPendingBitmap; - private final FloatAnimation mAnimation = - new FloatAnimation(0, 1, ANIMATION_DURATION); - - public AdaptiveBackground() { - Paint paint = new Paint(); - paint.setFilterBitmap(true); - paint.setColorFilter(new LightingColorFilter(FILTERED_COLOR, 0)); - mPaint = paint; - } - - public Bitmap getAdaptiveBitmap(Bitmap bitmap) { - Bitmap target = Bitmap.createBitmap( - BACKGROUND_WIDTH, BACKGROUND_HEIGHT, Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(target); - int width = bitmap.getWidth(); - int height = bitmap.getHeight(); - int left = 0; - int top = 0; - if (width * BACKGROUND_HEIGHT > height * BACKGROUND_WIDTH) { - float scale = (float) BACKGROUND_HEIGHT / height; - canvas.scale(scale, scale); - left = (BACKGROUND_WIDTH - (int) (width * scale + 0.5)) / 2; - } else { - float scale = (float) BACKGROUND_WIDTH / width; - canvas.scale(scale, scale); - top = (BACKGROUND_HEIGHT - (int) (height * scale + 0.5)) / 2; - } - canvas.drawBitmap(bitmap, left, top, mPaint); - BoxBlurFilter.apply(target, - BoxBlurFilter.MODE_REPEAT, BoxBlurFilter.MODE_CLAMP); - return target; - } - - private void startTransition(Bitmap bitmap) { - BitmapTexture texture = new BitmapTexture(bitmap); - if (mBackground == null) { - mBackground = texture; - } else { - if (mOldBackground != null) mOldBackground.recycle(); - mOldBackground = mBackground; - mBackground = texture; - mAnimation.start(); - } - invalidate(); - } - - public void setImage(Bitmap bitmap) { - if (mAnimation.isActive()) { - mPendingBitmap = bitmap; - } else { - startTransition(bitmap); - } - } - - public void setScrollPosition(int position) { - if (mScrollX == position) return; - mScrollX = position; - invalidate(); - } - - @Override - protected void render(GLCanvas canvas) { - if (mBackground == null) return; - - int height = getHeight(); - float scale = (float) height / BACKGROUND_HEIGHT; - int width = (int) (BACKGROUND_WIDTH * scale + 0.5f); - int scroll = mScrollX; - int start = (scroll / width) * width; - - if (mOldBackground == null) { - for (int i = start, n = scroll + getWidth(); i < n; i += width) { - mBackground.draw(canvas, i - scroll, 0, width, height); - } - } else { - boolean moreAnimation = mAnimation.calculate(AnimationTime.get()); - float ratio = mAnimation.get(); - for (int i = start, n = scroll + getWidth(); i < n; i += width) { - canvas.drawMixed(mOldBackground, - mBackground, ratio, i - scroll, 0, width, height); - } - if (moreAnimation) { - invalidate(); - } else if (mPendingBitmap != null) { - startTransition(mPendingBitmap); - mPendingBitmap = null; - } - } - } -} diff --git a/src/com/android/gallery3d/ui/AlbumSetView.java b/src/com/android/gallery3d/ui/AlbumSetView.java index 86398ec9d..577d54e33 100644 --- a/src/com/android/gallery3d/ui/AlbumSetView.java +++ b/src/com/android/gallery3d/ui/AlbumSetView.java @@ -146,10 +146,6 @@ public class AlbumSetView extends SlotView { removeDisplayItem(entry.labelItem); } - public int size() { - return mDataWindow.size(); - } - @Override public void onLayoutChanged(int width, int height) { updateVisibleRange(0, 0); diff --git a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java index d64c1f7ed..8d61f934d 100644 --- a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java +++ b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java @@ -124,10 +124,6 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener { return mData[slotIndex % mData.length]; } - public int size() { - return mSize; - } - public boolean isActiveSlot(int slotIndex) { return slotIndex >= mActiveStart && slotIndex < mActiveEnd; } diff --git a/src/com/android/gallery3d/ui/BitmapTileProvider.java b/src/com/android/gallery3d/ui/BitmapTileProvider.java index a47337fa2..4ad5412d6 100644 --- a/src/com/android/gallery3d/ui/BitmapTileProvider.java +++ b/src/com/android/gallery3d/ui/BitmapTileProvider.java @@ -81,10 +81,6 @@ public class BitmapTileProvider implements TileImageView.Model { BitmapUtils.recycleSilently(mBackup); } - public int getRotation() { - return 0; - } - public boolean isFailedToLoad() { return false; } diff --git a/src/com/android/gallery3d/ui/BoxBlurFilter.java b/src/com/android/gallery3d/ui/BoxBlurFilter.java deleted file mode 100644 index 0497a61fa..000000000 --- a/src/com/android/gallery3d/ui/BoxBlurFilter.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2010 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 android.graphics.Bitmap; - - -public class BoxBlurFilter { - private static final int RED_MASK = 0xff0000; - private static final int RED_MASK_SHIFT = 16; - private static final int GREEN_MASK = 0x00ff00; - private static final int GREEN_MASK_SHIFT = 8; - private static final int BLUE_MASK = 0x0000ff; - private static final int RADIUS = 4; - private static final int KERNEL_SIZE = RADIUS * 2 + 1; - private static final int NUM_COLORS = 256; - private static final int[] KERNEL_NORM = new int[KERNEL_SIZE * NUM_COLORS]; - - public static final int MODE_REPEAT = 1; - public static final int MODE_CLAMP = 2; - - static { - int index = 0; - // Build a lookup table from summed to normalized kernel values. - // The formula: KERNAL_NORM[value] = value / KERNEL_SIZE - for (int i = 0; i < NUM_COLORS; ++i) { - for (int j = 0; j < KERNEL_SIZE; ++j) { - KERNEL_NORM[index++] = i; - } - } - } - - private BoxBlurFilter() { - } - - private static int sample(int x, int width, int mode) { - if (x >= 0 && x < width) return x; - return mode == MODE_REPEAT - ? x < 0 ? x + width : x - width - : x < 0 ? 0 : width - 1; - } - - public static void apply( - Bitmap bitmap, int horizontalMode, int verticalMode) { - - int width = bitmap.getWidth(); - int height = bitmap.getHeight(); - int data[] = new int[width * height]; - bitmap.getPixels(data, 0, width, 0, 0, width, height); - int temp[] = new int[width * height]; - applyOneDimension(data, temp, width, height, horizontalMode); - applyOneDimension(temp, data, height, width, verticalMode); - bitmap.setPixels(data, 0, width, 0, 0, width, height); - } - - private static void applyOneDimension( - int[] in, int[] out, int width, int height, int mode) { - for (int y = 0, read = 0; y < height; ++y, read += width) { - // Evaluate the kernel for the first pixel in the row. - int red = 0; - int green = 0; - int blue = 0; - for (int i = -RADIUS; i <= RADIUS; ++i) { - int argb = in[read + sample(i, width, mode)]; - red += (argb & RED_MASK) >> RED_MASK_SHIFT; - green += (argb & GREEN_MASK) >> GREEN_MASK_SHIFT; - blue += argb & BLUE_MASK; - } - for (int x = 0, write = y; x < width; ++x, write += height) { - // Output the current pixel. - out[write] = 0xFF000000 - | (KERNEL_NORM[red] << RED_MASK_SHIFT) - | (KERNEL_NORM[green] << GREEN_MASK_SHIFT) - | KERNEL_NORM[blue]; - - // Slide to the next pixel, adding the new rightmost pixel and - // subtracting the former leftmost. - int prev = in[read + sample(x - RADIUS, width, mode)]; - int next = in[read + sample(x + RADIUS + 1, width, mode)]; - red += ((next & RED_MASK) - (prev & RED_MASK)) >> RED_MASK_SHIFT; - green += ((next & GREEN_MASK) - (prev & GREEN_MASK)) >> GREEN_MASK_SHIFT; - blue += (next & BLUE_MASK) - (prev & BLUE_MASK); - } - } - } -} diff --git a/src/com/android/gallery3d/ui/Config.java b/src/com/android/gallery3d/ui/Config.java deleted file mode 100644 index 5c5b6210a..000000000 --- a/src/com/android/gallery3d/ui/Config.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2010 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; - -interface DetailsWindowConfig { - public static final int FONT_SIZE = 18; - public static final int PREFERRED_WIDTH = 400; - public static final int LEFT_RIGHT_EXTRA_PADDING = 9; - public static final int TOP_BOTTOM_EXTRA_PADDING = 9; - public static final int LINE_SPACING = 5; - public static final int FIRST_LINE_SPACING = 18; -} - -interface TextButtonConfig { - public static final int HORIZONTAL_PADDINGS = 16; - public static final int VERTICAL_PADDINGS = 5; -} diff --git a/src/com/android/gallery3d/ui/CustomMenu.java b/src/com/android/gallery3d/ui/CustomMenu.java index de2367e60..c3dd4530f 100644 --- a/src/com/android/gallery3d/ui/CustomMenu.java +++ b/src/com/android/gallery3d/ui/CustomMenu.java @@ -85,38 +85,6 @@ public class CustomMenu implements OnMenuItemClickListener { mListener = listener; } - public MenuItem findMenuItem(int id) { - MenuItem item = null; - for (DropDownMenu menu : mMenus) { - item = menu.findItem(id); - if (item != null) return item; - } - return item; - } - - public void setMenuItemAppliedEnabled(int id, boolean applied, boolean enabled, - boolean updateTitle) { - MenuItem item = null; - for (DropDownMenu menu : mMenus) { - item = menu.findItem(id); - if (item != null) { - item.setCheckable(true); - item.setChecked(applied); - item.setEnabled(enabled); - if (updateTitle) { - menu.setTitle(item.getTitle()); - } - } - } - } - - public void setMenuItemVisibility(int id, boolean visibility) { - MenuItem item = findMenuItem(id); - if (item != null) { - item.setVisible(visibility); - } - } - public boolean onMenuItemClick(MenuItem item) { if (mListener != null) { return mListener.onMenuItemClick(item); diff --git a/src/com/android/gallery3d/ui/DialogDetailsView.java b/src/com/android/gallery3d/ui/DialogDetailsView.java index 580a40edb..60ced031d 100644 --- a/src/com/android/gallery3d/ui/DialogDetailsView.java +++ b/src/com/android/gallery3d/ui/DialogDetailsView.java @@ -80,10 +80,6 @@ public class DialogDetailsView implements DetailsViewContainer { } } - public boolean isVisible() { - return mDialog.isShowing(); - } - private void setDetails(MediaDetails details) { mAdapter = new DetailsAdapter(details); String title = String.format( diff --git a/src/com/android/gallery3d/ui/DrawableTexture.java b/src/com/android/gallery3d/ui/DrawableTexture.java deleted file mode 100644 index 5c3964d5c..000000000 --- a/src/com/android/gallery3d/ui/DrawableTexture.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2010 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 android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.drawable.Drawable; - -// DrawableTexture is a texture whose content is from a Drawable. -public class DrawableTexture extends CanvasTexture { - - private final Drawable mDrawable; - - public DrawableTexture(Drawable drawable, int width, int height) { - super(width, height); - mDrawable = drawable; - } - - @Override - protected void onDraw(Canvas canvas, Bitmap backing) { - mDrawable.setBounds(0, 0, mWidth, mHeight); - mDrawable.draw(canvas); - } -} diff --git a/src/com/android/gallery3d/ui/FilmStripView.java b/src/com/android/gallery3d/ui/FilmStripView.java index e6ed49b6e..ed288afee 100644 --- a/src/com/android/gallery3d/ui/FilmStripView.java +++ b/src/com/android/gallery3d/ui/FilmStripView.java @@ -28,8 +28,7 @@ import android.content.Context; import android.view.MotionEvent; import android.view.View.MeasureSpec; -public class FilmStripView extends GLView implements ScrollBarView.Listener, - UserInteractionListener { +public class FilmStripView extends GLView implements UserInteractionListener { @SuppressWarnings("unused") private static final String TAG = "FilmStripView"; @@ -108,7 +107,6 @@ public class FilmStripView extends GLView implements ScrollBarView.Listener, addComponent(mAlbumView); mScrollBarView = new ScrollBarView(activity.getAndroidContext(), mGripSize, gripWidth); - mScrollBarView.setListener(this); addComponent(mScrollBarView); mAlbumView.setModel(mAlbumDataAdapter); @@ -239,12 +237,6 @@ public class FilmStripView extends GLView implements ScrollBarView.Listener, mUIListener.onUserInteraction(); } - // Called by ScrollBarView - @Override - public void onScrollBarPositionChanged(int position) { - mAlbumView.setScrollPosition(position); - } - public void setFocusIndex(int slotIndex) { mAlbumView.setFocusIndex(slotIndex); mAlbumView.makeSlotVisible(slotIndex); diff --git a/src/com/android/gallery3d/ui/GLCanvas.java b/src/com/android/gallery3d/ui/GLCanvas.java index 52ce615ae..1359115f8 100644 --- a/src/com/android/gallery3d/ui/GLCanvas.java +++ b/src/com/android/gallery3d/ui/GLCanvas.java @@ -37,8 +37,6 @@ public interface GLCanvas { // Clear the drawing buffers. This should only be used by GLRoot. public void clearBuffer(); - public void setBlendEnabled(boolean enabled); - // Sets and gets the current alpha, alpha must be in [0, 1]. public void setAlpha(float alpha); public float getAlpha(); @@ -53,12 +51,7 @@ public interface GLCanvas { public void rotate(float angle, float x, float y, float z); public void multiplyMatrix(float[] mMatrix, int offset); - // Modifies the current clip with the specified rectangle. - // (current clip) = (current clip) intersect (specified rectangle). - // Returns true if the result clip is non-empty. - public boolean clipRect(int left, int top, int right, int bottom); - - // Pushes the configuration state (matrix, alpha, and clip) onto + // Pushes the configuration state (matrix, and alpha) onto // a private stack. public void save(); @@ -66,9 +59,8 @@ public interface GLCanvas { public void save(int saveFlags); public static final int SAVE_FLAG_ALL = 0xFFFFFFFF; - public static final int SAVE_FLAG_CLIP = 0x01; - public static final int SAVE_FLAG_ALPHA = 0x02; - public static final int SAVE_FLAG_MATRIX = 0x04; + public static final int SAVE_FLAG_ALPHA = 0x01; + public static final int SAVE_FLAG_MATRIX = 0x02; // Pops from the top of the stack as current configuration state (matrix, // alpha, and clip). This call balances a previous call to save(), and is @@ -93,26 +85,15 @@ public interface GLCanvas { public void drawMesh(BasicTexture tex, int x, int y, int xyBuffer, int uvBuffer, int indexBuffer, int indexCount); - // Draws a texture to the specified rectangle. The "alpha" parameter - // overrides the current drawing alpha value. - public void drawTexture(BasicTexture texture, - int x, int y, int width, int height, float alpha); - // Draws a the source rectangle part of the texture to the target rectangle. public void drawTexture(BasicTexture texture, RectF source, RectF target); // Draw two textures to the specified rectangle. The actual texture used is // from * (1 - ratio) + to * ratio // The two textures must have the same size. - public void drawMixed(BasicTexture from, BasicTexture to, - float ratio, int x, int y, int w, int h); - public void drawMixed(BasicTexture from, int toColor, float ratio, int x, int y, int w, int h); - // Return a texture copied from the specified rectangle. - public BasicTexture copyTexture(int x, int y, int width, int height); - // Gets the underlying GL instance. This is used only when direct access to // GL is needed. public GL11 getGLInstance(); @@ -130,4 +111,6 @@ public interface GLCanvas { // called in the GL thread. public void deleteRecycledResources(); + // Dump statistics information and clear the counters. For debug only. + public void dumpStatisticsAndClear(); } diff --git a/src/com/android/gallery3d/ui/GLCanvasImpl.java b/src/com/android/gallery3d/ui/GLCanvasImpl.java index 8775f0837..1c582853f 100644 --- a/src/com/android/gallery3d/ui/GLCanvasImpl.java +++ b/src/com/android/gallery3d/ui/GLCanvasImpl.java @@ -62,7 +62,6 @@ public class GLCanvasImpl implements GLCanvas { private final GLState mGLState; private float mAlpha; - private final Rect mClipRect = new Rect(); private final ArrayList<ConfigState> mRestoreStack = new ArrayList<ConfigState>(); private ConfigState mRecycledRestoreAction; @@ -106,7 +105,6 @@ public class GLCanvasImpl implements GLCanvas { Matrix.translateM(matrix, 0, 0, mHeight, 0); Matrix.scaleM(matrix, 0, 1, -1, 1); - mClipRect.set(0, 0, width, height); gl.glScissor(0, 0, width, height); } @@ -115,15 +113,15 @@ public class GLCanvasImpl implements GLCanvas { mAlpha = alpha; } + public float getAlpha() { + return mAlpha; + } + public void multiplyAlpha(float alpha) { Utils.assertTrue(alpha >= 0 && alpha <= 1); mAlpha *= alpha; } - public float getAlpha() { - return mAlpha; - } - private static ByteBuffer allocateDirectNativeOrderBuffer(int size) { return ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder()); } @@ -163,7 +161,6 @@ public class GLCanvasImpl implements GLCanvas { mGLState.setColorMode(paint.getColor(), mAlpha); mGLState.setLineWidth(paint.getLineWidth()); - mGLState.setLineSmooth(paint.getAntiAlias()); saveTransform(); translate(x, y); @@ -181,7 +178,6 @@ public class GLCanvasImpl implements GLCanvas { mGLState.setColorMode(paint.getColor(), mAlpha); mGLState.setLineWidth(paint.getLineWidth()); - mGLState.setLineSmooth(paint.getAntiAlias()); saveTransform(); translate(x1, y1); @@ -314,33 +310,6 @@ public class GLCanvasImpl implements GLCanvas { return r; } - public boolean clipRect(int left, int top, int right, int bottom) { - float point[] = mapPoints(mMatrixValues, left, top, right, bottom); - - // mMatrix could be a rotation matrix. In this case, we need to find - // the boundaries after rotation. (only handle 90 * n degrees) - if (point[0] > point[2]) { - left = (int) point[2]; - right = (int) point[0]; - } else { - left = (int) point[0]; - right = (int) point[2]; - } - if (point[1] > point[3]) { - top = (int) point[3]; - bottom = (int) point[1]; - } else { - top = (int) point[1]; - bottom = (int) point[3]; - } - Rect clip = mClipRect; - - boolean intersect = clip.intersect(left, top, right, bottom); - if (!intersect) clip.set(0, 0, 0, 0); - mGL.glScissor(clip.left, clip.top, clip.width(), clip.height()); - return intersect; - } - private void drawBoundTexture( BasicTexture texture, int x, int y, int width, int height) { // Test whether it has been rotated or flipped, if so, glDrawTexiOES @@ -378,11 +347,7 @@ public class GLCanvasImpl implements GLCanvas { drawTexture(texture, x, y, width, height, mAlpha); } - public void setBlendEnabled(boolean enabled) { - mBlendEnabled = enabled; - } - - public void drawTexture(BasicTexture texture, + private void drawTexture(BasicTexture texture, int x, int y, int width, int height, float alpha) { if (width <= 0 || height <= 0) return; @@ -447,11 +412,6 @@ public class GLCanvasImpl implements GLCanvas { drawMixed(from, toColor, ratio, x, y, w, h, mAlpha); } - public void drawMixed(BasicTexture from, BasicTexture to, - float ratio, int x, int y, int w, int h) { - drawMixed(from, to, ratio, x, y, w, h, mAlpha); - } - private boolean bindTexture(BasicTexture texture) { if (!texture.onBind(this)) return false; mGLState.setTexture2DEnabled(true); @@ -532,84 +492,6 @@ public class GLCanvasImpl implements GLCanvas { mGLState.setTexEnvMode(GL11.GL_REPLACE); } - private void drawMixed(BasicTexture from, BasicTexture to, - float ratio, int x, int y, int width, int height, float alpha) { - - if (ratio <= 0) { - drawTexture(from, x, y, width, height, alpha); - return; - } else if (ratio >= 1) { - drawTexture(to, x, y, width, height, alpha); - return; - } - - // In the current implementation the two textures must have the - // same size. - Utils.assertTrue(from.getWidth() == to.getWidth() - && from.getHeight() == to.getHeight()); - - mGLState.setBlendEnabled(mBlendEnabled && (!from.isOpaque() - || !to.isOpaque() || alpha < OPAQUE_ALPHA)); - - final GL11 gl = mGL; - if (!bindTexture(from)) return; - - // - // The formula we want: - // alpha * ((1 - ratio) * from + ratio * to) - // The formula that GL supports is in the form of: - // combo * (modulate * from) + (1 - combo) * to - // - // So, we have combo = 1 - alpha * ratio - // and modulate = alpha * (1f - ratio) / combo - // - float comboRatio = 1 - alpha * ratio; - - // handle the case that (1 - comboRatio) == 0 - if (alpha < OPAQUE_ALPHA) { - mGLState.setTextureAlpha(alpha * (1f - ratio) / comboRatio); - } else { - mGLState.setTextureAlpha(1f); - } - - gl.glActiveTexture(GL11.GL_TEXTURE1); - if (!bindTexture(to)) { - // Disable TEXTURE1. - gl.glDisable(GL11.GL_TEXTURE_2D); - // Switch back to the default texture unit. - gl.glActiveTexture(GL11.GL_TEXTURE0); - return; - } - gl.glEnable(GL11.GL_TEXTURE_2D); - - // Interpolate the RGB and alpha values between both textures. - mGLState.setTexEnvMode(GL11.GL_COMBINE); - gl.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_COMBINE_RGB, GL11.GL_INTERPOLATE); - gl.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_COMBINE_ALPHA, GL11.GL_INTERPOLATE); - - // Specify the interpolation factor via the alpha component of - // GL_TEXTURE_ENV_COLORs. - // We don't use the RGB color, so just give them 0s. - setTextureColor(0, 0, 0, comboRatio); - gl.glTexEnvfv(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_COLOR, mTextureColor, 0); - - // Wire up the interpolation factor for RGB. - gl.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_SRC2_RGB, GL11.GL_CONSTANT); - gl.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_OPERAND2_RGB, GL11.GL_SRC_ALPHA); - - // Wire up the interpolation factor for alpha. - gl.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_SRC2_ALPHA, GL11.GL_CONSTANT); - gl.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_OPERAND2_ALPHA, GL11.GL_SRC_ALPHA); - - // Draw the combined texture. - drawBoundTexture(to, x, y, width, height); - - // Disable TEXTURE1. - gl.glDisable(GL11.GL_TEXTURE_2D); - // Switch back to the default texture unit. - gl.glActiveTexture(GL11.GL_TEXTURE0); - } - // TODO: the code only work for 2D should get fixed for 3D or removed private static final int MSKEW_X = 4; private static final int MSKEW_Y = 1; @@ -624,41 +506,6 @@ public class GLCanvasImpl implements GLCanvas { || matrix[MSCALE_Y] > eps; } - public BasicTexture copyTexture(int x, int y, int width, int height) { - - if (isMatrixRotatedOrFlipped(mMatrixValues)) { - throw new IllegalArgumentException("cannot support rotated matrix"); - } - float points[] = mapPoints(mMatrixValues, x, y + height, x + width, y); - x = (int) points[0]; - y = (int) points[1]; - width = (int) points[2] - x; - height = (int) points[3] - y; - - GL11 gl = mGL; - - RawTexture texture = RawTexture.newInstance(this); - gl.glBindTexture(GL11.GL_TEXTURE_2D, texture.getId()); - texture.setSize(width, height); - - int[] cropRect = {0, 0, width, height}; - gl.glTexParameteriv(GL11.GL_TEXTURE_2D, - GL11Ext.GL_TEXTURE_CROP_RECT_OES, cropRect, 0); - gl.glTexParameteri(GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP_TO_EDGE); - gl.glTexParameteri(GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP_TO_EDGE); - gl.glTexParameterf(GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); - gl.glTexParameterf(GL11.GL_TEXTURE_2D, - GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); - gl.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, - GL11.GL_RGB, x, y, texture.getTextureWidth(), - texture.getTextureHeight(), 0); - - return texture; - } - private static class GLState { private final GL11 mGL; @@ -710,16 +557,6 @@ public class GLCanvasImpl implements GLCanvas { mGL.glLineWidth(width); } - public void setLineSmooth(boolean enabled) { - if (mLineSmooth == enabled) return; - mLineSmooth = enabled; - if (enabled) { - mGL.glEnable(GL11.GL_LINE_SMOOTH); - } else { - mGL.glDisable(GL11.GL_LINE_SMOOTH); - } - } - public void setTextureAlpha(float alpha) { if (mTextureAlpha == alpha) return; mTextureAlpha = alpha; @@ -841,11 +678,6 @@ public class GLCanvasImpl implements GLCanvas { config.mAlpha = -1; } - if ((saveFlags & SAVE_FLAG_CLIP) != 0) { - config.mRect.set(mClipRect); - } else { - config.mRect.left = Integer.MAX_VALUE; - } if ((saveFlags & SAVE_FLAG_MATRIX) != 0) { System.arraycopy(mMatrixValues, 0, config.mMatrix, 0, 16); @@ -885,12 +717,6 @@ public class GLCanvasImpl implements GLCanvas { public void restore(GLCanvasImpl canvas) { if (mAlpha >= 0) canvas.setAlpha(mAlpha); - if (mRect.left != Integer.MAX_VALUE) { - Rect rect = mRect; - canvas.mClipRect.set(rect); - canvas.mGL.glScissor( - rect.left, rect.top, rect.width(), rect.height()); - } if (mMatrix[0] != Float.NEGATIVE_INFINITY) { System.arraycopy(mMatrix, 0, canvas.mMatrixValues, 0, 16); } diff --git a/src/com/android/gallery3d/ui/GLPaint.java b/src/com/android/gallery3d/ui/GLPaint.java index 9f7b6f1f3..eb75cc51e 100644 --- a/src/com/android/gallery3d/ui/GLPaint.java +++ b/src/com/android/gallery3d/ui/GLPaint.java @@ -20,20 +20,9 @@ import com.android.gallery3d.common.Utils; public class GLPaint { - public static final int FLAG_ANTI_ALIAS = 0x01; - - private int mFlags = 0; private float mLineWidth = 1f; private int mColor = 0; - public int getFlags() { - return mFlags; - } - - public void setFlags(int flags) { - mFlags = flags; - } - public void setColor(int color) { mColor = color; } @@ -50,16 +39,4 @@ public class GLPaint { public float getLineWidth() { return mLineWidth; } - - public void setAntiAlias(boolean enabled) { - if (enabled) { - mFlags |= FLAG_ANTI_ALIAS; - } else { - mFlags &= ~FLAG_ANTI_ALIAS; - } - } - - public boolean getAntiAlias(){ - return (mFlags & FLAG_ANTI_ALIAS) != 0; - } } diff --git a/src/com/android/gallery3d/ui/GLRoot.java b/src/com/android/gallery3d/ui/GLRoot.java index 24e5794b0..834e85c91 100644 --- a/src/com/android/gallery3d/ui/GLRoot.java +++ b/src/com/android/gallery3d/ui/GLRoot.java @@ -28,7 +28,6 @@ public interface GLRoot { public void registerLaunchedAnimation(CanvasAnimation animation); public void requestRender(); public void requestLayoutContentPane(); - public boolean hasStencil(); public void lockRenderThread(); public void unlockRenderThread(); diff --git a/src/com/android/gallery3d/ui/GLRootView.java b/src/com/android/gallery3d/ui/GLRootView.java index d11de1229..6429d5a0a 100644 --- a/src/com/android/gallery3d/ui/GLRootView.java +++ b/src/com/android/gallery3d/ui/GLRootView.java @@ -67,10 +67,9 @@ public class GLRootView extends GLSurfaceView private static final int FLAG_NEED_LAYOUT = 2; private GL11 mGL; - private GLCanvasImpl mCanvas; + private GLCanvas mCanvas; private GLView mContentView; - private DisplayMetrics mDisplayMetrics; private int mFlags = FLAG_NEED_LAYOUT; private volatile boolean mRenderRequested = false; @@ -111,15 +110,6 @@ public class GLRootView extends GLSurfaceView //setDebugFlags(DEBUG_CHECK_GL_ERROR); } - public GalleryEGLConfigChooser getEGLConfigChooser() { - return mEglConfigChooser; - } - - @Override - public boolean hasStencil() { - return getEGLConfigChooser().getStencilBits() > 0; - } - @Override public void registerLaunchedAnimation(CanvasAnimation animation) { // Register the newly launched animation so that we can set the start @@ -159,10 +149,6 @@ public class GLRootView extends GLSurfaceView } } - public GLView getContentPane() { - return mContentView; - } - @Override public void requestRender() { if (DEBUG_INVALIDATE) { @@ -375,19 +361,6 @@ public class GLRootView extends GLSurfaceView } } - public DisplayMetrics getDisplayMetrics() { - if (mDisplayMetrics == null) { - mDisplayMetrics = new DisplayMetrics(); - ((Activity) getContext()).getWindowManager() - .getDefaultDisplay().getMetrics(mDisplayMetrics); - } - return mDisplayMetrics; - } - - public GLCanvas getCanvas() { - return mCanvas; - } - private class IdleRunner implements Runnable { // true if the idle runner is in the queue private boolean mActive = false; diff --git a/src/com/android/gallery3d/ui/GLView.java b/src/com/android/gallery3d/ui/GLView.java index 7ae980d06..26796b594 100644 --- a/src/com/android/gallery3d/ui/GLView.java +++ b/src/com/android/gallery3d/ui/GLView.java @@ -303,14 +303,6 @@ public class GLView { return mPaddings; } - public void setPaddings(Rect paddings) { - mPaddings.set(paddings); - } - - public void setPaddings(int left, int top, int right, int bottom) { - mPaddings.set(left, top, right, bottom); - } - public void layout(int left, int top, int right, int bottom) { boolean sizeChanged = setBounds(left, top, right, bottom); if (sizeChanged) { diff --git a/src/com/android/gallery3d/ui/GalleryEGLConfigChooser.java b/src/com/android/gallery3d/ui/GalleryEGLConfigChooser.java index 1d50d43f7..0d5643ff9 100644 --- a/src/com/android/gallery3d/ui/GalleryEGLConfigChooser.java +++ b/src/com/android/gallery3d/ui/GalleryEGLConfigChooser.java @@ -30,7 +30,6 @@ import javax.microedition.khronos.egl.EGLDisplay; class GalleryEGLConfigChooser implements EGLConfigChooser { private static final String TAG = "GalleryEGLConfigChooser"; - private int mStencilBits; private final int mConfigSpec[] = new int[] { EGL10.EGL_RED_SIZE, 5, @@ -40,10 +39,6 @@ class GalleryEGLConfigChooser implements EGLConfigChooser { EGL10.EGL_NONE }; - public int getStencilBits() { - return mStencilBits; - } - public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) { int[] numConfig = new int[1]; if (!egl.eglChooseConfig(display, mConfigSpec, null, 0, numConfig)) { @@ -94,7 +89,6 @@ class GalleryEGLConfigChooser implements EGLConfigChooser { if (result == null) result = configs[0]; egl.eglGetConfigAttrib( display, result, EGL10.EGL_STENCIL_SIZE, value); - mStencilBits = value[0]; logConfig(egl, display, result); return result; } diff --git a/src/com/android/gallery3d/ui/Icon.java b/src/com/android/gallery3d/ui/Icon.java deleted file mode 100644 index c710859f8..000000000 --- a/src/com/android/gallery3d/ui/Icon.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2010 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 android.content.Context; -import android.graphics.Rect; - -public class Icon extends GLView { - private final BasicTexture mIcon; - - // The width and height requested by the user. - private int mReqWidth; - private int mReqHeight; - - public Icon(Context context, int iconId, int width, int height) { - this(context, new ResourceTexture(context, iconId), width, height); - } - - public Icon(Context context, BasicTexture icon, int width, int height) { - mIcon = icon; - mReqWidth = width; - mReqHeight = height; - } - - @Override - protected void onMeasure(int widthSpec, int heightSpec) { - MeasureHelper.getInstance(this) - .setPreferredContentSize(mReqWidth, mReqHeight) - .measure(widthSpec, heightSpec); - } - - @Override - protected void render(GLCanvas canvas) { - Rect p = mPaddings; - - int width = getWidth() - p.left - p.right; - int height = getHeight() - p.top - p.bottom; - - // Draw the icon in the center of the space - int xoffset = p.left + (width - mReqWidth) / 2; - int yoffset = p.top + (height - mReqHeight) / 2; - - mIcon.draw(canvas, xoffset, yoffset, mReqWidth, mReqHeight); - } -} diff --git a/src/com/android/gallery3d/ui/OnSelectedListener.java b/src/com/android/gallery3d/ui/OnSelectedListener.java deleted file mode 100644 index 2cc5809bf..000000000 --- a/src/com/android/gallery3d/ui/OnSelectedListener.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2010 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; - -public interface OnSelectedListener { - public void onSelected(GLView source); -} diff --git a/src/com/android/gallery3d/ui/Paper.java b/src/com/android/gallery3d/ui/Paper.java index ecc415064..830698c4a 100644 --- a/src/com/android/gallery3d/ui/Paper.java +++ b/src/com/android/gallery3d/ui/Paper.java @@ -113,7 +113,6 @@ class EdgeAnimation { private final Interpolator mInterpolator; private int mState; - private long mAnimationStartTime; private float mValue; private float mValueStart; diff --git a/src/com/android/gallery3d/ui/RawTexture.java b/src/com/android/gallery3d/ui/RawTexture.java deleted file mode 100644 index 527880a35..000000000 --- a/src/com/android/gallery3d/ui/RawTexture.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2010 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 javax.microedition.khronos.opengles.GL11; - -// RawTexture is used for texture created by glCopyTexImage2D. -// -// It will throw RuntimeException in onBind() if used with a different GL -// context. It is only used internally by copyTexture() in GLCanvas. -class RawTexture extends BasicTexture { - - private RawTexture(GLCanvas canvas, int id) { - super(canvas, id, STATE_LOADED); - } - - public static RawTexture newInstance(GLCanvas canvas) { - int[] textureId = new int[1]; - GL11 gl = canvas.getGLInstance(); - gl.glGenTextures(1, textureId, 0); - return new RawTexture(canvas, textureId[0]); - } - - @Override - protected boolean onBind(GLCanvas canvas) { - if (mCanvasRef != canvas) { - throw new RuntimeException("cannot bind to different canvas"); - } - return true; - } - - public boolean isOpaque() { - return true; - } - - @Override - public void yield() { - // we cannot free the texture because we have no backup. - } -} diff --git a/src/com/android/gallery3d/ui/ScrollBarView.java b/src/com/android/gallery3d/ui/ScrollBarView.java index b33f03b07..c4266b6cf 100644 --- a/src/com/android/gallery3d/ui/ScrollBarView.java +++ b/src/com/android/gallery3d/ui/ScrollBarView.java @@ -26,10 +26,6 @@ public class ScrollBarView extends GLView { @SuppressWarnings("unused") private static final String TAG = "ScrollBarView"; - public interface Listener { - void onScrollBarPositionChanged(int position); - } - private int mBarHeight; private int mGripHeight; @@ -40,7 +36,6 @@ public class ScrollBarView extends GLView { private int mContentPosition; private int mContentTotal; - private Listener mListener; private NinePatchTexture mScrollBarTexture; public ScrollBarView(Context context, int gripHeight, int gripWidth) { @@ -55,10 +50,6 @@ public class ScrollBarView extends GLView { mGripHeight = gripHeight; } - public void setListener(Listener listener) { - mListener = listener; - } - @Override protected void onLayout( boolean changed, int left, int top, int right, int bottom) { @@ -94,13 +85,6 @@ public class ScrollBarView extends GLView { mGripPosition = Math.round(r * mContentPosition); } - private void notifyContentPositionFromGrip() { - if (mContentTotal <= 0) return; - float r = (getWidth() - mGripWidth) / (float) mContentTotal; - int newContentPosition = Math.round(mGripPosition / r); - mListener.onScrollBarPositionChanged(newContentPosition); - } - @Override protected void render(GLCanvas canvas) { super.render(canvas); @@ -109,31 +93,4 @@ public class ScrollBarView extends GLView { int y = (mBarHeight - mGripHeight) / 2; mScrollBarTexture.draw(canvas, mGripPosition, y, mGripWidth, mGripHeight); } - - // The onTouch() handler is disabled because now we don't want the user - // to drag the bar (it's an indicator only). - /* - @Override - protected boolean onTouch(MotionEvent event) { - switch (event.getAction()) { - case MotionEvent.ACTION_DOWN: { - int x = (int) event.getX(); - return (x >= mGripPosition && x < mGripPosition + mGripWidth); - } - case MotionEvent.ACTION_MOVE: { - // Adjust x by mGripWidth / 2 so the center of the grip - // matches the touch position. - int x = (int) event.getX() - mGripWidth / 2; - x = Utils.clamp(x, 0, getWidth() - mGripWidth); - if (mGripPosition != x) { - mGripPosition = x; - notifyContentPositionFromGrip(); - invalidate(); - } - break; - } - } - return true; - } - */ } diff --git a/src/com/android/gallery3d/ui/SelectionManager.java b/src/com/android/gallery3d/ui/SelectionManager.java index 2726e8add..f695372fd 100644 --- a/src/com/android/gallery3d/ui/SelectionManager.java +++ b/src/com/android/gallery3d/ui/SelectionManager.java @@ -216,8 +216,4 @@ public class SelectionManager { mSourceMediaSet = set; mTotal = -1; } - - public MediaSet getSourceMediaSet() { - return mSourceMediaSet; - } } diff --git a/src/com/android/gallery3d/ui/SlotView.java b/src/com/android/gallery3d/ui/SlotView.java index 9a0d5abec..863e66869 100644 --- a/src/com/android/gallery3d/ui/SlotView.java +++ b/src/com/android/gallery3d/ui/SlotView.java @@ -143,11 +143,6 @@ public class SlotView extends GLView { } @Override - public boolean removeComponent(GLView view) { - throw new UnsupportedOperationException(); - } - - @Override protected void onLayout(boolean changeSize, int l, int t, int r, int b) { if (!changeSize) return; @@ -415,21 +410,6 @@ public class SlotView extends GLView { public int rowsLand = -1; public int rowsPort = -1; public int slotGap = -1; - - static Spec newWithSize(int width, int height) { - Spec s = new Spec(); - s.slotWidth = width; - s.slotHeight = height; - return s; - } - - static Spec newWithRows(int rowsLand, int rowsPort, int slotGap) { - Spec s = new Spec(); - s.rowsLand = rowsLand; - s.rowsPort = rowsPort; - s.slotGap = slotGap; - return s; - } } public static class Layout { @@ -489,10 +469,6 @@ public class SlotView extends GLView { return mSlotHeight; } - public int getContentLength() { - return mContentLength; - } - // Calculate // (1) mUnitCount: the number of slots we can fit into one column (or row). // (2) mContentLength: the width (or height) we need to display all the diff --git a/src/com/android/gallery3d/ui/StaticBackground.java b/src/com/android/gallery3d/ui/StaticBackground.java deleted file mode 100644 index e7fd003f2..000000000 --- a/src/com/android/gallery3d/ui/StaticBackground.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2010 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 android.content.Context; - -public class StaticBackground extends GLView { - - private Context mContext; - private int mLandscapeResource; - private int mPortraitResource; - - private BasicTexture mBackground; - private boolean mIsLandscape = false; - - public StaticBackground(Context context) { - mContext = context; - } - - @Override - protected void onLayout(boolean changeSize, int l, int t, int r, int b) { - setOrientation(getWidth() >= getHeight()); - } - - private void setOrientation(boolean isLandscape) { - if (mIsLandscape == isLandscape) return; - mIsLandscape = isLandscape; - if (mBackground != null) mBackground.recycle(); - mBackground = new ResourceTexture( - mContext, mIsLandscape ? mLandscapeResource : mPortraitResource); - invalidate(); - } - - public void setImage(int landscapeId, int portraitId) { - mLandscapeResource = landscapeId; - mPortraitResource = portraitId; - if (mBackground != null) mBackground.recycle(); - mBackground = new ResourceTexture( - mContext, mIsLandscape ? landscapeId : portraitId); - invalidate(); - } - - @Override - protected void render(GLCanvas canvas) { - mBackground.draw(canvas, 0, 0, getWidth(), getHeight()); - } -} diff --git a/src/com/android/gallery3d/ui/Texture.java b/src/com/android/gallery3d/ui/Texture.java index 4d1749bb6..2c426f994 100644 --- a/src/com/android/gallery3d/ui/Texture.java +++ b/src/com/android/gallery3d/ui/Texture.java @@ -26,14 +26,12 @@ package com.android.gallery3d.ui; // -- ColorTexture // -- FadeInTexture // -- BasicTexture -// -- RawTexture // -- UploadedTexture // -- BitmapTexture // -- Tile // -- ResourceTexture // -- NinePatchTexture // -- CanvasTexture -// -- DrawableTexture // -- StringTexture // public interface Texture { diff --git a/src/com/android/gallery3d/util/FutureTask.java b/src/com/android/gallery3d/util/FutureTask.java deleted file mode 100644 index 9cfab27cb..000000000 --- a/src/com/android/gallery3d/util/FutureTask.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2010 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.util; - -import java.util.concurrent.Callable; - -// NOTE: If the Callable throws any Throwable, the result value will be null. -public class FutureTask<T> implements Runnable, Future<T> { - private static final String TAG = "FutureTask"; - private Callable<T> mCallable; - private FutureListener<T> mListener; - private volatile boolean mIsCancelled; - private boolean mIsDone; - private T mResult; - - public FutureTask(Callable<T> callable, FutureListener<T> listener) { - mCallable = callable; - mListener = listener; - } - - public FutureTask(Callable<T> callable) { - this(callable, null); - } - - public void cancel() { - mIsCancelled = true; - } - - public synchronized T get() { - while (!mIsDone) { - try { - wait(); - } catch (InterruptedException t) { - // ignore. - } - } - return mResult; - } - - public void waitDone() { - get(); - } - - public synchronized boolean isDone() { - return mIsDone; - } - - public boolean isCancelled() { - return mIsCancelled; - } - - public void run() { - T result = null; - - if (!mIsCancelled) { - try { - result = mCallable.call(); - } catch (Throwable ex) { - Log.w(TAG, "Exception in running a task", ex); - } - } - - synchronized(this) { - mResult = result; - mIsDone = true; - if (mListener != null) { - mListener.onFutureDone(this); - } - notifyAll(); - } - } -} diff --git a/src/com/android/gallery3d/util/GalleryUtils.java b/src/com/android/gallery3d/util/GalleryUtils.java index fcb27bad4..9a7e09316 100644 --- a/src/com/android/gallery3d/util/GalleryUtils.java +++ b/src/com/android/gallery3d/util/GalleryUtils.java @@ -324,31 +324,6 @@ public class GalleryUtils { return false; } - public static void assertInMainThread() { - if (Thread.currentThread() == sContext.getMainLooper().getThread()) { - throw new AssertionError(); - } - } - - public static void doubleToRational(double value, long[] output) { - // error is a magic number to control the tollerance of error - doubleToRational(value, output, 0.00001); - } - - private static void doubleToRational(double value, long[] output, double error) { - long number = (long) value; - value -= number; - if (value < 0.000001 || error > 1) { - output[0] = (int) (number + value + 0.5); - output[1] = 1; - } else { - doubleToRational(1.0 / value, output, error / value); - number = number * output[0] + output[1]; - output[1] = output[0]; - output[0] = number; - } - } - public static boolean isPanorama(MediaItem item) { if (item == null) return false; int w = item.getWidth(); diff --git a/src/com/android/gallery3d/util/IdentityCache.java b/src/com/android/gallery3d/util/IdentityCache.java index 02a46aef7..59a22910b 100644 --- a/src/com/android/gallery3d/util/IdentityCache.java +++ b/src/com/android/gallery3d/util/IdentityCache.java @@ -61,11 +61,15 @@ public class IdentityCache<K, V> { return entry == null ? null : entry.get(); } + // This is currently unused. + /* public synchronized void clear() { mWeakMap.clear(); mQueue = new ReferenceQueue<V>(); } + */ + // This is for debugging only public synchronized ArrayList<K> keys() { Set<K> set = mWeakMap.keySet(); ArrayList<K> result = new ArrayList<K>(set); diff --git a/src/com/android/gallery3d/util/IntArray.java b/src/com/android/gallery3d/util/IntArray.java index 88657bbd6..082089a65 100644 --- a/src/com/android/gallery3d/util/IntArray.java +++ b/src/com/android/gallery3d/util/IntArray.java @@ -35,6 +35,7 @@ public class IntArray { return mSize; } + // For testing only public int[] toArray(int[] result) { if (result == null || result.length < mSize) { result = new int[mSize]; diff --git a/src/com/android/gallery3d/util/JobLimiter.java b/src/com/android/gallery3d/util/JobLimiter.java index 5abdfd80b..42b754153 100644 --- a/src/com/android/gallery3d/util/JobLimiter.java +++ b/src/com/android/gallery3d/util/JobLimiter.java @@ -140,10 +140,6 @@ public class JobLimiter implements FutureListener { return future; } - public <T> Future<T> submit(Job<T> job) { - return submit(job, null); - } - @SuppressWarnings({"rawtypes", "unchecked"}) private void submitTasksIfAllowed() { while (mLimit > 0 && !mJobs.isEmpty()) { diff --git a/src/com/android/gallery3d/util/LinkedNode.java b/src/com/android/gallery3d/util/LinkedNode.java index 8554acd21..4cfc3cded 100644 --- a/src/com/android/gallery3d/util/LinkedNode.java +++ b/src/com/android/gallery3d/util/LinkedNode.java @@ -43,10 +43,6 @@ public class LinkedNode { public static class List<T extends LinkedNode> { private LinkedNode mHead = new LinkedNode(); - public void insertFirst(T node) { - mHead.insert(node); - } - public void insertLast(T node) { mHead.mPrev.insert(node); } diff --git a/src/com/android/gallery3d/util/UpdateHelper.java b/src/com/android/gallery3d/util/UpdateHelper.java index 9fdade683..f76705d06 100644 --- a/src/com/android/gallery3d/util/UpdateHelper.java +++ b/src/com/android/gallery3d/util/UpdateHelper.java @@ -45,14 +45,6 @@ public class UpdateHelper { return original; } - public double update(float original, float update) { - if (original != update) { - mUpdated = true; - original = update; - } - return original; - } - public <T> T update(T original, T update) { if (!Utils.equals(original, update)) { mUpdated = true; diff --git a/tests/src/com/android/gallery3d/common/UtilsTest.java b/tests/src/com/android/gallery3d/common/UtilsTest.java index b3552444b..a20ebeb2f 100644 --- a/tests/src/com/android/gallery3d/common/UtilsTest.java +++ b/tests/src/com/android/gallery3d/common/UtilsTest.java @@ -151,30 +151,6 @@ public class UtilsTest extends AndroidTestCase { assertFalse(Utils.equals(a, b)); } - public void testIsPowerOf2() { - for (int i = 0; i < 31; i++) { - int v = (1 << i); - assertTrue(Utils.isPowerOf2(v)); - } - - int[] f = new int[] {3, 5, 6, 7, 9, 10, 65535, Integer.MAX_VALUE - 1, - Integer.MAX_VALUE }; - for (int v : f) { - assertFalse(Utils.isPowerOf2(v)); - } - - int[] e = new int[] {0, -1, -2, -4, -65536, Integer.MIN_VALUE + 1, - Integer.MIN_VALUE }; - for (int v : e) { - try { - Utils.isPowerOf2(v); - fail(); - } catch (IllegalArgumentException ex) { - // expected. - } - } - } - public void testNextPowerOf2() { int[] q = new int[] {1, 2, 3, 4, 5, 6, 10, 65535, (1 << 30) - 1, (1 << 30)}; int[] a = new int[] {1, 2, 4, 4, 8, 8, 16, 65536, (1 << 30) , (1 << 30)}; @@ -195,16 +171,6 @@ public class UtilsTest extends AndroidTestCase { } } - public void testDistance() { - assertFloatEq(0f, Utils.distance(0, 0, 0, 0)); - assertFloatEq(1f, Utils.distance(0, 1, 0, 0)); - assertFloatEq(1f, Utils.distance(0, 0, 0, 1)); - assertFloatEq(2f, Utils.distance(1, 2, 3, 2)); - assertFloatEq(5f, Utils.distance(1, 2, 1 + 3, 2 + 4)); - assertFloatEq(5f, Utils.distance(1, 2, 1 + 3, 2 + 4)); - assertFloatEq(Float.MAX_VALUE, Utils.distance(Float.MAX_VALUE, 0, 0, 0)); - } - public void testClamp() { assertEquals(1000, Utils.clamp(300, 1000, 2000)); assertEquals(1300, Utils.clamp(1300, 1000, 2000)); @@ -227,14 +193,6 @@ public class UtilsTest extends AndroidTestCase { assertFalse(Utils.isOpaque(0xAA0000FF)); } - public static void testSwap() { - Integer[] a = {1, 2, 3}; - Utils.swap(a, 0, 2); - assertEquals(a[0].intValue(), 3); - assertEquals(a[1].intValue(), 2); - assertEquals(a[2].intValue(), 1); - } - public static void assertFloatEq(float expected, float actual) { if (Math.abs(actual - expected) > 1e-6) { Log.v(TAG, "expected: " + expected + ", actual: " + actual); diff --git a/tests/src/com/android/gallery3d/ui/GLCanvasStub.java b/tests/src/com/android/gallery3d/ui/GLCanvasStub.java index 41de108ad..70fef1a1c 100644 --- a/tests/src/com/android/gallery3d/ui/GLCanvasStub.java +++ b/tests/src/com/android/gallery3d/ui/GLCanvasStub.java @@ -77,4 +77,5 @@ public class GLCanvasStub implements GLCanvas { } public void deleteRecycledResources() {} public void multiplyMatrix(float[] mMatrix, int offset) {} + public void dumpStatisticsAndClear() {} } diff --git a/tests/src/com/android/gallery3d/ui/GLCanvasTest.java b/tests/src/com/android/gallery3d/ui/GLCanvasTest.java index ca34d7c3c..72ccbfb96 100644 --- a/tests/src/com/android/gallery3d/ui/GLCanvasTest.java +++ b/tests/src/com/android/gallery3d/ui/GLCanvasTest.java @@ -360,370 +360,6 @@ public class GLCanvasTest extends TestCase { } @SmallTest - public void testClipRect() { - // The test is currently broken, waiting for the fix - // new ClipRectTest().run(); - } - - private static class ClipRectTest extends GLStub { - int mX, mY, mWidth, mHeight; - - @Override - public void glScissor(int x, int y, int width, int height) { - mX = x; - mY = 100 - y - height; // flip in Y direction - mWidth = width; - mHeight = height; - } - - private void assertClipRect(int x, int y, int width, int height) { - assertEquals(x, mX); - assertEquals(y, mY); - assertEquals(width, mWidth); - assertEquals(height, mHeight); - } - - private void assertEmptyClipRect() { - assertEquals(0, mWidth); - assertEquals(0, mHeight); - } - - void run() { - GLCanvas canvas = new GLCanvasImpl(this); - canvas.setSize(100, 100); - canvas.save(); - assertClipRect(0, 0, 100, 100); - - assertTrue(canvas.clipRect(10, 10, 70, 70)); - canvas.save(); - assertClipRect(10, 10, 60, 60); - - assertTrue(canvas.clipRect(30, 30, 90, 90)); - canvas.save(); - assertClipRect(30, 30, 40, 40); - - assertTrue(canvas.clipRect(40, 40, 60, 90)); - assertClipRect(40, 40, 20, 30); - - assertFalse(canvas.clipRect(30, 30, 70, 40)); - assertEmptyClipRect(); - assertFalse(canvas.clipRect(0, 0, 100, 100)); - assertEmptyClipRect(); - - canvas.restore(); - assertClipRect(30, 30, 40, 40); - - canvas.restore(); - assertClipRect(10, 10, 60, 60); - - canvas.restore(); - assertClipRect(0, 0, 100, 100); - - canvas.translate(10, 20, 30); - assertTrue(canvas.clipRect(10, 10, 70, 70)); - canvas.save(); - assertClipRect(20, 30, 60, 60); - } - } - - @SmallTest - public void testSaveRestore() { - new SaveRestoreTest().run(); - } - - private static class SaveRestoreTest extends GLStub { - int mX, mY, mWidth, mHeight; - - @Override - public void glScissor(int x, int y, int width, int height) { - mX = x; - mY = 100 - y - height; // flip in Y direction - mWidth = width; - mHeight = height; - } - - private void assertClipRect(int x, int y, int width, int height) { - assertEquals(x, mX); - assertEquals(y, mY); - assertEquals(width, mWidth); - assertEquals(height, mHeight); - } - - void run() { - GLCanvas canvas = new GLCanvasImpl(this); - canvas.setSize(100, 100); - - canvas.setAlpha(0.7f); - assertTrue(canvas.clipRect(10, 10, 70, 70)); - - canvas.save(canvas.SAVE_FLAG_CLIP); - canvas.setAlpha(0.6f); - assertTrue(canvas.clipRect(30, 30, 90, 90)); - - canvas.save(canvas.SAVE_FLAG_CLIP | canvas.SAVE_FLAG_ALPHA); - canvas.setAlpha(0.5f); - assertTrue(canvas.clipRect(40, 40, 60, 90)); - - assertEquals(0.5f, canvas.getAlpha()); - assertClipRect(40, 40, 20, 30); - - canvas.restore(); // now both clipping rect and alpha are restored. - assertEquals(0.6f, canvas.getAlpha()); - assertClipRect(30, 30, 40, 40); - - canvas.restore(); // now only clipping rect is restored. - - canvas.save(0); - canvas.save(0); - canvas.restore(); - canvas.restore(); - - assertEquals(0.6f, canvas.getAlpha()); - assertTrue(canvas.clipRect(10, 10, 60, 60)); - } - } - - @SmallTest - public void testDrawTexture() { - new DrawTextureTest().run(); - new DrawTextureMixedTest().run(); - } - - private static class MyTexture extends BasicTexture { - boolean mIsOpaque; - int mBindCalled; - - MyTexture(GLCanvas canvas, int id, boolean isOpaque) { - super(canvas, id, STATE_LOADED); - setSize(1, 1); - mIsOpaque = isOpaque; - } - - @Override - protected boolean onBind(GLCanvas canvas) { - mBindCalled++; - return true; - } - - public boolean isOpaque() { - return mIsOpaque; - } - } - - private static class DrawTextureTest extends GLMock { - int mDrawTexiOESCalled; - int mDrawArrayCalled; - int[] mResult = new int[4]; - - @Override - public void glDrawTexiOES(int x, int y, int z, - int width, int height) { - mDrawTexiOESCalled++; - } - - @Override - public void glDrawArrays(int mode, int first, int count) { - assertNotNull(mGLVertexPointer); - assertEquals(GL10.GL_TRIANGLE_STRIP, mode); - assertEquals(4, count); - mGLVertexPointer.bindByteBuffer(); - - double[] coord = new double[4]; - mGLVertexPointer.getArrayElement(first, coord); - mResult[0] = (int) coord[0]; - mResult[1] = (int) coord[1]; - mGLVertexPointer.getArrayElement(first + 1, coord); - mResult[2] = (int) coord[0]; - mResult[3] = (int) coord[1]; - mDrawArrayCalled++; - } - - void run() { - GLCanvas canvas = new GLCanvasImpl(this); - canvas.setSize(400, 300); - MyTexture texture = new MyTexture(canvas, 42, false); // non-opaque - MyTexture texture_o = new MyTexture(canvas, 47, true); // opaque - - // Draw a non-opaque texture - canvas.drawTexture(texture, 100, 200, 300, 400); - assertEquals(42, mGLBindTextureId); - assertEquals(GL_REPLACE, getTexEnvi(GL_TEXTURE_ENV_MODE)); - assertPremultipliedBlending(this); - assertFalse(mGLStencilEnabled); - - // Draw an opaque texture - canvas.drawTexture(texture_o, 100, 200, 300, 400); - assertEquals(47, mGLBindTextureId); - assertEquals(GL_REPLACE, getTexEnvi(GL_TEXTURE_ENV_MODE)); - assertFalse(mGLBlendEnabled); - - // Draw a non-opaque texture with alpha = 0.5 - canvas.setAlpha(0.5f); - canvas.drawTexture(texture, 100, 200, 300, 400); - assertEquals(42, mGLBindTextureId); - assertEquals(0x80808080, mGLColor); - assertEquals(GL_MODULATE, getTexEnvi(GL_TEXTURE_ENV_MODE)); - assertPremultipliedBlending(this); - assertFalse(mGLStencilEnabled); - - // Draw an non-opaque texture with overriden alpha = 1 - canvas.drawTexture(texture, 100, 200, 300, 400, 1f); - assertEquals(42, mGLBindTextureId); - assertEquals(GL_REPLACE, getTexEnvi(GL_TEXTURE_ENV_MODE)); - assertPremultipliedBlending(this); - - // Draw an opaque texture with overriden alpha = 1 - canvas.drawTexture(texture_o, 100, 200, 300, 400, 1f); - assertEquals(47, mGLBindTextureId); - assertEquals(GL_REPLACE, getTexEnvi(GL_TEXTURE_ENV_MODE)); - assertFalse(mGLBlendEnabled); - - // Draw an opaque texture with overridden alpha = 0.25 - canvas.drawTexture(texture_o, 100, 200, 300, 400, 0.25f); - assertEquals(47, mGLBindTextureId); - assertEquals(0x40404040, mGLColor); - assertEquals(GL_MODULATE, getTexEnvi(GL_TEXTURE_ENV_MODE)); - assertPremultipliedBlending(this); - - // Draw an opaque texture with overridden alpha = 0.125 - // but with some rotation so it will use DrawArray. - canvas.save(); - canvas.rotate(30, 0, 0, 1); - canvas.drawTexture(texture_o, 100, 200, 300, 400, 0.125f); - canvas.restore(); - assertEquals(47, mGLBindTextureId); - assertEquals(0x20202020, mGLColor); - assertEquals(GL_MODULATE, getTexEnvi(GL_TEXTURE_ENV_MODE)); - assertPremultipliedBlending(this); - - // We have drawn seven textures above. - assertEquals(1, mDrawArrayCalled); - assertEquals(6, mDrawTexiOESCalled); - - // translate and scale does not affect whether we - // can use glDrawTexiOES, but rotate may. - canvas.translate(10, 20, 30); - canvas.drawTexture(texture, 100, 200, 300, 400); - assertEquals(7, mDrawTexiOESCalled); - - canvas.scale(10, 20, 30); - canvas.drawTexture(texture, 100, 200, 300, 400); - assertEquals(8, mDrawTexiOESCalled); - - canvas.rotate(90, 1, 2, 3); - canvas.drawTexture(texture, 100, 200, 300, 400); - assertEquals(8, mDrawTexiOESCalled); - - canvas.rotate(-90, 1, 2, 3); - canvas.drawTexture(texture, 100, 200, 300, 400); - assertEquals(9, mDrawTexiOESCalled); - - canvas.rotate(180, 0, 0, 1); - canvas.drawTexture(texture, 100, 200, 300, 400); - assertEquals(9, mDrawTexiOESCalled); - - canvas.rotate(180, 0, 0, 1); - canvas.drawTexture(texture, 100, 200, 300, 400); - assertEquals(10, mDrawTexiOESCalled); - - assertEquals(3, mDrawArrayCalled); - - assertTrue(texture.isLoaded(canvas)); - texture.recycle(); - assertFalse(texture.isLoaded(canvas)); - canvas.deleteRecycledResources(); - - assertTrue(texture_o.isLoaded(canvas)); - texture_o.recycle(); - assertFalse(texture_o.isLoaded(canvas)); - } - } - - private static class DrawTextureMixedTest extends GLMock { - - boolean mTexture2DEnabled0, mTexture2DEnabled1; - int mBindTexture0; - int mBindTexture1; - - @Override - public void glEnable(int cap) { - if (cap == GL_TEXTURE_2D) { - texture2DEnable(true); - } - } - - @Override - public void glDisable(int cap) { - if (cap == GL_TEXTURE_2D) { - texture2DEnable(false); - } - } - - private void texture2DEnable(boolean enable) { - if (mGLActiveTexture == GL_TEXTURE0) { - mTexture2DEnabled0 = enable; - } else if (mGLActiveTexture == GL_TEXTURE1) { - mTexture2DEnabled1 = enable; - } else { - fail(); - } - } - - @Override - public void glTexEnvfv(int target, int pname, float[] params, int offset) { - if (target == GL_TEXTURE_ENV && pname == GL_TEXTURE_ENV_COLOR) { - assertEquals(0.5f, params[offset + 3]); - } - } - - @Override - public void glBindTexture(int target, int texture) { - if (target == GL_TEXTURE_2D) { - if (mGLActiveTexture == GL_TEXTURE0) { - mBindTexture0 = texture; - } else if (mGLActiveTexture == GL_TEXTURE1) { - mBindTexture1 = texture; - } else { - fail(); - } - } - } - - void run() { - GLCanvas canvas = new GLCanvasImpl(this); - canvas.setSize(400, 300); - MyTexture from = new MyTexture(canvas, 42, false); // non-opaque - MyTexture to = new MyTexture(canvas, 47, true); // opaque - - canvas.drawMixed(from, to, 0.5f, 100, 200, 300, 400); - assertEquals(42, mBindTexture0); - assertEquals(47, mBindTexture1); - assertTrue(mTexture2DEnabled0); - assertFalse(mTexture2DEnabled1); - - assertEquals(GL_COMBINE, getTexEnvi(GL_TEXTURE1, GL_TEXTURE_ENV_MODE)); - assertEquals(GL_INTERPOLATE, getTexEnvi(GL_TEXTURE1, GL_COMBINE_RGB)); - assertEquals(GL_INTERPOLATE, getTexEnvi(GL_TEXTURE1, GL_COMBINE_ALPHA)); - assertEquals(GL_CONSTANT, getTexEnvi(GL_TEXTURE1, GL_SRC2_RGB)); - assertEquals(GL_CONSTANT, getTexEnvi(GL_TEXTURE1, GL_SRC2_ALPHA)); - assertEquals(GL_SRC_ALPHA, getTexEnvi(GL_TEXTURE1, GL_OPERAND2_RGB)); - assertEquals(GL_SRC_ALPHA, getTexEnvi(GL_TEXTURE1, GL_OPERAND2_ALPHA)); - - assertEquals(GL_REPLACE, getTexEnvi(GL_TEXTURE0, GL_TEXTURE_ENV_MODE)); - - assertFalse(mGLBlendEnabled); - - canvas.drawMixed(from, to, 0, 100, 200, 300, 400); - assertEquals(GL_REPLACE, getTexEnvi(GL_TEXTURE0, GL_TEXTURE_ENV_MODE)); - assertEquals(42, mBindTexture0); - - canvas.drawMixed(from, to, 1, 100, 200, 300, 400); - assertEquals(GL_REPLACE, getTexEnvi(GL_TEXTURE0, GL_TEXTURE_ENV_MODE)); - assertEquals(47, mBindTexture0); - } - } - - @SmallTest public void testGetGLInstance() { GL11 glStub = new GLStub(); GLCanvas canvas = new GLCanvasImpl(glStub); diff --git a/tests/src/com/android/gallery3d/ui/GLViewTest.java b/tests/src/com/android/gallery3d/ui/GLViewTest.java index a9377bfee..b17b25440 100644 --- a/tests/src/com/android/gallery3d/ui/GLViewTest.java +++ b/tests/src/com/android/gallery3d/ui/GLViewTest.java @@ -102,32 +102,6 @@ public class GLViewTest extends TestCase { } @SmallTest - public void testPaddings() { - GLView view = new GLView(); - - Rect p = view.getPaddings(); - assertEquals(0, p.left); - assertEquals(0, p.top); - assertEquals(0, p.right); - assertEquals(0, p.bottom); - - view.setPaddings(10, 20, 30, 100); - p = view.getPaddings(); - assertEquals(10, p.left); - assertEquals(20, p.top); - assertEquals(30, p.right); - assertEquals(100, p.bottom); - - p = new Rect(11, 22, 33, 104); - view.setPaddings(p); - p = view.getPaddings(); - assertEquals(11, p.left); - assertEquals(22, p.top); - assertEquals(33, p.right); - assertEquals(104, p.bottom); - } - - @SmallTest public void testParent() { GLView a = new GLView(); GLView b = new GLView(); diff --git a/tests/src/com/android/gallery3d/ui/TextureTest.java b/tests/src/com/android/gallery3d/ui/TextureTest.java index fb26060bc..821d49bb1 100644 --- a/tests/src/com/android/gallery3d/ui/TextureTest.java +++ b/tests/src/com/android/gallery3d/ui/TextureTest.java @@ -90,24 +90,6 @@ public class TextureTest extends TestCase { } @SmallTest - public void testRawTexture() { - GL11 glStub = new GLStub(); - GLCanvas canvas = new GLCanvasImpl(glStub); - RawTexture texture = RawTexture.newInstance(canvas); - texture.onBind(canvas); - - GLCanvas canvas2 = new GLCanvasImpl(new GLStub()); - try { - texture.onBind(canvas2); - fail(); - } catch (RuntimeException ex) { - // expected. - } - - assertTrue(texture.isOpaque()); - } - - @SmallTest public void testColorTexture() { GLCanvasMock canvas = new GLCanvasMock(); ColorTexture texture = new ColorTexture(0x12345678); |