public AtomicPaletteBlockStore( int shift, boolean storeState, int dirtySize, int[] palette, int blockArrayWidth, int[] variableWidthBlockArray) { this(shift, storeState, dirtySize); store.set(palette, blockArrayWidth, variableWidthBlockArray); }
@Override public short[] getDataArray(short[] array) { if (array.length != length) { array = new short[length]; } for (int i = 0; i < length; i++) { array[i] = BlockFullState.getData(store.get(i)); } return array; }
@Override public int getAndSetBlock(int x, int y, int z, short id, short data) { int oldState = BlockFullState.getPacked(id, data); int newState = 0; try { return newState = store.set(getIndex(x, y, z), oldState); } finally { markDirty(x, y, z, oldState, newState); } }
@Override public boolean compareAndSetBlock( int x, int y, int z, short expectId, short expectData, short newId, short newData) { int exp = BlockFullState.getPacked(expectId, expectData); int update = BlockFullState.getPacked(newId, newData); boolean success = store.compareAndSet(getIndex(x, y, z), exp, update); if (success && exp != update) { markDirty(x, y, z, exp, update); } return success; }
public AtomicPaletteBlockStore( int shift, boolean storeState, int dirtySize, short[] blocks, short[] data) { this(shift, storeState, dirtySize); if (blocks != null) { int[] initial = new int[Math.min(blocks.length, this.length)]; for (int i = 0; i < blocks.length; i++) { short d = data != null ? data[i] : 0; initial[i] = BlockFullState.getPacked(blocks[i], d); } store.set(initial); } }
@Override public boolean isBlockUniform() { return store.isUniform(); }
@Override public boolean tryWriteLock() { return store.tryLock(); }
@Override public void writeUnlock() { store.unlock(); }
@Override public void writeLock() { store.lock(); }
@Override public int[] getPalette() { return store.getPalette(); }
@Override public int[] getPackedArray() { return store.getBackingArray(); }
@Override public int getPackedWidth() { return store.width(); }
@Override public void compress(TIntHashSet inUseSet) { store.compress(inUseSet); }
@Override public int getFullData(int index) { return store.get(index); }