Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8e31b585 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove beginCommand variants with a helper template."

parents 77883fe5 96ee56bc
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -403,6 +403,11 @@ class CommandWriterBase {
    }

   protected:
     template <typename T>
     void beginCommand(T command, uint16_t length) {
         beginCommandBase(static_cast<IComposerClient::Command>(command), length);
     }

    void setClientTargetInternal(uint32_t slot, const native_handle_t* target, int acquireFence,
                                 int32_t dataspace,
                                 const std::vector<IComposerClient::Rect>& damage) {
@@ -429,7 +434,7 @@ class CommandWriterBase {
        endCommand();
    }

    void beginCommand(IComposerClient::Command command, uint16_t length) {
    void beginCommandBase(IComposerClient::Command command, uint16_t length) {
        if (mCommandEnd) {
            LOG_FATAL("endCommand was not called before command 0x%x", command);
        }
+3 −10
Original line number Diff line number Diff line
@@ -76,14 +76,13 @@ class CommandWriterBase : public V2_1::CommandWriterBase {

    static constexpr uint16_t kSetLayerFloatColorLength = 4;
    void setLayerFloatColor(IComposerClient::FloatColor color) {
        beginCommand_2_2(IComposerClient::Command::SET_LAYER_FLOAT_COLOR,
                         kSetLayerFloatColorLength);
        beginCommand(IComposerClient::Command::SET_LAYER_FLOAT_COLOR, kSetLayerFloatColorLength);
        writeFloatColor(color);
        endCommand();
    }

    void setLayerPerFrameMetadata(const hidl_vec<IComposerClient::PerFrameMetadata>& metadataVec) {
        beginCommand_2_2(IComposerClient::Command::SET_LAYER_PER_FRAME_METADATA,
        beginCommand(IComposerClient::Command::SET_LAYER_PER_FRAME_METADATA,
                     metadataVec.size() * 2);
        for (const auto& metadata : metadataVec) {
            writeSigned(static_cast<int32_t>(metadata.key));
@@ -99,12 +98,6 @@ class CommandWriterBase : public V2_1::CommandWriterBase {
        writeFloat(color.b);
        writeFloat(color.a);
    }

  private:
    void beginCommand_2_2(IComposerClient::Command command, uint16_t length) {
        V2_1::CommandWriterBase::beginCommand(
                static_cast<V2_1::IComposerClient::Command>(static_cast<int32_t>(command)), length);
    }
};

// This class helps parse a command queue.  Note that all sizes/lengths are in
+5 −11
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ using android::hardware::graphics::composer::V2_3::IComposerClient;
class CommandWriterBase : public V2_2::CommandWriterBase {
   public:
    void setLayerPerFrameMetadata(const hidl_vec<IComposerClient::PerFrameMetadata>& metadataVec) {
        beginCommand_2_3(IComposerClient::Command::SET_LAYER_PER_FRAME_METADATA,
        beginCommand(IComposerClient::Command::SET_LAYER_PER_FRAME_METADATA,
                     metadataVec.size() * 2);
        for (const auto& metadata : metadataVec) {
            writeSigned(static_cast<int32_t>(metadata.key));
@@ -69,7 +69,7 @@ class CommandWriterBase : public V2_2::CommandWriterBase {

    static constexpr uint16_t kSetLayerColorTransformLength = 16;
    void setLayerColorTransform(const float* matrix) {
        beginCommand_2_3(IComposerClient::Command::SET_LAYER_COLOR_TRANSFORM,
        beginCommand(IComposerClient::Command::SET_LAYER_COLOR_TRANSFORM,
                     kSetLayerColorTransformLength);
        for (int i = 0; i < 16; i++) {
            writeFloat(matrix[i]);
@@ -109,7 +109,7 @@ class CommandWriterBase : public V2_2::CommandWriterBase {
        // Blobs are written as:
        // {numElements, key1, size1, blob1, key2, size2, blob2, key3, size3...}
        uint16_t length = static_cast<uint16_t>(commandLength);
        beginCommand_2_3(IComposerClient::Command::SET_LAYER_PER_FRAME_METADATA_BLOBS, length);
        beginCommand(IComposerClient::Command::SET_LAYER_PER_FRAME_METADATA_BLOBS, length);
        write(static_cast<uint32_t>(metadata.size()));
        for (auto metadataBlob : metadata) {
            writeSigned(static_cast<int32_t>(metadataBlob.key));
@@ -126,12 +126,6 @@ class CommandWriterBase : public V2_2::CommandWriterBase {
        mDataWritten += numElements;
        mDataWritten += (length - (numElements * 4) > 0) ? 1 : 0;
    }

  private:
    void beginCommand_2_3(IComposerClient::Command command, uint16_t length) {
        V2_1::CommandWriterBase::beginCommand(
                static_cast<V2_1::IComposerClient::Command>(static_cast<int32_t>(command)), length);
    }
};

// This class helps parse a command queue.  Note that all sizes/lengths are in