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 IMAGE_EFFECT_CROP_EFILER_H
17 #define IMAGE_EFFECT_CROP_EFILER_H
18 
19 #include "efilter.h"
20 
21 namespace OHOS {
22 namespace Media {
23 namespace Effect {
24 class CropEFilter : public EFilter {
25 public:
26     class Parameter : public EFilter::Parameter {
27     public:
28         static const std::string KEY_REGION;
29     };
30 
CropEFilter(const std::string & name)31     explicit CropEFilter(const std::string &name) : EFilter(name) {}
32 
33     ~CropEFilter() override = default;
34 
35     ErrorCode Render(EffectBuffer *buffer, std::shared_ptr<EffectContext> &context) override;
36 
37     ErrorCode Render(EffectBuffer *src, EffectBuffer *dst, std::shared_ptr<EffectContext> &context) override;
38 
39     static std::shared_ptr<EffectInfo> GetEffectInfo(const std::string &name);
40 
41     ErrorCode Restore(const EffectJsonPtr &values) override;
42 
43     std::shared_ptr<MemNegotiatedCap> Negotiate(const std::shared_ptr<MemNegotiatedCap> &input,
44         std::shared_ptr<EffectContext> &context) override;
45 
46 private:
47     ErrorCode CropToOutputBuffer(EffectBuffer *src, std::shared_ptr<EffectContext> &context,
48         std::shared_ptr<EffectBuffer> &output);
49     static std::shared_ptr<EffectInfo> info_;
50 };
51 } // namespace Effect
52 } // namespace Media
53 } // namespace OHOS
54 #endif // IMAGE_EFFECT_CROP_EFILER_H