Alpha fixes
Don't | 0xff000000 when the colour is from raster Do | 0xff000000 when the 256 - opacity can't be found Also only check drawLoggedIn, other methods aren't drawn by gpu
This commit is contained in:
@@ -80,7 +80,7 @@ public class RasterizerAlpha extends AbstractInjector
|
||||
public void inject() throws Injexception
|
||||
{
|
||||
final Field r2dPx = InjectUtil.findField(inject, "Rasterizer2D_pixels", "Rasterizer2D");
|
||||
final Method draw = InjectUtil.findMethod(inject, "draw", "Client");
|
||||
final Method draw = InjectUtil.findMethod(inject, "drawLoggedIn", "Client");
|
||||
final ClassFile rasterizer2D = r2dPx.getClassFile();
|
||||
final Execution ex = new Execution(rasterizer2D.getGroup());
|
||||
ex.staticStep = false;
|
||||
@@ -98,6 +98,7 @@ public class RasterizerAlpha extends AbstractInjector
|
||||
int count = 0;
|
||||
int orCount = 0;
|
||||
|
||||
outer:
|
||||
for (InstructionContext ic : mc.getInstructionContexts())
|
||||
{
|
||||
Instruction instruction = ic.getInstruction();
|
||||
@@ -118,31 +119,14 @@ public class RasterizerAlpha extends AbstractInjector
|
||||
InstructionContext colPusher = colour.getPushed().resolve(colour);
|
||||
Instruction colPushI = colPusher.getInstruction();
|
||||
|
||||
// If it's not a >> or a | we're not interested
|
||||
if (colPushI instanceof LVTInstruction // when called from a method we didn't execute
|
||||
|| colPushI instanceof PushConstantInstruction &&
|
||||
!((PushConstantInstruction) colPushI).getConstant().equals(0)
|
||||
|| colPushI instanceof IALoad)
|
||||
{
|
||||
// OR with 0xFF000000, unless 0
|
||||
int storeIdx = instrs.getInstructions().indexOf(instruction);
|
||||
|
||||
instrs.addInstruction(storeIdx++, new LDC(instrs, ALPHA));
|
||||
instrs.addInstruction(storeIdx, new IOr(instrs, InstructionType.IOR));
|
||||
++orCount;
|
||||
continue;
|
||||
}
|
||||
else if (!(
|
||||
colPushI instanceof IShR ||
|
||||
// If it's not a >> or a >>> or a + it's not alpha
|
||||
if (colPushI instanceof IShR ||
|
||||
colPushI instanceof IUShR ||
|
||||
colPushI instanceof IAdd))
|
||||
colPushI instanceof IAdd)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// So we know we're dealing with alpha here, now we need the alpha value
|
||||
// earlier on in the method there's been a 256 - XXX, where xxx is alpha
|
||||
|
||||
// So we know we may be dealing with alpha here, now we need the alpha value
|
||||
// earlier on in the method there's been a 256 - XXX, where xxx is alpha.
|
||||
// if that SiPush 256 doesn't exist, we should just | 0xff000000 instead
|
||||
for (InstructionContext ins : mc.getInstructionContexts())
|
||||
{
|
||||
if (!(ins.getInstruction() instanceof SiPush))
|
||||
@@ -184,10 +168,28 @@ public class RasterizerAlpha extends AbstractInjector
|
||||
|
||||
instrs.getInstructions().set(storeIdx, new InvokeStatic(instrs, DRAWALPHA));
|
||||
++count;
|
||||
break;
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
|
||||
// If we're copying from the same field we don't have to apply extra alpha again
|
||||
if (colPushI instanceof IALoad
|
||||
&& isSameField(r2dPx, colPusher.getPops().get(1)))
|
||||
continue;
|
||||
|
||||
// If the value is 0, it's supposed to be transparent, not black
|
||||
if (colPushI instanceof PushConstantInstruction
|
||||
&& ((PushConstantInstruction) colPushI).getConstant().equals(0))
|
||||
continue;
|
||||
|
||||
// rasterPx[idx] = color | 0xff000000 (the | 0xff000000 is what's added)
|
||||
int storeIdx = instrs.getInstructions().indexOf(instruction);
|
||||
|
||||
instrs.addInstruction(storeIdx++, new LDC(instrs, ALPHA));
|
||||
instrs.addInstruction(storeIdx, new IOr(instrs, InstructionType.IOR));
|
||||
++orCount;
|
||||
}
|
||||
|
||||
if (orCount != 0)
|
||||
{
|
||||
counts[0] += orCount;
|
||||
|
||||
Reference in New Issue
Block a user