Mailing List Archive

NVidia Shield screen resolution
I cannot find a solution to this, Android is firmly in charge and thinks
it knows what is best for me.

On Linux, I can connect MythTV to a 3840x2160 screen and it uses the
full screen and plays 4K video perfectly (using vaapi). I have committed
a change that updates a few places in the code where 1920x1080 was
hardcoded as the maximum. None of those had actually prevented 4K video
from working.

I have a 3840x2160 screen connected to my NVidia Shield. In the Android
setup the resolution is set at "4K". The screen OSD itself confirms that
it is running at 3840x2160. However, QT informs us that the screen
resolution is 1920x1080. Playing a 4K video file results in it being
resized to 1920x1080 and then displayed as 3840x2160 via some android
scaling operation.

In the manifest (supports-screens) I tried adding
android:xlargeScreens="true". This did not help:

<supports-screens android:xlargeScreens="true"
android:largeScreens="true" android:normalScreens="true"
android:anyDensity="true" android:smallScreens="true" />

I also tried android:anyDensity="false" . This made things worse - QT
gave the screen size as 960x540 and everything was blurry. However this
does prove that android is ready and willing to scale the output as it
sees fit, and I don't know how to prevent that from happening.

I also tried removing the supports-screens setting altogether. Kodi does
not use that setting in its manifest. That did not help either. Still
1920x1080.

I tried QApplication::setAttribute(Qt::AA_DisableHighDpiScaling); in the
code in case it is QT that is messing with this. That did not help.

I set the program arguments to "-v general,playback,libav,gui". Then
when a video starts there is a log message with the resolution, which is
obtained for QT desktop widget:

MythUIHelper: Using screen 0, 1920x1080 at 0,0

