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

Commit 52052639 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11117647 from 59e5c729 to 24Q1-release

Change-Id: Ie732b9300f9807c23af06b22092d7dc724a06945
parents 688e5ea1 59e5c729
Loading
Loading
Loading
Loading
+3 −12
Original line number Diff line number Diff line
@@ -124,10 +124,7 @@ impl InputVerifier {
                        self.name, device_id, self.touching_pointer_ids_by_device
                    ));
                }
                let it = self
                    .touching_pointer_ids_by_device
                    .entry(device_id)
                    .or_insert_with(HashSet::new);
                let it = self.touching_pointer_ids_by_device.entry(device_id).or_default();
                it.insert(pointer_properties[0].id);
            }
            MotionAction::PointerDown { action_index } => {
@@ -224,19 +221,13 @@ impl InputVerifier {
                        self.name, device_id, self.hovering_pointer_ids_by_device
                    ));
                }
                let it = self
                    .hovering_pointer_ids_by_device
                    .entry(device_id)
                    .or_insert_with(HashSet::new);
                let it = self.hovering_pointer_ids_by_device.entry(device_id).or_default();
                it.insert(pointer_properties[0].id);
            }
            MotionAction::HoverMove => {
                // For compatibility reasons, we allow HOVER_MOVE without a prior HOVER_ENTER.
                // If there was no prior HOVER_ENTER, just start a new hovering pointer.
                let it = self
                    .hovering_pointer_ids_by_device
                    .entry(device_id)
                    .or_insert_with(HashSet::new);
                let it = self.hovering_pointer_ids_by_device.entry(device_id).or_default();
                it.insert(pointer_properties[0].id);
            }
            MotionAction::HoverExit => {
+0 −13
Original line number Diff line number Diff line
@@ -64,11 +64,6 @@ bool findExtension(const char* exts, const char* name, size_t nameLen) {
    return false;
}

bool needsAndroidPEglMitigation() {
    static const int32_t vndk_version = base::GetIntProperty("ro.vndk.version", -1);
    return vndk_version <= 28;
}

int egl_get_init_count(EGLDisplay dpy) {
    egl_display_t* eglDisplay = egl_display_t::get(dpy);
    return eglDisplay ? eglDisplay->getRefsCount() : 0;
@@ -365,14 +360,6 @@ EGLBoolean egl_display_t::initialize(EGLint* major, EGLint* minor) {
            if (len) {
                // NOTE: we could avoid the copy if we had strnstr.
                const std::string ext(start, len);
                // Mitigation for Android P vendor partitions: Adreno 530 driver shipped on
                // some Android P vendor partitions this extension under the draft KHR name,
                // but during Khronos review it was decided to demote it to EXT.
                if (needsAndroidPEglMitigation() && ext == "EGL_EXT_image_gl_colorspace" &&
                    findExtension(disp.queryString.extensions, "EGL_KHR_image_gl_colorspace")) {
                    mExtensionString.append("EGL_EXT_image_gl_colorspace ");
                }

                if (findExtension(disp.queryString.extensions, ext.c_str(), len)) {
                    mExtensionString.append(ext + " ");
                }
+0 −1
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ class egl_context_t;
struct egl_connection_t;

bool findExtension(const char* exts, const char* name, size_t nameLen = 0);
bool needsAndroidPEglMitigation();

class EGLAPI egl_display_t { // marked as EGLAPI for testing purposes
    static std::map<EGLDisplay, std::unique_ptr<egl_display_t>> displayMap;
+1 −22
Original line number Diff line number Diff line
@@ -1644,26 +1644,6 @@ EGLImageKHR eglCreateImageTmpl(EGLDisplay dpy, EGLContext ctx, EGLenum target,
    const egl_display_t* dp = validate_display(dpy);
    if (!dp) return EGL_NO_IMAGE_KHR;

    std::vector<AttrType> strippedAttribs;
    if (needsAndroidPEglMitigation()) {
        // Mitigation for Android P vendor partitions: eglImageCreateKHR should accept
        // EGL_GL_COLORSPACE_LINEAR_KHR, EGL_GL_COLORSPACE_SRGB_KHR and
        // EGL_GL_COLORSPACE_DEFAULT_EXT if EGL_EXT_image_gl_colorspace is supported,
        // but some drivers don't like the DEFAULT value and generate an error.
        for (const AttrType* attr = attrib_list; attr && attr[0] != EGL_NONE; attr += 2) {
            if (attr[0] == EGL_GL_COLORSPACE_KHR &&
                dp->haveExtension("EGL_EXT_image_gl_colorspace")) {
                if (attr[1] != EGL_GL_COLORSPACE_LINEAR_KHR &&
                    attr[1] != EGL_GL_COLORSPACE_SRGB_KHR) {
                    continue;
                }
            }
            strippedAttribs.push_back(attr[0]);
            strippedAttribs.push_back(attr[1]);
        }
        strippedAttribs.push_back(EGL_NONE);
    }

    ContextRef _c(dp, ctx);
    egl_context_t* const c = _c.get();

@@ -1671,8 +1651,7 @@ EGLImageKHR eglCreateImageTmpl(EGLDisplay dpy, EGLContext ctx, EGLenum target,
    egl_connection_t* const cnx = &gEGLImpl;
    if (cnx->dso && eglCreateImageFunc) {
        result = eglCreateImageFunc(dp->disp.dpy, c ? c->context : EGL_NO_CONTEXT, target, buffer,
                                    needsAndroidPEglMitigation() ? strippedAttribs.data()
                                                                 : attrib_list);
                                    attrib_list);
    }
    return result;
}
+57 −11
Original line number Diff line number Diff line
@@ -31,6 +31,11 @@ bool isFromMouse(const NotifyMotionArgs& args) {
            args.pointerProperties[0].toolType == ToolType::MOUSE;
}

bool isFromTouchpad(const NotifyMotionArgs& args) {
    return isFromSource(args.source, AINPUT_SOURCE_MOUSE) &&
            args.pointerProperties[0].toolType == ToolType::FINGER;
}

bool isHoverAction(int32_t action) {
    return action == AMOTION_EVENT_ACTION_HOVER_ENTER ||
            action == AMOTION_EVENT_ACTION_HOVER_MOVE || action == AMOTION_EVENT_ACTION_HOVER_EXIT;
@@ -83,6 +88,8 @@ NotifyMotionArgs PointerChoreographer::processMotion(const NotifyMotionArgs& arg

    if (isFromMouse(args)) {
        return processMouseEventLocked(args);
    } else if (isFromTouchpad(args)) {
        return processTouchpadEventLocked(args);
    } else if (mStylusPointerIconEnabled && isStylusHoverEvent(args)) {
        processStylusHoverEventLocked(args);
    } else if (isFromSource(args.source, AINPUT_SOURCE_TOUCHSCREEN)) {
@@ -97,30 +104,54 @@ NotifyMotionArgs PointerChoreographer::processMouseEventLocked(const NotifyMotio
                   << args.dump();
    }

    const int32_t displayId = getTargetMouseDisplayLocked(args.displayId);
    auto [displayId, pc] = getDisplayIdAndMouseControllerLocked(args.displayId);

    // Get the mouse pointer controller for the display, or create one if it doesn't exist.
    auto [it, emplaced] =
            mMousePointersByDisplay.try_emplace(displayId,
                                                getMouseControllerConstructor(displayId));
    if (emplaced) {
        notifyPointerDisplayIdChangedLocked();
    const float deltaX = args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X);
    const float deltaY = args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y);
    pc.move(deltaX, deltaY);
    pc.unfade(PointerControllerInterface::Transition::IMMEDIATE);

    const auto [x, y] = pc.getPosition();
    NotifyMotionArgs newArgs(args);
    newArgs.pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, x);
    newArgs.pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, y);
    newArgs.xCursorPosition = x;
    newArgs.yCursorPosition = y;
    newArgs.displayId = displayId;
    return newArgs;
}

    PointerControllerInterface& pc = *it->second;
NotifyMotionArgs PointerChoreographer::processTouchpadEventLocked(const NotifyMotionArgs& args) {
    auto [displayId, pc] = getDisplayIdAndMouseControllerLocked(args.displayId);

    NotifyMotionArgs newArgs(args);
    newArgs.displayId = displayId;
    if (args.getPointerCount() == 1 && args.classification == MotionClassification::NONE) {
        // This is a movement of the mouse pointer.
        const float deltaX = args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X);
        const float deltaY = args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y);
        pc.move(deltaX, deltaY);
        pc.unfade(PointerControllerInterface::Transition::IMMEDIATE);

        const auto [x, y] = pc.getPosition();
    NotifyMotionArgs newArgs(args);
        newArgs.pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, x);
        newArgs.pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, y);
        newArgs.xCursorPosition = x;
        newArgs.yCursorPosition = y;
    newArgs.displayId = displayId;
    } else {
        // This is a trackpad gesture with fake finger(s) that should not move the mouse pointer.
        pc.unfade(PointerControllerInterface::Transition::IMMEDIATE);

        const auto [x, y] = pc.getPosition();
        for (uint32_t i = 0; i < newArgs.getPointerCount(); i++) {
            newArgs.pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_X,
                                                  args.pointerCoords[i].getX() + x);
            newArgs.pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_Y,
                                                  args.pointerCoords[i].getY() + y);
        }
        newArgs.xCursorPosition = x;
        newArgs.yCursorPosition = y;
    }
    return newArgs;
}

@@ -270,6 +301,21 @@ int32_t PointerChoreographer::getTargetMouseDisplayLocked(int32_t associatedDisp
    return associatedDisplayId == ADISPLAY_ID_NONE ? mDefaultMouseDisplayId : associatedDisplayId;
}

std::pair<int32_t, PointerControllerInterface&>
PointerChoreographer::getDisplayIdAndMouseControllerLocked(int32_t associatedDisplayId) {
    const int32_t displayId = getTargetMouseDisplayLocked(associatedDisplayId);

    // Get the mouse pointer controller for the display, or create one if it doesn't exist.
    auto [it, emplaced] =
            mMousePointersByDisplay.try_emplace(displayId,
                                                getMouseControllerConstructor(displayId));
    if (emplaced) {
        notifyPointerDisplayIdChangedLocked();
    }

    return {displayId, *it->second};
}

InputDeviceInfo* PointerChoreographer::findInputDeviceLocked(DeviceId deviceId) {
    auto it = std::find_if(mInputDeviceInfos.begin(), mInputDeviceInfos.end(),
                           [deviceId](const auto& info) { return info.getId() == deviceId; });
Loading