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

Commit fb2d4066 authored by Sungtak Lee's avatar Sungtak Lee Committed by Automerger Merge Worker
Browse files

Merge changes from topic "64bit-usage" into main am: 4cf9ab59

parents 05bee682 4cf9ab59
Loading
Loading
Loading
Loading
+21 −6
Original line number Original line Diff line number Diff line
@@ -606,8 +606,16 @@ inline void wrapAs(AnwBuffer* t, GraphicBuffer const& l) {
    t->attr.height = l.getHeight();
    t->attr.height = l.getHeight();
    t->attr.stride = l.getStride();
    t->attr.stride = l.getStride();
    t->attr.format = static_cast<PixelFormat>(l.getPixelFormat());
    t->attr.format = static_cast<PixelFormat>(l.getPixelFormat());
    t->attr.layerCount = l.getLayerCount();
    // HACK
    t->attr.usage = l.getUsage();
    // anwBuffer.layerCount 8 bytes : GraphicBuffer::layerCount 4 bytes
    // anwBuffer.usage      4 bytes : GraphicBuffer::usage      8 bytes
    // We would like to retain high part of usage with high part of layerCount
    uint64_t usage = l.getUsage();
    uint32_t usageHigh = (usage >> 32);
    uint32_t usageLow = (0xFFFFFFFF & usage);
    uint32_t layerLow = l.getLayerCount();
    t->attr.layerCount = ((uint64_t(usageHigh) << 32) | layerLow);
    t->attr.usage = usageLow;
    t->attr.id = l.getId();
    t->attr.id = l.getId();
    t->attr.generationNumber = l.getGenerationNumber();
    t->attr.generationNumber = l.getGenerationNumber();
    t->nativeHandle = hidl_handle(l.handle);
    t->nativeHandle = hidl_handle(l.handle);
@@ -637,30 +645,37 @@ inline bool convertTo(GraphicBuffer* l, AnwBuffer const& t) {
        }
        }
    }
    }


    size_t const numInts = 12 + (handle ? handle->numInts : 0);
    size_t const numInts = 13 + (handle ? handle->numInts : 0);
    int32_t* ints = new int32_t[numInts];
    int32_t* ints = new int32_t[numInts];


    size_t numFds = static_cast<size_t>(handle ? handle->numFds : 0);
    size_t numFds = static_cast<size_t>(handle ? handle->numFds : 0);
    int* fds = new int[numFds];
    int* fds = new int[numFds];


    ints[0] = 'GBFR';
    ints[0] = 'GB01';
    ints[1] = static_cast<int32_t>(t.attr.width);
    ints[1] = static_cast<int32_t>(t.attr.width);
    ints[2] = static_cast<int32_t>(t.attr.height);
    ints[2] = static_cast<int32_t>(t.attr.height);
    ints[3] = static_cast<int32_t>(t.attr.stride);
    ints[3] = static_cast<int32_t>(t.attr.stride);
    ints[4] = static_cast<int32_t>(t.attr.format);
    ints[4] = static_cast<int32_t>(t.attr.format);
    ints[5] = static_cast<int32_t>(t.attr.layerCount);
    // HACK
    // anwBuffer.layerCount 8 bytes : GraphicBuffer::layerCount 4 bytes
    // anwBuffer.usage      4 bytes : GraphicBuffer::usage      8 bytes
    // We would like to retain high part of usage with high part of layerCount
    uint32_t layer = (0xFFFFFFFF & t.attr.layerCount);
    uint32_t usageHigh = (t.attr.layerCount >> 32);
    ints[5] = layer;
    ints[6] = static_cast<int32_t>(t.attr.usage);
    ints[6] = static_cast<int32_t>(t.attr.usage);
    ints[7] = static_cast<int32_t>(t.attr.id >> 32);
    ints[7] = static_cast<int32_t>(t.attr.id >> 32);
    ints[8] = static_cast<int32_t>(t.attr.id & 0xFFFFFFFF);
    ints[8] = static_cast<int32_t>(t.attr.id & 0xFFFFFFFF);
    ints[9] = static_cast<int32_t>(t.attr.generationNumber);
    ints[9] = static_cast<int32_t>(t.attr.generationNumber);
    ints[10] = 0;
    ints[10] = 0;
    ints[11] = 0;
    ints[11] = 0;
    ints[12] = usageHigh;
    if (handle) {
    if (handle) {
        ints[10] = static_cast<int32_t>(handle->numFds);
        ints[10] = static_cast<int32_t>(handle->numFds);
        ints[11] = static_cast<int32_t>(handle->numInts);
        ints[11] = static_cast<int32_t>(handle->numInts);
        int* intsStart = handle->data + handle->numFds;
        int* intsStart = handle->data + handle->numFds;
        std::copy(handle->data, intsStart, fds);
        std::copy(handle->data, intsStart, fds);
        std::copy(intsStart, intsStart + handle->numInts, &ints[12]);
        std::copy(intsStart, intsStart + handle->numInts, &ints[13]);
    }
    }


    void const* constBuffer = static_cast<void const*>(ints);
    void const* constBuffer = static_cast<void const*>(ints);
+10 −2
Original line number Original line Diff line number Diff line
@@ -425,8 +425,16 @@ inline CodecBuffer *wrapAs(CodecBuffer *t, sp<GraphicBuffer> const& graphicBuffe
    t->attr.anwBuffer.stride = graphicBuffer->getStride();
    t->attr.anwBuffer.stride = graphicBuffer->getStride();
    t->attr.anwBuffer.format = static_cast<PixelFormat>(
    t->attr.anwBuffer.format = static_cast<PixelFormat>(
            graphicBuffer->getPixelFormat());
            graphicBuffer->getPixelFormat());
    t->attr.anwBuffer.layerCount = graphicBuffer->getLayerCount();
    // HACK
    t->attr.anwBuffer.usage = graphicBuffer->getUsage();
    // anwBuffer.layerCount 8 bytes : GraphicBuffer::layerCount 4 bytes
    // anwBuffer.usage      4 bytes : GraphicBuffer::usage      8 bytes
    // We would like to retain high part of usage with high part of layerCount
    uint64_t usage = graphicBuffer->getUsage();
    uint32_t usageHigh = (usage >> 32);
    uint32_t usageLow = (0xFFFFFFFF & usage);
    uint32_t layerLow = graphicBuffer->getLayerCount();
    t->attr.anwBuffer.layerCount = ((uint64_t(usageHigh) << 32) | layerLow);
    t->attr.anwBuffer.usage = usageLow;
    t->nativeHandle = graphicBuffer->handle;
    t->nativeHandle = graphicBuffer->handle;
    return t;
    return t;
}
}