1 /*
2  * Copyright (c) 2024 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 "drawing_lattice_ohos.h"
17 
18 #include "base/utils/utils.h"
19 #include "draw/core_canvas.h"
20 #include "lattice_napi/js_lattice.h"
21 
22 namespace OHOS::Ace {
CreateDrawingLattice(void * sptrAddr)23 RefPtr<DrawingLattice> DrawingLattice::CreateDrawingLattice(void* sptrAddr)
24 {
25     CHECK_NULL_RETURN(sptrAddr, nullptr);
26     auto* jsLattice = reinterpret_cast<OHOS::Rosen::Drawing::JsLattice*>(sptrAddr);
27     return AceType::MakeRefPtr<DrawingLatticeOhos>(jsLattice->GetLattice());
28 }
29 
CreateDrawingLatticeFromNative(void * sptrAddr)30 RefPtr<DrawingLattice> DrawingLattice::CreateDrawingLatticeFromNative(void* sptrAddr)
31 {
32     CHECK_NULL_RETURN(sptrAddr, nullptr);
33     auto* lattice = reinterpret_cast<std::shared_ptr<OHOS::Rosen::Drawing::Lattice>*>(sptrAddr);
34     return AceType::MakeRefPtr<DrawingLatticeOhos>(*lattice);
35 }
36 
GetDrawingLatticeSptrAddr()37 void* DrawingLatticeOhos::GetDrawingLatticeSptrAddr()
38 {
39     return static_cast<void*>(&lattice_);
40 }
41 } // namespace OHOS::Ace
42