~ubuntu-branches/ubuntu/oneiric/bombono-dvd/oneiric

« back to all changes in this revision

Viewing changes to src/mgui/project/thumbnail.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-11-04 11:46:25 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20101104114625-2tfaxma74eqggp5r
Tags: 0.8.0-0ubuntu1
* New upstream release (LP: #670193).
* Refresh 02_sparc.diff patch.
* Replace 05-boost_filesystem-link.patch with 05-fix_boost.patch, it fixes
  build failure with Boost <= 1.44.
* Bump Standards.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
// mgui/project/thumbnail.cpp
3
3
// This file is part of Bombono DVD project.
4
4
//
5
 
// Copyright (c) 2008-2009 Ilya Murav'jov
 
5
// Copyright (c) 2008-2010 Ilya Murav'jov
6
6
//
7
7
// This program is free software; you can redistribute it and/or modify
8
8
// it under the terms of the GNU General Public License as published by
52
52
        ptr::weak_intrusive<VideoMD> curVI;
53
53
                    Mpeg::FwdPlayer  player;
54
54
 
55
 
        BrowserCache() { SetOutputFormat(player, fofRGB); }
 
55
        BrowserCache() { RGBOpen(player); }
56
56
};
57
57
 
58
58
static Mpeg::FwdPlayer& OpenCachePlayer(VideoItem vmd)
61
61
    if( (cache.curVI.lock() != vmd) || !cache.player.IsOpened() )
62
62
    {
63
63
        cache.curVI = vmd;
64
 
        bool is_open = cache.player.Open(GetFilename(*vmd).c_str());
65
 
        ASSERT(is_open);
 
64
        CheckOpen(cache.player, GetFilename(*vmd));
66
65
    }
67
66
    return cache.player;
68
67
}
69
68
 
70
 
RefPtr<Gdk::Pixbuf> GetVideoFrame(VideoItem vmd, double time, const Point& sz)
71
 
{
72
 
    Mpeg::FwdPlayer& player = OpenCachePlayer(vmd);
73
 
    RefPtr<Gdk::Pixbuf> pix = CreatePixbuf(sz);
74
 
    return GetFrame(pix, time, player);
 
69
//RefPtr<Gdk::Pixbuf> GetVideoFrame(VideoItem vmd, double time, const Point& sz)
 
70
//{
 
71
//    Mpeg::FwdPlayer& player = OpenCachePlayer(vmd);
 
72
//    RefPtr<Gdk::Pixbuf> pix = CreatePixbuf(sz);
 
73
//    return GetFrame(pix, time, player);
 
74
//}
 
75
 
 
76
const double VIDEO_THUMB_TIME = 0.;
 
77
 
 
78
VideoStart GetVideoStart(MediaItem mi)
 
79
{
 
80
    VideoStart res;
 
81
 
 
82
    if( VideoItem vi = IsVideo(mi) )
 
83
    {
 
84
        res.first  = vi;
 
85
        res.second = VIDEO_THUMB_TIME;
 
86
    }
 
87
    else if( ChapterItem ci = IsChapter(mi) )
 
88
    {
 
89
        res.first  = ci->owner;
 
90
        res.second = ci->chpTime;
 
91
    }
 
92
    else
 
93
        ASSERT(0);
 
94
    return res;
 
95
}
 
96
 
 
97
VideoPE::VideoPE(VideoStart vs): plyr(OpenCachePlayer(vs.first)), time(vs.second) {}
 
98
 
 
99
static VideoPE* CreateVideoPE(Media& md)
 
100
{
 
101
    return new VideoPE(GetVideoStart(&md));
75
102
}
76
103
 
77
104
void PrimaryShotGetter::Visit(VideoMD& obj)
78
105
{
79
 
    const double VIDEO_THUMB_TIME = 0.;
80
 
    pixExt = new VideoPE(OpenCachePlayer(&obj), VIDEO_THUMB_TIME);
 
106
    pixExt = CreateVideoPE(obj);
81
107
}
82
108
 
83
109
void PrimaryShotGetter::Visit(VideoChapterMD& obj)
84
110
{
85
 
    pixExt = new VideoPE(OpenCachePlayer(obj.owner), obj.chpTime);
 
111
    pixExt = CreateVideoPE(obj);
86
112
}
87
113
 
88
114
void PrimaryShotGetter::Visit(ColorMD& obj)
132
158
void ThumbSizeCalcer::Visit(StillImageMD& obj)
133
159
{
134
160
    bool true_ = gdk_pixbuf_get_file_info(GetFilename(obj).c_str(), &sz.x, &sz.y);
135
 
    ASSERT( true_ );
 
161
    ASSERT_OR_UNUSED( true_ );
136
162
 
137
163
    // вычисляем размеры кэша
138
164
    sz = CalcProportionSize(sz, ORIG_ITEM_AREA);
251
277
 
252
278
RefPtr<Gdk::Pixbuf> GetCalcedShot(MediaItem mi)
253
279
{
254
 
    using namespace boost;
255
 
    return GetInteractiveLRS( lambda::bind(&GetCalcedShotImpl, mi) );
 
280
    return GetInteractiveLRS( bb::bind(&GetCalcedShotImpl, mi) );
256
281
}
257
282
 
258
283
void SetDirtyCacheShot(MediaItem mi)
303
328
static void FillPixbuf(RefPtr<Gdk::Pixbuf>& pix, RefPtr<Gdk::Pixbuf> src, bool read_only)
304
329
{
305
330
    if( pix )
306
 
    {
307
 
        Point sz = PixbufSize(src);
308
 
        if( sz == PixbufSize(pix) )
309
 
            src->copy_area(0, 0, sz.x, sz.y, pix, 0, 0);
310
 
        else    
311
 
            RGBA::Scale(pix, src);
312
 
    }
 
331
        RGBA::CopyOrScale(pix, src);
313
332
    else
314
333
        pix = PixbufSource(src, read_only).RWPixbuf();
315
334
}
365
384
    if( AData().FirstPlayItem() != mi )
366
385
        return;
367
386
    bool is_menu = IsMenu(mi);
368
 
    RefPtr<Gdk::Pixbuf> emblem = GetFactoryImage(is_menu ? "copy-n-paste/HelixPlayer_Activity-watch-listen/28.png" 
369
 
                                                         : "copy-n-paste/HelixPlayer_Activity-watch-listen/16.png");
370
 
    CheckEmblem(pix, emblem);
371
 
 
372
 
    // местоположение
373
 
    Point e_sz(PixbufSize(emblem));
374
 
    Point p_sz(PixbufSize(pix));
375
 
    Rect plc = RectASz(Point(2, is_menu ? (p_sz.y-e_sz.y)/2 : 2), e_sz);
376
 
    RGBA::AlphaComposite(pix, emblem, plc);
 
387
    RefPtr<Gdk::Pixbuf> emblem = GetCheckEmblem(pix, is_menu 
 
388
                                                ? "copy-n-paste/HelixPlayer_Activity-watch-listen/28.png" 
 
389
                                                : "copy-n-paste/HelixPlayer_Activity-watch-listen/16.png");
 
390
    RGBA::AlphaComposite(pix, emblem, Point(2, is_menu ? (pix->get_height() - emblem->get_height())/2 : 2));
377
391
}
378
392
 
379
393
} // namespace Project