I found a web site that tells how to modify Android's dpi setting but
that does not seem to be available on the Shield
(https://www.thecustomdroid.com/change-dpi-density-android/).

Playing a 4K video on the Shield and looking at some small writing in
the video, I can see it is jagged, unlike when playing through Linux.

Android may be getting a screen size in inches from somewhere and
deciding that I don't need the full resolution. Or else it is deciding
that MythTV developers are too stupid to create an application that runs
at 4K so they are helping us by resizing it down to 1080.

My next step would be to create a basic "Hello world" android
application and see what screen resolution I get. Since I have never
created an android application from scratch, I don't think I will be
trying this.

Peter

_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: NVidia Shield screen resolution [ In reply to ]
On 29/07/18 21:55, Peter Bennett wrote:

>
> My next step would be to create a basic "Hello world" android
> application and see what screen resolution I get. Since I have never
> created an android application from scratch, I don't think I will be
> trying this.
>

I can help you out here...

https://github.com/stuarta/opengl-qt5

It's a re-implementation of the basic OpenGL triangle examples
using pure Qt. The basic test application is hard coded to 800x600,
but there is a commented out bit of code to tell Qt to use
full screen.

Hopefully this will be of some use.


Regards
Stuart
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: NVidia Shield screen resolution [ In reply to ]
On 7/30/2018 6:55 AM, Peter Bennett wrote:
> I cannot find a solution to this, Android is firmly in charge and
> thinks it knows what is best for me.
>
> On Linux, I can connect MythTV to a 3840x2160 screen and it uses the
> full screen and plays 4K video perfectly (using vaapi). I have
> committed a change that updates a few places in the code where
> 1920x1080 was hardcoded as the maximum. None of those had actually
> prevented 4K video from working.
>
> I have a 3840x2160 screen connected to my NVidia Shield. In the
> Android setup the resolution is set at "4K". The screen OSD itself
> confirms that it is running at 3840x2160. However, QT informs us that
> the screen resolution is 1920x1080. Playing a 4K video file results in
> it being resized to 1920x1080 and then displayed as 3840x2160 via some
> android scaling operation.
>
> In the manifest (supports-screens) I tried adding
> android:xlargeScreens="true". This did not help:
>
> <supports-screens android:xlargeScreens="true"
> android:largeScreens="true" android:normalScreens="true"
> android:anyDensity="true" android:smallScreens="true" />
>
> I also tried android:anyDensity="false" . This made things worse - QT
> gave the screen size as 960x540 and everything was blurry. However
> this does prove that android is ready and willing to scale the output
> as it sees fit, and I don't know how to prevent that from happening.
>
> I also tried removing the supports-screens setting altogether. Kodi
> does not use that setting in its manifest. That did not help either.
> Still 1920x1080.
>
> I tried QApplication::setAttribute(Qt::AA_DisableHighDpiScaling); in
> the code in case it is QT that is messing with this. That did not help.
>
> I set the program arguments to "-v general,playback,libav,gui". Then
> when a video starts there is a log message with the resolution, which
> is obtained for QT desktop widget:
>
> MythUIHelper: Using screen 0, 1920x1080 at 0,0
>
> I found a web site that tells how to modify Android's dpi setting but
> that does not seem to be available on the Shield
> (https://www.thecustomdroid.com/change-dpi-density-android/).
>
> Playing a 4K video on the Shield and looking at some small writing in
> the video, I can see it is jagged, unlike when playing through Linux.
>
> Android may be getting a screen size in inches from somewhere and
> deciding that I don't need the full resolution. Or else it is deciding
> that MythTV developers are too stupid to create an application that
> runs at 4K so they are helping us by resizing it down to 1080.
>
> My next step would be to create a basic "Hello world" android
> application and see what screen resolution I get. Since I have never
> created an android application from scratch, I don't think I will be
> trying this.
Is this also with video playback or UI only?
Is it different with media codec vs GLES?

CPU definitely takes a hit for a 4K screen though.

Will do some research on this.

Mark
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: NVidia Shield screen resolution [ In reply to ]
On 07/29/2018 06:14 PM, Mark Spieth wrote:
> Is this also with video playback or UI only?
It is both. In the Setup->Appearance I tried changing the GUI size to
1280x720. That should have used one third of the width and height, but
actually used two thirds of the width and height.
> Is it different with media codec vs GLES?
>
No - media codec is also using OpenGL for output, the same as used by
software decoding. It may be different with a surface but there is no
code to use a surface at this time.
> CPU definitely takes a hit for a 4K screen though.

> Will do some research on this.
>
> Mark

_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: NVidia Shield screen resolution [ In reply to ]
On 30 July 2018 08:29:31 GMT+10:00, Peter Bennett <pb.mythtv@gmail.com> wrote:
>
>
>On 07/29/2018 06:14 PM, Mark Spieth wrote:
>> Is this also with video playback or UI only?
>It is both. In the Setup->Appearance I tried changing the GUI size to
>1280x720. That should have used one third of the width and height, but
>actually used two thirds of the width and height.
>> Is it different with media codec vs GLES?
>>
>No - media codec is also using OpenGL for output, the same as used by
>software decoding. It may be different with a surface but there is no
>code to use a surface at this time.
>> CPU definitely takes a hit for a 4K screen though.
>
>> Will do some research on this.
>>
Smells like a qt or platform gl problem. Need to check qt source for 1920 restrictions.


--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: NVidia Shield screen resolution [ In reply to ]
On 07/29/2018 06:58 PM, Mark Spieth wrote:
>
> On 30 July 2018 08:29:31 GMT+10:00, Peter Bennett <pb.mythtv@gmail.com> wrote:
>>
>> On 07/29/2018 06:14 PM, Mark Spieth wrote:
>>> Is this also with video playback or UI only?
>> It is both. In the Setup->Appearance I tried changing the GUI size to
>> 1280x720. That should have used one third of the width and height, but
>> actually used two thirds of the width and height.
>>> Is it different with media codec vs GLES?
>>>
>> No - media codec is also using OpenGL for output, the same as used by
>> software decoding. It may be different with a surface but there is no
>> code to use a surface at this time.
>>> CPU definitely takes a hit for a 4K screen though.
>>> Will do some research on this.
>>>
> Smells like a qt or platform gl problem. Need to check qt source for 1920 restrictions.
>
>
FWIW 4K video works fine with Qt on Linux. Also I tested the 4K video
with Kodi on Shield and it is playing with the full 4K resolution on my
monitor, so it is possible to do it. I did scan carefully through the
Kodi manifest but I could find nothing that might help me.

Peter
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: NVidia Shield screen resolution [ In reply to ]
On 31/07/18 08:52, Peter Bennett wrote:
>
>
> On 07/29/2018 06:58 PM, Mark Spieth wrote:
>>
>> On 30 July 2018 08:29:31 GMT+10:00, Peter Bennett
>> <pb.mythtv@gmail.com> wrote:
>>>
>>> On 07/29/2018 06:14 PM, Mark Spieth wrote:
>>>> Is this also with video playback or UI only?
>>> It is both. In the Setup->Appearance I tried changing the GUI size to
>>> 1280x720. That should have used one third of the width and height, but
>>> actually used two thirds of the width and height.
>>>> Is it different with media codec vs GLES?
>>>>
>>> No - media codec is also using OpenGL for output, the same as used by
>>> software decoding. It may be different with a surface but there is no
>>> code to use a surface at this time.
>>>> CPU definitely takes a hit for a 4K screen though.
>>>> Will do some research on this.
>>>>
>> Smells like a qt or platform gl problem. Need to check qt source for
>> 1920 restrictions.
>>
>>
> FWIW 4K video works fine with Qt on Linux. Also I tested the 4K video
> with Kodi on Shield and it is playing with the full 4K resolution on
> my monitor, so it is possible to do it. I did scan carefully through
> the Kodi manifest but I could find nothing that might help me.
>
Here is something to look at.
in qt source qtbase/src/plugins/platforms/android/androidjnimain.cpp

there are 2 functions
createSurface and setSurfaceGeometry. This is the lowest level before
android and applies to qt's gl surface it allocates at start.
instrument with some __android_log_print to see what height and width
are being used. These will appear in logcat.
Make changes and then makelibs.sh without clean. Wont take as long as
clean and you dont need to export any diffs either.
Changes are preserved. since git is used for baselining you can git diff
to get your patches too.

Note this is the file that launches main() in mythtv. see
startapplication which launches a thread which then runs main(). This is
called from the java initial code (some in qt and 1 overridden in our
android_package_source tree.

Not sure when I can test this but may give you some hints as to where
the 4k is going.

All parts of our android app is using gl for rendering.
You can also go for gdb and break in these functions if you are extra
adventurous.

HTH
Mark
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: NVidia Shield screen resolution [ In reply to ]
On 07/30/2018 11:17 PM, Mark Spieth wrote:
>
> On 31/07/18 08:52, Peter Bennett wrote:
>>
>>
>> On 07/29/2018 06:58 PM, Mark Spieth wrote:
>>>
>>> On 30 July 2018 08:29:31 GMT+10:00, Peter Bennett
>>> <pb.mythtv@gmail.com> wrote:
>>>>
>>>> On 07/29/2018 06:14 PM, Mark Spieth wrote:
>>>>> Is this also with video playback or UI only?
>>>> It is both. In the Setup->Appearance I tried changing the GUI size to
>>>> 1280x720. That should have used one third of the width and height, but
>>>> actually used two thirds of the width and height.
>>>>> Is it different with media codec vs GLES?
>>>>>
>>>> No - media codec is also using OpenGL for output, the same as used by
>>>> software decoding. It may be different with a surface but there is no
>>>> code to use a surface at this time.
>>>>> CPU definitely takes a hit for a 4K screen though.
>>>>> Will do some research on this.
>>>>>
>>> Smells like a qt or platform gl problem. Need to check qt source for
>>> 1920 restrictions.
>>>
>>>
>> FWIW 4K video works fine with Qt on Linux. Also I tested the 4K video
>> with Kodi on Shield and it is playing with the full 4K resolution on
>> my monitor, so it is possible to do it. I did scan carefully through
>> the Kodi manifest but I could find nothing that might help me.
>>
> Here is something to look at.
> in qt source qtbase/src/plugins/platforms/android/androidjnimain.cpp
>
> there are 2 functions
> createSurface and setSurfaceGeometry. This is the lowest level before
> android and applies to qt's gl surface it allocates at start.
> instrument with some __android_log_print to see what height and width
> are being used. These will appear in logcat.
> Make changes and then makelibs.sh without clean. Wont take as long as
> clean and you dont need to export any diffs either.
> Changes are preserved. since git is used for baselining you can git
> diff to get your patches too.
>
> Note this is the file that launches main() in mythtv. see
> startapplication which launches a thread which then runs main(). This
> is called from the java initial code (some in qt and 1 overridden in
> our android_package_source tree.
>
> Not sure when I can test this but may give you some hints as to where
> the 4k is going.
>
> All parts of our android app is using gl for rendering.
> You can also go for gdb and break in these functions if you are extra
> adventurous.
>
> HTH
> Mark

This is what I get logged

androidjnimain.cpp setDisplayMetrics wP=1920 hP=1080 dWP=1920 dHP=1080
xdpi=213.000000 ydpi=213.000000 sD=2.000000 d=2.000000
qandroidplatformintegration.cpp setDefaultDisplayMetrics gw=1920 gh=1080
sw=229 sh=129 scrW=1920 scrH=1080
androidjnimain.cpp setSurfaceGeometry x=0 y=0 w=1920 h=1080

setDisplayMetrics parameters logged are
        widthPixels, heightPixels,
        desktopWidthPixels, desktopHeightPixels,
        xdpi, ydpi,
        scaledDensity, density);

Those last two parameters of setDisplayMetrics look like a possible cause
scaledDensity=2 and density=2. Documentation says scaledDensity is for
fonts and density is logical density.

QtLayout.onSizeChanged (java)
 calls android.view.Display.getMetrics()
 calls QtNative.setApplicationDisplayMetrics()
   calls setDisplayMetrics (c++)


/public void getMetrics (DisplayMetrics outMetrics)//
//
//Gets display metrics that describe the size and density of this
display. The size returned by this method does not necessarily represent
the actual raw size (native resolution) of the display.//
//2.//*It may be scaled to provide compatibility with older applications
that were originally designed for smaller displays.
*/How do we explain to android this is not an older application like
that? Will each android device do its own thing here?

/DisplayMetrics.density//
//The logical density of the display. This is a scaling factor for the
Density Independent Pixel unit, where one DIP is one pixel on an
approximately 160 dpi screen (for example a 240x320, 1.5"x2" screen),
providing the baseline of the system's display. Thus on a 160dpi screen
this density value will be 1; on a 120 dpi screen it would be .75; etc. //
/
Maybe we should use getRealMetrics instead of getMetrics I can try that.

Otherwise multiply screen height and width by density.

Either way involves changing some QT code ???

Peter
Re: NVidia Shield screen resolution [ In reply to ]
On 08/01/2018 05:17 PM, Peter Bennett wrote:
>
>
>
> On 07/30/2018 11:17 PM, Mark Spieth wrote:
>>
>> On 31/07/18 08:52, Peter Bennett wrote:
>>>
>>>
>>> On 07/29/2018 06:58 PM, Mark Spieth wrote:
>>>>
>>>> On 30 July 2018 08:29:31 GMT+10:00, Peter Bennett
>>>> <pb.mythtv@gmail.com> wrote:
>>>>>
>>>>> On 07/29/2018 06:14 PM, Mark Spieth wrote:
>>>>>> Is this also with video playback or UI only?
>>>>> It is both. In the Setup->Appearance I tried changing the GUI size to
>>>>> 1280x720. That should have used one third of the width and height,
>>>>> but
>>>>> actually used two thirds of the width and height.
>>>>>> Is it different with media codec vs GLES?
>>>>>>
>>>>> No - media codec is also using OpenGL for output, the same as used by
>>>>> software decoding. It may be different with a surface but there is no
>>>>> code to use a surface at this time.
>>>>>> CPU definitely takes a hit for a 4K screen though.
>>>>>> Will do some research on this.
>>>>>>
>>>> Smells like a qt or platform gl problem. Need to check qt source
>>>> for 1920 restrictions.
>>>>
>>>>
>>> FWIW 4K video works fine with Qt on Linux. Also I tested the 4K
>>> video with Kodi on Shield and it is playing with the full 4K
>>> resolution on my monitor, so it is possible to do it. I did scan
>>> carefully through the Kodi manifest but I could find nothing that
>>> might help me.
>>>
>> Here is something to look at.
>> in qt source qtbase/src/plugins/platforms/android/androidjnimain.cpp
>>
>> there are 2 functions
>> createSurface and setSurfaceGeometry. This is the lowest level before
>> android and applies to qt's gl surface it allocates at start.
>> instrument with some __android_log_print to see what height and width
>> are being used. These will appear in logcat.
>> Make changes and then makelibs.sh without clean. Wont take as long as
>> clean and you dont need to export any diffs either.
>> Changes are preserved. since git is used for baselining you can git
>> diff to get your patches too.
>>
>> Note this is the file that launches main() in mythtv. see
>> startapplication which launches a thread which then runs main(). This
>> is called from the java initial code (some in qt and 1 overridden in
>> our android_package_source tree.
>>
>> Not sure when I can test this but may give you some hints as to where
>> the 4k is going.
>>
>> All parts of our android app is using gl for rendering.
>> You can also go for gdb and break in these functions if you are extra
>> adventurous.
>>
>> HTH
>> Mark
>
> This is what I get logged
>
> androidjnimain.cpp setDisplayMetrics wP=1920 hP=1080 dWP=1920 dHP=1080
> xdpi=213.000000 ydpi=213.000000 sD=2.000000 d=2.000000
> qandroidplatformintegration.cpp setDefaultDisplayMetrics gw=1920
> gh=1080 sw=229 sh=129 scrW=1920 scrH=1080
> androidjnimain.cpp setSurfaceGeometry x=0 y=0 w=1920 h=1080
>
> setDisplayMetrics parameters logged are
>         widthPixels, heightPixels,
>         desktopWidthPixels, desktopHeightPixels,
>         xdpi, ydpi,
>         scaledDensity, density);
>
> Those last two parameters of setDisplayMetrics look like a possible cause
> scaledDensity=2 and density=2. Documentation says scaledDensity is for
> fonts and density is logical density.
>
> QtLayout.onSizeChanged (java)
>  calls android.view.Display.getMetrics()
>  calls QtNative.setApplicationDisplayMetrics()
>    calls setDisplayMetrics (c++)
>
>
> /public void getMetrics (DisplayMetrics outMetrics)//
> //
> //Gets display metrics that describe the size and density of this
> display. The size returned by this method does not necessarily
> represent the actual raw size (native resolution) of the display.//
> //2.//*It may be scaled to provide compatibility with older
> applications that were originally designed for smaller displays.
> */How do we explain to android this is not an older application like
> that? Will each android device do its own thing here?
>
> /DisplayMetrics.density//
> //The logical density of the display. This is a scaling factor for the
> Density Independent Pixel unit, where one DIP is one pixel on an
> approximately 160 dpi screen (for example a 240x320, 1.5"x2" screen),
> providing the baseline of the system's display. Thus on a 160dpi
> screen this density value will be 1; on a 120 dpi screen it would be
> .75; etc. //
> /
> Maybe we should use getRealMetrics instead of getMetrics I can try that.
>
> Otherwise multiply screen height and width by density.
>
> Either way involves changing some QT code ???
>
> Peter

No solution in sight - with the display physically at 1920x1080 or
3840x2160 the metrics are the same. Also using getRealMetrics returns
the same in both 1920 and 3840 resolution cases..

All 4 cases return the same values -
androidjnimain.cpp setDisplayMetrics wP=1920 hP=1080 dWP=1920 dHP=1080
xdpi=213.000000 ydpi=213.000000 sD=2.000000 d=2.000000

Peter
Re: NVidia Shield screen resolution [ In reply to ]
On 8/2/2018 7:17 AM, Peter Bennett wrote:
>
>
>
> On 07/30/2018 11:17 PM, Mark Spieth wrote:
>>
>> On 31/07/18 08:52, Peter Bennett wrote:
>>>
>>>
>>> On 07/29/2018 06:58 PM, Mark Spieth wrote:
>>>>
>>>> On 30 July 2018 08:29:31 GMT+10:00, Peter Bennett
>>>> <pb.mythtv@gmail.com> wrote:
>>>>>
>>>>> On 07/29/2018 06:14 PM, Mark Spieth wrote:
>>>>>> Is this also with video playback or UI only?
>>>>> It is both. In the Setup->Appearance I tried changing the GUI size to
>>>>> 1280x720. That should have used one third of the width and height,
>>>>> but
>>>>> actually used two thirds of the width and height.
>>>>>> Is it different with media codec vs GLES?
>>>>>>
>>>>> No - media codec is also using OpenGL for output, the same as used by
>>>>> software decoding. It may be different with a surface but there is no
>>>>> code to use a surface at this time.
>>>>>> CPU definitely takes a hit for a 4K screen though.
>>>>>> Will do some research on this.
>>>>>>
>>>> Smells like a qt or platform gl problem. Need to check qt source
>>>> for 1920 restrictions.
>>>>
>>>>
>>> FWIW 4K video works fine with Qt on Linux. Also I tested the 4K
>>> video with Kodi on Shield and it is playing with the full 4K
>>> resolution on my monitor, so it is possible to do it. I did scan
>>> carefully through the Kodi manifest but I could find nothing that
>>> might help me.
>>>
>> Here is something to look at.
>> in qt source qtbase/src/plugins/platforms/android/androidjnimain.cpp
>>
>> there are 2 functions
>> createSurface and setSurfaceGeometry. This is the lowest level before
>> android and applies to qt's gl surface it allocates at start.
>> instrument with some __android_log_print to see what height and width
>> are being used. These will appear in logcat.
>> Make changes and then makelibs.sh without clean. Wont take as long as
>> clean and you dont need to export any diffs either.
>> Changes are preserved. since git is used for baselining you can git
>> diff to get your patches too.
>>
>> Note this is the file that launches main() in mythtv. see
>> startapplication which launches a thread which then runs main(). This
>> is called from the java initial code (some in qt and 1 overridden in
>> our android_package_source tree.
>>
>> Not sure when I can test this but may give you some hints as to where
>> the 4k is going.
>>
>> All parts of our android app is using gl for rendering.
>> You can also go for gdb and break in these functions if you are extra
>> adventurous.
>>
>> HTH
>> Mark
>
> This is what I get logged
>
> androidjnimain.cpp setDisplayMetrics wP=1920 hP=1080 dWP=1920 dHP=1080
> xdpi=213.000000 ydpi=213.000000 sD=2.000000 d=2.000000
> qandroidplatformintegration.cpp setDefaultDisplayMetrics gw=1920
> gh=1080 sw=229 sh=129 scrW=1920 scrH=1080
> androidjnimain.cpp setSurfaceGeometry x=0 y=0 w=1920 h=1080
>
> setDisplayMetrics parameters logged are
>         widthPixels, heightPixels,
>         desktopWidthPixels, desktopHeightPixels,
>         xdpi, ydpi,
>         scaledDensity, density);
>
> Those last two parameters of setDisplayMetrics look like a possible cause
> scaledDensity=2 and density=2. Documentation says scaledDensity is for
> fonts and density is logical density.
>
> QtLayout.onSizeChanged (java)
>  calls android.view.Display.getMetrics()
>  calls QtNative.setApplicationDisplayMetrics()
>    calls setDisplayMetrics (c++)
>
>
> /public void getMetrics (DisplayMetrics outMetrics)//
> //
> //Gets display metrics that describe the size and density of this
> display. The size returned by this method does not necessarily
> represent the actual raw size (native resolution) of the display.//
> //2.//*It may be scaled to provide compatibility with older
> applications that were originally designed for smaller displays.
> */How do we explain to android this is not an older application like
> that? Will each android device do its own thing here?
>
> /DisplayMetrics.density//
> //The logical density of the display. This is a scaling factor for the
> Density Independent Pixel unit, where one DIP is one pixel on an
> approximately 160 dpi screen (for example a 240x320, 1.5"x2" screen),
> providing the baseline of the system's display. Thus on a 160dpi
> screen this density value will be 1; on a 120 dpi screen it would be
> .75; etc. //
> /
> Maybe we should use getRealMetrics instead of getMetrics I can try that.
>
> Otherwise multiply screen height and width by density.
>
> Either way involves changing some QT code ???
>
I'm not afraid of changing QT code (as evidenced by the patches) and nor
should anyone else be.
Looking at updating QT5.11.1 ATM to see if that will help but probably not.
getMetrics is interesting. This I think is used in myth too for API
compatibility originally. I was targeting 4.2 + because I had some
devices using that including my projector on 4.4 and tv on 4.4 which
will never get any updates.

If that is where the numbers HD are coming from, then replace it with
getRealMetrics and see.
Ill investigate the impacts today some time as I find time.

Mark
Re: NVidia Shield screen resolution [ In reply to ]
On 02/08/18 08:27, Peter Bennett wrote:
>
>
>
> On 08/01/2018 05:17 PM, Peter Bennett wrote:
>>
>>
>>
>> On 07/30/2018 11:17 PM, Mark Spieth wrote:
>>>
>>> On 31/07/18 08:52, Peter Bennett wrote:
>>>>
>>>>
>>>> On 07/29/2018 06:58 PM, Mark Spieth wrote:
>>>>>
>>>>> On 30 July 2018 08:29:31 GMT+10:00, Peter Bennett
>>>>> <pb.mythtv@gmail.com> wrote:
>>>>>>
>>>>>> On 07/29/2018 06:14 PM, Mark Spieth wrote:
>>>>>>> Is this also with video playback or UI only?
>>>>>> It is both. In the Setup->Appearance I tried changing the GUI
>>>>>> size to
>>>>>> 1280x720. That should have used one third of the width and
>>>>>> height, but
>>>>>> actually used two thirds of the width and height.
>>>>>>> Is it different with media codec vs GLES?
>>>>>>>
>>>>>> No - media codec is also using OpenGL for output, the same as
>>>>>> used by
>>>>>> software decoding. It may be different with a surface but there
>>>>>> is no
>>>>>> code to use a surface at this time.
>>>>>>> CPU definitely takes a hit for a 4K screen though.
>>>>>>> Will do some research on this.
>>>>>>>
>>>>> Smells like a qt or platform gl problem. Need to check qt source
>>>>> for 1920 restrictions.
>>>>>
>>>>>
>>>> FWIW 4K video works fine with Qt on Linux. Also I tested the 4K
>>>> video with Kodi on Shield and it is playing with the full 4K
>>>> resolution on my monitor, so it is possible to do it. I did scan
>>>> carefully through the Kodi manifest but I could find nothing that
>>>> might help me.
>>>>
>>> Here is something to look at.
>>> in qt source qtbase/src/plugins/platforms/android/androidjnimain.cpp
>>>
>>> there are 2 functions
>>> createSurface and setSurfaceGeometry. This is the lowest level
>>> before android and applies to qt's gl surface it allocates at start.
>>> instrument with some __android_log_print to see what height and
>>> width are being used. These will appear in logcat.
>>> Make changes and then makelibs.sh without clean. Wont take as long
>>> as clean and you dont need to export any diffs either.
>>> Changes are preserved. since git is used for baselining you can git
>>> diff to get your patches too.
>>>
>>> Note this is the file that launches main() in mythtv. see
>>> startapplication which launches a thread which then runs main().
>>> This is called from the java initial code (some in qt and 1
>>> overridden in our android_package_source tree.
>>>
>>> Not sure when I can test this but may give you some hints as to
>>> where the 4k is going.
>>>
>>> All parts of our android app is using gl for rendering.
>>> You can also go for gdb and break in these functions if you are
>>> extra adventurous.
>>>
>>> HTH
>>> Mark
>>
>> This is what I get logged
>>
>> androidjnimain.cpp setDisplayMetrics wP=1920 hP=1080 dWP=1920
>> dHP=1080 xdpi=213.000000 ydpi=213.000000 sD=2.000000 d=2.000000
>> qandroidplatformintegration.cpp setDefaultDisplayMetrics gw=1920
>> gh=1080 sw=229 sh=129 scrW=1920 scrH=1080
>> androidjnimain.cpp setSurfaceGeometry x=0 y=0 w=1920 h=1080
>>
>> setDisplayMetrics parameters logged are
>>         widthPixels, heightPixels,
>>         desktopWidthPixels, desktopHeightPixels,
>>         xdpi, ydpi,
>>         scaledDensity, density);
>>
>> Those last two parameters of setDisplayMetrics look like a possible cause
>> scaledDensity=2 and density=2. Documentation says scaledDensity is
>> for fonts and density is logical density.
>>
>> QtLayout.onSizeChanged (java)
>>  calls android.view.Display.getMetrics()
>>  calls QtNative.setApplicationDisplayMetrics()
>>    calls setDisplayMetrics (c++)
>>
>>
>> /public void getMetrics (DisplayMetrics outMetrics)//
>> //
>> //Gets display metrics that describe the size and density of this
>> display. The size returned by this method does not necessarily
>> represent the actual raw size (native resolution) of the display.//
>> //2.//*It may be scaled to provide compatibility with older
>> applications that were originally designed for smaller displays.
>> */How do we explain to android this is not an older application like
>> that? Will each android device do its own thing here?
>>
>> /DisplayMetrics.density//
>> //The logical density of the display. This is a scaling factor for
>> the Density Independent Pixel unit, where one DIP is one pixel on an
>> approximately 160 dpi screen (for example a 240x320, 1.5"x2" screen),
>> providing the baseline of the system's display. Thus on a 160dpi
>> screen this density value will be 1; on a 120 dpi screen it would be
>> .75; etc. //
>> /
>> Maybe we should use getRealMetrics instead of getMetrics I can try that.
>>
>> Otherwise multiply screen height and width by density.
>>
>> Either way involves changing some QT code ???
>>
>> Peter
>
> No solution in sight - with the display physically at 1920x1080 or
> 3840x2160 the metrics are the same. Also using getRealMetrics returns
> the same in both 1920 and 3840 resolution cases..
>
> All 4 cases return the same values -
> androidjnimain.cpp setDisplayMetrics wP=1920 hP=1080 dWP=1920 dHP=1080
> xdpi=213.000000 ydpi=213.000000 sD=2.000000 d=2.000000
>
Another thing to try

in qt src
qtbase/src/android/jar/src/org/qtproject/qt5/android
change all getMetrics calls to getRealMetrics in the java files.

It may be possible to copy these to android-package-source tree but not
sure as they are in the jar directory not the java directory. Should
work though and then we can modify them as required without patching qt.
It would mean a diff/merge on updating qt though just in case these change.

The optimal change is to check for PAI or try except get realmetrics and
then use getmetrics as a fallback. However since the APIs we are
targeting, this is probably not necessary as getRealMetrics should be
available always.

Mark
Re: NVidia Shield screen resolution [ In reply to ]
On 08/01/2018 07:47 PM, Mark Spieth wrote:
> Another thing to try
>
> in qt src
> qtbase/src/android/jar/src/org/qtproject/qt5/android
> change all getMetrics calls to getRealMetrics in the java files.
>
> It may be possible to copy these to android-package-source tree but
> not sure as they are in the jar directory not the java directory.
> Should work though and then we can modify them as required without
> patching qt. It would mean a diff/merge on updating qt though just in
> case these change.
>
> The optimal change is to check for PAI or try except get realmetrics
> and then use getmetrics as a fallback. However since the APIs we are
> targeting, this is probably not necessary as getRealMetrics should be
> available always.
>
> Mark
>
Hi Mark

Thanks for the suggestions. I still have no success.

getRealMetrics returns the exact same faulty result as getMetrics.

I found I can get the actual values from
android.view.Display.Mode.getPhysicalWidth and getPhysicalHeight. Those
return the real pixel size.

I changed the call to QtNative.setApplicationDisplayMetrics to use those
real pixel sizes instead of the ones from getMetrics.

Everything looks fine in the log messages:

androidjnimain.cpp setDisplayMetrics wP=3840 hP=2160 dWP=3840 dHP=2160
xdpi=213.000000 ydpi=213.000000 sD=2.000000 d=2.000000
qandroidplatformintegration.cpp setDefaultDisplayMetrics gw=3840 gh=2160
sw=458 sh=258 scrW=3840 scrH=2160
androidjnimain.cpp createSurface x=0 y=0 w=100 h=30
androidjnimain.cpp setSurfaceGeometry x=0 y=0 w=3840 h=2160

HOWEVER, on the screen is now a hugely enlarged version of the top left
hand corner of the MythTV GUI. MythTV is drawing it to the correct 4K
size but QT and android have taken the picture and scaled it to twice
the size.

The Android documentation of android.view.Display.Mode.getPhysicalWidth
states

/Note that due to application UI scaling, the number of pixels made
available to applications when the mode is active (as reported by
Display.getHeight() may differ from the mode's actual resolution (as
reported by this function).//
//
//For example, applications running on a 4K display may have their UI
laid out and rendered in 1080p and then scaled up. Applications can take
advantage of the extra resolution by rendering content through a
SurfaceView using full size buffers.//
/
It seems to me that this is what we are doing, without success.

Peter
Re: NVidia Shield screen resolution [ In reply to ]
On 8/3/2018 2:50 AM, Peter Bennett wrote:
>
>
>
> On 08/01/2018 07:47 PM, Mark Spieth wrote:
>> Another thing to try
>>
>> in qt src
>> qtbase/src/android/jar/src/org/qtproject/qt5/android
>> change all getMetrics calls to getRealMetrics in the java files.
>>
>> It may be possible to copy these to android-package-source tree but
>> not sure as they are in the jar directory not the java directory.
>> Should work though and then we can modify them as required without
>> patching qt. It would mean a diff/merge on updating qt though just in
>> case these change.
>>
>> The optimal change is to check for PAI or try except get realmetrics
>> and then use getmetrics as a fallback. However since the APIs we are
>> targeting, this is probably not necessary as getRealMetrics should be
>> available always.
>>
>> Mark
>>
> Hi Mark
>
> Thanks for the suggestions. I still have no success.
>
> getRealMetrics returns the exact same faulty result as getMetrics.
>
> I found I can get the actual values from
> android.view.Display.Mode.getPhysicalWidth and getPhysicalHeight.
> Those return the real pixel size.
>
> I changed the call to QtNative.setApplicationDisplayMetrics to use
> those real pixel sizes instead of the ones from getMetrics.
>
> Everything looks fine in the log messages:
>
> androidjnimain.cpp setDisplayMetrics wP=3840 hP=2160 dWP=3840 dHP=2160
> xdpi=213.000000 ydpi=213.000000 sD=2.000000 d=2.000000
> qandroidplatformintegration.cpp setDefaultDisplayMetrics gw=3840
> gh=2160 sw=458 sh=258 scrW=3840 scrH=2160
> androidjnimain.cpp createSurface x=0 y=0 w=100 h=30
> androidjnimain.cpp setSurfaceGeometry x=0 y=0 w=3840 h=2160
>
> HOWEVER, on the screen is now a hugely enlarged version of the top
> left hand corner of the MythTV GUI. MythTV is drawing it to the
> correct 4K size but QT and android have taken the picture and scaled
> it to twice the size.
>
> The Android documentation of
> android.view.Display.Mode.getPhysicalWidth states
>
> /Note that due to application UI scaling, the number of pixels made
> available to applications when the mode is active (as reported by
> Display.getHeight() may differ from the mode's actual resolution (as
> reported by this function).//
> //
> //For example, applications running on a 4K display may have their UI
> laid out and rendered in 1080p and then scaled up. Applications can
> take advantage of the extra resolution by rendering content through a
> SurfaceView using full size buffers.//
> /
> It seems to me that this is what we are doing, without success.
Some more ideas...

1. In AndroidManifest.xml set android.app.auto_screen_scale_factor to true

2. https://stackoverflow.com/questions/42898179/android-ui-scale
set scale factor using the getPhysicalWidth or perhaps
getDisplayMetrics(). May work.
OnCreate is in src/org/qtproject/qt5/android/bindings/QtActivity.java

We dont have a layout file so cant adapt this. my search terms are
"android application ui scaling"

HTH but probably not
Mark
Re: NVidia Shield screen resolution [ In reply to ]
On 08/02/2018 06:26 PM, Mark Spieth wrote:
> On 8/3/2018 2:50 AM, Peter Bennett wrote:
>>
>>
>>
>> On 08/01/2018 07:47 PM, Mark Spieth wrote:
>>> Another thing to try
>>>
>>> in qt src
>>> qtbase/src/android/jar/src/org/qtproject/qt5/android
>>> change all getMetrics calls to getRealMetrics in the java files.
>>>
>>> It may be possible to copy these to android-package-source tree but
>>> not sure as they are in the jar directory not the java directory.
>>> Should work though and then we can modify them as required without
>>> patching qt. It would mean a diff/merge on updating qt though just
>>> in case these change.
>>>
>>> The optimal change is to check for PAI or try except get realmetrics
>>> and then use getmetrics as a fallback. However since the APIs we are
>>> targeting, this is probably not necessary as getRealMetrics should
>>> be available always.
>>>
>>> Mark
>>>
>> Hi Mark
>>
>> Thanks for the suggestions. I still have no success.
>>
>> getRealMetrics returns the exact same faulty result as getMetrics.
>>
>> I found I can get the actual values from
>> android.view.Display.Mode.getPhysicalWidth and getPhysicalHeight.
>> Those return the real pixel size.
>>
>> I changed the call to QtNative.setApplicationDisplayMetrics to use
>> those real pixel sizes instead of the ones from getMetrics.
>>
>> Everything looks fine in the log messages:
>>
>> androidjnimain.cpp setDisplayMetrics wP=3840 hP=2160 dWP=3840
>> dHP=2160 xdpi=213.000000 ydpi=213.000000 sD=2.000000 d=2.000000
>> qandroidplatformintegration.cpp setDefaultDisplayMetrics gw=3840
>> gh=2160 sw=458 sh=258 scrW=3840 scrH=2160
>> androidjnimain.cpp createSurface x=0 y=0 w=100 h=30
>> androidjnimain.cpp setSurfaceGeometry x=0 y=0 w=3840 h=2160
>>
>> HOWEVER, on the screen is now a hugely enlarged version of the top
>> left hand corner of the MythTV GUI. MythTV is drawing it to the
>> correct 4K size but QT and android have taken the picture and scaled
>> it to twice the size.
>>
>> The Android documentation of
>> android.view.Display.Mode.getPhysicalWidth states
>>
>> /Note that due to application UI scaling, the number of pixels made
>> available to applications when the mode is active (as reported by
>> Display.getHeight() may differ from the mode's actual resolution (as
>> reported by this function).//
>> //
>> //For example, applications running on a 4K display may have their UI
>> laid out and rendered in 1080p and then scaled up. Applications can
>> take advantage of the extra resolution by rendering content through a
>> SurfaceView using full size buffers.//
>> /
>> It seems to me that this is what we are doing, without success.
> Some more ideas...
>
> 1. In AndroidManifest.xml set android.app.auto_screen_scale_factor to true
>
> 2. https://stackoverflow.com/questions/42898179/android-ui-scale
> set scale factor using the getPhysicalWidth or perhaps
> getDisplayMetrics(). May work.
> OnCreate is in src/org/qtproject/qt5/android/bindings/QtActivity.java
>
> We dont have a layout file so cant adapt this. my search terms are
> "android application ui scaling"
>
> HTH but probably not
> Mark
>
>
>
>
I tried QApplication::setAttribute(Qt::AA_DisableHighDpiScaling); (made
no diffference)

Also tried SurfaceHolder.setFixedSize() as suggested somewhere. Tried it
with different values. This produced bizarre results which made no sense

Also tried surface.setScaleX(); and surface.setScaleY(); Tried with
different values. More bizarre results.

Both setScale and setFixedSize are maintaining the doubling of the
pixels on the screen, and changing the size of my image within that
doubled setup.

Peter