swf_ObjectPlace(Clip) now only sets a matrix if it's not the unix matrix.
authorkramm <kramm>
Fri, 22 Oct 2004 15:05:48 +0000 (15:05 +0000)
committerkramm <kramm>
Fri, 22 Oct 2004 15:05:48 +0000 (15:05 +0000)
lib/modules/swfobject.c

index 18ccce7..d1a7632 100644 (file)
 #define PF_CLIPACTION   0x40
 #define PF_ACTIONEVENT  0x80
 
+int isUnitMatrix(MATRIX* m)
+{
+    /* a matrix with all zeros is also considered
+       "unit matrix", as a zeroed out MATRIX structure
+       usually means that the caller doesn't want to
+       set the matrix */
+    if((   (m->sx == 0x10000 && m->sy == 0x10000) 
+       || (m->sx == 0 && m->sy == 0))
+               && ((m->r0|m->r1|m->tx|m->ty) == 0)
+      )
+       return 1;
+    return 0;
+}
+
+int isUnitCXForm(CXFORM* cx)
+{
+    if((cx->a0==256 && cx->r0==256 && cx->g0==256 && cx->b0==256) &&
+       (cx->a1==0 && cx->r1==0 && cx->g1==0 && cx->b1==0))
+       return 1;
+    /* A CXForm of all zeros is, unfortunately, not as unlikely
+       as a matrix of all zeros. However, we still treat it
+       as non-existent/uniform transform */
+    if((cx->a0==0 && cx->r0==0 && cx->g0==0 && cx->b0==0) &&
+       (cx->a1==0 && cx->r1==0 && cx->g1==0 && cx->b1==0))
+       return 1;
+    return 0;
+}
+
 int swf_ObjectPlace(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * name)
 { U8 flags;
   if (!t) return -1;
@@ -38,6 +66,9 @@ int swf_ObjectPlace(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * name)
        && cx->r0==256 && cx->g0==256 && cx->b0==256 && cx->a0==256)
       cx = 0;
 
+  if(m && isUnitMatrix(m)) 
+      m = 0;
+
   flags = (id?PF_CHAR:0)|(m?PF_MATRIX:0)|(cx?PF_CXFORM:0)|(name?PF_NAME:0)|((m||cx)&&(!id)?PF_MOVE:0);
 
   swf_SetU8(t,flags);
@@ -58,6 +89,9 @@ int swf_ObjectPlaceClip(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * nam
   if(cx && cx->r1==0 && cx->g1==0 && cx->b1==0 && cx->a1==0
        && cx->r0==256 && cx->g0==256 && cx->b0==256 && cx->a0==256)
       cx = 0;
+  
+  if(m && isUnitMatrix(m)) 
+      m = 0;
 
   flags = (id?PF_CHAR:0)|(m?PF_MATRIX:0)|(cx?PF_CXFORM:0)|(name?PF_NAME:0)|
           ((m||cx)&&(!id)?PF_MOVE:0)|(clipaction?PF_CLIPACTION:0);
@@ -79,34 +113,6 @@ int swf_ObjectMove(TAG * t,U16 depth,MATRIX * m,CXFORM * cx)
 { return swf_ObjectPlace(t,0,depth,m,cx,NULL);
 }
 
-int isUnitMatrix(MATRIX* m)
-{
-    /* a matrix with all zeros is also considered
-       "unit matrix", as a zeroed out MATRIX structure
-       usually means that the caller doesn't want to
-       set the matrix */
-    if((   (m->sx == 0x10000 && m->sy == 0x10000) 
-       || (m->sx == 0 && m->sy == 0))
-               && ((m->r0|m->r1|m->tx|m->ty) == 0)
-      )
-       return 1;
-    return 0;
-}
-
-int isUnitCXForm(CXFORM* cx)
-{
-    if((cx->a0==256 && cx->r0==256 && cx->g0==256 && cx->b0==256) &&
-       (cx->a1==0 && cx->r1==0 && cx->g1==0 && cx->b1==0))
-       return 1;
-    /* A CXForm of all zeros is, unfortunately, not as unlikely
-       as a matrix of all zeros. However, we still treat it
-       as non-existent/uniform transform */
-    if((cx->a0==0 && cx->r0==0 && cx->g0==0 && cx->b0==0) &&
-       (cx->a1==0 && cx->r1==0 && cx->g1==0 && cx->b1==0))
-       return 1;
-    return 0;
-}
-
 void swf_SetPlaceObject(TAG * t,SWFPLACEOBJECT* obj)
 { 
     U8 flags;