166f3657fSopenharmony_ci/*
266f3657fSopenharmony_ci * Copyright (c) 2022-2024 Huawei Device Co., Ltd.
366f3657fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
466f3657fSopenharmony_ci * you may not use this file except in compliance with the License.
566f3657fSopenharmony_ci * You may obtain a copy of the License at
666f3657fSopenharmony_ci *
766f3657fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
866f3657fSopenharmony_ci *
966f3657fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1066f3657fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1166f3657fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1266f3657fSopenharmony_ci * See the License for the specific language governing permissions and
1366f3657fSopenharmony_ci * limitations under the License.
1466f3657fSopenharmony_ci */
1566f3657fSopenharmony_ci
1666f3657fSopenharmony_ci#ifndef OHOS_DATA_BUFFER_H
1766f3657fSopenharmony_ci#define OHOS_DATA_BUFFER_H
1866f3657fSopenharmony_ci
1966f3657fSopenharmony_ci#include <cstdint>
2066f3657fSopenharmony_ci#include <cstddef>
2166f3657fSopenharmony_ci#include <vector>
2266f3657fSopenharmony_ci
2366f3657fSopenharmony_ci#include "dscreen_constants.h"
2466f3657fSopenharmony_ci
2566f3657fSopenharmony_cinamespace OHOS {
2666f3657fSopenharmony_cinamespace DistributedHardware {
2766f3657fSopenharmony_cistruct DirtyRect {
2866f3657fSopenharmony_ci    uint32_t xPos;
2966f3657fSopenharmony_ci    uint32_t yPos;
3066f3657fSopenharmony_ci    uint32_t width;
3166f3657fSopenharmony_ci    uint32_t height;
3266f3657fSopenharmony_ci    uint32_t dirtySize;
3366f3657fSopenharmony_ci};
3466f3657fSopenharmony_ciclass DataBuffer {
3566f3657fSopenharmony_cipublic:
3666f3657fSopenharmony_ci    explicit DataBuffer(size_t capacity);
3766f3657fSopenharmony_ci    ~DataBuffer();
3866f3657fSopenharmony_ci
3966f3657fSopenharmony_ci    size_t Capacity() const;
4066f3657fSopenharmony_ci    uint8_t *Data() const;
4166f3657fSopenharmony_ci    void SetSize(size_t size);
4266f3657fSopenharmony_ci    void SetDataType(uint8_t dataType);
4366f3657fSopenharmony_ci    uint8_t DataType();
4466f3657fSopenharmony_ci    void SetDataNumber(size_t number);
4566f3657fSopenharmony_ci    size_t DataNumber();
4666f3657fSopenharmony_ci    void ResetCapcity(size_t capacity);
4766f3657fSopenharmony_ci    void AddData(size_t dataSize, unsigned char* &inputData);
4866f3657fSopenharmony_ci    void AddDirtyRect(DirtyRect rec);
4966f3657fSopenharmony_ci    std::vector<DirtyRect> GetDirtyRectVec();
5066f3657fSopenharmony_ci    int32_t GetData(int32_t offset, int32_t datasize, uint8_t* &output);
5166f3657fSopenharmony_ciprivate:
5266f3657fSopenharmony_ci    static const constexpr char *DSCREEN_LOG_TAG = "DataBuffer";
5366f3657fSopenharmony_ci    std::vector<DirtyRect> dirtyRectVec_;
5466f3657fSopenharmony_ci    size_t capacity_ = 0;
5566f3657fSopenharmony_ci    uint8_t *data_ = nullptr;
5666f3657fSopenharmony_ci    uint8_t dataType_ = 0;
5766f3657fSopenharmony_ci    size_t frameNumber_ = 0;
5866f3657fSopenharmony_ci};
5966f3657fSopenharmony_ci} // namespace DistributedHardware
6066f3657fSopenharmony_ci} // namespace OHOS
6166f3657fSopenharmony_ci#endif