From bf07b44ed6a8958dd321cc4c08fd2bdd08299611 Mon Sep 17 00:00:00 2001
From: Michael Bien <mbien@fh-landshut.de>
Date: Mon, 12 Apr 2010 22:18:39 +0200
Subject: renamed package com.mbien.* in com.jogamp.* JOCL is now officially a
 JogAmp team player ;).

---
 src/com/jogamp/opencl/CLImage.java | 90 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 90 insertions(+)
 create mode 100644 src/com/jogamp/opencl/CLImage.java

(limited to 'src/com/jogamp/opencl/CLImage.java')

diff --git a/src/com/jogamp/opencl/CLImage.java b/src/com/jogamp/opencl/CLImage.java
new file mode 100644
index 00000000..f8916fdb
--- /dev/null
+++ b/src/com/jogamp/opencl/CLImage.java
@@ -0,0 +1,90 @@
+package com.jogamp.opencl;
+
+import com.jogamp.common.nio.Int64Buffer;
+import java.nio.Buffer;
+
+import static com.jogamp.opencl.CL.*;
+
+/**
+ *
+ * @author Michael Bien
+ */
+public abstract class CLImage<B extends Buffer> extends CLMemory<B>  {
+
+    protected CLImageFormat format;
+
+    final CLInfoAccessor imageInfo;
+
+    public final int width;
+    public final int height;
+
+    protected CLImage(CLContext context, B directBuffer, CLImageFormat format, int width, int height, long id, int flags) {
+        this(context, directBuffer, format, new CLImageInfoAccessor(context.cl, id), width, height, id, flags);
+    }
+
+    protected CLImage(CLContext context, B directBuffer, CLImageFormat format, CLImageInfoAccessor accessor, int width, int height, long id, int flags) {
+        super(context, directBuffer, id, flags);
+        this.imageInfo = accessor;
+        this.format = format;
+        this.width = width;
+        this.height = height;
+    }
+
+    protected static CLImageFormat createUninitializedImageFormat() {
+        return new CLImageFormat();
+    }
+
+    /**
+     * Returns the image format descriptor specified when image was created.
+     */
+    public CLImageFormat getFormat() {
+        return format;
+    }
+
+    /**
+     * Returns the size of each element of the image memory object given by image.
+     * An element is made up of n channels. The value of n is given in {@link CLImageFormat} descriptor.
+     */
+    public int getElementSize() {
+        return (int)imageInfo.getLong(CL_IMAGE_ELEMENT_SIZE);
+    }
+
+    /**
+     * Returns the size in bytes of a row of elements of the image object given by image.
+     */
+    public int getRowPitch() {
+        return (int)imageInfo.getLong(CL_IMAGE_ROW_PITCH);
+    }
+
+    /**
+     * Returns width of this image in pixels.
+     */
+    public int getWidth() {
+        return width;
+    }
+
+    /**
+     * Returns the height of this image in pixels.
+     */
+    public int getHeight() {
+        return height;
+    }
+
+
+    protected final static class CLImageInfoAccessor extends CLInfoAccessor {
+
+        private final long id;
+        private final CL cl;
+
+        public CLImageInfoAccessor(CL cl, long id) {
+            this.cl = cl;
+            this.id = id;
+        }
+        @Override
+        public int getInfo(int name, long valueSize, Buffer value, Int64Buffer valueSizeRet) {
+            return cl.clGetImageInfo(id, name, valueSize, value, valueSizeRet);
+        }
+    }
+
+
+}
-- 
cgit v1.2.3