[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/multimedia/kmplayer/src
From:       Koos Vriezen <koos.vriezen () gmail ! com>
Date:       2011-10-08 12:39:40
Message-ID: 20111008123940.DE45CAC887 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1257947 by vriezen:

Implement sub region positioning of smilText

Which also means that animating on one of the attributes can invalidate
the surface, but not for animateMotion since that would make it choppy

 M  +33 -16    kmplayer_smil.cpp  
 M  +3 -0      kmplayer_smil.h  
 M  +2 -0      viewarea.cpp  


--- trunk/extragear/multimedia/kmplayer/src/kmplayer_smil.cpp #1257946:1257947
@@ -4059,6 +4059,7 @@
         text_surface->remove ();
         text_surface = NULL;
     }
+    sizes.resetSizes ();
     runtime->init ();
     Element::deactivate ();
 }
@@ -4079,21 +4080,39 @@
 }
 
 void SMIL::SmilText::parseParam (const TrieString &name, const QString &value) {
-    if (!props.parseParam (name, value) &&
-            !runtime->parseParam (name, value) &&
-            !parseBackgroundParam (background_color, name, value) &&
-            !parseMediaOpacityParam (media_opacity, name, value) &&
-            !parseTransitionParam (this, transition, runtime, name, value)) {
+    if (props.parseParam (name, value)
+            || sizes.setSizeParam (name, value)
+            || parseBackgroundParam (background_color, name, value)
+            || parseMediaOpacityParam (media_opacity, name, value)) {
+        message (MsgMediaUpdated);
+    } else if (!runtime->parseParam (name, value)
+            && !parseTransitionParam (this, transition, runtime, name, value)) {
         Element::parseParam (name, value);
     }
 }
 
+void SMIL::SmilText::updateBounds (bool remove) {
+    if (text_surface) {
+        SMIL::RegionBase *rb = convertNode <SMIL::RegionBase> (region_node);
+        Surface *rs = (Surface *) region_node->role (RoleDisplay);
+        if (rs) {
+            SRect b = rs->bounds;
+            Single x, y, w = size.width, h = size.height;
+            sizes.calcSizes (this, &rb->sizes, b.width(), b.height(), x, y, w, h);
+            if (!size.isEmpty () && w > 0 && h > 0) {
+                w = size.width;
+                h = size.height;
+            }
+            text_surface->resize (SRect (x, y, w, h), remove);
+        }
+    }
+}
+
 void SMIL::SmilText::message (MessageType msg, void *content) {
     switch (msg) {
 
         case MsgSurfaceBoundsUpdate:
-            if (content && text_surface)
-                text_surface->resize (text_surface->bounds, true);
+            updateBounds (!!content);
             return;
 
         case MsgStateFreeze:
@@ -4137,6 +4156,9 @@
     case RoleDisplay:
         return surface ();
 
+    case RoleSizer:
+        return &sizes;
+
     case RoleReceivers: {
         MessageType msgt = (MessageType) (long) content;
         ConnectionList *l = mouse_listeners.receivers (msgt);
@@ -4163,18 +4185,13 @@
             text_surface->remove ();
             text_surface = NULL;
         }
-    } else if (region_node) {
+    } else if (region_node && !text_surface) {
         Surface *rs = (Surface *) region_node->role (RoleDisplay);
         if (rs) {
-            SRect b = rs->bounds;
-            if (!text_surface)
-                text_surface = rs->createSurface (this,
-                        SRect (0, 0, b.width (), b.height ()));
-#ifdef KMPLAYER_WITH_CAIRO
-            else if (!text_surface->surface)
-                text_surface->bounds = SRect (0, 0, b.width (), b.height ());
-#endif
+            text_surface = rs->createSurface (this, SRect ());
             text_surface->setBackgroundColor (background_color.color);
+            size = SSize ();
+            updateBounds (false);
         }
     }
     return text_surface.ptr ();
--- trunk/extragear/multimedia/kmplayer/src/kmplayer_smil.h #1257946:1257947
@@ -817,6 +817,7 @@
     virtual void accept (Visitor *v) { v->visit (this); }
 
     Surface *surface ();
+    void updateBounds (bool remove);
 
     SmilColorProperty background_color;
     MediaOpacity media_opacity;
@@ -824,6 +825,8 @@
     SmilTextProperties props;
     SurfacePtrW text_surface;
     NodePtrW region_node;
+    CalculatedSizer sizes;
+    SSize size;
     ConnectionLink region_attach;
     ConnectionList media_attached;
     MouseListeners mouse_listeners;
--- trunk/extragear/multimedia/kmplayer/src/viewarea.cpp #1257946:1257947
@@ -1206,6 +1206,8 @@
 
             // update bounds rect
             s->bounds = matrix.toUser (IRect (scr.point, ISize (w, info.voffset)));
+            txt->size = s->bounds.size;
+            txt->updateBounds (false);
 
             // update coord. for painting below
             scr = matrix.toScreen (s->bounds);
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic