Revert "[hwc-batching] HWC changes for HWC-command batching support."

This reverts commit 82d6e4002c4166c46900448cb94ca2977a2b1373.

Reason for revert: Unusable next builds: b/319337934

Change-Id: Iffc36530ca12259f45d146e69305a69b1ce4cd9f
diff --git a/hwc3/ComposerCommandEngine.cpp b/hwc3/ComposerCommandEngine.cpp
index 8f21219..32ad027 100644
--- a/hwc3/ComposerCommandEngine.cpp
+++ b/hwc3/ComposerCommandEngine.cpp
@@ -93,48 +93,12 @@
     return ::android::NO_ERROR;
 }
 
-void ComposerCommandEngine::dispatchBatchCreateDestroyLayerCommand(int64_t display,
-                                                                   const LayerCommand& layerCmd) {
-    auto cmdType = layerCmd.layerLifecycleBatchCommandType;
-    if ((cmdType != LayerLifecycleBatchCommandType::CREATE) &&
-        (cmdType != LayerLifecycleBatchCommandType::DESTROY)) {
-        return;
-    }
-    auto err = mHal->batchedCreateDestroyLayer(display, layerCmd.layer, cmdType);
-    if (err) {
-        mWriter->setError(mCommandIndex, err);
-        return;
-    }
-
-    if (cmdType == LayerLifecycleBatchCommandType::CREATE) {
-        err = mResources->addLayer(display, layerCmd.layer, layerCmd.newBufferSlotCount);
-    } else {
-        err = mResources->removeLayer(display, layerCmd.layer);
-    }
-
-    if (err) {
-        mWriter->setError(mCommandIndex, err);
-    }
-}
-
 void ComposerCommandEngine::dispatchDisplayCommand(const DisplayCommand& command) {
-    // place batched createLayer commands before any other commands, so layers are
-    // properly created to operate on.
-    for (const auto& layerCmd : command.layers) {
-        if (layerCmd.layerLifecycleBatchCommandType == LayerLifecycleBatchCommandType::CREATE ||
-            layerCmd.layerLifecycleBatchCommandType == LayerLifecycleBatchCommandType::DESTROY) {
-            dispatchBatchCreateDestroyLayerCommand(command.display, layerCmd);
-        }
-    }
-
     //  place SetDisplayBrightness before SetLayerWhitePointNits since current
     //  display brightness is used to validate the layer white point nits.
     DISPATCH_DISPLAY_COMMAND(command, brightness, SetDisplayBrightness);
     for (const auto& layerCmd : command.layers) {
-        // ignore layer data update if command is DESTROY
-        if (layerCmd.layerLifecycleBatchCommandType != LayerLifecycleBatchCommandType::DESTROY) {
-            dispatchLayerCommand(command.display, layerCmd);
-        }
+        dispatchLayerCommand(command.display, layerCmd);
     }
 
     DISPATCH_DISPLAY_COMMAND(command, colorTransformMatrix, SetColorTransform);
diff --git a/hwc3/ComposerCommandEngine.h b/hwc3/ComposerCommandEngine.h
index 62dfd57..1ec110e 100644
--- a/hwc3/ComposerCommandEngine.h
+++ b/hwc3/ComposerCommandEngine.h
@@ -46,7 +46,7 @@
   private:
       void dispatchDisplayCommand(const DisplayCommand& displayCommand);
       void dispatchLayerCommand(int64_t display, const LayerCommand& displayCommand);
-      void dispatchBatchCreateDestroyLayerCommand(int64_t display, const LayerCommand& cmd);
+
       void executeSetColorTransform(int64_t display, const std::vector<float>& matrix);
       void executeSetClientTarget(int64_t display, const ClientTarget& command);
       void executeSetDisplayBrightness(uint64_t display, const DisplayBrightness& command);
diff --git a/hwc3/impl/HalImpl.cpp b/hwc3/impl/HalImpl.cpp
index c9d9b35..cc9303e 100644
--- a/hwc3/impl/HalImpl.cpp
+++ b/hwc3/impl/HalImpl.cpp
@@ -154,7 +154,6 @@
 
     mCaps.insert(Capability::BOOT_DISPLAY_CONFIG);
     mCaps.insert(Capability::REFRESH_RATE_CHANGED_CALLBACK_DEBUG);
-    mCaps.insert(Capability::LAYER_LIFECYCLE_BATCH_COMMAND);
 }
 
 int32_t HalImpl::getHalDisplay(int64_t display, ExynosDisplay*& halDisplay) {
@@ -171,9 +170,10 @@
 int32_t HalImpl::getHalLayer(int64_t display, int64_t layer, ExynosLayer*& halLayer) {
     ExynosDisplay* halDisplay;
     RET_IF_ERR(getHalDisplay(display, halDisplay));
-    hwc2_layer_t mapped_layer;
-    RET_IF_ERR(layerSf2Hwc(display, layer, mapped_layer));
-    halLayer = halDisplay->checkLayer(mapped_layer);
+
+    hwc2_layer_t hwcLayer;
+    a2h::translate(layer, hwcLayer);
+    halLayer = halDisplay->checkLayer(hwcLayer);
     if (!halLayer) { [[unlikely]]
         return HWC2_ERROR_BAD_LAYER;
     }
@@ -181,17 +181,6 @@
     return HWC2_ERROR_NONE;
 }
 
-int32_t HalImpl::layerSf2Hwc(int64_t display, int64_t layer, hwc2_layer_t& outMappedLayer) {
-    ExynosDisplay* halDisplay;
-    RET_IF_ERR(getHalDisplay(display, halDisplay));
-    auto iter = mSfLayerToHalLayerMap.find(layer);
-    if (iter == mSfLayerToHalLayerMap.end()) {
-        return HWC2_ERROR_BAD_LAYER;
-    }
-    outMappedLayer = iter->second;
-    return HWC2_ERROR_NONE;
-}
-
 bool HalImpl::hasCapability(Capability cap) {
     return mCaps.find(cap) != mCaps.end();
 }
@@ -266,66 +255,14 @@
     return HWC2_ERROR_NONE;
 }
 
