Merge "Convert orientation values in input to ui::Rotation."
This commit is contained in:
committed by
Android (Google) Code Review
commit
d4b82ab5c1
@@ -61,7 +61,8 @@ status_t android_hardware_display_DisplayViewport_toNative(JNIEnv* env, jobject
|
||||
|
||||
viewport->displayId = env->GetIntField(viewportObj, gDisplayViewportClassInfo.displayId);
|
||||
viewport->isActive = env->GetBooleanField(viewportObj, gDisplayViewportClassInfo.isActive);
|
||||
viewport->orientation = env->GetIntField(viewportObj, gDisplayViewportClassInfo.orientation);
|
||||
jint orientation = env->GetIntField(viewportObj, gDisplayViewportClassInfo.orientation);
|
||||
viewport->orientation = static_cast<ui::Rotation>(orientation);
|
||||
viewport->deviceWidth = env->GetIntField(viewportObj, gDisplayViewportClassInfo.deviceWidth);
|
||||
viewport->deviceHeight = env->GetIntField(viewportObj, gDisplayViewportClassInfo.deviceHeight);
|
||||
|
||||
|
||||
@@ -199,8 +199,7 @@ static void getNonRotatedSize(const DisplayViewport& viewport, int32_t& width, i
|
||||
width = viewport.deviceWidth;
|
||||
height = viewport.deviceHeight;
|
||||
|
||||
if (viewport.orientation == DISPLAY_ORIENTATION_90 ||
|
||||
viewport.orientation == DISPLAY_ORIENTATION_270) {
|
||||
if (viewport.orientation == ui::ROTATION_90 || viewport.orientation == ui::ROTATION_270) {
|
||||
std::swap(width, height);
|
||||
}
|
||||
}
|
||||
@@ -244,38 +243,42 @@ void MouseCursorController::setDisplayViewport(const DisplayViewport& viewport,
|
||||
|
||||
// Undo the previous rotation.
|
||||
switch (oldViewport.orientation) {
|
||||
case DISPLAY_ORIENTATION_90:
|
||||
case ui::ROTATION_90:
|
||||
temp = x;
|
||||
x = oldViewport.deviceHeight - y;
|
||||
y = temp;
|
||||
break;
|
||||
case DISPLAY_ORIENTATION_180:
|
||||
case ui::ROTATION_180:
|
||||
x = oldViewport.deviceWidth - x;
|
||||
y = oldViewport.deviceHeight - y;
|
||||
break;
|
||||
case DISPLAY_ORIENTATION_270:
|
||||
case ui::ROTATION_270:
|
||||
temp = x;
|
||||
x = y;
|
||||
y = oldViewport.deviceWidth - temp;
|
||||
break;
|
||||
case ui::ROTATION_0:
|
||||
break;
|
||||
}
|
||||
|
||||
// Perform the new rotation.
|
||||
switch (viewport.orientation) {
|
||||
case DISPLAY_ORIENTATION_90:
|
||||
case ui::ROTATION_90:
|
||||
temp = x;
|
||||
x = y;
|
||||
y = viewport.deviceHeight - temp;
|
||||
break;
|
||||
case DISPLAY_ORIENTATION_180:
|
||||
case ui::ROTATION_180:
|
||||
x = viewport.deviceWidth - x;
|
||||
y = viewport.deviceHeight - y;
|
||||
break;
|
||||
case DISPLAY_ORIENTATION_270:
|
||||
case ui::ROTATION_270:
|
||||
temp = x;
|
||||
x = viewport.deviceWidth - y;
|
||||
y = temp;
|
||||
break;
|
||||
case ui::ROTATION_0:
|
||||
break;
|
||||
}
|
||||
|
||||
// Apply offsets to convert from the pixel center to the pixel top-left corner position
|
||||
|
||||
@@ -310,7 +310,7 @@ public:
|
||||
const InputDeviceIdentifier& identifier) override;
|
||||
std::string getDeviceAlias(const InputDeviceIdentifier& identifier) override;
|
||||
TouchAffineTransformation getTouchAffineTransformation(const std::string& inputDeviceDescriptor,
|
||||
int32_t surfaceRotation) override;
|
||||
ui::Rotation surfaceRotation) override;
|
||||
|
||||
TouchAffineTransformation getTouchAffineTransformation(JNIEnv* env, jfloatArray matrixArr);
|
||||
void notifyStylusGestureStarted(int32_t deviceId, nsecs_t eventTime) override;
|
||||
@@ -1153,7 +1153,7 @@ TouchAffineTransformation NativeInputManager::getTouchAffineTransformation(
|
||||
}
|
||||
|
||||
TouchAffineTransformation NativeInputManager::getTouchAffineTransformation(
|
||||
const std::string& inputDeviceDescriptor, int32_t surfaceRotation) {
|
||||
const std::string& inputDeviceDescriptor, ui::Rotation surfaceRotation) {
|
||||
JNIEnv* env = jniEnv();
|
||||
|
||||
ScopedLocalRef<jstring> descriptorObj(env, env->NewStringUTF(inputDeviceDescriptor.c_str()));
|
||||
|
||||
Reference in New Issue
Block a user