]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/vout_window.cpp
ea380333275dd57d29221afae14ece4acd7814a7
[vlc] / modules / gui / skins2 / src / vout_window.cpp
1 /*****************************************************************************
2  * vout_window.cpp
3  *****************************************************************************
4  * Copyright (C) 2003 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #include "vout_window.hpp"
25 #include "vlcproc.hpp"
26 #include "os_factory.hpp"
27 #include "os_graphics.hpp"
28 #include "os_window.hpp"
29
30
31 VoutWindow::VoutWindow( intf_thread_t *pIntf, int left, int top,
32                         bool dragDrop, bool playOnDrop,
33                         GenericWindow &rParent ):
34     GenericWindow( pIntf, left, top, dragDrop, playOnDrop,
35                    &rParent ), m_pImage( NULL )
36 {
37 }
38
39
40 VoutWindow::~VoutWindow()
41 {
42     delete m_pImage;
43
44     // Get the VlcProc
45     VlcProc *pVlcProc = getIntf()->p_sys->p_vlcProc;
46
47     // Reparent the video output
48     if( pVlcProc && pVlcProc->isVoutUsed() )
49     {
50         pVlcProc->dropVout();
51     }
52 }
53
54
55 void VoutWindow::resize( int width, int height )
56 {
57     // Get the OSFactory
58     OSFactory *pOsFactory = OSFactory::instance( getIntf() );
59
60     // Recreate the image
61     delete m_pImage;
62     m_pImage = pOsFactory->createOSGraphics( width, height );
63     // Draw a black rectangle
64     m_pImage->fillRect( 0, 0, width, height, 0 );
65
66     // Resize the window
67     GenericWindow::resize( width, height );
68 }
69
70
71 void VoutWindow::refresh( int left, int top, int width, int height )
72 {
73     if( m_pImage )
74     {
75         // Get the VlcProc
76         VlcProc *pVlcProc = getIntf()->p_sys->p_vlcProc;
77
78         // Refresh only when there is no video!
79         if( pVlcProc && !pVlcProc->isVoutUsed() )
80         {
81             m_pImage->copyToWindow( *getOSWindow(), left, top,
82                                     width, height, left, top );
83         }
84     }
85 }
86