162b8cbc9Sopenharmony_ci/* 262b8cbc9Sopenharmony_ci * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 362b8cbc9Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 462b8cbc9Sopenharmony_ci * you may not use this file except in compliance with the License. 562b8cbc9Sopenharmony_ci * You may obtain a copy of the License at 662b8cbc9Sopenharmony_ci * 762b8cbc9Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 862b8cbc9Sopenharmony_ci * 962b8cbc9Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1062b8cbc9Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1162b8cbc9Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1262b8cbc9Sopenharmony_ci * See the License for the specific language governing permissions and 1362b8cbc9Sopenharmony_ci * limitations under the License. 1462b8cbc9Sopenharmony_ci */ 1562b8cbc9Sopenharmony_ci 1662b8cbc9Sopenharmony_ci#ifndef GRAPHIC_LITE_LITE_WIN_H 1762b8cbc9Sopenharmony_ci#define GRAPHIC_LITE_LITE_WIN_H 1862b8cbc9Sopenharmony_ci 1962b8cbc9Sopenharmony_ci#include <pthread.h> 2062b8cbc9Sopenharmony_ci 2162b8cbc9Sopenharmony_ci#include "gfx_utils/color.h" 2262b8cbc9Sopenharmony_ci#include "gfx_utils/geometry2d.h" 2362b8cbc9Sopenharmony_ci#include "isurface.h" 2462b8cbc9Sopenharmony_ci#include "lite_wm_type.h" 2562b8cbc9Sopenharmony_ci#include "ipc_skeleton.h" 2662b8cbc9Sopenharmony_ci#include "serializer.h" 2762b8cbc9Sopenharmony_ci#include "surface.h" 2862b8cbc9Sopenharmony_ci 2962b8cbc9Sopenharmony_cinamespace OHOS { 3062b8cbc9Sopenharmony_ciclass LiteWindow { 3162b8cbc9Sopenharmony_cipublic: 3262b8cbc9Sopenharmony_ci friend class LiteWM; 3362b8cbc9Sopenharmony_ci explicit LiteWindow(const LiteWinConfig& config); 3462b8cbc9Sopenharmony_ci virtual ~LiteWindow(); 3562b8cbc9Sopenharmony_ci 3662b8cbc9Sopenharmony_ci int32_t GetWindowId() const 3762b8cbc9Sopenharmony_ci { 3862b8cbc9Sopenharmony_ci return id_; 3962b8cbc9Sopenharmony_ci } 4062b8cbc9Sopenharmony_ci 4162b8cbc9Sopenharmony_ci const LiteWinConfig& GetConfig() const 4262b8cbc9Sopenharmony_ci { 4362b8cbc9Sopenharmony_ci return config_; 4462b8cbc9Sopenharmony_ci } 4562b8cbc9Sopenharmony_ci 4662b8cbc9Sopenharmony_ci void SetSid(const SvcIdentity& sid) 4762b8cbc9Sopenharmony_ci { 4862b8cbc9Sopenharmony_ci needUnregister_ = true; 4962b8cbc9Sopenharmony_ci sid_ = sid; 5062b8cbc9Sopenharmony_ci } 5162b8cbc9Sopenharmony_ci 5262b8cbc9Sopenharmony_ci void SetIsShow(bool isShow) 5362b8cbc9Sopenharmony_ci { 5462b8cbc9Sopenharmony_ci isShow_ = isShow; 5562b8cbc9Sopenharmony_ci } 5662b8cbc9Sopenharmony_ci 5762b8cbc9Sopenharmony_ci bool GetIsShow() const 5862b8cbc9Sopenharmony_ci { 5962b8cbc9Sopenharmony_ci return isShow_; 6062b8cbc9Sopenharmony_ci } 6162b8cbc9Sopenharmony_ci 6262b8cbc9Sopenharmony_ci void SetPid(pid_t pid) 6362b8cbc9Sopenharmony_ci { 6462b8cbc9Sopenharmony_ci pid_ = pid; 6562b8cbc9Sopenharmony_ci } 6662b8cbc9Sopenharmony_ci 6762b8cbc9Sopenharmony_ci pid_t GetPid() const 6862b8cbc9Sopenharmony_ci { 6962b8cbc9Sopenharmony_ci return pid_; 7062b8cbc9Sopenharmony_ci } 7162b8cbc9Sopenharmony_ci 7262b8cbc9Sopenharmony_ci bool IsCoverMode() const 7362b8cbc9Sopenharmony_ci { 7462b8cbc9Sopenharmony_ci return config_.compositeMode == LiteWinConfig::COPY; 7562b8cbc9Sopenharmony_ci } 7662b8cbc9Sopenharmony_ci 7762b8cbc9Sopenharmony_ci bool NoNeedToDraw() const 7862b8cbc9Sopenharmony_ci { 7962b8cbc9Sopenharmony_ci return config_.compositeMode == LiteWinConfig::BLEND && config_.opacity == OPA_TRANSPARENT; 8062b8cbc9Sopenharmony_ci } 8162b8cbc9Sopenharmony_ci 8262b8cbc9Sopenharmony_ci void ResizeSurface(int16_t width, int16_t height); 8362b8cbc9Sopenharmony_ci 8462b8cbc9Sopenharmony_ci void Update(Rect rect); 8562b8cbc9Sopenharmony_ci void UpdateBackBuf(); 8662b8cbc9Sopenharmony_ci void Flush(const Rect& srcRect, const LiteSurfaceData* layerData, int16_t dx, int16_t dy); 8762b8cbc9Sopenharmony_ci 8862b8cbc9Sopenharmony_ci Surface* GetSurface(); 8962b8cbc9Sopenharmony_ci void MoveTo(int16_t x, int16_t y); 9062b8cbc9Sopenharmony_ci void Resize(int16_t width, int16_t height); 9162b8cbc9Sopenharmony_ciprivate: 9262b8cbc9Sopenharmony_ci bool CreateSurface(); 9362b8cbc9Sopenharmony_ci static void ReleaseSurface(); 9462b8cbc9Sopenharmony_ci void FlushWithModeCopy(const Rect& srcRect, const LiteSurfaceData* layerData, int16_t dx, int16_t dy); 9562b8cbc9Sopenharmony_ci void FlushWithModeBlend(const Rect& srcRect, const LiteSurfaceData* layerData, int16_t dx, int16_t dy); 9662b8cbc9Sopenharmony_ci 9762b8cbc9Sopenharmony_ci int32_t id_; 9862b8cbc9Sopenharmony_ci pid_t pid_; 9962b8cbc9Sopenharmony_ci bool isShow_; 10062b8cbc9Sopenharmony_ci LiteWinConfig config_; 10162b8cbc9Sopenharmony_ci Surface* surface_; 10262b8cbc9Sopenharmony_ci SurfaceBuffer* backBuf_; 10362b8cbc9Sopenharmony_ci pthread_mutex_t backBufMutex_; 10462b8cbc9Sopenharmony_ci SvcIdentity sid_; 10562b8cbc9Sopenharmony_ci IpcObjectStub objectStub_; 10662b8cbc9Sopenharmony_ci bool needUnregister_; 10762b8cbc9Sopenharmony_ci}; 10862b8cbc9Sopenharmony_ci} 10962b8cbc9Sopenharmony_ci#endif