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

Commit 6b39324d authored by John Reck's avatar John Reck Committed by Android (Google) Code Review
Browse files

Merge "No-fail invokeFunctor"

parents 287c0361 3b20251a
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -386,17 +386,6 @@ public abstract class HardwareRenderer {

    abstract boolean copyLayerInto(HardwareLayer layer, Bitmap bitmap);

    /**
     * Schedules the functor for execution in either kModeProcess or
     * kModeProcessNoContext, depending on whether or not there is an EGLContext.
     *
     * @param functor The native functor to invoke
     * @param waitForCompletion If true, this will not return until the functor
     *                          has invoked. If false, the functor may be invoked
     *                          asynchronously.
     */
    abstract void invokeFunctor(long functor, boolean waitForCompletion);

    /**
     * Initializes the hardware renderer for the specified surface and setup the
     * renderer for drawing, if needed. This is invoked when the ViewAncestor has
+8 −9
Original line number Diff line number Diff line
@@ -80,13 +80,13 @@ public class ThreadedRenderer extends HardwareRenderer {
    private boolean mProfilingEnabled;

    ThreadedRenderer(Context context, boolean translucent) {
        AtlasInitializer.sInstance.init(context);

        long rootNodePtr = nCreateRootRenderNode();
        mRootNode = RenderNode.adopt(rootNodePtr);
        mRootNode.setClipToBounds(false);
        mNativeProxy = nCreateProxy(translucent, rootNodePtr);

        AtlasInitializer.sInstance.init(context, mNativeProxy);

        // Setup timing
        mChoreographer = Choreographer.getInstance();
        nSetFrameInterval(mNativeProxy, mChoreographer.getFrameIntervalNanos());
@@ -259,9 +259,8 @@ public class ThreadedRenderer extends HardwareRenderer {
        }
    }

    @Override
    void invokeFunctor(long functor, boolean waitForCompletion) {
        nInvokeFunctor(mNativeProxy, functor, waitForCompletion);
    static void invokeFunctor(long functor, boolean waitForCompletion) {
        nInvokeFunctor(functor, waitForCompletion);
    }

    @Override
@@ -342,7 +341,7 @@ public class ThreadedRenderer extends HardwareRenderer {

        private AtlasInitializer() {}

        synchronized void init(Context context) {
        synchronized void init(Context context, long renderProxy) {
            if (mInitialized) return;
            IBinder binder = ServiceManager.getService("assetatlas");
            if (binder == null) return;
@@ -356,7 +355,7 @@ public class ThreadedRenderer extends HardwareRenderer {
                        if (map != null) {
                            // TODO Remove after fixing b/15425820
                            validateMap(context, map);
                            nSetAtlas(buffer, map);
                            nSetAtlas(renderProxy, buffer, map);
                            mInitialized = true;
                        }
                        // If IAssetAtlas is not the same class as the IBinder
@@ -399,7 +398,7 @@ public class ThreadedRenderer extends HardwareRenderer {

    static native void setupShadersDiskCache(String cacheFile);

    private static native void nSetAtlas(GraphicBuffer buffer, long[] map);
    private static native void nSetAtlas(long nativeProxy, GraphicBuffer buffer, long[] map);

    private static native long nCreateRootRenderNode();
    private static native long nCreateProxy(boolean translucent, long rootRenderNode);
@@ -419,7 +418,7 @@ public class ThreadedRenderer extends HardwareRenderer {
    private static native void nRunWithGlContext(long nativeProxy, Runnable runnable);
    private static native void nDestroyCanvasAndSurface(long nativeProxy);

    private static native void nInvokeFunctor(long nativeProxy, long functor, boolean waitForCompletion);
    private static native void nInvokeFunctor(long functor, boolean waitForCompletion);

    private static native long nCreateDisplayListLayer(long nativeProxy, int width, int height);
    private static native long nCreateTextureLayer(long nativeProxy);
+12 −4
Original line number Diff line number Diff line
@@ -661,11 +661,19 @@ public final class ViewRootImpl implements ViewParent,
        }
    }

    /**
     * Schedules the functor for execution in either kModeProcess or
     * kModeProcessNoContext, depending on whether or not there is an EGLContext.
     *
     * @param functor The native functor to invoke
     * @param waitForCompletion If true, this will not return until the functor
     *                          has invoked. If false, the functor may be invoked
     *                          asynchronously.
     */
    public boolean invokeFunctor(long functor, boolean waitForCompletion) {
        if (mAttachInfo.mHardwareRenderer == null) {
            return false;
        }
        mAttachInfo.mHardwareRenderer.invokeFunctor(functor, waitForCompletion);
        ThreadedRenderer.invokeFunctor(functor, waitForCompletion);
        // TODO: Remove the return value. This is here for compatibility
        // with current webview, which expects a boolean
        return true;
    }

+64 −72

File changed.

Preview size limit exceeded, changes collapsed.

+7 −28
Original line number Diff line number Diff line
@@ -76,26 +76,6 @@ private:
    jobject mRunnable;
};

