Loading services/surfaceflinger/FrontEnd/LayerHierarchy.h +0 −10 Original line number Original line Diff line number Diff line Loading @@ -104,16 +104,6 @@ public: static const TraversalPath ROOT; static const TraversalPath ROOT; }; }; struct TraversalPathHash { std::size_t operator()(const LayerHierarchy::TraversalPath& key) const { uint32_t hashCode = key.id * 31; if (key.mirrorRootId != UNASSIGNED_LAYER_ID) { hashCode += key.mirrorRootId * 31; } return std::hash<size_t>{}(hashCode); } }; // Helper class to add nodes to an existing traversal id and removes the // Helper class to add nodes to an existing traversal id and removes the // node when it goes out of scope. // node when it goes out of scope. class ScopedAddToTraversalPath { class ScopedAddToTraversalPath { Loading services/surfaceflinger/FrontEnd/LayerSnapshot.cpp +3 −8 Original line number Original line Diff line number Diff line Loading @@ -28,14 +28,9 @@ LayerSnapshot::LayerSnapshot(const RequestedLayerState& state, const LayerHierarchy::TraversalPath& path) const LayerHierarchy::TraversalPath& path) : path(path) { : path(path) { static uint32_t sUniqueSequenceId = 0; static uint32_t sUniqueSequenceId = 0; // Provide a unique id for all snapshots. // Provide a unique id for clones otherwise keeping using the sequence id. // A front end layer can generate multiple snapshots if its mirrored. // The seq id can still be useful for debugging if its available. // Additionally, if the layer is not reachable, we may choose to destroy uniqueSequence = (path.isClone()) ? sUniqueSequenceId++ : state.id; // and recreate the snapshot in which case the unique sequence id will // change. The consumer shouldn't tie any lifetimes to this unique id but // register a LayerLifecycleManager::ILifecycleListener or get a list of // destroyed layers from LayerLifecycleManager. uniqueSequence = sUniqueSequenceId++; sequence = static_cast<int32_t>(state.id); sequence = static_cast<int32_t>(state.id); name = state.name; name = state.name; textureName = state.textureName; textureName = state.textureName; Loading services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.h +11 −3 Original line number Original line Diff line number Diff line Loading @@ -68,7 +68,6 @@ public: void update(const Args&); void update(const Args&); std::vector<std::unique_ptr<LayerSnapshot>>& getSnapshots(); std::vector<std::unique_ptr<LayerSnapshot>>& getSnapshots(); LayerSnapshot* getSnapshot(uint32_t layerId) const; LayerSnapshot* getSnapshot(uint32_t layerId) const; LayerSnapshot* getSnapshot(const LayerHierarchy::TraversalPath& id) const; typedef std::function<void(const LayerSnapshot& snapshot)> ConstVisitor; typedef std::function<void(const LayerSnapshot& snapshot)> ConstVisitor; Loading @@ -87,6 +86,7 @@ public: private: private: friend class LayerSnapshotTest; friend class LayerSnapshotTest; LayerSnapshot* getSnapshot(const LayerHierarchy::TraversalPath& id) const; static LayerSnapshot getRootSnapshot(); static LayerSnapshot getRootSnapshot(); // return true if we were able to successfully update the snapshots via // return true if we were able to successfully update the snapshots via Loading Loading @@ -120,8 +120,16 @@ private: void updateChildState(LayerSnapshot& snapshot, const LayerSnapshot& childSnapshot, void updateChildState(LayerSnapshot& snapshot, const LayerSnapshot& childSnapshot, const Args& args); const Args& args); std::unordered_map<LayerHierarchy::TraversalPath, LayerSnapshot*, struct TraversalPathHash { LayerHierarchy::TraversalPathHash> std::size_t operator()(const LayerHierarchy::TraversalPath& key) const { uint32_t hashCode = key.id * 31; if (key.mirrorRootId != UNASSIGNED_LAYER_ID) { hashCode += key.mirrorRootId * 31; } return std::hash<size_t>{}(hashCode); } }; std::unordered_map<LayerHierarchy::TraversalPath, LayerSnapshot*, TraversalPathHash> mIdToSnapshot; mIdToSnapshot; std::vector<std::unique_ptr<LayerSnapshot>> mSnapshots; std::vector<std::unique_ptr<LayerSnapshot>> mSnapshots; LayerSnapshot mRootSnapshot; LayerSnapshot mRootSnapshot; Loading services/surfaceflinger/LayerProtoHelper.cpp +32 −79 Original line number Original line Diff line number Diff line Loading @@ -15,8 +15,6 @@ */ */ // TODO(b/129481165): remove the #pragma below and fix conversion issues // TODO(b/129481165): remove the #pragma below and fix conversion issues #include "FrontEnd/LayerCreationArgs.h" #include "FrontEnd/LayerSnapshot.h" #pragma clang diagnostic push #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wconversion" #pragma clang diagnostic ignored "-Wconversion" #pragma clang diagnostic ignored "-Wextra" #pragma clang diagnostic ignored "-Wextra" Loading Loading @@ -250,88 +248,47 @@ void LayerProtoHelper::readFromProto(const BlurRegion& proto, android::BlurRegio outRegion.bottom = proto.bottom(); outRegion.bottom = proto.bottom(); } } LayersProto LayerProtoFromSnapshotGenerator::generate(const frontend::LayerHierarchy& root) { void LayerProtoHelper::writeHierarchyToProto( mLayersProto.clear_layers(); LayersProto& outLayersProto, const frontend::LayerHierarchy& root, std::unordered_set<uint64_t> stackIdsToSkip; const frontend::LayerSnapshotBuilder& snapshotBuilder, if ((mTraceFlags & LayerTracing::TRACE_VIRTUAL_DISPLAYS) == 0) { const std::unordered_map<uint32_t, sp<Layer>>& legacyLayers, uint32_t traceFlags) { for (const auto& [layerStack, displayInfo] : mDisplayInfos) { using Variant = frontend::LayerHierarchy::Variant; if (displayInfo.isVirtual) { frontend::LayerSnapshot defaultSnapshot; stackIdsToSkip.insert(layerStack.id); } } } frontend::LayerHierarchy::TraversalPath path = frontend::LayerHierarchy::TraversalPath::ROOT; LayerProto* layerProto = outLayersProto.add_layers(); for (auto& [child, variant] : root.mChildren) { const frontend::RequestedLayerState& layer = *root.getLayer(); if (variant != frontend::LayerHierarchy::Variant::Attached || frontend::LayerSnapshot* snapshot = snapshotBuilder.getSnapshot(layer.id); stackIdsToSkip.find(child->getLayer()->layerStack.id) != stackIdsToSkip.end()) { continue; } frontend::LayerHierarchy::ScopedAddToTraversalPath addChildToPath(path, child->getLayer()->id, variant); LayerProtoFromSnapshotGenerator::writeHierarchyToProto(*child, path); } // fill in relative and parent info if (!snapshot) { for (int i = 0; i < mLayersProto.layers_size(); i++) { defaultSnapshot.uniqueSequence = layer.id; auto layerProto = mLayersProto.mutable_layers()->Mutable(i); snapshot = &defaultSnapshot; auto it = mChildToRelativeParent.find(layerProto->id()); if (it == mChildToRelativeParent.end()) { layerProto->set_z_order_relative_of(-1); } else { layerProto->set_z_order_relative_of(it->second); } it = mChildToParent.find(layerProto->id()); if (it == mChildToParent.end()) { layerProto->set_parent(-1); } else { layerProto->set_parent(it->second); } } writeSnapshotToProto(layerProto, layer, *snapshot, traceFlags); for (const auto& [child, variant] : root.mChildren) { if (variant == Variant::Attached || variant == Variant::Detached) { layerProto->add_children(child->getLayer()->id); } else if (variant == Variant::Relative) { layerProto->add_relatives(child->getLayer()->id); } } mDefaultSnapshots.clear(); mChildToRelativeParent.clear(); return std::move(mLayersProto); } } frontend::LayerSnapshot* LayerProtoFromSnapshotGenerator::getSnapshot( auto parent = root.getParent(); frontend::LayerHierarchy::TraversalPath& path, const frontend::RequestedLayerState& layer) { if (parent && parent->getLayer()) { frontend::LayerSnapshot* snapshot = mSnapshotBuilder.getSnapshot(path); layerProto->set_parent(parent->getLayer()->id); if (snapshot) { return snapshot; } else { } else { mDefaultSnapshots[path] = frontend::LayerSnapshot(layer, path); layerProto->set_parent(-1); return &mDefaultSnapshots[path]; } } } void LayerProtoFromSnapshotGenerator::writeHierarchyToProto( auto relativeParent = root.getRelativeParent(); const frontend::LayerHierarchy& root, frontend::LayerHierarchy::TraversalPath& path) { if (relativeParent && relativeParent->getLayer()) { using Variant = frontend::LayerHierarchy::Variant; layerProto->set_z_order_relative_of(relativeParent->getLayer()->id); LayerProto* layerProto = mLayersProto.add_layers(); } else { const frontend::RequestedLayerState& layer = *root.getLayer(); layerProto->set_z_order_relative_of(-1); frontend::LayerSnapshot* snapshot = getSnapshot(path, layer); LayerProtoHelper::writeSnapshotToProto(layerProto, layer, *snapshot, mTraceFlags); for (const auto& [child, variant] : root.mChildren) { frontend::LayerHierarchy::ScopedAddToTraversalPath addChildToPath(path, child->getLayer()->id, variant); frontend::LayerSnapshot* childSnapshot = getSnapshot(path, layer); if (variant == Variant::Attached || variant == Variant::Detached || variant == Variant::Mirror) { mChildToParent[childSnapshot->uniqueSequence] = snapshot->uniqueSequence; layerProto->add_children(childSnapshot->uniqueSequence); } else if (variant == Variant::Relative) { mChildToRelativeParent[childSnapshot->uniqueSequence] = snapshot->uniqueSequence; layerProto->add_relatives(childSnapshot->uniqueSequence); } } } if (mTraceFlags & LayerTracing::TRACE_COMPOSITION) { if (traceFlags & LayerTracing::TRACE_COMPOSITION) { auto it = mLegacyLayers.find(layer.id); auto it = legacyLayers.find(layer.id); if (it != mLegacyLayers.end()) { if (it != legacyLayers.end()) { it->second->writeCompositionStateToProto(layerProto); it->second->writeCompositionStateToProto(layerProto); } } } } Loading @@ -341,10 +298,7 @@ void LayerProtoFromSnapshotGenerator::writeHierarchyToProto( if (variant == Variant::Detached) { if (variant == Variant::Detached) { continue; continue; } } frontend::LayerHierarchy::ScopedAddToTraversalPath addChildToPath(path, writeHierarchyToProto(outLayersProto, *child, snapshotBuilder, legacyLayers, traceFlags); child->getLayer()->id, variant); writeHierarchyToProto(*child, path); } } } } Loading Loading @@ -391,7 +345,6 @@ void LayerProtoHelper::writeSnapshotToProto(LayerProto* layerInfo, layerInfo->set_shadow_radius(snapshot.shadowRadius); layerInfo->set_shadow_radius(snapshot.shadowRadius); layerInfo->set_id(snapshot.uniqueSequence); layerInfo->set_id(snapshot.uniqueSequence); layerInfo->set_original_id(snapshot.sequence); layerInfo->set_name(requestedState.name); layerInfo->set_name(requestedState.name); layerInfo->set_type("Layer"); layerInfo->set_type("Layer"); Loading services/surfaceflinger/LayerProtoHelper.h +5 −36 Original line number Original line Diff line number Diff line Loading @@ -25,9 +25,6 @@ #include <ui/Rect.h> #include <ui/Rect.h> #include <ui/Region.h> #include <ui/Region.h> #include <ui/Transform.h> #include <ui/Transform.h> #include <cstdint> #include "FrontEnd/LayerHierarchy.h" #include "FrontEnd/LayerSnapshot.h" namespace android { namespace android { namespace surfaceflinger { namespace surfaceflinger { Loading Loading @@ -61,6 +58,11 @@ public: static void readFromProto(const ColorTransformProto& colorTransformProto, mat4& matrix); static void readFromProto(const ColorTransformProto& colorTransformProto, mat4& matrix); static void writeToProto(const android::BlurRegion region, BlurRegion*); static void writeToProto(const android::BlurRegion region, BlurRegion*); static void readFromProto(const BlurRegion& proto, android::BlurRegion& outRegion); static void readFromProto(const BlurRegion& proto, android::BlurRegion& outRegion); static void writeHierarchyToProto(LayersProto& layersProto, const frontend::LayerHierarchy& root, const frontend::LayerSnapshotBuilder& snapshotBuilder, const std::unordered_map<uint32_t, sp<Layer>>& mLegacyLayers, uint32_t traceFlags); static void writeSnapshotToProto(LayerProto* outProto, static void writeSnapshotToProto(LayerProto* outProto, const frontend::RequestedLayerState& requestedState, const frontend::RequestedLayerState& requestedState, const frontend::LayerSnapshot& snapshot, uint32_t traceFlags); const frontend::LayerSnapshot& snapshot, uint32_t traceFlags); Loading @@ -68,38 +70,5 @@ public: const display::DisplayMap<ui::LayerStack, frontend::DisplayInfo>& displayInfos); const display::DisplayMap<ui::LayerStack, frontend::DisplayInfo>& displayInfos); }; }; class LayerProtoFromSnapshotGenerator { public: LayerProtoFromSnapshotGenerator( const frontend::LayerSnapshotBuilder& snapshotBuilder, const display::DisplayMap<ui::LayerStack, frontend::DisplayInfo>& displayInfos, const std::unordered_map<uint32_t, sp<Layer>>& legacyLayers, uint32_t traceFlags) : mSnapshotBuilder(snapshotBuilder), mLegacyLayers(legacyLayers), mDisplayInfos(displayInfos), mTraceFlags(traceFlags) {} LayersProto generate(const frontend::LayerHierarchy& root); private: void writeHierarchyToProto(const frontend::LayerHierarchy& root, frontend::LayerHierarchy::TraversalPath& path); frontend::LayerSnapshot* getSnapshot(frontend::LayerHierarchy::TraversalPath& path, const frontend::RequestedLayerState& layer); const frontend::LayerSnapshotBuilder& mSnapshotBuilder; const std::unordered_map<uint32_t, sp<Layer>>& mLegacyLayers; const display::DisplayMap<ui::LayerStack, frontend::DisplayInfo>& mDisplayInfos; uint32_t mTraceFlags; LayersProto mLayersProto; // winscope expects all the layers, so provide a snapshot even if it not currently drawing std::unordered_map<frontend::LayerHierarchy::TraversalPath, frontend::LayerSnapshot, frontend::LayerHierarchy::TraversalPathHash> mDefaultSnapshots; std::unordered_map<uint32_t /* child unique seq*/, uint32_t /* relative parent unique seq*/> mChildToRelativeParent; std::unordered_map<uint32_t /* child unique seq*/, uint32_t /* parent unique seq*/> mChildToParent; }; } // namespace surfaceflinger } // namespace surfaceflinger } // namespace android } // namespace android Loading
services/surfaceflinger/FrontEnd/LayerHierarchy.h +0 −10 Original line number Original line Diff line number Diff line Loading @@ -104,16 +104,6 @@ public: static const TraversalPath ROOT; static const TraversalPath ROOT; }; }; struct TraversalPathHash { std::size_t operator()(const LayerHierarchy::TraversalPath& key) const { uint32_t hashCode = key.id * 31; if (key.mirrorRootId != UNASSIGNED_LAYER_ID) { hashCode += key.mirrorRootId * 31; } return std::hash<size_t>{}(hashCode); } }; // Helper class to add nodes to an existing traversal id and removes the // Helper class to add nodes to an existing traversal id and removes the // node when it goes out of scope. // node when it goes out of scope. class ScopedAddToTraversalPath { class ScopedAddToTraversalPath { Loading
services/surfaceflinger/FrontEnd/LayerSnapshot.cpp +3 −8 Original line number Original line Diff line number Diff line Loading @@ -28,14 +28,9 @@ LayerSnapshot::LayerSnapshot(const RequestedLayerState& state, const LayerHierarchy::TraversalPath& path) const LayerHierarchy::TraversalPath& path) : path(path) { : path(path) { static uint32_t sUniqueSequenceId = 0; static uint32_t sUniqueSequenceId = 0; // Provide a unique id for all snapshots. // Provide a unique id for clones otherwise keeping using the sequence id. // A front end layer can generate multiple snapshots if its mirrored. // The seq id can still be useful for debugging if its available. // Additionally, if the layer is not reachable, we may choose to destroy uniqueSequence = (path.isClone()) ? sUniqueSequenceId++ : state.id; // and recreate the snapshot in which case the unique sequence id will // change. The consumer shouldn't tie any lifetimes to this unique id but // register a LayerLifecycleManager::ILifecycleListener or get a list of // destroyed layers from LayerLifecycleManager. uniqueSequence = sUniqueSequenceId++; sequence = static_cast<int32_t>(state.id); sequence = static_cast<int32_t>(state.id); name = state.name; name = state.name; textureName = state.textureName; textureName = state.textureName; Loading
services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.h +11 −3 Original line number Original line Diff line number Diff line Loading @@ -68,7 +68,6 @@ public: void update(const Args&); void update(const Args&); std::vector<std::unique_ptr<LayerSnapshot>>& getSnapshots(); std::vector<std::unique_ptr<LayerSnapshot>>& getSnapshots(); LayerSnapshot* getSnapshot(uint32_t layerId) const; LayerSnapshot* getSnapshot(uint32_t layerId) const; LayerSnapshot* getSnapshot(const LayerHierarchy::TraversalPath& id) const; typedef std::function<void(const LayerSnapshot& snapshot)> ConstVisitor; typedef std::function<void(const LayerSnapshot& snapshot)> ConstVisitor; Loading @@ -87,6 +86,7 @@ public: private: private: friend class LayerSnapshotTest; friend class LayerSnapshotTest; LayerSnapshot* getSnapshot(const LayerHierarchy::TraversalPath& id) const; static LayerSnapshot getRootSnapshot(); static LayerSnapshot getRootSnapshot(); // return true if we were able to successfully update the snapshots via // return true if we were able to successfully update the snapshots via Loading Loading @@ -120,8 +120,16 @@ private: void updateChildState(LayerSnapshot& snapshot, const LayerSnapshot& childSnapshot, void updateChildState(LayerSnapshot& snapshot, const LayerSnapshot& childSnapshot, const Args& args); const Args& args); std::unordered_map<LayerHierarchy::TraversalPath, LayerSnapshot*, struct TraversalPathHash { LayerHierarchy::TraversalPathHash> std::size_t operator()(const LayerHierarchy::TraversalPath& key) const { uint32_t hashCode = key.id * 31; if (key.mirrorRootId != UNASSIGNED_LAYER_ID) { hashCode += key.mirrorRootId * 31; } return std::hash<size_t>{}(hashCode); } }; std::unordered_map<LayerHierarchy::TraversalPath, LayerSnapshot*, TraversalPathHash> mIdToSnapshot; mIdToSnapshot; std::vector<std::unique_ptr<LayerSnapshot>> mSnapshots; std::vector<std::unique_ptr<LayerSnapshot>> mSnapshots; LayerSnapshot mRootSnapshot; LayerSnapshot mRootSnapshot; Loading
services/surfaceflinger/LayerProtoHelper.cpp +32 −79 Original line number Original line Diff line number Diff line Loading @@ -15,8 +15,6 @@ */ */ // TODO(b/129481165): remove the #pragma below and fix conversion issues // TODO(b/129481165): remove the #pragma below and fix conversion issues #include "FrontEnd/LayerCreationArgs.h" #include "FrontEnd/LayerSnapshot.h" #pragma clang diagnostic push #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wconversion" #pragma clang diagnostic ignored "-Wconversion" #pragma clang diagnostic ignored "-Wextra" #pragma clang diagnostic ignored "-Wextra" Loading Loading @@ -250,88 +248,47 @@ void LayerProtoHelper::readFromProto(const BlurRegion& proto, android::BlurRegio outRegion.bottom = proto.bottom(); outRegion.bottom = proto.bottom(); } } LayersProto LayerProtoFromSnapshotGenerator::generate(const frontend::LayerHierarchy& root) { void LayerProtoHelper::writeHierarchyToProto( mLayersProto.clear_layers(); LayersProto& outLayersProto, const frontend::LayerHierarchy& root, std::unordered_set<uint64_t> stackIdsToSkip; const frontend::LayerSnapshotBuilder& snapshotBuilder, if ((mTraceFlags & LayerTracing::TRACE_VIRTUAL_DISPLAYS) == 0) { const std::unordered_map<uint32_t, sp<Layer>>& legacyLayers, uint32_t traceFlags) { for (const auto& [layerStack, displayInfo] : mDisplayInfos) { using Variant = frontend::LayerHierarchy::Variant; if (displayInfo.isVirtual) { frontend::LayerSnapshot defaultSnapshot; stackIdsToSkip.insert(layerStack.id); } } } frontend::LayerHierarchy::TraversalPath path = frontend::LayerHierarchy::TraversalPath::ROOT; LayerProto* layerProto = outLayersProto.add_layers(); for (auto& [child, variant] : root.mChildren) { const frontend::RequestedLayerState& layer = *root.getLayer(); if (variant != frontend::LayerHierarchy::Variant::Attached || frontend::LayerSnapshot* snapshot = snapshotBuilder.getSnapshot(layer.id); stackIdsToSkip.find(child->getLayer()->layerStack.id) != stackIdsToSkip.end()) { continue; } frontend::LayerHierarchy::ScopedAddToTraversalPath addChildToPath(path, child->getLayer()->id, variant); LayerProtoFromSnapshotGenerator::writeHierarchyToProto(*child, path); } // fill in relative and parent info if (!snapshot) { for (int i = 0; i < mLayersProto.layers_size(); i++) { defaultSnapshot.uniqueSequence = layer.id; auto layerProto = mLayersProto.mutable_layers()->Mutable(i); snapshot = &defaultSnapshot; auto it = mChildToRelativeParent.find(layerProto->id()); if (it == mChildToRelativeParent.end()) { layerProto->set_z_order_relative_of(-1); } else { layerProto->set_z_order_relative_of(it->second); } it = mChildToParent.find(layerProto->id()); if (it == mChildToParent.end()) { layerProto->set_parent(-1); } else { layerProto->set_parent(it->second); } } writeSnapshotToProto(layerProto, layer, *snapshot, traceFlags); for (const auto& [child, variant] : root.mChildren) { if (variant == Variant::Attached || variant == Variant::Detached) { layerProto->add_children(child->getLayer()->id); } else if (variant == Variant::Relative) { layerProto->add_relatives(child->getLayer()->id); } } mDefaultSnapshots.clear(); mChildToRelativeParent.clear(); return std::move(mLayersProto); } } frontend::LayerSnapshot* LayerProtoFromSnapshotGenerator::getSnapshot( auto parent = root.getParent(); frontend::LayerHierarchy::TraversalPath& path, const frontend::RequestedLayerState& layer) { if (parent && parent->getLayer()) { frontend::LayerSnapshot* snapshot = mSnapshotBuilder.getSnapshot(path); layerProto->set_parent(parent->getLayer()->id); if (snapshot) { return snapshot; } else { } else { mDefaultSnapshots[path] = frontend::LayerSnapshot(layer, path); layerProto->set_parent(-1); return &mDefaultSnapshots[path]; } } } void LayerProtoFromSnapshotGenerator::writeHierarchyToProto( auto relativeParent = root.getRelativeParent(); const frontend::LayerHierarchy& root, frontend::LayerHierarchy::TraversalPath& path) { if (relativeParent && relativeParent->getLayer()) { using Variant = frontend::LayerHierarchy::Variant; layerProto->set_z_order_relative_of(relativeParent->getLayer()->id); LayerProto* layerProto = mLayersProto.add_layers(); } else { const frontend::RequestedLayerState& layer = *root.getLayer(); layerProto->set_z_order_relative_of(-1); frontend::LayerSnapshot* snapshot = getSnapshot(path, layer); LayerProtoHelper::writeSnapshotToProto(layerProto, layer, *snapshot, mTraceFlags); for (const auto& [child, variant] : root.mChildren) { frontend::LayerHierarchy::ScopedAddToTraversalPath addChildToPath(path, child->getLayer()->id, variant); frontend::LayerSnapshot* childSnapshot = getSnapshot(path, layer); if (variant == Variant::Attached || variant == Variant::Detached || variant == Variant::Mirror) { mChildToParent[childSnapshot->uniqueSequence] = snapshot->uniqueSequence; layerProto->add_children(childSnapshot->uniqueSequence); } else if (variant == Variant::Relative) { mChildToRelativeParent[childSnapshot->uniqueSequence] = snapshot->uniqueSequence; layerProto->add_relatives(childSnapshot->uniqueSequence); } } } if (mTraceFlags & LayerTracing::TRACE_COMPOSITION) { if (traceFlags & LayerTracing::TRACE_COMPOSITION) { auto it = mLegacyLayers.find(layer.id); auto it = legacyLayers.find(layer.id); if (it != mLegacyLayers.end()) { if (it != legacyLayers.end()) { it->second->writeCompositionStateToProto(layerProto); it->second->writeCompositionStateToProto(layerProto); } } } } Loading @@ -341,10 +298,7 @@ void LayerProtoFromSnapshotGenerator::writeHierarchyToProto( if (variant == Variant::Detached) { if (variant == Variant::Detached) { continue; continue; } } frontend::LayerHierarchy::ScopedAddToTraversalPath addChildToPath(path, writeHierarchyToProto(outLayersProto, *child, snapshotBuilder, legacyLayers, traceFlags); child->getLayer()->id, variant); writeHierarchyToProto(*child, path); } } } } Loading Loading @@ -391,7 +345,6 @@ void LayerProtoHelper::writeSnapshotToProto(LayerProto* layerInfo, layerInfo->set_shadow_radius(snapshot.shadowRadius); layerInfo->set_shadow_radius(snapshot.shadowRadius); layerInfo->set_id(snapshot.uniqueSequence); layerInfo->set_id(snapshot.uniqueSequence); layerInfo->set_original_id(snapshot.sequence); layerInfo->set_name(requestedState.name); layerInfo->set_name(requestedState.name); layerInfo->set_type("Layer"); layerInfo->set_type("Layer"); Loading
services/surfaceflinger/LayerProtoHelper.h +5 −36 Original line number Original line Diff line number Diff line Loading @@ -25,9 +25,6 @@ #include <ui/Rect.h> #include <ui/Rect.h> #include <ui/Region.h> #include <ui/Region.h> #include <ui/Transform.h> #include <ui/Transform.h> #include <cstdint> #include "FrontEnd/LayerHierarchy.h" #include "FrontEnd/LayerSnapshot.h" namespace android { namespace android { namespace surfaceflinger { namespace surfaceflinger { Loading Loading @@ -61,6 +58,11 @@ public: static void readFromProto(const ColorTransformProto& colorTransformProto, mat4& matrix); static void readFromProto(const ColorTransformProto& colorTransformProto, mat4& matrix); static void writeToProto(const android::BlurRegion region, BlurRegion*); static void writeToProto(const android::BlurRegion region, BlurRegion*); static void readFromProto(const BlurRegion& proto, android::BlurRegion& outRegion); static void readFromProto(const BlurRegion& proto, android::BlurRegion& outRegion); static void writeHierarchyToProto(LayersProto& layersProto, const frontend::LayerHierarchy& root, const frontend::LayerSnapshotBuilder& snapshotBuilder, const std::unordered_map<uint32_t, sp<Layer>>& mLegacyLayers, uint32_t traceFlags); static void writeSnapshotToProto(LayerProto* outProto, static void writeSnapshotToProto(LayerProto* outProto, const frontend::RequestedLayerState& requestedState, const frontend::RequestedLayerState& requestedState, const frontend::LayerSnapshot& snapshot, uint32_t traceFlags); const frontend::LayerSnapshot& snapshot, uint32_t traceFlags); Loading @@ -68,38 +70,5 @@ public: const display::DisplayMap<ui::LayerStack, frontend::DisplayInfo>& displayInfos); const display::DisplayMap<ui::LayerStack, frontend::DisplayInfo>& displayInfos); }; }; class LayerProtoFromSnapshotGenerator { public: LayerProtoFromSnapshotGenerator( const frontend::LayerSnapshotBuilder& snapshotBuilder, const display::DisplayMap<ui::LayerStack, frontend::DisplayInfo>& displayInfos, const std::unordered_map<uint32_t, sp<Layer>>& legacyLayers, uint32_t traceFlags) : mSnapshotBuilder(snapshotBuilder), mLegacyLayers(legacyLayers), mDisplayInfos(displayInfos), mTraceFlags(traceFlags) {} LayersProto generate(const frontend::LayerHierarchy& root); private: void writeHierarchyToProto(const frontend::LayerHierarchy& root, frontend::LayerHierarchy::TraversalPath& path); frontend::LayerSnapshot* getSnapshot(frontend::LayerHierarchy::TraversalPath& path, const frontend::RequestedLayerState& layer); const frontend::LayerSnapshotBuilder& mSnapshotBuilder; const std::unordered_map<uint32_t, sp<Layer>>& mLegacyLayers; const display::DisplayMap<ui::LayerStack, frontend::DisplayInfo>& mDisplayInfos; uint32_t mTraceFlags; LayersProto mLayersProto; // winscope expects all the layers, so provide a snapshot even if it not currently drawing std::unordered_map<frontend::LayerHierarchy::TraversalPath, frontend::LayerSnapshot, frontend::LayerHierarchy::TraversalPathHash> mDefaultSnapshots; std::unordered_map<uint32_t /* child unique seq*/, uint32_t /* relative parent unique seq*/> mChildToRelativeParent; std::unordered_map<uint32_t /* child unique seq*/, uint32_t /* parent unique seq*/> mChildToParent; }; } // namespace surfaceflinger } // namespace surfaceflinger } // namespace android } // namespace android