< prev index next >

modules/javafx.web/src/main/java/com/sun/webkit/graphics/WCGraphicsManager.java

Print this page




   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 
  26 package com.sun.webkit.graphics;
  27 

  28 import com.sun.webkit.SharedBuffer;
  29 import com.sun.webkit.SimpleSharedBufferInputStream;
  30 import java.io.IOException;
  31 import java.io.InputStream;
  32 import java.nio.ByteBuffer;
  33 import java.util.HashMap;
  34 import java.util.MissingResourceException;
  35 import java.util.ResourceBundle;
  36 import java.util.concurrent.atomic.AtomicInteger;
  37 import java.util.logging.Level;
  38 import java.util.logging.Logger;
  39 
  40 public abstract class WCGraphicsManager {
  41 
  42     private static final Logger logger =
  43             Logger.getLogger(WCGraphicsManager.class.getName());
  44 
  45     private final AtomicInteger idCount = new AtomicInteger(0);
  46 
  47     private final HashMap<Integer,Ref> refMap = new HashMap<Integer,Ref>();
  48 
  49     private static ResourceBundle imageProperties = null;
  50     private static WCGraphicsManager manager = null;
  51 
  52     public static void setGraphicsManager(WCGraphicsManager manager) {
  53         WCGraphicsManager.manager = manager;
  54     }
  55 
  56     public static WCGraphicsManager getGraphicsManager() {
  57         return manager;
  58     }
  59 
  60     public abstract float getDevicePixelScale();
  61 
  62     protected abstract WCImageDecoder getImageDecoder();
  63 
  64     public abstract WCGraphicsContext createGraphicsContext(Object g);
  65 
  66     public abstract WCRenderQueue createRenderQueue(WCRectangle clip,
  67                                                     boolean opaque);
  68 
  69     protected abstract WCRenderQueue createBufferedContextRQ(WCImage image);
  70 
  71     public abstract WCPageBackBuffer createPageBackBuffer();
  72 
  73     protected abstract WCFont getWCFont(String name, boolean bold, boolean italic, float size);
  74 
  75     private WCFontCustomPlatformData fwkCreateFontCustomPlatformData(
  76             SharedBuffer sharedBuffer)
  77     {
  78         try {
  79             return createFontCustomPlatformData(
  80                     new SimpleSharedBufferInputStream(sharedBuffer));
  81         } catch (IOException ex) {
  82             logger.log(Level.FINEST,
  83                        "Error creating font custom platform data",
  84                        ex);
  85             return null;
  86         }
  87     }
  88 
  89     protected abstract WCFontCustomPlatformData createFontCustomPlatformData(
  90             InputStream inputStream) throws IOException;
  91 
  92     protected abstract WCPath createWCPath();
  93 
  94     protected abstract WCPath createWCPath(WCPath path);
  95 
  96     protected abstract WCImage createWCImage(int w, int h);
  97 
  98     protected abstract WCImage createRTImage(int w, int h);
  99 
 100     public abstract WCImage getIconImage(String iconURL);
 101 
 102     public abstract Object toPlatformImage(WCImage image);
 103 
 104     protected abstract WCImageFrame createFrame(int w, int h, ByteBuffer data);




   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 
  26 package com.sun.webkit.graphics;
  27 
  28 import com.sun.javafx.logging.PlatformLogger;
  29 import com.sun.webkit.SharedBuffer;
  30 import com.sun.webkit.SimpleSharedBufferInputStream;
  31 import java.io.IOException;
  32 import java.io.InputStream;
  33 import java.nio.ByteBuffer;
  34 import java.util.HashMap;
  35 import java.util.MissingResourceException;
  36 import java.util.ResourceBundle;
  37 import java.util.concurrent.atomic.AtomicInteger;


  38 
  39 public abstract class WCGraphicsManager {
  40 
  41     private static final PlatformLogger logger =
  42             PlatformLogger.getLogger(WCGraphicsManager.class.getName());
  43 
  44     private final AtomicInteger idCount = new AtomicInteger(0);
  45 
  46     private final HashMap<Integer,Ref> refMap = new HashMap<Integer,Ref>();
  47 
  48     private static ResourceBundle imageProperties = null;
  49     private static WCGraphicsManager manager = null;
  50 
  51     public static void setGraphicsManager(WCGraphicsManager manager) {
  52         WCGraphicsManager.manager = manager;
  53     }
  54 
  55     public static WCGraphicsManager getGraphicsManager() {
  56         return manager;
  57     }
  58 
  59     public abstract float getDevicePixelScale();
  60 
  61     protected abstract WCImageDecoder getImageDecoder();
  62 
  63     public abstract WCGraphicsContext createGraphicsContext(Object g);
  64 
  65     public abstract WCRenderQueue createRenderQueue(WCRectangle clip,
  66                                                     boolean opaque);
  67 
  68     protected abstract WCRenderQueue createBufferedContextRQ(WCImage image);
  69 
  70     public abstract WCPageBackBuffer createPageBackBuffer();
  71 
  72     protected abstract WCFont getWCFont(String name, boolean bold, boolean italic, float size);
  73 
  74     private WCFontCustomPlatformData fwkCreateFontCustomPlatformData(
  75             SharedBuffer sharedBuffer)
  76     {
  77         try {
  78             return createFontCustomPlatformData(
  79                     new SimpleSharedBufferInputStream(sharedBuffer));
  80         } catch (IOException ex) {
  81             logger.finest("Error creating font custom platform data", ex);


  82             return null;
  83         }
  84     }
  85 
  86     protected abstract WCFontCustomPlatformData createFontCustomPlatformData(
  87             InputStream inputStream) throws IOException;
  88 
  89     protected abstract WCPath createWCPath();
  90 
  91     protected abstract WCPath createWCPath(WCPath path);
  92 
  93     protected abstract WCImage createWCImage(int w, int h);
  94 
  95     protected abstract WCImage createRTImage(int w, int h);
  96 
  97     public abstract WCImage getIconImage(String iconURL);
  98 
  99     public abstract Object toPlatformImage(WCImage image);
 100 
 101     protected abstract WCImageFrame createFrame(int w, int h, ByteBuffer data);


< prev index next >