Turn on support for async cursor update in surfaceflinger.
If available, surfaceflinger will use the hwc setCursorPositionAsync()
api to change the position of supported cursor layers outside of
the usual prepare/set loop.
Change-Id: Ib3fc5c0c390b3489ddbba202379840a1d2748917
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index 185dab2..a8fb5bd 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -681,6 +681,9 @@
if (l.compositionType == HWC_OVERLAY) {
disp.hasOvComp = true;
}
+ if (l.compositionType == HWC_CURSOR_OVERLAY) {
+ disp.hasOvComp = true;
+ }
}
if (disp.list->numHwLayers == (disp.framebufferTarget ? 1 : 0)) {
disp.hasFbComp = true;
@@ -853,6 +856,16 @@
return mDisplayData[id].lastRetireFence;
}
+status_t HWComposer::setCursorPositionAsync(int32_t id, const Rect& pos)
+{
+ if (mHwc->setCursorPositionAsync) {
+ return (status_t)mHwc->setCursorPositionAsync(mHwc, id, pos.left, pos.top);
+ }
+ else {
+ return NO_ERROR;
+ }
+}
+
/*
* Helper template to implement a concrete HWCLayer
* This holds the pointer to the concrete hwc layer type
@@ -935,6 +948,16 @@
getLayer()->flags &= ~HWC_SKIP_LAYER;
}
}
+ virtual void setIsCursorLayerHint(bool isCursor) {
+ if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_4)) {
+ if (isCursor) {
+ getLayer()->flags |= HWC_IS_CURSOR_LAYER;
+ }
+ else {
+ getLayer()->flags &= ~HWC_IS_CURSOR_LAYER;
+ }
+ }
+ }
virtual void setBlending(uint32_t blending) {
getLayer()->blending = blending;
}
@@ -1122,6 +1145,8 @@
"HWC",
"BKGND",
"FB TARGET",
+ "SIDEBAND",
+ "HWC_CURSOR",
"UNKNOWN"};
if (type >= NELEM(compositionTypeName))
type = NELEM(compositionTypeName) - 1;
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.h b/services/surfaceflinger/DisplayHardware/HWComposer.h
index c62b924..9bd99eb 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.h
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.h
@@ -141,6 +141,8 @@
// displays, writes to the output buffer are complete.
sp<Fence> getLastRetireFence(int32_t id) const;
+ status_t setCursorPositionAsync(int32_t id, const Rect &pos);
+
/*
* Interface to hardware composer's layers functionality.
* This abstracts the HAL interface to layers which can evolve in
@@ -157,6 +159,7 @@
virtual sp<Fence> getAndResetReleaseFence() = 0;
virtual void setDefaultState() = 0;
virtual void setSkip(bool skip) = 0;
+ virtual void setIsCursorLayerHint(bool isCursor = true) = 0;
virtual void setBlending(uint32_t blending) = 0;
virtual void setTransform(uint32_t transform) = 0;
virtual void setFrame(const Rect& frame) = 0;