10 Replies Latest reply: Jan 12, 2009 5:45 AM by 800626 RSS

    Double Buffering Slow..is it in the code? or..

    800626
      Hi all..
      i make small application which use double buffering..
      here's the code:
      public void update(Graphics g){
              tys_a=System.currentTimeMillis();
              Dimension d = getSize();        
              if (offscreenImage == null || offscreenImage.getWidth(null) < d.width || offscreenImage.getHeight(null) < d.height){
      
                  if (offscreenImage != null) offscreenImage.flush();
                  offscreenImage = createImage(d.width, d.height);
                  offscreenSize = d;
                  offscreenGraphics = offscreenImage.getGraphics();
              }
              offscreenGraphics.clearRect(0, 0, d.width, d.height);
              paint(offscreenGraphics);
              g.drawImage(offscreenImage, 0, 0, null);
              g.dispose();
              
              tys_b=System.currentTimeMillis();
              tys_c=tys_b-tys_a;
              System.out.println("DRAW OFFSCREEN GRAPH " + tys_c + " --- " + tys_a + " ---- " + tys_b);
          }
      then i run it on my desktop PC, which specs are
      Core 2 duo E4500 - 2.20Ghz, 2 Gb RAM , Vista Home Premium
      its works fine..took 10 ms

      but when i try on Sony vaio laptop, which specs are:
      core 2 duo T8100 - 2.1Gghz, 2Gb RAM, Vista home premium
      its so slow..took average about 800-900ms (80-90 times slower)

      did i do something wrong with my code...i've been searching all day...but seems no answer

      but all i can think..is not about the code..because it works fine in my desktop...
      but i dunno what cause this problem?
      any body can help?or ever have this kind of problem willing to share?

      Thx,