javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/graphics/JavaCommandBuffer.java
changeset 62 9d831841012d
parent 61 bf7ee68962da
equal deleted inserted replaced
61:bf7ee68962da 62:9d831841012d
     1 /******************************************************************************* * Copyright (c) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: *     Nokia Corporation - initial implementation *******************************************************************************/
     1 /*******************************************************************************
       
     2  * Copyright (c) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved. This program and the accompanying materials
       
     4  * are made available under the terms of the Eclipse Public License v1.0
       
     5  * which accompanies this distribution, and is available at
       
     6  * http://www.eclipse.org/legal/epl-v10.html
       
     7  *
       
     8  * Contributors:
       
     9  *     Nokia Corporation - initial implementation
       
    10  *******************************************************************************/
       
    11 
     2 package org.eclipse.swt.internal.qt.graphics;
    12 package org.eclipse.swt.internal.qt.graphics;
     3 import java.util.Vector;import java.util.Enumeration;
    13 
     4 /** * This class implements a command buffer that can be bound by GraphicsContext * to collect the drawing operations. Contents of the command buffer can be replayed to * GraphicsContext target with GraphicsContext.render() method. * * When JavaCommandBuffer is set as the target of GraphicsContext some of the methods * provided by GraphicsContext are not supported, e.g. getters, since the JavaCommandBuffer * does not have a real rendering target from which to query related data. To find out what is * supported see the methods of this class. In principal GraphicsContext supports all draw and set operations, * when JavaCommandBuffer is set as rendering target. */public final class JavaCommandBuffer {    // All collected drawing operations and their parameters    private int[] intParams;    private int intCount;    private StringBuffer strParams;    // Container for images    private Vector images;    // Container for rgbData    private Vector rgbData;    // This flag is indicates if this buffer is bound by some GraphicsContext    private boolean bound;    // This flag indicates if this buffer is empty or not    private boolean containsData;    // This flag indicates if this buffer has any draw commands in it    private boolean containsPrimitiveData;    // Memory management configuration constants    private static final int INT_BUF_GRANULARITY         = 2560; // 10kB    private static final int INT_BUF_INITIAL_SIZE        = 256; // 1kB    private static final int IMAGE_BUF_INITIAL_SIZE      = 256; // 1kB    private static final int IMAGE_BUF_GRANULARITY       = 256; // 1kB    private static final int STRING_BUFFER_INITIAL_SIZE  = 256; // 1kB    // Prefixes for different categories of op codes, stored in MSB    final static int DRAW_PREFIX = 0;    final static int FILL_PREFIX = 1;    final static int SET_PREFIX = 2;    final static int MISC_PREFIX = 3;    // Unique operation codes for all the gc operations that can be buffered.    static final int OP_DRAWARC            = ((DRAW_PREFIX << 24) | 1);    static final int OP_DRAWFOCUS          = ((DRAW_PREFIX << 24) | 2);    static final int OP_DRAWIMAGE1         = ((DRAW_PREFIX << 24) | 3);    static final int OP_DRAWIMAGE2         = ((DRAW_PREFIX << 24) | 4);    static final int OP_DRAWLINE           = ((DRAW_PREFIX << 24) | 5);    static final int OP_DRAWELLIPSE        = ((DRAW_PREFIX << 24) | 6);    static final int OP_DRAWPOINT          = ((DRAW_PREFIX << 24) | 7);    static final int OP_DRAWPOLYGON        = ((DRAW_PREFIX << 24) | 8);    static final int OP_DRAWPOLYLINE       = ((DRAW_PREFIX << 24) | 9);    static final int OP_DRAWRECT           = ((DRAW_PREFIX << 24) | 10);    static final int OP_DRAWRGB_INT        = ((DRAW_PREFIX << 24) | 11);    static final int OP_DRAWRGB_BYTE       = ((DRAW_PREFIX << 24) | 12);    static final int OP_DRAWRGB_SHORT      = ((DRAW_PREFIX << 24) | 13);    static final int OP_DRAWROUNDRECT      = ((DRAW_PREFIX << 24) | 14);    static final int OP_DRAWSTRING         = ((DRAW_PREFIX << 24) | 15);    static final int OP_FILLARC            = ((FILL_PREFIX << 24) | 16);    static final int OP_FILLGRADIENTRECT   = ((FILL_PREFIX << 24) | 17);    static final int OP_FILLELLIPSE        = ((FILL_PREFIX << 24) | 18);    static final int OP_FILLPOLYGON        = ((FILL_PREFIX << 24) | 19);    static final int OP_FILLRECT           = ((FILL_PREFIX << 24) | 20);    static final int OP_FILLROUNDRECT      = ((FILL_PREFIX << 24) | 21);    static final int OP_SETBACKGROUNDALPHA = ((SET_PREFIX << 24) | 22);    static final int OP_SETBACKGROUNDCOLOR = ((SET_PREFIX << 24) | 23);    static final int OP_SETBLENDINGMODE    = ((SET_PREFIX << 24) | 24);    static final int OP_SETCLIP            = ((SET_PREFIX << 24) | 25);    static final int OP_CANCELCLIPPING     = ((SET_PREFIX << 24) | 26);    static final int OP_SETFONT            = ((SET_PREFIX << 24) | 27);    static final int OP_SETFOREGROUNDALPHA = ((SET_PREFIX << 24) | 28);    static final int OP_SETFOREGROUNDCOLOR = ((SET_PREFIX << 24) | 29);    static final int OP_SETSTROKESTYLE     = ((SET_PREFIX << 24) | 30);    static final int OP_SETSTROKEWIDTH     = ((SET_PREFIX << 24) | 31);    static final int OP_TRANSLATE          = ((MISC_PREFIX << 24) | 32);    static final int OP_SCALE              = ((MISC_PREFIX << 24) | 33);    static final int OP_RESETTRANSFORM     = ((MISC_PREFIX << 24) | 34);    static final int OP_COPYAREA1          = ((MISC_PREFIX << 24) | 35);    static final int OP_COPYAREA2          = ((MISC_PREFIX << 24) | 36);    /**     * Constructs empty command buffer with defined buffer sizes.     */    public JavaCommandBuffer() {        intParams = new int[INT_BUF_INITIAL_SIZE];        strParams = new StringBuffer(STRING_BUFFER_INITIAL_SIZE);        images = new Vector(IMAGE_BUF_INITIAL_SIZE, IMAGE_BUF_GRANULARITY);        rgbData = new Vector(IMAGE_BUF_INITIAL_SIZE, IMAGE_BUF_GRANULARITY);    }    /**     * Resets the buffer, i.e. removes all recorded commands and related data. The integer array containing     * the actual operation codes is not deleted, only the index pointer is rested, thus the memory consumption of that is not freed.     * CommandBuffer can be reseted only if it is not bound by any GraphicsContext     * @throws IllegalStateException if this CommandBuffer is bound while calling reset     */    public void reset() {        if(bound) {            throw new IllegalStateException("CommandBuffer is still bound by gc");        }        intCount = 0;        strParams.setLength(0);        Enumeration allImages = images.elements();        while(allImages.hasMoreElements()) {            Image image = (Image)allImages.nextElement();            if(image != null) {                image.freeCommandBufferCopy();            }        }        images.removeAllElements();        rgbData.removeAllElements();        containsData = false;        containsPrimitiveData = false;    }    /**     * Checks that does this buffer contain any commands     * @return true if any command has been written to buffer otherwise false     */    public boolean containsData() {        return containsData;    }    /**     * Checks that does this buffer contain any draw commands, i.e. any setters etc.     * that does to cause any pixels to be rendered are ignored     * @return true if any draw command has been written to buffer otherwise false     */    public boolean containsDrawnPrimitives() {        return containsPrimitiveData;    }    /**     * Binds this buffer     */    void bind() {        bound = true;    }    /**     * Provides the binding status of this buffer     * @return true if this buffer has been already bound otherwise false     */    boolean isBound() {        return bound;    }    /**     * Releases this buffer, i.e. it can be bound by some other GraphicsContext     */    void release() {        bound = false;    }    private void ensureIntArraySpace(final int items) {        if( intParams.length < intCount + items) {            int[] dst = new int[intParams.length + Math.max(INT_BUF_GRANULARITY, items)];            System.arraycopy(intParams, 0, dst, 0, intParams.length);            intParams = dst;        }        containsData = true;    }    private void reportNotSupported() {        throw new RuntimeException("Intenal: Operation not supported with JavaCommandBuffer");    }//    private void printBufferInfo() {//        System.out.println("CommandBuffer Info: " +this);//        System.out.println("intParamCount: " + intCount);//        System.out.println("intBuffer Size: " + intParams.length);//        System.out.println("StringBuffer Size: " + strParams.length());//    }    private void raisePrimitiveFlag() {        containsPrimitiveData = true;    }    int[] intParams() {        return intParams;    }    int intParamCount() {        return intCount;    }    Vector rgbParams() {        return rgbData;    }    Vector images() {        return images;    }    String strParams() {        return strParams.toString();    }    void drawArc (final int x, final int y, final int width, final int height, final int startAngle, final int arcAngle) {        ensureIntArraySpace(7);        intParams[intCount++] = OP_DRAWARC;        intParams[intCount++] = x;        intParams[intCount++] = y;        intParams[intCount++] = width;        intParams[intCount++] = height;        intParams[intCount++] = startAngle;        intParams[intCount++] = arcAngle;        raisePrimitiveFlag();    }    void drawFocus (final int x, final int y, final int width, final int height) {        ensureIntArraySpace(5);        intParams[intCount++] = OP_DRAWFOCUS;        intParams[intCount++] = x;        intParams[intCount++] = y;        intParams[intCount++] = width;        intParams[intCount++] = height;        raisePrimitiveFlag();    }    // Must be called from UI thread as images cannot be creates outside that    void drawImage(final Image image, final int x, final int y) {        ensureIntArraySpace(3);        intParams[intCount++] = OP_DRAWIMAGE1;        intParams[intCount++] = x;        intParams[intCount++] = y;        // creating copy of image here uses implicit data sharing,        // thus only a shallow copy is made        images.addElement(image.getCommandBufferCopy());        raisePrimitiveFlag();    }    // must be called from UI thread as images cannot be creates outside that    void drawImage(final Image image, final int tx, final int ty, final int tw, final int th, final int sx, final int sy, final int sw, final int sh, final int manipulation) {        ensureIntArraySpace(10);        intParams[intCount++] = OP_DRAWIMAGE2;        intParams[intCount++] = tx;        intParams[intCount++] = ty;        intParams[intCount++] = tw;        intParams[intCount++] = th;        intParams[intCount++] = sx;        intParams[intCount++] = sy;        intParams[intCount++] = sw;        intParams[intCount++] = sh;        intParams[intCount++] = manipulation;        // creating copy of image here uses implicit data sharing,        // thus only a shallow copy is made        images.addElement(image.getCommandBufferCopy());        raisePrimitiveFlag();    }    void drawLine (final int x1, final int y1, final int x2, final int y2) {        ensureIntArraySpace(5);        intParams[intCount++] = OP_DRAWLINE;        intParams[intCount++] = x1;        intParams[intCount++] = y1;        intParams[intCount++] = x2;        intParams[intCount++] = y2;        raisePrimitiveFlag();    }    void drawEllipse (final int x, final int y, final int width, final int height) {        ensureIntArraySpace(5);        intParams[intCount++] = OP_DRAWELLIPSE;        intParams[intCount++] = x;        intParams[intCount++] = y;        intParams[intCount++] = width;        intParams[intCount++] = height;        raisePrimitiveFlag();    }    void drawPoint (final int x, final int y) {        ensureIntArraySpace(3);        intParams[intCount++] = OP_DRAWPOINT;        intParams[intCount++] = x;        intParams[intCount++] = y;        raisePrimitiveFlag();    }    void drawPolygon(final int[] pointArray) {        ensureIntArraySpace(2 + pointArray.length);        intParams[intCount++] = OP_DRAWPOLYGON;        intParams[intCount++] = pointArray.length;        for(int i = 0; i < pointArray.length; ++i) {            intParams[intCount++] = pointArray[i];        }        raisePrimitiveFlag();    }    void drawPolyline(final int[] pointArray) {        ensureIntArraySpace(2 + pointArray.length);        intParams[intCount++] = OP_DRAWPOLYLINE;        intParams[intCount++] = pointArray.length;        for(int i = 0; i < pointArray.length; ++i) {            intParams[intCount++] = pointArray[i];        }        raisePrimitiveFlag();    }    void drawRect (final int x, final int y, final int width, final int height) {        ensureIntArraySpace(5);        intParams[intCount++] = OP_DRAWRECT;        intParams[intCount++] = x;        intParams[intCount++] = y;        intParams[intCount++] = width;        intParams[intCount++] = height;        raisePrimitiveFlag();    }    void drawRGB(final int[] rgb, final int offset, final int scanlength, final int x, final int y, final int width, final int height, final boolean processAlpha, final int manipulation) {        ensureIntArraySpace(9);        intParams[intCount++] = OP_DRAWRGB_INT;        intParams[intCount++] = offset;        intParams[intCount++] = scanlength;        intParams[intCount++] = x;        intParams[intCount++] = y;        intParams[intCount++] = width;        intParams[intCount++] = height;        intParams[intCount++] = processAlpha? 1 : 0;        intParams[intCount++] = manipulation;        rgbData.addElement(rgb);        raisePrimitiveFlag();    }    void drawRGB(final byte[] rgb, final byte[] transparencyMask, final int offset, final int scanlength, final int x, final int y, final int width, final int height, final int manipulation, final int format) {        ensureIntArraySpace(9);        intParams[intCount++] = OP_DRAWRGB_BYTE;        intParams[intCount++] = offset;        intParams[intCount++] = scanlength;        intParams[intCount++] = x;        intParams[intCount++] = y;        intParams[intCount++] = width;        intParams[intCount++] = height;        intParams[intCount++] = manipulation;        intParams[intCount++] = format;        rgbData.addElement(rgb);        rgbData.addElement(transparencyMask);        raisePrimitiveFlag();    }    void drawRGB(final short[] rgb, final int offset, final int scanlength, final int x, final int y, final int width, final int height, final boolean processAlpha, final int manipulation, final int format) {        ensureIntArraySpace(10);        intParams[intCount++] = OP_DRAWRGB_SHORT;        intParams[intCount++] = offset;        intParams[intCount++] = scanlength;        intParams[intCount++] = x;        intParams[intCount++] = y;        intParams[intCount++] = width;        intParams[intCount++] = height;        intParams[intCount++] = processAlpha? 1 : 0;        intParams[intCount++] = manipulation;        intParams[intCount++] = format;        rgbData.addElement(rgb);        raisePrimitiveFlag();    }    void drawRoundRect (final int x, final int y, final int width, final int height, final int arcWidth, final int arcHeight) {        ensureIntArraySpace(7);        intParams[intCount++] = OP_DRAWROUNDRECT;        intParams[intCount++] = x;        intParams[intCount++] = y;        intParams[intCount++] = width;        intParams[intCount++] = height;        intParams[intCount++] = arcWidth;        intParams[intCount++] = arcHeight;        raisePrimitiveFlag();    }    void drawString(final String string, final int x, final int y, final int width, final int height, final int alignments, final int flags, final boolean isTransparent) {        ensureIntArraySpace(9);        intParams[intCount++] = OP_DRAWSTRING;        intParams[intCount++] = string.length();        intParams[intCount++] = x;        intParams[intCount++] = y;        intParams[intCount++] = width;        intParams[intCount++] = height;        intParams[intCount++] = alignments;        intParams[intCount++] = flags;        intParams[intCount++] = isTransparent? 1 : 0;        strParams.append(string);        raisePrimitiveFlag();    }    void fillArc (final int x, final int y, final int width, final int height, final int startAngle, final int arcAngle) {        ensureIntArraySpace(7);        intParams[intCount++] = OP_FILLARC;        intParams[intCount++] = x;        intParams[intCount++] = y;        intParams[intCount++] = width;        intParams[intCount++] = height;        intParams[intCount++] = startAngle;        intParams[intCount++] = arcAngle;        raisePrimitiveFlag();    }    void fillGradientRect(final int x, final int y, final int width, final int height, final boolean vertical, final boolean swapColors) {        ensureIntArraySpace(7);        intParams[intCount++] = OP_FILLGRADIENTRECT;        intParams[intCount++] = x;        intParams[intCount++] = y;        intParams[intCount++] = width;        intParams[intCount++] = height;        intParams[intCount++] = vertical ? 1 : 0;        intParams[intCount++] = swapColors ? 1 : 0;        raisePrimitiveFlag();    }    void fillEllipse (final int x, final int y, final int width, final int height) {        ensureIntArraySpace(5);        intParams[intCount++] = OP_FILLELLIPSE;        intParams[intCount++] = x;        intParams[intCount++] = y;        intParams[intCount++] = width;        intParams[intCount++] = height;        raisePrimitiveFlag();    }    void fillPolygon (final int[] pointArray) {        ensureIntArraySpace(2 + pointArray.length);        intParams[intCount++] = OP_FILLPOLYGON;        intParams[intCount++] = pointArray.length;        for(int i = 0; i < pointArray.length; ++i) {            intParams[intCount++] = pointArray[i];        }        raisePrimitiveFlag();    }    void fillRect (final int x, final int y, final int width, final int height) {        ensureIntArraySpace(5);        intParams[intCount++] = OP_FILLRECT;        intParams[intCount++] = x;        intParams[intCount++] = y;        intParams[intCount++] = width;        intParams[intCount++] = height;        raisePrimitiveFlag();    }    void fillRoundRectangle (final int x, final int y, final int width, final int height, final int arcWidth, final int arcHeight) {        ensureIntArraySpace(7);        intParams[intCount++] = OP_FILLROUNDRECT;        intParams[intCount++] = x;        intParams[intCount++] = y;        intParams[intCount++] = width;        intParams[intCount++] = height;        intParams[intCount++] = arcWidth;        intParams[intCount++] = arcHeight;        raisePrimitiveFlag();    }    public void setBackgroundAlpha(final int alpha) {        ensureIntArraySpace(2);        intParams[intCount++] = OP_SETBACKGROUNDALPHA;        intParams[intCount++] = alpha;    }    void setBackgroundColor(final int argb, final boolean updateAlpha) {        ensureIntArraySpace(3);        intParams[intCount++] = OP_SETBACKGROUNDCOLOR;        intParams[intCount++] = argb;        intParams[intCount++] = updateAlpha? 1 : 0;    }    void setBlendingMode(final int mode) {        ensureIntArraySpace(2);        intParams[intCount++] = OP_SETBLENDINGMODE;        intParams[intCount++] = mode;    }    void setClip(final int x, final int y, final int width, final int height, final boolean intersects) {        ensureIntArraySpace(6);        intParams[intCount++] = OP_SETCLIP;        intParams[intCount++] = x;        intParams[intCount++] = y;        intParams[intCount++] = width;        intParams[intCount++] = height;        intParams[intCount++] = intersects? 1 : 0;    }    void cancelClipping () {        ensureIntArraySpace(1);        intParams[intCount++] = OP_CANCELCLIPPING;    }    void setFont(final int fontHandle) {        ensureIntArraySpace(2);        intParams[intCount++] = OP_SETFONT;        intParams[intCount++] = fontHandle;    }    void setForegroundAlpha(final int alpha) {        ensureIntArraySpace(2);        intParams[intCount++] = OP_SETFOREGROUNDALPHA;        intParams[intCount++] = alpha;    }    void setForegroundColor(final int argb, final boolean updateAlpha) {        ensureIntArraySpace(3);        intParams[intCount++] = OP_SETFOREGROUNDCOLOR;        intParams[intCount++] = argb;        intParams[intCount++] = updateAlpha? 1 : 0;    }    void setStrokeStyle(final int style) {        ensureIntArraySpace(2);        intParams[intCount++] = OP_SETSTROKESTYLE;        intParams[intCount++] = style;    }    void setStrokeWidth(final int width) {        ensureIntArraySpace(2);        intParams[intCount++] = OP_SETSTROKEWIDTH;        intParams[intCount++] = width;    }    void translate(final int x, final int y) {        ensureIntArraySpace(3);        intParams[intCount++] = OP_TRANSLATE;        intParams[intCount++] = x;        intParams[intCount++] = y;    }    void scale(final int x, final int y) {        ensureIntArraySpace(3);        intParams[intCount++] = OP_SCALE;        intParams[intCount++] = x;        intParams[intCount++] = y;    }    void resetTransform() {        ensureIntArraySpace(1);        intParams[intCount++] = OP_RESETTRANSFORM;    }    void copyArea(final Image image, final int x, final int y) {        ensureIntArraySpace(3);        intParams[intCount++] = OP_COPYAREA1;        intParams[intCount++] = x;        intParams[intCount++] = y;        // TODO does this need flushing on the image        images.addElement(new Image(image));        raisePrimitiveFlag();    }    void copyArea(final int srcX, final int srcY, final int width, final int height, final int destX, final int destY, final boolean paint) {        ensureIntArraySpace(8);        intParams[intCount++] = OP_COPYAREA2;        intParams[intCount++] = srcX;        intParams[intCount++] = srcY;        intParams[intCount++] = width;        intParams[intCount++] = height;        intParams[intCount++] = destX;        intParams[intCount++] = destY;        intParams[intCount++] = paint? 1 : 0;        raisePrimitiveFlag();    }    // Unsupported operations    int getAdvancedCharacterWidth(final char ch, final boolean isAdvanced) {        reportNotSupported();        return 0;    }    void getFontMetricsData(final int[] data, final int fontHandle) {        reportNotSupported();    }    int getBackgroundAlpha() {        reportNotSupported();        return 0;    }    int getBackgroundColor() {        reportNotSupported();        return 0;    }    int getBlendingMode() {        reportNotSupported();        return 0;    }    void getClip(final int[] clip) {        reportNotSupported();    }    int getForegroundAlpha() {        reportNotSupported();        return 0;    }    int getForegroundColor() {        reportNotSupported();        return 0;    }    void getTextBoundingBox(final int[] boundingBox, final String string, final int alignments, final int flags, final int rectX, final int rectY, final int rectWidth, final int rectHeight) {        reportNotSupported();    }    int getStrokeWidth() {        reportNotSupported();        return 0;    }    int getStrokeStyle() {        reportNotSupported();        return 0;    }    int getTranslateX() {        reportNotSupported();        return 0;    }    int getTranslateY() {        reportNotSupported();        return 0;    }    boolean hasClipping() {        reportNotSupported();        return false;    }    void saveSettings() {        reportNotSupported();    }    void restoreSettings() {        reportNotSupported();    }}
    14 import java.util.Vector;
       
    15 import java.util.Enumeration;
       
    16 
       
    17 /**
       
    18  * This class implements a command buffer that can be bound by GraphicsContext
       
    19  * to collect the drawing operations. Contents of the command buffer can be replayed to
       
    20  * GraphicsContext target with GraphicsContext.render() method.
       
    21  * * When JavaCommandBuffer is set as the target of GraphicsContext some of the methods
       
    22  * provided by GraphicsContext are not supported, e.g. getters, since the JavaCommandBuffer
       
    23  * does not have a real rendering target from which to query related data. To find out what is
       
    24  * supported see the methods of this class. In principal GraphicsContext supports all draw and set operations,
       
    25  * when JavaCommandBuffer is set as rendering target. */
       
    26 
       
    27 public final class JavaCommandBuffer {
       
    28     // All collected drawing operations and their parameters
       
    29     private int[] intParams;
       
    30     private int intCount;
       
    31     private StringBuffer strParams;
       
    32     // Container for images
       
    33     private Vector images;
       
    34 
       
    35     // Container for rgbData
       
    36     private Vector rgbData;
       
    37 
       
    38     // This flag is indicates if this buffer is bound by some GraphicsContext
       
    39     private boolean bound;
       
    40 
       
    41     // This flag indicates if this buffer is empty or not
       
    42     private boolean containsData;
       
    43 
       
    44     // This flag indicates if this buffer has any draw commands in it
       
    45     private boolean containsPrimitiveData;
       
    46 
       
    47     // Memory management configuration constants
       
    48     private static final int INT_BUF_GRANULARITY         = 2560; // 10kB
       
    49     private static final int INT_BUF_INITIAL_SIZE        = 256; // 1kB
       
    50     private static final int IMAGE_BUF_INITIAL_SIZE      = 256; // 1kB
       
    51     private static final int IMAGE_BUF_GRANULARITY       = 256; // 1kB
       
    52     private static final int STRING_BUFFER_INITIAL_SIZE  = 256; // 1kB
       
    53 
       
    54     // Prefixes for different categories of op codes, stored in MSB
       
    55     final static int DRAW_PREFIX = 0;
       
    56     final static int FILL_PREFIX = 1;
       
    57     final static int SET_PREFIX = 2;
       
    58     final static int MISC_PREFIX = 3;
       
    59 
       
    60     // Unique operation codes for all the gc operations that can be buffered.
       
    61     static final int OP_DRAWARC            = ((DRAW_PREFIX << 24) | 1);
       
    62     static final int OP_DRAWFOCUS          = ((DRAW_PREFIX << 24) | 2);
       
    63     static final int OP_DRAWIMAGE1         = ((DRAW_PREFIX << 24) | 3);
       
    64     static final int OP_DRAWIMAGE2         = ((DRAW_PREFIX << 24) | 4);
       
    65     static final int OP_DRAWLINE           = ((DRAW_PREFIX << 24) | 5);
       
    66     static final int OP_DRAWELLIPSE        = ((DRAW_PREFIX << 24) | 6);
       
    67     static final int OP_DRAWPOINT          = ((DRAW_PREFIX << 24) | 7);
       
    68     static final int OP_DRAWPOLYGON        = ((DRAW_PREFIX << 24) | 8);
       
    69     static final int OP_DRAWPOLYLINE       = ((DRAW_PREFIX << 24) | 9);
       
    70     static final int OP_DRAWRECT           = ((DRAW_PREFIX << 24) | 10);
       
    71     static final int OP_DRAWRGB_INT        = ((DRAW_PREFIX << 24) | 11);
       
    72     static final int OP_DRAWRGB_BYTE       = ((DRAW_PREFIX << 24) | 12);
       
    73     static final int OP_DRAWRGB_SHORT      = ((DRAW_PREFIX << 24) | 13);
       
    74     static final int OP_DRAWROUNDRECT      = ((DRAW_PREFIX << 24) | 14);
       
    75     static final int OP_DRAWSTRING         = ((DRAW_PREFIX << 24) | 15);
       
    76     static final int OP_FILLARC            = ((FILL_PREFIX << 24) | 16);
       
    77     static final int OP_FILLGRADIENTRECT   = ((FILL_PREFIX << 24) | 17);
       
    78     static final int OP_FILLELLIPSE        = ((FILL_PREFIX << 24) | 18);
       
    79     static final int OP_FILLPOLYGON        = ((FILL_PREFIX << 24) | 19);
       
    80     static final int OP_FILLRECT           = ((FILL_PREFIX << 24) | 20);
       
    81     static final int OP_FILLROUNDRECT      = ((FILL_PREFIX << 24) | 21);
       
    82     static final int OP_SETBACKGROUNDALPHA = ((SET_PREFIX << 24) | 22);
       
    83     static final int OP_SETBACKGROUNDCOLOR = ((SET_PREFIX << 24) | 23);
       
    84     static final int OP_SETBLENDINGMODE    = ((SET_PREFIX << 24) | 24);
       
    85     static final int OP_SETCLIP            = ((SET_PREFIX << 24) | 25);
       
    86     static final int OP_CANCELCLIPPING     = ((SET_PREFIX << 24) | 26);
       
    87     static final int OP_SETFONT            = ((SET_PREFIX << 24) | 27);
       
    88     static final int OP_SETFOREGROUNDALPHA = ((SET_PREFIX << 24) | 28);
       
    89     static final int OP_SETFOREGROUNDCOLOR = ((SET_PREFIX << 24) | 29);
       
    90     static final int OP_SETSTROKESTYLE     = ((SET_PREFIX << 24) | 30);
       
    91     static final int OP_SETSTROKEWIDTH     = ((SET_PREFIX << 24) | 31);
       
    92     static final int OP_TRANSLATE          = ((MISC_PREFIX << 24) | 32);
       
    93     static final int OP_SCALE              = ((MISC_PREFIX << 24) | 33);
       
    94     static final int OP_RESETTRANSFORM     = ((MISC_PREFIX << 24) | 34);
       
    95     static final int OP_COPYAREA1          = ((MISC_PREFIX << 24) | 35);
       
    96     static final int OP_COPYAREA2          = ((MISC_PREFIX << 24) | 36);
       
    97     /**    
       
    98  * Constructs empty command buffer with defined buffer sizes.     */
       
    99     public JavaCommandBuffer() {
       
   100         intParams = new int[INT_BUF_INITIAL_SIZE];
       
   101         strParams = new StringBuffer(STRING_BUFFER_INITIAL_SIZE);
       
   102         images = new Vector(IMAGE_BUF_INITIAL_SIZE, IMAGE_BUF_GRANULARITY);
       
   103         rgbData = new Vector(IMAGE_BUF_INITIAL_SIZE, IMAGE_BUF_GRANULARITY);
       
   104     }
       
   105     /**    
       
   106  * Resets the buffer, i.e. removes all recorded commands and related data. The integer array containing    
       
   107  * the actual operation codes is not deleted, only the index pointer is rested, thus the memory consumption of that is not freed.    
       
   108  * CommandBuffer can be reseted only if it is not bound by any GraphicsContext    
       
   109  * @throws IllegalStateException if this CommandBuffer is bound while calling reset     */
       
   110     public void reset() {
       
   111         if(bound) {
       
   112             throw new IllegalStateException("CommandBuffer is still bound by gc");
       
   113         }
       
   114         intCount = 0;
       
   115         strParams.setLength(0);
       
   116         Enumeration allImages = images.elements();
       
   117         while(allImages.hasMoreElements()) {
       
   118             Image image = (Image)allImages.nextElement();
       
   119             if(image != null) {
       
   120                 image.freeCommandBufferCopy();
       
   121             }
       
   122         }
       
   123         images.removeAllElements();
       
   124         rgbData.removeAllElements();
       
   125         containsData = false;
       
   126         containsPrimitiveData = false;
       
   127     }
       
   128     /**    
       
   129  * Checks that does this buffer contain any commands    
       
   130  * @return true if any command has been written to buffer otherwise false     */
       
   131     public boolean containsData() {
       
   132         return containsData;
       
   133     }
       
   134     /**    
       
   135  * Checks that does this buffer contain any draw commands, i.e. any setters etc.    
       
   136  * that does to cause any pixels to be rendered are ignored    
       
   137  * @return true if any draw command has been written to buffer otherwise false     */
       
   138     public boolean containsDrawnPrimitives() {
       
   139         return containsPrimitiveData;
       
   140     }
       
   141     /**    
       
   142  * Binds this buffer     */
       
   143     void bind() {
       
   144         bound = true;
       
   145     }
       
   146     /**    
       
   147  * Provides the binding status of this buffer    
       
   148  * @return true if this buffer has been already bound otherwise false     */
       
   149     boolean isBound() {
       
   150         return bound;
       
   151     }
       
   152     /**    
       
   153  * Releases this buffer, i.e. it can be bound by some other GraphicsContext     */
       
   154     void release() {
       
   155         bound = false;
       
   156     }
       
   157     private void ensureIntArraySpace(final int items) {
       
   158         if( intParams.length < intCount + items) {
       
   159             int[] dst = new int[intParams.length + Math.max(INT_BUF_GRANULARITY, items)];
       
   160             System.arraycopy(intParams, 0, dst, 0, intParams.length);
       
   161             intParams = dst;
       
   162         }
       
   163         containsData = true;
       
   164     }
       
   165     private void reportNotSupported() {
       
   166         throw new RuntimeException("Intenal: Operation not supported with JavaCommandBuffer");
       
   167     }
       
   168 //    private void printBufferInfo() {
       
   169 //        System.out.println("CommandBuffer Info: " +this);
       
   170 //        System.out.println("intParamCount: " + intCount);
       
   171 //        System.out.println("intBuffer Size: " + intParams.length);
       
   172 //        System.out.println("StringBuffer Size: " + strParams.length());
       
   173 //    }
       
   174     private void raisePrimitiveFlag() {
       
   175         containsPrimitiveData = true;
       
   176     }
       
   177     int[] intParams() {
       
   178         return intParams;
       
   179     }
       
   180     int intParamCount() {
       
   181         return intCount;
       
   182     }
       
   183     Vector rgbParams() {
       
   184         return rgbData;
       
   185     }
       
   186     Vector images() {
       
   187         return images;
       
   188     }
       
   189     String strParams() {
       
   190         return strParams.toString();
       
   191     }
       
   192     void drawArc (final int x, final int y, final int width, final int height, final int startAngle, final int arcAngle) {
       
   193         ensureIntArraySpace(7);
       
   194         intParams[intCount++] = OP_DRAWARC;
       
   195         intParams[intCount++] = x;
       
   196         intParams[intCount++] = y;
       
   197         intParams[intCount++] = width;
       
   198         intParams[intCount++] = height;
       
   199         intParams[intCount++] = startAngle;
       
   200         intParams[intCount++] = arcAngle;
       
   201         raisePrimitiveFlag();
       
   202     }
       
   203     void drawFocus (final int x, final int y, final int width, final int height) {
       
   204         ensureIntArraySpace(5);
       
   205         intParams[intCount++] = OP_DRAWFOCUS;
       
   206         intParams[intCount++] = x;
       
   207         intParams[intCount++] = y;
       
   208         intParams[intCount++] = width;
       
   209         intParams[intCount++] = height;
       
   210         raisePrimitiveFlag();
       
   211     }
       
   212     // Must be called from UI thread as images cannot be creates outside that
       
   213     void drawImage(final Image image, final int x, final int y) {
       
   214         ensureIntArraySpace(3);
       
   215         intParams[intCount++] = OP_DRAWIMAGE1;
       
   216         intParams[intCount++] = x;
       
   217         intParams[intCount++] = y;
       
   218         // creating copy of image here uses implicit data sharing,
       
   219         // thus only a shallow copy is made
       
   220         images.addElement(image.getCommandBufferCopy());
       
   221         raisePrimitiveFlag();
       
   222     }
       
   223     // must be called from UI thread as images cannot be creates outside that
       
   224     void drawImage(final Image image, final int tx, final int ty, final int tw, final int th, final int sx, final int sy, final int sw, final int sh, final int manipulation) {
       
   225         ensureIntArraySpace(10);
       
   226         intParams[intCount++] = OP_DRAWIMAGE2;
       
   227         intParams[intCount++] = tx;
       
   228         intParams[intCount++] = ty;
       
   229         intParams[intCount++] = tw;
       
   230         intParams[intCount++] = th;
       
   231         intParams[intCount++] = sx;
       
   232         intParams[intCount++] = sy;
       
   233         intParams[intCount++] = sw;
       
   234         intParams[intCount++] = sh;
       
   235         intParams[intCount++] = manipulation;
       
   236         // creating copy of image here uses implicit data sharing,
       
   237         // thus only a shallow copy is made
       
   238         images.addElement(image.getCommandBufferCopy());
       
   239         raisePrimitiveFlag();
       
   240     }
       
   241     void drawLine (final int x1, final int y1, final int x2, final int y2) {
       
   242         ensureIntArraySpace(5);
       
   243         intParams[intCount++] = OP_DRAWLINE;
       
   244         intParams[intCount++] = x1;
       
   245         intParams[intCount++] = y1;
       
   246         intParams[intCount++] = x2;
       
   247         intParams[intCount++] = y2;
       
   248         raisePrimitiveFlag();
       
   249     }
       
   250     void drawEllipse (final int x, final int y, final int width, final int height) {
       
   251         ensureIntArraySpace(5);
       
   252         intParams[intCount++] = OP_DRAWELLIPSE;
       
   253         intParams[intCount++] = x;
       
   254         intParams[intCount++] = y;
       
   255         intParams[intCount++] = width;
       
   256         intParams[intCount++] = height;
       
   257         raisePrimitiveFlag();
       
   258     }
       
   259     void drawPoint (final int x, final int y) {
       
   260         ensureIntArraySpace(3);
       
   261         intParams[intCount++] = OP_DRAWPOINT;
       
   262         intParams[intCount++] = x;
       
   263         intParams[intCount++] = y;
       
   264         raisePrimitiveFlag();
       
   265     }
       
   266     void drawPolygon(final int[] pointArray) {
       
   267         ensureIntArraySpace(2 + pointArray.length);
       
   268         intParams[intCount++] = OP_DRAWPOLYGON;
       
   269         intParams[intCount++] = pointArray.length;
       
   270         for(int i = 0; i < pointArray.length; ++i) {
       
   271             intParams[intCount++] = pointArray[i];
       
   272         }
       
   273         raisePrimitiveFlag();
       
   274     }
       
   275     void drawPolyline(final int[] pointArray) {
       
   276         ensureIntArraySpace(2 + pointArray.length);
       
   277         intParams[intCount++] = OP_DRAWPOLYLINE;
       
   278         intParams[intCount++] = pointArray.length;
       
   279         for(int i = 0; i < pointArray.length; ++i) {
       
   280             intParams[intCount++] = pointArray[i];
       
   281         }
       
   282         raisePrimitiveFlag();
       
   283     }
       
   284     void drawRect (final int x, final int y, final int width, final int height) {
       
   285         ensureIntArraySpace(5);
       
   286         intParams[intCount++] = OP_DRAWRECT;
       
   287         intParams[intCount++] = x;
       
   288         intParams[intCount++] = y;
       
   289         intParams[intCount++] = width;
       
   290         intParams[intCount++] = height;
       
   291         raisePrimitiveFlag();
       
   292     }
       
   293     void drawRGB(final int[] rgb, final int offset, final int scanlength, final int x, final int y, final int width, final int height, final boolean processAlpha, final int manipulation) {
       
   294         ensureIntArraySpace(9);
       
   295         intParams[intCount++] = OP_DRAWRGB_INT;
       
   296         intParams[intCount++] = offset;
       
   297         intParams[intCount++] = scanlength;
       
   298         intParams[intCount++] = x;
       
   299         intParams[intCount++] = y;
       
   300         intParams[intCount++] = width;
       
   301         intParams[intCount++] = height;
       
   302         intParams[intCount++] = processAlpha? 1 : 0;
       
   303         intParams[intCount++] = manipulation;
       
   304         rgbData.addElement(rgb);
       
   305         raisePrimitiveFlag();
       
   306     }
       
   307     void drawRGB(final byte[] rgb, final byte[] transparencyMask, final int offset, final int scanlength, final int x, final int y, final int width, final int height, final int manipulation, final int format) {
       
   308         ensureIntArraySpace(9);
       
   309         intParams[intCount++] = OP_DRAWRGB_BYTE;
       
   310         intParams[intCount++] = offset;
       
   311         intParams[intCount++] = scanlength;
       
   312         intParams[intCount++] = x;
       
   313         intParams[intCount++] = y;
       
   314         intParams[intCount++] = width;
       
   315         intParams[intCount++] = height;
       
   316         intParams[intCount++] = manipulation;
       
   317         intParams[intCount++] = format;
       
   318         rgbData.addElement(rgb);
       
   319         rgbData.addElement(transparencyMask);
       
   320         raisePrimitiveFlag();
       
   321     }
       
   322     void drawRGB(final short[] rgb, final int offset, final int scanlength, final int x, final int y, final int width, final int height, final boolean processAlpha, final int manipulation, final int format) {
       
   323         ensureIntArraySpace(10);
       
   324         intParams[intCount++] = OP_DRAWRGB_SHORT;
       
   325         intParams[intCount++] = offset;
       
   326         intParams[intCount++] = scanlength;
       
   327         intParams[intCount++] = x;
       
   328         intParams[intCount++] = y;
       
   329         intParams[intCount++] = width;
       
   330         intParams[intCount++] = height;
       
   331         intParams[intCount++] = processAlpha? 1 : 0;
       
   332         intParams[intCount++] = manipulation;
       
   333         intParams[intCount++] = format;
       
   334         rgbData.addElement(rgb);
       
   335         raisePrimitiveFlag();
       
   336     }
       
   337     void drawRoundRect (final int x, final int y, final int width, final int height, final int arcWidth, final int arcHeight) {
       
   338         ensureIntArraySpace(7);
       
   339         intParams[intCount++] = OP_DRAWROUNDRECT;
       
   340         intParams[intCount++] = x;
       
   341         intParams[intCount++] = y;
       
   342         intParams[intCount++] = width;
       
   343         intParams[intCount++] = height;
       
   344         intParams[intCount++] = arcWidth;
       
   345         intParams[intCount++] = arcHeight;
       
   346         raisePrimitiveFlag();
       
   347     }
       
   348     void drawString(final String string, final int x, final int y, final int width, final int height, final int alignments, final int flags, final boolean isTransparent) {
       
   349         ensureIntArraySpace(9);
       
   350         intParams[intCount++] = OP_DRAWSTRING;
       
   351         intParams[intCount++] = string.length();
       
   352         intParams[intCount++] = x;
       
   353         intParams[intCount++] = y;
       
   354         intParams[intCount++] = width;
       
   355         intParams[intCount++] = height;
       
   356         intParams[intCount++] = alignments;
       
   357         intParams[intCount++] = flags;
       
   358         intParams[intCount++] = isTransparent? 1 : 0;
       
   359         strParams.append(string);
       
   360         raisePrimitiveFlag();
       
   361     }
       
   362     void fillArc (final int x, final int y, final int width, final int height, final int startAngle, final int arcAngle) {
       
   363         ensureIntArraySpace(7);
       
   364         intParams[intCount++] = OP_FILLARC;
       
   365         intParams[intCount++] = x;
       
   366         intParams[intCount++] = y;
       
   367         intParams[intCount++] = width;
       
   368         intParams[intCount++] = height;
       
   369         intParams[intCount++] = startAngle;
       
   370         intParams[intCount++] = arcAngle;
       
   371         raisePrimitiveFlag();
       
   372     }
       
   373     void fillGradientRect(final int x, final int y, final int width, final int height, final boolean vertical, final boolean swapColors) {
       
   374         ensureIntArraySpace(7);
       
   375         intParams[intCount++] = OP_FILLGRADIENTRECT;
       
   376         intParams[intCount++] = x;
       
   377         intParams[intCount++] = y;
       
   378         intParams[intCount++] = width;
       
   379         intParams[intCount++] = height;
       
   380         intParams[intCount++] = vertical ? 1 : 0;
       
   381         intParams[intCount++] = swapColors ? 1 : 0;
       
   382         raisePrimitiveFlag();
       
   383     }
       
   384     void fillEllipse (final int x, final int y, final int width, final int height) {
       
   385         ensureIntArraySpace(5);
       
   386         intParams[intCount++] = OP_FILLELLIPSE;
       
   387         intParams[intCount++] = x;
       
   388         intParams[intCount++] = y;
       
   389         intParams[intCount++] = width;
       
   390         intParams[intCount++] = height;
       
   391         raisePrimitiveFlag();
       
   392     }
       
   393     void fillPolygon (final int[] pointArray) {
       
   394         ensureIntArraySpace(2 + pointArray.length);
       
   395         intParams[intCount++] = OP_FILLPOLYGON;
       
   396         intParams[intCount++] = pointArray.length;
       
   397         for(int i = 0; i < pointArray.length; ++i) {
       
   398             intParams[intCount++] = pointArray[i];
       
   399         }
       
   400         raisePrimitiveFlag();
       
   401     }
       
   402     void fillRect (final int x, final int y, final int width, final int height) {
       
   403         ensureIntArraySpace(5);
       
   404         intParams[intCount++] = OP_FILLRECT;
       
   405         intParams[intCount++] = x;
       
   406         intParams[intCount++] = y;
       
   407         intParams[intCount++] = width;
       
   408         intParams[intCount++] = height;
       
   409         raisePrimitiveFlag();
       
   410     }
       
   411     void fillRoundRectangle (final int x, final int y, final int width, final int height, final int arcWidth, final int arcHeight) {
       
   412         ensureIntArraySpace(7);
       
   413         intParams[intCount++] = OP_FILLROUNDRECT;
       
   414         intParams[intCount++] = x;
       
   415         intParams[intCount++] = y;
       
   416         intParams[intCount++] = width;
       
   417         intParams[intCount++] = height;
       
   418         intParams[intCount++] = arcWidth;
       
   419         intParams[intCount++] = arcHeight;
       
   420         raisePrimitiveFlag();
       
   421     }
       
   422     public void setBackgroundAlpha(final int alpha) {
       
   423         ensureIntArraySpace(2);
       
   424         intParams[intCount++] = OP_SETBACKGROUNDALPHA;
       
   425         intParams[intCount++] = alpha;
       
   426     }
       
   427     void setBackgroundColor(final int argb, final boolean updateAlpha) {
       
   428         ensureIntArraySpace(3);
       
   429         intParams[intCount++] = OP_SETBACKGROUNDCOLOR;
       
   430         intParams[intCount++] = argb;
       
   431         intParams[intCount++] = updateAlpha? 1 : 0;
       
   432     }
       
   433     void setBlendingMode(final int mode) {
       
   434         ensureIntArraySpace(2);
       
   435         intParams[intCount++] = OP_SETBLENDINGMODE;
       
   436         intParams[intCount++] = mode;
       
   437     }
       
   438     void setClip(final int x, final int y, final int width, final int height, final boolean intersects) {
       
   439         ensureIntArraySpace(6);
       
   440         intParams[intCount++] = OP_SETCLIP;
       
   441         intParams[intCount++] = x;
       
   442         intParams[intCount++] = y;
       
   443         intParams[intCount++] = width;
       
   444         intParams[intCount++] = height;
       
   445         intParams[intCount++] = intersects? 1 : 0;
       
   446     }
       
   447     void cancelClipping () {
       
   448         ensureIntArraySpace(1);
       
   449         intParams[intCount++] = OP_CANCELCLIPPING;
       
   450     }
       
   451     void setFont(final int fontHandle) {
       
   452         ensureIntArraySpace(2);
       
   453         intParams[intCount++] = OP_SETFONT;
       
   454         intParams[intCount++] = fontHandle;
       
   455     }
       
   456     void setForegroundAlpha(final int alpha) {
       
   457         ensureIntArraySpace(2);
       
   458         intParams[intCount++] = OP_SETFOREGROUNDALPHA;
       
   459         intParams[intCount++] = alpha;
       
   460     }
       
   461     void setForegroundColor(final int argb, final boolean updateAlpha) {
       
   462         ensureIntArraySpace(3);
       
   463         intParams[intCount++] = OP_SETFOREGROUNDCOLOR;
       
   464         intParams[intCount++] = argb;
       
   465         intParams[intCount++] = updateAlpha? 1 : 0;
       
   466     }
       
   467     void setStrokeStyle(final int style) {
       
   468         ensureIntArraySpace(2);
       
   469         intParams[intCount++] = OP_SETSTROKESTYLE;
       
   470         intParams[intCount++] = style;
       
   471     }
       
   472     void setStrokeWidth(final int width) {
       
   473         ensureIntArraySpace(2);
       
   474         intParams[intCount++] = OP_SETSTROKEWIDTH;
       
   475         intParams[intCount++] = width;
       
   476     }
       
   477     void translate(final int x, final int y) {
       
   478         ensureIntArraySpace(3);
       
   479         intParams[intCount++] = OP_TRANSLATE;
       
   480         intParams[intCount++] = x;
       
   481         intParams[intCount++] = y;
       
   482     }
       
   483     void scale(final int x, final int y) {
       
   484         ensureIntArraySpace(3);
       
   485         intParams[intCount++] = OP_SCALE;
       
   486         intParams[intCount++] = x;
       
   487         intParams[intCount++] = y;
       
   488     }
       
   489     void resetTransform() {
       
   490         ensureIntArraySpace(1);
       
   491         intParams[intCount++] = OP_RESETTRANSFORM;
       
   492     }
       
   493     void copyArea(final Image image, final int x, final int y) {
       
   494         ensureIntArraySpace(3);
       
   495         intParams[intCount++] = OP_COPYAREA1;
       
   496         intParams[intCount++] = x;
       
   497         intParams[intCount++] = y;
       
   498         // TODO does this need flushing on the image
       
   499         images.addElement(new Image(image));
       
   500         raisePrimitiveFlag();
       
   501     }
       
   502     void copyArea(final int srcX, final int srcY, final int width, final int height, final int destX, final int destY, final boolean paint) {
       
   503         ensureIntArraySpace(8);
       
   504         intParams[intCount++] = OP_COPYAREA2;
       
   505         intParams[intCount++] = srcX;
       
   506         intParams[intCount++] = srcY;
       
   507         intParams[intCount++] = width;
       
   508         intParams[intCount++] = height;
       
   509         intParams[intCount++] = destX;
       
   510         intParams[intCount++] = destY;
       
   511         intParams[intCount++] = paint? 1 : 0;
       
   512         raisePrimitiveFlag();
       
   513     }
       
   514     // Unsupported operations
       
   515     int getAdvancedCharacterWidth(final char ch, final boolean isAdvanced) {
       
   516         reportNotSupported();
       
   517         return 0;
       
   518     }
       
   519     void getFontMetricsData(final int[] data, final int fontHandle) {
       
   520         reportNotSupported();
       
   521     }
       
   522     int getBackgroundAlpha() {
       
   523         reportNotSupported();
       
   524         return 0;
       
   525     }
       
   526     int getBackgroundColor() {
       
   527         reportNotSupported();
       
   528         return 0;
       
   529     }
       
   530     int getBlendingMode() {
       
   531         reportNotSupported();
       
   532         return 0;
       
   533     }
       
   534     void getClip(final int[] clip) {
       
   535         reportNotSupported();
       
   536     }
       
   537     int getForegroundAlpha() {
       
   538         reportNotSupported();
       
   539         return 0;
       
   540     }
       
   541     int getForegroundColor() {
       
   542         reportNotSupported();
       
   543         return 0;
       
   544     }
       
   545     void getTextBoundingBox(final int[] boundingBox, final String string, final int alignments, final int flags, final int rectX, final int rectY, final int rectWidth, final int rectHeight) {
       
   546         reportNotSupported();
       
   547     }
       
   548     int getStrokeWidth() {
       
   549         reportNotSupported();
       
   550         return 0;
       
   551     }
       
   552     int getStrokeStyle() {
       
   553         reportNotSupported();
       
   554         return 0;
       
   555     }
       
   556     int getTranslateX() {
       
   557         reportNotSupported();
       
   558         return 0;
       
   559     }
       
   560     int getTranslateY() {
       
   561         reportNotSupported();
       
   562         return 0;
       
   563     }
       
   564     boolean hasClipping() {
       
   565         reportNotSupported();
       
   566         return false;
       
   567     }
       
   568     void saveSettings() {
       
   569         reportNotSupported();
       
   570     }
       
   571     void restoreSettings() {
       
   572         reportNotSupported();
       
   573     }
       
   574 }