Java Code Examples for sun.java2d.d3d.D3DSurfaceData.D3DWindowSurfaceData#getBounds()

The following examples show how to use sun.java2d.d3d.D3DSurfaceData.D3DWindowSurfaceData#getBounds() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: D3DScreenUpdateManager.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    while (!done) {
        synchronized (runLock) {
            // If the list is empty, suspend the thread until a
            // new surface is added. Note that we have to check before
            // wait() (and inside the runLock), otherwise we could miss a
            // notify() when a new surface is added and sleep forever.
            long timeout = d3dwSurfaces.size() > 0 ? 100 : 0;

            // don't go to sleep if there's a thread waiting for an update
            if (!needsUpdateNow) {
                try { runLock.wait(timeout); }
                    catch (InterruptedException e) {}
            }
            // if we were woken up, there are probably surfaces in the list,
            // no need to check if the list is empty
        }

        // make a copy to avoid synchronization during the loop
        D3DWindowSurfaceData surfaces[] = new D3DWindowSurfaceData[] {};
        synchronized (this) {
            surfaces = d3dwSurfaces.toArray(surfaces);
        }
        for (D3DWindowSurfaceData sd : surfaces) {
            // skip invalid surfaces (they could have become invalid
            // after we made a copy of the list) - just a precaution
            if (sd.isValid() && (sd.isDirty() || sd.isSurfaceLost())) {
                if (!sd.isSurfaceLost()) {
                    // the flip and the clearing of the dirty state
                    // must be done under the lock, otherwise it's
                    // possible to miss an update to the surface
                    D3DRenderQueue rq = D3DRenderQueue.getInstance();
                    rq.lock();
                    try {
                        Rectangle r = sd.getBounds();
                        D3DSurfaceData.swapBuffers(sd, 0, 0,
                                                   r.width, r.height);
                        sd.markClean();
                    } finally {
                        rq.unlock();
                    }
                } else if (!validate(sd)) {
                    // it is possible that the validation may never
                    // succeed, we need to detect this and replace
                    // the d3dw surface with gdi; the replacement of
                    // the surface will also trigger a repaint
                    sd.getPeer().replaceSurfaceDataLater();
                }
            }
        }
        synchronized (runLock) {
            needsUpdateNow = false;
            runLock.notifyAll();
        }
    }
}
 
Example 2
Source File: D3DScreenUpdateManager.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    while (!done) {
        synchronized (runLock) {
            // If the list is empty, suspend the thread until a
            // new surface is added. Note that we have to check before
            // wait() (and inside the runLock), otherwise we could miss a
            // notify() when a new surface is added and sleep forever.
            long timeout = d3dwSurfaces.size() > 0 ? 100 : 0;

            // don't go to sleep if there's a thread waiting for an update
            if (!needsUpdateNow) {
                try { runLock.wait(timeout); }
                    catch (InterruptedException e) {}
            }
            // if we were woken up, there are probably surfaces in the list,
            // no need to check if the list is empty
        }

        // make a copy to avoid synchronization during the loop
        D3DWindowSurfaceData surfaces[] = new D3DWindowSurfaceData[] {};
        synchronized (this) {
            surfaces = d3dwSurfaces.toArray(surfaces);
        }
        for (D3DWindowSurfaceData sd : surfaces) {
            // skip invalid surfaces (they could have become invalid
            // after we made a copy of the list) - just a precaution
            if (sd.isValid() && (sd.isDirty() || sd.isSurfaceLost())) {
                if (!sd.isSurfaceLost()) {
                    // the flip and the clearing of the dirty state
                    // must be done under the lock, otherwise it's
                    // possible to miss an update to the surface
                    D3DRenderQueue rq = D3DRenderQueue.getInstance();
                    rq.lock();
                    try {
                        Rectangle r = sd.getBounds();
                        D3DSurfaceData.swapBuffers(sd, 0, 0,
                                                   r.width, r.height);
                        sd.markClean();
                    } finally {
                        rq.unlock();
                    }
                } else if (!validate(sd)) {
                    // it is possible that the validation may never
                    // succeed, we need to detect this and replace
                    // the d3dw surface with gdi; the replacement of
                    // the surface will also trigger a repaint
                    sd.getPeer().replaceSurfaceDataLater();
                }
            }
        }
        synchronized (runLock) {
            needsUpdateNow = false;
            runLock.notifyAll();
        }
    }
}
 
