just a little cleanup, made PNG screenshots work

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12665 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2005-05-15 00:22:55 +00:00
parent d4045331c8
commit 151ebb14dd
6 changed files with 62 additions and 72 deletions

View File

@ -24,31 +24,34 @@
// Description: main manager object for the app_server
//
//------------------------------------------------------------------------------
#include <AppDefs.h>
#include <Accelerant.h>
#include <Entry.h>
#include <Path.h>
#include <AppDefs.h>
#include <Directory.h>
#include <PortLink.h>
#include <Entry.h>
#include <File.h>
#include <Message.h>
#include "AppServer.h"
#include <Path.h>
#include <PortLink.h>
#include <StopWatch.h>
#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 <StopWatch.h>
#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);

View File

@ -67,7 +67,7 @@ private:
BString fDecoratorName;
bool fQuittingServer;
volatile bool fQuittingServer;
BList *fAppList;
thread_id fPicassoThreadID;

View File

@ -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>((uint8)fAlphaSrcMode);
link.Attach<uint8>((uint8)fAlphaFncMode);
link.Attach<float>(fScale);
// TODO: bool, no?
link.Attach<float>(!fFontAntiAliasing);
link.Attach<bool>(!fFontAntiAliasing);
int32 clippingRectCount = fClippingRegion ? fClippingRegion->CountRects() : 0;
link.Attach<int32>(clippingRectCount);

View File

@ -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;i<bounds.IntegerHeight();i++)
{
row_pointers[i]=index;
index+=bytesperrow;
png_byte* row_pointers[height];
png_byte* index = (png_byte*)bits;
for (int32 i = 0; i < height; i++) {
row_pointers[i] = index;
index += bytesperrow;
}
png_write_image(png_ptr, row_pointers);
png_write_end(png_ptr, info_ptr);

View File

@ -513,12 +513,12 @@ AccelerantHWInterface::AvailableHWAcceleration() const
{
uint32 flags = 0;
if (fAccScreenBlit)
/* if (fAccScreenBlit)
flags |= HW_ACC_COPY_REGION;
if (fAccFillRect)
flags |= HW_ACC_FILL_REGION;
if (fAccInvertRect)
flags |= HW_ACC_INVERT_REGION;
flags |= HW_ACC_INVERT_REGION;*/
return flags;
}

View File

@ -30,6 +30,7 @@
#include "LayerData.h"
#include "Painter.h"
#include "PNGDump.h"
#include "RenderingBuffer.h"
#ifdef __HAIKU__
@ -1192,34 +1193,18 @@ DisplayDriverPainter::SetMode(const display_mode &mode)
bool
DisplayDriverPainter::DumpToFile(const char *path)
{
#if 0
// TODO: find out why this does not work
SaveToPNG( path,
BRect(0, 0, fDisplayMode.virtual_width - 1, fDisplayMode.virtual_height - 1),
(color_space)fDisplayMode.space,
mFrameBufferConfig.frame_buffer,
fDisplayMode.virtual_height * mFrameBufferConfig.bytes_per_row,
mFrameBufferConfig.bytes_per_row);*/
#else
// TODO: remove this when SaveToPNG works properly
// this does dump each line at a time to ensure that everything
// gets written even if we crash somewhere.
// it's a bit overkill, but works for now.
FILE *output = fopen(path, "w");
if (!output)
return false;
RenderingBuffer *backBuffer = fGraphicsCard->DrawingBuffer();
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;
}