// Adds the mask as the last channel
private static Page[] maskPages(boolean maskValue, Page... pages)
{
Page[] maskedPages = new Page[pages.length];
for (int i = 0; i < pages.length; i++) {
Page page = pages[i];
BlockBuilder blockBuilder = BOOLEAN.createBlockBuilder(new BlockBuilderStatus());
for (int j = 0; j < page.getPositionCount(); j++) {
BOOLEAN.writeBoolean(blockBuilder, maskValue);
}
Block[] sourceBlocks = page.getBlocks();
Block[] outputBlocks = new Block[sourceBlocks.length + 1]; // +1 for the single boolean output channel
System.arraycopy(sourceBlocks, 0, outputBlocks, 0, sourceBlocks.length);
outputBlocks[sourceBlocks.length] = blockBuilder.build();
maskedPages[i] = new Page(outputBlocks);
}
return maskedPages;
}