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 "skia_camera.h"
17
18 #include "skia_matrix.h"
19 namespace OHOS {
20 namespace Rosen {
21 namespace Drawing {
SkiaCamera()22 SkiaCamera::SkiaCamera() noexcept : view_() {}
23
Save()24 void SkiaCamera::Save()
25 {
26 view_.save();
27 }
28
Restore()29 void SkiaCamera::Restore()
30 {
31 view_.restore();
32 }
33
Translate(scalar x,scalar y,scalar z)34 void SkiaCamera::Translate(scalar x, scalar y, scalar z)
35 {
36 view_.translate(x, y, z);
37 }
38
RotateX(scalar deg)39 void SkiaCamera::RotateX(scalar deg)
40 {
41 view_.rotateX(deg);
42 }
43
RotateY(scalar deg)44 void SkiaCamera::RotateY(scalar deg)
45 {
46 view_.rotateY(deg);
47 }
48
RotateZ(scalar deg)49 void SkiaCamera::RotateZ(scalar deg)
50 {
51 view_.rotateZ(deg);
52 }
53
SetCameraPos(scalar x,scalar y,scalar z)54 void SkiaCamera::SetCameraPos(scalar x, scalar y, scalar z)
55 {
56 #if defined(USE_CANVASKIT0310_SKIA)
57 return;
58 #else
59 view_.setCameraLocation(x, y, z);
60 #endif
61 }
62
GetCameraPosX() const63 scalar SkiaCamera::GetCameraPosX() const
64 {
65 #if defined(USE_CANVASKIT0310_SKIA)
66 return 0;
67 #else
68 return view_.getCameraLocationX();
69 #endif
70 }
71
GetCameraPosY() const72 scalar SkiaCamera::GetCameraPosY() const
73 {
74 #if defined(USE_CANVASKIT0310_SKIA)
75 return 0;
76 #else
77 return view_.getCameraLocationY();
78 #endif
79 }
80
GetCameraPosZ() const81 scalar SkiaCamera::GetCameraPosZ() const
82 {
83 #if defined(USE_CANVASKIT0310_SKIA)
84 return 0;
85 #else
86 return view_.getCameraLocationZ();
87 #endif
88 }
89
ApplyToMatrix(Matrix & m)90 void SkiaCamera::ApplyToMatrix(Matrix& m)
91 {
92 SkMatrix& matrix = m.GetImpl<SkiaMatrix>()->ExportMatrix();
93 view_.getMatrix(&matrix);
94 }
95 } // namespace Drawing
96 } // namespace Rosen
97 } // namespace OHOS