From 11dcc2207f651acf836aa611e48ce75db90258b0 Mon Sep 17 00:00:00 2001 From: Pablo Gamito Date: Sat, 12 Sep 2020 15:49:39 +0000 Subject: Pass surface control instead of handle as reference to layers in LayerState Allows us to have access to the layer id stored in surface control so that it can be dumped when tracing the transaction merges Test: Existing tests Change-Id: I3e466c69585937d8ce74a29a49fdbb7b3353a460 --- libs/gui/LayerState.cpp | 68 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 14 deletions(-) (limited to 'libs/gui/LayerState.cpp') diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp index 4a57b1bfac..a4de66e8a7 100644 --- a/libs/gui/LayerState.cpp +++ b/libs/gui/LayerState.cpp @@ -18,16 +18,55 @@ #include -#include #include -#include #include +#include #include +#include #include namespace android { +layer_state_t::layer_state_t() + : what(0), + x(0), + y(0), + z(0), + w(0), + h(0), + layerStack(0), + alpha(0), + flags(0), + mask(0), + reserved(0), + crop_legacy(Rect::INVALID_RECT), + cornerRadius(0.0f), + backgroundBlurRadius(0), + barrierFrameNumber(0), + overrideScalingMode(-1), + transform(0), + transformToDisplayInverse(false), + crop(Rect::INVALID_RECT), + orientedDisplaySpaceRect(Rect::INVALID_RECT), + dataspace(ui::Dataspace::UNKNOWN), + surfaceDamageRegion(), + api(-1), + colorTransform(mat4()), + bgColorAlpha(0), + bgColorDataspace(ui::Dataspace::UNKNOWN), + colorSpaceAgnostic(false), + shadowRadius(0.0f), + frameRateSelectionPriority(-1), + frameRate(0.0f), + frameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT), + fixedTransformHint(ui::Transform::ROT_INVALID), + frameNumber(0) { + matrix.dsdx = matrix.dtdy = 1.0f; + matrix.dsdy = matrix.dtdx = 0.0f; + hdrMetadata.validTypes = 0; +} + status_t layer_state_t::write(Parcel& output) const { SAFE_PARCEL(output.writeStrongBinder, surface); @@ -44,13 +83,13 @@ status_t layer_state_t::write(Parcel& output) const SAFE_PARCEL(output.writeUint32, mask); SAFE_PARCEL(matrix.write, output); SAFE_PARCEL(output.write, crop_legacy); - SAFE_PARCEL(output.writeStrongBinder, barrierHandle_legacy); - SAFE_PARCEL(output.writeStrongBinder, reparentHandle); + SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, barrierSurfaceControl_legacy); + SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, reparentSurfaceControl); SAFE_PARCEL(output.writeUint64, barrierFrameNumber); SAFE_PARCEL(output.writeInt32, overrideScalingMode); SAFE_PARCEL(output.writeStrongBinder, IInterface::asBinder(barrierGbp_legacy)); - SAFE_PARCEL(output.writeStrongBinder, relativeLayerHandle); - SAFE_PARCEL(output.writeStrongBinder, parentHandleForChild); + SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, relativeLayerSurfaceControl); + SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, parentSurfaceControlForChild); SAFE_PARCEL(output.writeFloat, color.r); SAFE_PARCEL(output.writeFloat, color.g); SAFE_PARCEL(output.writeFloat, color.b); @@ -135,8 +174,8 @@ status_t layer_state_t::read(const Parcel& input) SAFE_PARCEL(matrix.read, input); SAFE_PARCEL(input.read, crop_legacy); - SAFE_PARCEL(input.readNullableStrongBinder, &barrierHandle_legacy); - SAFE_PARCEL(input.readNullableStrongBinder, &reparentHandle); + SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &barrierSurfaceControl_legacy); + SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &reparentSurfaceControl); SAFE_PARCEL(input.readUint64, &barrierFrameNumber); SAFE_PARCEL(input.readInt32, &overrideScalingMode); @@ -144,9 +183,10 @@ status_t layer_state_t::read(const Parcel& input) SAFE_PARCEL(input.readNullableStrongBinder, &tmpBinder); barrierGbp_legacy = interface_cast(tmpBinder); + SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &relativeLayerSurfaceControl); + SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &parentSurfaceControlForChild); + float tmpFloat = 0; - SAFE_PARCEL(input.readNullableStrongBinder, &relativeLayerHandle); - SAFE_PARCEL(input.readNullableStrongBinder, &parentHandleForChild); SAFE_PARCEL(input.readFloat, &tmpFloat); color.r = tmpFloat; SAFE_PARCEL(input.readFloat, &tmpFloat); @@ -342,7 +382,7 @@ void layer_state_t::merge(const layer_state_t& other) { } if (other.what & eDeferTransaction_legacy) { what |= eDeferTransaction_legacy; - barrierHandle_legacy = other.barrierHandle_legacy; + barrierSurfaceControl_legacy = other.barrierSurfaceControl_legacy; barrierGbp_legacy = other.barrierGbp_legacy; barrierFrameNumber = other.barrierFrameNumber; } @@ -352,7 +392,7 @@ void layer_state_t::merge(const layer_state_t& other) { } if (other.what & eReparentChildren) { what |= eReparentChildren; - reparentHandle = other.reparentHandle; + reparentSurfaceControl = other.reparentSurfaceControl; } if (other.what & eDetachChildren) { what |= eDetachChildren; @@ -361,11 +401,11 @@ void layer_state_t::merge(const layer_state_t& other) { what |= eRelativeLayerChanged; what &= ~eLayerChanged; z = other.z; - relativeLayerHandle = other.relativeLayerHandle; + relativeLayerSurfaceControl = other.relativeLayerSurfaceControl; } if (other.what & eReparent) { what |= eReparent; - parentHandleForChild = other.parentHandleForChild; + parentSurfaceControlForChild = other.parentSurfaceControlForChild; } if (other.what & eDestroySurface) { what |= eDestroySurface; -- cgit v1.2.3-59-g8ed1b