diff --git a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/assets/loaders/CubemapLoader.java b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/assets/loaders/CubemapLoader.java index 062c8b04..675c1b92 100644 --- a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/assets/loaders/CubemapLoader.java +++ b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/assets/loaders/CubemapLoader.java @@ -10,7 +10,6 @@ import com.badlogic.gdx.graphics.Pixmap.Format; import com.badlogic.gdx.graphics.Texture.TextureFilter; import com.badlogic.gdx.graphics.Texture.TextureWrap; -import com.badlogic.gdx.graphics.TextureData; import com.badlogic.gdx.utils.Array; /** {@link AssetLoader} for {@link Cubemap} instances. The pixel data is loaded asynchronously. The texture is then created on the diff --git a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/Pixmap.java b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/Pixmap.java index b1316ad0..82c43fff 100644 --- a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/Pixmap.java +++ b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/Pixmap.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright 2011 See AUTHORS file. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,6 +23,10 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.html.CanvasPixelArray; +import org.w3c.dom.html.CanvasRenderingContext2D; +import org.w3c.dom.html.HTMLCanvasElement; +import org.w3c.dom.html.Window; import com.badlogic.gdx.backends.dragome.DragomeFileHandle; import com.badlogic.gdx.files.FileHandle; @@ -31,54 +35,71 @@ import com.badlogic.gdx.utils.GdxRuntimeException; import com.dragome.services.WebServiceLocator; import com.dragome.web.enhancers.jsdelegate.JsDelegateFactory; -import com.dragome.web.html.dom.html5canvas.interfaces.CanvasPixelArray; -import com.dragome.web.html.dom.html5canvas.interfaces.CanvasRenderingContext2D; -import com.dragome.web.html.dom.html5canvas.interfaces.HTMLCanvasElement; -import com.dragome.web.html.dom.html5canvas.interfaces.ImageElement; +import com.dragome.web.html.dom.w3c.HTMLImageElementExtension; -public class Pixmap implements Disposable { - public static Map pixmaps = new HashMap(); - static int nextId = 0; +public class Pixmap implements Disposable +{ + public static Map pixmaps= new HashMap(); + static int nextId= 0; /** Different pixel formats. - * + * * @author mzechner */ - public enum Format { + public enum Format + { Alpha, Intensity, LuminanceAlpha, RGB565, RGBA4444, RGB888, RGBA8888; - - public static int toGlFormat (Format format) { - if (format == Alpha) return GL20.GL_ALPHA; - if (format == Intensity) return GL20.GL_ALPHA; - if (format == LuminanceAlpha) return GL20.GL_LUMINANCE_ALPHA; - if (format == RGB565) return GL20.GL_RGB; - if (format == RGB888) return GL20.GL_RGB; - if (format == RGBA4444) return GL20.GL_RGBA; - if (format == RGBA8888) return GL20.GL_RGBA; + + public static int toGlFormat(Format format) + { + if (format == Alpha) + return GL20.GL_ALPHA; + if (format == Intensity) + return GL20.GL_ALPHA; + if (format == LuminanceAlpha) + return GL20.GL_LUMINANCE_ALPHA; + if (format == RGB565) + return GL20.GL_RGB; + if (format == RGB888) + return GL20.GL_RGB; + if (format == RGBA4444) + return GL20.GL_RGBA; + if (format == RGBA8888) + return GL20.GL_RGBA; throw new GdxRuntimeException("unknown format: " + format); } - - public static int toGlType (Format format) { - if (format == Alpha) return GL20.GL_UNSIGNED_BYTE; - if (format == Intensity) return GL20.GL_UNSIGNED_BYTE; - if (format == LuminanceAlpha) return GL20.GL_UNSIGNED_BYTE; - if (format == RGB565) return GL20.GL_UNSIGNED_SHORT_5_6_5; - if (format == RGB888) return GL20.GL_UNSIGNED_BYTE; - if (format == RGBA4444) return GL20.GL_UNSIGNED_SHORT_4_4_4_4; - if (format == RGBA8888) return GL20.GL_UNSIGNED_BYTE; + + public static int toGlType(Format format) + { + if (format == Alpha) + return GL20.GL_UNSIGNED_BYTE; + if (format == Intensity) + return GL20.GL_UNSIGNED_BYTE; + if (format == LuminanceAlpha) + return GL20.GL_UNSIGNED_BYTE; + if (format == RGB565) + return GL20.GL_UNSIGNED_SHORT_5_6_5; + if (format == RGB888) + return GL20.GL_UNSIGNED_BYTE; + if (format == RGBA4444) + return GL20.GL_UNSIGNED_SHORT_4_4_4_4; + if (format == RGBA8888) + return GL20.GL_UNSIGNED_BYTE; throw new GdxRuntimeException("unknown format: " + format); } } /** Blending functions to be set with {@link Pixmap#setBlending}. * @author mzechner */ - public enum Blending { + public enum Blending + { None, SourceOver } /** Filters to be used with {@link Pixmap#drawPixmap(Pixmap, int, int, int, int, int, int, int, int)}. - * + * * @author mzechner */ - public enum Filter { + public enum Filter + { NearestNeighbour, BiLinear } @@ -89,195 +110,222 @@ public enum Filter { CanvasRenderingContext2D context; int id; IntBuffer buffer; - int r = 255, g = 255, b = 255; + int r= 255, g= 255, b= 255; float a; - String color = make(r, g, b, a); - static String clearColor = make(255, 255, 255, 1.0f); + String color= make(r, g, b, a); + static String clearColor= make(255, 255, 255, 1.0f); static Blending blending; CanvasPixelArray pixels; - public Pixmap (FileHandle file) { - DragomeFileHandle dragomeFile = (DragomeFileHandle)file; - ImageElement img = dragomeFile.preloader.images.get(file.path()); - if (img == null) throw new GdxRuntimeException("Couldn't load image '" + file.path() + "', file does not exist"); - create(img.getWidth(), img.getHeight(), Format.RGBA8888); + public Pixmap(FileHandle file) + { + DragomeFileHandle dragomeFile= (DragomeFileHandle) file; + HTMLImageElementExtension img= dragomeFile.preloader.images.get(file.path()); + if (img == null) + throw new GdxRuntimeException("Couldn't load image '" + file.path() + "', file does not exist"); + create(img.getWidthAsInteger(), img.getHeightAsInteger(), Format.RGBA8888); context.setGlobalCompositeOperation(Composite.COPY); context.drawImage(img, 0, 0); context.setGlobalCompositeOperation(getComposite()); } - private static String getComposite () { + private static String getComposite() + { return Composite.SOURCE_OVER; } - public Pixmap (ImageElement img) { - create(img.getWidth(), img.getHeight(), Format.RGBA8888); + public Pixmap(HTMLImageElementExtension img) + { + create(img.getWidthAsInteger(), img.getHeightAsInteger(), Format.RGBA8888); context.drawImage(img, 0, 0); } - public Pixmap (int width, int height, Format format) { + public Pixmap(int width, int height, Format format) + { create(width, height, format); } - private void create (int width, int height, Format format2) { - this.width = width; - this.height = height; - this.format = Format.RGBA8888; - Document document = WebServiceLocator.getInstance().getDomHandler().getDocument(); - Element createElement = document.createElement("canvas"); - canvas = JsDelegateFactory.createFromNode(createElement, HTMLCanvasElement.class); + private void create(int width, int height, Format format2) + { + this.width= width; + this.height= height; + this.format= Format.RGBA8888; + Document document= WebServiceLocator.getInstance().getDomHandler().getDocument(); + Element createElement= document.createElement("canvas"); + canvas= JsDelegateFactory.createFromNode(createElement, HTMLCanvasElement.class); canvas.setWidth(width); canvas.setHeight(height); - context = canvas.getContext("2d"); + context= (CanvasRenderingContext2D) canvas.getContext("2d"); context.setGlobalCompositeOperation(getComposite()); - buffer = BufferUtils.newIntBuffer(1); - id = nextId++; + buffer= BufferUtils.newIntBuffer(1); + id= nextId++; buffer.put(0, id); pixmaps.put(id, this); } - public static String make (int r2, int g2, int b2, float a2) { + public static String make(int r2, int g2, int b2, float a2) + { return "rgba(" + r2 + "," + g2 + "," + b2 + "," + a2 + ")"; } /** Sets the type of {@link Blending} to be used for all operations. Default is {@link Blending#SourceOver}. * @param blending the blending type */ - public static void setBlending (Blending blending) { - Pixmap.blending = blending; - String composite = getComposite(); - for (Pixmap pixmap : pixmaps.values()) { + public static void setBlending(Blending blending) + { + Pixmap.blending= blending; + String composite= getComposite(); + for (Pixmap pixmap : pixmaps.values()) + { pixmap.context.setGlobalCompositeOperation(composite); } } /** @return the currently set {@link Blending} */ - public static Blending getBlending () { + public static Blending getBlending() + { return blending; } /** Sets the type of interpolation {@link Filter} to be used in conjunction with * {@link Pixmap#drawPixmap(Pixmap, int, int, int, int, int, int, int, int)}. * @param filter the filter. */ - public static void setFilter (Filter filter) { + public static void setFilter(Filter filter) + { } - public Format getFormat () { + public Format getFormat() + { return format; } - public int getGLInternalFormat () { + public int getGLInternalFormat() + { return GL20.GL_RGBA; } - public int getGLFormat () { + public int getGLFormat() + { return GL20.GL_RGBA; } - public int getGLType () { + public int getGLType() + { return GL20.GL_UNSIGNED_BYTE; } - public int getWidth () { + public int getWidth() + { return width; } - public int getHeight () { + public int getHeight() + { return height; } - public Buffer getPixels () { + public Buffer getPixels() + { return buffer; } @Override - public void dispose () { + public void dispose() + { pixmaps.remove(id); } - public HTMLCanvasElement getCanvasElement () { + public HTMLCanvasElement getCanvasElement() + { return canvas; } /** Sets the color for the following drawing operations * @param color the color, encoded as RGBA8888 */ - public void setColor (int color) { - r = (color >>> 24) & 0xff; - g = (color >>> 16) & 0xff; - b = (color >>> 8) & 0xff; - a = (color & 0xff) / 255f; - this.color = make(r, g, b, a); + public void setColor(int color) + { + r= (color >>> 24) & 0xff; + g= (color >>> 16) & 0xff; + b= (color >>> 8) & 0xff; + a= (color & 0xff) / 255f; + this.color= make(r, g, b, a); context.setFillStyle(this.color); context.setStrokeStyle(this.color); } /** Sets the color for the following drawing operations. - * + * * @param r The red component. * @param g The green component. * @param b The blue component. * @param a The alpha component. */ - public void setColor (float r, float g, float b, float a) { - this.r = (int)(r * 255); - this.g = (int)(g * 255); - this.b = (int)(b * 255); - this.a = a; - color = make(this.r, this.g, this.b, this.a); + public void setColor(float r, float g, float b, float a) + { + this.r= (int) (r * 255); + this.g= (int) (g * 255); + this.b= (int) (b * 255); + this.a= a; + color= make(this.r, this.g, this.b, this.a); context.setFillStyle(color); context.setStrokeStyle(this.color); } /** Sets the color for the following drawing operations. * @param color The color. */ - public void setColor (Color color) { + public void setColor(Color color) + { setColor(color.r, color.g, color.b, color.a); } /** Fills the complete bitmap with the currently set color. */ - public void fill () { + public void fill() + { context.clearRect(0, 0, getWidth(), getHeight()); rectangle(0, 0, getWidth(), getHeight(), DrawType.FILL); } -// /** -// * Sets the width in pixels of strokes. -// * -// * @param width The stroke width in pixels. -// */ -// public void setStrokeWidth (int width); + // /** + // * Sets the width in pixels of strokes. + // * + // * @param width The stroke width in pixels. + // */ + // public void setStrokeWidth (int width); /** Draws a line between the given coordinates using the currently set color. - * + * * @param x The x-coodinate of the first point * @param y The y-coordinate of the first point * @param x2 The x-coordinate of the first point * @param y2 The y-coordinate of the first point */ - public void drawLine (int x, int y, int x2, int y2) { + public void drawLine(int x, int y, int x2, int y2) + { line(x, y, x2, y2, DrawType.STROKE); } /** Draws a rectangle outline starting at x, y extending by width to the right and by height downwards (y-axis points downwards) * using the current color. - * + * * @param x The x coordinate * @param y The y coordinate * @param width The width in pixels * @param height The height in pixels */ - public void drawRectangle (int x, int y, int width, int height) { + public void drawRectangle(int x, int y, int width, int height) + { rectangle(x, y, width, height, DrawType.STROKE); } /** Draws an area form another Pixmap to this Pixmap. - * + * * @param pixmap The other Pixmap * @param x The target x-coordinate (top left corner) * @param y The target y-coordinate (top left corner) */ - public void drawPixmap (Pixmap pixmap, int x, int y) { - HTMLCanvasElement image = pixmap.getCanvasElement(); + public void drawPixmap(Pixmap pixmap, int x, int y) + { + HTMLCanvasElement image= pixmap.getCanvasElement(); image(image, 0, 0, image.getWidth(), image.getHeight(), x, y, image.getWidth(), image.getHeight()); } /** Draws an area form another Pixmap to this Pixmap. - * + * * @param pixmap The other Pixmap * @param x The target x-coordinate (top left corner) * @param y The target y-coordinate (top left corner) @@ -285,15 +333,16 @@ public void drawPixmap (Pixmap pixmap, int x, int y) { * @param srcy The source y-coordinate (top left corner); * @param srcWidth The width of the area form the other Pixmap in pixels * @param srcHeight The height of the area form the other Pixmap in pixles */ - public void drawPixmap (Pixmap pixmap, int x, int y, int srcx, int srcy, int srcWidth, int srcHeight) { - HTMLCanvasElement image = pixmap.getCanvasElement(); - image(image, srcx, srcy, srcWidth, srcHeight, x, y, srcWidth, srcHeight); + public void drawPixmap(Pixmap pixmap, int x, int y, int srcx, int srcy, int srcWidth, int srcHeight) + { + HTMLCanvasElement image= pixmap.getCanvasElement(); + image(image, srcx, srcy, srcWidth, srcHeight, x, y, srcWidth, srcHeight); } /** Draws an area form another Pixmap to this Pixmap. This will automatically scale and stretch the source image to the * specified target rectangle. Use {@link Pixmap#setFilter(Filter)} to specify the type of filtering to be used (nearest * neighbour or bilinear). - * + * * @param pixmap The other Pixmap * @param srcx The source x-coordinate (top left corner) * @param srcy The source y-coordinate (top left corner); @@ -303,87 +352,97 @@ public void drawPixmap (Pixmap pixmap, int x, int y, int srcx, int srcy, int src * @param dsty The target y-coordinate (top left corner) * @param dstWidth The target width * @param dstHeight the target height */ - public void drawPixmap (Pixmap pixmap, int srcx, int srcy, int srcWidth, int srcHeight, int dstx, int dsty, int dstWidth, - int dstHeight) { + public void drawPixmap(Pixmap pixmap, int srcx, int srcy, int srcWidth, int srcHeight, int dstx, int dsty, int dstWidth, int dstHeight) + { image(pixmap.getCanvasElement(), srcx, srcy, srcWidth, srcHeight, dstx, dsty, dstWidth, dstHeight); } /** Fills a rectangle starting at x, y extending by width to the right and by height downwards (y-axis points downwards) using * the current color. - * + * * @param x The x coordinate * @param y The y coordinate * @param width The width in pixels * @param height The height in pixels */ - public void fillRectangle (int x, int y, int width, int height) { + public void fillRectangle(int x, int y, int width, int height) + { rectangle(x, y, width, height, DrawType.FILL); } /** Draws a circle outline with the center at x,y and a radius using the current color and stroke width. - * + * * @param x The x-coordinate of the center * @param y The y-coordinate of the center * @param radius The radius in pixels */ - public void drawCircle (int x, int y, int radius) { + public void drawCircle(int x, int y, int radius) + { circle(x, y, radius, DrawType.STROKE); } /** Fills a circle with the center at x,y and a radius using the current color. - * + * * @param x The x-coordinate of the center * @param y The y-coordinate of the center * @param radius The radius in pixels */ - public void fillCircle (int x, int y, int radius) { + public void fillCircle(int x, int y, int radius) + { circle(x, y, radius, DrawType.FILL); } /** Fills a triangle with vertices at x1,y1 and x2,y2 and x3,y3 using the current color. - * + * * @param x1 The x-coordinate of vertex 1 * @param y1 The y-coordinate of vertex 1 * @param x2 The x-coordinate of vertex 2 * @param y2 The y-coordinate of vertex 2 * @param x3 The x-coordinate of vertex 3 * @param y3 The y-coordinate of vertex 3 */ - public void fillTriangle (int x1, int y1, int x2, int y2, int x3, int y3) { + public void fillTriangle(int x1, int y1, int x2, int y2, int x3, int y3) + { triangle(x1, y1, x2, y2, x3, y3, DrawType.FILL); } /** Returns the 32-bit RGBA8888 value of the pixel at x, y. For Alpha formats the RGB components will be one. - * + * * @param x The x-coordinate * @param y The y-coordinate * @return The pixel color in RGBA8888 format. */ - public int getPixel (int x, int y) { - if (pixels == null) pixels = context.getImageData(0, 0, width, height).getData(); - int i = x * 4 + y * width * 4; - int r = pixels.get(i + 0) & 0xff; - int g = pixels.get(i + 1) & 0xff; - int b = pixels.get(i + 2) & 0xff; - int a = pixels.get(i + 3) & 0xff; + public int getPixel(int x, int y) + { + if (pixels == null) + pixels= context.getImageData(0, 0, width, height).getData(); + int i= x * 4 + y * width * 4; + int r= pixels.getElement(i + 0) & 0xff; + int g= pixels.getElement(i + 1) & 0xff; + int b= pixels.getElement(i + 2) & 0xff; + int a= pixels.getElement(i + 3) & 0xff; return (r << 24) | (g << 16) | (b << 8) | (a); } /** Draws a pixel at the given location with the current color. - * + * * @param x the x-coordinate * @param y the y-coordinate */ - public void drawPixel (int x, int y) { + public void drawPixel(int x, int y) + { rectangle(x, y, 1, 1, DrawType.FILL); } /** Draws a pixel at the given location with the given color. - * + * * @param x the x-coordinate * @param y the y-coordinate * @param color the color in RGBA8888 format. */ - public void drawPixel (int x, int y, int color) { + public void drawPixel(int x, int y, int color) + { setColor(color); drawPixel(x, y); } - private void circle (int x, int y, int radius, DrawType drawType) { - if (blending == Blending.None) { + private void circle(int x, int y, int radius, DrawType drawType) + { + if (blending == Blending.None) + { context.setFillStyle(clearColor); context.setStrokeStyle(clearColor); context.setGlobalCompositeOperation("destination-out"); @@ -399,11 +458,13 @@ private void circle (int x, int y, int radius, DrawType drawType) { context.arc(x, y, radius, 0, 2 * Math.PI, false); fillOrStrokePath(drawType); context.closePath(); - pixels = null; + pixels= null; } - - private void line(int x, int y, int x2, int y2, DrawType drawType) { - if (blending == Blending.None) { + + private void line(int x, int y, int x2, int y2, DrawType drawType) + { + if (blending == Blending.None) + { context.setFillStyle(clearColor); context.setStrokeStyle(clearColor); context.setGlobalCompositeOperation("destination-out"); @@ -415,17 +476,19 @@ private void line(int x, int y, int x2, int y2, DrawType drawType) { context.setFillStyle(color); context.setStrokeStyle(color); context.setGlobalCompositeOperation(Composite.SOURCE_OVER); - } + } context.beginPath(); context.moveTo(x, y); context.lineTo(x2, y2); fillOrStrokePath(drawType); context.closePath(); - pixels = null; + pixels= null; } - - private void rectangle(int x, int y, int width, int height, DrawType drawType) { - if (blending == Blending.None) { + + private void rectangle(int x, int y, int width, int height, DrawType drawType) + { + if (blending == Blending.None) + { context.setFillStyle(clearColor); context.setStrokeStyle(clearColor); context.setGlobalCompositeOperation("destination-out"); @@ -441,37 +504,41 @@ private void rectangle(int x, int y, int width, int height, DrawType drawType) { context.rect(x, y, width, height); fillOrStrokePath(drawType); context.closePath(); - pixels = null; + pixels= null; } - - private void triangle(int x1, int y1, int x2, int y2, int x3, int y3, DrawType drawType) { - if (blending == Blending.None) { + + private void triangle(int x1, int y1, int x2, int y2, int x3, int y3, DrawType drawType) + { + if (blending == Blending.None) + { context.setFillStyle(clearColor); context.setStrokeStyle(clearColor); context.setGlobalCompositeOperation("destination-out"); context.beginPath(); - context.moveTo(x1,y1); - context.lineTo(x2,y2); - context.lineTo(x3,y3); - context.lineTo(x1,y1); + context.moveTo(x1, y1); + context.lineTo(x2, y2); + context.lineTo(x3, y3); + context.lineTo(x1, y1); fillOrStrokePath(drawType); context.closePath(); context.setFillStyle(color); context.setStrokeStyle(color); context.setGlobalCompositeOperation(Composite.SOURCE_OVER); - } + } context.beginPath(); - context.moveTo(x1,y1); - context.lineTo(x2,y2); - context.lineTo(x3,y3); - context.lineTo(x1,y1); + context.moveTo(x1, y1); + context.lineTo(x2, y2); + context.lineTo(x3, y3); + context.lineTo(x1, y1); fillOrStrokePath(drawType); context.closePath(); - pixels = null; + pixels= null; } - - private void image (HTMLCanvasElement image, int srcX, int srcY, int srcWidth, int srcHeight, int dstX, int dstY, int dstWidth, int dstHeight) { - if (blending == Blending.None) { + + private void image(HTMLCanvasElement image, int srcX, int srcY, int srcWidth, int srcHeight, int dstX, int dstY, int dstWidth, int dstHeight) + { + if (blending == Blending.None) + { context.setFillStyle(clearColor); context.setStrokeStyle(clearColor); context.setGlobalCompositeOperation("destination-out"); @@ -484,22 +551,25 @@ private void image (HTMLCanvasElement image, int srcX, int srcY, int srcWidth, i context.setGlobalCompositeOperation(Composite.SOURCE_OVER); } context.drawImage(image, srcX, srcY, srcWidth, srcHeight, dstX, dstY, dstWidth, dstHeight); - pixels = null; + pixels= null; } - - private void fillOrStrokePath(DrawType drawType) { - switch (drawType) { + + private void fillOrStrokePath(DrawType drawType) + { + switch (drawType) + { case FILL: context.fill(); break; case STROKE: context.stroke(); break; - } + } } - - private enum DrawType { + + private enum DrawType + { FILL, STROKE } - + } diff --git a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/TextureData.java b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/TextureData.java index 290c3eea..8a3a004e 100644 --- a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/TextureData.java +++ b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/TextureData.java @@ -3,7 +3,6 @@ import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.Pixmap.Format; import com.badlogic.gdx.graphics.glutils.FileTextureData; -import com.badlogic.gdx.graphics.glutils.MipMapGenerator; /** Used by a {@link Texture} to load the pixel data. A TextureData can either return a {@link Pixmap} or upload the pixel data * itself. It signals it's type via {@link #getType()} to the Texture that's using it. The Texture will then either invoke diff --git a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/glutils/ETC1TextureData.java b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/glutils/ETC1TextureData.java index 38c325df..27da5f9a 100644 --- a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/glutils/ETC1TextureData.java +++ b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/glutils/ETC1TextureData.java @@ -16,11 +16,10 @@ package com.badlogic.gdx.graphics.glutils; -import com.badlogic.gdx.files.FileHandle; -import com.badlogic.gdx.graphics.Pixmap; -import com.badlogic.gdx.graphics.Pixmap.Format; -import com.badlogic.gdx.graphics.glutils.ETC1.ETC1Data; -import com.badlogic.gdx.graphics.TextureData; +import com.badlogic.gdx.files.FileHandle; +import com.badlogic.gdx.graphics.Pixmap; +import com.badlogic.gdx.graphics.Pixmap.Format; +import com.badlogic.gdx.graphics.TextureData; import com.badlogic.gdx.utils.GdxRuntimeException; public class ETC1TextureData implements TextureData { diff --git a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/glutils/IndexBufferObject.java b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/glutils/IndexBufferObject.java index 02c62fd6..ff24aabe 100644 --- a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/glutils/IndexBufferObject.java +++ b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/glutils/IndexBufferObject.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright 2011 See AUTHORS file. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,21 +27,21 @@ * In IndexBufferObject wraps OpenGL's index buffer functionality to be used in conjunction with VBOs. This class can be * seamlessly used with OpenGL ES 1.x and 2.0. *

- * + * *

* Uses indirect Buffers on Android 1.5/1.6 to fix GC invocation due to leaking PlatformAddress instances. *

- * + * *

* You can also use this to store indices for vertex arrays. Do not call {@link #bind()} or {@link #unbind()} in this case but * rather use {@link #getBuffer()} to use the buffer directly with glDrawElements. You must also create the IndexBufferObject with * the second constructor and specify isDirect as true as glDrawElements in conjunction with vertex arrays needs direct buffers. *

- * + * *

* VertexBufferObjects must be disposed via the {@link #dispose()} method when no longer needed *

- * + * * @author mzechner */ public class IndexBufferObject implements IndexData { ShortBuffer buffer; @@ -52,7 +52,7 @@ public class IndexBufferObject implements IndexData { final int usage; /** Creates a new IndexBufferObject. - * + * * @param isStatic whether the index buffer is static * @param maxIndices the maximum number of indices this buffer can hold */ public IndexBufferObject (boolean isStatic, int maxIndices) { @@ -64,7 +64,7 @@ public IndexBufferObject (boolean isStatic, int maxIndices) { } /** Creates a new IndexBufferObject to be used with vertex arrays. - * + * * @param maxIndices the maximum number of indices this buffer can hold */ public IndexBufferObject (int maxIndices) { this.isDirect = true; @@ -88,11 +88,11 @@ public int getNumMaxIndices () { * Sets the indices of this IndexBufferObject, discarding the old indices. The count must equal the number of indices to be * copied to this IndexBufferObject. *

- * + * *

* This can be called in between calls to {@link #bind()} and {@link #unbind()}. The index data will be updated instantly. *

- * + * * @param indices the vertex data * @param offset the offset to start copying the data from * @param count the number of shorts to copy */ @@ -107,20 +107,19 @@ public void setIndices (short[] indices, int offset, int count) { isDirty = false; } } - + public void setIndices (ShortBuffer indices) { isDirty = true; buffer.clear(); buffer.put(indices); buffer.flip(); - + if (isBound) { Gdx.gl20.glBufferData(GL20.GL_ELEMENT_ARRAY_BUFFER, buffer.limit(), buffer, usage); isDirty = false; } } - @Override public void updateIndices (int targetOffset, short[] indices, int offset, int count) { isDirty = true; final int pos = buffer.position(); @@ -138,7 +137,7 @@ public void updateIndices (int targetOffset, short[] indices, int offset, int co * Returns the underlying ShortBuffer. If you modify the buffer contents they wil be uploaded on the call to {@link #bind()}. * If you need immediate uploading use {@link #setIndices(short[], int, int)}. *

- * + * * @return the underlying short buffer. */ public ShortBuffer getBuffer () { isDirty = true; @@ -174,6 +173,6 @@ public void dispose () { GL20 gl = Gdx.gl20; gl.glBindBuffer(GL20.GL_ELEMENT_ARRAY_BUFFER, 0); gl.glDeleteBuffer(bufferHandle); - bufferHandle = 0; + bufferHandle = 0; } } diff --git a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/glutils/VertexBufferObjectWithVAO.java b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/glutils/VertexBufferObjectWithVAO.java index 76fd8079..32ab9823 100644 --- a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/glutils/VertexBufferObjectWithVAO.java +++ b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/glutils/VertexBufferObjectWithVAO.java @@ -1,6 +1,5 @@ package com.badlogic.gdx.graphics.glutils; -import java.nio.ByteBuffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; diff --git a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/profiling/GLErrorListener.java b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/profiling/GLErrorListener.java index 8607c4c2..2c5c4fe6 100644 --- a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/profiling/GLErrorListener.java +++ b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/profiling/GLErrorListener.java @@ -16,9 +16,10 @@ package com.badlogic.gdx.graphics.profiling; +import static com.badlogic.gdx.graphics.profiling.GLProfiler.resolveErrorNumber; + import com.badlogic.gdx.Gdx; import com.badlogic.gdx.utils.GdxRuntimeException; -import static com.badlogic.gdx.graphics.profiling.GLProfiler.resolveErrorNumber; /** @see GLProfiler * @author Jan Polák */ diff --git a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/utils/Utf8Decoder.java b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/utils/Utf8Decoder.java deleted file mode 100644 index 86217721..00000000 --- a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/utils/Utf8Decoder.java +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************* - * Copyright 2015 See AUTHORS file. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -/******************************************************************************* - * Copyright (c) 2008-2009 Bjoern Hoehrmann - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - ******************************************************************************/ - -package com.badlogic.gdx.utils; - -/** Utf8Decoder converts UTF-8 encoded bytes into characters properly handling buffer boundaries. - * - * This class is stateful and up to 4 calls to {@link #decode(byte)} may be needed before a character is appended to the char - * buffer. - * - * The UTF-8 decoding is done by this class and no additional buffers are created. The UTF-8 code was inspired by - * http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ - * - * @author davebaol */ -public class Utf8Decoder { - - private static final char REPLACEMENT = '\ufffd'; - private static final int UTF8_ACCEPT = 0; - private static final int UTF8_REJECT = 12; - - // This table maps bytes to character classes to reduce - // the size of the transition table and create bitmasks. - private static final byte[] BYTE_TABLE = { - // @off - disable libgdx formatter - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, - 10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8 - // @on - enable libgdx formatter - }; - - // This is a transition table that maps a combination of a - // state of the automaton and a character class to a state. - private static final byte[] TRANSITION_TABLE = { - // @off - disable libgdx formatter - 0,12,24,36,60,96,84,12,12,12,48,72, 12,12,12,12,12,12,12,12,12,12,12,12, - 12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24,12,12, - 12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12, - 12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12, - 12,36,12,12,12,12,12,12,12,12,12,12 - // @on - enable libgdx formatter - }; - - private int codePoint; - private int state; - private final char[] utf16Char = new char[2]; - private char[] charBuffer; - private int charOffset; - - public Utf8Decoder () { - this.state = UTF8_ACCEPT; - } - - protected void reset () { - state = UTF8_ACCEPT; - } - - public int decode (byte[] b, int offset, int length, char[] charBuffer, int charOffset) { - this.charBuffer = charBuffer; - this.charOffset = charOffset; - int end = offset + length; - for (int i = offset; i < end; i++) - decode(b[i]); - return this.charOffset - charOffset; - } - - private void decode (byte b) { - - if (b > 0 && state == UTF8_ACCEPT) { - charBuffer[charOffset++] = (char)(b & 0xFF); - } else { - int i = b & 0xFF; - int type = BYTE_TABLE[i]; - codePoint = state == UTF8_ACCEPT ? (0xFF >> type) & i : (i & 0x3F) | (codePoint << 6); - int next = TRANSITION_TABLE[state + type]; - - switch (next) { - case UTF8_ACCEPT: - state = next; - if (codePoint < Character.MIN_HIGH_SURROGATE) { - charBuffer[charOffset++] = (char)codePoint; - } else { - // The code below is equivalent to - // for (char c : Character.toChars(codePoint)) charBuffer[charOffset++] = c; - // but does not allocate a char array. - int codePointLength = Character.toChars(codePoint, utf16Char, 0); - charBuffer[charOffset++] = utf16Char[0]; - if (codePointLength == 2) charBuffer[charOffset++] = utf16Char[1]; - } - break; - - case UTF8_REJECT: - codePoint = 0; - state = UTF8_ACCEPT; - charBuffer[charOffset++] = REPLACEMENT; - break; - - default: - state = next; - break; - } - } - } -} diff --git a/backends/gdx-backend-dragome/emu/com/dragome/web/html/dom/html5canvas/interfaces/CanvasPixelArray.java b/backends/gdx-backend-dragome/emu/com/dragome/web/html/dom/html5canvas/interfaces/CanvasPixelArray.java deleted file mode 100644 index 0d4086d5..00000000 --- a/backends/gdx-backend-dragome/emu/com/dragome/web/html/dom/html5canvas/interfaces/CanvasPixelArray.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.dragome.web.html.dom.html5canvas.interfaces; - -public interface CanvasPixelArray { - public int get(int var); -} diff --git a/backends/gdx-backend-dragome/emu/com/dragome/web/html/dom/html5canvas/interfaces/ImageData.java b/backends/gdx-backend-dragome/emu/com/dragome/web/html/dom/html5canvas/interfaces/ImageData.java deleted file mode 100644 index 72663b26..00000000 --- a/backends/gdx-backend-dragome/emu/com/dragome/web/html/dom/html5canvas/interfaces/ImageData.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.dragome.web.html.dom.html5canvas.interfaces; - -public interface ImageData { - public int getWidth(); - public int getHeight(); - public CanvasPixelArray getData(); -} diff --git a/backends/gdx-backend-dragome/emu/com/dragome/web/html/dom/html5canvas/interfaces/ImageElement.java b/backends/gdx-backend-dragome/emu/com/dragome/web/html/dom/html5canvas/interfaces/ImageElement.java deleted file mode 100644 index b2d86e15..00000000 --- a/backends/gdx-backend-dragome/emu/com/dragome/web/html/dom/html5canvas/interfaces/ImageElement.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.dragome.web.html.dom.html5canvas.interfaces; - -import com.dragome.web.html.dom.html5canvas.interfaces.CanvasImageSource; - -public interface ImageElement extends CanvasImageSource{ - - int getWidth(); - int getHeight(); - void setSrc(String src); -} diff --git a/backends/gdx-backend-dragome/emu/java/io/BufferedInputStream.java b/backends/gdx-backend-dragome/emu/java/io/BufferedInputStream.java deleted file mode 100644 index e96157d3..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/BufferedInputStream.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright 2011 See AUTHORS file. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package java.io; - -public class BufferedInputStream extends FilterInputStream { - public BufferedInputStream (InputStream in) { - super(in); - } - - public BufferedInputStream (InputStream in, int size) { - super(in); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/BufferedReader.java b/backends/gdx-backend-dragome/emu/java/io/BufferedReader.java deleted file mode 100644 index b1294841..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/BufferedReader.java +++ /dev/null @@ -1,108 +0,0 @@ -/* Copyright (c) 2008, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -package java.io; - -public class BufferedReader extends Reader { - private final Reader in; - private final char[] buffer; - private int position; - private int limit; - - public BufferedReader (Reader in, int bufferSize) { - this.in = in; - this.buffer = new char[bufferSize]; - } - - public BufferedReader (Reader in) { - this(in, 8192); - } - - private void fill () throws IOException { - position = 0; - limit = in.read(buffer); - } - - public String readLine () throws IOException { - StringBuilder sb = new StringBuilder(); - while (true) { - if (position >= limit) { - fill(); - } - - if (position >= limit) { - return sb.length() == 0 ? null : sb.toString(); - } - - for (int i = position; i < limit; ++i) { - if (buffer[i] == '\r') { - sb.append(buffer, position, i - position); - position = i + 1; - if (i + 1 < limit) { - if (buffer[i + 1] == '\n') { - position = i + 2; - } - } else { - fill(); - if (buffer[position] == '\n') { - position += 1; - } - } - return sb.toString(); - } else if (buffer[i] == '\n') { - sb.append(buffer, position, i - position); - position = i + 1; - return sb.toString(); - } - } - sb.append(buffer, position, limit - position); - position = limit; - } - } - - public int read (char[] b, int offset, int length) throws IOException { - int count = 0; - - if (position >= limit && length < buffer.length) { - fill(); - } - - if (position < limit) { - int remaining = limit - position; - if (remaining > length) { - remaining = length; - } - - System.arraycopy(buffer, position, b, offset, remaining); - - count += remaining; - position += remaining; - offset += remaining; - length -= remaining; - } - - if (length > 0) { - int c = in.read(b, offset, length); - if (c == -1) { - if (count == 0) { - count = -1; - } - } else { - count += c; - } - } - - return count; - } - - public void close () throws IOException { - in.close(); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/BufferedWriter.java b/backends/gdx-backend-dragome/emu/java/io/BufferedWriter.java deleted file mode 100644 index 2aeed0c6..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/BufferedWriter.java +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (c) 2008, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -package java.io; - -public class BufferedWriter extends Writer { - private final Writer out; - private final char[] buffer; - private int position; - - public BufferedWriter (Writer out, int size) { - this.out = out; - this.buffer = new char[size]; - } - - public BufferedWriter (Writer out) { - this(out, 4096); - } - - private void drain () throws IOException { - if (position > 0) { - out.write(buffer, 0, position); - position = 0; - } - } - - public void write (char[] b, int offset, int length) throws IOException { - if (length > buffer.length - position) { - drain(); - out.write(b, offset, length); - } else { - System.arraycopy(b, offset, buffer, position, length); - position += length; - } - } - - public void flush () throws IOException { - drain(); - out.flush(); - } - - public void close () throws IOException { - flush(); - out.close(); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/ByteArrayInputStream.java b/backends/gdx-backend-dragome/emu/java/io/ByteArrayInputStream.java deleted file mode 100644 index ca8fccfb..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/ByteArrayInputStream.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright 2011 See AUTHORS file. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ -package java.io; - -public class ByteArrayInputStream extends InputStream { - byte buf[]; - int pos; - int count; - int mark = 0; - - public ByteArrayInputStream(byte buf[]) { - this.buf = buf; - this.pos = 0; - this.count = buf.length; - } - - public ByteArrayInputStream(byte buf[], int offset, int length) { - this.buf = buf; - this.pos = offset; - this.count = Math.min(offset + length, buf.length); - this.mark = offset; - } - - public synchronized int read() { - return (pos < count) ? (buf[pos++] & 0xff) : -1; - } - - public synchronized int read(byte b[], int off, int len) { - if (b == null) { - throw new NullPointerException(); - } else if (off < 0 || len < 0 || len > b.length - off) { - throw new IndexOutOfBoundsException(); - } - - if (pos >= count) { - return -1; - } - - int avail = count - pos; - if (len > avail) { - len = avail; - } - if (len <= 0) { - return 0; - } - System.arraycopy(buf, pos, b, off, len); - pos += len; - return len; - } - - public synchronized long skip(long n) { - long k = count - pos; - if (n < k) { - k = n < 0 ? 0 : n; - } - - pos += k; - return k; - } - - public synchronized int available() { - return count - pos; - } - - public boolean markSupported() { - return true; - } - - public void mark(int readAheadLimit) { - mark = pos; - } - - public synchronized void reset() { - pos = mark; - } - - public void close() throws IOException { - } -} \ No newline at end of file diff --git a/backends/gdx-backend-dragome/emu/java/io/ByteArrayOutputStream.java b/backends/gdx-backend-dragome/emu/java/io/ByteArrayOutputStream.java deleted file mode 100644 index 9153674d..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/ByteArrayOutputStream.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.io; - -public class ByteArrayOutputStream extends OutputStream { - - protected int count; - protected byte[] buf; - - public ByteArrayOutputStream () { - this(16); - } - - public ByteArrayOutputStream (int initialSize) { - buf = new byte[initialSize]; - } - - @Override - public void write (int b) { - if (buf.length == count) { - byte[] newBuf = new byte[buf.length * 3 / 2]; - System.arraycopy(buf, 0, newBuf, 0, count); - buf = newBuf; - } - - buf[count++] = (byte)b; - } - - public byte[] toByteArray () { - byte[] result = new byte[count]; - System.arraycopy(buf, 0, result, 0, count); - return result; - } - - public int size () { - return count; - } - - public String toString () { - return new String(buf, 0, count); - } - - public String toString (String enc) throws UnsupportedEncodingException { - return new String(buf, 0, count, enc); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/Closeable.java b/backends/gdx-backend-dragome/emu/java/io/Closeable.java deleted file mode 100644 index e752c4e8..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/Closeable.java +++ /dev/null @@ -1,29 +0,0 @@ -/** Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.io; - -/*** Defines an interface for classes that can (or need to) be closed once they are not used any longer. This usually includes all - * sorts of {@link InputStream}s and {@link OutputStream}s. Calling the {@code close} method releases resources that the object - * holds. */ -public interface Closeable { - - /*** Closes the object and release any system resources it holds. If the object has already been closed, then invoking this - * method has no effect. - * - * @throws IOException if any error occurs when closing the object. */ - public void close () throws IOException; -} diff --git a/backends/gdx-backend-dragome/emu/java/io/DataInput.java b/backends/gdx-backend-dragome/emu/java/io/DataInput.java deleted file mode 100644 index 29f3b7c3..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/DataInput.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.io; - -public interface DataInput { - public boolean readBoolean () throws IOException; - - public byte readByte () throws IOException; - - public char readChar () throws IOException; - - public double readDouble () throws IOException; - - public float readFloat () throws IOException; - - public void readFully (byte[] b) throws IOException; - - public void readFully (byte[] b, int off, int len) throws IOException; - - public int readInt () throws IOException; - - public String readLine () throws IOException; - - public long readLong () throws IOException; - - public short readShort () throws IOException; - - public String readUTF () throws IOException; - - public int readUnsignedByte () throws IOException; - - public int readUnsignedShort () throws IOException; - - public int skipBytes (int n) throws IOException; -} diff --git a/backends/gdx-backend-dragome/emu/java/io/DataInputStream.java b/backends/gdx-backend-dragome/emu/java/io/DataInputStream.java deleted file mode 100644 index 33be0a00..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/DataInputStream.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.io; - - -public class DataInputStream extends InputStream implements DataInput { - - private final InputStream is; - - public DataInputStream (final InputStream is) { - this.is = is; - } - - @Override - public int read () throws IOException { - return is.read(); - } - - public boolean readBoolean () throws IOException { - return readByte() != 0; - } - - public byte readByte () throws IOException { - int i = read(); - if (i == -1) { - throw new EOFException(); - } - return (byte)i; - } - - public char readChar () throws IOException { - int a = is.read(); - int b = readUnsignedByte(); - return (char)((a << 8) | b); - } - - public double readDouble () throws IOException { - return Double.longBitsToDouble(readLong()); - } - - public float readFloat () throws IOException { - return Numbers.intBitsToFloat(readInt()); - } - - public void readFully (byte[] b) throws IOException { - readFully(b, 0, b.length); - } - - public void readFully (byte[] b, int off, int len) throws IOException { - while (len > 0) { - int count = is.read(b, off, len); - if (count <= 0) { - throw new EOFException(); - } - off += count; - len -= count; - } - } - - public int readInt () throws IOException { - int a = is.read(); - int b = is.read(); - int c = is.read(); - int d = readUnsignedByte(); - return (a << 24) | (b << 16) | (c << 8) | d; - } - - public String readLine () throws IOException { - throw new RuntimeException("readline NYI"); - } - - public long readLong () throws IOException { - long a = readInt(); - long b = readInt() & 0x0ffffffff; - return (a << 32) | b; - } - - public short readShort () throws IOException { - int a = is.read(); - int b = readUnsignedByte(); - return (short)((a << 8) | b); - } - - public String readUTF () throws IOException { - int bytes = readUnsignedShort(); - StringBuilder sb = new StringBuilder(); - - while (bytes > 0) { - bytes -= readUtfChar(sb); - } - - return sb.toString(); - } - - private int readUtfChar (StringBuilder sb) throws IOException { - int a = readUnsignedByte(); - if ((a & 0x80) == 0) { - sb.append((char)a); - return 1; - } - if ((a & 0xe0) == 0xc0) { - int b = readUnsignedByte(); - sb.append((char)(((a & 0x1F) << 6) | (b & 0x3F))); - return 2; - } - if ((a & 0xf0) == 0xe0) { - int b = readUnsignedByte(); - int c = readUnsignedByte(); - sb.append((char)(((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F))); - return 3; - } - throw new UTFDataFormatException(); - } - - public int readUnsignedByte () throws IOException { - int i = read(); - if (i == -1) { - throw new EOFException(); - } - return i; - } - - public int readUnsignedShort () throws IOException { - int a = is.read(); - int b = readUnsignedByte(); - return ((a << 8) | b); - } - - public int skipBytes (int n) throws IOException { - // note: This is actually a valid implementation of this method, rendering it quite useless... - return 0; - } - - @Override - public int available () { - return is.available(); - } - - @Override - public void close () throws IOException { - is.close(); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/DataOutput.java b/backends/gdx-backend-dragome/emu/java/io/DataOutput.java deleted file mode 100644 index 16b58d3d..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/DataOutput.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.io; - -public interface DataOutput { - public void write (byte[] data) throws IOException; - - public void write (byte[] data, int ofs, int len) throws IOException; - - public void write (int v) throws IOException; - - public void writeBoolean (boolean v) throws IOException; - - public void writeByte (int v) throws IOException; - - public void writeBytes (String s) throws IOException; - - public void writeChar (int v) throws IOException; - - public void writeChars (String s) throws IOException; - - public void writeDouble (double v) throws IOException; - - public void writeFloat (float v) throws IOException; - - public void writeInt (int v) throws IOException; - - public void writeLong (long v) throws IOException; - - public void writeShort (int v) throws IOException; - - public void writeUTF (String s) throws IOException; -} diff --git a/backends/gdx-backend-dragome/emu/java/io/DataOutputStream.java b/backends/gdx-backend-dragome/emu/java/io/DataOutputStream.java deleted file mode 100644 index e5a590ce..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/DataOutputStream.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.io; - - -public class DataOutputStream extends OutputStream implements DataOutput { - - OutputStream os; - - public DataOutputStream (OutputStream os) { - this.os = os; - } - - @Override - public void write (int b) throws IOException { - os.write(b); - } - - public void writeBoolean (boolean v) throws IOException { - os.write(v ? 1 : 0); - } - - public void writeByte (int v) throws IOException { - os.write(v); - } - - public void writeBytes (String s) throws IOException { - int len = s.length(); - for (int i = 0; i < len; i++) { - os.write(s.charAt(i) & 0xff); - } - } - - public void writeChar (int v) throws IOException { - os.write(v >> 8); - os.write(v); - } - - public void writeChars (String s) throws IOException { - throw new RuntimeException("writeChars NYI"); - } - - public void writeDouble (double v) throws IOException { - writeLong(Double.doubleToLongBits(v)); - } - - public void writeFloat (float v) throws IOException { - writeInt(Numbers.floatToIntBits(v)); - } - - public void writeInt (int v) throws IOException { - os.write(v >> 24); - os.write(v >> 16); - os.write(v >> 8); - os.write(v); - } - - public void writeLong (long v) throws IOException { - writeInt((int)(v >> 32L)); - writeInt((int)v); - } - - public void writeShort (int v) throws IOException { - os.write(v >> 8); - os.write(v); - } - - public void writeUTF (String s) throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - for (int i = 0; i < s.length(); i++) { - char c = s.charAt(i); - if (c > 0 && c < 80) { - baos.write(c); - } else if (c < '\u0800') { - baos.write(0xc0 | (0x1f & (c >> 6))); - baos.write(0x80 | (0x3f & c)); - } else { - baos.write(0xe0 | (0x0f & (c >> 12))); - baos.write(0x80 | (0x3f & (c >> 6))); - baos.write(0x80 | (0x3f & c)); - } - } - writeShort(baos.count); - os.write(baos.buf, 0, baos.count); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/EOFException.java b/backends/gdx-backend-dragome/emu/java/io/EOFException.java deleted file mode 100644 index 0aaa32db..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/EOFException.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.io; - -public class EOFException extends IOException { - -} diff --git a/backends/gdx-backend-dragome/emu/java/io/FileFilter.java b/backends/gdx-backend-dragome/emu/java/io/FileFilter.java deleted file mode 100644 index c2599b51..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/FileFilter.java +++ /dev/null @@ -1,7 +0,0 @@ -package java.io; - -public interface FileFilter { - - boolean accept (File file); - -} diff --git a/backends/gdx-backend-dragome/emu/java/io/FileNotFoundException.java b/backends/gdx-backend-dragome/emu/java/io/FileNotFoundException.java deleted file mode 100644 index daf34606..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/FileNotFoundException.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.io; - -public class FileNotFoundException extends IOException { - - public FileNotFoundException () { - super(); - } - - public FileNotFoundException (String s) { - super(s); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/FileWriter.java b/backends/gdx-backend-dragome/emu/java/io/FileWriter.java deleted file mode 100644 index 1d7cfd78..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/FileWriter.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.io; - -public class FileWriter { - - private final RandomAccessFile file; - - public FileWriter (String name) throws FileNotFoundException { - this.file = new RandomAccessFile(new File(name), "rw"); - } - - public void close () throws IOException { - file.close(); - } - - public void flush () throws IOException { -// file.flush(); // TODO need to imp - } - - public void write (String s) throws IOException { - for (int i = 0; i < s.length(); i++) { - file.write(s.charAt(i)); - } - } - -// public void write(char[] cbuf, int off, int len) throws IOException { -// // TODO Auto-generated method stub -// -// } - -} diff --git a/backends/gdx-backend-dragome/emu/java/io/FilenameFilter.java b/backends/gdx-backend-dragome/emu/java/io/FilenameFilter.java deleted file mode 100644 index 71406716..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/FilenameFilter.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.io; - -public interface FilenameFilter { - - boolean accept (File file, String name); -} diff --git a/backends/gdx-backend-dragome/emu/java/io/FilterInputStream.java b/backends/gdx-backend-dragome/emu/java/io/FilterInputStream.java deleted file mode 100644 index a08dc477..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/FilterInputStream.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright 2011 See AUTHORS file. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package java.io; - -public class FilterInputStream extends InputStream { - protected InputStream in; - - protected FilterInputStream (InputStream in) { - this.in = in; - } - - public int read () throws IOException { - return in.read(); - } - - public int read (byte b[]) throws IOException { - return read(b, 0, b.length); - } - - public int read (byte b[], int off, int len) throws IOException { - return in.read(b, off, len); - } - - public long skip (long n) throws IOException { - return 0; - } - - public int available () { - return in.available(); - } - - public void close () throws IOException { - in.close(); - } - - public synchronized void mark (int readlimit) { - } - - public synchronized void reset () throws IOException { - } - - public boolean markSupported () { - return false; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/Flushable.java b/backends/gdx-backend-dragome/emu/java/io/Flushable.java deleted file mode 100644 index f0f46030..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/Flushable.java +++ /dev/null @@ -1,26 +0,0 @@ -/** Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.io; - -/*** Defines an interface for classes that can (or need to) be flushed, typically before some output processing is considered to be - * finished and the object gets closed. */ -public interface Flushable { - /*** Flushes the object by writing out any buffered data to the underlying output. - * - * @throws IOException if there are any issues writing the data. */ - void flush () throws IOException; -} diff --git a/backends/gdx-backend-dragome/emu/java/io/HasArrayBufferView.java b/backends/gdx-backend-dragome/emu/java/io/HasArrayBufferView.java deleted file mode 100644 index 86fdb911..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/HasArrayBufferView.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright 2011 See AUTHORS file. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package java.io; - -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBufferView; - -public interface HasArrayBufferView { - - public ArrayBufferView getTypedArray (); - - public int getElementSize (); -} diff --git a/backends/gdx-backend-dragome/emu/java/io/IOException.java b/backends/gdx-backend-dragome/emu/java/io/IOException.java deleted file mode 100644 index 55566791..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/IOException.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.io; - -public class IOException extends Exception { - - public IOException () { - super(); - } - - public IOException (String s) { - super(s); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/InputStream.java b/backends/gdx-backend-dragome/emu/java/io/InputStream.java deleted file mode 100644 index b6260582..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/InputStream.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.io; - -public abstract class InputStream implements Closeable { - public abstract int read () throws IOException; - - public int read (byte[] buf, int start, int len) throws IOException { - - int end = start + len; - for (int i = start; i < end; i++) { - int r = read(); - if (r == -1) { - return i == start ? -1 : i - start; - } - buf[i] = (byte)r; - } - return len; - } - - public int read (byte[] buf) throws IOException { - return read(buf, 0, buf.length); - } - - public void close () throws IOException { - - } - - public int available () { - return 0; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/InputStreamReader.java b/backends/gdx-backend-dragome/emu/java/io/InputStreamReader.java deleted file mode 100644 index 841a2c7d..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/InputStreamReader.java +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (c) 2008-2010, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -package java.io; - -import com.badlogic.gdx.utils.Utf8Decoder; - -public class InputStreamReader extends Reader { - private final InputStream in; - - private final Utf8Decoder utf8Decoder; - - public InputStreamReader (InputStream in) { - this.in = in; - this.utf8Decoder = new Utf8Decoder(); - } - - public InputStreamReader (InputStream in, String encoding) throws UnsupportedEncodingException { - this(in); - - // FIXME this is bad, but some APIs seem to use "ISO-8859-1", fuckers... -// if (! encoding.equals("UTF-8")) { -// throw new UnsupportedEncodingException(encoding); -// } - } - - public int read (char[] b, int offset, int length) throws IOException { - byte[] buffer = new byte[length]; - int c = in.read(buffer); - return c <= 0 ? c : utf8Decoder.decode(buffer, 0, c, b, offset); - } - - public void close () throws IOException { - in.close(); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/Numbers.java b/backends/gdx-backend-dragome/emu/java/io/Numbers.java deleted file mode 100644 index fdc551ed..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/Numbers.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.io; - -import com.badlogic.gdx.backends.dragome.js.typedarrays.Float32Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Int32Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Int8Array; - -public class Numbers { - - static final double LN2 = Math.log(2); - - public static final int floatToIntBits (float f) { - wfa.set(0, f); - return wia.get(0); - } - - static Int8Array wba = Int8Array.create(4); - static Int32Array wia = Int32Array.create(wba.get_buffer(), 0, 1); - static Float32Array wfa = Float32Array.create(wba.get_buffer(), 0, 1); - - public static final float intBitsToFloat (int i) { - wia.set(0, i); - return wfa.get(0); - } - - public static final long doubleToLongBits (Double d) { - throw new RuntimeException("NYI"); - } - - public static final double longBitsToDouble (long l) { - throw new RuntimeException("NYI"); - } - - public static long doubleToRawLongBits (double value) { - throw new RuntimeException("NYI: Numbers.doubleToRawLongBits"); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/OutputStream.java b/backends/gdx-backend-dragome/emu/java/io/OutputStream.java deleted file mode 100644 index bfeb9871..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/OutputStream.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.io; - -public abstract class OutputStream { - // not abstract because of some gwt strangeness - public void write (int b) throws IOException { - } - - public void write (byte[] ba) throws IOException { - write(ba, 0, ba.length); - } - - public void write (byte[] ba, int start, int len) throws IOException { - int end = start + len; - for (int i = start; i < end; i++) { - write(ba[i]); - } - } - - public void flush () { - } - - public void close () throws IOException { - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/Reader.java b/backends/gdx-backend-dragome/emu/java/io/Reader.java deleted file mode 100644 index 197ce446..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/Reader.java +++ /dev/null @@ -1,196 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.io; - -import java.nio.CharBuffer; -import java.nio.ReadOnlyBufferException; - -/*** The base class for all readers. A reader is a means of reading data from a source in a character-wise manner. Some readers also - * support marking a position in the input and returning to this position later. - *

- * This abstract class does not provide a fully working implementation, so it needs to be subclassed, and at least the - * {@link #read(char[], int, int)} and {@link #close()} methods needs to be overridden. Overriding some of the non-abstract - * methods is also often advised, since it might result in higher efficiency. - *

- * Many specialized readers for purposes like reading from a file already exist in this package. - * - * @see Writer */ -public abstract class Reader implements Readable, Closeable { - /*** The object used to synchronize access to the reader. */ - protected Object lock; - - /*** Constructs a new {@code Reader} with {@code this} as the object used to synchronize critical sections. */ - protected Reader () { - super(); - lock = this; - } - - /*** Constructs a new {@code Reader} with {@code lock} used to synchronize critical sections. - * - * @param lock the {@code Object} used to synchronize critical sections. - * @throws NullPointerException if {@code lock} is {@code null}. */ - protected Reader (Object lock) { - if (lock == null) { - throw new NullPointerException(); - } - this.lock = lock; - } - - /*** Closes this reader. Implementations of this method should free any resources associated with the reader. - * - * @throws IOException if an error occurs while closing this reader. */ - public abstract void close () throws IOException; - - /*** Sets a mark position in this reader. The parameter {@code readLimit} indicates how many characters can be read before the - * mark is invalidated. Calling {@code reset()} will reposition the reader back to the marked position if {@code readLimit} has - * not been surpassed. - *

- * This default implementation simply throws an {@code IOException}; subclasses must provide their own implementation. - * - * @param readLimit the number of characters that can be read before the mark is invalidated. - * @throws IllegalArgumentException if {@code readLimit < 0}. - * @throws IOException if an error occurs while setting a mark in this reader. - * @see #markSupported() - * @see #reset() */ - public void mark (int readLimit) throws IOException { - throw new IOException(); - } - - /*** Indicates whether this reader supports the {@code mark()} and {@code reset()} methods. This default implementation returns - * {@code false}. - * - * @return always {@code false}. */ - public boolean markSupported () { - return false; - } - - /*** Reads a single character from this reader and returns it as an integer with the two higher-order bytes set to 0. Returns -1 - * if the end of the reader has been reached. - * - * @return the character read or -1 if the end of the reader has been reached. - * @throws IOException if this reader is closed or some other I/O error occurs. */ - public int read () throws IOException { - synchronized (lock) { - char charArray[] = new char[1]; - if (read(charArray, 0, 1) != -1) { - return charArray[0]; - } - return -1; - } - } - - /*** Reads characters from this reader and stores them in the character array {@code buf} starting at offset 0. Returns the - * number of characters actually read or -1 if the end of the reader has been reached. - * - * @param buf character array to store the characters read. - * @return the number of characters read or -1 if the end of the reader has been reached. - * @throws IOException if this reader is closed or some other I/O error occurs. */ - public int read (char buf[]) throws IOException { - return read(buf, 0, buf.length); - } - - /*** Reads at most {@code count} characters from this reader and stores them at {@code offset} in the character array {@code buf} - * . Returns the number of characters actually read or -1 if the end of the reader has been reached. - * - * @param buf the character array to store the characters read. - * @param offset the initial position in {@code buffer} to store the characters read from this reader. - * @param count the maximum number of characters to read. - * @return the number of characters read or -1 if the end of the reader has been reached. - * @throws IOException if this reader is closed or some other I/O error occurs. */ - public abstract int read (char buf[], int offset, int count) throws IOException; - - /*** Indicates whether this reader is ready to be read without blocking. Returns {@code true} if this reader will not block when - * {@code read} is called, {@code false} if unknown or blocking will occur. This default implementation always returns - * {@code false}. - * - * @return always {@code false}. - * @throws IOException if this reader is closed or some other I/O error occurs. - * @see #read() - * @see #read(char[]) - * @see #read(char[], int, int) */ - public boolean ready () throws IOException { - return false; - } - - /*** Resets this reader's position to the last {@code mark()} location. Invocations of {@code read()} and {@code skip()} will - * occur from this new location. If this reader has not been marked, the behavior of {@code reset()} is implementation - * specific. This default implementation throws an {@code IOException}. - * - * @throws IOException always thrown in this default implementation. - * @see #mark(int) - * @see #markSupported() */ - public void reset () throws IOException { - throw new IOException(); - } - - /*** Skips {@code amount} characters in this reader. Subsequent calls of {@code read} methods will not return these characters - * unless {@code reset()} is used. This method may perform multiple reads to read {@code count} characters. - * - * @param count the maximum number of characters to skip. - * @return the number of characters actually skipped. - * @throws IllegalArgumentException if {@code amount < 0}. - * @throws IOException if this reader is closed or some other I/O error occurs. - * @see #mark(int) - * @see #markSupported() - * @see #reset() */ - public long skip (long count) throws IOException { - if (count < 0) { - throw new IllegalArgumentException(); - } - synchronized (lock) { - long skipped = 0; - int toRead = count < 512 ? (int)count : 512; - char charsSkipped[] = new char[toRead]; - while (skipped < count) { - int read = read(charsSkipped, 0, toRead); - if (read == -1) { - return skipped; - } - skipped += read; - if (read < toRead) { - return skipped; - } - if (count - skipped < toRead) { - toRead = (int)(count - skipped); - } - } - return skipped; - } - } - - /*** Reads characters and puts them into the {@code target} character buffer. - * - * @param target the destination character buffer. - * @return the number of characters put into {@code target} or -1 if the end of this reader has been reached before a character - * has been read. - * @throws IOException if any I/O error occurs while reading from this reader. - * @throws NullPointerException if {@code target} is {@code null}. - * @throws ReadOnlyBufferException if {@code target} is read-only. */ - public int read (CharBuffer target) throws IOException { - if (null == target) { - throw new NullPointerException(); - } - int length = target.length(); - char[] buf = new char[length]; - length = Math.min(length, read(buf)); - if (length > 0) { - target.put(buf, 0, length); - } - return length; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/StringReader.java b/backends/gdx-backend-dragome/emu/java/io/StringReader.java deleted file mode 100644 index c2247d1d..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/StringReader.java +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (c) 2008, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -package java.io; - -public class StringReader extends Reader { - private final String in; - private int position = 0; - - public StringReader (String in) { - this.in = in; - } - - public int read (char[] b, int offset, int length) throws IOException { - if (length > in.length() - position) { - length = in.length() - position; - if (length <= 0) { - return -1; - } - } - in.getChars(position, position + length, b, offset); - position += length; - return length; - } - - public void close () throws IOException { - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/StringWriter.java b/backends/gdx-backend-dragome/emu/java/io/StringWriter.java deleted file mode 100644 index cbf0703d..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/StringWriter.java +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (c) 2008, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -package java.io; - -public class StringWriter extends Writer { - private final StringBuilder out; - - public StringWriter() { - out = new StringBuilder(); - } - - public StringWriter(int initialCapacity) { - out = new StringBuilder(initialCapacity); - } - - public void write (char[] b, int offset, int length) throws IOException { - out.append(b, offset, length); - } - - public String toString () { - return out.toString(); - } - - public void flush () throws IOException { - } - - public void close () throws IOException { - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/UTFDataFormatException.java b/backends/gdx-backend-dragome/emu/java/io/UTFDataFormatException.java deleted file mode 100644 index b0076e65..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/UTFDataFormatException.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.io; - -public class UTFDataFormatException extends IOException { - - public UTFDataFormatException (String msg) { - super(msg); - } - - public UTFDataFormatException () { - super(); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/UnsupportedEncodingException.java b/backends/gdx-backend-dragome/emu/java/io/UnsupportedEncodingException.java deleted file mode 100644 index f0f81510..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/UnsupportedEncodingException.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.io; - -public class UnsupportedEncodingException extends IOException { - public UnsupportedEncodingException () { - super(); - } - - public UnsupportedEncodingException (String s) { - super(s); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/Writer.java b/backends/gdx-backend-dragome/emu/java/io/Writer.java deleted file mode 100644 index 8f07bb63..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/Writer.java +++ /dev/null @@ -1,173 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.io; - -/*** The base class for all writers. A writer is a means of writing data to a target in a character-wise manner. Most output streams - * expect the {@link #flush()} method to be called before closing the stream, to ensure all data is actually written out. - *

- * This abstract class does not provide a fully working implementation, so it needs to be subclassed, and at least the - * {@link #write(char[], int, int)}, {@link #close()} and {@link #flush()} methods needs to be overridden. Overriding some of the - * non-abstract methods is also often advised, since it might result in higher efficiency. - *

- * Many specialized readers for purposes like reading from a file already exist in this package. - * - * @see Reader */ -public abstract class Writer implements Appendable, Closeable, Flushable { - - static final String TOKEN_NULL = "null"; //$NON-NLS-1$ - - /*** The object used to synchronize access to the writer. */ - protected Object lock; - - /*** Constructs a new {@code Writer} with {@code this} as the object used to synchronize critical sections. */ - protected Writer () { - super(); - lock = this; - } - - /*** Constructs a new {@code Writer} with {@code lock} used to synchronize critical sections. - * - * @param lock the {@code Object} used to synchronize critical sections. - * @throws NullPointerException if {@code lock} is {@code null}. */ - protected Writer (Object lock) { - if (lock == null) { - throw new NullPointerException(); - } - this.lock = lock; - } - - /*** Closes this writer. Implementations of this method should free any resources associated with the writer. - * - * @throws IOException if an error occurs while closing this writer. */ - public abstract void close () throws IOException; - - /*** Flushes this writer. Implementations of this method should ensure that all buffered characters are written to the target. - * - * @throws IOException if an error occurs while flushing this writer. */ - public abstract void flush () throws IOException; - - /*** Writes the entire character buffer {@code buf} to the target. - * - * @param buf the non-null array containing characters to write. - * @throws IOException if this writer is closed or another I/O error occurs. */ - public void write (char buf[]) throws IOException { - write(buf, 0, buf.length); - } - - /*** Writes {@code count} characters starting at {@code offset} in {@code buf} to the target. - * - * @param buf the non-null character array to write. - * @param offset the index of the first character in {@code buf} to write. - * @param count the maximum number of characters to write. - * @throws IndexOutOfBoundsException if {@code offset < 0} or {@code count < 0}, or if {@code offset + count} is greater than - * the size of {@code buf}. - * @throws IOException if this writer is closed or another I/O error occurs. */ - public abstract void write (char buf[], int offset, int count) throws IOException; - - /*** Writes one character to the target. Only the two least significant bytes of the integer {@code oneChar} are written. - * - * @param oneChar the character to write to the target. - * @throws IOException if this writer is closed or another I/O error occurs. */ - public void write (int oneChar) throws IOException { - synchronized (lock) { - char oneCharArray[] = new char[1]; - oneCharArray[0] = (char)oneChar; - write(oneCharArray); - } - } - - /*** Writes the characters from the specified string to the target. - * - * @param str the non-null string containing the characters to write. - * @throws IOException if this writer is closed or another I/O error occurs. */ - public void write (String str) throws IOException { - write(str, 0, str.length()); - } - - /*** Writes {@code count} characters from {@code str} starting at {@code offset} to the target. - * - * @param str the non-null string containing the characters to write. - * @param offset the index of the first character in {@code str} to write. - * @param count the number of characters from {@code str} to write. - * @throws IOException if this writer is closed or another I/O error occurs. - * @throws IndexOutOfBoundsException if {@code offset < 0} or {@code count < 0}, or if {@code offset + count} is greater than - * the length of {@code str}. */ - public void write (String str, int offset, int count) throws IOException { - if (count < 0) { // other cases tested by getChars() - throw new StringIndexOutOfBoundsException(); - } - char buf[] = new char[count]; - str.getChars(offset, offset + count, buf, 0); - - synchronized (lock) { - write(buf, 0, buf.length); - } - } - - /*** Appends the character {@code c} to the target. This method works the same way as {@link #write(int)}. - * - * @param c the character to append to the target stream. - * @return this writer. - * @throws IOException if this writer is closed or another I/O error occurs. */ - public Writer append (char c) throws IOException { - write(c); - return this; - } - - /*** Appends the character sequence {@code csq} to the target. This method works the same way as - * {@code Writer.write(csq.toString())}. If {@code csq} is {@code null}, then the string "null" is written to the target - * stream. - * - * @param csq the character sequence appended to the target. - * @return this writer. - * @throws IOException if this writer is closed or another I/O error occurs. */ - public Writer append (CharSequence csq) throws IOException { - if (null == csq) { - write(TOKEN_NULL); - } else { - write(csq.toString()); - } - return this; - } - - /*** Appends a subsequence of the character sequence {@code csq} to the target. This method works the same way as - * {@code Writer.writer(csq.subsequence(start, end).toString())}. If {@code csq} is {@code null}, then the specified - * subsequence of the string "null" will be written to the target. - * - * @param csq the character sequence appended to the target. - * @param start the index of the first char in the character sequence appended to the target. - * @param end the index of the character following the last character of the subsequence appended to the target. - * @return this writer. - * @throws IOException if this writer is closed or another I/O error occurs. - * @throws IndexOutOfBoundsException if {@code start > end}, {@code start < 0}, {@code end < 0} or either {@code start} or - * {@code end} are greater or equal than the length of {@code csq}. */ - public Writer append (CharSequence csq, int start, int end) throws IOException { - if (null == csq) { - write(TOKEN_NULL.substring(start, end)); - } else { - write(csq.subSequence(start, end).toString()); - } - return this; - } - - /*** Returns true if this writer has encountered and suppressed an error. Used by PrintWriters as an alternative to checked - * exceptions. */ - boolean checkError () { - return false; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/net/URLEncoder.java b/backends/gdx-backend-dragome/emu/java/net/URLEncoder.java deleted file mode 100644 index ab19aca3..00000000 --- a/backends/gdx-backend-dragome/emu/java/net/URLEncoder.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.net; - -import java.io.UnsupportedEncodingException; - -/** - * This class is used to encode a string using the format required by - * {@code application/x-www-form-urlencoded} MIME content type. - */ -public class URLEncoder { - - static final String digits = "0123456789ABCDEF"; - - /** - * Prevents this class from being instantiated. - */ - private URLEncoder() { - } - - /** - * Encodes a given string {@code s} in a x-www-form-urlencoded string using - * the specified encoding scheme {@code enc}. - *

- * All characters except letters ('a'..'z', 'A'..'Z') and numbers ('0'..'9') - * and characters '.', '-', '*', '_' are converted into their hexadecimal - * value prepended by '%'. For example: '#' -> %23. In addition, spaces are - * substituted by '+' - * - * @param s - * the string to be encoded. - * @return the encoded string. - * @deprecated use {@link #encode(String, String)} instead. - */ - @Deprecated - public static String encode(String s) { - // Guess a bit bigger for encoded form - StringBuilder buf = new StringBuilder(s.length() + 16); - for (int i = 0; i < s.length(); i++) { - char ch = s.charAt(i); - if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') - || (ch >= '0' && ch <= '9') || ".-*_".indexOf(ch) > -1) { - buf.append(ch); - } else if (ch == ' ') { - buf.append('+'); - } else { - byte[] bytes = new String(new char[] { ch }).getBytes(); - for (int j = 0; j < bytes.length; j++) { - buf.append('%'); - buf.append(digits.charAt((bytes[j] & 0xf0) >> 4)); - buf.append(digits.charAt(bytes[j] & 0xf)); - } - } - } - return buf.toString(); - } - - /** - * Encodes the given string {@code s} in a x-www-form-urlencoded string - * using the specified encoding scheme {@code enc}. - *

- * All characters except letters ('a'..'z', 'A'..'Z') and numbers ('0'..'9') - * and characters '.', '-', '*', '_' are converted into their hexadecimal - * value prepended by '%'. For example: '#' -> %23. In addition, spaces are - * substituted by '+' - * - * @param s - * the string to be encoded. - * @param enc - * the encoding scheme to be used. - * @return the encoded string. - * @throws UnsupportedEncodingException - * if the specified encoding scheme is invalid. - */ - public static String encode(String s, String enc) throws UnsupportedEncodingException { - if (s == null || enc == null) { - throw new NullPointerException(); - } - // check for UnsupportedEncodingException - "".getBytes(enc); - - // Guess a bit bigger for encoded form - StringBuilder buf = new StringBuilder(s.length() + 16); - int start = -1; - for (int i = 0; i < s.length(); i++) { - char ch = s.charAt(i); - if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') - || (ch >= '0' && ch <= '9') || " .-*_".indexOf(ch) > -1) { - if (start >= 0) { - convert(s.substring(start, i), buf, enc); - start = -1; - } - if (ch != ' ') { - buf.append(ch); - } else { - buf.append('+'); - } - } else { - if (start < 0) { - start = i; - } - } - } - if (start >= 0) { - convert(s.substring(start, s.length()), buf, enc); - } - return buf.toString(); - } - - private static void convert(String s, StringBuilder buf, String enc) - throws UnsupportedEncodingException { - byte[] bytes = s.getBytes(enc); - for (int j = 0; j < bytes.length; j++) { - buf.append('%'); - buf.append(digits.charAt((bytes[j] & 0xf0) >> 4)); - buf.append(digits.charAt(bytes[j] & 0xf)); - } - } -} \ No newline at end of file diff --git a/backends/gdx-backend-dragome/emu/java/nio/BaseByteBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/BaseByteBuffer.java deleted file mode 100644 index 9c78c2a6..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/BaseByteBuffer.java +++ /dev/null @@ -1,71 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** Serves as the root of other byte buffer impl classes, implements common methods that can be shared by child classes. */ -abstract class BaseByteBuffer extends ByteBuffer { - - protected BaseByteBuffer (int capacity) { - super(capacity); - } - - @Override - public CharBuffer asCharBuffer () { - return CharToByteBufferAdapter.wrap(this); - } - - @Override - public DoubleBuffer asDoubleBuffer () { - return DoubleToByteBufferAdapter.wrap(this); - } - - @Override - public FloatBuffer asFloatBuffer () { - return FloatToByteBufferAdapter.wrap(this); - } - - @Override - public IntBuffer asIntBuffer () { - return IntToByteBufferAdapter.wrap(this); - } - - @Override - public LongBuffer asLongBuffer () { - return LongToByteBufferAdapter.wrap(this); - } - - @Override - public ShortBuffer asShortBuffer () { - return ShortToByteBufferAdapter.wrap(this); - } - - public final char getChar () { - return (char)getShort(); - } - - public final char getChar (int index) { - return (char)getShort(index); - } - - public final ByteBuffer putChar (char value) { - return putShort((short)value); - } - - public final ByteBuffer putChar (int index, char value) { - return putShort(index, (short)value); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/Buffer.java b/backends/gdx-backend-dragome/emu/java/nio/Buffer.java deleted file mode 100644 index 9e36157f..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/Buffer.java +++ /dev/null @@ -1,232 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** A buffer is a list of elements of a specific primitive type. - *

- * A buffer can be described by the following properties: - *

    - *
  • Capacity: the number of elements a buffer can hold. Capacity may not be negative and never changes.
  • - *
  • Position: a cursor of this buffer. Elements are read or written at the position if you do not specify an index explicitly. - * Position may not be negative and not greater than the limit.
  • - *
  • Limit: controls the scope of accessible elements. You can only read or write elements from index zero to - * limit - 1. Accessing elements out of the scope will cause an exception. Limit may not be negative and not greater - * than capacity.
  • - *
  • Mark: used to remember the current position, so that you can reset the position later. Mark may not be negative and no - * greater than position.
  • - *
  • A buffer can be read-only or read-write. Trying to modify the elements of a read-only buffer will cause a - * ReadOnlyBufferException, while changing the position, limit and mark of a read-only buffer is OK.
  • - *
  • A buffer can be direct or indirect. A direct buffer will try its best to take advantage of native memory APIs and it may - * not stay in the Java heap, thus it is not affected by garbage collection.
  • - *
- *

- *

- * Buffers are not thread-safe. If concurrent access to a buffer instance is required, then the callers are responsible to take - * care of the synchronization issues. - *

- * - * @since Android 1.0 */ -public abstract class Buffer { - - /** UNSET_MARK means the mark has not been set. */ - final static int UNSET_MARK = -1; - - /** The capacity of this buffer, which never change. */ - final int capacity; - - /** limit - 1 is the last element that can be read or written. Limit must be no less than zero and no greater than - * capacity. */ - int limit; - - /** Mark is where position will be set when reset() is called. Mark is not set by default. Mark is always no less - * than zero and no greater than position. */ - int mark = UNSET_MARK; - - /** The current position of this buffer. Position is always no less than zero and no greater than limit. */ - int position = 0; - - /** Construct a buffer with the specified capacity. - * - * @param capacity the capacity of this buffer. */ - Buffer (int capacity) { - super(); - if (capacity < 0) { - throw new IllegalArgumentException(); - } - this.capacity = this.limit = capacity; - } - - /** Returns the capacity of this buffer. - * - * @return the number of elements that are contained in this buffer. - * @since Android 1.0 */ - public final int capacity () { - return capacity; - } - - /** Clears this buffer. - *

- * While the content of this buffer is not changed, the following internal changes take place: the current position is reset - * back to the start of the buffer, the value of the buffer limit is made equal to the capacity and mark is cleared. - *

- * - * @return this buffer. - * @since Android 1.0 */ - public final Buffer clear () { - position = 0; - mark = UNSET_MARK; - limit = capacity; - return this; - } - - /** Flips this buffer. - *

- * The limit is set to the current position, then the position is set to zero, and the mark is cleared. - *

- *

- * The content of this buffer is not changed. - *

- * - * @return this buffer. - * @since Android 1.0 */ - public final Buffer flip () { - limit = position; - position = 0; - mark = UNSET_MARK; - return this; - } - - /** Indicates if there are elements remaining in this buffer, that is if {@code position < limit}. - * - * @return {@code true} if there are elements remaining in this buffer, {@code false} otherwise. - * @since Android 1.0 */ - public final boolean hasRemaining () { - return position < limit; - } - - /** Indicates whether this buffer is read-only. - * - * @return {@code true} if this buffer is read-only, {@code false} otherwise. - * @since Android 1.0 */ - public abstract boolean isReadOnly (); - - /** Returns the limit of this buffer. - * - * @return the limit of this buffer. - * @since Android 1.0 */ - public final int limit () { - return limit; - } - - /** Sets the limit of this buffer. - *

- * If the current position in the buffer is in excess of newLimit then, on returning from this call, it will have - * been adjusted to be equivalent to newLimit. If the mark is set and is greater than the new limit, then it is - * cleared. - *

- * - * @param newLimit the new limit, must not be negative and not greater than capacity. - * @return this buffer. - * @exception IllegalArgumentException if newLimit is invalid. - * @since Android 1.0 */ - public final Buffer limit (int newLimit) { - if (newLimit < 0 || newLimit > capacity) { - throw new IllegalArgumentException(); - } - - limit = newLimit; - if (position > newLimit) { - position = newLimit; - } - if ((mark != UNSET_MARK) && (mark > newLimit)) { - mark = UNSET_MARK; - } - return this; - } - - /** Marks the current position, so that the position may return to this point later by calling reset(). - * - * @return this buffer. - * @since Android 1.0 */ - public final Buffer mark () { - mark = position; - return this; - } - - /** Returns the position of this buffer. - * - * @return the value of this buffer's current position. - * @since Android 1.0 */ - public final int position () { - return position; - } - - /** Sets the position of this buffer. - *

- * If the mark is set and it is greater than the new position, then it is cleared. - *

- * - * @param newPosition the new position, must be not negative and not greater than limit. - * @return this buffer. - * @exception IllegalArgumentException if newPosition is invalid. - * @since Android 1.0 */ - public final Buffer position (int newPosition) { - if (newPosition < 0 || newPosition > limit) { - throw new IllegalArgumentException(); - } - - position = newPosition; - if ((mark != UNSET_MARK) && (mark > position)) { - mark = UNSET_MARK; - } - return this; - } - - /** Returns the number of remaining elements in this buffer, that is {@code limit - position}. - * - * @return the number of remaining elements in this buffer. - * @since Android 1.0 */ - public final int remaining () { - return limit - position; - } - - /** Resets the position of this buffer to the mark. - * - * @return this buffer. - * @exception InvalidMarkException if the mark is not set. - * @since Android 1.0 */ - public final Buffer reset () { - if (mark == UNSET_MARK) { - throw new InvalidMarkException(); - } - position = mark; - return this; - } - - /** Rewinds this buffer. - *

- * The position is set to zero, and the mark is cleared. The content of this buffer is not changed. - *

- * - * @return this buffer. - * @since Android 1.0 */ - public final Buffer rewind () { - position = 0; - mark = UNSET_MARK; - return this; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/BufferFactory.java b/backends/gdx-backend-dragome/emu/java/nio/BufferFactory.java deleted file mode 100644 index 8f58ee96..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/BufferFactory.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** Provide factory service of buffer classes. - *

- * Since all buffer impl classes are package private (except DirectByteBuffer), this factory is the only entrance to access buffer - * functions from outside of the impl package. - *

*/ -final class BufferFactory { - - /** Returns a new byte buffer based on the specified byte array. - * - * @param array The byte array - * @return A new byte buffer based on the specified byte array. */ - public static ByteBuffer newByteBuffer (byte array[]) { - return new ReadWriteHeapByteBuffer(array); - } - - /** Returns a new array based byte buffer with the specified capacity. - * - * @param capacity The capacity of the new buffer - * @return A new array based byte buffer with the specified capacity. */ - public static ByteBuffer newByteBuffer (int capacity) { - return new ReadWriteHeapByteBuffer(capacity); - } - - /** Returns a new char buffer based on the specified char array. - * - * @param array The char array - * @return A new char buffer based on the specified char array. */ - public static CharBuffer newCharBuffer (char array[]) { - return new ReadWriteCharArrayBuffer(array); - } - - /** Returns a new readonly char buffer based on the specified char sequence. - * - * @param chseq The char sequence - * @return A new readonly char buffer based on the specified char sequence. */ - public static CharBuffer newCharBuffer (CharSequence chseq) { - return new CharSequenceAdapter(chseq); - } - - /** Returns a new array based char buffer with the specified capacity. - * - * @param capacity The capacity of the new buffer - * @return A new array based char buffer with the specified capacity. */ - public static CharBuffer newCharBuffer (int capacity) { - return new ReadWriteCharArrayBuffer(capacity); - } - - /** Returns a new direct byte buffer with the specified capacity. - * - * @param capacity The capacity of the new buffer - * @return A new direct byte buffer with the specified capacity. */ - public static ByteBuffer newDirectByteBuffer (int capacity) { - return new DirectReadWriteByteBuffer(capacity); - } - - /** Returns a new double buffer based on the specified double array. - * - * @param array The double array - * @return A new double buffer based on the specified double array. */ - public static DoubleBuffer newDoubleBuffer (double array[]) { - return new ReadWriteDoubleArrayBuffer(array); - } - - /** Returns a new array based double buffer with the specified capacity. - * - * @param capacity The capacity of the new buffer - * @return A new array based double buffer with the specified capacity. */ - public static DoubleBuffer newDoubleBuffer (int capacity) { - return new ReadWriteDoubleArrayBuffer(capacity); - } - - /** Returns a new float buffer based on the specified float array. - * - * @param array The float array - * @return A new float buffer based on the specified float array. */ - public static FloatBuffer newFloatBuffer (float array[]) { - return new ReadWriteFloatArrayBuffer(array); - } - - /** Returns a new array based float buffer with the specified capacity. - * - * @param capacity The capacity of the new buffer - * @return A new array based float buffer with the specified capacity. */ - public static FloatBuffer newFloatBuffer (int capacity) { - return new ReadWriteFloatArrayBuffer(capacity); - } - - /** Returns a new array based int buffer with the specified capacity. - * - * @param capacity The capacity of the new buffer - * @return A new array based int buffer with the specified capacity. */ - public static IntBuffer newIntBuffer (int capacity) { - return new ReadWriteIntArrayBuffer(capacity); - } - - /** Returns a new int buffer based on the specified int array. - * - * @param array The int array - * @return A new int buffer based on the specified int array. */ - public static IntBuffer newIntBuffer (int array[]) { - return new ReadWriteIntArrayBuffer(array); - } - - /** Returns a new array based long buffer with the specified capacity. - * - * @param capacity The capacity of the new buffer - * @return A new array based long buffer with the specified capacity. */ - public static LongBuffer newLongBuffer (int capacity) { - return new ReadWriteLongArrayBuffer(capacity); - } - - /** Returns a new long buffer based on the specified long array. - * - * @param array The long array - * @return A new long buffer based on the specified long array. */ - public static LongBuffer newLongBuffer (long array[]) { - return new ReadWriteLongArrayBuffer(array); - } - - /** Returns a new array based short buffer with the specified capacity. - * - * @param capacity The capacity of the new buffer - * @return A new array based short buffer with the specified capacity. */ - public static ShortBuffer newShortBuffer (int capacity) { - return new ReadWriteShortArrayBuffer(capacity); - } - - /** Returns a new short buffer based on the specified short array. - * - * @param array The short array - * @return A new short buffer based on the specified short array. */ - public static ShortBuffer newShortBuffer (short array[]) { - return new ReadWriteShortArrayBuffer(array); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/BufferOverflowException.java b/backends/gdx-backend-dragome/emu/java/nio/BufferOverflowException.java deleted file mode 100644 index 923808ec..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/BufferOverflowException.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** A BufferOverflowException is thrown when elements are written to a buffer but there is not enough remaining space - * in the buffer. - * - * @since Android 1.0 */ -public class BufferOverflowException extends RuntimeException { - - private static final long serialVersionUID = -5484897634319144535L; - - /** Constructs a BufferOverflowException. - * - * @since Android 1.0 */ - public BufferOverflowException () { - super(); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/BufferUnderflowException.java b/backends/gdx-backend-dragome/emu/java/nio/BufferUnderflowException.java deleted file mode 100644 index 1d3251ee..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/BufferUnderflowException.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** A BufferUnderflowException is thrown when elements are read from a buffer but there are not enough remaining - * elements in the buffer. - * - * @since Android 1.0 */ -public class BufferUnderflowException extends RuntimeException { - - private static final long serialVersionUID = -1713313658691622206L; - - /** Constructs a BufferUnderflowException. - * - * @since Android 1.0 */ - public BufferUnderflowException () { - super(); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ByteBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ByteBuffer.java deleted file mode 100644 index 2c0d7ad0..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ByteBuffer.java +++ /dev/null @@ -1,836 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -import com.badlogic.gdx.backends.dragome.utils.Endianness; -import com.badlogic.gdx.backends.dragome.utils.StringToByteBuffer; - -/** A buffer for bytes. - *

- * A byte buffer can be created in either one of the following ways: - *

- *
    - *
  • {@link #allocate(int) Allocate} a new byte array and create a buffer based on it;
  • - *
  • {@link #allocateDirect(int) Allocate} a memory block and create a direct buffer based on it;
  • - *
  • {@link #wrap(byte[]) Wrap} an existing byte array to create a new buffer.
  • - *
- * @since Android 1.0 */ -public abstract class ByteBuffer extends Buffer implements Comparable, StringToByteBuffer { - - /** Creates a byte buffer based on a newly allocated byte array. - * - * @param capacity the capacity of the new buffer - * @return the created byte buffer. - * @throws IllegalArgumentException if {@code capacity < 0}. - * @since Android 1.0 */ - public static ByteBuffer allocate (int capacity) { - if (capacity < 0) { - throw new IllegalArgumentException(); - } - return BufferFactory.newByteBuffer(capacity); - } - - /** Creates a direct byte buffer based on a newly allocated memory block. - * - * @param capacity the capacity of the new buffer - * @return the created byte buffer. - * @throws IllegalArgumentException if {@code capacity < 0}. - * @since Android 1.0 */ - public static ByteBuffer allocateDirect (int capacity) { - if (capacity < 0) { - throw new IllegalArgumentException(); - } - return BufferFactory.newDirectByteBuffer(capacity); - } - - /** Creates a new byte buffer by wrapping the given byte array. - *

- * Calling this method has the same effect as {@code wrap(array, 0, array.length)}. - *

- * - * @param array the byte array which the new buffer will be based on - * @return the created byte buffer. - * @since Android 1.0 */ - public static ByteBuffer wrap (byte[] array) { - return BufferFactory.newByteBuffer(array); - } - - /** Creates a new byte buffer by wrapping the given byte array. - *

- * The new buffer's position will be {@code start}, limit will be {@code start + len}, capacity will be the length of the array. - *

- * - * @param array the byte array which the new buffer will be based on. - * @param start the start index, must not be negative and not greater than {@code array.length}. - * @param len the length, must not be negative and not greater than {@code array.length - start}. - * @return the created byte buffer. - * @exception IndexOutOfBoundsException if either {@code start} or {@code len} is invalid. - * @since Android 1.0 */ - public static ByteBuffer wrap (byte[] array, int start, int len) { - int length = array.length; - if ((start < 0) || (len < 0) || ((long)start + (long)len > length)) { - throw new IndexOutOfBoundsException(); - } - - ByteBuffer buf = BufferFactory.newByteBuffer(array); - buf.position = start; - buf.limit = start + len; - - return buf; - } - - /** The byte order of this buffer, default is {@code BIG_ENDIAN}. */ - Endianness order = Endianness.BIG_ENDIAN; - - /** Constructs a {@code ByteBuffer} with given capacity. - * - * @param capacity the capacity of the buffer. */ - ByteBuffer (int capacity) { - super(capacity); - } - - /** Returns the byte array which this buffer is based on, if there is one. - * - * @return the byte array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on a read-only array. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final byte[] array () { - return protectedArray(); - } - - /** Returns the offset of the byte array which this buffer is based on, if there is one. - *

- * The offset is the index of the array which corresponds to the zero position of the buffer. - *

- * - * @return the offset of the byte array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on a read-only array. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final int arrayOffset () { - return protectedArrayOffset(); - } - - /** Returns a char buffer which is based on the remaining content of this byte buffer. - *

- * The new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by two, and its mark is - * not set. The new buffer's read-only property and byte order are the same as this buffer's. The new buffer is direct if this - * byte buffer is direct. - *

- *

- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *

- * - * @return a char buffer which is based on the content of this byte buffer. - * @since Android 1.0 */ - public abstract CharBuffer asCharBuffer (); - - /** Returns a double buffer which is based on the remaining content of this byte buffer. - *

- * The new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by eight, and its mark is - * not set. The new buffer's read-only property and byte order are the same as this buffer's. The new buffer is direct if this - * byte buffer is direct. - *

- *

- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *

- * - * @return a double buffer which is based on the content of this byte buffer. - * @since Android 1.0 */ - public abstract DoubleBuffer asDoubleBuffer (); - - /** Returns a float buffer which is based on the remaining content of this byte buffer. - *

- * The new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by four, and its mark is - * not set. The new buffer's read-only property and byte order are the same as this buffer's. The new buffer is direct if this - * byte buffer is direct. - *

- *

- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *

- * - * @return a float buffer which is based on the content of this byte buffer. - * @since Android 1.0 */ - public abstract FloatBuffer asFloatBuffer (); - - /** Returns a int buffer which is based on the remaining content of this byte buffer. - *

- * The new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by four, and its mark is - * not set. The new buffer's read-only property and byte order are the same as this buffer's. The new buffer is direct if this - * byte buffer is direct. - *

- *

- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *

- * - * @return a int buffer which is based on the content of this byte buffer. - * @since Android 1.0 */ - public abstract IntBuffer asIntBuffer (); - - /** Returns a long buffer which is based on the remaining content of this byte buffer. - *

- * The new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by eight, and its mark is - * not set. The new buffer's read-only property and byte order are the same as this buffer's. The new buffer is direct if this - * byte buffer is direct. - *

- *

- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *

- * - * @return a long buffer which is based on the content of this byte buffer. - * @since Android 1.0 */ - public abstract LongBuffer asLongBuffer (); - - /** Returns a read-only buffer that shares its content with this buffer. - *

- * The returned buffer is guaranteed to be a new instance, even if this buffer is read-only itself. The new buffer's position, - * limit, capacity and mark are the same as this buffer. - *

- *

- * The new buffer shares its content with this buffer, which means this buffer's change of content will be visible to the new - * buffer. The two buffer's position, limit and mark are independent. - *

- * - * @return a read-only version of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer asReadOnlyBuffer (); - - /** Returns a short buffer which is based on the remaining content of this byte buffer. - *

- * The new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by two, and its mark is - * not set. The new buffer's read-only property and byte order are the same as this buffer's. The new buffer is direct if this - * byte buffer is direct. - *

- *

- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *

- * - * @return a short buffer which is based on the content of this byte buffer. - * @since Android 1.0 */ - public abstract ShortBuffer asShortBuffer (); - - /** Compacts this byte buffer. - *

- * The remaining bytes will be moved to the head of the buffer, starting from position zero. Then the position is set to - * {@code remaining()}; the limit is set to capacity; the mark is cleared. - *

- * - * @return this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer compact (); - - /** Compares the remaining bytes of this buffer to another byte buffer's remaining bytes. - * - * @param otherBuffer another byte buffer. - * @return a negative value if this is less than {@code other}; 0 if this equals to {@code other}; a positive value if this is - * greater than {@code other}. - * @exception ClassCastException if {@code other} is not a byte buffer. - * @since Android 1.0 */ - public int compareTo (ByteBuffer otherBuffer) { - int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining() : otherBuffer.remaining(); - int thisPos = position; - int otherPos = otherBuffer.position; - byte thisByte, otherByte; - while (compareRemaining > 0) { - thisByte = get(thisPos); - otherByte = otherBuffer.get(otherPos); - if (thisByte != otherByte) { - return thisByte < otherByte ? -1 : 1; - } - thisPos++; - otherPos++; - compareRemaining--; - } - return remaining() - otherBuffer.remaining(); - } - - /** Returns a duplicated buffer that shares its content with this buffer. - *

- * The duplicated buffer's position, limit, capacity and mark are the same as this buffer's. The duplicated buffer's read-only - * property and byte order are the same as this buffer's too. - *

- *

- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *

- * - * @return a duplicated buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer duplicate (); - - /** Checks whether this byte buffer is equal to another object. - *

- * If {@code other} is not a byte buffer then {@code false} is returned. Two byte buffers are equal if and only if their - * remaining bytes are exactly the same. Position, limit, capacity and mark are not considered. - *

- * - * @param other the object to compare with this byte buffer. - * @return {@code true} if this byte buffer is equal to {@code other}, {@code false} otherwise. - * @since Android 1.0 */ - public boolean equals (Object other) { - if (!(other instanceof ByteBuffer)) { - return false; - } - ByteBuffer otherBuffer = (ByteBuffer)other; - - if (remaining() != otherBuffer.remaining()) { - return false; - } - - int myPosition = position; - int otherPosition = otherBuffer.position; - boolean equalSoFar = true; - while (equalSoFar && (myPosition < limit)) { - equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++); - } - - return equalSoFar; - } - - /** Returns the byte at the current position and increases the position by 1. - * - * @return the byte at the current position. - * @exception BufferUnderflowException if the position is equal or greater than limit. - * @since Android 1.0 */ - public abstract byte get (); - - /** Reads bytes from the current position into the specified byte array and increases the position by the number of bytes read. - *

- * Calling this method has the same effect as {@code get(dest, 0, dest.length)}. - *

- * - * @param dest the destination byte array. - * @return this buffer. - * @exception BufferUnderflowException if {@code dest.length} is greater than {@code remaining()}. - * @since Android 1.0 */ - public ByteBuffer get (byte[] dest) { - return get(dest, 0, dest.length); - } - - /** Reads bytes from the current position into the specified byte array, starting at the specified offset, and increases the - * position by the number of bytes read. - * - * @param dest the target byte array. - * @param off the offset of the byte array, must not be negative and not greater than {@code dest.length}. - * @param len the number of bytes to read, must not be negative and not greater than {@code dest.length - off} - * @return this buffer. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception BufferUnderflowException if {@code len} is greater than {@code remaining()}. - * @since Android 1.0 */ - public ByteBuffer get (byte[] dest, int off, int len) { - int length = dest.length; - if ((off < 0) || (len < 0) || ((long)off + (long)len > length)) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferUnderflowException(); - } - for (int i = off; i < off + len; i++) { - dest[i] = get(); - } - return this; - } - - /** Returns the byte at the specified index and does not change the position. - * - * @param index the index, must not be negative and less than limit. - * @return the byte at the specified index. - * @exception IndexOutOfBoundsException if index is invalid. - * @since Android 1.0 */ - public abstract byte get (int index); - - /** Returns the char at the current position and increases the position by 2. - *

- * The 2 bytes starting at the current position are composed into a char according to the current byte order and returned. - *

- * - * @return the char at the current position. - * @exception BufferUnderflowException if the position is greater than {@code limit - 2}. - * @since Android 1.0 */ - public abstract char getChar (); - - /** Returns the char at the specified index. - *

- * The 2 bytes starting from the specified index are composed into a char according to the current byte order and returned. The - * position is not changed. - *

- * - * @param index the index, must not be negative and equal or less than {@code limit - 2}. - * @return the char at the specified index. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @since Android 1.0 */ - public abstract char getChar (int index); - - /** Returns the double at the current position and increases the position by 8. - *

- * The 8 bytes starting from the current position are composed into a double according to the current byte order and returned. - *

- * - * @return the double at the current position. - * @exception BufferUnderflowException if the position is greater than {@code limit - 8}. - * @since Android 1.0 */ - public abstract double getDouble (); - - /** Returns the double at the specified index. - *

- * The 8 bytes starting at the specified index are composed into a double according to the current byte order and returned. The - * position is not changed. - *

- * - * @param index the index, must not be negative and equal or less than {@code limit - 8}. - * @return the double at the specified index. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @since Android 1.0 */ - public abstract double getDouble (int index); - - /** Returns the float at the current position and increases the position by 4. - *

- * The 4 bytes starting at the current position are composed into a float according to the current byte order and returned. - *

- * - * @return the float at the current position. - * @exception BufferUnderflowException if the position is greater than {@code limit - 4}. - * @since Android 1.0 */ - public abstract float getFloat (); - - /** Returns the float at the specified index. - *

- * The 4 bytes starting at the specified index are composed into a float according to the current byte order and returned. The - * position is not changed. - *

- * - * @param index the index, must not be negative and equal or less than {@code limit - 4}. - * @return the float at the specified index. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @since Android 1.0 */ - public abstract float getFloat (int index); - - /** Returns the int at the current position and increases the position by 4. - *

- * The 4 bytes starting at the current position are composed into a int according to the current byte order and returned. - *

- * - * @return the int at the current position. - * @exception BufferUnderflowException if the position is greater than {@code limit - 4}. - * @since Android 1.0 */ - public abstract int getInt (); - - /** Returns the int at the specified index. - *

- * The 4 bytes starting at the specified index are composed into a int according to the current byte order and returned. The - * position is not changed. - *

- * - * @param index the index, must not be negative and equal or less than {@code limit - 4}. - * @return the int at the specified index. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @since Android 1.0 */ - public abstract int getInt (int index); - - /** Returns the long at the current position and increases the position by 8. - *

- * The 8 bytes starting at the current position are composed into a long according to the current byte order and returned. - *

- * - * @return the long at the current position. - * @exception BufferUnderflowException if the position is greater than {@code limit - 8}. - * @since Android 1.0 */ - public abstract long getLong (); - - /** Returns the long at the specified index. - *

- * The 8 bytes starting at the specified index are composed into a long according to the current byte order and returned. The - * position is not changed. - *

- * - * @param index the index, must not be negative and equal or less than {@code limit - 8}. - * @return the long at the specified index. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @since Android 1.0 */ - public abstract long getLong (int index); - - /** Returns the short at the current position and increases the position by 2. - *

- * The 2 bytes starting at the current position are composed into a short according to the current byte order and returned. - *

- * - * @return the short at the current position. - * @exception BufferUnderflowException if the position is greater than {@code limit - 2}. - * @since Android 1.0 */ - public abstract short getShort (); - - /** Returns the short at the specified index. - *

- * The 2 bytes starting at the specified index are composed into a short according to the current byte order and returned. The - * position is not changed. - *

- * - * @param index the index, must not be negative and equal or less than {@code limit - 2}. - * @return the short at the specified index. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @since Android 1.0 */ - public abstract short getShort (int index); - - /** Indicates whether this buffer is based on a byte array and provides read/write access. - * - * @return {@code true} if this buffer is based on a byte array and provides read/write access, {@code false} otherwise. - * @since Android 1.0 */ - public final boolean hasArray () { - return protectedHasArray(); - } - - /** Calculates this buffer's hash code from the remaining chars. The position, limit, capacity and mark don't affect the hash - * code. - * - * @return the hash code calculated from the remaining bytes. - * @since Android 1.0 */ - public int hashCode () { - int myPosition = position; - int hash = 0; - while (myPosition < limit) { - hash = hash + get(myPosition++); - } - return hash; - } - - /** Indicates whether this buffer is direct. - * - * @return {@code true} if this buffer is direct, {@code false} otherwise. - * @since Android 1.0 */ - public abstract boolean isDirect (); - - /** Returns the byte order used by this buffer when converting bytes from/to other primitive types. - *

- * The default byte order of byte buffer is always {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN} - *

- * - * @return the byte order used by this buffer when converting bytes from/to other primitive types. - * @since Android 1.0 */ - public final ByteOrder order () { - return order == Endianness.BIG_ENDIAN ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN; - } - - /** Sets the byte order of this buffer. - * - * @param byteOrder the byte order to set. If {@code null} then the order will be {@link ByteOrder#LITTLE_ENDIAN LITTLE_ENDIAN} - * . - * @return this buffer. - * @see ByteOrder - * @since Android 1.0 */ - public final ByteBuffer order (ByteOrder byteOrder) { - return orderImpl(byteOrder); - } - - ByteBuffer orderImpl (ByteOrder byteOrder) { - order = byteOrder == ByteOrder.BIG_ENDIAN ? Endianness.BIG_ENDIAN : Endianness.LITTLE_ENDIAN; - return this; - } - - /** Child class implements this method to realize {@code array()}. - * - * @see #array() - * @since Android 1.0 */ - abstract byte[] protectedArray (); - - /** Child class implements this method to realize {@code arrayOffset()}. - * - * @see #arrayOffset() - * @since Android 1.0 */ - abstract int protectedArrayOffset (); - - /** Child class implements this method to realize {@code hasArray()}. - * - * @see #hasArray() - * @since Android 1.0 */ - abstract boolean protectedHasArray (); - - /** Writes the given byte to the current position and increases the position by 1. - * - * @param b the byte to write. - * @return this buffer. - * @exception BufferOverflowException if position is equal or greater than limit. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer put (byte b); - - /** Writes bytes in the given byte array to the current position and increases the position by the number of bytes written. - *

- * Calling this method has the same effect as {@code put(src, 0, src.length)}. - *

- * - * @param src the source byte array. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code src.length}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public final ByteBuffer put (byte[] src) { - return put(src, 0, src.length); - } - - /** Writes bytes in the given byte array, starting from the specified offset, to the current position and increases the position - * by the number of bytes written. - * - * @param src the source byte array. - * @param off the offset of byte array, must not be negative and not greater than {@code src.length}. - * @param len the number of bytes to write, must not be negative and not greater than {@code src.length - off}. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code len}. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public ByteBuffer put (byte[] src, int off, int len) { - int length = src.length; - if ((off < 0) || (len < 0) || ((long)off + (long)len > length)) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferOverflowException(); - } - for (int i = off; i < off + len; i++) { - put(src[i]); - } - return this; - } - - /** Writes all the remaining bytes of the {@code src} byte buffer to this buffer's current position, and increases both buffers' - * position by the number of bytes copied. - * - * @param src the source byte buffer. - * @return this buffer. - * @exception BufferOverflowException if {@code src.remaining()} is greater than this buffer's {@code remaining()}. - * @exception IllegalArgumentException if {@code src} is this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public ByteBuffer put (ByteBuffer src) { - if (src == this) { - throw new IllegalArgumentException(); - } - if (src.remaining() > remaining()) { - throw new BufferOverflowException(); - } - byte[] contents = new byte[src.remaining()]; - src.get(contents); - put(contents); - return this; - } - - /** Write a byte to the specified index of this buffer without changing the position. - * - * @param index the index, must not be negative and less than the limit. - * @param b the byte to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer put (int index, byte b); - - /** Writes the given char to the current position and increases the position by 2. - *

- * The char is converted to bytes using the current byte order. - *

- * - * @param value the char to write. - * @return this buffer. - * @exception BufferOverflowException if position is greater than {@code limit - 2}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putChar (char value); - - /** Writes the given char to the specified index of this buffer. - *

- * The char is converted to bytes using the current byte order. The position is not changed. - *

- * - * @param index the index, must not be negative and equal or less than {@code limit - 2}. - * @param value the char to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putChar (int index, char value); - - /** Writes the given double to the current position and increases the position by 8. - *

- * The double is converted to bytes using the current byte order. - *

- * - * @param value the double to write. - * @return this buffer. - * @exception BufferOverflowException if position is greater than {@code limit - 8}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putDouble (double value); - - /** Writes the given double to the specified index of this buffer. - *

- * The double is converted to bytes using the current byte order. The position is not changed. - *

- * - * @param index the index, must not be negative and equal or less than {@code limit - 8}. - * @param value the double to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putDouble (int index, double value); - - /** Writes the given float to the current position and increases the position by 4. - *

- * The float is converted to bytes using the current byte order. - *

- * - * @param value the float to write. - * @return this buffer. - * @exception BufferOverflowException if position is greater than {@code limit - 4}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putFloat (float value); - - /** Writes the given float to the specified index of this buffer. - *

- * The float is converted to bytes using the current byte order. The position is not changed. - *

- * - * @param index the index, must not be negative and equal or less than {@code limit - 4}. - * @param value the float to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putFloat (int index, float value); - - /** Writes the given int to the current position and increases the position by 4. - *

- * The int is converted to bytes using the current byte order. - *

- * - * @param value the int to write. - * @return this buffer. - * @exception BufferOverflowException if position is greater than {@code limit - 4}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putInt (int value); - - /** Writes the given int to the specified index of this buffer. - *

- * The int is converted to bytes using the current byte order. The position is not changed. - *

- * - * @param index the index, must not be negative and equal or less than {@code limit - 4}. - * @param value the int to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putInt (int index, int value); - - /** Writes the given long to the current position and increases the position by 8. - *

- * The long is converted to bytes using the current byte order. - *

- * - * @param value the long to write. - * @return this buffer. - * @exception BufferOverflowException if position is greater than {@code limit - 8}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putLong (long value); - - /** Writes the given long to the specified index of this buffer. - *

- * The long is converted to bytes using the current byte order. The position is not changed. - *

- * - * @param index the index, must not be negative and equal or less than {@code limit - 8}. - * @param value the long to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putLong (int index, long value); - - /** Writes the given short to the current position and increases the position by 2. - *

- * The short is converted to bytes using the current byte order. - *

- * - * @param value the short to write. - * @return this buffer. - * @exception BufferOverflowException if position is greater than {@code limit - 2}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putShort (short value); - - /** Writes the given short to the specified index of this buffer. - *

- * The short is converted to bytes using the current byte order. The position is not changed. - *

- * - * @param index the index, must not be negative and equal or less than {@code limit - 2}. - * @param value the short to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putShort (int index, short value); - - /** Returns a sliced buffer that shares its content with this buffer. - *

- * The sliced buffer's capacity will be this buffer's {@code remaining()}, and it's zero position will correspond to this - * buffer's current position. The new buffer's position will be 0, limit will be its capacity, and its mark is cleared. The new - * buffer's read-only property and byte order are the same as this buffer's. - *

- *

- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *

- * - * @return a sliced buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer slice (); - - /** Returns a string representing the state of this byte buffer. - * - * @return a string representing the state of this byte buffer. - * @since Android 1.0 */ - public String toString () { - StringBuffer buf = new StringBuffer(); - buf.append(getClass().getName()); - buf.append(", status: capacity="); //$NON-NLS-1$ - buf.append(capacity()); - buf.append(" position="); //$NON-NLS-1$ - buf.append(position()); - buf.append(" limit="); //$NON-NLS-1$ - buf.append(limit()); - return buf.toString(); - } - - public ByteBuffer stringToByteBuffer (String s) { - return new StringByteBuffer(s); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ByteBufferWrapper.java b/backends/gdx-backend-dragome/emu/java/nio/ByteBufferWrapper.java deleted file mode 100644 index a8654af4..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ByteBufferWrapper.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.nio; - -public interface ByteBufferWrapper { - ByteBuffer getByteBuffer (); -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ByteOrder.java b/backends/gdx-backend-dragome/emu/java/nio/ByteOrder.java deleted file mode 100644 index a5b0f470..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ByteOrder.java +++ /dev/null @@ -1,69 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -//import org.apache.harmony.luni.platform.Platform; - -/** Defines byte order constants. - * - * @since Android 1.0 */ -public final class ByteOrder { - - /** This constant represents big endian. - * - * @since Android 1.0 */ - public static final ByteOrder BIG_ENDIAN = new ByteOrder("BIG_ENDIAN"); //$NON-NLS-1$ - - /** This constant represents little endian. - * - * @since Android 1.0 */ - public static final ByteOrder LITTLE_ENDIAN = new ByteOrder("LITTLE_ENDIAN"); //$NON-NLS-1$ - - private static final ByteOrder NATIVE_ORDER; - - static { -// if (Platform.getMemorySystem().isLittleEndian()) { - NATIVE_ORDER = LITTLE_ENDIAN; -// } else { -// NATIVE_ORDER = BIG_ENDIAN; -// } - } - - /** Returns the current platform byte order. - * - * @return the byte order object, which is either LITTLE_ENDIAN or BIG_ENDIAN. - * @since Android 1.0 */ - public static ByteOrder nativeOrder () { - return NATIVE_ORDER; - } - - private final String name; - - private ByteOrder (String name) { - super(); - this.name = name; - } - - /** Returns a string that describes this object. - * - * @return "BIG_ENDIAN" for {@link #BIG_ENDIAN ByteOrder.BIG_ENDIAN} objects, "LITTLE_ENDIAN" for {@link #LITTLE_ENDIAN - * ByteOrder.LITTLE_ENDIAN} objects. - * @since Android 1.0 */ - public String toString () { - return name; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/CharArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/CharArrayBuffer.java deleted file mode 100644 index 17a0522b..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/CharArrayBuffer.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** CharArrayBuffer, ReadWriteCharArrayBuffer and ReadOnlyCharArrayBuffer compose the implementation of array based char buffers. - *

- * CharArrayBuffer implements all the shared readonly methods and is extended by the other two classes. - *

- *

- * All methods are marked final for runtime performance. - *

*/ -abstract class CharArrayBuffer extends CharBuffer { - - protected final char[] backingArray; - - protected final int offset; - - CharArrayBuffer (char[] array) { - this(array.length, array, 0); - } - - CharArrayBuffer (int capacity) { - this(capacity, new char[capacity], 0); - } - - CharArrayBuffer (int capacity, char[] backingArray, int offset) { - super(capacity); - this.backingArray = backingArray; - this.offset = offset; - } - - public final char get () { - if (position == limit) { - throw new BufferUnderflowException(); - } - return backingArray[offset + position++]; - } - - public final char get (int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return backingArray[offset + index]; - } - - public final CharBuffer get (char[] dest, int off, int len) { - int length = dest.length; - if ((off < 0) || (len < 0) || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferUnderflowException(); - } - System.arraycopy(backingArray, offset + position, dest, off, len); - position += len; - return this; - } - - public final boolean isDirect () { - return false; - } - - public final ByteOrder order () { - return ByteOrder.nativeOrder(); - } - - public final CharSequence subSequence (int start, int end) { - if (start < 0 || end < start || end > remaining()) { - throw new IndexOutOfBoundsException(); - } - - CharBuffer result = duplicate(); - result.limit(position + end); - result.position(position + start); - return result; - } - - public final String toString () { - return String.copyValueOf(backingArray, offset + position, remaining()); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/CharBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/CharBuffer.java deleted file mode 100644 index 8011e36f..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/CharBuffer.java +++ /dev/null @@ -1,622 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -import java.io.IOException; - -/** A buffer of chars. - *

- * A char buffer can be created in either one of the following ways: - *

- *
    - *
  • {@link #allocate(int) Allocate} a new char array and create a buffer based on it;
  • - *
  • {@link #wrap(char[]) Wrap} an existing char array to create a new buffer;
  • - *
  • {@link #wrap(CharSequence) Wrap} an existing char sequence to create a new buffer;
  • - *
  • Use {@link java.nio.ByteBuffer#asCharBuffer() ByteBuffer.asCharBuffer} to create a char buffer based on a byte buffer.
  • - *
- * - * @since Android 1.0 */ -public abstract class CharBuffer extends Buffer implements Comparable, CharSequence, Appendable {// , Readable { - - /** Creates a char buffer based on a newly allocated char array. - * - * @param capacity the capacity of the new buffer. - * @return the created char buffer. - * @throws IllegalArgumentException if {@code capacity} is less than zero. - * @since Android 1.0 */ - public static CharBuffer allocate (int capacity) { - if (capacity < 0) { - throw new IllegalArgumentException(); - } - return BufferFactory.newCharBuffer(capacity); - } - - /** Creates a new char buffer by wrapping the given char array. - *

- * Calling this method has the same effect as {@code wrap(array, 0, array.length)}. - *

- * - * @param array the char array which the new buffer will be based on. - * @return the created char buffer. - * @since Android 1.0 */ - public static CharBuffer wrap (char[] array) { - return wrap(array, 0, array.length); - } - - /** Creates a new char buffer by wrapping the given char array. - *

- * The new buffer's position will be {@code start}, limit will be {@code start + len}, capacity will be the length of the array. - *

- * - * @param array the char array which the new buffer will be based on. - * @param start the start index, must not be negative and not greater than {@code array.length}. - * @param len the length, must not be negative and not greater than {@code array.length - start}. - * @return the created char buffer. - * @exception IndexOutOfBoundsException if either {@code start} or {@code len} is invalid. - * @since Android 1.0 */ - public static CharBuffer wrap (char[] array, int start, int len) { - int length = array.length; - if ((start < 0) || (len < 0) || (long)start + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - - CharBuffer buf = BufferFactory.newCharBuffer(array); - buf.position = start; - buf.limit = start + len; - - return buf; - } - - /** Creates a new char buffer by wrapping the given char sequence. - *

- * Calling this method has the same effect as {@code wrap(chseq, 0, chseq.length())}. - *

- * - * @param chseq the char sequence which the new buffer will be based on. - * @return the created char buffer. - * @since Android 1.0 */ - public static CharBuffer wrap (CharSequence chseq) { - return BufferFactory.newCharBuffer(chseq); - } - - /** Creates a new char buffer by wrapping the given char sequence. - *

- * The new buffer's position will be {@code start}, limit will be {@code end}, capacity will be the length of the char sequence. - * The new buffer is read-only. - *

- * - * @param chseq the char sequence which the new buffer will be based on. - * @param start the start index, must not be negative and not greater than {@code chseq.length()}. - * @param end the end index, must be no less than {@code start} and no greater than {@code chseq.length()}. - * @return the created char buffer. - * @exception IndexOutOfBoundsException if either {@code start} or {@code end} is invalid. - * @since Android 1.0 */ - public static CharBuffer wrap (CharSequence chseq, int start, int end) { - if (chseq == null) { - throw new NullPointerException(); - } - if (start < 0 || end < start || end > chseq.length()) { - throw new IndexOutOfBoundsException(); - } - - CharBuffer result = BufferFactory.newCharBuffer(chseq); - result.position = start; - result.limit = end; - return result; - } - - /** Constructs a {@code CharBuffer} with given capacity. - * - * @param capacity the capacity of the buffer. - * @since Android 1.0 */ - CharBuffer (int capacity) { - super(capacity); - } - - /** Returns the char array which this buffer is based on, if there is one. - * - * @return the char array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final char[] array () { - return protectedArray(); - } - - /** Returns the offset of the char array which this buffer is based on, if there is one. - *

- * The offset is the index of the array corresponds to the zero position of the buffer. - *

- * - * @return the offset of the char array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final int arrayOffset () { - return protectedArrayOffset(); - } - - /** Returns a read-only buffer that shares its content with this buffer. - *

- * The returned buffer is guaranteed to be a new instance, even if this buffer is read-only itself. The new buffer's position, - * limit, capacity and mark are the same as this buffer's. - *

- *

- * The new buffer shares its content with this buffer, which means this buffer's change of content will be visible to the new - * buffer. The two buffer's position, limit and mark are independent. - *

- * - * @return a read-only version of this buffer. - * @since Android 1.0 */ - public abstract CharBuffer asReadOnlyBuffer (); - - /** Returns the character located at the specified index in the buffer. The index value is referenced from the current buffer - * position. - * - * @param index the index referenced from the current buffer position. It must not be less than zero but less than the value - * obtained from a call to {@code remaining()}. - * @return the character located at the specified index (referenced from the current position) in the buffer. - * @exception IndexOutOfBoundsException if the index is invalid. - * @since Android 1.0 */ - public final char charAt (int index) { - if (index < 0 || index >= remaining()) { - throw new IndexOutOfBoundsException(); - } - return get(position + index); - } - - /** Compacts this char buffer. - *

- * The remaining chars will be moved to the head of the buffer, starting from position zero. Then the position is set to - * {@code remaining()}; the limit is set to capacity; the mark is cleared. - *

- * - * @return this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract CharBuffer compact (); - - /** Compare the remaining chars of this buffer to another char buffer's remaining chars. - * - * @param otherBuffer another char buffer. - * @return a negative value if this is less than {@code otherBuffer}; 0 if this equals to {@code otherBuffer}; a positive value - * if this is greater than {@code otherBuffer}. - * @exception ClassCastException if {@code otherBuffer} is not a char buffer. - * @since Android 1.0 */ - public int compareTo (CharBuffer otherBuffer) { - int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining() : otherBuffer.remaining(); - int thisPos = position; - int otherPos = otherBuffer.position; - char thisByte, otherByte; - while (compareRemaining > 0) { - thisByte = get(thisPos); - otherByte = otherBuffer.get(otherPos); - if (thisByte != otherByte) { - return thisByte < otherByte ? -1 : 1; - } - thisPos++; - otherPos++; - compareRemaining--; - } - return remaining() - otherBuffer.remaining(); - } - - /** Returns a duplicated buffer that shares its content with this buffer. - *

- * The duplicated buffer's initial position, limit, capacity and mark are the same as this buffer's. The duplicated buffer's - * read-only property and byte order are the same as this buffer's, too. - *

- *

- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *

- * - * @return a duplicated buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract CharBuffer duplicate (); - - /** Checks whether this char buffer is equal to another object. - *

- * If {@code other} is not a char buffer then {@code false} is returned. Two char buffers are equal if and only if their - * remaining chars are exactly the same. Position, limit, capacity and mark are not considered. - *

- * - * @param other the object to compare with this char buffer. - * @return {@code true} if this char buffer is equal to {@code other}, {@code false} otherwise. - * @since Android 1.0 */ - public boolean equals (Object other) { - if (!(other instanceof CharBuffer)) { - return false; - } - CharBuffer otherBuffer = (CharBuffer)other; - - if (remaining() != otherBuffer.remaining()) { - return false; - } - - int myPosition = position; - int otherPosition = otherBuffer.position; - boolean equalSoFar = true; - while (equalSoFar && (myPosition < limit)) { - equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++); - } - - return equalSoFar; - } - - /** Returns the char at the current position and increases the position by 1. - * - * @return the char at the current position. - * @exception BufferUnderflowException if the position is equal or greater than limit. - * @since Android 1.0 */ - public abstract char get (); - - /** Reads chars from the current position into the specified char array and increases the position by the number of chars read. - *

- * Calling this method has the same effect as {@code get(dest, 0, dest.length)}. - *

- * - * @param dest the destination char array. - * @return this buffer. - * @exception BufferUnderflowException if {@code dest.length} is greater than {@code remaining()}. - * @since Android 1.0 */ - public CharBuffer get (char[] dest) { - return get(dest, 0, dest.length); - } - - /** Reads chars from the current position into the specified char array, starting from the specified offset, and increases the - * position by the number of chars read. - * - * @param dest the target char array. - * @param off the offset of the char array, must not be negative and not greater than {@code dest.length}. - * @param len The number of chars to read, must be no less than zero and no greater than {@code dest.length - off}. - * @return this buffer. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception BufferUnderflowException if {@code len} is greater than {@code remaining()}. - * @since Android 1.0 */ - public CharBuffer get (char[] dest, int off, int len) { - int length = dest.length; - if ((off < 0) || (len < 0) || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferUnderflowException(); - } - for (int i = off; i < off + len; i++) { - dest[i] = get(); - } - return this; - } - - /** Returns a char at the specified index; the position is not changed. - * - * @param index the index, must not be negative and less than limit. - * @return a char at the specified index. - * @exception IndexOutOfBoundsException if index is invalid. - * @since Android 1.0 */ - public abstract char get (int index); - - /** Indicates whether this buffer is based on a char array and is read/write. - * - * @return {@code true} if this buffer is based on a byte array and provides read/write access, {@code false} otherwise. - * @since Android 1.0 */ - public final boolean hasArray () { - return protectedHasArray(); - } - - /** Calculates this buffer's hash code from the remaining chars. The position, limit, capacity and mark don't affect the hash - * code. - * - * @return the hash code calculated from the remaining chars. - * @since Android 1.0 */ - public int hashCode () { - int myPosition = position; - int hash = 0; - while (myPosition < limit) { - hash = hash + get(myPosition++); - } - return hash; - } - - /** Indicates whether this buffer is direct. A direct buffer will try its best to take advantage of native memory APIs and it - * may not stay in the Java heap, so it is not affected by garbage collection. - *

- * A char buffer is direct if it is based on a byte buffer and the byte buffer is direct. - *

- * - * @return {@code true} if this buffer is direct, {@code false} otherwise. - * @since Android 1.0 */ - public abstract boolean isDirect (); - - /** Returns the number of remaining chars. - * - * @return the number of remaining chars. - * @since Android 1.0 */ - public final int length () { - return remaining(); - } - - /** Returns the byte order used by this buffer when converting chars from/to bytes. - *

- * If this buffer is not based on a byte buffer, then this always returns the platform's native byte order. - *

- * - * @return the byte order used by this buffer when converting chars from/to bytes. - * @since Android 1.0 */ - public abstract ByteOrder order (); - - /** Child class implements this method to realize {@code array()}. - * - * @see #array() */ - abstract char[] protectedArray (); - - /** Child class implements this method to realize {@code arrayOffset()}. - * - * @see #arrayOffset() */ - abstract int protectedArrayOffset (); - - /** Child class implements this method to realize {@code hasArray()}. - * - * @see #hasArray() */ - abstract boolean protectedHasArray (); - - /** Writes the given char to the current position and increases the position by 1. - * - * @param c the char to write. - * @return this buffer. - * @exception BufferOverflowException if position is equal or greater than limit. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract CharBuffer put (char c); - - /** Writes chars from the given char array to the current position and increases the position by the number of chars written. - *

- * Calling this method has the same effect as {@code put(src, 0, src.length)}. - *

- * - * @param src the source char array. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code src.length}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public final CharBuffer put (char[] src) { - return put(src, 0, src.length); - } - - /** Writes chars from the given char array, starting from the specified offset, to the current position and increases the - * position by the number of chars written. - * - * @param src the source char array. - * @param off the offset of char array, must not be negative and not greater than {@code src.length}. - * @param len the number of chars to write, must be no less than zero and no greater than {@code src.length - off}. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code len}. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public CharBuffer put (char[] src, int off, int len) { - int length = src.length; - if ((off < 0) || (len < 0) || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferOverflowException(); - } - for (int i = off; i < off + len; i++) { - put(src[i]); - } - return this; - } - - /** Writes all the remaining chars of the {@code src} char buffer to this buffer's current position, and increases both buffers' - * position by the number of chars copied. - * - * @param src the source char buffer. - * @return this buffer. - * @exception BufferOverflowException if {@code src.remaining()} is greater than this buffer's {@code remaining()}. - * @exception IllegalArgumentException if {@code src} is this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public CharBuffer put (CharBuffer src) { - if (src == this) { - throw new IllegalArgumentException(); - } - if (src.remaining() > remaining()) { - throw new BufferOverflowException(); - } - - char[] contents = new char[src.remaining()]; - src.get(contents); - put(contents); - return this; - } - - /** Writes a char to the specified index of this buffer; the position is not changed. - * - * @param index the index, must be no less than zero and less than the limit. - * @param c the char to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if index is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract CharBuffer put (int index, char c); - - /** Writes all chars of the given string to the current position of this buffer, and increases the position by the length of - * string. - *

- * Calling this method has the same effect as {@code put(str, 0, str.length())}. - *

- * - * @param str the string to write. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than the length of string. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public final CharBuffer put (String str) { - return put(str, 0, str.length()); - } - - /** Writes chars of the given string to the current position of this buffer, and increases the position by the number of chars - * written. - * - * @param str the string to write. - * @param start the first char to write, must not be negative and not greater than {@code str.length()}. - * @param end the last char to write (excluding), must be less than {@code start} and not greater than {@code str.length()}. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code end - start}. - * @exception IndexOutOfBoundsException if either {@code start} or {@code end} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public CharBuffer put (String str, int start, int end) { - int length = str.length(); - if (start < 0 || end < start || end > length) { - throw new IndexOutOfBoundsException(); - } - - if (end - start > remaining()) { - throw new BufferOverflowException(); - } - for (int i = start; i < end; i++) { - put(str.charAt(i)); - } - return this; - } - - /** Returns a sliced buffer that shares its content with this buffer. - *

- * The sliced buffer's capacity will be this buffer's {@code remaining()}, and its zero position will correspond to this - * buffer's current position. The new buffer's position will be 0, limit will be its capacity, and its mark is cleared. The new - * buffer's read-only property and byte order are same as this buffer. - *

- *

- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *

- * - * @return a sliced buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract CharBuffer slice (); - - /** Returns a new char buffer representing a sub-sequence of this buffer's current remaining content. - *

- * The new buffer's position will be {@code position() + start}, limit will be {@code position() + end}, capacity will be the - * same as this buffer. The new buffer's read-only property and byte order are the same as this buffer. - *

- *

- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *

- * - * @param start the start index of the sub-sequence, referenced from the current buffer position. Must not be less than zero - * and not greater than the value obtained from a call to {@code remaining()}. - * @param end the end index of the sub-sequence, referenced from the current buffer position. Must not be less than - * {@code start} and not be greater than the value obtained from a call to {@code remaining()}. - * @return a new char buffer represents a sub-sequence of this buffer's current remaining content. - * @exception IndexOutOfBoundsException if either {@code start} or {@code end} is invalid. - * @since Android 1.0 */ - public abstract CharSequence subSequence (int start, int end); - - /** Returns a string representing the current remaining chars of this buffer. - * - * @return a string representing the current remaining chars of this buffer. - * @since Android 1.0 */ - public String toString () { - StringBuffer strbuf = new StringBuffer(); - for (int i = position; i < limit; i++) { - strbuf.append(get(i)); - } - return strbuf.toString(); - } - - /** Writes the given char to the current position and increases the position by 1. - * - * @param c the char to write. - * @return this buffer. - * @exception BufferOverflowException if position is equal or greater than limit. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public CharBuffer append (char c) { - return put(c); - } - - /** Writes all chars of the given character sequence {@code csq} to the current position of this buffer, and increases the - * position by the length of the csq. - *

- * Calling this method has the same effect as {@code append(csq.toString())}. - *

- * If the {@code CharSequence} is {@code null} the string "null" will be written to the buffer. - * - * @param csq the {@code CharSequence} to write. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than the length of csq. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public CharBuffer append (CharSequence csq) { - if (csq != null) { - return put(csq.toString()); - } - return put("null"); //$NON-NLS-1$ - } - - /** Writes chars of the given {@code CharSequence} to the current position of this buffer, and increases the position by the - * number of chars written. - * - * @param csq the {@code CharSequence} to write. - * @param start the first char to write, must not be negative and not greater than {@code csq.length()}. - * @param end the last char to write (excluding), must be less than {@code start} and not greater than {@code csq.length()}. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code end - start}. - * @exception IndexOutOfBoundsException if either {@code start} or {@code end} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public CharBuffer append (CharSequence csq, int start, int end) { - if (csq == null) { - csq = "null"; //$NON-NLS-1$ - } - CharSequence cs = csq.subSequence(start, end); - if (cs.length() > 0) { - return put(cs.toString()); - } - return this; - } - - /** Reads characters from this buffer and puts them into {@code target}. The number of chars that are copied is either the - * number of remaining chars in this buffer or the number of remaining chars in {@code target}, whichever is smaller. - * - * @param target the target char buffer. - * @throws IllegalArgumentException if {@code target} is this buffer. - * @throws IOException if an I/O error occurs. - * @throws ReadOnlyBufferException if no changes may be made to the contents of {@code target}. - * @return the number of chars copied or -1 if there are no chars left to be read from this buffer. - * @since Android 1.0 */ - public int read (CharBuffer target) throws IOException { - if (target == this) { - throw new IllegalArgumentException(); - } - if (remaining() == 0) { - return target.remaining() == 0 ? 0 : -1; - } - int result = Math.min(target.remaining(), remaining()); - char[] chars = new char[result]; - get(chars); - target.put(chars); - return result; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/CharSequenceAdapter.java b/backends/gdx-backend-dragome/emu/java/nio/CharSequenceAdapter.java deleted file mode 100644 index 45b7e77e..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/CharSequenceAdapter.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** This class wraps a char sequence to be a char buffer. - *

- * Implementation notice: - *

    - *
  • Char sequence based buffer is always readonly.
  • - *
- *

*/ -final class CharSequenceAdapter extends CharBuffer { - - static CharSequenceAdapter copy (CharSequenceAdapter other) { - CharSequenceAdapter buf = new CharSequenceAdapter(other.sequence); - buf.limit = other.limit; - buf.position = other.position; - buf.mark = other.mark; - return buf; - } - - final CharSequence sequence; - - CharSequenceAdapter (CharSequence chseq) { - super(chseq.length()); - sequence = chseq; - } - - public CharBuffer asReadOnlyBuffer () { - return duplicate(); - } - - public CharBuffer compact () { - throw new ReadOnlyBufferException(); - } - - public CharBuffer duplicate () { - return copy(this); - } - - public char get () { - if (position == limit) { - throw new BufferUnderflowException(); - } - return sequence.charAt(position++); - } - - public char get (int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return sequence.charAt(index); - } - - public final CharBuffer get (char[] dest, int off, int len) { - int length = dest.length; - if ((off < 0) || (len < 0) || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferUnderflowException(); - } - int newPosition = position + len; - sequence.toString().getChars(position, newPosition, dest, off); - position = newPosition; - return this; - } - - public boolean isDirect () { - return false; - } - - public boolean isReadOnly () { - return true; - } - - public ByteOrder order () { - return ByteOrder.nativeOrder(); - } - - protected char[] protectedArray () { - throw new UnsupportedOperationException(); - } - - protected int protectedArrayOffset () { - throw new UnsupportedOperationException(); - } - - protected boolean protectedHasArray () { - return false; - } - - public CharBuffer put (char c) { - throw new ReadOnlyBufferException(); - } - - public CharBuffer put (int index, char c) { - throw new ReadOnlyBufferException(); - } - - public final CharBuffer put (char[] src, int off, int len) { - if ((off < 0) || (len < 0) || (long)off + (long)len > src.length) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferOverflowException(); - } - - throw new ReadOnlyBufferException(); - } - - public CharBuffer put (String src, int start, int end) { - if ((start < 0) || (end < 0) || (long)start + (long)end > src.length()) { - throw new IndexOutOfBoundsException(); - } - throw new ReadOnlyBufferException(); - } - - public CharBuffer slice () { - return new CharSequenceAdapter(sequence.subSequence(position, limit)); - } - - public CharSequence subSequence (int start, int end) { - if (end < start || start < 0 || end > remaining()) { - throw new IndexOutOfBoundsException(); - } - - CharSequenceAdapter result = copy(this); - result.position = position + start; - result.limit = position + end; - return result; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/CharToByteBufferAdapter.java b/backends/gdx-backend-dragome/emu/java/nio/CharToByteBufferAdapter.java deleted file mode 100644 index 0f65cd43..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/CharToByteBufferAdapter.java +++ /dev/null @@ -1,211 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -//import org.apache.harmony.nio.internal.DirectBuffer; -//import org.apache.harmony.luni.platform.PlatformAddress; - -/** This class wraps a byte buffer to be a char buffer. - *

- * Implementation notice: - *

    - *
  • After a byte buffer instance is wrapped, it becomes privately owned by the adapter. It must NOT be accessed outside the - * adapter any more.
  • - *
  • The byte buffer's position and limit are NOT linked with the adapter. The adapter extends Buffer, thus has its own position - * and limit.
  • - *
- *

*/ -final class CharToByteBufferAdapter extends CharBuffer { // implements DirectBuffer { - - static CharBuffer wrap (ByteBuffer byteBuffer) { - return new CharToByteBufferAdapter(byteBuffer.slice()); - } - - private final ByteBuffer byteBuffer; - - CharToByteBufferAdapter (ByteBuffer byteBuffer) { - super((byteBuffer.capacity() >> 1)); - this.byteBuffer = byteBuffer; - this.byteBuffer.clear(); - } - -// public int getByteCapacity() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).getByteCapacity(); -// } -// assert false : byteBuffer; -// return -1; -// } -// -// public PlatformAddress getEffectiveAddress() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).getEffectiveAddress(); -// } -// assert false : byteBuffer; -// return null; -// } -// -// public PlatformAddress getBaseAddress() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).getBaseAddress(); -// } -// assert false : byteBuffer; -// return null; -// } -// -// public boolean isAddressValid() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).isAddressValid(); -// } -// assert false : byteBuffer; -// return false; -// } -// -// public void addressValidityCheck() { -// if (byteBuffer instanceof DirectBuffer) { -// ((DirectBuffer) byteBuffer).addressValidityCheck(); -// } else { -// assert false : byteBuffer; -// } -// } -// -// public void free() { -// if (byteBuffer instanceof DirectBuffer) { -// ((DirectBuffer) byteBuffer).free(); -// } else { -// assert false : byteBuffer; -// } -// } - - @Override - public CharBuffer asReadOnlyBuffer () { - CharToByteBufferAdapter buf = new CharToByteBufferAdapter(byteBuffer.asReadOnlyBuffer()); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public CharBuffer compact () { - if (byteBuffer.isReadOnly()) { - throw new ReadOnlyBufferException(); - } - byteBuffer.limit(limit << 1); - byteBuffer.position(position << 1); - byteBuffer.compact(); - byteBuffer.clear(); - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - @Override - public CharBuffer duplicate () { - CharToByteBufferAdapter buf = new CharToByteBufferAdapter(byteBuffer.duplicate()); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public char get () { - if (position == limit) { - throw new BufferUnderflowException(); - } - return byteBuffer.getChar(position++ << 1); - } - - @Override - public char get (int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return byteBuffer.getChar(index << 1); - } - - @Override - public boolean isDirect () { - return byteBuffer.isDirect(); - } - - @Override - public boolean isReadOnly () { - return byteBuffer.isReadOnly(); - } - - @Override - public ByteOrder order () { - return byteBuffer.order(); - } - - @Override - protected char[] protectedArray () { - throw new UnsupportedOperationException(); - } - - @Override - protected int protectedArrayOffset () { - throw new UnsupportedOperationException(); - } - - @Override - protected boolean protectedHasArray () { - return false; - } - - @Override - public CharBuffer put (char c) { - if (position == limit) { - throw new BufferOverflowException(); - } - byteBuffer.putChar(position++ << 1, c); - return this; - } - - @Override - public CharBuffer put (int index, char c) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - byteBuffer.putChar(index << 1, c); - return this; - } - - @Override - public CharBuffer slice () { - byteBuffer.limit(limit << 1); - byteBuffer.position(position << 1); - CharBuffer result = new CharToByteBufferAdapter(byteBuffer.slice()); - byteBuffer.clear(); - return result; - } - - @Override - public CharSequence subSequence (int start, int end) { - if (start < 0 || end < start || end > remaining()) { - throw new IndexOutOfBoundsException(); - } - - CharBuffer result = duplicate(); - result.limit(position + end); - result.position(position + start); - return result; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/DirectByteBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/DirectByteBuffer.java deleted file mode 100644 index 2142a7bd..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/DirectByteBuffer.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -import java.io.Numbers; - -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBuffer; -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBufferView; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Int8Array; -import com.badlogic.gdx.backends.dragome.utils.Endianness; - -/** DirectByteBuffer, DirectReadWriteByteBuffer and DirectReadOnlyHeapByteBuffer compose the implementation of direct byte buffers. - *

- * DirectByteBuffer implements all the shared readonly methods and is extended by the other two classes. - *

- *

- * All methods are marked final for runtime performance. - *

*/ -abstract class DirectByteBuffer extends BaseByteBuffer implements HasArrayBufferView { - - Int8Array byteArray; - - DirectByteBuffer (int capacity) { - this(ArrayBuffer.create(capacity), capacity, 0); - } - - DirectByteBuffer (ArrayBuffer buf) { - this(buf, buf.get_byteLength(), 0); - } - - DirectByteBuffer (ArrayBuffer buffer, int capacity, int offset) { - super(capacity); - byteArray = Int8Array.create(buffer, offset, capacity); - } - - public ArrayBufferView getTypedArray () { - return byteArray; - } - - public int getElementSize () { - return 1; - } - - /* - * Override ByteBuffer.get(byte[], int, int) to improve performance. - * - * (non-Javadoc) - * - * @see java.nio.ByteBuffer#get(byte[], int, int) - */ - public final ByteBuffer get (byte[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferUnderflowException(); - } - - for (int i = 0; i < len; i++) { - dest[i + off] = get(position + i); - } - - position += len; - return this; - } - - public final byte get () { -// if (position == limit) { -// throw new BufferUnderflowException(); -// } - return (byte)byteArray.get(position++); - } - - public final byte get (int index) { -// if (index < 0 || index >= limit) { -// throw new IndexOutOfBoundsException(); -// } - return (byte)byteArray.get(index); - } - - public final double getDouble () { - return Numbers.longBitsToDouble(getLong()); - } - - public final double getDouble (int index) { - return Numbers.longBitsToDouble(getLong(index)); - } - - public final float getFloat () { - return Numbers.intBitsToFloat(getInt()); - } - - public final float getFloat (int index) { - return Numbers.intBitsToFloat(getInt(index)); - } - - public final int getInt () { - int newPosition = position + 4; -// if (newPosition > limit) { -// throw new BufferUnderflowException(); -// } - int result = loadInt(position); - position = newPosition; - return result; - } - - public final int getInt (int index) { -// if (index < 0 || index + 4 > limit) { -// throw new IndexOutOfBoundsException(); -// } - return loadInt(index); - } - - public final long getLong () { - int newPosition = position + 8; -// if (newPosition > limit) { -// throw new BufferUnderflowException(); -// } - long result = loadLong(position); - position = newPosition; - return result; - } - - public final long getLong (int index) { -// if (index < 0 || index + 8 > limit) { -// throw new IndexOutOfBoundsException(); -// } - return loadLong(index); - } - - public final short getShort () { - int newPosition = position + 2; -// if (newPosition > limit) { -// throw new BufferUnderflowException(); -// } - short result = loadShort(position); - position = newPosition; - return result; - } - - public final short getShort (int index) { -// if (index < 0 || index + 2 > limit) { -// throw new IndexOutOfBoundsException(); -// } - return loadShort(index); - } - - public final boolean isDirect () { - return false; - } - - protected final int loadInt (int baseOffset) { - int bytes = 0; - if (order == Endianness.BIG_ENDIAN) { - for (int i = 0; i < 4; i++) { - bytes = bytes << 8; - bytes = bytes | (byteArray.get(baseOffset + i) & 0xFF); - } - } else { - for (int i = 3; i >= 0; i--) { - bytes = bytes << 8; - bytes = bytes | (byteArray.get(baseOffset + i) & 0xFF); - } - } - return bytes; - } - - protected final long loadLong (int baseOffset) { - long bytes = 0; - if (order == Endianness.BIG_ENDIAN) { - for (int i = 0; i < 8; i++) { - bytes = bytes << 8; - bytes = bytes | (byteArray.get(baseOffset + i) & 0xFF); - } - } else { - for (int i = 7; i >= 0; i--) { - bytes = bytes << 8; - bytes = bytes | (byteArray.get(baseOffset + i) & 0xFF); - } - } - return bytes; - } - - protected final short loadShort (int baseOffset) { - short bytes = 0; - if (order == Endianness.BIG_ENDIAN) { - bytes = (short)(byteArray.get(baseOffset) << 8); - bytes |= (byteArray.get(baseOffset + 1) & 0xFF); - } else { - bytes = (short)(byteArray.get(baseOffset + 1) << 8); - bytes |= (byteArray.get(baseOffset) & 0xFF); - } - return bytes; - } - - protected final void store (int baseOffset, int value) { - if (order == Endianness.BIG_ENDIAN) { - for (int i = 3; i >= 0; i--) { - byteArray.set(baseOffset + i, (byte)(value & 0xFF)); - value = value >> 8; - } - } else { - for (int i = 0; i <= 3; i++) { - byteArray.set(baseOffset + i, (byte)(value & 0xFF)); - value = value >> 8; - } - } - } - - protected final void store (int baseOffset, long value) { - if (order == Endianness.BIG_ENDIAN) { - for (int i = 7; i >= 0; i--) { - byteArray.set(baseOffset + i, (byte)(value & 0xFF)); - value = value >> 8; - } - } else { - for (int i = 0; i <= 7; i++) { - byteArray.set(baseOffset + i, (byte)(value & 0xFF)); - value = value >> 8; - } - } - } - - protected final void store (int baseOffset, short value) { - if (order == Endianness.BIG_ENDIAN) { - byteArray.set(baseOffset, (byte)((value >> 8) & 0xFF)); - byteArray.set(baseOffset + 1, (byte)(value & 0xFF)); - } else { - byteArray.set(baseOffset + 1, (byte)((value >> 8) & 0xFF)); - byteArray.set(baseOffset, (byte)(value & 0xFF)); - } - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/DirectReadOnlyByteBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/DirectReadOnlyByteBuffer.java deleted file mode 100644 index 156b9225..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/DirectReadOnlyByteBuffer.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBuffer; - -/** HeapByteBuffer, ReadWriteHeapByteBuffer and ReadOnlyHeapByteBuffer compose the implementation of array based byte buffers. - *

- * ReadOnlyHeapByteBuffer extends HeapByteBuffer with all the write methods throwing read only exception. - *

- *

- * This class is marked final for runtime performance. - *

*/ -final class DirectReadOnlyByteBuffer extends DirectByteBuffer { - - static DirectReadOnlyByteBuffer copy (DirectByteBuffer other, int markOfOther) { - DirectReadOnlyByteBuffer buf = new DirectReadOnlyByteBuffer(other.byteArray.get_buffer(), other.capacity(), - other.byteArray.get_byteOffset()); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - buf.order(other.order()); - return buf; - } - - DirectReadOnlyByteBuffer (ArrayBuffer backingArray, int capacity, int arrayOffset) { - super(backingArray, capacity, arrayOffset); - } - - public ByteBuffer asReadOnlyBuffer () { - return copy(this, mark); - } - - public ByteBuffer compact () { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return true; - } - - protected byte[] protectedArray () { - throw new ReadOnlyBufferException(); - } - - protected int protectedArrayOffset () { - throw new ReadOnlyBufferException(); - } - - protected boolean protectedHasArray () { - return false; - } - - public FloatBuffer asFloatBuffer () { - return DirectReadOnlyFloatBufferAdapter.wrap(this); - } - - public IntBuffer asIntBuffer () { - return order() == ByteOrder.nativeOrder() ? DirectReadOnlyIntBufferAdapter.wrap(this) : super.asIntBuffer(); - } - - public ShortBuffer asShortBuffer () { - return order() == ByteOrder.nativeOrder() ? DirectReadOnlyShortBufferAdapter.wrap(this) : super.asShortBuffer(); - } - - public ByteBuffer put (byte b) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer put (int index, byte b) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer put (byte[] src, int off, int len) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putDouble (double value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putDouble (int index, double value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putFloat (float value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putFloat (int index, float value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putInt (int value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putInt (int index, int value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putLong (int index, long value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putLong (long value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putShort (int index, short value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putShort (short value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer put (ByteBuffer buf) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer slice () { - DirectReadOnlyByteBuffer slice = new DirectReadOnlyByteBuffer(byteArray.get_buffer(), remaining(), byteArray.get_byteOffset() - + position); - slice.order = order; - return slice; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/DirectReadOnlyFloatBufferAdapter.java b/backends/gdx-backend-dragome/emu/java/nio/DirectReadOnlyFloatBufferAdapter.java deleted file mode 100644 index 07dd47d6..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/DirectReadOnlyFloatBufferAdapter.java +++ /dev/null @@ -1,145 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBufferView; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Float32Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.utils.TypedArrays; - -/** This class wraps a byte buffer to be a float buffer. - *

- * Implementation notice: - *

    - *
  • After a byte buffer instance is wrapped, it becomes privately owned by the adapter. It must NOT be accessed outside the - * adapter any more.
  • - *
  • The byte buffer's position and limit are NOT linked with the adapter. The adapter extends Buffer, thus has its own position - * and limit.
  • - *
- *

*/ -final class DirectReadOnlyFloatBufferAdapter extends FloatBuffer implements HasArrayBufferView { -// implements DirectBuffer { - - static FloatBuffer wrap (DirectByteBuffer byteBuffer) { - return new DirectReadOnlyFloatBufferAdapter((DirectByteBuffer)byteBuffer.slice()); - } - - private final DirectByteBuffer byteBuffer; - private final Float32Array floatArray; - - DirectReadOnlyFloatBufferAdapter (DirectByteBuffer byteBuffer) { - super((byteBuffer.capacity() >> 2)); - this.byteBuffer = byteBuffer; - this.byteBuffer.clear(); - this.floatArray = TypedArrays.createFloat32Array(byteBuffer.byteArray.get_buffer(), byteBuffer.byteArray.get_byteOffset(), capacity); - } - - @Override - public FloatBuffer asReadOnlyBuffer () { - DirectReadOnlyFloatBufferAdapter buf = new DirectReadOnlyFloatBufferAdapter(byteBuffer); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public FloatBuffer compact () { - throw new ReadOnlyBufferException(); - } - - @Override - public FloatBuffer duplicate () { - DirectReadOnlyFloatBufferAdapter buf = new DirectReadOnlyFloatBufferAdapter((DirectByteBuffer)byteBuffer.duplicate()); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public float get () { -// if (position == limit) { -// throw new BufferUnderflowException(); -// } - return floatArray.get(position++); - } - - @Override - public float get (int index) { -// if (index < 0 || index >= limit) { -// throw new IndexOutOfBoundsException(); -// } - return floatArray.get(index); - } - - @Override - public boolean isDirect () { - return true; - } - - @Override - public boolean isReadOnly () { - return true; - } - - @Override - public ByteOrder order () { - return byteBuffer.order(); - } - - @Override - float[] protectedArray () { - throw new UnsupportedOperationException(); - } - - @Override - int protectedArrayOffset () { - throw new UnsupportedOperationException(); - } - - @Override - boolean protectedHasArray () { - return false; - } - - @Override - public FloatBuffer put (float c) { - throw new ReadOnlyBufferException(); - } - - @Override - public FloatBuffer put (int index, float c) { - throw new ReadOnlyBufferException(); - } - - @Override - public FloatBuffer slice () { - byteBuffer.limit(limit << 2); - byteBuffer.position(position << 2); - FloatBuffer result = new DirectReadOnlyFloatBufferAdapter((DirectByteBuffer)byteBuffer.slice()); - byteBuffer.clear(); - return result; - } - - public ArrayBufferView getTypedArray () { - return floatArray; - } - - public int getElementSize () { - return 4; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/DirectReadOnlyIntBufferAdapter.java b/backends/gdx-backend-dragome/emu/java/nio/DirectReadOnlyIntBufferAdapter.java deleted file mode 100644 index 5a9b8fdf..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/DirectReadOnlyIntBufferAdapter.java +++ /dev/null @@ -1,145 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBufferView; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Int32Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.utils.TypedArrays; - -/** This class wraps a byte buffer to be a int buffer. - *

- * Implementation notice: - *

    - *
  • After a byte buffer instance is wrapped, it becomes privately owned by the adapter. It must NOT be accessed outside the - * adapter any more.
  • - *
  • The byte buffer's position and limit are NOT linked with the adapter. The adapter extends Buffer, thus has its own position - * and limit.
  • - *
- *

*/ -final class DirectReadOnlyIntBufferAdapter extends IntBuffer implements HasArrayBufferView { -// implements DirectBuffer { - - static IntBuffer wrap (DirectByteBuffer byteBuffer) { - return new DirectReadOnlyIntBufferAdapter((DirectByteBuffer)byteBuffer.slice()); - } - - private final DirectByteBuffer byteBuffer; - private final Int32Array intArray; - - DirectReadOnlyIntBufferAdapter (DirectByteBuffer byteBuffer) { - super((byteBuffer.capacity() >> 2)); - this.byteBuffer = byteBuffer; - this.byteBuffer.clear(); - this.intArray = TypedArrays.createInt32Array(byteBuffer.byteArray.get_buffer(), byteBuffer.byteArray.get_byteOffset(), capacity); - } - - @Override - public IntBuffer asReadOnlyBuffer () { - DirectReadOnlyIntBufferAdapter buf = new DirectReadOnlyIntBufferAdapter(byteBuffer); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public IntBuffer compact () { - throw new ReadOnlyBufferException(); - } - - @Override - public IntBuffer duplicate () { - DirectReadOnlyIntBufferAdapter buf = new DirectReadOnlyIntBufferAdapter((DirectByteBuffer)byteBuffer.duplicate()); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public int get () { -// if (position == limit) { -// throw new BufferUnderflowException(); -// } - return intArray.get(position++); - } - - @Override - public int get (int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return intArray.get(index); - } - - @Override - public boolean isDirect () { - return true; - } - - @Override - public boolean isReadOnly () { - return true; - } - - @Override - public ByteOrder order () { - return byteBuffer.order(); - } - - @Override - protected int[] protectedArray () { - throw new UnsupportedOperationException(); - } - - @Override - protected int protectedArrayOffset () { - throw new UnsupportedOperationException(); - } - - @Override - protected boolean protectedHasArray () { - return false; - } - - @Override - public IntBuffer put (int c) { - throw new ReadOnlyBufferException(); - } - - @Override - public IntBuffer put (int index, int c) { - throw new ReadOnlyBufferException(); - } - - @Override - public IntBuffer slice () { - byteBuffer.limit(limit << 2); - byteBuffer.position(position << 2); - IntBuffer result = new DirectReadOnlyIntBufferAdapter((DirectByteBuffer)byteBuffer.slice()); - byteBuffer.clear(); - return result; - } - - public ArrayBufferView getTypedArray () { - return intArray; - } - - public int getElementSize () { - return 4; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/DirectReadOnlyShortBufferAdapter.java b/backends/gdx-backend-dragome/emu/java/nio/DirectReadOnlyShortBufferAdapter.java deleted file mode 100644 index f7aa8f19..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/DirectReadOnlyShortBufferAdapter.java +++ /dev/null @@ -1,144 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBufferView; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Int16Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.utils.TypedArrays; - -/** This class wraps a byte buffer to be a short buffer. - *

- * Implementation notice: - *

    - *
  • After a byte buffer instance is wrapped, it becomes privately owned by the adapter. It must NOT be accessed outside the - * adapter any more.
  • - *
  • The byte buffer's position and limit are NOT linked with the adapter. The adapter extends Buffer, thus has its own position - * and limit.
  • - *
- *

*/ -final class DirectReadOnlyShortBufferAdapter extends ShortBuffer implements HasArrayBufferView { - - static ShortBuffer wrap (DirectByteBuffer byteBuffer) { - return new DirectReadOnlyShortBufferAdapter((DirectByteBuffer)byteBuffer.slice()); - } - - private final DirectByteBuffer byteBuffer; - private final Int16Array shortArray; - - DirectReadOnlyShortBufferAdapter (DirectByteBuffer byteBuffer) { - super((byteBuffer.capacity() >> 1)); - this.byteBuffer = byteBuffer; - this.byteBuffer.clear(); - this.shortArray = TypedArrays.createInt16Array(byteBuffer.byteArray.get_buffer(), byteBuffer.byteArray.get_byteOffset(), capacity); - } - - @Override - public ShortBuffer asReadOnlyBuffer () { - DirectReadOnlyShortBufferAdapter buf = new DirectReadOnlyShortBufferAdapter(byteBuffer); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public ShortBuffer compact () { - throw new ReadOnlyBufferException(); - } - - @Override - public ShortBuffer duplicate () { - DirectReadOnlyShortBufferAdapter buf = new DirectReadOnlyShortBufferAdapter((DirectByteBuffer)byteBuffer.duplicate()); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public short get () { -// if (position == limit) { -// throw new BufferUnderflowException(); -// } - return (short)shortArray.get(position++); - } - - @Override - public short get (int index) { -// if (index < 0 || index >= limit) { -// throw new IndexOutOfBoundsException(); -// } - return (short)shortArray.get(index); - } - - @Override - public boolean isDirect () { - return true; - } - - @Override - public boolean isReadOnly () { - return true; - } - - @Override - public ByteOrder order () { - return byteBuffer.order(); - } - - @Override - protected short[] protectedArray () { - throw new UnsupportedOperationException(); - } - - @Override - protected int protectedArrayOffset () { - throw new UnsupportedOperationException(); - } - - @Override - protected boolean protectedHasArray () { - return false; - } - - @Override - public ShortBuffer put (short c) { - throw new ReadOnlyBufferException(); - } - - @Override - public ShortBuffer put (int index, short c) { - throw new ReadOnlyBufferException(); - } - - @Override - public ShortBuffer slice () { - byteBuffer.limit(limit << 1); - byteBuffer.position(position << 1); - ShortBuffer result = new DirectReadOnlyShortBufferAdapter((DirectByteBuffer)byteBuffer.slice()); - byteBuffer.clear(); - return result; - } - - public ArrayBufferView getTypedArray () { - return shortArray; - } - - public int getElementSize () { - return 2; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/DirectReadWriteByteBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/DirectReadWriteByteBuffer.java deleted file mode 100644 index b20639b6..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/DirectReadWriteByteBuffer.java +++ /dev/null @@ -1,221 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -import java.io.Numbers; - -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBuffer; - -/** DirectByteBuffer, DirectReadWriteByteBuffer and DirectReadOnlyByteBuffer compose the implementation of direct byte buffers. - *

- * DirectReadWriteByteBuffer extends DirectByteBuffer with all the write methods. - *

- *

- * This class is marked final for runtime performance. - *

*/ -public final class DirectReadWriteByteBuffer extends DirectByteBuffer { - - static DirectReadWriteByteBuffer copy (DirectByteBuffer other, int markOfOther) { - DirectReadWriteByteBuffer buf = new DirectReadWriteByteBuffer(other.byteArray.get_buffer(), other.capacity(), - other.byteArray.get_byteOffset()); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - buf.order(other.order()); - return buf; - } - - DirectReadWriteByteBuffer (ArrayBuffer backingArray) { - super(backingArray); - } - - public DirectReadWriteByteBuffer (int capacity) { - super(capacity); - } - - DirectReadWriteByteBuffer (ArrayBuffer backingArray, int capacity, int arrayOffset) { - super(backingArray, capacity, arrayOffset); - } - - public FloatBuffer asFloatBuffer () { - return DirectReadWriteFloatBufferAdapter.wrap(this); - } - - public IntBuffer asIntBuffer () { - return order() == ByteOrder.nativeOrder() ? DirectReadWriteIntBufferAdapter.wrap(this) : super.asIntBuffer(); - } - - public ShortBuffer asShortBuffer () { - return order() == ByteOrder.nativeOrder() ? DirectReadWriteShortBufferAdapter.wrap(this) : super.asShortBuffer(); - } - - public ByteBuffer asReadOnlyBuffer () { - return DirectReadOnlyByteBuffer.copy(this, mark); - } - - public ByteBuffer compact () { -// System.arraycopy(backingArray, position + offset, backingArray, offset, -// remaining()); - - int rem = remaining(); - for (int i = 0; i < rem; i++) { - byteArray.set(i, byteArray.get(position + i)); - } - - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - public ByteBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return false; - } - - protected byte[] protectedArray () { - throw new UnsupportedOperationException(); - } - - protected int protectedArrayOffset () { - throw new UnsupportedOperationException(); - } - - protected boolean protectedHasArray () { - return true; - } - - public ByteBuffer put (byte b) { -// if (position == limit) { -// throw new BufferOverflowException(); -// } - byteArray.set(position++, b); - return this; - } - - public ByteBuffer put (int index, byte b) { -// if (index < 0 || index >= limit) { -// throw new IndexOutOfBoundsException(); -// } - byteArray.set(index, b); - return this; - } - - /* - * Override ByteBuffer.put(byte[], int, int) to improve performance. - * - * (non-Javadoc) - * - * @see java.nio.ByteBuffer#put(byte[], int, int) - */ - public ByteBuffer put (byte[] src, int off, int len) { - if (off < 0 || len < 0 || (long)off + (long)len > src.length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferOverflowException(); - } - if (isReadOnly()) { - throw new ReadOnlyBufferException(); - } - for (int i = 0; i < len; i++) { - byteArray.set(i + position, src[off + i]); - } - position += len; - return this; - } - - public ByteBuffer putDouble (double value) { - return putLong(Numbers.doubleToRawLongBits(value)); - } - - public ByteBuffer putDouble (int index, double value) { - return putLong(index, Numbers.doubleToRawLongBits(value)); - } - - public ByteBuffer putFloat (float value) { - return putInt(Numbers.floatToIntBits(value)); - } - - public ByteBuffer putFloat (int index, float value) { - return putInt(index, Numbers.floatToIntBits(value)); - } - - public ByteBuffer putInt (int value) { - int newPosition = position + 4; -// if (newPosition > limit) { -// throw new BufferOverflowException(); -// } - store(position, value); - position = newPosition; - return this; - } - - public ByteBuffer putInt (int index, int value) { -// if (index < 0 || (long)index + 4 > limit) { -// throw new IndexOutOfBoundsException(); -// } - store(index, value); - return this; - } - - public ByteBuffer putLong (int index, long value) { -// if (index < 0 || (long)index + 8 > limit) { -// throw new IndexOutOfBoundsException(); -// } - store(index, value); - return this; - } - - public ByteBuffer putLong (long value) { - int newPosition = position + 8; -// if (newPosition > limit) { -// throw new BufferOverflowException(); -// } - store(position, value); - position = newPosition; - return this; - } - - public ByteBuffer putShort (int index, short value) { -// if (index < 0 || (long)index + 2 > limit) { -// throw new IndexOutOfBoundsException(); -// } - store(index, value); - return this; - } - - public ByteBuffer putShort (short value) { - int newPosition = position + 2; -// if (newPosition > limit) { -// throw new BufferOverflowException(); -// } - store(position, value); - position = newPosition; - return this; - } - - public ByteBuffer slice () { - DirectReadWriteByteBuffer slice = new DirectReadWriteByteBuffer(byteArray.get_buffer(), remaining(), - byteArray.get_byteOffset() + position); - slice.order = order; - return slice; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/DirectReadWriteFloatBufferAdapter.java b/backends/gdx-backend-dragome/emu/java/nio/DirectReadWriteFloatBufferAdapter.java deleted file mode 100644 index 1bed4d61..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/DirectReadWriteFloatBufferAdapter.java +++ /dev/null @@ -1,162 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBufferView; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Float32Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.utils.TypedArrays; - -/** This class wraps a byte buffer to be a float buffer. - *

- * Implementation notice: - *

    - *
  • After a byte buffer instance is wrapped, it becomes privately owned by the adapter. It must NOT be accessed outside the - * adapter any more.
  • - *
  • The byte buffer's position and limit are NOT linked with the adapter. The adapter extends Buffer, thus has its own position - * and limit.
  • - *
- *

*/ -final class DirectReadWriteFloatBufferAdapter extends FloatBuffer implements HasArrayBufferView { -// implements DirectBuffer { - - static FloatBuffer wrap (DirectReadWriteByteBuffer byteBuffer) { - return new DirectReadWriteFloatBufferAdapter((DirectReadWriteByteBuffer)byteBuffer.slice()); - } - - private final DirectReadWriteByteBuffer byteBuffer; - private final Float32Array floatArray; - - DirectReadWriteFloatBufferAdapter (DirectReadWriteByteBuffer byteBuffer) { - super((byteBuffer.capacity() >> 2)); - this.byteBuffer = byteBuffer; - this.byteBuffer.clear(); - this.floatArray = TypedArrays.createFloat32Array(byteBuffer.byteArray.get_buffer(), byteBuffer.byteArray.get_byteOffset(), capacity); - } - - // TODO(haustein) This will be slow - @Override - public FloatBuffer asReadOnlyBuffer () { - DirectReadOnlyFloatBufferAdapter buf = new DirectReadOnlyFloatBufferAdapter(byteBuffer); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public FloatBuffer compact () { - byteBuffer.limit(limit << 2); - byteBuffer.position(position << 2); - byteBuffer.compact(); - byteBuffer.clear(); - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - @Override - public FloatBuffer duplicate () { - DirectReadWriteFloatBufferAdapter buf = new DirectReadWriteFloatBufferAdapter( - (DirectReadWriteByteBuffer)byteBuffer.duplicate()); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public float get () { -// if (position == limit) { -// throw new BufferUnderflowException(); -// } - return floatArray.get(position++); - } - - @Override - public float get (int index) { -// if (index < 0 || index >= limit) { -// throw new IndexOutOfBoundsException(); -// } - return floatArray.get(index); - } - - @Override - public boolean isDirect () { - return true; - } - - @Override - public boolean isReadOnly () { - return false; - } - - @Override - public ByteOrder order () { - return byteBuffer.order(); - } - - @Override - protected float[] protectedArray () { - throw new UnsupportedOperationException(); - } - - @Override - protected int protectedArrayOffset () { - throw new UnsupportedOperationException(); - } - - @Override - protected boolean protectedHasArray () { - return false; - } - - @Override - public FloatBuffer put (float c) { -// if (position == limit) { -// throw new BufferOverflowException(); -// } - floatArray.set(position++, c); - return this; - } - - @Override - public FloatBuffer put (int index, float c) { -// if (index < 0 || index >= limit) { -// throw new IndexOutOfBoundsException(); -// } - floatArray.set(index, c); - return this; - } - - @Override - public FloatBuffer slice () { - byteBuffer.limit(limit << 2); - byteBuffer.position(position << 2); - FloatBuffer result = new DirectReadWriteFloatBufferAdapter((DirectReadWriteByteBuffer)byteBuffer.slice()); - byteBuffer.clear(); - return result; - } - - public ArrayBufferView getTypedArray () { - return floatArray; - } - - public int getElementSize () { - return 4; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/DirectReadWriteIntBufferAdapter.java b/backends/gdx-backend-dragome/emu/java/nio/DirectReadWriteIntBufferAdapter.java deleted file mode 100644 index 53c41b78..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/DirectReadWriteIntBufferAdapter.java +++ /dev/null @@ -1,160 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBufferView; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Int32Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.utils.TypedArrays; - -/** This class wraps a byte buffer to be a int buffer. - *

- * Implementation notice: - *

    - *
  • After a byte buffer instance is wrapped, it becomes privately owned by the adapter. It must NOT be accessed outside the - * adapter any more.
  • - *
  • The byte buffer's position and limit are NOT linked with the adapter. The adapter extends Buffer, thus has its own position - * and limit.
  • - *
- *

*/ -final class DirectReadWriteIntBufferAdapter extends IntBuffer implements HasArrayBufferView { - - static IntBuffer wrap (DirectReadWriteByteBuffer byteBuffer) { - return new DirectReadWriteIntBufferAdapter((DirectReadWriteByteBuffer)byteBuffer.slice()); - } - - private final DirectReadWriteByteBuffer byteBuffer; - private final Int32Array intArray; - - DirectReadWriteIntBufferAdapter (DirectReadWriteByteBuffer byteBuffer) { - super((byteBuffer.capacity() >> 2)); - this.byteBuffer = byteBuffer; - this.byteBuffer.clear(); - this.intArray = TypedArrays.createInt32Array(byteBuffer.byteArray.get_buffer(), byteBuffer.byteArray.get_byteOffset(), capacity); - } - - // TODO(haustein) This will be slow - @Override - public IntBuffer asReadOnlyBuffer () { - DirectReadOnlyIntBufferAdapter buf = new DirectReadOnlyIntBufferAdapter(byteBuffer); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public IntBuffer compact () { - byteBuffer.limit(limit << 2); - byteBuffer.position(position << 2); - byteBuffer.compact(); - byteBuffer.clear(); - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - @Override - public IntBuffer duplicate () { - DirectReadWriteIntBufferAdapter buf = new DirectReadWriteIntBufferAdapter((DirectReadWriteByteBuffer)byteBuffer.duplicate()); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public int get () { -// if (position == limit) { -// throw new BufferUnderflowException(); -// } - return intArray.get(position++); - } - - @Override - public int get (int index) { -// if (index < 0 || index >= limit) { -// throw new IndexOutOfBoundsException(); -// } - return intArray.get(index); - } - - @Override - public boolean isDirect () { - return true; - } - - @Override - public boolean isReadOnly () { - return false; - } - - @Override - public ByteOrder order () { - return byteBuffer.order(); - } - - @Override - protected int[] protectedArray () { - throw new UnsupportedOperationException(); - } - - @Override - protected int protectedArrayOffset () { - throw new UnsupportedOperationException(); - } - - @Override - protected boolean protectedHasArray () { - return false; - } - - @Override - public IntBuffer put (int c) { -// if (position == limit) { -// throw new BufferOverflowException(); -// } - intArray.set(position++, c); - return this; - } - - @Override - public IntBuffer put (int index, int c) { -// if (index < 0 || index >= limit) { -// throw new IndexOutOfBoundsException(); -// } - intArray.set(index, c); - return this; - } - - @Override - public IntBuffer slice () { - byteBuffer.limit(limit << 2); - byteBuffer.position(position << 2); - IntBuffer result = new DirectReadWriteIntBufferAdapter((DirectReadWriteByteBuffer)byteBuffer.slice()); - byteBuffer.clear(); - return result; - } - - public ArrayBufferView getTypedArray () { - return intArray; - } - - public int getElementSize () { - return 4; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/DirectReadWriteShortBufferAdapter.java b/backends/gdx-backend-dragome/emu/java/nio/DirectReadWriteShortBufferAdapter.java deleted file mode 100644 index e615baab..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/DirectReadWriteShortBufferAdapter.java +++ /dev/null @@ -1,163 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBufferView; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Int16Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.utils.TypedArrays; - -/** This class wraps a byte buffer to be a short buffer. - *

- * Implementation notice: - *

    - *
  • After a byte buffer instance is wrapped, it becomes privately owned by the adapter. It must NOT be accessed outside the - * adapter any more.
  • - *
  • The byte buffer's position and limit are NOT linked with the adapter. The adapter extends Buffer, thus has its own position - * and limit.
  • - *
- *

*/ -final class DirectReadWriteShortBufferAdapter extends ShortBuffer implements HasArrayBufferView { -// implements DirectBuffer { - - static ShortBuffer wrap (DirectReadWriteByteBuffer byteBuffer) { - return new DirectReadWriteShortBufferAdapter((DirectReadWriteByteBuffer)byteBuffer.slice()); - } - - private final DirectReadWriteByteBuffer byteBuffer; - private final Int16Array shortArray; - - DirectReadWriteShortBufferAdapter (DirectReadWriteByteBuffer byteBuffer) { - super((byteBuffer.capacity() >> 1)); - this.byteBuffer = byteBuffer; - this.byteBuffer.clear(); - this.shortArray = TypedArrays.createInt16Array(byteBuffer.byteArray.get_buffer(), byteBuffer.byteArray.get_byteOffset(), capacity); - } - - // TODO(haustein) This will be slow - @Override - public ShortBuffer asReadOnlyBuffer () { - DirectReadOnlyShortBufferAdapter buf = new DirectReadOnlyShortBufferAdapter(byteBuffer); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public ShortBuffer compact () { - byteBuffer.limit(limit << 1); - byteBuffer.position(position << 1); - byteBuffer.compact(); - byteBuffer.clear(); - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - @Override - public ShortBuffer duplicate () { - DirectReadWriteShortBufferAdapter buf = new DirectReadWriteShortBufferAdapter( - (DirectReadWriteByteBuffer)byteBuffer.duplicate()); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public short get () { -// if (position == limit) { -// throw new BufferUnderflowException(); -// } - return (short)shortArray.get(position++); - } - - @Override - public short get (int index) { -// if (index < 0 || index >= limit) { -// throw new IndexOutOfBoundsException(); -// } - return (short)shortArray.get(index); - } - - @Override - public boolean isDirect () { - return true; - } - - @Override - public boolean isReadOnly () { - return false; - } - - @Override - public ByteOrder order () { - return byteBuffer.order(); - } - - @Override - protected short[] protectedArray () { - throw new UnsupportedOperationException(); - } - - @Override - protected int protectedArrayOffset () { - throw new UnsupportedOperationException(); - } - - @Override - protected boolean protectedHasArray () { - return false; - } - - @Override - public ShortBuffer put (short c) { -// if (position == limit) { -// throw new BufferOverflowException(); -// } - shortArray.set(position++, c); - return this; - } - - @Override - public ShortBuffer put (int index, short c) { -// if (index < 0 || index >= limit) { -// throw new IndexOutOfBoundsException(); -// } - shortArray.set(index, c); - return this; - } - - @Override - public ShortBuffer slice () { - byteBuffer.limit(limit << 1); - byteBuffer.position(position << 1); - ShortBuffer result = new DirectReadWriteShortBufferAdapter((DirectReadWriteByteBuffer)byteBuffer.slice()); - byteBuffer.clear(); - return result; - } - - public ArrayBufferView getTypedArray () { - return shortArray; - } - - public int getElementSize () { - return 2; - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/DoubleArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/DoubleArrayBuffer.java deleted file mode 100644 index f7270be8..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/DoubleArrayBuffer.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** DoubleArrayBuffer, ReadWriteDoubleArrayBuffer and ReadOnlyDoubleArrayBuffer compose the implementation of array based double - * buffers. - *

- * DoubleArrayBuffer implements all the shared readonly methods and is extended by the other two classes. - *

- *

- * All methods are marked final for runtime performance. - *

*/ -abstract class DoubleArrayBuffer extends DoubleBuffer { - - protected final double[] backingArray; - - protected final int offset; - - DoubleArrayBuffer (double[] array) { - this(array.length, array, 0); - } - - DoubleArrayBuffer (int capacity) { - this(capacity, new double[capacity], 0); - } - - DoubleArrayBuffer (int capacity, double[] backingArray, int offset) { - super(capacity); - this.backingArray = backingArray; - this.offset = offset; - } - - public final double get () { - if (position == limit) { - throw new BufferUnderflowException(); - } - return backingArray[offset + position++]; - } - - public final double get (int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return backingArray[offset + index]; - } - - public final DoubleBuffer get (double[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferUnderflowException(); - } - System.arraycopy(backingArray, offset + position, dest, off, len); - position += len; - return this; - } - - public final boolean isDirect () { - return false; - } - - public final ByteOrder order () { - return ByteOrder.nativeOrder(); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/DoubleBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/DoubleBuffer.java deleted file mode 100644 index c88d69c6..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/DoubleBuffer.java +++ /dev/null @@ -1,435 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** A buffer of doubles. - *

- * A double buffer can be created in either one of the following ways: - *

- *
    - *
  • {@link #allocate(int) Allocate} a new double array and create a buffer based on it;
  • - *
  • {@link #wrap(double[]) Wrap} an existing double array to create a new buffer;
  • - *
  • Use {@link java.nio.ByteBuffer#asDoubleBuffer() ByteBuffer.asDoubleBuffer} to create a double buffer based on a byte buffer. - *
  • - *
- * - * @since Android 1.0 */ -public abstract class DoubleBuffer extends Buffer implements Comparable { - - /** Creates a double buffer based on a newly allocated double array. - * - * @param capacity the capacity of the new buffer. - * @return the created double buffer. - * @throws IllegalArgumentException if {@code capacity} is less than zero. - * @since Android 1.0 */ - public static DoubleBuffer allocate (int capacity) { - if (capacity < 0) { - throw new IllegalArgumentException(); - } - return BufferFactory.newDoubleBuffer(capacity); - } - - /** Creates a new double buffer by wrapping the given double array. - *

- * Calling this method has the same effect as {@code wrap(array, 0, array.length)}. - *

- * - * @param array the double array which the new buffer will be based on. - * @return the created double buffer. - * @since Android 1.0 */ - public static DoubleBuffer wrap (double[] array) { - return wrap(array, 0, array.length); - } - - /** Creates a new double buffer by wrapping the given double array. - *

- * The new buffer's position will be {@code start}, limit will be {@code start + len}, capacity will be the length of the array. - *

- * - * @param array the double array which the new buffer will be based on. - * @param start the start index, must not be negative and not greater than {@code array.length}. - * @param len the length, must not be negative and not greater than {@code array.length - start}. - * @return the created double buffer. - * @exception IndexOutOfBoundsException if either {@code start} or {@code len} is invalid. - * @since Android 1.0 */ - public static DoubleBuffer wrap (double[] array, int start, int len) { - int length = array.length; - if (start < 0 || len < 0 || (long)start + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - - DoubleBuffer buf = BufferFactory.newDoubleBuffer(array); - buf.position = start; - buf.limit = start + len; - - return buf; - } - - /** Constructs a {@code DoubleBuffer} with given capacity. - * - * @param capacity the capacity of the buffer. */ - DoubleBuffer (int capacity) { - super(capacity); - } - - /** Returns the double array which this buffer is based on, if there is one. - * - * @return the double array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final double[] array () { - return protectedArray(); - } - - /** Returns the offset of the double array which this buffer is based on, if there is one. - *

- * The offset is the index of the array corresponding to the zero position of the buffer. - *

- * - * @return the offset of the double array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final int arrayOffset () { - return protectedArrayOffset(); - } - - /** Returns a read-only buffer that shares its content with this buffer. - *

- * The returned buffer is guaranteed to be a new instance, even if this buffer is read-only itself. The new buffer's position, - * limit, capacity and mark are the same as this buffer's. - *

- *

- * The new buffer shares its content with this buffer, which means that this buffer's change of content will be visible to the - * new buffer. The two buffer's position, limit and mark are independent. - *

- * - * @return a read-only version of this buffer. - * @since Android 1.0 */ - public abstract DoubleBuffer asReadOnlyBuffer (); - - /** Compacts this double buffer. - *

- * The remaining doubles will be moved to the head of the buffer, staring from position zero. Then the position is set to - * {@code remaining()}; the limit is set to capacity; the mark is cleared. - *

- * - * @return this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract DoubleBuffer compact (); - - /** Compare the remaining doubles of this buffer to another double buffer's remaining doubles. - * - * @param otherBuffer another double buffer. - * @return a negative value if this is less than {@code other}; 0 if this equals to {@code other}; a positive value if this is - * greater than {@code other}. - * @exception ClassCastException if {@code other} is not a double buffer. - * @since Android 1.0 */ - public int compareTo (DoubleBuffer otherBuffer) { - int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining() : otherBuffer.remaining(); - int thisPos = position; - int otherPos = otherBuffer.position; - // BEGIN android-changed - double thisDouble, otherDouble; - while (compareRemaining > 0) { - thisDouble = get(thisPos); - otherDouble = otherBuffer.get(otherPos); - // checks for double and NaN inequality - if ((thisDouble != otherDouble) && ((thisDouble == thisDouble) || (otherDouble == otherDouble))) { - return thisDouble < otherDouble ? -1 : 1; - } - thisPos++; - otherPos++; - compareRemaining--; - } - // END android-changed - return remaining() - otherBuffer.remaining(); - } - - /** Returns a duplicated buffer that shares its content with this buffer. - *

- * The duplicated buffer's position, limit, capacity and mark are the same as this buffer's. The duplicated buffer's read-only - * property and byte order are the same as this buffer's, too. - *

- *

- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *

- * - * @return a duplicated buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract DoubleBuffer duplicate (); - - /** Checks whether this double buffer is equal to another object. - *

- * If {@code other} is not a double buffer then {@code false} is returned. Two double buffers are equal if and only if their - * remaining doubles are exactly the same. Position, limit, capacity and mark are not considered. - *

- * - * @param other the object to compare with this double buffer. - * @return {@code true} if this double buffer is equal to {@code other}, {@code false} otherwise. - * @since Android 1.0 */ - public boolean equals (Object other) { - if (!(other instanceof DoubleBuffer)) { - return false; - } - DoubleBuffer otherBuffer = (DoubleBuffer)other; - - if (remaining() != otherBuffer.remaining()) { - return false; - } - - int myPosition = position; - int otherPosition = otherBuffer.position; - boolean equalSoFar = true; - while (equalSoFar && (myPosition < limit)) { - equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++); - } - - return equalSoFar; - } - - /** Returns the double at the current position and increases the position by 1. - * - * @return the double at the current position. - * @exception BufferUnderflowException if the position is equal or greater than limit. - * @since Android 1.0 */ - public abstract double get (); - - /** Reads doubles from the current position into the specified double array and increases the position by the number of doubles - * read. - *

- * Calling this method has the same effect as {@code get(dest, 0, dest.length)}. - *

- * - * @param dest the destination double array. - * @return this buffer. - * @exception BufferUnderflowException if {@code dest.length} is greater than {@code remaining()}. - * @since Android 1.0 */ - public DoubleBuffer get (double[] dest) { - return get(dest, 0, dest.length); - } - - /** Reads doubles from the current position into the specified double array, starting from the specified offset, and increases - * the position by the number of doubles read. - * - * @param dest the target double array. - * @param off the offset of the double array, must not be negative and not greater than {@code dest.length}. - * @param len the number of doubles to read, must be no less than zero and not greater than {@code dest.length - off}. - * @return this buffer. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception BufferUnderflowException if {@code len} is greater than {@code remaining()}. - * @since Android 1.0 */ - public DoubleBuffer get (double[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferUnderflowException(); - } - for (int i = off; i < off + len; i++) { - dest[i] = get(); - } - return this; - } - - /** Returns a double at the specified index; the position is not changed. - * - * @param index the index, must not be negative and less than limit. - * @return a double at the specified index. - * @exception IndexOutOfBoundsException if index is invalid. - * @since Android 1.0 */ - public abstract double get (int index); - - /** Indicates whether this buffer is based on a double array and is read/write. - * - * @return {@code true} if this buffer is based on a double array and provides read/write access, {@code false} otherwise. - * @since Android 1.0 */ - public final boolean hasArray () { - return protectedHasArray(); - } - -// /** -// * Calculates this buffer's hash code from the remaining chars. The -// * position, limit, capacity and mark don't affect the hash code. -// * -// * @return the hash code calculated from the remaining chars. -// * @since Android 1.0 -// */ -// public int hashCode() { -// int myPosition = position; -// int hash = 0; -// long l; -// while (myPosition < limit) { -// l = Double.doubleToLongBits(get(myPosition++)); -// hash = hash + ((int) l) ^ ((int) (l >> 32)); -// } -// return hash; -// } - - /** Indicates whether this buffer is direct. A direct buffer will try its best to take advantage of native memory APIs and it - * may not stay in the Java heap, so it is not affected by garbage collection. - *

- * A double buffer is direct if it is based on a byte buffer and the byte buffer is direct. - *

- * - * @return {@code true} if this buffer is direct, {@code false} otherwise. - * @since Android 1.0 */ - public abstract boolean isDirect (); - - /** Returns the byte order used by this buffer when converting doubles from/to bytes. - *

- * If this buffer is not based on a byte buffer, then this always returns the platform's native byte order. - *

- * - * @return the byte order used by this buffer when converting doubles from/to bytes. - * @since Android 1.0 */ - public abstract ByteOrder order (); - - /** Child class implements this method to realize {@code array()}. - * - * @see #array() */ - abstract double[] protectedArray (); - - /** Child class implements this method to realize {@code arrayOffset()}. - * - * @see #arrayOffset() */ - abstract int protectedArrayOffset (); - - /** Child class implements this method to realize {@code hasArray()}. - * - * @see #hasArray() */ - abstract boolean protectedHasArray (); - - /** Writes the given double to the current position and increases the position by 1. - * - * @param d the double to write. - * @return this buffer. - * @exception BufferOverflowException if position is equal or greater than limit. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract DoubleBuffer put (double d); - - /** Writes doubles from the given double array to the current position and increases the position by the number of doubles - * written. - *

- * Calling this method has the same effect as {@code put(src, 0, src.length)}. - *

- * - * @param src the source double array. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code src.length}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public final DoubleBuffer put (double[] src) { - return put(src, 0, src.length); - } - - /** Writes doubles from the given double array, starting from the specified offset, to the current position and increases the - * position by the number of doubles written. - * - * @param src the source double array. - * @param off the offset of double array, must not be negative and not greater than {@code src.length}. - * @param len the number of doubles to write, must be no less than zero and not greater than {@code src.length - off}. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code len}. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public DoubleBuffer put (double[] src, int off, int len) { - int length = src.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferOverflowException(); - } - for (int i = off; i < off + len; i++) { - put(src[i]); - } - return this; - } - - /** Writes all the remaining doubles of the {@code src} double buffer to this buffer's current position, and increases both - * buffers' position by the number of doubles copied. - * - * @param src the source double buffer. - * @return this buffer. - * @exception BufferOverflowException if {@code src.remaining()} is greater than this buffer's {@code remaining()}. - * @exception IllegalArgumentException if {@code src} is this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public DoubleBuffer put (DoubleBuffer src) { - if (src == this) { - throw new IllegalArgumentException(); - } - if (src.remaining() > remaining()) { - throw new BufferOverflowException(); - } - double[] doubles = new double[src.remaining()]; - src.get(doubles); - put(doubles); - return this; - } - - /** Write a double to the specified index of this buffer and the position is not changed. - * - * @param index the index, must not be negative and less than the limit. - * @param d the double to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if index is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract DoubleBuffer put (int index, double d); - - /** Returns a sliced buffer that shares its content with this buffer. - *

- * The sliced buffer's capacity will be this buffer's {@code remaining()}, and its zero position will correspond to this - * buffer's current position. The new buffer's position will be 0, limit will be its capacity, and its mark is cleared. The new - * buffer's read-only property and byte order are the same as this buffer's. - *

- *

- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *

- * - * @return a sliced buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract DoubleBuffer slice (); - - /** Returns a string representing the state of this double buffer. - * - * @return A string representing the state of this double buffer. - * @since Android 1.0 */ - public String toString () { - StringBuffer buf = new StringBuffer(); - buf.append(getClass().getName()); - buf.append(", status: capacity="); //$NON-NLS-1$ - buf.append(capacity()); - buf.append(" position="); //$NON-NLS-1$ - buf.append(position()); - buf.append(" limit="); //$NON-NLS-1$ - buf.append(limit()); - return buf.toString(); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/DoubleToByteBufferAdapter.java b/backends/gdx-backend-dragome/emu/java/nio/DoubleToByteBufferAdapter.java deleted file mode 100644 index 10c9ad9d..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/DoubleToByteBufferAdapter.java +++ /dev/null @@ -1,201 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -//import org.apache.harmony.nio.internal.DirectBuffer; -//import org.apache.harmony.luni.platform.PlatformAddress; - -/** This class wraps a byte buffer to be a double buffer. - *

- * Implementation notice: - *

    - *
  • After a byte buffer instance is wrapped, it becomes privately owned by the adapter. It must NOT be accessed outside the - * adapter any more.
  • - *
  • The byte buffer's position and limit are NOT linked with the adapter. The adapter extends Buffer, thus has its own position - * and limit.
  • - *
- *

*/ -final class DoubleToByteBufferAdapter extends DoubleBuffer { - // implements DirectBuffer { - - static DoubleBuffer wrap (ByteBuffer byteBuffer) { - return new DoubleToByteBufferAdapter(byteBuffer.slice()); - } - - private final ByteBuffer byteBuffer; - - DoubleToByteBufferAdapter (ByteBuffer byteBuffer) { - super((byteBuffer.capacity() >> 3)); - this.byteBuffer = byteBuffer; - this.byteBuffer.clear(); - } - -// public int getByteCapacity() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).getByteCapacity(); -// } -// assert false : byteBuffer; -// return -1; -// } -// -// public PlatformAddress getEffectiveAddress() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).getEffectiveAddress(); -// } -// assert false : byteBuffer; -// return null; -// } -// -// public PlatformAddress getBaseAddress() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).getBaseAddress(); -// } -// assert false : byteBuffer; -// return null; -// } -// -// public boolean isAddressValid() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).isAddressValid(); -// } -// assert false : byteBuffer; -// return false; -// } -// -// public void addressValidityCheck() { -// if (byteBuffer instanceof DirectBuffer) { -// ((DirectBuffer) byteBuffer).addressValidityCheck(); -// } else { -// assert false : byteBuffer; -// } -// } -// -// public void free() { -// if (byteBuffer instanceof DirectBuffer) { -// ((DirectBuffer) byteBuffer).free(); -// } else { -// assert false : byteBuffer; -// } -// } - - @Override - public DoubleBuffer asReadOnlyBuffer () { - DoubleToByteBufferAdapter buf = new DoubleToByteBufferAdapter(byteBuffer.asReadOnlyBuffer()); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public DoubleBuffer compact () { - if (byteBuffer.isReadOnly()) { - throw new ReadOnlyBufferException(); - } - byteBuffer.limit(limit << 3); - byteBuffer.position(position << 3); - byteBuffer.compact(); - byteBuffer.clear(); - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - @Override - public DoubleBuffer duplicate () { - DoubleToByteBufferAdapter buf = new DoubleToByteBufferAdapter(byteBuffer.duplicate()); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public double get () { - if (position == limit) { - throw new BufferUnderflowException(); - } - return byteBuffer.getDouble(position++ << 3); - } - - @Override - public double get (int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return byteBuffer.getDouble(index << 3); - } - - @Override - public boolean isDirect () { - return byteBuffer.isDirect(); - } - - @Override - public boolean isReadOnly () { - return byteBuffer.isReadOnly(); - } - - @Override - public ByteOrder order () { - return byteBuffer.order(); - } - - @Override - protected double[] protectedArray () { - throw new UnsupportedOperationException(); - } - - @Override - protected int protectedArrayOffset () { - throw new UnsupportedOperationException(); - } - - @Override - protected boolean protectedHasArray () { - return false; - } - - @Override - public DoubleBuffer put (double c) { - if (position == limit) { - throw new BufferOverflowException(); - } - byteBuffer.putDouble(position++ << 3, c); - return this; - } - - @Override - public DoubleBuffer put (int index, double c) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - byteBuffer.putDouble(index << 3, c); - return this; - } - - @Override - public DoubleBuffer slice () { - byteBuffer.limit(limit << 3); - byteBuffer.position(position << 3); - DoubleBuffer result = new DoubleToByteBufferAdapter(byteBuffer.slice()); - byteBuffer.clear(); - return result; - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/FloatArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/FloatArrayBuffer.java deleted file mode 100644 index 4c6eca80..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/FloatArrayBuffer.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** FloatArrayBuffer, ReadWriteFloatArrayBuffer and ReadOnlyFloatArrayBuffer compose the implementation of array based float - * buffers. - *

- * FloatArrayBuffer implements all the shared readonly methods and is extended by the other two classes. - *

- *

- * All methods are marked final for runtime performance. - *

*/ -abstract class FloatArrayBuffer extends FloatBuffer { - - protected final float[] backingArray; - - protected final int offset; - - FloatArrayBuffer (float[] array) { - this(array.length, array, 0); - } - - FloatArrayBuffer (int capacity) { - this(capacity, new float[capacity], 0); - } - - FloatArrayBuffer (int capacity, float[] backingArray, int offset) { - super(capacity); - this.backingArray = backingArray; - this.offset = offset; - } - - public final float get () { - if (position == limit) { - throw new BufferUnderflowException(); - } - return backingArray[offset + position++]; - } - - public final float get (int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return backingArray[offset + index]; - } - - public final FloatBuffer get (float[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferUnderflowException(); - } - System.arraycopy(backingArray, offset + position, dest, off, len); - position += len; - return this; - } - - public final boolean isDirect () { - return false; - } - - public final ByteOrder order () { - return ByteOrder.nativeOrder(); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/FloatBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/FloatBuffer.java deleted file mode 100644 index 9f34720e..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/FloatBuffer.java +++ /dev/null @@ -1,434 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** A buffer of floats. - *

- * A float buffer can be created in either of the following ways: - *

- *
    - *
  • {@link #allocate(int) Allocate} a new float array and create a buffer based on it;
  • - *
  • {@link #wrap(float[]) Wrap} an existing float array to create a new buffer;
  • - *
  • Use {@link java.nio.ByteBuffer#asFloatBuffer() ByteBuffer.asFloatBuffer} to create a float buffer based on a byte buffer.
  • - *
- * - * @since Android 1.0 */ -public abstract class FloatBuffer extends Buffer implements Comparable { - - /** Creates a float buffer based on a newly allocated float array. - * - * @param capacity the capacity of the new buffer. - * @return the created float buffer. - * @throws IllegalArgumentException if {@code capacity} is less than zero. - * @since Android 1.0 */ - public static FloatBuffer allocate (int capacity) { - if (capacity < 0) { - throw new IllegalArgumentException(); - } - return BufferFactory.newFloatBuffer(capacity); - } - - /** Creates a new float buffer by wrapping the given float array. - *

- * Calling this method has the same effect as {@code wrap(array, 0, array.length)}. - *

- * - * @param array the float array which the new buffer will be based on. - * @return the created float buffer. - * @since Android 1.0 */ - public static FloatBuffer wrap (float[] array) { - return wrap(array, 0, array.length); - } - - /** Creates a new float buffer by wrapping the given float array. - *

- * The new buffer's position will be {@code start}, limit will be {@code start + len}, capacity will be the length of the array. - *

- * - * @param array the float array which the new buffer will be based on. - * @param start the start index, must not be negative and not greater than {@code array.length}. - * @param len the length, must not be negative and not greater than {@code array.length - start}. - * @return the created float buffer. - * @exception IndexOutOfBoundsException if either {@code start} or {@code len} is invalid. - * @exception NullPointerException if {@code array} is null. - * @since Android 1.0 */ - public static FloatBuffer wrap (float[] array, int start, int len) { - if (array == null) { - throw new NullPointerException(); - } - if (start < 0 || len < 0 || (long)start + (long)len > array.length) { - throw new IndexOutOfBoundsException(); - } - - FloatBuffer buf = BufferFactory.newFloatBuffer(array); - buf.position = start; - buf.limit = start + len; - - return buf; - } - - /** Constructs a {@code FloatBuffer} with given capacity. - * - * @param capacity The capacity of the buffer */ - FloatBuffer (int capacity) { - super(capacity); - } - - /** Returns the float array which this buffer is based on, if there is one. - * - * @return the float array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final float[] array () { - return protectedArray(); - } - - /** Returns the offset of the float array which this buffer is based on, if there is one. - *

- * The offset is the index of the array and corresponds to the zero position of the buffer. - *

- * - * @return the offset of the float array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final int arrayOffset () { - return protectedArrayOffset(); - } - - /** Returns a read-only buffer that shares its content with this buffer. - *

- * The returned buffer is guaranteed to be a new instance, even if this buffer is read-only itself. The new buffer's position, - * limit, capacity and mark are the same as this buffer. - *

- *

- * The new buffer shares its content with this buffer, which means this buffer's change of content will be visible to the new - * buffer. The two buffer's position, limit and mark are independent. - *

- * - * @return a read-only version of this buffer. - * @since Android 1.0 */ - public abstract FloatBuffer asReadOnlyBuffer (); - - /** Compacts this float buffer. - *

- * The remaining floats will be moved to the head of the buffer, starting from position zero. Then the position is set to - * {@code remaining()}; the limit is set to capacity; the mark is cleared. - *

- * - * @return this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract FloatBuffer compact (); - - /** Compare the remaining floats of this buffer to another float buffer's remaining floats. - * - * @param otherBuffer another float buffer. - * @return a negative value if this is less than {@code otherBuffer}; 0 if this equals to {@code otherBuffer}; a positive value - * if this is greater than {@code otherBuffer}. - * @exception ClassCastException if {@code otherBuffer} is not a float buffer. - * @since Android 1.0 */ - public int compareTo (FloatBuffer otherBuffer) { - int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining() : otherBuffer.remaining(); - int thisPos = position; - int otherPos = otherBuffer.position; - // BEGIN android-changed - float thisFloat, otherFloat; - while (compareRemaining > 0) { - thisFloat = get(thisPos); - otherFloat = otherBuffer.get(otherPos); - // checks for float and NaN inequality - if ((thisFloat != otherFloat) && ((thisFloat == thisFloat) || (otherFloat == otherFloat))) { - return thisFloat < otherFloat ? -1 : 1; - } - thisPos++; - otherPos++; - compareRemaining--; - } - // END android-changed - return remaining() - otherBuffer.remaining(); - } - - /** Returns a duplicated buffer that shares its content with this buffer. - *

- * The duplicated buffer's position, limit, capacity and mark are the same as this buffer. The duplicated buffer's read-only - * property and byte order are same as this buffer too. - *

- *

- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *

- * - * @return a duplicated buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract FloatBuffer duplicate (); - - /** Checks whether this float buffer is equal to another object. - *

- * If {@code other} is not a float buffer then {@code false} is returned. Two float buffers are equal if and only if their - * remaining floats are exactly the same. Position, limit, capacity and mark are not considered. - *

- * - * @param other the object to compare with this float buffer. - * @return {@code true} if this float buffer is equal to {@code other}, {@code false} otherwise. - * @since Android 1.0 */ - public boolean equals (Object other) { - if (!(other instanceof FloatBuffer)) { - return false; - } - FloatBuffer otherBuffer = (FloatBuffer)other; - - if (remaining() != otherBuffer.remaining()) { - return false; - } - - int myPosition = position; - int otherPosition = otherBuffer.position; - boolean equalSoFar = true; - while (equalSoFar && (myPosition < limit)) { - equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++); - } - - return equalSoFar; - } - - /** Returns the float at the current position and increases the position by 1. - * - * @return the float at the current position. - * @exception BufferUnderflowException if the position is equal or greater than limit. - * @since Android 1.0 */ - public abstract float get (); - - /** Reads floats from the current position into the specified float array and increases the position by the number of floats - * read. - *

- * Calling this method has the same effect as {@code get(dest, 0, dest.length)}. - *

- * - * @param dest the destination float array. - * @return this buffer. - * @exception BufferUnderflowException if {@code dest.length} is greater than {@code remaining()}. - * @since Android 1.0 */ - public FloatBuffer get (float[] dest) { - return get(dest, 0, dest.length); - } - - /** Reads floats from the current position into the specified float array, starting from the specified offset, and increases the - * position by the number of floats read. - * - * @param dest the target float array. - * @param off the offset of the float array, must not be negative and no greater than {@code dest.length}. - * @param len the number of floats to read, must be no less than zero and no greater than {@code dest.length - off}. - * @return this buffer. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception BufferUnderflowException if {@code len} is greater than {@code remaining()}. - * @since Android 1.0 */ - public FloatBuffer get (float[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferUnderflowException(); - } - for (int i = off; i < off + len; i++) { - dest[i] = get(); - } - return this; - } - - /** Returns a float at the specified index; the position is not changed. - * - * @param index the index, must not be negative and less than limit. - * @return a float at the specified index. - * @exception IndexOutOfBoundsException if index is invalid. - * @since Android 1.0 */ - public abstract float get (int index); - - /** Indicates whether this buffer is based on a float array and is read/write. - * - * @return {@code true} if this buffer is based on a float array and provides read/write access, {@code false} otherwise. - * @since Android 1.0 */ - public final boolean hasArray () { - return protectedHasArray(); - } - -// /** -// * Calculates this buffer's hash code from the remaining chars. The -// * position, limit, capacity and mark don't affect the hash code. -// * -// * @return the hash code calculated from the remaining floats. -// * @since Android 1.0 -// */ -// public int hashCode() { -// int myPosition = position; -// int hash = 0; -// while (myPosition < limit) { -// hash = hash + Float.floatToIntBits(get(myPosition++)); -// } -// return hash; -// } - - /** Indicates whether this buffer is direct. A direct buffer will try its best to take advantage of native memory APIs and it - * may not stay in the Java heap, so it is not affected by garbage collection. - *

- * A float buffer is direct if it is based on a byte buffer and the byte buffer is direct. - *

- * - * @return {@code true} if this buffer is direct, {@code false} otherwise. - * @since Android 1.0 */ - public abstract boolean isDirect (); - - /** Returns the byte order used by this buffer when converting floats from/to bytes. - *

- * If this buffer is not based on a byte buffer, then always return the platform's native byte order. - *

- * - * @return the byte order used by this buffer when converting floats from/to bytes. - * @since Android 1.0 */ - public abstract ByteOrder order (); - - /** Child class implements this method to realize {@code array()}. - * - * @return see {@code array()} */ - abstract float[] protectedArray (); - - /** Child class implements this method to realize {@code arrayOffset()}. - * - * @return see {@code arrayOffset()} */ - abstract int protectedArrayOffset (); - - /** Child class implements this method to realize {@code hasArray()}. - * - * @return see {@code hasArray()} */ - abstract boolean protectedHasArray (); - - /** Writes the given float to the current position and increases the position by 1. - * - * @param f the float to write. - * @return this buffer. - * @exception BufferOverflowException if position is equal or greater than limit. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract FloatBuffer put (float f); - - /** Writes floats from the given float array to the current position and increases the position by the number of floats written. - *

- * Calling this method has the same effect as {@code put(src, 0, src.length)}. - *

- * - * @param src the source float array. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code src.length}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public final FloatBuffer put (float[] src) { - return put(src, 0, src.length); - } - - /** Writes floats from the given float array, starting from the specified offset, to the current position and increases the - * position by the number of floats written. - * - * @param src the source float array. - * @param off the offset of float array, must not be negative and not greater than {@code src.length}. - * @param len the number of floats to write, must be no less than zero and no greater than {@code src.length - off}. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code len}. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public FloatBuffer put (float[] src, int off, int len) { - int length = src.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferOverflowException(); - } - for (int i = off; i < off + len; i++) { - put(src[i]); - } - return this; - } - - /** Writes all the remaining floats of the {@code src} float buffer to this buffer's current position, and increases both - * buffers' position by the number of floats copied. - * - * @param src the source float buffer. - * @return this buffer. - * @exception BufferOverflowException if {@code src.remaining()} is greater than this buffer's {@code remaining()}. - * @exception IllegalArgumentException if {@code src} is this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public FloatBuffer put (FloatBuffer src) { - if (src == this) { - throw new IllegalArgumentException(); - } - if (src.remaining() > remaining()) { - throw new BufferOverflowException(); - } - float[] contents = new float[src.remaining()]; - src.get(contents); - put(contents); - return this; - } - - /** Writes a float to the specified index of this buffer; the position is not changed. - * - * @param index the index, must not be negative and less than the limit. - * @param f the float to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if index is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract FloatBuffer put (int index, float f); - - /** Returns a sliced buffer that shares its content with this buffer. - *

- * The sliced buffer's capacity will be this buffer's {@code remaining()}, and its zero position will correspond to this - * buffer's current position. The new buffer's position will be 0, limit will be its capacity, and its mark is cleared. The new - * buffer's read-only property and byte order are same as this buffer's. - *

- *

- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *

- * - * @return a sliced buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract FloatBuffer slice (); - - /** Returns a string representing the state of this float buffer. - * - * @return a string representing the state of this float buffer. - * @since Android 1.0 */ - public String toString () { - StringBuffer buf = new StringBuffer(); - buf.append(getClass().getName()); - buf.append(", status: capacity="); //$NON-NLS-1$ - buf.append(capacity()); - buf.append(" position="); //$NON-NLS-1$ - buf.append(position()); - buf.append(" limit="); //$NON-NLS-1$ - buf.append(limit()); - return buf.toString(); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/FloatToByteBufferAdapter.java b/backends/gdx-backend-dragome/emu/java/nio/FloatToByteBufferAdapter.java deleted file mode 100644 index c0722b7a..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/FloatToByteBufferAdapter.java +++ /dev/null @@ -1,201 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -//import org.apache.harmony.nio.internal.DirectBuffer; -//import org.apache.harmony.luni.platform.PlatformAddress; - -/** This class wraps a byte buffer to be a float buffer. - *

- * Implementation notice: - *

    - *
  • After a byte buffer instance is wrapped, it becomes privately owned by the adapter. It must NOT be accessed outside the - * adapter any more.
  • - *
  • The byte buffer's position and limit are NOT linked with the adapter. The adapter extends Buffer, thus has its own position - * and limit.
  • - *
- *

*/ -final class FloatToByteBufferAdapter extends FloatBuffer { -// implements DirectBuffer { - - static FloatBuffer wrap (ByteBuffer byteBuffer) { - return new FloatToByteBufferAdapter(byteBuffer.slice()); - } - - private final ByteBuffer byteBuffer; - - FloatToByteBufferAdapter (ByteBuffer byteBuffer) { - super((byteBuffer.capacity() >> 2)); - this.byteBuffer = byteBuffer; - this.byteBuffer.clear(); - } - -// public int getByteCapacity() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).getByteCapacity(); -// } -// assert false : byteBuffer; -// return -1; -// } -// -// public PlatformAddress getEffectiveAddress() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).getEffectiveAddress(); -// } -// assert false : byteBuffer; -// return null; -// } -// -// public PlatformAddress getBaseAddress() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).getBaseAddress(); -// } -// assert false : byteBuffer; -// return null; -// } -// -// public boolean isAddressValid() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).isAddressValid(); -// } -// assert false : byteBuffer; -// return false; -// } -// -// public void addressValidityCheck() { -// if (byteBuffer instanceof DirectBuffer) { -// ((DirectBuffer) byteBuffer).addressValidityCheck(); -// } else { -// assert false : byteBuffer; -// } -// } -// -// public void free() { -// if (byteBuffer instanceof DirectBuffer) { -// ((DirectBuffer) byteBuffer).free(); -// } else { -// assert false : byteBuffer; -// } -// } - - @Override - public FloatBuffer asReadOnlyBuffer () { - FloatToByteBufferAdapter buf = new FloatToByteBufferAdapter(byteBuffer.asReadOnlyBuffer()); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public FloatBuffer compact () { - if (byteBuffer.isReadOnly()) { - throw new ReadOnlyBufferException(); - } - byteBuffer.limit(limit << 2); - byteBuffer.position(position << 2); - byteBuffer.compact(); - byteBuffer.clear(); - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - @Override - public FloatBuffer duplicate () { - FloatToByteBufferAdapter buf = new FloatToByteBufferAdapter(byteBuffer.duplicate()); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public float get () { - if (position == limit) { - throw new BufferUnderflowException(); - } - return byteBuffer.getFloat(position++ << 2); - } - - @Override - public float get (int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return byteBuffer.getFloat(index << 2); - } - - @Override - public boolean isDirect () { - return byteBuffer.isDirect(); - } - - @Override - public boolean isReadOnly () { - return byteBuffer.isReadOnly(); - } - - @Override - public ByteOrder order () { - return byteBuffer.order(); - } - - @Override - protected float[] protectedArray () { - throw new UnsupportedOperationException(); - } - - @Override - protected int protectedArrayOffset () { - throw new UnsupportedOperationException(); - } - - @Override - protected boolean protectedHasArray () { - return false; - } - - @Override - public FloatBuffer put (float c) { - if (position == limit) { - throw new BufferOverflowException(); - } - byteBuffer.putFloat(position++ << 2, c); - return this; - } - - @Override - public FloatBuffer put (int index, float c) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - byteBuffer.putFloat(index << 2, c); - return this; - } - - @Override - public FloatBuffer slice () { - byteBuffer.limit(limit << 2); - byteBuffer.position(position << 2); - FloatBuffer result = new FloatToByteBufferAdapter(byteBuffer.slice()); - byteBuffer.clear(); - return result; - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/HasArrayBufferView.java b/backends/gdx-backend-dragome/emu/java/nio/HasArrayBufferView.java deleted file mode 100644 index a83d7e8d..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/HasArrayBufferView.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright 2011 See AUTHORS file. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package java.nio; - -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBufferView; - -public interface HasArrayBufferView { - - public ArrayBufferView getTypedArray (); - - public int getElementSize (); -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/HeapByteBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/HeapByteBuffer.java deleted file mode 100644 index 913ea80c..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/HeapByteBuffer.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -import java.io.Numbers; - -import com.badlogic.gdx.backends.dragome.utils.Endianness; - -/** HeapByteBuffer, ReadWriteHeapByteBuffer and ReadOnlyHeapByteBuffer compose the implementation of array based byte buffers. - *

- * HeapByteBuffer implements all the shared readonly methods and is extended by the other two classes. - *

- *

- * All methods are marked final for runtime performance. - *

*/ -abstract class HeapByteBuffer extends BaseByteBuffer { - - protected final byte[] backingArray; - - protected final int offset; - - HeapByteBuffer (byte[] backingArray) { - this(backingArray, backingArray.length, 0); - } - - HeapByteBuffer (int capacity) { - this(new byte[capacity], capacity, 0); - } - - HeapByteBuffer (byte[] backingArray, int capacity, int offset) { - super(capacity); - this.backingArray = backingArray; - this.offset = offset; - - if (offset + capacity > backingArray.length) { - throw new IndexOutOfBoundsException(); - } - } - - /* - * Override ByteBuffer.get(byte[], int, int) to improve performance. - * - * (non-Javadoc) - * - * @see java.nio.ByteBuffer#get(byte[], int, int) - */ - public final ByteBuffer get (byte[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferUnderflowException(); - } - System.arraycopy(backingArray, offset + position, dest, off, len); - position += len; - return this; - } - - public final byte get () { - if (position == limit) { - throw new BufferUnderflowException(); - } - return backingArray[offset + position++]; - } - - public final byte get (int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return backingArray[offset + index]; - } - - public final double getDouble () { - return Numbers.longBitsToDouble(getLong()); - } - - public final double getDouble (int index) { - return Numbers.longBitsToDouble(getLong(index)); - } - - public final float getFloat () { - return Numbers.intBitsToFloat(getInt()); - } - - public final float getFloat (int index) { - return Numbers.intBitsToFloat(getInt(index)); - } - - public final int getInt () { - int newPosition = position + 4; - if (newPosition > limit) { - throw new BufferUnderflowException(); - } - int result = loadInt(position); - position = newPosition; - return result; - } - - public final int getInt (int index) { - if (index < 0 || index + 4 > limit) { - throw new IndexOutOfBoundsException(); - } - return loadInt(index); - } - - public final long getLong () { - int newPosition = position + 8; - if (newPosition > limit) { - throw new BufferUnderflowException(); - } - long result = loadLong(position); - position = newPosition; - return result; - } - - public final long getLong (int index) { - if (index < 0 || index + 8 > limit) { - throw new IndexOutOfBoundsException(); - } - return loadLong(index); - } - - public final short getShort () { - int newPosition = position + 2; - if (newPosition > limit) { - throw new BufferUnderflowException(); - } - short result = loadShort(position); - position = newPosition; - return result; - } - - public final short getShort (int index) { - if (index < 0 || index + 2 > limit) { - throw new IndexOutOfBoundsException(); - } - return loadShort(index); - } - - public final boolean isDirect () { - return false; - } - - protected final int loadInt (int index) { - int baseOffset = offset + index; - int bytes = 0; - if (order == Endianness.BIG_ENDIAN) { - for (int i = 0; i < 4; i++) { - bytes = bytes << 8; - bytes = bytes | (backingArray[baseOffset + i] & 0xFF); - } - } else { - for (int i = 3; i >= 0; i--) { - bytes = bytes << 8; - bytes = bytes | (backingArray[baseOffset + i] & 0xFF); - } - } - return bytes; - } - - protected final long loadLong (int index) { - int baseOffset = offset + index; - long bytes = 0; - if (order == Endianness.BIG_ENDIAN) { - for (int i = 0; i < 8; i++) { - bytes = bytes << 8; - bytes = bytes | (backingArray[baseOffset + i] & 0xFF); - } - } else { - for (int i = 7; i >= 0; i--) { - bytes = bytes << 8; - bytes = bytes | (backingArray[baseOffset + i] & 0xFF); - } - } - return bytes; - } - - protected final short loadShort (int index) { - int baseOffset = offset + index; - short bytes = 0; - if (order == Endianness.BIG_ENDIAN) { - bytes = (short)(backingArray[baseOffset] << 8); - bytes |= (backingArray[baseOffset + 1] & 0xFF); - } else { - bytes = (short)(backingArray[baseOffset + 1] << 8); - bytes |= (backingArray[baseOffset] & 0xFF); - } - return bytes; - } - - protected final void store (int index, int value) { - int baseOffset = offset + index; - if (order == Endianness.BIG_ENDIAN) { - for (int i = 3; i >= 0; i--) { - backingArray[baseOffset + i] = (byte)(value & 0xFF); - value = value >> 8; - } - } else { - for (int i = 0; i <= 3; i++) { - backingArray[baseOffset + i] = (byte)(value & 0xFF); - value = value >> 8; - } - } - } - - protected final void store (int index, long value) { - int baseOffset = offset + index; - if (order == Endianness.BIG_ENDIAN) { - for (int i = 7; i >= 0; i--) { - backingArray[baseOffset + i] = (byte)(value & 0xFF); - value = value >> 8; - } - } else { - for (int i = 0; i <= 7; i++) { - backingArray[baseOffset + i] = (byte)(value & 0xFF); - value = value >> 8; - } - } - } - - protected final void store (int index, short value) { - int baseOffset = offset + index; - if (order == Endianness.BIG_ENDIAN) { - backingArray[baseOffset] = (byte)((value >> 8) & 0xFF); - backingArray[baseOffset + 1] = (byte)(value & 0xFF); - } else { - backingArray[baseOffset + 1] = (byte)((value >> 8) & 0xFF); - backingArray[baseOffset] = (byte)(value & 0xFF); - } - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/IntArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/IntArrayBuffer.java deleted file mode 100644 index 10a62ad4..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/IntArrayBuffer.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** IntArrayBuffer, ReadWriteIntArrayBuffer and ReadOnlyIntArrayBuffer compose the implementation of array based int buffers. - *

- * IntArrayBuffer implements all the shared readonly methods and is extended by the other two classes. - *

- *

- * All methods are marked final for runtime performance. - *

*/ -abstract class IntArrayBuffer extends IntBuffer { - - protected final int[] backingArray; - - protected final int offset; - - IntArrayBuffer (int[] array) { - this(array.length, array, 0); - } - - IntArrayBuffer (int capacity) { - this(capacity, new int[capacity], 0); - } - - IntArrayBuffer (int capacity, int[] backingArray, int offset) { - super(capacity); - this.backingArray = backingArray; - this.offset = offset; - } - - public final int get () { - if (position == limit) { - throw new BufferUnderflowException(); - } - return backingArray[offset + position++]; - } - - public final int get (int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return backingArray[offset + index]; - } - - public final IntBuffer get (int[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)len + (long)off > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferUnderflowException(); - } - System.arraycopy(backingArray, offset + position, dest, off, len); - position += len; - return this; - } - - public final boolean isDirect () { - return false; - } - - public final ByteOrder order () { - return ByteOrder.nativeOrder(); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/IntBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/IntBuffer.java deleted file mode 100644 index dab83306..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/IntBuffer.java +++ /dev/null @@ -1,427 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** A buffer of ints. - *

- * A int buffer can be created in either of the following ways: - *

- *
    - *
  • {@link #allocate(int) Allocate} a new int array and create a buffer based on it;
  • - *
  • {@link #wrap(int[]) Wrap} an existing int array to create a new buffer;
  • - *
  • Use {@link java.nio.ByteBuffer#asIntBuffer() ByteBuffer.asIntBuffer} to create a int buffer based on a byte buffer.
  • - *
- * - * @since Android 1.0 */ -public abstract class IntBuffer extends Buffer implements Comparable { - - /** Creates an int buffer based on a newly allocated int array. - * - * @param capacity the capacity of the new buffer. - * @return the created int buffer. - * @throws IllegalArgumentException if {@code capacity} is less than zero. - * @since Android 1.0 */ - public static IntBuffer allocate (int capacity) { - if (capacity < 0) { - throw new IllegalArgumentException(); - } - return BufferFactory.newIntBuffer(capacity); - } - - /** Creates a new int buffer by wrapping the given int array. - *

- * Calling this method has the same effect as {@code wrap(array, 0, array.length)}. - *

- * - * @param array the int array which the new buffer will be based on. - * @return the created int buffer. - * @since Android 1.0 */ - public static IntBuffer wrap (int[] array) { - return wrap(array, 0, array.length); - } - - /** Creates a new int buffer by wrapping the given int array. - *

- * The new buffer's position will be {@code start}, limit will be {@code start + len}, capacity will be the length of the array. - *

- * - * @param array the int array which the new buffer will be based on. - * @param start the start index, must not be negative and not greater than {@code array.length} - * @param len the length, must not be negative and not greater than {@code array.length - start}. - * @return the created int buffer. - * @exception IndexOutOfBoundsException if either {@code start} or {@code len} is invalid. - * @since Android 1.0 */ - public static IntBuffer wrap (int[] array, int start, int len) { - if (array == null) { - throw new NullPointerException(); - } - if (start < 0 || len < 0 || (long)len + (long)start > array.length) { - throw new IndexOutOfBoundsException(); - } - IntBuffer buf = BufferFactory.newIntBuffer(array); - buf.position = start; - buf.limit = start + len; - - return buf; - } - - /** Constructs a {@code IntBuffer} with given capacity. - * - * @param capacity the capacity of the buffer. */ - IntBuffer (int capacity) { - super(capacity); - } - - /** Returns the int array which this buffer is based on, if there is one. - * - * @return the int array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final int[] array () { - return protectedArray(); - } - - /** Returns the offset of the int array which this buffer is based on, if there is one. - *

- * The offset is the index of the array corresponds to the zero position of the buffer. - *

- * - * @return the offset of the int array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final int arrayOffset () { - return protectedArrayOffset(); - } - - /** Returns a read-only buffer that shares its content with this buffer. - *

- * The returned buffer is guaranteed to be a new instance, even this buffer is read-only itself. The new buffer's position, - * limit, capacity and mark are the same as this buffer's. - *

- *

- * The new buffer shares its content with this buffer, which means this buffer's change of content will be visible to the new - * buffer. The two buffer's position, limit and mark are independent. - *

- * - * @return a read-only version of this buffer. - * @since Android 1.0 */ - public abstract IntBuffer asReadOnlyBuffer (); - - /** Compacts this int buffer. - *

- * The remaining ints will be moved to the head of the buffer, starting from position zero. Then the position is set to - * {@code remaining()}; the limit is set to capacity; the mark is cleared. - *

- * - * @return this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract IntBuffer compact (); - - /** Compares the remaining ints of this buffer to another int buffer's remaining ints. - * - * @param otherBuffer another int buffer. - * @return a negative value if this is less than {@code other}; 0 if this equals to {@code other}; a positive value if this is - * greater than {@code other}. - * @exception ClassCastException if {@code other} is not an int buffer. - * @since Android 1.0 */ - public int compareTo (IntBuffer otherBuffer) { - int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining() : otherBuffer.remaining(); - int thisPos = position; - int otherPos = otherBuffer.position; - // BEGIN android-changed - int thisInt, otherInt; - while (compareRemaining > 0) { - thisInt = get(thisPos); - otherInt = otherBuffer.get(otherPos); - if (thisInt != otherInt) { - return thisInt < otherInt ? -1 : 1; - } - thisPos++; - otherPos++; - compareRemaining--; - } - // END android-changed - return remaining() - otherBuffer.remaining(); - } - - /** Returns a duplicated buffer that shares its content with this buffer. - *

- * The duplicated buffer's position, limit, capacity and mark are the same as this buffer. The duplicated buffer's read-only - * property and byte order are the same as this buffer's. - *

- *

- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *

- * - * @return a duplicated buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract IntBuffer duplicate (); - - /** Checks whether this int buffer is equal to another object. - *

- * If {@code other} is not a int buffer then {@code false} is returned. Two int buffers are equal if and only if their remaining - * ints are exactly the same. Position, limit, capacity and mark are not considered. - *

- * - * @param other the object to compare with this int buffer. - * @return {@code true} if this int buffer is equal to {@code other}, {@code false} otherwise. - * @since Android 1.0 */ - public boolean equals (Object other) { - if (!(other instanceof IntBuffer)) { - return false; - } - IntBuffer otherBuffer = (IntBuffer)other; - - if (remaining() != otherBuffer.remaining()) { - return false; - } - - int myPosition = position; - int otherPosition = otherBuffer.position; - boolean equalSoFar = true; - while (equalSoFar && (myPosition < limit)) { - equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++); - } - - return equalSoFar; - } - - /** Returns the int at the current position and increases the position by 1. - * - * @return the int at the current position. - * @exception BufferUnderflowException if the position is equal or greater than limit. - * @since Android 1.0 */ - public abstract int get (); - - /** Reads ints from the current position into the specified int array and increases the position by the number of ints read. - *

- * Calling this method has the same effect as {@code get(dest, 0, dest.length)}. - *

- * - * @param dest the destination int array. - * @return this buffer. - * @exception BufferUnderflowException if {@code dest.length} is greater than {@code remaining()}. - * @since Android 1.0 */ - public IntBuffer get (int[] dest) { - return get(dest, 0, dest.length); - } - - /** Reads ints from the current position into the specified int array, starting from the specified offset, and increases the - * position by the number of ints read. - * - * @param dest the target int array. - * @param off the offset of the int array, must not be negative and not greater than {@code dest.length}. - * @param len the number of ints to read, must be no less than zero and not greater than {@code dest.length - off}. - * @return this buffer. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception BufferUnderflowException if {@code len} is greater than {@code remaining()}. - * @since Android 1.0 */ - public IntBuffer get (int[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)len + (long)off > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferUnderflowException(); - } - for (int i = off; i < off + len; i++) { - dest[i] = get(); - } - return this; - } - - /** Returns an int at the specified index; the position is not changed. - * - * @param index the index, must not be negative and less than limit. - * @return an int at the specified index. - * @exception IndexOutOfBoundsException if index is invalid. - * @since Android 1.0 */ - public abstract int get (int index); - - /** Indicates whether this buffer is based on a int array and is read/write. - * - * @return {@code true} if this buffer is based on a int array and provides read/write access, {@code false} otherwise. - * @since Android 1.0 */ - public final boolean hasArray () { - return protectedHasArray(); - } - - /** Calculates this buffer's hash code from the remaining chars. The position, limit, capacity and mark don't affect the hash - * code. - * - * @return the hash code calculated from the remaining ints. - * @since Android 1.0 */ - public int hashCode () { - int myPosition = position; - int hash = 0; - while (myPosition < limit) { - hash = hash + get(myPosition++); - } - return hash; - } - - /** Indicates whether this buffer is direct. A direct buffer will try its best to take advantage of native memory APIs and it - * may not stay in the Java heap, so it is not affected by garbage collection. - *

- * An int buffer is direct if it is based on a byte buffer and the byte buffer is direct. - *

- * - * @return {@code true} if this buffer is direct, {@code false} otherwise. - * @since Android 1.0 */ - public abstract boolean isDirect (); - - /** Returns the byte order used by this buffer when converting ints from/to bytes. - *

- * If this buffer is not based on a byte buffer, then always return the platform's native byte order. - *

- * - * @return the byte order used by this buffer when converting ints from/to bytes. - * @since Android 1.0 */ - public abstract ByteOrder order (); - - /** Child class implements this method to realize {@code array()}. - * - * @return see {@code array()} */ - protected abstract int[] protectedArray (); - - /** Child class implements this method to realize {@code arrayOffset()}. - * - * @return see {@code arrayOffset()} */ - protected abstract int protectedArrayOffset (); - - /** Child class implements this method to realize {@code hasArray()}. - * - * @return see {@code hasArray()} */ - protected abstract boolean protectedHasArray (); - - /** Writes the given int to the current position and increases the position by 1. - * - * @param i the int to write. - * @return this buffer. - * @exception BufferOverflowException if position is equal or greater than limit. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract IntBuffer put (int i); - - /** Writes ints from the given int array to the current position and increases the position by the number of ints written. - *

- * Calling this method has the same effect as {@code put(src, 0, src.length)}. - *

- * - * @param src the source int array. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code src.length}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public final IntBuffer put (int[] src) { - return put(src, 0, src.length); - } - - /** Writes ints from the given int array, starting from the specified offset, to the current position and increases the position - * by the number of ints written. - * - * @param src the source int array. - * @param off the offset of int array, must not be negative and not greater than {@code src.length}. - * @param len the number of ints to write, must be no less than zero and not greater than {@code src.length - off}. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code len}. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public IntBuffer put (int[] src, int off, int len) { - int length = src.length; - if (off < 0 || len < 0 || (long)len + (long)off > length) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferOverflowException(); - } - for (int i = off; i < off + len; i++) { - put(src[i]); - } - return this; - } - - /** Writes all the remaining ints of the {@code src} int buffer to this buffer's current position, and increases both buffers' - * position by the number of ints copied. - * - * @param src the source int buffer. - * @return this buffer. - * @exception BufferOverflowException if {@code src.remaining()} is greater than this buffer's {@code remaining()}. - * @exception IllegalArgumentException if {@code src} is this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public IntBuffer put (IntBuffer src) { - if (src == this) { - throw new IllegalArgumentException(); - } - if (src.remaining() > remaining()) { - throw new BufferOverflowException(); - } - int[] contents = new int[src.remaining()]; - src.get(contents); - put(contents); - return this; - } - - /** Write a int to the specified index of this buffer; the position is not changed. - * - * @param index the index, must not be negative and less than the limit. - * @param i the int to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if index is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract IntBuffer put (int index, int i); - - /** Returns a sliced buffer that shares its content with this buffer. - *

- * The sliced buffer's capacity will be this buffer's {@code remaining()}, and its zero position will correspond to this - * buffer's current position. The new buffer's position will be 0, limit will be its capacity, and its mark is cleared. The new - * buffer's read-only property and byte order are same as this buffer's. - *

- *

- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *

- * - * @return a sliced buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract IntBuffer slice (); - - /** Returns a string represents of the state of this int buffer. - * - * @return a string represents of the state of this int buffer. - * @since Android 1.0 */ - public String toString () { - StringBuffer buf = new StringBuffer(); - buf.append(getClass().getName()); - buf.append(", status: capacity="); //$NON-NLS-1$ - buf.append(capacity()); - buf.append(" position="); //$NON-NLS-1$ - buf.append(position()); - buf.append(" limit="); //$NON-NLS-1$ - buf.append(limit()); - return buf.toString(); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/IntToByteBufferAdapter.java b/backends/gdx-backend-dragome/emu/java/nio/IntToByteBufferAdapter.java deleted file mode 100644 index f2151ff5..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/IntToByteBufferAdapter.java +++ /dev/null @@ -1,205 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -//import org.apache.harmony.nio.internal.DirectBuffer; -//import org.apache.harmony.luni.platform.PlatformAddress; - -/** This class wraps a byte buffer to be a int buffer. - *

- * Implementation notice: - *

    - *
  • After a byte buffer instance is wrapped, it becomes privately owned by the adapter. It must NOT be accessed outside the - * adapter any more.
  • - *
  • The byte buffer's position and limit are NOT linked with the adapter. The adapter extends Buffer, thus has its own position - * and limit.
  • - *
- *

*/ -final class IntToByteBufferAdapter extends IntBuffer implements ByteBufferWrapper { -// implements DirectBuffer { - - static IntBuffer wrap (ByteBuffer byteBuffer) { - return new IntToByteBufferAdapter(byteBuffer.slice()); - } - - private final ByteBuffer byteBuffer; - - IntToByteBufferAdapter (ByteBuffer byteBuffer) { - super((byteBuffer.capacity() >> 2)); - this.byteBuffer = byteBuffer; - this.byteBuffer.clear(); - } - -// public int getByteCapacity() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).getByteCapacity(); -// } -// assert false : byteBuffer; -// return -1; -// } -// -// public PlatformAddress getEffectiveAddress() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).getEffectiveAddress(); -// } -// assert false : byteBuffer; -// return null; -// } -// -// public PlatformAddress getBaseAddress() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).getBaseAddress(); -// } -// assert false : byteBuffer; -// return null; -// } -// -// public boolean isAddressValid() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).isAddressValid(); -// } -// assert false : byteBuffer; -// return false; -// } -// -// public void addressValidityCheck() { -// if (byteBuffer instanceof DirectBuffer) { -// ((DirectBuffer) byteBuffer).addressValidityCheck(); -// } else { -// assert false : byteBuffer; -// } -// } -// -// public void free() { -// if (byteBuffer instanceof DirectBuffer) { -// ((DirectBuffer) byteBuffer).free(); -// } else { -// assert false : byteBuffer; -// } -// } - - @Override - public IntBuffer asReadOnlyBuffer () { - IntToByteBufferAdapter buf = new IntToByteBufferAdapter(byteBuffer.asReadOnlyBuffer()); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public IntBuffer compact () { - if (byteBuffer.isReadOnly()) { - throw new ReadOnlyBufferException(); - } - byteBuffer.limit(limit << 2); - byteBuffer.position(position << 2); - byteBuffer.compact(); - byteBuffer.clear(); - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - @Override - public IntBuffer duplicate () { - IntToByteBufferAdapter buf = new IntToByteBufferAdapter(byteBuffer.duplicate()); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public int get () { - if (position == limit) { - throw new BufferUnderflowException(); - } - return byteBuffer.getInt(position++ << 2); - } - - @Override - public int get (int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return byteBuffer.getInt(index << 2); - } - - @Override - public boolean isDirect () { - return byteBuffer.isDirect(); - } - - @Override - public boolean isReadOnly () { - return byteBuffer.isReadOnly(); - } - - @Override - public ByteOrder order () { - return byteBuffer.order(); - } - - @Override - protected int[] protectedArray () { - throw new UnsupportedOperationException(); - } - - @Override - protected int protectedArrayOffset () { - throw new UnsupportedOperationException(); - } - - @Override - protected boolean protectedHasArray () { - return false; - } - - @Override - public IntBuffer put (int c) { - if (position == limit) { - throw new BufferOverflowException(); - } - byteBuffer.putInt(position++ << 2, c); - return this; - } - - @Override - public IntBuffer put (int index, int c) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - byteBuffer.putInt(index << 2, c); - return this; - } - - @Override - public IntBuffer slice () { - byteBuffer.limit(limit << 2); - byteBuffer.position(position << 2); - IntBuffer result = new IntToByteBufferAdapter(byteBuffer.slice()); - byteBuffer.clear(); - return result; - } - - public ByteBuffer getByteBuffer () { - return byteBuffer; - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/InvalidMarkException.java b/backends/gdx-backend-dragome/emu/java/nio/InvalidMarkException.java deleted file mode 100644 index a523dc5b..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/InvalidMarkException.java +++ /dev/null @@ -1,32 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** An {@code InvalidMarkException} is thrown when {@code reset()} is called on a buffer, but no mark has been set previously. - * - * @since Android 1.0 */ -public class InvalidMarkException extends IllegalStateException { - - private static final long serialVersionUID = 1698329710438510774L; - - /** Constructs an {@code InvalidMarkException}. - * - * @since Android 1.0 */ - public InvalidMarkException () { - super(); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/LongArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/LongArrayBuffer.java deleted file mode 100644 index 73c9be06..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/LongArrayBuffer.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** LongArrayBuffer, ReadWriteLongArrayBuffer and ReadOnlyLongArrayBuffer compose the implementation of array based long buffers. - *

- * LongArrayBuffer implements all the shared readonly methods and is extended by the other two classes. - *

- *

- * All methods are marked final for runtime performance. - *

*/ -abstract class LongArrayBuffer extends LongBuffer { - - protected final long[] backingArray; - - protected final int offset; - - LongArrayBuffer (long[] array) { - this(array.length, array, 0); - } - - LongArrayBuffer (int capacity) { - this(capacity, new long[capacity], 0); - } - - LongArrayBuffer (int capacity, long[] backingArray, int offset) { - super(capacity); - this.backingArray = backingArray; - this.offset = offset; - } - - public final long get () { - if (position == limit) { - throw new BufferUnderflowException(); - } - return backingArray[offset + position++]; - } - - public final long get (int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return backingArray[offset + index]; - } - - public final LongBuffer get (long[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)len + (long)off > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferUnderflowException(); - } - System.arraycopy(backingArray, offset + position, dest, off, len); - position += len; - return this; - } - - public final boolean isDirect () { - return false; - } - - public final ByteOrder order () { - return ByteOrder.nativeOrder(); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/LongBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/LongBuffer.java deleted file mode 100644 index 53a226fb..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/LongBuffer.java +++ /dev/null @@ -1,431 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** A buffer of longs. - *

- * A long buffer can be created in either of the following ways: - *

- *
    - *
  • {@link #allocate(int) Allocate} a new long array and create a buffer based on it;
  • - *
  • {@link #wrap(long[]) Wrap} an existing long array to create a new buffer;
  • - *
  • Use {@link java.nio.ByteBuffer#asLongBuffer() ByteBuffer.asLongBuffer} to create a long buffer based on a byte buffer.
  • - *
- * - * @since Android 1.0 */ -public abstract class LongBuffer extends Buffer implements Comparable { - - /** Creates a long buffer based on a newly allocated long array. - * - * @param capacity the capacity of the new buffer. - * @return the created long buffer. - * @throws IllegalArgumentException if {@code capacity} is less than zero. - * @since Android 1.0 */ - public static LongBuffer allocate (int capacity) { - if (capacity < 0) { - throw new IllegalArgumentException(); - } - return BufferFactory.newLongBuffer(capacity); - } - - /** Creates a new long buffer by wrapping the given long array. - *

- * Calling this method has the same effect as {@code wrap(array, 0, array.length)}. - *

- * - * @param array the long array which the new buffer will be based on. - * @return the created long buffer. - * @since Android 1.0 */ - public static LongBuffer wrap (long[] array) { - return wrap(array, 0, array.length); - } - - /** Creates a new long buffer by wrapping the given long array. - *

- * The new buffer's position will be {@code start}, limit will be {@code start + len}, capacity will be the length of the array. - *

- * - * @param array the long array which the new buffer will be based on. - * @param start the start index, must not be negative and not greater than {@code array.length}. - * @param len the length, must not be negative and not greater than {@code array.length - start}. - * @return the created long buffer. - * @exception IndexOutOfBoundsException if either {@code start} or {@code len} is invalid. - * @since Android 1.0 */ - public static LongBuffer wrap (long[] array, int start, int len) { - if (array == null) { - throw new NullPointerException(); - } - if (start < 0 || len < 0 || (long)len + (long)start > array.length) { - throw new IndexOutOfBoundsException(); - } - - LongBuffer buf = BufferFactory.newLongBuffer(array); - buf.position = start; - buf.limit = start + len; - - return buf; - } - - /** Constructs a {@code LongBuffer} with given capacity. - * - * @param capacity The capacity of the buffer */ - LongBuffer (int capacity) { - super(capacity); - } - - /** Returns the long array which this buffer is based on, if there is one. - * - * @return the long array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final long[] array () { - return protectedArray(); - } - - /** Returns the offset of the long array which this buffer is based on, if there is one. - *

- * The offset is the index of the array and corresponds to the zero position of the buffer. - *

- * - * @return the offset of the long array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final int arrayOffset () { - return protectedArrayOffset(); - } - - /** Returns a read-only buffer that shares its content with this buffer. - *

- * The returned buffer is guaranteed to be a new instance, even if this buffer is read-only itself. The new buffer's position, - * limit, capacity and mark are the same as this buffer's. - *

- *

- * The new buffer shares its content with this buffer, which means this buffer's change of content will be visible to the new - * buffer. The two buffer's position, limit and mark are independent. - *

- * - * @return a read-only version of this buffer. - * @since Android 1.0 */ - public abstract LongBuffer asReadOnlyBuffer (); - - /** Compacts this long buffer. - *

- * The remaining longs will be moved to the head of the buffer, staring from position zero. Then the position is set to - * {@code remaining()}; the limit is set to capacity; the mark is cleared. - *

- * - * @return this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract LongBuffer compact (); - - /** Compare the remaining longs of this buffer to another long buffer's remaining longs. - * - * @param otherBuffer another long buffer. - * @return a negative value if this is less than {@code otherBuffer}; 0 if this equals to {@code otherBuffer}; a positive value - * if this is greater than {@code otherBuffer} - * @exception ClassCastException if {@code otherBuffer} is not a long buffer. - * @since Android 1.0 */ - public int compareTo (LongBuffer otherBuffer) { - int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining() : otherBuffer.remaining(); - int thisPos = position; - int otherPos = otherBuffer.position; - // BEGIN android-changed - long thisLong, otherLong; - while (compareRemaining > 0) { - thisLong = get(thisPos); - otherLong = otherBuffer.get(otherPos); - if (thisLong != otherLong) { - return thisLong < otherLong ? -1 : 1; - } - thisPos++; - otherPos++; - compareRemaining--; - } - // END android-changed - return remaining() - otherBuffer.remaining(); - } - - /** Returns a duplicated buffer that shares its content with this buffer. - *

- * The duplicated buffer's position, limit, capacity and mark are the same as this buffer. The duplicated buffer's read-only - * property and byte order are same as this buffer's, too. - *

- *

- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *

- * - * @return a duplicated buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract LongBuffer duplicate (); - - /** Checks whether this long buffer is equal to another object. - *

- * If {@code other} is not a long buffer then {@code false} is returned. Two long buffers are equal if and only if their - * remaining longs are exactly the same. Position, limit, capacity and mark are not considered. - *

- * - * @param other the object to compare with this long buffer. - * @return {@code true} if this long buffer is equal to {@code other}, {@code false} otherwise. - * @since Android 1.0 */ - public boolean equals (Object other) { - if (!(other instanceof LongBuffer)) { - return false; - } - LongBuffer otherBuffer = (LongBuffer)other; - - if (remaining() != otherBuffer.remaining()) { - return false; - } - - int myPosition = position; - int otherPosition = otherBuffer.position; - boolean equalSoFar = true; - while (equalSoFar && (myPosition < limit)) { - equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++); - } - - return equalSoFar; - } - - /** Returns the long at the current position and increase the position by 1. - * - * @return the long at the current position. - * @exception BufferUnderflowException if the position is equal or greater than limit. - * @since Android 1.0 */ - public abstract long get (); - - /** Reads longs from the current position into the specified long array and increases the position by the number of longs read. - *

- * Calling this method has the same effect as {@code get(dest, 0, dest.length)}. - *

- * - * @param dest the destination long array. - * @return this buffer. - * @exception BufferUnderflowException if {@code dest.length} is greater than {@code remaining()}. - * @since Android 1.0 */ - public LongBuffer get (long[] dest) { - return get(dest, 0, dest.length); - } - - /** Reads longs from the current position into the specified long array, starting from the specified offset, and increase the - * position by the number of longs read. - * - * @param dest the target long array. - * @param off the offset of the long array, must not be negative and not greater than {@code dest.length}. - * @param len the number of longs to read, must be no less than zero and not greater than {@code dest.length - off}. - * @return this buffer. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception BufferUnderflowException if {@code len} is greater than {@code remaining()}. - * @since Android 1.0 */ - public LongBuffer get (long[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)len + (long)off > length) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferUnderflowException(); - } - for (int i = off; i < off + len; i++) { - dest[i] = get(); - } - return this; - } - - /** Returns the long at the specified index; the position is not changed. - * - * @param index the index, must not be negative and less than limit. - * @return the long at the specified index. - * @exception IndexOutOfBoundsException if index is invalid. - * @since Android 1.0 */ - public abstract long get (int index); - - /** Indicates whether this buffer is based on a long array and is read/write. - * - * @return {@code true} if this buffer is based on a long array and provides read/write access, {@code false} otherwise. - * @since Android 1.0 */ - public final boolean hasArray () { - return protectedHasArray(); - } - - /** Calculates this buffer's hash code from the remaining chars. The position, limit, capacity and mark don't affect the hash - * code. - * - * @return the hash code calculated from the remaining longs. - * @since Android 1.0 */ - public int hashCode () { - int myPosition = position; - int hash = 0; - long l; - while (myPosition < limit) { - l = get(myPosition++); - hash = hash + ((int)l) ^ ((int)(l >> 32)); - } - return hash; - } - - /** Indicates whether this buffer is direct. A direct buffer will try its best to take advantage of native memory APIs and it - * may not stay in the Java heap, so it is not affected by garbage collection. - *

- * A long buffer is direct if it is based on a byte buffer and the byte buffer is direct. - *

- * - * @return {@code true} if this buffer is direct, {@code false} otherwise. - * @since Android 1.0 */ - public abstract boolean isDirect (); - - /** Returns the byte order used by this buffer when converting longs from/to bytes. - *

- * If this buffer is not based on a byte buffer, then always return the platform's native byte order. - *

- * - * @return the byte order used by this buffer when converting longs from/to bytes. - * @since Android 1.0 */ - public abstract ByteOrder order (); - - /** Child class implements this method to realize {@code array()}. - * - * @return see {@code array()} */ - abstract long[] protectedArray (); - - /** Child class implements this method to realize {@code arrayOffset()}. - * - * @return see {@code arrayOffset()} */ - abstract int protectedArrayOffset (); - - /** Child class implements this method to realize {@code hasArray()}. - * - * @return see {@code hasArray()} */ - abstract boolean protectedHasArray (); - - /** Writes the given long to the current position and increases the position by 1. - * - * @param l the long to write. - * @return this buffer. - * @exception BufferOverflowException if position is equal or greater than limit. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract LongBuffer put (long l); - - /** Writes longs from the given long array to the current position and increases the position by the number of longs written. - *

- * Calling this method has the same effect as {@code put(src, 0, src.length)}. - *

- * - * @param src the source long array. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code src.length}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public final LongBuffer put (long[] src) { - return put(src, 0, src.length); - } - - /** Writes longs from the given long array, starting from the specified offset, to the current position and increases the - * position by the number of longs written. - * - * @param src the source long array. - * @param off the offset of long array, must not be negative and not greater than {@code src.length}. - * @param len the number of longs to write, must be no less than zero and not greater than {@code src.length - off}. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code len}. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public LongBuffer put (long[] src, int off, int len) { - int length = src.length; - if (off < 0 || len < 0 || (long)len + (long)off > length) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferOverflowException(); - } - for (int i = off; i < off + len; i++) { - put(src[i]); - } - return this; - } - - /** Writes all the remaining longs of the {@code src} long buffer to this buffer's current position, and increases both buffers' - * position by the number of longs copied. - * - * @param src the source long buffer. - * @return this buffer. - * @exception BufferOverflowException if {@code src.remaining()} is greater than this buffer's {@code remaining()}. - * @exception IllegalArgumentException if {@code src} is this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public LongBuffer put (LongBuffer src) { - if (src == this) { - throw new IllegalArgumentException(); - } - if (src.remaining() > remaining()) { - throw new BufferOverflowException(); - } - long[] contents = new long[src.remaining()]; - src.get(contents); - put(contents); - return this; - } - - /** Writes a long to the specified index of this buffer; the position is not changed. - * - * @param index the index, must not be negative and less than the limit. - * @param l the long to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if index is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract LongBuffer put (int index, long l); - - /** Returns a sliced buffer that shares its content with this buffer. - *

- * The sliced buffer's capacity will be this buffer's {@code remaining()}, and its zero position will correspond to this - * buffer's current position. The new buffer's position will be 0, limit will be its capacity, and its mark is cleared. The new - * buffer's read-only property and byte order are same as this buffer's. - *

- *

- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *

- * - * @return a sliced buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract LongBuffer slice (); - - /** Returns a string representing the state of this long buffer. - * - * @return a string representing the state of this long buffer. - * @since Android 1.0 */ - public String toString () { - StringBuffer buf = new StringBuffer(); - buf.append(getClass().getName()); - buf.append(", status: capacity="); //$NON-NLS-1$ - buf.append(capacity()); - buf.append(" position="); //$NON-NLS-1$ - buf.append(position()); - buf.append(" limit="); //$NON-NLS-1$ - buf.append(limit()); - return buf.toString(); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/LongToByteBufferAdapter.java b/backends/gdx-backend-dragome/emu/java/nio/LongToByteBufferAdapter.java deleted file mode 100644 index 410b3b30..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/LongToByteBufferAdapter.java +++ /dev/null @@ -1,200 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -//import org.apache.harmony.nio.internal.DirectBuffer; -//import org.apache.harmony.luni.platform.PlatformAddress; - -/** This class wraps a byte buffer to be a long buffer. - *

- * Implementation notice: - *

    - *
  • After a byte buffer instance is wrapped, it becomes privately owned by the adapter. It must NOT be accessed outside the - * adapter any more.
  • - *
  • The byte buffer's position and limit are NOT linked with the adapter. The adapter extends Buffer, thus has its own position - * and limit.
  • - *
- *

*/ -final class LongToByteBufferAdapter extends LongBuffer {// implements DirectBuffer { - - static LongBuffer wrap (ByteBuffer byteBuffer) { - return new LongToByteBufferAdapter(byteBuffer.slice()); - } - - private final ByteBuffer byteBuffer; - - LongToByteBufferAdapter (ByteBuffer byteBuffer) { - super((byteBuffer.capacity() >> 3)); - this.byteBuffer = byteBuffer; - this.byteBuffer.clear(); - } - -// public int getByteCapacity() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).getByteCapacity(); -// } -// assert false : byteBuffer; -// return -1; -// } -// -// public PlatformAddress getEffectiveAddress() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).getEffectiveAddress(); -// } -// assert false : byteBuffer; -// return null; -// } -// -// public PlatformAddress getBaseAddress() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).getBaseAddress(); -// } -// assert false : byteBuffer; -// return null; -// } -// -// public boolean isAddressValid() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).isAddressValid(); -// } -// assert false : byteBuffer; -// return false; -// } -// -// public void addressValidityCheck() { -// if (byteBuffer instanceof DirectBuffer) { -// ((DirectBuffer) byteBuffer).addressValidityCheck(); -// } else { -// assert false : byteBuffer; -// } -// } -// -// public void free() { -// if (byteBuffer instanceof DirectBuffer) { -// ((DirectBuffer) byteBuffer).free(); -// } else { -// assert false : byteBuffer; -// } -// } - - @Override - public LongBuffer asReadOnlyBuffer () { - LongToByteBufferAdapter buf = new LongToByteBufferAdapter(byteBuffer.asReadOnlyBuffer()); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public LongBuffer compact () { - if (byteBuffer.isReadOnly()) { - throw new ReadOnlyBufferException(); - } - byteBuffer.limit(limit << 3); - byteBuffer.position(position << 3); - byteBuffer.compact(); - byteBuffer.clear(); - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - @Override - public LongBuffer duplicate () { - LongToByteBufferAdapter buf = new LongToByteBufferAdapter(byteBuffer.duplicate()); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public long get () { - if (position == limit) { - throw new BufferUnderflowException(); - } - return byteBuffer.getLong(position++ << 3); - } - - @Override - public long get (int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return byteBuffer.getLong(index << 3); - } - - @Override - public boolean isDirect () { - return byteBuffer.isDirect(); - } - - @Override - public boolean isReadOnly () { - return byteBuffer.isReadOnly(); - } - - @Override - public ByteOrder order () { - return byteBuffer.order(); - } - - @Override - protected long[] protectedArray () { - throw new UnsupportedOperationException(); - } - - @Override - protected int protectedArrayOffset () { - throw new UnsupportedOperationException(); - } - - @Override - protected boolean protectedHasArray () { - return false; - } - - @Override - public LongBuffer put (long c) { - if (position == limit) { - throw new BufferOverflowException(); - } - byteBuffer.putLong(position++ << 3, c); - return this; - } - - @Override - public LongBuffer put (int index, long c) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - byteBuffer.putLong(index << 3, c); - return this; - } - - @Override - public LongBuffer slice () { - byteBuffer.limit(limit << 3); - byteBuffer.position(position << 3); - LongBuffer result = new LongToByteBufferAdapter(byteBuffer.slice()); - byteBuffer.clear(); - return result; - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyBufferException.java b/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyBufferException.java deleted file mode 100644 index 100ce78b..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyBufferException.java +++ /dev/null @@ -1,32 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** A {@code ReadOnlyBufferException} is thrown when some write operation is called on a read-only buffer. - * - * @since Android 1.0 */ -public class ReadOnlyBufferException extends UnsupportedOperationException { - - private static final long serialVersionUID = -1210063976496234090L; - - /** Constructs a {@code ReadOnlyBufferException}. - * - * @since Android 1.0 */ - public ReadOnlyBufferException () { - super(); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyCharArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyCharArrayBuffer.java deleted file mode 100644 index 773ab12d..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyCharArrayBuffer.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** CharArrayBuffer, ReadWriteCharArrayBuffer and ReadOnlyCharArrayBuffer compose the implementation of array based char buffers. - *

- * ReadOnlyCharArrayBuffer extends CharArrayBuffer with all the write methods throwing read only exception. - *

- *

- * This class is marked final for runtime performance. - *

*/ -final class ReadOnlyCharArrayBuffer extends CharArrayBuffer { - - static ReadOnlyCharArrayBuffer copy (CharArrayBuffer other, int markOfOther) { - ReadOnlyCharArrayBuffer buf = new ReadOnlyCharArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadOnlyCharArrayBuffer (int capacity, char[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public CharBuffer asReadOnlyBuffer () { - return duplicate(); - } - - public CharBuffer compact () { - throw new ReadOnlyBufferException(); - } - - public CharBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return true; - } - - protected char[] protectedArray () { - throw new ReadOnlyBufferException(); - } - - protected int protectedArrayOffset () { - throw new ReadOnlyBufferException(); - } - - protected boolean protectedHasArray () { - return false; - } - - public CharBuffer put (char c) { - throw new ReadOnlyBufferException(); - } - - public CharBuffer put (int index, char c) { - throw new ReadOnlyBufferException(); - } - - public final CharBuffer put (char[] src, int off, int len) { - throw new ReadOnlyBufferException(); - } - - public final CharBuffer put (CharBuffer src) { - throw new ReadOnlyBufferException(); - } - - public CharBuffer put (String src, int start, int end) { - if ((start < 0) || (end < 0) || (long)start + (long)end > src.length()) { - throw new IndexOutOfBoundsException(); - } - throw new ReadOnlyBufferException(); - } - - public CharBuffer slice () { - return new ReadOnlyCharArrayBuffer(remaining(), backingArray, offset + position); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyDoubleArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyDoubleArrayBuffer.java deleted file mode 100644 index 372ac4e3..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyDoubleArrayBuffer.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** DoubleArrayBuffer, ReadWriteDoubleArrayBuffer and ReadOnlyDoubleArrayBuffer compose the implementation of array based double - * buffers. - *

- * ReadOnlyDoubleArrayBuffer extends DoubleArrayBuffer with all the write methods throwing read only exception. - *

- *

- * This class is marked final for runtime performance. - *

*/ -final class ReadOnlyDoubleArrayBuffer extends DoubleArrayBuffer { - - static ReadOnlyDoubleArrayBuffer copy (DoubleArrayBuffer other, int markOfOther) { - ReadOnlyDoubleArrayBuffer buf = new ReadOnlyDoubleArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadOnlyDoubleArrayBuffer (int capacity, double[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public DoubleBuffer asReadOnlyBuffer () { - return duplicate(); - } - - public DoubleBuffer compact () { - throw new ReadOnlyBufferException(); - } - - public DoubleBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return true; - } - - protected double[] protectedArray () { - throw new ReadOnlyBufferException(); - } - - protected int protectedArrayOffset () { - throw new ReadOnlyBufferException(); - } - - protected boolean protectedHasArray () { - return false; - } - - public DoubleBuffer put (double c) { - throw new ReadOnlyBufferException(); - } - - public DoubleBuffer put (int index, double c) { - throw new ReadOnlyBufferException(); - } - - public final DoubleBuffer put (double[] src, int off, int len) { - throw new ReadOnlyBufferException(); - } - - public final DoubleBuffer put (DoubleBuffer buf) { - throw new ReadOnlyBufferException(); - } - - public DoubleBuffer slice () { - return new ReadOnlyDoubleArrayBuffer(remaining(), backingArray, offset + position); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyFloatArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyFloatArrayBuffer.java deleted file mode 100644 index 9bb46e2c..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyFloatArrayBuffer.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** FloatArrayBuffer, ReadWriteFloatArrayBuffer and ReadOnlyFloatArrayBuffer compose the implementation of array based float - * buffers. - *

- * ReadOnlyFloatArrayBuffer extends FloatArrayBuffer with all the write methods throwing read only exception. - *

- *

- * This class is marked final for runtime performance. - *

*/ -final class ReadOnlyFloatArrayBuffer extends FloatArrayBuffer { - - static ReadOnlyFloatArrayBuffer copy (FloatArrayBuffer other, int markOfOther) { - ReadOnlyFloatArrayBuffer buf = new ReadOnlyFloatArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadOnlyFloatArrayBuffer (int capacity, float[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public FloatBuffer asReadOnlyBuffer () { - return duplicate(); - } - - public FloatBuffer compact () { - throw new ReadOnlyBufferException(); - } - - public FloatBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return true; - } - - protected float[] protectedArray () { - throw new ReadOnlyBufferException(); - } - - protected int protectedArrayOffset () { - throw new ReadOnlyBufferException(); - } - - protected boolean protectedHasArray () { - return false; - } - - public FloatBuffer put (float c) { - throw new ReadOnlyBufferException(); - } - - public FloatBuffer put (int index, float c) { - throw new ReadOnlyBufferException(); - } - - public FloatBuffer put (FloatBuffer buf) { - throw new ReadOnlyBufferException(); - } - - public final FloatBuffer put (float[] src, int off, int len) { - throw new ReadOnlyBufferException(); - } - - public FloatBuffer slice () { - return new ReadOnlyFloatArrayBuffer(remaining(), backingArray, offset + position); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyHeapByteBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyHeapByteBuffer.java deleted file mode 100644 index 5e6a4671..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyHeapByteBuffer.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** HeapByteBuffer, ReadWriteHeapByteBuffer and ReadOnlyHeapByteBuffer compose the implementation of array based byte buffers. - *

- * ReadOnlyHeapByteBuffer extends HeapByteBuffer with all the write methods throwing read only exception. - *

- *

- * This class is marked final for runtime performance. - *

*/ -final class ReadOnlyHeapByteBuffer extends HeapByteBuffer { - - static ReadOnlyHeapByteBuffer copy (HeapByteBuffer other, int markOfOther) { - ReadOnlyHeapByteBuffer buf = new ReadOnlyHeapByteBuffer(other.backingArray, other.capacity(), other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - buf.order(other.order()); - return buf; - } - - ReadOnlyHeapByteBuffer (byte[] backingArray, int capacity, int arrayOffset) { - super(backingArray, capacity, arrayOffset); - } - - public ByteBuffer asReadOnlyBuffer () { - return copy(this, mark); - } - - public ByteBuffer compact () { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return true; - } - - protected byte[] protectedArray () { - throw new ReadOnlyBufferException(); - } - - protected int protectedArrayOffset () { - throw new ReadOnlyBufferException(); - } - - protected boolean protectedHasArray () { - return false; - } - - public ByteBuffer put (byte b) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer put (int index, byte b) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer put (byte[] src, int off, int len) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putDouble (double value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putDouble (int index, double value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putFloat (float value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putFloat (int index, float value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putInt (int value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putInt (int index, int value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putLong (int index, long value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putLong (long value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putShort (int index, short value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putShort (short value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer put (ByteBuffer buf) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer slice () { - ReadOnlyHeapByteBuffer slice = new ReadOnlyHeapByteBuffer(backingArray, remaining(), offset + position); - slice.order = order; - return slice; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyIntArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyIntArrayBuffer.java deleted file mode 100644 index 228db222..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyIntArrayBuffer.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** IntArrayBuffer, ReadWriteIntArrayBuffer and ReadOnlyIntArrayBuffer compose the implementation of array based int buffers. - *

- * ReadOnlyIntArrayBuffer extends IntArrayBuffer with all the write methods throwing read only exception. - *

- *

- * This class is marked final for runtime performance. - *

*/ -final class ReadOnlyIntArrayBuffer extends IntArrayBuffer { - - static ReadOnlyIntArrayBuffer copy (IntArrayBuffer other, int markOfOther) { - ReadOnlyIntArrayBuffer buf = new ReadOnlyIntArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadOnlyIntArrayBuffer (int capacity, int[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public IntBuffer asReadOnlyBuffer () { - return duplicate(); - } - - public IntBuffer compact () { - throw new ReadOnlyBufferException(); - } - - public IntBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return true; - } - - protected int[] protectedArray () { - throw new ReadOnlyBufferException(); - } - - protected int protectedArrayOffset () { - throw new ReadOnlyBufferException(); - } - - protected boolean protectedHasArray () { - return false; - } - - public IntBuffer put (int c) { - throw new ReadOnlyBufferException(); - } - - public IntBuffer put (int index, int c) { - throw new ReadOnlyBufferException(); - } - - public IntBuffer put (IntBuffer buf) { - throw new ReadOnlyBufferException(); - } - - public final IntBuffer put (int[] src, int off, int len) { - throw new ReadOnlyBufferException(); - } - - public IntBuffer slice () { - return new ReadOnlyIntArrayBuffer(remaining(), backingArray, offset + position); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyLongArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyLongArrayBuffer.java deleted file mode 100644 index bca9209b..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyLongArrayBuffer.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** LongArrayBuffer, ReadWriteLongArrayBuffer and ReadOnlyLongArrayBuffer compose the implementation of array based long buffers. - *

- * ReadOnlyLongArrayBuffer extends LongArrayBuffer with all the write methods throwing read only exception. - *

- *

- * This class is marked final for runtime performance. - *

*/ -final class ReadOnlyLongArrayBuffer extends LongArrayBuffer { - - static ReadOnlyLongArrayBuffer copy (LongArrayBuffer other, int markOfOther) { - ReadOnlyLongArrayBuffer buf = new ReadOnlyLongArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadOnlyLongArrayBuffer (int capacity, long[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public LongBuffer asReadOnlyBuffer () { - return duplicate(); - } - - public LongBuffer compact () { - throw new ReadOnlyBufferException(); - } - - public LongBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return true; - } - - protected long[] protectedArray () { - throw new ReadOnlyBufferException(); - } - - protected int protectedArrayOffset () { - throw new ReadOnlyBufferException(); - } - - protected boolean protectedHasArray () { - return false; - } - - public LongBuffer put (long c) { - throw new ReadOnlyBufferException(); - } - - public LongBuffer put (int index, long c) { - throw new ReadOnlyBufferException(); - } - - public LongBuffer put (LongBuffer buf) { - throw new ReadOnlyBufferException(); - } - - public final LongBuffer put (long[] src, int off, int len) { - throw new ReadOnlyBufferException(); - } - - public LongBuffer slice () { - return new ReadOnlyLongArrayBuffer(remaining(), backingArray, offset + position); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyShortArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyShortArrayBuffer.java deleted file mode 100644 index 7d9dbda5..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyShortArrayBuffer.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** ShortArrayBuffer, ReadWriteShortArrayBuffer and ReadOnlyShortArrayBuffer compose the implementation of array based short - * buffers. - *

- * ReadOnlyShortArrayBuffer extends ShortArrayBuffer with all the write methods throwing read only exception. - *

- *

- * This class is marked final for runtime performance. - *

*/ -final class ReadOnlyShortArrayBuffer extends ShortArrayBuffer { - - static ReadOnlyShortArrayBuffer copy (ShortArrayBuffer other, int markOfOther) { - ReadOnlyShortArrayBuffer buf = new ReadOnlyShortArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadOnlyShortArrayBuffer (int capacity, short[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public ShortBuffer asReadOnlyBuffer () { - return duplicate(); - } - - public ShortBuffer compact () { - throw new ReadOnlyBufferException(); - } - - public ShortBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return true; - } - - protected short[] protectedArray () { - throw new ReadOnlyBufferException(); - } - - protected int protectedArrayOffset () { - throw new ReadOnlyBufferException(); - } - - protected boolean protectedHasArray () { - return false; - } - - public ShortBuffer put (ShortBuffer buf) { - throw new ReadOnlyBufferException(); - } - - public ShortBuffer put (short c) { - throw new ReadOnlyBufferException(); - } - - public ShortBuffer put (int index, short c) { - throw new ReadOnlyBufferException(); - } - - public final ShortBuffer put (short[] src, int off, int len) { - throw new ReadOnlyBufferException(); - } - - public ShortBuffer slice () { - return new ReadOnlyShortArrayBuffer(remaining(), backingArray, offset + position); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteCharArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadWriteCharArrayBuffer.java deleted file mode 100644 index 3c1b55e4..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteCharArrayBuffer.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** CharArrayBuffer, ReadWriteCharArrayBuffer and ReadOnlyCharArrayBuffer compose the implementation of array based char buffers. - *

- * ReadWriteCharArrayBuffer extends CharArrayBuffer with all the write methods. - *

- *

- * This class is marked final for runtime performance. - *

*/ -final class ReadWriteCharArrayBuffer extends CharArrayBuffer { - - static ReadWriteCharArrayBuffer copy (CharArrayBuffer other, int markOfOther) { - ReadWriteCharArrayBuffer buf = new ReadWriteCharArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadWriteCharArrayBuffer (char[] array) { - super(array); - } - - ReadWriteCharArrayBuffer (int capacity) { - super(capacity); - } - - ReadWriteCharArrayBuffer (int capacity, char[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public CharBuffer asReadOnlyBuffer () { - return ReadOnlyCharArrayBuffer.copy(this, mark); - } - - public CharBuffer compact () { - System.arraycopy(backingArray, position + offset, backingArray, offset, remaining()); - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - public CharBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return false; - } - - protected char[] protectedArray () { - return backingArray; - } - - protected int protectedArrayOffset () { - return offset; - } - - protected boolean protectedHasArray () { - return true; - } - - public CharBuffer put (char c) { - if (position == limit) { - throw new BufferOverflowException(); - } - backingArray[offset + position++] = c; - return this; - } - - public CharBuffer put (int index, char c) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - backingArray[offset + index] = c; - return this; - } - - public CharBuffer put (char[] src, int off, int len) { - int length = src.length; - if (off < 0 || len < 0 || (long)len + (long)off > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferOverflowException(); - } - System.arraycopy(src, off, backingArray, offset + position, len); - position += len; - return this; - } - - public CharBuffer slice () { - return new ReadWriteCharArrayBuffer(remaining(), backingArray, offset + position); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteDoubleArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadWriteDoubleArrayBuffer.java deleted file mode 100644 index 336a0010..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteDoubleArrayBuffer.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** DoubleArrayBuffer, ReadWriteDoubleArrayBuffer and ReadOnlyDoubleArrayBuffer compose the implementation of array based double - * buffers. - *

- * ReadWriteDoubleArrayBuffer extends DoubleArrayBuffer with all the write methods. - *

- *

- * This class is marked final for runtime performance. - *

*/ -final class ReadWriteDoubleArrayBuffer extends DoubleArrayBuffer { - - static ReadWriteDoubleArrayBuffer copy (DoubleArrayBuffer other, int markOfOther) { - ReadWriteDoubleArrayBuffer buf = new ReadWriteDoubleArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadWriteDoubleArrayBuffer (double[] array) { - super(array); - } - - ReadWriteDoubleArrayBuffer (int capacity) { - super(capacity); - } - - ReadWriteDoubleArrayBuffer (int capacity, double[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public DoubleBuffer asReadOnlyBuffer () { - return ReadOnlyDoubleArrayBuffer.copy(this, mark); - } - - public DoubleBuffer compact () { - System.arraycopy(backingArray, position + offset, backingArray, offset, remaining()); - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - public DoubleBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return false; - } - - protected double[] protectedArray () { - return backingArray; - } - - protected int protectedArrayOffset () { - return offset; - } - - protected boolean protectedHasArray () { - return true; - } - - public DoubleBuffer put (double c) { - if (position == limit) { - throw new BufferOverflowException(); - } - backingArray[offset + position++] = c; - return this; - } - - public DoubleBuffer put (int index, double c) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - backingArray[offset + index] = c; - return this; - } - - public DoubleBuffer put (double[] src, int off, int len) { - int length = src.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferOverflowException(); - } - System.arraycopy(src, off, backingArray, offset + position, len); - position += len; - return this; - } - - public DoubleBuffer slice () { - return new ReadWriteDoubleArrayBuffer(remaining(), backingArray, offset + position); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteFloatArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadWriteFloatArrayBuffer.java deleted file mode 100644 index 87935220..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteFloatArrayBuffer.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** FloatArrayBuffer, ReadWriteFloatArrayBuffer and ReadOnlyFloatArrayBuffer compose the implementation of array based float - * buffers. - *

- * ReadWriteFloatArrayBuffer extends FloatArrayBuffer with all the write methods. - *

- *

- * This class is marked final for runtime performance. - *

*/ -final class ReadWriteFloatArrayBuffer extends FloatArrayBuffer { - - static ReadWriteFloatArrayBuffer copy (FloatArrayBuffer other, int markOfOther) { - ReadWriteFloatArrayBuffer buf = new ReadWriteFloatArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadWriteFloatArrayBuffer (float[] array) { - super(array); - } - - ReadWriteFloatArrayBuffer (int capacity) { - super(capacity); - } - - ReadWriteFloatArrayBuffer (int capacity, float[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public FloatBuffer asReadOnlyBuffer () { - return ReadOnlyFloatArrayBuffer.copy(this, mark); - } - - public FloatBuffer compact () { -// System.arraycopy(backingArray, position + offset, backingArray, offset, remaining()); - for (int i = position + offset, j = offset, k = 0; k < remaining(); i++, j++, k++) { - backingArray[j] = backingArray[i]; - } - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - public FloatBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return false; - } - - protected float[] protectedArray () { - return backingArray; - } - - protected int protectedArrayOffset () { - return offset; - } - - protected boolean protectedHasArray () { - return true; - } - - public FloatBuffer put (float c) { - if (position == limit) { - throw new BufferOverflowException(); - } - backingArray[offset + position++] = c; - return this; - } - - public FloatBuffer put (int index, float c) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - backingArray[offset + index] = c; - return this; - } - - public FloatBuffer put (float[] src, int off, int len) { - int length = src.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferOverflowException(); - } - System.arraycopy(src, off, backingArray, offset + position, len); - position += len; - return this; - } - - public FloatBuffer slice () { - return new ReadWriteFloatArrayBuffer(remaining(), backingArray, offset + position); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteHeapByteBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadWriteHeapByteBuffer.java deleted file mode 100644 index 72becafd..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteHeapByteBuffer.java +++ /dev/null @@ -1,196 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -import java.io.Numbers; - -/** HeapByteBuffer, ReadWriteHeapByteBuffer and ReadOnlyHeapByteBuffer compose the implementation of array based byte buffers. - *

- * ReadWriteHeapByteBuffer extends HeapByteBuffer with all the write methods. - *

- *

- * This class is marked final for runtime performance. - *

*/ -final class ReadWriteHeapByteBuffer extends HeapByteBuffer { - - static ReadWriteHeapByteBuffer copy (HeapByteBuffer other, int markOfOther) { - ReadWriteHeapByteBuffer buf = new ReadWriteHeapByteBuffer(other.backingArray, other.capacity(), other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - buf.order(other.order()); - return buf; - } - - ReadWriteHeapByteBuffer (byte[] backingArray) { - super(backingArray); - } - - ReadWriteHeapByteBuffer (int capacity) { - super(capacity); - } - - ReadWriteHeapByteBuffer (byte[] backingArray, int capacity, int arrayOffset) { - super(backingArray, capacity, arrayOffset); - } - - public ByteBuffer asReadOnlyBuffer () { - return ReadOnlyHeapByteBuffer.copy(this, mark); - } - - public ByteBuffer compact () { - System.arraycopy(backingArray, position + offset, backingArray, offset, remaining()); - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - public ByteBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return false; - } - - protected byte[] protectedArray () { - return backingArray; - } - - protected int protectedArrayOffset () { - return offset; - } - - protected boolean protectedHasArray () { - return true; - } - - public ByteBuffer put (byte b) { - if (position == limit) { - throw new BufferOverflowException(); - } - backingArray[offset + position++] = b; - return this; - } - - public ByteBuffer put (int index, byte b) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - backingArray[offset + index] = b; - return this; - } - - /* - * Override ByteBuffer.put(byte[], int, int) to improve performance. - * - * (non-Javadoc) - * - * @see java.nio.ByteBuffer#put(byte[], int, int) - */ - public ByteBuffer put (byte[] src, int off, int len) { - if (off < 0 || len < 0 || (long)off + (long)len > src.length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferOverflowException(); - } - if (isReadOnly()) { - throw new ReadOnlyBufferException(); - } - System.arraycopy(src, off, backingArray, offset + position, len); - position += len; - return this; - } - - public ByteBuffer putDouble (double value) { - return putLong(Numbers.doubleToRawLongBits(value)); - } - - public ByteBuffer putDouble (int index, double value) { - return putLong(index, Numbers.doubleToRawLongBits(value)); - } - - public ByteBuffer putFloat (float value) { - return putInt(Numbers.floatToIntBits(value)); - } - - public ByteBuffer putFloat (int index, float value) { - return putInt(index, Numbers.floatToIntBits(value)); - } - - public ByteBuffer putInt (int value) { - int newPosition = position + 4; - if (newPosition > limit) { - throw new BufferOverflowException(); - } - store(position, value); - position = newPosition; - return this; - } - - public ByteBuffer putInt (int index, int value) { - if (index < 0 || (long)index + 4 > limit) { - throw new IndexOutOfBoundsException(); - } - store(index, value); - return this; - } - - public ByteBuffer putLong (int index, long value) { - if (index < 0 || (long)index + 8 > limit) { - throw new IndexOutOfBoundsException(); - } - store(index, value); - return this; - } - - public ByteBuffer putLong (long value) { - int newPosition = position + 8; - if (newPosition > limit) { - throw new BufferOverflowException(); - } - store(position, value); - position = newPosition; - return this; - } - - public ByteBuffer putShort (int index, short value) { - if (index < 0 || (long)index + 2 > limit) { - throw new IndexOutOfBoundsException(); - } - store(index, value); - return this; - } - - public ByteBuffer putShort (short value) { - int newPosition = position + 2; - if (newPosition > limit) { - throw new BufferOverflowException(); - } - store(position, value); - position = newPosition; - return this; - } - - public ByteBuffer slice () { - ReadWriteHeapByteBuffer slice = new ReadWriteHeapByteBuffer(backingArray, remaining(), offset + position); - slice.order = order; - return slice; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteIntArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadWriteIntArrayBuffer.java deleted file mode 100644 index 34592717..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteIntArrayBuffer.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** IntArrayBuffer, ReadWriteIntArrayBuffer and ReadOnlyIntArrayBuffer compose the implementation of array based int buffers. - *

- * ReadWriteIntArrayBuffer extends IntArrayBuffer with all the write methods. - *

- *

- * This class is marked final for runtime performance. - *

*/ -final class ReadWriteIntArrayBuffer extends IntArrayBuffer { - - static ReadWriteIntArrayBuffer copy (IntArrayBuffer other, int markOfOther) { - ReadWriteIntArrayBuffer buf = new ReadWriteIntArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadWriteIntArrayBuffer (int[] array) { - super(array); - } - - ReadWriteIntArrayBuffer (int capacity) { - super(capacity); - } - - ReadWriteIntArrayBuffer (int capacity, int[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public IntBuffer asReadOnlyBuffer () { - return ReadOnlyIntArrayBuffer.copy(this, mark); - } - - public IntBuffer compact () { - System.arraycopy(backingArray, position + offset, backingArray, offset, remaining()); - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - public IntBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return false; - } - - protected int[] protectedArray () { - return backingArray; - } - - protected int protectedArrayOffset () { - return offset; - } - - protected boolean protectedHasArray () { - return true; - } - - public IntBuffer put (int c) { - if (position == limit) { - throw new BufferOverflowException(); - } - backingArray[offset + position++] = c; - return this; - } - - public IntBuffer put (int index, int c) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - backingArray[offset + index] = c; - return this; - } - - public IntBuffer put (int[] src, int off, int len) { - int length = src.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferOverflowException(); - } - System.arraycopy(src, off, backingArray, offset + position, len); - position += len; - return this; - } - - public IntBuffer slice () { - return new ReadWriteIntArrayBuffer(remaining(), backingArray, offset + position); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteLongArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadWriteLongArrayBuffer.java deleted file mode 100644 index bff78528..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteLongArrayBuffer.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** LongArrayBuffer, ReadWriteLongArrayBuffer and ReadOnlyLongArrayBuffer compose the implementation of array based long buffers. - *

- * ReadWriteLongArrayBuffer extends LongArrayBuffer with all the write methods. - *

- *

- * This class is marked final for runtime performance. - *

*/ -final class ReadWriteLongArrayBuffer extends LongArrayBuffer { - - static ReadWriteLongArrayBuffer copy (LongArrayBuffer other, int markOfOther) { - ReadWriteLongArrayBuffer buf = new ReadWriteLongArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadWriteLongArrayBuffer (long[] array) { - super(array); - } - - ReadWriteLongArrayBuffer (int capacity) { - super(capacity); - } - - ReadWriteLongArrayBuffer (int capacity, long[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public LongBuffer asReadOnlyBuffer () { - return ReadOnlyLongArrayBuffer.copy(this, mark); - } - - public LongBuffer compact () { - System.arraycopy(backingArray, position + offset, backingArray, offset, remaining()); - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - public LongBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return false; - } - - protected long[] protectedArray () { - return backingArray; - } - - protected int protectedArrayOffset () { - return offset; - } - - protected boolean protectedHasArray () { - return true; - } - - public LongBuffer put (long c) { - if (position == limit) { - throw new BufferOverflowException(); - } - backingArray[offset + position++] = c; - return this; - } - - public LongBuffer put (int index, long c) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - backingArray[offset + index] = c; - return this; - } - - public LongBuffer put (long[] src, int off, int len) { - int length = src.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferOverflowException(); - } - System.arraycopy(src, off, backingArray, offset + position, len); - position += len; - return this; - } - - public LongBuffer slice () { - return new ReadWriteLongArrayBuffer(remaining(), backingArray, offset + position); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteShortArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadWriteShortArrayBuffer.java deleted file mode 100644 index 7c32bcce..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteShortArrayBuffer.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** ShortArrayBuffer, ReadWriteShortArrayBuffer and ReadOnlyShortArrayBuffer compose the implementation of array based short - * buffers. - *

- * ReadWriteShortArrayBuffer extends ShortArrayBuffer with all the write methods. - *

- *

- * This class is marked final for runtime performance. - *

*/ -final class ReadWriteShortArrayBuffer extends ShortArrayBuffer { - - static ReadWriteShortArrayBuffer copy (ShortArrayBuffer other, int markOfOther) { - ReadWriteShortArrayBuffer buf = new ReadWriteShortArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadWriteShortArrayBuffer (short[] array) { - super(array); - } - - ReadWriteShortArrayBuffer (int capacity) { - super(capacity); - } - - ReadWriteShortArrayBuffer (int capacity, short[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public ShortBuffer asReadOnlyBuffer () { - return ReadOnlyShortArrayBuffer.copy(this, mark); - } - - public ShortBuffer compact () { - System.arraycopy(backingArray, position + offset, backingArray, offset, remaining()); - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - public ShortBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return false; - } - - protected short[] protectedArray () { - return backingArray; - } - - protected int protectedArrayOffset () { - return offset; - } - - protected boolean protectedHasArray () { - return true; - } - - public ShortBuffer put (short c) { - if (position == limit) { - throw new BufferOverflowException(); - } - backingArray[offset + position++] = c; - return this; - } - - public ShortBuffer put (int index, short c) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - backingArray[offset + index] = c; - return this; - } - - public ShortBuffer put (short[] src, int off, int len) { - int length = src.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferOverflowException(); - } - System.arraycopy(src, off, backingArray, offset + position, len); - position += len; - return this; - } - - public ShortBuffer slice () { - return new ReadWriteShortArrayBuffer(remaining(), backingArray, offset + position); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ShortArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ShortArrayBuffer.java deleted file mode 100644 index fce335df..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ShortArrayBuffer.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** ShortArrayBuffer, ReadWriteShortArrayBuffer and ReadOnlyShortArrayBuffer compose the implementation of array based short - * buffers. - *

- * ShortArrayBuffer implements all the shared readonly methods and is extended by the other two classes. - *

- *

- * All methods are marked final for runtime performance. - *

*/ -abstract class ShortArrayBuffer extends ShortBuffer { - - protected final short[] backingArray; - - protected final int offset; - - ShortArrayBuffer (short[] array) { - this(array.length, array, 0); - } - - ShortArrayBuffer (int capacity) { - this(capacity, new short[capacity], 0); - } - - ShortArrayBuffer (int capacity, short[] backingArray, int offset) { - super(capacity); - this.backingArray = backingArray; - this.offset = offset; - } - - public final short get () { - if (position == limit) { - throw new BufferUnderflowException(); - } - return backingArray[offset + position++]; - } - - public final short get (int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return backingArray[offset + index]; - } - - public final ShortBuffer get (short[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferUnderflowException(); - } - System.arraycopy(backingArray, offset + position, dest, off, len); - position += len; - return this; - } - - public final boolean isDirect () { - return false; - } - - public final ByteOrder order () { - return ByteOrder.nativeOrder(); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ShortBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ShortBuffer.java deleted file mode 100644 index 817cc48e..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ShortBuffer.java +++ /dev/null @@ -1,427 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** A buffer of shorts. - *

- * A short buffer can be created in either of the following ways: - *

- *
    - *
  • {@link #allocate(int) Allocate} a new short array and create a buffer based on it;
  • - *
  • {@link #wrap(short[]) Wrap} an existing short array to create a new buffer;
  • - *
  • Use {@link java.nio.ByteBuffer#asShortBuffer() ByteBuffer.asShortBuffer} to create a short buffer based on a byte buffer.
  • - *
- * - * @since Android 1.0 */ -public abstract class ShortBuffer extends Buffer implements Comparable { - - /** Creates a short buffer based on a newly allocated short array. - * - * @param capacity the capacity of the new buffer. - * @return the created short buffer. - * @throws IllegalArgumentException if {@code capacity} is less than zero. - * @since Android 1.0 */ - public static ShortBuffer allocate (int capacity) { - if (capacity < 0) { - throw new IllegalArgumentException(); - } - return BufferFactory.newShortBuffer(capacity); - } - - /** Creates a new short buffer by wrapping the given short array. - *

- * Calling this method has the same effect as {@code wrap(array, 0, array.length)}. - *

- * - * @param array the short array which the new buffer will be based on. - * @return the created short buffer. - * @since Android 1.0 */ - public static ShortBuffer wrap (short[] array) { - return wrap(array, 0, array.length); - } - - /** Creates a new short buffer by wrapping the given short array. - *

- * The new buffer's position will be {@code start}, limit will be {@code start + len}, capacity will be the length of the array. - *

- * - * @param array the short array which the new buffer will be based on. - * @param start the start index, must not be negative and not greater than {@code array.length}. - * @param len the length, must not be negative and not greater than {@code array.length - start}. - * @return the created short buffer. - * @exception IndexOutOfBoundsException if either {@code start} or {@code len} is invalid. - * @since Android 1.0 */ - public static ShortBuffer wrap (short[] array, int start, int len) { - if (array == null) { - throw new NullPointerException(); - } - if (start < 0 || len < 0 || (long)start + (long)len > array.length) { - throw new IndexOutOfBoundsException(); - } - - ShortBuffer buf = BufferFactory.newShortBuffer(array); - buf.position = start; - buf.limit = start + len; - - return buf; - } - - /** Constructs a {@code ShortBuffer} with given capacity. - * - * @param capacity The capacity of the buffer */ - ShortBuffer (int capacity) { - super(capacity); - } - - /** Returns the short array which this buffer is based on, if there is one. - * - * @return the short array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final short[] array () { - return protectedArray(); - } - - /** Returns the offset of the short array which this buffer is based on, if there is one. - *

- * The offset is the index of the array corresponding to the zero position of the buffer. - *

- * - * @return the offset of the short array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final int arrayOffset () { - return protectedArrayOffset(); - } - - /** Returns a read-only buffer that shares its content with this buffer. - *

- * The returned buffer is guaranteed to be a new instance, even if this buffer is read-only itself. The new buffer's position, - * limit, capacity and mark are the same as this buffer's. - *

- *

- * The new buffer shares its content with this buffer, which means this buffer's change of content will be visible to the new - * buffer. The two buffer's position, limit and mark are independent. - *

- * - * @return a read-only version of this buffer. - * @since Android 1.0 */ - public abstract ShortBuffer asReadOnlyBuffer (); - - /** Compacts this short buffer. - *

- * The remaining shorts will be moved to the head of the buffer, starting from position zero. Then the position is set to - * {@code remaining()}; the limit is set to capacity; the mark is cleared. - *

- * - * @return this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ShortBuffer compact (); - - /** Compare the remaining shorts of this buffer to another short buffer's remaining shorts. - * - * @param otherBuffer another short buffer. - * @return a negative value if this is less than {@code otherBuffer}; 0 if this equals to {@code otherBuffer}; a positive value - * if this is greater than {@code otherBuffer}. - * @exception ClassCastException if {@code otherBuffer} is not a short buffer. - * @since Android 1.0 */ - public int compareTo (ShortBuffer otherBuffer) { - int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining() : otherBuffer.remaining(); - int thisPos = position; - int otherPos = otherBuffer.position; - short thisByte, otherByte; - while (compareRemaining > 0) { - thisByte = get(thisPos); - otherByte = otherBuffer.get(otherPos); - if (thisByte != otherByte) { - return thisByte < otherByte ? -1 : 1; - } - thisPos++; - otherPos++; - compareRemaining--; - } - return remaining() - otherBuffer.remaining(); - } - - /** Returns a duplicated buffer that shares its content with this buffer. - *

- * The duplicated buffer's position, limit, capacity and mark are the same as this buffer. The duplicated buffer's read-only - * property and byte order are the same as this buffer's. - *

- *

- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *

- * - * @return a duplicated buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract ShortBuffer duplicate (); - - /** Checks whether this short buffer is equal to another object. - *

- * If {@code other} is not a short buffer then {@code false} is returned. Two short buffers are equal if and only if their - * remaining shorts are exactly the same. Position, limit, capacity and mark are not considered. - *

- * - * @param other the object to compare with this short buffer. - * @return {@code true} if this short buffer is equal to {@code other}, {@code false} otherwise. - * @since Android 1.0 */ - public boolean equals (Object other) { - if (!(other instanceof ShortBuffer)) { - return false; - } - ShortBuffer otherBuffer = (ShortBuffer)other; - - if (remaining() != otherBuffer.remaining()) { - return false; - } - - int myPosition = position; - int otherPosition = otherBuffer.position; - boolean equalSoFar = true; - while (equalSoFar && (myPosition < limit)) { - equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++); - } - - return equalSoFar; - } - - /** Returns the short at the current position and increases the position by 1. - * - * @return the short at the current position. - * @exception BufferUnderflowException if the position is equal or greater than limit. - * @since Android 1.0 */ - public abstract short get (); - - /** Reads shorts from the current position into the specified short array and increases the position by the number of shorts - * read. - *

- * Calling this method has the same effect as {@code get(dest, 0, dest.length)}. - *

- * - * @param dest the destination short array. - * @return this buffer. - * @exception BufferUnderflowException if {@code dest.length} is greater than {@code remaining()}. - * @since Android 1.0 */ - public ShortBuffer get (short[] dest) { - return get(dest, 0, dest.length); - } - - /** Reads shorts from the current position into the specified short array, starting from the specified offset, and increases the - * position by the number of shorts read. - * - * @param dest the target short array. - * @param off the offset of the short array, must not be negative and not greater than {@code dest.length}. - * @param len the number of shorts to read, must be no less than zero and not greater than {@code dest.length - off}. - * @return this buffer. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception BufferUnderflowException if {@code len} is greater than {@code remaining()}. - * @since Android 1.0 */ - public ShortBuffer get (short[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferUnderflowException(); - } - for (int i = off; i < off + len; i++) { - dest[i] = get(); - } - return this; - } - - /** Returns the short at the specified index; the position is not changed. - * - * @param index the index, must not be negative and less than limit. - * @return a short at the specified index. - * @exception IndexOutOfBoundsException if index is invalid. - * @since Android 1.0 */ - public abstract short get (int index); - - /** Indicates whether this buffer is based on a short array and is read/write. - * - * @return {@code true} if this buffer is based on a short array and provides read/write access, {@code false} otherwise. - * @since Android 1.0 */ - public final boolean hasArray () { - return protectedHasArray(); - } - - /** Calculates this buffer's hash code from the remaining chars. The position, limit, capacity and mark don't affect the hash - * code. - * - * @return the hash code calculated from the remaining shorts. - * @since Android 1.0 */ - public int hashCode () { - int myPosition = position; - int hash = 0; - while (myPosition < limit) { - hash = hash + get(myPosition++); - } - return hash; - } - - /** Indicates whether this buffer is direct. A direct buffer will try its best to take advantage of native memory APIs and it - * may not stay in the Java heap, so it is not affected by garbage collection. - *

- * A short buffer is direct if it is based on a byte buffer and the byte buffer is direct. - *

- * - * @return {@code true} if this buffer is direct, {@code false} otherwise. - * @since Android 1.0 */ - public abstract boolean isDirect (); - - /** Returns the byte order used by this buffer when converting shorts from/to bytes. - *

- * If this buffer is not based on a byte buffer, then always return the platform's native byte order. - *

- * - * @return the byte order used by this buffer when converting shorts from/to bytes. - * @since Android 1.0 */ - public abstract ByteOrder order (); - - /** Child class implements this method to realize {@code array()}. - * - * @return see {@code array()} */ - abstract short[] protectedArray (); - - /** Child class implements this method to realize {@code arrayOffset()}. - * - * @return see {@code arrayOffset()} */ - abstract int protectedArrayOffset (); - - /** Child class implements this method to realize {@code hasArray()}. - * - * @return see {@code hasArray()} */ - abstract boolean protectedHasArray (); - - /** Writes the given short to the current position and increases the position by 1. - * - * @param s the short to write. - * @return this buffer. - * @exception BufferOverflowException if position is equal or greater than limit. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ShortBuffer put (short s); - - /** Writes shorts from the given short array to the current position and increases the position by the number of shorts written. - *

- * Calling this method has the same effect as {@code put(src, 0, src.length)}. - *

- * - * @param src the source short array. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code src.length}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public final ShortBuffer put (short[] src) { - return put(src, 0, src.length); - } - - /** Writes shorts from the given short array, starting from the specified offset, to the current position and increases the - * position by the number of shorts written. - * - * @param src the source short array. - * @param off the offset of short array, must not be negative and not greater than {@code src.length}. - * @param len the number of shorts to write, must be no less than zero and not greater than {@code src.length - off}. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code len}. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public ShortBuffer put (short[] src, int off, int len) { - int length = src.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferOverflowException(); - } - for (int i = off; i < off + len; i++) { - put(src[i]); - } - return this; - } - - /** Writes all the remaining shorts of the {@code src} short buffer to this buffer's current position, and increases both - * buffers' position by the number of shorts copied. - * - * @param src the source short buffer. - * @return this buffer. - * @exception BufferOverflowException if {@code src.remaining()} is greater than this buffer's {@code remaining()}. - * @exception IllegalArgumentException if {@code src} is this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public ShortBuffer put (ShortBuffer src) { - if (src == this) { - throw new IllegalArgumentException(); - } - if (src.remaining() > remaining()) { - throw new BufferOverflowException(); - } - short[] contents = new short[src.remaining()]; - src.get(contents); - put(contents); - return this; - } - - /** Writes a short to the specified index of this buffer; the position is not changed. - * - * @param index the index, must not be negative and less than the limit. - * @param s the short to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if index is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ShortBuffer put (int index, short s); - - /** Returns a sliced buffer that shares its content with this buffer. - *

- * The sliced buffer's capacity will be this buffer's {@code remaining()}, and its zero position will correspond to this - * buffer's current position. The new buffer's position will be 0, limit will be its capacity, and its mark is cleared. The new - * buffer's read-only property and byte order are same as this buffer's. - *

- *

- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *

- * - * @return a sliced buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract ShortBuffer slice (); - - /** Returns a string representing the state of this short buffer. - * - * @return a string representing the state of this short buffer. - * @since Android 1.0 */ - public String toString () { - StringBuffer buf = new StringBuffer(); - buf.append(getClass().getName()); - buf.append(", status: capacity="); //$NON-NLS-1$ - buf.append(capacity()); - buf.append(" position="); //$NON-NLS-1$ - buf.append(position()); - buf.append(" limit="); //$NON-NLS-1$ - buf.append(limit()); - return buf.toString(); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ShortToByteBufferAdapter.java b/backends/gdx-backend-dragome/emu/java/nio/ShortToByteBufferAdapter.java deleted file mode 100644 index 868072cd..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ShortToByteBufferAdapter.java +++ /dev/null @@ -1,205 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -//import org.apache.harmony.nio.internal.DirectBuffer; -//import org.apache.harmony.luni.platform.PlatformAddress; - -/** This class wraps a byte buffer to be a short buffer. - *

- * Implementation notice: - *

    - *
  • After a byte buffer instance is wrapped, it becomes privately owned by the adapter. It must NOT be accessed outside the - * adapter any more.
  • - *
  • The byte buffer's position and limit are NOT linked with the adapter. The adapter extends Buffer, thus has its own position - * and limit.
  • - *
- *

*/ -final class ShortToByteBufferAdapter extends ShortBuffer implements ByteBufferWrapper { -// implements DirectBuffer { - - static ShortBuffer wrap (ByteBuffer byteBuffer) { - return new ShortToByteBufferAdapter(byteBuffer.slice()); - } - - private final ByteBuffer byteBuffer; - - ShortToByteBufferAdapter (ByteBuffer byteBuffer) { - super((byteBuffer.capacity() >> 1)); - this.byteBuffer = byteBuffer; - this.byteBuffer.clear(); - } - -// public int getByteCapacity() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).getByteCapacity(); -// } -// assert false : byteBuffer; -// return -1; -// } -// -// public PlatformAddress getEffectiveAddress() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).getEffectiveAddress(); -// } -// assert false : byteBuffer; -// return null; -// } -// -// public PlatformAddress getBaseAddress() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).getBaseAddress(); -// } -// assert false : byteBuffer; -// return null; -// } -// -// public boolean isAddressValid() { -// if (byteBuffer instanceof DirectBuffer) { -// return ((DirectBuffer) byteBuffer).isAddressValid(); -// } -// assert false : byteBuffer; -// return false; -// } -// -// public void addressValidityCheck() { -// if (byteBuffer instanceof DirectBuffer) { -// ((DirectBuffer) byteBuffer).addressValidityCheck(); -// } else { -// assert false : byteBuffer; -// } -// } -// -// public void free() { -// if (byteBuffer instanceof DirectBuffer) { -// ((DirectBuffer) byteBuffer).free(); -// } else { -// assert false : byteBuffer; -// } -// } - - @Override - public ShortBuffer asReadOnlyBuffer () { - ShortToByteBufferAdapter buf = new ShortToByteBufferAdapter(byteBuffer.asReadOnlyBuffer()); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public ShortBuffer compact () { - if (byteBuffer.isReadOnly()) { - throw new ReadOnlyBufferException(); - } - byteBuffer.limit(limit << 1); - byteBuffer.position(position << 1); - byteBuffer.compact(); - byteBuffer.clear(); - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - @Override - public ShortBuffer duplicate () { - ShortToByteBufferAdapter buf = new ShortToByteBufferAdapter(byteBuffer.duplicate()); - buf.limit = limit; - buf.position = position; - buf.mark = mark; - return buf; - } - - @Override - public short get () { - if (position == limit) { - throw new BufferUnderflowException(); - } - return byteBuffer.getShort(position++ << 1); - } - - @Override - public short get (int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return byteBuffer.getShort(index << 1); - } - - @Override - public boolean isDirect () { - return byteBuffer.isDirect(); - } - - @Override - public boolean isReadOnly () { - return byteBuffer.isReadOnly(); - } - - @Override - public ByteOrder order () { - return byteBuffer.order(); - } - - @Override - protected short[] protectedArray () { - throw new UnsupportedOperationException(); - } - - @Override - protected int protectedArrayOffset () { - throw new UnsupportedOperationException(); - } - - @Override - protected boolean protectedHasArray () { - return false; - } - - @Override - public ShortBuffer put (short c) { - if (position == limit) { - throw new BufferOverflowException(); - } - byteBuffer.putShort(position++ << 1, c); - return this; - } - - @Override - public ShortBuffer put (int index, short c) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - byteBuffer.putShort(index << 1, c); - return this; - } - - @Override - public ShortBuffer slice () { - byteBuffer.limit(limit << 1); - byteBuffer.position(position << 1); - ShortBuffer result = new ShortToByteBufferAdapter(byteBuffer.slice()); - byteBuffer.clear(); - return result; - } - - public ByteBuffer getByteBuffer () { - return byteBuffer; - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/StringByteBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/StringByteBuffer.java deleted file mode 100644 index 15adb0bc..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/StringByteBuffer.java +++ /dev/null @@ -1,218 +0,0 @@ -/******************************************************************************* - * Copyright 2011 See AUTHORS file. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package java.nio; - -import java.io.Numbers; - -class StringByteBuffer extends BaseByteBuffer { - - private String s; - - StringByteBuffer (String s) { - super(s.length()); - this.s = s; - order(ByteOrder.LITTLE_ENDIAN); - } - - StringByteBuffer (String s, int position, int limit) { - this(s); - this.position = position; - this.limit = limit; - } - - public ByteBuffer asReadOnlyBuffer () { - return this; - } - - byte[] protectedArray () { - throw new UnsupportedOperationException(); - } - - int protectedArrayOffset () { - throw new UnsupportedOperationException(); - } - - boolean protectedHasArray () { - throw new UnsupportedOperationException(); - } - - @Override - public ByteBuffer compact () { - return this; - } - - @Override - public ByteBuffer duplicate () { - return this; - } - - @Override - public byte get () { - return get(position++); - } - - @Override - public byte get (int index) { - return get(s, index); - } - - public final double getDouble () { - return Numbers.longBitsToDouble(getLong()); - } - - public final double getDouble (int index) { - return Numbers.longBitsToDouble(getLong(index)); - } - - public final float getFloat () { - return Numbers.intBitsToFloat(getInt()); - } - - public final float getFloat (int index) { - return Numbers.intBitsToFloat(getInt(index)); - } - - public final int getInt () { - int newPosition = position + 4; - int result = loadInt(position); - position = newPosition; - return result; - } - - public final int getInt (int index) { - return loadInt(index); - } - - public final long getLong () { - throw new UnsupportedOperationException(); - } - - public final long getLong (int index) { - throw new UnsupportedOperationException(); - } - - public final short getShort () { - int newPosition = position + 2; - short result = loadShort(position); - position = newPosition; - return result; - } - - public final short getShort (int index) { - return loadShort(index); - } - - @Override - public boolean isDirect () { - return false; - } - - @Override - public ByteBuffer put (byte b) { - throw new UnsupportedOperationException(); - } - - @Override - public ByteBuffer put (int index, byte b) { - throw new UnsupportedOperationException(); - } - - @Override - public ByteBuffer putDouble (double value) { - throw new UnsupportedOperationException(); - } - - @Override - public ByteBuffer putDouble (int index, double value) { - throw new UnsupportedOperationException(); - } - - @Override - public ByteBuffer putFloat (float value) { - throw new UnsupportedOperationException(); - } - - @Override - public ByteBuffer putFloat (int index, float value) { - throw new UnsupportedOperationException(); - } - - @Override - public ByteBuffer putInt (int value) { - throw new UnsupportedOperationException(); - } - - @Override - public ByteBuffer putInt (int index, int value) { - throw new UnsupportedOperationException(); - } - - @Override - public ByteBuffer putLong (long value) { - throw new UnsupportedOperationException(); - } - - @Override - public ByteBuffer putLong (int index, long value) { - throw new UnsupportedOperationException(); - } - - @Override - public ByteBuffer putShort (short value) { - throw new UnsupportedOperationException(); - } - - @Override - public ByteBuffer putShort (int index, short value) { - throw new UnsupportedOperationException(); - } - - @Override - public ByteBuffer slice () { - // TODO(jgw): I don't think this is right, but might work for our purposes. - StringByteBuffer slice = new StringByteBuffer(s, position, limit); - slice.order = order; - return slice; - } - - @Override - public boolean isReadOnly () { - return true; - } - - private native byte get (String s, int i) /*-{ - var x = s.charCodeAt(i) & 0xff; - if (x > 127) x -= 256; - return x; - }-*/; - - protected final int loadInt (int baseOffset) { - int bytes = 0; - for (int i = 3; i >= 0; i--) { - bytes = bytes << 8; - bytes = bytes | (get(baseOffset + i) & 0xFF); - } - return bytes; - } - - protected final short loadShort (int baseOffset) { - short bytes = 0; - bytes = (short)(get(baseOffset + 1) << 8); - bytes |= (get(baseOffset) & 0xFF); - return bytes; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/util/Locale.java b/backends/gdx-backend-dragome/emu/java/util/Locale.java deleted file mode 100644 index 466a6ed2..00000000 --- a/backends/gdx-backend-dragome/emu/java/util/Locale.java +++ /dev/null @@ -1,643 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.ObjectStreamField; -import java.io.Serializable; -//import libcore.icu.ICU; - - -/** - * {@code Locale} represents a language/country/variant combination. Locales are used to - * alter the presentation of information such as numbers or dates to suit the conventions - * in the region they describe. - * - *

The language codes are two-letter lowercase ISO language codes (such as "en") as defined by - * ISO 639-1. - * The country codes are two-letter uppercase ISO country codes (such as "US") as defined by - * ISO 3166-1. - * The variant codes are unspecified. - * - *

Note that Java uses several deprecated two-letter codes. The Hebrew ("he") language - * code is rewritten as "iw", Indonesian ("id") as "in", and Yiddish ("yi") as "ji". This - * rewriting happens even if you construct your own {@code Locale} object, not just for - * instances returned by the various lookup methods. - * - *

Available locales

- *

This class' constructors do no error checking. You can create a {@code Locale} for languages - * and countries that don't exist, and you can create instances for combinations that don't - * exist (such as "de_US" for "German as spoken in the US"). - * - *

Note that locale data is not necessarily available for any of the locales pre-defined as - * constants in this class except for en_US, which is the only locale Java guarantees is always - * available. - * - *

It is also a mistake to assume that all devices have the same locales available. - * A device sold in the US will almost certainly support en_US and es_US, but not necessarily - * any locales with the same language but different countries (such as en_GB or es_ES), - * nor any locales for other languages (such as de_DE). The opposite may well be true for a device - * sold in Europe. - * - *

You can use {@link Locale#getDefault} to get an appropriate locale for the user of the - * device you're running on, or {@link Locale#getAvailableLocales} to get a list of all the locales - * available on the device you're running on. - * - *

Locale data

- *

Note that locale data comes solely from ICU. User-supplied locale service providers (using - * the {@code java.text.spi} or {@code java.util.spi} mechanisms) are not supported. - * - *

Here are the versions of ICU (and the corresponding CLDR and Unicode versions) used in - * various Android releases: - * - * - * - * - * - * - * - *
Cupcake/Donut/Eclair ICU 3.8 CLDR 1.5 Unicode 5.0
Froyo ICU 4.2 CLDR 1.7 Unicode 5.1
Gingerbread/HoneycombICU 4.4 CLDR 1.8 Unicode 5.2
Ice Cream Sandwich ICU 4.6 CLDR 1.9 Unicode 6.0
Jelly Bean ICU 4.8 CLDR 2.0 Unicode 6.0
Jelly Bean MR2 ICU 50 CLDR 22.1 Unicode 6.2
- * - *

Be wary of the default locale

- *

Note that there are many convenience methods that automatically use the default locale, but - * using them may lead to subtle bugs. - * - *

The default locale is appropriate for tasks that involve presenting data to the user. In - * this case, you want to use the user's date/time formats, number - * formats, rules for conversion to lowercase, and so on. In this case, it's safe to use the - * convenience methods. - * - *

The default locale is not appropriate for machine-readable output. The best choice - * there is usually {@code Locale.US} – this locale is guaranteed to be available on all - * devices, and the fact that it has no surprising special cases and is frequently used (especially - * for computer-computer communication) means that it tends to be the most efficient choice too. - * - *

A common mistake is to implicitly use the default locale when producing output meant to be - * machine-readable. This tends to work on the developer's test devices (especially because so many - * developers use en_US), but fails when run on a device whose user is in a more complex locale. - * - *

For example, if you're formatting integers some locales will use non-ASCII decimal - * digits. As another example, if you're formatting floating-point numbers some locales will use - * {@code ','} as the decimal point and {@code '.'} for digit grouping. That's correct for - * human-readable output, but likely to cause problems if presented to another - * computer ({@link Double#parseDouble} can't parse such a number, for example). - * You should also be wary of the {@link String#toLowerCase} and - * {@link String#toUpperCase} overloads that don't take a {@code Locale}: in Turkey, for example, - * the characters {@code 'i'} and {@code 'I'} won't be converted to {@code 'I'} and {@code 'i'}. - * This is the correct behavior for Turkish text (such as user input), but inappropriate for, say, - * HTTP headers. - */ -public final class Locale implements Cloneable, Serializable { - - private static final long serialVersionUID = 9149081749638150636L; - - /** - * Locale constant for en_CA. - */ - public static final Locale CANADA = new Locale(true, "en", "CA"); - - /** - * Locale constant for fr_CA. - */ - public static final Locale CANADA_FRENCH = new Locale(true, "fr", "CA"); - - /** - * Locale constant for zh_CN. - */ - public static final Locale CHINA = new Locale(true, "zh", "CN"); - - /** - * Locale constant for zh. - */ - public static final Locale CHINESE = new Locale(true, "zh", ""); - - /** - * Locale constant for en. - */ - public static final Locale ENGLISH = new Locale(true, "en", ""); - - /** - * Locale constant for fr_FR. - */ - public static final Locale FRANCE = new Locale(true, "fr", "FR"); - - /** - * Locale constant for fr. - */ - public static final Locale FRENCH = new Locale(true, "fr", ""); - - /** - * Locale constant for de. - */ - public static final Locale GERMAN = new Locale(true, "de", ""); - - /** - * Locale constant for de_DE. - */ - public static final Locale GERMANY = new Locale(true, "de", "DE"); - - /** - * Locale constant for it. - */ - public static final Locale ITALIAN = new Locale(true, "it", ""); - - /** - * Locale constant for it_IT. - */ - public static final Locale ITALY = new Locale(true, "it", "IT"); - - /** - * Locale constant for ja_JP. - */ - public static final Locale JAPAN = new Locale(true, "ja", "JP"); - - /** - * Locale constant for ja. - */ - public static final Locale JAPANESE = new Locale(true, "ja", ""); - - /** - * Locale constant for ko_KR. - */ - public static final Locale KOREA = new Locale(true, "ko", "KR"); - - /** - * Locale constant for ko. - */ - public static final Locale KOREAN = new Locale(true, "ko", ""); - - /** - * Locale constant for zh_CN. - */ - public static final Locale PRC = new Locale(true, "zh", "CN"); - - /** - * Locale constant for the root locale. The root locale has an empty language, - * country, and variant. - * - * @since 1.6 - */ - public static final Locale ROOT = new Locale(true, "", ""); - - /** - * Locale constant for zh_CN. - */ - public static final Locale SIMPLIFIED_CHINESE = new Locale(true, "zh", "CN"); - - /** - * Locale constant for zh_TW. - */ - public static final Locale TAIWAN = new Locale(true, "zh", "TW"); - - /** - * Locale constant for zh_TW. - */ - public static final Locale TRADITIONAL_CHINESE = new Locale(true, "zh", "TW"); - - /** - * Locale constant for en_GB. - */ - public static final Locale UK = new Locale(true, "en", "GB"); - - /** - * Locale constant for en_US. - */ - public static final Locale US = new Locale(true, "en", "US"); - -// /** -// * The current default locale. It is temporarily assigned to US because we -// * need a default locale to lookup the real default locale. -// */ - private static Locale defaultLocale = US; - -// static { -// String language = System.getProperty("user.language", "en"); -// String region = System.getProperty("user.region", "US"); -// String variant = System.getProperty("user.variant", ""); -// defaultLocale = new Locale(language, region, variant); -// } - - private transient String countryCode; - private transient String languageCode; - private transient String variantCode; - private transient String cachedToStringResult; - - /** - * There's a circular dependency between toLowerCase/toUpperCase and - * Locale.US. Work around this by avoiding these methods when constructing - * the built-in locales. - * - * @param unused required for this constructor to have a unique signature - */ - private Locale(boolean unused, String lowerCaseLanguageCode, String upperCaseCountryCode) { - this.languageCode = lowerCaseLanguageCode; - this.countryCode = upperCaseCountryCode; - this.variantCode = ""; - } - - /** - * Constructs a new {@code Locale} using the specified language. - */ - public Locale(String language) { - this(language, "", ""); - } - - /** - * Constructs a new {@code Locale} using the specified language and country codes. - */ - public Locale(String language, String country) { - this(language, country, ""); - } - - /** - * Constructs a new {@code Locale} using the specified language, country, - * and variant codes. - */ - public Locale(String language, String country, String variant) { - if (language == null || country == null || variant == null) { - throw new NullPointerException("language=" + language + - ",country=" + country + - ",variant=" + variant); - } - if (language.isEmpty() && country.isEmpty()) { - languageCode = ""; - countryCode = ""; - variantCode = variant; - return; - } - -// languageCode = language.toLowerCase(Locale.US); // not supported by GWT - languageCode = language.toLowerCase(); - // Map new language codes to the obsolete language - // codes so the correct resource bundles will be used. - if (languageCode.equals("he")) { - languageCode = "iw"; - } else if (languageCode.equals("id")) { - languageCode = "in"; - } else if (languageCode.equals("yi")) { - languageCode = "ji"; - } - -// countryCode = country.toUpperCase(Locale.US); // not supported by GWT - countryCode = country.toUpperCase(); - - // Work around for be compatible with RI - variantCode = variant; - } - -// @Override public Object clone() { -// try { -// return super.clone(); -// } catch (CloneNotSupportedException e) { -// throw new AssertionError(e); -// } -// } - - /** - * Returns true if {@code object} is a locale with the same language, - * country and variant. - */ - @Override public boolean equals(Object object) { - if (object == this) { - return true; - } - if (object instanceof Locale) { - Locale o = (Locale) object; - return languageCode.equals(o.languageCode) - && countryCode.equals(o.countryCode) - && variantCode.equals(o.variantCode); - } - return false; - } - -// /** -// * Returns the system's installed locales. This array always includes {@code -// * Locale.US}, and usually several others. Most locale-sensitive classes -// * offer their own {@code getAvailableLocales} method, which should be -// * preferred over this general purpose method. -// * -// * @see java.text.BreakIterator#getAvailableLocales() -// * @see java.text.Collator#getAvailableLocales() -// * @see java.text.DateFormat#getAvailableLocales() -// * @see java.text.DateFormatSymbols#getAvailableLocales() -// * @see java.text.DecimalFormatSymbols#getAvailableLocales() -// * @see java.text.NumberFormat#getAvailableLocales() -// * @see java.util.Calendar#getAvailableLocales() -// */ -// public static Locale[] getAvailableLocales() { -// return ICU.getAvailableLocales(); -// } - - /** - * Returns the country code for this locale, or {@code ""} if this locale - * doesn't correspond to a specific country. - */ - public String getCountry() { - return countryCode; - } - - /** - * Returns the user's preferred locale. This may have been overridden for - * this process with {@link #setDefault}. - * - *

Since the user's locale changes dynamically, avoid caching this value. - * Instead, use this method to look it up for each use. - */ - public static Locale getDefault() { - return defaultLocale; - } - -// /** -// * Equivalent to {@code getDisplayCountry(Locale.getDefault())}. -// */ -// public final String getDisplayCountry() { -// return getDisplayCountry(getDefault()); -// } -// -// /** -// * Returns the name of this locale's country, localized to {@code locale}. -// * Returns the empty string if this locale does not correspond to a specific -// * country. -// */ -// public String getDisplayCountry(Locale locale) { -// if (countryCode.isEmpty()) { -// return ""; -// } -// String result = ICU.getDisplayCountryNative(toString(), locale.toString()); -// if (result == null) { // TODO: do we need to do this, or does ICU do it for us? -// result = ICU.getDisplayCountryNative(toString(), Locale.getDefault().toString()); -// } -// return result; -// } -// -// /** -// * Equivalent to {@code getDisplayLanguage(Locale.getDefault())}. -// */ -// public final String getDisplayLanguage() { -// return getDisplayLanguage(getDefault()); -// } -// -// /** -// * Returns the name of this locale's language, localized to {@code locale}. -// * If the language name is unknown, the language code is returned. -// */ -// public String getDisplayLanguage(Locale locale) { -// if (languageCode.isEmpty()) { -// return ""; -// } -// -// // http://b/8049507 --- frameworks/base should use fil_PH instead of tl_PH. -// // Until then, we're stuck covering their tracks, making it look like they're -// // using "fil" when they're not. -// String localeString = toString(); -// if (languageCode.equals("tl")) { -// localeString = toNewString("fil", countryCode, variantCode); -// } -// -// String result = ICU.getDisplayLanguageNative(localeString, locale.toString()); -// if (result == null) { // TODO: do we need to do this, or does ICU do it for us? -// result = ICU.getDisplayLanguageNative(localeString, Locale.getDefault().toString()); -// } -// return result; -// } -// -// /** -// * Equivalent to {@code getDisplayName(Locale.getDefault())}. -// */ -// public final String getDisplayName() { -// return getDisplayName(getDefault()); -// } -// -// /** -// * Returns this locale's language name, country name, and variant, localized -// * to {@code locale}. The exact output form depends on whether this locale -// * corresponds to a specific language, country and variant. -// * -// *

For example: -// *

    -// *
  • {@code new Locale("en").getDisplayName(Locale.US)} -> {@code English} -// *
  • {@code new Locale("en", "US").getDisplayName(Locale.US)} -> {@code English (United States)} -// *
  • {@code new Locale("en", "US", "POSIX").getDisplayName(Locale.US)} -> {@code English (United States,Computer)} -// *
  • {@code new Locale("en").getDisplayName(Locale.FRANCE)} -> {@code anglais} -// *
  • {@code new Locale("en", "US").getDisplayName(Locale.FRANCE)} -> {@code anglais (tats-Unis)} -// *
  • {@code new Locale("en", "US", "POSIX").getDisplayName(Locale.FRANCE)} -> {@code anglais (tats-Unis,informatique)}. -// *
-// */ -// public String getDisplayName(Locale locale) { -// int count = 0; -// StringBuilder buffer = new StringBuilder(); -// if (!languageCode.isEmpty()) { -// String displayLanguage = getDisplayLanguage(locale); -// buffer.append(displayLanguage.isEmpty() ? languageCode : displayLanguage); -// ++count; -// } -// if (!countryCode.isEmpty()) { -// if (count == 1) { -// buffer.append(" ("); -// } -// String displayCountry = getDisplayCountry(locale); -// buffer.append(displayCountry.isEmpty() ? countryCode : displayCountry); -// ++count; -// } -// if (!variantCode.isEmpty()) { -// if (count == 1) { -// buffer.append(" ("); -// } else if (count == 2) { -// buffer.append(","); -// } -// String displayVariant = getDisplayVariant(locale); -// buffer.append(displayVariant.isEmpty() ? variantCode : displayVariant); -// ++count; -// } -// if (count > 1) { -// buffer.append(")"); -// } -// return buffer.toString(); -// } -// -// /** -// * Returns the full variant name in the default {@code Locale} for the variant code of -// * this {@code Locale}. If there is no matching variant name, the variant code is -// * returned. -// */ -// public final String getDisplayVariant() { -// return getDisplayVariant(getDefault()); -// } -// -// /** -// * Returns the full variant name in the specified {@code Locale} for the variant code -// * of this {@code Locale}. If there is no matching variant name, the variant code is -// * returned. -// */ -// public String getDisplayVariant(Locale locale) { -// if (variantCode.length() == 0) { -// return variantCode; -// } -// String result = ICU.getDisplayVariantNative(toString(), locale.toString()); -// if (result == null) { // TODO: do we need to do this, or does ICU do it for us? -// result = ICU.getDisplayVariantNative(toString(), Locale.getDefault().toString()); -// } -// return result; -// } -// -// /** -// * Returns the three-letter ISO 3166 country code which corresponds to the country -// * code for this {@code Locale}. -// * @throws MissingResourceException if there's no 3-letter country code for this locale. -// */ -// public String getISO3Country() { -// String code = ICU.getISO3CountryNative(toString()); -// if (!countryCode.isEmpty() && code.isEmpty()) { -// throw new MissingResourceException("No 3-letter country code for locale: " + this, "FormatData_" + this, "ShortCountry"); -// } -// return code; -// } -// -// /** -// * Returns the three-letter ISO 639-2/T language code which corresponds to the language -// * code for this {@code Locale}. -// * @throws MissingResourceException if there's no 3-letter language code for this locale. -// */ -// public String getISO3Language() { -// String code = ICU.getISO3LanguageNative(toString()); -// if (!languageCode.isEmpty() && code.isEmpty()) { -// throw new MissingResourceException("No 3-letter language code for locale: " + this, "FormatData_" + this, "ShortLanguage"); -// } -// return code; -// } -// -// /** -// * Returns an array of strings containing all the two-letter ISO 3166 country codes that can be -// * used as the country code when constructing a {@code Locale}. -// */ -// public static String[] getISOCountries() { -// return ICU.getISOCountries(); -// } -// -// /** -// * Returns an array of strings containing all the two-letter ISO 639-1 language codes that can be -// * used as the language code when constructing a {@code Locale}. -// */ -// public static String[] getISOLanguages() { -// return ICU.getISOLanguages(); -// } - - /** - * Returns the language code for this {@code Locale} or the empty string if no language - * was set. - */ - public String getLanguage() { - return languageCode; - } - - /** - * Returns the variant code for this {@code Locale} or an empty {@code String} if no variant - * was set. - */ - public String getVariant() { - return variantCode; - } - - @Override - public synchronized int hashCode() { - return countryCode.hashCode() + languageCode.hashCode() - + variantCode.hashCode(); - } - - /** - * Overrides the default locale. This does not affect system configuration, - * and attempts to override the system-provided default locale may - * themselves be overridden by actual changes to the system configuration. - * Code that calls this method is usually incorrect, and should be fixed by - * passing the appropriate locale to each locale-sensitive method that's - * called. - */ - public synchronized static void setDefault(Locale locale) { - if (locale == null) { - throw new NullPointerException("locale == null"); - } - defaultLocale = locale; - } - - /** - * Returns the string representation of this {@code Locale}. It consists of the - * language code, country code and variant separated by underscores. - * If the language is missing the string begins - * with an underscore. If the country is missing there are 2 underscores - * between the language and the variant. The variant cannot stand alone - * without a language and/or country code: in this case this method would - * return the empty string. - * - *

Examples: "en", "en_US", "_US", "en__POSIX", "en_US_POSIX" - */ - @Override - public final String toString() { - String result = cachedToStringResult; - if (result == null) { - result = cachedToStringResult = toNewString(languageCode, countryCode, variantCode); - } - return result; - } - - private static String toNewString(String languageCode, String countryCode, String variantCode) { - // The string form of a locale that only has a variant is the empty string. - if (languageCode.length() == 0 && countryCode.length() == 0) { - return ""; - } - // Otherwise, the output format is "ll_cc_variant", where language and country are always - // two letters, but the variant is an arbitrary length. A size of 11 characters has room - // for "en_US_POSIX", the largest "common" value. (In practice, the string form is almost - // always 5 characters: "ll_cc".) - StringBuilder result = new StringBuilder(11); - result.append(languageCode); - if (countryCode.length() > 0 || variantCode.length() > 0) { - result.append('_'); - } - result.append(countryCode); - if (variantCode.length() > 0) { - result.append('_'); - } - result.append(variantCode); - return result.toString(); - } - -// private static final ObjectStreamField[] serialPersistentFields = { -// new ObjectStreamField("country", String.class), -// new ObjectStreamField("hashcode", int.class), -// new ObjectStreamField("language", String.class), -// new ObjectStreamField("variant", String.class), -// }; -// -// private void writeObject(ObjectOutputStream stream) throws IOException { -// ObjectOutputStream.PutField fields = stream.putFields(); -// fields.put("country", countryCode); -// fields.put("hashcode", -1); -// fields.put("language", languageCode); -// fields.put("variant", variantCode); -// stream.writeFields(); -// } -// -// private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { -// ObjectInputStream.GetField fields = stream.readFields(); -// countryCode = (String) fields.get("country", ""); -// languageCode = (String) fields.get("language", ""); -// variantCode = (String) fields.get("variant", ""); -// } -} diff --git a/backends/gdx-backend-dragome/emu/java/util/StringTokenizer.java b/backends/gdx-backend-dragome/emu/java/util/StringTokenizer.java deleted file mode 100644 index e6686e8b..00000000 --- a/backends/gdx-backend-dragome/emu/java/util/StringTokenizer.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util; - -/** - * Breaks a string into tokens; new code should probably use {@link String#split}. - * - *

- *
- * // Legacy code:
- * StringTokenizer st = new StringTokenizer("a:b:c", ":");
- * while (st.hasMoreTokens()) {
- *     System.err.println(st.nextToken());
- * }
- *
- * // New code:
- * for (String token : "a:b:c".split(":")) {
- *     System.err.println(token);
- * }
- * 
- *
- * - * @since 1.0 - */ -public class StringTokenizer implements Enumeration { - - private String string; - - private String delimiters; - - private boolean returnDelimiters; - - private int position; - - /** - * Constructs a new {@code StringTokenizer} for the parameter string using - * whitespace as the delimiter. The {@code returnDelimiters} flag is set to - * {@code false}. - * - * @param string - * the string to be tokenized. - */ - public StringTokenizer(String string) { - this(string, " \t\n\r\f", false); - } - - /** - * Constructs a new {@code StringTokenizer} for the parameter string using - * the specified delimiters. The {@code returnDelimiters} flag is set to - * {@code false}. If {@code delimiters} is {@code null}, this constructor - * doesn't throw an {@code Exception}, but later calls to some methods might - * throw a {@code NullPointerException}. - * - * @param string - * the string to be tokenized. - * @param delimiters - * the delimiters to use. - */ - public StringTokenizer(String string, String delimiters) { - this(string, delimiters, false); - } - - /** - * Constructs a new {@code StringTokenizer} for the parameter string using - * the specified delimiters, returning the delimiters as tokens if the - * parameter {@code returnDelimiters} is {@code true}. If {@code delimiters} - * is null this constructor doesn't throw an {@code Exception}, but later - * calls to some methods might throw a {@code NullPointerException}. - * - * @param string - * the string to be tokenized. - * @param delimiters - * the delimiters to use. - * @param returnDelimiters - * {@code true} to return each delimiter as a token. - */ - public StringTokenizer(String string, String delimiters, - boolean returnDelimiters) { - if (string == null) { - throw new NullPointerException("string == null"); - } - this.string = string; - this.delimiters = delimiters; - this.returnDelimiters = returnDelimiters; - this.position = 0; - } - - /** - * Returns the number of unprocessed tokens remaining in the string. - * - * @return number of tokens that can be retreived before an {@code - * Exception} will result from a call to {@code nextToken()}. - */ - public int countTokens() { - int count = 0; - boolean inToken = false; - for (int i = position, length = string.length(); i < length; i++) { - if (delimiters.indexOf(string.charAt(i), 0) >= 0) { - if (returnDelimiters) - count++; - if (inToken) { - count++; - inToken = false; - } - } else { - inToken = true; - } - } - if (inToken) - count++; - return count; - } - - /** - * Returns {@code true} if unprocessed tokens remain. This method is - * implemented in order to satisfy the {@code Enumeration} interface. - * - * @return {@code true} if unprocessed tokens remain. - */ - public boolean hasMoreElements() { - return hasMoreTokens(); - } - - /** - * Returns {@code true} if unprocessed tokens remain. - * - * @return {@code true} if unprocessed tokens remain. - */ - public boolean hasMoreTokens() { - if (delimiters == null) { - throw new NullPointerException("delimiters == null"); - } - int length = string.length(); - if (position < length) { - if (returnDelimiters) - return true; // there is at least one character and even if - // it is a delimiter it is a token - - // otherwise find a character which is not a delimiter - for (int i = position; i < length; i++) - if (delimiters.indexOf(string.charAt(i), 0) == -1) - return true; - } - return false; - } - - /** - * Returns the next token in the string as an {@code Object}. This method is - * implemented in order to satisfy the {@code Enumeration} interface. - * - * @return next token in the string as an {@code Object} - * @throws NoSuchElementException - * if no tokens remain. - */ - public Object nextElement() { - return nextToken(); - } - - /** - * Returns the next token in the string as a {@code String}. - * - * @return next token in the string as a {@code String}. - * @throws NoSuchElementException - * if no tokens remain. - */ - public String nextToken() { - if (delimiters == null) { - throw new NullPointerException("delimiters == null"); - } - int i = position; - int length = string.length(); - - if (i < length) { - if (returnDelimiters) { - if (delimiters.indexOf(string.charAt(position), 0) >= 0) - return String.valueOf(string.charAt(position++)); - for (position++; position < length; position++) - if (delimiters.indexOf(string.charAt(position), 0) >= 0) - return string.substring(i, position); - return string.substring(i); - } - - while (i < length && delimiters.indexOf(string.charAt(i), 0) >= 0) - i++; - position = i; - if (i < length) { - for (position++; position < length; position++) - if (delimiters.indexOf(string.charAt(position), 0) >= 0) - return string.substring(i, position); - return string.substring(i); - } - } - throw new NoSuchElementException(); - } - - /** - * Returns the next token in the string as a {@code String}. The delimiters - * used are changed to the specified delimiters. - * - * @param delims - * the new delimiters to use. - * @return next token in the string as a {@code String}. - * @throws NoSuchElementException - * if no tokens remain. - */ - public String nextToken(String delims) { - this.delimiters = delims; - return nextToken(); - } -} diff --git a/backends/gdx-backend-dragome/pom.xml b/backends/gdx-backend-dragome/pom.xml index 1703fb62..cd7547e5 100644 --- a/backends/gdx-backend-dragome/pom.xml +++ b/backends/gdx-backend-dragome/pom.xml @@ -1,74 +1,82 @@ - - 4.0.0 - gdx-backend-dragome - gdx-backend-dragome - 0.0.1-SNAPSHOT - - - - JBOSS_NEXUS - http://repository.jboss.org/nexus/content/groups/public - - - sonatype-snapshots - https://oss.sonatype.org/content/repositories/snapshots - - - dragome - dragome - https://raw.github.com/dragome/dragome/master/maven - - + + 4.0.0 + gdx-backend-dragome + gdx-backend-dragome + 0.0.1-SNAPSHOT - - - + + + JBOSS_NEXUS + http://repository.jboss.org/nexus/content/groups/public + + + sonatype-snapshots + https://oss.sonatype.org/content/repositories/snapshots + + + dragome + dragome + https://raw.github.com/dragome/dragome/master/maven + + - - org.codehaus.mojo - build-helper-maven-plugin - 1.8 - - - add-source - generate-sources - - add-source - - - - src - emu - - - - - - - maven-compiler-plugin - 3.3 - - 1.8 - 1.8 - - - - - - - com.dragome - dragome-sdk - 0.96-beta3-SNAPSHOT - pom - + + - - com.badlogicgames.gdx - gdx - 1.9.2 - + + org.codehaus.mojo + build-helper-maven-plugin + 1.8 + + + add-source + generate-sources + + add-source + + + + src + emu + + + + + - + + maven-compiler-plugin + 3.3 + + 1.8 + 1.8 + + + + + + + com.dragome + dragome-web + 0.96-beta3-SNAPSHOT + + + com.dragome + dragome-bytecode-js-compiler + 0.96-beta3-SNAPSHOT + + + com.dragome + dragome-js-jre + 0.96-beta3-SNAPSHOT + + + + com.badlogicgames.gdx + gdx + 1.9.2 + + + \ No newline at end of file diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/DragomeApplication.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/DragomeApplication.java index a3ccd27c..5638f269 100644 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/DragomeApplication.java +++ b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/DragomeApplication.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright 2016 Natan Guilherme. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,16 +35,15 @@ import com.badlogic.gdx.utils.Clipboard; import com.dragome.view.DefaultVisualActivity; import com.dragome.web.dispatcher.EventDispatcherImpl; -import com.dragome.web.html.dom.Timer; -import com.dragome.web.html.dom.html5canvas.interfaces.HTMLCanvasElement; import com.dragome.web.html.dom.w3c.BrowserDomHandler; +import com.dragome.web.html.dom.w3c.HTMLCanvasElementExtension; /** @author xpenatan */ public abstract class DragomeApplication extends DefaultVisualActivity implements Application { private ApplicationListener listener; BrowserDomHandler elementBySelector; - + DragomeGraphics graphics; DragomeInput input; DragomeNet net; @@ -73,7 +72,7 @@ public void build () { } private void prepate () { - listener = createApplicationListener(); + listener = createApplicationListener(); if (listener == null) return; DragomeApplicationConfiguration config = getConfig(); if(config == null) @@ -128,7 +127,7 @@ public void run () { // } // } // }, 0); - + DragomeWindow.requestAnimationFrame(new Runnable() { @Override @@ -142,7 +141,7 @@ public void run () { DragomeWindow.requestAnimationFrame(this, graphics.canvas); } }, graphics.canvas); - + init = true; } @@ -295,14 +294,14 @@ public void removeLifecycleListener (LifecycleListener listener) { } } - public HTMLCanvasElement getCanvas () { + public HTMLCanvasElementExtension getCanvas () { return graphics.canvas; } public Preloader getPreloader () { return preloader; } - + public void addEventListener (EventListener aEventListener, String... aEvent) { Element theElement = elementBySelector.getElementBySelector("body"); EventDispatcherImpl.setEventListener(theElement, aEventListener, aEvent); diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/DragomeConfiguration.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/DragomeConfiguration.java index 012023cb..ab6aa637 100644 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/DragomeConfiguration.java +++ b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/DragomeConfiguration.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright 2016 Natan Guilherme. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,96 +17,96 @@ package com.badlogic.gdx.backends.dragome; import java.io.File; -import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashSet; import java.util.List; -import org.apache.commons.io.FileUtils; -import org.w3c.dom.Attr; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.Text; import org.w3c.dom.events.Event; +import org.w3c.dom.typedarray.ArrayBuffer; +import org.w3c.dom.typedarray.ArrayBufferView; +import org.w3c.dom.typedarray.Float32Array; +import org.w3c.dom.typedarray.Float64Array; +import org.w3c.dom.typedarray.Int16Array; +import org.w3c.dom.typedarray.Int32Array; +import org.w3c.dom.typedarray.Int8Array; +import org.w3c.dom.typedarray.Uint16Array; +import org.w3c.dom.typedarray.Uint32Array; +import org.w3c.dom.typedarray.Uint8Array; +import org.w3c.dom.webgl.WebGLActiveInfo; +import org.w3c.dom.webgl.WebGLBuffer; +import org.w3c.dom.webgl.WebGLContextAttributes; +import org.w3c.dom.webgl.WebGLFramebuffer; +import org.w3c.dom.webgl.WebGLObject; +import org.w3c.dom.webgl.WebGLProgram; +import org.w3c.dom.webgl.WebGLRenderbuffer; +import org.w3c.dom.webgl.WebGLRenderingContext; +import org.w3c.dom.webgl.WebGLShader; +import org.w3c.dom.webgl.WebGLTexture; +import org.w3c.dom.webgl.WebGLUniformLocation; -import com.badlogic.gdx.backends.dragome.js.storage.Storage; -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBuffer; -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBufferView; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Float32Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Float64Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Int16Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Int32Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Int8Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Uint16Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Uint32Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Uint8Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Uint8ClampedArray; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLActiveInfo; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLBuffer; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLContextAttributes; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLFramebuffer; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLObject; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLProgram; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLRenderbuffer; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLRenderingContext; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLShader; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLTexture; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLUniformLocation; -import com.dragome.commons.ChainedInstrumentationDragomeConfigurator; import com.dragome.commons.DragomeConfiguratorImplementor; +import com.dragome.commons.compiler.ClasspathFile; import com.dragome.commons.compiler.annotations.CompilerType; -import com.dragome.web.config.NodeSubTypeFactory; -import com.dragome.web.enhancers.jsdelegate.DefaultDelegateStrategy; -import com.dragome.web.enhancers.jsdelegate.JsDelegateGenerator; -import com.dragome.web.enhancers.jsdelegate.interfaces.SubTypeFactory; +import com.dragome.web.config.DomHandlerApplicationConfigurator; import com.dragome.web.helpers.serverside.DefaultClasspathFilter; -import com.dragome.web.html.dom.html5canvas.interfaces.CanvasImageSource; -import com.dragome.web.html.dom.html5canvas.interfaces.CanvasRenderingContext2D; -import com.dragome.web.html.dom.html5canvas.interfaces.HTMLCanvasElement; -import com.dragome.web.html.dom.html5canvas.interfaces.ImageElement; - -import javassist.CtMethod; -import javassist.NotFoundException; +import com.dragome.web.html.dom.w3c.ArrayBufferFactory; +import com.dragome.web.html.dom.w3c.HTMLCanvasElementExtension; +import com.dragome.web.html.dom.w3c.HTMLImageElementExtension; +import com.dragome.web.html.dom.w3c.TypedArraysFactory; +import com.dragome.web.html.dom.w3c.WebGLRenderingContextExtension; /** @author xpenatan */ -@DragomeConfiguratorImplementor(priority = 10) -public class DragomeConfiguration extends ChainedInstrumentationDragomeConfigurator { +@DragomeConfiguratorImplementor(priority= 10) +public class DragomeConfiguration extends DomHandlerApplicationConfigurator +{ HashSet paths; String projName; String projPath; - List result; - private JsDelegateGenerator jsDelegateGenerator; - - boolean cache = false; - - public DragomeConfiguration () { - -// System.setProperty("dragome-compile-mode", CompilerMode.Production.toString()); -// System.setProperty("dragome-compile-mode", CompilerMode.Debug.toString()); - - result = new ArrayList(); - projPath = System.getProperty("user.dir"); - File file = new File(projPath); - projName = file.getName(); - paths = new HashSet(); - setClasspathFilter(new DefaultClasspathFilter() { - public boolean accept (File pathname) { - boolean accept = super.accept(pathname); - String absolutePath = pathname.getAbsolutePath(); - - String className = pathname.getName().replace(".class", ""); - if (paths.contains(className)) return false; - - if (absolutePath.contains("gdx-backend-dragome")) { + List extraClasspathFiles; + static List> additonalClasses= Arrays.asList(HTMLImageElementExtension.class, HTMLCanvasElementExtension.class, Event.class, // + WebGLActiveInfo.class, WebGLBuffer.class, WebGLContextAttributes.class, WebGLFramebuffer.class, // + WebGLObject.class, WebGLProgram.class, WebGLRenderbuffer.class, WebGLRenderingContext.class, // + WebGLShader.class, WebGLTexture.class, WebGLUniformLocation.class, WebGLRenderingContextExtension.class, // + ArrayBuffer.class, ArrayBufferView.class, Float32Array.class, Float64Array.class, Int16Array.class, // + Int32Array.class, Int8Array.class, Uint16Array.class, Uint32Array.class, Uint8Array.class, // + ArrayBufferFactory.class, TypedArraysFactory.class); + + boolean cache= false; + + public DragomeConfiguration() + { + super(additonalClasses); + // System.setProperty("dragome-compile-mode", CompilerMode.Production.toString()); + // System.setProperty("dragome-compile-mode", CompilerMode.Debug.toString()); + + extraClasspathFiles= new ArrayList(); + projPath= System.getProperty("user.dir"); + File file= new File(projPath); + projName= file.getName(); + paths= new HashSet(); + setClasspathFilter(new DefaultClasspathFilter() + { + public boolean accept(File pathname, File folder) + { + boolean accept= super.accept(pathname, folder); + + String relativePath= folder.toURI().relativize(pathname.toURI()).getPath(); + + if (relativePath.contains("utils\\Json")) + return false; + + String className= relativePath.replace(".class", ""); + if (paths.contains(className)) + return false; + + if (relativePath.contains("gdx-backend-dragome")) + { paths.add(className); } - - - System.out.println("ClassPathFilter: " + accept + " - " + absolutePath); - + + System.out.println("ClassPathFilter: " + accept + " - " + relativePath); + return accept; } @@ -114,149 +114,47 @@ public boolean accept (File pathname) { } - public void add (Class clazz) { - byte[] bytecode = jsDelegateGenerator.generate(clazz); - addClassBytecode(bytecode, JsDelegateGenerator.createDelegateClassName(clazz.getName())); - } - - private void createJsDelegateGenerator (String classpath) { - - if(cache == false) { - File file2 = new File(projPath + "\\target\\dragome.cache"); - if (file2.exists()) - file2.delete(); - } - File file1 = new File(projPath + "\\target\\jsdelegate"); - try { - - if (file1.exists()) - FileUtils.deleteDirectory(file1); - } catch (IOException e) { - e.printStackTrace(); - } - - jsDelegateGenerator = new JsDelegateGenerator(file1, classpath.replace(";", ":"), - new DefaultDelegateStrategy() { - @Override - public String createMethodCall (CtMethod method, StringBuffer code, String params) throws NotFoundException { - if (params == null) params = ""; - String longName = method.getLongName(); - String name = method.getName(); - -// System.out.println("Interfaces: " + longName); - - if (longName.contains(".js.")) { - - String codeStr = null; - - if(name.startsWith("set_") && method.getParameterTypes().length == 1) { - String variableName = name.replace("set_", ""); - codeStr = "this.node." + variableName + "=" + params; - } - else if(method.getName().startsWith("get_") && method.getParameterTypes().length == 0) { - String variableName = name.replace("get_", ""); - codeStr = "this.node." + variableName; - } - else - codeStr = "this.node." + name + "(" + params + ")"; - return codeStr; - } else { - return super.createMethodCall(method, code, params); - } - } - - public String getSubTypeExtractorFor(Class interface1, String methodName) - { - if (methodName.equals("item") || methodName.equals("cloneNode")) - return "temp.nodeType"; - - return null; - } - - public Class getSubTypeFactoryClassFor(Class interface1, String methodName) - { - if (methodName.equals("item") || methodName.equals("cloneNode")) - return NodeSubTypeFactory.class; - - return null; - } - }); - - result.add(jsDelegateGenerator.getBaseDir()); - } - - public List getExtraClasspath (String classpath) { - if (jsDelegateGenerator == null) createJsDelegateGenerator(classpath); - - add(Document.class); - add(Element.class); - add(Attr.class); - add(NodeList.class); - add(Node.class); - add(NamedNodeMap.class); - add(Text.class); - add(HTMLCanvasElement.class); - add(CanvasRenderingContext2D.class); - add(CanvasImageSource.class); - add(ImageElement.class); - add(Event.class); - - add(WebGLActiveInfo.class); - add(WebGLBuffer.class); - add(WebGLContextAttributes.class); - add(WebGLFramebuffer.class); - add(WebGLObject.class); - add(WebGLProgram.class); - add(WebGLRenderbuffer.class); - add(WebGLRenderingContext.class); - add(WebGLShader.class); - add(WebGLTexture.class); - add(WebGLUniformLocation.class); - - add(ArrayBuffer.class); - add(ArrayBufferView.class); - -// add(DataView.class); -// add(DataViewStream.class); - add(Float32Array.class); - add(Float64Array.class); - add(Int16Array.class); - add(Int32Array.class); - add(Int8Array.class); - add(Uint16Array.class); - add(Uint32Array.class); - add(Uint8Array.class); - add(Uint8ClampedArray.class); - - add(Storage.class); - return result; - } - @Override - public boolean filterClassPath (String aClassPathEntry) { - boolean flag = false; - if (aClassPathEntry.contains(projName)) flag = true; - else if (aClassPathEntry.contains("repository") && aClassPathEntry.contains("gdx") || aClassPathEntry.contains("gdx.jar") || aClassPathEntry.contains("gdx\\bin")) flag = true; - else if (aClassPathEntry.contains("repository\\gdx-backend-dragome") || aClassPathEntry.contains("gdx-backend-dragome\\bin")) flag = true; - else if (aClassPathEntry.contains("dragome-js-commons-") || aClassPathEntry.contains("dragome-js-commons\\bin")) flag = true; - else if (aClassPathEntry.contains("dragome-js-jre-") || aClassPathEntry.contains("dragome-js-jre\\bin")) flag = true; - else if (aClassPathEntry.contains("dragome-callback-evictor-") || aClassPathEntry.contains("dragome-callback-evictor\\bin")) flag = true; - else if (aClassPathEntry.contains("dragome-form-bindings-") || aClassPathEntry.contains("dragome-form-bindings\\bin")) flag = true; - else if (aClassPathEntry.contains("dragome-core-") || aClassPathEntry.contains("dragome-core\\bin")) flag = true; - else if (aClassPathEntry.contains("dragome-method-logger-") || aClassPathEntry.contains("dragome-method-logger\\bin")) flag = true; - else if (aClassPathEntry.contains("dragome-web-") || aClassPathEntry.contains("dragome-web\\bin")) flag = true; - else if (aClassPathEntry.contains("dragome-guia-web-") || aClassPathEntry.contains("dragome-guia-web\\bin")) flag = true; - else if (aClassPathEntry.contains("dragome-guia-") || aClassPathEntry.contains("dragome-guia\\bin")) flag = true; + public boolean filterClassPath(String aClassPathEntry) + { + boolean flag= false; + if (aClassPathEntry.contains(projName)) + flag= true; + else if (aClassPathEntry.contains("repository") && aClassPathEntry.contains("gdx") || aClassPathEntry.contains("gdx.jar") || aClassPathEntry.contains("gdx\\bin")) + flag= true; + else if (aClassPathEntry.contains("repository\\gdx-backend-dragome") || aClassPathEntry.contains("gdx-backend-dragome\\bin")) + flag= true; + else if (aClassPathEntry.contains("dragome-js-commons-") || aClassPathEntry.contains("dragome-js-commons\\bin")) + flag= true; + else if (aClassPathEntry.contains("dragome-js-jre-") || aClassPathEntry.contains("dragome-js-jre\\bin")) + flag= true; + else if (aClassPathEntry.contains("dragome-w3c-standards-") || aClassPathEntry.contains("dragome-w3c-standards\\bin")) + flag= true; + else if (aClassPathEntry.contains("dragome-callback-evictor-") || aClassPathEntry.contains("dragome-callback-evictor\\bin")) + flag= true; + else if (aClassPathEntry.contains("dragome-form-bindings-") || aClassPathEntry.contains("dragome-form-bindings\\bin")) + flag= true; + else if (aClassPathEntry.contains("dragome-core-") || aClassPathEntry.contains("dragome-core\\bin")) + flag= true; + else if (aClassPathEntry.contains("dragome-method-logger-") || aClassPathEntry.contains("dragome-method-logger\\bin")) + flag= true; + else if (aClassPathEntry.contains("dragome-web-") || aClassPathEntry.contains("dragome-web\\bin")) + flag= true; + else if (aClassPathEntry.contains("dragome-guia-web-") || aClassPathEntry.contains("dragome-guia-web\\bin")) + flag= true; + else if (aClassPathEntry.contains("dragome-guia-") || aClassPathEntry.contains("dragome-guia\\bin")) + flag= true; System.out.println("flag: " + flag + " path: " + aClassPathEntry); return flag; } - public CompilerType getDefaultCompilerType () { + public CompilerType getDefaultCompilerType() + { return CompilerType.Standard; } - @Override - public boolean isCheckingCast () { - return true; + public boolean isCheckingCast() + { + return false; } } diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/DragomeGL20.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/DragomeGL20.java index 4188e559..1b3ef1db 100644 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/DragomeGL20.java +++ b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/DragomeGL20.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright 2016 Natan Guilherme. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,27 +25,29 @@ import java.util.HashMap; import java.util.Map; -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBufferView; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Float32Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Int16Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Int32Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Uint8Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.utils.TypedArrays; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLActiveInfo; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLBuffer; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLFramebuffer; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLProgram; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLRenderbuffer; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLRenderingContext; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLShader; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLTexture; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLUniformLocation; +import org.w3c.dom.typedarray.ArrayBufferView; +import org.w3c.dom.typedarray.Float32Array; +import org.w3c.dom.typedarray.Int16Array; +import org.w3c.dom.typedarray.Int32Array; +import org.w3c.dom.typedarray.Uint8Array; +import org.w3c.dom.webgl.WebGLActiveInfo; +import org.w3c.dom.webgl.WebGLBuffer; +import org.w3c.dom.webgl.WebGLFramebuffer; +import org.w3c.dom.webgl.WebGLProgram; +import org.w3c.dom.webgl.WebGLRenderbuffer; +import org.w3c.dom.webgl.WebGLRenderingContext; +import org.w3c.dom.webgl.WebGLShader; +import org.w3c.dom.webgl.WebGLTexture; +import org.w3c.dom.webgl.WebGLUniformLocation; + import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.utils.GdxRuntimeException; import com.dragome.commons.javascript.ScriptHelper; +import com.dragome.web.html.dom.w3c.TypedArraysFactory; +import com.dragome.web.html.dom.w3c.WebGLRenderingContextExtension; -/** Ported from GWT backend. +/** Ported from GWT backend. * @author xpenatan */ public class DragomeGL20 implements GL20 { final Map programs = new HashMap(); @@ -69,31 +71,31 @@ public class DragomeGL20 implements GL20 { Int16Array shortBuffer; float[] floatArray = new float[16000]; - WebGLRenderingContext gl; + WebGLRenderingContextExtension gl; - public DragomeGL20 (WebGLRenderingContext gl) { + public DragomeGL20 (WebGLRenderingContextExtension gl) { this.gl = gl; - floatBuffer = TypedArrays.createFloat32Array(2000 * 20); - intBuffer = TypedArrays.createInt32Array(2000 * 6); - shortBuffer = TypedArrays.createInt16Array(2000 * 6); + floatBuffer= TypedArraysFactory.createInstanceOf(Float32Array.class, 2000 * 20); + intBuffer= TypedArraysFactory.createInstanceOf(Int32Array.class, 2000 * 6); + shortBuffer = TypedArraysFactory.createInstanceOf(Int16Array.class, 2000 * 6); this.gl.pixelStorei(WebGLRenderingContext.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0); } private void ensureCapacity (FloatBuffer buffer) { - if (buffer.remaining() > floatBuffer.get_length()) { - floatBuffer = TypedArrays.createFloat32Array(buffer.remaining()); + if (buffer.remaining() > floatBuffer.getLength()) { + floatBuffer= TypedArraysFactory.createInstanceOf(Float32Array.class, buffer.remaining()); } } private void ensureCapacity (ShortBuffer buffer) { - if (buffer.remaining() > shortBuffer.get_length()) { - shortBuffer = TypedArrays.createInt16Array(buffer.remaining()); + if (buffer.remaining() > shortBuffer.getLength()) { + shortBuffer = TypedArraysFactory.createInstanceOf(Int16Array.class, buffer.remaining()); } } private void ensureCapacity (IntBuffer buffer) { - if (buffer.remaining() > intBuffer.get_length()) { - intBuffer = TypedArrays.createInt32Array(buffer.remaining()); + if (buffer.remaining() > intBuffer.getLength()) { + intBuffer = TypedArraysFactory.createInstanceOf(Int32Array.class, buffer.remaining()); } } @@ -417,7 +419,7 @@ public void glReadPixels (int x, int y, int width, int height, int format, int t // create new ArrayBufferView (4 bytes per pixel) int size = 4 * width * height; - Uint8Array buffer = Uint8Array.create(size); + Uint8Array buffer = TypedArraysFactory.createInstanceOf(Uint8Array.class, size); // read bytes to ArrayBufferView gl.readPixels(x, y, width, height, format, type, buffer); @@ -461,9 +463,9 @@ public void glTexImage2D (int target, int level, int internalformat, int width, ArrayBufferView webGLArray = arrayHolder.getTypedArray(); int remainingBytes = pixels.remaining() * 4; - int byteOffset = webGLArray.get_byteOffset() + pixels.position() * 4; + int byteOffset = webGLArray.getByteOffset() + pixels.position() * 4; - Uint8Array buffer = Uint8Array.create(webGLArray.get_buffer(), byteOffset, remainingBytes); + Uint8Array buffer = TypedArraysFactory.createInstanceOf(Uint8Array.class, webGLArray.getBuffer(), byteOffset, remainingBytes); gl.texImage2D(target, level, internalformat, width, height, border, format, type, buffer); } else { @@ -487,9 +489,9 @@ public void glTexSubImage2D (int target, int level, int xoffset, int yoffset, in ArrayBufferView webGLArray = arrayHolder.getTypedArray(); int remainingBytes = pixels.remaining() * 4; - int byteOffset = webGLArray.get_byteOffset() + pixels.position() * 4; + int byteOffset = webGLArray.getByteOffset() + pixels.position() * 4; - Uint8Array buffer = Uint8Array.create(webGLArray.get_buffer(), byteOffset, remainingBytes); + Uint8Array buffer = TypedArraysFactory.createInstanceOf(Uint8Array.class, webGLArray.getBuffer(), byteOffset, remainingBytes); gl.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, buffer); } else { @@ -746,17 +748,17 @@ public int glGenRenderbuffer () { @Override public String glGetActiveAttrib (int program, int index, IntBuffer size, Buffer type) { WebGLActiveInfo activeAttrib = gl.getActiveAttrib(programs.get(program), index); - size.put(activeAttrib.get_size()); - ((IntBuffer)type).put(activeAttrib.get_type()); - return activeAttrib.get_name(); + size.put(activeAttrib.getSize()); + ((IntBuffer)type).put(activeAttrib.getType()); + return activeAttrib.getName(); } @Override public String glGetActiveUniform (int program, int index, IntBuffer size, Buffer type) { WebGLActiveInfo activeUniform = gl.getActiveUniform(programs.get(program), index); - size.put(activeUniform.get_size()); - ((IntBuffer)type).put(activeUniform.get_type()); - return activeUniform.get_name(); + size.put(activeUniform.getSize()); + ((IntBuffer)type).put(activeUniform.getType()); + return activeUniform.getName(); } @Override diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/DragomeGL20Debug.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/DragomeGL20Debug.java index d3c99bb8..37531bf3 100644 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/DragomeGL20Debug.java +++ b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/DragomeGL20Debug.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright 2011 See AUTHORS file. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,12 +20,12 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLRenderingContext; import com.badlogic.gdx.utils.GdxRuntimeException; +import com.dragome.web.html.dom.w3c.WebGLRenderingContextExtension; public class DragomeGL20Debug extends DragomeGL20 { - protected DragomeGL20Debug (WebGLRenderingContext gl) { + protected DragomeGL20Debug (WebGLRenderingContextExtension gl) { super(gl); } @@ -46,49 +46,49 @@ public void glActiveTexture (int texture) { @Override public void glBindTexture (int target, int texture) { - + super.glBindTexture(target, texture); checkError(); } @Override public void glBlendFunc (int sfactor, int dfactor) { - + super.glBlendFunc(sfactor, dfactor); checkError(); } @Override public void glClear (int mask) { - + super.glClear(mask); checkError(); } @Override public void glClearColor (float red, float green, float blue, float alpha) { - + super.glClearColor(red, green, blue, alpha); checkError(); } @Override public void glClearDepthf (float depth) { - + super.glClearDepthf(depth); checkError(); } @Override public void glClearStencil (int s) { - + super.glClearStencil(s); checkError(); } @Override public void glColorMask (boolean red, boolean green, boolean blue, boolean alpha) { - + super.glColorMask(red, green, blue, alpha); checkError(); } @@ -96,7 +96,7 @@ public void glColorMask (boolean red, boolean green, boolean blue, boolean alpha @Override public void glCompressedTexImage2D (int target, int level, int internalformat, int width, int height, int border, int imageSize, Buffer data) { - + super.glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); checkError(); } @@ -104,194 +104,194 @@ public void glCompressedTexImage2D (int target, int level, int internalformat, i @Override public void glCompressedTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format, int imageSize, Buffer data) { - + super.glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data); checkError(); } @Override public void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) { - + super.glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); checkError(); } @Override public void glCopyTexSubImage2D (int target, int level, int xoffset, int yoffset, int x, int y, int width, int height) { - + super.glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); checkError(); } @Override public void glCullFace (int mode) { - + super.glCullFace(mode); checkError(); } @Override public void glDeleteTextures (int n, IntBuffer textures) { - + super.glDeleteTextures(n, textures); checkError(); } @Override public void glDepthFunc (int func) { - + super.glDepthFunc(func); checkError(); } @Override public void glDepthMask (boolean flag) { - + super.glDepthMask(flag); checkError(); } @Override public void glDepthRangef (float zNear, float zFar) { - + super.glDepthRangef(zNear, zFar); checkError(); } @Override public void glDisable (int cap) { - + super.glDisable(cap); checkError(); } @Override public void glDrawArrays (int mode, int first, int count) { - + super.glDrawArrays(mode, first, count); checkError(); } @Override public void glDrawElements (int mode, int count, int type, Buffer indices) { - + super.glDrawElements(mode, count, type, indices); checkError(); } @Override public void glEnable (int cap) { - + super.glEnable(cap); checkError(); } @Override public void glFinish () { - + super.glFinish(); checkError(); } @Override public void glFlush () { - + super.glFlush(); checkError(); } @Override public void glFrontFace (int mode) { - + super.glFrontFace(mode); checkError(); } @Override public void glGenTextures (int n, IntBuffer textures) { - + super.glGenTextures(n, textures); checkError(); } @Override public int glGetError () { - + return super.glGetError(); } @Override public void glGetIntegerv (int pname, IntBuffer params) { - + super.glGetIntegerv(pname, params); checkError(); } @Override public String glGetString (int name) { - + return super.glGetString(name); } @Override public void glHint (int target, int mode) { - + super.glHint(target, mode); checkError(); } @Override public void glLineWidth (float width) { - + super.glLineWidth(width); checkError(); } @Override public void glPixelStorei (int pname, int param) { - + super.glPixelStorei(pname, param); checkError(); } @Override public void glPolygonOffset (float factor, float units) { - + super.glPolygonOffset(factor, units); checkError(); } @Override public void glReadPixels (int x, int y, int width, int height, int format, int type, Buffer pixels) { - + super.glReadPixels(x, y, width, height, format, type, pixels); checkError(); } @Override public void glScissor (int x, int y, int width, int height) { - + super.glScissor(x, y, width, height); checkError(); } @Override public void glStencilFunc (int func, int ref, int mask) { - + super.glStencilFunc(func, ref, mask); checkError(); } @Override public void glStencilMask (int mask) { - + super.glStencilMask(mask); checkError(); } @Override public void glStencilOp (int fail, int zfail, int zpass) { - + super.glStencilOp(fail, zfail, zpass); checkError(); } @@ -299,14 +299,14 @@ public void glStencilOp (int fail, int zfail, int zpass) { @Override public void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, Buffer pixels) { - + super.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); checkError(); } @Override public void glTexParameterf (int target, int pname, float param) { - + super.glTexParameterf(target, pname, param); checkError(); } @@ -314,111 +314,111 @@ public void glTexParameterf (int target, int pname, float param) { @Override public void glTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format, int type, Buffer pixels) { - + super.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); checkError(); } @Override public void glViewport (int x, int y, int width, int height) { - + super.glViewport(x, y, width, height); checkError(); } @Override public void glAttachShader (int program, int shader) { - + super.glAttachShader(program, shader); checkError(); } @Override public void glBindAttribLocation (int program, int index, String name) { - + super.glBindAttribLocation(program, index, name); checkError(); } @Override public void glBindBuffer (int target, int buffer) { - + super.glBindBuffer(target, buffer); checkError(); } @Override public void glBindFramebuffer (int target, int framebuffer) { - + super.glBindFramebuffer(target, framebuffer); checkError(); } @Override public void glBindRenderbuffer (int target, int renderbuffer) { - + super.glBindRenderbuffer(target, renderbuffer); checkError(); } @Override public void glBlendColor (float red, float green, float blue, float alpha) { - + super.glBlendColor(red, green, blue, alpha); checkError(); } @Override public void glBlendEquation (int mode) { - + super.glBlendEquation(mode); checkError(); } @Override public void glBlendEquationSeparate (int modeRGB, int modeAlpha) { - + super.glBlendEquationSeparate(modeRGB, modeAlpha); checkError(); } @Override public void glBlendFuncSeparate (int srcRGB, int dstRGB, int srcAlpha, int dstAlpha) { - + super.glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); checkError(); } @Override public void glBufferData (int target, int size, Buffer data, int usage) { - + super.glBufferData(target, size, data, usage); checkError(); } @Override public void glBufferSubData (int target, int offset, int size, Buffer data) { - + super.glBufferSubData(target, offset, size, data); checkError(); } @Override public int glCheckFramebufferStatus (int target) { - + return super.glCheckFramebufferStatus(target); } @Override public void glCompileShader (int shader) { - + super.glCompileShader(shader); checkError(); } @Override public int glCreateProgram () { - + int program = super.glCreateProgram(); checkError(); return program; @@ -426,7 +426,7 @@ public int glCreateProgram () { @Override public int glCreateShader (int type) { - + int shader = super.glCreateShader(type); checkError(); return shader; @@ -434,112 +434,112 @@ public int glCreateShader (int type) { @Override public void glDeleteBuffers (int n, IntBuffer buffers) { - + super.glDeleteBuffers(n, buffers); checkError(); } @Override public void glDeleteFramebuffers (int n, IntBuffer framebuffers) { - + super.glDeleteFramebuffers(n, framebuffers); checkError(); } @Override public void glDeleteProgram (int program) { - + super.glDeleteProgram(program); checkError(); } @Override public void glDeleteRenderbuffers (int n, IntBuffer renderbuffers) { - + super.glDeleteRenderbuffers(n, renderbuffers); checkError(); } @Override public void glDeleteShader (int shader) { - + super.glDeleteShader(shader); checkError(); } @Override public void glDetachShader (int program, int shader) { - + super.glDetachShader(program, shader); checkError(); } @Override public void glDisableVertexAttribArray (int index) { - + super.glDisableVertexAttribArray(index); checkError(); } @Override public void glDrawElements (int mode, int count, int type, int indices) { - + super.glDrawElements(mode, count, type, indices); checkError(); } @Override public void glEnableVertexAttribArray (int index) { - + super.glEnableVertexAttribArray(index); checkError(); } @Override public void glFramebufferRenderbuffer (int target, int attachment, int renderbuffertarget, int renderbuffer) { - + super.glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer); checkError(); } @Override public void glFramebufferTexture2D (int target, int attachment, int textarget, int texture, int level) { - + super.glFramebufferTexture2D(target, attachment, textarget, texture, level); checkError(); } @Override public void glGenBuffers (int n, IntBuffer buffers) { - + super.glGenBuffers(n, buffers); checkError(); } @Override public void glGenerateMipmap (int target) { - + super.glGenerateMipmap(target); checkError(); } @Override public void glGenFramebuffers (int n, IntBuffer framebuffers) { - + super.glGenFramebuffers(n, framebuffers); checkError(); } @Override public void glGenRenderbuffers (int n, IntBuffer renderbuffers) { - + super.glGenRenderbuffers(n, renderbuffers); checkError(); } @Override public String glGetActiveAttrib (int program, int index, IntBuffer size, Buffer type) { - + String attrib = super.glGetActiveAttrib(program, index, size, type); checkError(); return attrib; @@ -547,7 +547,7 @@ public String glGetActiveAttrib (int program, int index, IntBuffer size, Buffer @Override public String glGetActiveUniform (int program, int index, IntBuffer size, Buffer type) { - + String uniform = super.glGetActiveUniform(program, index, size, type); checkError(); return uniform; @@ -555,14 +555,14 @@ public String glGetActiveUniform (int program, int index, IntBuffer size, Buffer @Override public void glGetAttachedShaders (int program, int maxcount, Buffer count, IntBuffer shaders) { - + super.glGetAttachedShaders(program, maxcount, count, shaders); checkError(); } @Override public int glGetAttribLocation (int program, String name) { - + int loc = super.glGetAttribLocation(program, name); checkError(); return loc; @@ -570,42 +570,42 @@ public int glGetAttribLocation (int program, String name) { @Override public void glGetBooleanv (int pname, Buffer params) { - + super.glGetBooleanv(pname, params); checkError(); } @Override public void glGetBufferParameteriv (int target, int pname, IntBuffer params) { - + super.glGetBufferParameteriv(target, pname, params); checkError(); } @Override public void glGetFloatv (int pname, FloatBuffer params) { - + super.glGetFloatv(pname, params); checkError(); } @Override public void glGetFramebufferAttachmentParameteriv (int target, int attachment, int pname, IntBuffer params) { - + super.glGetFramebufferAttachmentParameteriv(target, attachment, pname, params); checkError(); } @Override public void glGetProgramiv (int program, int pname, IntBuffer params) { - + super.glGetProgramiv(program, pname, params); checkError(); } @Override public String glGetProgramInfoLog (int program) { - + String info = super.glGetProgramInfoLog(program); checkError(); return info; @@ -613,21 +613,21 @@ public String glGetProgramInfoLog (int program) { @Override public void glGetRenderbufferParameteriv (int target, int pname, IntBuffer params) { - + super.glGetRenderbufferParameteriv(target, pname, params); checkError(); } @Override public void glGetShaderiv (int shader, int pname, IntBuffer params) { - + super.glGetShaderiv(shader, pname, params); checkError(); } @Override public String glGetShaderInfoLog (int shader) { - + String info = super.glGetShaderInfoLog(shader); checkError(); return info; @@ -635,42 +635,42 @@ public String glGetShaderInfoLog (int shader) { @Override public void glGetShaderPrecisionFormat (int shadertype, int precisiontype, IntBuffer range, IntBuffer precision) { - + super.glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision); checkError(); } @Override public void glGetTexParameterfv (int target, int pname, FloatBuffer params) { - + super.glGetTexParameterfv(target, pname, params); checkError(); } @Override public void glGetTexParameteriv (int target, int pname, IntBuffer params) { - + super.glGetTexParameteriv(target, pname, params); checkError(); } @Override public void glGetUniformfv (int program, int location, FloatBuffer params) { - + super.glGetUniformfv(program, location, params); checkError(); } @Override public void glGetUniformiv (int program, int location, IntBuffer params) { - + super.glGetUniformiv(program, location, params); checkError(); } @Override public int glGetUniformLocation (int program, String name) { - + int loc = super.glGetUniformLocation(program, name); checkError(); return loc; @@ -678,28 +678,28 @@ public int glGetUniformLocation (int program, String name) { @Override public void glGetVertexAttribfv (int index, int pname, FloatBuffer params) { - + super.glGetVertexAttribfv(index, pname, params); checkError(); } @Override public void glGetVertexAttribiv (int index, int pname, IntBuffer params) { - + super.glGetVertexAttribiv(index, pname, params); checkError(); } @Override public void glGetVertexAttribPointerv (int index, int pname, Buffer pointer) { - + super.glGetVertexAttribPointerv(index, pname, pointer); checkError(); } @Override public boolean glIsBuffer (int buffer) { - + boolean res = super.glIsBuffer(buffer); checkError(); return res; @@ -707,7 +707,7 @@ public boolean glIsBuffer (int buffer) { @Override public boolean glIsEnabled (int cap) { - + boolean res = super.glIsEnabled(cap); checkError(); return res; @@ -715,7 +715,7 @@ public boolean glIsEnabled (int cap) { @Override public boolean glIsFramebuffer (int framebuffer) { - + boolean res = super.glIsFramebuffer(framebuffer); checkError(); return res; @@ -723,7 +723,7 @@ public boolean glIsFramebuffer (int framebuffer) { @Override public boolean glIsProgram (int program) { - + boolean res = super.glIsProgram(program); checkError(); return res; @@ -731,7 +731,7 @@ public boolean glIsProgram (int program) { @Override public boolean glIsRenderbuffer (int renderbuffer) { - + boolean res = super.glIsRenderbuffer(renderbuffer); checkError(); return res; @@ -739,7 +739,7 @@ public boolean glIsRenderbuffer (int renderbuffer) { @Override public boolean glIsShader (int shader) { - + boolean res = super.glIsShader(shader); checkError(); return res; @@ -747,7 +747,7 @@ public boolean glIsShader (int shader) { @Override public boolean glIsTexture (int texture) { - + boolean res = super.glIsTexture(texture); checkError(); return res; @@ -755,301 +755,301 @@ public boolean glIsTexture (int texture) { @Override public void glLinkProgram (int program) { - + super.glLinkProgram(program); checkError(); } @Override public void glReleaseShaderCompiler () { - + super.glReleaseShaderCompiler(); checkError(); } @Override public void glRenderbufferStorage (int target, int internalformat, int width, int height) { - + super.glRenderbufferStorage(target, internalformat, width, height); checkError(); } @Override public void glSampleCoverage (float value, boolean invert) { - + super.glSampleCoverage(value, invert); checkError(); } @Override public void glShaderBinary (int n, IntBuffer shaders, int binaryformat, Buffer binary, int length) { - + super.glShaderBinary(n, shaders, binaryformat, binary, length); checkError(); } @Override public void glShaderSource (int shader, String source) { - + super.glShaderSource(shader, source); checkError(); } @Override public void glStencilFuncSeparate (int face, int func, int ref, int mask) { - + super.glStencilFuncSeparate(face, func, ref, mask); checkError(); } @Override public void glStencilMaskSeparate (int face, int mask) { - + super.glStencilMaskSeparate(face, mask); checkError(); } @Override public void glStencilOpSeparate (int face, int fail, int zfail, int zpass) { - + super.glStencilOpSeparate(face, fail, zfail, zpass); checkError(); } @Override public void glTexParameterfv (int target, int pname, FloatBuffer params) { - + super.glTexParameterfv(target, pname, params); checkError(); } @Override public void glTexParameteri (int target, int pname, int param) { - + super.glTexParameteri(target, pname, param); checkError(); } @Override public void glTexParameteriv (int target, int pname, IntBuffer params) { - + super.glTexParameteriv(target, pname, params); checkError(); } @Override public void glUniform1f (int location, float x) { - + super.glUniform1f(location, x); checkError(); } @Override public void glUniform1fv (int location, int count, FloatBuffer v) { - + super.glUniform1fv(location, count, v); checkError(); } @Override public void glUniform1i (int location, int x) { - + super.glUniform1i(location, x); checkError(); } @Override public void glUniform1iv (int location, int count, IntBuffer v) { - + super.glUniform1iv(location, count, v); checkError(); } @Override public void glUniform2f (int location, float x, float y) { - + super.glUniform2f(location, x, y); checkError(); } @Override public void glUniform2fv (int location, int count, FloatBuffer v) { - + super.glUniform2fv(location, count, v); checkError(); } @Override public void glUniform2i (int location, int x, int y) { - + super.glUniform2i(location, x, y); checkError(); } @Override public void glUniform2iv (int location, int count, IntBuffer v) { - + super.glUniform2iv(location, count, v); checkError(); } @Override public void glUniform3f (int location, float x, float y, float z) { - + super.glUniform3f(location, x, y, z); checkError(); } @Override public void glUniform3fv (int location, int count, FloatBuffer v) { - + super.glUniform3fv(location, count, v); checkError(); } @Override public void glUniform3i (int location, int x, int y, int z) { - + super.glUniform3i(location, x, y, z); checkError(); } @Override public void glUniform3iv (int location, int count, IntBuffer v) { - + super.glUniform3iv(location, count, v); checkError(); } @Override public void glUniform4f (int location, float x, float y, float z, float w) { - + super.glUniform4f(location, x, y, z, w); checkError(); } @Override public void glUniform4fv (int location, int count, FloatBuffer v) { - + super.glUniform4fv(location, count, v); checkError(); } @Override public void glUniform4i (int location, int x, int y, int z, int w) { - + super.glUniform4i(location, x, y, z, w); checkError(); } @Override public void glUniform4iv (int location, int count, IntBuffer v) { - + super.glUniform4iv(location, count, v); checkError(); } @Override public void glUniformMatrix2fv (int location, int count, boolean transpose, FloatBuffer value) { - + super.glUniformMatrix2fv(location, count, transpose, value); checkError(); } @Override public void glUniformMatrix3fv (int location, int count, boolean transpose, FloatBuffer value) { - + super.glUniformMatrix3fv(location, count, transpose, value); checkError(); } @Override public void glUniformMatrix4fv (int location, int count, boolean transpose, FloatBuffer value) { - + super.glUniformMatrix4fv(location, count, transpose, value); checkError(); } @Override public void glUseProgram (int program) { - + super.glUseProgram(program); checkError(); } @Override public void glValidateProgram (int program) { - + super.glValidateProgram(program); checkError(); } @Override public void glVertexAttrib1f (int indx, float x) { - + super.glVertexAttrib1f(indx, x); checkError(); } @Override public void glVertexAttrib1fv (int indx, FloatBuffer values) { - + super.glVertexAttrib1fv(indx, values); checkError(); } @Override public void glVertexAttrib2f (int indx, float x, float y) { - + super.glVertexAttrib2f(indx, x, y); checkError(); } @Override public void glVertexAttrib2fv (int indx, FloatBuffer values) { - + super.glVertexAttrib2fv(indx, values); checkError(); } @Override public void glVertexAttrib3f (int indx, float x, float y, float z) { - + super.glVertexAttrib3f(indx, x, y, z); checkError(); } @Override public void glVertexAttrib3fv (int indx, FloatBuffer values) { - + super.glVertexAttrib3fv(indx, values); checkError(); } @Override public void glVertexAttrib4f (int indx, float x, float y, float z, float w) { - + super.glVertexAttrib4f(indx, x, y, z, w); checkError(); } @Override public void glVertexAttrib4fv (int indx, FloatBuffer values) { - + super.glVertexAttrib4fv(indx, values); checkError(); } @Override public void glVertexAttribPointer (int indx, int size, int type, boolean normalized, int stride, Buffer ptr) { - + super.glVertexAttribPointer(indx, size, type, normalized, stride, ptr); checkError(); } @Override public void glVertexAttribPointer (int indx, int size, int type, boolean normalized, int stride, int ptr) { - + super.glVertexAttribPointer(indx, size, type, normalized, stride, ptr); checkError(); } diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/DragomeGraphics.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/DragomeGraphics.java index 4044a03b..42022f02 100644 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/DragomeGraphics.java +++ b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/DragomeGraphics.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright 2016 Natan Guilherme. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,264 +17,315 @@ package com.badlogic.gdx.backends.dragome; import org.w3c.dom.Element; +import org.w3c.dom.webgl.WebGLContextAttributes; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Graphics; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLContextAttributes; -import com.badlogic.gdx.backends.dragome.js.webgl.WebGLRenderingContext; +import com.badlogic.gdx.backends.dragome.js.webgl.WebGLFactory; import com.badlogic.gdx.graphics.Cursor; import com.badlogic.gdx.graphics.Cursor.SystemCursor; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GL30; import com.badlogic.gdx.graphics.Pixmap; -import com.badlogic.gdx.graphics.glutils.GLVersion; import com.dragome.commons.javascript.ScriptHelper; import com.dragome.web.enhancers.jsdelegate.JsDelegateFactory; -import com.dragome.web.html.dom.html5canvas.interfaces.HTMLCanvasElement; +import com.dragome.web.html.dom.w3c.HTMLCanvasElementExtension; +import com.dragome.web.html.dom.w3c.WebGLRenderingContextExtension; /** @author xpenatan */ -public class DragomeGraphics implements Graphics { - - GLVersion glVersion; - HTMLCanvasElement canvas; +public class DragomeGraphics implements Graphics +{ + HTMLCanvasElementExtension canvas; GL20 gl; String extensions; - float fps = 0; - long lastTimeStamp = System.currentTimeMillis(); - long frameId = -1; - float deltaTime = 0; - float time = 0; + float fps= 0; + long lastTimeStamp= System.currentTimeMillis(); + long frameId= -1; + float deltaTime= 0; + float time= 0; int frames; DragomeApplicationConfiguration config; DragomeApplication app; - public DragomeGraphics (DragomeApplication app, DragomeApplicationConfiguration config) { - this.app = app; - Element canvasElement = app.elementBySelector.getElementBySelector("canvas"); - canvas = JsDelegateFactory.createFromNode(canvasElement, HTMLCanvasElement.class); - this.config = config; + public DragomeGraphics(DragomeApplication app, DragomeApplicationConfiguration config) + { + this.app= app; + Element canvasElement= app.elementBySelector.getElementBySelector("canvas"); + canvas= JsDelegateFactory.createFromNode(canvasElement, HTMLCanvasElementExtension.class); + this.config= config; } - public boolean init () { + public boolean init() + { ScriptHelper.put("canvas", canvas, this); - WebGLContextAttributes attributes = WebGLContextAttributes.create(); - attributes.set_antialias(config.antialiasing); - attributes.set_stencil(config.stencil); - attributes.set_alpha(config.alpha); - attributes.set_premultipliedAlpha(config.premultipliedAlpha); - attributes.set_preserveDrawingBuffer(config.preserveDrawingBuffer); - ScriptHelper.evalNoResult("var names = [ 'experimental-webgl', 'webgl', 'moz-webgl', 'webkit-webgl', 'webkit-3d']", this); - ScriptHelper.evalNoResult("var obj; for ( var i = 0; i < names.length; i++) { try {var ctx = canvas.node.getContext(names[i], attributes); if (ctx != null) { obj = ctx; } } catch (e) { } }", this); - Object instance = ScriptHelper.eval("obj", this); - if (instance == null) return false; - WebGLRenderingContext context = JsDelegateFactory.createFrom(instance, WebGLRenderingContext.class); - if(config.useDebugGL) - gl = new DragomeGL20Debug(context); + WebGLContextAttributes attributes= WebGLFactory.create(); + attributes.setAntialias(config.antialiasing); + attributes.setStencil(config.stencil); + attributes.setAlpha(config.alpha); + attributes.setPremultipliedAlpha(config.premultipliedAlpha); + attributes.setPreserveDrawingBuffer(config.preserveDrawingBuffer); + + WebGLRenderingContextExtension context= findWebGLContext(); + if (context == null) + return false; + + if (config.useDebugGL) + gl= new DragomeGL20Debug(context); else - gl = new DragomeGL20(context); + gl= new DragomeGL20(context); + return true; } - public void update () { - long currTimeStamp = System.currentTimeMillis(); - deltaTime = (currTimeStamp - lastTimeStamp) / 1000.0f; - lastTimeStamp = currTimeStamp; - time += deltaTime; + private WebGLRenderingContextExtension findWebGLContext() + { + String[] contextNames= new String[] { "moz-webgl", "webgl", "experimental-webgl", "webkit-webgl", "webkit-3d" }; + for (String contextName : contextNames) + { + Object context= canvas.getContext(contextName); + if (context != null) + return (WebGLRenderingContextExtension) context; + } + + return null; + } + + public void update() + { + long currTimeStamp= System.currentTimeMillis(); + deltaTime= (currTimeStamp - lastTimeStamp) / 1000.0f; + lastTimeStamp= currTimeStamp; + time+= deltaTime; frames++; - if (time > 1) { - this.fps = frames; - time = 0; - frames = 0; + if (time > 1) + { + this.fps= frames; + time= 0; + frames= 0; } } @Override - public boolean isGL30Available () { + public boolean isGL30Available() + { return false; } @Override - public GL20 getGL20 () { + public GL20 getGL20() + { return gl; } @Override - public GL30 getGL30 () { + public GL30 getGL30() + { return null; } @Override - public int getWidth () { + public int getWidth() + { return canvas.getWidth(); } @Override - public int getHeight () { + public int getHeight() + { return canvas.getHeight(); } @Override - public int getBackBufferWidth () { + public int getBackBufferWidth() + { return canvas.getWidth(); } @Override - public int getBackBufferHeight () { + public int getBackBufferHeight() + { return canvas.getHeight(); } @Override - public long getFrameId () { + public long getFrameId() + { return frameId; } @Override - public float getDeltaTime () { + public float getDeltaTime() + { return deltaTime; } @Override - public float getRawDeltaTime () { + public float getRawDeltaTime() + { return deltaTime; } @Override - public int getFramesPerSecond () { - return (int)fps; + public int getFramesPerSecond() + { + return (int) fps; } @Override - public GraphicsType getType () { + public GraphicsType getType() + { return GraphicsType.WebGL; } @Override - public float getPpiX () { + public float getPpiX() + { return 96; } @Override - public float getPpiY () { + public float getPpiY() + { return 96; } @Override - public float getPpcX () { + public float getPpcX() + { return 96 / 2.54f; } @Override - public float getPpcY () { + public float getPpcY() + { return 96 / 2.54f; } @Override - public float getDensity () { + public float getDensity() + { return 96.0f / 160; } @Override - public boolean supportsDisplayModeChange () { + public boolean supportsDisplayModeChange() + { return false; } @Override - public Monitor getPrimaryMonitor () { + public Monitor getPrimaryMonitor() + { return null; } @Override - public Monitor getMonitor () { + public Monitor getMonitor() + { return null; } @Override - public Monitor[] getMonitors () { + public Monitor[] getMonitors() + { return null; } @Override - public DisplayMode[] getDisplayModes () { + public DisplayMode[] getDisplayModes() + { return null; } @Override - public DisplayMode[] getDisplayModes (Monitor monitor) { + public DisplayMode[] getDisplayModes(Monitor monitor) + { return null; } @Override - public DisplayMode getDisplayMode () { + public DisplayMode getDisplayMode() + { return null; } @Override - public DisplayMode getDisplayMode (Monitor monitor) { + public DisplayMode getDisplayMode(Monitor monitor) + { return null; } @Override - public boolean setFullscreenMode (DisplayMode displayMode) { + public boolean setFullscreenMode(DisplayMode displayMode) + { return false; } @Override - public boolean setWindowedMode (int width, int height) { + public boolean setWindowedMode(int width, int height) + { return false; } @Override - public void setTitle (String title) { + public void setTitle(String title) + { } @Override - public void setVSync (boolean vsync) { + public void setVSync(boolean vsync) + { } @Override - public BufferFormat getBufferFormat () { + public BufferFormat getBufferFormat() + { return new BufferFormat(8, 8, 8, 0, 16, config.stencil ? 8 : 0, 0, false); } @Override - public boolean supportsExtension (String extension) { - if (extensions == null) extensions = Gdx.gl.glGetString(GL20.GL_EXTENSIONS); + public boolean supportsExtension(String extension) + { + if (extensions == null) + extensions= Gdx.gl.glGetString(GL20.GL_EXTENSIONS); return extensions.contains(extension); } @Override - public void setContinuousRendering (boolean isContinuous) { + public void setContinuousRendering(boolean isContinuous) + { } @Override - public boolean isContinuousRendering () { + public boolean isContinuousRendering() + { return true; } @Override - public void requestRendering () { + public void requestRendering() + { } @Override - public boolean isFullscreen () { + public boolean isFullscreen() + { return false; } @Override - public Cursor newCursor (Pixmap pixmap, int xHotspot, int yHotspot) { + public Cursor newCursor(Pixmap pixmap, int xHotspot, int yHotspot) + { return null; } @Override - public void setCursor (Cursor cursor) { - } - - @Override - public void setSystemCursor (SystemCursor systemCursor) { + public void setCursor(Cursor cursor) + { } @Override - public GLVersion getGLVersion() { - return glVersion; + public void setSystemCursor(SystemCursor systemCursor) + { } } diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/XMLHttpRequest.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/XMLHttpRequest.java index 51e0167b..88abc3ae 100644 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/XMLHttpRequest.java +++ b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/XMLHttpRequest.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright 2016 Natan Guilherme. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,8 @@ package com.badlogic.gdx.backends.dragome.js; -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBuffer; +import org.w3c.dom.typedarray.ArrayBuffer; + import com.dragome.commons.compiler.annotations.MethodAlias; import com.dragome.commons.javascript.ScriptHelper; import com.dragome.web.enhancers.jsdelegate.JsDelegateFactory; @@ -72,7 +73,7 @@ public int getStatus () { *

* See http://www.w3.org/TR/XMLHttpRequest/#the- * responsetext-attribute. - * + * * @return the response text */ public String getResponseText () { ScriptHelper.put("instance", instance, this); @@ -96,7 +97,7 @@ public String getResponseHeader (String header) { *

* See http:// * www.w3.org/TR/XMLHttpRequest/#the-open-method. - * + * * @param httpMethod the HTTP method to use * @param url the URL to be opened */ public void open (String httpMethod, String url) { @@ -110,7 +111,7 @@ public void open (String httpMethod, String url) { *

* See http:// * www.w3.org/TR/XMLHttpRequest/#the-open-method. - * + * * @param httpMethod the HTTP method to use * @param url the URL to be opened * @param user user to use in the URL */ @@ -171,7 +172,7 @@ public final void send () { *

* See http:// * www.w3.org/TR/XMLHttpRequest/#the-send-method. - * + * * @param requestData the data to be sent with the request */ public void send (String requestData) { ScriptHelper.put("instance", instance, this); @@ -203,7 +204,7 @@ public String getResponseTypeString () { public interface ReadyStateChangeHandler { /** This is called whenever the state of the XMLHttpRequest changes. See {@link XMLHttpRequest#setOnReadyStateChange}. - * + * * @param xhr the object whose state has changed. */ @MethodAlias(local_alias = "onReadyStateChange") void onReadyStateChange (XMLHttpRequest xhr); diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/storage/Storage.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/storage/Storage.java index 2f804fc7..2caddd2b 100644 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/storage/Storage.java +++ b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/storage/Storage.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright 2016 Natan Guilherme. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,6 +18,7 @@ import com.dragome.commons.javascript.ScriptHelper; import com.dragome.web.enhancers.jsdelegate.JsDelegateFactory; +import com.dragome.web.html.dom.w3c.ArrayBufferFactory; /** https://www.w3.org/TR/webstorage/#storage-0 * @author xpenatan */ @@ -25,11 +26,11 @@ public interface Storage { static final boolean localStorageSupported = checkStorageSupport("localStorage"); static final boolean sessionStorageSupported = checkStorageSupport("sessionStorage"); - public static Storage getLocalStorageIfSupported () { - Storage storage = null; + public static ArrayBufferFactory getLocalStorageIfSupported () { + ArrayBufferFactory storage = null; if (localStorageSupported || sessionStorageSupported) { Object instance = ScriptHelper.eval("window.localStorage", null); - storage = JsDelegateFactory.createFrom(instance, Storage.class); + storage = JsDelegateFactory.createFrom(instance, ArrayBufferFactory.class); } return storage; } diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/ArrayBuffer.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/ArrayBuffer.java deleted file mode 100644 index bfaaa274..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/ArrayBuffer.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.typedarrays; - -import com.dragome.commons.DelegateCode; -import com.dragome.commons.javascript.ScriptHelper; -import com.dragome.web.enhancers.jsdelegate.JsDelegateFactory; - -/** @author xpenatan */ -public interface ArrayBuffer { - - @DelegateCode(ignore = true) - public static ArrayBuffer create (int length) { - ScriptHelper.put("lenght", length, null); - Object instance = ScriptHelper.eval("new ArrayBuffer(length);", null); - ArrayBuffer node = JsDelegateFactory.createFrom(instance, ArrayBuffer.class); - return node; - } - - int get_byteLength (); -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/ArrayBufferView.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/ArrayBufferView.java deleted file mode 100644 index b7bc9b1a..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/ArrayBufferView.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.typedarrays; - -/** @author xpenatan */ -public interface ArrayBufferView { - - ArrayBuffer get_buffer (); - - int get_byteLength (); - - int get_byteOffset (); -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/DataView.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/DataView.java deleted file mode 100644 index f48d3772..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/DataView.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.typedarrays; - -import com.dragome.commons.DelegateCode; -import com.dragome.commons.javascript.ScriptHelper; -import com.dragome.web.enhancers.jsdelegate.JsDelegateFactory; - -/** @author xpenatan */ -public interface DataView extends ArrayBufferView { - - @DelegateCode(ignore = true) - public static DataView create (ArrayBuffer buffer) { - ScriptHelper.put("buffer", buffer, null); - Object instance = ScriptHelper.eval("new DataView(buffer.node);", null); - DataView node = JsDelegateFactory.createFrom(instance, DataView.class); - return node; - } - - @DelegateCode(ignore = true) - public static DataView create (ArrayBuffer buffer, int byteOffset) { - ScriptHelper.put("buffer", buffer, null); - ScriptHelper.put("byteOffset", byteOffset, null); - Object instance = ScriptHelper.eval("new DataView(buffer.node, byteOffset);", null); - DataView node = JsDelegateFactory.createFrom(instance, DataView.class); - return node; - }; - - @DelegateCode(ignore = true) - public static DataView create (ArrayBuffer buffer, int byteOffset, int length) { - ScriptHelper.put("buffer", buffer, null); - ScriptHelper.put("byteOffset", byteOffset, null); - ScriptHelper.put("length", length, null); - Object instance = ScriptHelper.eval("new DataView(buffer.node, byteOffset, length);", null); - DataView node = JsDelegateFactory.createFrom(instance, DataView.class); - return node; - }; - - float getFloat32 (int byteOffset); - - float getFloat32 (int byteOffset, boolean littleEndian); - - double getFloat64 (int byteOffset); - - double getFloat64 (int byteOffset, boolean littleEndian); - - byte getInt8 (int byteOffset); - - short getInt16 (int byteOffset); - - short getInt16 (int byteOffset, boolean littleEndian); - - int getInt32 (int byteOffset); - - int getInt32 (int byteOffset, boolean littleEndian); - - short getUint8 (int byteOffset); - - int getUint16 (int byteOffset); - - int getUint16 (int byteOffset, boolean littleEndian); - - long getUint32 (int byteOffset); - - long getUint32 (int byteOffset, boolean littleEndian); - - double getUint32AsDouble (int byteOffset); - - double getUint32AsDouble (int byteOffset, boolean littleEndian); - - void setFloat32 (int byteOffset, float value); - - void setFloat32 (int byteOffset, float value, boolean littleEndian); - - void setFloat64 (int byteOffset, double value); - - void setFloat64 (int byteOffset, double value, boolean littleEndian); - - void setInt8 (int byteOffset, int value); - - void setInt16 (int byteOffset, int value); - - void setInt16 (int byteOffset, int value, boolean littleEndian); - - void setInt32 (int byteOffset, int value); - - void setInt32 (int byteOffset, int value, boolean littleEndian); - - void setUint8 (int byteOffset, int i); - - void setUint16 (int byteOffset, int value); - - void setUint16 (int byteOffset, int value, boolean littleEndian); - - void setUint32 (int byteOffset, long value); - - void setUint32 (int byteOffset, long value, boolean littleEndian); - -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Float32Array.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Float32Array.java deleted file mode 100644 index 399c34f5..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Float32Array.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.typedarrays; - -import com.dragome.commons.DelegateCode; -import com.dragome.commons.javascript.ScriptHelper; -import com.dragome.web.enhancers.jsdelegate.JsDelegateFactory; - -/** @author xpenatan */ -public interface Float32Array extends ArrayBufferView { - - final int BYTES_PER_ELEMENT = 4; - - @DelegateCode(ignore = true) - public static Float32Array create (ArrayBuffer buffer) { - ScriptHelper.put("buffer", buffer, null); - Object instance = ScriptHelper.eval("new Float32Array(buffer.node);", null); - Float32Array node = JsDelegateFactory.createFrom(instance, Float32Array.class); - return node; - } - - @DelegateCode(ignore = true) - public static Float32Array create (ArrayBuffer buffer, int byteOffset) { - ScriptHelper.put("buffer", buffer, null); - ScriptHelper.put("byteOffset", byteOffset, null); - Object instance = ScriptHelper.eval("new Float32Array(buffer.node, byteOffset);", null); - Float32Array node = JsDelegateFactory.createFrom(instance, Float32Array.class); - return node; - }; - - @DelegateCode(ignore = true) - public static Float32Array create (ArrayBuffer buffer, int byteOffset, int length) { - ScriptHelper.put("buffer", buffer, null); - ScriptHelper.put("byteOffset", byteOffset, null); - ScriptHelper.put("length", length, null); - Object instance = ScriptHelper.eval("new Float32Array(buffer.node, byteOffset, length);", null); - Float32Array node = JsDelegateFactory.createFrom(instance, Float32Array.class); - return node; - }; - - @DelegateCode(ignore = true) - public static Float32Array create (int length) { - ScriptHelper.put("length", length, null); - Object instance = ScriptHelper.eval("new Float32Array(length);", null); - Float32Array node = JsDelegateFactory.createFrom(instance, Float32Array.class); - return node; - }; - - int get_length (); - - @DelegateCode(eval = "this.node[$1]") - float get (int index); - - @DelegateCode(eval = "this.node[$1] = $2") - void set (int index, float value); - - void set (Float32Array array, int offset); - - void set (float[] array, int offset); - - Float32Array subarray (int begin); - - Float32Array subarray (int begin, int end); -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Float64Array.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Float64Array.java deleted file mode 100644 index 568d808f..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Float64Array.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.typedarrays; - -import com.dragome.commons.DelegateCode; -import com.dragome.commons.javascript.ScriptHelper; -import com.dragome.web.enhancers.jsdelegate.JsDelegateFactory; - -/** @author xpenatan */ -public interface Float64Array extends ArrayBufferView { - - final int BYTES_PER_ELEMENT = 8; - - @DelegateCode(ignore = true) - public static Float64Array create (ArrayBuffer buffer) { - ScriptHelper.put("buffer", buffer, null); - Object instance = ScriptHelper.eval("new Float64Array(buffer.node);", null); - Float64Array node = JsDelegateFactory.createFrom(instance, Float64Array.class); - return node; - } - - @DelegateCode(ignore = true) - public static Float64Array create (ArrayBuffer buffer, int byteOffset) { - ScriptHelper.put("buffer", buffer, null); - ScriptHelper.put("byteOffset", byteOffset, null); - Object instance = ScriptHelper.eval("new Float64Array(buffer.node, byteOffset);", null); - Float64Array node = JsDelegateFactory.createFrom(instance, Float64Array.class); - return node; - }; - - @DelegateCode(ignore = true) - public static Float64Array create (ArrayBuffer buffer, int byteOffset, int length) { - ScriptHelper.put("buffer", buffer, null); - ScriptHelper.put("byteOffset", byteOffset, null); - ScriptHelper.put("length", length, null); - Object instance = ScriptHelper.eval("new Float64Array(buffer.node, byteOffset, length);", null); - Float64Array node = JsDelegateFactory.createFrom(instance, Float64Array.class); - return node; - }; - - @DelegateCode(ignore = true) - public static Float64Array create (int length) { - ScriptHelper.put("length", length, null); - Object instance = ScriptHelper.eval("new Float64Array(length);", null); - Float64Array node = JsDelegateFactory.createFrom(instance, Float64Array.class); - return node; - }; - - int get_length (); - - @DelegateCode(eval = "this.node[$1]") - double get (int index); - - @DelegateCode(eval = "this.node[$1] = $2") - void set (int index, double value); - - void set (Float64Array array, int offset); - - void set (double[] array, int offset); - - Float64Array subarray (int begin); - - Float64Array subarray (int begin, int end); -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Int16Array.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Int16Array.java deleted file mode 100644 index e560ca0a..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Int16Array.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.typedarrays; - -import com.dragome.commons.DelegateCode; -import com.dragome.commons.javascript.ScriptHelper; -import com.dragome.web.enhancers.jsdelegate.JsDelegateFactory; - -/** @author xpenatan */ -public interface Int16Array extends ArrayBufferView { - - final int BYTES_PER_ELEMENT = 2; - - @DelegateCode(ignore = true) - public static Int16Array create (ArrayBuffer buffer) { - ScriptHelper.put("buffer", buffer, null); - Object instance = ScriptHelper.eval("new Int16Array(buffer.node);", null); - Int16Array node = JsDelegateFactory.createFrom(instance, Int16Array.class); - return node; - } - - @DelegateCode(ignore = true) - public static Int16Array create (ArrayBuffer buffer, int byteOffset) { - ScriptHelper.put("buffer", buffer, null); - ScriptHelper.put("byteOffset", byteOffset, null); - Object instance = ScriptHelper.eval("new Int16Array(buffer.node, byteOffset);", null); - Int16Array node = JsDelegateFactory.createFrom(instance, Int16Array.class); - return node; - }; - - @DelegateCode(ignore = true) - public static Int16Array create (ArrayBuffer buffer, int byteOffset, int length) { - ScriptHelper.put("buffer", buffer, null); - ScriptHelper.put("byteOffset", byteOffset, null); - ScriptHelper.put("length", length, null); - Object instance = ScriptHelper.eval("new Int16Array(buffer.node, byteOffset, length);", null); - Int16Array node = JsDelegateFactory.createFrom(instance, Int16Array.class); - return node; - }; - - @DelegateCode(ignore = true) - public static Int16Array create (int length) { - ScriptHelper.put("length", length, null); - Object instance = ScriptHelper.eval("new Int16Array(length);", null); - Int16Array node = JsDelegateFactory.createFrom(instance, Int16Array.class); - return node; - }; - - int get_length (); - - @DelegateCode(eval = "this.node[$1]") - short get (int index); - - @DelegateCode(eval = "this.node[$1] = $2") - void set (int index, int value); - - void set (Int16Array array, int offset); - - void set (short[] array, int offset); - - void set (int[] array, int offset); - - Int16Array subarray (int begin, int end); -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Int32Array.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Int32Array.java deleted file mode 100644 index 5fc4d8fd..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Int32Array.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.typedarrays; - -import com.dragome.commons.DelegateCode; -import com.dragome.commons.javascript.ScriptHelper; -import com.dragome.web.enhancers.jsdelegate.JsDelegateFactory; - -/** @author xpenatan */ -public interface Int32Array extends ArrayBufferView { - - final int BYTES_PER_ELEMENT = 4; - - @DelegateCode(ignore = true) - public static Int32Array create (ArrayBuffer buffer) { - ScriptHelper.put("buffer", buffer, null); - Object instance = ScriptHelper.eval("new Int32Array(buffer.node);", null); - Int32Array node = JsDelegateFactory.createFrom(instance, Int32Array.class); - return node; - } - - @DelegateCode(ignore = true) - public static Int32Array create (ArrayBuffer buffer, int byteOffset) { - ScriptHelper.put("buffer", buffer, null); - ScriptHelper.put("byteOffset", byteOffset, null); - Object instance = ScriptHelper.eval("new Int32Array(buffer.node, byteOffset);", null); - Int32Array node = JsDelegateFactory.createFrom(instance, Int32Array.class); - return node; - }; - - @DelegateCode(ignore = true) - public static Int32Array create (ArrayBuffer buffer, int byteOffset, int length) { - ScriptHelper.put("buffer", buffer, null); - ScriptHelper.put("byteOffset", byteOffset, null); - ScriptHelper.put("length", length, null); - Object instance = ScriptHelper.eval("new Int32Array(buffer.node, byteOffset, length);", null); - Int32Array node = JsDelegateFactory.createFrom(instance, Int32Array.class); - return node; - }; - - @DelegateCode(ignore = true) - public static Int32Array create (int length) { - ScriptHelper.put("length", length, null); - Object instance = ScriptHelper.eval("new Int32Array(length);", null); - Int32Array node = JsDelegateFactory.createFrom(instance, Int32Array.class); - return node; - }; - - int get_length (); - - @DelegateCode(eval = "this.node[$1]") - int get (int index); - - @DelegateCode(eval = "this.node[$1] = $2") - void set (int index, int value); - - void set (Int32Array array, int offset); - - void set (int[] array, int offset); - - Int32Array subarray (int begin, int end); -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Int8Array.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Int8Array.java deleted file mode 100644 index b286a271..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Int8Array.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.typedarrays; - -import com.dragome.commons.DelegateCode; -import com.dragome.commons.javascript.ScriptHelper; -import com.dragome.web.enhancers.jsdelegate.JsDelegateFactory; - -/** @author xpenatan */ -public interface Int8Array extends ArrayBufferView { - - final int BYTES_PER_ELEMENT = 1; - - @DelegateCode(ignore = true) - public static Int8Array create (ArrayBuffer buffer) { - ScriptHelper.put("buffer", buffer, null); - Object instance = ScriptHelper.eval("new Int8Array(buffer.node);", null); - Int8Array node = JsDelegateFactory.createFrom(instance, Int8Array.class); - return node; - } - - @DelegateCode(ignore = true) - public static Int8Array create (ArrayBuffer buffer, int byteOffset) { - ScriptHelper.put("buffer", buffer, null); - ScriptHelper.put("byteOffset", byteOffset, null); - Object instance = ScriptHelper.eval("new Int8Array(buffer.node, byteOffset);", null); - Int8Array node = JsDelegateFactory.createFrom(instance, Int8Array.class); - return node; - }; - - @DelegateCode(ignore = true) - public static Int8Array create (ArrayBuffer buffer, int byteOffset, int length) { - ScriptHelper.put("buffer", buffer, null); - ScriptHelper.put("byteOffset", byteOffset, null); - ScriptHelper.put("length", length, null); - Object instance = ScriptHelper.eval("new Int8Array(buffer.node, byteOffset, length);", null); - Int8Array node = JsDelegateFactory.createFrom(instance, Int8Array.class); - return node; - }; - - @DelegateCode(ignore = true) - public static Int8Array create (int length) { - ScriptHelper.put("length", length, null); - Object instance = ScriptHelper.eval("new Int8Array(length);", null); - Int8Array node = JsDelegateFactory.createFrom(instance, Int8Array.class); - return node; - }; - - int get_length (); - - @DelegateCode(eval = "this.node[$1]") - byte get (int index); - - @DelegateCode(eval = "this.node[$1] = $2") - void set (int index, int value); - - void set (Int8Array array, int offset); - - void set (byte[] array, int offset); - - void set (int[] array, int offset); - - Int8Array subarray (int begin); - - Int8Array subarray (int begin, int end); -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/SharedArrayBuffer.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/SharedArrayBuffer.java deleted file mode 100644 index dc36bf36..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/SharedArrayBuffer.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.typedarrays; - -/** @author xpenatan */ -public interface SharedArrayBuffer { -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Uint16Array.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Uint16Array.java deleted file mode 100644 index 35b41bdf..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Uint16Array.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.typedarrays; - -import com.dragome.commons.DelegateCode; -import com.dragome.commons.javascript.ScriptHelper; -import com.dragome.web.enhancers.jsdelegate.JsDelegateFactory; - -/** @author xpenatan */ -public interface Uint16Array extends ArrayBufferView { - - final int BYTES_PER_ELEMENT = 2; - - @DelegateCode(ignore = true) - public static Uint16Array create (ArrayBuffer buffer) { - ScriptHelper.put("buffer", buffer, null); - Object instance = ScriptHelper.eval("new Uint16Array(buffer.node);", null); - Uint16Array node = JsDelegateFactory.createFrom(instance, Uint16Array.class); - return node; - } - - @DelegateCode(ignore = true) - public static Uint16Array create (ArrayBuffer buffer, int byteOffset) { - ScriptHelper.put("buffer", buffer, null); - ScriptHelper.put("byteOffset", byteOffset, null); - Object instance = ScriptHelper.eval("new Uint16Array(buffer.node, byteOffset);", null); - Uint16Array node = JsDelegateFactory.createFrom(instance, Uint16Array.class); - return node; - }; - - @DelegateCode(ignore = true) - public static Uint16Array create (ArrayBuffer buffer, int byteOffset, int length) { - ScriptHelper.put("buffer", buffer, null); - ScriptHelper.put("byteOffset", byteOffset, null); - ScriptHelper.put("length", length, null); - Object instance = ScriptHelper.eval("new Uint16Array(buffer.node, byteOffset, length);", null); - Uint16Array node = JsDelegateFactory.createFrom(instance, Uint16Array.class); - return node; - }; - - @DelegateCode(ignore = true) - public static Uint16Array create (int length) { - ScriptHelper.put("length", length, null); - Object instance = ScriptHelper.eval("new Uint16Array(length);", null); - Uint16Array node = JsDelegateFactory.createFrom(instance, Uint16Array.class); - return node; - }; - - int get_length (); - - @DelegateCode(eval = "this.node[$1]") - int get (int index); - - @DelegateCode(eval = "this.node[$1] = $2") - void set (int index, int value); - - void set (Uint16Array array, int offset); - - void set (int[] array, int offset); - - Uint16Array subarray (int begin); - - Uint16Array subarray (int begin, int end); -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Uint32Array.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Uint32Array.java deleted file mode 100644 index 3d7dd938..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Uint32Array.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.typedarrays; - -import com.dragome.commons.DelegateCode; -import com.dragome.commons.javascript.ScriptHelper; -import com.dragome.web.enhancers.jsdelegate.JsDelegateFactory; - -/** @author xpenatan */ -public interface Uint32Array extends ArrayBufferView { - - final int BYTES_PER_ELEMENT = 4; - - @DelegateCode(ignore = true) - public static Uint32Array create (ArrayBuffer buffer) { - ScriptHelper.put("buffer", buffer, null); - Object instance = ScriptHelper.eval("new Uint32Array(buffer.node);", null); - Uint32Array node = JsDelegateFactory.createFrom(instance, Uint32Array.class); - return node; - } - - @DelegateCode(ignore = true) - public static Uint32Array create (ArrayBuffer buffer, int byteOffset) { - ScriptHelper.put("buffer", buffer, null); - ScriptHelper.put("byteOffset", byteOffset, null); - Object instance = ScriptHelper.eval("new Uint32Array(buffer.node, byteOffset);", null); - Uint32Array node = JsDelegateFactory.createFrom(instance, Uint32Array.class); - return node; - }; - - @DelegateCode(ignore = true) - public static Uint32Array create (ArrayBuffer buffer, int byteOffset, int length) { - ScriptHelper.put("buffer", buffer, null); - ScriptHelper.put("byteOffset", byteOffset, null); - ScriptHelper.put("length", length, null); - Object instance = ScriptHelper.eval("new Uint32Array(buffer.node, byteOffset, length);", null); - Uint32Array node = JsDelegateFactory.createFrom(instance, Uint32Array.class); - return node; - }; - - @DelegateCode(ignore = true) - public static Uint32Array create (int length) { - ScriptHelper.put("length", length, null); - Object instance = ScriptHelper.eval("new Uint32Array(length);", null); - Uint32Array node = JsDelegateFactory.createFrom(instance, Uint32Array.class); - return node; - }; - - int get_length (); - - @DelegateCode(eval = "this.node[$1]") - long get (int index); - - @DelegateCode(eval = "this.node[$1]") - double getAsDouble (int index); - - @DelegateCode(eval = "this.node[$1] = $2") - void set (int index, long value); - - @DelegateCode(eval = "this.node[$1] = $2") - void set (int index, double value); - - void set (Uint32Array array, int offset); - - void set (long[] array, int offset); - - void set (double[] array, int offset); - - Uint32Array subarray (int begin); - - Uint32Array subarray (int begin, int end); -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Uint8Array.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Uint8Array.java deleted file mode 100644 index 61215951..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Uint8Array.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.typedarrays; - -import com.dragome.commons.DelegateCode; -import com.dragome.commons.javascript.ScriptHelper; -import com.dragome.web.enhancers.jsdelegate.JsDelegateFactory; - -/** @author xpenatan */ -public interface Uint8Array extends ArrayBufferView { - - final int BYTES_PER_ELEMENT = 1; - - @DelegateCode(ignore = true) - public static Uint8Array create (ArrayBuffer buffer) { - ScriptHelper.put("buffer", buffer, null); - Object instance = ScriptHelper.eval("new Uint8Array(buffer.node);", null); - Uint8Array node = JsDelegateFactory.createFrom(instance, Uint8Array.class); - return node; - } - - @DelegateCode(ignore = true) - public static Uint8Array create (ArrayBuffer buffer, int byteOffset) { - ScriptHelper.put("buffer", buffer, null); - ScriptHelper.put("byteOffset", byteOffset, null); - Object instance = ScriptHelper.eval("new Uint8Array(buffer.node, byteOffset);", null); - Uint8Array node = JsDelegateFactory.createFrom(instance, Uint8Array.class); - return node; - }; - - @DelegateCode(ignore = true) - public static Uint8Array create (ArrayBuffer buffer, int byteOffset, int length) { - ScriptHelper.put("buffer", buffer, null); - ScriptHelper.put("byteOffset", byteOffset, null); - ScriptHelper.put("length", length, null); - Object instance = ScriptHelper.eval("new Uint8Array(buffer.node, byteOffset, length);", null); - Uint8Array node = JsDelegateFactory.createFrom(instance, Uint8Array.class); - return node; - }; - - @DelegateCode(ignore = true) - public static Uint8Array create (int length) { - ScriptHelper.put("length", length, null); - Object instance = ScriptHelper.eval("new Uint8Array(length);", null); - Uint8Array node = JsDelegateFactory.createFrom(instance, Uint8Array.class); - return node; - }; - - int get_length (); - - @DelegateCode(eval = "this.node[$1]") - short get (int index); - - @DelegateCode(eval = "this.node[$1] = $2") - void set (int index, int value); - - void set (Uint8Array array, int offset); - - void set (int[] array, int offset); - - void set (short[] array, int offset); - - Uint8Array subarray (int begin); - - Uint8Array subarray (int begin, int end); -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Uint8ClampedArray.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Uint8ClampedArray.java deleted file mode 100644 index b8de5852..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/Uint8ClampedArray.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.typedarrays; - -import com.dragome.commons.DelegateCode; -import com.dragome.commons.javascript.ScriptHelper; -import com.dragome.web.enhancers.jsdelegate.JsDelegateFactory; - -/** @author xpenatan */ -public interface Uint8ClampedArray extends Uint8Array { - - @DelegateCode(ignore = true) - public static Uint8ClampedArray createClamped (ArrayBuffer buffer) { - ScriptHelper.put("buffer", buffer, null); - Object instance = ScriptHelper.eval("new Uint8ClampedArray(buffer.node);", null); - Uint8ClampedArray node = JsDelegateFactory.createFrom(instance, Uint8ClampedArray.class); - return node; - } - - @DelegateCode(ignore = true) - public static Uint8ClampedArray createClamped (ArrayBuffer buffer, int byteOffset) { - ScriptHelper.put("buffer", buffer, null); - ScriptHelper.put("byteOffset", byteOffset, null); - Object instance = ScriptHelper.eval("new Uint8ClampedArray(buffer.node, byteOffset);", null); - Uint8ClampedArray node = JsDelegateFactory.createFrom(instance, Uint8ClampedArray.class); - return node; - }; - - @DelegateCode(ignore = true) - public static Uint8ClampedArray createClamped (ArrayBuffer buffer, int byteOffset, int length) { - ScriptHelper.put("buffer", buffer, null); - ScriptHelper.put("byteOffset", byteOffset, null); - ScriptHelper.put("length", length, null); - Object instance = ScriptHelper.eval("new Uint8ClampedArray(buffer.node, byteOffset, length);", null); - Uint8ClampedArray node = JsDelegateFactory.createFrom(instance, Uint8ClampedArray.class); - return node; - }; - - @DelegateCode(ignore = true) - public static Uint8ClampedArray createClamped (int length) { - ScriptHelper.put("length", length, null); - Object instance = ScriptHelper.eval("new Uint8ClampedArray(length);", null); - Uint8ClampedArray node = JsDelegateFactory.createFrom(instance, Uint8ClampedArray.class); - return node; - }; - - public static Uint8ClampedArray createClamped (short[] array) { - return null; - } - - Uint8ClampedArray subarray (int begin); - - Uint8ClampedArray subarray (int begin, int end); -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/utils/NativeImpl.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/utils/NativeImpl.java deleted file mode 100644 index 9d30d294..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/utils/NativeImpl.java +++ /dev/null @@ -1,325 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.typedarrays.utils; - -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBuffer; -import com.badlogic.gdx.backends.dragome.js.typedarrays.DataView; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Float32Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Float64Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Int16Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Int32Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Int8Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Uint16Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Uint32Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Uint8Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Uint8ClampedArray; -import com.badlogic.gdx.backends.dragome.js.typedarrays.utils.TypedArrays.Impl; -import com.dragome.commons.javascript.ScriptHelper; -import com.dragome.web.enhancers.jsdelegate.JsDelegateFactory; - -public class NativeImpl extends Impl { - - @Override - public ArrayBuffer createArrayBuffer (int length) { - return ArrayBuffer.create(length); - } - - @Override - public DataView createDataView (ArrayBuffer buffer) { - return DataView.create(buffer); - } - - @Override - public DataView createDataView (ArrayBuffer buffer, int byteOffset) { - return DataView.create(buffer, byteOffset); - } - - @Override - public DataView createDataView (ArrayBuffer buffer, int byteOffset, int byteLength) { - return DataView.create(buffer, byteOffset, byteLength); - } - - @Override - public Float32Array createFloat32Array (ArrayBuffer buffer) { - return Float32Array.create(buffer); - } - - @Override - public Float32Array createFloat32Array (ArrayBuffer buffer, int byteOffset) { - return Float32Array.create(buffer, byteOffset); - } - - @Override - public Float32Array createFloat32Array (ArrayBuffer buffer, int byteOffset, int length) { - return Float32Array.create(buffer, byteOffset, length); - } - - @Override - public Float32Array createFloat32Array (float[] array) { - ScriptHelper.put("array", array, this); - Object eval = ScriptHelper.eval("new Float32Array(array)", this); - return JsDelegateFactory.createFrom(eval, Float32Array.class); - } - - @Override - public Float32Array createFloat32Array (int length) { - return Float32Array.create(length); - } - - @Override - public Float64Array createFloat64Array (ArrayBuffer buffer) { - return Float64Array.create(buffer); - } - - @Override - public Float64Array createFloat64Array (ArrayBuffer buffer, int byteOffset) { - return Float64Array.create(buffer, byteOffset); - } - - @Override - public Float64Array createFloat64Array (ArrayBuffer buffer, int byteOffset, int length) { - return Float64Array.create(buffer, byteOffset, length); - } - - @Override - public Float64Array createFloat64Array (double[] array) { - ScriptHelper.put("array", array, this); - Object eval = ScriptHelper.eval("new Float64Array(array)", this); - return JsDelegateFactory.createFrom(eval, Float64Array.class); - } - - @Override - public Float64Array createFloat64Array (int length) { - return Float64Array.create(length); - } - - @Override - public Int16Array createInt16Array (ArrayBuffer buffer) { - return Int16Array.create(buffer); - } - - @Override - public Int16Array createInt16Array (ArrayBuffer buffer, int byteOffset) { - return Int16Array.create(buffer, byteOffset); - } - - @Override - public Int16Array createInt16Array (ArrayBuffer buffer, int byteOffset, int length) { - return Int16Array.create(buffer, byteOffset, length); - } - - @Override - public Int16Array createInt16Array (int length) { - return Int16Array.create(length); - } - - @Override - public Int16Array createInt16Array (short[] array) { - ScriptHelper.put("array", array, this); - Object eval = ScriptHelper.eval("new Int16Array(array)", this); - return JsDelegateFactory.createFrom(eval, Int16Array.class); - } - - @Override - public Int32Array createInt32Array (ArrayBuffer buffer) { - return Int32Array.create(buffer); - } - - @Override - public Int32Array createInt32Array (ArrayBuffer buffer, int byteOffset) { - return Int32Array.create(buffer, byteOffset); - } - - @Override - public Int32Array createInt32Array (ArrayBuffer buffer, int byteOffset, int length) { - return Int32Array.create(buffer, byteOffset, length); - } - - @Override - public Int32Array createInt32Array (int length) { - return Int32Array.create(length); - } - - @Override - public Int32Array createInt32Array (int[] array) { - ScriptHelper.put("array", array, this); - Object eval = ScriptHelper.eval("new Int32Array(array)", this); - return JsDelegateFactory.createFrom(eval, Int32Array.class); - } - - @Override - public Int8Array createInt8Array (ArrayBuffer buffer) { - return Int8Array.create(buffer); - } - - @Override - public Int8Array createInt8Array (ArrayBuffer buffer, int byteOffset) { - return Int8Array.create(buffer, byteOffset); - } - - @Override - public Int8Array createInt8Array (ArrayBuffer buffer, int byteOffset, int length) { - return Int8Array.create(buffer, byteOffset, length); - } - - @Override - public Int8Array createInt8Array (byte[] array) { - ScriptHelper.put("array", array, this); - Object eval = ScriptHelper.eval("new Int8Array(array)", this); - return JsDelegateFactory.createFrom(eval, Int8Array.class); - } - - @Override - public Int8Array createInt8Array (int length) { - return Int8Array.create(length); - } - - @Override - public Uint16Array createUint16Array (ArrayBuffer buffer) { - return Uint16Array.create(buffer); - } - - @Override - public Uint16Array createUint16Array (ArrayBuffer buffer, int byteOffset) { - return Uint16Array.create(buffer, byteOffset); - } - - @Override - public Uint16Array createUint16Array (ArrayBuffer buffer, int byteOffset, int length) { - return Uint16Array.create(buffer, byteOffset, length); - } - - @Override - public Uint16Array createUint16Array (int length) { - return Uint16Array.create(length); - } - - @Override - public Uint16Array createUint16Array (int[] array) { - ScriptHelper.put("array", array, this); - Object eval = ScriptHelper.eval("new Uint16Array(array)", this); - return JsDelegateFactory.createFrom(eval, Uint16Array.class); - } - - @Override - public Uint32Array createUint32Array (ArrayBuffer buffer) { - return Uint32Array.create(buffer); - } - - @Override - public Uint32Array createUint32Array (ArrayBuffer buffer, int byteOffset) { - return Uint32Array.create(buffer, byteOffset); - } - - @Override - public Uint32Array createUint32Array (ArrayBuffer buffer, int byteOffset, int length) { - return Uint32Array.create(buffer, byteOffset, length); - } - - @Override - public Uint32Array createUint32Array (double[] array) { - ScriptHelper.put("array", array, this); - Object eval = ScriptHelper.eval("new Uint32Array(array)", this); - return JsDelegateFactory.createFrom(eval, Uint32Array.class); - } - - @Override - public Uint32Array createUint32Array (int length) { - return Uint32Array.create(length); - } - - @Override - public Uint32Array createUint32Array (long[] array) { - int len = array.length; - double[] temp = new double[len]; - for (int i = 0; i < len; ++i) { - temp[i] = array[i]; - } - ScriptHelper.put("array", temp, this); - Object eval = ScriptHelper.eval("new Uint32Array(array)", this); - return JsDelegateFactory.createFrom(eval, Uint32Array.class); - } - - @Override - public Uint8Array createUint8Array (ArrayBuffer buffer) { - return Uint8Array.create(buffer); - } - - @Override - public Uint8Array createUint8Array (ArrayBuffer buffer, int byteOffset) { - return Uint8Array.create(buffer, byteOffset); - } - - @Override - public Uint8Array createUint8Array (ArrayBuffer buffer, int byteOffset, int length) { - return Uint8Array.create(buffer, byteOffset, length); - } - - @Override - public Uint8Array createUint8Array (int length) { - return Uint8Array.create(length); - } - - @Override - public Uint8Array createUint8Array (short[] array) { - ScriptHelper.put("array", array, this); - Object eval = ScriptHelper.eval("new Uint8Array(array)", this); - return JsDelegateFactory.createFrom(eval, Uint8Array.class); - } - - @Override - public Uint8ClampedArray createUint8ClampedArray (ArrayBuffer buffer) { - return Uint8ClampedArray.createClamped(buffer); - } - - @Override - public Uint8ClampedArray createUint8ClampedArray (ArrayBuffer buffer, int byteOffset) { - return Uint8ClampedArray.createClamped(buffer, byteOffset); - } - - @Override - public Uint8ClampedArray createUint8ClampedArray (ArrayBuffer buffer, int byteOffset, int length) { - return Uint8ClampedArray.createClamped(buffer, byteOffset, length); - } - - @Override - public Uint8ClampedArray createUint8ClampedArray (int length) { - return Uint8ClampedArray.createClamped(length); - } - - @Override - public Uint8ClampedArray createUint8ClampedArray (short[] array) { - return Uint8ClampedArray.createClamped(array); - } - - protected boolean checkDataViewSupport () - { - return ScriptHelper.evalBoolean("!!(window.DataView)", this); - } - - - protected boolean checkUint8ClampedArraySupport () - { - return ScriptHelper.evalBoolean("!!(window.Uint8ClampedArray)", this); - } - - @Override - protected boolean runtimeSupportCheck () - { - return ScriptHelper.evalBoolean("!!(window.ArrayBuffer)", this); - } -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/utils/TypedArrays.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/utils/TypedArrays.java deleted file mode 100644 index 39cfacba..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/utils/TypedArrays.java +++ /dev/null @@ -1,673 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.typedarrays.utils; - -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBuffer; -import com.badlogic.gdx.backends.dragome.js.typedarrays.DataView; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Float32Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Float64Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Int16Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Int32Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Int8Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Uint16Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Uint32Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Uint8Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Uint8ClampedArray; - -public class TypedArrays { - - /** Base class of implementations for creating various typed array structures. - *

- * *** NOT A PUBLIC API *** */ - public abstract static class Impl { - - /** Get the number of elements in a number of bytes, throwing an exception if it isn't an integral number. - * - * @param byteLength - * @param elemLength length of each element in bytes - * @return count of elements - * @throws IllegalArgumentException if {@code byteLength} isn't an integral multiple of {@code elemLength} */ - protected static int getElementCount (int byteLength, int elemLength) { - int count = byteLength / elemLength; - if (count * elemLength != byteLength) { - throw new IllegalArgumentException(); - } - return count; - } - - public abstract ArrayBuffer createArrayBuffer (int length); - - public DataView createDataView (ArrayBuffer buffer) { - return createDataView(buffer, 0, buffer.get_byteLength()); - } - - public DataView createDataView (ArrayBuffer buffer, int offset) { - return createDataView(buffer, offset, buffer.get_byteLength() - offset); - } - - public abstract DataView createDataView (ArrayBuffer buffer, int byteOffset, int byteLength); - - public Float32Array createFloat32Array (ArrayBuffer buffer) { - return createFloat32Array(buffer, 0, getElementCount(buffer.get_byteLength(), Float32Array.BYTES_PER_ELEMENT)); - } - - public Float32Array createFloat32Array (ArrayBuffer buffer, int byteOffset) { - return createFloat32Array(buffer, byteOffset, - getElementCount(buffer.get_byteLength() - byteOffset, Float32Array.BYTES_PER_ELEMENT)); - } - - public abstract Float32Array createFloat32Array (ArrayBuffer buffer, int byteOffset, int length); - - public Float32Array createFloat32Array (float[] array) { - Float32Array result = createFloat32Array(array.length); - result.set(array, 0); - return result; - } - - public Float32Array createFloat32Array (int length) { - return createFloat32Array(createArrayBuffer(length * Float32Array.BYTES_PER_ELEMENT)); - } - - public Float64Array createFloat64Array (ArrayBuffer buffer) { - return createFloat64Array(buffer, 0, getElementCount(buffer.get_byteLength(), Float64Array.BYTES_PER_ELEMENT)); - } - - public Float64Array createFloat64Array (ArrayBuffer buffer, int byteOffset) { - return createFloat64Array(buffer, byteOffset, - getElementCount(buffer.get_byteLength() - byteOffset, Float64Array.BYTES_PER_ELEMENT)); - } - - public abstract Float64Array createFloat64Array (ArrayBuffer buffer, int byteOffset, int length); - - public Float64Array createFloat64Array (double[] array) { - Float64Array result = createFloat64Array(array.length); - result.set(array, 0); - return result; - } - - public Float64Array createFloat64Array (int length) { - return createFloat64Array(createArrayBuffer(length * Float64Array.BYTES_PER_ELEMENT)); - } - - public Int16Array createInt16Array (ArrayBuffer buffer) { - return createInt16Array(buffer, 0, getElementCount(buffer.get_byteLength(), Int16Array.BYTES_PER_ELEMENT)); - } - - public Int16Array createInt16Array (ArrayBuffer buffer, int byteOffset) { - return createInt16Array(buffer, byteOffset, - getElementCount(buffer.get_byteLength() - byteOffset, Int16Array.BYTES_PER_ELEMENT)); - } - - public abstract Int16Array createInt16Array (ArrayBuffer buffer, int byteOffset, int length); - - public Int16Array createInt16Array (int length) { - return createInt16Array(createArrayBuffer(length * Int16Array.BYTES_PER_ELEMENT)); - } - - public Int16Array createInt16Array (short[] array) { - Int16Array result = createInt16Array(array.length); - result.set(array, 0); - return result; - } - - public Int32Array createInt32Array (ArrayBuffer buffer) { - return createInt32Array(buffer, 0, getElementCount(buffer.get_byteLength(), Int32Array.BYTES_PER_ELEMENT)); - } - - public Int32Array createInt32Array (ArrayBuffer buffer, int byteOffset) { - return createInt32Array(buffer, byteOffset, - getElementCount(buffer.get_byteLength() - byteOffset, Int32Array.BYTES_PER_ELEMENT)); - } - - public abstract Int32Array createInt32Array (ArrayBuffer buffer, int byteOffset, int length); - - public Int32Array createInt32Array (int length) { - return createInt32Array(createArrayBuffer(length * Int32Array.BYTES_PER_ELEMENT)); - } - - public Int32Array createInt32Array (int[] array) { - Int32Array result = createInt32Array(array.length); - result.set(array, 0); - return result; - } - - public Int8Array createInt8Array (ArrayBuffer buffer) { - return createInt8Array(buffer, 0, buffer.get_byteLength()); - } - - public Int8Array createInt8Array (ArrayBuffer buffer, int byteOffset) { - return createInt8Array(buffer, byteOffset, buffer.get_byteLength() - byteOffset); - } - - public abstract Int8Array createInt8Array (ArrayBuffer buffer, int byteOffset, int length); - - public Int8Array createInt8Array (byte[] array) { - Int8Array result = createInt8Array(array.length); - result.set(array, 0); - return result; - } - - public Int8Array createInt8Array (int length) { - return createInt8Array(createArrayBuffer(length)); - } - - public Uint16Array createUint16Array (ArrayBuffer buffer) { - return createUint16Array(buffer, 0, getElementCount(buffer.get_byteLength(), Uint16Array.BYTES_PER_ELEMENT)); - } - - public Uint16Array createUint16Array (ArrayBuffer buffer, int byteOffset) { - return createUint16Array(buffer, byteOffset, - getElementCount(buffer.get_byteLength() - byteOffset, Uint16Array.BYTES_PER_ELEMENT)); - } - - public abstract Uint16Array createUint16Array (ArrayBuffer buffer, int byteOffset, int length); - - public Uint16Array createUint16Array (int length) { - return createUint16Array(createArrayBuffer(length * Uint16Array.BYTES_PER_ELEMENT)); - } - - public Uint16Array createUint16Array (int[] array) { - Uint16Array result = createUint16Array(array.length); - result.set(array, 0); - return result; - } - - public Uint32Array createUint32Array (ArrayBuffer buffer) { - return createUint32Array(buffer, 0, getElementCount(buffer.get_byteLength(), Uint32Array.BYTES_PER_ELEMENT)); - } - - public Uint32Array createUint32Array (ArrayBuffer buffer, int byteOffset) { - return createUint32Array(buffer, byteOffset, - getElementCount(buffer.get_byteLength() - byteOffset, Uint32Array.BYTES_PER_ELEMENT)); - } - - public abstract Uint32Array createUint32Array (ArrayBuffer buffer, int byteOffset, int length); - - public Uint32Array createUint32Array (double[] array) { - Uint32Array result = createUint32Array(array.length); - result.set(array, 0); - return result; - } - - public Uint32Array createUint32Array (int length) { - return createUint32Array(createArrayBuffer(length * Uint32Array.BYTES_PER_ELEMENT)); - } - - public Uint32Array createUint32Array (long[] array) { - Uint32Array result = createUint32Array(array.length); - result.set(array, 0); - return result; - } - - public Uint8Array createUint8Array (ArrayBuffer buffer) { - return createUint8Array(buffer, 0, buffer.get_byteLength()); - } - - public Uint8Array createUint8Array (ArrayBuffer buffer, int byteOffset) { - return createUint8Array(buffer, byteOffset, buffer.get_byteLength() - byteOffset); - } - - public abstract Uint8Array createUint8Array (ArrayBuffer buffer, int byteOffset, int length); - - public Uint8Array createUint8Array (int length) { - return createUint8Array(createArrayBuffer(length)); - } - - public Uint8Array createUint8Array (short[] array) { - Uint8Array result = createUint8Array(array.length); - result.set(array, 0); - return result; - } - - public Uint8ClampedArray createUint8ClampedArray (ArrayBuffer buffer) { - return createUint8ClampedArray(buffer, 0, buffer.get_byteLength()); - } - - public Uint8ClampedArray createUint8ClampedArray (ArrayBuffer buffer, int byteOffset) { - return createUint8ClampedArray(buffer, byteOffset, buffer.get_byteLength() - byteOffset); - } - - public abstract Uint8ClampedArray createUint8ClampedArray (ArrayBuffer buffer, int byteOffset, int length); - - public Uint8ClampedArray createUint8ClampedArray (int length) { - return createUint8ClampedArray(createArrayBuffer(length)); - } - - public Uint8ClampedArray createUint8ClampedArray (short[] array) { - Uint8ClampedArray result = createUint8ClampedArray(array.length); - result.set(array, 0); - return result; - } - - /** Check if the current environment might possibly support typed arrays. - *

- * The default implementation always returns true, and this is intended to be a static check based on deffered-bound - * parameters. - * - * @return true if the current environment might possibly support typed arrays */ - protected boolean mightBeSupported () { - return true; - } - - /** Check if the current environment actually does support typed arrays (including emulation). There is no partial support, - * so if true is returned, there must be acceptable implementations for all of the {@code createXXX} methods. - * - * @return true if the current environment actually does support typed arrays */ - protected boolean runtimeSupportCheck () { - return false; - } - } - - /** This class exists to keep clinit calls from littering callsites when compiled to JS. */ - private static class Instance { - protected static final Impl impl = TypedArraysFactory.createImpl(); - } - - /** Create a new {@link ArrayBuffer} of {@code length} bytes. - * - * @param length length of buffer in bytes - * @return an {@link ArrayBuffer} instance */ - public static ArrayBuffer createArrayBuffer (int length) { - return Instance.impl.createArrayBuffer(length); - } - - /** Create a new {@link DataView} instance on an {@link ArrayBuffer}. - * - * @param buffer {@link ArrayBuffer} - * @return {@link DataView} instance */ - public static DataView createDataView (ArrayBuffer buffer) { - return Instance.impl.createDataView(buffer); - } - - /** Create a new {@link DataView} instance on an {@link ArrayBuffer}, starting at an offset of {@code byteOffset}. - * - * @param buffer {@link ArrayBuffer} - * @param byteOffset offset into buffer - * @return {@link DataView} instance */ - public static DataView createDataView (ArrayBuffer buffer, int byteOffset) { - return Instance.impl.createDataView(buffer, byteOffset); - } - - /** Create a new {@link DataView} instance on an {@link ArrayBuffer}, starting at an offset of {@code byteOffset} and - * continuing for {@code length} bytes. - * - * @param buffer {@link ArrayBuffer} - * @param byteOffset offset into buffer - * @param byteLength length of view in bytes - * @return {@link DataView} instance */ - public static DataView createDataView (ArrayBuffer buffer, int byteOffset, int byteLength) { - return Instance.impl.createDataView(buffer, byteOffset, byteLength); - } - - /** Create a {@link Float32Array} instance on {@code buffer}, starting at starting at the beginning of the buffer and - * continuing to the end (which must be an integral number of elements). - * - * @param buffer underlying {@link ArrayBuffer} - * @return an {@link Float32Array} instance */ - public static Float32Array createFloat32Array (ArrayBuffer buffer) { - return Instance.impl.createFloat32Array(buffer); - } - - /** Create a {@link Float32Array} instance on {@code buffer}, starting at {@code byteOffset} into the buffer, continuing to the - * end of the buffer (which must be an integral number of elements). - * - * @param buffer underlying {@link ArrayBuffer} - * @param byteOffset byte offset from the start of {@code buffer} - * @return an {@link Float32Array} instance */ - public static Float32Array createFloat32Array (ArrayBuffer buffer, int byteOffset) { - return Instance.impl.createFloat32Array(buffer, byteOffset); - } - - /** Create a {@link Float32Array} instance on {@code buffer}, starting at {@code byteOffset} into the buffer, continuing for - * {@code length} elements. - * - * @param buffer underlying {@link ArrayBuffer} - * @param byteOffset byte offset from the start of {@code buffer} - * @param length number of elements in the resulting array - * @return an {@link Float32Array} instance */ - public static Float32Array createFloat32Array (ArrayBuffer buffer, int byteOffset, int length) { - return Instance.impl.createFloat32Array(buffer, byteOffset, length); - } - - /** Create a {@link Float32Array} instance of {@code length} elements, backed by a new {@link ArrayBuffer}. - * - * @param length size of array - * @return a {@link Float32Array} instance */ - public static Float32Array createFloat32Array (int length) { - return Instance.impl.createFloat32Array(length); - } - - /** Create a {@link Float64Array} instance on {@code buffer}, starting at starting at the beginning of the buffer and - * continuing to the end (which must be an integral number of elements). - *

- * Note that Safari does not currently support Float64 Arrays! - * - * @param buffer underlying {@link ArrayBuffer} - * @return an {@link Float64Array} instance */ - public static Float64Array createFloat64Array (ArrayBuffer buffer) { - return Instance.impl.createFloat64Array(buffer); - } - - /** Create a {@link Float64Array} instance on {@code buffer}, starting at {@code byteOffset} into the buffer, continuing to the - * end of the buffer (which must be an integral number of elements). - *

- * Note that Safari does not currently support Float64 Arrays! - * - * @param buffer underlying {@link ArrayBuffer} - * @param byteOffset byte offset from the start of {@code buffer} - * @return an {@link Float64Array} instance */ - public static Float64Array createFloat64Array (ArrayBuffer buffer, int byteOffset) { - return Instance.impl.createFloat64Array(buffer, byteOffset); - } - - /** Create a {@link Float64Array} instance on {@code buffer}, starting at {@code byteOffset} into the buffer, continuing for - * {@code length} elements. - *

- * Note that Safari does not currently support Float64 Arrays! - * - * @param buffer underlying {@link ArrayBuffer} - * @param byteOffset byte offset from the start of {@code buffer} - * @param length number of elements in the resulting array - * @return an {@link Float64Array} instance */ - public static Float64Array createFloat64Array (ArrayBuffer buffer, int byteOffset, int length) { - return Instance.impl.createFloat64Array(buffer, byteOffset, length); - } - - /** Create a {@link Float64Array} instance of {@code length} elements, backed by a new {@link ArrayBuffer}. - *

- * Note that Safari does not currently support Float64 Arrays! - * - * @param length size of array - * @return a {@link Float64Array} instance */ - public static Float64Array createFloat64Array (int length) { - return Instance.impl.createFloat64Array(length); - } - - /** Create a {@link Int16Array} instance on {@code buffer}, starting at starting at the beginning of the buffer and continuing - * to the end (which must be an integral number of elements). - * - * @param buffer underlying {@link ArrayBuffer} - * @return an {@link Int16Array} instance */ - public static Int16Array createInt16Array (ArrayBuffer buffer) { - return Instance.impl.createInt16Array(buffer); - } - - /** Create a {@link Int16Array} instance on {@code buffer}, starting at {@code byteOffset} into the buffer, continuing to the - * end of the buffer (which must be an integral number of elements). - * - * @param buffer underlying {@link ArrayBuffer} - * @param byteOffset byte offset from the start of {@code buffer} - * @return an {@link Int16Array} instance */ - public static Int16Array createInt16Array (ArrayBuffer buffer, int byteOffset) { - return Instance.impl.createInt16Array(buffer, byteOffset); - } - - /** Create a {@link Int16Array} instance on {@code buffer}, starting at {@code byteOffset} into the buffer, continuing for - * {@code length} elements. - * - * @param buffer underlying {@link ArrayBuffer} - * @param byteOffset byte offset from the start of {@code buffer} - * @param length number of elements in the resulting array - * @return an {@link Int16Array} instance */ - public static Int16Array createInt16Array (ArrayBuffer buffer, int byteOffset, int length) { - return Instance.impl.createInt16Array(buffer, byteOffset, length); - } - - /** Create a {@link Int16Array} instance of {@code length} elements, backed by a new {@link ArrayBuffer}. - * - * @param length size of array - * @return a {@link Int16Array} instance */ - public static Int16Array createInt16Array (int length) { - return Instance.impl.createInt16Array(length); - } - - /** Create a {@link Int32Array} instance on {@code buffer}, starting at starting at the beginning of the buffer and continuing - * to the end (which must be an integral number of elements). - * - * @param buffer underlying {@link ArrayBuffer} - * @return an {@link Int32Array} instance */ - public static Int32Array createInt32Array (ArrayBuffer buffer) { - return Instance.impl.createInt32Array(buffer); - } - - /** Create a {@link Int32Array} instance on {@code buffer}, starting at {@code byteOffset} into the buffer, continuing to the - * end of the buffer (which must be an integral number of elements). - * - * @param buffer underlying {@link ArrayBuffer} - * @param byteOffset byte offset from the start of {@code buffer} - * @return an {@link Int32Array} instance */ - public static Int32Array createInt32Array (ArrayBuffer buffer, int byteOffset) { - return Instance.impl.createInt32Array(buffer, byteOffset); - } - - /** Create a {@link Int32Array} instance on {@code buffer}, starting at {@code byteOffset} into the buffer, continuing for - * {@code length} elements. - * - * @param buffer underlying {@link ArrayBuffer} - * @param byteOffset byte offset from the start of {@code buffer} - * @param length number of elements in the resulting array - * @return an {@link Int32Array} instance */ - public static Int32Array createInt32Array (ArrayBuffer buffer, int byteOffset, int length) { - return Instance.impl.createInt32Array(buffer, byteOffset, length); - } - - /** Create a {@link Int32Array} instance of {@code length} elements, backed by a new {@link ArrayBuffer}. - * - * @param length size of array - * @return a {@link Int32Array} instance */ - public static Int32Array createInt32Array (int length) { - return Instance.impl.createInt32Array(length); - } - - /** Create a {@link Int8Array} instance on {@code buffer}, starting at starting at the beginning of the buffer and continuing - * to the end. - * - * @param buffer underlying {@link ArrayBuffer} - * @return an {@link Int8Array} instance */ - public static Int8Array createInt8Array (ArrayBuffer buffer) { - return Instance.impl.createInt8Array(buffer); - } - - /** Create a {@link Int8Array} instance on {@code buffer}, starting at {@code byteOffset} into the buffer, continuing to the - * end of the buffer (which must be an integral number of elements). - * - * @param buffer underlying {@link ArrayBuffer} - * @param byteOffset byte offset from the start of {@code buffer} - * @return an {@link Int8Array} instance */ - public static Int8Array createInt8Array (ArrayBuffer buffer, int byteOffset) { - return Instance.impl.createInt8Array(buffer, byteOffset); - } - - /** Create a {@link Int8Array} instance on {@code buffer}, starting at {@code byteOffset} into the buffer, continuing for - * {@code length} elements. - * - * @param buffer underlying {@link ArrayBuffer} - * @param byteOffset byte offset from the start of {@code buffer} - * @param length number of elements in the resulting array - * @return an {@link Int8Array} instance */ - public static Int8Array createInt8Array (ArrayBuffer buffer, int byteOffset, int length) { - return Instance.impl.createInt8Array(buffer, byteOffset, length); - } - - /** Create a {@link Int8Array} instance of {@code length} elements, backed by a new {@link ArrayBuffer}. - * - * @param length size of array - * @return a {@link Int8Array} instance */ - public static Int8Array createInt8Array (int length) { - return Instance.impl.createInt8Array(length); - } - - /** Create a {@link Uint16Array} instance on {@code buffer}, starting at starting at the beginning of the buffer and continuing - * to the end (which must be an integral number of elements). - * - * @param buffer underlying {@link ArrayBuffer} - * @return an {@link Uint16Array} instance */ - public static Uint16Array createUint16Array (ArrayBuffer buffer) { - return Instance.impl.createUint16Array(buffer); - } - - /** Create a {@link Uint16Array} instance on {@code buffer}, starting at {@code byteOffset} into the buffer, continuing to the - * end of the buffer (which must be an integral number of elements). - * - * @param buffer underlying {@link ArrayBuffer} - * @param byteOffset byte offset from the start of {@code buffer} - * @return an {@link Uint16Array} instance */ - public static Uint16Array createUint16Array (ArrayBuffer buffer, int byteOffset) { - return Instance.impl.createUint16Array(buffer, byteOffset); - } - - /** Create a {@link Uint16Array} instance on {@code buffer}, starting at {@code byteOffset} into the buffer, continuing for - * {@code length} elements. - * - * @param buffer underlying {@link ArrayBuffer} - * @param byteOffset byte offset from the start of {@code buffer} - * @param length number of elements in the resulting array - * @return an {@link Uint16Array} instance */ - public static Uint16Array createUint16Array (ArrayBuffer buffer, int byteOffset, int length) { - return Instance.impl.createUint16Array(buffer, byteOffset, length); - } - - /** Create a {@link Uint16Array} instance of {@code length} elements, backed by a new {@link ArrayBuffer}. - * - * @param length size of array - * @return a {@link Uint16Array} instance */ - public static Uint16Array createUint16Array (int length) { - return Instance.impl.createUint16Array(length); - } - - /** Create a {@link Uint32Array} instance on {@code buffer}, starting at starting at the beginning of the buffer and continuing - * to the end (which must be an integral number of elements). - * - * @param buffer underlying {@link ArrayBuffer} - * @return an {@link Uint32Array} instance */ - public static Uint32Array createUint32Array (ArrayBuffer buffer) { - return Instance.impl.createUint32Array(buffer); - } - - /** Create a {@link Uint32Array} instance on {@code buffer}, starting at {@code byteOffset} into the buffer, continuing to the - * end of the buffer (which must be an integral number of elements). - * - * @param buffer underlying {@link ArrayBuffer} - * @param byteOffset byte offset from the start of {@code buffer} - * @return an {@link Uint32Array} instance */ - public static Uint32Array createUint32Array (ArrayBuffer buffer, int byteOffset) { - return Instance.impl.createUint32Array(buffer, byteOffset); - } - - /** Create a {@link Uint32Array} instance on {@code buffer}, starting at {@code byteOffset} into the buffer, continuing for - * {@code length} elements. - * - * @param buffer underlying {@link ArrayBuffer} - * @param byteOffset byte offset from the start of {@code buffer} - * @param length number of elements in the resulting array - * @return an {@link Uint32Array} instance */ - public static Uint32Array createUint32Array (ArrayBuffer buffer, int byteOffset, int length) { - return Instance.impl.createUint32Array(buffer, byteOffset, length); - } - - /** Create a {@link Uint32Array} instance of {@code length} elements, backed by a new {@link ArrayBuffer}. - * - * @param length size of array - * @return a {@link Uint32Array} instance */ - public static Uint32Array createUint32Array (int length) { - return Instance.impl.createUint32Array(length); - } - - /** Create a {@link Uint8Array} instance on {@code buffer}, starting at starting at the beginning of the buffer and continuing - * to the end (which must be an integral number of elements). - * - * @param buffer underlying {@link ArrayBuffer} - * @return an {@link Uint8Array} instance */ - public static Uint8Array createUint8Array (ArrayBuffer buffer) { - return Instance.impl.createUint8Array(buffer); - } - - /** Create a {@link Uint8Array} instance on {@code buffer}, starting at {@code byteOffset} into the buffer, continuing to the - * end of the buffer. - * - * @param buffer underlying {@link ArrayBuffer} - * @param byteOffset byte offset from the start of {@code buffer} - * @return an {@link Uint8Array} instance */ - public static Uint8Array createUint8Array (ArrayBuffer buffer, int byteOffset) { - return Instance.impl.createUint8Array(buffer, byteOffset); - } - - /** Create a {@link Uint8Array} instance on {@code buffer}, starting at {@code byteOffset} into the buffer, continuing for - * {@code length} elements. - * - * @param buffer underlying {@link ArrayBuffer} - * @param byteOffset byte offset from the start of {@code buffer} - * @param length number of elements in the resulting array - * @return an {@link Uint8Array} instance */ - public static Uint8Array createUint8Array (ArrayBuffer buffer, int byteOffset, int length) { - return Instance.impl.createUint8Array(buffer, byteOffset, length); - } - - /** Create a {@link Uint8Array} instance of {@code length} elements, backed by a new {@link ArrayBuffer}. - * - * @param length size of array - * @return a {@link Uint8Array} instance */ - public static Uint8Array createUint8Array (int length) { - return Instance.impl.createUint8Array(length); - } - - /** Create a {@link Uint8ClampedArray} instance on {@code buffer}, starting at starting at the beginning of the buffer and - * continuing to the end. - * - * @param buffer underlying {@link ArrayBuffer} - * @return an {@link Uint8ClampedArray} instance */ - public static Uint8ClampedArray createUint8ClampedArray (ArrayBuffer buffer) { - return Instance.impl.createUint8ClampedArray(buffer, 0, buffer.get_byteLength()); - } - - /** Create a {@link Uint8ClampedArray} instance on {@code buffer}, starting at {@code byteOffset} into the buffer, continuing - * to the end of the buffer. - * - * @param buffer underlying {@link ArrayBuffer} - * @param byteOffset byte offset from the start of {@code buffer} - * @return an {@link Uint8ClampedArray} instance */ - public static Uint8ClampedArray createUint8ClampedArray (ArrayBuffer buffer, int byteOffset) { - return Instance.impl.createUint8ClampedArray(buffer, byteOffset); - } - - /** Create a {@link Uint8ClampedArray} instance on {@code buffer}, starting at {@code byteOffset} into the buffer, continuing - * for {@code length} elements. - * - * @param buffer underlying {@link ArrayBuffer} - * @param byteOffset byte offset from the start of {@code buffer} - * @param length number of elements in the resulting array - * @return an {@link Uint8ClampedArray} instance */ - public static Uint8ClampedArray createUint8ClampedArray (ArrayBuffer buffer, int byteOffset, int length) { - return Instance.impl.createUint8ClampedArray(buffer, byteOffset, length); - } - - /** Create a {@link Uint8ClampedArray} instance of {@code length} elements, backed by a new {@link ArrayBuffer}. - * - * @param length size of array - * @return a {@link Uint8ClampedArray} instance */ - public static Uint8ClampedArray createUint8ClampedArray (int length) { - return Instance.impl.createUint8ClampedArray(length); - } - - /** Check if the current environment supports typed arrays. Behavior of the various {@code createXXX} methods is undefined if - * this method returns {@code false}, but will typically throw some exception. - * - * @return true if typed arrays are support. */ - public static boolean isSupported () { - return Instance.impl.mightBeSupported() && Instance.impl.runtimeSupportCheck(); - } -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/utils/TypedArraysFactory.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/utils/TypedArraysFactory.java deleted file mode 100644 index cdb01fe4..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/typedarrays/utils/TypedArraysFactory.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.typedarrays.utils; - -public class TypedArraysFactory { - static TypedArrays.Impl createImpl() { - return new NativeImpl(); - } -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/HTMLVideoElement.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/HTMLVideoElement.java deleted file mode 100644 index f67ebb53..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/HTMLVideoElement.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.webgl; - -/** @author xpenatan */ -public interface HTMLVideoElement { -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLActiveInfo.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLActiveInfo.java deleted file mode 100644 index 9442144b..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLActiveInfo.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.webgl; - -/** @author xpenatan */ -public interface WebGLActiveInfo { - public int get_size (); - - public int get_type (); - - public String get_name (); -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLBuffer.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLBuffer.java deleted file mode 100644 index ae42c149..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLBuffer.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.webgl; - -/** @author xpenatan */ -public interface WebGLBuffer extends WebGLObject { -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLContextAttributes.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLContextAttributes.java deleted file mode 100644 index a6c2660e..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLContextAttributes.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.webgl; - -import com.dragome.commons.DelegateCode; -import com.dragome.commons.javascript.ScriptHelper; -import com.dragome.web.enhancers.jsdelegate.JsDelegateFactory; - -/** @author xpenatan */ -public interface WebGLContextAttributes { - - @DelegateCode(ignore = true) - public static WebGLContextAttributes create() { - WebGLContextAttributes attr = null; - Object instance = ScriptHelper.eval("{premultipliedAlpha:false}", null); - attr = JsDelegateFactory.createFrom(instance, WebGLContextAttributes.class); - return attr; - } - - public void set_alpha (boolean alpha); - - public void set_antialias (boolean antialias); - - public void set_depth (boolean depth); - - public void set_premultipliedAlpha (boolean premultipliedAlpha); - - public void set_preserveDrawingBuffer (boolean preserveDrawingBuffer); - - public void set_stencil (boolean stencil); -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLFactory.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLFactory.java new file mode 100644 index 00000000..e9ccaaab --- /dev/null +++ b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLFactory.java @@ -0,0 +1,17 @@ +package com.badlogic.gdx.backends.dragome.js.webgl; + +import org.w3c.dom.webgl.WebGLContextAttributes; + +import com.dragome.commons.javascript.ScriptHelper; +import com.dragome.web.enhancers.jsdelegate.JsDelegateFactory; + +public class WebGLFactory +{ + public static WebGLContextAttributes create() + { + WebGLContextAttributes attr= null; + Object instance= ScriptHelper.eval("{premultipliedAlpha:false}", null); + attr= JsDelegateFactory.createFrom(instance, WebGLContextAttributes.class); + return attr; + } +} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLFramebuffer.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLFramebuffer.java deleted file mode 100644 index 5b674913..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLFramebuffer.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.webgl; - -/** @author xpenatan */ -public interface WebGLFramebuffer extends WebGLObject { -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLObject.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLObject.java deleted file mode 100644 index 0a1552c7..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLObject.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.webgl; - -/** @author xpenatan */ -public interface WebGLObject { -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLProgram.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLProgram.java deleted file mode 100644 index 4cf815b3..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLProgram.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.webgl; - -/** @author xpenatan */ -public interface WebGLProgram extends WebGLObject { -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLRenderbuffer.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLRenderbuffer.java deleted file mode 100644 index 67ed1feb..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLRenderbuffer.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.webgl; - -/** - * @author xpenatan - */ -public interface WebGLRenderbuffer extends WebGLObject { - -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLRenderingContext.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLRenderingContext.java deleted file mode 100644 index 92f6295c..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLRenderingContext.java +++ /dev/null @@ -1,375 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.webgl; - -import org.w3c.dom.html.HTMLImageElement; - -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBuffer; -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBufferView; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Float32Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Int32Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.SharedArrayBuffer; -import com.dragome.web.html.dom.html5canvas.interfaces.HTMLCanvasElement; -import com.dragome.web.html.dom.html5canvas.interfaces.ImageData; - -/** From https://dxr.mozilla.org/mozilla-central/source/dom/webidl/WebGLRenderingContext.webidl
- * Match the same methods to use with javascript. - * - * @author xpenatan */ -public interface WebGLRenderingContext { - public static final int UNSIGNED_BYTE = 0x1401; - public static final int RGBA = 0x1908; - - /* WebGL-specific enums */ - public static final int UNPACK_FLIP_Y_WEBGL = 0x9240; - public static final int UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241; - public static final int CONTEXT_LOST_WEBGL = 0x9242; - - public WebGLContextAttributes getContextAttributes (); - - public boolean isContextLost (); - - public Object getSupportedExtensions (); - - public Object getExtension (String name); - - public void activeTexture (int texture); - - public void attachShader (WebGLProgram program, WebGLShader shader); - - public void bindAttribLocation (WebGLProgram program, int index, String name); - - public void bindBuffer (int target, WebGLBuffer buffer); - - public void bindFramebuffer (int target, WebGLFramebuffer framebuffer); - - public void bindRenderbuffer (int target, WebGLRenderbuffer renderbuffer); - - public void bindTexture (int target, WebGLTexture texture); - - public void blendColor (float red, float green, float blue, float alpha); - - public void blendEquation (int mode); - - public void blendEquationSeparate (int modeRGB, int modeAlpha); - - public void blendFunc (int sfactor, int dfactor); - - public void blendFuncSeparate (int srcRGB, int dstRGB, int srcAlpha, int dstAlpha); - - public void bufferData (int target, int size, int usage); - - public void bufferData (int target, ArrayBufferView data, int usage); - - public void bufferData (int target, ArrayBuffer data, int usage); - - public void bufferData (int target, SharedArrayBuffer data, int usage); - - public void bufferSubData (int target, int offset, ArrayBufferView data); - - public void bufferSubData (int target, int offset, ArrayBuffer data); - - public void bufferSubData (int target, int offset, SharedArrayBuffer data); - - public int checkFramebufferStatus (int target); - - public void clear (int mask); - - public void clearColor (float red, float green, float blue, float alpha); - - public void clearDepth (float depth); - - public void clearStencil (int s); - - public void colorMask (boolean red, boolean green, boolean blue, boolean alpha); - - public void compileShader (WebGLShader shader); - - public void compressedTexImage2D (int target, int level, int internalformat, int width, int height, int border, - ArrayBufferView data); - - public void compressedTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format, - ArrayBufferView data); - - public void copyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border); - - public void copyTexSubImage2D (int target, int level, int xoffset, int yoffset, int x, int y, int width, int height); - - public WebGLBuffer createBuffer (); - - public WebGLFramebuffer createFramebuffer (); - - public WebGLProgram createProgram (); - - public WebGLRenderbuffer createRenderbuffer (); - - public WebGLShader createShader (int type); - - public WebGLTexture createTexture (); - - public void cullFace (int mode); - - public void deleteBuffer (WebGLBuffer buffer); - - public void deleteFramebuffer (WebGLFramebuffer framebuffer); - - public void deleteProgram (WebGLProgram program); - - public void deleteRenderbuffer (WebGLRenderbuffer renderbuffer); - - public void deleteShader (WebGLShader shader); - - public void deleteTexture (WebGLTexture texture); - - public void depthFunc (int func); - - public void depthMask (boolean flag); - - public void depthRange (float zNear, float zFar); - - public void detachShader (WebGLProgram program, WebGLShader shader); - - public void disable (int cap); - - public void disableVertexAttribArray (int index); - - public void drawArrays (int mode, int first, int count); - - public void drawElements (int mode, int count, int type, int offset); - - public void enable (int cap); - - public void enableVertexAttribArray (int index); - - public void finish (); - - public void flush (); - - public void framebufferRenderbuffer (int target, int attachment, int renderbuffertarget, WebGLRenderbuffer renderbuffer); - - public void framebufferTexture2D (int target, int attachment, int textarget, WebGLTexture texture, int level); - - public void frontFace (int mode); - - public void generateMipmap (int target); - - public WebGLActiveInfo getActiveAttrib (WebGLProgram program, int index); - - public WebGLActiveInfo getActiveUniform (WebGLProgram program, int index); - - public Object getAttachedShaders (WebGLProgram program); - - public int getAttribLocation (WebGLProgram program, String name); - - public Object getBufferParameter (int target, int pname); - - public Object getParameter (int pname); - - public int getError (); - - public Object getFramebufferAttachmentParameter (int target, int attachment, int pname); - - public Object getProgramParameter (WebGLProgram program, int pname); - - public String getProgramInfoLog (WebGLProgram program); - - public Object getRenderbufferParameter (int target, int pname); - - public Object getShaderParameter (WebGLShader shader, int pname); - - public WebGLShaderPrecisionFormat getShaderPrecisionFormat (int shadertype, int precisiontype); - - public String getShaderInfoLog (WebGLShader shader); - - public String getShaderSource (WebGLShader shader); - - public Object getTexParameter (int target, int pname); - - public Object getUniform (WebGLProgram program, WebGLUniformLocation location); - - public WebGLUniformLocation getUniformLocation (WebGLProgram program, String name); - - public Object getVertexAttrib (int index, int pname); - - public int getVertexAttribOffset (int index, int pname); - - public void hint (int target, int mode); - - public boolean isBuffer (WebGLBuffer buffer); - - public boolean isEnabled (int cap); - - public boolean isFramebuffer (WebGLFramebuffer framebuffer); - - public boolean isProgram (WebGLProgram program); - - public boolean isRenderbuffer (WebGLRenderbuffer renderbuffer); - - public boolean isShader (WebGLShader shader); - - public boolean isTexture (WebGLTexture texture); - - public void lineWidth (float width); - - public void linkProgram (WebGLProgram program); - - public void pixelStorei (int pname, int param); - - public void polygonOffset (float factor, float units); - - public void readPixels (int x, int y, int width, int height, int format, int type, ArrayBufferView pixels); - - public void renderbufferStorage (int target, int internalformat, int width, int height); - - public void sampleCoverage (float value, boolean invert); - - public void scissor (int x, int y, int width, int height); - - public void shaderSource (WebGLShader shader, String source); - - public void stencilFunc (int func, int ref, int mask); - - public void stencilFuncSeparate (int face, int func, int ref, int mask); - - public void stencilMask (int mask); - - public void stencilMaskSeparate (int face, int mask); - - public void stencilOp (int fail, int zfail, int zpass); - - public void stencilOpSeparate (int face, int fail, int zfail, int zpass); - - public void texImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, - ArrayBufferView pixels); - - public void texImage2D (int target, int level, int internalformat, int format, int type, ImageData pixels); - - public void texImage2D (int target, int level, int internalformat, int format, int type, HTMLImageElement image); - - public void texImage2D (int target, int level, int internalformat, int format, int type, HTMLCanvasElement canvas); - - public void texImage2D (int target, int level, int internalformat, int format, int type, HTMLVideoElement video); - - public void texParameterf (int target, int pname, float param); - - public void texParameteri (int target, int pname, int param); - - public void texSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format, int type, - ArrayBufferView pixels); - - public void texSubImage2D (int target, int level, int xoffset, int yoffset, int format, int type, ImageData pixels); - - public void texSubImage2D (int target, int level, int xoffset, int yoffset, int format, int type, HTMLImageElement image); // May - // throw - // DOMException - - public void texSubImage2D (int target, int level, int xoffset, int yoffset, int format, int type, HTMLCanvasElement canvas); - - public void texSubImage2D (int target, int level, int xoffset, int yoffset, int format, int type, HTMLVideoElement video); - - public void uniform1f (WebGLUniformLocation location, float x); - - public void uniform1fv (WebGLUniformLocation location, Float32Array v); - - public void uniform1fv (WebGLUniformLocation location, Object v); - - public void uniform1i (WebGLUniformLocation location, int x); - - public void uniform1iv (WebGLUniformLocation location, Int32Array v); - - public void uniform1iv (WebGLUniformLocation location, Object v); - - public void uniform2f (WebGLUniformLocation location, float x, float y); - - public void uniform2fv (WebGLUniformLocation location, Float32Array v); - - public void uniform2fv (WebGLUniformLocation location, Object v); - - public void uniform2i (WebGLUniformLocation location, int x, int y); - - public void uniform2iv (WebGLUniformLocation location, Int32Array v); - - public void uniform2iv (WebGLUniformLocation location, Object v); - - public void uniform3f (WebGLUniformLocation location, float x, float y, float z); - - public void uniform3fv (WebGLUniformLocation location, Float32Array v); - - public void uniform3fv (WebGLUniformLocation location, Object v); - - public void uniform3i (WebGLUniformLocation location, int x, int y, int z); - - public void uniform3iv (WebGLUniformLocation location, Int32Array v); - - public void uniform3iv (WebGLUniformLocation location, Object v); - - public void uniform4f (WebGLUniformLocation location, float x, float y, float z, float w); - - public void uniform4fv (WebGLUniformLocation location, Float32Array v); - - public void uniform4fv (WebGLUniformLocation location, Object v); - - public void uniform4i (WebGLUniformLocation location, int x, int y, int z, int w); - - public void uniform4iv (WebGLUniformLocation location, Int32Array v); - - public void uniform4iv (WebGLUniformLocation location, Object v); - - public void uniformMatrix2fv (WebGLUniformLocation location, boolean transpose, Float32Array value); - - public void uniformMatrix2fv (WebGLUniformLocation location, boolean transpose, Object value); - - public void uniformMatrix3fv (WebGLUniformLocation location, boolean transpose, Float32Array value); - - public void uniformMatrix3fv (WebGLUniformLocation location, boolean transpose, Object value); - - public void uniformMatrix4fv (WebGLUniformLocation location, boolean transpose, Float32Array value); - - public void uniformMatrix4fv (WebGLUniformLocation location, boolean transpose, float[] value); - - public void useProgram (WebGLProgram program); - - public void validateProgram (WebGLProgram program); - - public void vertexAttrib1f (int indx, float x); - - public void vertexAttrib1fv (int indx, Float32Array values); - - public void vertexAttrib1fv (int indx, Object values); - - public void vertexAttrib2f (int indx, float x, float y); - - public void vertexAttrib2fv (int indx, Float32Array values); - - public void vertexAttrib2fv (int indx, Object values); - - public void vertexAttrib3f (int indx, float x, float y, float z); - - public void vertexAttrib3fv (int indx, Float32Array values); - - public void vertexAttrib3fv (int indx, Object values); - - public void vertexAttrib4f (int indx, float x, float y, float z, float w); - - public void vertexAttrib4fv (int indx, Float32Array values); - - public void vertexAttrib4fv (int indx, Object values); - - public void vertexAttribPointer (int indx, int size, int type, boolean normalized, int stride, int offset); - - public void viewport (int x, int y, int width, int height); -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLShader.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLShader.java deleted file mode 100644 index b05cf1f7..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLShader.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.webgl; - -/** @author xpenatan */ -public interface WebGLShader extends WebGLObject { -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLShaderPrecisionFormat.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLShaderPrecisionFormat.java deleted file mode 100644 index 11dbc94e..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLShaderPrecisionFormat.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.webgl; - -/** @author xpenatan */ -public interface WebGLShaderPrecisionFormat { - public int get_rangeMin (); - - public int get_rangeMax (); - - public int get_precision (); -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLTexture.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLTexture.java deleted file mode 100644 index 8664d2df..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLTexture.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.webgl; - -/** @author xpenatan */ -public interface WebGLTexture extends WebGLObject { -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLUniformLocation.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLUniformLocation.java deleted file mode 100644 index a62a227a..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/js/webgl/WebGLUniformLocation.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.js.webgl; - -/** @author xpenatan */ -public interface WebGLUniformLocation extends WebGLObject { -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/preloader/AssetDownloader.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/preloader/AssetDownloader.java index 92b91169..da19661f 100644 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/preloader/AssetDownloader.java +++ b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/preloader/AssetDownloader.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright 2016 Natan Guilherme. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,18 +17,19 @@ package com.badlogic.gdx.backends.dragome.preloader; import org.w3c.dom.events.Event; +import org.w3c.dom.html.HTMLImageElement; +import org.w3c.dom.typedarray.Int8Array; import com.badlogic.gdx.backends.dragome.js.XMLHttpRequest; import com.badlogic.gdx.backends.dragome.js.XMLHttpRequest.ReadyStateChangeHandler; import com.badlogic.gdx.backends.dragome.js.XMLHttpRequest.ResponseType; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Int8Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.utils.TypedArrays; import com.badlogic.gdx.backends.dragome.preloader.AssetFilter.AssetType; import com.badlogic.gdx.utils.GdxRuntimeException; import com.dragome.commons.compiler.annotations.MethodAlias; import com.dragome.commons.javascript.ScriptHelper; import com.dragome.web.enhancers.jsdelegate.JsDelegateFactory; -import com.dragome.web.html.dom.html5canvas.interfaces.ImageElement; +import com.dragome.web.html.dom.w3c.HTMLImageElementExtension; +import com.dragome.web.html.dom.w3c.TypedArraysFactory; /** Adapted from gwt backend * @author xpenatan */ @@ -70,7 +71,7 @@ public void load (String url, AssetType type, String mimeType, AssetLoaderListen loadText(url, (AssetLoaderListener)listener); break; case Image: - loadImage(url, mimeType, (AssetLoaderListener)listener); + loadImage(url, mimeType, (AssetLoaderListener)listener); break; case Binary: loadBinary(url, (AssetLoaderListener)listener); @@ -119,7 +120,8 @@ public void onReadyStateChange (XMLHttpRequest xhr) { if (xhr.getStatus() != 200) { listener.onFailure(); } else { - Int8Array data = TypedArrays.createInt8Array(xhr.getResponseArrayBuffer()); + + Int8Array data= TypedArraysFactory.createInstanceOf(Int8Array.class, xhr.getResponseArrayBuffer()); listener.onSuccess(new Blob(data)); } } @@ -155,12 +157,12 @@ public void onSuccess (Blob result) { } } - public void loadImage (final String url, final String mimeType, final AssetLoaderListener listener) { + public void loadImage (final String url, final String mimeType, final AssetLoaderListener listener) { loadImage(url, mimeType, null, listener); } public void loadImage (final String url, final String mimeType, final String crossOrigin, - final AssetLoaderListener listener) { + final AssetLoaderListener listener) { if (useBrowserCache || useInlineBase64) { loadBinary(url, new AssetLoaderListener() { @Override @@ -175,7 +177,7 @@ public void onFailure () { @Override public void onSuccess (Blob result) { - final ImageElement image = createImage(); + final HTMLImageElementExtension image = createImage(); if (crossOrigin != null) { image.setAttribute("crossOrigin", crossOrigin); @@ -198,7 +200,7 @@ public void onEvent (Event event) { }); } else { - final ImageElement image = createImage(); + final HTMLImageElementExtension image = createImage(); if (crossOrigin != null) { image.setAttribute("crossOrigin", crossOrigin); } @@ -220,7 +222,7 @@ private static interface ImgEventListener { public void onEvent (Event event); } - static void hookImgListener (ImageElement img, ImgEventListener h) { + static void hookImgListener (HTMLImageElementExtension img, ImgEventListener h) { ScriptHelper.put("img", img, null); ScriptHelper.put("h", h, null); @@ -234,9 +236,9 @@ private static void myEvent (ImgEventListener h, Object instance) { h.onEvent(event); } - static ImageElement createImage () { + static HTMLImageElementExtension createImage () { Object instance = ScriptHelper.eval("new Image()", null); - ImageElement img = JsDelegateFactory.createFrom(instance, ImageElement.class); + HTMLImageElementExtension img = JsDelegateFactory.createFrom(instance, HTMLImageElementExtension.class); return img; } diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/preloader/Blob.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/preloader/Blob.java index 394aa161..88714388 100644 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/preloader/Blob.java +++ b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/preloader/Blob.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright 2016 Natan Guilherme. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,7 +19,7 @@ import java.io.IOException; import java.io.InputStream; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Int8Array; +import org.w3c.dom.typedarray.Int8Array; /** Adapted from gwt backend * @author xpenatan */ @@ -30,7 +30,7 @@ public Blob (Int8Array data) { } public int length () { - return data.get_length(); + return data.getLength(); } public byte get (int i) { @@ -56,7 +56,7 @@ public int available () { } public String toBase64 () { - int length = data.get_length(); + int length = data.getLength(); String base64code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; StringBuilder encoded = new StringBuilder(length * 4 / 3 + 2); for (int i = 0; i < length; i += 3) { diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/preloader/Preloader.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/preloader/Preloader.java index 99de8b7f..06f64f03 100644 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/preloader/Preloader.java +++ b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/preloader/Preloader.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright 2016 Natan Guilherme. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,21 +23,21 @@ import java.io.InputStream; import java.io.UnsupportedEncodingException; +import com.badlogic.gdx.Files.FileType; import com.badlogic.gdx.backends.dragome.DragomeFileHandle; import com.badlogic.gdx.backends.dragome.preloader.AssetDownloader.AssetLoaderListener; import com.badlogic.gdx.backends.dragome.preloader.AssetFilter.AssetType; -import com.badlogic.gdx.Files.FileType; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.GdxRuntimeException; import com.badlogic.gdx.utils.ObjectMap; -import com.dragome.web.html.dom.html5canvas.interfaces.ImageElement; +import com.dragome.web.html.dom.w3c.HTMLImageElementExtension; /** Adapted from gwt backend * @author xpenatan */ public class Preloader { public ObjectMap directories = new ObjectMap(); - public ObjectMap images = new ObjectMap(); + public ObjectMap images = new ObjectMap(); public ObjectMap audio = new ObjectMap(); public ObjectMap texts = new ObjectMap(); public ObjectMap binaries = new ObjectMap(); @@ -150,7 +150,7 @@ public void onSuccess (Object result) { texts.put(url, (String)result); break; case Image: - images.put(url, (ImageElement)result); + images.put(url, (HTMLImageElementExtension)result); break; case Binary: binaries.put(url, (Blob)result); diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/utils/Endianness.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/utils/Endianness.java deleted file mode 100644 index fb7d595d..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/utils/Endianness.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.utils; - -public enum Endianness { - BIG_ENDIAN, LITTLE_ENDIAN -} diff --git a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/utils/StringToByteBuffer.java b/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/utils/StringToByteBuffer.java deleted file mode 100644 index 15d59616..00000000 --- a/backends/gdx-backend-dragome/src/com/badlogic/gdx/backends/dragome/utils/StringToByteBuffer.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright 2016 Natan Guilherme. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.dragome.utils; - -import java.nio.ByteBuffer; - -/** Ugly hack to get gwt internal stuff into nio, see StringByteBuffer in nio */ - -public interface StringToByteBuffer { - ByteBuffer stringToByteBuffer (String s); -} diff --git a/tests/gdx-tests-dragome/pom.xml b/tests/gdx-tests-dragome/pom.xml index f4045adb..bbcab450 100644 --- a/tests/gdx-tests-dragome/pom.xml +++ b/tests/gdx-tests-dragome/pom.xml @@ -1,162 +1,165 @@ - - 4.0.0 - gdx-tests-dragome - gdx-tests-dragome - 0.0.1-SNAPSHOT + + 4.0.0 + gdx-tests-dragome + gdx-tests-dragome + 0.0.1-SNAPSHOT - - - JBOSS_NEXUS - http://repository.jboss.org/nexus/content/groups/public - - - sonatype-snapshots - https://oss.sonatype.org/content/repositories/snapshots - - - dragome - dragome - https://raw.github.com/dragome/dragome/master/maven - - + + + JBOSS_NEXUS + http://repository.jboss.org/nexus/content/groups/public + + + sonatype-snapshots + https://oss.sonatype.org/content/repositories/snapshots + + + dragome + dragome + https://raw.github.com/dragome/dragome/master/maven + + - - - dragome - dragome - https://raw.github.com/dragome/dragome/master/maven - - true - - - true - - - + + + dragome + dragome + https://raw.github.com/dragome/dragome/master/maven + + true + + + true + + + - - - org.hibernate - hibernate-entitymanager - 4.3.5.Final - - - org.hsqldb - hsqldb - 2.2.8 - - - com.dragome - dragome-sdk - 0.96-beta3-SNAPSHOT - pom - - - com.badlogicgames.gdx - gdx - 1.9.2 - - - gdx-backend-dragome - gdx-backend-dragome - 0.0.1-SNAPSHOT - - + + + com.dragome + dragome-web + 0.96-beta3-SNAPSHOT + + + com.dragome + dragome-bytecode-js-compiler + 0.96-beta3-SNAPSHOT + + + com.dragome + dragome-js-jre + 0.96-beta3-SNAPSHOT + + + com.badlogicgames.gdx + gdx + 1.9.2 + + + gdx-backend-dragome + gdx-backend-dragome + 0.0.1-SNAPSHOT + + + com.dragome + dragome-w3c-standards + 0.96-beta3-SNAPSHOT + + - - gdx-tests-dragome - ${basedir}/webapp/WEB-INF/classes - - - maven-compiler-plugin - 3.1 - - 1.8 - 1.8 - - + + gdx-tests-dragome + ${basedir}/webapp/WEB-INF/classes + + + maven-compiler-plugin + 3.1 + + 1.8 + 1.8 + + - - org.eclipse.jetty - jetty-maven-plugin - 9.1.3.v20140225 - - - ${basedir}/../../backends/gdx-backend-dragome/resources/webdefault.xml - - - /examples - ${basedir}/../../backends/gdx-backend-dragome/target/classes - - - ${basedir}/webapp/WEB-INF/classes - ${basedir}/../../backends/gdx-backend-dragome/target/classes - + + org.eclipse.jetty + jetty-maven-plugin + 9.1.3.v20140225 + + + ${basedir}/../../backends/gdx-backend-dragome/resources/webdefault.xml + + + /examples + ${basedir}/../../backends/gdx-backend-dragome/target/classes + + + ${basedir}/webapp/WEB-INF/classes + ${basedir}/../../backends/gdx-backend-dragome/target/classes + - ${basedir}/webapp/WEB-INF/classes - ${basedir}/../../backends/gdx-backend-dragome/target/classes + ${basedir}/webapp/WEB-INF/classes + ${basedir}/../../backends/gdx-backend-dragome/target/classes - ${basedir}/webapp - - - 4016 - 7000000 - - - + ${basedir}/webapp + + + 4016 + 7000000 + + + - - - org.ow2.asm - asm - 5.0.2 - - - org.ow2.asm - asm-commons - 5.0.2 - - + + + org.ow2.asm + asm + 5.0.2 + + + org.ow2.asm + asm-commons + 5.0.2 + + - + - - com.dragome - dragome-maven-plugin - 0.96-beta3-SNAPSHOT - - - prepare-package - - compileclient - - - - - ${project.build.directory}/${project.build.finalName} - true - false - com.badlogic.gdx.tests.dragome.GearsLauncher - true - true - - - - gdx-backend-dragome - gdx-backend-dragome - 0.0.1-SNAPSHOT - - - gdx-tests-dragome - gdx-tests-dragome - 0.0.1-SNAPSHOT - - - + + com.dragome + dragome-maven-plugin + 0.96-beta3-SNAPSHOT + + + prepare-package + + compileclient + + + + + ${project.build.directory}/${project.build.finalName} + true + false + com.badlogic.gdx.tests.dragome.GearsLauncher + true + true + + + + gdx-backend-dragome + gdx-backend-dragome + 0.0.1-SNAPSHOT + + + gdx-tests-dragome + gdx-tests-dragome + 0.0.1-SNAPSHOT + + + - - + + \ No newline at end of file diff --git a/tests/gdx-tests-dragome/src/com/badlogic/gdx/tests/dragome/AnimationLauncher.java b/tests/gdx-tests-dragome/src/com/badlogic/gdx/tests/dragome/AnimationLauncher.java index fb70294d..881001f0 100644 --- a/tests/gdx-tests-dragome/src/com/badlogic/gdx/tests/dragome/AnimationLauncher.java +++ b/tests/gdx-tests-dragome/src/com/badlogic/gdx/tests/dragome/AnimationLauncher.java @@ -12,26 +12,27 @@ public class AnimationLauncher extends DragomeApplication { @Override - public ApplicationListener createApplicationListener() { + public ApplicationListener createApplicationListener() + { return new AnimationTest(); } @Override - public DragomeApplicationConfiguration getConfig() { + public DragomeApplicationConfiguration getConfig() + { return null; } - @Override - protected void onResize() { - - int clientWidth = DragomeWindow.getInnerWidth(); - int clientHeight = DragomeWindow.getInnerHeight(); + protected void onResize() + { + int clientWidth= DragomeWindow.getInnerWidth(); + int clientHeight= DragomeWindow.getInnerHeight(); getCanvas().setWidth(clientWidth); getCanvas().setHeight(clientHeight); getCanvas().setCoordinateSpaceWidth(clientWidth); getCanvas().setCoordinateSpaceHeight(clientHeight); - + super.onResize(); } } diff --git a/tests/gdx-tests-dragome/src/com/badlogic/gdx/tests/dragome/GearsLauncher.java b/tests/gdx-tests-dragome/src/com/badlogic/gdx/tests/dragome/GearsLauncher.java index cfbf65ce..09b385f7 100644 --- a/tests/gdx-tests-dragome/src/com/badlogic/gdx/tests/dragome/GearsLauncher.java +++ b/tests/gdx-tests-dragome/src/com/badlogic/gdx/tests/dragome/GearsLauncher.java @@ -10,28 +10,29 @@ @PageAlias(alias= "Gears") public class GearsLauncher extends DragomeApplication { - @Override - public ApplicationListener createApplicationListener() { - return new GearsDemo(); + public ApplicationListener createApplicationListener() + { + return new GearsDemo(); } @Override - public DragomeApplicationConfiguration getConfig() { + public DragomeApplicationConfiguration getConfig() + { return null; } - @Override - protected void onResize() { - - int clientWidth = DragomeWindow.getInnerWidth(); - int clientHeight = DragomeWindow.getInnerHeight(); + protected void onResize() + { + + int clientWidth= DragomeWindow.getInnerWidth(); + int clientHeight= DragomeWindow.getInnerHeight(); getCanvas().setWidth(clientWidth); getCanvas().setHeight(clientHeight); getCanvas().setCoordinateSpaceWidth(clientWidth); getCanvas().setCoordinateSpaceHeight(clientHeight); - + super.onResize(); } } diff --git a/tests/gdx-tests-dragome/src/com/badlogic/gdx/tests/dragome/examples/GearsDemo.java b/tests/gdx-tests-dragome/src/com/badlogic/gdx/tests/dragome/examples/GearsDemo.java index 2176d905..37b5e22c 100644 --- a/tests/gdx-tests-dragome/src/com/badlogic/gdx/tests/dragome/examples/GearsDemo.java +++ b/tests/gdx-tests-dragome/src/com/badlogic/gdx/tests/dragome/examples/GearsDemo.java @@ -64,56 +64,56 @@ public class GearsDemo implements ApplicationListener { long time; int fps; @Override - public void create () { - + public void create () { + String path = null; DragomeApplication app = (DragomeApplication)Gdx.app; Preloader preloader = app.getPreloader(); path = "com/badlogic/gdx/graphics/g3d/shaders/default.fragment.glsl"; preloader.loadAsset(path, AssetType.Text, null, new AssetLoaderListener() { - + @Override public void onSuccess(Object result) { loaded++; } - + @Override public void onProgress(double amount) { } - + @Override public void onFailure() { } }); - + path = "com/badlogic/gdx/graphics/g3d/shaders/default.vertex.glsl"; preloader.loadAsset(path, AssetType.Text, null, new AssetLoaderListener() { - + @Override public void onSuccess(Object result) { loaded++; } - + @Override public void onProgress(double amount) { } - + @Override public void onFailure() { } }); path = "com/badlogic/gdx/utils/arial-15.fnt"; preloader.loadAsset(path, AssetType.Text, null, new AssetLoaderListener() { - + @Override public void onSuccess(Object result) { loaded++; } - + @Override public void onProgress(double amount) { } - + @Override public void onFailure() { } @@ -124,23 +124,23 @@ public void onFailure() { public void onSuccess(Object result) { loaded++; } - + @Override public void onProgress(double amount) { } - + @Override public void onFailure() { } }); - + // loaded = 2; - + environment = new Environment(); environment.set(new ColorAttribute(ColorAttribute.AmbientLight, .1f, .1f, .1f, 1f)); // environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, 0f, -0.5f, -0.5f)); - + sl = new PointLight().setPosition(-5, 10, -6).setColor(1, 1,1, 1) .setIntensity(150); @@ -149,11 +149,11 @@ public void onFailure() { // // sl3 = new PointLight().setPosition(0, 9, 6).setColor(0.3f, 0.3f, 0.8f, 1) // .setIntensity(20); - + environment.add(sl); // environment.add(sl2); // environment.add(sl3); - + cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(-10, 3, 10f); @@ -163,7 +163,7 @@ public void onFailure() { cam.update(); time = TimeUtils.millis(); - + viewport = new ScreenViewport(); } @@ -176,52 +176,52 @@ public void render () { start = true; DefaultShaderProvider defaultShaderProvider = new DefaultShaderProvider(); modelBatch = new ModelBatch(defaultShaderProvider); - + ModelBuilder modelBuilder = new ModelBuilder(); model1 = gear(modelBuilder, 1.0f, 4.0f, 1.0f, 20, 0.7f, Color.RED); gear1 = new ModelInstance(model1); - + model2 = gear(modelBuilder, 0.5f, 2.0f, 2.0f, 10, 0.7f, Color.GREEN); gear2 = new ModelInstance(model2); - + model3 = gear(modelBuilder, 1.3f, 2.0f, 1.5f, 10, 0.7f, Color.BLUE); gear3 = new ModelInstance(model3); - + font = new BitmapFont(); - + batch = new SpriteBatch(); - + lightModel = modelBuilder.createSphere(1, 1, 1, 10, 10, new Material(ColorAttribute.createDiffuse(1, 1, 1, 1)), Usage.Position); lightModel.nodes.get(0).parts.get(0).setRenderable(pLight = new Renderable()); } - + Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); - + cam.update(); if(modelBatch != null) { angle += 1.0f; - + gear1.transform.setToTranslation(-3.0f, -2.0f, 0.0f); gear2.transform.setToTranslation(3.1f, -2.0f, 0.0f); gear3.transform.setToTranslation(-3.1f, 4.2f, 0.0f); gear1.transform.rotate(Vector3.Z, angle); gear2.transform.rotate(Vector3.Z, -2.0f * angle - 9.0f); gear3.transform.rotate(Vector3.Z, -2.0f * angle - 25.0f); - + final float delta = Gdx.graphics.getDeltaTime(); - + sl.position.sub(transformedCenter); sl.position.rotate(Vector3.X, delta * 50f); sl.position.rotate(Vector3.Y, delta * 13f); sl.position.rotate(Vector3.Z, delta * 3f); sl.position.add(transformedCenter.set(center).mul(transform)); - - - + + + modelBatch.begin(cam); modelBatch.render(gear1, environment); modelBatch.render(gear2, environment); @@ -229,8 +229,8 @@ public void render () { pLight.worldTransform.setTranslation(sl.position); modelBatch.render(pLight); modelBatch.end(); - - + + float timeSec = TimeUtils.millis() - time; if(timeSec > 1000) @@ -270,7 +270,7 @@ public void resize (int width, int height) { public void pause () { } - + static void gear_angle(int i, int teeth, float [] ar) { float angle = i * 2.0f * MathUtils.PI / teeth; float da = 2.0f * MathUtils.PI / teeth / 4.0f; @@ -279,24 +279,24 @@ static void gear_angle(int i, int teeth, float [] ar) { ar[2] = angle + 2.0f * da; ar[3] = angle + 3.0f * da; } - + private static Model gear(ModelBuilder builder, float inner_radius, float outer_radius, float width, int teeth, float tooth_depth, Color color) { // Ported from https://github.com/jeffboody/gears2/blob/master/project/jni/gear.c by xpenatan int i; float r0, r1, r2, dz; float angle, da; float u, v, len; - + float [] ar = new float[4]; VertexInfo vertTmp1 = new VertexInfo(); - + r0 = inner_radius; r1 = outer_radius - tooth_depth / 2.0f; r2 = outer_radius + tooth_depth / 2.0f; - + dz = 0.5f * width; - + builder.begin(); // draw front face // GL_TRIANGLE_STRIP @@ -312,7 +312,7 @@ private static Model gear(ModelBuilder builder, float inner_radius, float outer_ } part.index(part.vertex(vertTmp1.setPos(r0 * (float)Math.cos(0.0f), r0 * (float)Math.sin(0.0f), dz))); part.index(part.vertex(vertTmp1.setPos(r1 * (float)Math.cos(0.0f), r1 * (float)Math.sin(0.0f), dz))); - + // draw front sides of teeth // GL_TRIANGLES part = builder.part("gear", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal, new Material(ColorAttribute.createDiffuse(color))); @@ -322,18 +322,18 @@ private static Model gear(ModelBuilder builder, float inner_radius, float outer_ part.index(part.vertex(vertTmp1.setPos(r1 * (float)Math.cos(ar[0]), r1 * (float)Math.sin(ar[0]), dz))); part.index(part.vertex(vertTmp1.setPos(r2 * (float)Math.cos(ar[1]), r2 * (float)Math.sin(ar[1]), dz))); part.index(part.vertex(vertTmp1.setPos(r2 * (float)Math.cos(ar[2]), r2 * (float)Math.sin(ar[2]), dz))); - + part.index(part.vertex(vertTmp1.setPos(r1 * (float)Math.cos(ar[0]), r1 * (float)Math.sin(ar[0]), dz))); part.index(part.vertex(vertTmp1.setPos(r2 * (float)Math.cos(ar[2]), r2 * (float)Math.sin(ar[2]), dz))); part.index(part.vertex(vertTmp1.setPos(r1 * (float)Math.cos(ar[3]), r1 * (float)Math.sin(ar[3]), dz))); } - + // draw back face // GL_TRIANGLE_STRIP part = builder.part("gear", GL20.GL_TRIANGLE_STRIP, Usage.Position | Usage.Normal, new Material(ColorAttribute.createDiffuse(color))); for(i = 0; i < teeth; i++) { gear_angle(i, teeth, ar); - + part.index(part.vertex(vertTmp1.setPos(r0 * (float)Math.cos(ar[0]), r0 * (float)Math.sin(ar[0]), -dz))); part.index(part.vertex(vertTmp1.setPos(r1 * (float)Math.cos(ar[0]), r1 * (float)Math.sin(ar[0]), -dz))); part.index(part.vertex(vertTmp1.setPos(r0 * (float)Math.cos(ar[3]), r0 * (float)Math.sin(ar[3]), -dz))); @@ -341,7 +341,7 @@ private static Model gear(ModelBuilder builder, float inner_radius, float outer_ } part.index(part.vertex(vertTmp1.setPos(r1 * (float)Math.cos(0.0f), r1 * (float)Math.sin(0.0f), -dz))); part.index(part.vertex(vertTmp1.setPos(r0 * (float)Math.cos(0.0f), r0 * (float)Math.sin(0.0f), -dz))); - + // draw back sides of teeth // GL_TRIANGLES part = builder.part("gear", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal, new Material(ColorAttribute.createDiffuse(color))); @@ -351,13 +351,13 @@ private static Model gear(ModelBuilder builder, float inner_radius, float outer_ part.index(part.vertex(vertTmp1.setPos(r1 * (float)Math.cos(ar[3]), r1 * (float)Math.sin(ar[3]), -dz))); part.index(part.vertex(vertTmp1.setPos(r2 * (float)Math.cos(ar[2]), r2 * (float)Math.sin(ar[2]), -dz))); part.index(part.vertex(vertTmp1.setPos(r2 * (float)Math.cos(ar[1]), r2 * (float)Math.sin(ar[1]), -dz))); - + part.index(part.vertex(vertTmp1.setPos(r1 * (float)Math.cos(ar[3]), r1 * (float)Math.sin(ar[3]), -dz))); part.index(part.vertex(vertTmp1.setPos(r2 * (float)Math.cos(ar[1]), r2 * (float)Math.sin(ar[1]), -dz))); part.index(part.vertex(vertTmp1.setPos(r1 * (float)Math.cos(ar[0]), r1 * (float)Math.sin(ar[0]), -dz))); - + } - + // draw outward faces of teeth // GL_TRIANGLE_STRIP // repeated vertices are necessary to achieve flat shading in ES2 @@ -371,25 +371,25 @@ private static Model gear(ModelBuilder builder, float inner_radius, float outer_ part.index(part.vertex(vertTmp1.setPos(r1 * (float)Math.cos(ar[0]), r1 * (float)Math.sin(ar[0]), dz))); part.index(part.vertex(vertTmp1.setPos(r1 * (float)Math.cos(ar[0]), r1 * (float)Math.sin(ar[0]), -dz))); } - + u = r2 * (float)Math.cos(ar[1]) - r1 * (float)Math.cos(ar[0]); v = r2 * (float)Math.sin(ar[1]) - r1 * (float)Math.sin(ar[0]); len = (float)Math.sqrt(u * u + v * v); u /= len; v /= len; - + vertTmp1.setNor(v, -u, 0.0f); part.index(part.vertex(vertTmp1.setPos(r1 * (float)Math.cos(ar[0]), r1 * (float)Math.sin(ar[0]), dz))); part.index(part.vertex(vertTmp1.setPos(r1 * (float)Math.cos(ar[0]), r1 * (float)Math.sin(ar[0]), -dz))); part.index(part.vertex(vertTmp1.setPos(r2 * (float)Math.cos(ar[1]), r2 * (float)Math.sin(ar[1]), dz))); part.index(part.vertex(vertTmp1.setPos(r2 * (float)Math.cos(ar[1]), r2 * (float)Math.sin(ar[1]), -dz))); - + vertTmp1.setNor((float)Math.cos(ar[0]), (float)Math.sin(ar[0]), 0.0f); part.index(part.vertex(vertTmp1.setPos(r2 * (float)Math.cos(ar[1]), r2 * (float)Math.sin(ar[1]), dz))); part.index(part.vertex(vertTmp1.setPos(r2 * (float)Math.cos(ar[1]), r2 * (float)Math.sin(ar[1]), -dz))); part.index(part.vertex(vertTmp1.setPos(r2 * (float)Math.cos(ar[2]), r2 * (float)Math.sin(ar[2]), dz))); part.index(part.vertex(vertTmp1.setPos(r2 * (float)Math.cos(ar[2]), r2 * (float)Math.sin(ar[2]), -dz))); - + u = r1 * (float)Math.cos(ar[3]) - r2 * (float)Math.cos(ar[2]); v = r1 * (float)Math.sin(ar[3]) - r2 * (float)Math.sin(ar[2]); @@ -398,7 +398,7 @@ private static Model gear(ModelBuilder builder, float inner_radius, float outer_ part.index(part.vertex(vertTmp1.setPos(r2 * (float)Math.cos(ar[2]), r2 * (float)Math.sin(ar[2]), -dz))); part.index(part.vertex(vertTmp1.setPos(r1 * (float)Math.cos(ar[3]), r1 * (float)Math.sin(ar[3]), dz))); part.index(part.vertex(vertTmp1.setPos(r1 * (float)Math.cos(ar[3]), r1 * (float)Math.sin(ar[3]), -dz))); - + vertTmp1.setNor((float)Math.cos(ar[0]), (float)Math.sin(ar[0]), 0.0f); part.index(part.vertex(vertTmp1.setPos(r1 * (float)Math.cos(ar[3]), r1 * (float)Math.sin(ar[3]), dz))); part.index(part.vertex(vertTmp1.setPos(r1 * (float)Math.cos(ar[3]), r1 * (float)Math.sin(ar[3]), -dz))); @@ -406,9 +406,9 @@ private static Model gear(ModelBuilder builder, float inner_radius, float outer_ vertTmp1.hasNormal = false; part.index(part.vertex(vertTmp1.setPos(r1 * (float)Math.cos(0.0f), r1 * (float)Math.sin(0.0f), dz))); part.index(part.vertex(vertTmp1.setPos(r1 * (float)Math.cos(0.0f), r1 * (float)Math.sin(0.0f), -dz))); - - - + + + // draw inside radius cylinder // GL_TRIANGLE_STRIP part = builder.part("gear", GL20.GL_TRIANGLE_STRIP, Usage.Position | Usage.Normal, new Material(ColorAttribute.createDiffuse(color))); @@ -422,7 +422,7 @@ private static Model gear(ModelBuilder builder, float inner_radius, float outer_ vertTmp1.setNor(-(float)Math.cos(0.0f), -(float)Math.sin(0.0f), 0.0f); part.index(part.vertex(vertTmp1.setPos(r0 * (float)Math.cos(0.0f), r0 * (float)Math.sin(0.0f), -dz))); part.index(part.vertex(vertTmp1.setPos(r0 * (float)Math.cos(0.0f), r0 * (float)Math.sin(0.0f), dz))); - + return builder.end(); } }