1 /* 2 * Copyright (c) 2021-2023 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 ROSEN_RENDER_SERVICE_BASE_COMMAND_RS_COMMAND_H 17 #define ROSEN_RENDER_SERVICE_BASE_COMMAND_RS_COMMAND_H 18 19 #include <parcel.h> 20 #include <refbase.h> 21 22 #include "common/rs_common_def.h" 23 #include "pipeline/rs_context.h" 24 25 namespace OHOS { 26 namespace Rosen { 27 28 enum RSCommandType : uint16_t { 29 // node commands 30 BASE_NODE, 31 RS_NODE, // formerly RSPropertyNode 32 CANVAS_NODE, // formerly RSNode 33 SURFACE_NODE, 34 PROXY_NODE, 35 ROOT_NODE, 36 DISPLAY_NODE, 37 // animation commands 38 ANIMATION, 39 // read showing properties (deprecated, will be removed later) 40 RS_NODE_SYNCHRONOUS_READ_PROPERTY, 41 }; 42 43 class RSCommand : public Parcelable { 44 public: 45 virtual ~RSCommand() noexcept = default; 46 virtual void Process(RSContext& context) = 0; 47 GetType()48 virtual uint16_t GetType() const 49 { 50 return 0; 51 } 52 GetSubType()53 virtual uint16_t GetSubType() const 54 { 55 return 0; 56 } 57 PrintType()58 std::string PrintType() const 59 { 60 return "commandType:[" + std::to_string(GetType()) + ", " + std::to_string(GetSubType()) + "], "; 61 } 62 }; 63 64 class RSSyncTask : public RSCommand { 65 public: RSSyncTask(uint64_t timeoutNS)66 RSSyncTask(uint64_t timeoutNS) : timeoutNS_(timeoutNS) {} 67 68 virtual bool CheckHeader(Parcel& parcel) const = 0; 69 virtual bool ReadFromParcel(Parcel& parcel) = 0; 70 GetTimeout()71 inline uint64_t GetTimeout() const 72 { 73 return timeoutNS_; 74 } GetResult()75 inline bool GetResult() const 76 { 77 return result_; 78 } 79 80 protected: 81 uint64_t timeoutNS_ = 0; 82 bool result_ = false; 83 }; 84 85 } // namespace Rosen 86 } // namespace OHOS 87 88 #endif // ROSEN_RENDER_SERVICE_BASE_COMMAND_RS_COMMAND_H 89