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

Commit 8a0be29c authored by Jayant Chowdhary's avatar Jayant Chowdhary
Browse files

Add some move constructors and assignment operators to CameraMetadata.



This avoids unnecessary copying of camera metadata which can get
expensive in cases of large camera metadata blobs.

Bug: 71727540

Test: GCA (sanity)
Test: Add CallStack::logStack() in CameraMetadata's move asignment
      operator -> see that it gets called for every insertResultLocked.

Change-Id: I6c75c7ce5267126916c865b028e5f7c7f50b763b
Signed-off-by: default avatarJayant Chowdhary <jchowdhary@google.com>
parent 450c7b2a
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -50,6 +50,15 @@ CameraMetadata::CameraMetadata(const CameraMetadata &other) :
    mBuffer = clone_camera_metadata(other.mBuffer);
    mBuffer = clone_camera_metadata(other.mBuffer);
}
}


CameraMetadata::CameraMetadata(CameraMetadata &&other) :mBuffer(NULL),  mLocked(false) {
    acquire(other);
}

CameraMetadata &CameraMetadata::operator=(CameraMetadata &&other) {
    acquire(other);
    return *this;
}

CameraMetadata::CameraMetadata(camera_metadata_t *buffer) :
CameraMetadata::CameraMetadata(camera_metadata_t *buffer) :
        mBuffer(NULL), mLocked(false) {
        mBuffer(NULL), mLocked(false) {
    acquire(buffer);
    acquire(buffer);
+6 −0
Original line number Original line Diff line number Diff line
@@ -117,6 +117,12 @@ CaptureResult::CaptureResult() :
        mMetadata(), mResultExtras() {
        mMetadata(), mResultExtras() {
}
}


CaptureResult::CaptureResult(CaptureResult &&otherResult) {
    mMetadata = std::move(otherResult.mMetadata);
    mResultExtras = otherResult.mResultExtras;
    mPhysicalMetadatas = std::move(otherResult.mPhysicalMetadatas);
}

CaptureResult::CaptureResult(const CaptureResult &otherResult) {
CaptureResult::CaptureResult(const CaptureResult &otherResult) {
    mResultExtras = otherResult.mResultExtras;
    mResultExtras = otherResult.mResultExtras;
    mMetadata = otherResult.mMetadata;
    mMetadata = otherResult.mMetadata;
+10 −0
Original line number Original line Diff line number Diff line
@@ -40,6 +40,11 @@ class CameraMetadata: public Parcelable {
     * dataCapacity extra storage */
     * dataCapacity extra storage */
    CameraMetadata(size_t entryCapacity, size_t dataCapacity = 10);
    CameraMetadata(size_t entryCapacity, size_t dataCapacity = 10);


    /**
     * Move constructor, acquires other's metadata buffer
     */
    CameraMetadata(CameraMetadata &&other);

    ~CameraMetadata();
    ~CameraMetadata();


    /** Takes ownership of passed-in buffer */
    /** Takes ownership of passed-in buffer */
@@ -53,6 +58,11 @@ class CameraMetadata: public Parcelable {
    CameraMetadata &operator=(const CameraMetadata &other);
    CameraMetadata &operator=(const CameraMetadata &other);
    CameraMetadata &operator=(const camera_metadata_t *buffer);
    CameraMetadata &operator=(const camera_metadata_t *buffer);


    /**
     * Move assignment operator, acquires other's metadata buffer
     */
    CameraMetadata &operator=(CameraMetadata &&other);

    /**
    /**
     * Get reference to the underlying metadata buffer. Ownership remains with
     * Get reference to the underlying metadata buffer. Ownership remains with
     * the CameraMetadata object, but non-const CameraMetadata methods will not
     * the CameraMetadata object, but non-const CameraMetadata methods will not
+2 −0
Original line number Original line Diff line number Diff line
@@ -135,6 +135,8 @@ struct CaptureResult : public virtual LightRefBase<CaptureResult> {


    CaptureResult(const CaptureResult& otherResult);
    CaptureResult(const CaptureResult& otherResult);


    CaptureResult(CaptureResult &&captureResult);

    status_t                readFromParcel(android::Parcel* parcel);
    status_t                readFromParcel(android::Parcel* parcel);
    status_t                writeToParcel(android::Parcel* parcel) const;
    status_t                writeToParcel(android::Parcel* parcel) const;
};
};
+1 −1
Original line number Original line Diff line number Diff line
@@ -1102,7 +1102,7 @@ class Camera3Device :
    uint32_t               mNextReprocessShutterFrameNumber;
    uint32_t               mNextReprocessShutterFrameNumber;
    // the minimal frame number of the next ZSL still capture shutter
    // the minimal frame number of the next ZSL still capture shutter
    uint32_t               mNextZslStillShutterFrameNumber;
    uint32_t               mNextZslStillShutterFrameNumber;
    List<CaptureResult>    mResultQueue;
    std::list<CaptureResult>    mResultQueue;
    std::condition_variable  mResultSignal;
    std::condition_variable  mResultSignal;
    wp<NotificationListener> mListener;
    wp<NotificationListener> mListener;


Loading