aboutsummaryrefslogtreecommitdiff
path: root/system/hwc3/GuestFrameComposer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'system/hwc3/GuestFrameComposer.cpp')
-rw-r--r--system/hwc3/GuestFrameComposer.cpp67
1 files changed, 25 insertions, 42 deletions
diff --git a/system/hwc3/GuestFrameComposer.cpp b/system/hwc3/GuestFrameComposer.cpp
index f4333fc1..f4c92678 100644
--- a/system/hwc3/GuestFrameComposer.cpp
+++ b/system/hwc3/GuestFrameComposer.cpp
@@ -802,11 +802,12 @@ HWC3::Error GuestFrameComposer::presentDisplay(
continue;
}
- HWC3::Error error = composeLayerInto(layer, //
- compositionResultBufferData, //
- compositionResultBufferWidth, //
- compositionResultBufferHeight, //
- compositionResultBufferStride, //
+ HWC3::Error error = composeLayerInto(displayInfo.compositionIntermediateStorage, //
+ layer, //
+ compositionResultBufferData, //
+ compositionResultBufferWidth, //
+ compositionResultBufferHeight, //
+ compositionResultBufferStride, //
4);
if (error != HWC3::Error::None) {
ALOGE("%s: display:%" PRIu32 " failed to compose layer:%" PRIu64, __FUNCTION__,
@@ -878,12 +879,14 @@ bool GuestFrameComposer::canComposeLayer(Layer* layer) {
return true;
}
-HWC3::Error GuestFrameComposer::composeLayerInto(Layer* srcLayer, //
- std::uint8_t* dstBuffer, //
- std::uint32_t dstBufferWidth, //
- std::uint32_t dstBufferHeight, //
- std::uint32_t dstBufferStrideBytes, //
- std::uint32_t dstBufferBytesPerPixel) {
+HWC3::Error GuestFrameComposer::composeLayerInto(
+ AlternatingImageStorage& compositionIntermediateStorage,
+ Layer* srcLayer, //
+ std::uint8_t* dstBuffer, //
+ std::uint32_t dstBufferWidth, //
+ std::uint32_t dstBufferHeight, //
+ std::uint32_t dstBufferStrideBytes, //
+ std::uint32_t dstBufferBytesPerPixel) {
ATRACE_CALL();
libyuv::RotationMode rotation = GetRotationFromTransform(srcLayer->getTransform());
@@ -955,10 +958,10 @@ HWC3::Error GuestFrameComposer::composeLayerInto(Layer* srcLayer,
// framebuffer) is one of them, so only N-1 temporary buffers are needed.
// Vertical flip is not taken into account because it can be done together
// with any other operation.
- int neededScratchBuffers = (needsFill ? 1 : 0) + (needsConversion ? 1 : 0) +
- (needsScaling ? 1 : 0) + (needsRotation ? 1 : 0) +
- (needsAttenuation ? 1 : 0) + (needsBlending ? 1 : 0) +
- (needsCopy ? 1 : 0) - 1;
+ int neededIntermediateImages = (needsFill ? 1 : 0) + (needsConversion ? 1 : 0) +
+ (needsScaling ? 1 : 0) + (needsRotation ? 1 : 0) +
+ (needsAttenuation ? 1 : 0) + (needsBlending ? 1 : 0) +
+ (needsCopy ? 1 : 0) - 1;
uint32_t mScratchBufferWidth =
static_cast<uint32_t>(srcLayerDisplayFrame.right - srcLayerDisplayFrame.left);
@@ -968,10 +971,10 @@ HWC3::Error GuestFrameComposer::composeLayerInto(Layer* srcLayer,
AlignToPower2(mScratchBufferWidth * dstBufferBytesPerPixel, 4);
uint32_t mScratchBufferSizeBytes = mScratchBufferHeight * mScratchBufferStrideBytes;
- for (uint32_t i = 0; i < neededScratchBuffers; i++) {
- BufferSpec mScratchBufferspec(getRotatingScratchBuffer(mScratchBufferSizeBytes, i),
- mScratchBufferWidth, mScratchBufferHeight,
- mScratchBufferStrideBytes);
+ for (uint32_t i = 0; i < neededIntermediateImages; i++) {
+ BufferSpec mScratchBufferspec(
+ compositionIntermediateStorage.getRotatingScratchBuffer(mScratchBufferSizeBytes, i),
+ mScratchBufferWidth, mScratchBufferHeight, mScratchBufferStrideBytes);
dstBufferStack.push_back(mScratchBufferspec);
}
@@ -1004,7 +1007,7 @@ HWC3::Error GuestFrameComposer::composeLayerInto(Layer* srcLayer,
uint32_t srcWidth = srcLayerSpec.cropWidth;
uint32_t srcHeight = srcLayerSpec.cropHeight;
uint32_t dst_stride_bytes = AlignToPower2(srcWidth * dstBufferBytesPerPixel, 4);
- uint32_t needed_size = dst_stride_bytes * srcHeight;
+ uint32_t neededSize = dst_stride_bytes * srcHeight;
dstBufferSpec.width = srcWidth;
dstBufferSpec.height = srcHeight;
// Adjust the stride accordingly
@@ -1016,7 +1019,8 @@ HWC3::Error GuestFrameComposer::composeLayerInto(Layer* srcLayer,
// In case of a scale, the source frame may be bigger than the default tmp
// buffer size
- dstBufferSpec.buffer = getSpecialScratchBuffer(needed_size);
+ dstBufferSpec.buffer =
+ compositionIntermediateStorage.getSpecialScratchBuffer(neededSize);
}
int retval = DoConversion(srcLayerSpec, dstBufferSpec, needsVFlip);
@@ -1136,25 +1140,4 @@ HWC3::Error GuestFrameComposer::applyColorTransformToRGBA(
return HWC3::Error::None;
}
-uint8_t* GuestFrameComposer::getRotatingScratchBuffer(std::size_t neededSize, std::uint32_t order) {
- static constexpr const int kNumScratchBufferPieces = 2;
-
- std::size_t totalNeededSize = neededSize * kNumScratchBufferPieces;
- if (mScratchBuffer.size() < totalNeededSize) {
- mScratchBuffer.resize(totalNeededSize);
- }
-
- std::size_t bufferIndex = order % kNumScratchBufferPieces;
- std::size_t bufferOffset = bufferIndex * neededSize;
- return &mScratchBuffer[bufferOffset];
-}
-
-uint8_t* GuestFrameComposer::getSpecialScratchBuffer(size_t neededSize) {
- if (mSpecialScratchBuffer.size() < neededSize) {
- mSpecialScratchBuffer.resize(neededSize);
- }
-
- return &mSpecialScratchBuffer[0];
-}
-
} // namespace aidl::android::hardware::graphics::composer3::impl