In PsychoPy, later draws sit above earlier ones in the same window; blend modes such as avg also composite translucent pixels with what lies underneath.[1][4] The design question is whether the composite equals “draw each stimulus alone, then combine by the rule.” Commit 95b8a6f (PR #7890, merged 2026-11-09) rewrote that check: three older tests were removed and replaced by a Gaussian-masked rotating grating verified frame-by-frame against a blend prediction over a playing movie.[1][3] Below: fixed setup, controls and measures, and how old and new tests differ—from that commit, its parent file, and the rendering docs—with emphasis on when the back buffer is cleared and which footprint supplies the compare mask.

Fixed window, reference frames, and footprint regions

The shared window is 128×128 pixels (pyglet, no GUI). Captures always draw to the back buffer then read back, but old and new tests clear that buffer differently.[2] The old helper _drawToBackBuffer calls win.flip() before each capture to clear the back buffer (comment: leaving the window background), draws the stimuli, reads back, then flips again—so every alone or composite frame starts clean.[2] The new drawnOver only draws its arguments then _captureBackBuffer and does not clear: after black/white+grating calibration, movieAlone = drawnOver(mov) is followed immediately by composite = drawnOver(grating) so the just-drawn movie stays under the grating on the same back buffer—another flip, redraw, or frame advance between those two calls would break “grating over that movieAlone.”[1] Old tests find footprints (pixel-change threshold near 12), erode by EDGE_MARGIN=2 for overlap and dilate-then-complement for surround, checking “matches upper / lower untouched.”[2] The new mask is inside = erode(movie drawn region, 2) and scores the blend prediction only inside movie coverage—not the old grating-footprint plus surround complement.[1] Older tests often pause on a sample frame; the new test pre-plays with _drawFrames, then flips after each orientation step to advance playback.[1]

Schematic: alone frames and two draw-order compare regions.

Figure: Schematic alone references, two draw orders, and eroded/dilated overlap vs surround regions. Drawn for this article, PsychoPy commit 95b8a6f[1]

Old tests: two orders with an opaque grating

In the parent file, test_gratingOverMovieDrawsCorrectly, at orientations 0, 30, 45, 90, and 137°, uses _drawToBackBuffer for grating alone, movie alone, and movie-then-grating: max pixel difference ≤1 versus “grating alone” in the eroded overlap, and ≤1 versus “movie alone” in the surround.[2] The symmetric test_movieOverGratingDrawsCorrectly draws grating then a smaller movie, requiring the movie region to match the movie alone and the surround to match the grating.[2] test_rotatingGratingOverPlayingMovie rotates (and swaps textures) over a playing movie to check each angle against the alone grating while new frames upload between draws—if upload left a bad unpack alignment or row length, later grating textures would expose it.[2] All three were deleted in 95b8a6f. Shared old structure: flip-to-clear around every capture, (near-)opaque uppers, a hard ≤1 threshold, and two-way overlap/surround checks; opaque uppers make overlap nearly pixel-equal to the upper alone, which is why translucent masks later need an explicit blend prediction.[1][2]

New test: Gaussian mask, blend prediction, threshold 2

New test_rotatingMaskedGratingOverPlayingMovie places an 80×80 sine grating with a Gaussian mask over a 100×100 playing movie; orientation runs from 0 to 177° in 3° steps (60 frames).[1] Each frame uses drawnOver for black+grating and white+grating, then movieAlone, then—without clearing or redrawing the movie—drawnOver(grating) for the composite, and only afterward win.flip() to advance playback.[1] Scoring uses only the eroded movie coverage inside. From overBlack and overWhite it recovers colour and opacity: transmittance (overWhite−overBlack)/255, predicted composite overBlack + transmittance×movieAlone; max absolute error ≤2 inside inside (comment: each capture rounds to 8 bits).[1] A non-vacuous check requires mean |composite−movieAlone| > 1 in inside, and movieTime must advance past the loop start.[1] That matches reading avg as opacity-weighted mixing of layers.[4] The case is parametrized over movie backends and gpuColorConversion true/false; test_drawLeavesGLStateAlone remains separate from the geometry overlay check.[1]

The controlled comparison splits into two back-buffer paths and two masks: old tests flip-clear before and after every capture and run ≤1 two-way checks on grating-footprint overlap/surround; the new test chains uncleared drawnOver from movieAlone to composite, scores a blend prediction only inside the eroded movie region at ≤2, and adds a non-vacuous change check.[1][2] Old tests demand near-identity with alone draws; the new test allows translucent masks and 8-bit quantisation with an explicit prediction so failures can be traced against overBlack, transmittance, and movieAlone.[1] Names, angle tables, and thresholds follow that commit’s source; hardware-decode and HiDPI changes in the same period are out of scope.

References

  1. PsychoPy commit 95b8a6f (2026-11-09). revise MovieStim draw with other stimuli test (#7890). https://github.com/psychopy/psychopy/commit/95b8a6fb41892e6c11496ed17c3f542d7ef5ddd6

  2. psychopy/tests/test_visual/test_movies.py at parent 6e48ada (deleted tests) and at 95b8a6f (added test).

  3. Pull request #7890. https://github.com/psychopy/psychopy/pull/7890

  4. PsychoPy docs: OpenGL and Rendering. https://psychopy.readthedocs.io/en/stable/general/rendering.html

  5. test_movies.py at 95b8a6f

  6. test_movies.py at 6e48ada