[ 
https://issues.apache.org/jira/browse/TRINIDAD-1442?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Korhan Bircan updated TRINIDAD-1442:
------------------------------------

    Status: Patch Available  (was: Open)

> Aggregate single image to send to client
> ----------------------------------------
>
>                 Key: TRINIDAD-1442
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1442
>             Project: MyFaces Trinidad
>          Issue Type: New Feature
>          Components: Skinning
>            Reporter: Korhan Bircan
>
> Instead of sending Trinidad specific and application dependent images one by 
> one, aggregate them into one big image strip and send this strip to the 
> client at one time. Benefits will be twofold. First, there will be fewer HTTP 
> requests and the cold browser page load time will be faster. Second, when png 
> or gif images are combined, they take less space than the sum of individual 
> images.
> This feature would only improve the cold browser load times. There would be 
> no performance improvement for the warm browsers. There should be no change 
> in the look-and-feel of any page.
> In my current implementation I'm using a temporary private context parameter, 
> "org.apache.myfaces.trinidadinternal.ENABLE_IMAGE_AGGREGATION", to turn the 
> feature on and off in case there are any bugs early on. It can be removed 
> once the feature is fully tested. If the feature works properly it should 
> always be on.
> The code starts in 
> trinidadinternal.style.cache.FileSystemStyleCache::_createEntry(). This 
> method creates and caches a style sheet. All the StyleNode's are iterated and 
> if a StyleNode has background-image, an ImageStripIcon is created with the 
> background-image, background-position, width, and height properties of that 
> StyleNode. This ImageStripIcon is appended to an icon map.
> The same selector may appear in multiple places and may define different 
> properties (eg. background-image in one place, background-position in 
> another). In order to match the selectors with background-images, we keep 
> track of the selector names that contain background-images. If a selector is 
> associated with a background-image, we add it to the corresponding 
> ImageStripIcon's selector vector.
> Once we have collected all the background-images and background-positions, 
> width, height information associated with them, we create the image strips. 
> Because there may be multiple image formats (right now gif and png) we store 
> the image strips in an imageStripVec (Vector< ImageStrip >).
> The CSS file is written out in 
> trinidadinternal.style.util.CSSGenerationUtils, we pass imageStripVec and 
> selectorMap to _createStyleSheetFiles(), which calls 
> CSSGenerationUtils.writeCSS() passing along these two arguments.
> In writeCSS() the StyleNodes are converted to CSS. When the StyleNodes are 
> written out we tap in when we see a "background-image" property and insert 
> the image strip name instead of the actual image name, and the image's strip 
> coordinates as background-position, and width/height properties.
> Relevant files:
> trunk_1.2.10.1-branch_imageStripping\trinidad-impl\src\main\java\org\apache\myfaces\trinidadinternal\style\cache\FileSystemStyleCache.java
> trunk_1.2.10.1-branch_imageStripping\trinidad-impl\src\main\java\org\apache\myfaces\trinidadinternal\style\cache\ImageStrip.java
> trunk_1.2.10.1-branch_imageStripping\trinidad-impl\src\main\java\org\apache\myfaces\trinidadinternal\style\cache\ImageStripIcon.java
> trunk_1.2.10.1-branch_imageStripping\trinidad-impl\src\main\java\org\apache\myfaces\trinidadinternal\style\cache\ImageStripUtils.java
> trunk_1.2.10.1-branch_imageStripping\trinidad-impl\src\main\java\org\apache\myfaces\trinidadinternal\style\util\CSSGenerationUtils.java
> Possible issues:
> * All css images would be loaded in memory while creating the image strip 
> which is additional memory utilization.
> * All css images need to be followed by background-position property, which 
> would make css file size larger. This could be offset by replacement of image 
> names. Images names are arbitrarily long, they will be replaced with a fixed 
> length image strip name (could be as short as possible), thus making the file 
> size smaller.
> * Images that have background-repeat:repeat-x property would have to go to a 
> separate image strip file.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to