diff options
author | 2018-06-08 15:11:57 -0700 | |
---|---|---|
committer | 2018-06-08 15:11:57 -0700 | |
commit | f11e2bd016d886a333345dea853ebda23a408d5c (patch) | |
tree | 905bd4d25d6ab2b046620ff459777d8dcfa5d7de /libs/gui/HdrMetadata.cpp | |
parent | aabd6b7fa343654cd85b3b2da392e424d037d15a (diff) | |
parent | 5c947cdf72270fd1f766b2248d526ebc8c7227f6 (diff) |
Merge pi-dev-plus-aosp-without-vendor into stage-aosp-master
Bug: 79597307
Change-Id: I6d6bee71b9424eb478780bbfc06b830eb8ded342
Diffstat (limited to 'libs/gui/HdrMetadata.cpp')
-rw-r--r-- | libs/gui/HdrMetadata.cpp | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/libs/gui/HdrMetadata.cpp b/libs/gui/HdrMetadata.cpp new file mode 100644 index 0000000000..b715e431d5 --- /dev/null +++ b/libs/gui/HdrMetadata.cpp @@ -0,0 +1,97 @@ +/* + * Copyright 2018 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. + */ + +#include <gui/HdrMetadata.h> + +namespace android { + +size_t HdrMetadata::getFlattenedSize() const { + size_t size = sizeof(validTypes); + if (validTypes & SMPTE2086) { + size += sizeof(smpte2086); + } + if (validTypes & CTA861_3) { + size += sizeof(cta8613); + } + return size; +} + +status_t HdrMetadata::flatten(void* buffer, size_t size) const { + if (size < getFlattenedSize()) { + return NO_MEMORY; + } + + FlattenableUtils::write(buffer, size, validTypes); + if (validTypes & SMPTE2086) { + FlattenableUtils::write(buffer, size, smpte2086); + } + if (validTypes & CTA861_3) { + FlattenableUtils::write(buffer, size, cta8613); + } + + return NO_ERROR; +} + +status_t HdrMetadata::unflatten(void const* buffer, size_t size) { + if (size < sizeof(validTypes)) { + return NO_MEMORY; + } + FlattenableUtils::read(buffer, size, validTypes); + if (validTypes & SMPTE2086) { + if (size < sizeof(smpte2086)) { + return NO_MEMORY; + } + FlattenableUtils::read(buffer, size, smpte2086); + } + if (validTypes & CTA861_3) { + if (size < sizeof(cta8613)) { + return NO_MEMORY; + } + FlattenableUtils::read(buffer, size, cta8613); + } + + return NO_ERROR; +} + +bool HdrMetadata::operator==(const HdrMetadata& rhs) const { + if (validTypes != rhs.validTypes) return false; + + if ((validTypes & SMPTE2086) == SMPTE2086) { + if (smpte2086.displayPrimaryRed.x != rhs.smpte2086.displayPrimaryRed.x || + smpte2086.displayPrimaryRed.y != rhs.smpte2086.displayPrimaryRed.y || + smpte2086.displayPrimaryGreen.x != rhs.smpte2086.displayPrimaryGreen.x || + smpte2086.displayPrimaryGreen.y != rhs.smpte2086.displayPrimaryGreen.y || + smpte2086.displayPrimaryBlue.x != rhs.smpte2086.displayPrimaryBlue.x || + smpte2086.displayPrimaryBlue.y != rhs.smpte2086.displayPrimaryBlue.y || + smpte2086.whitePoint.x != rhs.smpte2086.whitePoint.x || + smpte2086.whitePoint.y != rhs.smpte2086.whitePoint.y || + smpte2086.maxLuminance != rhs.smpte2086.maxLuminance || + smpte2086.minLuminance != rhs.smpte2086.minLuminance) { + return false; + } + } + + if ((validTypes & CTA861_3) == CTA861_3) { + if (cta8613.maxFrameAverageLightLevel != rhs.cta8613.maxFrameAverageLightLevel || + cta8613.maxContentLightLevel != rhs.cta8613.maxContentLightLevel) { + return false; + } + } + + return true; +} + +} // namespace android |