1 32 package com.imagero.uio.buffer.arrays; 33 34 import com.imagero.uio.buffer.MemoryAccessManager; 35 36 43 public class IntArrayBufferManager extends AbstractArrayBufferManager { 44 45 int[] data; 46 47 52 public IntArrayBufferManager(int[] data) { 53 this(data, Math.min(TILE_SIZE, data.length)); 54 } 55 56 60 public IntArrayBufferManager(int[] data, int size) { 61 this(data, 0, data.length, size); 62 } 63 64 69 public IntArrayBufferManager(int[] data, int offset, int length) { 70 this(data, offset, length, TILE_SIZE); 71 } 72 73 79 public IntArrayBufferManager(int[] data, int offset, int length, int size) { 80 this.data = data; 81 this.tileSize = size; 82 this.unitSize = 4; 83 this.length = length; 84 this.offset = offset; 85 accessManager = MemoryAccessManager.createMemoryAccessManager(); 86 } 87 88 97 protected int writeUnitLE(byte[] source, int sourceOffset, int destOffset) { 98 int v = ((source[sourceOffset++] & 0xFF)) 99 | (((source[sourceOffset++] & 0xFF)) << 8) 100 | (((source[sourceOffset++] & 0xFF)) << 16) 101 | (((source[sourceOffset++] & 0xFF)) << 24); 102 data[destOffset] = v; 103 return sourceOffset; 104 } 105 106 115 protected int writeUnitBE(byte[] source, int sourceOffset, int destOffset) { 116 int v = ((source[sourceOffset++] & 0xFF) << 24) 117 | ((source[sourceOffset++] & 0xFF) << 16) 118 | ((source[sourceOffset++] & 0xFF) << 8) 119 | (source[sourceOffset++] & 0xFF); 120 data[destOffset] = v; 121 return sourceOffset; 122 } 123 124 133 protected int readUnitBE(int offset, byte[] dest, int destOffset) { 134 int v = data[offset]; 135 dest[destOffset++] = (byte) ((v >>> 24) & 0xFF); 136 dest[destOffset++] = (byte) ((v >>> 16) & 0xFF); 137 dest[destOffset++] = (byte) ((v >>> 8) & 0xFF); 138 dest[destOffset++] = (byte) (v & 0xFF); 139 return destOffset; 140 } 141 142 151 protected int readUnitLE(int offset, byte[] dest, int destOffset) { 152 int v = data[offset]; 153 dest[destOffset++] = (byte) (v & 0xFF); 154 dest[destOffset++] = (byte) ((v >>> 8) & 0xFF); 155 dest[destOffset++] = (byte) ((v >>> 16) & 0xFF); 156 dest[destOffset++] = (byte) ((v >>> 24) & 0xFF); 157 return destOffset; 158 } 159 160 public int getMaxCache() { 161 return 0; 162 } 163 164 public void setMaxCache(int max) { 165 } 166 } 167 | Popular Tags |