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

Unified Diff: blimp/client/app/android/java/src/org/chromium/blimp/app/BlimpContentsDisplay.java

Issue 2493333002: Move Java Blimp shell code to app subpackage (Closed)
Patch Set: Merge branch 'refs/heads/master' into blimp-shell-integration Created 4 years, 1 month 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: blimp/client/app/android/java/src/org/chromium/blimp/app/BlimpContentsDisplay.java
diff --git a/blimp/client/app/android/java/src/org/chromium/blimp/BlimpView.java b/blimp/client/app/android/java/src/org/chromium/blimp/app/BlimpContentsDisplay.java
similarity index 65%
rename from blimp/client/app/android/java/src/org/chromium/blimp/BlimpView.java
rename to blimp/client/app/android/java/src/org/chromium/blimp/app/BlimpContentsDisplay.java
index aaa555b17997afc0d456d89e57c49159ecca917b..9c6ce5b41d0215f524097de495eb502941779f6c 100644
--- a/blimp/client/app/android/java/src/org/chromium/blimp/BlimpView.java
+++ b/blimp/client/app/android/java/src/org/chromium/blimp/app/BlimpContentsDisplay.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.chromium.blimp;
+package org.chromium.blimp.app;
import android.content.Context;
import android.graphics.Color;
@@ -18,7 +18,7 @@ import android.view.WindowManager;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
-import org.chromium.blimp.session.BlimpClientSession;
+import org.chromium.blimp.app.session.BlimpClientSession;
import org.chromium.ui.UiUtils;
/**
@@ -26,16 +26,16 @@ import org.chromium.ui.UiUtils;
* a native compositor.
*/
@JNINamespace("blimp::client::app")
-public class BlimpView
+public class BlimpContentsDisplay
extends SurfaceView implements SurfaceHolder.Callback, View.OnLayoutChangeListener {
- private long mNativeBlimpViewPtr;
+ private long mNativeBlimpContentsDisplayPtr;
/**
- * Builds a new {@link BlimpView}.
+ * Builds a new {@link BlimpContentsDisplay}.
* @param context A {@link Context} instance.
* @param attrs An {@link AttributeSet} instance.
*/
- public BlimpView(Context context, AttributeSet attrs) {
+ public BlimpContentsDisplay(Context context, AttributeSet attrs) {
super(context, attrs);
setFocusable(true);
setFocusableInTouchMode(true);
@@ -49,7 +49,7 @@ public class BlimpView
* features required by the native components of the compositor.
*/
public void initializeRenderer(BlimpClientSession blimpClientSession) {
- assert mNativeBlimpViewPtr == 0;
+ assert mNativeBlimpContentsDisplayPtr == 0;
WindowManager windowManager =
(WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
@@ -60,8 +60,8 @@ public class BlimpView
windowManager.getDefaultDisplay().getRealSize(physicalSize);
}
float deviceScaleFactor = getContext().getResources().getDisplayMetrics().density;
- mNativeBlimpViewPtr = nativeInit(blimpClientSession, physicalSize.x, physicalSize.y,
- displaySize.x, displaySize.y, deviceScaleFactor);
+ mNativeBlimpContentsDisplayPtr = nativeInit(blimpClientSession, physicalSize.x,
+ physicalSize.y, displaySize.x, displaySize.y, deviceScaleFactor);
getHolder().addCallback(this);
setBackgroundColor(Color.WHITE);
setVisibility(VISIBLE);
@@ -73,9 +73,9 @@ public class BlimpView
*/
public void destroyRenderer() {
getHolder().removeCallback(this);
- if (mNativeBlimpViewPtr != 0) {
- nativeDestroy(mNativeBlimpViewPtr);
- mNativeBlimpViewPtr = 0;
+ if (mNativeBlimpContentsDisplayPtr != 0) {
+ nativeDestroy(mNativeBlimpContentsDisplayPtr);
+ mNativeBlimpContentsDisplayPtr = 0;
}
}
@@ -83,15 +83,16 @@ public class BlimpView
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft,
int oldTop, int oldRight, int oldBottom) {
- if (mNativeBlimpViewPtr == 0) return;
- nativeOnContentAreaSizeChanged(mNativeBlimpViewPtr, right - left, bottom - top,
+ if (mNativeBlimpContentsDisplayPtr == 0) return;
+ nativeOnContentAreaSizeChanged(mNativeBlimpContentsDisplayPtr, right - left, bottom - top,
getContext().getResources().getDisplayMetrics().density);
}
// View overrides.
@Override
public boolean onTouchEvent(MotionEvent event) {
- if (mNativeBlimpViewPtr == 0) return false;
+ // Remove this (integrate with BlimpView).
+ if (mNativeBlimpContentsDisplayPtr == 0) return false;
int eventAction = event.getActionMasked();
@@ -114,23 +115,18 @@ public class BlimpView
}
}
- boolean consumed = nativeOnTouchEvent(mNativeBlimpViewPtr, event,
- event.getEventTime(), eventAction,
- pointerCount, event.getHistorySize(), event.getActionIndex(),
- event.getX(), event.getY(),
- pointerCount > 1 ? event.getX(1) : 0,
- pointerCount > 1 ? event.getY(1) : 0,
- event.getPointerId(0), pointerCount > 1 ? event.getPointerId(1) : -1,
- touchMajor[0], touchMajor[1],
- touchMinor[0], touchMinor[1],
- event.getOrientation(), pointerCount > 1 ? event.getOrientation(1) : 0,
+ boolean consumed = nativeOnTouchEvent(mNativeBlimpContentsDisplayPtr, event,
+ event.getEventTime(), eventAction, pointerCount, event.getHistorySize(),
+ event.getActionIndex(), event.getX(), event.getY(),
+ pointerCount > 1 ? event.getX(1) : 0, pointerCount > 1 ? event.getY(1) : 0,
+ event.getPointerId(0), pointerCount > 1 ? event.getPointerId(1) : -1, touchMajor[0],
+ touchMajor[1], touchMinor[0], touchMinor[1], event.getOrientation(),
+ pointerCount > 1 ? event.getOrientation(1) : 0,
event.getAxisValue(MotionEvent.AXIS_TILT),
pointerCount > 1 ? event.getAxisValue(MotionEvent.AXIS_TILT, 1) : 0,
- event.getRawX(), event.getRawY(),
- event.getToolType(0),
+ event.getRawX(), event.getRawY(), event.getToolType(0),
pointerCount > 1 ? event.getToolType(1) : MotionEvent.TOOL_TYPE_UNKNOWN,
- event.getButtonState(),
- event.getMetaState());
+ event.getButtonState(), event.getMetaState());
return consumed;
}
@@ -147,28 +143,28 @@ public class BlimpView
// SurfaceHolder.Callback2 interface.
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
- if (mNativeBlimpViewPtr == 0) return;
- nativeOnSurfaceChanged(mNativeBlimpViewPtr, format, width, height, holder.getSurface());
+ if (mNativeBlimpContentsDisplayPtr == 0) return;
+ nativeOnSurfaceChanged(
+ mNativeBlimpContentsDisplayPtr, format, width, height, holder.getSurface());
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
- if (mNativeBlimpViewPtr == 0) return;
- nativeOnSurfaceCreated(mNativeBlimpViewPtr);
+ if (mNativeBlimpContentsDisplayPtr == 0) return;
+ nativeOnSurfaceCreated(mNativeBlimpContentsDisplayPtr);
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
- if (mNativeBlimpViewPtr == 0) return;
- nativeOnSurfaceDestroyed(mNativeBlimpViewPtr);
+ if (mNativeBlimpContentsDisplayPtr == 0) return;
+ nativeOnSurfaceDestroyed(mNativeBlimpContentsDisplayPtr);
}
private static boolean isValidTouchEventActionForNative(int eventAction) {
// Only these actions have any effect on gesture detection. Other
// actions have no corresponding WebTouchEvent type and may confuse the
// touch pipline, so we ignore them entirely.
- return eventAction == MotionEvent.ACTION_DOWN
- || eventAction == MotionEvent.ACTION_UP
+ return eventAction == MotionEvent.ACTION_DOWN || eventAction == MotionEvent.ACTION_UP
|| eventAction == MotionEvent.ACTION_CANCEL
|| eventAction == MotionEvent.ACTION_MOVE
|| eventAction == MotionEvent.ACTION_POINTER_DOWN
@@ -185,23 +181,18 @@ public class BlimpView
// Native Methods
private native long nativeInit(BlimpClientSession blimpClientSession, int physicalWidth,
int physicalHeight, int displayWidth, int displayHeight, float dpToPixel);
- private native void nativeDestroy(long nativeBlimpView);
+ private native void nativeDestroy(long nativeBlimpContentsDisplay);
private native void nativeOnContentAreaSizeChanged(
- long nativeBlimpView, int width, int height, float dpToPx);
+ long nativeBlimpContentsDisplay, int width, int height, float dpToPx);
private native void nativeOnSurfaceChanged(
- long nativeBlimpView, int format, int width, int height, Surface surface);
- private native void nativeOnSurfaceCreated(long nativeBlimpView);
- private native void nativeOnSurfaceDestroyed(long nativeBlimpView);
- private native boolean nativeOnTouchEvent(
- long nativeBlimpView, MotionEvent event,
- long timeMs, int action, int pointerCount, int historySize, int actionIndex,
- float x0, float y0, float x1, float y1,
- int pointerId0, int pointerId1,
- float touchMajor0, float touchMajor1,
- float touchMinor0, float touchMinor1,
- float orientation0, float orientation1,
- float tilt0, float tilt1,
- float rawX, float rawY,
- int androidToolType0, int androidToolType1,
- int androidButtonState, int androidMetaState);
+ long nativeBlimpContentsDisplay, int format, int width, int height, Surface surface);
+ private native void nativeOnSurfaceCreated(long nativeBlimpContentsDisplay);
+ private native void nativeOnSurfaceDestroyed(long nativeBlimpContentsDisplay);
+ private native boolean nativeOnTouchEvent(long nativeBlimpContentsDisplay, MotionEvent event,
+ long timeMs, int action, int pointerCount, int historySize, int actionIndex, float x0,
+ float y0, float x1, float y1, int pointerId0, int pointerId1, float touchMajor0,
+ float touchMajor1, float touchMinor0, float touchMinor1, float orientation0,
+ float orientation1, float tilt0, float tilt1, float rawX, float rawY,
+ int androidToolType0, int androidToolType1, int androidButtonState,
+ int androidMetaState);
}

Powered by Google App Engine
This is Rietveld 408576698