From 4d957a736845635f75cc8281d850c49d82b41275 Mon Sep 17 00:00:00 2001 From: koron393 Date: Mon, 16 Sep 2019 01:29:47 +0900 Subject: shinano-common: libshim_camera: Remove LIBUI_IN_VNDK ifdefs * Fix build Signed-off-by: koron393 Change-Id: I70f2be803b45c06e5a3b2a4ad8ce2ca6c2397a3f --- libshims/include/ui/GraphicBuffer.h | 30 ---------- libshims/ui/GraphicBuffer.cpp | 109 ------------------------------------ 2 files changed, 139 deletions(-) (limited to 'libshims') diff --git a/libshims/include/ui/GraphicBuffer.h b/libshims/include/ui/GraphicBuffer.h index c195342..bc820b0 100644 --- a/libshims/include/ui/GraphicBuffer.h +++ b/libshims/include/ui/GraphicBuffer.h @@ -38,10 +38,6 @@ namespace android { -#ifndef LIBUI_IN_VNDK -class BufferHubBuffer; -#endif // LIBUI_IN_VNDK - class GraphicBufferMapper; using GraphicBufferDeathCallback = std::function; @@ -147,11 +143,6 @@ public: GraphicBuffer(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat, uint32_t inUsage, std::string requestorName = ""); -#ifndef LIBUI_IN_VNDK - // Create a GraphicBuffer from an existing BufferHubBuffer. - GraphicBuffer(std::unique_ptr buffer); -#endif // LIBUI_IN_VNDK - // return status status_t initCheck() const; @@ -225,11 +216,6 @@ public: void addDeathCallback(GraphicBufferDeathCallback deathCallback, void* context); -#ifndef LIBUI_IN_VNDK - // Returns whether this GraphicBuffer is backed by BufferHubBuffer. - bool isBufferHubBuffer() const; -#endif // LIBUI_IN_VNDK - private: ~GraphicBuffer(); @@ -299,22 +285,6 @@ private: // and informs SurfaceFlinger that it should drop its strong pointer reference to the buffer. std::vector> mDeathCallbacks; - -#ifndef LIBUI_IN_VNDK - // Flatten this GraphicBuffer object if backed by BufferHubBuffer. - status_t flattenBufferHubBuffer(void*& buffer, size_t& size) const; - - // Unflatten into BufferHubBuffer backed GraphicBuffer. - // Unflatten will fail if the original GraphicBuffer object is destructed. For instance, a - // GraphicBuffer backed by BufferHubBuffer_1 flatten in process/thread A, transport the token - // to process/thread B through a socket, BufferHubBuffer_1 dies and bufferhub invalidated the - // token. Race condition occurs between the invalidation of the token in bufferhub process and - // process/thread B trying to unflatten and import the buffer with that token. - status_t unflattenBufferHubBuffer(void const*& buffer, size_t& size); - - // Stores a BufferHubBuffer that handles buffer signaling, identification. - std::unique_ptr mBufferHubBuffer; -#endif // LIBUI_IN_VNDK }; }; // namespace android diff --git a/libshims/ui/GraphicBuffer.cpp b/libshims/ui/GraphicBuffer.cpp index 3fc6a2d..325d176 100644 --- a/libshims/ui/GraphicBuffer.cpp +++ b/libshims/ui/GraphicBuffer.cpp @@ -23,10 +23,6 @@ #include -#ifndef LIBUI_IN_VNDK -#include -#endif // LIBUI_IN_VNDK - #include #include #include @@ -111,22 +107,6 @@ GraphicBuffer::GraphicBuffer(const native_handle_t* inHandle, HandleWrapMethod m inUsage, inStride); } -#ifndef LIBUI_IN_VNDK -GraphicBuffer::GraphicBuffer(std::unique_ptr buffer) : GraphicBuffer() { - if (buffer == nullptr) { - mInitCheck = BAD_VALUE; - return; - } - - mInitCheck = initWithHandle(buffer->duplicateHandle(), /*method=*/TAKE_UNREGISTERED_HANDLE, - buffer->desc().width, buffer->desc().height, - static_cast(buffer->desc().format), - buffer->desc().layers, buffer->desc().usage, buffer->desc().stride); - mBufferId = buffer->id(); - mBufferHubBuffer = std::move(buffer); -} -#endif // LIBUI_IN_VNDK - GraphicBuffer::~GraphicBuffer() { ATRACE_CALL(); @@ -375,29 +355,14 @@ status_t GraphicBuffer::isSupported(uint32_t inWidth, uint32_t inHeight, PixelFo } size_t GraphicBuffer::getFlattenedSize() const { -#ifndef LIBUI_IN_VNDK - if (mBufferHubBuffer != nullptr) { - return 48; - } -#endif return static_cast(13 + (handle ? mTransportNumInts : 0)) * sizeof(int); } size_t GraphicBuffer::getFdCount() const { -#ifndef LIBUI_IN_VNDK - if (mBufferHubBuffer != nullptr) { - return 0; - } -#endif return static_cast(handle ? mTransportNumFds : 0); } status_t GraphicBuffer::flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const { -#ifndef LIBUI_IN_VNDK - if (mBufferHubBuffer != nullptr) { - return flattenBufferHubBuffer(buffer, size); - } -#endif size_t sizeNeeded = GraphicBuffer::getFlattenedSize(); if (size < sizeNeeded) return NO_MEMORY; @@ -455,11 +420,7 @@ status_t GraphicBuffer::unflatten(void const*& buffer, size_t& size, int const*& // old version, when usage bits were 32-bits flattenWordCount = 12; } else if (buf[0] == 'BHBB') { // BufferHub backed buffer. -#ifndef LIBUI_IN_VNDK - return unflattenBufferHubBuffer(buffer, size); -#else return BAD_TYPE; -#endif } else { return BAD_TYPE; } @@ -566,76 +527,6 @@ void GraphicBuffer::addDeathCallback(GraphicBufferDeathCallback deathCallback, v mDeathCallbacks.emplace_back(deathCallback, context); } -#ifndef LIBUI_IN_VNDK -status_t GraphicBuffer::flattenBufferHubBuffer(void*& buffer, size_t& size) const { - sp tokenHandle = mBufferHubBuffer->duplicate(); - if (tokenHandle == nullptr || tokenHandle->handle() == nullptr || - tokenHandle->handle()->numFds != 0) { - return BAD_VALUE; - } - - // Size needed for one label, one number of ints inside the token, one generation number and - // the token itself. - int numIntsInToken = tokenHandle->handle()->numInts; - const size_t sizeNeeded = static_cast(3 + numIntsInToken) * sizeof(int); - if (size < sizeNeeded) { - ALOGE("%s: needed size %d, given size %d. Not enough memory.", __FUNCTION__, - static_cast(sizeNeeded), static_cast(size)); - return NO_MEMORY; - } - size -= sizeNeeded; - - int* buf = static_cast(buffer); - buf[0] = 'BHBB'; - buf[1] = numIntsInToken; - memcpy(buf + 2, tokenHandle->handle()->data, static_cast(numIntsInToken) * sizeof(int)); - buf[2 + numIntsInToken] = static_cast(mGenerationNumber); - - return NO_ERROR; -} - -status_t GraphicBuffer::unflattenBufferHubBuffer(void const*& buffer, size_t& size) { - const int* buf = static_cast(buffer); - int numIntsInToken = buf[1]; - // Size needed for one label, one number of ints inside the token, one generation number and - // the token itself. - const size_t sizeNeeded = static_cast(3 + numIntsInToken) * sizeof(int); - if (size < sizeNeeded) { - ALOGE("%s: needed size %d, given size %d. Not enough memory.", __FUNCTION__, - static_cast(sizeNeeded), static_cast(size)); - return NO_MEMORY; - } - size -= sizeNeeded; - native_handle_t* importToken = native_handle_create(/*numFds=*/0, /*numInts=*/numIntsInToken); - memcpy(importToken->data, buf + 2, static_cast(buf[1]) * sizeof(int)); - sp importTokenHandle = NativeHandle::create(importToken, /*ownHandle=*/true); - std::unique_ptr bufferHubBuffer = BufferHubBuffer::import(importTokenHandle); - if (bufferHubBuffer == nullptr || bufferHubBuffer.get() == nullptr) { - return BAD_VALUE; - } - // Reconstruct this GraphicBuffer object using the new BufferHubBuffer object. - if (handle) { - free_handle(); - } - mId = 0; - mGenerationNumber = static_cast(buf[2 + numIntsInToken]); - mInitCheck = - initWithHandle(bufferHubBuffer->duplicateHandle(), /*method=*/TAKE_UNREGISTERED_HANDLE, - bufferHubBuffer->desc().width, bufferHubBuffer->desc().height, - static_cast(bufferHubBuffer->desc().format), - bufferHubBuffer->desc().layers, bufferHubBuffer->desc().usage, - bufferHubBuffer->desc().stride); - mBufferId = bufferHubBuffer->id(); - mBufferHubBuffer.reset(std::move(bufferHubBuffer.get())); - - return NO_ERROR; -} - -bool GraphicBuffer::isBufferHubBuffer() const { - return mBufferHubBuffer != nullptr; -} -#endif // LIBUI_IN_VNDK - // --------------------------------------------------------------------------- }; // namespace android -- cgit v1.2.3