Guest User

Untitled

a guest
Oct 18th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.90 KB | None | 0 0
  1. [drew@master aosp]$ repo forall -pcv git log --oneline --no-merges android-4.0.4_r1.2..android-4.0.4_r2.1
  2.  
  3. project build/
  4. 1bbaf73 IMM76L
  5. b0936b7 IMM76K
  6. 396c8cf IMM76J
  7.  
  8. project device/moto/stingray/
  9. ca7247e Update for cmda radio 3.1A.65P
  10.  
  11. project packages/apps/Gallery2/
  12. fd69559 Patch 2 for MR1.
  13. 1cdcda4 Patch for MR1.
  14.  
  15. [drew@master aosp]$ repo forall -pcv git log -p --oneline --no-merges android-4.0.4_r1.2..android-4.0.4_r2.1
  16.  
  17. project build/
  18. 1bbaf73 IMM76L
  19. diff --git a/core/build_id.mk b/core/build_id.mk
  20. index 77e9923..8f1b5ba 100644
  21. --- a/core/build_id.mk
  22. +++ b/core/build_id.mk
  23. @@ -19,4 +19,4 @@
  24. # (like "CRB01"). It must be a single word, and is
  25. # capitalized by convention.
  26.  
  27. -export BUILD_ID=IMM76K
  28. +export BUILD_ID=IMM76L
  29. b0936b7 IMM76K
  30. diff --git a/core/build_id.mk b/core/build_id.mk
  31. index c7f7c2b..77e9923 100644
  32. --- a/core/build_id.mk
  33. +++ b/core/build_id.mk
  34. @@ -19,4 +19,4 @@
  35. # (like "CRB01"). It must be a single word, and is
  36. # capitalized by convention.
  37.  
  38. -export BUILD_ID=IMM76J
  39. +export BUILD_ID=IMM76K
  40. 396c8cf IMM76J
  41. diff --git a/core/build_id.mk b/core/build_id.mk
  42. index 9d1709c..c7f7c2b 100644
  43. --- a/core/build_id.mk
  44. +++ b/core/build_id.mk
  45. @@ -19,4 +19,4 @@
  46. # (like "CRB01"). It must be a single word, and is
  47. # capitalized by convention.
  48.  
  49. -export BUILD_ID=IMM76I
  50. +export BUILD_ID=IMM76J
  51.  
  52. project device/moto/stingray/
  53. ca7247e Update for cmda radio 3.1A.65P
  54. diff --git a/board-info.txt b/board-info.txt
  55. index d69c0e0..0095444 100644
  56. --- a/board-info.txt
  57. +++ b/board-info.txt
  58. @@ -1,4 +1,4 @@
  59. require product=stingray|xoom-cdma|xoom-cdma-lte
  60. require version-bootloader=1050
  61. -require version-baseband=CDMA_N_03.1A.64PS
  62. +require version-baseband=CDMA_N_03.1A.65PS
  63. require-for-product:xoom-cdma-lte version-baseband-2=LTEDC_U_07.1F.00
  64.  
  65. project external/android-clat/
  66.  
  67. project external/ant-glob/
  68.  
  69. project external/apache-qp/
  70.  
  71. project external/checkpolicy/
  72.  
  73. project external/eclipse-basebuilder/
  74.  
  75. project external/eclipse-windowbuilder/
  76.  
  77. project external/libmtp/
  78.  
  79. project external/libselinux/
  80.  
  81. project external/libsepol/
  82.  
  83. project external/libusb/
  84.  
  85. project external/libusb-compat/
  86.  
  87. project external/sepolicy/
  88.  
  89. project frameworks/opt/carddav/
  90.  
  91. project hardware/ti/wlan/
  92.  
  93. project hardware/ti/wpan/
  94.  
  95. project packages/apps/Gallery2/
  96. fd69559 Patch 2 for MR1.
  97. diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java
  98. index aeed577..217a290 100644
  99. --- a/src/com/android/gallery3d/ui/PhotoView.java
  100. +++ b/src/com/android/gallery3d/ui/PhotoView.java
  101. @@ -43,6 +43,7 @@ public class PhotoView extends GLView {
  102.  
  103. private static final int MSG_TRANSITION_COMPLETE = 1;
  104. private static final int MSG_SHOW_LOADING = 2;
  105. + private static final int MSG_CANCEL_EXTRA_SCALING = 3;
  106.  
  107. private static final long DELAY_SHOW_LOADING = 250; // 250ms;
  108.  
  109. @@ -111,6 +112,7 @@ public class PhotoView extends GLView {
  110. private Path mOpenedItemPath;
  111. private GalleryActivity mActivity;
  112. private Point mImageCenter = new Point();
  113. + private boolean mCancelExtraScalingPending;
  114.  
  115. public PhotoView(GalleryActivity activity) {
  116. mActivity = activity;
  117. @@ -146,6 +148,12 @@ public class PhotoView extends GLView {
  118. }
  119. break;
  120. }
  121. + case MSG_CANCEL_EXTRA_SCALING: {
  122. + cancelScaleGesture();
  123. + mPositionController.setExtraScalingRange(false);
  124. + mCancelExtraScalingPending = false;
  125. + break;
  126. + }
  127. default: throw new AssertionError(message.what);
  128. }
  129. }
  130. @@ -585,8 +593,22 @@ public class PhotoView extends GLView {
  131. float scale = detector.getScaleFactor();
  132. if (Float.isNaN(scale) || Float.isInfinite(scale)
  133. || mTransitionMode != TRANS_NONE) return true;
  134. - mPositionController.scaleBy(scale,
  135. + boolean outOfRange = mPositionController.scaleBy(scale,
  136. detector.getFocusX(), detector.getFocusY());
  137. + if (outOfRange) {
  138. + if (!mCancelExtraScalingPending) {
  139. + mHandler.sendEmptyMessageDelayed(
  140. + MSG_CANCEL_EXTRA_SCALING, 700);
  141. + mPositionController.setExtraScalingRange(true);
  142. + mCancelExtraScalingPending = true;
  143. + }
  144. + } else {
  145. + if (mCancelExtraScalingPending) {
  146. + mHandler.removeMessages(MSG_CANCEL_EXTRA_SCALING);
  147. + mPositionController.setExtraScalingRange(false);
  148. + mCancelExtraScalingPending = false;
  149. + }
  150. + }
  151. return true;
  152. }
  153.  
  154. @@ -605,6 +627,14 @@ public class PhotoView extends GLView {
  155. }
  156. }
  157.  
  158. + private void cancelScaleGesture() {
  159. + long now = SystemClock.uptimeMillis();
  160. + MotionEvent cancelEvent = MotionEvent.obtain(
  161. + now, now, MotionEvent.ACTION_CANCEL, 0, 0, 0);
  162. + mScaleDetector.onTouchEvent(cancelEvent);
  163. + cancelEvent.recycle();
  164. + }
  165. +
  166. public boolean jumpTo(int index) {
  167. if (mTransitionMode != TRANS_NONE) return false;
  168. mModel.jumpTo(index);
  169. diff --git a/src/com/android/gallery3d/ui/PositionController.java b/src/com/android/gallery3d/ui/PositionController.java
  170. index b4dac97..2068446 100644
  171. --- a/src/com/android/gallery3d/ui/PositionController.java
  172. +++ b/src/com/android/gallery3d/ui/PositionController.java
  173. @@ -64,6 +64,9 @@ class PositionController {
  174. private static final float SCALE_LIMIT = 4;
  175. private static final int sHorizontalSlack = GalleryUtils.dpToPixel(12);
  176.  
  177. + private static final float SCALE_MIN_EXTRA = 0.6f;
  178. + private static final float SCALE_MAX_EXTRA = 1.4f;
  179. +
  180. private PhotoView mViewer;
  181. private EdgeView mEdgeView;
  182. private int mImageW, mImageH;
  183. @@ -83,6 +86,7 @@ class PositionController {
  184.  
  185. // The minimum and maximum scale we allow.
  186. private float mScaleMin, mScaleMax = SCALE_LIMIT;
  187. + private boolean mExtraScalingRange = false;
  188.  
  189. // This is used by the fling animation
  190. private FlingScroller mScroller;
  191. @@ -268,7 +272,8 @@ class PositionController {
  192. (focusY - mViewH / 2f) / mCurrentScale);
  193. }
  194.  
  195. - public void scaleBy(float s, float focusX, float focusY) {
  196. + // Returns true if the result scale is outside the stable range.
  197. + public boolean scaleBy(float s, float focusX, float focusY) {
  198.  
  199. // We want to keep the focus point (on the bitmap) the same as when
  200. // we begin the scale guesture, that is,
  201. @@ -280,6 +285,7 @@ class PositionController {
  202. int y = Math.round(mFocusBitmapY - (focusY - mViewH / 2f) / s);
  203.  
  204. startAnimation(x, y, s, ANIM_KIND_SCALE);
  205. + return (s < mScaleMin || s > mScaleMax);
  206. }
  207.  
  208. public void endScale() {
  209. @@ -287,6 +293,13 @@ class PositionController {
  210. startSnapbackIfNeeded();
  211. }
  212.  
  213. + public void setExtraScalingRange(boolean enabled) {
  214. + mExtraScalingRange = enabled;
  215. + if (!enabled) {
  216. + startSnapbackIfNeeded();
  217. + }
  218. + }
  219. +
  220. public float getCurrentScale() {
  221. return mCurrentScale;
  222. }
  223. @@ -400,7 +413,8 @@ class PositionController {
  224.  
  225. mToX = targetX;
  226. mToY = targetY;
  227. - mToScale = Utils.clamp(scale, 0.6f * mScaleMin, 1.4f * mScaleMax);
  228. + mToScale = Utils.clamp(scale, SCALE_MIN_EXTRA * mScaleMin,
  229. + SCALE_MAX_EXTRA * mScaleMax);
  230.  
  231. // If the scaled height is smaller than the view height,
  232. // force it to be in the center.
  233. @@ -540,9 +554,14 @@ class PositionController {
  234. boolean needAnimation = false;
  235. float scale = mCurrentScale;
  236.  
  237. - if (mCurrentScale < mScaleMin || mCurrentScale > mScaleMax) {
  238. + float scaleMin = mExtraScalingRange ?
  239. + mScaleMin * SCALE_MIN_EXTRA : mScaleMin;
  240. + float scaleMax = mExtraScalingRange ?
  241. + mScaleMax * SCALE_MAX_EXTRA : mScaleMax;
  242. +
  243. + if (mCurrentScale < scaleMin || mCurrentScale > scaleMax) {
  244. needAnimation = true;
  245. - scale = Utils.clamp(mCurrentScale, mScaleMin, mScaleMax);
  246. + scale = Utils.clamp(mCurrentScale, scaleMin, scaleMax);
  247. }
  248.  
  249. calculateStableBound(scale, sHorizontalSlack);
  250. 1cdcda4 Patch for MR1.
  251. diff --git a/src/com/android/gallery3d/app/PhotoDataAdapter.java b/src/com/android/gallery3d/app/PhotoDataAdapter.java
  252. index 9b1c8c4..d7d1168 100644
  253. --- a/src/com/android/gallery3d/app/PhotoDataAdapter.java
  254. +++ b/src/com/android/gallery3d/app/PhotoDataAdapter.java
  255. @@ -365,8 +365,9 @@ public class PhotoDataAdapter implements PhotoPage.Model {
  256. return mTileProvider.getLevelCount();
  257. }
  258.  
  259. - public Bitmap getTile(int level, int x, int y, int tileSize) {
  260. - return mTileProvider.getTile(level, x, y, tileSize);
  261. + public Bitmap getTile(int level, int x, int y, int tileSize,
  262. + int borderSize) {
  263. + return mTileProvider.getTile(level, x, y, tileSize, borderSize);
  264. }
  265.  
  266. public boolean isFailedToLoad() {
  267. diff --git a/src/com/android/gallery3d/ui/BitmapTileProvider.java b/src/com/android/gallery3d/ui/BitmapTileProvider.java
  268. index a47337f..3d4d4dc 100644
  269. --- a/src/com/android/gallery3d/ui/BitmapTileProvider.java
  270. +++ b/src/com/android/gallery3d/ui/BitmapTileProvider.java
  271. @@ -65,11 +65,28 @@ public class BitmapTileProvider implements TileImageView.Model {
  272. return mMipmaps.length;
  273. }
  274.  
  275. - public Bitmap getTile(int level, int x, int y, int tileSize) {
  276. - Bitmap result = Bitmap.createBitmap(tileSize, tileSize, mConfig);
  277. + public Bitmap getTile(int level, int x, int y, int tileSize,
  278. + int borderSize) {
  279. + x >>= level;
  280. + y >>= level;
  281. + int size = tileSize + 2 * borderSize;
  282. + Bitmap result = Bitmap.createBitmap(size, size, mConfig);
  283. + Bitmap mipmap = mMipmaps[level];
  284. Canvas canvas = new Canvas(result);
  285. - canvas.drawBitmap(mMipmaps[level], -(x >> level), -(y >> level), null);
  286. - return result;
  287. + int offsetX = -x + borderSize;
  288. + int offsetY = -y + borderSize;
  289. + canvas.drawBitmap(mipmap, offsetX, offsetY, null);
  290. +
  291. + // If the valid region (covered by mipmap or border) is smaller than the
  292. + // result bitmap, subset it.
  293. + int endX = offsetX + mipmap.getWidth() + borderSize;
  294. + int endY = offsetY + mipmap.getHeight() + borderSize;
  295. + if (endX < size || endY < size) {
  296. + return Bitmap.createBitmap(result, 0, 0, Math.min(size, endX),
  297. + Math.min(size, endY));
  298. + } else {
  299. + return result;
  300. + }
  301. }
  302.  
  303. public void recycle() {
  304. diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java
  305. index 5062c0e..aeed577 100644
  306. --- a/src/com/android/gallery3d/ui/PhotoView.java
  307. +++ b/src/com/android/gallery3d/ui/PhotoView.java
  308. @@ -25,12 +25,15 @@ import com.android.gallery3d.ui.PositionRepository.Position;
  309. import android.content.Context;
  310. import android.graphics.Bitmap;
  311. import android.graphics.Color;
  312. +import android.graphics.Point;
  313. +import android.graphics.Rect;
  314. import android.graphics.RectF;
  315. import android.os.Message;
  316. import android.os.SystemClock;
  317. import android.view.GestureDetector;
  318. import android.view.MotionEvent;
  319. import android.view.ScaleGestureDetector;
  320. +import android.view.animation.AccelerateInterpolator;
  321.  
  322. public class PhotoView extends GLView {
  323. @SuppressWarnings("unused")
  324. @@ -64,6 +67,14 @@ public class PhotoView extends GLView {
  325. private static final float SWIPE_THRESHOLD = 300f;
  326.  
  327. private static final float DEFAULT_TEXT_SIZE = 20;
  328. + private static float TRANSITION_SCALE_FACTOR = 0.74f;
  329. +
  330. + // Used to calculate the scaling factor for the fading animation.
  331. + private ZInterpolator mScaleInterpolator = new ZInterpolator(0.5f);
  332. +
  333. + // Used to calculate the alpha factor for the fading animation.
  334. + private AccelerateInterpolator mAlphaInterpolator =
  335. + new AccelerateInterpolator(0.9f);
  336.  
  337. public interface PhotoTapListener {
  338. public void onSingleTapUp(int x, int y);
  339. @@ -99,6 +110,7 @@ public class PhotoView extends GLView {
  340.  
  341. private Path mOpenedItemPath;
  342. private GalleryActivity mActivity;
  343. + private Point mImageCenter = new Point();
  344.  
  345. public PhotoView(GalleryActivity activity) {
  346. mActivity = activity;
  347. @@ -164,24 +176,49 @@ public class PhotoView extends GLView {
  348. mPhotoTapListener = listener;
  349. }
  350.  
  351. - private boolean setTileViewPosition(int centerX, int centerY, float scale) {
  352. + private void setTileViewPosition(int centerX, int centerY, float scale) {
  353. + TileImageView t = mTileView;
  354. +
  355. + // Calculate the move-out progress value.
  356. + RectF bounds = mPositionController.getImageBounds();
  357. + int left = Math.round(bounds.left);
  358. + int right = Math.round(bounds.right);
  359. + int width = getWidth();
  360. + float progress = calculateMoveOutProgress(left, right, width);
  361. + progress = Utils.clamp(progress, -1f, 1f);
  362. +
  363. + // We only want to apply the fading animation if the scrolling movement
  364. + // is to the right.
  365. + if (progress < 0) {
  366. + if (right - left < width) {
  367. + // If the picture is narrower than the view, keep it at the center
  368. + // of the view.
  369. + centerX = mPositionController.getImageWidth() / 2;
  370. + } else {
  371. + // If the picture is wider than the view (it's zoomed-in), keep
  372. + // the left edge of the object align the the left edge of the view.
  373. + centerX = Math.round(width / 2f / scale);
  374. + }
  375. + scale *= getScrollScale(progress);
  376. + t.setAlpha(getScrollAlpha(progress));
  377. + }
  378. +
  379. + // set the position of the tile view
  380. int inverseX = mPositionController.getImageWidth() - centerX;
  381. int inverseY = mPositionController.getImageHeight() - centerY;
  382. - TileImageView t = mTileView;
  383. int rotation = mImageRotation;
  384. switch (rotation) {
  385. - case 0: return t.setPosition(centerX, centerY, scale, 0);
  386. - case 90: return t.setPosition(centerY, inverseX, scale, 90);
  387. - case 180: return t.setPosition(inverseX, inverseY, scale, 180);
  388. - case 270: return t.setPosition(inverseY, centerX, scale, 270);
  389. + case 0: t.setPosition(centerX, centerY, scale, 0); break;
  390. + case 90: t.setPosition(centerY, inverseX, scale, 90); break;
  391. + case 180: t.setPosition(inverseX, inverseY, scale, 180); break;
  392. + case 270: t.setPosition(inverseY, centerX, scale, 270); break;
  393. default: throw new IllegalArgumentException(String.valueOf(rotation));
  394. }
  395. }
  396.  
  397. public void setPosition(int centerX, int centerY, float scale) {
  398. - if (setTileViewPosition(centerX, centerY, scale)) {
  399. - layoutScreenNails();
  400. - }
  401. + setTileViewPosition(centerX, centerY, scale);
  402. + layoutScreenNails();
  403. }
  404.  
  405. private void updateScreenNailEntry(int which, ImageData data) {
  406. @@ -217,6 +254,7 @@ public class PhotoView extends GLView {
  407. case 0: {
  408. // mImageWidth and mImageHeight will get updated
  409. mTileView.notifyModelInvalidated();
  410. + mTileView.setAlpha(1.0f);
  411.  
  412. mImageRotation = mModel.getImageRotation();
  413. if (((mImageRotation / 90) & 1) == 0) {
  414. @@ -264,6 +302,7 @@ public class PhotoView extends GLView {
  415.  
  416. if (mModel == null) {
  417. mTileView.notifyModelInvalidated();
  418. + mTileView.setAlpha(1.0f);
  419. mImageRotation = 0;
  420. mPositionController.setImageSize(0, 0);
  421. updateLoadingState();
  422. @@ -341,23 +380,40 @@ public class PhotoView extends GLView {
  423. @Override
  424. protected void render(GLCanvas canvas) {
  425. PositionController p = mPositionController;
  426. + boolean drawScreenNail = (mTransitionMode != TRANS_SLIDE_IN_LEFT
  427. + && mTransitionMode != TRANS_SLIDE_IN_RIGHT
  428. + && mTransitionMode != TRANS_OPEN_ANIMATION);
  429. +
  430. + // Draw the next photo
  431. + if (drawScreenNail) {
  432. + ScreenNailEntry nextNail = mScreenNails[ENTRY_NEXT];
  433. + if (nextNail.mVisible) nextNail.draw(canvas, true);
  434. + }
  435.  
  436. // Draw the current photo
  437. if (mLoadingState == LOADING_COMPLETE) {
  438. super.render(canvas);
  439. }
  440.  
  441. - // Draw the previous and the next photo
  442. - if (mTransitionMode != TRANS_SLIDE_IN_LEFT
  443. - && mTransitionMode != TRANS_SLIDE_IN_RIGHT
  444. - && mTransitionMode != TRANS_OPEN_ANIMATION) {
  445. - ScreenNailEntry prevNail = mScreenNails[ENTRY_PREVIOUS];
  446. - ScreenNailEntry nextNail = mScreenNails[ENTRY_NEXT];
  447. + // If the photo is loaded, draw the message/icon at the center of it,
  448. + // otherwise draw the message/icon at the center of the view.
  449. + if (mLoadingState == LOADING_COMPLETE) {
  450. + mTileView.getImageCenter(mImageCenter);
  451. + renderMessage(canvas, mImageCenter.x, mImageCenter.y);
  452. + } else {
  453. + renderMessage(canvas, getWidth() / 2, getHeight() / 2);
  454. + }
  455.  
  456. - if (prevNail.mVisible) prevNail.draw(canvas);
  457. - if (nextNail.mVisible) nextNail.draw(canvas);
  458. + // Draw the previous photo
  459. + if (drawScreenNail) {
  460. + ScreenNailEntry prevNail = mScreenNails[ENTRY_PREVIOUS];
  461. + if (prevNail.mVisible) prevNail.draw(canvas, false);
  462. }
  463.  
  464. + if (mPositionController.advanceAnimation()) invalidate();
  465. + }
  466. +
  467. + private void renderMessage(GLCanvas canvas, int x, int y) {
  468. // Draw the progress spinner and the text below it
  469. //
  470. // (x, y) is where we put the center of the spinner.
  471. @@ -366,8 +422,6 @@ public class PhotoView extends GLView {
  472. // play icon is shown instead of the spinner.
  473. int w = getWidth();
  474. int h = getHeight();
  475. - int x = Math.round(mPositionController.getImageBounds().centerX());
  476. - int y = h / 2;
  477. int s = Math.min(getWidth(), getHeight()) / 6;
  478.  
  479. if (mLoadingState == LOADING_TIMEOUT) {
  480. @@ -387,8 +441,6 @@ public class PhotoView extends GLView {
  481. && mLoadingState != LOADING_TIMEOUT) {
  482. mVideoPlayIcon.draw(canvas, x - s / 2, y - s / 2, s, s);
  483. }
  484. -
  485. - if (mPositionController.advanceAnimation()) invalidate();
  486. }
  487.  
  488. private void stopCurrentSwipingIfNeeded() {
  489. @@ -731,23 +783,107 @@ public class PhotoView extends GLView {
  490. return mEnabled;
  491. }
  492.  
  493. - public void draw(GLCanvas canvas) {
  494. - int x = mOffsetX;
  495. - int y = getHeight() / 2;
  496. + public void draw(GLCanvas canvas, boolean applyFadingAnimation) {
  497. + if (mTexture == null) return;
  498.  
  499. - if (mTexture != null) {
  500. - if (mRotation != 0) {
  501. - canvas.save(GLCanvas.SAVE_FLAG_MATRIX);
  502. - canvas.translate(x, y, 0);
  503. - canvas.rotate(mRotation, 0, 0, 1); //mRotation
  504. - canvas.translate(-x, -y, 0);
  505. - }
  506. - mTexture.draw(canvas, x - mDrawWidth / 2, y - mDrawHeight / 2,
  507. - mDrawWidth, mDrawHeight);
  508. - if (mRotation != 0) {
  509. - canvas.restore();
  510. - }
  511. + int w = getWidth();
  512. + int x = applyFadingAnimation ? w / 2 : mOffsetX;
  513. + int y = getHeight() / 2;
  514. + int flags = GLCanvas.SAVE_FLAG_MATRIX;
  515. +
  516. + if (applyFadingAnimation) flags |= GLCanvas.SAVE_FLAG_ALPHA;
  517. + canvas.save(flags);
  518. + canvas.translate(x, y, 0);
  519. + if (applyFadingAnimation) {
  520. + float progress = (float) (x - mOffsetX) / w;
  521. + float alpha = getScrollAlpha(progress);
  522. + float scale = getScrollScale(progress);
  523. + canvas.multiplyAlpha(alpha);
  524. + canvas.scale(scale, scale, 1);
  525. }
  526. + if (mRotation != 0) {
  527. + canvas.rotate(mRotation, 0, 0, 1);
  528. + }
  529. + canvas.translate(-x, -y, 0);
  530. + mTexture.draw(canvas, x - mDrawWidth / 2, y - mDrawHeight / 2,
  531. + mDrawWidth, mDrawHeight);
  532. + canvas.restore();
  533. + }
  534. + }
  535. +
  536. + // Returns the scrolling progress value for an object moving out of a
  537. + // view. The progress value measures how much the object has moving out of
  538. + // the view. The object currently displays in [left, right), and the view is
  539. + // at [0, viewWidth].
  540. + //
  541. + // The returned value is negative when the object is moving right, and
  542. + // positive when the object is moving left. The value goes to -1 or 1 when
  543. + // the object just moves out of the view completely. The value is 0 if the
  544. + // object currently fills the view.
  545. + private static float calculateMoveOutProgress(int left, int right,
  546. + int viewWidth) {
  547. + // w = object width
  548. + // viewWidth = view width
  549. + int w = right - left;
  550. +
  551. + // If the object width is smaller than the view width,
  552. + // |....view....|
  553. + // |<-->| progress = -1 when left = viewWidth
  554. + // |<-->| progress = 1 when left = -w
  555. + // So progress = 1 - 2 * (left + w) / (viewWidth + w)
  556. + if (w < viewWidth) {
  557. + return 1f - 2f * (left + w) / (viewWidth + w);
  558. + }
  559. +
  560. + // If the object width is larger than the view width,
  561. + // |..view..|
  562. + // |<--------->| progress = -1 when left = viewWidth
  563. + // |<--------->| progress = 0 between left = 0
  564. + // |<--------->| and right = viewWidth
  565. + // |<--------->| progress = 1 when right = 0
  566. + if (left > 0) {
  567. + return -left / (float) viewWidth;
  568. + }
  569. +
  570. + if (right < viewWidth) {
  571. + return (viewWidth - right) / (float) viewWidth;
  572. + }
  573. +
  574. + return 0;
  575. + }
  576. +
  577. + // Maps a scrolling progress value to the alpha factor in the fading
  578. + // animation.
  579. + private float getScrollAlpha(float scrollProgress) {
  580. + return scrollProgress < 0 ? mAlphaInterpolator.getInterpolation(
  581. + 1 - Math.abs(scrollProgress)) : 1.0f;
  582. + }
  583. +
  584. + // Maps a scrolling progress value to the scaling factor in the fading
  585. + // animation.
  586. + private float getScrollScale(float scrollProgress) {
  587. + float interpolatedProgress = mScaleInterpolator.getInterpolation(
  588. + Math.abs(scrollProgress));
  589. + float scale = (1 - interpolatedProgress) +
  590. + interpolatedProgress * TRANSITION_SCALE_FACTOR;
  591. + return scale;
  592. + }
  593. +
  594. +
  595. + // This interpolator emulates the rate at which the perceived scale of an
  596. + // object changes as its distance from a camera increases. When this
  597. + // interpolator is applied to a scale animation on a view, it evokes the
  598. + // sense that the object is shrinking due to moving away from the camera.
  599. + private static class ZInterpolator {
  600. + private float focalLength;
  601. +
  602. + public ZInterpolator(float foc) {
  603. + focalLength = foc;
  604. + }
  605. +
  606. + public float getInterpolation(float input) {
  607. + return (1.0f - focalLength / (focalLength + input)) /
  608. + (1.0f - focalLength / (focalLength + 1.0f));
  609. }
  610. }
  611.  
  612. diff --git a/src/com/android/gallery3d/ui/TileImageView.java b/src/com/android/gallery3d/ui/TileImageView.java
  613. index 980f7b2..5c9f3f4 100644
  614. --- a/src/com/android/gallery3d/ui/TileImageView.java
  615. +++ b/src/com/android/gallery3d/ui/TileImageView.java
  616. @@ -17,6 +17,7 @@
  617. package com.android.gallery3d.ui;
  618.  
  619. import android.graphics.Bitmap;
  620. +import android.graphics.Point;
  621. import android.graphics.Rect;
  622. import android.graphics.RectF;
  623.  
  624. @@ -108,6 +109,7 @@ public class TileImageView extends GLView {
  625. protected int mCenterY;
  626. protected float mScale;
  627. protected int mRotation;
  628. + protected float mAlpha = 1.0f;
  629.  
  630. // Temp variables to avoid memory allocation
  631. private final Rect mTileRange = new Rect();
  632. @@ -125,8 +127,20 @@ public class TileImageView extends GLView {
  633. public int getImageWidth();
  634. public int getImageHeight();
  635.  
  636. - // The method would be called in another thread
  637. - public Bitmap getTile(int level, int x, int y, int tileSize);
  638. + // The tile returned by this method can be specified this way: Assuming
  639. + // the image size is (width, height), first take the intersection of (0,
  640. + // 0) - (width, height) and (x, y) - (x + tileSize, y + tileSize). Then
  641. + // extend this intersection region by borderSize pixels on each side. If
  642. + // in extending the region, we found some part of the region are outside
  643. + // the image, those pixels are filled with black.
  644. + //
  645. + // If level > 0, it does the same operation on a down-scaled version of
  646. + // the original image (down-scaled by a factor of 2^level), but (x, y)
  647. + // still refers to the coordinate on the original image.
  648. + //
  649. + // The method would be called in another thread.
  650. + public Bitmap getTile(int level, int x, int y, int tileSize,
  651. + int borderSize);
  652. public boolean isFailedToLoad();
  653. }
  654.  
  655. @@ -308,6 +322,30 @@ public class TileImageView extends GLView {
  656. out.set(left, top, right, bottom);
  657. }
  658.  
  659. + // Calculate where the center of the image is, in the view coordinates.
  660. + public void getImageCenter(Point center) {
  661. + // The width and height of this view.
  662. + int viewW = getWidth();
  663. + int viewH = getHeight();
  664. +
  665. + // The distance between the center of the view to the center of the
  666. + // bitmap, in bitmap units. (mCenterX and mCenterY are the bitmap
  667. + // coordinates correspond to the center of view)
  668. + int distW, distH;
  669. + if (mRotation % 180 == 0) {
  670. + distW = mImageWidth / 2 - mCenterX;
  671. + distH = mImageHeight / 2 - mCenterY;
  672. + } else {
  673. + distW = mImageHeight / 2 - mCenterY;
  674. + distH = mImageWidth / 2 - mCenterX;
  675. + }
  676. +
  677. + // Convert to view coordinates. mScale translates from bitmap units to
  678. + // view units.
  679. + center.x = Math.round(viewW / 2f + distW * mScale);
  680. + center.y = Math.round(viewH / 2f + distH * mScale);
  681. + }
  682. +
  683. public boolean setPosition(int centerX, int centerY, float scale, int rotation) {
  684. if (mCenterX == centerX
  685. && mCenterY == centerY && mScale == scale) return false;
  686. @@ -320,6 +358,13 @@ public class TileImageView extends GLView {
  687. return true;
  688. }
  689.  
  690. + public boolean setAlpha(float alpha) {
  691. + if (mAlpha == alpha) return false;
  692. + mAlpha = alpha;
  693. + invalidate();
  694. + return true;
  695. + }
  696. +
  697. public void freeTextures() {
  698. mIsTextureFreed = true;
  699.  
  700. @@ -365,13 +410,19 @@ public class TileImageView extends GLView {
  701.  
  702. int level = mLevel;
  703. int rotation = mRotation;
  704. -
  705. - if (rotation != 0) {
  706. - canvas.save(GLCanvas.SAVE_FLAG_MATRIX);
  707. - int centerX = getWidth() / 2, centerY = getHeight() / 2;
  708. - canvas.translate(centerX, centerY, 0);
  709. - canvas.rotate(rotation, 0, 0, 1);
  710. - canvas.translate(-centerX, -centerY, 0);
  711. + int flags = 0;
  712. + if (rotation != 0) flags |= GLCanvas.SAVE_FLAG_MATRIX;
  713. + if (mAlpha != 1.0f) flags |= GLCanvas.SAVE_FLAG_ALPHA;
  714. +
  715. + if (flags != 0) {
  716. + canvas.save(flags);
  717. + if (rotation != 0) {
  718. + int centerX = getWidth() / 2, centerY = getHeight() / 2;
  719. + canvas.translate(centerX, centerY, 0);
  720. + canvas.rotate(rotation, 0, 0, 1);
  721. + canvas.translate(-centerX, -centerY, 0);
  722. + }
  723. + if (mAlpha != 1.0f) canvas.multiplyAlpha(mAlpha);
  724. }
  725. try {
  726. if (level != mLevelCount) {
  727. @@ -392,7 +443,7 @@ public class TileImageView extends GLView {
  728. Math.round(mImageHeight * mScale));
  729. }
  730. } finally {
  731. - if (rotation != 0) canvas.restore();
  732. + if (flags != 0) canvas.restore();
  733. }
  734.  
  735. if (mRenderComplete) {
  736. @@ -601,11 +652,9 @@ public class TileImageView extends GLView {
  737. boolean decode() {
  738. // Get a tile from the original image. The tile is down-scaled
  739. // by (1 << mTilelevel) from a region in the original image.
  740. - int tileLength = (TILE_SIZE + 2 * TILE_BORDER);
  741. - int borderLength = TILE_BORDER << mTileLevel;
  742. try {
  743. mDecodedTile = DecodeUtils.ensureGLCompatibleBitmap(mModel.getTile(
  744. - mTileLevel, mX - borderLength, mY - borderLength, tileLength));
  745. + mTileLevel, mX, mY, TILE_SIZE, TILE_BORDER));
  746. } catch (Throwable t) {
  747. Log.w(TAG, "fail to decode tile", t);
  748. }
  749. @@ -621,6 +670,20 @@ public class TileImageView extends GLView {
  750. return bitmap;
  751. }
  752.  
  753. + // We override getTextureWidth() and getTextureHeight() here, so the
  754. + // texture can be re-used for different tiles regardless of the actual
  755. + // size of the tile (which may be small because it is a tile at the
  756. + // boundary).
  757. + @Override
  758. + public int getTextureWidth() {
  759. + return TILE_SIZE + TILE_BORDER * 2;
  760. + }
  761. +
  762. + @Override
  763. + public int getTextureHeight() {
  764. + return TILE_SIZE + TILE_BORDER * 2;
  765. + }
  766. +
  767. public void update(int x, int y, int level) {
  768. mX = x;
  769. mY = y;
  770. diff --git a/src/com/android/gallery3d/ui/TileImageViewAdapter.java b/src/com/android/gallery3d/ui/TileImageViewAdapter.java
  771. index 63bb0b2..be255d2 100644
  772. --- a/src/com/android/gallery3d/ui/TileImageViewAdapter.java
  773. +++ b/src/com/android/gallery3d/ui/TileImageViewAdapter.java
  774. @@ -34,9 +34,6 @@ public class TileImageViewAdapter implements TileImageView.Model {
  775. protected int mLevelCount;
  776. protected boolean mFailedToLoad;
  777.  
  778. - private final Rect mIntersectRect = new Rect();
  779. - private final Rect mRegionRect = new Rect();
  780. -
  781. public TileImageViewAdapter() {
  782. }
  783.  
  784. @@ -80,16 +77,24 @@ public class TileImageViewAdapter implements TileImageView.Model {
  785. }
  786.  
  787. @Override
  788. - public synchronized Bitmap getTile(int level, int x, int y, int length) {
  789. + public synchronized Bitmap getTile(int level, int x, int y, int tileSize,
  790. + int borderSize) {
  791. if (mRegionDecoder == null) return null;
  792.  
  793. - Rect region = mRegionRect;
  794. - Rect intersectRect = mIntersectRect;
  795. - region.set(x, y, x + (length << level), y + (length << level));
  796. - intersectRect.set(0, 0, mImageWidth, mImageHeight);
  797. + // wantRegion is the rectangle on the original image we want. askRegion
  798. + // is the rectangle on the original image that we will ask from
  799. + // mRegionDecoder. Both are in the coordinates of the original image,
  800. + // not the coordinates of the scaled-down images.
  801. + Rect wantRegion = new Rect();
  802. + Rect askRegion = new Rect();
  803. +
  804. + int b = borderSize << level;
  805. + wantRegion.set(x - b, y - b, x + (tileSize << level) + b,
  806. + y + (tileSize << level) + b);
  807.  
  808. - // Get the intersected rect of the requested region and the image.
  809. - Utils.assertTrue(intersectRect.intersect(region));
  810. + // askRegion is the intersection of wantRegion and the original image.
  811. + askRegion.set(0, 0, mImageWidth, mImageHeight);
  812. + Utils.assertTrue(askRegion.intersect(wantRegion));
  813.  
  814. BitmapFactory.Options options = new BitmapFactory.Options();
  815. options.inPreferredConfig = Config.ARGB_8888;
  816. @@ -100,25 +105,37 @@ public class TileImageViewAdapter implements TileImageView.Model {
  817.  
  818. // In CropImage, we may call the decodeRegion() concurrently.
  819. synchronized (mRegionDecoder) {
  820. - bitmap = mRegionDecoder.decodeRegion(intersectRect, options);
  821. + bitmap = mRegionDecoder.decodeRegion(askRegion, options);
  822. }
  823.  
  824. - // The returned region may not match with the targetLength.
  825. - // If so, we fill black pixels on it.
  826. - if (intersectRect.equals(region)) return bitmap;
  827. -
  828. if (bitmap == null) {
  829. Log.w(TAG, "fail in decoding region");
  830. return null;
  831. }
  832.  
  833. - Bitmap tile = Bitmap.createBitmap(length, length, Config.ARGB_8888);
  834. - Canvas canvas = new Canvas(tile);
  835. - canvas.drawBitmap(bitmap,
  836. - (intersectRect.left - region.left) >> level,
  837. - (intersectRect.top - region.top) >> level, null);
  838. + if (wantRegion.equals(askRegion)) return bitmap;
  839. +
  840. + // Now the wantRegion does not match the askRegion. This means we are at
  841. + // a boundary tile, and we need to add paddings. Create a new Bitmap
  842. + // and copy over.
  843. + int size = tileSize + 2 * borderSize;
  844. + Bitmap result = Bitmap.createBitmap(size, size, Config.ARGB_8888);
  845. + Canvas canvas = new Canvas(result);
  846. + int offsetX = (askRegion.left - wantRegion.left) >> level;
  847. + int offsetY = (askRegion.top - wantRegion.top) >> level;
  848. + canvas.drawBitmap(bitmap, offsetX, offsetY, null);
  849. +
  850. + // If the valid region (covered by bitmap or border) is smaller than the
  851. + // result bitmap, subset it.
  852. + int endX = offsetX + bitmap.getWidth() + borderSize;
  853. + int endY = offsetY + bitmap.getHeight() + borderSize;
  854. bitmap.recycle();
  855. - return tile;
  856. + if (endX < size || endY < size) {
  857. + return Bitmap.createBitmap(result, 0, 0, Math.min(size, endX),
  858. + Math.min(size, endY));
  859. + } else {
  860. + return result;
  861. + }
  862. }
  863.  
  864. @Override
  865. diff --git a/src/com/android/gallery3d/ui/UploadedTexture.java b/src/com/android/gallery3d/ui/UploadedTexture.java
  866. index b2b8cd5..1777048 100644
  867. --- a/src/com/android/gallery3d/ui/UploadedTexture.java
  868. +++ b/src/com/android/gallery3d/ui/UploadedTexture.java
  869. @@ -161,6 +161,8 @@ abstract class UploadedTexture extends BasicTexture {
  870. protected void invalidateContent() {
  871. if (mBitmap != null) freeBitmap();
  872. mContentValid = false;
  873. + mWidth = UNSPECIFIED;
  874. + mHeight = UNSPECIFIED;
  875. }
  876.  
  877. /**
  878.  
  879. project packages/apps/SmartCardService/
  880.  
  881. project prebuilts/eclipse/
  882.  
  883. project prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/
  884.  
  885. project prebuilts/gcc/darwin-x86/mips/mipsel-linux-android-4.4.3/
  886.  
  887. project prebuilts/gcc/darwin-x86/mips/mipsel-linux-android-4.6/
  888.  
  889. project prebuilts/gcc/darwin-x86/x86/i686-linux-android-4.6/
  890.  
  891. project prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/
  892.  
  893. project prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6/
  894.  
  895. project prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6/
  896.  
  897. project prebuilts/gcc/linux-x86/mips/mipsel-linux-android-4.4.3/
  898.  
  899. project prebuilts/gcc/linux-x86/mips/mipsel-linux-android-4.6/
  900.  
  901. project prebuilts/gcc/linux-x86/x86/i686-linux-android-4.6/
  902.  
  903. project prebuilts/misc/
  904.  
  905. project prebuilts/qemu-kernel/
  906.  
  907. project prebuilts/tools/
Add Comment
Please, Sign In to add comment