1*d57664e9SAndroid Build Coastguard Worker /* 2*d57664e9SAndroid Build Coastguard Worker * Copyright (C) 2020 The Android Open Source Project 3*d57664e9SAndroid Build Coastguard Worker * 4*d57664e9SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*d57664e9SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*d57664e9SAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*d57664e9SAndroid Build Coastguard Worker * 8*d57664e9SAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*d57664e9SAndroid Build Coastguard Worker * 10*d57664e9SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*d57664e9SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*d57664e9SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*d57664e9SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*d57664e9SAndroid Build Coastguard Worker * limitations under the License. 15*d57664e9SAndroid Build Coastguard Worker */ 16*d57664e9SAndroid Build Coastguard Worker 17*d57664e9SAndroid Build Coastguard Worker #ifndef _UI_SPRITE_ICON_H 18*d57664e9SAndroid Build Coastguard Worker #define _UI_SPRITE_ICON_H 19*d57664e9SAndroid Build Coastguard Worker 20*d57664e9SAndroid Build Coastguard Worker #include <android/graphics/bitmap.h> 21*d57664e9SAndroid Build Coastguard Worker #include <gui/Surface.h> 22*d57664e9SAndroid Build Coastguard Worker #include <input/Input.h> 23*d57664e9SAndroid Build Coastguard Worker 24*d57664e9SAndroid Build Coastguard Worker namespace android { 25*d57664e9SAndroid Build Coastguard Worker 26*d57664e9SAndroid Build Coastguard Worker /* 27*d57664e9SAndroid Build Coastguard Worker * Icon that a sprite displays, including its hotspot. 28*d57664e9SAndroid Build Coastguard Worker */ 29*d57664e9SAndroid Build Coastguard Worker struct SpriteIcon { 30*d57664e9SAndroid Build Coastguard Worker explicit SpriteIcon() = default; SpriteIconSpriteIcon31*d57664e9SAndroid Build Coastguard Worker explicit SpriteIcon(const graphics::Bitmap& bitmap, PointerIconStyle style, float hotSpotX, 32*d57664e9SAndroid Build Coastguard Worker float hotSpotY, bool drawNativeDropShadow) 33*d57664e9SAndroid Build Coastguard Worker : bitmap(bitmap), 34*d57664e9SAndroid Build Coastguard Worker style(style), 35*d57664e9SAndroid Build Coastguard Worker hotSpotX(hotSpotX), 36*d57664e9SAndroid Build Coastguard Worker hotSpotY(hotSpotY), 37*d57664e9SAndroid Build Coastguard Worker drawNativeDropShadow(drawNativeDropShadow) {} 38*d57664e9SAndroid Build Coastguard Worker 39*d57664e9SAndroid Build Coastguard Worker graphics::Bitmap bitmap{}; 40*d57664e9SAndroid Build Coastguard Worker PointerIconStyle style{PointerIconStyle::TYPE_NULL}; 41*d57664e9SAndroid Build Coastguard Worker float hotSpotX{}; 42*d57664e9SAndroid Build Coastguard Worker float hotSpotY{}; 43*d57664e9SAndroid Build Coastguard Worker bool drawNativeDropShadow{}; 44*d57664e9SAndroid Build Coastguard Worker isValidSpriteIcon45*d57664e9SAndroid Build Coastguard Worker inline bool isValid() const { return bitmap.isValid() && !bitmap.isEmpty(); } 46*d57664e9SAndroid Build Coastguard Worker widthSpriteIcon47*d57664e9SAndroid Build Coastguard Worker inline int32_t width() const { return bitmap.getInfo().width; } heightSpriteIcon48*d57664e9SAndroid Build Coastguard Worker inline int32_t height() const { return bitmap.getInfo().height; } 49*d57664e9SAndroid Build Coastguard Worker 50*d57664e9SAndroid Build Coastguard Worker // Draw the bitmap onto the given surface. Returns true if it's successful, or false otherwise. 51*d57664e9SAndroid Build Coastguard Worker // Note it doesn't set any metadata to the surface. 52*d57664e9SAndroid Build Coastguard Worker bool draw(const sp<Surface> surface) const; 53*d57664e9SAndroid Build Coastguard Worker }; 54*d57664e9SAndroid Build Coastguard Worker 55*d57664e9SAndroid Build Coastguard Worker } // namespace android 56*d57664e9SAndroid Build Coastguard Worker 57*d57664e9SAndroid Build Coastguard Worker #endif // _UI_SPRITE_ICON_H 58