Loading cmds/bootanimation/BootAnimation.cpp +10 −7 Original line number Original line Diff line number Diff line Loading @@ -42,10 +42,10 @@ #include <android-base/properties.h> #include <android-base/properties.h> #include <ui/DisplayConfig.h> #include <ui/PixelFormat.h> #include <ui/PixelFormat.h> #include <ui/Rect.h> #include <ui/Rect.h> #include <ui/Region.h> #include <ui/Region.h> #include <ui/DisplayInfo.h> #include <gui/ISurfaceComposer.h> #include <gui/ISurfaceComposer.h> #include <gui/Surface.h> #include <gui/Surface.h> Loading Loading @@ -283,16 +283,19 @@ status_t BootAnimation::readyToRun() { mDisplayToken = SurfaceComposerClient::getInternalDisplayToken(); mDisplayToken = SurfaceComposerClient::getInternalDisplayToken(); if (mDisplayToken == nullptr) if (mDisplayToken == nullptr) return -1; return NAME_NOT_FOUND; DisplayInfo dinfo; DisplayConfig displayConfig; status_t status = SurfaceComposerClient::getDisplayInfo(mDisplayToken, &dinfo); const status_t error = if (status) SurfaceComposerClient::getActiveDisplayConfig(mDisplayToken, &displayConfig); return -1; if (error != NO_ERROR) return error; const ui::Size& resolution = displayConfig.resolution; // create the native surface // create the native surface sp<SurfaceControl> control = session()->createSurface(String8("BootAnimation"), sp<SurfaceControl> control = session()->createSurface(String8("BootAnimation"), dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565); resolution.getWidth(), resolution.getHeight(), PIXEL_FORMAT_RGB_565); SurfaceComposerClient::Transaction t; SurfaceComposerClient::Transaction t; Loading core/java/android/view/SurfaceControl.java +38 −123 Original line number Original line Diff line number Diff line Loading @@ -152,7 +152,8 @@ public final class SurfaceControl implements Parcelable { int L, int T, int R, int B); int L, int T, int R, int B); private static native void nativeSetDisplaySize(long transactionObj, IBinder displayToken, private static native void nativeSetDisplaySize(long transactionObj, IBinder displayToken, int width, int height); int width, int height); private static native SurfaceControl.PhysicalDisplayInfo[] nativeGetDisplayConfigs( private static native SurfaceControl.DisplayInfo nativeGetDisplayInfo(IBinder displayToken); private static native SurfaceControl.DisplayConfig[] nativeGetDisplayConfigs( IBinder displayToken); IBinder displayToken); private static native DisplayedContentSamplingAttributes private static native DisplayedContentSamplingAttributes nativeGetDisplayedContentSamplingAttributes(IBinder displayToken); nativeGetDisplayedContentSamplingAttributes(IBinder displayToken); Loading Loading @@ -1278,158 +1279,72 @@ public final class SurfaceControl implements Parcelable { Integer.toHexString(System.identityHashCode(this)); Integer.toHexString(System.identityHashCode(this)); } } /* * set display parameters. * needs to be inside open/closeTransaction block */ /** * Describes the properties of a physical display known to surface flinger. * @hide */ public static final class PhysicalDisplayInfo { /** * @hide */ @UnsupportedAppUsage public int width; /** * @hide */ @UnsupportedAppUsage public int height; /** * @hide */ @UnsupportedAppUsage public float refreshRate; /** /** * Immutable information about physical display. * * @hide * @hide */ */ @UnsupportedAppUsage public static final class DisplayInfo { public float density; public float density; /** * @hide */ @UnsupportedAppUsage public float xDpi; /** * @hide */ @UnsupportedAppUsage public float yDpi; /** * @hide */ @UnsupportedAppUsage public boolean secure; public boolean secure; /** @Override * @hide public String toString() { */ return "DisplayInfo{density=" + density + ", secure=" + secure + "}"; @UnsupportedAppUsage public long appVsyncOffsetNanos; /** * @hide */ @UnsupportedAppUsage public long presentationDeadlineNanos; /** * @hide */ @UnsupportedAppUsage public PhysicalDisplayInfo() { } } /** * @hide */ public PhysicalDisplayInfo(PhysicalDisplayInfo other) { copyFrom(other); } } /** /** * Configuration supported by physical display. * * @hide * @hide */ */ @Override public static final class DisplayConfig { public boolean equals(Object o) { public int width; return o instanceof PhysicalDisplayInfo && equals((PhysicalDisplayInfo)o); public int height; } public float xDpi; public float yDpi; /** public float refreshRate; * @hide public long appVsyncOffsetNanos; */ public long presentationDeadlineNanos; public boolean equals(PhysicalDisplayInfo other) { return other != null && width == other.width && height == other.height && refreshRate == other.refreshRate && density == other.density && xDpi == other.xDpi && yDpi == other.yDpi && secure == other.secure && appVsyncOffsetNanos == other.appVsyncOffsetNanos && presentationDeadlineNanos == other.presentationDeadlineNanos; } /** * @hide */ @Override @Override public int hashCode() { public String toString() { return 0; // don't care return "DisplayConfig{width=" + width + ", height=" + height + ", xDpi=" + xDpi + ", yDpi=" + yDpi + ", refreshRate=" + refreshRate + ", appVsyncOffsetNanos=" + appVsyncOffsetNanos + ", presentationDeadlineNanos=" + presentationDeadlineNanos + "}"; } } /** * @hide */ public void copyFrom(PhysicalDisplayInfo other) { width = other.width; height = other.height; refreshRate = other.refreshRate; density = other.density; xDpi = other.xDpi; yDpi = other.yDpi; secure = other.secure; appVsyncOffsetNanos = other.appVsyncOffsetNanos; presentationDeadlineNanos = other.presentationDeadlineNanos; } } /** /** * @hide * @hide */ */ @Override public static void setDisplayPowerMode(IBinder displayToken, int mode) { public String toString() { if (displayToken == null) { return "PhysicalDisplayInfo{" + width + " x " + height + ", " + refreshRate + " fps, " throw new IllegalArgumentException("displayToken must not be null"); + "density " + density + ", " + xDpi + " x " + yDpi + " dpi, secure " + secure + ", appVsyncOffset " + appVsyncOffsetNanos + ", bufferDeadline " + presentationDeadlineNanos + "}"; } } nativeSetDisplayPowerMode(displayToken, mode); } } /** /** * @hide * @hide */ */ public static void setDisplayPowerMode(IBinder displayToken, int mode) { public static SurfaceControl.DisplayInfo getDisplayInfo(IBinder displayToken) { if (displayToken == null) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); throw new IllegalArgumentException("displayToken must not be null"); } } nativeSetDisplayPowerMode(displayToken, mode); return nativeGetDisplayInfo(displayToken); } } /** /** * @hide * @hide */ */ @UnsupportedAppUsage public static SurfaceControl.DisplayConfig[] getDisplayConfigs(IBinder displayToken) { public static SurfaceControl.PhysicalDisplayInfo[] getDisplayConfigs(IBinder displayToken) { if (displayToken == null) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); throw new IllegalArgumentException("displayToken must not be null"); } } Loading Loading @@ -1825,7 +1740,7 @@ public final class SurfaceControl implements Parcelable { } } /** /** * TODO(116025192): Remove this stopgap once framework is display-agnostic. * TODO(b/116025192): Remove this stopgap once framework is display-agnostic. * * * @hide * @hide */ */ Loading core/jni/android_view_SurfaceControl.cpp +71 −50 Original line number Original line Diff line number Diff line Loading @@ -22,20 +22,22 @@ #include "android_hardware_input_InputWindowHandle.h" #include "android_hardware_input_InputWindowHandle.h" #include "core_jni_helpers.h" #include "core_jni_helpers.h" #include <memory> #include <android-base/chrono_utils.h> #include <android/graphics/region.h> #include <android/graphics/region.h> #include <android_runtime/AndroidRuntime.h> #include <android_runtime/AndroidRuntime.h> #include <android-base/chrono_utils.h> #include <nativehelper/JNIHelp.h> #include <nativehelper/ScopedUtfChars.h> #include <android_runtime/android_view_Surface.h> #include <android_runtime/android_view_Surface.h> #include <android_runtime/android_view_SurfaceSession.h> #include <android_runtime/android_view_SurfaceSession.h> #include <gui/Surface.h> #include <gui/Surface.h> #include <gui/SurfaceComposerClient.h> #include <gui/SurfaceComposerClient.h> #include <jni.h> #include <jni.h> #include <memory> #include <nativehelper/JNIHelp.h> #include <nativehelper/ScopedUtfChars.h> #include <stdio.h> #include <stdio.h> #include <system/graphics.h> #include <system/graphics.h> #include <ui/ConfigStoreTypes.h> #include <ui/ConfigStoreTypes.h> #include <ui/DisplayConfig.h> #include <ui/DisplayInfo.h> #include <ui/DisplayInfo.h> #include <ui/DisplayedFrameStats.h> #include <ui/DisplayedFrameStats.h> #include <ui/FrameStats.h> #include <ui/FrameStats.h> Loading @@ -60,19 +62,24 @@ static void doThrowIAE(JNIEnv* env, const char* msg = nullptr) { static const char* const OutOfResourcesException = static const char* const OutOfResourcesException = "android/view/Surface$OutOfResourcesException"; "android/view/Surface$OutOfResourcesException"; static struct { jclass clazz; jmethodID ctor; jfieldID density; jfieldID secure; } gDisplayInfoClassInfo; static struct { static struct { jclass clazz; jclass clazz; jmethodID ctor; jmethodID ctor; jfieldID width; jfieldID width; jfieldID height; jfieldID height; jfieldID refreshRate; jfieldID density; jfieldID xDpi; jfieldID xDpi; jfieldID yDpi; jfieldID yDpi; jfieldID secure; jfieldID refreshRate; jfieldID appVsyncOffsetNanos; jfieldID appVsyncOffsetNanos; jfieldID presentationDeadlineNanos; jfieldID presentationDeadlineNanos; } gPhysicalDisplayInfoClassInfo; } gDisplayConfigClassInfo; static struct { static struct { jfieldID bottom; jfieldID bottom; Loading Loading @@ -766,37 +773,46 @@ static void nativeSetDisplaySize(JNIEnv* env, jclass clazz, } } } } static jobjectArray nativeGetDisplayConfigs(JNIEnv* env, jclass clazz, static jobject nativeGetDisplayInfo(JNIEnv* env, jclass clazz, jobject tokenObj) { jobject tokenObj) { DisplayInfo info; sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (const auto token = ibinderForJavaObject(env, tokenObj); if (token == NULL) return NULL; !token || SurfaceComposerClient::getDisplayInfo(token, &info) != NO_ERROR) { return nullptr; } Vector<DisplayInfo> configs; jobject object = env->NewObject(gDisplayInfoClassInfo.clazz, gDisplayInfoClassInfo.ctor); if (SurfaceComposerClient::getDisplayConfigs(token, &configs) != NO_ERROR || env->SetFloatField(object, gDisplayInfoClassInfo.density, info.density); configs.size() == 0) { env->SetBooleanField(object, gDisplayInfoClassInfo.secure, info.secure); return NULL; return object; } static jobjectArray nativeGetDisplayConfigs(JNIEnv* env, jclass clazz, jobject tokenObj) { Vector<DisplayConfig> configs; if (const auto token = ibinderForJavaObject(env, tokenObj); !token || SurfaceComposerClient::getDisplayConfigs(token, &configs) != NO_ERROR || configs.isEmpty()) { return nullptr; } } jobjectArray configArray = env->NewObjectArray(configs.size(), jobjectArray configArray = gPhysicalDisplayInfoClassInfo.clazz, NULL); env->NewObjectArray(configs.size(), gDisplayConfigClassInfo.clazz, nullptr); for (size_t c = 0; c < configs.size(); ++c) { for (size_t c = 0; c < configs.size(); ++c) { const DisplayInfo& info = configs[c]; const DisplayConfig& config = configs[c]; jobject infoObj = env->NewObject(gPhysicalDisplayInfoClassInfo.clazz, jobject object = gPhysicalDisplayInfoClassInfo.ctor); env->NewObject(gDisplayConfigClassInfo.clazz, gDisplayConfigClassInfo.ctor); env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.width, info.w); env->SetIntField(object, gDisplayConfigClassInfo.width, config.resolution.getWidth()); env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.height, info.h); env->SetIntField(object, gDisplayConfigClassInfo.height, config.resolution.getHeight()); env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.refreshRate, info.fps); env->SetFloatField(object, gDisplayConfigClassInfo.xDpi, config.xDpi); env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.density, info.density); env->SetFloatField(object, gDisplayConfigClassInfo.yDpi, config.yDpi); env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.xDpi, info.xdpi); env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.yDpi, info.ydpi); env->SetFloatField(object, gDisplayConfigClassInfo.refreshRate, config.refreshRate); env->SetBooleanField(infoObj, gPhysicalDisplayInfoClassInfo.secure, info.secure); env->SetLongField(object, gDisplayConfigClassInfo.appVsyncOffsetNanos, env->SetLongField(infoObj, gPhysicalDisplayInfoClassInfo.appVsyncOffsetNanos, config.appVsyncOffset); info.appVsyncOffset); env->SetLongField(object, gDisplayConfigClassInfo.presentationDeadlineNanos, env->SetLongField(infoObj, gPhysicalDisplayInfoClassInfo.presentationDeadlineNanos, config.presentationDeadline); info.presentationDeadline); env->SetObjectArrayElement(configArray, static_cast<jsize>(c), object); env->SetObjectArrayElement(configArray, static_cast<jsize>(c), infoObj); env->DeleteLocalRef(object); env->DeleteLocalRef(infoObj); } } return configArray; return configArray; Loading Loading @@ -1409,7 +1425,9 @@ static const JNINativeMethod sSurfaceControlMethods[] = { (void*)nativeSetDisplayProjection }, (void*)nativeSetDisplayProjection }, {"nativeSetDisplaySize", "(JLandroid/os/IBinder;II)V", {"nativeSetDisplaySize", "(JLandroid/os/IBinder;II)V", (void*)nativeSetDisplaySize }, (void*)nativeSetDisplaySize }, {"nativeGetDisplayConfigs", "(Landroid/os/IBinder;)[Landroid/view/SurfaceControl$PhysicalDisplayInfo;", {"nativeGetDisplayInfo", "(Landroid/os/IBinder;)Landroid/view/SurfaceControl$DisplayInfo;", (void*)nativeGetDisplayInfo }, {"nativeGetDisplayConfigs", "(Landroid/os/IBinder;)[Landroid/view/SurfaceControl$DisplayConfig;", (void*)nativeGetDisplayConfigs }, (void*)nativeGetDisplayConfigs }, {"nativeGetActiveConfig", "(Landroid/os/IBinder;)I", {"nativeGetActiveConfig", "(Landroid/os/IBinder;)I", (void*)nativeGetActiveConfig }, (void*)nativeGetActiveConfig }, Loading Loading @@ -1507,21 +1525,24 @@ int register_android_view_SurfaceControl(JNIEnv* env) int err = RegisterMethodsOrDie(env, "android/view/SurfaceControl", int err = RegisterMethodsOrDie(env, "android/view/SurfaceControl", sSurfaceControlMethods, NELEM(sSurfaceControlMethods)); sSurfaceControlMethods, NELEM(sSurfaceControlMethods)); jclass clazz = FindClassOrDie(env, "android/view/SurfaceControl$PhysicalDisplayInfo"); jclass infoClazz = FindClassOrDie(env, "android/view/SurfaceControl$DisplayInfo"); gPhysicalDisplayInfoClassInfo.clazz = MakeGlobalRefOrDie(env, clazz); gDisplayInfoClassInfo.clazz = MakeGlobalRefOrDie(env, infoClazz); gPhysicalDisplayInfoClassInfo.ctor = GetMethodIDOrDie(env, gDisplayInfoClassInfo.ctor = GetMethodIDOrDie(env, infoClazz, "<init>", "()V"); gPhysicalDisplayInfoClassInfo.clazz, "<init>", "()V"); gDisplayInfoClassInfo.density = GetFieldIDOrDie(env, infoClazz, "density", "F"); gPhysicalDisplayInfoClassInfo.width = GetFieldIDOrDie(env, clazz, "width", "I"); gDisplayInfoClassInfo.secure = GetFieldIDOrDie(env, infoClazz, "secure", "Z"); gPhysicalDisplayInfoClassInfo.height = GetFieldIDOrDie(env, clazz, "height", "I"); gPhysicalDisplayInfoClassInfo.refreshRate = GetFieldIDOrDie(env, clazz, "refreshRate", "F"); jclass configClazz = FindClassOrDie(env, "android/view/SurfaceControl$DisplayConfig"); gPhysicalDisplayInfoClassInfo.density = GetFieldIDOrDie(env, clazz, "density", "F"); gDisplayConfigClassInfo.clazz = MakeGlobalRefOrDie(env, configClazz); gPhysicalDisplayInfoClassInfo.xDpi = GetFieldIDOrDie(env, clazz, "xDpi", "F"); gDisplayConfigClassInfo.ctor = GetMethodIDOrDie(env, configClazz, "<init>", "()V"); gPhysicalDisplayInfoClassInfo.yDpi = GetFieldIDOrDie(env, clazz, "yDpi", "F"); gDisplayConfigClassInfo.width = GetFieldIDOrDie(env, configClazz, "width", "I"); gPhysicalDisplayInfoClassInfo.secure = GetFieldIDOrDie(env, clazz, "secure", "Z"); gDisplayConfigClassInfo.height = GetFieldIDOrDie(env, configClazz, "height", "I"); gPhysicalDisplayInfoClassInfo.appVsyncOffsetNanos = GetFieldIDOrDie(env, gDisplayConfigClassInfo.xDpi = GetFieldIDOrDie(env, configClazz, "xDpi", "F"); clazz, "appVsyncOffsetNanos", "J"); gDisplayConfigClassInfo.yDpi = GetFieldIDOrDie(env, configClazz, "yDpi", "F"); gPhysicalDisplayInfoClassInfo.presentationDeadlineNanos = GetFieldIDOrDie(env, gDisplayConfigClassInfo.refreshRate = GetFieldIDOrDie(env, configClazz, "refreshRate", "F"); clazz, "presentationDeadlineNanos", "J"); gDisplayConfigClassInfo.appVsyncOffsetNanos = GetFieldIDOrDie(env, configClazz, "appVsyncOffsetNanos", "J"); gDisplayConfigClassInfo.presentationDeadlineNanos = GetFieldIDOrDie(env, configClazz, "presentationDeadlineNanos", "J"); jclass rectClazz = FindClassOrDie(env, "android/graphics/Rect"); jclass rectClazz = FindClassOrDie(env, "android/graphics/Rect"); gRectClassInfo.bottom = GetFieldIDOrDie(env, rectClazz, "bottom", "I"); gRectClassInfo.bottom = GetFieldIDOrDie(env, rectClazz, "bottom", "I"); Loading libs/hwui/tests/common/TestContext.cpp +42 −32 Original line number Original line Diff line number Diff line Loading @@ -22,43 +22,50 @@ namespace android { namespace uirenderer { namespace uirenderer { namespace test { namespace test { static const int IDENT_DISPLAYEVENT = 1; const DisplayInfo& getDisplayInfo() { static DisplayInfo info = [] { static android::DisplayInfo DUMMY_DISPLAY{ DisplayInfo info; 1080, // w #if HWUI_NULL_GPU 1920, // h info.density = 2.f; 320.0, // xdpi 320.0, // ydpi 60.0, // fps 2.0, // density ui::ROTATION_0, // orientation false, // secure? 0, // appVsyncOffset 0, // presentationDeadline }; DisplayInfo getInternalDisplay() { #if !HWUI_NULL_GPU DisplayInfo display; const sp<IBinder> token = SurfaceComposerClient::getInternalDisplayToken(); LOG_ALWAYS_FATAL_IF(token == nullptr, "Failed to get display info because internal display is disconnected\n"); status_t status = SurfaceComposerClient::getDisplayInfo(token, &display); LOG_ALWAYS_FATAL_IF(status, "Failed to get display info\n"); return display; #else #else return DUMMY_DISPLAY; const sp<IBinder> token = SurfaceComposerClient::getInternalDisplayToken(); LOG_ALWAYS_FATAL_IF(!token, "%s: No internal display", __FUNCTION__); const status_t status = SurfaceComposerClient::getDisplayInfo(token, &info); LOG_ALWAYS_FATAL_IF(status, "%s: Failed to get display info", __FUNCTION__); #endif #endif return info; }(); return info; } } // Initialize to a dummy default const DisplayConfig& getActiveDisplayConfig() { android::DisplayInfo gDisplay = DUMMY_DISPLAY; static DisplayConfig config = [] { DisplayConfig config; #if HWUI_NULL_GPU config.resolution = ui::Size(1080, 1920); config.xDpi = config.yDpi = 320.f; config.refreshRate = 60.f; #else const sp<IBinder> token = SurfaceComposerClient::getInternalDisplayToken(); LOG_ALWAYS_FATAL_IF(!token, "%s: No internal display", __FUNCTION__); const status_t status = SurfaceComposerClient::getActiveDisplayConfig(token, &config); LOG_ALWAYS_FATAL_IF(status, "%s: Failed to get active display config", __FUNCTION__); #endif return config; }(); return config; } TestContext::TestContext() { TestContext::TestContext() { mLooper = new Looper(true); mLooper = new Looper(true); mSurfaceComposerClient = new SurfaceComposerClient(); mSurfaceComposerClient = new SurfaceComposerClient(); mLooper->addFd(mDisplayEventReceiver.getFd(), IDENT_DISPLAYEVENT, Looper::EVENT_INPUT, nullptr, nullptr); constexpr int EVENT_ID = 1; mLooper->addFd(mDisplayEventReceiver.getFd(), EVENT_ID, Looper::EVENT_INPUT, nullptr, nullptr); } } TestContext::~TestContext() {} TestContext::~TestContext() {} Loading @@ -79,8 +86,10 @@ void TestContext::createSurface() { } } void TestContext::createWindowSurface() { void TestContext::createWindowSurface() { mSurfaceControl = mSurfaceComposerClient->createSurface(String8("HwuiTest"), gDisplay.w, const ui::Size& resolution = getActiveDisplayResolution(); gDisplay.h, PIXEL_FORMAT_RGBX_8888); mSurfaceControl = mSurfaceComposerClient->createSurface(String8("HwuiTest"), resolution.getWidth(), resolution.getHeight(), PIXEL_FORMAT_RGBX_8888); SurfaceComposerClient::Transaction t; SurfaceComposerClient::Transaction t; t.setLayer(mSurfaceControl, 0x7FFFFFF).show(mSurfaceControl).apply(); t.setLayer(mSurfaceControl, 0x7FFFFFF).show(mSurfaceControl).apply(); Loading @@ -94,7 +103,8 @@ void TestContext::createOffscreenSurface() { producer->setMaxDequeuedBufferCount(3); producer->setMaxDequeuedBufferCount(3); producer->setAsyncMode(true); producer->setAsyncMode(true); mConsumer = new BufferItemConsumer(consumer, GRALLOC_USAGE_HW_COMPOSER, 4); mConsumer = new BufferItemConsumer(consumer, GRALLOC_USAGE_HW_COMPOSER, 4); mConsumer->setDefaultBufferSize(gDisplay.w, gDisplay.h); const ui::Size& resolution = getActiveDisplayResolution(); mConsumer->setDefaultBufferSize(resolution.getWidth(), resolution.getHeight()); mSurface = new Surface(producer); mSurface = new Surface(producer); } } Loading libs/hwui/tests/common/TestContext.h +8 −3 Original line number Original line Diff line number Diff line Loading @@ -23,20 +23,25 @@ #include <gui/Surface.h> #include <gui/Surface.h> #include <gui/SurfaceComposerClient.h> #include <gui/SurfaceComposerClient.h> #include <gui/SurfaceControl.h> #include <gui/SurfaceControl.h> #include <ui/DisplayConfig.h> #include <ui/DisplayInfo.h> #include <ui/DisplayInfo.h> #include <utils/Looper.h> #include <utils/Looper.h> #include <atomic> #include <atomic> #include <thread> #include <thread> #define dp(x) ((x) * android::uirenderer::test::getDisplayInfo().density) namespace android { namespace android { namespace uirenderer { namespace uirenderer { namespace test { namespace test { extern DisplayInfo gDisplay; const DisplayInfo& getDisplayInfo(); #define dp(x) ((x)*android::uirenderer::test::gDisplay.density) const DisplayConfig& getActiveDisplayConfig(); DisplayInfo getInternalDisplay(); inline const ui::Size& getActiveDisplayResolution() { return getActiveDisplayConfig().resolution; } class TestContext { class TestContext { public: public: Loading Loading
cmds/bootanimation/BootAnimation.cpp +10 −7 Original line number Original line Diff line number Diff line Loading @@ -42,10 +42,10 @@ #include <android-base/properties.h> #include <android-base/properties.h> #include <ui/DisplayConfig.h> #include <ui/PixelFormat.h> #include <ui/PixelFormat.h> #include <ui/Rect.h> #include <ui/Rect.h> #include <ui/Region.h> #include <ui/Region.h> #include <ui/DisplayInfo.h> #include <gui/ISurfaceComposer.h> #include <gui/ISurfaceComposer.h> #include <gui/Surface.h> #include <gui/Surface.h> Loading Loading @@ -283,16 +283,19 @@ status_t BootAnimation::readyToRun() { mDisplayToken = SurfaceComposerClient::getInternalDisplayToken(); mDisplayToken = SurfaceComposerClient::getInternalDisplayToken(); if (mDisplayToken == nullptr) if (mDisplayToken == nullptr) return -1; return NAME_NOT_FOUND; DisplayInfo dinfo; DisplayConfig displayConfig; status_t status = SurfaceComposerClient::getDisplayInfo(mDisplayToken, &dinfo); const status_t error = if (status) SurfaceComposerClient::getActiveDisplayConfig(mDisplayToken, &displayConfig); return -1; if (error != NO_ERROR) return error; const ui::Size& resolution = displayConfig.resolution; // create the native surface // create the native surface sp<SurfaceControl> control = session()->createSurface(String8("BootAnimation"), sp<SurfaceControl> control = session()->createSurface(String8("BootAnimation"), dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565); resolution.getWidth(), resolution.getHeight(), PIXEL_FORMAT_RGB_565); SurfaceComposerClient::Transaction t; SurfaceComposerClient::Transaction t; Loading
core/java/android/view/SurfaceControl.java +38 −123 Original line number Original line Diff line number Diff line Loading @@ -152,7 +152,8 @@ public final class SurfaceControl implements Parcelable { int L, int T, int R, int B); int L, int T, int R, int B); private static native void nativeSetDisplaySize(long transactionObj, IBinder displayToken, private static native void nativeSetDisplaySize(long transactionObj, IBinder displayToken, int width, int height); int width, int height); private static native SurfaceControl.PhysicalDisplayInfo[] nativeGetDisplayConfigs( private static native SurfaceControl.DisplayInfo nativeGetDisplayInfo(IBinder displayToken); private static native SurfaceControl.DisplayConfig[] nativeGetDisplayConfigs( IBinder displayToken); IBinder displayToken); private static native DisplayedContentSamplingAttributes private static native DisplayedContentSamplingAttributes nativeGetDisplayedContentSamplingAttributes(IBinder displayToken); nativeGetDisplayedContentSamplingAttributes(IBinder displayToken); Loading Loading @@ -1278,158 +1279,72 @@ public final class SurfaceControl implements Parcelable { Integer.toHexString(System.identityHashCode(this)); Integer.toHexString(System.identityHashCode(this)); } } /* * set display parameters. * needs to be inside open/closeTransaction block */ /** * Describes the properties of a physical display known to surface flinger. * @hide */ public static final class PhysicalDisplayInfo { /** * @hide */ @UnsupportedAppUsage public int width; /** * @hide */ @UnsupportedAppUsage public int height; /** * @hide */ @UnsupportedAppUsage public float refreshRate; /** /** * Immutable information about physical display. * * @hide * @hide */ */ @UnsupportedAppUsage public static final class DisplayInfo { public float density; public float density; /** * @hide */ @UnsupportedAppUsage public float xDpi; /** * @hide */ @UnsupportedAppUsage public float yDpi; /** * @hide */ @UnsupportedAppUsage public boolean secure; public boolean secure; /** @Override * @hide public String toString() { */ return "DisplayInfo{density=" + density + ", secure=" + secure + "}"; @UnsupportedAppUsage public long appVsyncOffsetNanos; /** * @hide */ @UnsupportedAppUsage public long presentationDeadlineNanos; /** * @hide */ @UnsupportedAppUsage public PhysicalDisplayInfo() { } } /** * @hide */ public PhysicalDisplayInfo(PhysicalDisplayInfo other) { copyFrom(other); } } /** /** * Configuration supported by physical display. * * @hide * @hide */ */ @Override public static final class DisplayConfig { public boolean equals(Object o) { public int width; return o instanceof PhysicalDisplayInfo && equals((PhysicalDisplayInfo)o); public int height; } public float xDpi; public float yDpi; /** public float refreshRate; * @hide public long appVsyncOffsetNanos; */ public long presentationDeadlineNanos; public boolean equals(PhysicalDisplayInfo other) { return other != null && width == other.width && height == other.height && refreshRate == other.refreshRate && density == other.density && xDpi == other.xDpi && yDpi == other.yDpi && secure == other.secure && appVsyncOffsetNanos == other.appVsyncOffsetNanos && presentationDeadlineNanos == other.presentationDeadlineNanos; } /** * @hide */ @Override @Override public int hashCode() { public String toString() { return 0; // don't care return "DisplayConfig{width=" + width + ", height=" + height + ", xDpi=" + xDpi + ", yDpi=" + yDpi + ", refreshRate=" + refreshRate + ", appVsyncOffsetNanos=" + appVsyncOffsetNanos + ", presentationDeadlineNanos=" + presentationDeadlineNanos + "}"; } } /** * @hide */ public void copyFrom(PhysicalDisplayInfo other) { width = other.width; height = other.height; refreshRate = other.refreshRate; density = other.density; xDpi = other.xDpi; yDpi = other.yDpi; secure = other.secure; appVsyncOffsetNanos = other.appVsyncOffsetNanos; presentationDeadlineNanos = other.presentationDeadlineNanos; } } /** /** * @hide * @hide */ */ @Override public static void setDisplayPowerMode(IBinder displayToken, int mode) { public String toString() { if (displayToken == null) { return "PhysicalDisplayInfo{" + width + " x " + height + ", " + refreshRate + " fps, " throw new IllegalArgumentException("displayToken must not be null"); + "density " + density + ", " + xDpi + " x " + yDpi + " dpi, secure " + secure + ", appVsyncOffset " + appVsyncOffsetNanos + ", bufferDeadline " + presentationDeadlineNanos + "}"; } } nativeSetDisplayPowerMode(displayToken, mode); } } /** /** * @hide * @hide */ */ public static void setDisplayPowerMode(IBinder displayToken, int mode) { public static SurfaceControl.DisplayInfo getDisplayInfo(IBinder displayToken) { if (displayToken == null) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); throw new IllegalArgumentException("displayToken must not be null"); } } nativeSetDisplayPowerMode(displayToken, mode); return nativeGetDisplayInfo(displayToken); } } /** /** * @hide * @hide */ */ @UnsupportedAppUsage public static SurfaceControl.DisplayConfig[] getDisplayConfigs(IBinder displayToken) { public static SurfaceControl.PhysicalDisplayInfo[] getDisplayConfigs(IBinder displayToken) { if (displayToken == null) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); throw new IllegalArgumentException("displayToken must not be null"); } } Loading Loading @@ -1825,7 +1740,7 @@ public final class SurfaceControl implements Parcelable { } } /** /** * TODO(116025192): Remove this stopgap once framework is display-agnostic. * TODO(b/116025192): Remove this stopgap once framework is display-agnostic. * * * @hide * @hide */ */ Loading
core/jni/android_view_SurfaceControl.cpp +71 −50 Original line number Original line Diff line number Diff line Loading @@ -22,20 +22,22 @@ #include "android_hardware_input_InputWindowHandle.h" #include "android_hardware_input_InputWindowHandle.h" #include "core_jni_helpers.h" #include "core_jni_helpers.h" #include <memory> #include <android-base/chrono_utils.h> #include <android/graphics/region.h> #include <android/graphics/region.h> #include <android_runtime/AndroidRuntime.h> #include <android_runtime/AndroidRuntime.h> #include <android-base/chrono_utils.h> #include <nativehelper/JNIHelp.h> #include <nativehelper/ScopedUtfChars.h> #include <android_runtime/android_view_Surface.h> #include <android_runtime/android_view_Surface.h> #include <android_runtime/android_view_SurfaceSession.h> #include <android_runtime/android_view_SurfaceSession.h> #include <gui/Surface.h> #include <gui/Surface.h> #include <gui/SurfaceComposerClient.h> #include <gui/SurfaceComposerClient.h> #include <jni.h> #include <jni.h> #include <memory> #include <nativehelper/JNIHelp.h> #include <nativehelper/ScopedUtfChars.h> #include <stdio.h> #include <stdio.h> #include <system/graphics.h> #include <system/graphics.h> #include <ui/ConfigStoreTypes.h> #include <ui/ConfigStoreTypes.h> #include <ui/DisplayConfig.h> #include <ui/DisplayInfo.h> #include <ui/DisplayInfo.h> #include <ui/DisplayedFrameStats.h> #include <ui/DisplayedFrameStats.h> #include <ui/FrameStats.h> #include <ui/FrameStats.h> Loading @@ -60,19 +62,24 @@ static void doThrowIAE(JNIEnv* env, const char* msg = nullptr) { static const char* const OutOfResourcesException = static const char* const OutOfResourcesException = "android/view/Surface$OutOfResourcesException"; "android/view/Surface$OutOfResourcesException"; static struct { jclass clazz; jmethodID ctor; jfieldID density; jfieldID secure; } gDisplayInfoClassInfo; static struct { static struct { jclass clazz; jclass clazz; jmethodID ctor; jmethodID ctor; jfieldID width; jfieldID width; jfieldID height; jfieldID height; jfieldID refreshRate; jfieldID density; jfieldID xDpi; jfieldID xDpi; jfieldID yDpi; jfieldID yDpi; jfieldID secure; jfieldID refreshRate; jfieldID appVsyncOffsetNanos; jfieldID appVsyncOffsetNanos; jfieldID presentationDeadlineNanos; jfieldID presentationDeadlineNanos; } gPhysicalDisplayInfoClassInfo; } gDisplayConfigClassInfo; static struct { static struct { jfieldID bottom; jfieldID bottom; Loading Loading @@ -766,37 +773,46 @@ static void nativeSetDisplaySize(JNIEnv* env, jclass clazz, } } } } static jobjectArray nativeGetDisplayConfigs(JNIEnv* env, jclass clazz, static jobject nativeGetDisplayInfo(JNIEnv* env, jclass clazz, jobject tokenObj) { jobject tokenObj) { DisplayInfo info; sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (const auto token = ibinderForJavaObject(env, tokenObj); if (token == NULL) return NULL; !token || SurfaceComposerClient::getDisplayInfo(token, &info) != NO_ERROR) { return nullptr; } Vector<DisplayInfo> configs; jobject object = env->NewObject(gDisplayInfoClassInfo.clazz, gDisplayInfoClassInfo.ctor); if (SurfaceComposerClient::getDisplayConfigs(token, &configs) != NO_ERROR || env->SetFloatField(object, gDisplayInfoClassInfo.density, info.density); configs.size() == 0) { env->SetBooleanField(object, gDisplayInfoClassInfo.secure, info.secure); return NULL; return object; } static jobjectArray nativeGetDisplayConfigs(JNIEnv* env, jclass clazz, jobject tokenObj) { Vector<DisplayConfig> configs; if (const auto token = ibinderForJavaObject(env, tokenObj); !token || SurfaceComposerClient::getDisplayConfigs(token, &configs) != NO_ERROR || configs.isEmpty()) { return nullptr; } } jobjectArray configArray = env->NewObjectArray(configs.size(), jobjectArray configArray = gPhysicalDisplayInfoClassInfo.clazz, NULL); env->NewObjectArray(configs.size(), gDisplayConfigClassInfo.clazz, nullptr); for (size_t c = 0; c < configs.size(); ++c) { for (size_t c = 0; c < configs.size(); ++c) { const DisplayInfo& info = configs[c]; const DisplayConfig& config = configs[c]; jobject infoObj = env->NewObject(gPhysicalDisplayInfoClassInfo.clazz, jobject object = gPhysicalDisplayInfoClassInfo.ctor); env->NewObject(gDisplayConfigClassInfo.clazz, gDisplayConfigClassInfo.ctor); env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.width, info.w); env->SetIntField(object, gDisplayConfigClassInfo.width, config.resolution.getWidth()); env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.height, info.h); env->SetIntField(object, gDisplayConfigClassInfo.height, config.resolution.getHeight()); env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.refreshRate, info.fps); env->SetFloatField(object, gDisplayConfigClassInfo.xDpi, config.xDpi); env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.density, info.density); env->SetFloatField(object, gDisplayConfigClassInfo.yDpi, config.yDpi); env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.xDpi, info.xdpi); env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.yDpi, info.ydpi); env->SetFloatField(object, gDisplayConfigClassInfo.refreshRate, config.refreshRate); env->SetBooleanField(infoObj, gPhysicalDisplayInfoClassInfo.secure, info.secure); env->SetLongField(object, gDisplayConfigClassInfo.appVsyncOffsetNanos, env->SetLongField(infoObj, gPhysicalDisplayInfoClassInfo.appVsyncOffsetNanos, config.appVsyncOffset); info.appVsyncOffset); env->SetLongField(object, gDisplayConfigClassInfo.presentationDeadlineNanos, env->SetLongField(infoObj, gPhysicalDisplayInfoClassInfo.presentationDeadlineNanos, config.presentationDeadline); info.presentationDeadline); env->SetObjectArrayElement(configArray, static_cast<jsize>(c), object); env->SetObjectArrayElement(configArray, static_cast<jsize>(c), infoObj); env->DeleteLocalRef(object); env->DeleteLocalRef(infoObj); } } return configArray; return configArray; Loading Loading @@ -1409,7 +1425,9 @@ static const JNINativeMethod sSurfaceControlMethods[] = { (void*)nativeSetDisplayProjection }, (void*)nativeSetDisplayProjection }, {"nativeSetDisplaySize", "(JLandroid/os/IBinder;II)V", {"nativeSetDisplaySize", "(JLandroid/os/IBinder;II)V", (void*)nativeSetDisplaySize }, (void*)nativeSetDisplaySize }, {"nativeGetDisplayConfigs", "(Landroid/os/IBinder;)[Landroid/view/SurfaceControl$PhysicalDisplayInfo;", {"nativeGetDisplayInfo", "(Landroid/os/IBinder;)Landroid/view/SurfaceControl$DisplayInfo;", (void*)nativeGetDisplayInfo }, {"nativeGetDisplayConfigs", "(Landroid/os/IBinder;)[Landroid/view/SurfaceControl$DisplayConfig;", (void*)nativeGetDisplayConfigs }, (void*)nativeGetDisplayConfigs }, {"nativeGetActiveConfig", "(Landroid/os/IBinder;)I", {"nativeGetActiveConfig", "(Landroid/os/IBinder;)I", (void*)nativeGetActiveConfig }, (void*)nativeGetActiveConfig }, Loading Loading @@ -1507,21 +1525,24 @@ int register_android_view_SurfaceControl(JNIEnv* env) int err = RegisterMethodsOrDie(env, "android/view/SurfaceControl", int err = RegisterMethodsOrDie(env, "android/view/SurfaceControl", sSurfaceControlMethods, NELEM(sSurfaceControlMethods)); sSurfaceControlMethods, NELEM(sSurfaceControlMethods)); jclass clazz = FindClassOrDie(env, "android/view/SurfaceControl$PhysicalDisplayInfo"); jclass infoClazz = FindClassOrDie(env, "android/view/SurfaceControl$DisplayInfo"); gPhysicalDisplayInfoClassInfo.clazz = MakeGlobalRefOrDie(env, clazz); gDisplayInfoClassInfo.clazz = MakeGlobalRefOrDie(env, infoClazz); gPhysicalDisplayInfoClassInfo.ctor = GetMethodIDOrDie(env, gDisplayInfoClassInfo.ctor = GetMethodIDOrDie(env, infoClazz, "<init>", "()V"); gPhysicalDisplayInfoClassInfo.clazz, "<init>", "()V"); gDisplayInfoClassInfo.density = GetFieldIDOrDie(env, infoClazz, "density", "F"); gPhysicalDisplayInfoClassInfo.width = GetFieldIDOrDie(env, clazz, "width", "I"); gDisplayInfoClassInfo.secure = GetFieldIDOrDie(env, infoClazz, "secure", "Z"); gPhysicalDisplayInfoClassInfo.height = GetFieldIDOrDie(env, clazz, "height", "I"); gPhysicalDisplayInfoClassInfo.refreshRate = GetFieldIDOrDie(env, clazz, "refreshRate", "F"); jclass configClazz = FindClassOrDie(env, "android/view/SurfaceControl$DisplayConfig"); gPhysicalDisplayInfoClassInfo.density = GetFieldIDOrDie(env, clazz, "density", "F"); gDisplayConfigClassInfo.clazz = MakeGlobalRefOrDie(env, configClazz); gPhysicalDisplayInfoClassInfo.xDpi = GetFieldIDOrDie(env, clazz, "xDpi", "F"); gDisplayConfigClassInfo.ctor = GetMethodIDOrDie(env, configClazz, "<init>", "()V"); gPhysicalDisplayInfoClassInfo.yDpi = GetFieldIDOrDie(env, clazz, "yDpi", "F"); gDisplayConfigClassInfo.width = GetFieldIDOrDie(env, configClazz, "width", "I"); gPhysicalDisplayInfoClassInfo.secure = GetFieldIDOrDie(env, clazz, "secure", "Z"); gDisplayConfigClassInfo.height = GetFieldIDOrDie(env, configClazz, "height", "I"); gPhysicalDisplayInfoClassInfo.appVsyncOffsetNanos = GetFieldIDOrDie(env, gDisplayConfigClassInfo.xDpi = GetFieldIDOrDie(env, configClazz, "xDpi", "F"); clazz, "appVsyncOffsetNanos", "J"); gDisplayConfigClassInfo.yDpi = GetFieldIDOrDie(env, configClazz, "yDpi", "F"); gPhysicalDisplayInfoClassInfo.presentationDeadlineNanos = GetFieldIDOrDie(env, gDisplayConfigClassInfo.refreshRate = GetFieldIDOrDie(env, configClazz, "refreshRate", "F"); clazz, "presentationDeadlineNanos", "J"); gDisplayConfigClassInfo.appVsyncOffsetNanos = GetFieldIDOrDie(env, configClazz, "appVsyncOffsetNanos", "J"); gDisplayConfigClassInfo.presentationDeadlineNanos = GetFieldIDOrDie(env, configClazz, "presentationDeadlineNanos", "J"); jclass rectClazz = FindClassOrDie(env, "android/graphics/Rect"); jclass rectClazz = FindClassOrDie(env, "android/graphics/Rect"); gRectClassInfo.bottom = GetFieldIDOrDie(env, rectClazz, "bottom", "I"); gRectClassInfo.bottom = GetFieldIDOrDie(env, rectClazz, "bottom", "I"); Loading
libs/hwui/tests/common/TestContext.cpp +42 −32 Original line number Original line Diff line number Diff line Loading @@ -22,43 +22,50 @@ namespace android { namespace uirenderer { namespace uirenderer { namespace test { namespace test { static const int IDENT_DISPLAYEVENT = 1; const DisplayInfo& getDisplayInfo() { static DisplayInfo info = [] { static android::DisplayInfo DUMMY_DISPLAY{ DisplayInfo info; 1080, // w #if HWUI_NULL_GPU 1920, // h info.density = 2.f; 320.0, // xdpi 320.0, // ydpi 60.0, // fps 2.0, // density ui::ROTATION_0, // orientation false, // secure? 0, // appVsyncOffset 0, // presentationDeadline }; DisplayInfo getInternalDisplay() { #if !HWUI_NULL_GPU DisplayInfo display; const sp<IBinder> token = SurfaceComposerClient::getInternalDisplayToken(); LOG_ALWAYS_FATAL_IF(token == nullptr, "Failed to get display info because internal display is disconnected\n"); status_t status = SurfaceComposerClient::getDisplayInfo(token, &display); LOG_ALWAYS_FATAL_IF(status, "Failed to get display info\n"); return display; #else #else return DUMMY_DISPLAY; const sp<IBinder> token = SurfaceComposerClient::getInternalDisplayToken(); LOG_ALWAYS_FATAL_IF(!token, "%s: No internal display", __FUNCTION__); const status_t status = SurfaceComposerClient::getDisplayInfo(token, &info); LOG_ALWAYS_FATAL_IF(status, "%s: Failed to get display info", __FUNCTION__); #endif #endif return info; }(); return info; } } // Initialize to a dummy default const DisplayConfig& getActiveDisplayConfig() { android::DisplayInfo gDisplay = DUMMY_DISPLAY; static DisplayConfig config = [] { DisplayConfig config; #if HWUI_NULL_GPU config.resolution = ui::Size(1080, 1920); config.xDpi = config.yDpi = 320.f; config.refreshRate = 60.f; #else const sp<IBinder> token = SurfaceComposerClient::getInternalDisplayToken(); LOG_ALWAYS_FATAL_IF(!token, "%s: No internal display", __FUNCTION__); const status_t status = SurfaceComposerClient::getActiveDisplayConfig(token, &config); LOG_ALWAYS_FATAL_IF(status, "%s: Failed to get active display config", __FUNCTION__); #endif return config; }(); return config; } TestContext::TestContext() { TestContext::TestContext() { mLooper = new Looper(true); mLooper = new Looper(true); mSurfaceComposerClient = new SurfaceComposerClient(); mSurfaceComposerClient = new SurfaceComposerClient(); mLooper->addFd(mDisplayEventReceiver.getFd(), IDENT_DISPLAYEVENT, Looper::EVENT_INPUT, nullptr, nullptr); constexpr int EVENT_ID = 1; mLooper->addFd(mDisplayEventReceiver.getFd(), EVENT_ID, Looper::EVENT_INPUT, nullptr, nullptr); } } TestContext::~TestContext() {} TestContext::~TestContext() {} Loading @@ -79,8 +86,10 @@ void TestContext::createSurface() { } } void TestContext::createWindowSurface() { void TestContext::createWindowSurface() { mSurfaceControl = mSurfaceComposerClient->createSurface(String8("HwuiTest"), gDisplay.w, const ui::Size& resolution = getActiveDisplayResolution(); gDisplay.h, PIXEL_FORMAT_RGBX_8888); mSurfaceControl = mSurfaceComposerClient->createSurface(String8("HwuiTest"), resolution.getWidth(), resolution.getHeight(), PIXEL_FORMAT_RGBX_8888); SurfaceComposerClient::Transaction t; SurfaceComposerClient::Transaction t; t.setLayer(mSurfaceControl, 0x7FFFFFF).show(mSurfaceControl).apply(); t.setLayer(mSurfaceControl, 0x7FFFFFF).show(mSurfaceControl).apply(); Loading @@ -94,7 +103,8 @@ void TestContext::createOffscreenSurface() { producer->setMaxDequeuedBufferCount(3); producer->setMaxDequeuedBufferCount(3); producer->setAsyncMode(true); producer->setAsyncMode(true); mConsumer = new BufferItemConsumer(consumer, GRALLOC_USAGE_HW_COMPOSER, 4); mConsumer = new BufferItemConsumer(consumer, GRALLOC_USAGE_HW_COMPOSER, 4); mConsumer->setDefaultBufferSize(gDisplay.w, gDisplay.h); const ui::Size& resolution = getActiveDisplayResolution(); mConsumer->setDefaultBufferSize(resolution.getWidth(), resolution.getHeight()); mSurface = new Surface(producer); mSurface = new Surface(producer); } } Loading
libs/hwui/tests/common/TestContext.h +8 −3 Original line number Original line Diff line number Diff line Loading @@ -23,20 +23,25 @@ #include <gui/Surface.h> #include <gui/Surface.h> #include <gui/SurfaceComposerClient.h> #include <gui/SurfaceComposerClient.h> #include <gui/SurfaceControl.h> #include <gui/SurfaceControl.h> #include <ui/DisplayConfig.h> #include <ui/DisplayInfo.h> #include <ui/DisplayInfo.h> #include <utils/Looper.h> #include <utils/Looper.h> #include <atomic> #include <atomic> #include <thread> #include <thread> #define dp(x) ((x) * android::uirenderer::test::getDisplayInfo().density) namespace android { namespace android { namespace uirenderer { namespace uirenderer { namespace test { namespace test { extern DisplayInfo gDisplay; const DisplayInfo& getDisplayInfo(); #define dp(x) ((x)*android::uirenderer::test::gDisplay.density) const DisplayConfig& getActiveDisplayConfig(); DisplayInfo getInternalDisplay(); inline const ui::Size& getActiveDisplayResolution() { return getActiveDisplayConfig().resolution; } class TestContext { class TestContext { public: public: Loading