changes submitted by Christopher ML Zumwalt May

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2357 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
beveloper
2003-01-06 02:19:29 +00:00
parent 835140c89a
commit de613a80e7
2 changed files with 574 additions and 463 deletions
+167 -173
View File
@@ -1,173 +1,167 @@
/******************************************************************************* //------------------------------------------------------------------------------
// // Copyright (c) 2001-2002, OpenBeOS
// File: DirectWindow.h //
// // Permission is hereby granted, free of charge, to any person obtaining a
// Description: Client window class for direct screen access. // copy of this software and associated documentation files (the "Software"),
// // to deal in the Software without restriction, including without limitation
// Copyright 1998, Be Incorporated, All Rights Reserved. // the rights to use, copy, modify, merge, publish, distribute, sublicense,
// // and/or sell copies of the Software, and to permit persons to whom the
*******************************************************************************/ // Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
#ifndef _DIRECT_WINDOW_H // all copies or substantial portions of the Software.
#define _DIRECT_WINDOW_H //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#include <Region.h> // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#include <Window.h> // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
class BDirectDriver; // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
/* State of the direct access when called back through DirectConnected */ // DEALINGS IN THE SOFTWARE.
enum direct_buffer_state { //
B_DIRECT_MODE_MASK = 15, // File Name: DirectWindow.h
// Author: Christopher ML Zumwalt May ([email protected])
B_DIRECT_START = 0, // Description: BFileGameSound allow the developer to directly draw to the
B_DIRECT_STOP = 1, // app_server's frame buffer.
B_DIRECT_MODIFY = 2, //------------------------------------------------------------------------------
B_CLIPPING_MODIFIED = 16, #ifndef _DIRECTWINDOW_H
B_BUFFER_RESIZED = 32, #define _DIRECTWINDOW_H
B_BUFFER_MOVED = 64,
B_BUFFER_RESET = 128 // Standard Includes -----------------------------------------------------------
};
// System Includes -------------------------------------------------------------
/* State of the direct driver and its hooks functions */ #include <Region.h>
enum direct_driver_state { #include <Window.h>
B_DRIVER_CHANGED = 0x0001,
B_MODE_CHANGED = 0x0002 // Project Includes ------------------------------------------------------------
};
// Local Includes --------------------------------------------------------------
/* Integer rect used to define a cliping rectangle. All bounds are included */
/* Moved to Region.h */ // Local Defines ---------------------------------------------------------------
/* Frame buffer access descriptor */ // Globals ---------------------------------------------------------------------
typedef struct { enum direct_buffer_state {
direct_buffer_state buffer_state; B_DIRECT_MODE_MASK = 15,
direct_driver_state driver_state;
void *bits; B_DIRECT_START = 0,
void *pci_bits; B_DIRECT_STOP = 1,
int32 bytes_per_row; B_DIRECT_MODIFY = 2,
uint32 bits_per_pixel;
color_space pixel_format; B_CLIPPING_MODIFIED = 16,
buffer_layout layout; B_BUFFER_RESIZED = 32,
buffer_orientation orientation; B_BUFFER_MOVED = 64,
uint32 _reserved[9]; B_BUFFER_RESET = 128
uint32 _dd_type_; };
uint32 _dd_token_;
uint32 clip_list_count; enum direct_driver_state {
clipping_rect window_bounds; B_DRIVER_CHANGED = 0x0001,
clipping_rect clip_bounds; B_MODE_CHANGED = 0x0002
clipping_rect clip_list[1]; };
} direct_buffer_info;
typedef struct {
/* BDirectWindow class */ direct_buffer_state buffer_state;
class BDirectWindow : public BWindow { direct_driver_state driver_state;
public: void *bits;
BDirectWindow( BRect frame, void *pci_bits;
const char *title, int32 bytes_per_row;
window_type type, uint32 bits_per_pixel;
uint32 flags, color_space pixel_format;
uint32 workspace = B_CURRENT_WORKSPACE); buffer_layout layout;
BDirectWindow( BRect frame, buffer_orientation orientation;
const char *title, uint32 _reserved[9];
window_look look, uint32 _dd_type_;
window_feel feel, uint32 _dd_token_;
uint32 flags, uint32 clip_list_count;
uint32 workspace = B_CURRENT_WORKSPACE); clipping_rect window_bounds;
virtual ~BDirectWindow(); clipping_rect clip_bounds;
static BArchivable *Instantiate(BMessage *data); clipping_rect clip_list[1];
virtual status_t Archive(BMessage *data, bool deep = true) const; } direct_buffer_info;
/* defined for future extension (fragile base class). Identical to BWindow */ // PushGameSound ---------------------------------------------------------------
virtual void Quit(void); class BDirectWindow : public BWindow
virtual void DispatchMessage(BMessage *message, BHandler *handler); {
virtual void MessageReceived(BMessage *message); public:
virtual void FrameMoved(BPoint new_position); BDirectWindow(BRect frame,
virtual void WorkspacesChanged(uint32 old_ws, uint32 new_ws); const char *title,
virtual void WorkspaceActivated(int32 ws, bool state); window_type type,
virtual void FrameResized(float new_width, float new_height); uint32 flags,
virtual void Minimize(bool minimize); uint32 workspace = B_CURRENT_WORKSPACE);
virtual void Zoom( BPoint rec_position, BDirectWindow(BRect frame,
float rec_width, const char *title,
float rec_height); window_look look,
virtual void ScreenChanged(BRect screen_size, color_space depth); window_feel feel,
virtual void MenusBeginning(); uint32 flags,
virtual void MenusEnded(); uint32 workspace = B_CURRENT_WORKSPACE);
virtual void WindowActivated(bool state); virtual ~BDirectWindow();
virtual void Show();
virtual void Hide(); static BArchivable *Instantiate(BMessage *data);
virtual BHandler *ResolveSpecifier(BMessage *msg, virtual status_t Archive(BMessage *data, bool deep = true) const;
int32 index, virtual void Quit(void);
BMessage *specifier, virtual void DispatchMessage(BMessage *message, BHandler *handler);
int32 form, virtual void MessageReceived(BMessage *message);
const char *property); virtual void FrameMoved(BPoint new_position);
virtual status_t GetSupportedSuites(BMessage *data); virtual void WorkspacesChanged(uint32 old_ws, uint32 new_ws);
virtual status_t Perform(perform_code d, void *arg); virtual void WorkspaceActivated(int32 ws, bool state);
virtual void FrameResized(float new_width, float new_height);
private: virtual void Minimize(bool minimize);
virtual void task_looper(); virtual void Zoom(BPoint rec_position,
virtual BMessage *ConvertToMessage(void *raw, int32 code); float rec_width,
float rec_height);
/* new APIs */ virtual void ScreenChanged(BRect screen_size, color_space depth);
virtual void MenusBeginning();
public: virtual void MenusEnded();
virtual void DirectConnected(direct_buffer_info *info); virtual void WindowActivated(bool state);
status_t GetClippingRegion(BRegion *region, BPoint *origin = NULL) const; virtual void Show();
status_t SetFullScreen(bool enable); virtual void Hide();
bool IsFullScreen() const; virtual BHandler *ResolveSpecifier(BMessage *msg,
int32 index,
static bool SupportsWindowMode(screen_id = B_MAIN_SCREEN_ID); BMessage *specifier,
int32 form,
/* private */ const char *property);
private: virtual status_t GetSupportedSuites(BMessage *data);
virtual status_t Perform(perform_code d, void *arg);
typedef BWindow inherited;
private:
virtual void _ReservedDirectWindow1(); virtual void _ReservedDirectWindow1();
virtual void _ReservedDirectWindow2(); virtual void _ReservedDirectWindow2();
virtual void _ReservedDirectWindow3();
virtual void _ReservedDirectWindow4(); public:
// BDirectWindow API
virtual void DirectConnected(direct_buffer_info *info);
BDirectWindow(); status_t GetClippingRegion(BRegion *region, BPoint *origin = NULL) const;
BDirectWindow(BDirectWindow &); status_t SetFullScreen(bool enable);
BDirectWindow &operator=(BDirectWindow &); bool IsFullScreen() const;
bool deamon_killer; static bool SupportsWindowMode(screen_id = B_MAIN_SCREEN_ID);
bool connection_enable;
bool full_screen_enable; private:
bool direct_driver_ready;
bool in_direct_connect; typedef BWindow inherited;
int32 direct_lock;
sem_id direct_sem; virtual void _ReservedDirectWindow3();
uint32 direct_lock_count; virtual void _ReservedDirectWindow4();
thread_id direct_lock_owner; virtual void _ReservedDirectWindow5();
char *direct_lock_stack; virtual void _ReservedDirectWindow6();
sem_id disable_sem;
sem_id disable_sem_ack; BDirectWindow();
uint32 dw_init_status; BDirectWindow(BDirectWindow &);
uint32 info_area_size; BDirectWindow &operator=(BDirectWindow &);
uint32 direct_driver_type;
uint32 direct_driver_token; void InitData(BRect frame);
area_id cloned_clipping_area;
area_id source_clipping_area; void DoDirectConnected();
thread_id direct_deamon_id; void Connect();
direct_buffer_info *buffer_desc; void Disconnect();
BDirectDriver *direct_driver;
struct priv_ext *extension; void CreateClippingList();
uint32 _reserved_[15]; void GetFrameBuffer();
static int32 DirectDeamonFunc(void *arg); bool fIsFullScreen;
bool LockDirect() const; bool fIsConnected;
void UnlockDirect() const; direct_buffer_info *fBufferInfo;
void InitData(); uint32 _reserved_[31];
void DisposeData(); };
status_t DriverSetup() const;
}; #endif
#endif
+407 -290
View File
@@ -1,290 +1,407 @@
/* //------------------------------------------------------------------------------
* Copyright 2002, Marcus Overhagen. All rights reserved. // Copyright (c) 2001-2002, OpenBeOS
* Distributed under the terms of the MIT License. //
*/ // Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
#include <DirectWindow.h> // to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
BDirectWindow::BDirectWindow(BRect frame, // and/or sell copies of the Software, and to permit persons to whom the
const char *title, // Software is furnished to do so, subject to the following conditions:
window_type type, //
uint32 flags, // The above copyright notice and this permission notice shall be included in
uint32 workspace) // all copies or substantial portions of the Software.
: BWindow(frame, title, type, flags, workspace) //
{ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
} // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
BDirectWindow::BDirectWindow(BRect frame, // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
const char *title, // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
window_look look, // DEALINGS IN THE SOFTWARE.
window_feel feel, //
uint32 flags, // File Name: DirectWindow.cpp
uint32 workspace) // Author: Christopher ML Zumwalt May ([email protected])
: BWindow(frame, title, look, feel, flags, workspace) // Description: BFileGameSound allow the developer to directly draw to the
{ // app_server's frame buffer.
} //------------------------------------------------------------------------------
#include <memory.h>
BDirectWindow::~BDirectWindow()
{ #include "DirectWindow.h"
}
BDirectWindow::BDirectWindow(BRect frame,
const char *title,
BArchivable * window_type type,
BDirectWindow::Instantiate(BMessage *data) uint32 flags,
{ uint32 workspace)
return NULL; : BWindow(frame, title, type, flags, workspace),
} fIsFullScreen(false),
fIsConnected(false)
{
status_t InitData(frame);
BDirectWindow::Archive(BMessage *data, }
bool deep) const
{
return B_ERROR; BDirectWindow::BDirectWindow(BRect frame,
} const char *title,
window_look look,
window_feel feel,
void uint32 flags,
BDirectWindow::Quit(void) uint32 workspace)
{ : BWindow(frame, title, look, feel, flags, workspace),
} fIsFullScreen(false),
fIsConnected(false)
{
void InitData(frame);
BDirectWindow::DispatchMessage(BMessage *message, }
BHandler *handler)
{
} BDirectWindow::~BDirectWindow()
{
if (fIsConnected)
void {
BDirectWindow::MessageReceived(BMessage *message) fBufferInfo->buffer_state = B_DIRECT_STOP;
{ DoDirectConnected();
} }
delete fBufferInfo;
void }
BDirectWindow::FrameMoved(BPoint new_position)
{ BArchivable *
} BDirectWindow::Instantiate(BMessage *data)
{
return NULL;
void }
BDirectWindow::WorkspacesChanged(uint32 old_ws,
uint32 new_ws)
{ status_t
} BDirectWindow::Archive(BMessage *data,
bool deep) const
{
void return B_ERROR;
BDirectWindow::WorkspaceActivated(int32 ws, }
bool state)
{
} void
BDirectWindow::Quit(void)
{
void if (fIsConnected) Disconnect();
BDirectWindow::FrameResized(float new_width,
float new_height) BWindow::Quit();
{ }
}
void
void BDirectWindow::DispatchMessage(BMessage *message,
BDirectWindow::Minimize(bool minimize) BHandler *handler)
{ {
} BWindow::DispatchMessage(message, handler);
}
void
BDirectWindow::Zoom(BPoint rec_position, void
float rec_width, BDirectWindow::MessageReceived(BMessage *message)
float rec_height) {
{ BWindow::MessageReceived(message);
} }
void void
BDirectWindow::ScreenChanged(BRect screen_size, BDirectWindow::FrameMoved(BPoint new_position)
color_space depth) {
{ clipping_rect * bounds = &fBufferInfo->window_bounds;
}
int32 dx = int32(new_position.x - bounds->left);
int32 dy = int32(new_position.y - bounds->top);
void
BDirectWindow::MenusBeginning() bounds->top += dy;
{ bounds->left += dx;
} bounds->right += dx;
bounds->bottom += dy;
void fBufferInfo->buffer_state = direct_buffer_state(B_DIRECT_MODIFY | B_BUFFER_MOVED);
BDirectWindow::MenusEnded() DoDirectConnected();
{ }
}
void
void BDirectWindow::WorkspacesChanged(uint32 old_ws,
BDirectWindow::WindowActivated(bool state) uint32 new_ws)
{ {
} }
void void
BDirectWindow::Show() BDirectWindow::WorkspaceActivated(int32 ws,
{ bool state)
} {
if (state)
Connect();
void else
BDirectWindow::Hide() Disconnect();
{ }
}
void
BHandler * BDirectWindow::FrameResized(float new_width,
BDirectWindow::ResolveSpecifier(BMessage *msg, float new_height)
int32 index, {
BMessage *specifier, clipping_rect * bounds = &fBufferInfo->window_bounds;
int32 form,
const char *property) bounds->right = int32(bounds->left + new_width);
{ bounds->bottom = int32(bounds->top + new_height);
return NULL;
} fBufferInfo->buffer_state = direct_buffer_state(B_DIRECT_MODIFY | B_BUFFER_RESIZED);
DoDirectConnected();
}
status_t
BDirectWindow::GetSupportedSuites(BMessage *data)
{ void
return B_ERROR; BDirectWindow::Minimize(bool minimize)
} {
if (minimize)
{
status_t Disconnect();
BDirectWindow::Perform(perform_code d, BWindow::Minimize(false);
void *arg) }
{ else
return B_ERROR; {
} BWindow::Minimize(true);
Connect();
}
void }
BDirectWindow::task_looper()
{
} void
BDirectWindow::Zoom(BPoint rec_position,
float rec_width,
BMessage * float rec_height)
BDirectWindow::ConvertToMessage(void *raw, {
int32 code) BWindow::Zoom(rec_position, rec_width, rec_height);
{ }
return NULL;
}
void
BDirectWindow::ScreenChanged(BRect screen_size,
void color_space depth)
BDirectWindow::DirectConnected(direct_buffer_info *info) {
{ direct_buffer_state state = B_DIRECT_MODIFY;
}
if (fIsConnected && fIsFullScreen)
{
status_t ResizeTo(screen_size.right, screen_size.bottom);
BDirectWindow::GetClippingRegion(BRegion *region, state = direct_buffer_state(state | B_BUFFER_RESIZED);
BPoint *origin) const }
{
return B_ERROR; GetFrameBuffer();
}
fBufferInfo->buffer_state = direct_buffer_state(state | B_BUFFER_RESET);
DoDirectConnected();
status_t }
BDirectWindow::SetFullScreen(bool enable)
{
return B_ERROR; void
} BDirectWindow::MenusBeginning()
{
}
bool
BDirectWindow::IsFullScreen() const
{ void
return false; BDirectWindow::MenusEnded()
} {
}
bool
BDirectWindow::SupportsWindowMode(screen_id) void
{ BDirectWindow::WindowActivated(bool state)
return false; {
} CreateClippingList();
}
void
BDirectWindow::_ReservedDirectWindow1() void
{ BDirectWindow::Show()
} {
BWindow::Show();
void Connect();
BDirectWindow::_ReservedDirectWindow2() }
{
}
void
BDirectWindow::Hide()
void {
BDirectWindow::_ReservedDirectWindow3() Disconnect();
{
} BWindow::Hide();
}
void
BDirectWindow::_ReservedDirectWindow4() BHandler *
{ BDirectWindow::ResolveSpecifier(BMessage *msg,
} int32 index,
BMessage *specifier,
int32 form,
/* unimplemented for protection of the user: const char *property)
* {
* BDirectWindow::BDirectWindow() return NULL;
* BDirectWindow::BDirectWindow(BDirectWindow &) }
* BDirectWindow &BDirectWindow::operator=(BDirectWindow &)
*/
status_t
int32 BDirectWindow::GetSupportedSuites(BMessage *data)
BDirectWindow::DirectDeamonFunc(void *arg) {
{ return B_ERROR;
return 0; }
}
status_t
bool BDirectWindow::Perform(perform_code d,
BDirectWindow::LockDirect() const void *arg)
{ {
return false; return B_ERROR;
} }
void //BMessage *
BDirectWindow::UnlockDirect() const //BDirectWindow::ConvertToMessage(void *raw,
{ // int32 code)
} //{
// return NULL;
//}
void
BDirectWindow::InitData()
{ void
} BDirectWindow::DirectConnected(direct_buffer_info *info)
{
}
void
BDirectWindow::DisposeData()
{ status_t
} BDirectWindow::GetClippingRegion(BRegion *region,
BPoint *origin) const
{
status_t return B_ERROR;
BDirectWindow::DriverSetup() const }
{
return B_ERROR;
} status_t
BDirectWindow::SetFullScreen(bool enable)
{
return B_ERROR;
}
bool
BDirectWindow::IsFullScreen() const
{
return fIsFullScreen;
}
bool
BDirectWindow::SupportsWindowMode(screen_id)
{
return true;
}
void
BDirectWindow::_ReservedDirectWindow1()
{
}
void
BDirectWindow::_ReservedDirectWindow2()
{
}
void
BDirectWindow::_ReservedDirectWindow3()
{
}
void
BDirectWindow::_ReservedDirectWindow4()
{
}
void
BDirectWindow::_ReservedDirectWindow5()
{
}
void
BDirectWindow::_ReservedDirectWindow6()
{
}
/* unimplemented for protection of the user:
*
* BDirectWindow::BDirectWindow()
* BDirectWindow::BDirectWindow(BDirectWindow &)
* BDirectWindow &BDirectWindow::operator=(BDirectWindow &)
*/
void
BDirectWindow::InitData(BRect frame)
{
fBufferInfo = new direct_buffer_info;
memset(fBufferInfo, 0, sizeof(direct_buffer_info));
fBufferInfo->window_bounds.top = int32(frame.top);
fBufferInfo->window_bounds.left = int32(frame.left);
fBufferInfo->window_bounds.right = int32(frame.right);
fBufferInfo->window_bounds.bottom = int32(frame.bottom);
GetFrameBuffer();
}
void
BDirectWindow::DoDirectConnected()
{
if (fIsConnected)
{
direct_buffer_info * info = new direct_buffer_info;
memcpy(info, fBufferInfo, sizeof(direct_buffer_info));
DirectConnected(info);
delete info;
}
}
void
BDirectWindow::Connect()
{
fIsConnected = true;
fBufferInfo->buffer_state = B_DIRECT_START;
DoDirectConnected();
}
void
BDirectWindow::Disconnect()
{
fBufferInfo->buffer_state = B_DIRECT_STOP;
DoDirectConnected();
fIsConnected = false;
}
void
BDirectWindow::CreateClippingList()
{
}
void
BDirectWindow::GetFrameBuffer()
{
}