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:
parent
d4045331c8
commit
151ebb14dd
@ -24,31 +24,34 @@
|
|||||||
// Description: main manager object for the app_server
|
// Description: main manager object for the app_server
|
||||||
//
|
//
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
#include <AppDefs.h>
|
|
||||||
#include <Accelerant.h>
|
#include <Accelerant.h>
|
||||||
#include <Entry.h>
|
#include <AppDefs.h>
|
||||||
#include <Path.h>
|
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <PortLink.h>
|
#include <Entry.h>
|
||||||
|
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include "AppServer.h"
|
#include <Path.h>
|
||||||
|
#include <PortLink.h>
|
||||||
|
#include <StopWatch.h>
|
||||||
|
|
||||||
|
#include "BitmapManager.h"
|
||||||
#include "ColorSet.h"
|
#include "ColorSet.h"
|
||||||
|
#include "CursorManager.h"
|
||||||
|
#include "DefaultDecorator.h"
|
||||||
|
#include "Desktop.h"
|
||||||
#include "DisplayDriver.h"
|
#include "DisplayDriver.h"
|
||||||
|
#include "FontServer.h"
|
||||||
|
#include "RegistrarDefs.h"
|
||||||
|
#include "RGBColor.h"
|
||||||
|
#include "RootLayer.h"
|
||||||
#include "ServerApp.h"
|
#include "ServerApp.h"
|
||||||
#include "ServerCursor.h"
|
#include "ServerCursor.h"
|
||||||
#include "ServerProtocol.h"
|
#include "ServerProtocol.h"
|
||||||
#include "ServerWindow.h"
|
#include "ServerWindow.h"
|
||||||
#include "DefaultDecorator.h"
|
|
||||||
#include "RGBColor.h"
|
|
||||||
#include "BitmapManager.h"
|
|
||||||
#include "CursorManager.h"
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "FontServer.h"
|
|
||||||
#include "Desktop.h"
|
#include "AppServer.h"
|
||||||
#include "RootLayer.h"
|
|
||||||
#include <StopWatch.h>
|
|
||||||
//#define DEBUG_KEYHANDLING
|
//#define DEBUG_KEYHANDLING
|
||||||
//#define DEBUG_SERVER
|
//#define DEBUG_SERVER
|
||||||
|
|
||||||
@ -104,7 +107,7 @@ AppServer::AppServer(void) :
|
|||||||
if (fServerInputPort == B_NO_MORE_PORTS)
|
if (fServerInputPort == B_NO_MORE_PORTS)
|
||||||
debugger("app_server could not create input port");
|
debugger("app_server could not create input port");
|
||||||
|
|
||||||
fAppList= new BList(0);
|
fAppList= new BList();
|
||||||
fQuittingServer= false;
|
fQuittingServer= false;
|
||||||
make_decorator= NULL;
|
make_decorator= NULL;
|
||||||
|
|
||||||
@ -282,7 +285,7 @@ AppServer::LaunchInputServer()
|
|||||||
|
|
||||||
fISThreadID = B_ERROR;
|
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);
|
snooze(250000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,7 +298,7 @@ AppServer::LaunchInputServer()
|
|||||||
if (fCursorArea < B_OK)
|
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);
|
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)
|
if (fCursorSem < B_OK)
|
||||||
fCursorSem = create_sem(0, "isSem");
|
fCursorSem = create_sem(0, "isSem");
|
||||||
|
|
||||||
int32 arg_c = 1;
|
int32 arg_c = 1;
|
||||||
char **arg_v = (char **)malloc(sizeof(char *) * (arg_c + 1));
|
char **arg_v = (char **)malloc(sizeof(char *) * (arg_c + 1));
|
||||||
@ -309,8 +312,8 @@ AppServer::LaunchInputServer()
|
|||||||
free(arg_v[0]);
|
free(arg_v[0]);
|
||||||
|
|
||||||
int32 tmpbuf[2] = {fCursorSem, fCursorArea};
|
int32 tmpbuf[2] = {fCursorSem, fCursorArea};
|
||||||
int32 code = 0;
|
int32 code = 0;
|
||||||
send_data(fISThreadID, code, (void *)tmpbuf, sizeof(tmpbuf));
|
send_data(fISThreadID, code, (void *)tmpbuf, sizeof(tmpbuf));
|
||||||
|
|
||||||
resume_thread(fISThreadID);
|
resume_thread(fISThreadID);
|
||||||
setpgid(fISThreadID, 0);
|
setpgid(fISThreadID, 0);
|
||||||
@ -318,9 +321,9 @@ AppServer::LaunchInputServer()
|
|||||||
// we receive
|
// we receive
|
||||||
|
|
||||||
thread_id sender;
|
thread_id sender;
|
||||||
code = receive_data(&sender, (void *)tmpbuf, sizeof(tmpbuf));
|
code = receive_data(&sender, (void *)tmpbuf, sizeof(tmpbuf));
|
||||||
fISASPort = tmpbuf[0];
|
fISASPort = tmpbuf[0];
|
||||||
fISPort = tmpbuf[1];
|
fISPort = tmpbuf[1];
|
||||||
|
|
||||||
// if at any time, one of these ports is error prone, it might mean input_server is gone
|
// if at any time, one of these ports is error prone, it might mean input_server is gone
|
||||||
// then relaunch input_server
|
// then relaunch input_server
|
||||||
@ -334,9 +337,9 @@ void
|
|||||||
AppServer::LaunchCursorThread()
|
AppServer::LaunchCursorThread()
|
||||||
{
|
{
|
||||||
// Spawn our cursor thread
|
// 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)
|
if (fCursorThreadID >= 0)
|
||||||
resume_thread(fCursorThreadID);
|
resume_thread(fCursorThreadID);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,7 +359,7 @@ AppServer::CursorThread(void* data)
|
|||||||
|
|
||||||
while (acquire_sem(app->fCursorSem) == B_OK) {
|
while (acquire_sem(app->fCursorSem) == B_OK) {
|
||||||
|
|
||||||
p.y = *app->fCursorAddr & 0x7fff;
|
p.y = *app->fCursorAddr & 0x7fff;
|
||||||
p.x = *app->fCursorAddr >> 15 & 0x7fff;
|
p.x = *app->fCursorAddr >> 15 & 0x7fff;
|
||||||
|
|
||||||
desktop->GetDisplayDriver()->MoveCursorTo(p.x, p.y);
|
desktop->GetDisplayDriver()->MoveCursorTo(p.x, p.y);
|
||||||
|
@ -67,7 +67,7 @@ private:
|
|||||||
|
|
||||||
BString fDecoratorName;
|
BString fDecoratorName;
|
||||||
|
|
||||||
bool fQuittingServer;
|
volatile bool fQuittingServer;
|
||||||
|
|
||||||
BList *fAppList;
|
BList *fAppList;
|
||||||
thread_id fPicassoThreadID;
|
thread_id fPicassoThreadID;
|
||||||
|
@ -265,7 +265,7 @@ DrawData::SetFont(const ServerFont& font, uint32 flags)
|
|||||||
// face
|
// face
|
||||||
if (flags & B_FONT_FACE)
|
if (flags & B_FONT_FACE)
|
||||||
fFont.SetFace(font.Face());
|
fFont.SetFace(font.Face());
|
||||||
// face
|
// flags
|
||||||
if (flags & B_FONT_FLAGS)
|
if (flags & B_FONT_FLAGS)
|
||||||
fFont.SetFlags(font.Flags());
|
fFont.SetFlags(font.Flags());
|
||||||
}
|
}
|
||||||
@ -411,7 +411,7 @@ LayerData::PrintToStream() const
|
|||||||
printf("\t Flags: %lu\n", fFont.Flags());
|
printf("\t Flags: %lu\n", fFont.Flags());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadFromLink
|
// ReadFontFromLink
|
||||||
void
|
void
|
||||||
LayerData::ReadFontFromLink(LinkMsgReader& link)
|
LayerData::ReadFontFromLink(LinkMsgReader& link)
|
||||||
{
|
{
|
||||||
@ -548,8 +548,7 @@ LayerData::WriteToLink(LinkMsgSender& link) const
|
|||||||
link.Attach<uint8>((uint8)fAlphaSrcMode);
|
link.Attach<uint8>((uint8)fAlphaSrcMode);
|
||||||
link.Attach<uint8>((uint8)fAlphaFncMode);
|
link.Attach<uint8>((uint8)fAlphaFncMode);
|
||||||
link.Attach<float>(fScale);
|
link.Attach<float>(fScale);
|
||||||
// TODO: bool, no?
|
link.Attach<bool>(!fFontAntiAliasing);
|
||||||
link.Attach<float>(!fFontAntiAliasing);
|
|
||||||
|
|
||||||
int32 clippingRectCount = fClippingRegion ? fClippingRegion->CountRects() : 0;
|
int32 clippingRectCount = fClippingRegion ? fClippingRegion->CountRects() : 0;
|
||||||
link.Attach<int32>(clippingRectCount);
|
link.Attach<int32>(clippingRectCount);
|
||||||
|
@ -72,7 +72,7 @@ printf("Couldn't create write struct\n");
|
|||||||
printf("Couldn't create info struct\n");
|
printf("Couldn't create info struct\n");
|
||||||
#endif
|
#endif
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
|
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,27 +82,30 @@ printf("Couldn't create info struct\n");
|
|||||||
printf("Couldn't set jump\n");
|
printf("Couldn't set jump\n");
|
||||||
#endif
|
#endif
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
|
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
png_init_io(png_ptr, fp);
|
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);
|
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_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_BASE, PNG_FILTER_TYPE_BASE);
|
||||||
|
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
|
||||||
|
|
||||||
png_write_info(png_ptr, info_ptr);
|
png_write_info(png_ptr, info_ptr);
|
||||||
|
|
||||||
png_byte *row_pointers[bounds.IntegerHeight()];
|
png_byte* row_pointers[height];
|
||||||
png_byte *index=(png_byte*)bits;
|
png_byte* index = (png_byte*)bits;
|
||||||
for(int32 i=0;i<bounds.IntegerHeight();i++)
|
for (int32 i = 0; i < height; i++) {
|
||||||
{
|
row_pointers[i] = index;
|
||||||
row_pointers[i]=index;
|
index += bytesperrow;
|
||||||
index+=bytesperrow;
|
|
||||||
}
|
}
|
||||||
png_write_image(png_ptr, row_pointers);
|
png_write_image(png_ptr, row_pointers);
|
||||||
png_write_end(png_ptr, info_ptr);
|
png_write_end(png_ptr, info_ptr);
|
||||||
|
@ -513,12 +513,12 @@ AccelerantHWInterface::AvailableHWAcceleration() const
|
|||||||
{
|
{
|
||||||
uint32 flags = 0;
|
uint32 flags = 0;
|
||||||
|
|
||||||
if (fAccScreenBlit)
|
/* if (fAccScreenBlit)
|
||||||
flags |= HW_ACC_COPY_REGION;
|
flags |= HW_ACC_COPY_REGION;
|
||||||
if (fAccFillRect)
|
if (fAccFillRect)
|
||||||
flags |= HW_ACC_FILL_REGION;
|
flags |= HW_ACC_FILL_REGION;
|
||||||
if (fAccInvertRect)
|
if (fAccInvertRect)
|
||||||
flags |= HW_ACC_INVERT_REGION;
|
flags |= HW_ACC_INVERT_REGION;*/
|
||||||
|
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "LayerData.h"
|
#include "LayerData.h"
|
||||||
#include "Painter.h"
|
#include "Painter.h"
|
||||||
|
#include "PNGDump.h"
|
||||||
#include "RenderingBuffer.h"
|
#include "RenderingBuffer.h"
|
||||||
|
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
@ -1192,34 +1193,18 @@ DisplayDriverPainter::SetMode(const display_mode &mode)
|
|||||||
bool
|
bool
|
||||||
DisplayDriverPainter::DumpToFile(const char *path)
|
DisplayDriverPainter::DumpToFile(const char *path)
|
||||||
{
|
{
|
||||||
#if 0
|
if (Lock()) {
|
||||||
// TODO: find out why this does not work
|
RenderingBuffer* buffer = fGraphicsCard->DrawingBuffer();
|
||||||
SaveToPNG( path,
|
if (buffer) {
|
||||||
BRect(0, 0, fDisplayMode.virtual_width - 1, fDisplayMode.virtual_height - 1),
|
BRect bounds(0.0, 0.0, buffer->Width() - 1, buffer->Height() - 1);
|
||||||
(color_space)fDisplayMode.space,
|
// TODO: Don't assume B_RGBA32!!
|
||||||
mFrameBufferConfig.frame_buffer,
|
SaveToPNG(path, bounds, B_RGBA32,
|
||||||
fDisplayMode.virtual_height * mFrameBufferConfig.bytes_per_row,
|
buffer->Bits(),
|
||||||
mFrameBufferConfig.bytes_per_row);*/
|
buffer->BitsLength(),
|
||||||
#else
|
buffer->BytesPerRow());
|
||||||
// TODO: remove this when SaveToPNG works properly
|
}
|
||||||
|
Unlock();
|
||||||
// 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
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user