Skip to content

Conversation

@gujjwal00
Copy link
Contributor

@gujjwal00 gujjwal00 commented Mar 17, 2020

This PR removes unused code related to scaling. Issue: #59 .

Edit: I have added some reasons for cleanup.

@gujjwal00 gujjwal00 changed the title Smooth scaling [1]: Remove unused scaling code Smooth scaling [1]: Remove unused code Mar 17, 2020
Comment on lines -14 to -44
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);
}

Copy link
Contributor Author

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);
Copy link
Contributor Author

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

Comment on lines -94 to -98
/**
* True if this scale type allows panning of the image
* @return
*/
abstract boolean isAbleToPan();
Copy link
Contributor Author

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.

Comment on lines -100 to -106
/**
* 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);

Copy link
Contributor Author

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.

Comment on lines -825 to -836

public int getCenteredXOffset() {
int xoffset = (vncConn.getFramebufferWidth() - getWidth()) / 2;
return xoffset;
}

public int getCenteredYOffset() {
int yoffset = (vncConn.getFramebufferHeight() - getHeight()) / 2;
return yoffset;
}


Copy link
Contributor Author

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);
Copy link
Contributor Author

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.

Comment on lines -16 to -18
private Matrix matrix;
int canvasXOffset;
int canvasYOffset;
Copy link
Contributor Author

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.

@bk138 bk138 merged commit defbefc into bk138:master Jun 6, 2020
bk138 pushed a commit that referenced this pull request Jun 6, 2020
@gujjwal00 gujjwal00 deleted the smooth-scaling-1 branch June 7, 2020 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants