29c403704aa135d2aa36e959668329635294c26e
[platform/core/uifw/lottie-player.git] / src / vector / vbitmap.h
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
3  *
4  * Licensed under the Flora License, Version 1.1 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://floralicense.org/license/
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef VBITMAP_H
18 #define VBITMAP_H
19
20 #include "vrect.h"
21
22 V_BEGIN_NAMESPACE
23
24 struct VBitmapData;
25 typedef void (*VBitmapCleanupFunction)(void *);
26 class VBitmap {
27 public:
28     enum class Format { Invalid, Alpha8, ARGB32, ARGB32_Premultiplied, Last };
29     ~VBitmap();
30     VBitmap();
31     VBitmap(const VBitmap &other);
32     VBitmap(VBitmap &&other);
33     VBitmap &operator=(const VBitmap &);
34     VBitmap &operator=(VBitmap &&other);
35
36     VBitmap(int w, int h, VBitmap::Format format);
37     VBitmap(uchar *data, int w, int h, int bytesPerLine, VBitmap::Format format,
38             VBitmapCleanupFunction f = nullptr, void *cleanupInfo = nullptr);
39
40     VBitmap copy(const VRect &rect = VRect()) const;
41     void    fill(uint pixel);
42
43     int             width() const;
44     int             height() const;
45     uchar *         bits();
46     const uchar *   bits() const;
47     uchar *         scanLine(int);
48     const uchar *   scanLine(int) const;
49     int             stride() const;
50     bool            isNull() const;
51     VBitmap::Format format() const;
52
53 private:
54     void         detach();
55     void         cleanUp(VBitmapData *x);
56     VBitmapData *d{nullptr};
57 };
58
59 V_END_NAMESPACE
60
61 #endif  // VBITMAP_H