greatwar93 / gwt-g2d

Automatically exported from code.google.com/p/gwt-g2d
0 stars 0 forks source link

Using Surface.scale() doesn't work in Firefox, but does in IE #5

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Make a call to scale on a Surface.
2. Make a call to drawImage on the same surface.

What is the expected output? What do you see instead?
The expected output is that the contents of the surface should be drawn
scaled in relation to the scale factor, which happens in IE, but doesn't in FF.

What version of the product are you using? On what operating system?
gwt 2.0, gwt-g2d 0.06, running on JBoss Application Server 5.0.1 GA, Windows XP

Please provide any additional information below.
I want to draw an image and writing strokes on it. When I used drawImage
with image size attributes to scale the image and scaled my strokes
accordingly I got performance issues on IE, but not on FF. Then I tried
using scale and the performance on IE was much better. However, on FF the
image and strokes aren't scaled.

Original issue reported on code.google.com by degstud...@gmail.com on 8 Mar 2010 at 12:12

GoogleCodeExporter commented 8 years ago
I am having problem reproducing this issue. When I can scale() and then 
strokeShape() 
and drawImage() afterward, it seems to be scaling them correctly

What version of FF are you using? Do you have the same issue when running on 
another 
browser beside IE and FF (say, Chrome)? Have you tried clearing the cache?

Original comment by hao1...@gmail.com on 9 Mar 2010 at 12:34

GoogleCodeExporter commented 8 years ago
I tried making a simpler project with just a Surface, scale() it and then
drawImage(). In that case, FF (3.5), IE (8) and Chrome (4) all work in the same 
manner.

However, in my original project, which is a lot more complicated, I am still 
able to
reproduce. FF and Chrome doesn't scale and IE does. The call to scale is 
performed in
one method and the drawing of lines and images are done in other methods.

The structure of classes and calls are as follows:

Presenter - Presenter class
Page - Class containing the Surface

In Presenter.renderPage:
Page.scale() (which calls Surface.scale())
Page.drawImage() (which calls Surface.drawImage())
Page.drawStrokes() (which uses ShapeBuilder and draws lines)

I have attached some printscreens.

Original comment by degstud...@gmail.com on 9 Mar 2010 at 7:49

Attachments:

GoogleCodeExporter commented 8 years ago
This is odd. However, if you are seeing that same behavior in FF and Chrome, I 
am more 
inclined to think that it is IE that is bugged.

Since I can't really reproduce it, would you mind checking the followings in 
your 
project:
1, Are you sure that you don't have any other call to Surface between scale() 
and 
drawImage()/drawStrokes()? If you do, try comment them out and see if scaling 
works.
2, Does it scale if you comment out one of drawImage() or drawStrokes()?
3, Does it scale if you comment out both drawImage() and drawStrokes() and draw 
something in your scale() method right after you call the Surface.scale() 
method?
4, Does it scale if you change your scaling factor?

Let me know how it goes.

Original comment by hao1...@gmail.com on 9 Mar 2010 at 2:33

GoogleCodeExporter commented 8 years ago
Hello again

1: No, sorry. I didn't mention that I was making a bunch of other operations on 
the
Surface. The chain of calls was as follows:
scale()
setWidth()
setHeight()
clear()
drawImage()
save()
DirectShapeRenderer.beginPath()
setLineCap()
setLineJoin()
setStrokeStyle()
setLineWidth()
DirectShapeRenderer.stroke() // With a bunch of moveTo() and drawLineTo()
restore()

2,3: The problem is the call to clear(). If I comment it out, it works.

It is a bit hard to know which is the expected behavior, but I know your nice 
library
is a work in progress. Sorry about the unclear background information earlier.

Tell me if you want some additional information.

Original comment by degstud...@gmail.com on 9 Mar 2010 at 4:10

GoogleCodeExporter commented 8 years ago
It seems to me that when the size of the Surface is changed 
(setWidth()/setHeight()), 
the transformation state of the Surface is also reset (not sure if other things 
are 
reset as well). I am not sure what is the expected behavior is as I can't find 
what the 
Context 2D specification says about this, but just to be safe, you should call 
scale() 
after setWidth() and setHeight(). (I don't think clear() is the issue though...)

Let me know if this fixes the inconsistency.

Original comment by hao1...@gmail.com on 9 Mar 2010 at 6:39

GoogleCodeExporter commented 8 years ago
I have actually solved my task by scaling the images and coordinates instead of
scaling the canvas.
Just thought that for the sake of gwt-g2d being browser independent, it should 
behave
so in this case as well. 

However, yesterday, when not using clear() at all and calling scale() after
setWidth() and setHeight(), it all worked. 
I think it worked as expected when I just commented out the call to clear() 
though,
but since testing this requires deploying an old version of my project, I don't 
have
the energy to retry right now. :-)

Original comment by degstud...@gmail.com on 10 Mar 2010 at 7:38

GoogleCodeExporter commented 8 years ago
Well, being truly browser independent is a little tough :/

I am closing this issue ticket. If the problem arises again, feel free to 
restart the 
ticket or start a new one.

Original comment by hao1...@gmail.com on 10 Mar 2010 at 1:31