-
Notifications
You must be signed in to change notification settings - Fork 166
Replace usages of new Image(device, width, height) #2178
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1581,14 +1581,25 @@ LRESULT WM_PAINT (long wParam, long lParam) { | |||||||||||||||||||
GC paintGC = null; | ||||||||||||||||||||
Image image = null; | ||||||||||||||||||||
if ((style & (SWT.DOUBLE_BUFFERED | SWT.TRANSPARENT)) != 0) { | ||||||||||||||||||||
image = new Image (display, width, height); | ||||||||||||||||||||
paintGC = gc; | ||||||||||||||||||||
gc = new GC (image, paintGC.getStyle() & SWT.RIGHT_TO_LEFT); | ||||||||||||||||||||
GCData gcData = gc.getGCData (); | ||||||||||||||||||||
gcData.uiState = data.uiState; | ||||||||||||||||||||
gc.setForeground (getForeground ()); | ||||||||||||||||||||
gc.setBackground (getBackground ()); | ||||||||||||||||||||
gc.setFont (getFont ()); | ||||||||||||||||||||
int originalStyle = gc.getStyle(); | ||||||||||||||||||||
ImageGcDrawer drawer = new ImageGcDrawer() { | ||||||||||||||||||||
@Override | ||||||||||||||||||||
public void drawOn(GC gc, int iWidth, int iHeight) { | ||||||||||||||||||||
GCData gcData = gc.getGCData (); | ||||||||||||||||||||
gcData.uiState = data.uiState; | ||||||||||||||||||||
gc.setForeground (getForeground ()); | ||||||||||||||||||||
gc.setBackground (getBackground ()); | ||||||||||||||||||||
gc.setFont (getFont ()); | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
@Override | ||||||||||||||||||||
public int getGcStyle() { | ||||||||||||||||||||
return originalStyle & SWT.RIGHT_TO_LEFT; | ||||||||||||||||||||
} | ||||||||||||||||||||
}; | ||||||||||||||||||||
image = new Image (display, drawer, width, height); | ||||||||||||||||||||
gc = new GC(image, originalStyle & SWT.RIGHT_TO_LEFT); | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure that this works as expected? You now initialize the GC inside the |
||||||||||||||||||||
if ((style & SWT.TRANSPARENT) != 0) { | ||||||||||||||||||||
OS.BitBlt (gc.handle, 0, 0, width, height, paintGC.handle, ps.left, ps.top, OS.SRCCOPY); | ||||||||||||||||||||
} | ||||||||||||||||||||
|
@@ -1598,6 +1609,16 @@ LRESULT WM_PAINT (long wParam, long lParam) { | |||||||||||||||||||
OS.SetMetaRgn (gc.handle); | ||||||||||||||||||||
OS.SetWindowOrgEx (gc.handle, ps.left, ps.top, null); | ||||||||||||||||||||
OS.SetBrushOrgEx (gc.handle, ps.left, ps.top, null); | ||||||||||||||||||||
|
||||||||||||||||||||
if ((style & (SWT.NO_BACKGROUND | SWT.TRANSPARENT)) != 0) { | ||||||||||||||||||||
/* This code is intentionally commented because it may be slow to copy bits from the screen */ | ||||||||||||||||||||
//newPaintGC.copyArea (image, ps.left, ps.top); | ||||||||||||||||||||
} else { | ||||||||||||||||||||
RECT rect = new RECT (); | ||||||||||||||||||||
OS.SetRect (rect, ps.left, ps.top, ps.right, ps.bottom); | ||||||||||||||||||||
drawBackground (gc.handle, rect); | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
Comment on lines
+1612
to
+1621
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why duplicate this code?
Suggested change
|
||||||||||||||||||||
if ((style & (SWT.NO_BACKGROUND | SWT.TRANSPARENT)) != 0) { | ||||||||||||||||||||
/* This code is intentionally commented because it may be slow to copy bits from the screen */ | ||||||||||||||||||||
//paintGC.copyArea (image, ps.left, ps.top); | ||||||||||||||||||||
|
@@ -1642,10 +1663,10 @@ LRESULT WM_PAINT (long wParam, long lParam) { | |||||||||||||||||||
GCData gcData = gc.getGCData (); | ||||||||||||||||||||
if (gcData.focusDrawn && !isDisposed ()) updateUIState (); | ||||||||||||||||||||
} | ||||||||||||||||||||
gc.dispose(); | ||||||||||||||||||||
if (!isDisposed ()) { | ||||||||||||||||||||
paintGC.drawImage (image, DPIUtil.scaleDown(ps.left, zoom), DPIUtil.scaleDown(ps.top, zoom)); | ||||||||||||||||||||
} | ||||||||||||||||||||
gc.dispose(); | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Revert this change, it's unnecessary now that you instantiated |
||||||||||||||||||||
image.dispose (); | ||||||||||||||||||||
gc = paintGC; | ||||||||||||||||||||
} | ||||||||||||||||||||
|
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.
The indentation looks wrong in Eclipse (not in GH though)