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 /** 30 * Predefined Image filter type. 31 */ 32 enum AImageFilter { 33 /** Drop shadow image filter for PointerIcons. */ 34 AIMAGE_FILTER_DROP_SHADOW_FOR_POINTER_ICON = 0, 35 }; 36 37 /** Bitmap pixel format. */ 38 enum ABlendMode { 39 /** replaces destination with zero: fully transparent */ 40 ABLEND_MODE_CLEAR = 0, 41 /** source over destination */ 42 ABLEND_MODE_SRC_OVER = 1, 43 /** replaces destination **/ 44 ABLEND_MODE_SRC = 2, 45 }; 46 47 ANDROID_API APaint* APaint_createPaint(); 48 49 ANDROID_API void APaint_destroyPaint(APaint* paint); 50 51 ANDROID_API void APaint_setBlendMode(APaint* paint, ABlendMode blendMode); 52 53 ANDROID_API void APaint_setImageFilter(APaint* paint, AImageFilter imageFilter); 54 55 __END_DECLS 56 57 #ifdef __cplusplus 58 namespace android { 59 namespace graphics { 60 class Paint { 61 public: Paint()62 Paint() : mPaint(APaint_createPaint()) {} ~Paint()63 ~Paint() { APaint_destroyPaint(mPaint); } 64 setBlendMode(ABlendMode blendMode)65 void setBlendMode(ABlendMode blendMode) { APaint_setBlendMode(mPaint, blendMode); } 66 setImageFilter(AImageFilter imageFilter)67 void setImageFilter(AImageFilter imageFilter) { 68 APaint_setImageFilter(mPaint, imageFilter); 69 } 70 get()71 const APaint& get() const { return *mPaint; } 72 73 private: 74 APaint* mPaint; 75 }; 76 }; // namespace graphics 77 }; // namespace android 78 #endif // __cplusplus 79 80 81 #endif // ANDROID_GRAPHICS_PAINT_H