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 (!surfaceNode_) { 47 parcel.WriteBool(false); 48 } else if (auto surfaceNode = surfaceNode_->ReinterpretCastTo<RSSurfaceNode>()) { 49 parcel.WriteBool(true); 50 surfaceNode->Marshalling(parcel); 51 } else { 52 return false; 53 } 54 parcel.WriteUint32(windowId_); 55 parcel.WriteUint64(displayId_); 56 parcel.WriteInt32(missionId_); 57 return true; 58 } 59 ReadFromParcel(Parcel & parcel)60bool RSWindowAnimationTarget::ReadFromParcel(Parcel& parcel) 61 { 62 bundleName_ = parcel.ReadString(); 63 abilityName_ = parcel.ReadString(); 64 windowBounds_.rect_.left_ = parcel.ReadFloat(); 65 windowBounds_.rect_.top_ = parcel.ReadFloat(); 66 windowBounds_.rect_.width_ = parcel.ReadFloat(); 67 windowBounds_.rect_.height_ = parcel.ReadFloat(); 68 windowBounds_.radius_[0].x_ = parcel.ReadFloat(); 69 // unmarshalling as RSProxyNode 70 if (parcel.ReadBool()) { 71 surfaceNode_ = RSSurfaceNode::UnmarshallingAsProxyNode(parcel); 72 } 73 windowId_ = parcel.ReadUint32(); 74 displayId_ = parcel.ReadUint64(); 75 missionId_ = parcel.ReadInt32(); 76 return true; 77 } 78 } // namespace Rosen 79 } // namespace OHOS 80