Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: third_party/libva/va/x11/va_dricommon.c

Issue 10375035: Add libva to chromium third_party. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #include "va_dricommon.h"
2
3 // X error trap
4 static int x11_error_code = 0;
5 static int (*old_error_handler)(Display *, XErrorEvent *);
6
7 static int
8 error_handler(Display *dpy, XErrorEvent *error)
9 {
10 x11_error_code = error->error_code;
11 return 0;
12 }
13
14 static void
15 x11_trap_errors(void)
16 {
17 x11_error_code = 0;
18 old_error_handler = XSetErrorHandler(error_handler);
19 }
20
21 static int
22 x11_untrap_errors(void)
23 {
24 XSetErrorHandler(old_error_handler);
25 return x11_error_code;
26 }
27
28 static int
29 is_window(Display *dpy, Drawable drawable)
30 {
31 XWindowAttributes wattr;
32
33 x11_trap_errors();
34 XGetWindowAttributes(dpy, drawable, &wattr);
35 return x11_untrap_errors() == 0;
36 }
37
38 static struct dri_drawable *
39 do_drawable_hash(VADriverContextP ctx, XID drawable)
40 {
41 struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
42 int index = drawable % DRAWABLE_HASH_SZ;
43 struct dri_drawable *dri_drawable = dri_state->drawable_hash[index];
44
45 while (dri_drawable) {
46 if (dri_drawable->x_drawable == drawable)
47 return dri_drawable;
48 dri_drawable = dri_drawable->next;
49 }
50
51 dri_drawable = dri_state->createDrawable(ctx, drawable);
52 dri_drawable->x_drawable = drawable;
53 dri_drawable->is_window = is_window(ctx->native_dpy, drawable);
54 dri_drawable->next = dri_state->drawable_hash[index];
55 dri_state->drawable_hash[index] = dri_drawable;
56
57 return dri_drawable;
58 }
59
60 void
61 free_drawable(VADriverContextP ctx, struct dri_drawable* dri_drawable)
62 {
63 struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
64 int i = 0;
65
66 while (i++ < DRAWABLE_HASH_SZ) {
67 if (dri_drawable == dri_state->drawable_hash[i]) {
68 dri_state->destroyDrawable(ctx, dri_drawable);
69 dri_state->drawable_hash[i] = NULL;
70 }
71 }
72 }
73
74 void
75 free_drawable_hashtable(VADriverContextP ctx)
76 {
77 struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
78 int i;
79 struct dri_drawable *dri_drawable, *prev;
80
81 for (i = 0; i < DRAWABLE_HASH_SZ; i++) {
82 dri_drawable = dri_state->drawable_hash[i];
83
84 while (dri_drawable) {
85 prev = dri_drawable;
86 dri_drawable = prev->next;
87 dri_state->destroyDrawable(ctx, prev);
88 }
89
90 dri_state->drawable_hash[i] = NULL;
91 }
92 }
93
94 struct dri_drawable *
95 dri_get_drawable(VADriverContextP ctx, XID drawable)
96 {
97 return do_drawable_hash(ctx, drawable);
98 }
99
100 void
101 dri_swap_buffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
102 {
103 struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
104
105 dri_state->swapBuffer(ctx, dri_drawable);
106 }
107
108 union dri_buffer *
109 dri_get_rendering_buffer(VADriverContextP ctx, struct dri_drawable *dri_drawable )
110 {
111 struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
112
113 return dri_state->getRenderingBuffer(ctx, dri_drawable);
114 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698