summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/FrameInfo.cpp2
-rw-r--r--libs/hwui/FrameInfo.h6
-rw-r--r--libs/hwui/FrameMetricsObserver.h4
-rw-r--r--libs/hwui/FrameMetricsReporter.cpp4
-rw-r--r--libs/hwui/FrameMetricsReporter.h2
-rw-r--r--libs/hwui/jni/android_graphics_HardwareRendererObserver.cpp9
-rw-r--r--libs/hwui/jni/android_graphics_HardwareRendererObserver.h2
-rw-r--r--libs/hwui/tests/unit/FrameMetricsReporterTests.cpp23
-rw-r--r--libs/hwui/tests/unit/JankTrackerTests.cpp9
9 files changed, 35 insertions, 26 deletions
diff --git a/libs/hwui/FrameInfo.cpp b/libs/hwui/FrameInfo.cpp
index 36feabde07eb..fa09296f647c 100644
--- a/libs/hwui/FrameInfo.cpp
+++ b/libs/hwui/FrameInfo.cpp
@@ -53,7 +53,7 @@ static_assert(static_cast<int>(FrameInfoIndex::NumIndexes) == 24,
"Must update value in FrameMetrics.java#FRAME_STATS_COUNT (and here)");
void FrameInfo::importUiThreadInfo(int64_t* info) {
- memcpy(mFrameInfo, info, UI_THREAD_FRAME_INFO_SIZE * sizeof(int64_t));
+ memcpy(mFrameInfo.data(), info, UI_THREAD_FRAME_INFO_SIZE * sizeof(int64_t));
mSkippedFrameReason.reset();
}
diff --git a/libs/hwui/FrameInfo.h b/libs/hwui/FrameInfo.h
index 61c30b803b00..8b486cd49e24 100644
--- a/libs/hwui/FrameInfo.h
+++ b/libs/hwui/FrameInfo.h
@@ -84,6 +84,8 @@ enum {
};
};
+using FrameInfoBuffer = std::array<int64_t, static_cast<size_t>(FrameInfoIndex::NumIndexes)>;
+
class UiFrameInfoBuilder {
public:
static constexpr int64_t INVALID_VSYNC_ID = -1;
@@ -152,7 +154,7 @@ public:
set(FrameInfoIndex::Flags) |= static_cast<uint64_t>(frameInfoFlag);
}
- const int64_t* data() const { return mFrameInfo; }
+ const FrameInfoBuffer& data() const { return mFrameInfo; }
inline int64_t operator[](FrameInfoIndex index) const { return get(index); }
@@ -201,7 +203,7 @@ public:
}
private:
- int64_t mFrameInfo[static_cast<int>(FrameInfoIndex::NumIndexes)];
+ FrameInfoBuffer mFrameInfo;
std::optional<SkippedFrameReason> mSkippedFrameReason;
};
diff --git a/libs/hwui/FrameMetricsObserver.h b/libs/hwui/FrameMetricsObserver.h
index 3ea49518eecd..d267740d15c4 100644
--- a/libs/hwui/FrameMetricsObserver.h
+++ b/libs/hwui/FrameMetricsObserver.h
@@ -18,12 +18,14 @@
#include <utils/RefBase.h>
+#include "FrameInfo.h"
+
namespace android {
namespace uirenderer {
class FrameMetricsObserver : public VirtualLightRefBase {
public:
- virtual void notify(const int64_t* buffer) = 0;
+ virtual void notify(const FrameInfoBuffer& buffer) = 0;
bool waitForPresentTime() const { return mWaitForPresentTime; };
void reportMetricsFrom(uint64_t frameNumber, int32_t surfaceControlId) {
diff --git a/libs/hwui/FrameMetricsReporter.cpp b/libs/hwui/FrameMetricsReporter.cpp
index ee32ea17bfaf..4ad9c9ad7b31 100644
--- a/libs/hwui/FrameMetricsReporter.cpp
+++ b/libs/hwui/FrameMetricsReporter.cpp
@@ -16,10 +16,12 @@
#include "FrameMetricsReporter.h"
+#include "FrameInfo.h"
+
namespace android {
namespace uirenderer {
-void FrameMetricsReporter::reportFrameMetrics(const int64_t* stats, bool hasPresentTime,
+void FrameMetricsReporter::reportFrameMetrics(const FrameInfoBuffer& stats, bool hasPresentTime,
uint64_t frameNumber, int32_t surfaceControlId) {
FatVector<sp<FrameMetricsObserver>, 10> copy;
{
diff --git a/libs/hwui/FrameMetricsReporter.h b/libs/hwui/FrameMetricsReporter.h
index 7e51df7ce6fc..0b0895aa3f3d 100644
--- a/libs/hwui/FrameMetricsReporter.h
+++ b/libs/hwui/FrameMetricsReporter.h
@@ -69,7 +69,7 @@ public:
* stats of frames that are from "old" surfaces (i.e. with surfaceControlIds older than the one
* the observer was attached on) nor those that are from "old" frame numbers.
*/
- void reportFrameMetrics(const int64_t* stats, bool hasPresentTime, uint64_t frameNumber,
+ void reportFrameMetrics(const FrameInfoBuffer& stats, bool hasPresentTime, uint64_t frameNumber,
int32_t surfaceControlId);
private:
diff --git a/libs/hwui/jni/android_graphics_HardwareRendererObserver.cpp b/libs/hwui/jni/android_graphics_HardwareRendererObserver.cpp
index 6cae5ffa397f..4f383ee063a2 100644
--- a/libs/hwui/jni/android_graphics_HardwareRendererObserver.cpp
+++ b/libs/hwui/jni/android_graphics_HardwareRendererObserver.cpp
@@ -16,11 +16,12 @@
#include "android_graphics_HardwareRendererObserver.h"
+#include <array>
+
+#include "FrameInfo.h"
#include "graphics_jni_helpers.h"
#include "nativehelper/jni_macros.h"
-#include <array>
-
namespace android {
struct {
@@ -65,13 +66,13 @@ bool HardwareRendererObserver::getNextBuffer(JNIEnv* env, jlongArray metrics, in
return false;
}
-void HardwareRendererObserver::notify(const int64_t* stats) {
+void HardwareRendererObserver::notify(const uirenderer::FrameInfoBuffer& stats) {
if (!mKeepListening) return;
FrameMetricsNotification& elem = mRingBuffer[mNextFree];
if (!elem.hasData.load()) {
- memcpy(elem.buffer, stats, kBufferSize * sizeof(stats[0]));
+ memcpy(elem.buffer, stats.data(), kBufferSize * sizeof(stats[0]));
elem.dropCount = mDroppedReports;
mDroppedReports = 0;
diff --git a/libs/hwui/jni/android_graphics_HardwareRendererObserver.h b/libs/hwui/jni/android_graphics_HardwareRendererObserver.h
index 5ee3e1669502..cf20ee135363 100644
--- a/libs/hwui/jni/android_graphics_HardwareRendererObserver.h
+++ b/libs/hwui/jni/android_graphics_HardwareRendererObserver.h
@@ -43,7 +43,7 @@ public:
*/
bool getNextBuffer(JNIEnv* env, jlongArray metrics, int* dropCount);
- void notify(const int64_t* stats) override;
+ void notify(const uirenderer::FrameInfoBuffer& stats) override;
private:
static constexpr int kBufferSize = static_cast<int>(uirenderer::FrameInfoIndex::NumIndexes);
diff --git a/libs/hwui/tests/unit/FrameMetricsReporterTests.cpp b/libs/hwui/tests/unit/FrameMetricsReporterTests.cpp
index 571a26707c93..c7935ac5a753 100644
--- a/libs/hwui/tests/unit/FrameMetricsReporterTests.cpp
+++ b/libs/hwui/tests/unit/FrameMetricsReporterTests.cpp
@@ -14,13 +14,14 @@
* limitations under the License.
*/
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
#include <FrameMetricsObserver.h>
#include <FrameMetricsReporter.h>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
#include <utils/TimeUtils.h>
+#include "FrameInfo.h"
+
using namespace android;
using namespace android::uirenderer;
@@ -31,7 +32,7 @@ public:
explicit TestFrameMetricsObserver(bool waitForPresentTime)
: FrameMetricsObserver(waitForPresentTime){};
- MOCK_METHOD(void, notify, (const int64_t* buffer), (override));
+ MOCK_METHOD(void, notify, (const FrameInfoBuffer& buffer), (override));
};
// To make sure it is clear that something went wrong if no from frame is set (to make it easier
@@ -44,7 +45,7 @@ TEST(FrameMetricsReporter, doesNotReportAnyFrameIfNoFromFrameIsSpecified) {
reporter->addObserver(observer.get());
- const int64_t* stats;
+ FrameInfoBuffer stats;
bool hasPresentTime = false;
uint64_t frameNumber = 1;
int32_t surfaceControlId = 0;
@@ -64,7 +65,7 @@ TEST(FrameMetricsReporter, doesNotReportAnyFrameIfNoFromFrameIsSpecified) {
}
TEST(FrameMetricsReporter, respectsWaitForPresentTimeUnset) {
- const int64_t* stats;
+ FrameInfoBuffer stats;
bool hasPresentTime = false;
uint64_t frameNumber = 3;
int32_t surfaceControlId = 0;
@@ -85,7 +86,7 @@ TEST(FrameMetricsReporter, respectsWaitForPresentTimeUnset) {
}
TEST(FrameMetricsReporter, respectsWaitForPresentTimeSet) {
- const int64_t* stats;
+ FrameInfoBuffer stats;
bool hasPresentTime = true;
uint64_t frameNumber = 3;
int32_t surfaceControlId = 0;
@@ -106,7 +107,7 @@ TEST(FrameMetricsReporter, respectsWaitForPresentTimeSet) {
}
TEST(FrameMetricsReporter, reportsAllFramesAfterSpecifiedFromFrame) {
- const int64_t* stats;
+ FrameInfoBuffer stats;
bool hasPresentTime = false;
std::vector<uint64_t> frameNumbers{0, 1, 10};
@@ -138,7 +139,7 @@ TEST(FrameMetricsReporter, reportsAllFramesAfterSpecifiedFromFrame) {
}
TEST(FrameMetricsReporter, doesNotReportsFramesBeforeSpecifiedFromFrame) {
- const int64_t* stats;
+ FrameInfoBuffer stats;
bool hasPresentTime = false;
std::vector<uint64_t> frameNumbers{1, 10};
@@ -165,7 +166,7 @@ TEST(FrameMetricsReporter, doesNotReportsFramesBeforeSpecifiedFromFrame) {
}
TEST(FrameMetricsReporter, canRemoveObservers) {
- const int64_t* stats;
+ FrameInfoBuffer stats;
bool hasPresentTime = false;
uint64_t frameNumber = 3;
int32_t surfaceControlId = 0;
@@ -187,7 +188,7 @@ TEST(FrameMetricsReporter, canRemoveObservers) {
}
TEST(FrameMetricsReporter, canSupportMultipleObservers) {
- const int64_t* stats;
+ FrameInfoBuffer stats;
bool hasPresentTime = false;
uint64_t frameNumber = 3;
int32_t surfaceControlId = 0;
diff --git a/libs/hwui/tests/unit/JankTrackerTests.cpp b/libs/hwui/tests/unit/JankTrackerTests.cpp
index c289d67fbef6..08718c959150 100644
--- a/libs/hwui/tests/unit/JankTrackerTests.cpp
+++ b/libs/hwui/tests/unit/JankTrackerTests.cpp
@@ -14,18 +14,19 @@
* limitations under the License.
*/
-#include <gtest/gtest.h>
-#include <gmock/gmock.h>
-
#include <JankTracker.h>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
#include <utils/TimeUtils.h>
+#include "FrameInfo.h"
+
using namespace android;
using namespace android::uirenderer;
class TestFrameMetricsObserver : public FrameMetricsObserver {
public:
- void notify(const int64_t*) {}
+ void notify(const FrameInfoBuffer&) override {}
};
TEST(JankTracker, noJank) {