• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 "camera_test.h"
17 
18 namespace OHOS {
19 namespace Rosen {
20 namespace Drawing {
TestCamera(Canvas & canvas,uint32_t width,uint32_t height)21 void CameraTest::TestCamera(Canvas& canvas, uint32_t width, uint32_t height)
22 {
23     LOGI("+++++++ TestCamera");
24 
25     Brush brush;
26     Matrix m0;
27     m0.Translate(width / 2.0, height / 2.0); // Set matrix m0 to translate by (width / 2.0, height / 2.0).
28     canvas.SetMatrix(m0);
29 
30     Camera3D camera;
31     camera.RotateXDegrees(-25);      // Set camera to rotate by degrees -25 at x-aixs.
32     camera.RotateYDegrees(45);       // Set camera to rotate by degrees 45 at y-aixs.
33     camera.Translate(-50, 50, 50);   // Set camera to translate by (-50, 50, 50).
34     Drawing::Rect r(0, 0, 500, 500); // rect is set to (fLeft, fTop, fRight, fBottom)
35 
36     canvas.Save();
37     camera.Save();
38     camera.RotateYDegrees(90); // Set camera to rotate by degrees 90 at y-aixs.
39     Matrix m1;
40     camera.ApplyToMatrix(m1);
41     camera.Restore();
42     canvas.ConcatMatrix(m1);
43     brush.SetColor(Drawing::Color::COLOR_LTGRAY);
44     canvas.AttachBrush(brush);
45     canvas.DrawRect(r);
46     canvas.Restore();
47     LOGI("------- TestCamera");
48 }
49 
CameraTestCase()50 std::vector<CameraTest::TestFunc> CameraTest::CameraTestCase()
51 {
52     std::vector<TestFunc> testFuncVec;
53     testFuncVec.push_back(TestCamera);
54     return testFuncVec;
55 }
56 } // namespace Drawing
57 } // namespace Rosen
58 } // namespace OHOS