diff options
-rw-r--r-- | libs/binder/include/binder/IInterface.h | 1 | ||||
-rw-r--r-- | libs/gui/Android.bp | 1 | ||||
-rw-r--r-- | libs/gui/IRegionSamplingListener.cpp | 64 | ||||
-rw-r--r-- | libs/gui/ISurfaceComposer.cpp | 3 | ||||
-rw-r--r-- | libs/gui/SurfaceComposerClient.cpp | 1 | ||||
-rw-r--r-- | libs/gui/aidl/android/gui/IRegionSamplingListener.aidl | 22 | ||||
-rw-r--r-- | libs/gui/include/gui/IRegionSamplingListener.h | 43 | ||||
-rw-r--r-- | libs/gui/include/gui/ISurfaceComposer.h | 3 | ||||
-rw-r--r-- | libs/gui/include/gui/SurfaceComposerClient.h | 3 | ||||
-rw-r--r-- | libs/gui/tests/RegionSampling_test.cpp | 7 | ||||
-rw-r--r-- | libs/gui/tests/SamplingDemo.cpp | 7 | ||||
-rw-r--r-- | libs/gui/tests/Surface_test.cpp | 1 | ||||
-rw-r--r-- | services/surfaceflinger/RegionSamplingThread.cpp | 1 | ||||
-rw-r--r-- | services/surfaceflinger/RegionSamplingThread.h | 4 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 1 |
15 files changed, 42 insertions, 120 deletions
diff --git a/libs/binder/include/binder/IInterface.h b/libs/binder/include/binder/IInterface.h index 7d14315b01..415b19adf6 100644 --- a/libs/binder/include/binder/IInterface.h +++ b/libs/binder/include/binder/IInterface.h @@ -231,7 +231,6 @@ constexpr const char* const kManualInterfaces[] = { "android.gui.DisplayEventConnection", "android.gui.IConsumerListener", "android.gui.IGraphicBufferConsumer", - "android.gui.IRegionSamplingListener", "android.gui.ITransactionComposerListener", "android.gui.SensorEventConnection", "android.gui.SensorServer", diff --git a/libs/gui/Android.bp b/libs/gui/Android.bp index 19a29c196d..fea9f810c2 100644 --- a/libs/gui/Android.bp +++ b/libs/gui/Android.bp @@ -184,7 +184,6 @@ cc_library_shared { "IGraphicBufferConsumer.cpp", "IGraphicBufferProducer.cpp", "IProducerListener.cpp", - "IRegionSamplingListener.cpp", "ISurfaceComposer.cpp", "ISurfaceComposerClient.cpp", "ITransactionCompletedListener.cpp", diff --git a/libs/gui/IRegionSamplingListener.cpp b/libs/gui/IRegionSamplingListener.cpp deleted file mode 100644 index 40cbfceaf7..0000000000 --- a/libs/gui/IRegionSamplingListener.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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. - */ - -#define LOG_TAG "IRegionSamplingListener" -//#define LOG_NDEBUG 0 - -#include <gui/IRegionSamplingListener.h> - -namespace android { - -namespace { // Anonymous - -enum class Tag : uint32_t { - ON_SAMPLE_COLLECTED = IBinder::FIRST_CALL_TRANSACTION, - LAST = ON_SAMPLE_COLLECTED, -}; - -} // Anonymous namespace - -class BpRegionSamplingListener : public SafeBpInterface<IRegionSamplingListener> { -public: - explicit BpRegionSamplingListener(const sp<IBinder>& impl) - : SafeBpInterface<IRegionSamplingListener>(impl, "BpRegionSamplingListener") {} - - ~BpRegionSamplingListener() override; - - void onSampleCollected(float medianLuma) override { - callRemoteAsync<decltype( - &IRegionSamplingListener::onSampleCollected)>(Tag::ON_SAMPLE_COLLECTED, medianLuma); - } -}; - -// Out-of-line virtual method definitions to trigger vtable emission in this translation unit (see -// clang warning -Wweak-vtables) -BpRegionSamplingListener::~BpRegionSamplingListener() = default; - -IMPLEMENT_META_INTERFACE(RegionSamplingListener, "android.gui.IRegionSamplingListener"); - -status_t BnRegionSamplingListener::onTransact(uint32_t code, const Parcel& data, Parcel* reply, - uint32_t flags) { - if (code < IBinder::FIRST_CALL_TRANSACTION || code > static_cast<uint32_t>(Tag::LAST)) { - return BBinder::onTransact(code, data, reply, flags); - } - auto tag = static_cast<Tag>(code); - switch (tag) { - case Tag::ON_SAMPLE_COLLECTED: - return callLocalAsync(data, reply, &IRegionSamplingListener::onSampleCollected); - } -} - -} // namespace android diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp index 02950995af..a90f7559b3 100644 --- a/libs/gui/ISurfaceComposer.cpp +++ b/libs/gui/ISurfaceComposer.cpp @@ -17,13 +17,13 @@ // tag as surfaceflinger #define LOG_TAG "SurfaceFlinger" +#include <android/gui/IRegionSamplingListener.h> #include <android/gui/ITransactionTraceListener.h> #include <binder/IPCThreadState.h> #include <binder/IServiceManager.h> #include <binder/Parcel.h> #include <gui/IDisplayEventConnection.h> #include <gui/IGraphicBufferProducer.h> -#include <gui/IRegionSamplingListener.h> #include <gui/ISurfaceComposer.h> #include <gui/ISurfaceComposerClient.h> #include <gui/LayerDebugInfo.h> @@ -44,6 +44,7 @@ namespace android { +using gui::IRegionSamplingListener; using gui::IWindowInfosListener; using ui::ColorMode; diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index b139cf126c..f6253a256c 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -53,6 +53,7 @@ namespace android { using gui::FocusRequest; +using gui::IRegionSamplingListener; using gui::WindowInfo; using gui::WindowInfoHandle; using gui::WindowInfosListener; diff --git a/libs/gui/aidl/android/gui/IRegionSamplingListener.aidl b/libs/gui/aidl/android/gui/IRegionSamplingListener.aidl new file mode 100644 index 0000000000..00a3959d79 --- /dev/null +++ b/libs/gui/aidl/android/gui/IRegionSamplingListener.aidl @@ -0,0 +1,22 @@ +/* + * Copyright 2021 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. + */ + +package android.gui; + +/** @hide */ +oneway interface IRegionSamplingListener { + void onSampleCollected(float medianLuma); +} diff --git a/libs/gui/include/gui/IRegionSamplingListener.h b/libs/gui/include/gui/IRegionSamplingListener.h deleted file mode 100644 index 1803d9a1da..0000000000 --- a/libs/gui/include/gui/IRegionSamplingListener.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 <cstdint> -#include <vector> - -#include <binder/IInterface.h> -#include <binder/SafeInterface.h> - -namespace android { - -class IRegionSamplingListener : public IInterface { -public: - DECLARE_META_INTERFACE(RegionSamplingListener) - - virtual void onSampleCollected(float medianLuma) = 0; -}; - -class BnRegionSamplingListener : public SafeBnInterface<IRegionSamplingListener> { -public: - BnRegionSamplingListener() - : SafeBnInterface<IRegionSamplingListener>("BnRegionSamplingListener") {} - - status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, - uint32_t flags = 0) override; -}; - -} // namespace android diff --git a/libs/gui/include/gui/ISurfaceComposer.h b/libs/gui/include/gui/ISurfaceComposer.h index e0183adbe6..e1e9182056 100644 --- a/libs/gui/include/gui/ISurfaceComposer.h +++ b/libs/gui/include/gui/ISurfaceComposer.h @@ -19,6 +19,7 @@ #include <android/gui/DisplayBrightness.h> #include <android/gui/IFpsListener.h> #include <android/gui/IHdrLayerInfoListener.h> +#include <android/gui/IRegionSamplingListener.h> #include <android/gui/IScreenCaptureListener.h> #include <android/gui/ITransactionTraceListener.h> #include <android/gui/ITunnelModeEnabledListener.h> @@ -63,10 +64,10 @@ class HdrCapabilities; class IDisplayEventConnection; class IGraphicBufferProducer; class ISurfaceComposerClient; -class IRegionSamplingListener; class Rect; enum class FrameEvent; +using gui::IRegionSamplingListener; using gui::IScreenCaptureListener; namespace ui { diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h index e05c3646c6..0fe1253f94 100644 --- a/libs/gui/include/gui/SurfaceComposerClient.h +++ b/libs/gui/include/gui/SurfaceComposerClient.h @@ -51,10 +51,11 @@ namespace android { class HdrCapabilities; class ISurfaceComposerClient; class IGraphicBufferProducer; -class IRegionSamplingListener; class ITunnelModeEnabledListener; class Region; +using gui::IRegionSamplingListener; + struct SurfaceControlStats { SurfaceControlStats(const sp<SurfaceControl>& sc, nsecs_t latchTime, nsecs_t acquireTime, const sp<Fence>& presentFence, const sp<Fence>& prevReleaseFence, diff --git a/libs/gui/tests/RegionSampling_test.cpp b/libs/gui/tests/RegionSampling_test.cpp index 6746b0a827..c9106bed4c 100644 --- a/libs/gui/tests/RegionSampling_test.cpp +++ b/libs/gui/tests/RegionSampling_test.cpp @@ -17,9 +17,9 @@ #include <gtest/gtest.h> #include <thread> +#include <android/gui/BnRegionSamplingListener.h> #include <binder/ProcessState.h> #include <gui/DisplayEventReceiver.h> -#include <gui/IRegionSamplingListener.h> #include <gui/ISurfaceComposer.h> #include <gui/Surface.h> #include <gui/SurfaceComposerClient.h> @@ -135,12 +135,13 @@ private: std::atomic<bool> poll_{true}; }; -struct Listener : BnRegionSamplingListener { - void onSampleCollected(float medianLuma) override { +struct Listener : android::gui::BnRegionSamplingListener { + binder::Status onSampleCollected(float medianLuma) override { std::unique_lock<decltype(mutex)> lk(mutex); received = true; mLuma = medianLuma; cv.notify_all(); + return binder::Status::ok(); }; bool wait_event(std::chrono::milliseconds timeout) { std::unique_lock<decltype(mutex)> lk(mutex); diff --git a/libs/gui/tests/SamplingDemo.cpp b/libs/gui/tests/SamplingDemo.cpp index 0cd150d3cb..a083a228a6 100644 --- a/libs/gui/tests/SamplingDemo.cpp +++ b/libs/gui/tests/SamplingDemo.cpp @@ -20,9 +20,9 @@ #include <chrono> #include <thread> +#include <android/gui/BnRegionSamplingListener.h> #include <binder/IPCThreadState.h> #include <binder/ProcessState.h> -#include <gui/IRegionSamplingListener.h> #include <gui/ISurfaceComposer.h> #include <gui/SurfaceComposerClient.h> #include <gui/SurfaceControl.h> @@ -33,7 +33,7 @@ using namespace std::chrono_literals; namespace android { -class Button : public BnRegionSamplingListener { +class Button : public gui::BnRegionSamplingListener { public: Button(const char* name, const Rect& samplingArea) { sp<SurfaceComposerClient> client = new SurfaceComposerClient; @@ -99,9 +99,10 @@ private: .apply(); } - void onSampleCollected(float medianLuma) override { + binder::Status onSampleCollected(float medianLuma) override { ATRACE_CALL(); setColor(medianLuma); + return binder::Status::ok(); } sp<SurfaceComposerClient> mClient; diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp index b2baea6aba..e0c2aa7181 100644 --- a/libs/gui/tests/Surface_test.cpp +++ b/libs/gui/tests/Surface_test.cpp @@ -45,6 +45,7 @@ using namespace std::chrono_literals; // retrieve wide-color and hdr settings from configstore using namespace android::hardware::configstore; using namespace android::hardware::configstore::V1_0; +using gui::IRegionSamplingListener; using ui::ColorMode; using Transaction = SurfaceComposerClient::Transaction; diff --git a/services/surfaceflinger/RegionSamplingThread.cpp b/services/surfaceflinger/RegionSamplingThread.cpp index 32585dd9ac..da8c3e062c 100644 --- a/services/surfaceflinger/RegionSamplingThread.cpp +++ b/services/surfaceflinger/RegionSamplingThread.cpp @@ -30,7 +30,6 @@ #include <compositionengine/impl/OutputCompositionState.h> #include <cutils/properties.h> #include <ftl/future.h> -#include <gui/IRegionSamplingListener.h> #include <gui/SyncScreenCaptureListener.h> #include <ui/DisplayStatInfo.h> #include <utils/Trace.h> diff --git a/services/surfaceflinger/RegionSamplingThread.h b/services/surfaceflinger/RegionSamplingThread.h index f715309b2e..686b4b1e1f 100644 --- a/services/surfaceflinger/RegionSamplingThread.h +++ b/services/surfaceflinger/RegionSamplingThread.h @@ -17,6 +17,7 @@ #pragma once #include <android-base/thread_annotations.h> +#include <android/gui/IRegionSamplingListener.h> #include <binder/IBinder.h> #include <renderengine/ExternalTexture.h> #include <ui/GraphicBuffer.h> @@ -34,12 +35,13 @@ namespace android { -class IRegionSamplingListener; class Layer; class Scheduler; class SurfaceFlinger; struct SamplingOffsetCallback; +using gui::IRegionSamplingListener; + float sampleArea(const uint32_t* data, int32_t width, int32_t height, int32_t stride, uint32_t orientation, const Rect& area); diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 7339b3bc3d..1545c0004f 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -105,6 +105,7 @@ class TimeStats; class FrameTracer; class WindowInfosListenerInvoker; +using gui::IRegionSamplingListener; using gui::ScreenCaptureResults; namespace frametimeline { |