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