~vanvugt/mir/frontend-server

« back to all changes in this revision

Viewing changes to tests/unit-tests/compositor/test_gl_renderer.cpp

Fix thread-safety of Renderable::transformation(). The transformation matrix
is written to and read from different threads. However only the former does
so while holding a lock.

To resolve this we must return a copy instead of a reference, so that the
real BasicSurface.transformation_matrix is always locked when it's being
read.

Approved by Alexandros Frantzis, PS Jenkins bot, Alan Griffiths.

Show diffs side-by-side

added added

removed removed

Lines of Context:
262
262
 
263
263
        EXPECT_CALL(renderable, shaped()).WillRepeatedly(Return(false));
264
264
        EXPECT_CALL(renderable, alpha()).WillRepeatedly(Return(1.0f));
265
 
        EXPECT_CALL(renderable, transformation()).WillRepeatedly(ReturnRef(trans));
 
265
        EXPECT_CALL(renderable, transformation()).WillRepeatedly(Return(trans));
266
266
        EXPECT_CALL(mock_gl, glDisable(_)).Times(AnyNumber());
267
267
 
268
268
        InSequence s;
313
313
    EXPECT_CALL(mock_gl, glActiveTexture(GL_TEXTURE0));
314
314
 
315
315
    EXPECT_CALL(renderable, transformation())
316
 
        .WillOnce(ReturnRef(trans));
 
316
        .WillOnce(Return(trans));
317
317
    EXPECT_CALL(mock_gl, glUniformMatrix4fv(transform_uniform_location, 1, GL_FALSE, _));
318
318
    EXPECT_CALL(renderable, alpha())
319
319
        .WillOnce(Return(0.0f));