2009-02-01 00:43:21 +01:00
|
|
|
/*
|
|
|
|
|
DISPLAY-SERVICE.hpp - service providing access to a display for outputting frames
|
|
|
|
|
|
|
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2009, Hermann Vosseler <Ichthyostega@web.de>
|
|
|
|
|
|
|
|
|
|
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** @file display-service.hpp
|
|
|
|
|
** A public service provided by the GUI, implementing the gui::GuiNotification facade interface.
|
|
|
|
|
** The purpose of this service is to push state update and notification of events from the lower
|
|
|
|
|
** layers into the Lumiera GUI. Typically, this happens asynchronously and triggered by events
|
|
|
|
|
** within the lower layers.
|
|
|
|
|
**
|
|
|
|
|
** This service is the implementation of a layer separation facade interface. Clients should use
|
|
|
|
|
** proc::play::DummyPlayer#facade to access this service. This header defines the interface used
|
|
|
|
|
** to \em provide this service, not to access it.
|
|
|
|
|
**
|
|
|
|
|
** @see gui::GuiFacade
|
|
|
|
|
** @see guifacade.cpp starting this service
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef GUI_DISPLAY_SERVICE_H
|
|
|
|
|
#define GUI_DISPLAY_SERVICE_H
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "include/display-facade.h"
|
|
|
|
|
#include "common/instancehandle.hpp"
|
|
|
|
|
#include "lib/singleton-ref.hpp"
|
2009-02-08 01:35:45 +01:00
|
|
|
#include "lib/scoped-ptrvect.hpp"
|
2009-02-01 00:43:21 +01:00
|
|
|
|
2009-02-06 22:52:06 +01:00
|
|
|
#include <glibmm.h>
|
2009-02-02 05:25:49 +01:00
|
|
|
#include <sigc++/sigc++.h>
|
2009-02-01 00:43:21 +01:00
|
|
|
#include <boost/noncopyable.hpp>
|
|
|
|
|
#include <string>
|
2009-02-02 05:25:49 +01:00
|
|
|
#include <vector>
|
2009-02-01 00:43:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace gui {
|
2009-02-02 05:25:49 +01:00
|
|
|
|
2009-02-01 00:43:21 +01:00
|
|
|
using std::string;
|
2009-02-02 05:25:49 +01:00
|
|
|
using std::vector;
|
2009-02-01 00:43:21 +01:00
|
|
|
using lumiera::Display;
|
2009-02-02 05:25:49 +01:00
|
|
|
using Glib::Dispatcher;
|
2009-02-01 00:43:21 +01:00
|
|
|
|
|
|
|
|
|
2009-02-02 05:25:49 +01:00
|
|
|
typedef sigc::slot<void, void*> FrameDestination;
|
|
|
|
|
typedef sigc::signal<void, void*> FrameSignal;
|
|
|
|
|
|
2009-02-01 00:43:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
|
* Actual implementation of a single displayer slot. Internally,
|
2009-02-02 05:25:49 +01:00
|
|
|
* it is connected via the Glib::Dispatcher for outputting frames
|
|
|
|
|
* to a viewer widget, which executes within the GTK event thread.
|
|
|
|
|
* @note must be created from the GTK event thread.
|
2009-02-01 00:43:21 +01:00
|
|
|
*/
|
|
|
|
|
class DisplayerSlot
|
2009-02-04 05:23:43 +01:00
|
|
|
: public lumiera_displaySlot,
|
|
|
|
|
boost::noncopyable
|
2009-02-01 00:43:21 +01:00
|
|
|
{
|
2009-02-02 05:25:49 +01:00
|
|
|
Dispatcher dispatcher_;
|
|
|
|
|
FrameSignal hasFrame_;
|
|
|
|
|
|
|
|
|
|
LumieraDisplayFrame currBuffer_;
|
|
|
|
|
|
2009-02-01 00:43:21 +01:00
|
|
|
|
|
|
|
|
public:
|
2009-02-02 05:25:49 +01:00
|
|
|
DisplayerSlot (FrameDestination const&) ;
|
2009-02-01 00:43:21 +01:00
|
|
|
|
|
|
|
|
/* Implementation-level API to be used by DisplayService */
|
|
|
|
|
|
2009-02-02 05:25:49 +01:00
|
|
|
/** receive a frame to be displayed */
|
|
|
|
|
inline void put (LumieraDisplayFrame);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
/** internal: activated via Dispatcher
|
|
|
|
|
* and running in GTK main thread */
|
|
|
|
|
void displayCurrentFrame();
|
|
|
|
|
|
2009-02-01 00:43:21 +01:00
|
|
|
};
|
|
|
|
|
|
2009-02-08 01:35:45 +01:00
|
|
|
typedef lib::ScopedPtrVect<DisplayerSlot> DisplayerTab;
|
2009-02-02 05:25:49 +01:00
|
|
|
|
2009-02-01 00:43:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
|
* Actual implementation of the DisplayService.
|
|
|
|
|
* Creating an instance of this class automatically
|
|
|
|
|
* registers the interface lumieraorg_Display with
|
|
|
|
|
* the Lumiera Interface/Plugin system and creates
|
|
|
|
|
* a forwarding proxy within the application core to
|
|
|
|
|
* route calls through this interface.
|
|
|
|
|
* \par
|
|
|
|
|
* In addition to the Display interface, this class
|
|
|
|
|
* implements an additional service for the GUI,
|
|
|
|
|
* allowing actually to set up display slots, which
|
|
|
|
|
* then can be handed out to client code in the
|
|
|
|
|
* course of the play process for outputting frames.
|
|
|
|
|
*/
|
|
|
|
|
class DisplayService
|
|
|
|
|
: boost::noncopyable
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string error_;
|
2009-02-02 05:25:49 +01:00
|
|
|
DisplayerTab slots_;
|
2009-02-01 00:43:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/* === Interface Lifecycle === */
|
|
|
|
|
|
|
|
|
|
typedef lumiera::InstanceHandle< LUMIERA_INTERFACE_INAME(lumieraorg_Display, 0)
|
|
|
|
|
, lumiera::Display
|
|
|
|
|
> ServiceInstanceHandle;
|
|
|
|
|
|
|
|
|
|
lib::SingletonRef<DisplayService> implInstance_;
|
|
|
|
|
ServiceInstanceHandle serviceInstance_;
|
|
|
|
|
|
2009-02-02 05:25:49 +01:00
|
|
|
|
2009-02-01 00:43:21 +01:00
|
|
|
public:
|
|
|
|
|
DisplayService();
|
2009-02-06 22:52:06 +01:00
|
|
|
~DisplayService() { }
|
2009-02-01 00:43:21 +01:00
|
|
|
|
|
|
|
|
|
2009-02-04 05:23:43 +01:00
|
|
|
/** open a new display, sending frames to the given output destination
|
|
|
|
|
* @return handle for this slot, can be used to start a play process.
|
|
|
|
|
* NULL handle in case of any error. */
|
|
|
|
|
static LumieraDisplaySlot setUp (FrameDestination const&);
|
2009-02-01 00:43:21 +01:00
|
|
|
|
2009-02-06 22:52:06 +01:00
|
|
|
|
|
|
|
|
/** prepare and the given slot for output
|
|
|
|
|
* @param doAllocate allocate when true, else release it
|
|
|
|
|
* @throw lumiera::error::Logic when already in use */
|
|
|
|
|
void allocate (LumieraDisplaySlot, bool doAllocate);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** resolve the given display slot handle to yield a ref
|
|
|
|
|
* to an actual implementation object. In order to be resolvable,
|
|
|
|
|
* the DisplayerSlot needs to be locked (=allocated) for output use. */
|
|
|
|
|
DisplayerSlot& resolve (LumieraDisplaySlot);
|
|
|
|
|
|
2009-02-01 00:43:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-02-02 05:25:49 +01:00
|
|
|
void
|
|
|
|
|
DisplayerSlot::put(LumieraDisplayFrame newFrame)
|
|
|
|
|
{
|
|
|
|
|
if (newFrame != currBuffer_)
|
|
|
|
|
{
|
|
|
|
|
currBuffer_ = newFrame;
|
|
|
|
|
dispatcher_.emit();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TRACE (render, "frame dropped?");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-02-01 00:43:21 +01:00
|
|
|
} // namespace gui
|
|
|
|
|
#endif
|