Size: a a a

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

2020 October 24

DG

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

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
now to port all my java code to JNI x.x
источник

DG

Dmitry Gordin in Android NDK (C++) — русскоговорящее сообщество
try flutter it uses skia inside
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
i dont think flutter would be useful
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
also rip, my DrawText native code draws in 24 ms when the Canvas.drawText can draw in 4 ms x.x
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
https://gist.github.com/f8111df74147c3002ed8dbe8f8716b64

    public void draw(Canvas canvas, TextPaint textPaint) {
       Instant before = Instant.now();
       Bitmap bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
       drawLine(bitmap, text == null ? null : text.toString(), textPaint);
       canvas.drawBitmap(bitmap, 0, 0, null);
       bitmap.recycle();
       Instant after = Instant.now();
       Log.d(TAG, "draw: completed in " + Duration.between(before, after).toMillis() + " milliseconds");
   }
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
tho the code itself is not optimized
источник
2020 October 25

MG

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

D/Skia: draw: read pixels in 213 milliseconds

Instant before = Instant.now();
int[] pixels = getPixels(native_skia_ptr);
Instant after = Instant.now();
Log.d(TAG, "draw: read pixels in " + Duration.between(before, after).toMillis() + " milliseconds");


jintArray SkiaInstance::getPixels(JNIEnv *env) {
   auto sRGB = SkColorSpace::MakeSRGB();
   SkImageInfo dstInfo = SkImageInfo::Make(
           width, height, kBGRA_8888_SkColorType, kUnpremul_SkAlphaType, sRGB);
   size_t dstRowBytes = dstInfo.minRowBytes();
   auto length = dstInfo.computeMinByteSize();

   uint32_t * dst = new SkColor[length];
   bitmap.readPixels(dstInfo, dst, dstRowBytes, 0, 0);

   jintArray array = env->NewIntArray(length);
   env->SetIntArrayRegion(array, 0, length, reinterpret_cast<const jint *>(dst));
   delete[] dst;
   return array;
}
источник

MG

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

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
also how does Flutter draw at 60FPS using Skia? as i can only draw with ~200ms draw time due to reading the pixels from native bitmap so i can draw them using Java bitmap + canvas

as i doubt that it uses GL surface view's since (from my experience) they contain an internal OS memory leak on Surface View visibility change
источник

DG

Dmitry Gordin in Android NDK (C++) — русскоговорящее сообщество
ofcourse they DON’T use bitmaps to transfer image!
it renders directly to SurfaceView proof
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
Matthew Good
also how does Flutter draw at 60FPS using Skia? as i can only draw with ~200ms draw time due to reading the pixels from native bitmap so i can draw them using Java bitmap + canvas

as i doubt that it uses GL surface view's since (from my experience) they contain an internal OS memory leak on Surface View visibility change
welp, Surface view DOES NOT leak memory
источник

MG

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

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
this continually adds and remove the gl surface view to the hierarchy, resulting in constant GL creation and destruction

there are no observable memory leaks in the android studio profiler :)
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
which means there must be a leak in my VSTDEMO's Vst system
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
(or in the gl code itself, since im using gles 3 and the manager uses GLES CM 1.1 but im gonna rule that out since gles3 works with no memory leaks so i assume that ES 1 through 3.2 also work with no memory leaks (provided proper initialization and deinitialization of the GL context))
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
so yay i can have 3d views, and fk there are memory leaks in my vst manager ;-;
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
(which i have abandoned for like a year because of the leaks which i thought where originating from android's internal framework and thus ventured out to create an Android Compositor to try to work around this)
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
so rip i wasted a year ;-;
источник

MG

Matthew Good in Android NDK (C++) — русскоговорящее сообщество
but hey, i finally now that the leaks are from my vst system itself and not android OS nor opengl

and i now know that i need to redesign my vst manager in a way that does not produce leaks
источник