1 /*
2  * Copyright (c) 2023 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 VERTICESIMPL_H
17 #define VERTICESIMPL_H
18 
19 #include "base_impl.h"
20 
21 #include "utils/data.h"
22 #include "utils/point.h"
23 #include "draw/color.h"
24 
25 namespace OHOS {
26 namespace Rosen {
27 namespace Drawing {
28 
29 enum class VertexMode;
30 
31 class VerticesImpl : public BaseImpl {
32 public:
VerticesImpl()33     VerticesImpl() noexcept {}
~VerticesImpl()34     ~VerticesImpl() override {}
35 
36     virtual bool MakeCopy(VertexMode mode, int vertexCount,
37         const Point positions[], const Point texs[], const ColorQuad colors[],
38         int indexCount, const uint16_t indices[]) = 0;
39 
40     virtual bool MakeCopy(VertexMode mode,
41         int vertexCount, const Point positions[], const Point texs[], const ColorQuad colors[]) = 0;
42 
43     virtual std::shared_ptr<Data> Serialize() const = 0;
44     virtual bool Deserialize(std::shared_ptr<Data> data) = 0;
45 
46     class BuilderImpl : public BaseImpl {
47     public:
BuilderImpl()48         BuilderImpl() noexcept {}
~BuilderImpl()49         ~BuilderImpl() override {}
50 
51         virtual void Init(VertexMode mode, int vertexCount, int indexCount, uint32_t flags) = 0;
52         virtual bool IsValid() = 0;
53 
54         virtual Point* Positions() = 0;
55         virtual uint16_t* Indices() = 0;
56         virtual Point* TexCoords() = 0;
57         virtual ColorQuad* Colors() = 0;
58 
59         virtual std::shared_ptr<VerticesImpl> Detach() = 0;
60     };
61 };
62 } // namespace Drawing
63 } // namespace Rosen
64 } // namespace OHOS
65 #endif
66