diff options
author | 2023-09-01 00:45:24 +0000 | |
---|---|---|
committer | 2023-09-01 10:29:33 +0800 | |
commit | 2401daf78395903f1940bbb1b5e2bc777efd2802 (patch) | |
tree | 0678919512c3431dedb6083c2b3467c71e84588f | |
parent | b194d7ba3c207505c5eeafa407e3c3e256461da2 (diff) |
Revert "Move proto definitions to external/perfetto"
This reverts commit bec51fdc3c8a42cbcb833d7d14800fbb0a14a7f3.
Reason for revert: 298512106
Change-Id: Icb9d6d5a23176a809c3b71bcaa3928b03dfb0622
29 files changed, 934 insertions, 296 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index d4babdbd79..cdf7cff76d 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -139,7 +139,7 @@ using gui::WindowInfo; using PresentState = frametimeline::SurfaceFrame::PresentState; -Layer::Layer(const surfaceflinger::LayerCreationArgs& args) +Layer::Layer(const LayerCreationArgs& args) : sequence(args.sequence), mFlinger(sp<SurfaceFlinger>::fromExisting(args.flinger)), mName(base::StringPrintf("%s#%d", args.name.c_str(), sequence)), @@ -1000,8 +1000,8 @@ bool Layer::setBackgroundColor(const half3& color, float alpha, ui::Dataspace da uint32_t flags = ISurfaceComposerClient::eFXSurfaceEffect; std::string name = mName + "BackgroundColorLayer"; mDrawingState.bgColorLayer = mFlinger->getFactory().createEffectLayer( - surfaceflinger::LayerCreationArgs(mFlinger.get(), nullptr, std::move(name), flags, - LayerMetadata())); + LayerCreationArgs(mFlinger.get(), nullptr, std::move(name), flags, + LayerMetadata())); // add to child list addChild(mDrawingState.bgColorLayer); @@ -2203,9 +2203,8 @@ void Layer::setInputInfo(const WindowInfo& info) { setTransactionFlags(eTransactionNeeded); } -perfetto::protos::LayerProto* Layer::writeToProto(perfetto::protos::LayersProto& layersProto, - uint32_t traceFlags) { - perfetto::protos::LayerProto* layerProto = layersProto.add_layers(); +LayerProto* Layer::writeToProto(LayersProto& layersProto, uint32_t traceFlags) { + LayerProto* layerProto = layersProto.add_layers(); writeToProtoDrawingState(layerProto); writeToProtoCommonState(layerProto, LayerVector::StateSet::Drawing, traceFlags); @@ -2222,22 +2221,20 @@ perfetto::protos::LayerProto* Layer::writeToProto(perfetto::protos::LayersProto& return layerProto; } -void Layer::writeCompositionStateToProto(perfetto::protos::LayerProto* layerProto, - ui::LayerStack layerStack) { +void Layer::writeCompositionStateToProto(LayerProto* layerProto, ui::LayerStack layerStack) { ftl::FakeGuard guard(mFlinger->mStateLock); // Called from the main thread. ftl::FakeGuard mainThreadGuard(kMainThreadContext); // Only populate for the primary display. if (const auto display = mFlinger->getDisplayFromLayerStack(layerStack)) { const auto compositionType = getCompositionType(*display); - layerProto->set_hwc_composition_type( - static_cast<perfetto::protos::HwcCompositionType>(compositionType)); + layerProto->set_hwc_composition_type(static_cast<HwcCompositionType>(compositionType)); LayerProtoHelper::writeToProto(getVisibleRegion(display), [&]() { return layerProto->mutable_visible_region(); }); } } -void Layer::writeToProtoDrawingState(perfetto::protos::LayerProto* layerInfo) { +void Layer::writeToProtoDrawingState(LayerProto* layerInfo) { const ui::Transform transform = getTransform(); auto buffer = getExternalTexture(); if (buffer != nullptr) { @@ -2276,8 +2273,8 @@ void Layer::writeToProtoDrawingState(perfetto::protos::LayerProto* layerInfo) { layerInfo->set_shadow_radius(mEffectiveShadowRadius); } -void Layer::writeToProtoCommonState(perfetto::protos::LayerProto* layerInfo, - LayerVector::StateSet stateSet, uint32_t traceFlags) { +void Layer::writeToProtoCommonState(LayerProto* layerInfo, LayerVector::StateSet stateSet, + uint32_t traceFlags) { const bool useDrawing = stateSet == LayerVector::StateSet::Drawing; const LayerVector& children = useDrawing ? mDrawingChildren : mCurrentChildren; const State& state = useDrawing ? mDrawingState : mDrawingState; @@ -3633,8 +3630,7 @@ Rect Layer::computeBufferCrop(const State& s) { } sp<Layer> Layer::createClone(uint32_t mirrorRootId) { - surfaceflinger::LayerCreationArgs args(mFlinger.get(), nullptr, mName + " (Mirror)", 0, - LayerMetadata()); + LayerCreationArgs args(mFlinger.get(), nullptr, mName + " (Mirror)", 0, LayerMetadata()); sp<Layer> layer = mFlinger->getFactory().createBufferStateLayer(args); layer->setInitialValuesForClone(sp<Layer>::fromExisting(this), mirrorRootId); return layer; diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h index dc4ceb0bfa..7b6c56b6a8 100644 --- a/services/surfaceflinger/Layer.h +++ b/services/surfaceflinger/Layer.h @@ -235,7 +235,7 @@ public: bool useVsyncIdForRefreshRateSelection = false; }; - explicit Layer(const surfaceflinger::LayerCreationArgs& args); + explicit Layer(const LayerCreationArgs& args); virtual ~Layer(); static bool isLayerFocusedBasedOnPriority(int32_t priority); @@ -634,19 +634,17 @@ public: bool isRemovedFromCurrentState() const; - perfetto::protos::LayerProto* writeToProto(perfetto::protos::LayersProto& layersProto, - uint32_t traceFlags); - void writeCompositionStateToProto(perfetto::protos::LayerProto* layerProto, - ui::LayerStack layerStack); + LayerProto* writeToProto(LayersProto& layersProto, uint32_t traceFlags); + void writeCompositionStateToProto(LayerProto* layerProto, ui::LayerStack layerStack); // Write states that are modified by the main thread. This includes drawing // state as well as buffer data. This should be called in the main or tracing // thread. - void writeToProtoDrawingState(perfetto::protos::LayerProto* layerInfo); + void writeToProtoDrawingState(LayerProto* layerInfo); // Write drawing or current state. If writing current state, the caller should hold the // external mStateLock. If writing drawing state, this function should be called on the // main or tracing thread. - void writeToProtoCommonState(perfetto::protos::LayerProto* layerInfo, LayerVector::StateSet, + void writeToProtoCommonState(LayerProto* layerInfo, LayerVector::StateSet, uint32_t traceFlags = LayerTracing::TRACE_ALL); gui::WindowInfo::Type getWindowType() const { return mWindowType; } diff --git a/services/surfaceflinger/LayerProtoHelper.cpp b/services/surfaceflinger/LayerProtoHelper.cpp index 144e1f5abf..341f041086 100644 --- a/services/surfaceflinger/LayerProtoHelper.cpp +++ b/services/surfaceflinger/LayerProtoHelper.cpp @@ -29,30 +29,28 @@ using gui::WindowInfo; namespace surfaceflinger { -void LayerProtoHelper::writePositionToProto( - const float x, const float y, - std::function<perfetto::protos::PositionProto*()> getPositionProto) { +void LayerProtoHelper::writePositionToProto(const float x, const float y, + std::function<PositionProto*()> getPositionProto) { if (x != 0 || y != 0) { // Use a lambda do avoid writing the object header when the object is empty - perfetto::protos::PositionProto* position = getPositionProto(); + PositionProto* position = getPositionProto(); position->set_x(x); position->set_y(y); } } -void LayerProtoHelper::writeSizeToProto( - const uint32_t w, const uint32_t h, - std::function<perfetto::protos::SizeProto*()> getSizeProto) { +void LayerProtoHelper::writeSizeToProto(const uint32_t w, const uint32_t h, + std::function<SizeProto*()> getSizeProto) { if (w != 0 || h != 0) { // Use a lambda do avoid writing the object header when the object is empty - perfetto::protos::SizeProto* size = getSizeProto(); + SizeProto* size = getSizeProto(); size->set_w(w); size->set_h(h); } } -void LayerProtoHelper::writeToProto( - const Region& region, std::function<perfetto::protos::RegionProto*()> getRegionProto) { +void LayerProtoHelper::writeToProto(const Region& region, + std::function<RegionProto*()> getRegionProto) { if (region.isEmpty()) { return; } @@ -60,8 +58,7 @@ void LayerProtoHelper::writeToProto( writeToProto(region, getRegionProto()); } -void LayerProtoHelper::writeToProto(const Region& region, - perfetto::protos::RegionProto* regionProto) { +void LayerProtoHelper::writeToProto(const Region& region, RegionProto* regionProto) { if (region.isEmpty()) { return; } @@ -75,8 +72,7 @@ void LayerProtoHelper::writeToProto(const Region& region, } } -void LayerProtoHelper::readFromProto(const perfetto::protos::RegionProto& regionProto, - Region& outRegion) { +void LayerProtoHelper::readFromProto(const RegionProto& regionProto, Region& outRegion) { for (int i = 0; i < regionProto.rect_size(); i++) { Rect rect; readFromProto(regionProto.rect(i), rect); @@ -84,34 +80,32 @@ void LayerProtoHelper::readFromProto(const perfetto::protos::RegionProto& region } } -void LayerProtoHelper::writeToProto(const Rect& rect, - std::function<perfetto::protos::RectProto*()> getRectProto) { +void LayerProtoHelper::writeToProto(const Rect& rect, std::function<RectProto*()> getRectProto) { if (rect.left != 0 || rect.right != 0 || rect.top != 0 || rect.bottom != 0) { // Use a lambda do avoid writing the object header when the object is empty writeToProto(rect, getRectProto()); } } -void LayerProtoHelper::writeToProto(const Rect& rect, perfetto::protos::RectProto* rectProto) { +void LayerProtoHelper::writeToProto(const Rect& rect, RectProto* rectProto) { rectProto->set_left(rect.left); rectProto->set_top(rect.top); rectProto->set_bottom(rect.bottom); rectProto->set_right(rect.right); } -void LayerProtoHelper::readFromProto(const perfetto::protos::RectProto& proto, Rect& outRect) { +void LayerProtoHelper::readFromProto(const RectProto& proto, Rect& outRect) { outRect.left = proto.left(); outRect.top = proto.top(); outRect.bottom = proto.bottom(); outRect.right = proto.right(); } -void LayerProtoHelper::writeToProto( - const FloatRect& rect, - std::function<perfetto::protos::FloatRectProto*()> getFloatRectProto) { +void LayerProtoHelper::writeToProto(const FloatRect& rect, + std::function<FloatRectProto*()> getFloatRectProto) { if (rect.left != 0 || rect.right != 0 || rect.top != 0 || rect.bottom != 0) { // Use a lambda do avoid writing the object header when the object is empty - perfetto::protos::FloatRectProto* rectProto = getFloatRectProto(); + FloatRectProto* rectProto = getFloatRectProto(); rectProto->set_left(rect.left); rectProto->set_top(rect.top); rectProto->set_bottom(rect.bottom); @@ -119,11 +113,10 @@ void LayerProtoHelper::writeToProto( } } -void LayerProtoHelper::writeToProto(const half4 color, - std::function<perfetto::protos::ColorProto*()> getColorProto) { +void LayerProtoHelper::writeToProto(const half4 color, std::function<ColorProto*()> getColorProto) { if (color.r != 0 || color.g != 0 || color.b != 0 || color.a != 0) { // Use a lambda do avoid writing the object header when the object is empty - perfetto::protos::ColorProto* colorProto = getColorProto(); + ColorProto* colorProto = getColorProto(); colorProto->set_r(color.r); colorProto->set_g(color.g); colorProto->set_b(color.b); @@ -132,7 +125,7 @@ void LayerProtoHelper::writeToProto(const half4 color, } void LayerProtoHelper::writeToProtoDeprecated(const ui::Transform& transform, - perfetto::protos::TransformProto* transformProto) { + TransformProto* transformProto) { const uint32_t type = transform.getType() | (transform.getOrientation() << 8); transformProto->set_type(type); @@ -148,7 +141,7 @@ void LayerProtoHelper::writeToProtoDeprecated(const ui::Transform& transform, } void LayerProtoHelper::writeTransformToProto(const ui::Transform& transform, - perfetto::protos::TransformProto* transformProto) { + TransformProto* transformProto) { const uint32_t type = transform.getType() | (transform.getOrientation() << 8); transformProto->set_type(type); @@ -163,13 +156,12 @@ void LayerProtoHelper::writeTransformToProto(const ui::Transform& transform, } } -void LayerProtoHelper::writeToProto( - const renderengine::ExternalTexture& buffer, - std::function<perfetto::protos::ActiveBufferProto*()> getActiveBufferProto) { +void LayerProtoHelper::writeToProto(const renderengine::ExternalTexture& buffer, + std::function<ActiveBufferProto*()> getActiveBufferProto) { if (buffer.getWidth() != 0 || buffer.getHeight() != 0 || buffer.getUsage() != 0 || buffer.getPixelFormat() != 0) { // Use a lambda do avoid writing the object header when the object is empty - auto* activeBufferProto = getActiveBufferProto(); + ActiveBufferProto* activeBufferProto = getActiveBufferProto(); activeBufferProto->set_width(buffer.getWidth()); activeBufferProto->set_height(buffer.getHeight()); activeBufferProto->set_stride(buffer.getUsage()); @@ -179,12 +171,12 @@ void LayerProtoHelper::writeToProto( void LayerProtoHelper::writeToProto( const WindowInfo& inputInfo, const wp<Layer>& touchableRegionBounds, - std::function<perfetto::protos::InputWindowInfoProto*()> getInputWindowInfoProto) { + std::function<InputWindowInfoProto*()> getInputWindowInfoProto) { if (inputInfo.token == nullptr) { return; } - perfetto::protos::InputWindowInfoProto* proto = getInputWindowInfoProto(); + InputWindowInfoProto* proto = getInputWindowInfoProto(); proto->set_layout_params_flags(inputInfo.layoutParamsFlags.get()); proto->set_input_config(inputInfo.inputConfig.get()); using U = std::underlying_type_t<WindowInfo::Type>; @@ -217,8 +209,7 @@ void LayerProtoHelper::writeToProto( } } -void LayerProtoHelper::writeToProto(const mat4 matrix, - perfetto::protos::ColorTransformProto* colorTransformProto) { +void LayerProtoHelper::writeToProto(const mat4 matrix, ColorTransformProto* colorTransformProto) { for (int i = 0; i < mat4::ROW_SIZE; i++) { for (int j = 0; j < mat4::COL_SIZE; j++) { colorTransformProto->add_val(matrix[i][j]); @@ -226,8 +217,7 @@ void LayerProtoHelper::writeToProto(const mat4 matrix, } } -void LayerProtoHelper::readFromProto( - const perfetto::protos::ColorTransformProto& colorTransformProto, mat4& matrix) { +void LayerProtoHelper::readFromProto(const ColorTransformProto& colorTransformProto, mat4& matrix) { for (int i = 0; i < mat4::ROW_SIZE; i++) { for (int j = 0; j < mat4::COL_SIZE; j++) { matrix[i][j] = colorTransformProto.val(i * mat4::COL_SIZE + j); @@ -235,8 +225,7 @@ void LayerProtoHelper::readFromProto( } } -void LayerProtoHelper::writeToProto(const android::BlurRegion region, - perfetto::protos::BlurRegion* proto) { +void LayerProtoHelper::writeToProto(const android::BlurRegion region, BlurRegion* proto) { proto->set_blur_radius(region.blurRadius); proto->set_corner_radius_tl(region.cornerRadiusTL); proto->set_corner_radius_tr(region.cornerRadiusTR); @@ -249,8 +238,7 @@ void LayerProtoHelper::writeToProto(const android::BlurRegion region, proto->set_bottom(region.bottom); } -void LayerProtoHelper::readFromProto(const perfetto::protos::BlurRegion& proto, - android::BlurRegion& outRegion) { +void LayerProtoHelper::readFromProto(const BlurRegion& proto, android::BlurRegion& outRegion) { outRegion.blurRadius = proto.blur_radius(); outRegion.cornerRadiusTL = proto.corner_radius_tl(); outRegion.cornerRadiusTR = proto.corner_radius_tr(); @@ -263,8 +251,7 @@ void LayerProtoHelper::readFromProto(const perfetto::protos::BlurRegion& proto, outRegion.bottom = proto.bottom(); } -perfetto::protos::LayersProto LayerProtoFromSnapshotGenerator::generate( - const frontend::LayerHierarchy& root) { +LayersProto LayerProtoFromSnapshotGenerator::generate(const frontend::LayerHierarchy& root) { mLayersProto.clear_layers(); std::unordered_set<uint64_t> stackIdsToSkip; if ((mTraceFlags & LayerTracing::TRACE_VIRTUAL_DISPLAYS) == 0) { @@ -323,7 +310,7 @@ frontend::LayerSnapshot* LayerProtoFromSnapshotGenerator::getSnapshot( void LayerProtoFromSnapshotGenerator::writeHierarchyToProto( const frontend::LayerHierarchy& root, frontend::LayerHierarchy::TraversalPath& path) { using Variant = frontend::LayerHierarchy::Variant; - perfetto::protos::LayerProto* layerProto = mLayersProto.add_layers(); + LayerProto* layerProto = mLayersProto.add_layers(); const frontend::RequestedLayerState& layer = *root.getLayer(); frontend::LayerSnapshot* snapshot = getSnapshot(path, layer); LayerProtoHelper::writeSnapshotToProto(layerProto, layer, *snapshot, mTraceFlags); @@ -362,7 +349,7 @@ void LayerProtoFromSnapshotGenerator::writeHierarchyToProto( } } -void LayerProtoHelper::writeSnapshotToProto(perfetto::protos::LayerProto* layerInfo, +void LayerProtoHelper::writeSnapshotToProto(LayerProto* layerInfo, const frontend::RequestedLayerState& requestedState, const frontend::LayerSnapshot& snapshot, uint32_t traceFlags) { @@ -459,9 +446,9 @@ void LayerProtoHelper::writeSnapshotToProto(perfetto::protos::LayerProto* layerI [&]() { return layerInfo->mutable_destination_frame(); }); } -google::protobuf::RepeatedPtrField<perfetto::protos::DisplayProto> -LayerProtoHelper::writeDisplayInfoToProto(const frontend::DisplayInfos& displayInfos) { - google::protobuf::RepeatedPtrField<perfetto::protos::DisplayProto> displays; +google::protobuf::RepeatedPtrField<DisplayProto> LayerProtoHelper::writeDisplayInfoToProto( + const frontend::DisplayInfos& displayInfos) { + google::protobuf::RepeatedPtrField<DisplayProto> displays; displays.Reserve(displayInfos.size()); for (const auto& [layerStack, displayInfo] : displayInfos) { auto displayProto = displays.Add(); diff --git a/services/surfaceflinger/LayerProtoHelper.h b/services/surfaceflinger/LayerProtoHelper.h index 20c226006c..346685f259 100644 --- a/services/surfaceflinger/LayerProtoHelper.h +++ b/services/surfaceflinger/LayerProtoHelper.h @@ -35,47 +35,39 @@ namespace android { namespace surfaceflinger { class LayerProtoHelper { public: - static void writePositionToProto( - const float x, const float y, - std::function<perfetto::protos::PositionProto*()> getPositionProto); + static void writePositionToProto(const float x, const float y, + std::function<PositionProto*()> getPositionProto); static void writeSizeToProto(const uint32_t w, const uint32_t h, - std::function<perfetto::protos::SizeProto*()> getSizeProto); - static void writeToProto(const Rect& rect, - std::function<perfetto::protos::RectProto*()> getRectProto); - static void writeToProto(const Rect& rect, perfetto::protos::RectProto* rectProto); - static void readFromProto(const perfetto::protos::RectProto& proto, Rect& outRect); + std::function<SizeProto*()> getSizeProto); + static void writeToProto(const Rect& rect, std::function<RectProto*()> getRectProto); + static void writeToProto(const Rect& rect, RectProto* rectProto); + static void readFromProto(const RectProto& proto, Rect& outRect); static void writeToProto(const FloatRect& rect, - std::function<perfetto::protos::FloatRectProto*()> getFloatRectProto); - static void writeToProto(const Region& region, - std::function<perfetto::protos::RegionProto*()> getRegionProto); - static void writeToProto(const Region& region, perfetto::protos::RegionProto* regionProto); - static void readFromProto(const perfetto::protos::RegionProto& regionProto, Region& outRegion); - static void writeToProto(const half4 color, - std::function<perfetto::protos::ColorProto*()> getColorProto); + std::function<FloatRectProto*()> getFloatRectProto); + static void writeToProto(const Region& region, std::function<RegionProto*()> getRegionProto); + static void writeToProto(const Region& region, RegionProto* regionProto); + static void readFromProto(const RegionProto& regionProto, Region& outRegion); + static void writeToProto(const half4 color, std::function<ColorProto*()> getColorProto); // This writeToProto for transform is incorrect, but due to backwards compatibility, we can't // update Layers to use it. Use writeTransformToProto for any new transform proto data. static void writeToProtoDeprecated(const ui::Transform& transform, - perfetto::protos::TransformProto* transformProto); + TransformProto* transformProto); static void writeTransformToProto(const ui::Transform& transform, - perfetto::protos::TransformProto* transformProto); - static void writeToProto( - const renderengine::ExternalTexture& buffer, - std::function<perfetto::protos::ActiveBufferProto*()> getActiveBufferProto); - static void writeToProto( - const gui::WindowInfo& inputInfo, const wp<Layer>& touchableRegionBounds, - std::function<perfetto::protos::InputWindowInfoProto*()> getInputWindowInfoProto); - static void writeToProto(const mat4 matrix, - perfetto::protos::ColorTransformProto* colorTransformProto); - static void readFromProto(const perfetto::protos::ColorTransformProto& colorTransformProto, - mat4& matrix); - static void writeToProto(const android::BlurRegion region, perfetto::protos::BlurRegion*); - static void readFromProto(const perfetto::protos::BlurRegion& proto, - android::BlurRegion& outRegion); - static void writeSnapshotToProto(perfetto::protos::LayerProto* outProto, + TransformProto* transformProto); + static void writeToProto(const renderengine::ExternalTexture& buffer, + std::function<ActiveBufferProto*()> getActiveBufferProto); + static void writeToProto(const gui::WindowInfo& inputInfo, + const wp<Layer>& touchableRegionBounds, + std::function<InputWindowInfoProto*()> getInputWindowInfoProto); + static void writeToProto(const mat4 matrix, ColorTransformProto* colorTransformProto); + static void readFromProto(const ColorTransformProto& colorTransformProto, mat4& matrix); + static void writeToProto(const android::BlurRegion region, BlurRegion*); + static void readFromProto(const BlurRegion& proto, android::BlurRegion& outRegion); + static void writeSnapshotToProto(LayerProto* outProto, const frontend::RequestedLayerState& requestedState, const frontend::LayerSnapshot& snapshot, uint32_t traceFlags); - static google::protobuf::RepeatedPtrField<perfetto::protos::DisplayProto> - writeDisplayInfoToProto(const frontend::DisplayInfos&); + static google::protobuf::RepeatedPtrField<DisplayProto> writeDisplayInfoToProto( + const frontend::DisplayInfos&); }; class LayerProtoFromSnapshotGenerator { @@ -88,7 +80,7 @@ public: mLegacyLayers(legacyLayers), mDisplayInfos(displayInfos), mTraceFlags(traceFlags) {} - perfetto::protos::LayersProto generate(const frontend::LayerHierarchy& root); + LayersProto generate(const frontend::LayerHierarchy& root); private: void writeHierarchyToProto(const frontend::LayerHierarchy& root, @@ -100,7 +92,7 @@ private: const std::unordered_map<uint32_t, sp<Layer>>& mLegacyLayers; const frontend::DisplayInfos& mDisplayInfos; uint32_t mTraceFlags; - perfetto::protos::LayersProto mLayersProto; + 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> diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index e24c0dba4d..bc626f3030 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -5889,10 +5889,9 @@ status_t SurfaceFlinger::doDump(int fd, const DumpArgs& args, bool asProto) { } if (dumpLayers) { - perfetto::protos::LayersTraceFileProto traceFileProto = - mLayerTracing.createTraceFileProto(); - perfetto::protos::LayersSnapshotProto* layersTrace = traceFileProto.add_entry(); - perfetto::protos::LayersProto layersProto = dumpProtoFromMainThread(); + LayersTraceFileProto traceFileProto = mLayerTracing.createTraceFileProto(); + LayersTraceProto* layersTrace = traceFileProto.add_entry(); + LayersProto layersProto = dumpProtoFromMainThread(); layersTrace->mutable_layers()->Swap(&layersProto); auto displayProtos = dumpDisplayProto(); layersTrace->mutable_displays()->Swap(&displayProtos); @@ -6118,7 +6117,7 @@ void SurfaceFlinger::dumpHdrInfo(std::string& result) const { } } -perfetto::protos::LayersProto SurfaceFlinger::dumpDrawingStateProto(uint32_t traceFlags) const { +LayersProto SurfaceFlinger::dumpDrawingStateProto(uint32_t traceFlags) const { std::unordered_set<uint64_t> stackIdsToSkip; // Determine if virtual layers display should be skipped @@ -6131,7 +6130,7 @@ perfetto::protos::LayersProto SurfaceFlinger::dumpDrawingStateProto(uint32_t tra } if (mLegacyFrontEndEnabled) { - perfetto::protos::LayersProto layersProto; + LayersProto layersProto; for (const sp<Layer>& layer : mDrawingState.layersSortedByZ) { if (stackIdsToSkip.find(layer->getLayerStack().id) != stackIdsToSkip.end()) { continue; @@ -6146,11 +6145,10 @@ perfetto::protos::LayersProto SurfaceFlinger::dumpDrawingStateProto(uint32_t tra .generate(mLayerHierarchyBuilder.getHierarchy()); } -google::protobuf::RepeatedPtrField<perfetto::protos::DisplayProto> -SurfaceFlinger::dumpDisplayProto() const { - google::protobuf::RepeatedPtrField<perfetto::protos::DisplayProto> displays; +google::protobuf::RepeatedPtrField<DisplayProto> SurfaceFlinger::dumpDisplayProto() const { + google::protobuf::RepeatedPtrField<DisplayProto> displays; for (const auto& [_, display] : FTL_FAKE_GUARD(mStateLock, mDisplays)) { - perfetto::protos::DisplayProto* displayProto = displays.Add(); + DisplayProto* displayProto = displays.Add(); displayProto->set_id(display->getId().value); displayProto->set_name(display->getDisplayName()); displayProto->set_layer_stack(display->getLayerStack().id); @@ -6177,11 +6175,10 @@ void SurfaceFlinger::dumpHwc(std::string& result) const { getHwComposer().dump(result); } -void SurfaceFlinger::dumpOffscreenLayersProto(perfetto::protos::LayersProto& layersProto, - uint32_t traceFlags) const { +void SurfaceFlinger::dumpOffscreenLayersProto(LayersProto& layersProto, uint32_t traceFlags) const { // Add a fake invisible root layer to the proto output and parent all the offscreen layers to // it. - perfetto::protos::LayerProto* rootProto = layersProto.add_layers(); + LayerProto* rootProto = layersProto.add_layers(); const int32_t offscreenRootLayerId = INT32_MAX - 2; rootProto->set_id(offscreenRootLayerId); rootProto->set_name("Offscreen Root"); @@ -6192,12 +6189,12 @@ void SurfaceFlinger::dumpOffscreenLayersProto(perfetto::protos::LayersProto& lay rootProto->add_children(offscreenLayer->sequence); // Add layer - auto* layerProto = offscreenLayer->writeToProto(layersProto, traceFlags); + LayerProto* layerProto = offscreenLayer->writeToProto(layersProto, traceFlags); layerProto->set_parent(offscreenRootLayerId); } } -perfetto::protos::LayersProto SurfaceFlinger::dumpProtoFromMainThread(uint32_t traceFlags) { +LayersProto SurfaceFlinger::dumpProtoFromMainThread(uint32_t traceFlags) { return mScheduler->schedule([=] { return dumpDrawingStateProto(traceFlags); }).get(); } @@ -8793,7 +8790,7 @@ frontend::Update SurfaceFlinger::flushLifecycleUpdates() { void SurfaceFlinger::addToLayerTracing(bool visibleRegionDirty, TimePoint time, VsyncId vsyncId) { const uint32_t tracingFlags = mLayerTracing.getFlags(); - perfetto::protos::LayersProto layers(dumpDrawingStateProto(tracingFlags)); + LayersProto layers(dumpDrawingStateProto(tracingFlags)); if (tracingFlags & LayerTracing::TRACE_EXTRA) { dumpOffscreenLayersProto(layers); } diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 693bf3b35a..79dcd0d1b2 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -1092,17 +1092,17 @@ private: void dumpWideColorInfo(std::string& result) const REQUIRES(mStateLock); void dumpHdrInfo(std::string& result) const REQUIRES(mStateLock); - perfetto::protos::LayersProto dumpDrawingStateProto(uint32_t traceFlags) const; - void dumpOffscreenLayersProto(perfetto::protos::LayersProto& layersProto, + LayersProto dumpDrawingStateProto(uint32_t traceFlags) const; + void dumpOffscreenLayersProto(LayersProto& layersProto, uint32_t traceFlags = LayerTracing::TRACE_ALL) const; - google::protobuf::RepeatedPtrField<perfetto::protos::DisplayProto> dumpDisplayProto() const; + google::protobuf::RepeatedPtrField<DisplayProto> dumpDisplayProto() const; void addToLayerTracing(bool visibleRegionDirty, TimePoint, VsyncId) REQUIRES(kMainThreadContext); // Dumps state from HW Composer void dumpHwc(std::string& result) const; - perfetto::protos::LayersProto dumpProtoFromMainThread( - uint32_t traceFlags = LayerTracing::TRACE_ALL) EXCLUDES(mStateLock); + LayersProto dumpProtoFromMainThread(uint32_t traceFlags = LayerTracing::TRACE_ALL) + EXCLUDES(mStateLock); void dumpOffscreenLayers(std::string& result) EXCLUDES(mStateLock); void dumpPlannerInfo(const DumpArgs& args, std::string& result) const REQUIRES(mStateLock); diff --git a/services/surfaceflinger/Tracing/TransactionProtoParser.cpp b/services/surfaceflinger/Tracing/TransactionProtoParser.cpp index 2dc89b55ba..b1e3d6378a 100644 --- a/services/surfaceflinger/Tracing/TransactionProtoParser.cpp +++ b/services/surfaceflinger/Tracing/TransactionProtoParser.cpp @@ -51,8 +51,8 @@ public: ~FakeExternalTexture() = default; }; -perfetto::protos::TransactionState TransactionProtoParser::toProto(const TransactionState& t) { - perfetto::protos::TransactionState proto; +proto::TransactionState TransactionProtoParser::toProto(const TransactionState& t) { + proto::TransactionState proto; proto.set_pid(t.originPid); proto.set_uid(t.originUid); proto.set_vsync_id(t.frameTimelineInfo.vsyncId); @@ -79,21 +79,21 @@ perfetto::protos::TransactionState TransactionProtoParser::toProto(const Transac return proto; } -perfetto::protos::TransactionState TransactionProtoParser::toProto( +proto::TransactionState TransactionProtoParser::toProto( const std::map<uint32_t /* layerId */, TracingLayerState>& states) { - perfetto::protos::TransactionState proto; + proto::TransactionState proto; proto.mutable_layer_changes()->Reserve(static_cast<int32_t>(states.size())); for (auto& [layerId, state] : states) { - perfetto::protos::LayerState layerProto = toProto(state); + proto::LayerState layerProto = toProto(state); layerProto.set_has_sideband_stream(state.hasSidebandStream); proto.mutable_layer_changes()->Add(std::move(layerProto)); } return proto; } -perfetto::protos::LayerState TransactionProtoParser::toProto( +proto::LayerState TransactionProtoParser::toProto( const ResolvedComposerState& resolvedComposerState) { - perfetto::protos::LayerState proto; + proto::LayerState proto; auto& layer = resolvedComposerState.state; proto.set_layer_id(resolvedComposerState.layerId); proto.set_what(layer.what); @@ -114,7 +114,7 @@ perfetto::protos::LayerState TransactionProtoParser::toProto( proto.set_mask(layer.mask); } if (layer.what & layer_state_t::eMatrixChanged) { - perfetto::protos::LayerState_Matrix22* matrixProto = proto.mutable_matrix(); + proto::LayerState_Matrix22* matrixProto = proto.mutable_matrix(); matrixProto->set_dsdx(layer.matrix.dsdx); matrixProto->set_dsdy(layer.matrix.dsdy); matrixProto->set_dtdx(layer.matrix.dtdx); @@ -132,7 +132,7 @@ perfetto::protos::LayerState TransactionProtoParser::toProto( } if (layer.what & layer_state_t::eColorChanged) { - perfetto::protos::LayerState_Color3* colorProto = proto.mutable_color(); + proto::LayerState_Color3* colorProto = proto.mutable_color(); colorProto->set_r(layer.color.r); colorProto->set_g(layer.color.g); colorProto->set_b(layer.color.b); @@ -150,14 +150,13 @@ perfetto::protos::LayerState TransactionProtoParser::toProto( LayerProtoHelper::writeToProto(layer.crop, proto.mutable_crop()); } if (layer.what & layer_state_t::eBufferChanged) { - perfetto::protos::LayerState_BufferData* bufferProto = proto.mutable_buffer_data(); + proto::LayerState_BufferData* bufferProto = proto.mutable_buffer_data(); if (resolvedComposerState.externalTexture) { bufferProto->set_buffer_id(resolvedComposerState.externalTexture->getId()); bufferProto->set_width(resolvedComposerState.externalTexture->getWidth()); bufferProto->set_height(resolvedComposerState.externalTexture->getHeight()); - bufferProto->set_pixel_format( - static_cast<perfetto::protos::LayerState_BufferData_PixelFormat>( - resolvedComposerState.externalTexture->getPixelFormat())); + bufferProto->set_pixel_format(static_cast<proto::LayerState_BufferData_PixelFormat>( + resolvedComposerState.externalTexture->getPixelFormat())); bufferProto->set_usage(resolvedComposerState.externalTexture->getUsage()); } bufferProto->set_frame_number(layer.bufferData->frameNumber); @@ -192,8 +191,7 @@ perfetto::protos::LayerState TransactionProtoParser::toProto( if (layer.what & layer_state_t::eInputInfoChanged) { if (layer.windowInfoHandle) { const gui::WindowInfo* inputInfo = layer.windowInfoHandle->getInfo(); - perfetto::protos::LayerState_WindowInfo* windowInfoProto = - proto.mutable_window_info_handle(); + proto::LayerState_WindowInfo* windowInfoProto = proto.mutable_window_info_handle(); windowInfoProto->set_layout_params_flags(inputInfo->layoutParamsFlags.get()); windowInfoProto->set_layout_params_type( static_cast<int32_t>(inputInfo->layoutParamsType)); @@ -206,7 +204,7 @@ perfetto::protos::LayerState TransactionProtoParser::toProto( windowInfoProto->set_has_wallpaper(inputInfo->inputConfig.test( gui::WindowInfo::InputConfig::DUPLICATE_TOUCH_TO_WALLPAPER)); windowInfoProto->set_global_scale_factor(inputInfo->globalScaleFactor); - perfetto::protos::Transform* transformProto = windowInfoProto->mutable_transform(); + proto::Transform* transformProto = windowInfoProto->mutable_transform(); transformProto->set_dsdx(inputInfo->transform.dsdx()); transformProto->set_dtdx(inputInfo->transform.dtdx()); transformProto->set_dtdy(inputInfo->transform.dtdy()); @@ -221,7 +219,7 @@ perfetto::protos::LayerState TransactionProtoParser::toProto( if (layer.what & layer_state_t::eBackgroundColorChanged) { proto.set_bg_color_alpha(layer.bgColor.a); proto.set_bg_color_dataspace(static_cast<int32_t>(layer.bgColorDataspace)); - perfetto::protos::LayerState_Color3* colorProto = proto.mutable_color(); + proto::LayerState_Color3* colorProto = proto.mutable_color(); colorProto->set_r(layer.bgColor.r); colorProto->set_g(layer.bgColor.g); colorProto->set_b(layer.bgColor.b); @@ -257,13 +255,13 @@ perfetto::protos::LayerState TransactionProtoParser::toProto( } if (layer.what & layer_state_t::eDropInputModeChanged) { proto.set_drop_input_mode( - static_cast<perfetto::protos::LayerState_DropInputMode>(layer.dropInputMode)); + static_cast<proto::LayerState_DropInputMode>(layer.dropInputMode)); } return proto; } -perfetto::protos::DisplayState TransactionProtoParser::toProto(const DisplayState& display) { - perfetto::protos::DisplayState proto; +proto::DisplayState TransactionProtoParser::toProto(const DisplayState& display) { + proto::DisplayState proto; proto.set_what(display.what); proto.set_id(mMapper->getDisplayId(display.token)); @@ -287,8 +285,8 @@ perfetto::protos::DisplayState TransactionProtoParser::toProto(const DisplayStat return proto; } -perfetto::protos::LayerCreationArgs TransactionProtoParser::toProto(const LayerCreationArgs& args) { - perfetto::protos::LayerCreationArgs proto; +proto::LayerCreationArgs TransactionProtoParser::toProto(const LayerCreationArgs& args) { + proto::LayerCreationArgs proto; proto.set_layer_id(args.sequence); proto.set_name(args.name); proto.set_flags(args.flags); @@ -299,8 +297,7 @@ perfetto::protos::LayerCreationArgs TransactionProtoParser::toProto(const LayerC return proto; } -TransactionState TransactionProtoParser::fromProto( - const perfetto::protos::TransactionState& proto) { +TransactionState TransactionProtoParser::fromProto(const proto::TransactionState& proto) { TransactionState t; t.originPid = proto.pid(); t.originUid = proto.uid(); @@ -326,7 +323,7 @@ TransactionState TransactionProtoParser::fromProto( return t; } -void TransactionProtoParser::fromProto(const perfetto::protos::LayerCreationArgs& proto, +void TransactionProtoParser::fromProto(const proto::LayerCreationArgs& proto, LayerCreationArgs& outArgs) { outArgs.sequence = proto.layer_id(); @@ -338,7 +335,7 @@ void TransactionProtoParser::fromProto(const perfetto::protos::LayerCreationArgs outArgs.layerStackToMirror.id = proto.layer_stack_to_mirror(); } -void TransactionProtoParser::mergeFromProto(const perfetto::protos::LayerState& proto, +void TransactionProtoParser::mergeFromProto(const proto::LayerState& proto, TracingLayerState& outState) { ResolvedComposerState resolvedComposerState; fromProto(proto, resolvedComposerState); @@ -363,7 +360,7 @@ void TransactionProtoParser::mergeFromProto(const perfetto::protos::LayerState& } } -void TransactionProtoParser::fromProto(const perfetto::protos::LayerState& proto, +void TransactionProtoParser::fromProto(const proto::LayerState& proto, ResolvedComposerState& resolvedComposerState) { auto& layer = resolvedComposerState.state; resolvedComposerState.layerId = proto.layer_id(); @@ -384,7 +381,7 @@ void TransactionProtoParser::fromProto(const perfetto::protos::LayerState& proto layer.mask = proto.mask(); } if (proto.what() & layer_state_t::eMatrixChanged) { - const perfetto::protos::LayerState_Matrix22& matrixProto = proto.matrix(); + const proto::LayerState_Matrix22& matrixProto = proto.matrix(); layer.matrix.dsdx = matrixProto.dsdx(); layer.matrix.dsdy = matrixProto.dsdy(); layer.matrix.dtdx = matrixProto.dtdx(); @@ -402,7 +399,7 @@ void TransactionProtoParser::fromProto(const perfetto::protos::LayerState& proto } if (proto.what() & layer_state_t::eColorChanged) { - const perfetto::protos::LayerState_Color3& colorProto = proto.color(); + const proto::LayerState_Color3& colorProto = proto.color(); layer.color.r = colorProto.r(); layer.color.g = colorProto.g(); layer.color.b = colorProto.b(); @@ -420,7 +417,7 @@ void TransactionProtoParser::fromProto(const perfetto::protos::LayerState& proto LayerProtoHelper::readFromProto(proto.crop(), layer.crop); } if (proto.what() & layer_state_t::eBufferChanged) { - const perfetto::protos::LayerState_BufferData& bufferProto = proto.buffer_data(); + const proto::LayerState_BufferData& bufferProto = proto.buffer_data(); layer.bufferData = std::make_shared<fake::BufferData>(bufferProto.buffer_id(), bufferProto.width(), bufferProto.height(), bufferProto.pixel_format(), @@ -463,7 +460,7 @@ void TransactionProtoParser::fromProto(const perfetto::protos::LayerState& proto if ((proto.what() & layer_state_t::eInputInfoChanged) && proto.has_window_info_handle()) { gui::WindowInfo inputInfo; - const perfetto::protos::LayerState_WindowInfo& windowInfoProto = proto.window_info_handle(); + const proto::LayerState_WindowInfo& windowInfoProto = proto.window_info_handle(); inputInfo.layoutParamsFlags = static_cast<gui::WindowInfo::Flag>(windowInfoProto.layout_params_flags()); @@ -475,7 +472,7 @@ void TransactionProtoParser::fromProto(const perfetto::protos::LayerState& proto ftl::Flags<gui::WindowInfo::InputConfig>(windowInfoProto.input_config()); inputInfo.surfaceInset = windowInfoProto.surface_inset(); inputInfo.globalScaleFactor = windowInfoProto.global_scale_factor(); - const perfetto::protos::Transform& transformProto = windowInfoProto.transform(); + const proto::Transform& transformProto = windowInfoProto.transform(); inputInfo.transform.set(transformProto.dsdx(), transformProto.dtdx(), transformProto.dtdy(), transformProto.dsdy()); inputInfo.transform.set(transformProto.tx(), transformProto.ty()); @@ -488,7 +485,7 @@ void TransactionProtoParser::fromProto(const perfetto::protos::LayerState& proto if (proto.what() & layer_state_t::eBackgroundColorChanged) { layer.bgColor.a = proto.bg_color_alpha(); layer.bgColorDataspace = static_cast<ui::Dataspace>(proto.bg_color_dataspace()); - const perfetto::protos::LayerState_Color3& colorProto = proto.color(); + const proto::LayerState_Color3& colorProto = proto.color(); layer.bgColor.r = colorProto.r(); layer.bgColor.g = colorProto.g(); layer.bgColor.b = colorProto.b(); @@ -528,7 +525,7 @@ void TransactionProtoParser::fromProto(const perfetto::protos::LayerState& proto } } -DisplayState TransactionProtoParser::fromProto(const perfetto::protos::DisplayState& proto) { +DisplayState TransactionProtoParser::fromProto(const proto::DisplayState& proto) { DisplayState display; display.what = proto.what(); display.token = mMapper->getDisplayHandle(proto.id()); @@ -553,7 +550,7 @@ DisplayState TransactionProtoParser::fromProto(const perfetto::protos::DisplaySt return display; } -void asProto(perfetto::protos::Transform* proto, const ui::Transform& transform) { +void asProto(proto::Transform* proto, const ui::Transform& transform) { proto->set_dsdx(transform.dsdx()); proto->set_dtdx(transform.dtdx()); proto->set_dtdy(transform.dtdy()); @@ -562,9 +559,9 @@ void asProto(perfetto::protos::Transform* proto, const ui::Transform& transform) proto->set_ty(transform.ty()); } -perfetto::protos::DisplayInfo TransactionProtoParser::toProto( - const frontend::DisplayInfo& displayInfo, uint32_t layerStack) { - perfetto::protos::DisplayInfo proto; +proto::DisplayInfo TransactionProtoParser::toProto(const frontend::DisplayInfo& displayInfo, + uint32_t layerStack) { + proto::DisplayInfo proto; proto.set_layer_stack(layerStack); proto.set_display_id(displayInfo.info.displayId); proto.set_logical_width(displayInfo.info.logicalWidth); @@ -580,13 +577,12 @@ perfetto::protos::DisplayInfo TransactionProtoParser::toProto( return proto; } -void fromProto2(ui::Transform& outTransform, const perfetto::protos::Transform& proto) { +void fromProto2(ui::Transform& outTransform, const proto::Transform& proto) { outTransform.set(proto.dsdx(), proto.dtdx(), proto.dtdy(), proto.dsdy()); outTransform.set(proto.tx(), proto.ty()); } -frontend::DisplayInfo TransactionProtoParser::fromProto( - const perfetto::protos::DisplayInfo& proto) { +frontend::DisplayInfo TransactionProtoParser::fromProto(const proto::DisplayInfo& proto) { frontend::DisplayInfo displayInfo; displayInfo.info.displayId = proto.display_id(); displayInfo.info.logicalWidth = proto.logical_width(); @@ -603,10 +599,10 @@ frontend::DisplayInfo TransactionProtoParser::fromProto( } void TransactionProtoParser::fromProto( - const google::protobuf::RepeatedPtrField<perfetto::protos::DisplayInfo>& proto, + const google::protobuf::RepeatedPtrField<proto::DisplayInfo>& proto, frontend::DisplayInfos& outDisplayInfos) { outDisplayInfos.clear(); - for (const perfetto::protos::DisplayInfo& displayInfo : proto) { + for (const proto::DisplayInfo& displayInfo : proto) { outDisplayInfos.emplace_or_replace(ui::LayerStack::fromValue(displayInfo.layer_stack()), fromProto(displayInfo)); } diff --git a/services/surfaceflinger/Tracing/TransactionProtoParser.h b/services/surfaceflinger/Tracing/TransactionProtoParser.h index b3ab71cfb5..457c3bec40 100644 --- a/services/surfaceflinger/Tracing/TransactionProtoParser.h +++ b/services/surfaceflinger/Tracing/TransactionProtoParser.h @@ -44,25 +44,25 @@ public: TransactionProtoParser(std::unique_ptr<FlingerDataMapper> provider) : mMapper(std::move(provider)) {} - perfetto::protos::TransactionState toProto(const TransactionState&); - perfetto::protos::TransactionState toProto( - const std::map<uint32_t /* layerId */, TracingLayerState>&); - perfetto::protos::LayerCreationArgs toProto(const LayerCreationArgs& args); - perfetto::protos::LayerState toProto(const ResolvedComposerState&); - static perfetto::protos::DisplayInfo toProto(const frontend::DisplayInfo&, uint32_t layerStack); + proto::TransactionState toProto(const TransactionState&); + proto::TransactionState toProto(const std::map<uint32_t /* layerId */, TracingLayerState>&); + proto::LayerCreationArgs toProto(const LayerCreationArgs& args); + proto::LayerState toProto(const ResolvedComposerState&); + static proto::DisplayInfo toProto(const frontend::DisplayInfo&, uint32_t layerStack); - TransactionState fromProto(const perfetto::protos::TransactionState&); - void mergeFromProto(const perfetto::protos::LayerState&, TracingLayerState& outState); - void fromProto(const perfetto::protos::LayerCreationArgs&, LayerCreationArgs& outArgs); + TransactionState fromProto(const proto::TransactionState&); + void mergeFromProto(const proto::LayerState&, TracingLayerState& outState); + void fromProto(const proto::LayerCreationArgs&, LayerCreationArgs& outArgs); std::unique_ptr<FlingerDataMapper> mMapper; - static frontend::DisplayInfo fromProto(const perfetto::protos::DisplayInfo&); - static void fromProto(const google::protobuf::RepeatedPtrField<perfetto::protos::DisplayInfo>&, + static frontend::DisplayInfo fromProto(const proto::DisplayInfo&); + static void fromProto(const google::protobuf::RepeatedPtrField<proto::DisplayInfo>&, frontend::DisplayInfos& outDisplayInfos); private: - perfetto::protos::DisplayState toProto(const DisplayState&); - void fromProto(const perfetto::protos::LayerState&, ResolvedComposerState& out); - DisplayState fromProto(const perfetto::protos::DisplayState&); + proto::DisplayState toProto(const DisplayState&); + void fromProto(const proto::LayerState&, ResolvedComposerState& out); + DisplayState fromProto(const proto::DisplayState&); + }; } // namespace android::surfaceflinger diff --git a/services/surfaceflinger/Tracing/TransactionTracing.cpp b/services/surfaceflinger/Tracing/TransactionTracing.cpp index 8aacbca90c..bc69191cc1 100644 --- a/services/surfaceflinger/Tracing/TransactionTracing.cpp +++ b/services/surfaceflinger/Tracing/TransactionTracing.cpp @@ -59,7 +59,7 @@ TransactionTracing::~TransactionTracing() { status_t TransactionTracing::writeToFile(const std::string& filename) { std::scoped_lock lock(mTraceLock); - perfetto::protos::TransactionTraceFile fileProto = createTraceFileProto(); + proto::TransactionTraceFile fileProto = createTraceFileProto(); addStartingStateToProtoLocked(fileProto); return mBuffer.writeToFile(fileProto, filename); } @@ -70,11 +70,10 @@ void TransactionTracing::setBufferSize(size_t bufferSizeInBytes) { mBuffer.setSize(mBufferSizeInBytes); } -perfetto::protos::TransactionTraceFile TransactionTracing::createTraceFileProto() const { - perfetto::protos::TransactionTraceFile proto; - proto.set_magic_number( - uint64_t(perfetto::protos::TransactionTraceFile_MagicNumber_MAGIC_NUMBER_H) << 32 | - perfetto::protos::TransactionTraceFile_MagicNumber_MAGIC_NUMBER_L); +proto::TransactionTraceFile TransactionTracing::createTraceFileProto() const { + proto::TransactionTraceFile proto; + proto.set_magic_number(uint64_t(proto::TransactionTraceFile_MagicNumber_MAGIC_NUMBER_H) << 32 | + proto::TransactionTraceFile_MagicNumber_MAGIC_NUMBER_L); auto timeOffsetNs = static_cast<std::uint64_t>(systemTime(SYSTEM_TIME_REALTIME) - systemTime(SYSTEM_TIME_MONOTONIC)); proto.set_real_to_elapsed_time_offset_nanos(timeOffsetNs); @@ -90,8 +89,7 @@ void TransactionTracing::dump(std::string& result) const { } void TransactionTracing::addQueuedTransaction(const TransactionState& transaction) { - perfetto::protos::TransactionState* state = - new perfetto::protos::TransactionState(mProtoParser.toProto(transaction)); + proto::TransactionState* state = new proto::TransactionState(mProtoParser.toProto(transaction)); mTransactionQueue.push(state); } @@ -154,7 +152,7 @@ void TransactionTracing::addEntry(const std::vector<CommittedUpdates>& committed ATRACE_CALL(); std::scoped_lock lock(mTraceLock); std::vector<std::string> removedEntries; - perfetto::protos::TransactionTraceEntry entryProto; + proto::TransactionTraceEntry entryProto; while (auto incomingTransaction = mTransactionQueue.pop()) { auto transaction = *incomingTransaction; @@ -213,7 +211,7 @@ void TransactionTracing::addEntry(const std::vector<CommittedUpdates>& committed std::make_move_iterator(entries.end())); } - perfetto::protos::TransactionTraceEntry removedEntryProto; + proto::TransactionTraceEntry removedEntryProto; for (const std::string& removedEntry : removedEntries) { removedEntryProto.ParseFromString(removedEntry); updateStartingStateLocked(removedEntryProto); @@ -238,7 +236,7 @@ void TransactionTracing::flush() { base::ScopedLockAssertion assumeLocked(mTraceLock); mTransactionsAddedToBufferCv.wait_for(lock, std::chrono::milliseconds(100), [&]() REQUIRES(mTraceLock) { - perfetto::protos::TransactionTraceEntry entry; + proto::TransactionTraceEntry entry; if (mBuffer.used() > 0) { entry.ParseFromString(mBuffer.back()); } @@ -270,19 +268,19 @@ void TransactionTracing::tryPushToTracingThread() { } void TransactionTracing::updateStartingStateLocked( - const perfetto::protos::TransactionTraceEntry& removedEntry) { + const proto::TransactionTraceEntry& removedEntry) { mStartingTimestamp = removedEntry.elapsed_realtime_nanos(); // Keep track of layer starting state so we can reconstruct the layer state as we purge // transactions from the buffer. - for (const perfetto::protos::LayerCreationArgs& addedLayer : removedEntry.added_layers()) { + for (const proto::LayerCreationArgs& addedLayer : removedEntry.added_layers()) { TracingLayerState& startingState = mStartingStates[addedLayer.layer_id()]; startingState.layerId = addedLayer.layer_id(); mProtoParser.fromProto(addedLayer, startingState.args); } // Merge layer states to starting transaction state. - for (const perfetto::protos::TransactionState& transaction : removedEntry.transactions()) { - for (const perfetto::protos::LayerState& layerState : transaction.layer_changes()) { + for (const proto::TransactionState& transaction : removedEntry.transactions()) { + for (const proto::LayerState& layerState : transaction.layer_changes()) { auto it = mStartingStates.find(layerState.layer_id()); if (it == mStartingStates.end()) { // TODO(b/238781169) make this log fatal when we switch over to using new fe @@ -309,13 +307,12 @@ void TransactionTracing::updateStartingStateLocked( } } -void TransactionTracing::addStartingStateToProtoLocked( - perfetto::protos::TransactionTraceFile& proto) { +void TransactionTracing::addStartingStateToProtoLocked(proto::TransactionTraceFile& proto) { if (mStartingStates.size() == 0) { return; } - perfetto::protos::TransactionTraceEntry* entryProto = proto.add_entry(); + proto::TransactionTraceEntry* entryProto = proto.add_entry(); entryProto->set_elapsed_realtime_nanos(mStartingTimestamp); entryProto->set_vsync_id(0); @@ -324,7 +321,7 @@ void TransactionTracing::addStartingStateToProtoLocked( entryProto->mutable_added_layers()->Add(mProtoParser.toProto(state.args)); } - perfetto::protos::TransactionState transactionProto = mProtoParser.toProto(mStartingStates); + proto::TransactionState transactionProto = mProtoParser.toProto(mStartingStates); transactionProto.set_vsync_id(0); transactionProto.set_post_time(mStartingTimestamp); entryProto->mutable_transactions()->Add(std::move(transactionProto)); @@ -341,9 +338,9 @@ void TransactionTracing::addStartingStateToProtoLocked( } } -perfetto::protos::TransactionTraceFile TransactionTracing::writeToProto() { +proto::TransactionTraceFile TransactionTracing::writeToProto() { std::scoped_lock<std::mutex> lock(mTraceLock); - perfetto::protos::TransactionTraceFile proto = createTraceFileProto(); + proto::TransactionTraceFile proto = createTraceFileProto(); addStartingStateToProtoLocked(proto); mBuffer.writeToProto(proto); return proto; diff --git a/services/surfaceflinger/Tracing/TransactionTracing.h b/services/surfaceflinger/Tracing/TransactionTracing.h index 09fcd8ad96..422b5f3689 100644 --- a/services/surfaceflinger/Tracing/TransactionTracing.h +++ b/services/surfaceflinger/Tracing/TransactionTracing.h @@ -85,16 +85,14 @@ private: } mutable std::mutex mTraceLock; - TransactionRingBuffer<perfetto::protos::TransactionTraceFile, - perfetto::protos::TransactionTraceEntry> - mBuffer GUARDED_BY(mTraceLock); + TransactionRingBuffer<proto::TransactionTraceFile, proto::TransactionTraceEntry> mBuffer + GUARDED_BY(mTraceLock); size_t mBufferSizeInBytes GUARDED_BY(mTraceLock) = CONTINUOUS_TRACING_BUFFER_SIZE; - std::unordered_map<uint64_t, perfetto::protos::TransactionState> mQueuedTransactions + std::unordered_map<uint64_t, proto::TransactionState> mQueuedTransactions GUARDED_BY(mTraceLock); - LocklessStack<perfetto::protos::TransactionState> mTransactionQueue; + LocklessStack<proto::TransactionState> mTransactionQueue; nsecs_t mStartingTimestamp GUARDED_BY(mTraceLock); - std::unordered_map<int, perfetto::protos::LayerCreationArgs> mCreatedLayers - GUARDED_BY(mTraceLock); + std::unordered_map<int, proto::LayerCreationArgs> mCreatedLayers GUARDED_BY(mTraceLock); std::map<uint32_t /* layerId */, TracingLayerState> mStartingStates GUARDED_BY(mTraceLock); frontend::DisplayInfos mStartingDisplayInfos GUARDED_BY(mTraceLock); @@ -124,19 +122,17 @@ private: std::vector<uint32_t /* layerId */> mPendingDestroyedLayers; // only accessed by main thread int64_t mLastUpdatedVsyncId = -1; - perfetto::protos::TransactionTraceFile createTraceFileProto() const; + proto::TransactionTraceFile createTraceFileProto() const; void loop(); void addEntry(const std::vector<CommittedUpdates>& committedTransactions, const std::vector<uint32_t>& removedLayers) EXCLUDES(mTraceLock); int32_t getLayerIdLocked(const sp<IBinder>& layerHandle) REQUIRES(mTraceLock); void tryPushToTracingThread() EXCLUDES(mMainThreadLock); - void addStartingStateToProtoLocked(perfetto::protos::TransactionTraceFile& proto) - REQUIRES(mTraceLock); - void updateStartingStateLocked(const perfetto::protos::TransactionTraceEntry& entry) - REQUIRES(mTraceLock); + void addStartingStateToProtoLocked(proto::TransactionTraceFile& proto) REQUIRES(mTraceLock); + void updateStartingStateLocked(const proto::TransactionTraceEntry& entry) REQUIRES(mTraceLock); // TEST // Return buffer contents as trace file proto - perfetto::protos::TransactionTraceFile writeToProto() EXCLUDES(mMainThreadLock); + proto::TransactionTraceFile writeToProto() EXCLUDES(mMainThreadLock); }; class TransactionTraceWriter : public Singleton<TransactionTraceWriter> { diff --git a/services/surfaceflinger/Tracing/tools/LayerTraceGenerator.cpp b/services/surfaceflinger/Tracing/tools/LayerTraceGenerator.cpp index 9471e954d8..321b8baccc 100644 --- a/services/surfaceflinger/Tracing/tools/LayerTraceGenerator.cpp +++ b/services/surfaceflinger/Tracing/tools/LayerTraceGenerator.cpp @@ -40,8 +40,8 @@ namespace android { using namespace ftl::flag_operators; -bool LayerTraceGenerator::generate(const perfetto::protos::TransactionTraceFile& traceFile, - const char*, bool onlyLastEntry) { +bool LayerTraceGenerator::generate(const proto::TransactionTraceFile& traceFile, + const char* outputLayersTracePath, bool onlyLastEntry) { if (traceFile.entry_size() == 0) { ALOGD("Trace file is empty"); return false; diff --git a/services/surfaceflinger/Tracing/tools/LayerTraceGenerator.h b/services/surfaceflinger/Tracing/tools/LayerTraceGenerator.h index a1e5fc894b..e41d1e6e0b 100644 --- a/services/surfaceflinger/Tracing/tools/LayerTraceGenerator.h +++ b/services/surfaceflinger/Tracing/tools/LayerTraceGenerator.h @@ -21,7 +21,7 @@ namespace android { class LayerTraceGenerator { public: - bool generate(const perfetto::protos::TransactionTraceFile&, const char* outputLayersTracePath, + bool generate(const proto::TransactionTraceFile&, const char* outputLayersTracePath, bool onlyLastEntry); }; -} // namespace android +} // namespace android
\ No newline at end of file diff --git a/services/surfaceflinger/Tracing/tools/main.cpp b/services/surfaceflinger/Tracing/tools/main.cpp index 0ff8f98d36..5ca87e4cb3 100644 --- a/services/surfaceflinger/Tracing/tools/main.cpp +++ b/services/surfaceflinger/Tracing/tools/main.cpp @@ -41,7 +41,7 @@ int main(int argc, char** argv) { return -1; } - perfetto::protos::TransactionTraceFile transactionTraceFile; + proto::TransactionTraceFile transactionTraceFile; if (!transactionTraceFile.ParseFromIstream(&input)) { std::cout << "Error: Failed to parse " << transactionTracePath; return -1; diff --git a/services/surfaceflinger/fuzzer/surfaceflinger_fuzzers_utils.h b/services/surfaceflinger/fuzzer/surfaceflinger_fuzzers_utils.h index 437fd35c15..8a050fdab5 100644 --- a/services/surfaceflinger/fuzzer/surfaceflinger_fuzzers_utils.h +++ b/services/surfaceflinger/fuzzer/surfaceflinger_fuzzers_utils.h @@ -455,8 +455,7 @@ public: result = fdp->ConsumeRandomLengthString().c_str(); mFlinger->dumpRawDisplayIdentificationData(dumpArgs, result); - perfetto::protos::LayersProto layersProto = - mFlinger->dumpDrawingStateProto(fdp->ConsumeIntegral<uint32_t>()); + LayersProto layersProto = mFlinger->dumpDrawingStateProto(fdp->ConsumeIntegral<uint32_t>()); mFlinger->dumpOffscreenLayersProto(layersProto); mFlinger->dumpDisplayProto(); diff --git a/services/surfaceflinger/layerproto/Android.bp b/services/surfaceflinger/layerproto/Android.bp index a4dc8a058e..7287dd0103 100644 --- a/services/surfaceflinger/layerproto/Android.bp +++ b/services/surfaceflinger/layerproto/Android.bp @@ -13,20 +13,7 @@ cc_library { srcs: [ "LayerProtoParser.cpp", - ], - - static_libs: [ - "libperfetto_client_experimental", - ], - - whole_static_libs: [ - // TODO(b/169779783): move into "static_libs" when the soong issue is fixed - "perfetto_trace_protos", - ], - - export_static_lib_headers: [ - "libperfetto_client_experimental", - "perfetto_trace_protos", + "*.proto", ], shared_libs: [ @@ -37,6 +24,10 @@ cc_library { "libbase", ], + proto: { + export_proto_headers: true, + }, + cppflags: [ "-Werror", "-Wno-unused-parameter", @@ -51,3 +42,22 @@ cc_library { "-Wno-undef", ], } + +java_library_static { + name: "layersprotoslite", + host_supported: true, + proto: { + type: "lite", + include_dirs: ["external/protobuf/src"], + }, + srcs: ["*.proto"], + sdk_version: "core_platform", + target: { + android: { + jarjar_rules: "jarjar-rules.txt", + }, + host: { + static_libs: ["libprotobuf-java-lite"], + }, + }, +} diff --git a/services/surfaceflinger/layerproto/LayerProtoParser.cpp b/services/surfaceflinger/layerproto/LayerProtoParser.cpp index 8d48070e13..854084e7f9 100644 --- a/services/surfaceflinger/layerproto/LayerProtoParser.cpp +++ b/services/surfaceflinger/layerproto/LayerProtoParser.cpp @@ -37,8 +37,7 @@ bool sortLayers(LayerProtoParser::Layer* lhs, const LayerProtoParser::Layer* rhs return lhs->id < rhs->id; } -LayerProtoParser::LayerTree LayerProtoParser::generateLayerTree( - const perfetto::protos::LayersProto& layersProto) { +LayerProtoParser::LayerTree LayerProtoParser::generateLayerTree(const LayersProto& layersProto) { LayerTree layerTree; layerTree.allLayers = generateLayerList(layersProto); @@ -54,7 +53,7 @@ LayerProtoParser::LayerTree LayerProtoParser::generateLayerTree( } std::vector<LayerProtoParser::Layer> LayerProtoParser::generateLayerList( - const perfetto::protos::LayersProto& layersProto) { + const LayersProto& layersProto) { std::vector<Layer> layerList; std::unordered_map<int32_t, Layer*> layerMap; @@ -75,8 +74,7 @@ std::vector<LayerProtoParser::Layer> LayerProtoParser::generateLayerList( return layerList; } -LayerProtoParser::Layer LayerProtoParser::generateLayer( - const perfetto::protos::LayerProto& layerProto) { +LayerProtoParser::Layer LayerProtoParser::generateLayer(const LayerProto& layerProto) { Layer layer; layer.id = layerProto.id(); layer.name = layerProto.name(); @@ -122,19 +120,17 @@ LayerProtoParser::Layer LayerProtoParser::generateLayer( return layer; } -LayerProtoParser::Region LayerProtoParser::generateRegion( - const perfetto::protos::RegionProto& regionProto) { +LayerProtoParser::Region LayerProtoParser::generateRegion(const RegionProto& regionProto) { LayerProtoParser::Region region; for (int i = 0; i < regionProto.rect_size(); i++) { - const perfetto::protos::RectProto& rectProto = regionProto.rect(i); + const RectProto& rectProto = regionProto.rect(i); region.rects.push_back(generateRect(rectProto)); } return region; } -LayerProtoParser::Rect LayerProtoParser::generateRect( - const perfetto::protos::RectProto& rectProto) { +LayerProtoParser::Rect LayerProtoParser::generateRect(const RectProto& rectProto) { LayerProtoParser::Rect rect; rect.left = rectProto.left(); rect.top = rectProto.top(); @@ -144,8 +140,7 @@ LayerProtoParser::Rect LayerProtoParser::generateRect( return rect; } -LayerProtoParser::FloatRect LayerProtoParser::generateFloatRect( - const perfetto::protos::FloatRectProto& rectProto) { +LayerProtoParser::FloatRect LayerProtoParser::generateFloatRect(const FloatRectProto& rectProto) { LayerProtoParser::FloatRect rect; rect.left = rectProto.left(); rect.top = rectProto.top(); @@ -156,7 +151,7 @@ LayerProtoParser::FloatRect LayerProtoParser::generateFloatRect( } LayerProtoParser::Transform LayerProtoParser::generateTransform( - const perfetto::protos::TransformProto& transformProto) { + const TransformProto& transformProto) { LayerProtoParser::Transform transform; transform.dsdx = transformProto.dsdx(); transform.dtdx = transformProto.dtdx(); @@ -167,7 +162,7 @@ LayerProtoParser::Transform LayerProtoParser::generateTransform( } LayerProtoParser::ActiveBuffer LayerProtoParser::generateActiveBuffer( - const perfetto::protos::ActiveBufferProto& activeBufferProto) { + const ActiveBufferProto& activeBufferProto) { LayerProtoParser::ActiveBuffer activeBuffer; activeBuffer.width = activeBufferProto.width(); activeBuffer.height = activeBufferProto.height(); @@ -177,7 +172,7 @@ LayerProtoParser::ActiveBuffer LayerProtoParser::generateActiveBuffer( return activeBuffer; } -void LayerProtoParser::updateChildrenAndRelative(const perfetto::protos::LayerProto& layerProto, +void LayerProtoParser::updateChildrenAndRelative(const LayerProto& layerProto, std::unordered_map<int32_t, Layer*>& layerMap) { auto currLayer = layerMap[layerProto.id()]; diff --git a/services/surfaceflinger/layerproto/common.proto b/services/surfaceflinger/layerproto/common.proto new file mode 100644 index 0000000000..5e20d4d0f5 --- /dev/null +++ b/services/surfaceflinger/layerproto/common.proto @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +syntax = "proto3"; +option optimize_for = LITE_RUNTIME; +package android.surfaceflinger; + +message RegionProto { + reserved 1; // Previously: uint64 id + repeated RectProto rect = 2; +} + +message RectProto { + int32 left = 1; + int32 top = 2; + int32 right = 3; + int32 bottom = 4; +} + +message SizeProto { + int32 w = 1; + int32 h = 2; +} + +message TransformProto { + float dsdx = 1; + float dtdx = 2; + float dsdy = 3; + float dtdy = 4; + int32 type = 5; +} + +message ColorProto { + float r = 1; + float g = 2; + float b = 3; + float a = 4; +} + +message InputWindowInfoProto { + uint32 layout_params_flags = 1; + int32 layout_params_type = 2; + RectProto frame = 3; + RegionProto touchable_region = 4; + + int32 surface_inset = 5; + bool visible = 6; + bool can_receive_keys = 7 [deprecated = true]; + bool focusable = 8; + bool has_wallpaper = 9; + + float global_scale_factor = 10; + float window_x_scale = 11 [deprecated = true]; + float window_y_scale = 12 [deprecated = true]; + + int32 crop_layer_id = 13; + bool replace_touchable_region_with_crop = 14; + RectProto touchable_region_crop = 15; + TransformProto transform = 16; + uint32 input_config = 17; +} + +message BlurRegion { + uint32 blur_radius = 1; + uint32 corner_radius_tl = 2; + uint32 corner_radius_tr = 3; + uint32 corner_radius_bl = 4; + float corner_radius_br = 5; + float alpha = 6; + int32 left = 7; + int32 top = 8; + int32 right = 9; + int32 bottom = 10; +} + +message ColorTransformProto { + // This will be a 4x4 matrix of float values + repeated float val = 1; +} diff --git a/services/surfaceflinger/layerproto/display.proto b/services/surfaceflinger/layerproto/display.proto new file mode 100644 index 0000000000..64de775b8b --- /dev/null +++ b/services/surfaceflinger/layerproto/display.proto @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +syntax = "proto3"; +option optimize_for = LITE_RUNTIME; + +import "frameworks/native/services/surfaceflinger/layerproto/common.proto"; + +package android.surfaceflinger; + +message DisplayProto { + uint64 id = 1; + + string name = 2; + + uint32 layer_stack = 3; + + SizeProto size = 4; + + RectProto layer_stack_space_rect = 5; + + TransformProto transform = 6; + + bool is_virtual = 7; + + double dpi_x = 8; + + double dpi_y = 9; +} diff --git a/services/surfaceflinger/layerproto/include/layerproto/LayerProtoHeader.h b/services/surfaceflinger/layerproto/include/layerproto/LayerProtoHeader.h index 4a2ef3ddf8..f560562c94 100644 --- a/services/surfaceflinger/layerproto/include/layerproto/LayerProtoHeader.h +++ b/services/surfaceflinger/layerproto/include/layerproto/LayerProtoHeader.h @@ -14,14 +14,11 @@ * limitations under the License. */ -#pragma once - // pragma is used here to disable the warnings emitted from the protobuf // headers. By adding #pragma before including layer.pb.h, it supresses // protobuf warnings, but allows the rest of the files to continuing using // the current flags. // This file should be included instead of directly including layer.b.h #pragma GCC system_header -#include <perfetto/config/android/surfaceflinger_layers_config.pbzero.h> -#include <perfetto/trace/android/surfaceflinger_layers.pb.h> -#include <perfetto/trace/android/surfaceflinger_layers.pbzero.h> +#include <layers.pb.h> +#include <layerstrace.pb.h> diff --git a/services/surfaceflinger/layerproto/include/layerproto/LayerProtoParser.h b/services/surfaceflinger/layerproto/include/layerproto/LayerProtoParser.h index 79c3982dbd..cdc2706ee2 100644 --- a/services/surfaceflinger/layerproto/include/layerproto/LayerProtoParser.h +++ b/services/surfaceflinger/layerproto/include/layerproto/LayerProtoParser.h @@ -131,22 +131,19 @@ public: std::vector<Layer*> topLevelLayers; }; - static LayerTree generateLayerTree(const perfetto::protos::LayersProto& layersProto); + static LayerTree generateLayerTree(const LayersProto& layersProto); static std::string layerTreeToString(const LayerTree& layerTree); private: - static std::vector<Layer> generateLayerList(const perfetto::protos::LayersProto& layersProto); - static LayerProtoParser::Layer generateLayer(const perfetto::protos::LayerProto& layerProto); - static LayerProtoParser::Region generateRegion( - const perfetto::protos::RegionProto& regionProto); - static LayerProtoParser::Rect generateRect(const perfetto::protos::RectProto& rectProto); - static LayerProtoParser::FloatRect generateFloatRect( - const perfetto::protos::FloatRectProto& rectProto); - static LayerProtoParser::Transform generateTransform( - const perfetto::protos::TransformProto& transformProto); + static std::vector<Layer> generateLayerList(const LayersProto& layersProto); + static LayerProtoParser::Layer generateLayer(const LayerProto& layerProto); + static LayerProtoParser::Region generateRegion(const RegionProto& regionProto); + static LayerProtoParser::Rect generateRect(const RectProto& rectProto); + static LayerProtoParser::FloatRect generateFloatRect(const FloatRectProto& rectProto); + static LayerProtoParser::Transform generateTransform(const TransformProto& transformProto); static LayerProtoParser::ActiveBuffer generateActiveBuffer( - const perfetto::protos::ActiveBufferProto& activeBufferProto); - static void updateChildrenAndRelative(const perfetto::protos::LayerProto& layerProto, + const ActiveBufferProto& activeBufferProto); + static void updateChildrenAndRelative(const LayerProto& layerProto, std::unordered_map<int32_t, Layer*>& layerMap); static std::string layerToString(const LayerProtoParser::Layer* layer); diff --git a/services/surfaceflinger/layerproto/include/layerproto/TransactionProto.h b/services/surfaceflinger/layerproto/include/layerproto/TransactionProto.h index ea80ad8f33..3e9ca52fff 100644 --- a/services/surfaceflinger/layerproto/include/layerproto/TransactionProto.h +++ b/services/surfaceflinger/layerproto/include/layerproto/TransactionProto.h @@ -14,11 +14,7 @@ * limitations under the License. */ -#pragma once - // disable the warnings emitted from the protobuf headers. This file should be included instead of // directly including the generated header file #pragma GCC system_header -#include <perfetto/config/android/surfaceflinger_transactions_config.pbzero.h> -#include <perfetto/trace/android/surfaceflinger_transactions.pb.h> -#include <perfetto/trace/android/surfaceflinger_transactions.pbzero.h> +#include <transactions.pb.h> diff --git a/services/surfaceflinger/layerproto/jarjar-rules.txt b/services/surfaceflinger/layerproto/jarjar-rules.txt new file mode 100644 index 0000000000..40043a861c --- /dev/null +++ b/services/surfaceflinger/layerproto/jarjar-rules.txt @@ -0,0 +1 @@ +rule com.google.protobuf.nano.** com.android.framework.protobuf.nano.@1 diff --git a/services/surfaceflinger/layerproto/layers.proto b/services/surfaceflinger/layerproto/layers.proto new file mode 100644 index 0000000000..e9add2e1a4 --- /dev/null +++ b/services/surfaceflinger/layerproto/layers.proto @@ -0,0 +1,171 @@ +// Definitions for SurfaceFlinger layers. + +syntax = "proto3"; +option optimize_for = LITE_RUNTIME; + +import "frameworks/native/services/surfaceflinger/layerproto/common.proto"; + +package android.surfaceflinger; + +// Contains a list of all layers. +message LayersProto { + repeated LayerProto layers = 1; +} + +// Must match definition in the IComposerClient HAL +enum HwcCompositionType { + // Invalid composition type + INVALID = 0; + // Layer was composited by the client into the client target buffer + CLIENT = 1; + // Layer was composited by the device through hardware overlays + DEVICE = 2; + // Layer was composited by the device using a color + SOLID_COLOR = 3; + // Similar to DEVICE, but the layer position may have been asynchronously set + // through setCursorPosition + CURSOR = 4; + // Layer was composited by the device via a sideband stream. + SIDEBAND = 5; +} + +// Information about each layer. +message LayerProto { + // unique id per layer. + int32 id = 1; + // unique name per layer. + string name = 2; + // list of children this layer may have. May be empty. + repeated int32 children = 3; + // list of layers that are z order relative to this layer. + repeated int32 relatives = 4; + // The type of layer, ex Color, Layer + string type = 5; + RegionProto transparent_region = 6; + RegionProto visible_region = 7; + RegionProto damage_region = 8; + uint32 layer_stack = 9; + // The layer's z order. Can be z order in layer stack, relative to parent, + // or relative to another layer specified in zOrderRelative. + int32 z = 10; + // The layer's position on the display. + PositionProto position = 11; + // The layer's requested position. + PositionProto requested_position = 12; + // The layer's size. + SizeProto size = 13; + // The layer's crop in it's own bounds. + RectProto crop = 14; + // The layer's crop in it's parent's bounds. + RectProto final_crop = 15 [deprecated=true]; + bool is_opaque = 16; + bool invalidate = 17; + string dataspace = 18; + string pixel_format = 19; + // The layer's actual color. + ColorProto color = 20; + // The layer's requested color. + ColorProto requested_color = 21; + // Can be any combination of + // hidden = 0x01 + // opaque = 0x02, + // secure = 0x80, + uint32 flags = 22; + // The layer's actual transform + TransformProto transform = 23; + // The layer's requested transform. + TransformProto requested_transform = 24; + // The parent layer. This value can be null if there is no parent. + int32 parent = 25; + // The layer that this layer has a z order relative to. This value can be null. + int32 z_order_relative_of = 26; + // This value can be null if there's nothing to draw. + ActiveBufferProto active_buffer = 27; + // The number of frames available. + int32 queued_frames = 28; + bool refresh_pending = 29; + // The layer's composer backend destination frame + RectProto hwc_frame = 30; + // The layer's composer backend source crop + FloatRectProto hwc_crop = 31; + // The layer's composer backend transform + int32 hwc_transform = 32; + int32 window_type = 33 [deprecated=true]; + int32 app_id = 34 [deprecated=true]; + // The layer's composition type + HwcCompositionType hwc_composition_type = 35; + // If it's a buffer layer, indicate if the content is protected + bool is_protected = 36; + // Current frame number being rendered. + uint64 curr_frame = 37; + // A list of barriers that the layer is waiting to update state. + repeated BarrierLayerProto barrier_layer = 38; + // If active_buffer is not null, record its transform. + TransformProto buffer_transform = 39; + int32 effective_scaling_mode = 40; + // Layer's corner radius. + float corner_radius = 41; + // Metadata map. May be empty. + map<int32, bytes> metadata = 42; + + TransformProto effective_transform = 43; + FloatRectProto source_bounds = 44; + FloatRectProto bounds = 45; + FloatRectProto screen_bounds = 46; + + InputWindowInfoProto input_window_info = 47; + + // Crop used to draw the rounded corner. + FloatRectProto corner_radius_crop = 48; + + // length of the shadow to draw around the layer, it may be set on the + // layer or set by a parent layer. + float shadow_radius = 49; + ColorTransformProto color_transform = 50; + + bool is_relative_of = 51; + // Layer's background blur radius in pixels. + int32 background_blur_radius = 52; + + uint32 owner_uid = 53; + + // Regions of a layer, where blur should be applied. + repeated BlurRegion blur_regions = 54; + + bool is_trusted_overlay = 55; + + // Corner radius explicitly set on layer rather than inherited + float requested_corner_radius = 56; + + RectProto destination_frame = 57; + + uint32 original_id = 58; +} + +message PositionProto { + float x = 1; + float y = 2; +} + +message FloatRectProto { + float left = 1; + float top = 2; + float right = 3; + float bottom = 4; +} + +message ActiveBufferProto { + uint32 width = 1; + uint32 height = 2; + uint32 stride = 3; + int32 format = 4; + uint64 usage = 5; +} + +message BarrierLayerProto { + // layer id the barrier is waiting on. + int32 id = 1; + // frame number the barrier is waiting on. + uint64 frame_number = 2; +} + diff --git a/services/surfaceflinger/layerproto/layerstrace.proto b/services/surfaceflinger/layerproto/layerstrace.proto new file mode 100644 index 0000000000..804a4994ee --- /dev/null +++ b/services/surfaceflinger/layerproto/layerstrace.proto @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +syntax = "proto2"; +option optimize_for = LITE_RUNTIME; + +import "frameworks/native/services/surfaceflinger/layerproto/layers.proto"; +import "frameworks/native/services/surfaceflinger/layerproto/display.proto"; + +package android.surfaceflinger; + +/* represents a file full of surface flinger trace entries. + Encoded, it should start with 0x4c 0x59 0x52 0x54 0x52 0x41 0x43 0x45 (.LYRTRACE), such + that they can be easily identified. */ +message LayersTraceFileProto { + + /* constant; MAGIC_NUMBER = (long) MAGIC_NUMBER_H << 32 | MagicNumber.MAGIC_NUMBER_L + (this is needed because enums have to be 32 bits and there's no nice way to put 64bit + constants into .proto files. */ + enum MagicNumber { + INVALID = 0; + MAGIC_NUMBER_L = 0x5452594c; /* LYRT (little-endian ASCII) */ + MAGIC_NUMBER_H = 0x45434152; /* RACE (little-endian ASCII) */ + } + + optional fixed64 magic_number = 1; /* Must be the first field, set to value in MagicNumber */ + repeated LayersTraceProto entry = 2; + + /* offset between real-time clock and elapsed time clock in nanoseconds. + Calculated as: systemTime(SYSTEM_TIME_REALTIME) - systemTime(SYSTEM_TIME_MONOTONIC) */ + optional fixed64 real_to_elapsed_time_offset_nanos = 3; +} + +/* one layers trace entry. */ +message LayersTraceProto { + /* required: elapsed realtime in nanos since boot of when this entry was logged */ + optional sfixed64 elapsed_realtime_nanos = 1; + + /* where the trace originated */ + optional string where = 2; + + optional LayersProto layers = 3; + + // Blob for the current HWC information for all layers, reported by dumpsys. + optional string hwc_blob = 4; + + /* Includes state sent during composition like visible region and composition type. */ + optional bool excludes_composition_state = 5; + + /* Number of missed entries since the last entry was recorded. */ + optional uint32 missed_entries = 6; + + repeated DisplayProto displays = 7; + + optional int64 vsync_id = 8; +} diff --git a/services/surfaceflinger/layerproto/transactions.proto b/services/surfaceflinger/layerproto/transactions.proto new file mode 100644 index 0000000000..d03afa05ab --- /dev/null +++ b/services/surfaceflinger/layerproto/transactions.proto @@ -0,0 +1,310 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +syntax = "proto3"; +option optimize_for = LITE_RUNTIME; + +import "frameworks/native/services/surfaceflinger/layerproto/common.proto"; + +package android.surfaceflinger.proto; + +/* Represents a file full of surface flinger transactions. + Encoded, it should start with 0x54 0x4E 0x58 0x54 0x52 0x41 0x43 0x45 (.TNXTRACE), such + that they can be easily identified. */ +message TransactionTraceFile { + /* constant; MAGIC_NUMBER = (long) MAGIC_NUMBER_H << 32 | MagicNumber.MAGIC_NUMBER_L + (this is needed because enums have to be 32 bits and there's no nice way to put 64bit + constants into .proto files. */ + enum MagicNumber { + INVALID = 0; + MAGIC_NUMBER_L = 0x54584E54; /* TNXT (little-endian ASCII) */ + MAGIC_NUMBER_H = 0x45434152; /* RACE (little-endian ASCII) */ + } + + fixed64 magic_number = 1; /* Must be the first field, set to value in MagicNumber */ + repeated TransactionTraceEntry entry = 2; + + /* offset between real-time clock and elapsed time clock in nanoseconds. + Calculated as: systemTime(SYSTEM_TIME_REALTIME) - systemTime(SYSTEM_TIME_MONOTONIC) */ + fixed64 real_to_elapsed_time_offset_nanos = 3; + uint32 version = 4; +} + +message TransactionTraceEntry { + int64 elapsed_realtime_nanos = 1; + int64 vsync_id = 2; + repeated TransactionState transactions = 3; + repeated LayerCreationArgs added_layers = 4; + repeated uint32 destroyed_layers = 5; + repeated DisplayState added_displays = 6; + repeated int32 removed_displays = 7; + repeated uint32 destroyed_layer_handles = 8; + bool displays_changed = 9; + repeated DisplayInfo displays = 10; +} + +message DisplayInfo { + uint32 layer_stack = 1; + int32 display_id = 2; + int32 logical_width = 3; + int32 logical_height = 4; + Transform transform_inverse = 5; + Transform transform = 6; + bool receives_input = 7; + bool is_secure = 8; + bool is_primary = 9; + bool is_virtual = 10; + int32 rotation_flags = 11; + int32 transform_hint = 12; + +} + +message LayerCreationArgs { + uint32 layer_id = 1; + string name = 2; + uint32 flags = 3; + uint32 parent_id = 4; + uint32 mirror_from_id = 5; + bool add_to_root = 6; + uint32 layer_stack_to_mirror = 7; +} + +message Transform { + float dsdx = 1; + float dtdx = 2; + float dtdy = 3; + float dsdy = 4; + float tx = 5; + float ty = 6; +} + +message TransactionState { + int32 pid = 1; + int32 uid = 2; + int64 vsync_id = 3; + int32 input_event_id = 4; + int64 post_time = 5; + uint64 transaction_id = 6; + repeated LayerState layer_changes = 7; + repeated DisplayState display_changes = 8; + repeated uint64 merged_transaction_ids = 9; +} + +// Keep insync with layer_state_t +message LayerState { + uint32 layer_id = 1; + // Changes are split into ChangesLsb and ChangesMsb. First 32 bits are in ChangesLsb + // and the next 32 bits are in ChangesMsb. This is needed because enums have to be + // 32 bits and there's no nice way to put 64bit constants into .proto files. + enum ChangesLsb { + eChangesLsbNone = 0; + ePositionChanged = 0x00000001; + eLayerChanged = 0x00000002; + // unused = 0x00000004; + eAlphaChanged = 0x00000008; + + eMatrixChanged = 0x00000010; + eTransparentRegionChanged = 0x00000020; + eFlagsChanged = 0x00000040; + eLayerStackChanged = 0x00000080; + + eReleaseBufferListenerChanged = 0x00000400; + eShadowRadiusChanged = 0x00000800; + + eBufferCropChanged = 0x00002000; + eRelativeLayerChanged = 0x00004000; + eReparent = 0x00008000; + + eColorChanged = 0x00010000; + eBufferTransformChanged = 0x00040000; + eTransformToDisplayInverseChanged = 0x00080000; + + eCropChanged = 0x00100000; + eBufferChanged = 0x00200000; + eAcquireFenceChanged = 0x00400000; + eDataspaceChanged = 0x00800000; + + eHdrMetadataChanged = 0x01000000; + eSurfaceDamageRegionChanged = 0x02000000; + eApiChanged = 0x04000000; + eSidebandStreamChanged = 0x08000000; + + eColorTransformChanged = 0x10000000; + eHasListenerCallbacksChanged = 0x20000000; + eInputInfoChanged = 0x40000000; + eCornerRadiusChanged = -2147483648; // 0x80000000; (proto stores enums as signed int) + }; + enum ChangesMsb { + eChangesMsbNone = 0; + eDestinationFrameChanged = 0x1; + eCachedBufferChanged = 0x2; + eBackgroundColorChanged = 0x4; + eMetadataChanged = 0x8; + eColorSpaceAgnosticChanged = 0x10; + eFrameRateSelectionPriority = 0x20; + eFrameRateChanged = 0x40; + eBackgroundBlurRadiusChanged = 0x80; + eProducerDisconnect = 0x100; + eFixedTransformHintChanged = 0x200; + eFrameNumberChanged = 0x400; + eBlurRegionsChanged = 0x800; + eAutoRefreshChanged = 0x1000; + eStretchChanged = 0x2000; + eTrustedOverlayChanged = 0x4000; + eDropInputModeChanged = 0x8000; + }; + uint64 what = 2; + float x = 3; + float y = 4; + int32 z = 5; + uint32 w = 6; + uint32 h = 7; + uint32 layer_stack = 8; + + enum Flags { + eFlagsNone = 0; + eLayerHidden = 0x01; + eLayerOpaque = 0x02; + eLayerSkipScreenshot = 0x40; + eLayerSecure = 0x80; + eEnableBackpressure = 0x100; + eLayerIsDisplayDecoration = 0x200; + }; + uint32 flags = 9; + uint32 mask = 10; + + message Matrix22 { + float dsdx = 1; + float dtdx = 2; + float dtdy = 3; + float dsdy = 4; + }; + Matrix22 matrix = 11; + float corner_radius = 12; + uint32 background_blur_radius = 13; + uint32 parent_id = 14; + uint32 relative_parent_id = 15; + + float alpha = 16; + message Color3 { + float r = 1; + float g = 2; + float b = 3; + } + Color3 color = 17; + RegionProto transparent_region = 18; + uint32 transform = 19; + bool transform_to_display_inverse = 20; + RectProto crop = 21; + + message BufferData { + uint64 buffer_id = 1; + uint32 width = 2; + uint32 height = 3; + uint64 frame_number = 4; + + enum BufferDataChange { + BufferDataChangeNone = 0; + fenceChanged = 0x01; + frameNumberChanged = 0x02; + cachedBufferChanged = 0x04; + } + uint32 flags = 5; + uint64 cached_buffer_id = 6; + + enum PixelFormat { + PIXEL_FORMAT_UNKNOWN = 0; + PIXEL_FORMAT_CUSTOM = -4; + PIXEL_FORMAT_TRANSLUCENT = -3; + PIXEL_FORMAT_TRANSPARENT = -2; + PIXEL_FORMAT_OPAQUE = -1; + PIXEL_FORMAT_RGBA_8888 = 1; + PIXEL_FORMAT_RGBX_8888 = 2; + PIXEL_FORMAT_RGB_888 = 3; + PIXEL_FORMAT_RGB_565 = 4; + PIXEL_FORMAT_BGRA_8888 = 5; + PIXEL_FORMAT_RGBA_5551 = 6; + PIXEL_FORMAT_RGBA_4444 = 7; + PIXEL_FORMAT_RGBA_FP16 = 22; + PIXEL_FORMAT_RGBA_1010102 = 43; + PIXEL_FORMAT_R_8 = 0x38; + } + PixelFormat pixel_format = 7; + uint64 usage = 8; + } + BufferData buffer_data = 22; + int32 api = 23; + bool has_sideband_stream = 24; + ColorTransformProto color_transform = 25; + repeated BlurRegion blur_regions = 26; + + message WindowInfo { + uint32 layout_params_flags = 1; + int32 layout_params_type = 2; + RegionProto touchable_region = 3; + int32 surface_inset = 4; + bool focusable = 5; // unused + bool has_wallpaper = 6; // unused + float global_scale_factor = 7; + uint32 crop_layer_id = 8; + bool replace_touchable_region_with_crop = 9; + RectProto touchable_region_crop = 10; + Transform transform = 11; + uint32 input_config = 12; + } + WindowInfo window_info_handle = 27; + float bg_color_alpha = 28; + int32 bg_color_dataspace = 29; + bool color_space_agnostic = 30; + float shadow_radius = 31; + int32 frame_rate_selection_priority = 32; + float frame_rate = 33; + int32 frame_rate_compatibility = 34; + int32 change_frame_rate_strategy = 35; + uint32 fixed_transform_hint = 36; + uint64 frame_number = 37; + bool auto_refresh = 38; + bool is_trusted_overlay = 39; + RectProto buffer_crop = 40; + RectProto destination_frame = 41; + + enum DropInputMode { + NONE = 0; + ALL = 1; + OBSCURED = 2; + }; + DropInputMode drop_input_mode = 42; +} + +message DisplayState { + enum Changes { + eChangesNone = 0; + eSurfaceChanged = 0x01; + eLayerStackChanged = 0x02; + eDisplayProjectionChanged = 0x04; + eDisplaySizeChanged = 0x08; + eFlagsChanged = 0x10; + }; + int32 id = 1; + uint32 what = 2; + uint32 flags = 3; + uint32 layer_stack = 4; + uint32 orientation = 5; + RectProto layer_stack_space_rect = 6; + RectProto oriented_display_space_rect = 7; + uint32 width = 8; + uint32 height = 9; +} diff --git a/services/surfaceflinger/tests/Stress_test.cpp b/services/surfaceflinger/tests/Stress_test.cpp index b30df5ef15..03201f7937 100644 --- a/services/surfaceflinger/tests/Stress_test.cpp +++ b/services/surfaceflinger/tests/Stress_test.cpp @@ -51,9 +51,9 @@ TEST(SurfaceFlingerStress, create_and_destroy) { } } -perfetto::protos::LayersProto generateLayerProto() { - perfetto::protos::LayersProto layersProto; - std::array<perfetto::protos::LayerProto*, 10> layers = {}; +surfaceflinger::LayersProto generateLayerProto() { + surfaceflinger::LayersProto layersProto; + std::array<surfaceflinger::LayerProto*, 10> layers = {}; for (size_t i = 0; i < layers.size(); ++i) { layers[i] = layersProto.add_layers(); layers[i]->set_id(i); @@ -103,7 +103,7 @@ TEST(LayerProtoStress, mem_info) { cmd += std::to_string(getpid()); system(cmd.c_str()); for (int i = 0; i < 100000; i++) { - perfetto::protos::LayersProto layersProto = generateLayerProto(); + surfaceflinger::LayersProto layersProto = generateLayerProto(); auto layerTree = surfaceflinger::LayerProtoParser::generateLayerTree(layersProto); surfaceflinger::LayerProtoParser::layerTreeToString(layerTree); } diff --git a/services/surfaceflinger/tests/tracing/TransactionTraceTestSuite.cpp b/services/surfaceflinger/tests/tracing/TransactionTraceTestSuite.cpp index 333768a92a..b8a5e79a38 100644 --- a/services/surfaceflinger/tests/tracing/TransactionTraceTestSuite.cpp +++ b/services/surfaceflinger/tests/tracing/TransactionTraceTestSuite.cpp @@ -149,7 +149,7 @@ static LayerInfo getLayerInfoFromProto(::android::surfaceflinger::LayerProto& pr } static std::vector<LayerInfo> getLayerInfosFromProto( - perfetto::protos::pbzero::LayersSnapshotProto& entry) { + android::surfaceflinger::LayersTraceProto& entry) { std::unordered_map<uint64_t /* snapshotId*/, uint64_t /*layerId*/> snapshotIdToLayerId; std::vector<LayerInfo> layers; layers.reserve(static_cast<size_t>(entry.layers().layers_size())); @@ -267,4 +267,4 @@ int main(int argc, char** argv) { } ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); -} +}
\ No newline at end of file diff --git a/services/surfaceflinger/tests/unittests/TransactionProtoParserTest.cpp b/services/surfaceflinger/tests/unittests/TransactionProtoParserTest.cpp index cbb597af69..a95a6453d5 100644 --- a/services/surfaceflinger/tests/unittests/TransactionProtoParserTest.cpp +++ b/services/surfaceflinger/tests/unittests/TransactionProtoParserTest.cpp @@ -85,7 +85,7 @@ TEST(TransactionProtoParserTest, parse) { TransactionProtoParser parser(std::make_unique<TestMapper>(displayHandle)); - perfetto::protos::TransactionState proto = parser.toProto(t1); + proto::TransactionState proto = parser.toProto(t1); TransactionState t2 = parser.fromProto(proto); ASSERT_EQ(t1.originPid, t2.originPid); @@ -119,7 +119,7 @@ TEST(TransactionProtoParserTest, parseDisplayInfo) { d1.transformHint = ui::Transform::ROT_90; const uint32_t layerStack = 2; - google::protobuf::RepeatedPtrField<perfetto::protos::DisplayInfo> displayProtos; + google::protobuf::RepeatedPtrField<proto::DisplayInfo> displayProtos; auto displayInfoProto = displayProtos.Add(); *displayInfoProto = TransactionProtoParser::toProto(d1, layerStack); frontend::DisplayInfos displayInfos; diff --git a/services/surfaceflinger/tests/unittests/TransactionTracingTest.cpp b/services/surfaceflinger/tests/unittests/TransactionTracingTest.cpp index 7981224b5c..71a2d2b9a6 100644 --- a/services/surfaceflinger/tests/unittests/TransactionTracingTest.cpp +++ b/services/surfaceflinger/tests/unittests/TransactionTracingTest.cpp @@ -37,11 +37,11 @@ protected: TransactionTracing mTracing; void flush() { mTracing.flush(); } - perfetto::protos::TransactionTraceFile writeToProto() { return mTracing.writeToProto(); } + proto::TransactionTraceFile writeToProto() { return mTracing.writeToProto(); } - perfetto::protos::TransactionTraceEntry bufferFront() { + proto::TransactionTraceEntry bufferFront() { std::scoped_lock<std::mutex> lock(mTracing.mTraceLock); - perfetto::protos::TransactionTraceEntry entry; + proto::TransactionTraceEntry entry; entry.ParseFromString(mTracing.mBuffer.front()); return entry; } @@ -59,7 +59,7 @@ protected: flush(); } - void verifyEntry(const perfetto::protos::TransactionTraceEntry& actualProto, + void verifyEntry(const proto::TransactionTraceEntry& actualProto, const std::vector<TransactionState>& expectedTransactions, int64_t expectedVsyncId) { EXPECT_EQ(actualProto.vsync_id(), expectedVsyncId); @@ -117,7 +117,7 @@ TEST_F(TransactionTracingTest, addTransactions) { mTracing.addCommittedTransactions(secondTransactionSetVsyncId, 0, secondUpdate, {}, false); flush(); - perfetto::protos::TransactionTraceFile proto = writeToProto(); + proto::TransactionTraceFile proto = writeToProto(); ASSERT_EQ(proto.entry().size(), 2); verifyEntry(proto.entry(0), firstUpdate.transactions, firstTransactionSetVsyncId); verifyEntry(proto.entry(1), secondUpdate.transactions, secondTransactionSetVsyncId); @@ -203,7 +203,7 @@ TEST_F(TransactionTracingLayerHandlingTest, addStartingState) { while (bufferFront().vsync_id() <= VSYNC_ID_FIRST_LAYER_CHANGE) { queueAndCommitTransaction(++mVsyncId); } - perfetto::protos::TransactionTraceFile proto = writeToProto(); + proto::TransactionTraceFile proto = writeToProto(); // verify we can still retrieve the layer change from the first entry containing starting // states. EXPECT_GT(proto.entry().size(), 0); @@ -221,7 +221,7 @@ TEST_F(TransactionTracingLayerHandlingTest, updateStartingState) { while (bufferFront().vsync_id() <= VSYNC_ID_SECOND_LAYER_CHANGE) { queueAndCommitTransaction(++mVsyncId); } - perfetto::protos::TransactionTraceFile proto = writeToProto(); + proto::TransactionTraceFile proto = writeToProto(); // verify starting states are updated correctly EXPECT_EQ(proto.entry(0).transactions(0).layer_changes(0).z(), 41); } @@ -231,7 +231,7 @@ TEST_F(TransactionTracingLayerHandlingTest, removeStartingState) { while (bufferFront().vsync_id() <= VSYNC_ID_CHILD_LAYER_REMOVED) { queueAndCommitTransaction(++mVsyncId); } - perfetto::protos::TransactionTraceFile proto = writeToProto(); + proto::TransactionTraceFile proto = writeToProto(); // verify the child layer has been removed from the trace EXPECT_EQ(proto.entry(0).transactions(0).layer_changes().size(), 1); EXPECT_EQ(proto.entry(0).transactions(0).layer_changes(0).layer_id(), mParentLayerId); @@ -242,7 +242,7 @@ TEST_F(TransactionTracingLayerHandlingTest, startingStateSurvivesBufferFlush) { while (bufferFront().vsync_id() <= VSYNC_ID_SECOND_LAYER_CHANGE) { queueAndCommitTransaction(++mVsyncId); } - perfetto::protos::TransactionTraceFile proto = writeToProto(); + proto::TransactionTraceFile proto = writeToProto(); // verify we have two starting states EXPECT_EQ(proto.entry(0).transactions(0).layer_changes().size(), 2); @@ -302,7 +302,7 @@ protected: }; TEST_F(TransactionTracingMirrorLayerTest, canAddMirrorLayers) { - perfetto::protos::TransactionTraceFile proto = writeToProto(); + proto::TransactionTraceFile proto = writeToProto(); // We don't have any starting states since no layer was removed from. EXPECT_EQ(proto.entry().size(), 1); @@ -317,18 +317,18 @@ TEST_F(TransactionTracingMirrorLayerTest, canAddMirrorLayers) { // Verify we can write the layers traces by entry to reduce mem pressure // on the system when generating large traces. TEST(LayerTraceTest, canStreamLayersTrace) { - perfetto::protos::LayersTraceFileProto inProto = LayerTracing::createTraceFileProto(); + LayersTraceFileProto inProto = LayerTracing::createTraceFileProto(); inProto.add_entry(); inProto.add_entry(); std::string output; inProto.SerializeToString(&output); - perfetto::protos::LayersTraceFileProto inProto2 = LayerTracing::createTraceFileProto(); + LayersTraceFileProto inProto2 = LayerTracing::createTraceFileProto(); inProto2.add_entry(); std::string output2; inProto2.SerializeToString(&output2); - perfetto::protos::LayersTraceFileProto outProto; + LayersTraceFileProto outProto; outProto.ParseFromString(output + output2); // magic? EXPECT_EQ(outProto.entry().size(), 3); |