diff options
author | Chia-I Wu <olv@google.com> | 2018-01-16 18:10:08 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-01-16 18:10:08 +0000 |
commit | 0651511689534f30c986fdc0657e07f63ec45cac (patch) | |
tree | 540df2f64a5e31db280b6fd643de614d8ba288ec /graphics/allocator | |
parent | 80a04eb31973f6bac09d76f24ce0fb0a508eee63 (diff) | |
parent | 864c9f82340cae767c3665c91abe3cfc7928ac64 (diff) | |
download | android_hardware_interfaces-0651511689534f30c986fdc0657e07f63ec45cac.tar.gz android_hardware_interfaces-0651511689534f30c986fdc0657e07f63ec45cac.tar.bz2 android_hardware_interfaces-0651511689534f30c986fdc0657e07f63ec45cac.zip |
graphics: clang-format allocator default impl
am: 864c9f8234
Change-Id: I1a83cdbf10c27859649c10cf2e1c62c2974e99fa
Diffstat (limited to 'graphics/allocator')
7 files changed, 47 insertions, 67 deletions
diff --git a/graphics/allocator/2.0/default/Gralloc.cpp b/graphics/allocator/2.0/default/Gralloc.cpp index 273d3f584..af578e8e1 100644 --- a/graphics/allocator/2.0/default/Gralloc.cpp +++ b/graphics/allocator/2.0/default/Gralloc.cpp @@ -49,9 +49,9 @@ IAllocator* HIDL_FETCH_IAllocator(const char* /* name */) { } } -} // namespace implementation -} // namespace V2_0 -} // namespace allocator -} // namespace graphics -} // namespace hardware -} // namespace android +} // namespace implementation +} // namespace V2_0 +} // namespace allocator +} // namespace graphics +} // namespace hardware +} // namespace android diff --git a/graphics/allocator/2.0/default/Gralloc.h b/graphics/allocator/2.0/default/Gralloc.h index c79eeaa42..18c52023e 100644 --- a/graphics/allocator/2.0/default/Gralloc.h +++ b/graphics/allocator/2.0/default/Gralloc.h @@ -28,11 +28,11 @@ namespace implementation { extern "C" IAllocator* HIDL_FETCH_IAllocator(const char* name); -} // namespace implementation -} // namespace V2_0 -} // namespace allocator -} // namespace graphics -} // namespace hardware -} // namespace android +} // namespace implementation +} // namespace V2_0 +} // namespace allocator +} // namespace graphics +} // namespace hardware +} // namespace android -#endif // ANDROID_HARDWARE_GRAPHICS_ALLOCATOR_V2_0_GRALLOC_H +#endif // ANDROID_HARDWARE_GRAPHICS_ALLOCATOR_V2_0_GRALLOC_H diff --git a/graphics/allocator/2.0/default/service.cpp b/graphics/allocator/2.0/default/service.cpp index 99f462cf2..bc0539a61 100644 --- a/graphics/allocator/2.0/default/service.cpp +++ b/graphics/allocator/2.0/default/service.cpp @@ -20,8 +20,8 @@ #include <hidl/LegacySupport.h> -using android::hardware::graphics::allocator::V2_0::IAllocator; using android::hardware::defaultPassthroughServiceImplementation; +using android::hardware::graphics::allocator::V2_0::IAllocator; int main() { return defaultPassthroughServiceImplementation<IAllocator>(4); diff --git a/graphics/allocator/2.0/utils/passthrough/Gralloc0Allocator.cpp b/graphics/allocator/2.0/utils/passthrough/Gralloc0Allocator.cpp index 3b62bb319..b49370a39 100644 --- a/graphics/allocator/2.0/utils/passthrough/Gralloc0Allocator.cpp +++ b/graphics/allocator/2.0/utils/passthrough/Gralloc0Allocator.cpp @@ -32,14 +32,12 @@ namespace allocator { namespace V2_0 { namespace implementation { -using android::hardware::graphics::mapper::V2_0::implementation:: - grallocDecodeBufferDescriptor; +using android::hardware::graphics::mapper::V2_0::implementation::grallocDecodeBufferDescriptor; Gralloc0Allocator::Gralloc0Allocator(const hw_module_t* module) { int result = gralloc_open(module, &mDevice); if (result) { - LOG_ALWAYS_FATAL("failed to open gralloc0 device: %s", - strerror(-result)); + LOG_ALWAYS_FATAL("failed to open gralloc0 device: %s", strerror(-result)); } } @@ -59,8 +57,8 @@ Return<void> Gralloc0Allocator::dumpDebugInfo(dumpDebugInfo_cb hidl_cb) { return Void(); } -Return<void> Gralloc0Allocator::allocate(const BufferDescriptor& descriptor, - uint32_t count, allocate_cb hidl_cb) { +Return<void> Gralloc0Allocator::allocate(const BufferDescriptor& descriptor, uint32_t count, + allocate_cb hidl_cb) { IMapper::BufferDescriptorInfo descriptorInfo; if (!grallocDecodeBufferDescriptor(descriptor, &descriptorInfo)) { hidl_cb(Error::BAD_DESCRIPTOR, 0, hidl_vec<hidl_handle>()); @@ -110,17 +108,15 @@ Return<void> Gralloc0Allocator::allocate(const BufferDescriptor& descriptor, } Error Gralloc0Allocator::allocateOne(const IMapper::BufferDescriptorInfo& info, - buffer_handle_t* outBuffer, - uint32_t* outStride) { + buffer_handle_t* outBuffer, uint32_t* outStride) { if (info.layerCount > 1 || (info.usage >> 32) != 0) { return Error::BAD_VALUE; } buffer_handle_t buffer = nullptr; int stride = 0; - int result = mDevice->alloc(mDevice, info.width, info.height, - static_cast<int>(info.format), info.usage, - &buffer, &stride); + int result = mDevice->alloc(mDevice, info.width, info.height, static_cast<int>(info.format), + info.usage, &buffer, &stride); if (result) { switch (result) { case -EINVAL: diff --git a/graphics/allocator/2.0/utils/passthrough/Gralloc0Allocator.h b/graphics/allocator/2.0/utils/passthrough/Gralloc0Allocator.h index 0e90527f7..605228204 100644 --- a/graphics/allocator/2.0/utils/passthrough/Gralloc0Allocator.h +++ b/graphics/allocator/2.0/utils/passthrough/Gralloc0Allocator.h @@ -28,9 +28,9 @@ namespace allocator { namespace V2_0 { namespace implementation { -using android::hardware::graphics::mapper::V2_0::IMapper; using android::hardware::graphics::mapper::V2_0::BufferDescriptor; using android::hardware::graphics::mapper::V2_0::Error; +using android::hardware::graphics::mapper::V2_0::IMapper; class Gralloc0Allocator : public IAllocator { public: @@ -43,8 +43,8 @@ class Gralloc0Allocator : public IAllocator { allocate_cb hidl_cb) override; private: - Error allocateOne(const IMapper::BufferDescriptorInfo& info, - buffer_handle_t* outBuffer, uint32_t* outStride); + Error allocateOne(const IMapper::BufferDescriptorInfo& info, buffer_handle_t* outBuffer, + uint32_t* outStride); alloc_device_t* mDevice; }; diff --git a/graphics/allocator/2.0/utils/passthrough/Gralloc1Allocator.cpp b/graphics/allocator/2.0/utils/passthrough/Gralloc1Allocator.cpp index 6cbb79155..b7e27bb01 100644 --- a/graphics/allocator/2.0/utils/passthrough/Gralloc1Allocator.cpp +++ b/graphics/allocator/2.0/utils/passthrough/Gralloc1Allocator.cpp @@ -33,15 +33,13 @@ namespace V2_0 { namespace implementation { using android::hardware::graphics::common::V1_0::BufferUsage; -using android::hardware::graphics::mapper::V2_0::implementation:: - grallocDecodeBufferDescriptor; +using android::hardware::graphics::mapper::V2_0::implementation::grallocDecodeBufferDescriptor; Gralloc1Allocator::Gralloc1Allocator(const hw_module_t* module) : mDevice(nullptr), mCapabilities(), mDispatch() { int result = gralloc1_open(module, &mDevice); if (result) { - LOG_ALWAYS_FATAL("failed to open gralloc1 device: %s", - strerror(-result)); + LOG_ALWAYS_FATAL("failed to open gralloc1 device: %s", strerror(-result)); } initCapabilities(); @@ -69,8 +67,7 @@ void Gralloc1Allocator::initCapabilities() { } template <typename T> -void Gralloc1Allocator::initDispatch(gralloc1_function_descriptor_t desc, - T* outPfn) { +void Gralloc1Allocator::initDispatch(gralloc1_function_descriptor_t desc, T* outPfn) { auto pfn = mDevice->getFunction(mDevice, desc); if (!pfn) { LOG_ALWAYS_FATAL("failed to get gralloc1 function %d", desc); @@ -81,20 +78,15 @@ void Gralloc1Allocator::initDispatch(gralloc1_function_descriptor_t desc, void Gralloc1Allocator::initDispatch() { initDispatch(GRALLOC1_FUNCTION_DUMP, &mDispatch.dump); - initDispatch(GRALLOC1_FUNCTION_CREATE_DESCRIPTOR, - &mDispatch.createDescriptor); - initDispatch(GRALLOC1_FUNCTION_DESTROY_DESCRIPTOR, - &mDispatch.destroyDescriptor); + initDispatch(GRALLOC1_FUNCTION_CREATE_DESCRIPTOR, &mDispatch.createDescriptor); + initDispatch(GRALLOC1_FUNCTION_DESTROY_DESCRIPTOR, &mDispatch.destroyDescriptor); initDispatch(GRALLOC1_FUNCTION_SET_DIMENSIONS, &mDispatch.setDimensions); initDispatch(GRALLOC1_FUNCTION_SET_FORMAT, &mDispatch.setFormat); if (mCapabilities.layeredBuffers) { - initDispatch(GRALLOC1_FUNCTION_SET_LAYER_COUNT, - &mDispatch.setLayerCount); + initDispatch(GRALLOC1_FUNCTION_SET_LAYER_COUNT, &mDispatch.setLayerCount); } - initDispatch(GRALLOC1_FUNCTION_SET_CONSUMER_USAGE, - &mDispatch.setConsumerUsage); - initDispatch(GRALLOC1_FUNCTION_SET_PRODUCER_USAGE, - &mDispatch.setProducerUsage); + initDispatch(GRALLOC1_FUNCTION_SET_CONSUMER_USAGE, &mDispatch.setConsumerUsage); + initDispatch(GRALLOC1_FUNCTION_SET_PRODUCER_USAGE, &mDispatch.setProducerUsage); initDispatch(GRALLOC1_FUNCTION_GET_STRIDE, &mDispatch.getStride); initDispatch(GRALLOC1_FUNCTION_ALLOCATE, &mDispatch.allocate); initDispatch(GRALLOC1_FUNCTION_RELEASE, &mDispatch.release); @@ -116,8 +108,8 @@ Return<void> Gralloc1Allocator::dumpDebugInfo(dumpDebugInfo_cb hidl_cb) { return Void(); } -Return<void> Gralloc1Allocator::allocate(const BufferDescriptor& descriptor, - uint32_t count, allocate_cb hidl_cb) { +Return<void> Gralloc1Allocator::allocate(const BufferDescriptor& descriptor, uint32_t count, + allocate_cb hidl_cb) { IMapper::BufferDescriptorInfo descriptorInfo; if (!grallocDecodeBufferDescriptor(descriptor, &descriptorInfo)) { hidl_cb(Error::BAD_DESCRIPTOR, 0, hidl_vec<hidl_handle>()); @@ -199,9 +191,8 @@ uint64_t Gralloc1Allocator::toProducerUsage(uint64_t usage) { // this is potentially broken as we have no idea which private flags // should be filtered out uint64_t producerUsage = - usage & - ~static_cast<uint64_t>(BufferUsage::CPU_READ_MASK | BufferUsage::CPU_WRITE_MASK | - BufferUsage::GPU_DATA_BUFFER); + usage & ~static_cast<uint64_t>(BufferUsage::CPU_READ_MASK | BufferUsage::CPU_WRITE_MASK | + BufferUsage::GPU_DATA_BUFFER); switch (usage & BufferUsage::CPU_WRITE_MASK) { case static_cast<uint64_t>(BufferUsage::CPU_WRITE_RARELY): @@ -258,36 +249,30 @@ uint64_t Gralloc1Allocator::toConsumerUsage(uint64_t usage) { return consumerUsage; } -Error Gralloc1Allocator::createDescriptor( - const IMapper::BufferDescriptorInfo& info, - gralloc1_buffer_descriptor_t* outDescriptor) { +Error Gralloc1Allocator::createDescriptor(const IMapper::BufferDescriptorInfo& info, + gralloc1_buffer_descriptor_t* outDescriptor) { gralloc1_buffer_descriptor_t descriptor; int32_t error = mDispatch.createDescriptor(mDevice, &descriptor); if (error == GRALLOC1_ERROR_NONE) { - error = mDispatch.setDimensions(mDevice, descriptor, info.width, - info.height); + error = mDispatch.setDimensions(mDevice, descriptor, info.width, info.height); } if (error == GRALLOC1_ERROR_NONE) { - error = mDispatch.setFormat(mDevice, descriptor, - static_cast<int32_t>(info.format)); + error = mDispatch.setFormat(mDevice, descriptor, static_cast<int32_t>(info.format)); } if (error == GRALLOC1_ERROR_NONE) { if (mCapabilities.layeredBuffers) { - error = - mDispatch.setLayerCount(mDevice, descriptor, info.layerCount); + error = mDispatch.setLayerCount(mDevice, descriptor, info.layerCount); } else if (info.layerCount > 1) { error = GRALLOC1_ERROR_UNSUPPORTED; } } if (error == GRALLOC1_ERROR_NONE) { - error = mDispatch.setProducerUsage(mDevice, descriptor, - toProducerUsage(info.usage)); + error = mDispatch.setProducerUsage(mDevice, descriptor, toProducerUsage(info.usage)); } if (error == GRALLOC1_ERROR_NONE) { - error = mDispatch.setConsumerUsage(mDevice, descriptor, - toConsumerUsage(info.usage)); + error = mDispatch.setConsumerUsage(mDevice, descriptor, toConsumerUsage(info.usage)); } if (error == GRALLOC1_ERROR_NONE) { @@ -300,8 +285,7 @@ Error Gralloc1Allocator::createDescriptor( } Error Gralloc1Allocator::allocateOne(gralloc1_buffer_descriptor_t descriptor, - buffer_handle_t* outBuffer, - uint32_t* outStride) { + buffer_handle_t* outBuffer, uint32_t* outStride) { buffer_handle_t buffer = nullptr; int32_t error = mDispatch.allocate(mDevice, 1, &descriptor, &buffer); if (error != GRALLOC1_ERROR_NONE && error != GRALLOC1_ERROR_NOT_SHARED) { diff --git a/graphics/allocator/2.0/utils/passthrough/Gralloc1Allocator.h b/graphics/allocator/2.0/utils/passthrough/Gralloc1Allocator.h index 7b5a96613..686e8b35d 100644 --- a/graphics/allocator/2.0/utils/passthrough/Gralloc1Allocator.h +++ b/graphics/allocator/2.0/utils/passthrough/Gralloc1Allocator.h @@ -28,9 +28,9 @@ namespace allocator { namespace V2_0 { namespace implementation { -using android::hardware::graphics::mapper::V2_0::IMapper; using android::hardware::graphics::mapper::V2_0::BufferDescriptor; using android::hardware::graphics::mapper::V2_0::Error; +using android::hardware::graphics::mapper::V2_0::IMapper; class Gralloc1Allocator : public IAllocator { public: @@ -55,8 +55,8 @@ class Gralloc1Allocator : public IAllocator { Error createDescriptor(const IMapper::BufferDescriptorInfo& info, gralloc1_buffer_descriptor_t* outDescriptor); - Error allocateOne(gralloc1_buffer_descriptor_t descriptor, - buffer_handle_t* outBuffer, uint32_t* outStride); + Error allocateOne(gralloc1_buffer_descriptor_t descriptor, buffer_handle_t* outBuffer, + uint32_t* outStride); gralloc1_device_t* mDevice; |