Andreas Falkenhahn
2018-04-01 16:45:45 UTC
I'm moving away from NativeActivity because I want to do more things on the Java side and less things in C. However, I still want to keep the renderer in C. That's why I'm using an Activity which has a SurfaceView as its content.
When I used NativeActivity, ANativeWindow_getFormat() returned RGBX_8888 which was just fine. With my new renderer based on SurfaceView, however, my surfaceChanged() callback always receives RGB_565 as the pixel format which looks really ugly because it only has 65536 colors and gradients look pretty cheap in 16 bits.
So I tried to add the following code to my onCreate() before calling setContentView():
getWindow().setFormat(PixelFormat.RGBX_8888);
This indeed solves the problem on my Nexus 5X device running Android 8 but on my Nexus 9 tablet running Android 6 it doesn't work and I still get 16-bit surfaces. What is confusing me, however, is the fact that when using NativeActivity on my Nexus 9 tablet running Android 6 I actually *get* RGBX_8888 surfaces! So this is definitely *not* a hardware/system limitation on Nexus 9/Android 6. It works for NativeActivity, but not for my SurfaceView.
This leads me to the following question: What magic does NativeActivity do in order to get RGBX_8888 surfaces on Nexus 9/Android 6? In other words, what do I have to do in order to get RGBX_8888 in my non-NativeActivity app as well?
I've already peeked into the Android sources but I don't see anything. To make the confusion complete, NativeActivity.java explicitly sets the pixel format to RGB_565 in onCreate() but I definitely get RGBX_8888 surfaces with NativeActivity! So where do these come from and how do I request them in a non-NativeActivity app?
Thanks for listening!
--
Best regards,
Andreas Falkenhahn mailto:***@falkenhahn.com
When I used NativeActivity, ANativeWindow_getFormat() returned RGBX_8888 which was just fine. With my new renderer based on SurfaceView, however, my surfaceChanged() callback always receives RGB_565 as the pixel format which looks really ugly because it only has 65536 colors and gradients look pretty cheap in 16 bits.
So I tried to add the following code to my onCreate() before calling setContentView():
getWindow().setFormat(PixelFormat.RGBX_8888);
This indeed solves the problem on my Nexus 5X device running Android 8 but on my Nexus 9 tablet running Android 6 it doesn't work and I still get 16-bit surfaces. What is confusing me, however, is the fact that when using NativeActivity on my Nexus 9 tablet running Android 6 I actually *get* RGBX_8888 surfaces! So this is definitely *not* a hardware/system limitation on Nexus 9/Android 6. It works for NativeActivity, but not for my SurfaceView.
This leads me to the following question: What magic does NativeActivity do in order to get RGBX_8888 surfaces on Nexus 9/Android 6? In other words, what do I have to do in order to get RGBX_8888 in my non-NativeActivity app as well?
I've already peeked into the Android sources but I don't see anything. To make the confusion complete, NativeActivity.java explicitly sets the pixel format to RGB_565 in onCreate() but I definitely get RGBX_8888 surfaces with NativeActivity! So where do these come from and how do I request them in a non-NativeActivity app?
Thanks for listening!
--
Best regards,
Andreas Falkenhahn mailto:***@falkenhahn.com
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/1488280579.20180401184545%40falkenhahn.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/1488280579.20180401184545%40falkenhahn.com.
For more options, visit https://groups.google.com/d/optout.