~ubuntu-branches/ubuntu/quantal/vice/quantal

« back to all changes in this revision

Viewing changes to src/arch/unix/x11/gnome/gnomevideo.c

  • Committer: Bazaar Package Importer
  • Author(s): Zed Pobre
  • Date: 2005-03-27 13:06:04 UTC
  • mfrom: (4 hoary)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20050327130604-zodmv0i60dbbmcik
Tags: 1.16-3
Apply patch from Andreas Jochens <aj@andaco.de> to correct building on
AMD64 and GCC 4.x (closes: #300936)

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include <string.h>
33
33
 
34
34
#include "log.h"
 
35
#include "types.h"
35
36
#include "videoarch.h"
36
37
#include "video.h"
37
38
 
38
39
#include "ui.h"
39
40
#include "uiarch.h"
40
 
#include "utils.h"
 
41
#include "x11ui.h"
 
42
#ifdef HAVE_XVIDEO
 
43
#include "renderxv.h"
 
44
#endif
41
45
 
42
46
static log_t gnomevideo_log = LOG_ERR;
43
 
video_canvas_t *dangling_canvas = NULL; /* remember canvas after freeing the FB */
44
47
 
45
48
void video_init_arch(void)
46
49
{
50
53
extern GtkWidget *canvas;
51
54
extern GdkGC *app_gc;
52
55
 
53
 
inline void GDK_PUTIMAGE(Display *d, GdkPixmap *drawable, GdkGC *gc,
 
56
inline void GDK_PUTIMAGE(Display *d, GdkWindow *drawable, GdkGC *gc,
54
57
                         GdkImage *image, int src_x, int src_y,
55
58
                         int dest_x, int dest_y,
56
59
                         unsigned int width, unsigned int height, int b,
57
 
                         video_frame_buffer_t *fb, video_canvas_t *c)
 
60
                         void *dummy, video_canvas_t *c)
58
61
{
59
 
  gdk_draw_image(drawable, gc, fb->gdk_image, src_x, src_y,
 
62
  gdk_draw_image(drawable, gc, c->gdk_image, src_x, src_y,
60
63
                 dest_x, dest_y, width, height);
61
 
  gdk_window_clear_area(c->emuwindow->window, dest_x, dest_y, width, height);
62
64
 
63
65
  gdk_flush();
64
66
}
65
67
 
66
 
int video_frame_buffer_alloc(video_frame_buffer_t **ip, unsigned int width,
67
 
                             unsigned int height)
 
68
int video_arch_frame_buffer_alloc(video_canvas_t *canvas, unsigned int width,
 
69
                                  unsigned int height)
68
70
{
69
 
    int sizeofpixel = sizeof(PIXEL);
70
71
    GdkImageType typ;
71
 
    int depth;
72
 
    video_frame_buffer_t *i;
73
 
 
74
 
#ifdef VIDEO_REMOVE_2X
75
 
    width *= 2;
76
 
    height *= 2;
77
 
#endif
78
 
 
79
 
    i = (video_frame_buffer_t *)xmalloc(sizeof(video_frame_buffer_t));
80
 
    memset(i, 0, sizeof(video_frame_buffer_t));
81
 
    *ip = i;
82
 
 
83
 
    if (sizeof(PIXEL2) != sizeof(PIXEL) * 2 ||
84
 
        sizeof(PIXEL4) != sizeof(PIXEL) * 4) {
85
 
        log_error(gnomevideo_log, "PIXEL2 / PIXEL4 typedefs have wrong size.");
86
 
        return -1;
 
72
 
 
73
#ifdef HAVE_XVIDEO
 
74
    canvas->xv_image = NULL;
 
75
 
 
76
    if (canvas->videoconfig->hwscale
 
77
        && (canvas->videoconfig->rendermode == VIDEO_RENDER_PAL_1X1
 
78
            || canvas->videoconfig->rendermode == VIDEO_RENDER_PAL_2X2))
 
79
    {
 
80
        Display *display = x11ui_get_display_ptr();
 
81
        XShmSegmentInfo* shminfo = use_mitshm ? &canvas->xshm_info : NULL;
 
82
        
 
83
        if (!find_yuv_port(display, &canvas->xv_port, &canvas->xv_format)) {
 
84
          return -1;
 
85
        }
 
86
 
 
87
        if (!(canvas->xv_image = create_yuv_image(display, canvas->xv_port, canvas->xv_format, width, height, shminfo))) {
 
88
          return -1;
 
89
        }
 
90
 
 
91
        /* Copy data for architecture independent rendering. */
 
92
        canvas->yuv_image.width = canvas->xv_image->width;
 
93
        canvas->yuv_image.height = canvas->xv_image->height;
 
94
        canvas->yuv_image.data_size = canvas->xv_image->data_size;
 
95
        canvas->yuv_image.num_planes = canvas->xv_image->num_planes;
 
96
        canvas->yuv_image.pitches = canvas->xv_image->pitches;
 
97
        canvas->yuv_image.offsets = canvas->xv_image->offsets;
 
98
        canvas->yuv_image.data = canvas->xv_image->data;
 
99
 
 
100
        log_message(gnomevideo_log,
 
101
                    _("Successfully initialized using XVideo (%dx%d %.4s)."),
 
102
                    width, height, canvas->xv_format.label);
 
103
 
 
104
        return 0;
87
105
    }
88
 
 
89
 
    depth = ui_get_display_depth();
90
 
 
91
 
    /* Round up to 32-bit boundary. */
92
 
    width = (width + 3) & ~0x3;
93
 
 
94
 
#if VIDEO_DISPLAY_DEPTH == 0
95
 
    /* sizeof(PIXEL) is not always what we are using. I guess this should
96
 
       be checked from the XImage but I'm lazy... */
97
 
    if (depth > 8)
98
 
        sizeofpixel *= 2;
99
 
    if (depth > 16)
100
 
        sizeofpixel *= 2;
101
106
#endif
102
 
 
103
107
    typ = GDK_IMAGE_FASTEST;
104
 
    i->gdk_image = gdk_image_new(typ, visual, width, height);
105
 
    i->x_image = GDK_IMAGE_XIMAGE(i->gdk_image);
106
 
    if (!i->x_image)
 
108
    canvas->gdk_image = gdk_image_new(typ, visual, width, height);
 
109
    canvas->x_image = GDK_IMAGE_XIMAGE(canvas->gdk_image);
 
110
    if (!canvas->x_image)
107
111
        return -1;
108
112
 
109
 
    if (dangling_canvas)
110
 
    {
111
 
        /* reusage of existing canvas, so reallocate drawable */
112
 
        dangling_canvas->width = width;
113
 
        dangling_canvas->height = height;
114
 
        /* destroy the old pixmap here ?
115
 
          e.g.  gdk_window_destroy(GDK_WINDOW(i->canvas->drawable));
116
 
          FIXME!
117
 
        */
118
 
        i->canvas = dangling_canvas;
119
 
        ui_finish_canvas(dangling_canvas);
120
 
        dangling_canvas = NULL;
121
 
    } else {
122
 
        i->canvas = NULL;
123
 
    }
124
 
 
125
113
    video_refresh_func((void (*)(void))GDK_PUTIMAGE);
126
114
 
127
 
    if (video_convert_func(i, depth, width, height) < 0)
128
 
        return -1;
129
 
 
130
115
    log_message(gnomevideo_log,
131
116
                _("Successfully initialized video."));
132
117
 
133
 
#ifdef USE_XF86_DGA2_EXTENSIONS
134
 
    fullscreen_set_framebuffer(i);
135
 
#endif 
136
118
    return 0;
137
119
}
138
120
 
139
121
GC video_get_gc(void *not_used)
140
122
{
141
 
    return (GC) app_gc;
 
123
    return (GC)app_gc;
142
124
}
143
125
 
144
 
void video_add_handlers(ui_window_t w) 
 
126
void video_add_handlers(video_canvas_t *canvas) 
145
127
{
146
128
}
147
129
 
159
141
 
160
142
void ui_finish_canvas(video_canvas_t *c)
161
143
{
162
 
    int depth;
163
 
 
164
 
    depth = ui_get_display_depth();
165
 
 
166
 
    if (c->drawable)
167
 
        gdk_pixmap_unref(c->drawable);    
168
 
    
169
 
    c->drawable = gdk_pixmap_new(c->emuwindow->window, 
170
 
                                 c->width, c->height, depth);
171
 
    gdk_window_set_back_pixmap(c->emuwindow->window, 
172
 
                               c->drawable, 0);
 
144
    c->drawable = c->emuwindow->window;
173
145
}
174
146