Size: a a a

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

2020 October 21

1

1xBet in Android NDK (C++) — русскоговорящее сообщество
Здравствуйте кто может помочь обойти проверку наличие активации в приложении ?
источник
2020 October 23

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
would it be faster to measure text in JNI than an java?
источник

MG

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

DG

Dmitry Gordin in Android NDK (C++) — русскоговорящее сообщество
Matthew Good
would it be faster to measure text in JNI than an java?
is it possible to do so?
1. if you use monospace font and no text wrapping then there's nothing to do actually just integer division
2. if you use monospace but need text wrapping then for transferring string and converting it into char array I guess you'll spent more time than just loop through in java
3. if you need non monospace font - there's nothing to do in cpp, use built-in functions from android
smth like paint.getTextBounds or pain.measureText
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
Dmitry Gordin
is it possible to do so?
1. if you use monospace font and no text wrapping then there's nothing to do actually just integer division
2. if you use monospace but need text wrapping then for transferring string and converting it into char array I guess you'll spent more time than just loop through in java
3. if you need non monospace font - there's nothing to do in cpp, use built-in functions from android
smth like paint.getTextBounds or pain.measureText
hm ok
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
welp heres an interesting fact:

i out-perform android's TextView by a factor of 10 o.o

android's line breaking is the last thing I expected to be a performance hit from its text layout system

but instead it is like 96% of the performance hit

With most of it being in

android.text.StaticLayout.generate
   android.graphics.text.LineBreaker.computeLineBreaks
       android.graphics.text.LineBreaker.nComputeLineBreaks
           2.29s

meanwhile i take ~220ms to do line breaking

like holy crap 😱
источник

DG

Dmitry Gordin in Android NDK (C++) — русскоговорящее сообщество
you're doing for monospace right?
источник

MG

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

MG

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

MG

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

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
even with the same text size for both (setTextSize(30.0f);)
источник

MG

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

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
the text paint i cant really change in TextView

        mRes = getResources();
       mTextBookPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
       mTextBookPaint.density = mRes.getDisplayMetrics().density;
       mBackgroundPaint = new Paint();
       mBackgroundPaint.setColor(Color.WHITE);
       mBackgroundPaint.setStyle(Paint.Style.FILL);
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
even with textBookView.setBreakStrategy(LineBreaker.BREAK_STRATEGY_SIMPLE); it still takes over 2 seconds
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
so yea i dont know wtf nComputeLineBreaks is doing that takes it over 2 seconds to complete
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
also would it be faster to like... build my line info structure in CPP instead of Java?
источник

MG

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

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
as i need to get this to at least 16ms
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
to be fast enough fot real-time text layout and measurement (eg with no drawing lag as the user inputs text)
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
as i managed to get it down from 630 ms average to around 220 ms to 330 ms average

by moving the allocations from the inside of the loop to the outside of the loop, measuring the entire line once, and then using the consumed count as an offset to the measured widths index

instead of allocating and measuring each loop

but i am not sure what else i can do
источник