-
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
7ac43c0
commit bc1b223
Showing
3 changed files
with
91 additions
and
37 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
...org.eclipse.swt/Eclipse SWT Tests/win32/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,49 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Yatta Solutions | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Yatta Solutions - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.swt.graphics; | ||
|
||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotEquals; | ||
|
||
import org.eclipse.swt.internal.*; | ||
import org.eclipse.swt.internal.gdip.*; | ||
import org.junit.*; | ||
|
||
public class TransformWin32Tests extends Win32AutoscaleTestBase { | ||
|
||
@Test | ||
public void testShouldHaveDifferentHandlesAtDifferentZoomLevels() { | ||
int zoom = DPIUtil.getDeviceZoom(); | ||
Transform transform = new Transform(display); | ||
long scaledHandle = transform.getHandle(zoom * 2); | ||
assertNotEquals("There should be different handles for different zoom levels", scaledHandle, transform.getHandle(zoom)); | ||
long scaledHandle2 = transform.getHandle(zoom * 3); | ||
assertNotEquals("There should be different handles for different zoom levels", scaledHandle, scaledHandle2); | ||
} | ||
|
||
@Test | ||
public void testScaledTrasformMustHaveScaledValues() { | ||
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.getHandle(zoom * 2); | ||
float[] scaledElements = new float[6]; | ||
Gdip.Matrix_GetElements(scaledHandle, scaledElements); | ||
assertEquals(elements[4] * 2, scaledElements[4], 0); | ||
assertEquals(elements[5] * 2, scaledElements[5], 0); | ||
} | ||
|
||
} |
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