mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 09:01:57 -05:00
Mac classic: Avoid allocating second offscreen framebuffer when possible
This commit is contained in:
parent
72ea74f27d
commit
e2a4fc1205
3 changed files with 15 additions and 26 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -120,6 +120,7 @@ TestResult.xml
|
||||||
[Rr]eleasePS/
|
[Rr]eleasePS/
|
||||||
dlldata.c
|
dlldata.c
|
||||||
|
|
||||||
|
# Mac classic
|
||||||
retro68scripts/
|
retro68scripts/
|
||||||
|
|
||||||
*_i.c
|
*_i.c
|
||||||
|
|
|
@ -18,6 +18,6 @@ resource 'SIZE' (-1) {
|
||||||
reserved,
|
reserved,
|
||||||
reserved,
|
reserved,
|
||||||
reserved,
|
reserved,
|
||||||
3072 * 1024,
|
3584 * 1024,
|
||||||
8192 * 1024
|
8192 * 1024
|
||||||
};
|
};
|
||||||
|
|
|
@ -329,16 +329,15 @@ cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* args) {
|
||||||
|
|
||||||
static GWorldPtr fb_world;
|
static GWorldPtr fb_world;
|
||||||
static PixMapHandle fb_pixmap;
|
static PixMapHandle fb_pixmap;
|
||||||
static int fb_stride;
|
|
||||||
static char* fb_bits;
|
|
||||||
|
|
||||||
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
||||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels");
|
if (!useGWorld) {
|
||||||
bmp->width = width;
|
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels");
|
||||||
bmp->height = height;
|
bmp->width = width;
|
||||||
if (!useGWorld) return;
|
bmp->height = height;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO bmp->scan0 should be the fb_world
|
|
||||||
QDErr err = NewGWorld(&fb_world, 32, &win->portRect, 0, 0, 0);
|
QDErr err = NewGWorld(&fb_world, 32, &win->portRect, 0, 0, 0);
|
||||||
if (err != noErr) Logger_Abort2(err, "Failed to allocate GWorld");
|
if (err != noErr) Logger_Abort2(err, "Failed to allocate GWorld");
|
||||||
|
|
||||||
|
@ -346,28 +345,17 @@ void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
||||||
if (!fb_pixmap) Logger_Abort("Failed to allocate pixmap");
|
if (!fb_pixmap) Logger_Abort("Failed to allocate pixmap");
|
||||||
|
|
||||||
LockPixels(fb_pixmap);
|
LockPixels(fb_pixmap);
|
||||||
fb_stride = (*fb_pixmap)->rowBytes & 0x3FFF;
|
int stride = (*fb_pixmap)->rowBytes & 0x3FFF;
|
||||||
fb_bits = (char*)GetPixBaseAddr(fb_pixmap);
|
|
||||||
|
bmp->scan0 = (BitmapCol*)GetPixBaseAddr(fb_pixmap);
|
||||||
|
bmp->width = stride >> 2;
|
||||||
|
bmp->height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DrawFramebufferBulk(Rect2D r, struct Bitmap* bmp) {
|
static void DrawFramebufferBulk(Rect2D r, struct Bitmap* bmp) {
|
||||||
GrafPtr thePort = (GrafPtr)win;
|
GrafPtr thePort = (GrafPtr)win;
|
||||||
BitMap* memBits;
|
BitMap* memBits = &((GrafPtr)fb_world)->portBits;
|
||||||
BitMap* winBits;
|
BitMap* winBits = &thePort->portBits;
|
||||||
|
|
||||||
for (int y = r.y; y < r.y + r.height; y++)
|
|
||||||
{
|
|
||||||
BitmapCol* src = Bitmap_GetRow(bmp, y);
|
|
||||||
uint32_t* dst = (uint32_t*)(fb_bits + fb_stride * y);
|
|
||||||
|
|
||||||
for (int x = r.x; x < r.x + r.width; x++)
|
|
||||||
{
|
|
||||||
dst[x] = src[x];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
memBits = &((GrafPtr)fb_world)->portBits;
|
|
||||||
winBits = &thePort->portBits;
|
|
||||||
|
|
||||||
Rect update;
|
Rect update;
|
||||||
update.left = r.x;
|
update.left = r.x;
|
||||||
|
|
Loading…
Reference in a new issue