add scale blit to grc, add compositing interface
authorFelix Domke <tmbinc@elitedvb.net>
Wed, 3 Jun 2009 12:52:58 +0000 (14:52 +0200)
committerFelix Domke <tmbinc@elitedvb.net>
Wed, 3 Jun 2009 12:59:33 +0000 (14:59 +0200)
lib/gdi/grc.cpp
lib/gdi/grc.h

index 86d53fd..5ef6833 100644 (file)
@@ -119,7 +119,11 @@ void *gRC::thread()
                                break;
                        else if (o.opcode==gOpcode::notify)
                                need_notify = 1;
-                       else if(o.dc)
+                       else if (o.opcode==gOpcode::setCompositing)
+                       {
+                               m_compositing = o.parm.setCompositing;
+                               m_compositing->Release();
+                       } else if(o.dc)
                        {
                                o.dc->exec(&o);
                                // o.dc is a gDC* filled with grabref... so we must release it here
@@ -377,6 +381,13 @@ void gPainter::clear()
 
 void gPainter::blit(gPixmap *pixmap, ePoint pos, const eRect &clip, int flags)
 {
+       blitScale(pixmap, eRect(pos, eSize()), clip, flags, 0);
+}
+
+void gPainter::blitScale(gPixmap *pixmap, const eRect &position, const eRect &clip, int flags, int aflags)
+{
+       flags |= aflags;
+
        if ( m_dc->islocked() )
                return;
        gOpcode o;
@@ -388,13 +399,12 @@ void gPainter::blit(gPixmap *pixmap, ePoint pos, const eRect &clip, int flags)
        pixmap->AddRef();
        o.parm.blit  = new gOpcode::para::pblit;
        o.parm.blit->pixmap = pixmap;
-       o.parm.blit->position = pos;
        o.parm.blit->clip = clip;
-       o.parm.blit->flags=flags;
+       o.parm.blit->flags = flags;
+       o.parm.blit->position = position;
        m_rc->submit(o);
 }
 
-
 void gPainter::setPalette(gRGB *colors, int start, int len)
 {
        if ( m_dc->islocked() )
@@ -549,6 +559,16 @@ void gPainter::notify()
        m_rc->submit(o);
 }
 
+void gPainter::setCompositing(gCompositingData *comp)
+{
+       gOpcode o;
+       o.opcode = gOpcode::setCompositing;
+       o.dc = 0;
+       o.parm.setCompositing = comp;
+       comp->AddRef(); /* will be freed in ::thread */
+       m_rc->submit(o);
+}
+
 void gPainter::end()
 {
        if ( m_dc->islocked() )
@@ -677,7 +697,7 @@ void gDC::exec(gOpcode *o)
                gRegion clip;
                                // this code should be checked again but i'm too tired now
                
-               o->parm.blit->position += m_current_offset;
+               o->parm.blit->position.moveBy(m_current_offset);
                
                if (o->parm.blit->clip.valid())
                {
@@ -777,7 +797,7 @@ void gDC::enableSpinner()
        ASSERT(m_spinner_saved);
        
                /* save the background to restore it later. We need to negative position because we want to blit from the middle of the screen. */
-       m_spinner_saved->blit(*m_pixmap, -m_spinner_pos.topLeft(), gRegion(eRect(ePoint(0, 0), m_spinner_saved->size())), 0);
+       m_spinner_saved->blit(*m_pixmap, eRect(-m_spinner_pos.topLeft(), eSize()), gRegion(eRect(ePoint(0, 0), m_spinner_saved->size())), 0);
        
        incrementSpinner();
 }
@@ -787,7 +807,7 @@ void gDC::disableSpinner()
        ASSERT(m_spinner_saved);
 
                /* restore background */
-       m_pixmap->blit(*m_spinner_saved, m_spinner_pos.topLeft(), gRegion(m_spinner_pos), 0);
+       m_pixmap->blit(*m_spinner_saved, eRect(m_spinner_pos.topLeft(), eSize()), gRegion(m_spinner_pos), 0);
 }
 
 void gDC::incrementSpinner()
@@ -811,12 +831,12 @@ void gDC::incrementSpinner()
        }
 #endif
 
-       m_spinner_temp->blit(*m_spinner_saved, ePoint(0, 0), eRect(ePoint(0, 0), m_spinner_pos.size()));
+       m_spinner_temp->blit(*m_spinner_saved, eRect(0, 0, 0, 0), eRect(ePoint(0, 0), m_spinner_pos.size()));
 
        if (m_spinner_pic[m_spinner_i])
-               m_spinner_temp->blit(*m_spinner_pic[m_spinner_i], ePoint(0, 0), eRect(ePoint(0, 0), m_spinner_pos.size()), gPixmap::blitAlphaTest);
+               m_spinner_temp->blit(*m_spinner_pic[m_spinner_i], eRect(0, 0, 0, 0), eRect(ePoint(0, 0), m_spinner_pos.size()), gPixmap::blitAlphaTest);
 
-       m_pixmap->blit(*m_spinner_temp, m_spinner_pos.topLeft(), gRegion(m_spinner_pos), 0);
+       m_pixmap->blit(*m_spinner_temp, eRect(m_spinner_pos.topLeft(), eSize()), gRegion(m_spinner_pos), 0);
        m_spinner_i++;
        m_spinner_i %= m_spinner_num;
 }
index 7071425..3b6ed32 100644 (file)
@@ -22,6 +22,7 @@
 #include <lib/gdi/gpixmap.h>
 #include <lib/gdi/region.h>
 #include <lib/gdi/gfont.h>
+#include <lib/gdi/compositing.h>
 
 class eTextPara;
 
@@ -60,7 +61,9 @@ struct gOpcode
                
                enableSpinner, disableSpinner, incrementSpinner,
                
-               shutdown
+               shutdown,
+               
+               setCompositing,
        } opcode;
 
        gDC *dc;
@@ -102,8 +105,8 @@ struct gOpcode
                struct pblit
                {
                        gPixmap *pixmap;
-                       ePoint position;
                        int flags;
+                       eRect position;
                        eRect clip;
                } *blit;
 
@@ -137,6 +140,8 @@ struct gOpcode
                        ePoint value;
                        int rel;
                } *setOffset;
+               
+               gCompositingData *setCompositing;
        } parm;
 };
 
@@ -168,6 +173,8 @@ class gRC: public iObject, public Object
        
        void enableSpinner();
        void disableSpinner();
+       
+       ePtr<gCompositingData> m_compositing;
 
 public:
        gRC();
@@ -230,10 +237,12 @@ public:
        enum
        {
                BT_ALPHATEST = 1,
-               BT_ALPHABLEND = 2
+               BT_ALPHABLEND = 2,
+               BT_SCALE = 4 /* will be automatically set by blitScale */
        };
 
-       void blit(gPixmap *pixmap, ePoint pos, const eRect &what=eRect(), int flags=0);
+       void blit(gPixmap *pixmap, ePoint pos, const eRect &clip=eRect(), int flags=0);
+       void blitScale(gPixmap *pixmap, const eRect &pos, const eRect &clip=eRect(), int flags=0, int aflags = BT_SCALE);
 
        void setPalette(gRGB *colors, int start=0, int len=256);
        void setPalette(gPixmap *source);
@@ -252,6 +261,7 @@ public:
        void waitVSync();
        void flip();
        void notify();
+       void setCompositing(gCompositingData *comp);
 };
 
 class gDC: public iObject