1 /* 2 * Copyright (c) 2025 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 OHOS_WEB_PICTURE_IN_PICTURE_CONTROLLER_H 17 #define OHOS_WEB_PICTURE_IN_PICTURE_CONTROLLER_H 18 19 #include "picture_in_picture_controller_base.h" 20 21 namespace OHOS { 22 namespace Rosen { 23 24 using namespace Ace; 25 26 struct PiPConfig { 27 uint32_t mainWindowId; 28 uint32_t pipTemplateType; 29 uint32_t width; 30 uint32_t height; 31 std::vector<uint32_t> controlGroup; 32 napi_env env; 33 }; 34 35 class WebPictureInPictureController : public PictureInPictureControllerBase { 36 public: 37 explicit WebPictureInPictureController(const PiPConfig& config); 38 ~WebPictureInPictureController() = default; 39 WMError StartPictureInPicture(StartPipType startType) override; 40 void UpdateContentSize(int32_t width, int32_t height) override; 41 void SetPipInitialSurfaceRect(int32_t positionX, int32_t positionY, uint32_t width, uint32_t height) override; 42 void RestorePictureInPictureWindow() override; 43 WMError SetXComponentController(std::shared_ptr<XComponentController> xComponentController) override; 44 uint8_t GetWebRequestId() override; 45 46 protected: 47 WMError CreatePictureInPictureWindow(StartPipType startType) override; 48 void UpdateWinRectByComponent() override; 49 void SetUIContent() const override; 50 void UpdatePiPSourceRect() const override; 51 52 private: 53 wptr<WebPictureInPictureController> weakRef_ = nullptr; 54 uint8_t webRequestId_ = 0; 55 int32_t initPositionX_ = 0; 56 int32_t initPositionY_ = 0; 57 uint32_t initWidth_ = 0; 58 uint32_t initHeight_ = 0; 59 }; 60 } // namespace Rosen 61 } // namespace OHOS 62 #endif // OHOS_PICTURE_IN_PICTURE_CONTROLLER_H