gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog gui/gui.cpp


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog gui/gui.cpp
Date: Wed, 23 Apr 2008 17:09:02 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  08/04/23 17:09:02

Modified files:
        .              : ChangeLog 
        gui            : gui.cpp 

Log message:
        (updateStageMatrix): add support for all scale modes.
        Query all from movie_root.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6366&r2=1.6367
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.cpp?cvsroot=gnash&r1=1.157&r2=1.158

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6366
retrieving revision 1.6367
diff -u -b -r1.6366 -r1.6367
--- ChangeLog   23 Apr 2008 17:04:32 -0000      1.6366
+++ ChangeLog   23 Apr 2008 17:09:01 -0000      1.6367
@@ -1,3 +1,8 @@
+2008-04-23 Sandro Santilli <address@hidden>
+
+       * gui/gui.cpp (updateStageMatrix): add support for
+         all scale modes. Query all from movie_root.
+
 2008-04-23 Benjamin Wolsey <address@hidden>
 
        * testsuite/actionscript.all/Stage.as: update passes.

Index: gui/gui.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gui.cpp,v
retrieving revision 1.157
retrieving revision 1.158
diff -u -b -r1.157 -r1.158
--- gui/gui.cpp 23 Apr 2008 16:10:19 -0000      1.157
+++ gui/gui.cpp 23 Apr 2008 17:09:02 -0000      1.158
@@ -231,63 +231,100 @@
                return;
        }
 
+       assert(_stage); // when VM is initialized this should hold
+
        float swfwidth = _movieDef->get_width_pixels();
        float swfheight = _movieDef->get_height_pixels();
 
-       // TODO: query scaleMode [ noScale,showAll,exactFit,noBorders ]
-       if ( _stage && _stage->isRescalingAllowed() )
+       // Fetch scale mode
+       movie_root::ScaleMode scaleMode = _stage->getScaleMode();
+       switch (scaleMode)
        {
+               case movie_root::noScale:
+                       _xscale = _yscale = 1.0f;
+                       break;
 
+               case movie_root::showAll:
+               {
                // set new scale value ( user-pixel / pseudo-pixel )
                _xscale = _width / swfwidth;
                _yscale = _height / swfheight;
                
-               // always scale proportionally
+                       // Scale proportionally, using smallest scale
                if (_xscale < _yscale) _yscale = _xscale;
                else if (_yscale < _xscale) _xscale = _yscale;
+
+                       break;
        }
-       else
+
+               case movie_root::noBorder:
        {
-               _xscale = _yscale = 1.0f;
+
+                       // set new scale value ( user-pixel / pseudo-pixel )
+                       _xscale = _width / swfwidth;
+                       _yscale = _height / swfheight;
+                       
+                       // Scale proportionally, using biggest scale
+                       if (_xscale > _yscale) _yscale = _xscale;
+                       else if (_yscale > _xscale) _xscale = _yscale;
+
+                       break;
+               }
+
+               case movie_root::exactFit:
+               {
+                       // NOTE: changing aspect ratio is valid!
+                       _xscale = _width / swfwidth;
+                       _yscale = _height / swfheight;
+                       //LOG_ONCE( log_unimpl("Stage.scaleMode=exactFit") );
+                       break;
+               }
+
+               default:
+               {
+                       log_error("Invalid scaleMode %d", scaleMode);
+                       break;
+               }
        }
 
        _xoffset=0;
        _yoffset=0;
 
-       // Align to center
-       // TODO: use _stage.getAlignMode
-       movie_root::StageHorizontalAlign halign = movie_root::STAGE_H_ALIGN_C;
-       movie_root::StageVerticalAlign valign = movie_root::STAGE_V_ALIGN_C;
+       // Fetch align mode
+       movie_root::StageAlign align = _stage->getStageAlignment();
+       movie_root::StageHorizontalAlign halign = align.first;
+       movie_root::StageVerticalAlign valign = align.second;
 
        // Handle horizontal alignment
        switch ( halign )
        {
                case movie_root::STAGE_H_ALIGN_L:
+               {
                        // _xoffset=0 is fine
                        break;
+               }
 
                case movie_root::STAGE_H_ALIGN_R:
                {
                        // Offsets in pixels
                        float defWidth = swfwidth *= _xscale;
-                       if ( _width > defWidth )
-                       {
                                float diffWidth = _width-defWidth;
                                _xoffset = diffWidth;
-                       }
                        break;
                }
 
                case movie_root::STAGE_V_ALIGN_C:
-               default:
                {
                        // Offsets in pixels
                        float defWidth = swfwidth *= _xscale;
-                       if ( _width > defWidth )
-                       {
                                float diffWidth = _width-defWidth;
                                _xoffset = diffWidth/2.0;
+                       break;
                        }
+
+               default:
+               {
+                       log_error("Invalid horizontal align %d", valign);
                        break;
                }
        }
@@ -296,29 +333,30 @@
        switch ( valign )
        {
                case movie_root::STAGE_V_ALIGN_T:
+               {
                        // _yoffset=0 is fine
                        break;
+               }
 
                case movie_root::STAGE_V_ALIGN_B:
                {
                        float defHeight = swfheight *= _yscale;
-                       if ( _height > defHeight )
-                       {
                                float diffHeight = _height-defHeight;
                                _yoffset = diffHeight;
-                       }
                        break;
                }
 
                case movie_root::STAGE_V_ALIGN_C:
-               default:
                {
                        float defHeight = swfheight *= _yscale;
-                       if ( _height > defHeight )
-                       {
                                float diffHeight = _height-defHeight;
                                _yoffset = diffHeight/2.0;
                        }
+
+               default:
+               {
+                       log_error("Invalid vertical align %d", valign);
+                       break;
                }
        }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]