-int32_t HalImpl::batchedCreateDestroyLayer(int64_t display, int64_t layer,
-                                           LayerLifecycleBatchCommandType cmd) {
-    int32_t err = HWC2_ERROR_NONE;
-    ExynosDisplay* halDisplay;
-    RET_IF_ERR(getHalDisplay(display, halDisplay));
-
-    if (cmd == LayerLifecycleBatchCommandType::CREATE) {
-        if (mSfLayerToHalLayerMap.find(layer) != mSfLayerToHalLayerMap.end()) {
-            return HWC2_ERROR_BAD_LAYER;
-        }
-        hwc2_layer_t hwcLayer = 0;
-        RET_IF_ERR(halDisplay->createLayer(&hwcLayer));
-        int64_t hwclayerAidl;
-        h2a::translate(hwcLayer, hwclayerAidl);
-        mSfLayerToHalLayerMap[layer] = hwclayerAidl;
-
-        mHalLayerToSfLayerMap[hwcLayer] = layer;
-    } else if (cmd == LayerLifecycleBatchCommandType::DESTROY) {
-        int64_t HalLayerAidl;
-        ExynosLayer* halLayer;
-        auto iter = mSfLayerToHalLayerMap.find(layer);
-        if (iter == mSfLayerToHalLayerMap.end()) {
-            return HWC2_ERROR_BAD_LAYER;
-        }
-        HalLayerAidl = iter->second;
-
-        RET_IF_ERR(getHalLayer(display, layer, halLayer));
-        err = halDisplay->destroyLayer(reinterpret_cast<hwc2_layer_t>(halLayer));
-        if (err != HWC2_ERROR_NONE) {
-            ALOGW("HalImpl: destroyLayer failed with error: %u", err);
-        }
-        mSfLayerToHalLayerMap.erase(iter);
-        auto iterator = mHalLayerToSfLayerMap.find(reinterpret_cast<hwc2_layer_t>(halLayer));
-        if (iterator == mHalLayerToSfLayerMap.end()) {
-            return HWC2_ERROR_BAD_LAYER;
-        }
-
-        mHalLayerToSfLayerMap.erase(iterator);
-    }
-    return err;
-}
-
 int32_t HalImpl::destroyLayer(int64_t display, int64_t layer) {
-    int32_t err = HWC2_ERROR_NONE;
     ExynosDisplay* halDisplay;
     RET_IF_ERR(getHalDisplay(display, halDisplay));
 
     ExynosLayer *halLayer;
     RET_IF_ERR(getHalLayer(display, layer, halLayer));
 
-    err = halDisplay->destroyLayer(reinterpret_cast<hwc2_layer_t>(halLayer));
-    auto iter = mSfLayerToHalLayerMap.find(layer);
-    if (iter != mSfLayerToHalLayerMap.end()) {
-        mSfLayerToHalLayerMap.erase(iter);
-    }
-    auto iterator = mHalLayerToSfLayerMap.find(reinterpret_cast<hwc2_layer_t>(halLayer));
-    if (iterator != mHalLayerToSfLayerMap.end()) {
-        mHalLayerToSfLayerMap.erase(iterator);
-    }
-    return err;
+    return halDisplay->destroyLayer(reinterpret_cast<hwc2_layer_t>(halLayer));
 }
 
 int32_t HalImpl::createVirtualDisplay(uint32_t width, uint32_t height, AidlPixelFormat format,
@@ -736,17 +673,7 @@
     std::vector<int32_t> hwcFences(count);
     RET_IF_ERR(halDisplay->getReleaseFences(&count, hwcLayers.data(), hwcFences.data()));
 
-    std::vector<int64_t> sfLayers(count);
-
-    for (int i = 0; i < count; i++) {
-        auto iter = mHalLayerToSfLayerMap.find(hwcLayers[i]);
-        if (iter != mHalLayerToSfLayerMap.end()) {
-            sfLayers[i] = iter->second;
-        } else {
-            LOG(ERROR) << "HalImpl::presentDisplay incorrect hal mapping. ";
-        }
-    }
-    h2a::translate(sfLayers, *outLayers);
+    h2a::translate(hwcLayers, *outLayers);
     h2a::translate(hwcFences, *outReleaseFences);
 
     return HWC2_ERROR_NONE;
diff --git a/hwc3/impl/HalImpl.h b/hwc3/impl/HalImpl.h
index a705f74..6a0108a 100644
--- a/hwc3/impl/HalImpl.h
+++ b/hwc3/impl/HalImpl.h
@@ -16,12 +16,9 @@
 
 #pragma once
 
-#include <map>
 #include <memory>
 #include <unordered_set>
 
-#include <hardware/hwcomposer2.h>
-
 #include "include/IComposerHal.h"
 
 class ExynosDevice;
@@ -48,8 +45,6 @@
 
     int32_t acceptDisplayChanges(int64_t display) override;
     int32_t createLayer(int64_t display, int64_t* outLayer) override;
-    int32_t batchedCreateDestroyLayer(int64_t display, int64_t layer,
-                                      LayerLifecycleBatchCommandType cmd) override;
     int32_t createVirtualDisplay(uint32_t width, uint32_t height, AidlPixelFormat format,
                                  VirtualDisplay* outDisplay) override;
     int32_t destroyLayer(int64_t display, int64_t layer) override;
@@ -170,7 +165,6 @@
 
     EventCallback* getEventCallback() { return mEventCallback; }
     int32_t setRefreshRateChangedCallbackDebugEnabled(int64_t display, bool enabled) override;
-    int32_t layerSf2Hwc(int64_t display, int64_t layer, hwc2_layer_t& outMappedLayer) override;
 
 private:
     void initCaps();
@@ -183,8 +177,6 @@
     std::unique_ptr<ExynosHWCCtx> mHwcCtx;
 #endif
     std::unordered_set<Capability> mCaps;
-    std::map<int64_t, hwc2_layer_t> mSfLayerToHalLayerMap;
-    std::map<hwc2_layer_t, int64_t> mHalLayerToSfLayerMap;
 };
 
 } // namespace aidl::android::hardware::graphics::composer3::impl
