-
-
Notifications
You must be signed in to change notification settings - Fork 78
Smooth scaling [1]: Remove unused code #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| public static final int zoomableId = -1; | ||
| private static final int scaleModeIds[] = { zoomableId }; | ||
|
|
||
| private static AbstractScaling[] scalings; | ||
|
|
||
| static AbstractScaling getById(int id) | ||
| { | ||
| if ( scalings==null) | ||
| { | ||
| scalings=new AbstractScaling[scaleModeIds.length]; | ||
| } | ||
| for ( int i=0; i<scaleModeIds.length; ++i) | ||
| { | ||
| if ( scaleModeIds[i]==id) | ||
| { | ||
| if ( scalings[i]==null) | ||
| { | ||
| switch ( id ) | ||
| { | ||
|
|
||
| case zoomableId: | ||
| scalings[i]=new ZoomScaling(); | ||
| break; | ||
| } | ||
| } | ||
| return scalings[i]; | ||
| } | ||
| } | ||
| throw new IllegalArgumentException("Unknown scaling id " + id); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These static fields & methods (along with getByScaleType() below) are used for creating new scaling instances. But we only have ZoomScaling. Now we create new ZoomScaling object directly which makes all these obsolete.
| void setScaleTypeForActivity(VncCanvasActivity activity){ | ||
| activity.zoomer.hide(); | ||
| activity.vncCanvas.scaling = this; | ||
| activity.vncCanvas.setScaleType(scaleType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scale type is not used by VncCanvas
| /** | ||
| * True if this scale type allows panning of the image | ||
| * @return | ||
| */ | ||
| abstract boolean isAbleToPan(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isAbleToPan() is always true for ZoomScaling.
| /** | ||
| * True if the listed input mode is valid for this scaling mode | ||
| * @param mode Id of the input mode | ||
| * @return True if the input mode is compatible with the scaling mode | ||
| */ | ||
| abstract boolean isValidInputMode(int mode); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not used anymore.
|
|
||
| public int getCenteredXOffset() { | ||
| int xoffset = (vncConn.getFramebufferWidth() - getWidth()) / 2; | ||
| return xoffset; | ||
| } | ||
|
|
||
| public int getCenteredYOffset() { | ||
| int yoffset = (vncConn.getFramebufferHeight() - getHeight()) / 2; | ||
| return yoffset; | ||
| } | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were used for updating scaling matrix.
| AbstractScaling.getByScaleType(connection.getScaleMode()) | ||
| .setScaleTypeForActivity(this); | ||
|
|
||
| new ZoomScaling().setScaleTypeForActivity(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We directly create an object of ZoomScaling. It removes the need of static factory methods in AbstractScaling.
| private Matrix matrix; | ||
| int canvasXOffset; | ||
| int canvasYOffset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were used before OpenGL scaling. Now they are redundant.
This PR removes unused code related to scaling. Issue: #59 .
Edit: I have added some reasons for cleanup.