1 /*
2  * Copyright (C) 2011 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 
17 #ifndef _ANDROID_VIEW_POINTER_ICON_H
18 #define _ANDROID_VIEW_POINTER_ICON_H
19 
20 #include <android/graphics/bitmap.h>
21 #include <input/Input.h>
22 #include <utils/Errors.h>
23 
24 #include <vector>
25 
26 #include "jni.h"
27 
28 namespace android {
29 
30 /*
31  * Describes a pointer icon.
32  */
33 struct PointerIcon {
PointerIconPointerIcon34     inline PointerIcon() { reset(); }
35 
36     PointerIconStyle style;
37     graphics::Bitmap bitmap;
38     float hotSpotX;
39     float hotSpotY;
40     std::vector<graphics::Bitmap> bitmapFrames;
41     int32_t durationPerFrame;
42     bool drawNativeDropShadow;
43 
isNullIconPointerIcon44     inline bool isNullIcon() { return style == PointerIconStyle::TYPE_NULL; }
45 
resetPointerIcon46     inline void reset() {
47         style = PointerIconStyle::TYPE_NULL;
48         bitmap.reset();
49         hotSpotX = 0;
50         hotSpotY = 0;
51         bitmapFrames.clear();
52         durationPerFrame = 0;
53         drawNativeDropShadow = false;
54     }
55 };
56 
57 /*
58  * Obtain the data of the Java pointerIconObj into a native PointerIcon.
59  *
60  * The pointerIconObj must not be null.
61  */
62 PointerIcon android_view_PointerIcon_toNative(JNIEnv* env, jobject pointerIconObj);
63 
64 } // namespace android
65 
66 #endif // _ANDROID_OS_POINTER_ICON_H
67