[Laszlo-checkins] r8956 - in openlaszlo/trunk: WEB-INF/lps/lfc/kernel/dhtml WEB-INF/lps/lfc/kernel/swf WEB-INF/lps/lfc/kernel/swf9 WEB-INF/lps/lfc/views WEB-INF/lps/schema lps/components/extensions

max@openlaszlo.org max at openlaszlo.org
Thu May 1 09:46:38 PDT 2008


Author: max
Date: 2008-05-01 09:46:32 -0700 (Thu, 01 May 2008)
New Revision: 8956

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as
   openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs
   openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx
   openlaszlo/trunk/lps/components/extensions/drawview.lzx
Log:
Change 20080430-maxcarlson-e by maxcarlson at Roboto on 2008-04-30 22:51:46 PDT
    in /Users/maxcarlson/openlaszlo/trunk-clean
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Add 'cachebitmap' attribute to view

New Features:

Bugs Fixed: LPP-5904 - Add bitmap caching API

Technical Reviewer: promanik
QA Reviewer: hminsky
Doc Reviewer: (pending)

Documentation:

Release Notes: Setting the cachebitmap attribute to true will tunr on bitmap caching for views.  Note that text defaults to cachebitmap='true'.  This currently works only in Flash.

Details: lfc.lzx - Add setter method and attribute name.

swf/LzTextSprite.as - Default  cachebitmap to true instead of setting directly.

swf/LzSprite.as - Set bitmapcaching capability to true.  Turn off bitmap caching for clipped views, and warn in $debug mode.  Add setBitmapCache()  and getContext() implementations.

dhtml/LzSprite.js - Set bitmapcaching capability to false.  Add getContext() placeholder method.

swf9/LzSprite.as - Set bitmapcaching capability to true.  Add setBitmapCache()  and getContext() implementations.  Update getMCRef() to return the proper reference.

LaszloView.lzs - Add cachebitmap class attribute and setter.

drawview.lzx - Use inherited cachebitmap property.  Default cachebitmap to true.  Use sprite.getContext() API to get graphics context.  Rely on sprite warnings when clipping is on and cachebitmap is true. 

    

Tests: /test/drawing/drawing.lzx runs as it did before in swf 7,8,9 and dhtml.



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js	2008-05-01 16:41:28 UTC (rev 8955)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js	2008-05-01 16:46:32 UTC (rev 8956)
@@ -247,6 +247,7 @@
     ,accessibility: false
     ,htmlinputtext: false
     ,advancedfonts: false
+    ,bitmapcaching: false
 }
 
 LzSprite.prototype.__updateQuirks = function () {
@@ -1405,6 +1406,11 @@
     return this.__LZdiv;
 }
 
