src/video/bwindow/SDL_bframebuffer.cc
changeset 5934 01531d8d1e01
parent 5933 5f8a7ebc88e5
child 5936 116b7457e73a
equal deleted inserted replaced
5933:5f8a7ebc88e5 5934:01531d8d1e01
    60 	int32 bpp = ColorSpaceToBitsPerPixel(bmode.space);
    60 	int32 bpp = ColorSpaceToBitsPerPixel(bmode.space);
    61 	*format = BPPToSDLPxFormat(bpp);
    61 	*format = BPPToSDLPxFormat(bpp);
    62 
    62 
    63 	/* Create the new bitmap object */
    63 	/* Create the new bitmap object */
    64 	BBitmap *bitmap = bwin->GetBitmap();
    64 	BBitmap *bitmap = bwin->GetBitmap();
       
    65 
    65 	if(bitmap) {
    66 	if(bitmap) {
    66 		delete bitmap;
    67 		delete bitmap;
    67 	}
    68 	}
    68 	bitmap = new BBitmap(bwin->Bounds(), (color_space)bmode.space,
    69 	bitmap = new BBitmap(bwin->Bounds(), (color_space)bmode.space,
    69 			false,	/* Views not accepted */
    70 			false,	/* Views not accepted */
    70 			true);	/* Contiguous memory required */
    71 			true);	/* Contiguous memory required */
       
    72 			
       
    73 	if(bitmap->InitCheck() != B_OK) {
       
    74 		SDL_SetError("Could not initialize back buffer!\n");
       
    75 		return -1;
       
    76 	}
       
    77 
       
    78 
    71 	bwin->SetBitmap(bitmap);
    79 	bwin->SetBitmap(bitmap);
    72 	
    80 	
    73 	/* Set the pixel pointer */
    81 	/* Set the pixel pointer */
    74 	*pixels = bitmap->Bits();
    82 	*pixels = bitmap->Bits();
    75 
    83 
   130 				/* Get addresses of the start of each clipping rectangle */
   138 				/* Get addresses of the start of each clipping rectangle */
   131 				int32 width = clips[i].right - clips[i].left + 1;
   139 				int32 width = clips[i].right - clips[i].left + 1;
   132 				int32 height = clips[i].bottom - clips[i].top + 1;
   140 				int32 height = clips[i].bottom - clips[i].top + 1;
   133 				bufferpx = bwin->GetBufferPx() + 
   141 				bufferpx = bwin->GetBufferPx() + 
   134 					clips[i].top * bufferPitch + clips[i].left * BPP;
   142 					clips[i].top * bufferPitch + clips[i].left * BPP;
   135 				windowpx = (uint8*)bitmap->Bits(); + 
   143 				windowpx = (uint8*)bitmap->Bits() + 
   136 					clips[i].top * windowPitch + clips[i].left * BPP -
   144 					clips[i].top * windowPitch + clips[i].left * BPP -
   137 					windowSub;
   145 					windowSub;
   138 
   146 
   139 				/* Copy each row of pixels from the window buffer into the frame
   147 				/* Copy each row of pixels from the window buffer into the frame
   140 				   buffer */
   148 				   buffer */
   141 				for(y = 0; y < height; ++y)
   149 				for(y = 0; y < height; ++y)
   142 				{
   150 				{
   143 					if(bwin->CanTrashWindowBuffer()) {
   151 					if(bwin->CanTrashWindowBuffer()) {
   144 						goto escape;	/* Break out before the buffer is killed */
   152 						goto escape;	/* Break out before the buffer is killed */
   145 					}
   153 					}
       
   154 //					printf("memcpy(0x%x, 0x%x, %i) ", bufferpx, windowpx, width * BPP);
   146 					memcpy(bufferpx, windowpx, width * BPP);
   155 					memcpy(bufferpx, windowpx, width * BPP);
   147 					bufferpx += bufferPitch;
   156 					bufferpx += bufferPitch;
   148 					windowpx += windowPitch;
   157 					windowpx += windowPitch;
   149 				}
   158 				}
       
   159 //				printf("\t-\t");
   150 			}
   160 			}
       
   161 //			printf("\n");
   151 			bwin->SetBufferDirty(false);
   162 			bwin->SetBufferDirty(false);
   152 escape:
   163 escape:
   153 			bwin->UnlockBuffer();
   164 			bwin->UnlockBuffer();
   154 		} else {
   165 		} else {
   155 			snooze(16000);
   166 			snooze(16000);