@@ -468,6 +468,82 @@ TEST_F(RenderedTargetTest, PaintSvg)
468468 context.doneCurrent ();
469469}
470470
471+ TEST_F (RenderedTargetTest, HullPoints)
472+ {
473+ EngineMock engine;
474+ Sprite sprite;
475+ SpriteModel model;
476+ model.init (&sprite);
477+
478+ RenderedTarget target;
479+ target.setEngine (&engine);
480+ target.setSpriteModel (&model);
481+
482+ // Create OpenGL context
483+ QOpenGLContext context;
484+ QOffscreenSurface surface;
485+ createContextAndSurface (&context, &surface);
486+
487+ // Create a painter
488+ QNanoPainter painter;
489+
490+ QOpenGLFramebufferObjectFormat format;
491+ format.setAttachment (QOpenGLFramebufferObject::CombinedDepthStencil);
492+
493+ // Begin painting
494+ QOpenGLFramebufferObject fbo (4 , 6 , format);
495+ fbo.bind ();
496+ painter.beginFrame (fbo.width (), fbo.height ());
497+
498+ // Paint
499+ QNanoImage image = QNanoImage::fromCache (&painter, " image.png" );
500+ painter.drawImage (image, 0 , 0 );
501+ painter.endFrame ();
502+
503+ // Test hull points
504+ target.updateHullPoints (&fbo);
505+ ASSERT_EQ (target.hullPoints (), std::vector<QPointF>({ { 1 , 1 }, { 2 , 1 }, { 3 , 1 }, { 1 , 2 }, { 3 , 2 }, { 1 , 3 }, { 2 , 3 }, { 3 , 3 } }));
506+
507+ // Begin painting (multisampled)
508+ format.setSamples (16 );
509+ QOpenGLFramebufferObject fboMultiSampled (4 , 6 , format);
510+ fboMultiSampled.bind ();
511+ painter.beginFrame (fboMultiSampled.width (), fboMultiSampled.height ());
512+
513+ // Paint (multisampled)
514+ painter.drawImage (image, 0 , 0 );
515+ painter.endFrame ();
516+
517+ // Test hull points (this is undefined with multisampling, so we just check if there are any hull points)
518+ ASSERT_FALSE (target.hullPoints ().empty ());
519+
520+ // Release
521+ fbo.release ();
522+ context.doneCurrent ();
523+
524+ // Test contains()
525+ ASSERT_FALSE (target.contains ({ 0 , 0 }));
526+ ASSERT_FALSE (target.contains ({ 1 , 0 }));
527+ ASSERT_FALSE (target.contains ({ 2 , 0 }));
528+ ASSERT_FALSE (target.contains ({ 3 , 0 }));
529+
530+ ASSERT_FALSE (target.contains ({ 0 , 1 }));
531+ ASSERT_TRUE (target.contains ({ 1 , 1 }));
532+ ASSERT_TRUE (target.contains ({ 1.4 , 1.25 }));
533+ ASSERT_TRUE (target.contains ({ 2 , 1 }));
534+ ASSERT_TRUE (target.contains ({ 3 , 1 }));
535+
536+ ASSERT_TRUE (target.contains ({ 1 , 2 }));
537+ ASSERT_FALSE (target.contains ({ 2 , 2 }));
538+ ASSERT_TRUE (target.contains ({ 3 , 2 }));
539+ ASSERT_FALSE (target.contains ({ 3.5 , 2.1 }));
540+
541+ ASSERT_TRUE (target.contains ({ 1 , 3 }));
542+ ASSERT_TRUE (target.contains ({ 2 , 3 }));
543+ ASSERT_TRUE (target.contains ({ 3 , 3 }));
544+ ASSERT_FALSE (target.contains ({ 3.3 , 3.5 }));
545+ }
546+
471547TEST_F (RenderedTargetTest, Engine)
472548{
473549 RenderedTarget target;
0 commit comments