<p>What Direct3D render states should be used to implement Java's Porter-Duff compositing rules (CLEAR, SRC, SRCOVER, etc.)?</p>

I'm haven't used Java too much, but based on the
white paper from 1984
, it should be a fairly straightforward mapping of render state blend modes.
There are of course more that you can do than just these, like normal alpha blending (SourceAlpha, InvSourceAlpha) or additive (One, One) to name a few.
(I assume that you are asking about these specifically because you are porting some existing functionality? In that cause you may not care about other combinations...)
Anyway, these assume a BlendOperation of Add and that AlphaBlendEnable is true.
Clear
```
```
SourceBlend = Zero
DestinationBlend = Zero
```
```
A
```
```
SourceBlend = One
DestinationBlend = Zero
```
```
B
```
```
SourceBlend = Zero
DestinationBlend = One
```
```
A over B
```
```
SourceBlend = One
DestinationBlend = InvSourceAlpha
```
```
B over A
```
```
SourceBlend = InvDestinationAlpha
DestinationBlend = One
```
```
A in B
```
```
SourceBlend = DestinationAlpha
DestinationBlend = One
```
```
B in A
```
```
SourceBlend = Zero
DestinationBlend = SourceAlpha
```
```
A out B
```
```
SourceBlend = InvDestinationAlpha
DestinationBlend = Zero
```
```
B out A
```
```
SourceBlend = Zero
DestinationBlend = InvSourceAlpha
```
```
A atop B
```
```
SourceBlend = DestinationAlpha
DestinationBlend = InvSourceAlpha
```
```
B atop A
```
```
SourceBlend = InvDestinationAlpha
DestinationBlend = SourceAlpha
```
```
A xor B
```
```
SourceBlend = InvDestinationAlpha
DestinationBlend = InvSourceAlpha
```
```
Chaining these is a little more complex and would require either multiple passes or multiple texture inputs to a shader.