From e2de64d6f1beb9e492daf5b886e19933c1fa41dd Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- mpeglib/lib/util/render/sdl/Makefile.am | 43 ++++++ mpeglib/lib/util/render/sdl/imageDeskSDL.cpp | 110 ++++++++++++++ mpeglib/lib/util/render/sdl/imageDeskSDL.h | 65 ++++++++ mpeglib/lib/util/render/sdl/sdlSurface.cpp | 219 +++++++++++++++++++++++++++ mpeglib/lib/util/render/sdl/sdlSurface.h | 78 ++++++++++ 5 files changed, 515 insertions(+) create mode 100644 mpeglib/lib/util/render/sdl/Makefile.am create mode 100644 mpeglib/lib/util/render/sdl/imageDeskSDL.cpp create mode 100644 mpeglib/lib/util/render/sdl/imageDeskSDL.h create mode 100644 mpeglib/lib/util/render/sdl/sdlSurface.cpp create mode 100644 mpeglib/lib/util/render/sdl/sdlSurface.h (limited to 'mpeglib/lib/util/render/sdl') diff --git a/mpeglib/lib/util/render/sdl/Makefile.am b/mpeglib/lib/util/render/sdl/Makefile.am new file mode 100644 index 00000000..1a4b85eb --- /dev/null +++ b/mpeglib/lib/util/render/sdl/Makefile.am @@ -0,0 +1,43 @@ +# player - Makefile.am + +INCLUDES = $(all_includes) + + +noinst_LTLIBRARIES = libutilsdl.la + +noinst_HEADERS = imageDeskSDL.h sdlSurface.h + +libutilsdl_la_SOURCES = imageDeskSDL.cpp sdlSurface.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mpeglib/lib/util/render/sdl/imageDeskSDL.cpp b/mpeglib/lib/util/render/sdl/imageDeskSDL.cpp new file mode 100644 index 00000000..b1ff9a7c --- /dev/null +++ b/mpeglib/lib/util/render/sdl/imageDeskSDL.cpp @@ -0,0 +1,110 @@ +/* + SDL surface output + Copyright (C) 2000 Martin Vogt + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation. + + For more information look at the file COPYRIGHT in this package + + */ + + +#include "imageDeskSDL.h" + +#ifdef SDL_WRAPPER + + +ImageDeskSDL::ImageDeskSDL() { + + this->surface=NULL; + this->rect=NULL; + imageMode=_IMAGE_NONE; + lSupport=true; + image=NULL; +} + + +ImageDeskSDL::~ImageDeskSDL() { + closeImage(); + cout << "SDL destry needed"<surface=(SDL_Surface*)xWindow; + this->rect=(SDL_Rect*)pic; +} + +int ImageDeskSDL::openImage(int imageMode) { + int w=rect->w; + int h=rect->h; + this->imageMode=imageMode; + /* Create a YV12 image (Y + V + U) */ + cout << "CreateYUVOverlay -s"<getWidth(); + int h=pic->getHeight(); + int size=w*h+(w*h)/2; + SDL_LockYUVOverlay(image); + memcpy(*((char**)image->pixels),pic->getLuminancePtr(),size); + SDL_UnlockYUVOverlay(image); + +} + + +void ImageDeskSDL::putImage(int w, int h) { + SDL_Rect dest; + dest.x=0; + dest.y=0; + dest.w=rect->w; + dest.h=rect->h; + if (imageMode & _IMAGE_RESIZE) { + dest.w = w; + dest.h = h; + } + + if (imageMode & _IMAGE_DOUBLE) { + dest.w*=2; + dest.h*=2; + } + SDL_DisplayYUVOverlay(image,&dest); + +} + +#endif + diff --git a/mpeglib/lib/util/render/sdl/imageDeskSDL.h b/mpeglib/lib/util/render/sdl/imageDeskSDL.h new file mode 100644 index 00000000..1bccb94a --- /dev/null +++ b/mpeglib/lib/util/render/sdl/imageDeskSDL.h @@ -0,0 +1,65 @@ +/* + SDL surface output + Copyright (C) 2000 Martin Vogt + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation. + + For more information look at the file COPYRIGHT in this package + + */ + + +#ifndef __IMAGEDESKSDL_H +#define __IMAGEDESKSDL_H + +#include "../imageBase.h" + + + +#ifndef SDL_WRAPPER + class ImageDeskSDL : public ImageBase { + }; +#endif + +#ifdef SDL_WRAPPER + +#if defined WIN32 +#include +#include +#else +#include +#include +#endif + +class ImageDeskSDL : public ImageBase { + + int lSupport; + SDL_Overlay *image; + + SDL_Surface* surface; + SDL_Rect* rect; + int imageMode; + + public: + ImageDeskSDL(); + ~ImageDeskSDL(); + + int support(); + void init(XWindow* xWindow, YUVPicture* pic=NULL); + + + int openImage(int imageMode); + int closeImage(); + + void ditherImage(YUVPicture* pic); + + void putImage(int w, int h); + + + +}; +#endif + +#endif diff --git a/mpeglib/lib/util/render/sdl/sdlSurface.cpp b/mpeglib/lib/util/render/sdl/sdlSurface.cpp new file mode 100644 index 00000000..86ef41bb --- /dev/null +++ b/mpeglib/lib/util/render/sdl/sdlSurface.cpp @@ -0,0 +1,219 @@ +/* + surface wrapper for SDL + Copyright (C) 2000 Martin Vogt + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation. + + For more information look at the file COPYRIGHT in this package + + */ + + + +#include "sdlSurface.h" + + +#ifdef SDL_WRAPPER + + +SDLSurface::SDLSurface() { + surface=NULL; + lOpen=false; + imageMode=_IMAGE_NONE; + lSDLInit=false; + imageDeskSDL=new ImageDeskSDL(); +} + + +SDLSurface::~SDLSurface() { + close(); + if (imageCurrent != NULL) { + imageCurrent->closeImage(); + delete imageCurrent; + // otherwise test of NULL will fail + imageCurrent = NULL; + } +} + + +int SDLSurface::isOpen() { + return lOpen; +} + +int SDLSurface::getImageMode() { + return imageMode; +} + +int SDLSurface::open(int width, int height,const char *title,bool border) { + cout << "SDL openImage:"<imageMode != _IMAGE_NONE) { + cout << "bad open error X11Surface::openImage"<imageMode=imageMode; + imageCurrent=NULL; + int w=getWidth(); + int h=getHeight(); + if(imageMode & _IMAGE_RESIZE) { + w=resize_rect.w; + h=resize_rect.h; + } + + if (imageMode & _IMAGE_DOUBLE) { + w=rect.w*2; + h=rect.h*2; + } + + if (imageMode & _IMAGE_DESK) { + if (imageDeskSDL->support()) { + imageCurrent=imageDeskSDL; + int video_flags = SDL_SWSURFACE; + video_flags |= SDL_ASYNCBLIT; + video_flags |= SDL_RESIZABLE; + if(surface) + SDL_FreeSurface(surface); + surface = SDL_SetVideoMode(w, h, video_bpp, video_flags); + + } + } + if (imageMode & _IMAGE_FULL) { + if (imageDeskSDL->support()) { + imageCurrent=imageDeskSDL; + int video_flags = SDL_FULLSCREEN; + video_flags |= SDL_ASYNCBLIT; + video_flags |= SDL_HWSURFACE; + if(surface) + SDL_FreeSurface(surface); + surface = SDL_SetVideoMode(w, h, video_bpp, video_flags); + } + } + if (imageCurrent != NULL) { + cout << "surface:"<init((XWindow*)surface,(YUVPicture*)&rect); + imageCurrent->openImage(imageMode); + } + return (imageCurrent != NULL); +} + + +int SDLSurface::closeImage() { + this->imageMode = _IMAGE_NONE; + if (imageCurrent != NULL) { + imageCurrent->closeImage(); + } + imageCurrent=NULL; + return true; +} + +int SDLSurface::checkEvent(int* newMode) { + int back=false; + SDL_Event event; + SDL_PollEvent(&event); + switch (event.type) { + case SDL_MOUSEBUTTONDOWN: { + int button=event.button.button; + if (button == 1) { + *newMode = imageMode ^ _IMAGE_DOUBLE; + back=true; + } + if (button == 3) { + *newMode = imageMode ^ _IMAGE_DESK ^ _IMAGE_FULL; + back=true; + } + break; + } + case SDL_VIDEORESIZE : { + resize_rect.w = event.resize.w; + resize_rect.h = event.resize.h; + *newMode = imageMode | _IMAGE_RESIZE; + back = true; + break; + } + + } + return back; +} + +int SDLSurface::dither(YUVPicture* pic) { + if (imageCurrent != NULL) { + imageCurrent->ditherImage(pic); + if(imageMode & _IMAGE_RESIZE) { + imageCurrent->putImage(resize_rect.w, resize_rect.h); + } else { + imageCurrent->putImage(rect.w, rect.h); + } + } + return true; +} + +void SDLSurface::sdlinit() { + if (lSDLInit == false) { + if (SDL_Init(SDL_INIT_VIDEO) < 0 ) { + fprintf(stderr, "Warning: Couldn't init SDL video: %s\n", + SDL_GetError()); + fprintf(stderr, "Will ignore video stream\n"); + exit(0); + } + atexit(SDL_Quit); + cout << "****************** SDL VIDEO System **********"<vfmt->BitsPerPixel; + imageMode=_IMAGE_NONE; + + imageCurrent=NULL; + } + lSDLInit=true; +} + +#endif diff --git a/mpeglib/lib/util/render/sdl/sdlSurface.h b/mpeglib/lib/util/render/sdl/sdlSurface.h new file mode 100644 index 00000000..aca5f293 --- /dev/null +++ b/mpeglib/lib/util/render/sdl/sdlSurface.h @@ -0,0 +1,78 @@ +/* + surface wrapper for SDL + Copyright (C) 2000 Martin Vogt + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation. + + For more information look at the file COPYRIGHT in this package + + */ + + + +#ifndef __SDLSURFACE_H +#define __SDLSURFACE_H + + +#include "../surface.h" +#include "imageDeskSDL.h" + + + +#ifndef SDL_WRAPPER + class SDLSurface : public Surface { + }; +#endif + +#ifdef SDL_WRAPPER +#if defined WIN32 +#include +#include +#else +#include +#include +#endif + + +class SDLSurface : public Surface { + + int lOpen; + int imageMode; + int lSDLInit; + int video_bpp; + SDL_Surface* surface; + SDL_Rect rect; + SDL_Rect resize_rect; + const SDL_VideoInfo *video_info; + + ImageBase* imageCurrent; + + ImageDeskSDL* imageDeskSDL; + + public: + SDLSurface(); + ~SDLSurface(); + + int isOpen(); + int open(int width, int height,const char *title, bool border=false); + int close(); + int getHeight(); + int getWidth(); + int getDepth(); + int getImageMode(); + int checkEvent(int* mode); + + int openImage(int imageMode, YUVPicture* pic = NULL); + int closeImage(); + int dither(YUVPicture* pic); + int putImage(YUVPicture* pic); + + + private: + void sdlinit(); +}; +#endif + +#endif -- cgit v1.2.1