diff options
author | 2020-06-02 11:39:57 +0000 | |
---|---|---|
committer | 2020-06-02 11:39:57 +0000 | |
commit | e350724e34185f29140b6a00e22efe6e49dcf285 (patch) | |
tree | 97005f65b3bc79691686082796f8a70a3eee00f1 /cmds/bootanimation | |
parent | 71572d9ba0791da380c88ec21f68aa5416b8ba4a (diff) | |
parent | 3c1b9ad9afd950a8e95bbc5525fae3c4882b1b7b (diff) |
Merge "Render boot animation with same size as framebuffer" into rvc-dev am: cbea0ab58f am: 937a25de15 am: 35ae2778c3 am: 3c1b9ad9af
Original change: undetermined
Change-Id: I1ae7b19afe2e88fc1a7fd32c41fb870e80685ff8
Diffstat (limited to 'cmds/bootanimation')
-rw-r--r-- | cmds/bootanimation/BootAnimation.cpp | 30 | ||||
-rw-r--r-- | cmds/bootanimation/BootAnimation.h | 3 |
2 files changed, 29 insertions, 4 deletions
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp index d8e25accdaaf..36ff20f45ec2 100644 --- a/cmds/bootanimation/BootAnimation.cpp +++ b/cmds/bootanimation/BootAnimation.cpp @@ -372,6 +372,25 @@ EGLConfig BootAnimation::getEglConfig(const EGLDisplay& display) { return config; } +ui::Size BootAnimation::limitSurfaceSize(int width, int height) const { + ui::Size limited(width, height); + bool wasLimited = false; + const float aspectRatio = float(width) / float(height); + if (mMaxWidth != 0 && width > mMaxWidth) { + limited.height = mMaxWidth / aspectRatio; + limited.width = mMaxWidth; + wasLimited = true; + } + if (mMaxHeight != 0 && limited.height > mMaxHeight) { + limited.height = mMaxHeight; + limited.width = mMaxHeight * aspectRatio; + wasLimited = true; + } + SLOGV_IF(wasLimited, "Surface size has been limited to [%dx%d] from [%dx%d]", + limited.width, limited.height, width, height); + return limited; +} + status_t BootAnimation::readyToRun() { mAssets.addDefaultAssets(); @@ -385,8 +404,10 @@ status_t BootAnimation::readyToRun() { if (error != NO_ERROR) return error; - const ui::Size& resolution = displayConfig.resolution; - + mMaxWidth = android::base::GetIntProperty("ro.surface_flinger.max_graphics_width", 0); + mMaxHeight = android::base::GetIntProperty("ro.surface_flinger.max_graphics_height", 0); + ui::Size resolution = displayConfig.resolution; + resolution = limitSurfaceSize(resolution.width, resolution.height); // create the native surface sp<SurfaceControl> control = session()->createSurface(String8("BootAnimation"), resolution.getWidth(), resolution.getHeight(), PIXEL_FORMAT_RGB_565); @@ -482,8 +503,9 @@ void BootAnimation::resizeSurface(int newWidth, int newHeight) { eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglDestroySurface(mDisplay, mSurface); - mWidth = newWidth; - mHeight = newHeight; + const auto limitedSize = limitSurfaceSize(newWidth, newHeight); + mWidth = limitedSize.width; + mHeight = limitedSize.height; SurfaceComposerClient::Transaction t; t.setSize(mFlingerSurfaceControl, mWidth, mHeight); diff --git a/cmds/bootanimation/BootAnimation.h b/cmds/bootanimation/BootAnimation.h index 875819d3c6ef..9e6e4aa42f1c 100644 --- a/cmds/bootanimation/BootAnimation.h +++ b/cmds/bootanimation/BootAnimation.h @@ -170,6 +170,7 @@ private: bool findBootAnimationFileInternal(const std::vector<std::string>& files); bool preloadAnimation(); EGLConfig getEglConfig(const EGLDisplay&); + ui::Size limitSurfaceSize(int width, int height) const; void resizeSurface(int newWidth, int newHeight); void checkExit(); @@ -181,6 +182,8 @@ private: Texture mAndroid[2]; int mWidth; int mHeight; + int mMaxWidth = 0; + int mMaxHeight = 0; int mCurrentInset; int mTargetInset; bool mUseNpotTextures = false; |