示例#1
0
 private void haltProgressivePaintThread() {
   if (progressivePaintThread != null) {
     progressivePaintThread.halt();
     progressivePaintThread = null;
   }
 }
示例#2
0
  // long lastFrame = -1;
  public void repaint(RectListManager devRLM) {
    if (devRLM == null) return;

    updateWorkingBuffers();
    if ((rootGN == null) || (workImg == null)) return;

    try {
      // Ensure only one thread works on WorkImg at a time...
      synchronized (workImg) {
        Graphics2D g2d = GraphicsUtil.createGraphics(workImg, renderingHints);

        Rectangle dr;
        dr = new Rectangle(0, 0, offScreenWidth, offScreenHeight);

        if ((isDoubleBuffered) && (currImg != null) && (damagedAreas != null)) {

          damagedAreas.subtract(devRLM, COPY_OVERHEAD, COPY_LINE_OVERHEAD);

          damagedAreas.mergeRects(COPY_OVERHEAD, COPY_LINE_OVERHEAD);

          Iterator iter = damagedAreas.iterator();
          g2d.setComposite(AlphaComposite.Src);
          while (iter.hasNext()) {
            Rectangle r = (Rectangle) iter.next();
            if (!dr.intersects(r)) continue;
            r = dr.intersection(r);
            g2d.setClip(r.x, r.y, r.width, r.height);
            g2d.setComposite(AlphaComposite.Clear);
            g2d.fillRect(r.x, r.y, r.width, r.height);
            g2d.setComposite(AlphaComposite.SrcOver);
            g2d.drawImage(currImg, 0, 0, null);
          }
        }

        Iterator iter = devRLM.iterator();
        while (iter.hasNext()) {
          Rectangle r = (Rectangle) iter.next();
          if (!dr.intersects(r)) continue;
          r = dr.intersection(r);
          g2d.setTransform(IDENTITY);
          g2d.setClip(r.x, r.y, r.width, r.height);
          g2d.setComposite(AlphaComposite.Clear);
          g2d.fillRect(r.x, r.y, r.width, r.height);
          g2d.setComposite(AlphaComposite.SrcOver);
          g2d.transform(usr2dev);
          rootGN.paint(g2d);
        }
        g2d.dispose();
      }
    } catch (Throwable t) {
      t.printStackTrace();
    }
    if (HaltingThread.hasBeenHalted()) return;

    // System.out.println("Dmg: "   + damagedAreas);
    // System.out.println("Areas: " + devRects);

    // Swap the buffers if the rendering completed cleanly.
    if (isDoubleBuffered) {
      BufferedImage tmpImg = workImg;
      workImg = currImg;
      currImg = tmpImg;
      damagedAreas = devRLM;
    }
  }