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

Commit 3518dd84 authored by Valerie Hau's avatar Valerie Hau Committed by Android (Google) Code Review
Browse files

Merge "Adding optional 3.0 lock support to GraphicBuffer"

parents 44650259 250c654e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ Gralloc2Mapper::Gralloc2Mapper() {
    mMapperV2_1 = IMapper::castFrom(mMapper);
}

bool Gralloc2Mapper::isSupported() const {
bool Gralloc2Mapper::isLoaded() const {
    return mMapper != nullptr;
}

@@ -359,7 +359,7 @@ Gralloc2Allocator::Gralloc2Allocator(const Gralloc2Mapper& mapper) : mMapper(map
    }
}

bool Gralloc2Allocator::isSupported() const {
bool Gralloc2Allocator::isLoaded() const {
    return mAllocator != nullptr;
}

+2 −2
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ Gralloc3Mapper::Gralloc3Mapper() {
    }
}

bool Gralloc3Mapper::isSupported() const {
bool Gralloc3Mapper::isLoaded() const {
    return mMapper != nullptr;
}

@@ -322,7 +322,7 @@ Gralloc3Allocator::Gralloc3Allocator(const Gralloc3Mapper& mapper) : mMapper(map
    }
}

bool Gralloc3Allocator::isSupported() const {
bool Gralloc3Allocator::isLoaded() const {
    return mAllocator != nullptr;
}

+8 −8
Original line number Diff line number Diff line
@@ -236,15 +236,15 @@ status_t GraphicBuffer::initWithHandle(const native_handle_t* inHandle, HandleWr
    return NO_ERROR;
}

status_t GraphicBuffer::lock(uint32_t inUsage, void** vaddr)
{
status_t GraphicBuffer::lock(uint32_t inUsage, void** vaddr, int32_t* outBytesPerPixel,
                             int32_t* outBytesPerStride) {
    const Rect lockBounds(width, height);
    status_t res = lock(inUsage, lockBounds, vaddr);
    status_t res = lock(inUsage, lockBounds, vaddr, outBytesPerPixel, outBytesPerStride);
    return res;
}

status_t GraphicBuffer::lock(uint32_t inUsage, const Rect& rect, void** vaddr)
{
status_t GraphicBuffer::lock(uint32_t inUsage, const Rect& rect, void** vaddr,
                             int32_t* outBytesPerPixel, int32_t* outBytesPerStride) {
    if (rect.left < 0 || rect.right  > width ||
        rect.top  < 0 || rect.bottom > height) {
        ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)",
@@ -252,10 +252,10 @@ status_t GraphicBuffer::lock(uint32_t inUsage, const Rect& rect, void** vaddr)
                width, height);
        return BAD_VALUE;
    }
    int32_t bytesPerPixel, bytesPerStride;

    status_t res =
            getBufferMapper().lock(handle, inUsage, rect, vaddr, &bytesPerPixel, &bytesPerStride);
    status_t res = getBufferMapper().lock(handle, inUsage, rect, vaddr, outBytesPerPixel,
                                          outBytesPerStride);

    return res;
}

+2 −2
Original line number Diff line number Diff line
@@ -48,12 +48,12 @@ KeyedVector<buffer_handle_t,
GraphicBufferAllocator::GraphicBufferAllocator() : mMapper(GraphicBufferMapper::getInstance()) {
    mAllocator = std::make_unique<const Gralloc3Allocator>(
            reinterpret_cast<const Gralloc3Mapper&>(mMapper.getGrallocMapper()));
    if (!mAllocator->isSupported()) {
    if (!mAllocator->isLoaded()) {
        mAllocator = std::make_unique<const Gralloc2Allocator>(
                reinterpret_cast<const Gralloc2Mapper&>(mMapper.getGrallocMapper()));
    }

    if (!mAllocator->isSupported()) {
    if (!mAllocator->isLoaded()) {
        LOG_ALWAYS_FATAL("gralloc-allocator is missing");
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -51,11 +51,11 @@ void GraphicBufferMapper::preloadHal() {

GraphicBufferMapper::GraphicBufferMapper() {
    mMapper = std::make_unique<const Gralloc3Mapper>();
    if (!mMapper->isSupported()) {
    if (!mMapper->isLoaded()) {
        mMapper = std::make_unique<const Gralloc2Mapper>();
    }

    if (!mMapper->isSupported()) {
    if (!mMapper->isLoaded()) {
        LOG_ALWAYS_FATAL("gralloc-mapper is missing");
    }
}
Loading