-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multi Zoom Level feature in transform for win32
This commit implements the mean to provide different handles of a transform object at different zoom levels which can be consumed by GC depending on the zoom level available within its GCData. Contributes to #62 and #127
- Loading branch information
1 parent
4c4074f
commit c35ce40
Showing
3 changed files
with
88 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/graphics/TransformWin32Tests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.eclipse.swt.graphics; | ||
|
||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotEquals; | ||
|
||
import org.eclipse.swt.internal.DPIUtil; | ||
import org.eclipse.swt.internal.gdip.Gdip; | ||
import org.eclipse.swt.widgets.Display; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class TransformWin32Tests { | ||
private Display display; | ||
|
||
@Before | ||
public void setUp() { | ||
display = Display.getDefault(); | ||
} | ||
|
||
@Test | ||
public void shouldHaveDifferentHandlesAtDifferentZoomLevels() { | ||
int zoom = DPIUtil.getDeviceZoom(); | ||
Transform transform = new Transform(display); | ||
long scaledHandle = Transform.win32_getHandle(transform, zoom * 2); | ||
assertNotEquals("There exist different handles for different zoom levels", scaledHandle, transform.handle); | ||
long scaledHandle2 = Transform.win32_getHandle(transform, zoom * 3); | ||
assertNotEquals("There exist different handles for different zoom levels", scaledHandle, scaledHandle2); | ||
} | ||
|
||
@Test | ||
public void scaledTrasformMustHaveScaledValues() { | ||
int zoom = DPIUtil.getDeviceZoom(); | ||
Transform transform = new Transform(display, 0, 0, 0, 0, 4, 2); | ||
float[] elements = new float[6]; | ||
transform.getElements(elements); | ||
long scaledHandle = Transform.win32_getHandle(transform, zoom * 2); | ||
float[] scaledElements = new float[6]; | ||
Gdip.Matrix_GetElements(scaledHandle, scaledElements); | ||
assertEquals(elements[4] * 2, scaledElements[4], 0); | ||
} | ||
|
||
} |