Loading services/surfaceflinger/RegionSamplingThread.cpp +5 −4 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ #include "DisplayDevice.h" #include "DisplayRenderArea.h" #include "FrontEnd/LayerCreationArgs.h" #include "Layer.h" #include "Scheduler/VsyncController.h" #include "SurfaceFlinger.h" Loading Loading @@ -129,12 +130,12 @@ RegionSamplingThread::~RegionSamplingThread() { } } void RegionSamplingThread::addListener(const Rect& samplingArea, const wp<Layer>& stopLayer, void RegionSamplingThread::addListener(const Rect& samplingArea, uint32_t stopLayerId, const sp<IRegionSamplingListener>& listener) { sp<IBinder> asBinder = IInterface::asBinder(listener); asBinder->linkToDeath(sp<DeathRecipient>::fromExisting(this)); std::lock_guard lock(mSamplingMutex); mDescriptors.emplace(wp<IBinder>(asBinder), Descriptor{samplingArea, stopLayer, listener}); mDescriptors.emplace(wp<IBinder>(asBinder), Descriptor{samplingArea, stopLayerId, listener}); } void RegionSamplingThread::removeListener(const sp<IRegionSamplingListener>& listener) { Loading Loading @@ -291,8 +292,8 @@ void RegionSamplingThread::captureSample() { if (stopLayerFound) return; // Likewise if we just found a stop layer, set the flag and abort for (const auto& [area, stopLayer, listener] : descriptors) { if (layer == stopLayer.promote().get()) { for (const auto& [area, stopLayerId, listener] : descriptors) { if (stopLayerId != UNASSIGNED_LAYER_ID && layer->getSequence() == stopLayerId) { stopLayerFound = true; return; } Loading services/surfaceflinger/RegionSamplingThread.h +3 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include <chrono> #include <condition_variable> #include <cstdint> #include <mutex> #include <thread> #include <unordered_map> Loading Loading @@ -73,7 +74,7 @@ public: // Add a listener to receive luma notifications. The luma reported via listener will // report the median luma for the layers under the stopLayerHandle, in the samplingArea region. void addListener(const Rect& samplingArea, const wp<Layer>& stopLayer, void addListener(const Rect& samplingArea, uint32_t stopLayerId, const sp<IRegionSamplingListener>& listener); // Remove the listener to stop receiving median luma notifications. void removeListener(const sp<IRegionSamplingListener>& listener); Loading @@ -87,7 +88,7 @@ public: private: struct Descriptor { Rect area = Rect::EMPTY_RECT; wp<Layer> stopLayer; uint32_t stopLayerId; sp<IRegionSamplingListener> listener; }; Loading services/surfaceflinger/SurfaceFlinger.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -1581,9 +1581,10 @@ status_t SurfaceFlinger::addRegionSamplingListener(const Rect& samplingArea, // LayerHandle::getLayer promotes the layer object in a binder thread but we will not destroy // the layer here since the caller has a strong ref to the layer's handle. // TODO (b/238781169): replace layer with layer id const wp<Layer> stopLayer = LayerHandle::getLayer(stopLayerHandle); mRegionSamplingThread->addListener(samplingArea, stopLayer, listener); const sp<Layer> stopLayer = LayerHandle::getLayer(stopLayerHandle); mRegionSamplingThread->addListener(samplingArea, stopLayer ? stopLayer->getSequence() : UNASSIGNED_LAYER_ID, listener); return NO_ERROR; } Loading Loading
services/surfaceflinger/RegionSamplingThread.cpp +5 −4 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ #include "DisplayDevice.h" #include "DisplayRenderArea.h" #include "FrontEnd/LayerCreationArgs.h" #include "Layer.h" #include "Scheduler/VsyncController.h" #include "SurfaceFlinger.h" Loading Loading @@ -129,12 +130,12 @@ RegionSamplingThread::~RegionSamplingThread() { } } void RegionSamplingThread::addListener(const Rect& samplingArea, const wp<Layer>& stopLayer, void RegionSamplingThread::addListener(const Rect& samplingArea, uint32_t stopLayerId, const sp<IRegionSamplingListener>& listener) { sp<IBinder> asBinder = IInterface::asBinder(listener); asBinder->linkToDeath(sp<DeathRecipient>::fromExisting(this)); std::lock_guard lock(mSamplingMutex); mDescriptors.emplace(wp<IBinder>(asBinder), Descriptor{samplingArea, stopLayer, listener}); mDescriptors.emplace(wp<IBinder>(asBinder), Descriptor{samplingArea, stopLayerId, listener}); } void RegionSamplingThread::removeListener(const sp<IRegionSamplingListener>& listener) { Loading Loading @@ -291,8 +292,8 @@ void RegionSamplingThread::captureSample() { if (stopLayerFound) return; // Likewise if we just found a stop layer, set the flag and abort for (const auto& [area, stopLayer, listener] : descriptors) { if (layer == stopLayer.promote().get()) { for (const auto& [area, stopLayerId, listener] : descriptors) { if (stopLayerId != UNASSIGNED_LAYER_ID && layer->getSequence() == stopLayerId) { stopLayerFound = true; return; } Loading
services/surfaceflinger/RegionSamplingThread.h +3 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include <chrono> #include <condition_variable> #include <cstdint> #include <mutex> #include <thread> #include <unordered_map> Loading Loading @@ -73,7 +74,7 @@ public: // Add a listener to receive luma notifications. The luma reported via listener will // report the median luma for the layers under the stopLayerHandle, in the samplingArea region. void addListener(const Rect& samplingArea, const wp<Layer>& stopLayer, void addListener(const Rect& samplingArea, uint32_t stopLayerId, const sp<IRegionSamplingListener>& listener); // Remove the listener to stop receiving median luma notifications. void removeListener(const sp<IRegionSamplingListener>& listener); Loading @@ -87,7 +88,7 @@ public: private: struct Descriptor { Rect area = Rect::EMPTY_RECT; wp<Layer> stopLayer; uint32_t stopLayerId; sp<IRegionSamplingListener> listener; }; Loading
services/surfaceflinger/SurfaceFlinger.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -1581,9 +1581,10 @@ status_t SurfaceFlinger::addRegionSamplingListener(const Rect& samplingArea, // LayerHandle::getLayer promotes the layer object in a binder thread but we will not destroy // the layer here since the caller has a strong ref to the layer's handle. // TODO (b/238781169): replace layer with layer id const wp<Layer> stopLayer = LayerHandle::getLayer(stopLayerHandle); mRegionSamplingThread->addListener(samplingArea, stopLayer, listener); const sp<Layer> stopLayer = LayerHandle::getLayer(stopLayerHandle); mRegionSamplingThread->addListener(samplingArea, stopLayer ? stopLayer->getSequence() : UNASSIGNED_LAYER_ID, listener); return NO_ERROR; } Loading