private void renderBlend(Surface input1, Surface input2, Surface output) { if (output.hasAlpha()) { output.process(new Blit().setBlendMode(BlendMode.Add).setOpacity(1 - mix), input1); output.process(new Blit().setBlendMode(BlendMode.Add).setOpacity(mix), input2); input1.release(); } else { output.copy(input1); input1.release(); output.process(new Blit().setBlendMode(BlendMode.Normal).setOpacity(mix), input2); } input2.release(); }
private void drawSingle(Surface input, Surface output) { if (mix == 0.0) { output.copy(input); } else if (mix == 1.0) { output.clear(); } else { output.process(new Blit().setBlendMode(BlendMode.Normal).setOpacity(1 - mix), input); } input.release(); }
private void drawComposite(Surface input1, Surface input2, Surface output) { if (mix == 0.0) { output.process(Blit.op(), input1); } else if (mix == 1.0) { output.process(Blit.op(), input2); } else { switch (mode) { case Add: renderAdd(input1, input2, output); break; case Difference: renderDifference(input1, input2, output); break; case BitXor: renderBitXor(input1, input2, output); break; default: renderBlend(input1, input2, output); } } }
private void renderDifference(Surface input1, Surface input2, Surface output) { double alpha; Surface src; Surface dst; if (mix >= 0.5) { alpha = (1.0 - mix) * 2; src = input1; dst = input2; } else { alpha = mix * 2; src = input2; dst = input1; } output.copy(dst); dst.release(); output.process(new Blit().setBlendMode(BlendMode.Difference).setOpacity(alpha), src); src.release(); }