@@ -55,6 +55,28 @@ namespace android {
5555using gui::FocusRequest;
5656using gui::WindowInfoHandle;
5757
58+ namespace {
59+ bool isSameWindowHandle (const sp<WindowInfoHandle>& lhs, const sp<WindowInfoHandle>& rhs) {
60+ if (lhs == rhs) {
61+ return true ;
62+ }
63+
64+ if (!lhs || !rhs) {
65+ return false ;
66+ }
67+
68+ return *lhs->getInfo () == *rhs->getInfo ();
69+ };
70+
71+ bool isSameSurfaceControl (const sp<SurfaceControl>& lhs, const sp<SurfaceControl>& rhs) {
72+ if (lhs == rhs) {
73+ return true ;
74+ }
75+
76+ return SurfaceControl::isSameSurface (lhs, rhs);
77+ };
78+ } // namespace
79+
5880layer_state_t::layer_state_t ()
5981 : surface(nullptr ),
6082 layerId (-1 ),
@@ -73,7 +95,6 @@ layer_state_t::layer_state_t()
7395 transformToDisplayInverse(false ),
7496 crop({0 , 0 , -1 , -1 }),
7597 dataspace(ui::Dataspace::UNKNOWN),
76- surfaceDamageRegion(),
7798 api(-1 ),
7899 colorTransform(mat4()),
79100 bgColor(0 ),
@@ -117,19 +138,21 @@ status_t layer_state_t::write(Parcel& output) const
117138 SAFE_PARCEL (output.writeFloat , crop.left );
118139 SAFE_PARCEL (output.writeFloat , crop.bottom );
119140 SAFE_PARCEL (output.writeFloat , crop.right );
120- SAFE_PARCEL (SurfaceControl::writeNullableToParcel, output, relativeLayerSurfaceControl);
121- SAFE_PARCEL (SurfaceControl::writeNullableToParcel, output, parentSurfaceControlForChild);
141+ SAFE_PARCEL (SurfaceControl::writeNullableToParcel, output,
142+ mNotDefCmpState .relativeLayerSurfaceControl );
143+ SAFE_PARCEL (SurfaceControl::writeNullableToParcel, output,
144+ mNotDefCmpState .parentSurfaceControlForChild );
122145 SAFE_PARCEL (output.writeFloat , color.r );
123146 SAFE_PARCEL (output.writeFloat , color.g );
124147 SAFE_PARCEL (output.writeFloat , color.b );
125148 SAFE_PARCEL (output.writeFloat , color.a );
126- SAFE_PARCEL (windowInfoHandle->writeToParcel , &output);
127- SAFE_PARCEL (output.write , transparentRegion);
149+ SAFE_PARCEL (mNotDefCmpState . windowInfoHandle ->writeToParcel , &output);
150+ SAFE_PARCEL (output.write , mNotDefCmpState . transparentRegion );
128151 SAFE_PARCEL (output.writeUint32 , bufferTransform);
129152 SAFE_PARCEL (output.writeBool , transformToDisplayInverse);
130153 SAFE_PARCEL (output.writeUint32 , static_cast <uint32_t >(dataspace));
131154 SAFE_PARCEL (output.write , hdrMetadata);
132- SAFE_PARCEL (output.write , surfaceDamageRegion);
155+ SAFE_PARCEL (output.write , mNotDefCmpState . surfaceDamageRegion );
133156 SAFE_PARCEL (output.writeInt32 , api);
134157
135158 if (sidebandStream) {
@@ -241,8 +264,10 @@ status_t layer_state_t::read(const Parcel& input)
241264 SAFE_PARCEL (input.readFloat , &crop.bottom );
242265 SAFE_PARCEL (input.readFloat , &crop.right );
243266
244- SAFE_PARCEL (SurfaceControl::readNullableFromParcel, input, &relativeLayerSurfaceControl);
245- SAFE_PARCEL (SurfaceControl::readNullableFromParcel, input, &parentSurfaceControlForChild);
267+ SAFE_PARCEL (SurfaceControl::readNullableFromParcel, input,
268+ &mNotDefCmpState .relativeLayerSurfaceControl );
269+ SAFE_PARCEL (SurfaceControl::readNullableFromParcel, input,
270+ &mNotDefCmpState .parentSurfaceControlForChild );
246271
247272 float tmpFloat = 0 ;
248273 SAFE_PARCEL (input.readFloat , &tmpFloat);
@@ -254,9 +279,9 @@ status_t layer_state_t::read(const Parcel& input)
254279 SAFE_PARCEL (input.readFloat , &tmpFloat);
255280 color.a = tmpFloat;
256281
257- SAFE_PARCEL (windowInfoHandle->readFromParcel , &input);
282+ SAFE_PARCEL (mNotDefCmpState . windowInfoHandle ->readFromParcel , &input);
258283
259- SAFE_PARCEL (input.read , transparentRegion);
284+ SAFE_PARCEL (input.read , mNotDefCmpState . transparentRegion );
260285 SAFE_PARCEL (input.readUint32 , &bufferTransform);
261286 SAFE_PARCEL (input.readBool , &transformToDisplayInverse);
262287
@@ -265,7 +290,7 @@ status_t layer_state_t::read(const Parcel& input)
265290 dataspace = static_cast <ui::Dataspace>(tmpUint32);
266291
267292 SAFE_PARCEL (input.read , hdrMetadata);
268- SAFE_PARCEL (input.read , surfaceDamageRegion);
293+ SAFE_PARCEL (input.read , mNotDefCmpState . surfaceDamageRegion );
269294 SAFE_PARCEL (input.readInt32 , &api);
270295
271296 bool tmpBool = false ;
@@ -583,7 +608,7 @@ void layer_state_t::merge(const layer_state_t& other) {
583608 }
584609 if (other.what & eTransparentRegionChanged) {
585610 what |= eTransparentRegionChanged;
586- transparentRegion = other.transparentRegion ;
611+ mNotDefCmpState . transparentRegion = other. mNotDefCmpState .transparentRegion ;
587612 }
588613 if (other.what & eFlagsChanged) {
589614 what |= eFlagsChanged;
@@ -615,11 +640,13 @@ void layer_state_t::merge(const layer_state_t& other) {
615640 what |= eRelativeLayerChanged;
616641 what &= ~eLayerChanged;
617642 z = other.z ;
618- relativeLayerSurfaceControl = other.relativeLayerSurfaceControl ;
643+ mNotDefCmpState .relativeLayerSurfaceControl =
644+ other.mNotDefCmpState .relativeLayerSurfaceControl ;
619645 }
620646 if (other.what & eReparent) {
621647 what |= eReparent;
622- parentSurfaceControlForChild = other.parentSurfaceControlForChild ;
648+ mNotDefCmpState .parentSurfaceControlForChild =
649+ other.mNotDefCmpState .parentSurfaceControlForChild ;
623650 }
624651 if (other.what & eBufferTransformChanged) {
625652 what |= eBufferTransformChanged;
@@ -665,7 +692,7 @@ void layer_state_t::merge(const layer_state_t& other) {
665692 }
666693 if (other.what & eSurfaceDamageRegionChanged) {
667694 what |= eSurfaceDamageRegionChanged;
668- surfaceDamageRegion = other.surfaceDamageRegion ;
695+ mNotDefCmpState . surfaceDamageRegion = other. mNotDefCmpState .surfaceDamageRegion ;
669696 }
670697 if (other.what & eApiChanged) {
671698 what |= eApiChanged;
@@ -684,7 +711,8 @@ void layer_state_t::merge(const layer_state_t& other) {
684711 }
685712 if (other.what & eInputInfoChanged) {
686713 what |= eInputInfoChanged;
687- windowInfoHandle = sp<WindowInfoHandle>::make (*other.windowInfoHandle );
714+ mNotDefCmpState .windowInfoHandle =
715+ sp<WindowInfoHandle>::make (*other.mNotDefCmpState .windowInfoHandle );
688716 }
689717 if (other.what & eBackgroundColorChanged) {
690718 what |= eBackgroundColorChanged;
@@ -807,7 +835,8 @@ uint64_t layer_state_t::diff(const layer_state_t& other) const {
807835 CHECK_DIFF (diff, eAlphaChanged, other, color.a );
808836 CHECK_DIFF (diff, eMatrixChanged, other, matrix);
809837 if (other.what & eTransparentRegionChanged &&
810- (!transparentRegion.hasSameRects (other.transparentRegion ))) {
838+ (!mNotDefCmpState .transparentRegion .hasSameRects (
839+ other.mNotDefCmpState .transparentRegion ))) {
811840 diff |= eTransparentRegionChanged;
812841 }
813842 if (other.what & eFlagsChanged) {
@@ -824,8 +853,8 @@ uint64_t layer_state_t::diff(const layer_state_t& other) const {
824853 diff &= ~eLayerChanged;
825854 }
826855 if (other.what & eReparent &&
827- !SurfaceControl::isSameSurface (parentSurfaceControlForChild,
828- other.parentSurfaceControlForChild )) {
856+ !SurfaceControl::isSameSurface (mNotDefCmpState . parentSurfaceControlForChild ,
857+ other.mNotDefCmpState . parentSurfaceControlForChild )) {
829858 diff |= eReparent;
830859 }
831860 CHECK_DIFF (diff, eBufferTransformChanged, other, bufferTransform);
@@ -839,7 +868,8 @@ uint64_t layer_state_t::diff(const layer_state_t& other) const {
839868 CHECK_DIFF (diff, eCachingHintChanged, other, cachingHint);
840869 CHECK_DIFF (diff, eHdrMetadataChanged, other, hdrMetadata);
841870 if (other.what & eSurfaceDamageRegionChanged &&
842- (!surfaceDamageRegion.hasSameRects (other.surfaceDamageRegion ))) {
871+ (!mNotDefCmpState .surfaceDamageRegion .hasSameRects (
872+ other.mNotDefCmpState .surfaceDamageRegion ))) {
843873 diff |= eSurfaceDamageRegionChanged;
844874 }
845875 CHECK_DIFF (diff, eApiChanged, other, api);
@@ -901,6 +931,38 @@ status_t layer_state_t::matrix22_t::read(const Parcel& input) {
901931 SAFE_PARCEL (input.readFloat , &dsdy);
902932 return NO_ERROR;
903933}
934+ void layer_state_t::updateTransparentRegion (const Region& transparentRegion) {
935+ what |= eTransparentRegionChanged;
936+ mNotDefCmpState .transparentRegion = transparentRegion;
937+ }
938+ void layer_state_t::updateSurfaceDamageRegion (const Region& surfaceDamageRegion) {
939+ what |= eSurfaceDamageRegionChanged;
940+ mNotDefCmpState .surfaceDamageRegion = surfaceDamageRegion;
941+ }
942+ void layer_state_t::updateRelativeLayer (const sp<SurfaceControl>& relativeTo, int32_t z) {
943+ what |= layer_state_t ::eRelativeLayerChanged;
944+ what &= ~layer_state_t ::eLayerChanged;
945+ mNotDefCmpState .relativeLayerSurfaceControl = relativeTo;
946+ this ->z = z;
947+ }
948+ void layer_state_t::updateParentLayer (const sp<SurfaceControl>& newParent) {
949+ what |= layer_state_t ::eReparent;
950+ mNotDefCmpState .parentSurfaceControlForChild =
951+ newParent ? newParent->getParentingLayer () : nullptr ;
952+ }
953+ void layer_state_t::updateInputWindowInfo (sp<gui::WindowInfoHandle>&& info) {
954+ what |= eInputInfoChanged;
955+ mNotDefCmpState .windowInfoHandle = std::move (info);
956+ }
957+
958+ bool layer_state_t ::NotDefaultComparableState::operator ==(
959+ const NotDefaultComparableState& rhs) const {
960+ return transparentRegion.hasSameRects (rhs.transparentRegion ) &&
961+ surfaceDamageRegion.hasSameRects (rhs.surfaceDamageRegion ) &&
962+ isSameWindowHandle (windowInfoHandle, rhs.windowInfoHandle ) &&
963+ isSameSurfaceControl (relativeLayerSurfaceControl, rhs.relativeLayerSurfaceControl ) &&
964+ isSameSurfaceControl (parentSurfaceControlForChild, rhs.parentSurfaceControlForChild );
965+ }
904966
905967// ------------------------------- InputWindowCommands ----------------------------------------
906968
@@ -1034,18 +1096,18 @@ status_t BufferData::readFromParcel(const Parcel* input) {
10341096}
10351097
10361098status_t TrustedPresentationListener::writeToParcel (Parcel* parcel) const {
1037- SAFE_PARCEL (parcel->writeStrongBinder , callbackInterface);
1038- SAFE_PARCEL (parcel->writeInt32 , callbackId);
1099+ SAFE_PARCEL (parcel->writeStrongBinder , mState . callbackInterface );
1100+ SAFE_PARCEL (parcel->writeInt32 , mState . callbackId );
10391101 return NO_ERROR;
10401102}
10411103
10421104status_t TrustedPresentationListener::readFromParcel (const Parcel* parcel) {
10431105 sp<IBinder> tmpBinder = nullptr ;
10441106 SAFE_PARCEL (parcel->readNullableStrongBinder , &tmpBinder);
10451107 if (tmpBinder) {
1046- callbackInterface = checked_interface_cast<ITransactionCompletedListener>(tmpBinder);
1108+ mState . callbackInterface = checked_interface_cast<ITransactionCompletedListener>(tmpBinder);
10471109 }
1048- SAFE_PARCEL (parcel->readInt32 , &callbackId);
1110+ SAFE_PARCEL (parcel->readInt32 , &mState . callbackId );
10491111 return NO_ERROR;
10501112}
10511113
0 commit comments