summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/Layer.cpp
diff options
context:
space:
mode:
author Vishnu Nair <vishnun@google.com> 2022-10-18 19:18:16 +0000
committer Vishnu Nair <vishnun@google.com> 2022-10-25 17:46:55 +0000
commit07e2a48bf1640b68751e782d2ac79db444622c67 (patch)
tree44a92865dff96a7fba4e44effa54ee2766f1d193 /services/surfaceflinger/Layer.cpp
parente23e6bb2ad90eee19af11489052200e300afd9a5 (diff)
SF: Carve out LayerHandle
Move LayerHandle outside of layer so it can be used with the new LayerLifecycleManager. Make Handle fields like layer private and provide access functions so callers have to safely cast from a binder instead of directly casting it. Add layerid to LayerHandle since we want to expose the layer class in fewer places. Finally fold LayerCleaner class into LayerHandler. Bug: 238781169 Test: presubmit Change-Id: I86e08050cfcc89d68e6ed8fa0e8ff30063cf3603
Diffstat (limited to 'services/surfaceflinger/Layer.cpp')
-rw-r--r--services/surfaceflinger/Layer.cpp27
1 files changed, 6 insertions, 21 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index def0dfaa49..631cf65de8 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -70,6 +70,7 @@
#include "FrameTimeline.h"
#include "FrameTracer/FrameTracer.h"
#include "FrontEnd/LayerCreationArgs.h"
+#include "FrontEnd/LayerHandle.h"
#include "LayerProtoHelper.h"
#include "SurfaceFlinger.h"
#include "TimeStats/TimeStats.h"
@@ -332,7 +333,7 @@ sp<IBinder> Layer::getHandle() {
return nullptr;
}
mGetHandleCalled = true;
- return sp<Handle>::make(mFlinger, sp<Layer>::fromExisting(this));
+ return sp<LayerHandle>::make(mFlinger, sp<Layer>::fromExisting(this));
}
// ---------------------------------------------------------------------------
@@ -774,7 +775,7 @@ void Layer::setZOrderRelativeOf(const wp<Layer>& relativeOf) {
}
bool Layer::setRelativeLayer(const sp<IBinder>& relativeToHandle, int32_t relativeZ) {
- sp<Layer> relative = fromHandle(relativeToHandle).promote();
+ sp<Layer> relative = LayerHandle::getLayer(relativeToHandle);
if (relative == nullptr) {
return false;
}
@@ -1543,7 +1544,7 @@ void Layer::setChildrenDrawingParent(const sp<Layer>& newParent) {
bool Layer::reparent(const sp<IBinder>& newParentHandle) {
sp<Layer> newParent;
if (newParentHandle != nullptr) {
- newParent = fromHandle(newParentHandle).promote();
+ newParent = LayerHandle::getLayer(newParentHandle);
if (newParent == nullptr) {
ALOGE("Unable to promote Layer handle");
return false;
@@ -1936,7 +1937,8 @@ void Layer::commitChildList() {
void Layer::setInputInfo(const WindowInfo& info) {
mDrawingState.inputInfo = info;
- mDrawingState.touchableRegionCrop = fromHandle(info.touchableRegionCropHandle.promote());
+ mDrawingState.touchableRegionCrop =
+ LayerHandle::getLayer(info.touchableRegionCropHandle.promote());
mDrawingState.modified = true;
mFlinger->mUpdateInputInfo = true;
setTransactionFlags(eTransactionNeeded);
@@ -2583,23 +2585,6 @@ void Layer::setClonedChild(const sp<Layer>& clonedChild) {
mFlinger->mNumClones++;
}
-const String16 Layer::Handle::kDescriptor = String16("android.Layer.Handle");
-
-wp<Layer> Layer::fromHandle(const sp<IBinder>& handleBinder) {
- if (handleBinder == nullptr) {
- return nullptr;
- }
-
- BBinder* b = handleBinder->localBinder();
- if (b == nullptr || b->getInterfaceDescriptor() != Handle::kDescriptor) {
- return nullptr;
- }
-
- // We can safely cast this binder since its local and we verified its interface descriptor.
- sp<Handle> handle = sp<Handle>::cast(handleBinder);
- return handle->owner;
-}
-
bool Layer::setDropInputMode(gui::DropInputMode mode) {
if (mDrawingState.dropInputMode == mode) {
return false;