summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorBrian Orr <brianorr@google.com>2021-05-13 09:29:52 -0700
committerBrian Orr <brianorr@google.com>2021-05-13 09:29:52 -0700
commit2002595eeaa15527bedfee55f7cf1be1e53a96cd (patch)
tree03b73f8bc1eb66ba48150e179382440597539085 /include
parente06752e28f70267b23356c511130da74b3e9f40f (diff)
parentd253621149976855feed18e51ed504be145fa1c4 (diff)
Merge SP1A.210510.001
Change-Id: Id17825b5c1611b4a2e80450a412b06082d854ae1
Diffstat (limited to 'include')
-rw-r--r--include/android/imagedecoder.h31
-rw-r--r--include/android/surface_control.h12
-rw-r--r--include/input/Input.h50
-rw-r--r--include/input/InputTransport.h9
-rw-r--r--include/input/InputWindow.h4
5 files changed, 86 insertions, 20 deletions
diff --git a/include/android/imagedecoder.h b/include/android/imagedecoder.h
index 8d1bf99fe7..fb7d09c04d 100644
--- a/include/android/imagedecoder.h
+++ b/include/android/imagedecoder.h
@@ -739,6 +739,9 @@ int32_t AImageDecoder_getRepeatCount(AImageDecoder* _Nonnull decoder)
* skipping frames in an image with such frames may not produce the correct
* results.
*
+ * Only supported by {@link ANDROID_BITMAP_FORMAT_RGBA_8888} and
+ * {@link ANDROID_BITMAP_FORMAT_RGBA_F16}.
+ *
* @param decoder an {@link AImageDecoder} object.
* @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value
* indicating the reason for the failure.
@@ -747,6 +750,8 @@ int32_t AImageDecoder_getRepeatCount(AImageDecoder* _Nonnull decoder)
* - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The AImageDecoder
* represents an image that is not animated (see
* {@link AImageDecoder_isAnimated}) or the AImageDecoder is null.
+ * - {@link ANDROID_IMAGE_DECODER_INVALID_STATE): The requested
+ * {@link AndroidBitmapFormat} does not support animation.
* - {@link ANDROID_IMAGE_DECODER_INCOMPLETE}: The input appears
* to be truncated. The client must call {@link AImageDecoder_rewind}
* before calling {@link AImageDecoder_decodeImage} again.
@@ -832,9 +837,11 @@ void AImageDecoderFrameInfo_delete(
* is the current frame.
*
* If the image only has one frame, this will fill the {@link
- * AImageDecoderFrameInfo} with the encoded info, if any, or reasonable
+ * AImageDecoderFrameInfo} with the encoded info and reasonable
* defaults.
*
+ * If {@link AImageDecoder_advanceFrame} succeeded, this will succeed as well.
+ *
* @param decoder Opaque object representing the decoder.
* @param info Opaque object to hold frame information. On success, will be
* filled with information regarding the current frame.
@@ -856,7 +863,7 @@ int AImageDecoder_getFrameInfo(AImageDecoder* _Nonnull decoder,
* Introduced in API 31.
*
* Errors:
- * - returns 0 if |info| is null.
+ * - returns {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER} if |info| is null.
*/
int64_t AImageDecoderFrameInfo_getDuration(
const AImageDecoderFrameInfo* _Nonnull info) __INTRODUCED_IN(31);
@@ -891,19 +898,25 @@ ARect AImageDecoderFrameInfo_getFrameRect(
*
* Introduced in API 31.
*
- * Note that this may differ from whether the composed frame has
- * alpha. If this frame does not fill the entire image dimensions
- * (see {@link AImageDecoderFrameInfo_getFrameRect}) or it blends
- * with an opaque frame, for example, the composed frame’s alpha
- * may not match. It is also conservative; for example, if a color
- * index-based frame has a color with alpha but does not use it,
- * this will still return true.
+ * Unless this frame is independent (see {@link AImageDecoder_decodeImage}),
+ * a single call to {@link AImageDecoder_decodeImage} will decode an updated
+ * rectangle of pixels and then blend it with the existing pixels in the
+ * |pixels| buffer according to {@link AImageDecoderFrameInfo_getBlendOp}. This
+ * method returns whether the updated rectangle has alpha, prior to blending.
+ * The return value is conservative; for example, if a color-index-based frame
+ * has a color with alpha but does not use it, this will still return true.
*
* This, along with other information in AImageDecoderFrameInfo,
* can be useful for determining whether a frame is independent, but
* the decoder handles blending frames, so a simple
* sequential client does not need this.
*
+ * Note that this may differ from whether the composed frame (that is, the
+ * resulting image after blending) has alpha. If this frame does not fill the
+ * entire image dimensions (see {@link AImageDecoderFrameInfo_getFrameRect})
+ * or it blends with an opaque frame, for example, the composed frame’s alpha
+ * may not match.
+ *
* Errors:
* - returns false if |info| is null.
*/
diff --git a/include/android/surface_control.h b/include/android/surface_control.h
index b7eafcd6cd..988137112b 100644
--- a/include/android/surface_control.h
+++ b/include/android/surface_control.h
@@ -526,6 +526,9 @@ void ASurfaceTransaction_setFrameRate(ASurfaceTransaction* transaction,
* callback timings, and changes to the time interval at which the system releases buffers back to
* the application.
*
+ * You can register for changes in the refresh rate using
+ * \a AChoreographer_registerRefreshRateCallback.
+ *
* \param frameRate is the intended frame rate of this surface, in frames per second. 0 is a special
* value that indicates the app will accept the system's choice for the display frame rate, which is
* the default behavior if this function isn't called. The frameRate param does <em>not</em> need to
@@ -534,11 +537,12 @@ void ASurfaceTransaction_setFrameRate(ASurfaceTransaction* transaction,
*
* \param compatibility The frame rate compatibility of this surface. The compatibility value may
* influence the system's choice of display frame rate. To specify a compatibility use the
- * ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_* enum.
+ * ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_* enum. This parameter is ignored when frameRate is 0.
*
- * \param changeFrameRateStrategy Whether display refresh rate transitions should be seamless.
- * A seamless transition is one that doesn't have any visual interruptions, such as a black
- * screen for a second or two. See the ANATIVEWINDOW_CHANGE_FRAME_RATE_* values.
+ * \param changeFrameRateStrategy Whether display refresh rate transitions caused by this
+ * surface should be seamless. A seamless transition is one that doesn't have any visual
+ * interruptions, such as a black screen for a second or two. See the
+ * ANATIVEWINDOW_CHANGE_FRAME_RATE_* values. This parameter is ignored when frameRate is 0.
*
* Available since API level 31.
*/
diff --git a/include/input/Input.h b/include/input/Input.h
index bb5ca0ef04..d4defa8269 100644
--- a/include/input/Input.h
+++ b/include/input/Input.h
@@ -70,6 +70,14 @@ enum {
*/
AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE = 0x8,
+ /**
+ * This flag indicates that the event will not cause a focus change if it is directed to an
+ * unfocused window, even if it an ACTION_DOWN. This is typically used with pointer
+ * gestures to allow the user to direct gestures to an unfocused window without bringing it
+ * into focus.
+ */
+ AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE = 0x40,
+
/* Motion event is inconsistent with previously sent motion events. */
AMOTION_EVENT_FLAG_TAINTED = 0x80000000,
};
@@ -318,6 +326,12 @@ private:
*/
constexpr float AMOTION_EVENT_INVALID_CURSOR_POSITION = std::numeric_limits<float>::quiet_NaN();
+/**
+ * Invalid value for display size. Used when display size isn't available for an event or doesn't
+ * matter. This is just a constant 0 so that it has no effect if unused.
+ */
+constexpr int32_t AMOTION_EVENT_INVALID_DISPLAY_SIZE = 0;
+
/*
* Pointer coordinate data.
*/
@@ -360,6 +374,8 @@ struct PointerCoords {
return getAxisValue(AMOTION_EVENT_AXIS_Y);
}
+ vec2 getXYValue() const { return vec2(getX(), getY()); }
+
#ifdef __linux__
status_t readFromParcel(Parcel* parcel);
status_t writeToParcel(Parcel* parcel) const;
@@ -548,6 +564,8 @@ public:
void setCursorPosition(float x, float y);
+ int2 getDisplaySize() const { return {mDisplayWidth, mDisplayHeight}; }
+
static inline bool isValidCursorPosition(float x, float y) { return !isnan(x) && !isnan(y); }
inline nsecs_t getDownTime() const { return mDownTime; }
@@ -570,8 +588,17 @@ public:
inline nsecs_t getEventTime() const { return mSampleEventTimes[getHistorySize()]; }
+ /**
+ * The actual raw pointer coords: whatever comes from the input device without any external
+ * transforms applied.
+ */
const PointerCoords* getRawPointerCoords(size_t pointerIndex) const;
+ /**
+ * This is the raw axis value. However, for X/Y axes, this currently applies a "compat-raw"
+ * transform because many apps (incorrectly) assumed that raw == oriented-screen-space.
+ * "compat raw" is raw coordinates with screen rotation applied.
+ */
float getRawAxisValue(int32_t axis, size_t pointerIndex) const;
inline float getRawX(size_t pointerIndex) const {
@@ -634,9 +661,18 @@ public:
return mSampleEventTimes[historicalIndex];
}
+ /**
+ * The actual raw pointer coords: whatever comes from the input device without any external
+ * transforms applied.
+ */
const PointerCoords* getHistoricalRawPointerCoords(
size_t pointerIndex, size_t historicalIndex) const;
+ /**
+ * This is the raw axis value. However, for X/Y axes, this currently applies a "compat-raw"
+ * transform because many apps (incorrectly) assumed that raw == oriented-screen-space.
+ * "compat raw" is raw coordinates with screen rotation applied.
+ */
float getHistoricalRawAxisValue(int32_t axis, size_t pointerIndex,
size_t historicalIndex) const;
@@ -704,9 +740,9 @@ public:
int32_t flags, int32_t edgeFlags, int32_t metaState, int32_t buttonState,
MotionClassification classification, const ui::Transform& transform,
float xPrecision, float yPrecision, float rawXCursorPosition,
- float rawYCursorPosition, nsecs_t downTime, nsecs_t eventTime,
- size_t pointerCount, const PointerProperties* pointerProperties,
- const PointerCoords* pointerCoords);
+ float rawYCursorPosition, int32_t displayWidth, int32_t displayHeight,
+ nsecs_t downTime, nsecs_t eventTime, size_t pointerCount,
+ const PointerProperties* pointerProperties, const PointerCoords* pointerCoords);
void copyFrom(const MotionEvent* other, bool keepHistory);
@@ -718,10 +754,14 @@ public:
void scale(float globalScaleFactor);
- // Apply 3x3 perspective matrix transformation.
+ // Set 3x3 perspective matrix transformation.
// Matrix is in row-major form and compatible with SkMatrix.
void transform(const std::array<float, 9>& matrix);
+ // Apply 3x3 perspective matrix transformation only to content (do not modify mTransform).
+ // Matrix is in row-major form and compatible with SkMatrix.
+ void applyTransform(const std::array<float, 9>& matrix);
+
#ifdef __linux__
status_t readFromParcel(Parcel* parcel);
status_t writeToParcel(Parcel* parcel) const;
@@ -759,6 +799,8 @@ protected:
float mYPrecision;
float mRawXCursorPosition;
float mRawYCursorPosition;
+ int32_t mDisplayWidth;
+ int32_t mDisplayHeight;
nsecs_t mDownTime;
Vector<PointerProperties> mPointerProperties;
std::vector<nsecs_t> mSampleEventTimes;
diff --git a/include/input/InputTransport.h b/include/input/InputTransport.h
index eef057e773..e8ffc64535 100644
--- a/include/input/InputTransport.h
+++ b/include/input/InputTransport.h
@@ -136,6 +136,8 @@ struct InputMessage {
float yPrecision;
float xCursorPosition;
float yCursorPosition;
+ int32_t displayWidth;
+ int32_t displayHeight;
uint32_t pointerCount;
uint32_t empty3;
/**
@@ -227,7 +229,7 @@ public:
InputChannel(const InputChannel& other)
: mName(other.mName), mFd(::dup(other.mFd)), mToken(other.mToken){};
InputChannel(const std::string name, android::base::unique_fd fd, sp<IBinder> token);
- virtual ~InputChannel();
+ ~InputChannel() override;
/**
* Create a pair of input channels.
* The two returned input channels are equivalent, and are labeled as "server" and "client"
@@ -353,8 +355,9 @@ public:
int32_t metaState, int32_t buttonState,
MotionClassification classification, const ui::Transform& transform,
float xPrecision, float yPrecision, float xCursorPosition,
- float yCursorPosition, nsecs_t downTime, nsecs_t eventTime,
- uint32_t pointerCount, const PointerProperties* pointerProperties,
+ float yCursorPosition, int32_t displayWidth, int32_t displayHeight,
+ nsecs_t downTime, nsecs_t eventTime, uint32_t pointerCount,
+ const PointerProperties* pointerProperties,
const PointerCoords* pointerCoords);
/* Publishes a focus event to the input channel.
diff --git a/include/input/InputWindow.h b/include/input/InputWindow.h
index 36097d6d65..121be6d963 100644
--- a/include/input/InputWindow.h
+++ b/include/input/InputWindow.h
@@ -168,6 +168,10 @@ struct InputWindowInfo : public Parcelable {
// Transform applied to individual windows.
ui::Transform transform;
+ // Display size in its natural rotation. Used to rotate raw coordinates for compatibility.
+ int32_t displayWidth = AMOTION_EVENT_INVALID_DISPLAY_SIZE;
+ int32_t displayHeight = AMOTION_EVENT_INVALID_DISPLAY_SIZE;
+
/*
* This is filled in by the WM relative to the frame and then translated
* to absolute coordinates by SurfaceFlinger once the frame is computed.