diff --git a/hwc3/include/IComposerHal.h b/hwc3/include/IComposerHal.h
index 2106a63..2387973 100644
--- a/hwc3/include/IComposerHal.h
+++ b/hwc3/include/IComposerHal.h
@@ -59,7 +59,6 @@
 #include <aidl/android/hardware/graphics/composer3/HdrCapabilities.h>
 #include <aidl/android/hardware/graphics/composer3/LayerBrightness.h>
 #include <aidl/android/hardware/graphics/composer3/LayerCommand.h>
-#include <aidl/android/hardware/graphics/composer3/LayerLifecycleBatchCommandType.h>
 #include <aidl/android/hardware/graphics/composer3/OverlayProperties.h>
 #include <aidl/android/hardware/graphics/composer3/ParcelableBlendMode.h>
 #include <aidl/android/hardware/graphics/composer3/ParcelableComposition.h>
@@ -81,7 +80,6 @@
 #include <aidl/android/hardware/graphics/composer3/VsyncPeriodChangeTimeline.h>
 #include <aidl/android/hardware/graphics/composer3/ZOrder.h>
 #include <cutils/native_handle.h>
-#include <hardware/hwcomposer2.h>
 
 // avoid naming conflict
 using AidlPixelFormat = aidl::android::hardware::graphics::common::PixelFormat;
@@ -118,8 +116,6 @@
 
     virtual int32_t acceptDisplayChanges(int64_t display) = 0;
     virtual int32_t createLayer(int64_t display, int64_t* outLayer) = 0;
-    virtual int32_t batchedCreateDestroyLayer(int64_t display, int64_t layer,
-                                              LayerLifecycleBatchCommandType cmd) = 0;
     virtual int32_t createVirtualDisplay(uint32_t width, uint32_t height, AidlPixelFormat format,
                                          VirtualDisplay* outDisplay) = 0;
     virtual int32_t destroyLayer(int64_t display, int64_t layer) = 0;
@@ -245,7 +241,6 @@
             int64_t display, int64_t layer,
             const std::vector<std::optional<common::Rect>>& blockingRegion) = 0;
     virtual int32_t setRefreshRateChangedCallbackDebugEnabled(int64_t display, bool enabled) = 0;
-    virtual int32_t layerSf2Hwc(int64_t display, int64_t layer, hwc2_layer_t& outMappedLayer) = 0;
 };
 
 } // namespace aidl::android::hardware::graphics::composer3::detail