Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cfde87ba authored by Andreas Huber's avatar Andreas Huber
Browse files

Use physical memory for software rendering to take a fast path through surface flinger if possible.

related-to-bug: 2386023
parent 3ff37c1d
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include "../include/SoftwareRenderer.h"

#include <binder/MemoryHeapBase.h>
#include <binder/MemoryHeapPmem.h>
#include <media/stagefright/MediaDebug.h>
#include <ui/ISurface.h>

@@ -38,8 +39,16 @@ SoftwareRenderer::SoftwareRenderer(
      mDecodedWidth(decodedWidth),
      mDecodedHeight(decodedHeight),
      mFrameSize(mDecodedWidth * mDecodedHeight * 2),  // RGB565
      mMemoryHeap(new MemoryHeapBase(2 * mFrameSize)),
      mIndex(0) {
    // TODO: How do I allocate physical memory on Droid?
    mMemoryHeap = new MemoryHeapBase("/dev/pmem_adsp", 2 * mFrameSize);
    if (mMemoryHeap->heapID() < 0) {
        LOGI("Creating physical memory heap failed, reverting to regular heap.");
        mMemoryHeap = new MemoryHeapBase(2 * mFrameSize);
    } else {
        mMemoryHeap = new MemoryHeapPmem(mMemoryHeap);
    }

    CHECK(mISurface.get() != NULL);
    CHECK(mDecodedWidth > 0);
    CHECK(mDecodedHeight > 0);