* Now calls BApplication::HideCursor() on creation and ShowCursor() when it's
disconnected (so that you can still just call ShowCursor() to have it back, in case you want that). * Rewrote WindowScreen.h. * Cleanup, removed unused variables, renamed private methods. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17349 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+93
-194
@@ -1,227 +1,126 @@
|
|||||||
/*******************************************************************************
|
/*
|
||||||
/
|
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
||||||
/ File: WindowScreen.h
|
* Distributed under the terms of the MIT License.
|
||||||
/
|
*/
|
||||||
/ Description: Client window class for direct screen access.
|
|
||||||
/
|
|
||||||
/ Copyright 1993-98, Be Incorporated, All Rights Reserved.
|
|
||||||
/
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _WINDOW_SCREEN_H
|
#ifndef _WINDOW_SCREEN_H
|
||||||
#define _WINDOW_SCREEN_H
|
#define _WINDOW_SCREEN_H
|
||||||
|
|
||||||
#include <BeBuild.h>
|
|
||||||
#include <Window.h>
|
|
||||||
#include <SupportDefs.h>
|
|
||||||
#include <OS.h>
|
|
||||||
#include <kernel/image.h>
|
|
||||||
#include <GraphicsCard.h>
|
|
||||||
#include <Accelerant.h>
|
#include <Accelerant.h>
|
||||||
|
#include <GraphicsCard.h>
|
||||||
|
#include <OS.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
#include <Window.h>
|
||||||
|
#include <kernel/image.h>
|
||||||
|
|
||||||
/* private struct */
|
|
||||||
typedef struct {
|
|
||||||
area_id memory_area;
|
|
||||||
area_id io_area;
|
|
||||||
char addon_path[64+B_FILE_NAME_LENGTH];
|
|
||||||
} _direct_screen_info_;
|
|
||||||
|
|
||||||
/* private typedef */
|
_IMPEXP_GAME void set_mouse_position(int32 x, int32 y);
|
||||||
typedef int32 (*_add_on_control_)(uint32,void *);
|
// Controls the mouse cursor position on screen
|
||||||
|
|
||||||
/* Global function, allowing to move the position of the mouse when the GameKit is in
|
|
||||||
control of the screen. */
|
|
||||||
_IMPEXP_GAME
|
|
||||||
void set_mouse_position(int32 x, int32 y);
|
|
||||||
|
|
||||||
/********************** WARNING - WARNING - WARNING ***********************************
|
|
||||||
This is the current version of WindowScreen. The main purpose of this object is to
|
|
||||||
establish a direct connexion between application and graphic driver, to increase
|
|
||||||
efficiency and abilities. The graphic driver architecture will overcome serious
|
|
||||||
changes in the next release, consequently this could only be a preview version of
|
|
||||||
the real WindowScreen API.
|
|
||||||
|
|
||||||
Nevertheless, compatibility will be insure in future releases FOR MOST OF THE API,
|
|
||||||
through the use of a compatibility library (the new game library having a name
|
|
||||||
different from "libgame.so"), or a compatibility class (the new WindowScreen class
|
|
||||||
using a different name). Part of the API for which compatibility will not be insure
|
|
||||||
after the Preview Release are specifically pointed out in the following declarations.
|
|
||||||
****************************************************************************************/
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
B_ENABLE_VIEW_DRAWING = 0x0001,
|
B_ENABLE_VIEW_DRAWING = 0x0001,
|
||||||
B_ENABLE_DEBUGGER = 0x0002
|
B_ENABLE_DEBUGGER = 0x0002
|
||||||
};
|
};
|
||||||
|
|
||||||
class BWindowScreen : public BWindow {
|
class BWindowScreen : public BWindow {
|
||||||
public:
|
public:
|
||||||
BWindowScreen(const char *title, uint32 space, status_t *error,
|
BWindowScreen(const char* title, uint32 space,
|
||||||
bool debug_enable = false);
|
status_t* _error, bool debugMode = false);
|
||||||
BWindowScreen(const char *title, uint32 space, uint32 attributes,
|
BWindowScreen(const char* title, uint32 space,
|
||||||
status_t *error);
|
uint32 attributes, status_t* _error);
|
||||||
virtual ~BWindowScreen();
|
virtual ~BWindowScreen();
|
||||||
|
|
||||||
virtual void Quit();
|
virtual void Quit();
|
||||||
virtual void ScreenConnected(bool active);
|
virtual void ScreenConnected(bool active);
|
||||||
void Disconnect();
|
void Disconnect();
|
||||||
|
|
||||||
virtual void WindowActivated(bool active);
|
virtual void WindowActivated(bool active);
|
||||||
virtual void WorkspaceActivated(int32 ws, bool state);
|
virtual void WorkspaceActivated(int32 workspace, bool active);
|
||||||
virtual void ScreenChanged(BRect screen_size, color_space depth);
|
virtual void ScreenChanged(BRect screenSize, color_space depth);
|
||||||
|
|
||||||
virtual void Hide();
|
virtual void Hide();
|
||||||
virtual void Show();
|
virtual void Show();
|
||||||
|
|
||||||
void SetColorList(rgb_color *list,int32 first_index = 0,int32 last_index = 255);
|
void SetColorList(rgb_color* list, int32 firstIndex = 0,
|
||||||
status_t SetSpace(uint32 space);
|
int32 lastIndex = 255);
|
||||||
|
status_t SetSpace(uint32 space);
|
||||||
|
|
||||||
bool CanControlFrameBuffer();
|
bool CanControlFrameBuffer();
|
||||||
status_t SetFrameBuffer(int32 width, int32 height);
|
status_t SetFrameBuffer(int32 width, int32 height);
|
||||||
status_t MoveDisplayArea(int32 x, int32 y);
|
status_t MoveDisplayArea(int32 x, int32 y);
|
||||||
|
|
||||||
void *IOBase(); // Not supported anymore. It always returns NULL
|
rgb_color* ColorList();
|
||||||
|
frame_buffer_info* FrameBufferInfo();
|
||||||
|
graphics_card_hook CardHookAt(int32 index);
|
||||||
|
graphics_card_info* CardInfo();
|
||||||
|
|
||||||
rgb_color *ColorList();
|
void RegisterThread(thread_id thread);
|
||||||
frame_buffer_info *FrameBufferInfo();
|
virtual void SuspensionHook(bool active);
|
||||||
graphics_card_hook CardHookAt(int32 index);
|
void Suspend(char* label);
|
||||||
graphics_card_info *CardInfo();
|
|
||||||
|
|
||||||
/******************************* Debugger API Notice ********************************
|
private:
|
||||||
Those three calls, and the debug_enable flag in the constructor, have been added to
|
virtual status_t Perform(perform_code d, void* arg);
|
||||||
help debugging a WindowScreen application without a cross-developement platform or
|
|
||||||
the use of serial debug output.
|
|
||||||
|
|
||||||
To use them, you need to :
|
|
||||||
- enable the debug mode by setting the debug_enable flag of the constructor to "true".
|
|
||||||
- register all threads that could be accessing the screen directly at any time. To do
|
|
||||||
that, call RegisterThread after spawning the new thread and before resuming
|
|
||||||
it (you should never draw from the Window thread itself, neither register it).
|
|
||||||
- launch your application from Terminal. The GameKit will first swicth to another
|
|
||||||
workspace before opening the WindowScreen. If you launch from workspace 0 [Alt-F1],
|
|
||||||
it will choose the workspace 1 [Alt-F2]. For any other workspace, it will choose
|
|
||||||
the previous one (for example, for workspace 3 (Alt-F4), it will choose workspace 2
|
|
||||||
[Alt-F3]).
|
|
||||||
|
|
||||||
Then :
|
|
||||||
- You can use printf(...) anywhere to display informations that will be logged in the
|
|
||||||
Terminal window. You can go back to the Terminal Window at any time (using the
|
|
||||||
correct Alt-F?? key). Switching workspace will automatically suspend all the thread
|
|
||||||
you registered and save the graphic context. Switching back to the WindowScreen
|
|
||||||
workspace will restore everything and resume your application.
|
|
||||||
- If you need to save and restore more states when your application is suspended and
|
|
||||||
resumed, you can overwrite the ForceSwitchForDebug() method. This function is called
|
|
||||||
with active == true just after suspending your app, and active == false just before
|
|
||||||
resuming it.
|
|
||||||
- You can suspend your application by calling the Debugger() method. This will also
|
|
||||||
switch to the Terminal workspace. Then you can resume by just switchng back to the
|
|
||||||
WindowScreen workspace (using the good Alt-F?? key). It's better not to call Debugger()
|
|
||||||
with the WindowScreen locked.
|
|
||||||
|
|
||||||
In case of crash :
|
|
||||||
- Use the safety short-cut : All the left modifiers (Ctrl, Shift, Option, Command, Alt
|
|
||||||
or equivalents) of your keyboard and F12. That should send you back to 640x480, and
|
|
||||||
the debugger terminal should be visible (and usable) if any.
|
|
||||||
- Then, you can also switch to your Terminal workspace to check the last printf infos.
|
|
||||||
- After you got (we hope) more information about your (or our :-) bug, quit the debugger
|
|
||||||
window. Then you should be able to change your code and run your application again.
|
|
||||||
In any case, check the Error() function immediately after the WindowScreen constructor.
|
|
||||||
A bad error code will mean that the GameKit is in a inconsistent state, and then you
|
|
||||||
have better to reboot your machine. If you don't wnat to reboot, you can also try to
|
|
||||||
run your application in a different workspace.
|
|
||||||
|
|
||||||
It's far to be perfect, but we hope it will still help.
|
|
||||||
|
|
||||||
The Debug API will not be support after the Preview Release (replaced by the debug
|
|
||||||
API in the new WindowScreen class).
|
|
||||||
***************************************************************************************/
|
|
||||||
void RegisterThread(thread_id id);
|
|
||||||
virtual void SuspensionHook(bool active);
|
|
||||||
void Suspend(char *label);
|
|
||||||
|
|
||||||
|
|
||||||
virtual status_t Perform(perform_code d, void *arg);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
typedef BWindow inherited;
|
|
||||||
|
|
||||||
virtual void _ReservedWindowScreen1();
|
|
||||||
virtual void _ReservedWindowScreen2();
|
|
||||||
virtual void _ReservedWindowScreen3();
|
|
||||||
virtual void _ReservedWindowScreen4();
|
|
||||||
|
|
||||||
BWindowScreen();
|
|
||||||
BWindowScreen(BWindowScreen &);
|
|
||||||
BWindowScreen &operator=(BWindowScreen &);
|
|
||||||
|
|
||||||
char _unused;
|
|
||||||
char space_mode;
|
|
||||||
bool direct_enable;
|
|
||||||
bool fWorkState;
|
|
||||||
bool fWindowState;
|
|
||||||
bool fActivateState;
|
|
||||||
int32 fLockState;
|
|
||||||
int32 fScreenIndex;
|
|
||||||
|
|
||||||
display_mode *fOldDisplayMode;
|
|
||||||
display_mode *fDisplayMode;
|
|
||||||
uint32 space0;
|
|
||||||
sem_id fActivateSem;
|
|
||||||
sem_id fDebugSem;
|
|
||||||
image_id fAddonImage;
|
|
||||||
|
|
||||||
rgb_color fColorList[256];
|
|
||||||
GetAccelerantHook fGetAccelerantHook;
|
|
||||||
graphics_card_info fCardInfo;
|
|
||||||
|
|
||||||
graphics_card_hook hooks[B_HOOK_COUNT];
|
|
||||||
_direct_screen_info_ info;
|
|
||||||
frame_buffer_info fFrameBufferInfo;
|
|
||||||
|
|
||||||
char *fDebugBuffer;
|
|
||||||
bool fDebugState;
|
|
||||||
bool fDebugFirst;
|
|
||||||
int32 fDebugListCount;
|
|
||||||
int32 fDebugWorkspace;
|
|
||||||
thread_id *fDebugList;
|
|
||||||
|
|
||||||
uint32 fAttributes;
|
|
||||||
uint32 fModeCount;
|
|
||||||
display_mode *fModeList;
|
|
||||||
|
|
||||||
engine_token *fEngineToken;
|
|
||||||
wait_engine_idle m_wei;
|
|
||||||
acquire_engine m_ae;
|
|
||||||
release_engine m_re;
|
|
||||||
fill_rectangle fill_rect;
|
|
||||||
screen_to_screen_blit blit_rect;
|
|
||||||
screen_to_screen_transparent_blit trans_blit_rect;
|
|
||||||
screen_to_screen_scaled_filtered_blit scaled_filtered_blit_rect;
|
|
||||||
|
|
||||||
uint32 _reserved_[24];
|
|
||||||
|
|
||||||
static BRect CalcFrame(int32 index, int32 space, display_mode *dmode);
|
|
||||||
status_t InitData(uint32 space, uint32 attributes);
|
|
||||||
status_t SetActiveState(int32 state);
|
|
||||||
status_t SetupAccelerantHooks(bool enable);
|
|
||||||
status_t GetCardInfo();
|
|
||||||
void Suspend();
|
|
||||||
void Resume();
|
|
||||||
status_t GetModeFromSpace(uint32 space, display_mode *dmode);
|
|
||||||
status_t InitClone();
|
|
||||||
status_t AssertDisplayMode(display_mode *dmode);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
void* IOBase();
|
||||||
|
// deprecated API, always returns NULL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
virtual void _ReservedWindowScreen1();
|
||||||
|
virtual void _ReservedWindowScreen2();
|
||||||
|
virtual void _ReservedWindowScreen3();
|
||||||
|
virtual void _ReservedWindowScreen4();
|
||||||
|
|
||||||
|
// not implemented:
|
||||||
|
BWindowScreen();
|
||||||
|
BWindowScreen(BWindowScreen& other);
|
||||||
|
BWindowScreen &operator=(BWindowScreen& other);
|
||||||
|
|
||||||
|
status_t _InitData(uint32 space, uint32 attributes);
|
||||||
|
status_t _SetActiveState(int32 state);
|
||||||
|
status_t _SetupAccelerantHooks(bool enable);
|
||||||
|
status_t _GetCardInfo();
|
||||||
|
void _Suspend();
|
||||||
|
void _Resume();
|
||||||
|
status_t _GetModeFromSpace(uint32 space, display_mode* mode);
|
||||||
|
status_t _InitClone();
|
||||||
|
status_t _AssertDisplayMode(display_mode* mode);
|
||||||
|
|
||||||
|
uint16 _reserved0;
|
||||||
|
bool _reserved1;
|
||||||
|
bool fWorkState;
|
||||||
|
bool fWindowState;
|
||||||
|
bool fActivateState;
|
||||||
|
int32 fLockState;
|
||||||
|
int32 fWorkspaceIndex;
|
||||||
|
|
||||||
|
display_mode* fOriginalDisplayMode;
|
||||||
|
display_mode* fDisplayMode;
|
||||||
|
sem_id fActivateSem;
|
||||||
|
sem_id fDebugSem;
|
||||||
|
image_id fAddonImage;
|
||||||
|
uint32 fAttributes;
|
||||||
|
|
||||||
|
rgb_color fPalette[256];
|
||||||
|
|
||||||
|
graphics_card_info fCardInfo;
|
||||||
|
frame_buffer_info fFrameBufferInfo;
|
||||||
|
|
||||||
|
char* fDebugFrameBuffer;
|
||||||
|
bool fDebugState;
|
||||||
|
bool fDebugFirst;
|
||||||
|
int32 fDebugWorkspace;
|
||||||
|
int32 fDebugThreadCount;
|
||||||
|
thread_id* fDebugThreads;
|
||||||
|
|
||||||
|
uint32 fModeCount;
|
||||||
|
display_mode* fModeList;
|
||||||
|
|
||||||
|
GetAccelerantHook fGetAccelerantHook;
|
||||||
|
wait_engine_idle fWaitEngineIdle;
|
||||||
|
|
||||||
|
uint32 _reserved[162];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _WINDOW_SCREEN_H
|
||||||
|
|||||||
+107
-100
@@ -1,9 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2006,
|
* Copyright 2002-2006, Haiku. All Rights Reserved.
|
||||||
* Marcus Overhagen,
|
* Copyright 2002-2005,
|
||||||
* Stefano Ceccherini ([email protected]),
|
* Marcus Overhagen,
|
||||||
* Carwyn Jones (tur[email protected])
|
* Stefano Ceccherini (bur[email protected]),
|
||||||
* All rights reserved.
|
* Carwyn Jones ([email protected])
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -288,7 +290,7 @@ BWindowScreen::BWindowScreen(const char *title, uint32 space,
|
|||||||
if (debug_enable)
|
if (debug_enable)
|
||||||
attributes |= B_ENABLE_DEBUGGER;
|
attributes |= B_ENABLE_DEBUGGER;
|
||||||
|
|
||||||
status_t status = InitData(space, attributes);
|
status_t status = _InitData(space, attributes);
|
||||||
if (error)
|
if (error)
|
||||||
*error = status;
|
*error = status;
|
||||||
}
|
}
|
||||||
@@ -301,7 +303,7 @@ BWindowScreen::BWindowScreen(const char *title, uint32 space,
|
|||||||
| B_NOT_ZOOMABLE | B_NOT_MOVABLE | B_NOT_RESIZABLE, B_CURRENT_WORKSPACE)
|
| B_NOT_ZOOMABLE | B_NOT_MOVABLE | B_NOT_RESIZABLE, B_CURRENT_WORKSPACE)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
status_t status = InitData(space, attributes);
|
status_t status = _InitData(space, attributes);
|
||||||
if (error)
|
if (error)
|
||||||
*error = status;
|
*error = status;
|
||||||
}
|
}
|
||||||
@@ -321,7 +323,7 @@ BWindowScreen::~BWindowScreen()
|
|||||||
activate_workspace(fDebugWorkspace);
|
activate_workspace(fDebugWorkspace);
|
||||||
|
|
||||||
free(fDisplayMode);
|
free(fDisplayMode);
|
||||||
free(fOldDisplayMode);
|
free(fOriginalDisplayMode);
|
||||||
free(fModeList);
|
free(fModeList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,8 +351,10 @@ BWindowScreen::Disconnect()
|
|||||||
if (fLockState == 1) {
|
if (fLockState == 1) {
|
||||||
if (fDebugState)
|
if (fDebugState)
|
||||||
fDebugFirst = true;
|
fDebugFirst = true;
|
||||||
SetActiveState(0);
|
_SetActiveState(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
be_app->ShowCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -359,8 +363,8 @@ BWindowScreen::WindowActivated(bool active)
|
|||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
fWindowState = active;
|
fWindowState = active;
|
||||||
if(active && fLockState == 0 && fWorkState)
|
if (active && fLockState == 0 && fWorkState)
|
||||||
SetActiveState(1);
|
_SetActiveState(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -371,14 +375,14 @@ BWindowScreen::WorkspaceActivated(int32 ws, bool state)
|
|||||||
fWorkState = state;
|
fWorkState = state;
|
||||||
if (state) {
|
if (state) {
|
||||||
if (fLockState == 0 && fWindowState) {
|
if (fLockState == 0 && fWindowState) {
|
||||||
SetActiveState(1);
|
_SetActiveState(1);
|
||||||
if (!IsHidden()) {
|
if (!IsHidden()) {
|
||||||
Activate(true);
|
Activate(true);
|
||||||
WindowActivated(true);
|
WindowActivated(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (fLockState)
|
} else if (fLockState)
|
||||||
SetActiveState(0);
|
_SetActiveState(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -393,6 +397,7 @@ void
|
|||||||
BWindowScreen::Hide()
|
BWindowScreen::Hide()
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
Disconnect();
|
Disconnect();
|
||||||
BWindow::Hide();
|
BWindow::Hide();
|
||||||
}
|
}
|
||||||
@@ -402,10 +407,13 @@ void
|
|||||||
BWindowScreen::Show()
|
BWindowScreen::Show()
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
BWindow::Show();
|
BWindow::Show();
|
||||||
|
|
||||||
if (!fActivateState) {
|
if (!fActivateState) {
|
||||||
release_sem(fActivateSem);
|
release_sem(fActivateSem);
|
||||||
fActivateState = true;
|
fActivateState = true;
|
||||||
|
be_app->HideCursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,7 +429,7 @@ BWindowScreen::SetColorList(rgb_color *list, int32 firstIndex, int32 lastIndex)
|
|||||||
if (!fActivateState) {
|
if (!fActivateState) {
|
||||||
// If we aren't active, we just change our local palette
|
// If we aren't active, we just change our local palette
|
||||||
for (int32 x = firstIndex; x <= lastIndex; x++) {
|
for (int32 x = firstIndex; x <= lastIndex; x++) {
|
||||||
fColorList[x] = list[x];
|
fPalette[x] = list[x];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
uint8 colors[3 * 256];
|
uint8 colors[3 * 256];
|
||||||
@@ -429,7 +437,7 @@ BWindowScreen::SetColorList(rgb_color *list, int32 firstIndex, int32 lastIndex)
|
|||||||
int32 j = 0;
|
int32 j = 0;
|
||||||
|
|
||||||
for (int32 x = firstIndex; x <= lastIndex; x++) {
|
for (int32 x = firstIndex; x <= lastIndex; x++) {
|
||||||
fColorList[x] = list[x];
|
fPalette[x] = list[x];
|
||||||
// update our local palette as well
|
// update our local palette as well
|
||||||
|
|
||||||
colors[j++] = list[x].red;
|
colors[j++] = list[x].red;
|
||||||
@@ -459,10 +467,12 @@ status_t
|
|||||||
BWindowScreen::SetSpace(uint32 space)
|
BWindowScreen::SetSpace(uint32 space)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
display_mode mode;
|
display_mode mode;
|
||||||
status_t status = GetModeFromSpace(space, &mode);
|
status_t status = _GetModeFromSpace(space, &mode);
|
||||||
if (status == B_OK)
|
if (status == B_OK)
|
||||||
status = AssertDisplayMode(&mode);
|
status = _AssertDisplayMode(&mode);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -490,7 +500,7 @@ BWindowScreen::SetFrameBuffer(int32 width, int32 height)
|
|||||||
BScreen screen(this);
|
BScreen screen(this);
|
||||||
status_t status = screen.ProposeMode(&mode, &lowMode, &highMode);
|
status_t status = screen.ProposeMode(&mode, &lowMode, &highMode);
|
||||||
if (status == B_OK)
|
if (status == B_OK)
|
||||||
status = AssertDisplayMode(&mode);
|
status = _AssertDisplayMode(&mode);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -512,19 +522,21 @@ BWindowScreen::MoveDisplayArea(int32 x, int32 y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
void *
|
void *
|
||||||
BWindowScreen::IOBase()
|
BWindowScreen::IOBase()
|
||||||
{
|
{
|
||||||
// Not supported
|
// Not supported
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
rgb_color *
|
rgb_color *
|
||||||
BWindowScreen::ColorList()
|
BWindowScreen::ColorList()
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
return fColorList;
|
return fPalette;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -581,7 +593,7 @@ BWindowScreen::CardInfo()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BWindowScreen::RegisterThread(thread_id id)
|
BWindowScreen::RegisterThread(thread_id thread)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
@@ -593,11 +605,11 @@ BWindowScreen::RegisterThread(thread_id id)
|
|||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
void *newDebugList = realloc(fDebugList, (fDebugListCount + 1) * sizeof(thread_id));
|
void *newDebugList = realloc(fDebugThreads, (fDebugThreadCount + 1) * sizeof(thread_id));
|
||||||
if (newDebugList != NULL) {
|
if (newDebugList != NULL) {
|
||||||
fDebugList = (thread_id *)newDebugList;
|
fDebugThreads = (thread_id *)newDebugList;
|
||||||
fDebugList[fDebugListCount] = id;
|
fDebugThreads[fDebugThreadCount] = thread;
|
||||||
fDebugListCount++;
|
fDebugThreadCount++;
|
||||||
}
|
}
|
||||||
release_sem(fDebugSem);
|
release_sem(fDebugSem);
|
||||||
}
|
}
|
||||||
@@ -611,12 +623,13 @@ BWindowScreen::SuspensionHook(bool active)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BWindowScreen::Suspend(char *label)
|
BWindowScreen::Suspend(char* label)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
if (fDebugState) {
|
if (fDebugState) {
|
||||||
fprintf(stderr, "## Debugger(\"%s\").", label);
|
fprintf(stderr, "## Debugger(\"%s\").", label);
|
||||||
fprintf(stderr, " Press Alt-F%ld or Cmd-F%ld to resume.\n", space0 + 1, space0 + 1);
|
fprintf(stderr, " Press Alt-F%ld or Cmd-F%ld to resume.\n", fWorkspaceIndex + 1,
|
||||||
|
fWorkspaceIndex + 1);
|
||||||
|
|
||||||
if (IsLocked())
|
if (IsLocked())
|
||||||
Unlock();
|
Unlock();
|
||||||
@@ -632,7 +645,7 @@ BWindowScreen::Suspend(char *label)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BWindowScreen::Perform(perform_code d, void *arg)
|
BWindowScreen::Perform(perform_code d, void* arg)
|
||||||
{
|
{
|
||||||
return inherited::Perform(d, arg);
|
return inherited::Perform(d, arg);
|
||||||
}
|
}
|
||||||
@@ -653,31 +666,20 @@ void BWindowScreen::_ReservedWindowScreen4() {}
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
BRect
|
|
||||||
BWindowScreen::CalcFrame(int32 index, int32 space, display_mode* mode)
|
|
||||||
{
|
|
||||||
CALLED();
|
|
||||||
|
|
||||||
BScreen screen;
|
|
||||||
if (mode != NULL)
|
|
||||||
screen.GetMode(mode);
|
|
||||||
|
|
||||||
return screen.Frame();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BWindowScreen::InitData(uint32 space, uint32 attributes)
|
BWindowScreen::_InitData(uint32 space, uint32 attributes)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
fDebugState = attributes & B_ENABLE_DEBUGGER;
|
fDebugState = attributes & B_ENABLE_DEBUGGER;
|
||||||
fDebugListCount = 0;
|
fDebugThreadCount = 0;
|
||||||
fDebugList = NULL;
|
fDebugThreads = NULL;
|
||||||
fDebugFirst = true;
|
fDebugFirst = true;
|
||||||
|
|
||||||
fAttributes = attributes;
|
fAttributes = attributes;
|
||||||
fScreenIndex = fDebugWorkspace = current_workspace();
|
// TODO: not really used right now, but should probably be known by the app_server
|
||||||
|
|
||||||
|
fWorkspaceIndex = fDebugWorkspace = current_workspace();
|
||||||
fLockState = 0;
|
fLockState = 0;
|
||||||
fAddonImage = -1;
|
fAddonImage = -1;
|
||||||
fWindowState = 0;
|
fWindowState = 0;
|
||||||
@@ -693,16 +695,13 @@ BWindowScreen::InitData(uint32 space, uint32 attributes)
|
|||||||
if (fDisplayMode == NULL)
|
if (fDisplayMode == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
status = GetModeFromSpace(space, fDisplayMode);
|
status = _GetModeFromSpace(space, fDisplayMode);
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
space_mode = 1;
|
memcpy(fPalette, screen.ColorMap()->color_list, 256);
|
||||||
space0 = 0;
|
|
||||||
|
|
||||||
memcpy(fColorList, screen.ColorMap()->color_list, 256);
|
status = _GetCardInfo();
|
||||||
|
|
||||||
status = GetCardInfo();
|
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
@@ -718,25 +717,25 @@ BWindowScreen::InitData(uint32 space, uint32 attributes)
|
|||||||
|
|
||||||
fWorkState = 1;
|
fWorkState = 1;
|
||||||
|
|
||||||
fOldDisplayMode = (display_mode *)malloc(sizeof(display_mode));
|
fOriginalDisplayMode = (display_mode *)malloc(sizeof(display_mode));
|
||||||
if (fOldDisplayMode == NULL)
|
if (fOriginalDisplayMode == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
screen.GetMode(fOldDisplayMode);
|
screen.GetMode(fOriginalDisplayMode);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BWindowScreen::SetActiveState(int32 state)
|
BWindowScreen::_SetActiveState(int32 state)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
status_t status = B_ERROR;
|
status_t status = B_ERROR;
|
||||||
if (state == 1) {
|
if (state == 1) {
|
||||||
//be_app->HideCursor();
|
//be_app->HideCursor();
|
||||||
status = AssertDisplayMode(fDisplayMode);
|
status = _AssertDisplayMode(fDisplayMode);
|
||||||
if (status == B_OK && (status = SetupAccelerantHooks(true)) == B_OK) {
|
if (status == B_OK && (status = _SetupAccelerantHooks(true)) == B_OK) {
|
||||||
if (!fActivateState) {
|
if (!fActivateState) {
|
||||||
do {
|
do {
|
||||||
status = acquire_sem(fActivateSem);
|
status = acquire_sem(fActivateSem);
|
||||||
@@ -746,10 +745,10 @@ BWindowScreen::SetActiveState(int32 state)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetColorList(fColorList);
|
SetColorList(fPalette);
|
||||||
if (fDebugState && !fDebugFirst) {
|
if (fDebugState && !fDebugFirst) {
|
||||||
SuspensionHook(true);
|
SuspensionHook(true);
|
||||||
Resume();
|
_Resume();
|
||||||
} else {
|
} else {
|
||||||
fDebugFirst = true;
|
fDebugFirst = true;
|
||||||
ScreenConnected(true);
|
ScreenConnected(true);
|
||||||
@@ -758,18 +757,17 @@ BWindowScreen::SetActiveState(int32 state)
|
|||||||
if (status == B_OK)
|
if (status == B_OK)
|
||||||
return status;
|
return status;
|
||||||
} else
|
} else
|
||||||
SetupAccelerantHooks(false);
|
_SetupAccelerantHooks(false);
|
||||||
|
|
||||||
be_app->ShowCursor();
|
|
||||||
} else {
|
} else {
|
||||||
AssertDisplayMode(fOldDisplayMode);
|
_AssertDisplayMode(fOriginalDisplayMode);
|
||||||
|
|
||||||
if (fDebugState && !fDebugFirst) {
|
if (fDebugState && !fDebugFirst) {
|
||||||
Suspend();
|
_Suspend();
|
||||||
SuspensionHook(false);
|
SuspensionHook(false);
|
||||||
} else
|
} else
|
||||||
ScreenConnected(false);
|
ScreenConnected(false);
|
||||||
|
|
||||||
status = SetupAccelerantHooks(false);
|
status = _SetupAccelerantHooks(false);
|
||||||
if (status == B_OK) {
|
if (status == B_OK) {
|
||||||
be_app->ShowCursor();
|
be_app->ShowCursor();
|
||||||
if (fActivateState) {
|
if (fActivateState) {
|
||||||
@@ -783,11 +781,11 @@ BWindowScreen::SetActiveState(int32 state)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BWindowScreen::SetupAccelerantHooks(bool enable)
|
BWindowScreen::_SetupAccelerantHooks(bool enable)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
if (fAddonImage >= 0) {
|
if (fAddonImage >= 0) {
|
||||||
m_wei();
|
fWaitEngineIdle();
|
||||||
sFillRectHook = NULL;
|
sFillRectHook = NULL;
|
||||||
sBlitRectHook = NULL;
|
sBlitRectHook = NULL;
|
||||||
sTransparentBlitHook = NULL;
|
sTransparentBlitHook = NULL;
|
||||||
@@ -802,28 +800,37 @@ BWindowScreen::SetupAccelerantHooks(bool enable)
|
|||||||
|
|
||||||
status_t status = B_OK;
|
status_t status = B_OK;
|
||||||
if (enable) {
|
if (enable) {
|
||||||
|
acquire_engine aquireEngine = NULL;
|
||||||
|
release_engine releaseEngine = NULL;
|
||||||
|
fill_rectangle fillRectangle = NULL;
|
||||||
|
screen_to_screen_blit blit = NULL;
|
||||||
|
screen_to_screen_transparent_blit transparentBlit = NULL;
|
||||||
|
screen_to_screen_scaled_filtered_blit scaledFilteredBlit = NULL;
|
||||||
|
|
||||||
if (fAddonImage < 0) {
|
if (fAddonImage < 0) {
|
||||||
status = InitClone();
|
status = _InitClone();
|
||||||
if (status == B_OK) {
|
if (status == B_OK) {
|
||||||
m_wei = (wait_engine_idle)fGetAccelerantHook(B_WAIT_ENGINE_IDLE, NULL);
|
fWaitEngineIdle = (wait_engine_idle)fGetAccelerantHook(B_WAIT_ENGINE_IDLE, NULL);
|
||||||
m_re = (release_engine)fGetAccelerantHook(B_RELEASE_ENGINE, NULL);
|
|
||||||
m_ae = (acquire_engine)fGetAccelerantHook(B_ACQUIRE_ENGINE, NULL);
|
releaseEngine = (release_engine)fGetAccelerantHook(B_RELEASE_ENGINE, NULL);
|
||||||
fill_rect = (fill_rectangle)fGetAccelerantHook(B_FILL_RECTANGLE, NULL);
|
aquireEngine = (acquire_engine)fGetAccelerantHook(B_ACQUIRE_ENGINE, NULL);
|
||||||
blit_rect = (screen_to_screen_blit)fGetAccelerantHook(B_SCREEN_TO_SCREEN_BLIT, NULL);
|
fillRectangle = (fill_rectangle)fGetAccelerantHook(B_FILL_RECTANGLE, NULL);
|
||||||
trans_blit_rect = (screen_to_screen_transparent_blit)fGetAccelerantHook(B_SCREEN_TO_SCREEN_TRANSPARENT_BLIT, NULL);
|
blit = (screen_to_screen_blit)fGetAccelerantHook(B_SCREEN_TO_SCREEN_BLIT, NULL);
|
||||||
scaled_filtered_blit_rect = (screen_to_screen_scaled_filtered_blit)fGetAccelerantHook(B_SCREEN_TO_SCREEN_SCALED_FILTERED_BLIT, NULL);
|
transparentBlit = (screen_to_screen_transparent_blit)fGetAccelerantHook(B_SCREEN_TO_SCREEN_TRANSPARENT_BLIT, NULL);
|
||||||
|
scaledFilteredBlit = (screen_to_screen_scaled_filtered_blit)fGetAccelerantHook(B_SCREEN_TO_SCREEN_SCALED_FILTERED_BLIT, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status == B_OK) {
|
if (status == B_OK) {
|
||||||
sFillRectHook = fill_rect;
|
sFillRectHook = fillRectangle;
|
||||||
sBlitRectHook = blit_rect;
|
sBlitRectHook = blit;
|
||||||
sTransparentBlitHook = trans_blit_rect;
|
sTransparentBlitHook = transparentBlit;
|
||||||
sScaledFilteredBlitHook = scaled_filtered_blit_rect;
|
sScaledFilteredBlitHook = scaledFilteredBlit;
|
||||||
sWaitIdleHook = m_wei;
|
sWaitIdleHook = fWaitEngineIdle;
|
||||||
sAcquireEngineHook = m_ae;
|
sAcquireEngineHook = aquireEngine;
|
||||||
sReleaseEngineHook = m_re;
|
sReleaseEngineHook = releaseEngine;
|
||||||
m_wei();
|
|
||||||
|
fWaitEngineIdle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -832,7 +839,7 @@ BWindowScreen::SetupAccelerantHooks(bool enable)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BWindowScreen::GetCardInfo()
|
BWindowScreen::_GetCardInfo()
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
@@ -897,7 +904,7 @@ BWindowScreen::GetCardInfo()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BWindowScreen::Suspend()
|
BWindowScreen::_Suspend()
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
@@ -910,33 +917,34 @@ BWindowScreen::Suspend()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Suspend all the registered threads
|
// Suspend all the registered threads
|
||||||
for (int32 i = 0; i < fDebugListCount; i++) {
|
for (int32 i = 0; i < fDebugThreadCount; i++) {
|
||||||
snooze(10000);
|
snooze(10000);
|
||||||
suspend_thread(fDebugList[i]);
|
suspend_thread(fDebugThreads[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
graphics_card_info *info = CardInfo();
|
graphics_card_info *info = CardInfo();
|
||||||
size_t fbSize = info->bytes_per_row * info->height;
|
size_t fbSize = info->bytes_per_row * info->height;
|
||||||
|
|
||||||
// Save the content of the frame buffer into the local buffer
|
// Save the content of the frame buffer into the local buffer
|
||||||
fDebugBuffer = (char *)malloc(fbSize);
|
fDebugFrameBuffer = (char *)malloc(fbSize);
|
||||||
memcpy(fDebugBuffer, info->frame_buffer, fbSize);
|
memcpy(fDebugFrameBuffer, info->frame_buffer, fbSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BWindowScreen::Resume()
|
BWindowScreen::_Resume()
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
graphics_card_info *info = CardInfo();
|
graphics_card_info *info = CardInfo();
|
||||||
|
|
||||||
// Copy the content of the debug_buffer back into the frame buffer.
|
// Copy the content of the debug_buffer back into the frame buffer.
|
||||||
memcpy(info->frame_buffer, fDebugBuffer, info->bytes_per_row * info->height);
|
memcpy(info->frame_buffer, fDebugFrameBuffer, info->bytes_per_row * info->height);
|
||||||
free(fDebugBuffer);
|
free(fDebugFrameBuffer);
|
||||||
|
fDebugFrameBuffer = NULL;
|
||||||
|
|
||||||
// Resume all the registered threads
|
// Resume all the registered threads
|
||||||
for (int32 i = 0; i < fDebugListCount; i++) {
|
for (int32 i = 0; i < fDebugThreadCount; i++) {
|
||||||
resume_thread(fDebugList[i]);
|
resume_thread(fDebugThreads[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
release_sem(fDebugSem);
|
release_sem(fDebugSem);
|
||||||
@@ -944,7 +952,7 @@ BWindowScreen::Resume()
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BWindowScreen::GetModeFromSpace(uint32 space, display_mode *dmode)
|
BWindowScreen::_GetModeFromSpace(uint32 space, display_mode *dmode)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
@@ -966,7 +974,7 @@ BWindowScreen::GetModeFromSpace(uint32 space, display_mode *dmode)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BWindowScreen::InitClone()
|
BWindowScreen::_InitClone()
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
@@ -975,7 +983,7 @@ BWindowScreen::InitClone()
|
|||||||
|
|
||||||
AppServerLink link;
|
AppServerLink link;
|
||||||
link.StartMessage(AS_GET_ACCELERANT_PATH);
|
link.StartMessage(AS_GET_ACCELERANT_PATH);
|
||||||
link.Attach<int32>(fScreenIndex);
|
link.Attach<int32>(fWorkspaceIndex);
|
||||||
|
|
||||||
status_t status = B_ERROR;
|
status_t status = B_ERROR;
|
||||||
if (link.FlushWithReply(status) < B_OK || status < B_OK)
|
if (link.FlushWithReply(status) < B_OK || status < B_OK)
|
||||||
@@ -1008,7 +1016,7 @@ BWindowScreen::InitClone()
|
|||||||
}
|
}
|
||||||
|
|
||||||
link.StartMessage(AS_GET_DRIVER_PATH);
|
link.StartMessage(AS_GET_DRIVER_PATH);
|
||||||
link.Attach<int32>(fScreenIndex);
|
link.Attach<int32>(fWorkspaceIndex);
|
||||||
if (link.FlushWithReply(status) == B_OK && status == B_OK) {
|
if (link.FlushWithReply(status) == B_OK && status == B_OK) {
|
||||||
BString driverPath;
|
BString driverPath;
|
||||||
link.ReadString(driverPath);
|
link.ReadString(driverPath);
|
||||||
@@ -1026,7 +1034,7 @@ BWindowScreen::InitClone()
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BWindowScreen::AssertDisplayMode(display_mode* displayMode)
|
BWindowScreen::_AssertDisplayMode(display_mode* displayMode)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
@@ -1048,10 +1056,9 @@ BWindowScreen::AssertDisplayMode(display_mode* displayMode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
memcpy(fDisplayMode, displayMode, sizeof(display_mode));
|
memcpy(fDisplayMode, displayMode, sizeof(display_mode));
|
||||||
space_mode = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
status = GetCardInfo();
|
status = _GetCardInfo();
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user