Exemple #1
0
/// Not implemented, Fixme
void
FBOvgGlue::setInvalidatedRegions(const InvalidatedRanges& ranges)
{
    if (!_renderer) {
        log_error(_("No renderer set!"));
        return;
    }

    _renderer->set_invalidated_regions(ranges);
    
    _drawbounds.clear();

    for (size_t rno = 0; rno<ranges.size(); rno++) {
        geometry::Range2d<int> bounds = Intersection(
            _renderer->world_to_pixel(ranges.getRange(rno)),
            _validbounds);
        // it may happen that a particular range is out of the screen, which 
        // will lead to bounds==null. 
        if (bounds.isNull()) continue; 
        
        _drawbounds.push_back(bounds);   
    }
    
    // GNASH_REPORT_FUNCTION;
    // if (_renderer) {
    //     _renderer->setInvalidatedRegions(ranges);
    // }
}
Exemple #2
0
void
Bitmap::add_invalidated_bounds(InvalidatedRanges& ranges, bool force)
{
    if (!force && !invalidated()) return;

    ranges.add(m_old_invalidated_ranges);

    SWFRect bounds;
    bounds.expand_to_transformed_rect(getWorldMatrix(*this), getBounds()); 
    ranges.add(bounds.getRange());

}
Exemple #3
0
void
Video::add_invalidated_bounds(InvalidatedRanges& ranges, bool force)
{
    if (!force && !invalidated()) return; // no need to redraw

    ranges.add(m_old_invalidated_ranges);

    assert(m_def);

    SWFRect bounds;
    bounds.expand_to_transformed_rect(getWorldMatrix(*this), m_def->bounds());

    ranges.add(bounds.getRange());
}
Exemple #4
0
void
GtkOvgGlue::setRenderHandlerSize(int width, int height)
{
    GNASH_REPORT_FUNCTION;

    assert(width > 0);
    assert(height > 0);
    assert(_renderer != NULL);
    
#ifdef ENABLE_EGL_OFFSCREEN
    if (_offscreenbuf && _offscreenbuf->width == width &&
        _offscreenbuf->height == height) {
        return; 
    }

    if (_offscreenbuf) {
        gdk_image_destroy(_offscreenbuf);
    }

    GdkVisual* visual = gdk_drawable_get_visual(_drawing_area->window);
    _offscreenbuf = gdk_image_new (GDK_IMAGE_FASTEST, visual, width,
                                   height);
#endif

#if 1
    // if (_renderer) {
    //     vgScale(width, height);
    // }
#else
    // Attach the window to the low level device
    long xid = GDK_WINDOW_XID(gtk_widget_get_window(_drawing_area));
    _device->attachWindow(static_cast<renderer::GnashDevice::native_window_t>
                          (xid));

    vgLoadIdentity();

    // Allow drawing everywhere by default
    InvalidatedRanges ranges;
    ranges.setWorld();
    _renderer->set_invalidated_regions(ranges);    

    renderer::EGLDevice *egl = (renderer::EGLDevice*)_device.get();
    egl->swapBuffers();
#endif    
}
Exemple #5
0
void
MovieTester::render() 
{
    // Get invalidated ranges and cache them
    _invalidatedBounds.setNull();
    
    _movie_root->add_invalidated_bounds(_invalidatedBounds, false);
    
#ifdef SHOW_INVALIDATED_BOUNDS_ON_ADVANCE
    const MovieClip* r = getRootMovie();
    std::cout << "frame " << r->get_current_frame() << ") Invalidated bounds " << _invalidatedBounds << std::endl;
#endif
    
    // Force full redraw by using a WORLD invalidated ranges
    InvalidatedRanges ranges = _invalidatedBounds; 
    if ( _forceRedraw )	{
	ranges.setWorld(); // set to world if asked a full redraw
	_forceRedraw = false; // reset to no forced redraw
    }
    
    for (TestingRenderers::const_iterator it=_testingRenderers.begin(),
	     itE=_testingRenderers.end(); it != itE; ++it) {
	const TestingRenderer& rend = *it;
	render(rend.getRenderer(), ranges);
    }
    
    if ( _testingRenderers.empty() ) {
	// Make sure display is called in any case 
	//
	// What we're particularly interested about is 
	// proper computation of invalidated bounds, which
	// needs clear_invalidated() to be called.
	// display() will call clear_invalidated() on DisplayObjects
	// actually modified so we're fine with that.
	//
	// Directly calling _movie->clear_invalidated() here
	// also work currently, as invalidating the topmost
	// movie will force recomputation of all invalidated
	// bounds. Still, possible future changes might 
	// introduce differences, so better to reproduce
	// real runs as close as possible, by calling display().
	//
	_movie_root->display();
    }
}
void
AOS4CairoGlue::setInvalidatedRegions(const InvalidatedRanges& ranges)
{
    _cairo_renderer->set_invalidated_regions(ranges);
    _drawbounds.clear();

    for (unsigned int rno=0; rno<ranges.size(); rno++)
    {
		// twips changed to pixels here
        geometry::Range2d<int> bounds = Intersection(_cairo_renderer->world_to_pixel(ranges.getRange(rno)),_validbounds);

        // it may happen that a particular range is out of the screen, which
        // will lead to bounds==null.
        if (bounds.isNull()) continue;

        _drawbounds.push_back(bounds);
    }
}
Exemple #7
0
void 
qwidget::paintEvent(QPaintEvent *event)
{
    const QRegion& region = event->region();
    QRect rect = region.boundingRect();

    int xmin = static_cast<int> (pixelsToTwips(rect.x()-1)),
        ymin = static_cast<int> (pixelsToTwips(rect.y()-1)),
        xmax = static_cast<int> (pixelsToTwips(rect.right()+1)),
        ymax = static_cast<int> (pixelsToTwips(rect.bottom()+1));

    geometry::Range2d<int> range(xmin, ymin, xmax, ymax);
    InvalidatedRanges ranges;
    ranges.add(range);

    
    _godfather->setInvalidatedRegions(ranges);
    _godfather->renderBuffer();
}
Exemple #8
0
void
nsPluginInstance::threadMain(void)
{
    DBG("nsPluginInstance::threadMain started\n");
    DBG("URL: %s\n", _url.c_str());

	PR_Lock(playerLock);

    // Initialize Gnash core library.
    DBG("Gnash core initialized.\n");
 
    // Init logfile.
    gnash::RcInitFile& rcinit = gnash::RcInitFile::getDefaultInstance();
    std::string logfilename = std::string("T:npgnash.log");
    rcinit.setDebugLog(logfilename);
    gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
    dbglogfile.setWriteDisk(true);
    dbglogfile.setVerbosity(GNASH_DEBUG_LEVEL);
    DBG("Gnash logging initialized: %s\n", logfilename.c_str());

    // Init sound.
    //_sound_handler.reset(gnash::sound::create_sound_handler_sdl());
    //gnash::set_sound_handler(_sound_handler.get());
    DBG("Gnash sound initialized.\n");

    // Init GUI.
    int old_mouse_x = 0, old_mouse_y = 0, old_mouse_buttons = 0;
    _render_handler =
        (gnash::render_handler *) gnash::create_render_handler_agg("BGR24");
    // _memaddr = (unsigned char *) malloc(getMemSize());
    static_cast<gnash::render_handler_agg_base *>(_render_handler)->init_buffer(
            getMemAddr(), getMemSize(), _width, _height, _rowstride);
    gnash::set_render_handler(_render_handler);
    DBG("Gnash GUI initialized: %ux%u\n", _width, _height);

    gnash::URL url(_url);

    VariableMap vars;
    gnash::URL::parse_querystring(url.querystring(), vars);
    for (VariableMap::iterator i = vars.begin(), ie = vars.end(); i != ie; i++) {
        _flashVars[i->first] = i->second;
    }

    gnash::set_base_url(url);

    gnash::movie_definition* md = NULL;
    try {
        md = gnash::createMovie(url, _url.c_str(), false);
    } catch (const gnash::GnashException& err) {
        md = NULL;
    }
    if (!md) {
        /*
         * N.B. Can't use the goto here, as C++ complains about "jump to
         * label 'done' from here crosses initialization of ..." a bunch
         * of things.  Sigh.  So, instead, I duplicate the cleanup code
         * here.  TODO: Remove this duplication.
         */
        // goto done;

        PR_Unlock(playerLock);

        DBG("Clean up Gnash.\n");
        //gnash::clear();

        DBG("nsPluginInstance::threadMain exiting\n");
        return;
    }
    DBG("Movie created: %s\n", _url.c_str());

    int movie_width = static_cast<int>(md->get_width_pixels());
    int movie_height = static_cast<int>(md->get_height_pixels());
    float movie_fps = md->get_frame_rate();
    DBG("Movie dimensions: %ux%u (%.2f fps)\n",
            movie_width, movie_height, movie_fps);

    gnash::SystemClock clock; // use system clock here...
    gnash::movie_root& root = gnash::VM::init(*md, clock).getRoot();
    DBG("Gnash VM initialized.\n");
    
    // Register this plugin as listener for FsCommands from the core
    // (movie_root)
#if 0
    /* Commenting out for now as registerFSCommandCallback() has changed. */
    root.registerFSCommandCallback(FSCommand_callback);
#endif
    
    // Register a static function to handle ActionScript events such
    // as Mouse.hide, Stage.align etc.
    // root.registerEventCallback(&staticEventHandlingFunction);

    md->completeLoad();
    DBG("Movie loaded.\n");

    std::auto_ptr<gnash::Movie> mr(md->createMovie());
    mr->setVariables(_flashVars);
    root.setRootMovie(mr.release());
    //root.set_display_viewport(0, 0, _width, _height);
    root.set_background_alpha(1.0f);
    gnash::Movie* mi = root.getRootMovie();
    DBG("Movie instance created.\n");

    //ShowWindow(_window, SW_SHOW);
	IIntuition->ShowWindow(_window,NULL);
	
    for (;;) {
        // DBG("Inside main thread loop.\n");

        if (_shutdown) {
            DBG("Main thread shutting down.\n");
            break;
        }

        size_t cur_frame = mi->get_current_frame();
        // DBG("Got current frame number: %d.\n", cur_frame);
        size_t tot_frames = mi->get_frame_count();
        // DBG("Got total frame count: %d.\n", tot_frames);

        // DBG("Advancing one frame.\n");
        root.advance();
        // DBG("Going to next frame.\n");
        root.goto_frame(cur_frame + 1);
        // DBG("Ensuring frame is loaded.\n");
        //root.get_movie_definition()->ensure_frame_loaded(tot_frames);
        // DBG("Setting play state to PLAY.\n");
        root.set_play_state(gnash::MovieClip::PLAYSTATE_PLAY);

        if (old_mouse_x != mouse_x || old_mouse_y != mouse_y) {
            old_mouse_x = mouse_x;
            old_mouse_y = mouse_y;
            //root.notify_mouse_moved(mouse_x, mouse_y);
        }
        if (old_mouse_buttons != mouse_buttons) {
            old_mouse_buttons = mouse_buttons;
            int mask = 1;
            //root.notify_mouse_clicked(mouse_buttons > 0, mask);
        }

        root.display();

#if 0
        RECT rt;
        GetClientRect(_window, &rt);
        InvalidateRect(_window, &rt, FALSE);

        InvalidatedRanges ranges;
        ranges.setSnapFactor(1.3f);
        ranges.setSingleMode(false);
        root.add_invalidated_bounds(ranges, false);
        ranges.growBy(40.0f);
        ranges.combine_ranges();

        if (!ranges.isNull()) {
            InvalidateRect(_window, &rt, FALSE);
        }

        root.display();
#endif

        // DBG("Unlocking playerLock mutex.\n");
        PR_Unlock(playerLock);
        // DBG("Sleeping.\n");
        PR_Sleep(PR_INTERVAL_MIN);
        // DBG("Acquiring playerLock mutex.\n");
        PR_Lock(playerLock);
    }

done:
	PR_Unlock(playerLock);

    DBG("Clean up Gnash.\n");

    /*
     * N.B.  As per server/impl.cpp:clear(), all of Gnash's threads aren't
     * guaranteed to be terminated by this, yet.  Therefore, when Firefox
     * unloads npgnash.dll after calling NS_PluginShutdown(), and there are
     * still Gnash threads running, they will try and access memory that was
     * freed as part of the unloading of npgnash.dll, resulting in a process
     * abend.
     */

    //gnash::clear();

    DBG("nsPluginInstance::threadMain exiting\n");
}