Size: a a a

Android NDK (C++) — русскоговорящее сообщество

2020 October 23

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
(tho the measure text is probably the largest factor of the time taken, as i doubt moving the allocation back into the loop would make any impact on the performance, but it is recommended to not allocate in onDraw for a reason so heh, the same would also apply to tight loops i guess)
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
tho making the entire text information structure (building and storing) 100% native would squeeze the most performance out of it right?
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
tho the only problem with that would be figuring out how to call the Java Paint api's from C++
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
as i doubt that i can just, for example call nGetStringBounds(mNativePaint, text, start, end, mBidiFlags, bounds) from C++
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
also there would likely be JNI overhead for C++ to Java to C++
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
so im not sure if the total overhead itself, in combination with the C++ code, would end up being greater or equal to the the the total time that my Java version takes
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
as Android's C++ api's (including the private AOSP-only api's (eg the ones that are unaccessable from NDK and can only be accessed if you build from AOSP source yourself)) would be heavily optimized due to years of development, maintenance, and improving (from the very early 2.2 Android to Android 9, 10, and 11) right?
источник

AB

Alex Bieliaiev in Android NDK (C++) — русскоговорящее сообщество
It feels like there is something terribly wrong
источник

AB

Alex Bieliaiev in Android NDK (C++) — русскоговорящее сообщество
Over the last years I've never seen text layout measurement as a performance hit
источник

AB

Alex Bieliaiev in Android NDK (C++) — русскоговорящее сообщество
Would you mind sharing your code and the details of your testing hardware?
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
im using a plain TextView, Samsung S8 and custom ROM based on Android 10
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
and im using a TextFile that contains 260k characters
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
with about 3.6k lines
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
which is literally just copied from https://en.wikipedia.org/wiki/UTF-8 via CTRL-A and CTRL-V
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
        renderer.setTextBookView(taskBuilder.CodeView.findViewById(R.id.codeEditor));
       TextView textBookView = renderer.getTextBookView();
       textBookView.setTextSize(30.0f);
       textBookView.setBreakStrategy(LineBreaker.BREAK_STRATEGY_SIMPLE);
       try {
           textBookView.setText(TextBook.readTextFile(textBookView.getResources().getAssets().open(TextBookView.SAMPLE_TEXT_LONG)));
       } catch (IOException e) {
           e.printStackTrace();
       }
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
Alex Bieliaiev
Would you mind sharing your code and the details of your testing hardware?
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
i can also test with a Treble stock AOSP GSI if you want, as i dont have the original samsung ROM my phone comes with
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
источник

DG

Dmitry Gordin in Android NDK (C++) — русскоговорящее сообщество
Matthew Good
        renderer.setTextBookView(taskBuilder.CodeView.findViewById(R.id.codeEditor));
       TextView textBookView = renderer.getTextBookView();
       textBookView.setTextSize(30.0f);
       textBookView.setBreakStrategy(LineBreaker.BREAK_STRATEGY_SIMPLE);
       try {
           textBookView.setText(TextBook.readTextFile(textBookView.getResources().getAssets().open(TextBookView.SAMPLE_TEXT_LONG)));
       } catch (IOException e) {
           e.printStackTrace();
       }
based on name I guess you're working on book reader
is it really nessesary to have measurements for whole text for each frame?
you won't be able to render even 0.01% of text at screen at one time
why don't you compute this only for small amount of text and cache results as user scrolls down?
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
at the moment i only measure on first draw
источник