+LzSprite.prototype.getContext = function ( ){
+    //TODO: move from drawview
+    return this.getMCRef();
+}
+
 LzSprite.prototype.bringToFront = function() {
     if (! this.__parent) {
         if ($debug) {

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as	2008-05-01 16:41:28 UTC (rev 8955)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as	2008-05-01 16:46:32 UTC (rev 8956)
@@ -63,6 +63,7 @@
     ,accessibility: true
     ,htmlinputtext: true
     ,advancedfonts: true
+    ,bitmapcaching: true
 }
 
 /**
@@ -807,6 +808,11 @@
                     this);
         return;
     }
+    if (s && this.cachebitmap) {
+        if ($debug) Debug.warn('Clipping automatically disables bitmap caching');
+        this.setBitmapCache(false);
+    }
+
     var mc = this.__LZmovieClipRef;
     if (s) {
         var mask = mc.createEmptyMovieClip("$mcM", this.MASK_DEPTH);
@@ -1028,7 +1034,6 @@
 
 /**
   * Get a reference to the control mc - may be overridden by loader
-  * @access private
   */
 LzSprite.prototype.getMCRef = function () {
     if (this.__LZmovieClipRef == null){
@@ -1704,6 +1709,21 @@
 }
 
 /**
+  * Allows bitmap caching to be enabled/disabled where available.
+  * @param Boolean cache: Whether or not to cache bitmaps for this view
+  */
+LzSprite.prototype.setBitmapCache = function(cache) {
+    this.cachebitmap = cache;
+    var mc = this.getMCRef();
+    mc.cacheAsBitmap = cache;
+}
+
+/**
+  * Get a reference to the graphics context
+  */
+LzSprite.prototype.getContext = LzSprite.prototype.getMCRef;
+
+/**
   * Register for update when the button gets the focus.
   * Set the behavior of the enter key depending on whether the field is
   * multiline or not.

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as	2008-05-01 16:41:28 UTC (rev 8955)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as	2008-05-01 16:46:32 UTC (rev 8956)
@@ -42,7 +42,6 @@
 
     //Debug.write('created', textclip, 'in', mc, txtname);
 
-    textclip.cacheAsBitmap = true;
     this.__LZtextclip = textclip;
     // set a pointer back to this view from the TextField object
     textclip.__lzview = this.owner;
@@ -53,7 +52,9 @@
 
     //    textclip._quality = "BEST";
     ///   textclip._highquality = 2;
-    
+
+    // default to bitmap caching being on 
+    if (args.cachebitmap == null) args.cachebitmap = true;
 }
 
 LzTextSprite.prototype = new LzSprite(null);

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as	2008-05-01 16:41:28 UTC (rev 8955)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as	2008-05-01 16:46:32 UTC (rev 8956)
@@ -83,6 +83,7 @@
       ,accessibility: true
       ,htmlinputtext: true
       ,advancedfonts: true
+      ,bitmapcaching: true
       }
 
       public function LzSprite (newowner = null, isroot = null, args = null) {
@@ -703,9 +704,17 @@
       }
 
       public function getMCRef () {
+          return this; 
+      }
+
+      public function getContext () {
           return this.graphics; 
       }
 
+      public function setBitmapCache(cache) {
+          this.cacheAsBitmap = cache;
+      }
+
       /**
         * Get the current z order of the sprite
         * @return Integer: A number representing z orderin

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs	2008-05-01 16:41:28 UTC (rev 8955)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs	2008-05-01 16:46:32 UTC (rev 8956)
@@ -2983,6 +2983,27 @@
   */
 function getPrevSelection() {
 }
+
+/** A value of true means that this view's bitmap will be cached, if available.
+  * @type Boolean
+  * @lzxtype boolean
+  * @lzxdefault false
+  */
+var cachebitmap = false;
+/**
+  * @param Boolean cache: Whether or not to cache bitmaps for this view
+  * @access private 
+  */
+function $lzc$set_cachebitmap( cache ) {
+    if (cache != this.cachebitmap) {
+        this.cachebitmap = cache;
+        if (this.capabilities.bitmapcaching) {
+            this.sprite.setBitmapCache(cache);
+        } else {
+            if ($debug) this.__warnCapability('view.cachebitmap'); 
+        }
+    }
+}
 } // End of LzView
 
 ConstructorMap[LzView.tagname] = LzView;

Modified: openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx	2008-05-01 16:41:28 UTC (rev 8955)
+++ openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx	2008-05-01 16:46:32 UTC (rev 8956)
@@ -257,6 +257,7 @@
   <attribute name="aatabindex" type="number"/>
   <attribute name="aasilent" type="boolean"/>
   <attribute name="showhandcursor" type="boolean"/>
+  <attribute name="cachebitmap" type="boolean"/>
   <event name="onaddsubresource"/>
   <event name="onaddsubview"/>
   <event name="onbgcolor"/>
@@ -346,6 +347,7 @@
   <method name="$lzc$set_xoffset"/>
   <method name="$lzc$set_y"/>
   <method name="$lzc$set_yoffset"/>
+  <method name="$lzc$set_cachebitmap"/>
   <method name="__LZFinishDestroyOnIdle"/>
   <method name="__LZalignCenter"/>
   <method name="__LZalignRight"/>

Modified: openlaszlo/trunk/lps/components/extensions/drawview.lzx
===================================================================
--- openlaszlo/trunk/lps/components/extensions/drawview.lzx	2008-05-01 16:41:28 UTC (rev 8955)
+++ openlaszlo/trunk/lps/components/extensions/drawview.lzx	2008-05-01 16:46:32 UTC (rev 8956)
@@ -496,7 +496,6 @@
             var strokeStyle = '#000000';
             var fillStyle = '#000000';
             var context = null;
-            var cachebitmap = true;
             
             var oncontext = LzDeclaredEvent;
     
@@ -801,7 +800,6 @@
             var strokeStyle = '#000000';
             var fillStyle = '#000000';
             var context = null;
-            var cachebitmap = true;
             var __path = [];
             var __pathisopen = false;
             var __MOVETO_OP = 0;
@@ -815,14 +813,10 @@
             }
 
             override function construct(parent,args) {
+                // default to bitmap caching on    
+                if (args['cachebitmap'] == null) args['cachebitmap'] = true;
                 super.construct(parent, args);
-                this.context = this.getMCRef();
-                if ($as2) {
-                    if (args['cachebitmap'] != null) {
-                        this.cachebitmap = args['cachebitmap'];
-                    }
-                    this.context.cacheAsBitmap = this.cachebitmap;
-                }
+                this.context = this.sprite.getContext();
                 this.beginPath();
 
                 new LzDelegate( this , "_oninit" , this , "oninit" );
@@ -1046,10 +1040,6 @@
                 this.clipPath();
             }
             function clipPath() {
-                if ($as2 && this.cachebitmap) {
-                    if ($debug) Debug.warn('drawview.clip() automatically disables bitmap caching');
-                    this.cachebitmap = this.context.cacheAsBitmap = false;
-                }
                 this.sprite.applyMask(true);
                 var __clipmc = this.sprite.__LZmaskClip;
                 this.closePath();



More information about the Laszlo-checkins mailing list