summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Wright <michaelwr@google.com>2014-02-05 18:02:40 -0800
committerMichael Wright <michaelwr@google.com>2014-02-10 12:59:34 -0800
commita407d6a003d746fa0aff50f7ba5da61f19a85b75 (patch)
tree47f16be39026a324f3aeff1d534932c7cb3cd03a
parentd5154ec2bc7e7c0bdfd14fc784912d390afe43cc (diff)
downloadframeworks_base-a407d6a003d746fa0aff50f7ba5da61f19a85b75.zip
frameworks_base-a407d6a003d746fa0aff50f7ba5da61f19a85b75.tar.gz
frameworks_base-a407d6a003d746fa0aff50f7ba5da61f19a85b75.tar.bz2
Remove SkRegion dependency from libinput
This gets us one step closer to removing our dependency on Skia, which is at least one of the things blocking us from moving the input system out of f/b. Change-Id: I755e6267996c93fe700f1056327386923287575a
-rw-r--r--libs/input/InputDispatcher.cpp11
-rw-r--r--libs/input/InputWindow.cpp9
-rw-r--r--libs/input/InputWindow.h9
-rw-r--r--services/core/jni/com_android_server_input_InputWindowHandle.cpp10
4 files changed, 28 insertions, 11 deletions
diff --git a/libs/input/InputDispatcher.cpp b/libs/input/InputDispatcher.cpp
index 10a639e..8c8e705 100644
--- a/libs/input/InputDispatcher.cpp
+++ b/libs/input/InputDispatcher.cpp
@@ -48,6 +48,7 @@
#include <utils/Trace.h>
#include <cutils/log.h>
#include <androidfw/PowerManager.h>
+#include <ui/Region.h>
#include <stddef.h>
#include <unistd.h>
@@ -172,21 +173,23 @@ static bool isMainDisplay(int32_t displayId) {
return displayId == ADISPLAY_ID_DEFAULT || displayId == ADISPLAY_ID_NONE;
}
-static void dumpRegion(String8& dump, const SkRegion& region) {
+static void dumpRegion(String8& dump, const Region& region) {
if (region.isEmpty()) {
dump.append("<empty>");
return;
}
bool first = true;
- for (SkRegion::Iterator it(region); !it.done(); it.next()) {
+ Region::const_iterator cur = region.begin();
+ Region::const_iterator const tail = region.end();
+ while (cur != tail) {
if (first) {
first = false;
} else {
dump.append("|");
}
- const SkIRect& rect = it.rect();
- dump.appendFormat("[%d,%d][%d,%d]", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+ dump.appendFormat("[%d,%d][%d,%d]", cur->left, cur->top, cur->right, cur->bottom);
+ cur++;
}
}
diff --git a/libs/input/InputWindow.cpp b/libs/input/InputWindow.cpp
index fe61918..da59159 100644
--- a/libs/input/InputWindow.cpp
+++ b/libs/input/InputWindow.cpp
@@ -15,17 +15,24 @@
*/
#define LOG_TAG "InputWindow"
+#define LOG_NDEBUG 0
#include "InputWindow.h"
#include <cutils/log.h>
+#include <ui/Rect.h>
+#include <ui/Region.h>
+
namespace android {
// --- InputWindowInfo ---
+void InputWindowInfo::addTouchableRegion(const Rect& region) {
+ touchableRegion.orSelf(region);
+}
bool InputWindowInfo::touchableRegionContainsPoint(int32_t x, int32_t y) const {
- return touchableRegion.contains(x, y);
+ return touchableRegion.contains(x,y);
}
bool InputWindowInfo::frameContainsPoint(int32_t x, int32_t y) const {
diff --git a/libs/input/InputWindow.h b/libs/input/InputWindow.h
index 28fa7ab..9618ffe 100644
--- a/libs/input/InputWindow.h
+++ b/libs/input/InputWindow.h
@@ -19,16 +19,17 @@
#include <input/Input.h>
#include <input/InputTransport.h>
+#include <ui/Rect.h>
+#include <ui/Region.h>
#include <utils/RefBase.h>
#include <utils/Timers.h>
#include <utils/String8.h>
-#include <SkRegion.h>
-
#include "InputApplication.h"
namespace android {
+
/*
* Describes the properties of a window that can receive input.
*/
@@ -125,7 +126,7 @@ struct InputWindowInfo {
int32_t frameRight;
int32_t frameBottom;
float scaleFactor;
- SkRegion touchableRegion;
+ Region touchableRegion;
bool visible;
bool canReceiveKeys;
bool hasFocus;
@@ -137,6 +138,8 @@ struct InputWindowInfo {
int32_t inputFeatures;
int32_t displayId;
+ void addTouchableRegion(const Rect& region);
+
bool touchableRegionContainsPoint(int32_t x, int32_t y) const;
bool frameContainsPoint(int32_t x, int32_t y) const;
diff --git a/services/core/jni/com_android_server_input_InputWindowHandle.cpp b/services/core/jni/com_android_server_input_InputWindowHandle.cpp
index b80183c..03bf7eb 100644
--- a/services/core/jni/com_android_server_input_InputWindowHandle.cpp
+++ b/services/core/jni/com_android_server_input_InputWindowHandle.cpp
@@ -23,6 +23,7 @@
#include <android_view_InputChannel.h>
#include <android/graphics/Region.h>
+#include <ui/Region.h>
#include "com_android_server_input_InputWindowHandle.h"
#include "com_android_server_input_InputApplicationHandle.h"
@@ -86,6 +87,8 @@ bool NativeInputWindowHandle::updateInfo() {
if (!mInfo) {
mInfo = new InputWindowInfo();
+ } else {
+ mInfo->touchableRegion.clear();
}
jobject inputChannelObj = env->GetObjectField(obj,
@@ -131,10 +134,11 @@ bool NativeInputWindowHandle::updateInfo() {
gInputWindowHandleClassInfo.touchableRegion);
if (regionObj) {
SkRegion* region = android_graphics_Region_getSkRegion(env, regionObj);
- mInfo->touchableRegion.set(*region);
+ for (SkRegion::Iterator it(*region); !it.done(); it.next()) {
+ const SkIRect& rect = it.rect();
+ mInfo->addTouchableRegion(Rect(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom));
+ }
env->DeleteLocalRef(regionObj);
- } else {
- mInfo->touchableRegion.setEmpty();
}
mInfo->visible = env->GetBooleanField(obj,