Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 943c05f3 authored by Michael Wright's avatar Michael Wright Committed by Android (Google) Code Review
Browse files

Merge "Remove SkRegion dependency from libinput"

parents e7755a0d a407d6a0
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -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++;
    }
}

+8 −1
Original line number Diff line number Diff line
@@ -15,14 +15,21 @@
 */

#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);
+6 −3
Original line number Diff line number Diff line
@@ -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;

+7 −3
Original line number Diff line number Diff line
@@ -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,