On Jan 24, 2008 3:39 PM, Sandro Santilli <[EMAIL PROTECTED]> wrote:
> On Thu, Jan 24, 2008 at 09:13:37AM +0800, zou lunkai wrote:
> > Hello, strk
> >
> > > Suppose in a displayList we have 2 layer masks:
> >
> > >  mask1: at depth 1 masks up to layer 3
> > >  mask2: at depth 2 (masked by mask1) masks up to layer 5
> > >  maskee: at depth 4
> >
> > > Is maskee masked by both mask1 and mask2 or only by mask2 ?
> >
> > yes, the maskee should be masked by both mask1 and mask2.  I am pretty
> > sure about this, otherwise the stack based algorithm won't work.
>
> Could you extend the test with this other scenario please:
>
> mask1: at depth 1 masks up to layer 6
> mask2: at depth 2 masks up to layer 3
> maskee: at depth 4
>
> I guess maskee should be masked by mask1 and not mask2.
>

yes, you are right. And our stack mode stil works here.

> The test, with both scenarios (maybe in two frames) would
> be very helpful to test more things:
>         - rendering
>         - AS hitTest
>         - mouse handling (maskee should do something onRollOver/Out, like 
> changing alpha)
>         - _droptarget (needs something to drag)
>

rendering should be fine. Not sure about the others.

See attached tests by visual check, both cases are tested. Seems masks
could respond to the mouse pointer in the test, but haven't done any
deep deduction.

--zou
/*
 *   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */ 

/*
 * Zou Lunkai, [EMAIL PROTECTED]
 *
 *  Test for nested masks
 */

#include <stdlib.h>
#include <stdio.h>
#include <ming.h>

#include "ming_utils.h"

#define OUTPUT_VERSION 6
#define OUTPUT_FILENAME "masks_test4.swf"

SWFMovieClip defineMovieclip(int x, int y, int w, int h);

SWFMovieClip defineMovieclip(int x, int y, int w, int h)
{
    SWFMovieClip mc;
    SWFShape  sh;
    mc = newSWFMovieClip();
    sh = make_fill_square (x, y, w, h, 255, 0, 0, 255, 0, 0);
    SWFMovieClip_add(mc, (SWFBlock)sh);  
    SWFMovieClip_nextFrame(mc);
    return mc;
}

int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFMovieClip  mc1, mc2, mc3, dejagnuclip;
  SWFDisplayItem it;
  const char *srcdir=".";
    
  Ming_init();
  mo = newSWFMovieWithVersion(OUTPUT_VERSION);
  SWFMovie_setDimension(mo, 800, 600);
  SWFMovie_setRate (mo, 0.5);
  // NOTE: take care of the TextFiled instance box!
  // Better not use it here:)! it seems violates this test.
  // dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 
0, 800, 600);
  // SWFMovie_add(mo, (SWFBlock)dejagnuclip);
  SWFMovie_nextFrame(mo); // frame1
  
  
  mc1 = defineMovieclip(0, 0, 30, 30);   // medium square
  mc2 = defineMovieclip(0, 0, 10, 10);   // small square
  mc3 = defineMovieclip(0, 0, 90, 90); // big square

  // -- case1 --
  //  mask1: at depth 1 masks up to layer 3
  //  mask2: at depth 2 (masked by mask1) masks up to layer 5
  //  maskee: at depth 4
  // expected: maskee masked by both mask1 and mask2.
  it = SWFMovie_add(mo, (SWFBlock)mc1);  
  SWFDisplayItem_setDepth(it, 1); 
  SWFDisplayItem_setMaskLevel(it, 3);
  SWFDisplayItem_addAction(it,
    compileSWFActionCode( " _root.note(this + ' pressed'); "),
    SWFACTION_PRESS);
  SWFDisplayItem_setName(it, "mask1");
  SWFDisplayItem_moveTo(it, 200, 200);
  
  it = SWFMovie_add(mo, (SWFBlock)mc2);  
  SWFDisplayItem_setDepth(it, 2); 
  SWFDisplayItem_setMaskLevel(it, 5);
  SWFDisplayItem_addAction(it,
    compileSWFActionCode( " _root.note(this + ' pressed'); "),
    SWFACTION_PRESS);
  SWFDisplayItem_setName(it, "mask2");
  SWFDisplayItem_moveTo(it, 200, 200);
   
  it = SWFMovie_add(mo, (SWFBlock)mc3);  
  SWFDisplayItem_setDepth(it, 4); 
  SWFDisplayItem_addAction(it,
    compileSWFActionCode( " _root.note(this + ' pressed'); "),
    SWFACTION_PRESS);
  SWFDisplayItem_setName(it, "maskee");
  SWFDisplayItem_moveTo(it, 200, 200);
  // visual check: show a small square, the result of mask1 & mask2             
    
  SWFMovie_nextFrame(mo); // frame 2
  
  
  // -- case2 --
  // mask1: at depth 11 masks up to layer 16
  // mask2: at depth 12 masks up to layer 13
  // maskee: at depth 14
  // expected: maskee masked by only mask1.
  it = SWFMovie_add(mo, (SWFBlock)mc1);  
  SWFDisplayItem_setDepth(it, 11); 
  SWFDisplayItem_setMaskLevel(it, 16);
  SWFDisplayItem_moveTo(it, 400, 400);
  SWFDisplayItem_addAction(it,
    compileSWFActionCode( " _root.note(this + ' pressed'); "),
    SWFACTION_PRESS);
  SWFDisplayItem_setName(it, "mask1");
    
  it = SWFMovie_add(mo, (SWFBlock)mc2);  
  SWFDisplayItem_setDepth(it, 12); 
  SWFDisplayItem_setMaskLevel(it, 13);
   SWFDisplayItem_moveTo(it, 400, 400);
  SWFDisplayItem_addAction(it,
    compileSWFActionCode( " _root.note(this + ' pressed'); "),
    SWFACTION_PRESS);
  SWFDisplayItem_setName(it, "mask2");
  
  it = SWFMovie_add(mo, (SWFBlock)mc3);  
  SWFDisplayItem_setDepth(it, 14); 
   SWFDisplayItem_moveTo(it, 400, 400);
  SWFDisplayItem_addAction(it,
    compileSWFActionCode( " _root.note(this + ' pressed'); "),
    SWFACTION_PRESS);
  SWFDisplayItem_setName(it, "maskee");
  // visual check: show a medium square, the result of mask1.
  SWFMovie_nextFrame(mo); // frame 4
  
  //Output movie
  puts("Saving " OUTPUT_FILENAME );
  SWFMovie_save(mo, OUTPUT_FILENAME);

  return 0;
}



_______________________________________________
Gnash-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnash-dev

Reply via email to