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

Side by Side Diff: ports/xaos/nacl-ui-driver/ppapi.c

Issue 1491453003: Fix Xaos port (Closed) Base URL: https://chromium.googlesource.com/external/naclports.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « ports/xaos/build.sh ('k') | ports/xaos/nacl-ui-driver/ui_nacl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 #include "aconfig.h" 6 #include "aconfig.h"
7 7
8 /*includes */ 8 /*includes */
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <stdlib.h> 10 #include <stdlib.h>
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 /* it is now safe to use the video buffer */ 101 /* it is now safe to use the video buffer */
102 Video.dirty = 0; 102 Video.dirty = 0;
103 pthread_mutex_unlock(&Video.flush_mutex); 103 pthread_mutex_unlock(&Video.flush_mutex);
104 ScheduleScreenRefresh(); 104 ScheduleScreenRefresh();
105 } 105 }
106 106
107 void CopyImageDataToVideo(void* data) { 107 void CopyImageDataToVideo(void* data) {
108 pthread_mutex_lock(&Video.flush_mutex); 108 pthread_mutex_lock(&Video.flush_mutex);
109 Video.dirty = 1; 109 Video.dirty = 1;
110 memcpy(Video.image_data, data, Video.width * Video.height * BYTES_PER_PIXEL); 110 memcpy(Video.image_data, data, Video.width * Video.height * BYTES_PER_PIXEL);
111
112 /* Set alpha to 0xff. xaos generates zeros here */
113 int* pixels = (int*)Video.image_data;
114 int i;
115 for (i = 0; i < Video.width * Video.height; i++) {
116 pixels[i] |= 0xff000000;
117 }
118
111 /* do not let anybody write into video buffer while flush in progress*/ 119 /* do not let anybody write into video buffer while flush in progress*/
112 pthread_mutex_unlock(&Video.flush_mutex); 120 pthread_mutex_unlock(&Video.flush_mutex);
113 } 121 }
114 122
115 struct PP_CompletionCallback FlushCallback = {FlushCallbackFun, NULL}; 123 struct PP_CompletionCallback FlushCallback = {FlushCallbackFun, NULL};
116 124
117 void ScreenUpdateCallbackFun(void* user_data, int32_t result) { 125 void ScreenUpdateCallbackFun(void* user_data, int32_t result) {
118 if (!Video.dirty) { 126 if (!Video.dirty) {
119 ScheduleScreenRefresh(); 127 ScheduleScreenRefresh();
120 return; 128 return;
121 } 129 }
122 130
131 NaClLog(LOG_TRACE, "ScreenUpdateCallbackFun\n");
123 pthread_mutex_lock(&Video.flush_mutex); 132 pthread_mutex_lock(&Video.flush_mutex);
124 struct PP_Point top_left = PP_MakePoint(0, 0); 133 struct PP_Point top_left = PP_MakePoint(0, 0);
125 Global.if_graphics_2d->PaintImageData(Video.device, Video.image, &top_left, 134 Global.if_graphics_2d->PaintImageData(Video.device, Video.image, &top_left,
126 NULL); 135 NULL);
127 136
128 Global.if_graphics_2d->Flush(Video.device, FlushCallback); 137 Global.if_graphics_2d->Flush(Video.device, FlushCallback);
129 } 138 }
130 139
131 struct PP_CompletionCallback ScreenUpdateCallback = {ScreenUpdateCallbackFun, 140 struct PP_CompletionCallback ScreenUpdateCallback = {ScreenUpdateCallbackFun,
132 NULL}; 141 NULL};
133 142
134 static void InitEvents() { 143 static void InitEvents() {
135 NaClLog(LOG_INFO, "initialize event queue\n"); 144 NaClLog(LOG_INFO, "initialize event queue\n");
136 pthread_mutex_init(&EventQueue.mutex, NULL); 145 pthread_mutex_init(&EventQueue.mutex, NULL);
137 pthread_cond_init(&EventQueue.condvar, NULL); 146 pthread_cond_init(&EventQueue.condvar, NULL);
138 } 147 }
139 148
140 static void InitScreenRefresh(PP_Instance instance, 149 static void InitScreenRefresh(PP_Instance instance,
141 const struct PP_Size* size) { 150 const struct PP_Size* size) {
142 NaClLog(LOG_INFO, "initialize screen refresh\n"); 151 NaClLog(LOG_INFO, "initialize screen refresh %dx%d\n", size->width,
152 size->height);
143 /* NOTE: these limits are not tight but there seem to be some 153 /* NOTE: these limits are not tight but there seem to be some
144 not so well documented limitations inside xaos */ 154 not so well documented limitations inside xaos */
145 CHECK(size->width <= 640); 155 CHECK(size->width <= 640);
146 CHECK(size->height <= 480); 156 CHECK(size->height <= 480);
147 157
148 Video.width = size->width; 158 Video.width = size->width;
149 Video.height = size->height; 159 Video.height = size->height;
150 160
151 NaClLog(LOG_INFO, "create PPAPI graphics device\n"); 161 NaClLog(LOG_INFO, "create PPAPI graphics device\n");
152 Video.device = Global.if_graphics_2d->Create(instance, size, PP_FALSE); 162 Video.device = Global.if_graphics_2d->Create(instance, size, PP_TRUE);
153 CHECK(Video.device != 0); 163 CHECK(Video.device != 0);
154 NaClLog(LOG_INFO, "create PPAPI image"); 164 NaClLog(LOG_INFO, "create PPAPI image");
155 CHECK(Global.if_instance->BindGraphics(Global.instance, Video.device)); 165 CHECK(Global.if_instance->BindGraphics(Global.instance, Video.device));
156 Video.image = Global.if_image_data->Create( 166 Video.image = Global.if_image_data->Create(
157 instance, PP_IMAGEDATAFORMAT_BGRA_PREMUL, size, PP_TRUE); 167 instance, PP_IMAGEDATAFORMAT_BGRA_PREMUL, size, PP_TRUE);
158 CHECK(Video.image != 0); 168 CHECK(Video.image != 0);
159 NaClLog(LOG_INFO, "map image into shared memory\n"); 169 NaClLog(LOG_INFO, "map image into shared memory\n");
160 Video.image_data = (void*)Global.if_image_data->Map(Video.image); 170 Video.image_data = (void*)Global.if_image_data->Map(Video.image);
161 CHECK(Video.image_data != NULL); 171 CHECK(Video.image_data != NULL);
162 NaClLog(LOG_INFO, "map is %p\n", Video.image_data); 172 NaClLog(LOG_INFO, "map is %p\n", Video.image_data);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 Init(instance, &position.size); 235 Init(instance, &position.size);
226 } 236 }
227 237
228 static void DidChangeFocus(PP_Instance instance, PP_Bool has_focus) { 238 static void DidChangeFocus(PP_Instance instance, PP_Bool has_focus) {
229 NaClLog(LOG_INFO, "DidChangeFocus\n"); 239 NaClLog(LOG_INFO, "DidChangeFocus\n");
230 /* force a refresh */ 240 /* force a refresh */
231 Video.dirty = 1; 241 Video.dirty = 1;
232 } 242 }
233 243
234 static PP_Bool HandleInputEvent(PP_Instance instance, PP_Resource input_event) { 244 static PP_Bool HandleInputEvent(PP_Instance instance, PP_Resource input_event) {
235 NaClLog(LOG_INFO, "HandleInputEvent\n"); 245 NaClLog(LOG_TRACE, "HandleInputEvent\n");
236 if (!Global.if_mouse_input_event->IsMouseInputEvent(input_event)) { 246 if (!Global.if_mouse_input_event->IsMouseInputEvent(input_event)) {
237 return PP_FALSE; 247 return PP_FALSE;
238 } 248 }
239 249
240 // XaoS has problems with Buttons numbered higher than the right button 250 // XaoS has problems with Buttons numbered higher than the right button
241 if (Global.if_mouse_input_event->GetButton(input_event) > 2) { 251 if (Global.if_mouse_input_event->GetButton(input_event) > 2) {
242 return PP_FALSE; 252 return PP_FALSE;
243 } 253 }
244 254
245 struct PpapiEvent* event = (struct PpapiEvent*)malloc(sizeof *event); 255 struct PpapiEvent* event = (struct PpapiEvent*)malloc(sizeof *event);
246 event->type = Global.if_input_event->GetType(input_event); 256 event->type = Global.if_input_event->GetType(input_event);
247 event->button = Global.if_mouse_input_event->GetButton(input_event); 257 event->button = Global.if_mouse_input_event->GetButton(input_event);
248 event->position = Global.if_mouse_input_event->GetPosition(input_event); 258 event->position = Global.if_mouse_input_event->GetPosition(input_event);
249 event->clicks = Global.if_mouse_input_event->GetClickCount(input_event); 259 event->clicks = Global.if_mouse_input_event->GetClickCount(input_event);
250 260
251 pthread_mutex_lock(&EventQueue.mutex); 261 pthread_mutex_lock(&EventQueue.mutex);
252 if (EventQueue.num >= kMaxEvents) { 262 if (EventQueue.num >= kMaxEvents) {
253 NaClLog(LOG_ERROR, "dropping events because of overflow\n"); 263 NaClLog(LOG_ERROR, "dropping events because of overflow\n");
254 } else { 264 } else {
265 NaClLog(LOG_TRACE, "queue input event\n");
255 int head = (EventQueue.tail + EventQueue.num) % kMaxEvents; 266 int head = (EventQueue.tail + EventQueue.num) % kMaxEvents;
256 EventQueue.queue[head] = event; 267 EventQueue.queue[head] = event;
257 ++EventQueue.num; 268 ++EventQueue.num;
258 if (EventQueue.num >= kMaxEvents) 269 if (EventQueue.num >= kMaxEvents)
259 EventQueue.num -= kMaxEvents; 270 EventQueue.num -= kMaxEvents;
260 pthread_cond_signal(&EventQueue.condvar); 271 pthread_cond_signal(&EventQueue.condvar);
261 } 272 }
262 273
263 pthread_mutex_unlock(&EventQueue.mutex); 274 pthread_mutex_unlock(&EventQueue.mutex);
264 return PP_TRUE; 275 return PP_TRUE;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 if (0 == strncmp(PPP_INSTANCE_INTERFACE, interface_name, 350 if (0 == strncmp(PPP_INSTANCE_INTERFACE, interface_name,
340 strlen(PPP_INSTANCE_INTERFACE))) { 351 strlen(PPP_INSTANCE_INTERFACE))) {
341 return &GlobalInstanceInterface; 352 return &GlobalInstanceInterface;
342 } 353 }
343 if (0 == strncmp(PPP_INPUT_EVENT_INTERFACE, interface_name, 354 if (0 == strncmp(PPP_INPUT_EVENT_INTERFACE, interface_name,
344 strlen(PPP_INPUT_EVENT_INTERFACE))) { 355 strlen(PPP_INPUT_EVENT_INTERFACE))) {
345 return &GlobalInputEventInterface; 356 return &GlobalInputEventInterface;
346 } 357 }
347 return NULL; 358 return NULL;
348 } 359 }
OLDNEW
« no previous file with comments | « ports/xaos/build.sh ('k') | ports/xaos/nacl-ui-driver/ui_nacl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698