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 isNullIconPointerIcon43 inline bool isNullIcon() { return style == PointerIconStyle::TYPE_NULL; } 44 resetPointerIcon45 inline void reset() { 46 style = PointerIconStyle::TYPE_NULL; 47 bitmap.reset(); 48 hotSpotX = 0; 49 hotSpotY = 0; 50 bitmapFrames.clear(); 51 durationPerFrame = 0; 52 } 53 }; 54 55 /* Gets a system pointer icon with the specified style. */ 56 extern jobject android_view_PointerIcon_getSystemIcon(JNIEnv* env, jobject contextObj, 57 PointerIconStyle style); 58 59 /* Loads the bitmap associated with a pointer icon. 60 * If pointerIconObj is NULL, returns OK and a pointer icon with POINTER_ICON_STYLE_NULL. */ 61 extern status_t android_view_PointerIcon_load(JNIEnv* env, jobject pointerIconObj, 62 jobject contextObj, PointerIcon* outPointerIcon); 63 64 /* Obtain the data of pointerIconObj and put to outPointerIcon. */ 65 extern status_t android_view_PointerIcon_getLoadedIcon(JNIEnv* env, jobject pointerIconObj, 66 PointerIcon* outPointerIcon); 67 68 /* Loads the bitmap associated with a pointer icon by style. 69 * If pointerIconObj is NULL, returns OK and a pointer icon with POINTER_ICON_STYLE_NULL. */ 70 extern status_t android_view_PointerIcon_loadSystemIcon(JNIEnv* env, jobject contextObj, 71 PointerIconStyle style, 72 PointerIcon* outPointerIcon); 73 74 } // namespace android 75 76 #endif // _ANDROID_OS_POINTER_ICON_H 77