Example 3
Source File: D3DScreenUpdateManager.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    while (!done) {
        synchronized (runLock) {
            // If the list is empty, suspend the thread until a
            // new surface is added. Note that we have to check before
            // wait() (and inside the runLock), otherwise we could miss a
            // notify() when a new surface is added and sleep forever.
            long timeout = d3dwSurfaces.size() > 0 ? 100 : 0;

            // don't go to sleep if there's a thread waiting for an update
            if (!needsUpdateNow) {
                try { runLock.wait(timeout); }
                    catch (InterruptedException e) {}
            }
            // if we were woken up, there are probably surfaces in the list,
            // no need to check if the list is empty
        }

        // make a copy to avoid synchronization during the loop
        D3DWindowSurfaceData surfaces[] = new D3DWindowSurfaceData[] {};
        synchronized (this) {
            surfaces = d3dwSurfaces.toArray(surfaces);
        }
        for (D3DWindowSurfaceData sd : surfaces) {
            // skip invalid surfaces (they could have become invalid
            // after we made a copy of the list) - just a precaution
            if (sd.isValid() && (sd.isDirty() || sd.isSurfaceLost())) {
                if (!sd.isSurfaceLost()) {
                    // the flip and the clearing of the dirty state
                    // must be done under the lock, otherwise it's
                    // possible to miss an update to the surface
                    D3DRenderQueue rq = D3DRenderQueue.getInstance();
                    rq.lock();
                    try {
                        Rectangle r = sd.getBounds();
                        D3DSurfaceData.swapBuffers(sd, 0, 0,
                                                   r.width, r.height);
                        sd.markClean();
                    } finally {
                        rq.unlock();
                    }
                } else if (!validate(sd)) {
                    // it is possible that the validation may never
                    // succeed, we need to detect this and replace
                    // the d3dw surface with gdi; the replacement of
                    // the surface will also trigger a repaint
                    sd.getPeer().replaceSurfaceDataLater();
                }
            }
        }
        synchronized (runLock) {
            needsUpdateNow = false;
            runLock.notifyAll();
        }
    }
}
 
Example 4
Source File: D3DScreenUpdateManager.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    while (!done) {
        synchronized (runLock) {
            // If the list is empty, suspend the thread until a
            // new surface is added. Note that we have to check before
            // wait() (and inside the runLock), otherwise we could miss a
            // notify() when a new surface is added and sleep forever.
            long timeout = d3dwSurfaces.size() > 0 ? 100 : 0;

            // don't go to sleep if there's a thread waiting for an update
            if (!needsUpdateNow) {
                try { runLock.wait(timeout); }
                    catch (InterruptedException e) {}
            }
            // if we were woken up, there are probably surfaces in the list,
            // no need to check if the list is empty
        }

        // make a copy to avoid synchronization during the loop
        D3DWindowSurfaceData surfaces[] = new D3DWindowSurfaceData[] {};
        synchronized (this) {
            surfaces = d3dwSurfaces.toArray(surfaces);
        }
        for (D3DWindowSurfaceData sd : surfaces) {
            // skip invalid surfaces (they could have become invalid
            // after we made a copy of the list) - just a precaution
            if (sd.isValid() && (sd.isDirty() || sd.isSurfaceLost())) {
                if (!sd.isSurfaceLost()) {
                    // the flip and the clearing of the dirty state
                    // must be done under the lock, otherwise it's
                    // possible to miss an update to the surface
                    D3DRenderQueue rq = D3DRenderQueue.getInstance();
                    rq.lock();
                    try {
                        Rectangle r = sd.getBounds();
                        D3DSurfaceData.swapBuffers(sd, 0, 0,
                                                   r.width, r.height);
                        sd.markClean();
                    } finally {
                        rq.unlock();
                    }
                } else if (!validate(sd)) {
                    // it is possible that the validation may never
                    // succeed, we need to detect this and replace
                    // the d3dw surface with gdi; the replacement of
                    // the surface will also trigger a repaint
                    sd.getPeer().replaceSurfaceDataLater();
                }
            }
        }
        synchronized (runLock) {
            needsUpdateNow = false;
            runLock.notifyAll();
        }
    }
}
 
