Bug 46583 - [PATCH] PS tiling patterns implementation
Summary: [PATCH] PS tiling patterns implementation
Alias: None
Product: XMLGraphicsCommons - Now in Jira
Classification: Unclassified
Component: postscript (show other bugs)
Version: Trunk
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: --
Assignee: XML Graphics Project Mailing List
Depends on:
Reported: 2009-01-22 00:45 UTC by Jiri Kunhart
Modified: 2009-08-15 02:15 UTC (History)
0 users

tiling patterns patch (21.29 KB, patch)
2009-01-22 00:45 UTC, Jiri Kunhart
Details | Diff
java 1.4 compatible patch (23.56 KB, patch)
2009-02-17 01:43 UTC, Jiri Kunhart
Details | Diff
Patterns will not violate DSC rules after using this patch (4.20 KB, patch)
2009-05-27 07:08 UTC, Jiri Kunhart
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Kunhart 2009-01-22 00:45:50 UTC
Created attachment 23157 [details]
tiling patterns patch

This patch allows to make and use postscript tiling patterns. Tiling patterns consist of a small graphical figure (called a pattern cell) that is replicated at fixed horizontal and vertical intervals to fill the area to be painted. 

Notice that a image (a texture) must not be a too large, otherwise the postscript error 'limitcheck' will be generated (on ps printer or in ps viewer).
Comment 1 Jeremias Maerki 2009-02-07 03:31:24 UTC
Sorry for not responding earlier. Thank you for your patch. This is a nice addition. However, before I can process your patch, can I ask you to do the following:

- Since your patch includes new files, please fill out and send an ICLA (Individual Contributor License Agreement, see [1] for details). Depending on your work contract you may also need to ask your employer to consider sending in a CCLA.

[1] http://apache.org/licenses/#clas

- Please put the same license header you find in our other source files on top of the new files you create to clearly indicate that you are donating this to the ASF.

- And finally, please rework the patch to make it Java 1.4 compatible. (this point I can handle for you if you want but it would be great if you could do it while you add the license headers)

- One note on the code while taking a quick look: You used an ArrayList for the bounding box. Please consider using a java.awt.Rectangle instead.

I hope you understand. Thank you very much!
Comment 2 Jiri Kunhart 2009-02-17 01:43:05 UTC
Created attachment 23267 [details]
java 1.4 compatible patch
Comment 3 Jiri Kunhart 2009-02-17 01:54:52 UTC
Jeremias, it should be ok now.
I have sent ICLA and CCLA licenses, the patch is now java 1.4 compatible, headers are included and Rectangle instead of Array is used.
Comment 4 Jeremias Maerki 2009-02-18 00:46:20 UTC
Thank you, Jiri. I'll process your patch as soon as your ICLA is recorded. That could take a few days, though.
Comment 5 Jeremias Maerki 2009-03-02 00:41:55 UTC
Jiri, your CLA still hasn't shown up. :-( How did you submit it? In the meantime, there have been a number of batches with CLAs but yours was not among them.
Comment 6 Jiri Kunhart 2009-03-02 01:00:02 UTC

I sent it via email to secretary@apache.org, 14 days ago (17.2.2009), the subject was "FOP ICLA and CCLA". Should I send it again?
Comment 7 Jeremias Maerki 2009-03-02 01:03:19 UTC
If it's no trouble for you, yes, please do. I'll talk to the secretary directly if it doesn't appear by next week. Thanks for your patience.
Comment 8 Jiri Kunhart 2009-03-02 01:10:20 UTC
No problem Jeremias. I have sent it again.
Comment 9 Jeremias Maerki 2009-03-12 03:14:56 UTC
Jiri, your ICLA (and the CCLA) has finally been recorded. I've also already taken the time to process the patch and applied it with modifications:

As you can see in the commit message, I found a bug concerning the anchor rectangle. I found that using the example I've just committed:

Another problem which I didn't realize earlier is that your changes violate the DSC specification. Here's the scenario:
Create a PostScript document with two pages and use the same TexturePaint on both pages. Then extract the second page according to DSC rules and you get an invalid PostScript file (because it misses the pattern that is part of the first page).
The example above demonstrates this. This is not catastrophic but it should be fixed at some point. This is why I'll leave this issue open for the time being.

I think there are two approaches:
1. limit the reuse of tiling patterns to one page and ignore DSC for pattern resources.
2. Tie pattern resources into resource tracking. This will require changes in PSDocumentGraphics2D similar to what we do in Apache FOP: we create the PostScript file as a temporary file and create common resources in the setup part in a second pass. See: http://svn.eu.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/ResourceHandler.java?view=markup

Thanks for your patience, Jiri.
Comment 10 Jiri Kunhart 2009-05-26 06:05:08 UTC
Hi Jeremias,

I checked your changes about anchor rectangle in the code and I think you did it very well. But now I think, there is no reason to define the patterns in the ResourceHandler, because now every pattern is unique - because of the line 
"x y translate" in PaintProc - x and y will be always different (there is no reason to draw the same pattern (if I say the same pattern I mean the same binary data of pattern) on the same position (I mean the position which is specified by "x y translate") several times). So I decided to delete class PSPatternStorage, don't use the ResourceHandler and the pattern define directly on a page where is used.
Comment 11 Jiri Kunhart 2009-05-27 07:08:39 UTC
Created attachment 23720 [details]
Patterns will not violate DSC rules after using this patch

This patch remove the class PSPaternStorage and all references to it. Patterns will not violate DSC rules, but now the same pattern can be defined more than one time on the page (document) => the size of the output file can be a bigger than it is necessary. The right solution would be to define pattern resources in the begin of the ps document, similarly how it is done for fonts and images.
Comment 12 Jeremias Maerki 2009-08-15 02:15:05 UTC
Latest patch applied: http://svn.apache.org/viewvc?rev=804444&view=rev

Thanks a lot, Jiří and sorry for the slow reaction time! Pattern generation now looks fine to me. I think that means we can close this issue here.