src/video/haiku/SDL_bframebuffer.cc
changeset 12082 09999a0e8f9a
parent 11811 5d94cb6b24d3
child 12201 8bdc4d340419
equal deleted inserted replaced
12081:277e57c09ff4 12082:09999a0e8f9a
    34 #ifdef __cplusplus
    34 #ifdef __cplusplus
    35 extern "C" {
    35 extern "C" {
    36 #endif
    36 #endif
    37 
    37 
    38 #ifndef DRAWTHREAD
    38 #ifndef DRAWTHREAD
    39 static int32 BE_UpdateOnce(SDL_Window *window);
    39 static int32 HAIKU_UpdateOnce(SDL_Window *window);
    40 #endif
    40 #endif
    41 
    41 
    42 static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) {
    42 static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) {
    43 	return ((SDL_BWin*)(window->driverdata));
    43 	return ((SDL_BWin*)(window->driverdata));
    44 }
    44 }
    45 
    45 
    46 static SDL_INLINE SDL_BApp *_GetBeApp() {
    46 static SDL_INLINE SDL_BApp *_GetBeApp() {
    47 	return ((SDL_BApp*)be_app);
    47 	return ((SDL_BApp*)be_app);
    48 }
    48 }
    49 
    49 
    50 int BE_CreateWindowFramebuffer(_THIS, SDL_Window * window,
    50 int HAIKU_CreateWindowFramebuffer(_THIS, SDL_Window * window,
    51                                        Uint32 * format,
    51                                        Uint32 * format,
    52                                        void ** pixels, int *pitch) {
    52                                        void ** pixels, int *pitch) {
    53 	SDL_BWin *bwin = _ToBeWin(window);
    53 	SDL_BWin *bwin = _ToBeWin(window);
    54 	BScreen bscreen;
    54 	BScreen bscreen;
    55 	if(!bscreen.IsValid()) {
    55 	if(!bscreen.IsValid()) {
    62 	bwin->LockBuffer();
    62 	bwin->LockBuffer();
    63 
    63 
    64 	/* format */
    64 	/* format */
    65 	display_mode bmode;
    65 	display_mode bmode;
    66 	bscreen.GetMode(&bmode);
    66 	bscreen.GetMode(&bmode);
    67 	int32 bpp = BE_ColorSpaceToBitsPerPixel(bmode.space);
    67 	int32 bpp = HAIKU_ColorSpaceToBitsPerPixel(bmode.space);
    68 	*format = BE_BPPToSDLPxFormat(bpp);
    68 	*format = HAIKU_BPPToSDLPxFormat(bpp);
    69 
    69 
    70 	/* Create the new bitmap object */
    70 	/* Create the new bitmap object */
    71 	BBitmap *bitmap = bwin->GetBitmap();
    71 	BBitmap *bitmap = bwin->GetBitmap();
    72 
    72 
    73 	if(bitmap) {
    73 	if(bitmap) {
    97 	return 0;
    97 	return 0;
    98 }
    98 }
    99 
    99 
   100 
   100 
   101 
   101 
   102 int BE_UpdateWindowFramebuffer(_THIS, SDL_Window * window,
   102 int HAIKU_UpdateWindowFramebuffer(_THIS, SDL_Window * window,
   103                                       const SDL_Rect * rects, int numrects) {
   103                                       const SDL_Rect * rects, int numrects) {
   104 	if(!window)
   104 	if(!window)
   105 		return 0;
   105 		return 0;
   106 
   106 
   107 	SDL_BWin *bwin = _ToBeWin(window);
   107 	SDL_BWin *bwin = _ToBeWin(window);
   110 	bwin->LockBuffer();
   110 	bwin->LockBuffer();
   111 	bwin->SetBufferDirty(true);
   111 	bwin->SetBufferDirty(true);
   112 	bwin->UnlockBuffer();
   112 	bwin->UnlockBuffer();
   113 #else
   113 #else
   114 	bwin->SetBufferDirty(true);
   114 	bwin->SetBufferDirty(true);
   115 	BE_UpdateOnce(window);
   115 	HAIKU_UpdateOnce(window);
   116 #endif
   116 #endif
   117 
   117 
   118 	return 0;
   118 	return 0;
   119 }
   119 }
   120 
   120 
   121 int32 BE_DrawThread(void *data) {
   121 int32 HAIKU_DrawThread(void *data) {
   122 	SDL_BWin *bwin = (SDL_BWin*)data;
   122 	SDL_BWin *bwin = (SDL_BWin*)data;
   123 	
   123 	
   124 	BScreen bscreen;
   124 	BScreen bscreen;
   125 	if(!bscreen.IsValid()) {
   125 	if(!bscreen.IsValid()) {
   126 		return -1;
   126 		return -1;
   179 	}
   179 	}
   180 	
   180 	
   181 	return B_OK;
   181 	return B_OK;
   182 }
   182 }
   183 
   183 
   184 void BE_DestroyWindowFramebuffer(_THIS, SDL_Window * window) {
   184 void HAIKU_DestroyWindowFramebuffer(_THIS, SDL_Window * window) {
   185 	SDL_BWin *bwin = _ToBeWin(window);
   185 	SDL_BWin *bwin = _ToBeWin(window);
   186 	
   186 	
   187 	bwin->LockBuffer();
   187 	bwin->LockBuffer();
   188 	
   188 	
   189 	/* Free and clear the window buffer */
   189 	/* Free and clear the window buffer */
   200  * This was written to test if certain errors were caused by threading issues.
   200  * This was written to test if certain errors were caused by threading issues.
   201  * The specific issues have since become rare enough that they may have been
   201  * The specific issues have since become rare enough that they may have been
   202  * solved, but I doubt it- they were pretty sporadic before now.
   202  * solved, but I doubt it- they were pretty sporadic before now.
   203  */
   203  */
   204 #ifndef DRAWTHREAD
   204 #ifndef DRAWTHREAD
   205 static int32 BE_UpdateOnce(SDL_Window *window) {
   205 static int32 HAIKU_UpdateOnce(SDL_Window *window) {
   206 	SDL_BWin *bwin = _ToBeWin(window);
   206 	SDL_BWin *bwin = _ToBeWin(window);
   207 	BScreen bscreen;
   207 	BScreen bscreen;
   208 	if(!bscreen.IsValid()) {
   208 	if(!bscreen.IsValid()) {
   209 		return -1;
   209 		return -1;
   210 	}
   210 	}