Skip to content

Commit

Permalink
log pixel format on surface changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pazos authored and NiLuJe committed Jan 26, 2021
1 parent 9690635 commit ba72e00
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/src/main/java/org/koreader/launcher/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ class MainActivity : NativeActivity(), JNILuaInterface,
}
override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) {
Logger.v(tag, String.format(Locale.US,
"surface changed {\n width: %d\n height: %d\n}", width, height))
"surface changed {\n width: %d\n height: %d\n format: %s\n}",
width, height, ScreenUtils.pixelFormatName(format))
)
}
override fun surfaceDestroyed(holder: SurfaceHolder) {
Logger.v(tag, "surface destroyed")
Expand Down Expand Up @@ -133,6 +135,10 @@ class MainActivity : NativeActivity(), JNILuaInterface,
}

override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) {
Logger.v(TAG_MAIN, String.format(Locale.US,
"surface changed {\n width: %d\n height: %d\n format: %s\n}",
width, height, ScreenUtils.pixelFormatName(format))
)
super.surfaceChanged(holder, format, width, height)
drawSplashScreen(holder)
}
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/org/koreader/launcher/utils/ScreenUtils.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package org.koreader.launcher.utils

import android.app.Activity
import android.graphics.PixelFormat
import android.graphics.Point
import android.graphics.Rect
import android.os.Build
import android.util.DisplayMetrics
import android.view.WindowManager
import org.koreader.launcher.Logger
import java.util.Locale
import java.util.concurrent.CountDownLatch

@Suppress("DEPRECATION")
Expand Down Expand Up @@ -64,6 +66,16 @@ object ScreenUtils {
}
}

fun pixelFormatName(format: Int): String {
return when(format) {
PixelFormat.RGBA_8888 -> "RGBA_8888"
PixelFormat.RGBX_8888 -> "RGBX_8888"
PixelFormat.RGB_888 -> "RGB_888"
PixelFormat.RGB_565 -> "RGB_565"
else -> String.format(Locale.US, "Unknown: %d", format)
}
}

private fun getScreenSize(activity: Activity): Point {
val size = Point()
val display = activity.windowManager.defaultDisplay
Expand Down

0 comments on commit ba72e00

Please sign in to comment.