Projects >> platform_frameworks_base >>79447b2087c8c820d742185dda7305101f9656f0

Chunk
Conflicting content
             * accesses EGL.
             */
            try {
<<<<<<< HEAD
                sGLAccessLock.acquire();
=======
                try {
                    sGLThreadManager.start(this);
                } catch (InterruptedException e) {
                    return;
                }
>>>>>>> 84872738f291faf25ae07235cde382d38c796567
                guardedRun();
            } catch (InterruptedException e) {
                // fall thru and exit normally
Solution content
             * accesses EGL.
             */
            try {
                try {
                    sGLThreadManager.start(this);
                } catch (InterruptedException e) {
                    return;
                }
                guardedRun();
            } catch (InterruptedException e) {
                // fall thru and exit normally
File
GLSurfaceView.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Try statement
Chunk
Conflicting content
            } catch (InterruptedException e) {
                // fall thru and exit normally
            } finally {
<<<<<<< HEAD
                sGLAccessLock.release();
=======
                try {
                    sGLThreadManager.end(this);
                } finally {
                    synchronized(this) {
                        if (LOG_THREADS) {
                            Log.i("GLThread", "exiting tid=" +  getId());
                        }
                        mDone = true;
                        notifyAll();
                    }
                }
>>>>>>> 84872738f291faf25ae07235cde382d38c796567
            }
        }
Solution content
            } catch (InterruptedException e) {
                // fall thru and exit normally
            } finally {
                try {
                    sGLThreadManager.end(this);
                } finally {
                    synchronized(this) {
                        if (LOG_THREADS) {
                            Log.i("GLThread", "exiting tid=" +  getId());
                        }
                        mDone = true;
                        notifyAll();
                    }
                }
            }
        }
File
GLSurfaceView.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Try statement
Chunk
Conflicting content
        }
    }

<<<<<<< HEAD
    private static class GLAccessLock {
        public synchronized void acquire() throws InterruptedException {
            if (! mGLESVersionCheckComplete) {
                mGLESVersion = SystemProperties.getInt(
                        "ro.opengles.version",
                        ConfigurationInfo.GL_ES_VERSION_UNDEFINED);
                if (mGLESVersion >= kGLES_20) {
                    mMultipleGLESContextsAllowed = true;
                }
                mGLESVersionCheckComplete = true;
            }

            while ((! mMultipleGLESContextsAllowed)
                    && mGLContextCount > 0) {
                wait();
            }

            mGLContextCount++;

        }

        public synchronized void release() {
            mGLContextCount--;
            notifyAll();
        }

        public synchronized void checkGLDriver(GL10 gl) {
            if (! mGLESDriverCheckComplete) {
                if (mGLESVersion < kGLES_20) {
                    String renderer = gl.glGetString(GL10.GL_RENDERER);
                    mMultipleGLESContextsAllowed =
                        ! renderer.startsWith(kMSM7K_RENDERER_PREFIX);
                    notifyAll();
                }
                mGLESDriverCheckComplete = true;
            }
        }

        private boolean mGLESVersionCheckComplete;
        private int mGLESVersion;
        private boolean mGLESDriverCheckComplete;
        private boolean mMultipleGLESContextsAllowed;
        private int mGLContextCount;
        private static final int kGLES_20 = 0x20000;
        private static final String kMSM7K_RENDERER_PREFIX =
            "Q3Dimension MSM7500 ";
    };

    private static GLAccessLock sGLAccessLock = new GLAccessLock();

=======
    static class GLThreadManager {
        public boolean shouldQuit(GLThread thread) {
            synchronized(this) {
                return thread != mMostRecentGLThread;
            }
        }
        public void start(GLThread thread) throws InterruptedException {
            GLThread oldThread = null;
            synchronized(this) {
                mMostRecentGLThread = thread;
                oldThread = mMostRecentGLThread;
            }
            if (oldThread != null) {
                synchronized(oldThread) {
                    oldThread.notifyAll();
                }
            }
            sEglSemaphore.acquire();
        }
        public void end(GLThread thread) {
            sEglSemaphore.release();
            synchronized(this) {
                if (mMostRecentGLThread == thread) {
                    mMostRecentGLThread = null;
                }
            }
        }
        private GLThread mMostRecentGLThread;
    }

    private static final Semaphore sEglSemaphore = new Semaphore(1);
    private static final GLThreadManager sGLThreadManager = new GLThreadManager();
>>>>>>> 84872738f291faf25ae07235cde382d38c796567
    private boolean mSizeChanged = true;

    private GLThread mGLThread;
Solution content
        }
    }

    private static class GLThreadManager {
        public void start(GLThread thread) throws InterruptedException {
           if (! mGLESVersionCheckComplete) {
                mGLESVersion = SystemProperties.getInt(
                        "ro.opengles.version",
                        ConfigurationInfo.GL_ES_VERSION_UNDEFINED);
                if (mGLESVersion >= kGLES_20) {
                    mMultipleGLESContextsAllowed = true;
                }
                mGLESVersionCheckComplete = true;
            }

            GLThread oldThread = null;
            synchronized(this) {
                mMostRecentGLThread = thread;
                oldThread = mMostRecentGLThread;

                while ((! mMultipleGLESContextsAllowed)
                        && mGLContextCount > 0) {
                    wait();
                }

                mGLContextCount++;
            }

            if (oldThread != null && ! mMultipleGLESContextsAllowed) {
                synchronized(oldThread) {
                    oldThread.notifyAll();
                }
            }
        }

        public synchronized void end(GLThread thread) {
            mGLContextCount--;
            notifyAll();
            if (mMostRecentGLThread == thread) {
                mMostRecentGLThread = null;
            }
        }

        public synchronized void checkGLDriver(GL10 gl) {
            if (! mGLESDriverCheckComplete) {
                if (mGLESVersion < kGLES_20) {
                    String renderer = gl.glGetString(GL10.GL_RENDERER);
                    mMultipleGLESContextsAllowed =
                        ! renderer.startsWith(kMSM7K_RENDERER_PREFIX);
                    notifyAll();
                }
                mGLESDriverCheckComplete = true;
            }
        }

        public boolean shouldQuit(GLThread thread) {
            synchronized(this) {
                return thread != mMostRecentGLThread;
            }
        }

        private boolean mGLESVersionCheckComplete;
        private int mGLESVersion;
        private GLThread mMostRecentGLThread;
        private boolean mGLESDriverCheckComplete;
        private boolean mMultipleGLESContextsAllowed;
        private int mGLContextCount;
        private static final int kGLES_20 = 0x20000;
        private static final String kMSM7K_RENDERER_PREFIX =
            "Q3Dimension MSM7500 ";
    };

    private static final GLThreadManager sGLThreadManager = new GLThreadManager();
    private boolean mSizeChanged = true;

    private GLThread mGLThread;
File
GLSurfaceView.java
Developer's decision
Manual
Kind of conflict
Attribute
Class declaration
Method invocation