Example 5
Source File: D3DScreenUpdateManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    while (!done) {
        synchronized (runLock) {
            // If the list is empty, suspend the thread until a
            // new surface is added. Note that we have to check before
            // wait() (and inside the runLock), otherwise we could miss a
            // notify() when a new surface is added and sleep forever.
            long timeout = d3dwSurfaces.size() > 0 ? 100 : 0;

            // don't go to sleep if there's a thread waiting for an update
            if (!needsUpdateNow) {
                try { runLock.wait(timeout); }
                    catch (InterruptedException e) {}
            }
            // if we were woken up, there are probably surfaces in the list,
            // no need to check if the list is empty
        }

        // make a copy to avoid synchronization during the loop
        D3DWindowSurfaceData surfaces[] = new D3DWindowSurfaceData[] {};
        synchronized (this) {
            surfaces = d3dwSurfaces.toArray(surfaces);
        }
        for (D3DWindowSurfaceData sd : surfaces) {
            // skip invalid surfaces (they could have become invalid
            // after we made a copy of the list) - just a precaution
            if (sd.isValid() && (sd.isDirty() || sd.isSurfaceLost())) {
                if (!sd.isSurfaceLost()) {
                    // the flip and the clearing of the dirty state
                    // must be done under the lock, otherwise it's
                    // possible to miss an update to the surface
                    D3DRenderQueue rq = D3DRenderQueue.getInstance();
                    rq.lock();
                    try {
                        Rectangle r = sd.getBounds();
                        D3DSurfaceData.swapBuffers(sd, 0, 0,
                                                   r.width, r.height);
                        sd.markClean();
                    } finally {
                        rq.unlock();
                    }
                } else if (!validate(sd)) {
                    // it is possible that the validation may never
                    // succeed, we need to detect this and replace
                    // the d3dw surface with gdi; the replacement of
                    // the surface will also trigger a repaint
                    sd.getPeer().replaceSurfaceDataLater();
                }
            }
        }
        synchronized (runLock) {
            needsUpdateNow = false;
            runLock.notifyAll();
        }
    }
}
 
Example 6
Source File: D3DScreenUpdateManager.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    while (!done) {
        synchronized (runLock) {
            // If the list is empty, suspend the thread until a
            // new surface is added. Note that we have to check before
            // wait() (and inside the runLock), otherwise we could miss a
            // notify() when a new surface is added and sleep forever.
            long timeout = d3dwSurfaces.size() > 0 ? 100 : 0;

            // don't go to sleep if there's a thread waiting for an update
            if (!needsUpdateNow) {
                try { runLock.wait(timeout); }
                    catch (InterruptedException e) {}
            }
            // if we were woken up, there are probably surfaces in the list,
            // no need to check if the list is empty
        }

        // make a copy to avoid synchronization during the loop
        D3DWindowSurfaceData surfaces[] = new D3DWindowSurfaceData[] {};
        synchronized (this) {
            surfaces = d3dwSurfaces.toArray(surfaces);
        }
        for (D3DWindowSurfaceData sd : surfaces) {
            // skip invalid surfaces (they could have become invalid
            // after we made a copy of the list) - just a precaution
            if (sd.isValid() && (sd.isDirty() || sd.isSurfaceLost())) {
                if (!sd.isSurfaceLost()) {
                    // the flip and the clearing of the dirty state
                    // must be done under the lock, otherwise it's
                    // possible to miss an update to the surface
                    D3DRenderQueue rq = D3DRenderQueue.getInstance();
                    rq.lock();
                    try {
                        Rectangle r = sd.getBounds();
                        D3DSurfaceData.swapBuffers(sd, 0, 0,
                                                   r.width, r.height);
                        sd.markClean();
                    } finally {
                        rq.unlock();
                    }
                } else if (!validate(sd)) {
                    // it is possible that the validation may never
                    // succeed, we need to detect this and replace
                    // the d3dw surface with gdi; the replacement of
                    // the surface will also trigger a repaint
                    sd.getPeer().replaceSurfaceDataLater();
                }
            }
        }
        synchronized (runLock) {
            needsUpdateNow = false;
            runLock.notifyAll();
        }
    }
}
 
