• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 "static_call.h"
17 
18 #include <mutex>
19 
20 #include "subwindow_normal_impl.h"
21 #include "subwindow_video_impl.h"
22 #include "subwindow_offscreen_impl.h"
23 #include "window_impl.h"
24 
25 namespace OHOS {
GetInstance()26 sptr<StaticCall> StaticCall::GetInstance()
27 {
28     if (instance == nullptr) {
29         static std::mutex mutex;
30         std::lock_guard<std::mutex> lock(mutex);
31         if (instance == nullptr) {
32             instance = new StaticCall();
33         }
34     }
35     return instance;
36 }
37 
SurfaceCreateSurfaceAsConsumer(std::string name)38 sptr<Surface> StaticCall::SurfaceCreateSurfaceAsConsumer(std::string name)
39 {
40     return Surface::CreateSurfaceAsConsumer(name);
41 }
42 
SurfaceCreateSurfaceAsProducer(sptr<IBufferProducer> & producer)43 sptr<Surface> StaticCall::SurfaceCreateSurfaceAsProducer(sptr<IBufferProducer>& producer)
44 {
45     return Surface::CreateSurfaceAsProducer(producer);
46 }
47 
SurfaceCreateEglSurfaceAsConsumer(std::string name)48 sptr<Surface> StaticCall::SurfaceCreateEglSurfaceAsConsumer(std::string name)
49 {
50     return Surface::CreateEglSurfaceAsConsumer(name);
51 }
52 
WindowImplCreate(sptr<Window> & window,const sptr<WindowOption> & option,const sptr<IWindowManagerService> & wms)53 GSError StaticCall::WindowImplCreate(sptr<Window> &window,
54                                      const sptr<WindowOption> &option,
55                                      const sptr<IWindowManagerService> &wms)
56 {
57     return WindowImpl::Create(window, option, wms);
58 }
59 
SubwindowNormalImplCreate(sptr<Subwindow> & subwindow,const sptr<Window> & window,const sptr<SubwindowOption> & option)60 GSError StaticCall::SubwindowNormalImplCreate(sptr<Subwindow> &subwindow,
61                                               const sptr<Window> &window,
62                                               const sptr<SubwindowOption> &option)
63 {
64     sptr<SubwindowNormalImpl> sni = new SubwindowNormalImpl();
65     auto ret = sni->Init(window, option);
66     if (ret == GSERROR_OK) {
67         subwindow = sni;
68     }
69     return ret;
70 }
71 
SubwindowVideoImplCreate(sptr<Subwindow> & subwindow,const sptr<Window> & window,const sptr<SubwindowOption> & option)72 GSError StaticCall::SubwindowVideoImplCreate(sptr<Subwindow> &subwindow,
73                                              const sptr<Window> &window,
74                                              const sptr<SubwindowOption> &option)
75 {
76     sptr<SubwindowVideoImpl> svi = new SubwindowVideoImpl();
77     auto ret = svi->Init(window, option);
78     if (ret == GSERROR_OK) {
79         subwindow = svi;
80     }
81     return ret;
82 }
83 
SubwindowOffscreenImplCreate(sptr<Subwindow> & subwindow,const sptr<Window> & window,const sptr<SubwindowOption> & option)84 GSError StaticCall::SubwindowOffscreenImplCreate(sptr<Subwindow> &subwindow,
85                                                  const sptr<Window> &window,
86                                                  const sptr<SubwindowOption> &option)
87 {
88     sptr<SubwindowOffscreenImpl> soi = new SubwindowOffscreenImpl();
89     auto ret = soi->Init(window, option);
90     if (ret == GSERROR_OK) {
91         subwindow = soi;
92     }
93     return ret;
94 }
95 } // namespace OHOS
96