* Cleanup, no functional change.

+alphabranch


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32881 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-09-01 09:53:41 +00:00
parent 419f2d6f3e
commit 7b8b23e9a4
10 changed files with 773 additions and 684 deletions
+100 -87
View File
@@ -14,17 +14,13 @@
#include "AccelerantHWInterface.h" #include "AccelerantHWInterface.h"
#include "AccelerantBuffer.h" #include <dirent.h>
#include "MallocBuffer.h" #include <new>
#include "Overlay.h" #include <stdio.h>
#include "RGBColor.h" #include <stdlib.h>
#include "ServerConfig.h" #include <string.h>
#include "ServerCursor.h" #include <unistd.h>
#include "ServerProtocol.h" #include <sys/ioctl.h>
#include "SystemPalette.h"
#include <edid.h>
#include <safemode_defs.h>
#include <Accelerant.h> #include <Accelerant.h>
#include <Cursor.h> #include <Cursor.h>
@@ -34,13 +30,19 @@
#include <image.h> #include <image.h>
#include <String.h> #include <String.h>
#include <dirent.h> #include <edid.h>
#include <new> #include <safemode_defs.h>
#include <stdio.h> #include <syscalls.h>
#include <stdlib.h>
#include <string.h> #include "AccelerantBuffer.h"
#include <unistd.h> #include "MallocBuffer.h"
#include <sys/ioctl.h> #include "Overlay.h"
#include "RGBColor.h"
#include "ServerConfig.h"
#include "ServerCursor.h"
#include "ServerProtocol.h"
#include "SystemPalette.h"
using std::nothrow; using std::nothrow;
@@ -56,14 +58,6 @@ using std::nothrow;
#define OFFSCREEN_BACK_BUFFER 0 #define OFFSCREEN_BACK_BUFFER 0
// This call updates the frame buffer used by the on-screen KDL
extern "C" status_t _kern_frame_buffer_update(void *baseAddress,
int32 width, int32 height, int32 depth, int32 bytesPerRow);
// This call retrieves the system's safemode options
extern "C" status_t _kern_get_safemode_option(const char* parameter,
char* buffer, size_t* _size);
const int32 kDefaultParamsCount = 64; const int32 kDefaultParamsCount = 64;
@@ -157,7 +151,7 @@ AccelerantHWInterface::AccelerantHWInterface()
memset(&fSyncToken, 0, sizeof(sync_token)); memset(&fSyncToken, 0, sizeof(sync_token));
} }
// destructor
AccelerantHWInterface::~AccelerantHWInterface() AccelerantHWInterface::~AccelerantHWInterface()
{ {
delete fBackBuffer; delete fBackBuffer;
@@ -170,8 +164,7 @@ AccelerantHWInterface::~AccelerantHWInterface()
} }
/*! /*! \brief Opens the first available graphics device and initializes it
\brief Opens the first available graphics device and initializes it
\return B_OK on success or an appropriate error message on failure. \return B_OK on success or an appropriate error message on failure.
*/ */
status_t status_t
@@ -203,8 +196,7 @@ AccelerantHWInterface::Initialize()
} }
/*! /*! \brief Opens a graphics device for read-write access
\brief Opens a graphics device for read-write access
\param deviceNumber Number identifying which graphics card to open (1 for first card) \param deviceNumber Number identifying which graphics card to open (1 for first card)
\return The file descriptor for the opened graphics device \return The file descriptor for the opened graphics device
@@ -341,12 +333,17 @@ AccelerantHWInterface::_SetupDefaultHooks()
fAccAcquireEngine = (acquire_engine)fAccelerantHook(B_ACQUIRE_ENGINE, NULL); fAccAcquireEngine = (acquire_engine)fAccelerantHook(B_ACQUIRE_ENGINE, NULL);
fAccReleaseEngine = (release_engine)fAccelerantHook(B_RELEASE_ENGINE, NULL); fAccReleaseEngine = (release_engine)fAccelerantHook(B_RELEASE_ENGINE, NULL);
fAccSyncToToken = (sync_to_token)fAccelerantHook(B_SYNC_TO_TOKEN, NULL); fAccSyncToToken = (sync_to_token)fAccelerantHook(B_SYNC_TO_TOKEN, NULL);
fAccGetModeCount = (accelerant_mode_count)fAccelerantHook(B_ACCELERANT_MODE_COUNT, NULL); fAccGetModeCount
= (accelerant_mode_count)fAccelerantHook(B_ACCELERANT_MODE_COUNT, NULL);
fAccGetModeList = (get_mode_list)fAccelerantHook(B_GET_MODE_LIST, NULL); fAccGetModeList = (get_mode_list)fAccelerantHook(B_GET_MODE_LIST, NULL);
fAccGetFrameBufferConfig = (get_frame_buffer_config)fAccelerantHook(B_GET_FRAME_BUFFER_CONFIG, NULL); fAccGetFrameBufferConfig = (get_frame_buffer_config)fAccelerantHook(
fAccSetDisplayMode = (set_display_mode)fAccelerantHook(B_SET_DISPLAY_MODE, NULL); B_GET_FRAME_BUFFER_CONFIG, NULL);
fAccGetDisplayMode = (get_display_mode)fAccelerantHook(B_GET_DISPLAY_MODE, NULL); fAccSetDisplayMode
fAccGetPixelClockLimits = (get_pixel_clock_limits)fAccelerantHook(B_GET_PIXEL_CLOCK_LIMITS, NULL); = (set_display_mode)fAccelerantHook(B_SET_DISPLAY_MODE, NULL);
fAccGetDisplayMode
= (get_display_mode)fAccelerantHook(B_GET_DISPLAY_MODE, NULL);
fAccGetPixelClockLimits = (get_pixel_clock_limits)fAccelerantHook(
B_GET_PIXEL_CLOCK_LIMITS, NULL);
if (!fAccAcquireEngine || !fAccReleaseEngine || !fAccGetFrameBufferConfig if (!fAccAcquireEngine || !fAccReleaseEngine || !fAccGetFrameBufferConfig
|| !fAccGetModeCount || !fAccGetModeList || !fAccSetDisplayMode || !fAccGetModeCount || !fAccGetModeList || !fAccSetDisplayMode
@@ -355,43 +352,57 @@ AccelerantHWInterface::_SetupDefaultHooks()
} }
// optional // optional
fAccGetTimingConstraints = (get_timing_constraints)fAccelerantHook(B_GET_TIMING_CONSTRAINTS, NULL); fAccGetTimingConstraints = (get_timing_constraints)fAccelerantHook(
fAccProposeDisplayMode = (propose_display_mode)fAccelerantHook(B_PROPOSE_DISPLAY_MODE, NULL); B_GET_TIMING_CONSTRAINTS, NULL);
fAccGetPreferredDisplayMode = (get_preferred_display_mode)fAccelerantHook(B_GET_PREFERRED_DISPLAY_MODE, NULL); fAccProposeDisplayMode = (propose_display_mode)fAccelerantHook(
fAccGetMonitorInfo = (get_monitor_info)fAccelerantHook(B_GET_MONITOR_INFO, NULL); B_PROPOSE_DISPLAY_MODE, NULL);
fAccGetPreferredDisplayMode = (get_preferred_display_mode)fAccelerantHook(
B_GET_PREFERRED_DISPLAY_MODE, NULL);
fAccGetMonitorInfo
= (get_monitor_info)fAccelerantHook(B_GET_MONITOR_INFO, NULL);
fAccGetEDIDInfo = (get_edid_info)fAccelerantHook(B_GET_EDID_INFO, NULL); fAccGetEDIDInfo = (get_edid_info)fAccelerantHook(B_GET_EDID_INFO, NULL);
// cursor // cursor
fAccSetCursorShape = (set_cursor_shape)fAccelerantHook(B_SET_CURSOR_SHAPE, NULL); fAccSetCursorShape
= (set_cursor_shape)fAccelerantHook(B_SET_CURSOR_SHAPE, NULL);
fAccMoveCursor = (move_cursor)fAccelerantHook(B_MOVE_CURSOR, NULL); fAccMoveCursor = (move_cursor)fAccelerantHook(B_MOVE_CURSOR, NULL);
fAccShowCursor = (show_cursor)fAccelerantHook(B_SHOW_CURSOR, NULL); fAccShowCursor = (show_cursor)fAccelerantHook(B_SHOW_CURSOR, NULL);
// dpms // dpms
fAccDPMSCapabilities = (dpms_capabilities)fAccelerantHook(B_DPMS_CAPABILITIES, NULL); fAccDPMSCapabilities
= (dpms_capabilities)fAccelerantHook(B_DPMS_CAPABILITIES, NULL);
fAccDPMSMode = (dpms_mode)fAccelerantHook(B_DPMS_MODE, NULL); fAccDPMSMode = (dpms_mode)fAccelerantHook(B_DPMS_MODE, NULL);
fAccSetDPMSMode = (set_dpms_mode)fAccelerantHook(B_SET_DPMS_MODE, NULL); fAccSetDPMSMode = (set_dpms_mode)fAccelerantHook(B_SET_DPMS_MODE, NULL);
// overlay // overlay
fAccOverlayCount = (overlay_count)fAccelerantHook(B_OVERLAY_COUNT, NULL); fAccOverlayCount = (overlay_count)fAccelerantHook(B_OVERLAY_COUNT, NULL);
fAccOverlaySupportedSpaces = (overlay_supported_spaces)fAccelerantHook(B_OVERLAY_SUPPORTED_SPACES, NULL); fAccOverlaySupportedSpaces = (overlay_supported_spaces)fAccelerantHook(
fAccOverlaySupportedFeatures = (overlay_supported_features)fAccelerantHook(B_OVERLAY_SUPPORTED_FEATURES, NULL); B_OVERLAY_SUPPORTED_SPACES, NULL);
fAccAllocateOverlayBuffer = (allocate_overlay_buffer)fAccelerantHook(B_ALLOCATE_OVERLAY_BUFFER, NULL); fAccOverlaySupportedFeatures = (overlay_supported_features)fAccelerantHook(
fAccReleaseOverlayBuffer = (release_overlay_buffer)fAccelerantHook(B_RELEASE_OVERLAY_BUFFER, NULL); B_OVERLAY_SUPPORTED_FEATURES, NULL);
fAccGetOverlayConstraints = (get_overlay_constraints)fAccelerantHook(B_GET_OVERLAY_CONSTRAINTS, NULL); fAccAllocateOverlayBuffer = (allocate_overlay_buffer)fAccelerantHook(
fAccAllocateOverlay = (allocate_overlay)fAccelerantHook(B_ALLOCATE_OVERLAY, NULL); B_ALLOCATE_OVERLAY_BUFFER, NULL);
fAccReleaseOverlay = (release_overlay)fAccelerantHook(B_RELEASE_OVERLAY, NULL); fAccReleaseOverlayBuffer = (release_overlay_buffer)fAccelerantHook(
fAccConfigureOverlay = (configure_overlay)fAccelerantHook(B_CONFIGURE_OVERLAY, NULL); B_RELEASE_OVERLAY_BUFFER, NULL);
fAccGetOverlayConstraints = (get_overlay_constraints)fAccelerantHook(
B_GET_OVERLAY_CONSTRAINTS, NULL);
fAccAllocateOverlay
= (allocate_overlay)fAccelerantHook(B_ALLOCATE_OVERLAY, NULL);
fAccReleaseOverlay
= (release_overlay)fAccelerantHook(B_RELEASE_OVERLAY, NULL);
fAccConfigureOverlay
= (configure_overlay)fAccelerantHook(B_CONFIGURE_OVERLAY, NULL);
return B_OK; return B_OK;
} }
// Shutdown
status_t status_t
AccelerantHWInterface::Shutdown() AccelerantHWInterface::Shutdown()
{ {
if (fAccelerantHook) { if (fAccelerantHook) {
uninit_accelerant UninitAccelerant = (uninit_accelerant) uninit_accelerant UninitAccelerant
fAccelerantHook(B_UNINIT_ACCELERANT, NULL); = (uninit_accelerant)fAccelerantHook(B_UNINIT_ACCELERANT, NULL);
if (UninitAccelerant) if (UninitAccelerant)
UninitAccelerant(); UninitAccelerant();
} }
@@ -424,11 +435,14 @@ AccelerantHWInterface::_FindBestMode(const display_mode& compareMode,
// compute some random equality score // compute some random equality score
// TODO: check if these scores make sense // TODO: check if these scores make sense
int32 diff = 1000 * abs(mode.timing.h_display - compareMode.timing.h_display) int32 diff
= 1000 * abs(mode.timing.h_display - compareMode.timing.h_display)
+ 1000 * abs(mode.timing.v_display - compareMode.timing.v_display) + 1000 * abs(mode.timing.v_display - compareMode.timing.v_display)
+ abs(mode.timing.h_total * mode.timing.v_total + abs(mode.timing.h_total * mode.timing.v_total
- compareMode.timing.h_total * compareMode.timing.v_total) / 100 - compareMode.timing.h_total * compareMode.timing.v_total)
+ abs(mode.timing.pixel_clock - compareMode.timing.pixel_clock) / 100 / 100
+ abs(mode.timing.pixel_clock - compareMode.timing.pixel_clock)
/ 100
+ (int32)(500 * fabs(aspectRatio - compareAspectRatio)) + (int32)(500 * fabs(aspectRatio - compareAspectRatio))
+ 100 * abs(mode.space - compareMode.space); + 100 * abs(mode.space - compareMode.space);
@@ -449,8 +463,7 @@ AccelerantHWInterface::_FindBestMode(const display_mode& compareMode,
} }
/*! /*! This method is used for the initial mode set only - because that one
This method is used for the initial mode set only - because that one
should really not fail. should really not fail.
Basically we try to set all modes as found in the mode list the driver Basically we try to set all modes as found in the mode list the driver
returned, but we start with the one that best fits the originally returned, but we start with the one that best fits the originally
@@ -594,7 +607,7 @@ AccelerantHWInterface::SetMode(const display_mode& mode)
if (fDisplayMode.space == B_RGB15) if (fDisplayMode.space == B_RGB15)
depth = 15; depth = 15;
_kern_frame_buffer_update(fFrameBufferConfig.frame_buffer, _kern_frame_buffer_update((addr_t)fFrameBufferConfig.frame_buffer,
fFrontBuffer->Width(), fFrontBuffer->Height(), fFrontBuffer->Width(), fFrontBuffer->Height(),
depth, fFrameBufferConfig.bytes_per_row); depth, fFrameBufferConfig.bytes_per_row);
#endif #endif
@@ -683,7 +696,7 @@ AccelerantHWInterface::SetMode(const display_mode& mode)
void void
AccelerantHWInterface::GetMode(display_mode *mode) AccelerantHWInterface::GetMode(display_mode* mode)
{ {
if (mode && LockParallelAccess()) { if (mode && LockParallelAccess()) {
*mode = fDisplayMode; *mode = fDisplayMode;
@@ -728,7 +741,7 @@ AccelerantHWInterface::_UpdateFrameBufferConfig()
status_t status_t
AccelerantHWInterface::GetDeviceInfo(accelerant_device_info *info) AccelerantHWInterface::GetDeviceInfo(accelerant_device_info* info)
{ {
get_accelerant_device_info GetAccelerantDeviceInfo get_accelerant_device_info GetAccelerantDeviceInfo
= (get_accelerant_device_info)fAccelerantHook( = (get_accelerant_device_info)fAccelerantHook(
@@ -751,7 +764,7 @@ AccelerantHWInterface::GetFrameBufferConfig(frame_buffer_config& config)
status_t status_t
AccelerantHWInterface::GetModeList(display_mode** _modes, uint32 *_count) AccelerantHWInterface::GetModeList(display_mode** _modes, uint32* _count)
{ {
AutoReadLocker _(this); AutoReadLocker _(this);
@@ -778,41 +791,42 @@ AccelerantHWInterface::GetModeList(display_mode** _modes, uint32 *_count)
status_t status_t
AccelerantHWInterface::GetPixelClockLimits(display_mode *mode, uint32 *low, AccelerantHWInterface::GetPixelClockLimits(display_mode *mode, uint32* _low,
uint32 *high) uint32* _high)
{ {
AutoReadLocker _(this); if (mode == NULL || _low == NULL || _high == NULL)
if (!mode || !low || !high)
return B_BAD_VALUE; return B_BAD_VALUE;
return fAccGetPixelClockLimits(mode, low, high); AutoReadLocker _(this);
return fAccGetPixelClockLimits(mode, _low, _high);
} }
status_t status_t
AccelerantHWInterface::GetTimingConstraints(display_timing_constraints *dtc) AccelerantHWInterface::GetTimingConstraints(
display_timing_constraints* constraints)
{ {
AutoReadLocker _(this); if (constraints == NULL)
if (!dtc)
return B_BAD_VALUE; return B_BAD_VALUE;
AutoReadLocker _(this);
if (fAccGetTimingConstraints) if (fAccGetTimingConstraints)
return fAccGetTimingConstraints(dtc); return fAccGetTimingConstraints(constraints);
return B_UNSUPPORTED; return B_UNSUPPORTED;
} }
status_t status_t
AccelerantHWInterface::ProposeMode(display_mode *candidate, AccelerantHWInterface::ProposeMode(display_mode* candidate,
const display_mode *_low, const display_mode *_high) const display_mode* _low, const display_mode* _high)
{ {
AutoReadLocker _(this);
if (candidate == NULL || _low == NULL || _high == NULL) if (candidate == NULL || _low == NULL || _high == NULL)
return B_BAD_VALUE; return B_BAD_VALUE;
AutoReadLocker _(this);
if (fAccProposeDisplayMode == NULL) if (fAccProposeDisplayMode == NULL)
return B_UNSUPPORTED; return B_UNSUPPORTED;
@@ -1022,7 +1036,7 @@ AccelerantHWInterface::WaitForRetrace(bigtime_t timeout)
status_t status_t
AccelerantHWInterface::SetDPMSMode(const uint32 &state) AccelerantHWInterface::SetDPMSMode(uint32 state)
{ {
AutoWriteLocker _(this); AutoWriteLocker _(this);
@@ -1032,7 +1046,7 @@ AccelerantHWInterface::SetDPMSMode(const uint32 &state)
return fAccSetDPMSMode(state); return fAccSetDPMSMode(state);
} }
// DPMSMode
uint32 uint32
AccelerantHWInterface::DPMSMode() AccelerantHWInterface::DPMSMode()
{ {
@@ -1044,7 +1058,7 @@ AccelerantHWInterface::DPMSMode()
return fAccDPMSMode(); return fAccDPMSMode();
} }
// DPMSCapabilities
uint32 uint32
AccelerantHWInterface::DPMSCapabilities() AccelerantHWInterface::DPMSCapabilities()
{ {
@@ -1058,7 +1072,7 @@ AccelerantHWInterface::DPMSCapabilities()
status_t status_t
AccelerantHWInterface::GetAccelerantPath(BString &string) AccelerantHWInterface::GetAccelerantPath(BString& string)
{ {
image_info info; image_info info;
status_t status = get_image_info(fAccelerantImage, &info); status_t status = get_image_info(fAccelerantImage, &info);
@@ -1069,7 +1083,7 @@ AccelerantHWInterface::GetAccelerantPath(BString &string)
status_t status_t
AccelerantHWInterface::GetDriverPath(BString &string) AccelerantHWInterface::GetDriverPath(BString& string)
{ {
// TODO: this currently assumes that the accelerant's clone info // TODO: this currently assumes that the accelerant's clone info
// is always the path name of its driver (that's the case for // is always the path name of its driver (that's the case for
@@ -1082,7 +1096,7 @@ AccelerantHWInterface::GetDriverPath(BString &string)
if (getCloneInfo == NULL) if (getCloneInfo == NULL)
return B_NOT_SUPPORTED; return B_NOT_SUPPORTED;
getCloneInfo((void *)path); getCloneInfo((void*)path);
string.SetTo(path); string.SetTo(path);
return B_OK; return B_OK;
} }
@@ -1330,7 +1344,7 @@ AccelerantHWInterface::SetCursorVisible(bool visible)
void void
AccelerantHWInterface::MoveCursorTo(const float& x, const float& y) AccelerantHWInterface::MoveCursorTo(float x, float y)
{ {
HWInterface::MoveCursorTo(x, y); HWInterface::MoveCursorTo(x, y);
// if (LockExclusiveAccess()) { // if (LockExclusiveAccess()) {
@@ -1343,15 +1357,14 @@ AccelerantHWInterface::MoveCursorTo(const float& x, const float& y)
// #pragma mark - buffer access // #pragma mark - buffer access
RenderingBuffer*
RenderingBuffer *
AccelerantHWInterface::FrontBuffer() const AccelerantHWInterface::FrontBuffer() const
{ {
return fFrontBuffer; return fFrontBuffer;
} }
RenderingBuffer * RenderingBuffer*
AccelerantHWInterface::BackBuffer() const AccelerantHWInterface::BackBuffer() const
{ {
return fBackBuffer; return fBackBuffer;
+29 -28
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2005-2008, Haiku. * Copyright 2005-2009, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -27,43 +27,44 @@ public:
virtual status_t Initialize(); virtual status_t Initialize();
virtual status_t Shutdown(); virtual status_t Shutdown();
virtual status_t SetMode(const display_mode &mode); virtual status_t SetMode(const display_mode& mode);
virtual void GetMode(display_mode *mode); virtual void GetMode(display_mode* mode);
virtual status_t GetDeviceInfo(accelerant_device_info *info); virtual status_t GetDeviceInfo(accelerant_device_info* info);
virtual status_t GetFrameBufferConfig(frame_buffer_config& config); virtual status_t GetFrameBufferConfig(
frame_buffer_config& config);
virtual status_t GetModeList(display_mode **mode_list, virtual status_t GetModeList(display_mode** _modeList,
uint32 *count); uint32* _count);
virtual status_t GetPixelClockLimits(display_mode *mode, virtual status_t GetPixelClockLimits(display_mode* mode,
uint32 *low, uint32 *high); uint32* _low, uint32* _high);
virtual status_t GetTimingConstraints(display_timing_constraints *dtc); virtual status_t GetTimingConstraints(display_timing_constraints*
virtual status_t ProposeMode(display_mode *candidate, constraints);
const display_mode *low, virtual status_t ProposeMode(display_mode* candidate,
const display_mode *high); const display_mode* low,
const display_mode* high);
virtual status_t GetPreferredMode(display_mode* mode); virtual status_t GetPreferredMode(display_mode* mode);
virtual status_t GetMonitorInfo(monitor_info* info); virtual status_t GetMonitorInfo(monitor_info* info);
virtual sem_id RetraceSemaphore(); virtual sem_id RetraceSemaphore();
virtual status_t WaitForRetrace(bigtime_t timeout = B_INFINITE_TIMEOUT); virtual status_t WaitForRetrace(
bigtime_t timeout = B_INFINITE_TIMEOUT);
virtual status_t SetDPMSMode(const uint32 &state); virtual status_t SetDPMSMode(uint32 state);
virtual uint32 DPMSMode(); virtual uint32 DPMSMode();
virtual uint32 DPMSCapabilities(); virtual uint32 DPMSCapabilities();
virtual status_t GetAccelerantPath(BString &path); virtual status_t GetAccelerantPath(BString& path);
virtual status_t GetDriverPath(BString &path); virtual status_t GetDriverPath(BString& path);
// query for available hardware accleration // query for available hardware accleration
virtual uint32 AvailableHWAcceleration() const; virtual uint32 AvailableHWAcceleration() const;
// accelerated drawing // accelerated drawing
virtual void CopyRegion(const clipping_rect* sortedRectList, virtual void CopyRegion(const clipping_rect* sortedRectList,
uint32 count, uint32 count, int32 xOffset, int32 yOffset);
int32 xOffset, int32 yOffset);
virtual void FillRegion(/*const*/ BRegion& region, virtual void FillRegion(/*const*/ BRegion& region,
const rgb_color& color, const rgb_color& color, bool autoSync);
bool autoSync);
virtual void InvertRegion(/*const*/ BRegion& region); virtual void InvertRegion(/*const*/ BRegion& region);
virtual void Sync(); virtual void Sync();
@@ -86,8 +87,7 @@ public:
// cursor handling // cursor handling
virtual void SetCursor(ServerCursor* cursor); virtual void SetCursor(ServerCursor* cursor);
virtual void SetCursorVisible(bool visible); virtual void SetCursorVisible(bool visible);
virtual void MoveCursorTo(const float& x, virtual void MoveCursorTo(float x, float y);
const float& y);
// frame buffer access // frame buffer access
virtual RenderingBuffer* FrontBuffer() const; virtual RenderingBuffer* FrontBuffer() const;
@@ -119,10 +119,11 @@ private:
void _SetSystemPalette(); void _SetSystemPalette();
void _SetGrayscalePalette(); void _SetGrayscalePalette();
private:
int fCardFD; int fCardFD;
image_id fAccelerantImage; image_id fAccelerantImage;
GetAccelerantHook fAccelerantHook; GetAccelerantHook fAccelerantHook;
engine_token *fEngineToken; engine_token* fEngineToken;
sync_token fSyncToken; sync_token fSyncToken;
// required hooks - guaranteed to be valid // required hooks - guaranteed to be valid
@@ -176,10 +177,10 @@ private:
display_mode fDisplayMode; display_mode fDisplayMode;
bool fInitialModeSwitch; bool fInitialModeSwitch;
mutable fill_rect_params* fRectParams; mutable fill_rect_params* fRectParams;
mutable uint32 fRectParamsCount; mutable uint32 fRectParamsCount;
mutable blit_params* fBlitParams; mutable blit_params* fBlitParams;
mutable uint32 fBlitParamsCount; mutable uint32 fBlitParamsCount;
}; };
#endif // ACCELERANT_HW_INTERFACE_H #endif // ACCELERANT_HW_INTERFACE_H
+28 -31
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2005, Haiku. * Copyright 2002-2009, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -23,7 +23,8 @@ using std::nothrow;
BitmapHWInterface::BitmapHWInterface(ServerBitmap* bitmap) BitmapHWInterface::BitmapHWInterface(ServerBitmap* bitmap)
: HWInterface(false, false), :
HWInterface(false, false),
fBackBuffer(NULL), fBackBuffer(NULL),
fFrontBuffer(new(nothrow) BitmapBuffer(bitmap)) fFrontBuffer(new(nothrow) BitmapBuffer(bitmap))
{ {
@@ -54,8 +55,7 @@ BitmapHWInterface::Initialize()
if (fFrontBuffer->ColorSpace() != B_RGB32 if (fFrontBuffer->ColorSpace() != B_RGB32
&& fFrontBuffer->ColorSpace() != B_RGBA32) { && fFrontBuffer->ColorSpace() != B_RGBA32) {
BBitmap* backBitmap = new BBitmap(fFrontBuffer->Bounds(), BBitmap* backBitmap = new BBitmap(fFrontBuffer->Bounds(),
B_BITMAP_NO_SERVER_LINK, B_BITMAP_NO_SERVER_LINK, B_RGBA32);
B_RGBA32);
fBackBuffer = new BBitmapBuffer(backBitmap); fBackBuffer = new BBitmapBuffer(backBitmap);
ret = fBackBuffer->InitCheck(); ret = fBackBuffer->InitCheck();
@@ -66,9 +66,7 @@ BitmapHWInterface::Initialize()
// import the current contents of the bitmap // import the current contents of the bitmap
// into the back bitmap // into the back bitmap
backBitmap->ImportBits(fFrontBuffer->Bits(), backBitmap->ImportBits(fFrontBuffer->Bits(),
fFrontBuffer->BitsLength(), fFrontBuffer->BitsLength(), fFrontBuffer->BytesPerRow(), 0,
fFrontBuffer->BytesPerRow(),
0,
fFrontBuffer->ColorSpace()); fFrontBuffer->ColorSpace());
} }
} }
@@ -85,23 +83,22 @@ BitmapHWInterface::Shutdown()
status_t status_t
BitmapHWInterface::SetMode(const display_mode &mode) BitmapHWInterface::SetMode(const display_mode& mode)
{ {
return B_UNSUPPORTED; return B_UNSUPPORTED;
} }
void void
BitmapHWInterface::GetMode(display_mode *mode) BitmapHWInterface::GetMode(display_mode* mode)
{ {
if (mode) { if (mode != NULL)
memset(mode, 0, sizeof(display_mode)); memset(mode, 0, sizeof(display_mode));
}
} }
status_t status_t
BitmapHWInterface::GetDeviceInfo(accelerant_device_info *info) BitmapHWInterface::GetDeviceInfo(accelerant_device_info* info)
{ {
return B_UNSUPPORTED; return B_UNSUPPORTED;
} }
@@ -120,77 +117,79 @@ BitmapHWInterface::GetModeList(display_mode** modes, uint32 *count)
return B_UNSUPPORTED; return B_UNSUPPORTED;
} }
// GetPixelClockLimits
status_t status_t
BitmapHWInterface::GetPixelClockLimits(display_mode *mode, uint32 *low, uint32 *high) BitmapHWInterface::GetPixelClockLimits(display_mode* mode, uint32* low,
uint32* high)
{ {
return B_UNSUPPORTED; return B_UNSUPPORTED;
} }
// GetPixelClockLimits
status_t status_t
BitmapHWInterface::GetTimingConstraints(display_timing_constraints *dtc) BitmapHWInterface::GetTimingConstraints(display_timing_constraints* constraints)
{ {
return B_UNSUPPORTED; return B_UNSUPPORTED;
} }
// ProposeMode
status_t status_t
BitmapHWInterface::ProposeMode(display_mode *candidate, const display_mode *low, const display_mode *high) BitmapHWInterface::ProposeMode(display_mode* candidate, const display_mode* low,
const display_mode* high)
{ {
return B_UNSUPPORTED; return B_UNSUPPORTED;
} }
// RetraceSemaphore
sem_id sem_id
BitmapHWInterface::RetraceSemaphore() BitmapHWInterface::RetraceSemaphore()
{ {
return B_ERROR; return B_ERROR;
} }
// WaitForRetrace
status_t status_t
BitmapHWInterface::WaitForRetrace(bigtime_t timeout) BitmapHWInterface::WaitForRetrace(bigtime_t timeout)
{ {
return B_UNSUPPORTED; return B_UNSUPPORTED;
} }
// SetDPMSMode
status_t status_t
BitmapHWInterface::SetDPMSMode(const uint32 &state) BitmapHWInterface::SetDPMSMode(uint32 state)
{ {
return B_UNSUPPORTED; return B_UNSUPPORTED;
} }
// DPMSMode
uint32 uint32
BitmapHWInterface::DPMSMode() BitmapHWInterface::DPMSMode()
{ {
return 0; return 0;
} }
// DPMSCapabilities
uint32 uint32
BitmapHWInterface::DPMSCapabilities() BitmapHWInterface::DPMSCapabilities()
{ {
return 0; return 0;
} }
// FrontBuffer
RenderingBuffer * RenderingBuffer*
BitmapHWInterface::FrontBuffer() const BitmapHWInterface::FrontBuffer() const
{ {
return fFrontBuffer; return fFrontBuffer;
} }
// BackBuffer
RenderingBuffer * RenderingBuffer*
BitmapHWInterface::BackBuffer() const BitmapHWInterface::BackBuffer() const
{ {
return fBackBuffer; return fBackBuffer;
} }
// IsDoubleBuffered
bool bool
BitmapHWInterface::IsDoubleBuffered() const BitmapHWInterface::IsDoubleBuffered() const
{ {
@@ -200,5 +199,3 @@ BitmapHWInterface::IsDoubleBuffered() const
return HWInterface::IsDoubleBuffered(); return HWInterface::IsDoubleBuffered();
} }
+19 -16
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2005, Haiku. * Copyright 2005-2009, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -18,7 +18,7 @@ class BBitmapBuffer;
class BitmapHWInterface : public HWInterface { class BitmapHWInterface : public HWInterface {
public: public:
BitmapHWInterface(ServerBitmap* bitmap); BitmapHWInterface(ServerBitmap* bitmap);
virtual ~BitmapHWInterface(); virtual ~BitmapHWInterface();
@@ -26,25 +26,28 @@ class BitmapHWInterface : public HWInterface {
virtual status_t Shutdown(); virtual status_t Shutdown();
// overwrite all the meaningless functions with empty code // overwrite all the meaningless functions with empty code
virtual status_t SetMode(const display_mode &mode); virtual status_t SetMode(const display_mode& mode);
virtual void GetMode(display_mode *mode); virtual void GetMode(display_mode* mode);
virtual status_t GetDeviceInfo(accelerant_device_info *info); virtual status_t GetDeviceInfo(accelerant_device_info* info);
virtual status_t GetFrameBufferConfig(frame_buffer_config& config); virtual status_t GetFrameBufferConfig(
frame_buffer_config& config);
virtual status_t GetModeList(display_mode **mode_list, virtual status_t GetModeList(display_mode** _modeList,
uint32 *count); uint32* _count);
virtual status_t GetPixelClockLimits(display_mode *mode, virtual status_t GetPixelClockLimits(display_mode* mode,
uint32 *low, uint32 *high); uint32* _low, uint32* _high);
virtual status_t GetTimingConstraints(display_timing_constraints *dtc); virtual status_t GetTimingConstraints(display_timing_constraints*
virtual status_t ProposeMode(display_mode *candidate, constraints);
const display_mode *low, virtual status_t ProposeMode(display_mode* candidate,
const display_mode *high); const display_mode* low,
const display_mode* high);
virtual sem_id RetraceSemaphore(); virtual sem_id RetraceSemaphore();
virtual status_t WaitForRetrace(bigtime_t timeout = B_INFINITE_TIMEOUT); virtual status_t WaitForRetrace(
bigtime_t timeout = B_INFINITE_TIMEOUT);
virtual status_t SetDPMSMode(const uint32 &state); virtual status_t SetDPMSMode(uint32 state);
virtual uint32 DPMSMode(); virtual uint32 DPMSMode();
virtual uint32 DPMSCapabilities(); virtual uint32 DPMSCapabilities();
+146 -109
View File
@@ -1,15 +1,19 @@
/* /*
* Copyright 2001-2005, Haiku. * Copyright 2001-2009, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* DarkWyrm <[email protected]> * DarkWyrm <[email protected]>
* Michael Lotz <[email protected]> * Michael Lotz <[email protected]>
* Stephan Aßmus <[email protected]> * Stephan Aßmus <[email protected]>
*/ */
/** BView/BDirectWindow/Accelerant combination HWInterface
implementation */ /*! BView/BDirectWindow/Accelerant combination HWInterface implementation
*/
#include "DWindowHWInterface.h"
#include <malloc.h> #include <malloc.h>
#include <new> #include <new>
@@ -45,7 +49,6 @@
#include "ServerCursor.h" #include "ServerCursor.h"
#include "UpdateQueue.h" #include "UpdateQueue.h"
#include "DWindowHWInterface.h"
#ifdef DEBUG_DRIVER_MODULE #ifdef DEBUG_DRIVER_MODULE
# include <stdio.h> # include <stdio.h>
@@ -54,13 +57,14 @@
# define STRACE(x) ; # define STRACE(x) ;
#endif #endif
const unsigned char kEmptyCursor[] = { 16, 1, 0, 0, const unsigned char kEmptyCursor[] = { 16, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
// run_app_thread
static int32 static int32
run_app_thread(void* cookie) run_app_thread(void* cookie)
{ {
@@ -74,8 +78,9 @@ run_app_thread(void* cookie)
//#define INPUTSERVER_TEST_MODE 1 //#define INPUTSERVER_TEST_MODE 1
class DView : public BView { class DView : public BView {
public: public:
DView(BRect bounds); DView(BRect bounds);
virtual ~DView(); virtual ~DView();
@@ -87,7 +92,7 @@ private:
}; };
class DWindow : public BWindow { class DWindow : public BWindow {
public: public:
DWindow(BRect frame, DWindow(BRect frame,
DWindowHWInterface* interface, DWindowHWInterface* interface,
DWindowBuffer* buffer); DWindowBuffer* buffer);
@@ -99,26 +104,28 @@ class DWindow : public BWindow {
virtual void FrameMoved(BPoint newOffset); virtual void FrameMoved(BPoint newOffset);
private: private:
DWindowHWInterface* fHWInterface; DWindowHWInterface* fHWInterface;
DWindowBuffer* fBuffer; DWindowBuffer* fBuffer;
}; };
class DirectMessageFilter : public BMessageFilter { class DirectMessageFilter : public BMessageFilter {
public: public:
DirectMessageFilter(DView* view); DirectMessageFilter(DView* view);
virtual filter_result Filter(BMessage *message, BHandler **_target); virtual filter_result Filter(BMessage *message, BHandler** _target);
private: private:
DView* fView; DView* fView;
}; };
// #pragma mark - // #pragma mark -
DView::DView(BRect bounds) DView::DView(BRect bounds)
: BView(bounds, "graphics card view", B_FOLLOW_ALL, 0) :
BView(bounds, "graphics card view", B_FOLLOW_ALL, 0)
{ {
SetViewColor(B_TRANSPARENT_COLOR); SetViewColor(B_TRANSPARENT_COLOR);
#ifndef INPUTSERVER_TEST_MODE #ifndef INPUTSERVER_TEST_MODE
@@ -138,10 +145,10 @@ DView::~DView()
} }
// This function emulates the Input Server by sending the *exact* same kind of messages /*! This function emulates the Input Server by sending the *exact* same kind of
// to the server's port. Being we're using a regular window, it would make little sense messages to the server's port. Being we're using a regular window, it would
// to do anything else. make little sense to do anything else.
*/
void void
DView::ForwardMessage(BMessage* message) DView::ForwardMessage(BMessage* message)
{ {
@@ -169,14 +176,15 @@ DView::ForwardMessage(BMessage* message)
DirectMessageFilter::DirectMessageFilter(DView* view) DirectMessageFilter::DirectMessageFilter(DView* view)
: BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE), :
BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE),
fView(view) fView(view)
{ {
} }
filter_result filter_result
DirectMessageFilter::Filter(BMessage *message, BHandler **target) DirectMessageFilter::Filter(BMessage* message, BHandler** target)
{ {
switch (message->what) { switch (message->what) {
case B_KEY_DOWN: case B_KEY_DOWN:
@@ -211,9 +219,12 @@ DirectMessageFilter::Filter(BMessage *message, BHandler **target)
// #pragma mark - // #pragma mark -
DWindow::DWindow(BRect frame, DWindowHWInterface* interface, DWindowBuffer* buffer) DWindow::DWindow(BRect frame, DWindowHWInterface* interface,
: BWindow(frame, "Haiku App Server", B_TITLED_WINDOW_LOOK, DWindowBuffer* buffer)
B_FLOATING_ALL_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_NOT_MOVABLE), :
BWindow(frame, "Haiku App Server", B_TITLED_WINDOW_LOOK,
B_FLOATING_ALL_WINDOW_FEEL,
B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_NOT_MOVABLE),
fHWInterface(interface), fHWInterface(interface),
fBuffer(buffer) fBuffer(buffer)
{ {
@@ -229,7 +240,6 @@ DWindow::~DWindow()
} }
// QuitRequested
bool bool
DWindow::QuitRequested() DWindow::QuitRequested()
{ {
@@ -245,8 +255,9 @@ DWindow::QuitRequested()
// we don't quit on ourself, we let us be Quit()! // we don't quit on ourself, we let us be Quit()!
return false; return false;
} }
/* /*
// DirectConnected
void void
DWindow::DirectConnected(direct_buffer_info* info) DWindow::DirectConnected(direct_buffer_info* info)
{ {
@@ -273,20 +284,22 @@ DWindow::DirectConnected(direct_buffer_info* info)
} }
*/ */
// FrameMoved
void void
DWindow::FrameMoved(BPoint newOffset) DWindow::FrameMoved(BPoint newOffset)
{ {
fHWInterface->SetOffset((int32)newOffset.x, (int32)newOffset.y); fHWInterface->SetOffset((int32)newOffset.x, (int32)newOffset.y);
} }
// #pragma mark - // #pragma mark -
const int32 kDefaultParamsCount = 64; const int32 kDefaultParamsCount = 64;
DWindowHWInterface::DWindowHWInterface() DWindowHWInterface::DWindowHWInterface()
: HWInterface(), :
HWInterface(),
fFrontBuffer(new DWindowBuffer()), fFrontBuffer(new DWindowBuffer()),
fWindow(NULL), fWindow(NULL),
@@ -350,7 +363,7 @@ DWindowHWInterface::~DWindowHWInterface()
delete be_app; delete be_app;
} }
// Initialize
status_t status_t
DWindowHWInterface::Initialize() DWindowHWInterface::Initialize()
{ {
@@ -380,14 +393,14 @@ DWindowHWInterface::Initialize()
} }
/*! /*! \brief Opens a graphics device for read-write access
\brief Opens a graphics device for read-write access \param deviceNumber Number identifying which graphics card to open (1 for
\param deviceNumber Number identifying which graphics card to open (1 for first card) first card)
\return The file descriptor for the opened graphics device \return The file descriptor for the opened graphics device
The deviceNumber is relative to the number of graphics devices that can be successfully The deviceNumber is relative to the number of graphics devices that can be
opened. One represents the first card that can be successfully opened (not necessarily successfully opened. One represents the first card that can be successfully
the first one listed in the directory). opened (not necessarily the first one listed in the directory).
Graphics drivers must be able to be opened more than once, so we really get Graphics drivers must be able to be opened more than once, so we really get
the first working entry. the first working entry.
*/ */
@@ -481,7 +494,8 @@ DWindowHWInterface::_OpenAccelerant(int device)
accelerant_clone_info_size cloneInfoSize; accelerant_clone_info_size cloneInfoSize;
cloneInfoSize = (accelerant_clone_info_size)fAccelerantHook(B_ACCELERANT_CLONE_INFO_SIZE, NULL); cloneInfoSize = (accelerant_clone_info_size)fAccelerantHook(
B_ACCELERANT_CLONE_INFO_SIZE, NULL);
if (!cloneInfoSize) { if (!cloneInfoSize) {
STRACE(("unable to get B_ACCELERANT_CLONE_INFO_SIZE (%s)\n", path)); STRACE(("unable to get B_ACCELERANT_CLONE_INFO_SIZE (%s)\n", path));
unload_add_on(fAccelerantImage); unload_add_on(fAccelerantImage);
@@ -554,12 +568,17 @@ DWindowHWInterface::_SetupDefaultHooks()
fAccAcquireEngine = (acquire_engine)fAccelerantHook(B_ACQUIRE_ENGINE, NULL); fAccAcquireEngine = (acquire_engine)fAccelerantHook(B_ACQUIRE_ENGINE, NULL);
fAccReleaseEngine = (release_engine)fAccelerantHook(B_RELEASE_ENGINE, NULL); fAccReleaseEngine = (release_engine)fAccelerantHook(B_RELEASE_ENGINE, NULL);
fAccSyncToToken = (sync_to_token)fAccelerantHook(B_SYNC_TO_TOKEN, NULL); fAccSyncToToken = (sync_to_token)fAccelerantHook(B_SYNC_TO_TOKEN, NULL);
fAccGetModeCount = (accelerant_mode_count)fAccelerantHook(B_ACCELERANT_MODE_COUNT, NULL); fAccGetModeCount = (accelerant_mode_count)fAccelerantHook(
B_ACCELERANT_MODE_COUNT, NULL);
fAccGetModeList = (get_mode_list)fAccelerantHook(B_GET_MODE_LIST, NULL); fAccGetModeList = (get_mode_list)fAccelerantHook(B_GET_MODE_LIST, NULL);
fAccGetFrameBufferConfig = (get_frame_buffer_config)fAccelerantHook(B_GET_FRAME_BUFFER_CONFIG, NULL); fAccGetFrameBufferConfig = (get_frame_buffer_config)fAccelerantHook(
fAccSetDisplayMode = (set_display_mode)fAccelerantHook(B_SET_DISPLAY_MODE, NULL); B_GET_FRAME_BUFFER_CONFIG, NULL);
fAccGetDisplayMode = (get_display_mode)fAccelerantHook(B_GET_DISPLAY_MODE, NULL); fAccSetDisplayMode = (set_display_mode)fAccelerantHook(
fAccGetPixelClockLimits = (get_pixel_clock_limits)fAccelerantHook(B_GET_PIXEL_CLOCK_LIMITS, NULL); B_SET_DISPLAY_MODE, NULL);
fAccGetDisplayMode = (get_display_mode)fAccelerantHook(
B_GET_DISPLAY_MODE, NULL);
fAccGetPixelClockLimits = (get_pixel_clock_limits)fAccelerantHook(
B_GET_PIXEL_CLOCK_LIMITS, NULL);
if (!fAccAcquireEngine || !fAccReleaseEngine || !fAccGetFrameBufferConfig if (!fAccAcquireEngine || !fAccReleaseEngine || !fAccGetFrameBufferConfig
|| !fAccGetModeCount || !fAccGetModeList || !fAccSetDisplayMode || !fAccGetModeCount || !fAccGetModeList || !fAccSetDisplayMode
@@ -568,24 +587,28 @@ DWindowHWInterface::_SetupDefaultHooks()
} }
// optional // optional
fAccGetTimingConstraints = (get_timing_constraints)fAccelerantHook(B_GET_TIMING_CONSTRAINTS, NULL); fAccGetTimingConstraints = (get_timing_constraints)fAccelerantHook(
fAccProposeDisplayMode = (propose_display_mode)fAccelerantHook(B_PROPOSE_DISPLAY_MODE, NULL); B_GET_TIMING_CONSTRAINTS, NULL);
fAccProposeDisplayMode = (propose_display_mode)fAccelerantHook(
B_PROPOSE_DISPLAY_MODE, NULL);
// cursor // cursor
fAccSetCursorShape = (set_cursor_shape)fAccelerantHook(B_SET_CURSOR_SHAPE, NULL); fAccSetCursorShape = (set_cursor_shape)fAccelerantHook(
B_SET_CURSOR_SHAPE, NULL);
fAccMoveCursor = (move_cursor)fAccelerantHook(B_MOVE_CURSOR, NULL); fAccMoveCursor = (move_cursor)fAccelerantHook(B_MOVE_CURSOR, NULL);
fAccShowCursor = (show_cursor)fAccelerantHook(B_SHOW_CURSOR, NULL); fAccShowCursor = (show_cursor)fAccelerantHook(B_SHOW_CURSOR, NULL);
// update acceleration hooks // update acceleration hooks
// TODO: would actually have to pass a valid display_mode! // TODO: would actually have to pass a valid display_mode!
fAccFillRect = (fill_rectangle)fAccelerantHook(B_FILL_RECTANGLE, NULL); fAccFillRect = (fill_rectangle)fAccelerantHook(B_FILL_RECTANGLE, NULL);
fAccInvertRect = (invert_rectangle)fAccelerantHook(B_INVERT_RECTANGLE, NULL); fAccInvertRect = (invert_rectangle)fAccelerantHook(B_INVERT_RECTANGLE, NULL);
fAccScreenBlit = (screen_to_screen_blit)fAccelerantHook(B_SCREEN_TO_SCREEN_BLIT, NULL); fAccScreenBlit = (screen_to_screen_blit)fAccelerantHook(
B_SCREEN_TO_SCREEN_BLIT, NULL);
return B_OK; return B_OK;
} }
// _UpdateFrameBufferConfig
status_t status_t
DWindowHWInterface::_UpdateFrameBufferConfig() DWindowHWInterface::_UpdateFrameBufferConfig()
{ {
@@ -595,22 +618,20 @@ DWindowHWInterface::_UpdateFrameBufferConfig()
return B_ERROR; return B_ERROR;
} }
fFrontBuffer->SetTo(&config, fXOffset, fYOffset, fFrontBuffer->SetTo(&config, fXOffset, fYOffset, fDisplayMode.virtual_width,
fDisplayMode.virtual_width, fDisplayMode.virtual_height, (color_space)fDisplayMode.space);
fDisplayMode.virtual_height,
(color_space)fDisplayMode.space);
return B_OK; return B_OK;
} }
// Shutdown
status_t status_t
DWindowHWInterface::Shutdown() DWindowHWInterface::Shutdown()
{ {
printf("DWindowHWInterface::Shutdown()\n"); printf("DWindowHWInterface::Shutdown()\n");
if (fAccelerantHook) { if (fAccelerantHook) {
uninit_accelerant UninitAccelerant = (uninit_accelerant)fAccelerantHook(B_UNINIT_ACCELERANT, NULL); uninit_accelerant UninitAccelerant
= (uninit_accelerant)fAccelerantHook(B_UNINIT_ACCELERANT, NULL);
if (UninitAccelerant) if (UninitAccelerant)
UninitAccelerant(); UninitAccelerant();
} }
@@ -624,9 +645,9 @@ printf("DWindowHWInterface::Shutdown()\n");
return B_OK; return B_OK;
} }
// SetMode
status_t status_t
DWindowHWInterface::SetMode(const display_mode &mode) DWindowHWInterface::SetMode(const display_mode& mode)
{ {
AutoWriteLocker _(this); AutoWriteLocker _(this);
@@ -684,7 +705,8 @@ DWindowHWInterface::SetMode(const display_mode &mode)
if (ret < B_OK) if (ret < B_OK)
return ret; return ret;
fWindow = new DWindow(frame.OffsetByCopy(fXOffset, fYOffset), this, fFrontBuffer); fWindow = new DWindow(frame.OffsetByCopy(fXOffset, fYOffset), this,
fFrontBuffer);
// fire up the window thread but don't show it on screen yet // fire up the window thread but don't show it on screen yet
fWindow->Hide(); fWindow->Hide();
@@ -715,7 +737,7 @@ DWindowHWInterface::SetMode(const display_mode &mode)
return ret; return ret;
} }
// GetMode
void void
DWindowHWInterface::GetMode(display_mode* mode) DWindowHWInterface::GetMode(display_mode* mode)
{ {
@@ -725,9 +747,9 @@ DWindowHWInterface::GetMode(display_mode* mode)
} }
} }
// GetDeviceInfo
status_t status_t
DWindowHWInterface::GetDeviceInfo(accelerant_device_info *info) DWindowHWInterface::GetDeviceInfo(accelerant_device_info* info)
{ {
// We really don't have to provide anything here because this is strictly // We really don't have to provide anything here because this is strictly
// a software-only driver, but we'll have some fun, anyway. // a software-only driver, but we'll have some fun, anyway.
@@ -761,7 +783,7 @@ DWindowHWInterface::GetFrameBufferConfig(frame_buffer_config& config)
status_t status_t
DWindowHWInterface::GetModeList(display_mode **_modes, uint32 *_count) DWindowHWInterface::GetModeList(display_mode** _modes, uint32* _count)
{ {
AutoReadLocker _(this); AutoReadLocker _(this);
@@ -775,7 +797,7 @@ DWindowHWInterface::GetModeList(display_mode **_modes, uint32 *_count)
// const uint32 colors[] = {B_CMAP8, B_RGB15, B_RGB16, B_RGB32}; // const uint32 colors[] = {B_CMAP8, B_RGB15, B_RGB16, B_RGB32};
uint32 count = resolutionCount/* * 4*/; uint32 count = resolutionCount/* * 4*/;
display_mode *modes = new(nothrow) display_mode[count]; display_mode* modes = new(nothrow) display_mode[count];
if (modes == NULL) if (modes == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
@@ -815,35 +837,42 @@ DWindowHWInterface::GetModeList(display_mode **_modes, uint32 *_count)
return B_OK; return B_OK;
} }
status_t status_t
DWindowHWInterface::GetPixelClockLimits(display_mode *mode, uint32 *low, uint32 *high) DWindowHWInterface::GetPixelClockLimits(display_mode* mode, uint32* low,
uint32* high)
{ {
return B_ERROR; return B_ERROR;
} }
status_t status_t
DWindowHWInterface::GetTimingConstraints(display_timing_constraints *dtc) DWindowHWInterface::GetTimingConstraints(
display_timing_constraints* constraints)
{ {
return B_ERROR; return B_ERROR;
} }
status_t status_t
DWindowHWInterface::ProposeMode(display_mode *candidate, const display_mode *low, const display_mode *high) DWindowHWInterface::ProposeMode(display_mode* candidate,
const display_mode* low, const display_mode* high)
{ {
// We should be able to get away with this because we're not dealing with any // We should be able to get away with this because we're not dealing with
// specific hardware. This is a Good Thing(TM) because we can support any hardware // any specific hardware. This is a Good Thing(TM) because we can support
// we wish within reasonable expectaions and programmer laziness. :P // any hardware we wish within reasonable expectaions and programmer
// laziness. :P
return B_OK; return B_OK;
} }
// RetraceSemaphore
sem_id sem_id
DWindowHWInterface::RetraceSemaphore() DWindowHWInterface::RetraceSemaphore()
{ {
return -1; return -1;
} }
// WaitForRetrace
status_t status_t
DWindowHWInterface::WaitForRetrace(bigtime_t timeout = B_INFINITE_TIMEOUT) DWindowHWInterface::WaitForRetrace(bigtime_t timeout = B_INFINITE_TIMEOUT)
{ {
@@ -852,16 +881,16 @@ DWindowHWInterface::WaitForRetrace(bigtime_t timeout = B_INFINITE_TIMEOUT)
return screen.WaitForRetrace(timeout); return screen.WaitForRetrace(timeout);
} }
// SetDPMSMode
status_t status_t
DWindowHWInterface::SetDPMSMode(const uint32 &state) DWindowHWInterface::SetDPMSMode(uint32 state)
{ {
AutoWriteLocker _(this); AutoWriteLocker _(this);
return BScreen().SetDPMS(state); return BScreen().SetDPMS(state);
} }
// DPMSMode
uint32 uint32
DWindowHWInterface::DPMSMode() DWindowHWInterface::DPMSMode()
{ {
@@ -870,7 +899,7 @@ DWindowHWInterface::DPMSMode()
return BScreen().DPMSState(); return BScreen().DPMSState();
} }
// DPMSCapabilities
uint32 uint32
DWindowHWInterface::DPMSCapabilities() DWindowHWInterface::DPMSCapabilities()
{ {
@@ -879,7 +908,7 @@ DWindowHWInterface::DPMSCapabilities()
return BScreen().DPMSCapabilites(); return BScreen().DPMSCapabilites();
} }
// AvailableHardwareAcceleration
uint32 uint32
DWindowHWInterface::AvailableHWAcceleration() const DWindowHWInterface::AvailableHWAcceleration() const
{ {
@@ -897,19 +926,21 @@ DWindowHWInterface::AvailableHWAcceleration() const
return flags; return flags;
} }
// CopyRegion
void void
DWindowHWInterface::CopyRegion(const clipping_rect* sortedRectList, DWindowHWInterface::CopyRegion(const clipping_rect* sortedRectList,
uint32 count, int32 xOffset, int32 yOffset) uint32 count, int32 xOffset, int32 yOffset)
{ {
if (fAccScreenBlit && fAccAcquireEngine) { if (fAccScreenBlit && fAccAcquireEngine) {
if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken, &fEngineToken) >= B_OK) { if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken,
&fEngineToken) >= B_OK) {
// make sure the blit_params cache is large enough // make sure the blit_params cache is large enough
if (fBlitParamsCount < count) { if (fBlitParamsCount < count) {
fBlitParamsCount = (count / kDefaultParamsCount + 1) * kDefaultParamsCount; fBlitParamsCount = (count / kDefaultParamsCount + 1)
* kDefaultParamsCount;
// NOTE: realloc() could be used instead... // NOTE: realloc() could be used instead...
blit_params* params = new (nothrow) blit_params[fBlitParamsCount]; blit_params* params
= new(std::nothrow) blit_params[fBlitParamsCount];
if (params) { if (params) {
delete[] fBlitParams; delete[] fBlitParams;
fBlitParams = params; fBlitParams = params;
@@ -919,15 +950,21 @@ DWindowHWInterface::CopyRegion(const clipping_rect* sortedRectList,
} }
// convert the rects // convert the rects
for (uint32 i = 0; i < count; i++) { for (uint32 i = 0; i < count; i++) {
fBlitParams[i].src_left = (uint16)sortedRectList[i].left + fXOffset; fBlitParams[i].src_left
fBlitParams[i].src_top = (uint16)sortedRectList[i].top + fYOffset; = (uint16)sortedRectList[i].left + fXOffset;
fBlitParams[i].src_top
= (uint16)sortedRectList[i].top + fYOffset;
fBlitParams[i].dest_left = (uint16)sortedRectList[i].left + xOffset + fXOffset; fBlitParams[i].dest_left
fBlitParams[i].dest_top = (uint16)sortedRectList[i].top + yOffset + fYOffset; = (uint16)sortedRectList[i].left + xOffset + fXOffset;
fBlitParams[i].dest_top
= (uint16)sortedRectList[i].top + yOffset + fYOffset;
// NOTE: width and height are expressed as distance, not pixel count! // NOTE: width and height are expressed as distance, not count!
fBlitParams[i].width = (uint16)(sortedRectList[i].right - sortedRectList[i].left); fBlitParams[i].width = (uint16)(sortedRectList[i].right
fBlitParams[i].height = (uint16)(sortedRectList[i].bottom - sortedRectList[i].top); - sortedRectList[i].left);
fBlitParams[i].height = (uint16)(sortedRectList[i].bottom
- sortedRectList[i].top);
} }
// go // go
@@ -944,7 +981,7 @@ DWindowHWInterface::CopyRegion(const clipping_rect* sortedRectList,
} }
} }
// FillRegion
void void
DWindowHWInterface::FillRegion(/*const*/ BRegion& region, DWindowHWInterface::FillRegion(/*const*/ BRegion& region,
const rgb_color& color, bool autoSync) const rgb_color& color, bool autoSync)
@@ -952,7 +989,6 @@ DWindowHWInterface::FillRegion(/*const*/ BRegion& region,
if (fAccFillRect && fAccAcquireEngine) { if (fAccFillRect && fAccAcquireEngine) {
if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken, if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken,
&fEngineToken) >= B_OK) { &fEngineToken) >= B_OK) {
// convert the region // convert the region
uint32 count; uint32 count;
_RegionToRectParams(&region, &count); _RegionToRectParams(&region, &count);
@@ -971,13 +1007,13 @@ DWindowHWInterface::FillRegion(/*const*/ BRegion& region,
} }
} }
// InvertRegion
void void
DWindowHWInterface::InvertRegion(/*const*/ BRegion& region) DWindowHWInterface::InvertRegion(/*const*/ BRegion& region)
{ {
if (fAccInvertRect && fAccAcquireEngine) { if (fAccInvertRect && fAccAcquireEngine) {
if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken, &fEngineToken) >= B_OK) { if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken,
&fEngineToken) >= B_OK) {
// convert the region // convert the region
uint32 count; uint32 count;
_RegionToRectParams(&region, &count); _RegionToRectParams(&region, &count);
@@ -997,11 +1033,12 @@ DWindowHWInterface::InvertRegion(/*const*/ BRegion& region)
fprintf(stderr, "AcquireEngine failed!\n"); fprintf(stderr, "AcquireEngine failed!\n");
} }
} else { } else {
fprintf(stderr, "AccelerantHWInterface::InvertRegion() called, but hook not available!\n"); fprintf(stderr, "AccelerantHWInterface::InvertRegion() called, but "
"hook not available!\n");
} }
} }
// Sync
void void
DWindowHWInterface::Sync() DWindowHWInterface::Sync()
{ {
@@ -1009,35 +1046,35 @@ DWindowHWInterface::Sync()
fAccSyncToToken(&fSyncToken); fAccSyncToToken(&fSyncToken);
} }
// FrontBuffer
RenderingBuffer* RenderingBuffer*
DWindowHWInterface::FrontBuffer() const DWindowHWInterface::FrontBuffer() const
{ {
return fFrontBuffer; return fFrontBuffer;
} }
// BackBuffer
RenderingBuffer* RenderingBuffer*
DWindowHWInterface::BackBuffer() const DWindowHWInterface::BackBuffer() const
{ {
return fFrontBuffer; return fFrontBuffer;
} }
// IsDoubleBuffered
bool bool
DWindowHWInterface::IsDoubleBuffered() const DWindowHWInterface::IsDoubleBuffered() const
{ {
return false; return false;
} }
// Invalidate
status_t status_t
DWindowHWInterface::Invalidate(const BRect& frame) DWindowHWInterface::Invalidate(const BRect& frame)
{ {
return HWInterface::Invalidate(frame); return HWInterface::Invalidate(frame);
} }
// SetOffset
void void
DWindowHWInterface::SetOffset(int32 left, int32 top) DWindowHWInterface::SetOffset(int32 left, int32 top)
{ {
@@ -1054,16 +1091,18 @@ DWindowHWInterface::SetOffset(int32 left, int32 top)
WriteUnlock(); WriteUnlock();
} }
// _RegionToRectParams
void void
DWindowHWInterface::_RegionToRectParams(/*const*/ BRegion* region, DWindowHWInterface::_RegionToRectParams(/*const*/ BRegion* region,
uint32* count) const uint32* count) const
{ {
*count = region->CountRects(); *count = region->CountRects();
if (fRectParamsCount < *count) { if (fRectParamsCount < *count) {
fRectParamsCount = (*count / kDefaultParamsCount + 1) * kDefaultParamsCount; fRectParamsCount = (*count / kDefaultParamsCount + 1)
* kDefaultParamsCount;
// NOTE: realloc() could be used instead... // NOTE: realloc() could be used instead...
fill_rect_params* params = new (nothrow) fill_rect_params[fRectParamsCount]; fill_rect_params* params
= new(std::nothrow) fill_rect_params[fRectParamsCount];
if (params) { if (params) {
delete[] fRectParams; delete[] fRectParams;
fRectParams = params; fRectParams = params;
@@ -1081,7 +1120,7 @@ DWindowHWInterface::_RegionToRectParams(/*const*/ BRegion* region,
} }
} }
// _NativeColor
uint32 uint32
DWindowHWInterface::_NativeColor(const rgb_color& color) const DWindowHWInterface::_NativeColor(const rgb_color& color) const
{ {
@@ -1106,10 +1145,8 @@ DWindowHWInterface::_NativeColor(const rgb_color& color) const
case B_RGBA32_BIG: case B_RGBA32_BIG:
case B_RGB32_LITTLE: case B_RGB32_LITTLE:
case B_RGBA32_LITTLE: { case B_RGBA32_LITTLE: {
uint32 native = (color.alpha << 24) | uint32 native = (color.alpha << 24) | (color.red << 16)
(color.red << 16) | | (color.green << 8) | (color.blue);
(color.green << 8) |
(color.blue);
return native; return native;
} }
} }
+30 -30
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2005, Haiku. * Copyright 2005-2009, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -10,11 +10,12 @@
#define D_WINDOW_HW_INTERACE_H #define D_WINDOW_HW_INTERACE_H
#include "HWInterface.h"
#include <Accelerant.h> #include <Accelerant.h>
#include <Region.h> #include <Region.h>
#include <String.h> #include <String.h>
#include "HWInterface.h"
class DWindowBuffer; class DWindowBuffer;
class DWindow; class DWindow;
@@ -22,33 +23,35 @@ class UpdateQueue;
class DWindowHWInterface : public HWInterface { class DWindowHWInterface : public HWInterface {
public: public:
DWindowHWInterface(); DWindowHWInterface();
virtual ~DWindowHWInterface(); virtual ~DWindowHWInterface();
virtual status_t Initialize(); virtual status_t Initialize();
virtual status_t Shutdown(); virtual status_t Shutdown();
virtual status_t SetMode(const display_mode &mode); virtual status_t SetMode(const display_mode& mode);
virtual void GetMode(display_mode *mode); virtual void GetMode(display_mode* mode);
virtual status_t GetDeviceInfo(accelerant_device_info *info); virtual status_t GetDeviceInfo(accelerant_device_info* info);
virtual status_t GetFrameBufferConfig(frame_buffer_config& config); virtual status_t GetFrameBufferConfig(
frame_buffer_config& config);
virtual status_t GetModeList(display_mode **mode_list, virtual status_t GetModeList(display_mode** _modeList,
uint32 *count); uint32* _count);
virtual status_t GetPixelClockLimits(display_mode *mode, virtual status_t GetPixelClockLimits(display_mode* mode,
uint32 *low, uint32* _low, uint32* _high);
uint32 *high); virtual status_t GetTimingConstraints(display_timing_constraints*
virtual status_t GetTimingConstraints(display_timing_constraints *dtc); constraints);
virtual status_t ProposeMode(display_mode *candidate, virtual status_t ProposeMode(display_mode* candidate,
const display_mode *low, const display_mode* low,
const display_mode *high); const display_mode* high);
virtual sem_id RetraceSemaphore(); virtual sem_id RetraceSemaphore();
virtual status_t WaitForRetrace(bigtime_t timeout = B_INFINITE_TIMEOUT); virtual status_t WaitForRetrace(
bigtime_t timeout = B_INFINITE_TIMEOUT);
virtual status_t SetDPMSMode(const uint32 &state); virtual status_t SetDPMSMode(uint32 state);
virtual uint32 DPMSMode(); virtual uint32 DPMSMode();
virtual uint32 DPMSCapabilities(); virtual uint32 DPMSCapabilities();
@@ -56,11 +59,9 @@ class DWindowHWInterface : public HWInterface {
virtual uint32 AvailableHWAcceleration() const; virtual uint32 AvailableHWAcceleration() const;
virtual void CopyRegion(const clipping_rect* sortedRectList, virtual void CopyRegion(const clipping_rect* sortedRectList,
uint32 count, uint32 count, int32 xOffset, int32 yOffset);
int32 xOffset, int32 yOffset);
virtual void FillRegion(/*const*/ BRegion& region, virtual void FillRegion(/*const*/ BRegion& region,
const rgb_color& color, const rgb_color& color, bool autoSync);
bool autoSync);
virtual void InvertRegion(/*const*/ BRegion& region); virtual void InvertRegion(/*const*/ BRegion& region);
virtual void Sync(); virtual void Sync();
@@ -75,7 +76,7 @@ class DWindowHWInterface : public HWInterface {
// DWindowHWInterface // DWindowHWInterface
void SetOffset(int32 left, int32 top); void SetOffset(int32 left, int32 top);
private: private:
DWindowBuffer* fFrontBuffer; DWindowBuffer* fFrontBuffer;
DWindow* fWindow; DWindow* fWindow;
@@ -94,12 +95,11 @@ class DWindowHWInterface : public HWInterface {
uint32* count) const; uint32* count) const;
uint32 _NativeColor(const rgb_color& color) const; uint32 _NativeColor(const rgb_color& color) const;
private:
int fCardFD; int fCardFD;
image_id fAccelerantImage; image_id fAccelerantImage;
GetAccelerantHook fAccelerantHook; GetAccelerantHook fAccelerantHook;
engine_token *fEngineToken; engine_token* fEngineToken;
sync_token fSyncToken; sync_token fSyncToken;
// required hooks - guaranteed to be valid // required hooks - guaranteed to be valid
@@ -127,10 +127,10 @@ class DWindowHWInterface : public HWInterface {
BString fCardNameInDevFS; BString fCardNameInDevFS;
mutable fill_rect_params* fRectParams; mutable fill_rect_params* fRectParams;
mutable uint32 fRectParamsCount; mutable uint32 fRectParamsCount;
mutable blit_params* fBlitParams; mutable blit_params* fBlitParams;
mutable uint32 fBlitParamsCount; mutable uint32 fBlitParamsCount;
}; };
#endif // D_WINDOW_HW_INTERACE_H #endif // D_WINDOW_HW_INTERACE_H
+78 -62
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2005-2007, Haiku. * Copyright 2005-2009, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -40,7 +40,8 @@ HWInterfaceListener::~HWInterfaceListener()
HWInterface::HWInterface(bool doubleBuffered, bool enableUpdateQueue) HWInterface::HWInterface(bool doubleBuffered, bool enableUpdateQueue)
: MultiLocker("hw interface lock"), :
MultiLocker("hw interface lock"),
fCursorAreaBackup(NULL), fCursorAreaBackup(NULL),
fFloatingOverlaysLock("floating overlays lock"), fFloatingOverlaysLock("floating overlays lock"),
fCursor(NULL), fCursor(NULL),
@@ -58,7 +59,7 @@ HWInterface::HWInterface(bool doubleBuffered, bool enableUpdateQueue)
SetAsyncDoubleBuffered(doubleBuffered && enableUpdateQueue); SetAsyncDoubleBuffered(doubleBuffered && enableUpdateQueue);
} }
// destructor
HWInterface::~HWInterface() HWInterface::~HWInterface()
{ {
SetAsyncDoubleBuffered(false); SetAsyncDoubleBuffered(false);
@@ -70,7 +71,7 @@ HWInterface::~HWInterface()
delete fCursorAndDragBitmap; delete fCursorAndDragBitmap;
} }
// Initialize
status_t status_t
HWInterface::Initialize() HWInterface::Initialize()
{ {
@@ -151,18 +152,19 @@ HWInterface::SetCursor(ServerCursor* cursor)
fFloatingOverlaysLock.Unlock(); fFloatingOverlaysLock.Unlock();
} }
// Cursor
ServerCursorReference ServerCursorReference
HWInterface::Cursor() const HWInterface::Cursor() const
{ {
if (!fFloatingOverlaysLock.Lock()) if (!fFloatingOverlaysLock.Lock())
return ServerCursorReference(NULL); return ServerCursorReference(NULL);
ServerCursorReference reference(fCursor); ServerCursorReference reference(fCursor);
fFloatingOverlaysLock.Unlock(); fFloatingOverlaysLock.Unlock();
return reference; return reference;
} }
// SetCursorVisible
void void
HWInterface::SetCursorVisible(bool visible) HWInterface::SetCursorVisible(bool visible)
{ {
@@ -191,7 +193,7 @@ HWInterface::SetCursorVisible(bool visible)
fFloatingOverlaysLock.Unlock(); fFloatingOverlaysLock.Unlock();
} }
// IsCursorVisible
bool bool
HWInterface::IsCursorVisible() HWInterface::IsCursorVisible()
{ {
@@ -203,7 +205,7 @@ HWInterface::IsCursorVisible()
return visible; return visible;
} }
// ObscureCursor
void void
HWInterface::ObscureCursor() HWInterface::ObscureCursor()
{ {
@@ -217,9 +219,9 @@ HWInterface::ObscureCursor()
fFloatingOverlaysLock.Unlock(); fFloatingOverlaysLock.Unlock();
} }
// MoveCursorTo
void void
HWInterface::MoveCursorTo(const float& x, const float& y) HWInterface::MoveCursorTo(float x, float y)
{ {
if (!fFloatingOverlaysLock.Lock()) if (!fFloatingOverlaysLock.Lock())
return; return;
@@ -315,7 +317,8 @@ HWInterface::IsDoubleBuffered() const
} }
// * the object needs to be already locked! /*! The object needs to be already locked!
*/
status_t status_t
HWInterface::Invalidate(const BRect& frame) HWInterface::Invalidate(const BRect& frame)
{ {
@@ -340,7 +343,8 @@ HWInterface::Invalidate(const BRect& frame)
} }
// * the object must already be locked! /*! The object must already be locked!
*/
status_t status_t
HWInterface::CopyBackToFront(const BRect& frame) HWInterface::CopyBackToFront(const BRect& frame)
{ {
@@ -464,10 +468,8 @@ HWInterface::HideFloatingOverlays(const BRect& area)
if (!fFloatingOverlaysLock.Lock()) if (!fFloatingOverlaysLock.Lock())
return false; return false;
if (fCursorAreaBackup && !fCursorAreaBackup->cursor_hidden) { if (fCursorAreaBackup && !fCursorAreaBackup->cursor_hidden) {
BRect backupArea(fCursorAreaBackup->left, BRect backupArea(fCursorAreaBackup->left, fCursorAreaBackup->top,
fCursorAreaBackup->top, fCursorAreaBackup->right, fCursorAreaBackup->bottom);
fCursorAreaBackup->right,
fCursorAreaBackup->bottom);
if (area.Intersects(backupArea)) { if (area.Intersects(backupArea)) {
_RestoreCursorArea(); _RestoreCursorArea();
// do not unlock the cursor lock // do not unlock the cursor lock
@@ -495,9 +497,9 @@ HWInterface::HideFloatingOverlays()
void void
HWInterface::ShowFloatingOverlays() HWInterface::ShowFloatingOverlays()
{ {
if (fCursorAreaBackup && fCursorAreaBackup->cursor_hidden) { if (fCursorAreaBackup && fCursorAreaBackup->cursor_hidden)
_DrawCursor(_CursorFrame()); _DrawCursor(_CursorFrame());
}
fFloatingOverlaysLock.Unlock(); fFloatingOverlaysLock.Unlock();
} }
@@ -524,10 +526,10 @@ HWInterface::RemoveListener(HWInterfaceListener* listener)
// #pragma mark - // #pragma mark -
// * default implementation, can be used as fallback or for /*! Default implementation, can be used as fallback or for software cursor.
// software cursor \param area is where we potentially draw the cursor, the cursor
// * area is where we potentially draw the cursor, the cursor might be somewhere else, in which case this function does nothing
// might be somewhere else, in which case this function does nothing */
void void
HWInterface::_DrawCursor(IntRect area) const HWInterface::_DrawCursor(IntRect area) const
{ {
@@ -641,10 +643,11 @@ HWInterface::_DrawCursor(IntRect area) const
} }
// * source is assumed to be already at the right offset /*! - source is assumed to be already at the right offset
// * source is assumed to be in B_RGBA32 format - source is assumed to be in B_RGBA32 format
// * location in front buffer is calculated - location in front buffer is calculated
// * conversion from B_RGBA32 to format of front buffer is taken care of - conversion from B_RGBA32 to format of front buffer is taken care of
*/
void void
HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y, HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
int32 right, int32 bottom) const int32 right, int32 bottom) const
@@ -657,7 +660,8 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
// transfer, handle colorspace conversion // transfer, handle colorspace conversion
switch (frontBuffer->ColorSpace()) { switch (frontBuffer->ColorSpace()) {
case B_RGB32: case B_RGB32:
case B_RGBA32: { case B_RGBA32:
{
int32 bytes = (right - x + 1) * 4; int32 bytes = (right - x + 1) * 4;
if (bytes > 0) { if (bytes > 0) {
@@ -673,8 +677,9 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
} }
break; break;
} }
// NOTE: on R5, B_RGB24 bitmaps are not supported by DrawBitmap()
case B_RGB24: { case B_RGB24:
{
// offset to left top pixel in dest buffer // offset to left top pixel in dest buffer
dst += y * dstBPR + x * 3; dst += y * dstBPR + x * 3;
int32 left = x; int32 left = x;
@@ -694,7 +699,9 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
} }
break; break;
} }
case B_RGB16: {
case B_RGB16:
{
// offset to left top pixel in dest buffer // offset to left top pixel in dest buffer
dst += y * dstBPR + x * 2; dst += y * dstBPR + x * 2;
int32 left = x; int32 left = x;
@@ -704,9 +711,8 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
uint8* srcHandle = src; uint8* srcHandle = src;
uint16* dstHandle = (uint16*)dst; uint16* dstHandle = (uint16*)dst;
for (x = left; x <= right; x++) { for (x = left; x <= right; x++) {
*dstHandle = (uint16)(((srcHandle[2] & 0xf8) << 8) | *dstHandle = (uint16)(((srcHandle[2] & 0xf8) << 8)
((srcHandle[1] & 0xfc) << 3) | | ((srcHandle[1] & 0xfc) << 3) | (srcHandle[0] >> 3));
(srcHandle[0] >> 3));
dstHandle ++; dstHandle ++;
srcHandle += 4; srcHandle += 4;
} }
@@ -715,8 +721,10 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
} }
break; break;
} }
case B_RGB15: case B_RGB15:
case B_RGBA15: { case B_RGBA15:
{
// offset to left top pixel in dest buffer // offset to left top pixel in dest buffer
dst += y * dstBPR + x * 2; dst += y * dstBPR + x * 2;
int32 left = x; int32 left = x;
@@ -726,9 +734,8 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
uint8* srcHandle = src; uint8* srcHandle = src;
uint16* dstHandle = (uint16*)dst; uint16* dstHandle = (uint16*)dst;
for (x = left; x <= right; x++) { for (x = left; x <= right; x++) {
*dstHandle = (uint16)(((srcHandle[2] & 0xf8) << 7) | *dstHandle = (uint16)(((srcHandle[2] & 0xf8) << 7)
((srcHandle[1] & 0xf8) << 2) | | ((srcHandle[1] & 0xf8) << 2) | (srcHandle[0] >> 3));
(srcHandle[0] >> 3));
dstHandle ++; dstHandle ++;
srcHandle += 4; srcHandle += 4;
} }
@@ -737,7 +744,9 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
} }
break; break;
} }
case B_CMAP8: {
case B_CMAP8:
{
const color_map *colorMap = SystemColorMap(); const color_map *colorMap = SystemColorMap();
// offset to left top pixel in dest buffer // offset to left top pixel in dest buffer
dst += y * dstBPR + x; dst += y * dstBPR + x;
@@ -749,7 +758,8 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
uint8* srcHandle = src; uint8* srcHandle = src;
uint8* dstHandle = dst; uint8* dstHandle = dst;
for (x = left; x <= right; x++) { for (x = left; x <= right; x++) {
index = ((srcHandle[2] & 0xf8) << 7) | ((srcHandle[1] & 0xf8) << 2) | (srcHandle[0] >> 3); index = ((srcHandle[2] & 0xf8) << 7)
| ((srcHandle[1] & 0xf8) << 2) | (srcHandle[0] >> 3);
*dstHandle = colorMap->index_map[index]; *dstHandle = colorMap->index_map[index];
dstHandle ++; dstHandle ++;
srcHandle += 4; srcHandle += 4;
@@ -760,6 +770,7 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
break; break;
} }
case B_GRAY8: case B_GRAY8:
if (frontBuffer->Width() > dstBPR) { if (frontBuffer->Width() > dstBPR) {
// VGA 16 color grayscale planar mode // VGA 16 color grayscale planar mode
@@ -771,7 +782,8 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
args.top = y; args.top = y;
args.right = right; args.right = right;
args.bottom = bottom; args.bottom = bottom;
if (ioctl(fVGADevice, VGA_PLANAR_BLIT, &args, sizeof(args)) == 0) if (ioctl(fVGADevice, VGA_PLANAR_BLIT, &args, sizeof(args))
== 0)
break; break;
} }
@@ -822,7 +834,8 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
uint8* srcHandle = src; uint8* srcHandle = src;
uint8* dstHandle = dst; uint8* dstHandle = dst;
for (x = left; x <= right; x++) { for (x = left; x <= right; x++) {
*dstHandle = (308 * srcHandle[2] + 600 * srcHandle[1] + 116 * srcHandle[0]) / 1024; *dstHandle = (308 * srcHandle[2] + 600 * srcHandle[1]
+ 116 * srcHandle[0]) / 1024;
dstHandle ++; dstHandle ++;
srcHandle += 4; srcHandle += 4;
} }
@@ -833,14 +846,15 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
break; break;
default: default:
fprintf(stderr, "HWInterface::CopyBackToFront() - unsupported front " fprintf(stderr, "HWInterface::CopyBackToFront() - unsupported "
"buffer format! (0x%x)\n", frontBuffer->ColorSpace()); "front buffer format! (0x%x)\n", frontBuffer->ColorSpace());
break; break;
} }
} }
// PRE: the object must be locked /*! The object must be locked
*/
IntRect IntRect
HWInterface::_CursorFrame() const HWInterface::_CursorFrame() const
{ {
@@ -857,25 +871,23 @@ void
HWInterface::_RestoreCursorArea() const HWInterface::_RestoreCursorArea() const
{ {
if (fCursorAreaBackup && !fCursorAreaBackup->cursor_hidden) { if (fCursorAreaBackup && !fCursorAreaBackup->cursor_hidden) {
_CopyToFront(fCursorAreaBackup->buffer, _CopyToFront(fCursorAreaBackup->buffer, fCursorAreaBackup->bpr,
fCursorAreaBackup->bpr, fCursorAreaBackup->left, fCursorAreaBackup->top,
fCursorAreaBackup->left, fCursorAreaBackup->right, fCursorAreaBackup->bottom);
fCursorAreaBackup->top,
fCursorAreaBackup->right,
fCursorAreaBackup->bottom);
fCursorAreaBackup->cursor_hidden = true; fCursorAreaBackup->cursor_hidden = true;
} }
} }
// _AdoptDragBitmap
void void
HWInterface::_AdoptDragBitmap(const ServerBitmap* bitmap, const BPoint& offset) HWInterface::_AdoptDragBitmap(const ServerBitmap* bitmap, const BPoint& offset)
{ {
// TODO: support other colorspaces/convert bitmap // TODO: support other colorspaces/convert bitmap
if (bitmap && !(bitmap->ColorSpace() == B_RGB32 if (bitmap && !(bitmap->ColorSpace() == B_RGB32
|| bitmap->ColorSpace() == B_RGBA32)) { || bitmap->ColorSpace() == B_RGBA32)) {
fprintf(stderr, "HWInterface::_AdoptDragBitmap() - bitmap has yet unsupported colorspace\n"); fprintf(stderr, "HWInterface::_AdoptDragBitmap() - bitmap has yet "
"unsupported colorspace\n");
return; return;
} }
@@ -910,8 +922,7 @@ HWInterface::_AdoptDragBitmap(const ServerBitmap* bitmap, const BPoint& offset)
bitmapFrame.OffsetBy(shift); bitmapFrame.OffsetBy(shift);
fCursorAndDragBitmap = new ServerCursor(combindedBounds, fCursorAndDragBitmap = new ServerCursor(combindedBounds,
bitmap->ColorSpace(), 0, bitmap->ColorSpace(), 0, hotspot + shift);
hotspot + shift);
// clear the combined buffer // clear the combined buffer
uint8* dst = (uint8*)fCursorAndDragBitmap->Bits(); uint8* dst = (uint8*)fCursorAndDragBitmap->Bits();
@@ -923,7 +934,8 @@ HWInterface::_AdoptDragBitmap(const ServerBitmap* bitmap, const BPoint& offset)
uint8* src = (uint8*)bitmap->Bits(); uint8* src = (uint8*)bitmap->Bits();
uint32 srcBPR = bitmap->BytesPerRow(); uint32 srcBPR = bitmap->BytesPerRow();
dst += (int32)bitmapFrame.top * dstBPR + (int32)bitmapFrame.left * 4; dst += (int32)bitmapFrame.top * dstBPR
+ (int32)bitmapFrame.left * 4;
uint32 width = bitmapFrame.IntegerWidth() + 1; uint32 width = bitmapFrame.IntegerWidth() + 1;
uint32 height = bitmapFrame.IntegerHeight() + 1; uint32 height = bitmapFrame.IntegerHeight() + 1;
@@ -936,7 +948,8 @@ HWInterface::_AdoptDragBitmap(const ServerBitmap* bitmap, const BPoint& offset)
// compose cursor into combined buffer // compose cursor into combined buffer
dst = (uint8*)fCursorAndDragBitmap->Bits(); dst = (uint8*)fCursorAndDragBitmap->Bits();
dst += (int32)cursorFrame.top * dstBPR + (int32)cursorFrame.left * 4; dst += (int32)cursorFrame.top * dstBPR
+ (int32)cursorFrame.left * 4;
src = (uint8*)fCursor->Bits(); src = (uint8*)fCursor->Bits();
srcBPR = fCursor->BytesPerRow(); srcBPR = fCursor->BytesPerRow();
@@ -959,12 +972,16 @@ HWInterface::_AdoptDragBitmap(const ServerBitmap* bitmap, const BPoint& offset)
d[3] = 255; d[3] = 255;
} else { } else {
uint8 alphaRest = 255 - s[3]; uint8 alphaRest = 255 - s[3];
uint32 alphaTemp = (65025 - alphaRest * (255 - d[3])); uint32 alphaTemp
= (65025 - alphaRest * (255 - d[3]));
uint32 alphaDest = d[3] * alphaRest; uint32 alphaDest = d[3] * alphaRest;
uint32 alphaSrc = 255 * s[3]; uint32 alphaSrc = 255 * s[3];
d[0] = (d[0] * alphaDest + s[0] * alphaSrc) / alphaTemp; d[0] = (d[0] * alphaDest + s[0] * alphaSrc)
d[1] = (d[1] * alphaDest + s[1] * alphaSrc) / alphaTemp; / alphaTemp;
d[2] = (d[2] * alphaDest + s[2] * alphaSrc) / alphaTemp; d[1] = (d[1] * alphaDest + s[1] * alphaSrc)
/ alphaTemp;
d[2] = (d[2] * alphaDest + s[2] * alphaSrc)
/ alphaTemp;
d[3] = alphaTemp / 255; d[3] = alphaTemp / 255;
} }
} }
@@ -998,8 +1015,7 @@ HWInterface::_AdoptDragBitmap(const ServerBitmap* bitmap, const BPoint& offset)
} }
} else { } else {
fCursorAndDragBitmap = new ServerCursor(bitmap->Bits(), fCursorAndDragBitmap = new ServerCursor(bitmap->Bits(),
bitmapFrame.IntegerWidth() + 1, bitmapFrame.IntegerWidth() + 1, bitmapFrame.IntegerHeight() + 1,
bitmapFrame.IntegerHeight() + 1,
bitmap->ColorSpace()); bitmap->ColorSpace());
fCursorAndDragBitmap->SetHotSpot(BPoint(-offset.x, -offset.y)); fCursorAndDragBitmap->SetHotSpot(BPoint(-offset.x, -offset.y));
} }
+45 -39
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2005-2007, Haiku. * Copyright 2005-2009, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -9,12 +9,6 @@
#define HW_INTERFACE_H #define HW_INTERFACE_H
#include "IntRect.h"
#include "MultiLocker.h"
#include "ServerCursor.h"
#include <video_overlay.h>
#include <Accelerant.h> #include <Accelerant.h>
#include <GraphicsCard.h> #include <GraphicsCard.h>
#include <List.h> #include <List.h>
@@ -22,6 +16,12 @@
#include <OS.h> #include <OS.h>
#include <Region.h> #include <Region.h>
#include <video_overlay.h>
#include "IntRect.h"
#include "MultiLocker.h"
#include "ServerCursor.h"
class Overlay; class Overlay;
class RenderingBuffer; class RenderingBuffer;
@@ -29,22 +29,25 @@ class ServerBitmap;
class UpdateQueue; class UpdateQueue;
class BString; class BString;
enum { enum {
HW_ACC_COPY_REGION = 0x00000001, HW_ACC_COPY_REGION = 0x00000001,
HW_ACC_FILL_REGION = 0x00000002, HW_ACC_FILL_REGION = 0x00000002,
HW_ACC_INVERT_REGION = 0x00000004, HW_ACC_INVERT_REGION = 0x00000004,
}; };
class HWInterfaceListener { class HWInterfaceListener {
public: public:
HWInterfaceListener(); HWInterfaceListener();
virtual ~HWInterfaceListener(); virtual ~HWInterfaceListener();
virtual void FrameBufferChanged() = 0; virtual void FrameBufferChanged() = 0;
}; };
class HWInterface : protected MultiLocker { class HWInterface : protected MultiLocker {
public: public:
HWInterface(bool doubleBuffered = false, HWInterface(bool doubleBuffered = false,
bool enableUpdateQueue = true); bool enableUpdateQueue = true);
virtual ~HWInterface(); virtual ~HWInterface();
@@ -52,12 +55,14 @@ class HWInterface : protected MultiLocker {
// locking // locking
bool LockParallelAccess() { return ReadLock(); } bool LockParallelAccess() { return ReadLock(); }
#if DEBUG #if DEBUG
bool IsParallelAccessLocked() { return IsReadLocked(); } bool IsParallelAccessLocked()
{ return IsReadLocked(); }
#endif #endif
void UnlockParallelAccess() { ReadUnlock(); } void UnlockParallelAccess() { ReadUnlock(); }
bool LockExclusiveAccess() { return WriteLock(); } bool LockExclusiveAccess() { return WriteLock(); }
bool IsExclusiveAccessLocked() { return IsWriteLocked(); } bool IsExclusiveAccessLocked()
{ return IsWriteLocked(); }
void UnlockExclusiveAccess() { WriteUnlock(); } void UnlockExclusiveAccess() { WriteUnlock(); }
// You need to WriteLock // You need to WriteLock
@@ -65,32 +70,34 @@ class HWInterface : protected MultiLocker {
virtual status_t Shutdown() = 0; virtual status_t Shutdown() = 0;
// screen mode stuff // screen mode stuff
virtual status_t SetMode(const display_mode &mode) = 0; virtual status_t SetMode(const display_mode& mode) = 0;
virtual void GetMode(display_mode *mode) = 0; virtual void GetMode(display_mode* mode) = 0;
virtual status_t GetDeviceInfo(accelerant_device_info *info) = 0; virtual status_t GetDeviceInfo(accelerant_device_info* info) = 0;
virtual status_t GetFrameBufferConfig(frame_buffer_config& config) = 0; virtual status_t GetFrameBufferConfig(
virtual status_t GetModeList(display_mode **mode_list, frame_buffer_config& config) = 0;
uint32 *count) = 0; virtual status_t GetModeList(display_mode** _modeList,
virtual status_t GetPixelClockLimits(display_mode *mode, uint32* _count) = 0;
uint32 *low, virtual status_t GetPixelClockLimits(display_mode* mode,
uint32 *high) = 0; uint32* _low, uint32* _high) = 0;
virtual status_t GetTimingConstraints(display_timing_constraints *dtc) = 0; virtual status_t GetTimingConstraints(display_timing_constraints*
virtual status_t ProposeMode(display_mode *candidate, constraints) = 0;
const display_mode *low, virtual status_t ProposeMode(display_mode* candidate,
const display_mode *high) = 0; const display_mode* low,
const display_mode* high) = 0;
virtual status_t GetPreferredMode(display_mode* mode); virtual status_t GetPreferredMode(display_mode* mode);
virtual status_t GetMonitorInfo(monitor_info* info); virtual status_t GetMonitorInfo(monitor_info* info);
virtual sem_id RetraceSemaphore() = 0; virtual sem_id RetraceSemaphore() = 0;
virtual status_t WaitForRetrace(bigtime_t timeout = B_INFINITE_TIMEOUT) = 0; virtual status_t WaitForRetrace(
bigtime_t timeout = B_INFINITE_TIMEOUT) = 0;
virtual status_t SetDPMSMode(const uint32 &state) = 0; virtual status_t SetDPMSMode(uint32 state) = 0;
virtual uint32 DPMSMode() = 0; virtual uint32 DPMSMode() = 0;
virtual uint32 DPMSCapabilities() = 0; virtual uint32 DPMSCapabilities() = 0;
virtual status_t GetAccelerantPath(BString &path); virtual status_t GetAccelerantPath(BString& path);
virtual status_t GetDriverPath(BString &path); virtual status_t GetDriverPath(BString& path);
// query for available hardware accleration and perform it // query for available hardware accleration and perform it
// (Initialize() must have been called already) // (Initialize() must have been called already)
@@ -98,11 +105,10 @@ class HWInterface : protected MultiLocker {
{ return 0; } { return 0; }
virtual void CopyRegion(const clipping_rect* sortedRectList, virtual void CopyRegion(const clipping_rect* sortedRectList,
uint32 count, uint32 count, int32 xOffset, int32 yOffset)
int32 xOffset, int32 yOffset) {} {}
virtual void FillRegion(/*const*/ BRegion& region, virtual void FillRegion(/*const*/ BRegion& region,
const rgb_color& color, const rgb_color& color, bool autoSync) {}
bool autoSync) {}
virtual void InvertRegion(/*const*/ BRegion& region) {} virtual void InvertRegion(/*const*/ BRegion& region) {}
virtual void Sync() {} virtual void Sync() {}
@@ -113,8 +119,7 @@ class HWInterface : protected MultiLocker {
virtual void SetCursorVisible(bool visible); virtual void SetCursorVisible(bool visible);
bool IsCursorVisible(); bool IsCursorVisible();
virtual void ObscureCursor(); virtual void ObscureCursor();
virtual void MoveCursorTo(const float& x, virtual void MoveCursorTo(float x, float y);
const float& y);
BPoint CursorPosition(); BPoint CursorPosition();
void SetDragBitmap(const ServerBitmap* bitmap, void SetDragBitmap(const ServerBitmap* bitmap,
@@ -174,14 +179,13 @@ public:
bool AddListener(HWInterfaceListener* listener); bool AddListener(HWInterfaceListener* listener);
void RemoveListener(HWInterfaceListener* listener); void RemoveListener(HWInterfaceListener* listener);
protected: protected:
// implement this in derived classes // implement this in derived classes
virtual void _DrawCursor(IntRect area) const; virtual void _DrawCursor(IntRect area) const;
// does the actual transfer and handles color space conversion // does the actual transfer and handles color space conversion
void _CopyToFront(uint8* src, uint32 srcBPR, void _CopyToFront(uint8* src, uint32 srcBPR, int32 x,
int32 x, int32 y, int32 y, int32 right, int32 bottom) const;
int32 right, int32 bottom) const;
IntRect _CursorFrame() const; IntRect _CursorFrame() const;
void _RestoreCursorArea() const; void _RestoreCursorArea() const;
@@ -210,10 +214,12 @@ public:
bottom = -1; bottom = -1;
cursor_hidden = true; cursor_hidden = true;
} }
~buffer_clip() ~buffer_clip()
{ {
delete[] buffer; delete[] buffer;
} }
uint8* buffer; uint8* buffer;
int32 left; int32 left;
int32 top; int32 top;
@@ -239,7 +245,7 @@ public:
bool fDoubleBuffered; bool fDoubleBuffered;
int fVGADevice; int fVGADevice;
private: private:
UpdateQueue* fUpdateExecutor; UpdateQueue* fUpdateExecutor;
BList fListeners; BList fListeners;
+79 -66
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2005, Haiku. * Copyright 2001-2009, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -7,7 +7,11 @@
* Stephan Aßmus <superstippi@gmx.de> * Stephan Aßmus <superstippi@gmx.de>
*/ */
/** BView/BWindow combination HWInterface implementation */
/*! BView/BWindow combination HWInterface implementation */
#include "ViewHWInterface.h"
#include <new> #include <new>
#include <stdio.h> #include <stdio.h>
@@ -33,7 +37,6 @@
#include "ServerCursor.h" #include "ServerCursor.h"
#include "UpdateQueue.h" #include "UpdateQueue.h"
#include "ViewHWInterface.h"
#ifdef DEBUG_DRIVER_MODULE #ifdef DEBUG_DRIVER_MODULE
# include <stdio.h> # include <stdio.h>
@@ -42,17 +45,20 @@
# define STRACE(x) ; # define STRACE(x) ;
#endif #endif
const unsigned char kEmptyCursor[] = { 16, 1, 0, 0, const unsigned char kEmptyCursor[] = { 16, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
static const bool kDefaultDoubleBuffered = true;
enum { enum {
MSG_UPDATE = 'updt', MSG_UPDATE = 'updt'
}; };
// string_for_color_space
const char* const char*
string_for_color_space(color_space format) string_for_color_space(color_space format)
{ {
@@ -91,7 +97,7 @@ string_for_color_space(color_space format)
return name; return name;
} }
// run_app_thread
static int32 static int32
run_app_thread(void* cookie) run_app_thread(void* cookie)
{ {
@@ -105,8 +111,9 @@ run_app_thread(void* cookie)
//#define INPUTSERVER_TEST_MODE 1 //#define INPUTSERVER_TEST_MODE 1
class CardView : public BView { class CardView : public BView {
public: public:
CardView(BRect bounds); CardView(BRect bounds);
virtual ~CardView(); virtual ~CardView();
@@ -115,7 +122,7 @@ class CardView : public BView {
virtual void MessageReceived(BMessage* message); virtual void MessageReceived(BMessage* message);
// CardView // CardView
void SetBitmap(const BBitmap* bimtap); void SetBitmap(const BBitmap* bitmap);
void ForwardMessage(BMessage* message = NULL); void ForwardMessage(BMessage* message = NULL);
@@ -125,7 +132,7 @@ private:
}; };
class CardWindow : public BWindow { class CardWindow : public BWindow {
public: public:
CardWindow(BRect frame); CardWindow(BRect frame);
virtual ~CardWindow(); virtual ~CardWindow();
@@ -136,7 +143,7 @@ class CardWindow : public BWindow {
void SetBitmap(const BBitmap* bitmap); void SetBitmap(const BBitmap* bitmap);
void Invalidate(const BRect& area); void Invalidate(const BRect& area);
private: private:
CardView* fView; CardView* fView;
BMessageRunner* fUpdateRunner; BMessageRunner* fUpdateRunner;
BRegion fUpdateRegion; BRegion fUpdateRegion;
@@ -144,20 +151,22 @@ class CardWindow : public BWindow {
}; };
class CardMessageFilter : public BMessageFilter { class CardMessageFilter : public BMessageFilter {
public: public:
CardMessageFilter(CardView* view); CardMessageFilter(CardView* view);
virtual filter_result Filter(BMessage *message, BHandler **_target); virtual filter_result Filter(BMessage* message, BHandler** _target);
private: private:
CardView* fView; CardView* fView;
}; };
// #pragma mark - // #pragma mark -
CardView::CardView(BRect bounds) CardView::CardView(BRect bounds)
: BView(bounds, "graphics card view", B_FOLLOW_ALL, B_WILL_DRAW), :
BView(bounds, "graphics card view", B_FOLLOW_ALL, B_WILL_DRAW),
fBitmap(NULL) fBitmap(NULL)
{ {
SetViewColor(B_TRANSPARENT_32_BIT); SetViewColor(B_TRANSPARENT_32_BIT);
@@ -179,25 +188,24 @@ CardView::~CardView()
} }
// AttachedToWindow
void void
CardView::AttachedToWindow() CardView::AttachedToWindow()
{ {
} }
// Draw
void void
CardView::Draw(BRect updateRect) CardView::Draw(BRect updateRect)
{ {
if (fBitmap) { if (fBitmap != NULL)
DrawBitmapAsync(fBitmap, updateRect, updateRect); DrawBitmapAsync(fBitmap, updateRect, updateRect);
}
} }
// These functions emulate the Input Server by sending the *exact* same kind of messages
// to the server's port. Being we're using a regular window, it would make little sense
// to do anything else.
/*! These functions emulate the Input Server by sending the *exact* same kind of
messages to the server's port. Being we're using a regular window, it would
make little sense to do anything else.
*/
void void
CardView::ForwardMessage(BMessage* message) CardView::ForwardMessage(BMessage* message)
{ {
@@ -232,7 +240,6 @@ CardView::MessageReceived(BMessage* message)
} }
// SetBitmap
void void
CardView::SetBitmap(const BBitmap* bitmap) CardView::SetBitmap(const BBitmap* bitmap)
{ {
@@ -249,14 +256,15 @@ CardView::SetBitmap(const BBitmap* bitmap)
CardMessageFilter::CardMessageFilter(CardView* view) CardMessageFilter::CardMessageFilter(CardView* view)
: BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE), :
BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE),
fView(view) fView(view)
{ {
} }
filter_result filter_result
CardMessageFilter::Filter(BMessage *message, BHandler **target) CardMessageFilter::Filter(BMessage* message, BHandler** target)
{ {
switch (message->what) { switch (message->what) {
case B_KEY_DOWN: case B_KEY_DOWN:
@@ -292,7 +300,8 @@ CardMessageFilter::Filter(BMessage *message, BHandler **target)
CardWindow::CardWindow(BRect frame) CardWindow::CardWindow(BRect frame)
: BWindow(frame, "Haiku App Server", B_TITLED_WINDOW, :
BWindow(frame, "Haiku App Server", B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_NOT_RESIZABLE), B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
fUpdateRunner(NULL), fUpdateRunner(NULL),
fUpdateRegion(), fUpdateRegion(),
@@ -312,7 +321,7 @@ CardWindow::~CardWindow()
void void
CardWindow::MessageReceived(BMessage *msg) CardWindow::MessageReceived(BMessage* msg)
{ {
STRACE("CardWindow::MessageReceived()\n"); STRACE("CardWindow::MessageReceived()\n");
switch (msg->what) { switch (msg->what) {
@@ -343,7 +352,6 @@ CardWindow::MessageReceived(BMessage *msg)
} }
// QuitRequested
bool bool
CardWindow::QuitRequested() CardWindow::QuitRequested()
{ {
@@ -360,21 +368,22 @@ CardWindow::QuitRequested()
return false; return false;
} }
// SetBitmap
void void
CardWindow::SetBitmap(const BBitmap* bitmap) CardWindow::SetBitmap(const BBitmap* bitmap)
{ {
fView->SetBitmap(bitmap); fView->SetBitmap(bitmap);
} }
// Invalidate
void void
CardWindow::Invalidate(const BRect& frame) CardWindow::Invalidate(const BRect& frame)
{ {
if (fUpdateLock.Lock()) { if (fUpdateLock.Lock()) {
if (!fUpdateRunner) { if (!fUpdateRunner) {
BMessage message(MSG_UPDATE); BMessage message(MSG_UPDATE);
fUpdateRunner = new BMessageRunner(BMessenger(this, this), &message, 20000); fUpdateRunner = new BMessageRunner(BMessenger(this, this), &message,
20000);
} }
fUpdateRegion.Include(frame); fUpdateRegion.Include(frame);
fUpdateLock.Unlock(); fUpdateLock.Unlock();
@@ -385,11 +394,9 @@ CardWindow::Invalidate(const BRect& frame)
// #pragma mark - // #pragma mark -
static const bool kDefaultDoubleBuffered = true;
ViewHWInterface::ViewHWInterface() ViewHWInterface::ViewHWInterface()
: HWInterface(kDefaultDoubleBuffered), :
HWInterface(kDefaultDoubleBuffered),
fBackBuffer(NULL), fBackBuffer(NULL),
fFrontBuffer(NULL), fFrontBuffer(NULL),
fWindow(NULL) fWindow(NULL)
@@ -415,23 +422,23 @@ ViewHWInterface::~ViewHWInterface()
delete be_app; delete be_app;
} }
// Initialize
status_t status_t
ViewHWInterface::Initialize() ViewHWInterface::Initialize()
{ {
return B_OK; return B_OK;
} }
// Shutdown
status_t status_t
ViewHWInterface::Shutdown() ViewHWInterface::Shutdown()
{ {
return B_OK; return B_OK;
} }
// SetMode
status_t status_t
ViewHWInterface::SetMode(const display_mode &mode) ViewHWInterface::SetMode(const display_mode& mode)
{ {
AutoWriteLocker _(this); AutoWriteLocker _(this);
@@ -445,7 +452,7 @@ ViewHWInterface::SetMode(const display_mode &mode)
// check if we support the mode // check if we support the mode
display_mode *modes; display_mode* modes;
uint32 modeCount, i; uint32 modeCount, i;
if (GetModeList(&modes, &modeCount) != B_OK) if (GetModeList(&modes, &modeCount) != B_OK)
return B_NO_MEMORY; return B_NO_MEMORY;
@@ -466,8 +473,7 @@ ViewHWInterface::SetMode(const display_mode &mode)
if (i == modeCount) if (i == modeCount)
return B_BAD_VALUE; return B_BAD_VALUE;
BRect frame(0.0, 0.0, BRect frame(0.0, 0.0, fDisplayMode.virtual_width - 1,
fDisplayMode.virtual_width - 1,
fDisplayMode.virtual_height - 1); fDisplayMode.virtual_height - 1);
// create the window if we don't have one already // create the window if we don't have one already
@@ -514,11 +520,12 @@ ViewHWInterface::SetMode(const display_mode &mode)
// -> fall back to double buffer for fDisplayMode.space != B_RGB32 // -> fall back to double buffer for fDisplayMode.space != B_RGB32
// as intermediate solution... // as intermediate solution...
bool doubleBuffered = HWInterface::IsDoubleBuffered(); bool doubleBuffered = HWInterface::IsDoubleBuffered();
if ((color_space)fDisplayMode.space != B_RGB32 && if ((color_space)fDisplayMode.space != B_RGB32
(color_space)fDisplayMode.space != B_RGBA32) && (color_space)fDisplayMode.space != B_RGBA32)
doubleBuffered = true; doubleBuffered = true;
BBitmap* frontBitmap = new BBitmap(frame, 0, (color_space)fDisplayMode.space); BBitmap* frontBitmap
= new BBitmap(frame, 0, (color_space)fDisplayMode.space);
fFrontBuffer = new BBitmapBuffer(frontBitmap); fFrontBuffer = new BBitmapBuffer(frontBitmap);
status_t err = fFrontBuffer->InitCheck(); status_t err = fFrontBuffer->InitCheck();
@@ -568,7 +575,7 @@ ViewHWInterface::SetMode(const display_mode &mode)
return ret; return ret;
} }
// GetMode
void void
ViewHWInterface::GetMode(display_mode* mode) ViewHWInterface::GetMode(display_mode* mode)
{ {
@@ -578,9 +585,9 @@ ViewHWInterface::GetMode(display_mode* mode)
} }
} }
// GetDeviceInfo
status_t status_t
ViewHWInterface::GetDeviceInfo(accelerant_device_info *info) ViewHWInterface::GetDeviceInfo(accelerant_device_info* info)
{ {
// We really don't have to provide anything here because this is strictly // We really don't have to provide anything here because this is strictly
// a software-only driver, but we'll have some fun, anyway. // a software-only driver, but we'll have some fun, anyway.
@@ -614,7 +621,7 @@ ViewHWInterface::GetFrameBufferConfig(frame_buffer_config& config)
status_t status_t
ViewHWInterface::GetModeList(display_mode **_modes, uint32 *_count) ViewHWInterface::GetModeList(display_mode** _modes, uint32* _count)
{ {
AutoReadLocker _(this); AutoReadLocker _(this);
@@ -628,7 +635,7 @@ ViewHWInterface::GetModeList(display_mode **_modes, uint32 *_count)
const uint32 colors[] = {B_CMAP8, B_RGB15, B_RGB16, B_RGB32}; const uint32 colors[] = {B_CMAP8, B_RGB15, B_RGB16, B_RGB32};
uint32 count = resolutionCount * 4; uint32 count = resolutionCount * 4;
display_mode *modes = new(nothrow) display_mode[count]; display_mode* modes = new(std::nothrow) display_mode[count];
if (modes == NULL) if (modes == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
@@ -670,37 +677,43 @@ ViewHWInterface::GetModeList(display_mode **_modes, uint32 *_count)
return B_OK; return B_OK;
} }
status_t status_t
ViewHWInterface::GetPixelClockLimits(display_mode *mode, uint32 *low, uint32 *high) ViewHWInterface::GetPixelClockLimits(display_mode* mode, uint32* low,
uint32* high)
{ {
return B_ERROR; return B_ERROR;
} }
status_t status_t
ViewHWInterface::GetTimingConstraints(display_timing_constraints *dtc) ViewHWInterface::GetTimingConstraints(display_timing_constraints* constraints)
{ {
return B_ERROR; return B_ERROR;
} }
status_t status_t
ViewHWInterface::ProposeMode(display_mode *candidate, const display_mode *low, const display_mode *high) ViewHWInterface::ProposeMode(display_mode* candidate, const display_mode* low,
const display_mode* high)
{ {
// We should be able to get away with this because we're not dealing with any // We should be able to get away with this because we're not dealing with
// specific hardware. This is a Good Thing(TM) because we can support any hardware // any specific hardware. This is a Good Thing(TM) because we can support
// we wish within reasonable expectaions and programmer laziness. :P // any hardware we wish within reasonable expectaions and programmer
// laziness. :P
return B_OK; return B_OK;
} }
// SetDPMSMode
status_t status_t
ViewHWInterface::SetDPMSMode(const uint32 &state) ViewHWInterface::SetDPMSMode(uint32 state)
{ {
AutoWriteLocker _(this); AutoWriteLocker _(this);
return BScreen().SetDPMS(state); return BScreen().SetDPMS(state);
} }
// DPMSMode
uint32 uint32
ViewHWInterface::DPMSMode() ViewHWInterface::DPMSMode()
{ {
@@ -709,7 +722,7 @@ ViewHWInterface::DPMSMode()
return BScreen().DPMSState(); return BScreen().DPMSState();
} }
// DPMSCapabilities
uint32 uint32
ViewHWInterface::DPMSCapabilities() ViewHWInterface::DPMSCapabilities()
{ {
@@ -718,14 +731,14 @@ ViewHWInterface::DPMSCapabilities()
return BScreen().DPMSCapabilites(); return BScreen().DPMSCapabilites();
} }
// RetraceSemaphore
sem_id sem_id
ViewHWInterface::RetraceSemaphore() ViewHWInterface::RetraceSemaphore()
{ {
return -1; return -1;
} }
// WaitForRetrace
status_t status_t
ViewHWInterface::WaitForRetrace(bigtime_t timeout = B_INFINITE_TIMEOUT) ViewHWInterface::WaitForRetrace(bigtime_t timeout = B_INFINITE_TIMEOUT)
{ {
@@ -734,21 +747,21 @@ ViewHWInterface::WaitForRetrace(bigtime_t timeout = B_INFINITE_TIMEOUT)
return screen.WaitForRetrace(timeout); return screen.WaitForRetrace(timeout);
} }
// FrontBuffer
RenderingBuffer* RenderingBuffer*
ViewHWInterface::FrontBuffer() const ViewHWInterface::FrontBuffer() const
{ {
return fFrontBuffer; return fFrontBuffer;
} }
// BackBuffer
RenderingBuffer* RenderingBuffer*
ViewHWInterface::BackBuffer() const ViewHWInterface::BackBuffer() const
{ {
return fBackBuffer; return fBackBuffer;
} }
// IsDoubleBuffered
bool bool
ViewHWInterface::IsDoubleBuffered() const ViewHWInterface::IsDoubleBuffered() const
{ {
@@ -758,7 +771,7 @@ ViewHWInterface::IsDoubleBuffered() const
return HWInterface::IsDoubleBuffered(); return HWInterface::IsDoubleBuffered();
} }
// Invalidate
status_t status_t
ViewHWInterface::Invalidate(const BRect& frame) ViewHWInterface::Invalidate(const BRect& frame)
{ {
@@ -769,7 +782,7 @@ ViewHWInterface::Invalidate(const BRect& frame)
return ret; return ret;
} }
// CopyBackToFront
status_t status_t
ViewHWInterface::CopyBackToFront(const BRect& frame) ViewHWInterface::CopyBackToFront(const BRect& frame)
{ {
+21 -18
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2005, Haiku. * Copyright 2005-2009, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -11,6 +11,7 @@
#include "HWInterface.h" #include "HWInterface.h"
class BBitmap; class BBitmap;
class BBitmapBuffer; class BBitmapBuffer;
class CardWindow; class CardWindow;
@@ -18,33 +19,35 @@ class UpdateQueue;
class ViewHWInterface : public HWInterface { class ViewHWInterface : public HWInterface {
public: public:
ViewHWInterface(); ViewHWInterface();
virtual ~ViewHWInterface(); virtual ~ViewHWInterface();
virtual status_t Initialize(); virtual status_t Initialize();
virtual status_t Shutdown(); virtual status_t Shutdown();
virtual status_t SetMode(const display_mode &mode); virtual status_t SetMode(const display_mode& mode);
virtual void GetMode(display_mode *mode); virtual void GetMode(display_mode* mode);
virtual status_t GetDeviceInfo(accelerant_device_info *info); virtual status_t GetDeviceInfo(accelerant_device_info* info);
virtual status_t GetFrameBufferConfig(frame_buffer_config& config); virtual status_t GetFrameBufferConfig(
frame_buffer_config& config);
virtual status_t GetModeList(display_mode **mode_list, virtual status_t GetModeList(display_mode** _modeList,
uint32 *count); uint32* _count);
virtual status_t GetPixelClockLimits(display_mode *mode, virtual status_t GetPixelClockLimits(display_mode* mode,
uint32 *low, uint32* _low, uint32* _high);
uint32 *high); virtual status_t GetTimingConstraints(display_timing_constraints*
virtual status_t GetTimingConstraints(display_timing_constraints *dtc); constraints);
virtual status_t ProposeMode(display_mode *candidate, virtual status_t ProposeMode(display_mode* candidate,
const display_mode *low, const display_mode* low,
const display_mode *high); const display_mode* high);
virtual sem_id RetraceSemaphore(); virtual sem_id RetraceSemaphore();
virtual status_t WaitForRetrace(bigtime_t timeout = B_INFINITE_TIMEOUT); virtual status_t WaitForRetrace(
bigtime_t timeout = B_INFINITE_TIMEOUT);
virtual status_t SetDPMSMode(const uint32 &state); virtual status_t SetDPMSMode(uint32 state);
virtual uint32 DPMSMode(); virtual uint32 DPMSMode();
virtual uint32 DPMSCapabilities(); virtual uint32 DPMSCapabilities();
@@ -56,7 +59,7 @@ class ViewHWInterface : public HWInterface {
virtual status_t Invalidate(const BRect& frame); virtual status_t Invalidate(const BRect& frame);
virtual status_t CopyBackToFront(const BRect& frame); virtual status_t CopyBackToFront(const BRect& frame);
private: private:
BBitmapBuffer* fBackBuffer; BBitmapBuffer* fBackBuffer;
BBitmapBuffer* fFrontBuffer; BBitmapBuffer* fFrontBuffer;