1 /* 2 * Copyright (c) 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_NODE_SHOWING_COMMAND_H 17 #define ROSEN_RENDER_SERVICE_BASE_COMMAND_RS_NODE_SHOWING_COMMAND_H 18 19 #include <map> 20 21 #include "command/rs_command.h" 22 #include "command/rs_command_factory.h" 23 24 namespace OHOS { 25 namespace Rosen { 26 class RSRenderPropertyBase; 27 28 enum RSNodeShowingCommandType : uint16_t { 29 GET_RENDER_PROPERTY, 30 GET_RENDER_PROPERTIES, 31 }; 32 33 class RSB_EXPORT RSNodeGetShowingPropertyAndCancelAnimation : public RSSyncTask { 34 constexpr static uint16_t commandType = RS_NODE_SYNCHRONOUS_READ_PROPERTY; 35 constexpr static uint16_t commandSubType = GET_RENDER_PROPERTY; 36 37 public: 38 explicit RSNodeGetShowingPropertyAndCancelAnimation( 39 NodeId targetId, std::shared_ptr<RSRenderPropertyBase> property, uint64_t timeoutNS = 1e8) RSSyncTask(timeoutNS)40 : RSSyncTask(timeoutNS), targetId_(targetId), property_(property) 41 {} 42 ~RSNodeGetShowingPropertyAndCancelAnimation() override = default; 43 44 bool Marshalling(Parcel& parcel) const override; 45 static RSCommand* Unmarshalling(Parcel& parcel); 46 47 bool CheckHeader(Parcel& parcel) const override; 48 bool ReadFromParcel(Parcel& parcel) override; 49 50 void Process(RSContext& context) override; GetProperty()51 std::shared_ptr<RSRenderPropertyBase> GetProperty() const 52 { 53 return property_; 54 } IsTimeout()55 bool IsTimeout() const 56 { 57 return isTimeout_; 58 } 59 60 private: 61 NodeId targetId_ = 0; 62 std::shared_ptr<RSRenderPropertyBase> property_; 63 bool isTimeout_ = true; 64 static inline RSCommandRegister<commandType, commandSubType, Unmarshalling> registry; 65 }; 66 67 class RSB_EXPORT RSNodeGetShowingPropertiesAndCancelAnimation : public RSSyncTask { 68 constexpr static uint16_t commandType = RS_NODE_SYNCHRONOUS_READ_PROPERTY; 69 constexpr static uint16_t commandSubType = GET_RENDER_PROPERTIES; 70 71 public: 72 using PropertiesMap = std::map<std::pair<NodeId, PropertyId>, std::shared_ptr<RSRenderPropertyBase>>; RSNodeGetShowingPropertiesAndCancelAnimation(uint64_t timeoutNS,PropertiesMap && map)73 explicit RSNodeGetShowingPropertiesAndCancelAnimation(uint64_t timeoutNS, PropertiesMap&& map) 74 : RSSyncTask(timeoutNS), propertiesMap_(std::move(map)) 75 {} 76 ~RSNodeGetShowingPropertiesAndCancelAnimation() override = default; 77 78 bool Marshalling(Parcel& parcel) const override; 79 static RSCommand* Unmarshalling(Parcel& parcel); 80 81 bool CheckHeader(Parcel& parcel) const override; 82 bool ReadFromParcel(Parcel& parcel) override; 83 84 void Process(RSContext& context) override; 85 GetProperties()86 const PropertiesMap& GetProperties() const 87 { 88 return this->propertiesMap_; 89 } 90 91 private: RSNodeGetShowingPropertiesAndCancelAnimation(uint64_t timeoutNS)92 RSNodeGetShowingPropertiesAndCancelAnimation(uint64_t timeoutNS): RSSyncTask(timeoutNS) {} 93 PropertiesMap propertiesMap_; 94 static inline RSCommandRegister<commandType, commandSubType, Unmarshalling> registry; 95 }; 96 97 } // namespace Rosen 98 } // namespace OHOS 99 100 #endif // ROSEN_RENDER_SERVICE_BASE_COMMAND_RS_NODE_SHOWING_COMMAND_H