Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 253541 Details for
Bug 467528
IllegalArgumentException in GC.drawImage, when being called from Thumbnail$ThumbnailUpdater.run()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Possible solution, caching the source file, on which the tile size computation was based
467528.patch (text/plain), 4.40 KB, created by
Alexander Nyßen
on 2015-05-18 15:31:52 EDT
(
hide
)
Description:
Possible solution, caching the source file, on which the tile size computation was based
Filename:
MIME Type:
Creator:
Alexander Nyßen
Created:
2015-05-18 15:31:52 EDT
Size:
4.40 KB
patch
obsolete
>diff --git a/org.eclipse.draw2d/src/org/eclipse/draw2d/parts/Thumbnail.java b/org.eclipse.draw2d/src/org/eclipse/draw2d/parts/Thumbnail.java >index 84dcd67..5b7daf1 100644 >--- a/org.eclipse.draw2d/src/org/eclipse/draw2d/parts/Thumbnail.java >+++ b/org.eclipse.draw2d/src/org/eclipse/draw2d/parts/Thumbnail.java >@@ -45,7 +45,11 @@ > static final int MAX_BUFFER_SIZE = 256; > private int currentHTile, currentVTile; > private int hTiles, vTiles; >+ > private Dimension tileSize; >+ private Dimension sourceSize; // the source size that was used for the >+ // tileSize computation >+ > private boolean isActive = true; > > private boolean isRunning = false; >@@ -115,16 +119,17 @@ > * tile size and current tile index. > */ > public void resetTileValues() { >- hTiles = (int) Math.ceil((float) getSourceRectangle().width >+ // keep track of source size that matches the computed tile size >+ sourceSize = getSourceRectangle().getSize(); >+ >+ hTiles = (int) Math.ceil((float) sourceSize.width > / (float) MAX_BUFFER_SIZE); >- vTiles = (int) Math.ceil((float) getSourceRectangle().height >+ vTiles = (int) Math.ceil((float) sourceSize.height > / (float) MAX_BUFFER_SIZE); > >- tileSize = new Dimension( >- (int) Math.ceil((float) getSourceRectangle().width >- / (float) hTiles), >- (int) Math.ceil((float) getSourceRectangle().height >- / (float) vTiles)); >+ tileSize = new Dimension((int) Math.ceil((float) sourceSize.width >+ / (float) hTiles), >+ (int) Math.ceil((float) sourceSize.height / (float) vTiles)); > > currentHTile = 0; > currentVTile = 0; >@@ -152,15 +157,14 @@ > public void run() { > if (!isActive() || !isRunning() || tileGraphics == null) > return; >+ > int v = getCurrentVTile(); > int sy1 = v * tileSize.height; >- int sy2 = Math.min((v + 1) * tileSize.height, >- getSourceRectangle().height); >+ int sy2 = Math.min((v + 1) * tileSize.height, sourceSize.height); > > int h = getCurrentHTile(); > int sx1 = h * tileSize.width; >- int sx2 = Math.min((h + 1) * tileSize.width, >- getSourceRectangle().width); >+ int sx2 = Math.min((h + 1) * tileSize.width, sourceSize.width); > > tileGraphics.pushState(); > // clear the background (by filling with the background color) >@@ -168,14 +172,21 @@ > tileGraphics.fillRectangle(rect); > > // let the source figure paint into the tile image >- // IMPORTANT (fix for bug #309912): we do not let the source figure >- // paint directly into the thumbnail image, because we cannot ensure >- // that it paints completely inside the current tile area (it may >- // set its own clip inside paint(Graphics) and overwrite areas of >- // tile that have already been rendered. By providing an own tile >- // image and copying from it into the thumbnail image, we are safe. >+ // IMPORTANT (fix for bug #309912): we do not let the source >+ // figure >+ // paint directly into the thumbnail image, because we cannot >+ // ensure >+ // that it paints completely inside the current tile area (it >+ // may >+ // set its own clip inside paint(Graphics) and overwrite areas >+ // of >+ // tile that have already been rendered. By providing an own >+ // tile >+ // image and copying from it into the thumbnail image, we are >+ // safe. > org.eclipse.draw2d.geometry.Point p = getSourceRectangle() > .getLocation(); >+ > tileGraphics.translate(-p.x - sx1, -p.y - sy1); > tileGraphics.scale(getScaleX()); > sourceFigure.paint(tileGraphics); >@@ -195,9 +206,9 @@ > setCurrentVTile(0); > } > >- if (getCurrentHTile() != 0 || getCurrentVTile() != 0) >+ if (getCurrentHTile() != 0 || getCurrentVTile() != 0) { > Display.getCurrent().asyncExec(this); >- else if (isDirty()) { >+ } else if (isDirty()) { > setDirty(false); > Display.getCurrent().asyncExec(this); > repaint(); >@@ -278,8 +289,8 @@ > tileGraphics.setBackgroundColor(color); > tileGraphics.setFont(sourceFigure.getFont()); > >- setScales(targetSize.width / (float) getSourceRectangle().width, >- targetSize.height / (float) getSourceRectangle().height); >+ setScales(targetSize.width / (float) sourceSize.width, >+ targetSize.height / (float) sourceSize.height); > > Display.getCurrent().asyncExec(this); > } >@@ -349,8 +360,8 @@ > private float scaleX; > private float scaleY; > >- private IFigure sourceFigure; > Dimension targetSize = new Dimension(0, 0); >+ private IFigure sourceFigure; > private Image thumbnailImage; > > private Dimension thumbnailImageSize;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 467528
: 253541