SurfaceFlinger: add Refresh Rate overlay
Add an overlay to indicate what is the current refresh rate.
Currently it is implemented by a ColorLayer:
- Red - Default refresh rate
- Green - Performance refresh rate
To enable the overlay:
adb shell service call SurfaceFlinger 1034 i32 1
To disable the overlay:
adb shell service call SurfaceFlinger 1034 i32 0
Test: manual
Change-Id: I851f2530e7accacd2cac446b30aa2e0b6d431a92
diff --git a/services/surfaceflinger/RefreshRateOverlay.h b/services/surfaceflinger/RefreshRateOverlay.h
new file mode 100644
index 0000000..ce29bc3
--- /dev/null
+++ b/services/surfaceflinger/RefreshRateOverlay.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2019 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.
+ */
+#pragma once
+
+#include "SurfaceFlinger.h"
+
+namespace android {
+
+using RefreshRateType = scheduler::RefreshRateConfigs::RefreshRateType;
+
+class RefreshRateOverlay {
+public:
+ RefreshRateOverlay(SurfaceFlinger& flinger);
+
+ void changeRefreshRate(RefreshRateType type);
+
+private:
+ bool createLayer();
+
+ SurfaceFlinger& mFlinger;
+ sp<Client> mClient;
+ sp<Layer> mLayer;
+ sp<IBinder> mIBinder;
+ sp<IGraphicBufferProducer> mGbp;
+
+ const half3 RED = half3(1.0f, 0.0f, 0.0f);
+ const half3 GREEN = half3(0.0f, 1.0f, 0.0f);
+};
+
+}; // namespace android