void KisCoordinatesConverterTest::testMirroringCanvasBiggerThanImage()
{
    KisImageSP image;
    KisCoordinatesConverter converter;
    initImage(&image, &converter);

    QSize widgetSize(2000,2000);
    QSize flakeSize(1000,1000);
    QRectF testRect(300, 100, 200, 200);

    converter.setImage(image);
    converter.setDocumentOffset(QPoint(-50,-50));
    converter.setCanvasWidgetSize(widgetSize);

    QTransform imageToWidget;
    QTransform documentToWidget;
    QTransform flakeToWidget;
    QTransform viewportToWidget;

    converter.mirror(converter.imageCenterInWidgetPixel(), true, false);
    converter.setZoom(1.);

    // image pixels == flake pixels

    QRectF viewportRect = converter.imageToViewport(testRect);
    QRectF widgetRect = converter.viewportToWidget(viewportRect);

    QCOMPARE(widgetRect, QRectF(550,150,200,200));
    QCOMPARE(viewportRect, QRectF(300,100,200,200));
}
void KisCoordinatesConverterTest::testRotation()
{
    KisImageSP image;
    KisCoordinatesConverter converter;
    initImage(&image, &converter);

    QSize widgetSize(1000,500);
    QRectF testRect(800, 100, 300, 300);

    converter.setImage(image);
    converter.setDocumentOffset(QPoint(0,0));
    converter.setCanvasWidgetSize(widgetSize);

    converter.rotate(converter.widgetCenterPoint(), 30);
    converter.setZoom(1.);

    QTransform viewportToWidget = converter.viewportToWidgetTransform();

    QRectF boundingRect = viewportToWidget.mapRect(testRect);
    QRectF directRect = converter.viewportToWidget(testRect);

    QCOMPARE(boundingRect, directRect);

    QRectF referenceRect(QPointF(742.82,53.5898), QSizeF(409.808,409.808));

#define FUZZY(a,b) ((a)-(b) < 0.01)

    QVERIFY(FUZZY(boundingRect.top(), referenceRect.top()));
    QVERIFY(FUZZY(boundingRect.left(), referenceRect.left()));
    QVERIFY(FUZZY(boundingRect.width(), referenceRect.width()));
    QVERIFY(FUZZY(boundingRect.height(), referenceRect.height()));
}
Exemple #3
0
void TestCanvas::test(GiCanvas* canvas, int bits, int n, bool randStyle)
{
    s_randStyle = randStyle;
    if ((bits & kDynCurves) == 0 || !s_inited) {
        initRand();
    }
    
    if (bits & kRect)
        testRect(canvas, n * 2);
    if (bits & kLine)
        testLine(canvas, n * 2);
    if (bits & kTextAt)
        testTextAt(canvas, n);
    if (bits & kEllipse)
        testEllipse(canvas, n * 2);
    if (bits & kQuadBezier)
        testQuadBezier(canvas, n);
    if (bits & kCubicBezier)
        testCubicBezier(canvas, n);
    if (bits & kPolygon)
        testPolygon(canvas, n);
    if (bits & kClearRect)
        canvas->clearRect(100, 100, 200, 200);
    if (bits & kClipPath)
        testClipPath(canvas, n);
    if (bits & kHandle)
        testHandle(canvas, n);
    if (bits & kDynCurves)
        testDynCurves(canvas);
}
Exemple #4
0
void TestCanvas::test(GiCanvas* canvas, int bits, int n, bool randStyle)
{
    s_randStyle = randStyle;
    if ((bits & 0x400) == 0 || !s_inited) {
        initRand();
    }
    
    if (bits & 0x01)
        testRect(canvas, n);
    if (bits & 0x02)
        testLine(canvas, n);
    if (bits & 0x04)
        testTextAt(canvas, n);
    if (bits & 0x08)
        testEllipse(canvas, n);
    if (bits & 0x10)
        testQuadBezier(canvas, n);
    if (bits & 0x20)
        testCubicBezier(canvas, n);
    if (bits & 0x40)
        testPolygon(canvas, n);
    if (bits & 0x80)
        canvas->clearRect(100, 100, 200, 200);
    if (bits & 0x100)
        testClipPath(canvas, n);
    if (bits & 0x200)
        testHandle(canvas, n);
    if (bits & 0x400)
        testDynCurves(canvas);
}
Exemple #5
0
bool UIView::processTouchMove(int x, int y)
{
	onMouseMove();

	for(std::vector<UIView*>::iterator it = m_children.begin(); it != m_children.end(); it++)
	{
		FloatRect controlRect = (*it)->getBounds();
		FloatRect testRect(controlRect.left, controlRect.top, controlRect.width - 1, controlRect.height - 1);

		(*it)->processTouchMove(x,y);

		if(testRect.contains(x,y))
		{
			if(!(*it)->m_hovered)
			{
				(*it)->setPseudoClass("hover", true);
				(*it)->m_hovered = true;
			}
		}
		else
		{
			// mouse is not in it, is it just leaving now?
			if((*it)->m_hovered)
			{
				(*it)->setPseudoClass("hover", false);
				(*it)->onMouseLeave();
				(*it)->m_hovered = false;
			}
		}
	}

	return false;
}
void KisCoordinatesConverterTest::testConsistency()
{
    KisImageSP image;
    KisCoordinatesConverter converter;
    initImage(&image, &converter);

    converter.setImage(image);
    converter.setDocumentOffset(QPoint(20,30));
    converter.setCanvasWidgetSize(QSize(500,500));

    QRectF testRect(100,100,100,100);
    QTransform imageToWidget;
    QTransform documentToWidget;
    QTransform viewportToWidget;

    converter.setZoom(0.5);

    imageToWidget = converter.imageToWidgetTransform();
    documentToWidget = converter.documentToWidgetTransform();
    viewportToWidget = converter.viewportToWidgetTransform();

    QRectF fromImage = converter.viewportToWidget(converter.imageToViewport(testRect));
    QRectF fromDocument = converter.documentToWidget(testRect);
    QRectF fromViewport = converter.viewportToWidget(testRect);

    CHECK_TRANSFORM(imageToWidget, testRect, fromImage);
    CHECK_TRANSFORM(documentToWidget, testRect, fromDocument);
    CHECK_TRANSFORM(viewportToWidget, testRect, fromViewport);
}
void KisTransformMaskTest::testSafeTransformSingleVanishingPoint()
{
    // rotation around 0X has a single vanishing point for 0Y axis
    QTransform transform(1, 0, 0,
                         -0.870208, -0.414416, -0.000955222,
                         132.386, 1082.91, 1.99439);

    QTransform R; R.rotateRadians(M_PI / 4.0);
    //transform *= R;

    QRectF testRect(1536, 1024, 512, 512);
    KisSafeTransform t2(transform, QRect(0, 0, 2048, 2048), testRect.toRect());

    QPolygonF fwdPoly = t2.mapForward(testRect);
    QRectF fwdRect = t2.mapRectForward(testRect);

    QPolygonF bwdPoly = t2.mapBackward(fwdPoly);
    QRectF bwdRect = t2.mapRectBackward(fwdRect);

    /**
     * A special weird rect that crosses the vanishing point,
     * which is (911.001, 433.84) in this case
     */
    QRectF fwdNastyRect(800, 100, 400, 600);
    //QRectF fwdNastyRect(100, 400, 1000, 800);
    QRectF bwdNastyRect = t2.mapRectBackward(fwdNastyRect);

/*
    dbgKrita << ppVar(testRect);
    dbgKrita << ppVar(fwdPoly);
    dbgKrita << ppVar(fwdRect);
    dbgKrita << ppVar(bwdPoly);
    dbgKrita << ppVar(bwdRect);
    dbgKrita << ppVar(bwdNastyRect);
*/

    QPolygon ref;

    ref.clear();
    ref << QPoint(765,648);
    ref << QPoint(1269, 648);
    ref << QPoint(1601, 847);
    ref << QPoint(629, 847);
    ref << QPoint(765, 648);
    QCOMPARE(fwdPoly.toPolygon(), ref);
    QCOMPARE(fwdRect.toRect(), QRect(629,648,971,199));

    ref.clear();
    ref << QPoint(1536,1024);
    ref << QPoint(2048,1024);
    ref << QPoint(2048,1536);
    ref << QPoint(1536,1536);
    ref << QPoint(1536,1024);
    QCOMPARE(bwdPoly.toPolygon(), ref);
    QCOMPARE(bwdRect.toRect(), QRect(1398,1024,650,512));

    QCOMPARE(bwdNastyRect.toRect(), QRect(1463,0,585,1232));
}
rSize ruiLinearLayout::ComputeSize() {
	rRect testRect(0, 0, INT_MAX, INT_MAX);

	if (m_layoutDirection == ruiLAYOUT_HORIZONTAL) {
		return LayoutHorizontal(testRect, false);
	}
	else {
		return LayoutVertical(testRect, false);
	}
}
Exemple #9
0
void HSBackport::doExclusiveEffect() {
	
	int percent = 100 - getBackportProgress(); // + backportFinishedReleaseFrames;

	// int nc = effectColorsMat->cols*effectColorsMat->channels();					// number of elements per line
	// get the address of row 0
	// uchar* data = effectColorsMat.ptr<uchar>(0);

	int halfWidth = (int)floor(effectMat.cols / 2);
	// int rowSize = effectColorsMat.cols * effectColorsMat.channels();

	for (int c = halfWidth; c > 0; c--) {
		for (int d = 0; d < 90; d++) {
			
			int colorAddressX = halfWidth - c + (int)floor((effectColorsMat.cols - halfWidth) / 100 * percent);
			if (colorAddressX >= effectColorsMat.cols) {
				colorAddressX = effectColorsMat.cols - 1;
			}
			int colorAddressY = d;

			// int colorAddressj = ((halfWidth - c + (int)floor((effectColorsMat.cols - halfWidth) / 100 * percent)) * effectColorsMat.channels()) + (rowSize * d);
			// Scalar sColor(data[colorAddressj], data[colorAddressj + 1], data[colorAddressj + 2], 255);
			
			Vec4b myColor = effectColorsMat.at<Vec4b>(colorAddressY, colorAddressX);
			Scalar sColor(myColor[0], myColor[1], myColor[2], 255);
			
			// cv::circle(effectMat, bCenterPoint, c*2, sColor, CV_FILLED, 8, 0);
			cv::ellipse(effectMat,
				bCenterPoint,
				Size(c, c),
				0, 
				d*4, 
				(d+1)*4,
				sColor, CV_FILLED, 8, 0);
		}
	}
	
	int test = 1;
	// effectMat
	
	for (vector<CorsairLedPosition>::iterator it = allKeys.begin(); it != allKeys.end(); ++it) {

		cv::Rect testRect((int)it->left, (int)it->top, (int)it->width, (int)it->height);
		Mat4b testMat = Mat(effectMat, testRect);
		resize(testMat, testMat, cv::Size(1, 1), 0, 0, INTER_CUBIC);

		Vec4b color = testMat.at<Vec4b>(0, 0);
		LEDController::getInstance()->setKey(it->ledId, color[2], color[1], color[0]);
		testMat.release();
	}

//	backportFinishedReleaseFrames++;

}
Exemple #10
0
void KisFilterOption::lodLimitations(KisPaintopLodLimitations *l) const
{
    KisFilterConfigurationSP config = filterConfig();

    if (m_currentFilter && config) {
        QRect testRect(0,0,100,100);
        if (m_currentFilter->neededRect(testRect, config, 0) != testRect ||
            m_currentFilter->changedRect(testRect, config, 0) != testRect) {

            l->blockers << KoID("filter-nonlinear", i18nc("PaintOp instant preview limitation", "\"%1\" does not support scaled preview (non-linear filter)", config->name()));
        }
    }
}
void KisTransformMaskTest::testSafeTransformUnity()
{
    QTransform transform;

    QRectF testRect(0, 1024, 512, 512);
    KisSafeTransform t2(transform, QRect(0, 0, 2048, 2048), testRect.toRect());

    QPolygonF fwdPoly = t2.mapForward(testRect);
    QRectF fwdRect = t2.mapRectForward(testRect);

    QPolygonF bwdPoly = t2.mapBackward(fwdPoly);
    QRectF bwdRect = t2.mapRectBackward(fwdRect);

    QCOMPARE(testRect, fwdRect);
    QCOMPARE(testRect, bwdRect);
    QCOMPARE(fwdPoly, QPolygonF(testRect));
    QCOMPARE(bwdPoly, QPolygonF(testRect));
}
MikeDrumTrackBuilder::MikeDrumTrackBuilder(void):m_pMouseHandlerNext(NULL),
												m_pRayPicker(NULL),m_nSelectedRect(-1)
{
	
	mdsVector<3, double> p3Xlate;
	p3Xlate[0] = -30;

	CollisionRect testRect(10.0, 40.0, 90.0);
	testRect.TranslateBy(p3Xlate);
	m_arrRectsCopyFrom[0] = testRect;
	
	
	p3Xlate[1] = 120;
	
	CollisionRect testRect2(10.0, 40.0, 120.0);
	testRect2.TranslateBy(p3Xlate);
	m_arrRectsCopyFrom[1] = testRect2;
}
void KisCoordinatesConverterTest::testTransformations()
{
    KisImageSP image;
    KisCoordinatesConverter converter;
    initImage(&image, &converter);

    converter.setImage(image);
    converter.setDocumentOffset(QPoint(20,30));
    converter.setCanvasWidgetSize(QSize(500,500));

    QRectF testRect(100,100,100,100);
    QTransform imageToWidget;
    QTransform documentToWidget;
    QTransform flakeToWidget;
    QTransform viewportToWidget;

    converter.setZoom(1.);

    imageToWidget = converter.imageToWidgetTransform();
    documentToWidget = converter.documentToWidgetTransform();
    flakeToWidget = converter.flakeToWidgetTransform();
    viewportToWidget = converter.viewportToWidgetTransform();

    CHECK_TRANSFORM(imageToWidget, testRect, QRectF(80,70,100,100));
    CHECK_TRANSFORM(documentToWidget, testRect, QRectF(9980,9970,10000,10000));
    CHECK_TRANSFORM(flakeToWidget, testRect, QRectF(80,70,100,100));
    CHECK_TRANSFORM(viewportToWidget, testRect, QRectF(100,100,100,100));

    converter.setZoom(0.5);

    imageToWidget = converter.imageToWidgetTransform();
    documentToWidget = converter.documentToWidgetTransform();
    flakeToWidget = converter.flakeToWidgetTransform();
    viewportToWidget = converter.viewportToWidgetTransform();

    CHECK_TRANSFORM(imageToWidget, testRect, QRectF(30,20,50,50));
    CHECK_TRANSFORM(documentToWidget, testRect, QRectF(4980,4970,5000,5000));
    CHECK_TRANSFORM(flakeToWidget, testRect, QRectF(80,70,100,100));
    CHECK_TRANSFORM(viewportToWidget, testRect, QRectF(100,100,100,100));
}
void KisCoordinatesConverterTest::testConversion()
{
    KisImageSP image;
    KisCoordinatesConverter converter;
    initImage(&image, &converter);

    converter.setImage(image);
    converter.setDocumentOffset(QPoint(20,20));
    converter.setCanvasWidgetSize(QSize(500,500));
    converter.setZoom(1.);

    QRectF testRect(100,100,100,100);

    QCOMPARE(converter.imageToViewport(testRect), QRectF(80,80,100,100));
    QCOMPARE(converter.viewportToImage(testRect), QRectF(120,120,100,100));

    QCOMPARE(converter.widgetToViewport(testRect), QRectF(100,100,100,100));
    QCOMPARE(converter.viewportToWidget(testRect), QRectF(100,100,100,100));

    QCOMPARE(converter.widgetToDocument(testRect), QRectF(1.20,1.20,1,1));
    QCOMPARE(converter.documentToWidget(testRect), QRectF(9980,9980,10000,10000));

    QCOMPARE(converter.imageToDocument(testRect), QRectF(1,1,1,1));
    QCOMPARE(converter.documentToImage(testRect), QRectF(10000,10000,10000,10000));

    converter.setZoom(0.5);

    QCOMPARE(converter.imageToViewport(testRect), QRectF(30,30,50,50));
    QCOMPARE(converter.viewportToImage(testRect), QRectF(240,240,200,200));

    QCOMPARE(converter.widgetToViewport(testRect), QRectF(100,100,100,100));
    QCOMPARE(converter.viewportToWidget(testRect), QRectF(100,100,100,100));

    QCOMPARE(converter.widgetToDocument(testRect), QRectF(2.4,2.4,2,2));
    QCOMPARE(converter.documentToWidget(testRect), QRectF(4980,4980,5000,5000));

    QCOMPARE(converter.imageToDocument(testRect), QRectF(1,1,1,1));
    QCOMPARE(converter.documentToImage(testRect), QRectF(10000,10000,10000,10000));
}
Exemple #15
0
void CMMFTestVideoPreProcHwDevice::SetInputCropOptionsL(const TRect& aRect)
	{
	TRect testRect(KTestInputCropRectD, KTestInputCropRectC, KTestInputCropRectB, KTestInputCropRectA);
	if (!(aRect == testRect))
		User::Leave(KErrCorrupt);
	}
