nested clipping now works with save/restore

This commit is contained in:
Thomas Friedel 2018-03-25 15:48:26 +02:00
parent 649cffa1e3
commit a9aa15d1d6

View file

@ -505,16 +505,16 @@ func (cv *Canvas) Restore() {
if l <= 0 { if l <= 0 {
return return
} }
hadClip := len(cv.state.clip) > 0
cv.state = cv.stateStack[l-1]
cv.stateStack = cv.stateStack[:l-1]
if len(cv.state.clip) > 0 {
cv.clip(cv.state.clip)
} else if hadClip {
gli.StencilMask(0x02) gli.StencilMask(0x02)
gli.Clear(gl_STENCIL_BUFFER_BIT) gli.Clear(gl_STENCIL_BUFFER_BIT)
gli.StencilMask(0xFF) gli.StencilMask(0xFF)
for _, st := range cv.stateStack {
if len(st.clip) > 0 {
cv.clip(st.clip)
} }
}
cv.state = cv.stateStack[l-1]
cv.stateStack = cv.stateStack[:l-1]
} }
// Scale updates the current transformation with a scaling by the given values // Scale updates the current transformation with a scaling by the given values