Example 7
Source File: D3DScreenUpdateManager.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    while (!done) {
        synchronized (runLock) {
            // If the list is empty, suspend the thread until a
            // new surface is added. Note that we have to check before
            // wait() (and inside the runLock), otherwise we could miss a
            // notify() when a new surface is added and sleep forever.
            long timeout = d3dwSurfaces.size() > 0 ? 100 : 0;

            // don't go to sleep if there's a thread waiting for an update
            if (!needsUpdateNow) {
                try { runLock.wait(timeout); }
                    catch (InterruptedException e) {}
            }
            // if we were woken up, there are probably surfaces in the list,
            // no need to check if the list is empty
        }

        // make a copy to avoid synchronization during the loop
        D3DWindowSurfaceData surfaces[] = new D3DWindowSurfaceData[] {};
        synchronized (this) {
            surfaces = d3dwSurfaces.toArray(surfaces);
        }
        for (D3DWindowSurfaceData sd : surfaces) {
            // skip invalid surfaces (they could have become invalid
            // after we made a copy of the list) - just a precaution
            if (sd.isValid() && (sd.isDirty() || sd.isSurfaceLost())) {
                if (!sd.isSurfaceLost()) {
                    // the flip and the clearing of the dirty state
                    // must be done under the lock, otherwise it's
                    // possible to miss an update to the surface
                    D3DRenderQueue rq = D3DRenderQueue.getInstance();
                    rq.lock();
                    try {
                        Rectangle r = sd.getBounds();
                        D3DSurfaceData.swapBuffers(sd, 0, 0,
                                                   r.width, r.height);
                        sd.markClean();
                    } finally {
                        rq.unlock();
                    }
                } else if (!validate(sd)) {
                    // it is possible that the validation may never
                    // succeed, we need to detect this and replace
                    // the d3dw surface with gdi; the replacement of
                    // the surface will also trigger a repaint
                    sd.getPeer().replaceSurfaceDataLater();
                }
            }
        }
        synchronized (runLock) {
            needsUpdateNow = false;
            runLock.notifyAll();
        }
    }
}
 