Exemple #16
0
/**
@SYMTestCaseID		GRAPHICS-WSERV-0462

@SYMDEF  			PDEF114190

@SYMTestCaseDesc    Test sprite list cleanup when a window is deleted in low memory conditions

@SYMTestPriority    High

@SYMTestStatus      Implemented

@SYMTestActions     Have a loop which increases the number of allocations in the server thread before failure;
					Within the loop:
					1) Create a parent window and a child window of the parent;
					2) Create a sprite on the child window; 
					3) Delete the parent window only, but not the child window; 
					4) Create a testWindow and do redraw on this window; 
					5) Do redraw on the testWindow. This testWindow's redraw will force checking the sprite list. 
					This would panic the client thread due to this defect because the sprite on the orphaned 
					window (which is the previous child window) is still in the sprite list;
					6) Delete all the windows involved.

@SYMTestExpectedResults The sprite should be disabled when a window is deleted;
						The client thread should not be panic'd.
						The test should pass.
*/
void CTTSprite::SpriteOnWindowOrphanedTestsL()
	{
	TInt handles = 344;
	TInt loop = 0;
	TInt allocFailRate = 0;
	TInt err = KErrNone;

	CFbsBitmap* bitmap = new(ELeave) CFbsBitmap;
	CleanupStack::PushL(bitmap);
	User::LeaveIfError(bitmap->Create(TSize(500, 500), EColor16MU));
	TSpriteMember spritemember;
	spritemember.iBitmap = bitmap;
	spritemember.iMaskBitmap = NULL;	
	
	RWindowGroup group(TheClient->iWs);
	RWindow parent1(TheClient->iWs);
	RWindow child1(TheClient->iWs);
	RWindow testWindow(TheClient->iWs);
	RWsSprite sprite(TheClient->iWs);
	
	while (loop < 5)
		{
		TRect mainRect(TPoint(0,0), TSize(500,500));
		err = group.Construct(++handles, EFalse);	
		if (err == KErrNone)
			{
			TheClient->iWs.HeapSetFail(RHeap::EDeterministic, allocFailRate);

			//Create parent 1
			err = parent1.Construct(group,++handles);
			if (err == KErrNone)
				{
				parent1.SetExtent(mainRect.iTl, mainRect.Size());
				parent1.EnableRedrawStore(ETrue);
				parent1.Activate();
				}			
			}
		
		//Create child 1
		if (err == KErrNone)
			{
			TRect childRect(TPoint (10, 10), TSize (200, 150));
			err = child1.Construct(parent1,++handles);
			if (err == KErrNone)
				{
				child1.SetExtent(childRect.iTl, childRect.Size());
				child1.SetBackgroundColor(TRgb(128,100,255,20));
				child1.Activate();
				}
			}
		
		//Add sprite to child 1
		if (err == KErrNone) 
			{
			err = sprite.Construct(child1,TPoint(10,10), 0);
			if (err == KErrNone)
				{
				err = sprite.AppendMember(spritemember);
				if (err == KErrNone)
					err = sprite.Activate();	
				}
			}

		//Only delete parent 1, but not child 1	
		parent1.Close();		

		if (err == KErrNone) 
			{
			TRect testRect(TPoint(10, 30), TSize(200, 150));
			//Create testWindow
			err = testWindow.Construct(group,++handles);
			if (err == KErrNone)
				{
				testWindow.SetExtent(testRect.iTl, testRect.Size());
				testWindow.SetBackgroundColor(TRgb(128,100,255,20));
				testWindow.EnableRedrawStore(ETrue);
				testWindow.Activate();
				testWindow.BeginRedraw();
				testWindow.EndRedraw();	
				TheClient->Flush();			
				}
			}
		TheClient->iWs.HeapSetFail(RAllocator::ENone, 0);

		sprite.Close();
		child1.Close();
		testWindow.Close();
		group.Close();		
		++allocFailRate;
		loop = (err == KErrNone) ? loop + 1 : 0;
		}
	CleanupStack::PopAndDestroy(bitmap);
	}
