< prev index next >

src/java.desktop/windows/classes/sun/awt/windows/WComponentPeer.java

Print this page
rev 57801 : XXXXXXX: Component.xxxImage cleanup
Reviewed-by: XXX
   1 /*
   2  * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package sun.awt.windows;
  26 
  27 import java.awt.*;
  28 import java.awt.peer.*;
  29 import java.awt.image.VolatileImage;
  30 import sun.awt.RepaintArea;
  31 import sun.awt.image.SunVolatileImage;
  32 import sun.awt.image.ToolkitImage;
  33 import java.awt.image.BufferedImage;
  34 import java.awt.image.ImageProducer;
  35 import java.awt.image.ImageObserver;
  36 import java.awt.image.ColorModel;
  37 import java.awt.event.PaintEvent;










  38 import java.awt.event.InvocationEvent;
  39 import java.awt.event.KeyEvent;
  40 import java.awt.event.FocusEvent;
  41 import java.awt.event.MouseEvent;
  42 import java.awt.event.MouseWheelEvent;
  43 import java.awt.event.InputEvent;











  44 import sun.awt.Win32GraphicsConfig;
  45 import sun.awt.Win32GraphicsEnvironment;


  46 import sun.java2d.InvalidPipeException;
  47 import sun.java2d.SurfaceData;
  48 import sun.java2d.ScreenUpdateManager;

  49 import sun.java2d.d3d.D3DSurfaceData;
  50 import sun.java2d.opengl.OGLSurfaceData;
  51 import sun.java2d.pipe.Region;
  52 import sun.awt.PaintEventDispatcher;
  53 import sun.awt.SunToolkit;
  54 import sun.awt.event.IgnorePaintEvent;
  55 
  56 import java.awt.dnd.DropTarget;
  57 import java.awt.dnd.peer.DropTargetPeer;
  58 import java.awt.geom.AffineTransform;
  59 import sun.awt.AWTAccessor;
  60 
  61 import sun.util.logging.PlatformLogger;
  62 
  63 public abstract class WComponentPeer extends WObjectPeer
  64     implements ComponentPeer, DropTargetPeer
  65 {
  66     /**
  67      * Handle to native window
  68      */
  69     protected volatile long hwnd;
  70 
  71     private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WComponentPeer");
  72     private static final PlatformLogger shapeLog = PlatformLogger.getLogger("sun.awt.windows.shape.WComponentPeer");
  73     private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.windows.focus.WComponentPeer");
  74 
  75     // ComponentPeer implementation
  76     SurfaceData surfaceData;
  77 
  78     private RepaintArea paintArea;
  79 
  80     protected Win32GraphicsConfig winGraphicsConfig;


 734                                                             temporary,
 735                                                             focusedWindowChangeAllowed,
 736                                                             time, cause);
 737 
 738           case WKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
 739               // Either lightweight or excessive request - all events are generated.
 740               return true;
 741         }
 742         return false;
 743     }
 744 
 745     private boolean rejectFocusRequestHelper(String logMsg) {
 746         if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
 747             focusLog.finer(logMsg);
 748         }
 749         WKeyboardFocusManagerPeer.removeLastFocusRequest((Component)target);
 750         return false;
 751     }
 752 
 753     @Override
 754     public Image createImage(ImageProducer producer) {
 755         return new ToolkitImage(producer);
 756     }
 757 
 758     @Override
 759     public Image createImage(int width, int height) {
 760         Win32GraphicsConfig gc =
 761             (Win32GraphicsConfig)getGraphicsConfiguration();
 762         return gc.createAcceleratedImage((Component)target, width, height);
 763     }
 764 
 765     @Override
 766     public VolatileImage createVolatileImage(int width, int height) {
 767         return new SunVolatileImage((Component)target, width, height);
 768     }
 769 
 770     @Override
 771     public boolean prepareImage(Image img, int w, int h, ImageObserver o) {
 772         return Toolkit.getDefaultToolkit().prepareImage(img, w, h, o);
 773     }
 774 
 775     @Override
 776     public int checkImage(Image img, int w, int h, ImageObserver o) {
 777         return Toolkit.getDefaultToolkit().checkImage(img, w, h, o);
 778     }
 779 
 780     // Object overrides
 781 
 782     public String toString() {
 783         return getClass().getName() + "[" + target + "]";
 784     }
 785 
 786     // Toolkit & peer internals
 787 
 788     private int updateX1, updateY1, updateX2, updateY2;
 789 
 790     WComponentPeer(Component target) {
 791         this.target = target;
 792         this.paintArea = new RepaintArea();
 793         create(getNativeParent());
 794         // fix for 5088782: check if window object is created successfully
 795         checkCreation();
 796 
 797         createScreenSurface(false);
 798         initialize();
 799         start();  // Initialize enable/disable state, turn on callbacks


   1 /*
   2  * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package sun.awt.windows;
  26 
  27 import java.awt.AWTEvent;
  28 import java.awt.AWTException;
  29 import java.awt.BufferCapabilities;
  30 import java.awt.Color;
  31 import java.awt.Component;
  32 import java.awt.Container;
  33 import java.awt.Dimension;
  34 import java.awt.Font;
  35 import java.awt.FontMetrics;
  36 import java.awt.Graphics;
  37 import java.awt.GraphicsConfiguration;
  38 import java.awt.GraphicsDevice;
  39 import java.awt.Image;
  40 import java.awt.Point;
  41 import java.awt.Rectangle;
  42 import java.awt.SystemColor;
  43 import java.awt.Window;
  44 import java.awt.dnd.DropTarget;
  45 import java.awt.dnd.peer.DropTargetPeer;
  46 import java.awt.event.FocusEvent;
  47 import java.awt.event.InputEvent;
  48 import java.awt.event.InvocationEvent;
  49 import java.awt.event.KeyEvent;

  50 import java.awt.event.MouseEvent;
  51 import java.awt.event.MouseWheelEvent;
  52 import java.awt.event.PaintEvent;
  53 import java.awt.geom.AffineTransform;
  54 import java.awt.image.BufferedImage;
  55 import java.awt.image.ColorModel;
  56 import java.awt.image.VolatileImage;
  57 import java.awt.peer.ComponentPeer;
  58 import java.awt.peer.ContainerPeer;
  59 
  60 import sun.awt.AWTAccessor;
  61 import sun.awt.PaintEventDispatcher;
  62 import sun.awt.RepaintArea;
  63 import sun.awt.SunToolkit;
  64 import sun.awt.Win32GraphicsConfig;
  65 import sun.awt.Win32GraphicsEnvironment;
  66 import sun.awt.event.IgnorePaintEvent;
  67 import sun.awt.image.SunVolatileImage;
  68 import sun.java2d.InvalidPipeException;

  69 import sun.java2d.ScreenUpdateManager;
  70 import sun.java2d.SurfaceData;
  71 import sun.java2d.d3d.D3DSurfaceData;
  72 import sun.java2d.opengl.OGLSurfaceData;
  73 import sun.java2d.pipe.Region;









  74 import sun.util.logging.PlatformLogger;
  75 
  76 public abstract class WComponentPeer extends WObjectPeer
  77     implements ComponentPeer, DropTargetPeer
  78 {
  79     /**
  80      * Handle to native window
  81      */
  82     protected volatile long hwnd;
  83 
  84     private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WComponentPeer");
  85     private static final PlatformLogger shapeLog = PlatformLogger.getLogger("sun.awt.windows.shape.WComponentPeer");
  86     private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.windows.focus.WComponentPeer");
  87 
  88     // ComponentPeer implementation
  89     SurfaceData surfaceData;
  90 
  91     private RepaintArea paintArea;
  92 
  93     protected Win32GraphicsConfig winGraphicsConfig;


 747                                                             temporary,
 748                                                             focusedWindowChangeAllowed,
 749                                                             time, cause);
 750 
 751           case WKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
 752               // Either lightweight or excessive request - all events are generated.
 753               return true;
 754         }
 755         return false;
 756     }
 757 
 758     private boolean rejectFocusRequestHelper(String logMsg) {
 759         if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
 760             focusLog.finer(logMsg);
 761         }
 762         WKeyboardFocusManagerPeer.removeLastFocusRequest((Component)target);
 763         return false;
 764     }
 765 
 766     @Override





 767     public Image createImage(int width, int height) {
 768         Win32GraphicsConfig gc =
 769             (Win32GraphicsConfig)getGraphicsConfiguration();
 770         return gc.createAcceleratedImage((Component)target, width, height);
 771     }
 772 
 773     @Override
 774     public VolatileImage createVolatileImage(int width, int height) {
 775         return new SunVolatileImage((Component)target, width, height);
 776     }
 777 










 778     // Object overrides
 779 
 780     public String toString() {
 781         return getClass().getName() + "[" + target + "]";
 782     }
 783 
 784     // Toolkit & peer internals
 785 
 786     private int updateX1, updateY1, updateX2, updateY2;
 787 
 788     WComponentPeer(Component target) {
 789         this.target = target;
 790         this.paintArea = new RepaintArea();
 791         create(getNativeParent());
 792         // fix for 5088782: check if window object is created successfully
 793         checkCreation();
 794 
 795         createScreenSurface(false);
 796         initialize();
 797         start();  // Initialize enable/disable state, turn on callbacks


< prev index next >