diff --git a/src/servers/app/AppServer.cpp b/src/servers/app/AppServer.cpp index 5a36860168..64a0572acb 100644 --- a/src/servers/app/AppServer.cpp +++ b/src/servers/app/AppServer.cpp @@ -24,31 +24,34 @@ // Description: main manager object for the app_server // //------------------------------------------------------------------------------ -#include #include -#include -#include +#include #include -#include - +#include #include #include -#include "AppServer.h" +#include +#include +#include + +#include "BitmapManager.h" #include "ColorSet.h" +#include "CursorManager.h" +#include "DefaultDecorator.h" +#include "Desktop.h" #include "DisplayDriver.h" +#include "FontServer.h" +#include "RegistrarDefs.h" +#include "RGBColor.h" +#include "RootLayer.h" #include "ServerApp.h" #include "ServerCursor.h" #include "ServerProtocol.h" #include "ServerWindow.h" -#include "DefaultDecorator.h" -#include "RGBColor.h" -#include "BitmapManager.h" -#include "CursorManager.h" #include "Utils.h" -#include "FontServer.h" -#include "Desktop.h" -#include "RootLayer.h" -#include + +#include "AppServer.h" + //#define DEBUG_KEYHANDLING //#define DEBUG_SERVER @@ -104,7 +107,7 @@ AppServer::AppServer(void) : if (fServerInputPort == B_NO_MORE_PORTS) debugger("app_server could not create input port"); - fAppList= new BList(0); + fAppList= new BList(); fQuittingServer= false; make_decorator= NULL; @@ -282,7 +285,7 @@ AppServer::LaunchInputServer() fISThreadID = B_ERROR; - while (find_thread("_roster_thread_") == B_NAME_NOT_FOUND && !fQuittingServer) { + while (find_thread(BPrivate::kRosterThreadName) == B_NAME_NOT_FOUND && !fQuittingServer) { snooze(250000); } @@ -295,7 +298,7 @@ AppServer::LaunchInputServer() if (fCursorArea < B_OK) fCursorArea = create_area("isCursor", (void**) &fCursorAddr, B_ANY_ADDRESS, B_PAGE_SIZE, B_FULL_LOCK, B_READ_AREA | B_WRITE_AREA); if (fCursorSem < B_OK) - fCursorSem = create_sem(0, "isSem"); + fCursorSem = create_sem(0, "isSem"); int32 arg_c = 1; char **arg_v = (char **)malloc(sizeof(char *) * (arg_c + 1)); @@ -309,8 +312,8 @@ AppServer::LaunchInputServer() free(arg_v[0]); int32 tmpbuf[2] = {fCursorSem, fCursorArea}; - int32 code = 0; - send_data(fISThreadID, code, (void *)tmpbuf, sizeof(tmpbuf)); + int32 code = 0; + send_data(fISThreadID, code, (void *)tmpbuf, sizeof(tmpbuf)); resume_thread(fISThreadID); setpgid(fISThreadID, 0); @@ -318,9 +321,9 @@ AppServer::LaunchInputServer() // we receive thread_id sender; - code = receive_data(&sender, (void *)tmpbuf, sizeof(tmpbuf)); - fISASPort = tmpbuf[0]; - fISPort = tmpbuf[1]; + code = receive_data(&sender, (void *)tmpbuf, sizeof(tmpbuf)); + fISASPort = tmpbuf[0]; + fISPort = tmpbuf[1]; // if at any time, one of these ports is error prone, it might mean input_server is gone // then relaunch input_server @@ -334,9 +337,9 @@ void AppServer::LaunchCursorThread() { // Spawn our cursor thread - fCursorThreadID = spawn_thread(CursorThread,"CursorThreadOfTheDeath", B_REAL_TIME_DISPLAY_PRIORITY - 1, this); + fCursorThreadID = spawn_thread(CursorThread, "CursorThreadOfTheDeath", B_REAL_TIME_DISPLAY_PRIORITY - 1, this); if (fCursorThreadID >= 0) - resume_thread(fCursorThreadID); + resume_thread(fCursorThreadID); } @@ -356,7 +359,7 @@ AppServer::CursorThread(void* data) while (acquire_sem(app->fCursorSem) == B_OK) { - p.y = *app->fCursorAddr & 0x7fff; + p.y = *app->fCursorAddr & 0x7fff; p.x = *app->fCursorAddr >> 15 & 0x7fff; desktop->GetDisplayDriver()->MoveCursorTo(p.x, p.y); diff --git a/src/servers/app/AppServer.h b/src/servers/app/AppServer.h index b8f7e56a85..44d3d127fc 100644 --- a/src/servers/app/AppServer.h +++ b/src/servers/app/AppServer.h @@ -67,7 +67,7 @@ private: BString fDecoratorName; - bool fQuittingServer; + volatile bool fQuittingServer; BList *fAppList; thread_id fPicassoThreadID; diff --git a/src/servers/app/LayerData.cpp b/src/servers/app/LayerData.cpp index d417923080..63bcf085ff 100644 --- a/src/servers/app/LayerData.cpp +++ b/src/servers/app/LayerData.cpp @@ -265,7 +265,7 @@ DrawData::SetFont(const ServerFont& font, uint32 flags) // face if (flags & B_FONT_FACE) fFont.SetFace(font.Face()); - // face + // flags if (flags & B_FONT_FLAGS) fFont.SetFlags(font.Flags()); } @@ -411,7 +411,7 @@ LayerData::PrintToStream() const printf("\t Flags: %lu\n", fFont.Flags()); } -// ReadFromLink +// ReadFontFromLink void LayerData::ReadFontFromLink(LinkMsgReader& link) { @@ -548,8 +548,7 @@ LayerData::WriteToLink(LinkMsgSender& link) const link.Attach((uint8)fAlphaSrcMode); link.Attach((uint8)fAlphaFncMode); link.Attach(fScale); - // TODO: bool, no? - link.Attach(!fFontAntiAliasing); + link.Attach(!fFontAntiAliasing); int32 clippingRectCount = fClippingRegion ? fClippingRegion->CountRects() : 0; link.Attach(clippingRectCount); diff --git a/src/servers/app/PNGDump.cpp b/src/servers/app/PNGDump.cpp index dc035fba1b..773836c4f4 100644 --- a/src/servers/app/PNGDump.cpp +++ b/src/servers/app/PNGDump.cpp @@ -72,7 +72,7 @@ printf("Couldn't create write struct\n"); printf("Couldn't create info struct\n"); #endif fclose(fp); - png_destroy_write_struct(&png_ptr, (png_infopp)NULL); + png_destroy_write_struct(&png_ptr, (png_infopp)NULL); return; } @@ -82,27 +82,30 @@ printf("Couldn't create info struct\n"); printf("Couldn't set jump\n"); #endif fclose(fp); - png_destroy_write_struct(&png_ptr, (png_infopp)NULL); + png_destroy_write_struct(&png_ptr, (png_infopp)NULL); return; } png_init_io(png_ptr, fp); - png_set_compression_level(png_ptr,Z_NO_COMPRESSION); +// png_set_compression_level(png_ptr, Z_NO_COMPRESSION); png_set_bgr(png_ptr); + + int32 width = bounds.IntegerWidth() + 1; + int32 height = bounds.IntegerHeight() + 1; - png_set_IHDR(png_ptr, info_ptr, bounds.IntegerWidth(), bounds.IntegerHeight(), 8, PNG_COLOR_TYPE_RGB_ALPHA, - PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + png_set_IHDR(png_ptr, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB_ALPHA, +// PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); png_write_info(png_ptr, info_ptr); - - png_byte *row_pointers[bounds.IntegerHeight()]; - png_byte *index=(png_byte*)bits; - for(int32 i=0;iDrawingBuffer(); - uint32 row = backBuffer->BytesPerRow() / 4; - for (int i = 0; i < fDisplayMode.virtual_height; i++) { - fwrite((uint32 *)backBuffer->Bits() + i * row, 4, row, output); - sync(); - } - fclose(output); - sync(); -#endif - + if (Lock()) { + RenderingBuffer* buffer = fGraphicsCard->DrawingBuffer(); + if (buffer) { + BRect bounds(0.0, 0.0, buffer->Width() - 1, buffer->Height() - 1); + // TODO: Don't assume B_RGBA32!! + SaveToPNG(path, bounds, B_RGBA32, + buffer->Bits(), + buffer->BitsLength(), + buffer->BytesPerRow()); + } + Unlock(); + } return true; }