diff options
author | Michael Bien <[email protected]> | 2010-01-18 15:24:29 +0100 |
---|---|---|
committer | Michael Bien <[email protected]> | 2010-01-18 15:24:29 +0100 |
commit | 09ac312a0645bd0d9adff580f29f20382dfbf8c9 (patch) | |
tree | 52e121e8c366c797f34008244243dd896cc1e88a /src/com/mbien/opencl/CLImage.java | |
parent | c4aeea288271f57b3c8640a8cd4ba87d1c331814 (diff) |
introduced CLMemory as superclass for all memory objects.
added CLImage, CLImage2d and CLImage3d.
Diffstat (limited to 'src/com/mbien/opencl/CLImage.java')
-rw-r--r-- | src/com/mbien/opencl/CLImage.java | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/com/mbien/opencl/CLImage.java b/src/com/mbien/opencl/CLImage.java new file mode 100644 index 00000000..448caeda --- /dev/null +++ b/src/com/mbien/opencl/CLImage.java @@ -0,0 +1,70 @@ +package com.mbien.opencl; + +import com.sun.gluegen.runtime.PointerBuffer; +import java.nio.Buffer; + +import static com.mbien.opencl.CL.*; + +/** + * + * @author Michael Bien + */ +public abstract class CLImage<B extends Buffer> extends CLMemory<B> { + + protected final CLImageFormat format; + + final CLInfoAccessor imageInfo; + + protected CLImage(CLContext context, B directBuffer, CLImageFormat format, long id) { + super(context, directBuffer, id); + this.imageInfo = new CLImageInfoAccessor(); + this.format = format; + } + + /** + * 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 (int)imageInfo.getLong(CL_IMAGE_WIDTH); + } + + /** + * Returns the height of this image in pixels. + */ + public int getHeight() { + return (int)imageInfo.getLong(CL_IMAGE_HEIGHT); + } + + + + private final class CLImageInfoAccessor extends CLInfoAccessor { + @Override + protected int getInfo(int name, long valueSize, Buffer value, PointerBuffer valueSizeRet) { + return cl.clGetImageInfo(ID, name, valueSize, value, valueSizeRet); + } + } + + +} |