Example 8
Source File: D3DScreenUpdateManager.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    while (!done) {
        synchronized (runLock) {
            // If the list is empty, suspend the thread until a
            // new surface is added. Note that we have to check before
            // wait() (and inside the runLock), otherwise we could miss a
            // notify() when a new surface is added and sleep forever.
            long timeout = d3dwSurfaces.size() > 0 ? 100 : 0;

            // don't go to sleep if there's a thread waiting for an update
            if (!needsUpdateNow) {
                try { runLock.wait(timeout); }
                    catch (InterruptedException e) {}
            }
            // if we were woken up, there are probably surfaces in the list,
            // no need to check if the list is empty
        }

        // make a copy to avoid synchronization during the loop
        D3DWindowSurfaceData surfaces[] = new D3DWindowSurfaceData[] {};
        synchronized (this) {
            surfaces = d3dwSurfaces.toArray(surfaces);
        }
        for (D3DWindowSurfaceData sd : surfaces) {
            // skip invalid surfaces (they could have become invalid
            // after we made a copy of the list) - just a precaution
            if (sd.isValid() && (sd.isDirty() || sd.isSurfaceLost())) {
                if (!sd.isSurfaceLost()) {
                    // the flip and the clearing of the dirty state
                    // must be done under the lock, otherwise it's
                    // possible to miss an update to the surface
                    D3DRenderQueue rq = D3DRenderQueue.getInstance();
                    rq.lock();
                    try {
                        Rectangle r = sd.getBounds();
                        D3DSurfaceData.swapBuffers(sd, 0, 0,
                                                   r.width, r.height);
                        sd.markClean();
                    } finally {
                        rq.unlock();
                    }
                } else if (!validate(sd)) {
                    // it is possible that the validation may never
                    // succeed, we need to detect this and replace
                    // the d3dw surface with gdi; the replacement of
                    // the surface will also trigger a repaint
                    sd.getPeer().replaceSurfaceDataLater();
                }
            }
        }
        synchronized (runLock) {
            needsUpdateNow = false;
            runLock.notifyAll();
        }
    }
}
 
Example 9
Source File: D3DScreenUpdateManager.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    while (!done) {
        synchronized (runLock) {
            // If the list is empty, suspend the thread until a
            // new surface is added. Note that we have to check before
            // wait() (and inside the runLock), otherwise we could miss a
            // notify() when a new surface is added and sleep forever.
            long timeout = d3dwSurfaces.size() > 0 ? 100 : 0;

            // don't go to sleep if there's a thread waiting for an update
            if (!needsUpdateNow) {
                try { runLock.wait(timeout); }
                    catch (InterruptedException e) {}
            }
            // if we were woken up, there are probably surfaces in the list,
            // no need to check if the list is empty
        }

        // make a copy to avoid synchronization during the loop
        D3DWindowSurfaceData surfaces[] = new D3DWindowSurfaceData[] {};
        synchronized (this) {
            surfaces = d3dwSurfaces.toArray(surfaces);
        }
        for (D3DWindowSurfaceData sd : surfaces) {
            // skip invalid surfaces (they could have become invalid
            // after we made a copy of the list) - just a precaution
            if (sd.isValid() && (sd.isDirty() || sd.isSurfaceLost())) {
                if (!sd.isSurfaceLost()) {
                    // the flip and the clearing of the dirty state
                    // must be done under the lock, otherwise it's
                    // possible to miss an update to the surface
                    D3DRenderQueue rq = D3DRenderQueue.getInstance();
                    rq.lock();
                    try {
                        Rectangle r = sd.getBounds();
                        D3DSurfaceData.swapBuffers(sd, 0, 0,
                                                   r.width, r.height);
                        sd.markClean();
                    } finally {
                        rq.unlock();
                    }
                } else if (!validate(sd)) {
                    // it is possible that the validation may never
                    // succeed, we need to detect this and replace
                    // the d3dw surface with gdi; the replacement of
                    // the surface will also trigger a repaint
                    sd.getPeer().replaceSurfaceDataLater();
                }
            }
        }
        synchronized (runLock) {
            needsUpdateNow = false;
            runLock.notifyAll();
        }
    }
}
 