class SetAtlasTask : public RenderTask {
public:
    SetAtlasTask(const sp<GraphicBuffer>& buffer, int64_t* map, size_t size)
            : mBuffer(buffer)
            , mMap(map)
            , mMapSize(size) {
    }

    virtual void run() {
        CanvasContext::setTextureAtlas(mBuffer, mMap, mMapSize);
        mMap = 0;
        delete this;
    }

private:
    sp<GraphicBuffer> mBuffer;
    int64_t* mMap;
    size_t mMapSize;
};

class OnFinishedEvent {
public:
    OnFinishedEvent(BaseRenderNodeAnimator* animator, AnimationListener* listener)
@@ -193,7 +173,7 @@ private:
};

static void android_view_ThreadedRenderer_setAtlas(JNIEnv* env, jobject clazz,
        jobject graphicBuffer, jlongArray atlasMapArray) {
        jlong proxyPtr, jobject graphicBuffer, jlongArray atlasMapArray) {
    sp<GraphicBuffer> buffer = graphicBufferForJavaObject(env, graphicBuffer);
    jsize len = env->GetArrayLength(atlasMapArray);
    if (len <= 0) {
@@ -203,8 +183,8 @@ static void android_view_ThreadedRenderer_setAtlas(JNIEnv* env, jobject clazz,
    int64_t* map = new int64_t[len];
    env->GetLongArrayRegion(atlasMapArray, 0, len, map);

    SetAtlasTask* task = new SetAtlasTask(buffer, map, len);
    RenderThread::getInstance().queue(task);
    RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
    proxy->setTextureAtlas(buffer, map, len);
}

static jlong android_view_ThreadedRenderer_createRootRenderNode(JNIEnv* env, jobject clazz) {
@@ -291,10 +271,9 @@ static void android_view_ThreadedRenderer_destroyCanvasAndSurface(JNIEnv* env, j
}

static void android_view_ThreadedRenderer_invokeFunctor(JNIEnv* env, jobject clazz,
        jlong proxyPtr, jlong functorPtr, jboolean waitForCompletion) {
    RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
        jlong functorPtr, jboolean waitForCompletion) {
    Functor* functor = reinterpret_cast<Functor*>(functorPtr);
    proxy->invokeFunctor(functor, waitForCompletion);
    RenderProxy::invokeFunctor(functor, waitForCompletion);
}

static void android_view_ThreadedRenderer_runWithGlContext(JNIEnv* env, jobject clazz,
@@ -387,7 +366,7 @@ const char* const kClassPathName = "android/view/ThreadedRenderer";

static JNINativeMethod gMethods[] = {
#ifdef USE_OPENGL_RENDERER
    { "nSetAtlas", "(Landroid/view/GraphicBuffer;[J)V",   (void*) android_view_ThreadedRenderer_setAtlas },
    { "nSetAtlas", "(JLandroid/view/GraphicBuffer;[J)V",   (void*) android_view_ThreadedRenderer_setAtlas },
    { "nCreateRootRenderNode", "()J", (void*) android_view_ThreadedRenderer_createRootRenderNode },
    { "nCreateProxy", "(ZJ)J", (void*) android_view_ThreadedRenderer_createProxy },
    { "nDeleteProxy", "(J)V", (void*) android_view_ThreadedRenderer_deleteProxy },
@@ -400,7 +379,7 @@ static JNINativeMethod gMethods[] = {
    { "nSetOpaque", "(JZ)V", (void*) android_view_ThreadedRenderer_setOpaque },
    { "nSyncAndDrawFrame", "(JJJF)I", (void*) android_view_ThreadedRenderer_syncAndDrawFrame },
    { "nDestroyCanvasAndSurface", "(J)V", (void*) android_view_ThreadedRenderer_destroyCanvasAndSurface },
    { "nInvokeFunctor", "(JJZ)V", (void*) android_view_ThreadedRenderer_invokeFunctor },
    { "nInvokeFunctor", "(JZ)V", (void*) android_view_ThreadedRenderer_invokeFunctor },
    { "nRunWithGlContext", "(JLjava/lang/Runnable;)V", (void*) android_view_ThreadedRenderer_runWithGlContext },
    { "nCreateDisplayListLayer", "(JII)J", (void*) android_view_ThreadedRenderer_createDisplayListLayer },
    { "nCreateTextureLayer", "(J)J", (void*) android_view_ThreadedRenderer_createTextureLayer },
Loading