src/macosx/classes/sun/lwawt/LWComponentPeer.java

Print this page

        

*** 422,433 **** return false; } @Override public final Graphics getGraphics() { ! Graphics g = getWindowPeerOrSelf().isOpaque() ? getOnscreenGraphics() ! : getOffscreenGraphics(); if (g != null) { synchronized (getPeerTreeLock()){ applyConstrain(g); } } --- 422,432 ---- return false; } @Override public final Graphics getGraphics() { ! final Graphics g = getOnscreenGraphics(); if (g != null) { synchronized (getPeerTreeLock()){ applyConstrain(g); } }
*** 441,457 **** */ public final Graphics getOnscreenGraphics() { final LWWindowPeer wp = getWindowPeerOrSelf(); return wp.getOnscreenGraphics(getForeground(), getBackground(), getFont()); - } - public final Graphics getOffscreenGraphics() { - final LWWindowPeer wp = getWindowPeerOrSelf(); - - return wp.getOffscreenGraphics(getForeground(), getBackground(), - getFont()); } private void applyConstrain(final Graphics g) { final SunGraphics2D sg2d = (SunGraphics2D) g; final Rectangle constr = localToWindow(getSize()); --- 440,450 ----
*** 461,471 **** //sg2d.constrain(getVisibleRegion()); SG2DConstraint(sg2d, getVisibleRegion()); } //TODO Move this method to SG2D? ! private void SG2DConstraint(final SunGraphics2D sg2d, Region r) { sg2d.constrainX = sg2d.transX; sg2d.constrainY = sg2d.transY; Region c = sg2d.constrainClip; if ((sg2d.constrainX | sg2d.constrainY) != 0) { --- 454,464 ---- //sg2d.constrain(getVisibleRegion()); SG2DConstraint(sg2d, getVisibleRegion()); } //TODO Move this method to SG2D? ! void SG2DConstraint(final SunGraphics2D sg2d, Region r) { sg2d.constrainX = sg2d.transX; sg2d.constrainY = sg2d.transY; Region c = sg2d.constrainClip; if ((sg2d.constrainX | sg2d.constrainY) != 0) {
*** 708,718 **** // Borrow the metrics from the top-level window // return getWindowPeer().getFontMetrics(f); // Obtain the metrics from the offscreen window where this peer is // mostly drawn to. // TODO: check for "use platform metrics" settings ! Graphics g = getWindowPeer().getOffscreenGraphics(); try { if (g != null) { return g.getFontMetrics(f); } else { synchronized (getDelegateLock()) { --- 701,711 ---- // Borrow the metrics from the top-level window // return getWindowPeer().getFontMetrics(f); // Obtain the metrics from the offscreen window where this peer is // mostly drawn to. // TODO: check for "use platform metrics" settings ! Graphics g = getWindowPeer().getGraphics(); try { if (g != null) { return g.getFontMetrics(f); } else { synchronized (getDelegateLock()) {
*** 1009,1026 **** } @Override public final void applyShape(final Region shape) { synchronized (getStateLock()) { ! region = shape; } repaintParent(getBounds()); } protected final Region getRegion() { synchronized (getStateLock()) { ! return region == null ? Region.getInstance(getSize()) : region; } } // DropTargetPeer Method @Override --- 1002,1038 ---- } @Override public final void applyShape(final Region shape) { synchronized (getStateLock()) { ! if (region == shape || (region != null && region.equals(shape))) { ! return; ! } ! } ! applyShapeImpl(shape); ! } ! ! void applyShapeImpl(final Region shape) { ! synchronized (getStateLock()) { ! if (shape != null) { ! region = Region.WHOLE_REGION.getIntersection(shape); ! } else { ! region = null; ! } } repaintParent(getBounds()); } protected final Region getRegion() { synchronized (getStateLock()) { ! return isShaped() ? region : Region.getInstance(getSize()); ! } ! } ! ! public boolean isShaped() { ! synchronized (getStateLock()) { ! return region != null; } } // DropTargetPeer Method @Override
*** 1384,1438 **** getDelegate().print(g); } } } - // Just a helper method, thus final - protected final void flushOffscreenGraphics() { - flushOffscreenGraphics(getSize()); - } - protected static final void flushOnscreenGraphics(){ final OGLRenderQueue rq = OGLRenderQueue.getInstance(); rq.lock(); try { rq.flushNow(); } finally { rq.unlock(); } } - /* - * Flushes the given rectangle from the back buffer to the screen. - */ - protected void flushOffscreenGraphics(Rectangle r) { - flushOffscreenGraphics(r.x, r.y, r.width, r.height); - } - - private void flushOffscreenGraphics(int x, int y, int width, int height) { - Image bb = getWindowPeerOrSelf().getBackBuffer(); - if (bb != null) { - // g is a screen Graphics from the delegate - final Graphics g = getOnscreenGraphics(); - - if (g != null && g instanceof Graphics2D) { - try { - Graphics2D g2d = (Graphics2D)g; - Point p = localToWindow(new Point(0, 0)); - Composite composite = g2d.getComposite(); - g2d.setComposite(AlphaComposite.Src); - g.drawImage(bb, x, y, x + width, y + height, p.x + x, - p.y + y, p.x + x + width, p.y + y + height, - null); - g2d.setComposite(composite); - } finally { - g.dispose(); - } - } - } - } - /** * Used by ContainerPeer to skip all the paint events during layout. * * @param isLayouting layouting state. */ --- 1396,1415 ----