Example 10
Source File: D3DScreenUpdateManager.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    while (!done) {
        synchronized (runLock) {
            // If the list is empty, suspend the thread until a
            // new surface is added. Note that we have to check before
            // wait() (and inside the runLock), otherwise we could miss a
            // notify() when a new surface is added and sleep forever.
            long timeout = d3dwSurfaces.size() > 0 ? 100 : 0;

            // don't go to sleep if there's a thread waiting for an update
            if (!needsUpdateNow) {
                try { runLock.wait(timeout); }
                    catch (InterruptedException e) {}
            }
            // if we were woken up, there are probably surfaces in the list,
            // no need to check if the list is empty
        }

        // make a copy to avoid synchronization during the loop
        D3DWindowSurfaceData surfaces[] = new D3DWindowSurfaceData[] {};
        synchronized (this) {
            surfaces = d3dwSurfaces.toArray(surfaces);
        }
        for (D3DWindowSurfaceData sd : surfaces) {
            // skip invalid surfaces (they could have become invalid
            // after we made a copy of the list) - just a precaution
            if (sd.isValid() && (sd.isDirty() || sd.isSurfaceLost())) {
                if (!sd.isSurfaceLost()) {
                    // the flip and the clearing of the dirty state
                    // must be done under the lock, otherwise it's
                    // possible to miss an update to the surface
                    D3DRenderQueue rq = D3DRenderQueue.getInstance();
                    rq.lock();
                    try {
                        Rectangle r = sd.getBounds();
                        D3DSurfaceData.swapBuffers(sd, 0, 0,
                                                   r.width, r.height);
                        sd.markClean();
                    } finally {
                        rq.unlock();
                    }
                } else if (!validate(sd)) {
                    // it is possible that the validation may never
                    // succeed, we need to detect this and replace
                    // the d3dw surface with gdi; the replacement of
                    // the surface will also trigger a repaint
                    sd.getPeer().replaceSurfaceDataLater();
                }
            }
        }
        synchronized (runLock) {
            needsUpdateNow = false;
            runLock.notifyAll();
        }
    }
}
 
Example 11
Source File: D3DScreenUpdateManager.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    while (!done) {
        synchronized (runLock) {
            // If the list is empty, suspend the thread until a
            // new surface is added. Note that we have to check before
            // wait() (and inside the runLock), otherwise we could miss a
            // notify() when a new surface is added and sleep forever.
            long timeout = d3dwSurfaces.size() > 0 ? 100 : 0;

            // don't go to sleep if there's a thread waiting for an update
            if (!needsUpdateNow) {
                try { runLock.wait(timeout); }
                    catch (InterruptedException e) {}
            }
            // if we were woken up, there are probably surfaces in the list,
            // no need to check if the list is empty
        }

        // make a copy to avoid synchronization during the loop
        D3DWindowSurfaceData surfaces[] = new D3DWindowSurfaceData[] {};
        synchronized (this) {
            surfaces = d3dwSurfaces.toArray(surfaces);
        }
        for (D3DWindowSurfaceData sd : surfaces) {
            // skip invalid surfaces (they could have become invalid
            // after we made a copy of the list) - just a precaution
            if (sd.isValid() && (sd.isDirty() || sd.isSurfaceLost())) {
                if (!sd.isSurfaceLost()) {
                    // the flip and the clearing of the dirty state
                    // must be done under the lock, otherwise it's
                    // possible to miss an update to the surface
                    D3DRenderQueue rq = D3DRenderQueue.getInstance();
                    rq.lock();
                    try {
                        Rectangle r = sd.getBounds();
                        D3DSurfaceData.swapBuffers(sd, 0, 0,
                                                   r.width, r.height);
                        sd.markClean();
                    } finally {
                        rq.unlock();
                    }
                } else if (!validate(sd)) {
                    // it is possible that the validation may never
                    // succeed, we need to detect this and replace
                    // the d3dw surface with gdi; the replacement of
                    // the surface will also trigger a repaint
                    sd.getPeer().replaceSurfaceDataLater();
                }
            }
        }
        synchronized (runLock) {
            needsUpdateNow = false;
            runLock.notifyAll();
        }
    }
}
 
