1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FRAMEWORKS_BOOTANIMATION_INCLUDE_RAW_MAKER_H 17 #define FRAMEWORKS_BOOTANIMATION_INCLUDE_RAW_MAKER_H 18 19 #include <raw_parser.h> 20 21 #include <memory> 22 #include <fstream> 23 #include <string> 24 25 namespace OHOS { 26 class RawMaker { 27 public: 28 void SetFilename(const std::string &filename); 29 void SetWidth(uint32_t width); 30 void SetHeight(uint32_t height); 31 void SetHeaderType(RawHeaderType type); 32 int32_t WriteNextData(const uint8_t *addr); 33 34 private: 35 int32_t DoFirstFrame(); 36 int32_t PrepareInNone(); 37 int32_t PrepareInRaw(const uint8_t *addr); 38 int32_t PrepareInCompress(const uint8_t *addr); 39 int32_t UpdateLastFrame(const uint8_t *addr); 40 int32_t WriteData(); 41 void WriteInt32(int32_t integer); 42 void CompareWithLastFrame(const uint8_t *addr); 43 44 std::string filename = ""; 45 uint32_t width = 0; 46 uint32_t height = 0; 47 int32_t size = 0; 48 RawHeaderType type = RAW_HEADER_TYPE_NONE; 49 bool firstFrame = true; 50 std::ofstream ofs; 51 std::unique_ptr<uint8_t[]> lastFrame; 52 std::unique_ptr<uint8_t[]> compressed; 53 54 struct { 55 RawHeaderType type; 56 int32_t offset; 57 int32_t length; 58 int32_t compressedLength; 59 const uint8_t *data; 60 } writing; 61 }; 62 } // namespace OHOS 63 64 #endif // FRAMEWORKS_BOOTANIMATION_INCLUDE_RAW_MAKER_H 65