1 /* 2 * Copyright (c) 2022 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 #include "rs_window_animation_target.h" 17 18 #include "rs_window_animation_log.h" 19 20 #include "ui/rs_surface_node.h" 21 22 namespace OHOS { 23 namespace Rosen { Unmarshalling(Parcel & parcel)24RSWindowAnimationTarget* RSWindowAnimationTarget::Unmarshalling(Parcel& parcel) 25 { 26 auto windowAnimationTarget = new (std::nothrow) RSWindowAnimationTarget(); 27 if (windowAnimationTarget != nullptr && !windowAnimationTarget->ReadFromParcel(parcel)) { 28 WALOGE("Failed to unmarshalling window animation target!"); 29 delete windowAnimationTarget; 30 windowAnimationTarget = nullptr; 31 } 32 33 return windowAnimationTarget; 34 } 35 Marshalling(Parcel & parcel) const36bool RSWindowAnimationTarget::Marshalling(Parcel& parcel) const 37 { 38 parcel.WriteString(bundleName_); 39 parcel.WriteString(abilityName_); 40 parcel.WriteFloat(windowBounds_.rect_.left_); 41 parcel.WriteFloat(windowBounds_.rect_.top_); 42 parcel.WriteFloat(windowBounds_.rect_.width_); 43 parcel.WriteFloat(windowBounds_.rect_.height_); 44 parcel.WriteFloat(windowBounds_.radius_[0].x_); 45 // marshalling as RSSurfaceNode 46 if (auto surfaceNode = surfaceNode_->ReinterpretCastTo<RSSurfaceNode>()) { 47 surfaceNode->Marshalling(parcel); 48 } else { 49 return false; 50 } 51 parcel.WriteUint32(windowId_); 52 parcel.WriteUint64(displayId_); 53 parcel.WriteInt32(missionId_); 54 return true; 55 } 56 ReadFromParcel(Parcel & parcel)57bool RSWindowAnimationTarget::ReadFromParcel(Parcel& parcel) 58 { 59 bundleName_ = parcel.ReadString(); 60 abilityName_ = parcel.ReadString(); 61 windowBounds_.rect_.left_ = parcel.ReadFloat(); 62 windowBounds_.rect_.top_ = parcel.ReadFloat(); 63 windowBounds_.rect_.width_ = parcel.ReadFloat(); 64 windowBounds_.rect_.height_ = parcel.ReadFloat(); 65 windowBounds_.radius_[0].x_ = parcel.ReadFloat(); 66 // unmarshalling as RSProxyNode 67 surfaceNode_ = RSSurfaceNode::UnmarshallingAsProxyNode(parcel); 68 windowId_ = parcel.ReadUint32(); 69 displayId_ = parcel.ReadUint64(); 70 missionId_ = parcel.ReadInt32(); 71 return true; 72 } 73 } // namespace Rosen 74 } // namespace OHOS 75