Example 12
Source File: D3DScreenUpdateManager.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    while (!done) {
        synchronized (runLock) {
            // If the list is empty, suspend the thread until a
            // new surface is added. Note that we have to check before
            // wait() (and inside the runLock), otherwise we could miss a
            // notify() when a new surface is added and sleep forever.
            long timeout = d3dwSurfaces.size() > 0 ? 100 : 0;

            // don't go to sleep if there's a thread waiting for an update
            if (!needsUpdateNow) {
                try { runLock.wait(timeout); }
                    catch (InterruptedException e) {}
            }
            // if we were woken up, there are probably surfaces in the list,
            // no need to check if the list is empty
        }

        // make a copy to avoid synchronization during the loop
        D3DWindowSurfaceData surfaces[] = new D3DWindowSurfaceData[] {};
        synchronized (this) {
            surfaces = d3dwSurfaces.toArray(surfaces);
        }
        for (D3DWindowSurfaceData sd : surfaces) {
            // skip invalid surfaces (they could have become invalid
            // after we made a copy of the list) - just a precaution
            if (sd.isValid() && (sd.isDirty() || sd.isSurfaceLost())) {
                if (!sd.isSurfaceLost()) {
                    // the flip and the clearing of the dirty state
                    // must be done under the lock, otherwise it's
                    // possible to miss an update to the surface
                    D3DRenderQueue rq = D3DRenderQueue.getInstance();
                    rq.lock();
                    try {
                        Rectangle r = sd.getBounds();
                        D3DSurfaceData.swapBuffers(sd, 0, 0,
                                                   r.width, r.height);
                        sd.markClean();
                    } finally {
                        rq.unlock();
                    }
                } else if (!validate(sd)) {
                    // it is possible that the validation may never
                    // succeed, we need to detect this and replace
                    // the d3dw surface with gdi; the replacement of
                    // the surface will also trigger a repaint
                    sd.getPeer().replaceSurfaceDataLater();
                }
            }
        }
        synchronized (runLock) {
            needsUpdateNow = false;
            runLock.notifyAll();
        }
    }
}
 
Example 13
Source File: D3DScreenUpdateManager.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    while (!done) {
        synchronized (runLock) {
            // If the list is empty, suspend the thread until a
            // new surface is added. Note that we have to check before
            // wait() (and inside the runLock), otherwise we could miss a
            // notify() when a new surface is added and sleep forever.
            long timeout = d3dwSurfaces.size() > 0 ? 100 : 0;

            // don't go to sleep if there's a thread waiting for an update
            if (!needsUpdateNow) {
                try { runLock.wait(timeout); }
                    catch (InterruptedException e) {}
            }
            // if we were woken up, there are probably surfaces in the list,
            // no need to check if the list is empty
        }

        // make a copy to avoid synchronization during the loop
        D3DWindowSurfaceData surfaces[] = new D3DWindowSurfaceData[] {};
        synchronized (this) {
            surfaces = d3dwSurfaces.toArray(surfaces);
        }
        for (D3DWindowSurfaceData sd : surfaces) {
            // skip invalid surfaces (they could have become invalid
            // after we made a copy of the list) - just a precaution
            if (sd.isValid() && (sd.isDirty() || sd.isSurfaceLost())) {
                if (!sd.isSurfaceLost()) {
                    // the flip and the clearing of the dirty state
                    // must be done under the lock, otherwise it's
                    // possible to miss an update to the surface
                    D3DRenderQueue rq = D3DRenderQueue.getInstance();
                    rq.lock();
                    try {
                        Rectangle r = sd.getBounds();
                        D3DSurfaceData.swapBuffers(sd, 0, 0,
                                                   r.width, r.height);
                        sd.markClean();
                    } finally {
                        rq.unlock();
                    }
                } else if (!validate(sd)) {
                    // it is possible that the validation may never
                    // succeed, we need to detect this and replace
                    // the d3dw surface with gdi; the replacement of
                    // the surface will also trigger a repaint
                    sd.getPeer().replaceSurfaceDataLater();
                }
            }
        }
        synchronized (runLock) {
            needsUpdateNow = false;
            runLock.notifyAll();
        }
    }
}