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 #ifndef RENDERROI_H
17 #define RENDERROI_H
18 
19 #include <algorithm>
20 
21 #include "base/render_base.h"
22 
23 namespace OHOS {
24 namespace Media {
25 namespace Effect {
26 class RenderROI {
27 public:
RenderROI(int srcW,int srcH,double roiL,double roiR,double roiB,double roiT)28     RenderROI(int srcW, int srcH, double roiL, double roiR, double roiB, double roiT)
29         : w(srcW), h(srcH), l(roiL), r(roiR), b(roiB), t(roiT)
30     {}
RenderROI()31     RenderROI() : RenderROI(0, 0, 0.0, 1.0, 0.0, 1.0) {}
IsValid()32     bool IsValid()
33     {
34         return std::isless(l, r) && std::isless(b, t) && std::isgreater(w, 0.0) && std::isgreater(h, 0.0);
35     }
Width()36     int Width()
37     {
38         return (r - l) * w + 0.5f;
39     }
Height()40     int Height()
41     {
42         return (t - b) * h + 0.5f;
43     }
44 
45     int w;
46     int h;
47     double l;
48     double r;
49     double b;
50     double t;
51 };
52 
53 using RenderROIPtr = std::shared_ptr<RenderROI>;
54 } // namespace Effect
55 } // namespace Media
56 } // namespace OHOS
57 #endif // RENDERROI_H