summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java
blob: 475906c81ec06c099ba758bb24f3020f6340c81f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.android.gallery3d.ui;

import com.android.gallery3d.ui.GLRoot.OnGLIdleListener;

public class PreparePageFadeoutTexture implements OnGLIdleListener {
    private RawTexture mTexture;
    private boolean mResultReady = false;
    private GLView mRootPane;

    public PreparePageFadeoutTexture(int w, int h,  GLView rootPane) {
        mTexture = new RawTexture(w, h, true);
        mRootPane =  rootPane;
    }

    public synchronized RawTexture get() {
        try {
            while (!mResultReady) {
                wait();
            }
        } catch (InterruptedException e) {
            // Since this is just used for a transition, not that important
        }
        return mTexture;
    }

    @Override
    public boolean onGLIdle(GLCanvas canvas, boolean renderRequested) {
            canvas.beginRenderTarget(mTexture);
            mRootPane.render(canvas);
            canvas.endRenderTarget();
            synchronized (this) {
                mResultReady = true;
                notifyAll();
            }
            return false;
    }
}