• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef BRUSH_H
17 #define BRUSH_H
18 
19 #include "draw/color.h"
20 #include "effect/color_space.h"
21 #include "effect/filter.h"
22 #include "effect/shader_effect.h"
23 
24 namespace OHOS {
25 namespace Rosen {
26 namespace Drawing {
27 class Brush {
28 public:
29     Brush() noexcept;
30     Brush(const Brush& b) noexcept = default;
31     Brush(const Color& c) noexcept;
32     Brush(const std::shared_ptr<ShaderEffect> e) noexcept;
33     Brush(int rgba) noexcept;
34 
~Brush()35     ~Brush() {}
36     Color GetColor() const;
37     void SetColor(const Color& c);
38     void SetColor(int c);
39     void SetARGB(int r, int g, int b, int a);
40 
41     Color4f GetColor4f();
42     std::shared_ptr<ColorSpace> GetColorSpace() const;
43     void SetColor(const Color4f& cf, std::shared_ptr<ColorSpace> s);
44 
45     uint32_t GetAlpha() const;
46     void SetAlpha(uint32_t a);
47     void SetAlphaF(scalar a);
48 
49     BlendMode GetBlendMode() const;
50     void SetBlendMode(BlendMode mode);
51 
52     void SetFilter(const Filter& filter);
53     Filter GetFilter() const;
54 
55     void SetShaderEffect(std::shared_ptr<ShaderEffect> e);
56     std::shared_ptr<ShaderEffect> GetShaderEffect() const;
57 
58     bool IsAntiAlias() const;
59     void SetAntiAlias(bool aa);
60 
61     void Reset();
62 
63     friend bool operator==(const Brush& b1, const Brush& b2);
64     friend bool operator!=(const Brush& b1, const Brush& b2);
65 
66 private:
67     Color color_;
68     BlendMode blendMode_;
69     Filter filter_;
70     std::shared_ptr<ColorSpace> colorSpace_;
71     std::shared_ptr<ShaderEffect> shaderEffect_;
72 
73     bool antiAlias_;
74 };
75 } // namespace Drawing
76 } // namespace Rosen
77 } // namespace OHOS
78 #endif