Loading libs/gui/LayerState.cpp +18 −6 Original line number Diff line number Diff line Loading @@ -35,7 +35,9 @@ using gui::FocusRequest; using gui::WindowInfoHandle; layer_state_t::layer_state_t() : what(0), : surface(nullptr), layerId(-1), what(0), x(0), y(0), z(0), Loading Loading @@ -153,8 +155,12 @@ status_t layer_state_t::write(Parcel& output) const SAFE_PARCEL(output.writeBool, isTrustedOverlay); SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dropInputMode)); SAFE_PARCEL(output.writeNullableParcelable, bufferData ? std::make_optional<BufferData>(*bufferData) : std::nullopt); const bool hasBufferData = (bufferData != nullptr); SAFE_PARCEL(output.writeBool, hasBufferData); if (hasBufferData) { SAFE_PARCEL(output.writeParcelable, *bufferData); } return NO_ERROR; } Loading Loading @@ -264,9 +270,15 @@ status_t layer_state_t::read(const Parcel& input) uint32_t mode; SAFE_PARCEL(input.readUint32, &mode); dropInputMode = static_cast<gui::DropInputMode>(mode); std::optional<BufferData> tmpBufferData; SAFE_PARCEL(input.readParcelable, &tmpBufferData); bufferData = tmpBufferData ? std::make_shared<BufferData>(*tmpBufferData) : nullptr; bool hasBufferData; SAFE_PARCEL(input.readBool, &hasBufferData); if (hasBufferData) { bufferData = std::make_shared<BufferData>(); SAFE_PARCEL(input.readParcelable, bufferData.get()); } else { bufferData = nullptr; } return NO_ERROR; } Loading services/surfaceflinger/Layer.cpp +8 −10 Original line number Diff line number Diff line Loading @@ -1993,29 +1993,31 @@ void Layer::setInputInfo(const WindowInfo& info) { setTransactionFlags(eTransactionNeeded); } LayerProto* Layer::writeToProto(LayersProto& layersProto, uint32_t traceFlags, const DisplayDevice* display) { LayerProto* Layer::writeToProto(LayersProto& layersProto, uint32_t traceFlags) { LayerProto* layerProto = layersProto.add_layers(); writeToProtoDrawingState(layerProto, traceFlags, display); writeToProtoDrawingState(layerProto); writeToProtoCommonState(layerProto, LayerVector::StateSet::Drawing, traceFlags); if (traceFlags & LayerTracing::TRACE_COMPOSITION) { // Only populate for the primary display. UnnecessaryLock assumeLocked(mFlinger->mStateLock); // called from the main thread. const auto display = mFlinger->getDefaultDisplayDeviceLocked(); if (display) { const auto compositionType = getCompositionType(*display); layerProto->set_hwc_composition_type(static_cast<HwcCompositionType>(compositionType)); LayerProtoHelper::writeToProto(getVisibleRegion(display.get()), [&]() { return layerProto->mutable_visible_region(); }); } } for (const sp<Layer>& layer : mDrawingChildren) { layer->writeToProto(layersProto, traceFlags, display); layer->writeToProto(layersProto, traceFlags); } return layerProto; } void Layer::writeToProtoDrawingState(LayerProto* layerInfo, uint32_t traceFlags, const DisplayDevice* display) { void Layer::writeToProtoDrawingState(LayerProto* layerInfo) { const ui::Transform transform = getTransform(); auto buffer = getExternalTexture(); if (buffer != nullptr) { Loading @@ -2039,10 +2041,6 @@ void Layer::writeToProtoDrawingState(LayerProto* layerInfo, uint32_t traceFlags, LayerProtoHelper::writePositionToProto(transform.tx(), transform.ty(), [&]() { return layerInfo->mutable_position(); }); LayerProtoHelper::writeToProto(mBounds, [&]() { return layerInfo->mutable_bounds(); }); if (traceFlags & LayerTracing::TRACE_COMPOSITION) { LayerProtoHelper::writeToProto(getVisibleRegion(display), [&]() { return layerInfo->mutable_visible_region(); }); } LayerProtoHelper::writeToProto(surfaceDamageRegion, [&]() { return layerInfo->mutable_damage_region(); }); Loading services/surfaceflinger/Layer.h +2 −2 Original line number Diff line number Diff line Loading @@ -686,12 +686,12 @@ public: bool isRemovedFromCurrentState() const; LayerProto* writeToProto(LayersProto& layersProto, uint32_t traceFlags, const DisplayDevice*); LayerProto* writeToProto(LayersProto& layersProto, uint32_t traceFlags); // 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(LayerProto* layerInfo, uint32_t traceFlags, const DisplayDevice*); 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. Loading services/surfaceflinger/LayerProtoHelper.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -156,14 +156,14 @@ void LayerProtoHelper::writeTransformToProto(const ui::Transform& transform, void LayerProtoHelper::writeToProto(const renderengine::ExternalTexture& buffer, std::function<ActiveBufferProto*()> getActiveBufferProto) { if (buffer.getBuffer()->getWidth() != 0 || buffer.getBuffer()->getHeight() != 0 || buffer.getBuffer()->getUsage() != 0 || buffer.getBuffer()->getPixelFormat() != 0) { 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 ActiveBufferProto* activeBufferProto = getActiveBufferProto(); activeBufferProto->set_width(buffer.getBuffer()->getWidth()); activeBufferProto->set_height(buffer.getBuffer()->getHeight()); activeBufferProto->set_format(buffer.getBuffer()->getPixelFormat()); activeBufferProto->set_usage(buffer.getBuffer()->getUsage()); activeBufferProto->set_width(buffer.getWidth()); activeBufferProto->set_height(buffer.getHeight()); activeBufferProto->set_stride(buffer.getUsage()); activeBufferProto->set_format(buffer.getPixelFormat()); } } Loading services/surfaceflinger/SurfaceFlinger.cpp +9 −13 Original line number Diff line number Diff line Loading @@ -250,11 +250,6 @@ struct SCOPED_CAPABILITY TimedLock { const status_t status; }; struct SCOPED_CAPABILITY UnnecessaryLock { explicit UnnecessaryLock(Mutex& mutex) ACQUIRE(mutex) {} ~UnnecessaryLock() RELEASE() {} }; // TODO(b/141333600): Consolidate with DisplayMode::Builder::getDefaultDensity. constexpr float FALLBACK_DENSITY = ACONFIGURATION_DENSITY_TV; Loading Loading @@ -5102,11 +5097,9 @@ void SurfaceFlinger::dumpWideColorInfo(std::string& result) const { } LayersProto SurfaceFlinger::dumpDrawingStateProto(uint32_t traceFlags) const { const auto display = ON_MAIN_THREAD(getDefaultDisplayDeviceLocked()); LayersProto layersProto; for (const sp<Layer>& layer : mDrawingState.layersSortedByZ) { layer->writeToProto(layersProto, traceFlags, display.get()); layer->writeToProto(layersProto, traceFlags); } return layersProto; Loading Loading @@ -5147,8 +5140,7 @@ void SurfaceFlinger::dumpOffscreenLayersProto(LayersProto& layersProto, uint32_t rootProto->add_children(offscreenLayer->sequence); // Add layer LayerProto* layerProto = offscreenLayer->writeToProto(layersProto, traceFlags, nullptr /*device*/); LayerProto* layerProto = offscreenLayer->writeToProto(layersProto, traceFlags); layerProto->set_parent(offscreenRootLayerId); } } Loading Loading @@ -5743,9 +5735,9 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r } case 1025: { // Set layer tracing n = data.readInt32(); int64_t fixedStartingTime = data.readInt64(); bool tracingEnabledChanged; if (n) { if (n == 1) { int64_t fixedStartingTime = data.readInt64(); ALOGD("LayerTracing enabled"); tracingEnabledChanged = mLayerTracing.enable(); if (tracingEnabledChanged) { Loading @@ -5757,6 +5749,10 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r }) .wait(); } } else if (n == 2) { std::string filename = std::string(data.readCString()); ALOGD("LayerTracing disabled. Trace wrote to %s", filename.c_str()); tracingEnabledChanged = mLayerTracing.disable(filename.c_str()); } else { ALOGD("LayerTracing disabled"); tracingEnabledChanged = mLayerTracing.disable(); Loading Loading @@ -6009,9 +6005,9 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r mTransactionTracing->setBufferSize( TransactionTracing::ACTIVE_TRACING_BUFFER_SIZE); } else { mTransactionTracing->writeToFile(); mTransactionTracing->setBufferSize( TransactionTracing::CONTINUOUS_TRACING_BUFFER_SIZE); mTransactionTracing->writeToFile(); } } reply->writeInt32(NO_ERROR); Loading Loading
libs/gui/LayerState.cpp +18 −6 Original line number Diff line number Diff line Loading @@ -35,7 +35,9 @@ using gui::FocusRequest; using gui::WindowInfoHandle; layer_state_t::layer_state_t() : what(0), : surface(nullptr), layerId(-1), what(0), x(0), y(0), z(0), Loading Loading @@ -153,8 +155,12 @@ status_t layer_state_t::write(Parcel& output) const SAFE_PARCEL(output.writeBool, isTrustedOverlay); SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dropInputMode)); SAFE_PARCEL(output.writeNullableParcelable, bufferData ? std::make_optional<BufferData>(*bufferData) : std::nullopt); const bool hasBufferData = (bufferData != nullptr); SAFE_PARCEL(output.writeBool, hasBufferData); if (hasBufferData) { SAFE_PARCEL(output.writeParcelable, *bufferData); } return NO_ERROR; } Loading Loading @@ -264,9 +270,15 @@ status_t layer_state_t::read(const Parcel& input) uint32_t mode; SAFE_PARCEL(input.readUint32, &mode); dropInputMode = static_cast<gui::DropInputMode>(mode); std::optional<BufferData> tmpBufferData; SAFE_PARCEL(input.readParcelable, &tmpBufferData); bufferData = tmpBufferData ? std::make_shared<BufferData>(*tmpBufferData) : nullptr; bool hasBufferData; SAFE_PARCEL(input.readBool, &hasBufferData); if (hasBufferData) { bufferData = std::make_shared<BufferData>(); SAFE_PARCEL(input.readParcelable, bufferData.get()); } else { bufferData = nullptr; } return NO_ERROR; } Loading
services/surfaceflinger/Layer.cpp +8 −10 Original line number Diff line number Diff line Loading @@ -1993,29 +1993,31 @@ void Layer::setInputInfo(const WindowInfo& info) { setTransactionFlags(eTransactionNeeded); } LayerProto* Layer::writeToProto(LayersProto& layersProto, uint32_t traceFlags, const DisplayDevice* display) { LayerProto* Layer::writeToProto(LayersProto& layersProto, uint32_t traceFlags) { LayerProto* layerProto = layersProto.add_layers(); writeToProtoDrawingState(layerProto, traceFlags, display); writeToProtoDrawingState(layerProto); writeToProtoCommonState(layerProto, LayerVector::StateSet::Drawing, traceFlags); if (traceFlags & LayerTracing::TRACE_COMPOSITION) { // Only populate for the primary display. UnnecessaryLock assumeLocked(mFlinger->mStateLock); // called from the main thread. const auto display = mFlinger->getDefaultDisplayDeviceLocked(); if (display) { const auto compositionType = getCompositionType(*display); layerProto->set_hwc_composition_type(static_cast<HwcCompositionType>(compositionType)); LayerProtoHelper::writeToProto(getVisibleRegion(display.get()), [&]() { return layerProto->mutable_visible_region(); }); } } for (const sp<Layer>& layer : mDrawingChildren) { layer->writeToProto(layersProto, traceFlags, display); layer->writeToProto(layersProto, traceFlags); } return layerProto; } void Layer::writeToProtoDrawingState(LayerProto* layerInfo, uint32_t traceFlags, const DisplayDevice* display) { void Layer::writeToProtoDrawingState(LayerProto* layerInfo) { const ui::Transform transform = getTransform(); auto buffer = getExternalTexture(); if (buffer != nullptr) { Loading @@ -2039,10 +2041,6 @@ void Layer::writeToProtoDrawingState(LayerProto* layerInfo, uint32_t traceFlags, LayerProtoHelper::writePositionToProto(transform.tx(), transform.ty(), [&]() { return layerInfo->mutable_position(); }); LayerProtoHelper::writeToProto(mBounds, [&]() { return layerInfo->mutable_bounds(); }); if (traceFlags & LayerTracing::TRACE_COMPOSITION) { LayerProtoHelper::writeToProto(getVisibleRegion(display), [&]() { return layerInfo->mutable_visible_region(); }); } LayerProtoHelper::writeToProto(surfaceDamageRegion, [&]() { return layerInfo->mutable_damage_region(); }); Loading
services/surfaceflinger/Layer.h +2 −2 Original line number Diff line number Diff line Loading @@ -686,12 +686,12 @@ public: bool isRemovedFromCurrentState() const; LayerProto* writeToProto(LayersProto& layersProto, uint32_t traceFlags, const DisplayDevice*); LayerProto* writeToProto(LayersProto& layersProto, uint32_t traceFlags); // 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(LayerProto* layerInfo, uint32_t traceFlags, const DisplayDevice*); 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. Loading
services/surfaceflinger/LayerProtoHelper.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -156,14 +156,14 @@ void LayerProtoHelper::writeTransformToProto(const ui::Transform& transform, void LayerProtoHelper::writeToProto(const renderengine::ExternalTexture& buffer, std::function<ActiveBufferProto*()> getActiveBufferProto) { if (buffer.getBuffer()->getWidth() != 0 || buffer.getBuffer()->getHeight() != 0 || buffer.getBuffer()->getUsage() != 0 || buffer.getBuffer()->getPixelFormat() != 0) { 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 ActiveBufferProto* activeBufferProto = getActiveBufferProto(); activeBufferProto->set_width(buffer.getBuffer()->getWidth()); activeBufferProto->set_height(buffer.getBuffer()->getHeight()); activeBufferProto->set_format(buffer.getBuffer()->getPixelFormat()); activeBufferProto->set_usage(buffer.getBuffer()->getUsage()); activeBufferProto->set_width(buffer.getWidth()); activeBufferProto->set_height(buffer.getHeight()); activeBufferProto->set_stride(buffer.getUsage()); activeBufferProto->set_format(buffer.getPixelFormat()); } } Loading
services/surfaceflinger/SurfaceFlinger.cpp +9 −13 Original line number Diff line number Diff line Loading @@ -250,11 +250,6 @@ struct SCOPED_CAPABILITY TimedLock { const status_t status; }; struct SCOPED_CAPABILITY UnnecessaryLock { explicit UnnecessaryLock(Mutex& mutex) ACQUIRE(mutex) {} ~UnnecessaryLock() RELEASE() {} }; // TODO(b/141333600): Consolidate with DisplayMode::Builder::getDefaultDensity. constexpr float FALLBACK_DENSITY = ACONFIGURATION_DENSITY_TV; Loading Loading @@ -5102,11 +5097,9 @@ void SurfaceFlinger::dumpWideColorInfo(std::string& result) const { } LayersProto SurfaceFlinger::dumpDrawingStateProto(uint32_t traceFlags) const { const auto display = ON_MAIN_THREAD(getDefaultDisplayDeviceLocked()); LayersProto layersProto; for (const sp<Layer>& layer : mDrawingState.layersSortedByZ) { layer->writeToProto(layersProto, traceFlags, display.get()); layer->writeToProto(layersProto, traceFlags); } return layersProto; Loading Loading @@ -5147,8 +5140,7 @@ void SurfaceFlinger::dumpOffscreenLayersProto(LayersProto& layersProto, uint32_t rootProto->add_children(offscreenLayer->sequence); // Add layer LayerProto* layerProto = offscreenLayer->writeToProto(layersProto, traceFlags, nullptr /*device*/); LayerProto* layerProto = offscreenLayer->writeToProto(layersProto, traceFlags); layerProto->set_parent(offscreenRootLayerId); } } Loading Loading @@ -5743,9 +5735,9 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r } case 1025: { // Set layer tracing n = data.readInt32(); int64_t fixedStartingTime = data.readInt64(); bool tracingEnabledChanged; if (n) { if (n == 1) { int64_t fixedStartingTime = data.readInt64(); ALOGD("LayerTracing enabled"); tracingEnabledChanged = mLayerTracing.enable(); if (tracingEnabledChanged) { Loading @@ -5757,6 +5749,10 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r }) .wait(); } } else if (n == 2) { std::string filename = std::string(data.readCString()); ALOGD("LayerTracing disabled. Trace wrote to %s", filename.c_str()); tracingEnabledChanged = mLayerTracing.disable(filename.c_str()); } else { ALOGD("LayerTracing disabled"); tracingEnabledChanged = mLayerTracing.disable(); Loading Loading @@ -6009,9 +6005,9 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r mTransactionTracing->setBufferSize( TransactionTracing::ACTIVE_TRACING_BUFFER_SIZE); } else { mTransactionTracing->writeToFile(); mTransactionTracing->setBufferSize( TransactionTracing::CONTINUOUS_TRACING_BUFFER_SIZE); mTransactionTracing->writeToFile(); } } reply->writeInt32(NO_ERROR); Loading