Exemple #17
0
void CMMFTestVideoDecodeHwDevice::SetOutputCropOptionsL(const TRect& aRect)
	{
	TRect testRect(KTestOutputCropRectA, KTestOutputCropRectB, KTestOutputCropRectC, KTestOutputCropRectD);
	if (!(aRect == testRect))
		User::Leave(KErrCorrupt);
	}
void KisTransformMaskTest::testSafeTransform()
{
    QTransform transform(-0.177454, -0.805953, -0.00213713,
                         -1.9295, -0.371835, -0.00290463,
                         3075.05, 2252.32, 7.62371);

    QRectF testRect(0, 1024, 512, 512);
    KisSafeTransform t2(transform, QRect(0, 0, 2048, 2048), testRect.toRect());

    QPolygonF fwdPoly = t2.mapForward(testRect);
    QRectF fwdRect = t2.mapRectForward(testRect);

    QPolygonF bwdPoly = t2.mapBackward(fwdPoly);
    QRectF bwdRect = t2.mapRectBackward(fwdRect);

    QPolygon ref;

    ref.clear();
    ref << QPoint(284, 410);
    ref << QPoint(10, 613);
    ref << QPoint(35, 532);
    ref << QPoint(236, 403);
    ref << QPoint(284, 410);
    QCOMPARE(fwdPoly.toPolygon(), ref);
    QCOMPARE(fwdRect.toRect(), QRect(10,403,274,211));

    ref.clear();
    ref << QPoint(512, 1024);
    ref << QPoint(512, 1536);
    ref << QPoint(0, 1536);
    ref << QPoint(0, 1024);
    ref << QPoint(512, 1024);
    QCOMPARE(bwdPoly.toPolygon(), ref);
    QCOMPARE(bwdRect.toRect(), QRect(0, 994, 1198, 584));

/*
    QImage image(2500, 2500, QImage::Format_ARGB32);
    QPainter gc(&image);
    gc.setPen(Qt::cyan);

    gc.setOpacity(0.7);

    gc.setBrush(Qt::red);
    gc.drawPolygon(t2.srcClipPolygon());

    gc.setBrush(Qt::green);
    gc.drawPolygon(t2.dstClipPolygon());

    dbgKrita << ppVar(testRect);
    dbgKrita << ppVar(fwdPoly);
    dbgKrita << ppVar(fwdRect);
    dbgKrita << ppVar(bwdPoly);
    dbgKrita << ppVar(bwdRect);

    gc.setBrush(Qt::yellow);
    gc.drawPolygon(testRect);

    gc.setBrush(Qt::red);
    gc.drawPolygon(fwdRect);
    gc.setBrush(Qt::blue);
    gc.drawPolygon(fwdPoly);

    gc.setBrush(Qt::magenta);
    gc.drawPolygon(bwdRect);
    gc.setBrush(Qt::cyan);
    gc.drawPolygon(bwdPoly);

    gc.end();
    image.save("polygons_safety.png");
*/
}