Loading libs/ui/Android.bp +10 −1 Original line number Diff line number Diff line Loading @@ -82,6 +82,9 @@ cc_library_shared { "frameworks/native/include", ], // Uncomment the following line to enable VALIDATE_REGIONS traces //defaults: ["libui-validate-regions-defaults"], shared_libs: [ "android.frameworks.bufferhub@1.0", "android.hardware.graphics.allocator@2.0", Loading @@ -98,7 +101,6 @@ cc_library_shared { "libhwbinder", "libsync", "libutils", "libutilscallstack", "liblog", ], Loading Loading @@ -175,6 +177,13 @@ cc_library_headers { ], } // defaults to enable VALIDATE_REGIONS traces cc_defaults { name: "libui-validate-regions-defaults", shared_libs: ["libutilscallstack"], cflags: ["-DVALIDATE_REGIONS"], } subdirs = [ "tests", "tools", Loading libs/ui/Region.cpp +21 −12 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ #include <android-base/stringprintf.h> #include <utils/Log.h> #include <utils/CallStack.h> #include <ui/Rect.h> #include <ui/Region.h> Loading @@ -31,10 +30,18 @@ #include <private/ui/RegionHelper.h> // ---------------------------------------------------------------------------- #define VALIDATE_REGIONS (false) // ### VALIDATE_REGIONS ### // To enable VALIDATE_REGIONS traces, use the "libui-validate-regions-defaults" // in Android.bp. Do not #define VALIDATE_REGIONS here as it requires extra libs. #define VALIDATE_WITH_CORECG (false) // ---------------------------------------------------------------------------- #if defined(VALIDATE_REGIONS) #include <utils/CallStack.h> #endif #if VALIDATE_WITH_CORECG #include <core/SkRegion.h> #endif Loading Loading @@ -67,7 +74,7 @@ Region::Region() { Region::Region(const Region& rhs) : mStorage(rhs.mStorage) { #if VALIDATE_REGIONS #if defined(VALIDATE_REGIONS) validate(rhs, "rhs copy-ctor"); #endif } Loading Loading @@ -203,7 +210,7 @@ Region Region::createTJunctionFreeRegion(const Region& r) { outputRegion.mStorage, direction_LTR); outputRegion.mStorage.add(r.getBounds()); // to make region valid, mStorage must end with bounds #if VALIDATE_REGIONS #if defined(VALIDATE_REGIONS) validate(outputRegion, "T-Junction free region"); #endif Loading @@ -212,7 +219,7 @@ Region Region::createTJunctionFreeRegion(const Region& r) { Region& Region::operator = (const Region& rhs) { #if VALIDATE_REGIONS #if defined(VALIDATE_REGIONS) validate(*this, "this->operator="); validate(rhs, "rhs.operator="); #endif Loading Loading @@ -599,10 +606,12 @@ bool Region::validate(const Region& reg, const char* name, bool silent) result = false; ALOGE_IF(!silent, "%s: mStorage size is 2, which is never valid", name); } #if defined(VALIDATE_REGIONS) if (result == false && !silent) { reg.dump(name); CallStack stack(LOG_TAG); } #endif return result; } Loading @@ -610,7 +619,7 @@ void Region::boolean_operation(uint32_t op, Region& dst, const Region& lhs, const Region& rhs, int dx, int dy) { #if VALIDATE_REGIONS #if defined(VALIDATE_REGIONS) validate(lhs, "boolean_operation (before): lhs"); validate(rhs, "boolean_operation (before): rhs"); validate(dst, "boolean_operation (before): dst"); Loading @@ -630,7 +639,7 @@ void Region::boolean_operation(uint32_t op, Region& dst, operation(r); } #if VALIDATE_REGIONS #if defined(VALIDATE_REGIONS) validate(lhs, "boolean_operation: lhs"); validate(rhs, "boolean_operation: rhs"); validate(dst, "boolean_operation: dst"); Loading Loading @@ -728,7 +737,7 @@ void Region::boolean_operation(uint32_t op, Region& dst, return; } #if VALIDATE_WITH_CORECG || VALIDATE_REGIONS #if VALIDATE_WITH_CORECG || defined(VALIDATE_REGIONS) boolean_operation(op, dst, lhs, Region(rhs), dx, dy); #else size_t lhs_count; Loading Loading @@ -760,7 +769,7 @@ void Region::boolean_operation(uint32_t op, Region& dst, void Region::translate(Region& reg, int dx, int dy) { if ((dx || dy) && !reg.isEmpty()) { #if VALIDATE_REGIONS #if defined(VALIDATE_REGIONS) validate(reg, "translate (before)"); #endif size_t count = reg.mStorage.size(); Loading @@ -770,7 +779,7 @@ void Region::translate(Region& reg, int dx, int dy) rects++; count--; } #if VALIDATE_REGIONS #if defined(VALIDATE_REGIONS) validate(reg, "translate (after)"); #endif } Loading @@ -789,7 +798,7 @@ size_t Region::getFlattenedSize() const { } status_t Region::flatten(void* buffer, size_t size) const { #if VALIDATE_REGIONS #if defined(VALIDATE_REGIONS) validate(*this, "Region::flatten"); #endif if (size < getFlattenedSize()) { Loading Loading @@ -836,7 +845,7 @@ status_t Region::unflatten(void const* buffer, size_t size) { result.mStorage.push_back(rect); } #if VALIDATE_REGIONS #if defined(VALIDATE_REGIONS) validate(result, "Region::unflatten"); #endif Loading services/sensorservice/SensorDevice.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -767,6 +767,10 @@ void SensorDevice::enableAllSensors() { checkReturn(mSensors->activate(sensor_handle, 1 /* enabled */))); ALOGE_IF(err, "Error activating sensor %d (%s)", sensor_handle, strerror(-err)); } if (err == NO_ERROR) { info.isActive = true; } } } Loading @@ -774,7 +778,7 @@ void SensorDevice::disableAllSensors() { if (mSensors == nullptr) return; Mutex::Autolock _l(mLock); for (size_t i = 0; i< mActivationCount.size(); ++i) { const Info& info = mActivationCount.valueAt(i); Info& info = mActivationCount.editValueAt(i); // Check if this sensor has been activated previously and disable it. if (info.batchParams.size() > 0) { const int sensor_handle = mActivationCount.keyAt(i); Loading @@ -788,6 +792,8 @@ void SensorDevice::disableAllSensors() { mDisabledClients.add(info.batchParams.keyAt(j)); ALOGI("added %p to mDisabledClients", info.batchParams.keyAt(j)); } info.isActive = false; } } } Loading services/sensorservice/SensorService.cpp +14 −9 Original line number Diff line number Diff line Loading @@ -1381,15 +1381,6 @@ void SensorService::cleanupConnection(SensorEventConnection* c) { ALOGD_IF(DEBUG_CONNECTIONS, "... and it was the last connection"); mActiveSensors.removeItemsAt(i, 1); mActiveVirtualSensors.erase(handle); // If this is the last connection, then mark the RecentEventLogger as stale. This is // critical for on-change events since the previous event is sent to a client if the // sensor is already active. If two clients request the sensor at the same time, one // of the clients would receive a stale event. auto logger = mRecentEvent.find(handle); if (logger != mRecentEvent.end()) { logger->second->setLastEventStale(); } delete rec; size--; } else { Loading Loading @@ -1444,6 +1435,20 @@ status_t SensorService::enable(const sp<SensorEventConnection>& connection, if (sensor->isVirtual()) { mActiveVirtualSensors.emplace(handle); } // There was no SensorRecord for this sensor which means it was previously disabled. Mark // the recent event as stale to ensure that the previous event is not sent to a client. This // ensures on-change events that were generated during a previous sensor activation are not // erroneously sent to newly connected clients, especially if a second client registers for // an on-change sensor before the first client receives the updated event. Once an updated // event is received, the recent events will be marked as current, and any new clients will // immediately receive the most recent event. if (sensor->getSensor().getReportingMode() == AREPORTING_MODE_ON_CHANGE) { auto logger = mRecentEvent.find(handle); if (logger != mRecentEvent.end()) { logger->second->setLastEventStale(); } } } else { if (rec->addConnection(connection)) { // this sensor is already activated, but we are adding a connection that uses it. Loading services/surfaceflinger/BufferStateLayer.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -425,7 +425,7 @@ uint32_t BufferStateLayer::getDrawingScalingMode() const { } Region BufferStateLayer::getDrawingSurfaceDamage() const { return Region::INVALID_REGION; return getDrawingState().surfaceDamageRegion; } const HdrMetadata& BufferStateLayer::getDrawingHdrMetadata() const { Loading Loading
libs/ui/Android.bp +10 −1 Original line number Diff line number Diff line Loading @@ -82,6 +82,9 @@ cc_library_shared { "frameworks/native/include", ], // Uncomment the following line to enable VALIDATE_REGIONS traces //defaults: ["libui-validate-regions-defaults"], shared_libs: [ "android.frameworks.bufferhub@1.0", "android.hardware.graphics.allocator@2.0", Loading @@ -98,7 +101,6 @@ cc_library_shared { "libhwbinder", "libsync", "libutils", "libutilscallstack", "liblog", ], Loading Loading @@ -175,6 +177,13 @@ cc_library_headers { ], } // defaults to enable VALIDATE_REGIONS traces cc_defaults { name: "libui-validate-regions-defaults", shared_libs: ["libutilscallstack"], cflags: ["-DVALIDATE_REGIONS"], } subdirs = [ "tests", "tools", Loading
libs/ui/Region.cpp +21 −12 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ #include <android-base/stringprintf.h> #include <utils/Log.h> #include <utils/CallStack.h> #include <ui/Rect.h> #include <ui/Region.h> Loading @@ -31,10 +30,18 @@ #include <private/ui/RegionHelper.h> // ---------------------------------------------------------------------------- #define VALIDATE_REGIONS (false) // ### VALIDATE_REGIONS ### // To enable VALIDATE_REGIONS traces, use the "libui-validate-regions-defaults" // in Android.bp. Do not #define VALIDATE_REGIONS here as it requires extra libs. #define VALIDATE_WITH_CORECG (false) // ---------------------------------------------------------------------------- #if defined(VALIDATE_REGIONS) #include <utils/CallStack.h> #endif #if VALIDATE_WITH_CORECG #include <core/SkRegion.h> #endif Loading Loading @@ -67,7 +74,7 @@ Region::Region() { Region::Region(const Region& rhs) : mStorage(rhs.mStorage) { #if VALIDATE_REGIONS #if defined(VALIDATE_REGIONS) validate(rhs, "rhs copy-ctor"); #endif } Loading Loading @@ -203,7 +210,7 @@ Region Region::createTJunctionFreeRegion(const Region& r) { outputRegion.mStorage, direction_LTR); outputRegion.mStorage.add(r.getBounds()); // to make region valid, mStorage must end with bounds #if VALIDATE_REGIONS #if defined(VALIDATE_REGIONS) validate(outputRegion, "T-Junction free region"); #endif Loading @@ -212,7 +219,7 @@ Region Region::createTJunctionFreeRegion(const Region& r) { Region& Region::operator = (const Region& rhs) { #if VALIDATE_REGIONS #if defined(VALIDATE_REGIONS) validate(*this, "this->operator="); validate(rhs, "rhs.operator="); #endif Loading Loading @@ -599,10 +606,12 @@ bool Region::validate(const Region& reg, const char* name, bool silent) result = false; ALOGE_IF(!silent, "%s: mStorage size is 2, which is never valid", name); } #if defined(VALIDATE_REGIONS) if (result == false && !silent) { reg.dump(name); CallStack stack(LOG_TAG); } #endif return result; } Loading @@ -610,7 +619,7 @@ void Region::boolean_operation(uint32_t op, Region& dst, const Region& lhs, const Region& rhs, int dx, int dy) { #if VALIDATE_REGIONS #if defined(VALIDATE_REGIONS) validate(lhs, "boolean_operation (before): lhs"); validate(rhs, "boolean_operation (before): rhs"); validate(dst, "boolean_operation (before): dst"); Loading @@ -630,7 +639,7 @@ void Region::boolean_operation(uint32_t op, Region& dst, operation(r); } #if VALIDATE_REGIONS #if defined(VALIDATE_REGIONS) validate(lhs, "boolean_operation: lhs"); validate(rhs, "boolean_operation: rhs"); validate(dst, "boolean_operation: dst"); Loading Loading @@ -728,7 +737,7 @@ void Region::boolean_operation(uint32_t op, Region& dst, return; } #if VALIDATE_WITH_CORECG || VALIDATE_REGIONS #if VALIDATE_WITH_CORECG || defined(VALIDATE_REGIONS) boolean_operation(op, dst, lhs, Region(rhs), dx, dy); #else size_t lhs_count; Loading Loading @@ -760,7 +769,7 @@ void Region::boolean_operation(uint32_t op, Region& dst, void Region::translate(Region& reg, int dx, int dy) { if ((dx || dy) && !reg.isEmpty()) { #if VALIDATE_REGIONS #if defined(VALIDATE_REGIONS) validate(reg, "translate (before)"); #endif size_t count = reg.mStorage.size(); Loading @@ -770,7 +779,7 @@ void Region::translate(Region& reg, int dx, int dy) rects++; count--; } #if VALIDATE_REGIONS #if defined(VALIDATE_REGIONS) validate(reg, "translate (after)"); #endif } Loading @@ -789,7 +798,7 @@ size_t Region::getFlattenedSize() const { } status_t Region::flatten(void* buffer, size_t size) const { #if VALIDATE_REGIONS #if defined(VALIDATE_REGIONS) validate(*this, "Region::flatten"); #endif if (size < getFlattenedSize()) { Loading Loading @@ -836,7 +845,7 @@ status_t Region::unflatten(void const* buffer, size_t size) { result.mStorage.push_back(rect); } #if VALIDATE_REGIONS #if defined(VALIDATE_REGIONS) validate(result, "Region::unflatten"); #endif Loading
services/sensorservice/SensorDevice.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -767,6 +767,10 @@ void SensorDevice::enableAllSensors() { checkReturn(mSensors->activate(sensor_handle, 1 /* enabled */))); ALOGE_IF(err, "Error activating sensor %d (%s)", sensor_handle, strerror(-err)); } if (err == NO_ERROR) { info.isActive = true; } } } Loading @@ -774,7 +778,7 @@ void SensorDevice::disableAllSensors() { if (mSensors == nullptr) return; Mutex::Autolock _l(mLock); for (size_t i = 0; i< mActivationCount.size(); ++i) { const Info& info = mActivationCount.valueAt(i); Info& info = mActivationCount.editValueAt(i); // Check if this sensor has been activated previously and disable it. if (info.batchParams.size() > 0) { const int sensor_handle = mActivationCount.keyAt(i); Loading @@ -788,6 +792,8 @@ void SensorDevice::disableAllSensors() { mDisabledClients.add(info.batchParams.keyAt(j)); ALOGI("added %p to mDisabledClients", info.batchParams.keyAt(j)); } info.isActive = false; } } } Loading
services/sensorservice/SensorService.cpp +14 −9 Original line number Diff line number Diff line Loading @@ -1381,15 +1381,6 @@ void SensorService::cleanupConnection(SensorEventConnection* c) { ALOGD_IF(DEBUG_CONNECTIONS, "... and it was the last connection"); mActiveSensors.removeItemsAt(i, 1); mActiveVirtualSensors.erase(handle); // If this is the last connection, then mark the RecentEventLogger as stale. This is // critical for on-change events since the previous event is sent to a client if the // sensor is already active. If two clients request the sensor at the same time, one // of the clients would receive a stale event. auto logger = mRecentEvent.find(handle); if (logger != mRecentEvent.end()) { logger->second->setLastEventStale(); } delete rec; size--; } else { Loading Loading @@ -1444,6 +1435,20 @@ status_t SensorService::enable(const sp<SensorEventConnection>& connection, if (sensor->isVirtual()) { mActiveVirtualSensors.emplace(handle); } // There was no SensorRecord for this sensor which means it was previously disabled. Mark // the recent event as stale to ensure that the previous event is not sent to a client. This // ensures on-change events that were generated during a previous sensor activation are not // erroneously sent to newly connected clients, especially if a second client registers for // an on-change sensor before the first client receives the updated event. Once an updated // event is received, the recent events will be marked as current, and any new clients will // immediately receive the most recent event. if (sensor->getSensor().getReportingMode() == AREPORTING_MODE_ON_CHANGE) { auto logger = mRecentEvent.find(handle); if (logger != mRecentEvent.end()) { logger->second->setLastEventStale(); } } } else { if (rec->addConnection(connection)) { // this sensor is already activated, but we are adding a connection that uses it. Loading
services/surfaceflinger/BufferStateLayer.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -425,7 +425,7 @@ uint32_t BufferStateLayer::getDrawingScalingMode() const { } Region BufferStateLayer::getDrawingSurfaceDamage() const { return Region::INVALID_REGION; return getDrawingState().surfaceDamageRegion; } const HdrMetadata& BufferStateLayer::getDrawingHdrMetadata() const { Loading