• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (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://www.apache.org/licenses/LICENSE-2.0
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 #ifndef ANDROID_GRAPHICS_PAINT_H
17 #define ANDROID_GRAPHICS_PAINT_H
18 
19 #include <cutils/compiler.h>
20 #include <sys/cdefs.h>
21 
22 __BEGIN_DECLS
23 
24 /**
25  * Opaque handle for a native graphics canvas.
26  */
27 typedef struct APaint APaint;
28 
29 /** Bitmap pixel format. */
30 enum ABlendMode {
31     /** replaces destination with zero: fully transparent */
32     ABLEND_MODE_CLEAR    = 0,
33     /** source over destination */
34     ABLEND_MODE_SRC_OVER = 1,
35     /** replaces destination **/
36     ABLEND_MODE_SRC      = 2,
37 };
38 
39 ANDROID_API APaint* APaint_createPaint();
40 
41 ANDROID_API void APaint_destroyPaint(APaint* paint);
42 
43 ANDROID_API void APaint_setBlendMode(APaint* paint, ABlendMode blendMode);
44 
45 __END_DECLS
46 
47 #ifdef	__cplusplus
48 namespace android {
49 namespace graphics {
50     class Paint {
51     public:
Paint()52         Paint() : mPaint(APaint_createPaint()) {}
~Paint()53         ~Paint() { APaint_destroyPaint(mPaint); }
54 
setBlendMode(ABlendMode blendMode)55         void setBlendMode(ABlendMode blendMode) { APaint_setBlendMode(mPaint, blendMode); }
56 
get()57         const APaint& get() const { return *mPaint; }
58 
59     private:
60         APaint* mPaint;
61     };
62 }; // namespace graphics
63 }; // namespace android
64 #endif // __cplusplus
65 
66 
67 #endif // ANDROID_GRAPHICS_PAINT_H