Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1918)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/input/HandleViewResources.java

Issue 481683003: Support for Adaptive Handle Orientation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: some more cleaning up Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/input/HandleViewResources.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/HandleViewResources.java b/content/public/android/java/src/org/chromium/content/browser/input/HandleViewResources.java
index 25fc8b62b5847dc1ab90c64cb0eeb0fab2d2a607..a7d551a1c0e2d58f9524fb005fbbe3f4094ad996 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/HandleViewResources.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/HandleViewResources.java
@@ -10,6 +10,7 @@ import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
+import android.graphics.Matrix;
import android.graphics.drawable.Drawable;
import org.chromium.base.CalledByNative;
@@ -77,6 +78,16 @@ public class HandleViewResources {
return canvasBitmap;
}
+ private static Bitmap invertBitmap(Bitmap source) {
+ Matrix matrix = new Matrix();
+ matrix.postRotate(180, source.getWidth() / 2, source.getHeight() / 2);
+ Bitmap scaledBitmap = Bitmap.createScaledBitmap(source, source.getWidth(),
jdduke (slow) 2014/08/20 15:15:01 Why do we need to invert the bitmap explicitly whe
AviD 2014/08/21 16:15:20 Please correct if my understanding is wrong. Does
jdduke (slow) 2014/08/22 18:04:08 Right, we can use the same bitmap/drawable, but si
+ source.getHeight(), true);
+ source = Bitmap.createBitmap(scaledBitmap, 0, 0, scaledBitmap.getWidth(),
+ scaledBitmap.getHeight(), matrix, true);
+ return source;
+ }
+
@CalledByNative
private static Bitmap getLeftHandleBitmap(Context context) {
return getHandleBitmap(context, LEFT_HANDLE_ATTRS);
@@ -91,4 +102,22 @@ public class HandleViewResources {
private static Bitmap getRightHandleBitmap(Context context) {
return getHandleBitmap(context, RIGHT_HANDLE_ATTRS);
}
+
+ @CalledByNative
+ private static Bitmap getRightHandleBitmapInverted(Context context) {
+ Bitmap leftBitmap = getHandleBitmap(context, LEFT_HANDLE_ATTRS);
+ return invertBitmap(leftBitmap);
+ }
+
+ @CalledByNative
+ private static Bitmap getLeftHandleBitmapInverted(Context context) {
+ Bitmap rightBitmap = getHandleBitmap(context, RIGHT_HANDLE_ATTRS);
+ return invertBitmap(rightBitmap);
+ }
+
+ @CalledByNative
+ private static Bitmap getCenterHandleBitmapInverted(Context context) {
+ Bitmap centerBitmap = getHandleBitmap(context, CENTER_HANDLE_ATTRS);
+ return invertBitmap(centerBitmap);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698