Skip to content

Commit

Permalink
image factory methods for CLContext.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbien committed Jun 28, 2010
1 parent 467453f commit c5dae5b
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/com/jogamp/opencl/CLContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,66 @@ public final <B extends Buffer> CLBuffer<B> createBuffer(B directBuffer, int fla
return buffer;
}

/**
* Creates a CLImage2d with the specified format, dimension and flags.
*/
public final CLImage2d<?> createImage2d(int width, int height, CLImageFormat format, Mem... flags) {
return createImage2d(null, width, height, 0, format, flags);
}

/**
* Creates a CLImage2d with the specified format, dimension and flags.
*/
public final CLImage2d<?> createImage2d(int width, int height, int rowPitch, CLImageFormat format, Mem... flags) {
return createImage2d(null, width, height, rowPitch, format, flags);
}

/**
* Creates a CLImage2d with the specified format, dimension and flags.
*/
public final <B extends Buffer> CLImage2d<B> createImage2d(B directBuffer, int width, int height, CLImageFormat format, Mem... flags) {
return createImage2d(directBuffer, width, height, 0, format, flags);
}

/**
* Creates a CLImage2d with the specified format, dimension and flags.
*/
public final <B extends Buffer> CLImage2d<B> createImage2d(B directBuffer, int width, int height, int rowPitch, CLImageFormat format, Mem... flags) {
CLImage2d<B> image = CLImage2d.createImage(this, directBuffer, width, height, rowPitch, format, Mem.flagsToInt(flags));
memoryObjects.add(image);
return image;
}

/**
* Creates a CLImage3d with the specified format, dimension and flags.
*/
public final CLImage3d<?> createImage3d(int width, int height, CLImageFormat format, Mem... flags) {
return createImage3d(null, width, height, 0, format, flags);
}

/**
* Creates a CLImage3d with the specified format, dimension and flags.
*/
public final CLImage3d<?> createImage3d(int width, int height, int depth, int rowPitch, CLImageFormat format, Mem... flags) {
return createImage3d(null, width, height, rowPitch, format, flags);
}

/**
* Creates a CLImage3d with the specified format, dimension and flags.
*/
public final <B extends Buffer> CLImage3d<B> createImage3d(B directBuffer, int width, int height, int depth, CLImageFormat format, Mem... flags) {
return createImage3d(directBuffer, width, height, depth, 0, 0, format, flags);
}

/**
* Creates a CLImage3d with the specified format, dimension and flags.
*/
public final <B extends Buffer> CLImage3d<B> createImage3d(B directBuffer, int width, int height, int depth, int rowPitch, int slicePitch, CLImageFormat format, Mem... flags) {
CLImage3d<B> image = CLImage3d.createImage(this, directBuffer, width, height, depth, rowPitch, slicePitch, format, Mem.flagsToInt(flags));
memoryObjects.add(image);
return image;
}

CLCommandQueue createCommandQueue(CLDevice device, long properties) {

CLCommandQueue queue = CLCommandQueue.create(this, device, properties);
Expand Down
28 changes: 28 additions & 0 deletions src/com/jogamp/opencl/CLImageFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
/**
* Represents the OpenCL image format with its channeltype and order.
* @author Michael Bien
* @see CLContext#getSupportedImage2dFormats(com.jogamp.opencl.CLMemory.Mem[])
* @see CLContext#getSupportedImage3dFormats(com.jogamp.opencl.CLMemory.Mem[])
*/
public final class CLImageFormat {

Expand Down Expand Up @@ -56,6 +58,32 @@ public String toString() {
return "CLImageFormat["+getImageChannelOrder()+" "+getImageChannelDataType()+"]";
}

@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final CLImageFormat other = (CLImageFormat) obj;
if (this.getImageChannelDataType() != other.getImageChannelDataType()) {
return false;
}
if (this.getImageChannelOrder() != other.getImageChannelOrder()) {
return false;
}
return true;
}

@Override
public int hashCode() {
int hash = 5;
hash = 47 * hash + (this.getImageChannelDataType() != null ? this.getImageChannelDataType().hashCode() : 0);
hash = 47 * hash + (this.getImageChannelOrder() != null ? this.getImageChannelOrder().hashCode() : 0);
return hash;
}

/**
* Specifies the number of channels and the channel layout i.e. the memory
* layout in which channels are stored in the image.
Expand Down

0 comments on commit c5dae5b

Please sign in to comment.