diff --git a/graphics/composer/aidl/Android.bp b/graphics/composer/aidl/Android.bp index 5f5b54ec7c..2532a7a740 100644 --- a/graphics/composer/aidl/Android.bp +++ b/graphics/composer/aidl/Android.bp @@ -55,20 +55,6 @@ aidl_interface { }, } -cc_library { - name: "android.hardware.graphics.composer3-translate-ndk", - vendor_available: true, - srcs: ["android/hardware/graphics/composer3/translate-ndk.cpp"], - shared_libs: [ - "libbinder_ndk", - "libhidlbase", - "android.hardware.graphics.composer3-V1-ndk", - "android.hardware.graphics.composer@2.1", - "android.hardware.graphics.composer@2.4", - ], - export_include_dirs: ["include"], -} - cc_library_headers { name: "android.hardware.graphics.composer3-command-buffer", vendor_available: true, @@ -88,3 +74,16 @@ cc_library_headers { ], export_include_dirs: ["include"], } + +cc_test { + name: "android.hardware.graphics.composer3-hidl2aidl-asserts", + vendor_available: true, + srcs: ["android/hardware/graphics/composer3/Hidl2AidlAsserts.cpp"], + shared_libs: [ + "libbinder_ndk", + "libhidlbase", + "android.hardware.graphics.composer3-V1-ndk", + "android.hardware.graphics.composer@2.1", + "android.hardware.graphics.composer@2.4", + ], +} diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/translate-ndk.cpp b/graphics/composer/aidl/android/hardware/graphics/composer3/Hidl2AidlAsserts.cpp similarity index 81% rename from graphics/composer/aidl/android/hardware/graphics/composer3/translate-ndk.cpp rename to graphics/composer/aidl/android/hardware/graphics/composer3/Hidl2AidlAsserts.cpp index c2a4fdd0ce..d34b4051fa 100644 --- a/graphics/composer/aidl/android/hardware/graphics/composer3/translate-ndk.cpp +++ b/graphics/composer/aidl/android/hardware/graphics/composer3/Hidl2AidlAsserts.cpp @@ -14,7 +14,33 @@ * limitations under the License. */ -#include "android/hardware/graphics/composer3/translate-ndk.h" +#include "aidl/android/hardware/graphics/common/BlendMode.h" +#include "aidl/android/hardware/graphics/common/FRect.h" +#include "aidl/android/hardware/graphics/common/Rect.h" +#include "aidl/android/hardware/graphics/composer3/Capability.h" +#include "aidl/android/hardware/graphics/composer3/ClientTargetProperty.h" +#include "aidl/android/hardware/graphics/composer3/Color.h" +#include "aidl/android/hardware/graphics/composer3/Composition.h" +#include "aidl/android/hardware/graphics/composer3/ContentType.h" +#include "aidl/android/hardware/graphics/composer3/DisplayAttribute.h" +#include "aidl/android/hardware/graphics/composer3/DisplayCapability.h" +#include "aidl/android/hardware/graphics/composer3/DisplayConnectionType.h" +#include "aidl/android/hardware/graphics/composer3/FloatColor.h" +#include "aidl/android/hardware/graphics/composer3/FormatColorComponent.h" +#include "aidl/android/hardware/graphics/composer3/IComposer.h" +#include "aidl/android/hardware/graphics/composer3/PerFrameMetadata.h" +#include "aidl/android/hardware/graphics/composer3/PerFrameMetadataBlob.h" +#include "aidl/android/hardware/graphics/composer3/PerFrameMetadataKey.h" +#include "aidl/android/hardware/graphics/composer3/PowerMode.h" +#include "aidl/android/hardware/graphics/composer3/VsyncPeriodChangeConstraints.h" +#include "aidl/android/hardware/graphics/composer3/VsyncPeriodChangeTimeline.h" +#include "android/hardware/graphics/composer/2.1/IComposer.h" +#include "android/hardware/graphics/composer/2.1/IComposerCallback.h" +#include "android/hardware/graphics/composer/2.1/IComposerClient.h" +#include "android/hardware/graphics/composer/2.2/IComposerClient.h" +#include "android/hardware/graphics/composer/2.3/IComposerClient.h" +#include "android/hardware/graphics/composer/2.4/IComposerClient.h" +#include "android/hardware/graphics/composer/2.4/types.h" namespace android::h2a { @@ -325,122 +351,4 @@ static_assert( aidl::android::hardware::graphics::composer3::PresentOrValidate::Result::Validated == static_cast(0)); -__attribute__((warn_unused_result)) bool translate( - const ::android::hardware::graphics::composer::V2_4::VsyncPeriodChangeTimeline& in, - aidl::android::hardware::graphics::composer3::VsyncPeriodChangeTimeline* out) { - out->newVsyncAppliedTimeNanos = static_cast(in.newVsyncAppliedTimeNanos); - out->refreshRequired = static_cast(in.refreshRequired); - out->refreshTimeNanos = static_cast(in.refreshTimeNanos); - return true; -} - -__attribute__((warn_unused_result)) bool translate( - const ::android::hardware::graphics::composer::V2_1::IComposerClient::Rect& in, - aidl::android::hardware::graphics::common::Rect* out) { - out->left = static_cast(in.left); - out->top = static_cast(in.top); - out->right = static_cast(in.right); - out->bottom = static_cast(in.bottom); - return true; -} - -__attribute__((warn_unused_result)) bool translate( - const ::android::hardware::graphics::composer::V2_1::IComposerClient::FRect& in, - aidl::android::hardware::graphics::common::FRect* out) { - out->left = static_cast(in.left); - out->top = static_cast(in.top); - out->right = static_cast(in.right); - out->bottom = static_cast(in.bottom); - return true; -} - -__attribute__((warn_unused_result)) bool translate( - const ::android::hardware::graphics::composer::V2_1::IComposerClient::Color& in, - aidl::android::hardware::graphics::composer3::Color* out) { - // FIXME This requires conversion between signed and unsigned. Change this if it doesn't suit - // your needs. - if (in.r > std::numeric_limits::max() || in.r < 0) { - return false; - } - out->r = static_cast(in.r); - // FIXME This requires conversion between signed and unsigned. Change this if it doesn't suit - // your needs. - if (in.g > std::numeric_limits::max() || in.g < 0) { - return false; - } - out->g = static_cast(in.g); - // FIXME This requires conversion between signed and unsigned. Change this if it doesn't suit - // your needs. - if (in.b > std::numeric_limits::max() || in.b < 0) { - return false; - } - out->b = static_cast(in.b); - // FIXME This requires conversion between signed and unsigned. Change this if it doesn't suit - // your needs. - if (in.a > std::numeric_limits::max() || in.a < 0) { - return false; - } - out->a = static_cast(in.a); - return true; -} - -__attribute__((warn_unused_result)) bool translate( - const ::android::hardware::graphics::composer::V2_3::IComposerClient::PerFrameMetadata& in, - aidl::android::hardware::graphics::composer3::PerFrameMetadata* out) { - out->key = - static_cast(in.key); - out->value = static_cast(in.value); - return true; -} - -__attribute__((warn_unused_result)) bool translate( - const ::android::hardware::graphics::composer::V2_2::IComposerClient::FloatColor& in, - aidl::android::hardware::graphics::composer3::FloatColor* out) { - out->r = static_cast(in.r); - out->g = static_cast(in.g); - out->b = static_cast(in.b); - out->a = static_cast(in.a); - return true; -} - -__attribute__((warn_unused_result)) bool translate( - const ::android::hardware::graphics::composer::V2_3::IComposerClient::PerFrameMetadataBlob& - in, - aidl::android::hardware::graphics::composer3::PerFrameMetadataBlob* out) { - out->key = - static_cast(in.key); - { - size_t size = in.blob.size(); - for (size_t i = 0; i < size; i++) { - // FIXME This requires conversion between signed and unsigned. Change this if it doesn't - // suit your needs. - if (in.blob[i] > std::numeric_limits::max() || in.blob[i] < 0) { - return false; - } - out->blob.push_back(static_cast(in.blob[i])); - } - } - return true; -} - -__attribute__((warn_unused_result)) bool translate( - const ::android::hardware::graphics::composer::V2_4::IComposerClient:: - VsyncPeriodChangeConstraints& in, - aidl::android::hardware::graphics::composer3::VsyncPeriodChangeConstraints* out) { - out->desiredTimeNanos = static_cast(in.desiredTimeNanos); - out->seamlessRequired = static_cast(in.seamlessRequired); - return true; -} - -__attribute__((warn_unused_result)) bool translate( - const ::android::hardware::graphics::composer::V2_4::IComposerClient::ClientTargetProperty& - in, - aidl::android::hardware::graphics::composer3::ClientTargetProperty* out) { - out->pixelFormat = - static_cast(in.pixelFormat); - out->dataspace = - static_cast(in.dataspace); - return true; -} - } // namespace android::h2a diff --git a/graphics/composer/aidl/include/android/hardware/graphics/composer3/translate-ndk.h b/graphics/composer/aidl/include/android/hardware/graphics/composer3/translate-ndk.h deleted file mode 100644 index 3a92ae61d0..0000000000 --- a/graphics/composer/aidl/include/android/hardware/graphics/composer3/translate-ndk.h +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Copyright (c) 2021, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include -#include "aidl/android/hardware/graphics/common/BlendMode.h" -#include "aidl/android/hardware/graphics/common/FRect.h" -#include "aidl/android/hardware/graphics/common/Rect.h" -#include "aidl/android/hardware/graphics/composer3/Capability.h" -#include "aidl/android/hardware/graphics/composer3/ClientTargetProperty.h" -#include "aidl/android/hardware/graphics/composer3/Color.h" -#include "aidl/android/hardware/graphics/composer3/Composition.h" -#include "aidl/android/hardware/graphics/composer3/ContentType.h" -#include "aidl/android/hardware/graphics/composer3/DisplayAttribute.h" -#include "aidl/android/hardware/graphics/composer3/DisplayCapability.h" -#include "aidl/android/hardware/graphics/composer3/DisplayConnectionType.h" -#include "aidl/android/hardware/graphics/composer3/FloatColor.h" -#include "aidl/android/hardware/graphics/composer3/FormatColorComponent.h" -#include "aidl/android/hardware/graphics/composer3/IComposer.h" -#include "aidl/android/hardware/graphics/composer3/PerFrameMetadata.h" -#include "aidl/android/hardware/graphics/composer3/PerFrameMetadataBlob.h" -#include "aidl/android/hardware/graphics/composer3/PerFrameMetadataKey.h" -#include "aidl/android/hardware/graphics/composer3/PowerMode.h" -#include "aidl/android/hardware/graphics/composer3/VsyncPeriodChangeConstraints.h" -#include "aidl/android/hardware/graphics/composer3/VsyncPeriodChangeTimeline.h" -#include "android/hardware/graphics/composer/2.1/IComposer.h" -#include "android/hardware/graphics/composer/2.1/IComposerCallback.h" -#include "android/hardware/graphics/composer/2.1/IComposerClient.h" -#include "android/hardware/graphics/composer/2.2/IComposerClient.h" -#include "android/hardware/graphics/composer/2.3/IComposerClient.h" -#include "android/hardware/graphics/composer/2.4/IComposerClient.h" -#include "android/hardware/graphics/composer/2.4/types.h" - -namespace android::h2a { - -__attribute__((warn_unused_result)) bool translate( - const ::android::hardware::graphics::composer::V2_4::VsyncPeriodChangeTimeline& in, - aidl::android::hardware::graphics::composer3::VsyncPeriodChangeTimeline* out); -__attribute__((warn_unused_result)) bool translate( - const ::android::hardware::graphics::composer::V2_1::IComposerClient::Rect& in, - aidl::android::hardware::graphics::common::Rect* out); -__attribute__((warn_unused_result)) bool translate( - const ::android::hardware::graphics::composer::V2_1::IComposerClient::FRect& in, - aidl::android::hardware::graphics::common::FRect* out); -__attribute__((warn_unused_result)) bool translate( - const ::android::hardware::graphics::composer::V2_1::IComposerClient::Color& in, - aidl::android::hardware::graphics::composer3::Color* out); -__attribute__((warn_unused_result)) bool translate( - const ::android::hardware::graphics::composer::V2_3::IComposerClient::PerFrameMetadata& in, - aidl::android::hardware::graphics::composer3::PerFrameMetadata* out); -__attribute__((warn_unused_result)) bool translate( - const ::android::hardware::graphics::composer::V2_2::IComposerClient::FloatColor& in, - aidl::android::hardware::graphics::composer3::FloatColor* out); -__attribute__((warn_unused_result)) bool translate( - const ::android::hardware::graphics::composer::V2_3::IComposerClient::PerFrameMetadataBlob& - in, - aidl::android::hardware::graphics::composer3::PerFrameMetadataBlob* out); -__attribute__((warn_unused_result)) bool translate( - const ::android::hardware::graphics::composer::V2_4::IComposerClient:: - VsyncPeriodChangeConstraints& in, - aidl::android::hardware::graphics::composer3::VsyncPeriodChangeConstraints* out); -__attribute__((warn_unused_result)) bool translate( - const ::android::hardware::graphics::composer::V2_4::IComposerClient::ClientTargetProperty& - in, - aidl::android::hardware::graphics::composer3::ClientTargetProperty* out); - -} // namespace android::h2a