< prev index next >

src/java.desktop/share/classes/javax/swing/BufferStrategyPaintManager.java

Print this page




  63     // will then block until showing is true.  This scheme ensures we
  64     // only ever have one thread using the BufferStrategy and it also
  65     // ensures the toolkit thread remains as responsive as possible.
  66     //
  67     // If we're using a flip strategy the contents of the backbuffer may
  68     // have changed and so show only attempts to show from the backbuffer
  69     // if we get a blit strategy.
  70     //
  71 
  72     private static final PlatformLogger LOGGER = PlatformLogger.getLogger(
  73                            "javax.swing.BufferStrategyPaintManager");
  74 
  75     /**
  76      * List of BufferInfos.  We don't use a Map primarily because
  77      * there are typically only a handful of top level components making
  78      * a Map overkill.
  79      */
  80     private ArrayList<BufferInfo> bufferInfos;
  81 
  82     /**
  83      * Indicates <code>beginPaint</code> has been invoked.  This is
  84      * set to true for the life of beginPaint/endPaint pair.
  85      */
  86     private boolean painting;
  87     /**
  88      * Indicates we're in the process of showing.  All painting, on the EDT,
  89      * is blocked while this is true.
  90      */
  91     private boolean showing;
  92 
  93     //
  94     // Region that we need to flush.  When beginPaint is called these are
  95     // reset and any subsequent calls to paint/copyArea then update these
  96     // fields accordingly.  When endPaint is called we then try and show
  97     // the accumulated region.
  98     // These fields are in the coordinate system of the root.
  99     //
 100     private int accumulatedX;
 101     private int accumulatedY;
 102     private int accumulatedMaxX;
 103     private int accumulatedMaxY;


 669         }
 670 
 671         /**
 672          * Whether or not the contents of the buffer strategy
 673          * is in sync with the window.  This is set to true when the root
 674          * pane paints all, and false when contents are lost/restored.
 675          */
 676         public boolean isInSync() {
 677             return inSync;
 678         }
 679 
 680         /**
 681          * Returns the Root (Window or Applet) that this BufferInfo references.
 682          */
 683         public Container getRoot() {
 684             return (root == null) ? null : root.get();
 685         }
 686 
 687         /**
 688          * Returns the BufferStartegy.  This will return null if
 689          * the BufferStartegy hasn't been created and <code>create</code> is
 690          * false, or if there is a problem in creating the
 691          * <code>BufferStartegy</code>.
 692          *
 693          * @param create If true, and the BufferStartegy is currently null,
 694          *               one will be created.
 695          */
 696         public BufferStrategy getBufferStrategy(boolean create) {
 697             BufferStrategy bs = (weakBS == null) ? null : weakBS.get();
 698             if (bs == null && create) {
 699                 bs = createBufferStrategy();
 700                 if (bs != null) {
 701                     weakBS = new WeakReference<BufferStrategy>(bs);
 702                 }
 703                 if (LOGGER.isLoggable(PlatformLogger.Level.FINER)) {
 704                     LOGGER.finer("getBufferStrategy: created bs: " + bs);
 705                 }
 706             }
 707             return bs;
 708         }
 709 
 710         /**
 711          * Returns true if the buffer strategy of the component differs




  63     // will then block until showing is true.  This scheme ensures we
  64     // only ever have one thread using the BufferStrategy and it also
  65     // ensures the toolkit thread remains as responsive as possible.
  66     //
  67     // If we're using a flip strategy the contents of the backbuffer may
  68     // have changed and so show only attempts to show from the backbuffer
  69     // if we get a blit strategy.
  70     //
  71 
  72     private static final PlatformLogger LOGGER = PlatformLogger.getLogger(
  73                            "javax.swing.BufferStrategyPaintManager");
  74 
  75     /**
  76      * List of BufferInfos.  We don't use a Map primarily because
  77      * there are typically only a handful of top level components making
  78      * a Map overkill.
  79      */
  80     private ArrayList<BufferInfo> bufferInfos;
  81 
  82     /**
  83      * Indicates {@code beginPaint} has been invoked.  This is
  84      * set to true for the life of beginPaint/endPaint pair.
  85      */
  86     private boolean painting;
  87     /**
  88      * Indicates we're in the process of showing.  All painting, on the EDT,
  89      * is blocked while this is true.
  90      */
  91     private boolean showing;
  92 
  93     //
  94     // Region that we need to flush.  When beginPaint is called these are
  95     // reset and any subsequent calls to paint/copyArea then update these
  96     // fields accordingly.  When endPaint is called we then try and show
  97     // the accumulated region.
  98     // These fields are in the coordinate system of the root.
  99     //
 100     private int accumulatedX;
 101     private int accumulatedY;
 102     private int accumulatedMaxX;
 103     private int accumulatedMaxY;


 669         }
 670 
 671         /**
 672          * Whether or not the contents of the buffer strategy
 673          * is in sync with the window.  This is set to true when the root
 674          * pane paints all, and false when contents are lost/restored.
 675          */
 676         public boolean isInSync() {
 677             return inSync;
 678         }
 679 
 680         /**
 681          * Returns the Root (Window or Applet) that this BufferInfo references.
 682          */
 683         public Container getRoot() {
 684             return (root == null) ? null : root.get();
 685         }
 686 
 687         /**
 688          * Returns the BufferStartegy.  This will return null if
 689          * the BufferStartegy hasn't been created and {@code create} is
 690          * false, or if there is a problem in creating the
 691          * {@code BufferStartegy}.
 692          *
 693          * @param create If true, and the BufferStartegy is currently null,
 694          *               one will be created.
 695          */
 696         public BufferStrategy getBufferStrategy(boolean create) {
 697             BufferStrategy bs = (weakBS == null) ? null : weakBS.get();
 698             if (bs == null && create) {
 699                 bs = createBufferStrategy();
 700                 if (bs != null) {
 701                     weakBS = new WeakReference<BufferStrategy>(bs);
 702                 }
 703                 if (LOGGER.isLoggable(PlatformLogger.Level.FINER)) {
 704                     LOGGER.finer("getBufferStrategy: created bs: " + bs);
 705                 }
 706             }
 707             return bs;
 708         }
 709 
 710         /**
 711          * Returns true if the buffer strategy of the component differs


< prev index next >