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

Commit d0426fb5 authored by Alec Mouri's avatar Alec Mouri Committed by Android (Google) Code Review
Browse files

Merge "Move CaptureArgs + friends to structured aidl" into main

parents 8ca05164 bae67866
Loading
Loading
Loading
Loading
+0 −82
Original line number Diff line number Diff line
@@ -892,88 +892,6 @@ status_t InputWindowCommands::read(const Parcel& input) {

// ----------------------------------------------------------------------------

namespace gui {

status_t CaptureArgs::writeToParcel(Parcel* output) const {
    SAFE_PARCEL(output->writeInt32, static_cast<int32_t>(pixelFormat));
    SAFE_PARCEL(output->write, sourceCrop);
    SAFE_PARCEL(output->writeFloat, frameScaleX);
    SAFE_PARCEL(output->writeFloat, frameScaleY);
    SAFE_PARCEL(output->writeBool, captureSecureLayers);
    SAFE_PARCEL(output->writeInt32, uid);
    SAFE_PARCEL(output->writeInt32, static_cast<int32_t>(dataspace));
    SAFE_PARCEL(output->writeBool, allowProtected);
    SAFE_PARCEL(output->writeBool, grayscale);
    SAFE_PARCEL(output->writeInt32, excludeHandles.size());
    for (auto& excludeHandle : excludeHandles) {
        SAFE_PARCEL(output->writeStrongBinder, excludeHandle);
    }
    SAFE_PARCEL(output->writeBool, hintForSeamlessTransition);
    return NO_ERROR;
}

status_t CaptureArgs::readFromParcel(const Parcel* input) {
    int32_t value = 0;
    SAFE_PARCEL(input->readInt32, &value);
    pixelFormat = static_cast<ui::PixelFormat>(value);
    SAFE_PARCEL(input->read, sourceCrop);
    SAFE_PARCEL(input->readFloat, &frameScaleX);
    SAFE_PARCEL(input->readFloat, &frameScaleY);
    SAFE_PARCEL(input->readBool, &captureSecureLayers);
    SAFE_PARCEL(input->readInt32, &uid);
    SAFE_PARCEL(input->readInt32, &value);
    dataspace = static_cast<ui::Dataspace>(value);
    SAFE_PARCEL(input->readBool, &allowProtected);
    SAFE_PARCEL(input->readBool, &grayscale);
    int32_t numExcludeHandles = 0;
    SAFE_PARCEL_READ_SIZE(input->readInt32, &numExcludeHandles, input->dataSize());
    excludeHandles.reserve(numExcludeHandles);
    for (int i = 0; i < numExcludeHandles; i++) {
        sp<IBinder> binder;
        SAFE_PARCEL(input->readStrongBinder, &binder);
        excludeHandles.emplace(binder);
    }
    SAFE_PARCEL(input->readBool, &hintForSeamlessTransition);
    return NO_ERROR;
}

status_t DisplayCaptureArgs::writeToParcel(Parcel* output) const {
    SAFE_PARCEL(CaptureArgs::writeToParcel, output);

    SAFE_PARCEL(output->writeStrongBinder, displayToken);
    SAFE_PARCEL(output->writeUint32, width);
    SAFE_PARCEL(output->writeUint32, height);
    return NO_ERROR;
}

status_t DisplayCaptureArgs::readFromParcel(const Parcel* input) {
    SAFE_PARCEL(CaptureArgs::readFromParcel, input);

    SAFE_PARCEL(input->readStrongBinder, &displayToken);
    SAFE_PARCEL(input->readUint32, &width);
    SAFE_PARCEL(input->readUint32, &height);
    return NO_ERROR;
}

status_t LayerCaptureArgs::writeToParcel(Parcel* output) const {
    SAFE_PARCEL(CaptureArgs::writeToParcel, output);

    SAFE_PARCEL(output->writeStrongBinder, layerHandle);
    SAFE_PARCEL(output->writeBool, childrenOnly);
    return NO_ERROR;
}

status_t LayerCaptureArgs::readFromParcel(const Parcel* input) {
    SAFE_PARCEL(CaptureArgs::readFromParcel, input);

    SAFE_PARCEL(input->readStrongBinder, &layerHandle);

    SAFE_PARCEL(input->readBool, &childrenOnly);
    return NO_ERROR;
}

}; // namespace gui

ReleaseCallbackId BufferData::generateReleaseCallbackId() const {
    uint64_t bufferId;
    if (buffer) {
+0 −3
Original line number Diff line number Diff line
@@ -28,9 +28,6 @@ filegroup {
        ":libgui_extra_unstructured_aidl_files",

        "android/gui/BitTube.aidl",
        "android/gui/CaptureArgs.aidl",
        "android/gui/DisplayCaptureArgs.aidl",
        "android/gui/LayerCaptureArgs.aidl",
        "android/gui/LayerMetadata.aidl",
        "android/gui/ParcelableVsyncEventData.aidl",
        "android/gui/ScreenCaptureResults.aidl",
+55 −1
Original line number Diff line number Diff line
@@ -16,4 +16,58 @@

package android.gui;

parcelable CaptureArgs cpp_header "gui/DisplayCaptureArgs.h" rust_type "gui_aidl_types_rs::CaptureArgs";
import android.gui.ARect;

// Common arguments for capturing content on-screen
parcelable CaptureArgs {
    const int UNSET_UID = -1;

    // Desired pixel format of the final screenshotted buffer
    int /*ui::PixelFormat*/ pixelFormat = 1;

    // Crop in layer space: all content outside of the crop will not be captured.
    ARect sourceCrop;

    // Scale in the x-direction for the screenshotted result.
    float frameScaleX = 1.0f;

    // Scale in the y-direction for the screenshotted result.
    float frameScaleY = 1.0f;

    // True if capturing secure layers is permitted
    boolean captureSecureLayers = false;

    // UID whose content we want to screenshot
    int uid = UNSET_UID;

    // Force capture to be in a color space. If the value is ui::Dataspace::UNKNOWN, the captured
    // result will be in a colorspace appropriate for capturing the display contents
    // The display may use non-RGB dataspace (ex. displayP3) that could cause pixel data could be
    // different from SRGB (byte per color), and failed when checking colors in tests.
    // NOTE: In normal cases, we want the screen to be captured in display's colorspace.
    int /*ui::Dataspace*/ dataspace = 0;

    // The receiver of the capture can handle protected buffer. A protected buffer has
    // GRALLOC_USAGE_PROTECTED usage bit and must not be accessed unprotected behaviour.
    // Any read/write access from unprotected context will result in undefined behaviour.
    // Protected contents are typically DRM contents. This has no direct implication to the
    // secure property of the surface, which is specified by the application explicitly to avoid
    // the contents being accessed/captured by screenshot or unsecure display.
    boolean allowProtected = false;

    // True if the content should be captured in grayscale
    boolean grayscale = false;

    // List of layers to exclude capturing from
    IBinder[] excludeHandles;

    // Hint that the caller will use the screenshot animation as part of a transition animation.
    // The canonical example would be screen rotation - in such a case any color shift in the
    // screenshot is a detractor so composition in the display's colorspace is required.
    // Otherwise, the system may choose a colorspace that is more appropriate for use-cases
    // such as file encoding or for blending HDR content into an ap's UI, where the display's
    // exact colorspace is not an appropriate intermediate result.
    // Note that if the caller is requesting a specific dataspace, this hint does nothing.
    boolean hintForSeamlessTransition = false;
}
+14 −1
Original line number Diff line number Diff line
@@ -16,5 +16,18 @@

package android.gui;

parcelable DisplayCaptureArgs cpp_header "gui/DisplayCaptureArgs.h" rust_type "gui_aidl_types_rs::DisplayCaptureArgs";
import android.gui.CaptureArgs;

// Arguments for screenshotting an entire display
parcelable DisplayCaptureArgs {
    CaptureArgs captureArgs;

    // The display that we want to screenshot
    IBinder displayToken;

    // The width of the render area when we screenshot
    int width = 0;
    // The length of the render area when we screenshot
    int height = 0;
}
+12 −1
Original line number Diff line number Diff line
@@ -16,4 +16,15 @@

package android.gui;

parcelable LayerCaptureArgs cpp_header "gui/LayerCaptureArgs.h" rust_type "gui_aidl_types_rs::LayerCaptureArgs";
import android.gui.CaptureArgs;

// Arguments for capturing a layer and/or its children
parcelable LayerCaptureArgs {
    CaptureArgs captureArgs;

    // The Layer that we may want to capture. We would also capture its children
    IBinder layerHandle;
    // True if we don't actually want to capture the layer and want to capture
    // its children instead.
    boolean childrenOnly = false;
}
Loading