* 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:
parent
419f2d6f3e
commit
7b8b23e9a4
@ -14,17 +14,13 @@
|
||||
|
||||
#include "AccelerantHWInterface.h"
|
||||
|
||||
#include "AccelerantBuffer.h"
|
||||
#include "MallocBuffer.h"
|
||||
#include "Overlay.h"
|
||||
#include "RGBColor.h"
|
||||
#include "ServerConfig.h"
|
||||
#include "ServerCursor.h"
|
||||
#include "ServerProtocol.h"
|
||||
#include "SystemPalette.h"
|
||||
|
||||
#include <edid.h>
|
||||
#include <safemode_defs.h>
|
||||
#include <dirent.h>
|
||||
#include <new>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <Accelerant.h>
|
||||
#include <Cursor.h>
|
||||
@ -34,13 +30,19 @@
|
||||
#include <image.h>
|
||||
#include <String.h>
|
||||
|
||||
#include <dirent.h>
|
||||
#include <new>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <edid.h>
|
||||
#include <safemode_defs.h>
|
||||
#include <syscalls.h>
|
||||
|
||||
#include "AccelerantBuffer.h"
|
||||
#include "MallocBuffer.h"
|
||||
#include "Overlay.h"
|
||||
#include "RGBColor.h"
|
||||
#include "ServerConfig.h"
|
||||
#include "ServerCursor.h"
|
||||
#include "ServerProtocol.h"
|
||||
#include "SystemPalette.h"
|
||||
|
||||
|
||||
using std::nothrow;
|
||||
|
||||
@ -56,14 +58,6 @@ using std::nothrow;
|
||||
#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;
|
||||
|
||||
|
||||
@ -157,7 +151,7 @@ AccelerantHWInterface::AccelerantHWInterface()
|
||||
memset(&fSyncToken, 0, sizeof(sync_token));
|
||||
}
|
||||
|
||||
// destructor
|
||||
|
||||
AccelerantHWInterface::~AccelerantHWInterface()
|
||||
{
|
||||
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.
|
||||
*/
|
||||
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)
|
||||
\return The file descriptor for the opened graphics device
|
||||
|
||||
@ -341,12 +333,17 @@ AccelerantHWInterface::_SetupDefaultHooks()
|
||||
fAccAcquireEngine = (acquire_engine)fAccelerantHook(B_ACQUIRE_ENGINE, NULL);
|
||||
fAccReleaseEngine = (release_engine)fAccelerantHook(B_RELEASE_ENGINE, 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);
|
||||
fAccGetFrameBufferConfig = (get_frame_buffer_config)fAccelerantHook(B_GET_FRAME_BUFFER_CONFIG, NULL);
|
||||
fAccSetDisplayMode = (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);
|
||||
fAccGetFrameBufferConfig = (get_frame_buffer_config)fAccelerantHook(
|
||||
B_GET_FRAME_BUFFER_CONFIG, NULL);
|
||||
fAccSetDisplayMode
|
||||
= (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
|
||||
|| !fAccGetModeCount || !fAccGetModeList || !fAccSetDisplayMode
|
||||
@ -355,43 +352,57 @@ AccelerantHWInterface::_SetupDefaultHooks()
|
||||
}
|
||||
|
||||
// optional
|
||||
fAccGetTimingConstraints = (get_timing_constraints)fAccelerantHook(B_GET_TIMING_CONSTRAINTS, NULL);
|
||||
fAccProposeDisplayMode = (propose_display_mode)fAccelerantHook(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);
|
||||
fAccGetTimingConstraints = (get_timing_constraints)fAccelerantHook(
|
||||
B_GET_TIMING_CONSTRAINTS, NULL);
|
||||
fAccProposeDisplayMode = (propose_display_mode)fAccelerantHook(
|
||||
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);
|
||||
|
||||
// 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);
|
||||
fAccShowCursor = (show_cursor)fAccelerantHook(B_SHOW_CURSOR, NULL);
|
||||
|
||||
// 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);
|
||||
fAccSetDPMSMode = (set_dpms_mode)fAccelerantHook(B_SET_DPMS_MODE, NULL);
|
||||
|
||||
// overlay
|
||||
fAccOverlayCount = (overlay_count)fAccelerantHook(B_OVERLAY_COUNT, NULL);
|
||||
fAccOverlaySupportedSpaces = (overlay_supported_spaces)fAccelerantHook(B_OVERLAY_SUPPORTED_SPACES, NULL);
|
||||
fAccOverlaySupportedFeatures = (overlay_supported_features)fAccelerantHook(B_OVERLAY_SUPPORTED_FEATURES, NULL);
|
||||
fAccAllocateOverlayBuffer = (allocate_overlay_buffer)fAccelerantHook(B_ALLOCATE_OVERLAY_BUFFER, NULL);
|
||||
fAccReleaseOverlayBuffer = (release_overlay_buffer)fAccelerantHook(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);
|
||||
fAccOverlaySupportedSpaces = (overlay_supported_spaces)fAccelerantHook(
|
||||
B_OVERLAY_SUPPORTED_SPACES, NULL);
|
||||
fAccOverlaySupportedFeatures = (overlay_supported_features)fAccelerantHook(
|
||||
B_OVERLAY_SUPPORTED_FEATURES, NULL);
|
||||
fAccAllocateOverlayBuffer = (allocate_overlay_buffer)fAccelerantHook(
|
||||
B_ALLOCATE_OVERLAY_BUFFER, NULL);
|
||||
fAccReleaseOverlayBuffer = (release_overlay_buffer)fAccelerantHook(
|
||||
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;
|
||||
}
|
||||
|
||||
// Shutdown
|
||||
|
||||
status_t
|
||||
AccelerantHWInterface::Shutdown()
|
||||
{
|
||||
if (fAccelerantHook) {
|
||||
uninit_accelerant UninitAccelerant = (uninit_accelerant)
|
||||
fAccelerantHook(B_UNINIT_ACCELERANT, NULL);
|
||||
uninit_accelerant UninitAccelerant
|
||||
= (uninit_accelerant)fAccelerantHook(B_UNINIT_ACCELERANT, NULL);
|
||||
if (UninitAccelerant)
|
||||
UninitAccelerant();
|
||||
}
|
||||
@ -424,11 +435,14 @@ AccelerantHWInterface::_FindBestMode(const display_mode& compareMode,
|
||||
|
||||
// compute some random equality score
|
||||
// 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)
|
||||
+ abs(mode.timing.h_total * mode.timing.v_total
|
||||
- compareMode.timing.h_total * compareMode.timing.v_total) / 100
|
||||
+ abs(mode.timing.pixel_clock - compareMode.timing.pixel_clock) / 100
|
||||
- compareMode.timing.h_total * compareMode.timing.v_total)
|
||||
/ 100
|
||||
+ abs(mode.timing.pixel_clock - compareMode.timing.pixel_clock)
|
||||
/ 100
|
||||
+ (int32)(500 * fabs(aspectRatio - compareAspectRatio))
|
||||
+ 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.
|
||||
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
|
||||
@ -594,7 +607,7 @@ AccelerantHWInterface::SetMode(const display_mode& mode)
|
||||
if (fDisplayMode.space == B_RGB15)
|
||||
depth = 15;
|
||||
|
||||
_kern_frame_buffer_update(fFrameBufferConfig.frame_buffer,
|
||||
_kern_frame_buffer_update((addr_t)fFrameBufferConfig.frame_buffer,
|
||||
fFrontBuffer->Width(), fFrontBuffer->Height(),
|
||||
depth, fFrameBufferConfig.bytes_per_row);
|
||||
#endif
|
||||
@ -683,7 +696,7 @@ AccelerantHWInterface::SetMode(const display_mode& mode)
|
||||
|
||||
|
||||
void
|
||||
AccelerantHWInterface::GetMode(display_mode *mode)
|
||||
AccelerantHWInterface::GetMode(display_mode* mode)
|
||||
{
|
||||
if (mode && LockParallelAccess()) {
|
||||
*mode = fDisplayMode;
|
||||
@ -728,7 +741,7 @@ AccelerantHWInterface::_UpdateFrameBufferConfig()
|
||||
|
||||
|
||||
status_t
|
||||
AccelerantHWInterface::GetDeviceInfo(accelerant_device_info *info)
|
||||
AccelerantHWInterface::GetDeviceInfo(accelerant_device_info* info)
|
||||
{
|
||||
get_accelerant_device_info GetAccelerantDeviceInfo
|
||||
= (get_accelerant_device_info)fAccelerantHook(
|
||||
@ -751,7 +764,7 @@ AccelerantHWInterface::GetFrameBufferConfig(frame_buffer_config& config)
|
||||
|
||||
|
||||
status_t
|
||||
AccelerantHWInterface::GetModeList(display_mode** _modes, uint32 *_count)
|
||||
AccelerantHWInterface::GetModeList(display_mode** _modes, uint32* _count)
|
||||
{
|
||||
AutoReadLocker _(this);
|
||||
|
||||
@ -778,41 +791,42 @@ AccelerantHWInterface::GetModeList(display_mode** _modes, uint32 *_count)
|
||||
|
||||
|
||||
status_t
|
||||
AccelerantHWInterface::GetPixelClockLimits(display_mode *mode, uint32 *low,
|
||||
uint32 *high)
|
||||
AccelerantHWInterface::GetPixelClockLimits(display_mode *mode, uint32* _low,
|
||||
uint32* _high)
|
||||
{
|
||||
AutoReadLocker _(this);
|
||||
|
||||
if (!mode || !low || !high)
|
||||
if (mode == NULL || _low == NULL || _high == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
return fAccGetPixelClockLimits(mode, low, high);
|
||||
AutoReadLocker _(this);
|
||||
return fAccGetPixelClockLimits(mode, _low, _high);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
AccelerantHWInterface::GetTimingConstraints(display_timing_constraints *dtc)
|
||||
AccelerantHWInterface::GetTimingConstraints(
|
||||
display_timing_constraints* constraints)
|
||||
{
|
||||
AutoReadLocker _(this);
|
||||
|
||||
if (!dtc)
|
||||
if (constraints == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
AutoReadLocker _(this);
|
||||
|
||||
if (fAccGetTimingConstraints)
|
||||
return fAccGetTimingConstraints(dtc);
|
||||
return fAccGetTimingConstraints(constraints);
|
||||
|
||||
return B_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
AccelerantHWInterface::ProposeMode(display_mode *candidate,
|
||||
const display_mode *_low, const display_mode *_high)
|
||||
AccelerantHWInterface::ProposeMode(display_mode* candidate,
|
||||
const display_mode* _low, const display_mode* _high)
|
||||
{
|
||||
AutoReadLocker _(this);
|
||||
|
||||
if (candidate == NULL || _low == NULL || _high == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
AutoReadLocker _(this);
|
||||
|
||||
if (fAccProposeDisplayMode == NULL)
|
||||
return B_UNSUPPORTED;
|
||||
|
||||
@ -1022,7 +1036,7 @@ AccelerantHWInterface::WaitForRetrace(bigtime_t timeout)
|
||||
|
||||
|
||||
status_t
|
||||
AccelerantHWInterface::SetDPMSMode(const uint32 &state)
|
||||
AccelerantHWInterface::SetDPMSMode(uint32 state)
|
||||
{
|
||||
AutoWriteLocker _(this);
|
||||
|
||||
@ -1032,7 +1046,7 @@ AccelerantHWInterface::SetDPMSMode(const uint32 &state)
|
||||
return fAccSetDPMSMode(state);
|
||||
}
|
||||
|
||||
// DPMSMode
|
||||
|
||||
uint32
|
||||
AccelerantHWInterface::DPMSMode()
|
||||
{
|
||||
@ -1044,7 +1058,7 @@ AccelerantHWInterface::DPMSMode()
|
||||
return fAccDPMSMode();
|
||||
}
|
||||
|
||||
// DPMSCapabilities
|
||||
|
||||
uint32
|
||||
AccelerantHWInterface::DPMSCapabilities()
|
||||
{
|
||||
@ -1058,7 +1072,7 @@ AccelerantHWInterface::DPMSCapabilities()
|
||||
|
||||
|
||||
status_t
|
||||
AccelerantHWInterface::GetAccelerantPath(BString &string)
|
||||
AccelerantHWInterface::GetAccelerantPath(BString& string)
|
||||
{
|
||||
image_info info;
|
||||
status_t status = get_image_info(fAccelerantImage, &info);
|
||||
@ -1069,7 +1083,7 @@ AccelerantHWInterface::GetAccelerantPath(BString &string)
|
||||
|
||||
|
||||
status_t
|
||||
AccelerantHWInterface::GetDriverPath(BString &string)
|
||||
AccelerantHWInterface::GetDriverPath(BString& string)
|
||||
{
|
||||
// TODO: this currently assumes that the accelerant's clone info
|
||||
// is always the path name of its driver (that's the case for
|
||||
@ -1082,7 +1096,7 @@ AccelerantHWInterface::GetDriverPath(BString &string)
|
||||
if (getCloneInfo == NULL)
|
||||
return B_NOT_SUPPORTED;
|
||||
|
||||
getCloneInfo((void *)path);
|
||||
getCloneInfo((void*)path);
|
||||
string.SetTo(path);
|
||||
return B_OK;
|
||||
}
|
||||
@ -1330,7 +1344,7 @@ AccelerantHWInterface::SetCursorVisible(bool visible)
|
||||
|
||||
|
||||
void
|
||||
AccelerantHWInterface::MoveCursorTo(const float& x, const float& y)
|
||||
AccelerantHWInterface::MoveCursorTo(float x, float y)
|
||||
{
|
||||
HWInterface::MoveCursorTo(x, y);
|
||||
// if (LockExclusiveAccess()) {
|
||||
@ -1343,15 +1357,14 @@ AccelerantHWInterface::MoveCursorTo(const float& x, const float& y)
|
||||
// #pragma mark - buffer access
|
||||
|
||||
|
||||
|
||||
RenderingBuffer *
|
||||
RenderingBuffer*
|
||||
AccelerantHWInterface::FrontBuffer() const
|
||||
{
|
||||
return fFrontBuffer;
|
||||
}
|
||||
|
||||
|
||||
RenderingBuffer *
|
||||
RenderingBuffer*
|
||||
AccelerantHWInterface::BackBuffer() const
|
||||
{
|
||||
return fBackBuffer;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2008, Haiku.
|
||||
* Copyright 2005-2009, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -27,43 +27,44 @@ public:
|
||||
virtual status_t Initialize();
|
||||
virtual status_t Shutdown();
|
||||
|
||||
virtual status_t SetMode(const display_mode &mode);
|
||||
virtual void GetMode(display_mode *mode);
|
||||
virtual status_t SetMode(const display_mode& mode);
|
||||
virtual void GetMode(display_mode* mode);
|
||||
|
||||
virtual status_t GetDeviceInfo(accelerant_device_info *info);
|
||||
virtual status_t GetFrameBufferConfig(frame_buffer_config& config);
|
||||
virtual status_t GetDeviceInfo(accelerant_device_info* info);
|
||||
virtual status_t GetFrameBufferConfig(
|
||||
frame_buffer_config& config);
|
||||
|
||||
virtual status_t GetModeList(display_mode **mode_list,
|
||||
uint32 *count);
|
||||
virtual status_t GetPixelClockLimits(display_mode *mode,
|
||||
uint32 *low, uint32 *high);
|
||||
virtual status_t GetTimingConstraints(display_timing_constraints *dtc);
|
||||
virtual status_t ProposeMode(display_mode *candidate,
|
||||
const display_mode *low,
|
||||
const display_mode *high);
|
||||
virtual status_t GetModeList(display_mode** _modeList,
|
||||
uint32* _count);
|
||||
virtual status_t GetPixelClockLimits(display_mode* mode,
|
||||
uint32* _low, uint32* _high);
|
||||
virtual status_t GetTimingConstraints(display_timing_constraints*
|
||||
constraints);
|
||||
virtual status_t ProposeMode(display_mode* candidate,
|
||||
const display_mode* low,
|
||||
const display_mode* high);
|
||||
virtual status_t GetPreferredMode(display_mode* mode);
|
||||
virtual status_t GetMonitorInfo(monitor_info* info);
|
||||
|
||||
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 DPMSCapabilities();
|
||||
|
||||
virtual status_t GetAccelerantPath(BString &path);
|
||||
virtual status_t GetDriverPath(BString &path);
|
||||
virtual status_t GetAccelerantPath(BString& path);
|
||||
virtual status_t GetDriverPath(BString& path);
|
||||
|
||||
// query for available hardware accleration
|
||||
virtual uint32 AvailableHWAcceleration() const;
|
||||
|
||||
// accelerated drawing
|
||||
virtual void CopyRegion(const clipping_rect* sortedRectList,
|
||||
uint32 count,
|
||||
int32 xOffset, int32 yOffset);
|
||||
uint32 count, int32 xOffset, int32 yOffset);
|
||||
virtual void FillRegion(/*const*/ BRegion& region,
|
||||
const rgb_color& color,
|
||||
bool autoSync);
|
||||
const rgb_color& color, bool autoSync);
|
||||
virtual void InvertRegion(/*const*/ BRegion& region);
|
||||
|
||||
virtual void Sync();
|
||||
@ -86,8 +87,7 @@ public:
|
||||
// cursor handling
|
||||
virtual void SetCursor(ServerCursor* cursor);
|
||||
virtual void SetCursorVisible(bool visible);
|
||||
virtual void MoveCursorTo(const float& x,
|
||||
const float& y);
|
||||
virtual void MoveCursorTo(float x, float y);
|
||||
|
||||
// frame buffer access
|
||||
virtual RenderingBuffer* FrontBuffer() const;
|
||||
@ -100,86 +100,87 @@ protected:
|
||||
virtual void _DrawCursor(IntRect area) const;
|
||||
|
||||
private:
|
||||
int _OpenGraphicsDevice(int deviceNumber);
|
||||
status_t _OpenAccelerant(int device);
|
||||
status_t _SetupDefaultHooks();
|
||||
status_t _UpdateModeList();
|
||||
status_t _UpdateFrameBufferConfig();
|
||||
void _RegionToRectParams(/*const*/ BRegion* region,
|
||||
int _OpenGraphicsDevice(int deviceNumber);
|
||||
status_t _OpenAccelerant(int device);
|
||||
status_t _SetupDefaultHooks();
|
||||
status_t _UpdateModeList();
|
||||
status_t _UpdateFrameBufferConfig();
|
||||
void _RegionToRectParams(/*const*/ BRegion* region,
|
||||
uint32* count) const;
|
||||
void _CopyRegion(const clipping_rect* sortedRectList,
|
||||
void _CopyRegion(const clipping_rect* sortedRectList,
|
||||
uint32 count, int32 xOffset, int32 yOffset,
|
||||
bool inBackBuffer);
|
||||
uint32 _NativeColor(const rgb_color& color) const;
|
||||
status_t _FindBestMode(const display_mode& compareMode,
|
||||
uint32 _NativeColor(const rgb_color& color) const;
|
||||
status_t _FindBestMode(const display_mode& compareMode,
|
||||
float compareAspectRatio,
|
||||
display_mode& modeFound,
|
||||
int32 *_diff = NULL) const;
|
||||
status_t _SetFallbackMode(display_mode& mode) const;
|
||||
void _SetSystemPalette();
|
||||
void _SetGrayscalePalette();
|
||||
status_t _SetFallbackMode(display_mode& mode) const;
|
||||
void _SetSystemPalette();
|
||||
void _SetGrayscalePalette();
|
||||
|
||||
int fCardFD;
|
||||
image_id fAccelerantImage;
|
||||
GetAccelerantHook fAccelerantHook;
|
||||
engine_token *fEngineToken;
|
||||
sync_token fSyncToken;
|
||||
private:
|
||||
int fCardFD;
|
||||
image_id fAccelerantImage;
|
||||
GetAccelerantHook fAccelerantHook;
|
||||
engine_token* fEngineToken;
|
||||
sync_token fSyncToken;
|
||||
|
||||
// required hooks - guaranteed to be valid
|
||||
acquire_engine fAccAcquireEngine;
|
||||
release_engine fAccReleaseEngine;
|
||||
sync_to_token fAccSyncToToken;
|
||||
accelerant_mode_count fAccGetModeCount;
|
||||
get_mode_list fAccGetModeList;
|
||||
get_frame_buffer_config fAccGetFrameBufferConfig;
|
||||
set_display_mode fAccSetDisplayMode;
|
||||
get_display_mode fAccGetDisplayMode;
|
||||
get_pixel_clock_limits fAccGetPixelClockLimits;
|
||||
// required hooks - guaranteed to be valid
|
||||
acquire_engine fAccAcquireEngine;
|
||||
release_engine fAccReleaseEngine;
|
||||
sync_to_token fAccSyncToToken;
|
||||
accelerant_mode_count fAccGetModeCount;
|
||||
get_mode_list fAccGetModeList;
|
||||
get_frame_buffer_config fAccGetFrameBufferConfig;
|
||||
set_display_mode fAccSetDisplayMode;
|
||||
get_display_mode fAccGetDisplayMode;
|
||||
get_pixel_clock_limits fAccGetPixelClockLimits;
|
||||
|
||||
// optional accelerant hooks
|
||||
get_timing_constraints fAccGetTimingConstraints;
|
||||
propose_display_mode fAccProposeDisplayMode;
|
||||
get_preferred_display_mode fAccGetPreferredDisplayMode;
|
||||
get_monitor_info fAccGetMonitorInfo;
|
||||
get_edid_info fAccGetEDIDInfo;
|
||||
fill_rectangle fAccFillRect;
|
||||
invert_rectangle fAccInvertRect;
|
||||
screen_to_screen_blit fAccScreenBlit;
|
||||
set_cursor_shape fAccSetCursorShape;
|
||||
move_cursor fAccMoveCursor;
|
||||
show_cursor fAccShowCursor;
|
||||
|
||||
// dpms hooks
|
||||
dpms_capabilities fAccDPMSCapabilities;
|
||||
dpms_mode fAccDPMSMode;
|
||||
set_dpms_mode fAccSetDPMSMode;
|
||||
// optional accelerant hooks
|
||||
get_timing_constraints fAccGetTimingConstraints;
|
||||
propose_display_mode fAccProposeDisplayMode;
|
||||
get_preferred_display_mode fAccGetPreferredDisplayMode;
|
||||
get_monitor_info fAccGetMonitorInfo;
|
||||
get_edid_info fAccGetEDIDInfo;
|
||||
fill_rectangle fAccFillRect;
|
||||
invert_rectangle fAccInvertRect;
|
||||
screen_to_screen_blit fAccScreenBlit;
|
||||
set_cursor_shape fAccSetCursorShape;
|
||||
move_cursor fAccMoveCursor;
|
||||
show_cursor fAccShowCursor;
|
||||
|
||||
// overlay hooks
|
||||
overlay_count fAccOverlayCount;
|
||||
overlay_supported_spaces fAccOverlaySupportedSpaces;
|
||||
overlay_supported_features fAccOverlaySupportedFeatures;
|
||||
allocate_overlay_buffer fAccAllocateOverlayBuffer;
|
||||
release_overlay_buffer fAccReleaseOverlayBuffer;
|
||||
get_overlay_constraints fAccGetOverlayConstraints;
|
||||
allocate_overlay fAccAllocateOverlay;
|
||||
release_overlay fAccReleaseOverlay;
|
||||
configure_overlay fAccConfigureOverlay;
|
||||
// dpms hooks
|
||||
dpms_capabilities fAccDPMSCapabilities;
|
||||
dpms_mode fAccDPMSMode;
|
||||
set_dpms_mode fAccSetDPMSMode;
|
||||
|
||||
frame_buffer_config fFrameBufferConfig;
|
||||
int fModeCount;
|
||||
display_mode* fModeList;
|
||||
// overlay hooks
|
||||
overlay_count fAccOverlayCount;
|
||||
overlay_supported_spaces fAccOverlaySupportedSpaces;
|
||||
overlay_supported_features fAccOverlaySupportedFeatures;
|
||||
allocate_overlay_buffer fAccAllocateOverlayBuffer;
|
||||
release_overlay_buffer fAccReleaseOverlayBuffer;
|
||||
get_overlay_constraints fAccGetOverlayConstraints;
|
||||
allocate_overlay fAccAllocateOverlay;
|
||||
release_overlay fAccReleaseOverlay;
|
||||
configure_overlay fAccConfigureOverlay;
|
||||
|
||||
RenderingBuffer* fBackBuffer;
|
||||
AccelerantBuffer* fFrontBuffer;
|
||||
bool fOffscreenBackBuffer;
|
||||
frame_buffer_config fFrameBufferConfig;
|
||||
int fModeCount;
|
||||
display_mode* fModeList;
|
||||
|
||||
display_mode fDisplayMode;
|
||||
bool fInitialModeSwitch;
|
||||
RenderingBuffer* fBackBuffer;
|
||||
AccelerantBuffer* fFrontBuffer;
|
||||
bool fOffscreenBackBuffer;
|
||||
|
||||
mutable fill_rect_params* fRectParams;
|
||||
mutable uint32 fRectParamsCount;
|
||||
mutable blit_params* fBlitParams;
|
||||
mutable uint32 fBlitParamsCount;
|
||||
display_mode fDisplayMode;
|
||||
bool fInitialModeSwitch;
|
||||
|
||||
mutable fill_rect_params* fRectParams;
|
||||
mutable uint32 fRectParamsCount;
|
||||
mutable blit_params* fBlitParams;
|
||||
mutable uint32 fBlitParamsCount;
|
||||
};
|
||||
|
||||
#endif // ACCELERANT_HW_INTERFACE_H
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2005, Haiku.
|
||||
* Copyright 2002-2009, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -23,9 +23,10 @@ using std::nothrow;
|
||||
|
||||
|
||||
BitmapHWInterface::BitmapHWInterface(ServerBitmap* bitmap)
|
||||
: HWInterface(false, false),
|
||||
fBackBuffer(NULL),
|
||||
fFrontBuffer(new(nothrow) BitmapBuffer(bitmap))
|
||||
:
|
||||
HWInterface(false, false),
|
||||
fBackBuffer(NULL),
|
||||
fFrontBuffer(new(nothrow) BitmapBuffer(bitmap))
|
||||
{
|
||||
}
|
||||
|
||||
@ -54,8 +55,7 @@ BitmapHWInterface::Initialize()
|
||||
if (fFrontBuffer->ColorSpace() != B_RGB32
|
||||
&& fFrontBuffer->ColorSpace() != B_RGBA32) {
|
||||
BBitmap* backBitmap = new BBitmap(fFrontBuffer->Bounds(),
|
||||
B_BITMAP_NO_SERVER_LINK,
|
||||
B_RGBA32);
|
||||
B_BITMAP_NO_SERVER_LINK, B_RGBA32);
|
||||
fBackBuffer = new BBitmapBuffer(backBitmap);
|
||||
|
||||
ret = fBackBuffer->InitCheck();
|
||||
@ -66,10 +66,8 @@ BitmapHWInterface::Initialize()
|
||||
// import the current contents of the bitmap
|
||||
// into the back bitmap
|
||||
backBitmap->ImportBits(fFrontBuffer->Bits(),
|
||||
fFrontBuffer->BitsLength(),
|
||||
fFrontBuffer->BytesPerRow(),
|
||||
0,
|
||||
fFrontBuffer->ColorSpace());
|
||||
fFrontBuffer->BitsLength(), fFrontBuffer->BytesPerRow(), 0,
|
||||
fFrontBuffer->ColorSpace());
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,23 +83,22 @@ BitmapHWInterface::Shutdown()
|
||||
|
||||
|
||||
status_t
|
||||
BitmapHWInterface::SetMode(const display_mode &mode)
|
||||
BitmapHWInterface::SetMode(const display_mode& mode)
|
||||
{
|
||||
return B_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BitmapHWInterface::GetMode(display_mode *mode)
|
||||
BitmapHWInterface::GetMode(display_mode* mode)
|
||||
{
|
||||
if (mode) {
|
||||
if (mode != NULL)
|
||||
memset(mode, 0, sizeof(display_mode));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BitmapHWInterface::GetDeviceInfo(accelerant_device_info *info)
|
||||
BitmapHWInterface::GetDeviceInfo(accelerant_device_info* info)
|
||||
{
|
||||
return B_UNSUPPORTED;
|
||||
}
|
||||
@ -120,77 +117,79 @@ BitmapHWInterface::GetModeList(display_mode** modes, uint32 *count)
|
||||
return B_UNSUPPORTED;
|
||||
}
|
||||
|
||||
// GetPixelClockLimits
|
||||
|
||||
status_t
|
||||
BitmapHWInterface::GetPixelClockLimits(display_mode *mode, uint32 *low, uint32 *high)
|
||||
BitmapHWInterface::GetPixelClockLimits(display_mode* mode, uint32* low,
|
||||
uint32* high)
|
||||
{
|
||||
return B_UNSUPPORTED;
|
||||
}
|
||||
|
||||
// GetPixelClockLimits
|
||||
|
||||
status_t
|
||||
BitmapHWInterface::GetTimingConstraints(display_timing_constraints *dtc)
|
||||
BitmapHWInterface::GetTimingConstraints(display_timing_constraints* constraints)
|
||||
{
|
||||
return B_UNSUPPORTED;
|
||||
}
|
||||
|
||||
// ProposeMode
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// RetraceSemaphore
|
||||
|
||||
sem_id
|
||||
BitmapHWInterface::RetraceSemaphore()
|
||||
{
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
// WaitForRetrace
|
||||
|
||||
status_t
|
||||
BitmapHWInterface::WaitForRetrace(bigtime_t timeout)
|
||||
{
|
||||
return B_UNSUPPORTED;
|
||||
}
|
||||
|
||||
// SetDPMSMode
|
||||
|
||||
status_t
|
||||
BitmapHWInterface::SetDPMSMode(const uint32 &state)
|
||||
BitmapHWInterface::SetDPMSMode(uint32 state)
|
||||
{
|
||||
return B_UNSUPPORTED;
|
||||
}
|
||||
|
||||
// DPMSMode
|
||||
|
||||
uint32
|
||||
BitmapHWInterface::DPMSMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// DPMSCapabilities
|
||||
|
||||
uint32
|
||||
BitmapHWInterface::DPMSCapabilities()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// FrontBuffer
|
||||
RenderingBuffer *
|
||||
|
||||
RenderingBuffer*
|
||||
BitmapHWInterface::FrontBuffer() const
|
||||
{
|
||||
return fFrontBuffer;
|
||||
}
|
||||
|
||||
// BackBuffer
|
||||
RenderingBuffer *
|
||||
|
||||
RenderingBuffer*
|
||||
BitmapHWInterface::BackBuffer() const
|
||||
{
|
||||
return fBackBuffer;
|
||||
}
|
||||
|
||||
// IsDoubleBuffered
|
||||
|
||||
bool
|
||||
BitmapHWInterface::IsDoubleBuffered() const
|
||||
{
|
||||
@ -200,5 +199,3 @@ BitmapHWInterface::IsDoubleBuffered() const
|
||||
|
||||
return HWInterface::IsDoubleBuffered();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005, Haiku.
|
||||
* Copyright 2005-2009, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -18,7 +18,7 @@ class BBitmapBuffer;
|
||||
|
||||
|
||||
class BitmapHWInterface : public HWInterface {
|
||||
public:
|
||||
public:
|
||||
BitmapHWInterface(ServerBitmap* bitmap);
|
||||
virtual ~BitmapHWInterface();
|
||||
|
||||
@ -26,25 +26,28 @@ class BitmapHWInterface : public HWInterface {
|
||||
virtual status_t Shutdown();
|
||||
|
||||
// overwrite all the meaningless functions with empty code
|
||||
virtual status_t SetMode(const display_mode &mode);
|
||||
virtual void GetMode(display_mode *mode);
|
||||
|
||||
virtual status_t GetDeviceInfo(accelerant_device_info *info);
|
||||
virtual status_t GetFrameBufferConfig(frame_buffer_config& config);
|
||||
virtual status_t SetMode(const display_mode& mode);
|
||||
virtual void GetMode(display_mode* mode);
|
||||
|
||||
virtual status_t GetDeviceInfo(accelerant_device_info* info);
|
||||
virtual status_t GetFrameBufferConfig(
|
||||
frame_buffer_config& config);
|
||||
|
||||
virtual status_t GetModeList(display_mode** _modeList,
|
||||
uint32* _count);
|
||||
virtual status_t GetPixelClockLimits(display_mode* mode,
|
||||
uint32* _low, uint32* _high);
|
||||
virtual status_t GetTimingConstraints(display_timing_constraints*
|
||||
constraints);
|
||||
virtual status_t ProposeMode(display_mode* candidate,
|
||||
const display_mode* low,
|
||||
const display_mode* high);
|
||||
|
||||
virtual status_t GetModeList(display_mode **mode_list,
|
||||
uint32 *count);
|
||||
virtual status_t GetPixelClockLimits(display_mode *mode,
|
||||
uint32 *low, uint32 *high);
|
||||
virtual status_t GetTimingConstraints(display_timing_constraints *dtc);
|
||||
virtual status_t ProposeMode(display_mode *candidate,
|
||||
const display_mode *low,
|
||||
const display_mode *high);
|
||||
|
||||
virtual sem_id RetraceSemaphore();
|
||||
virtual status_t WaitForRetrace(bigtime_t timeout = B_INFINITE_TIMEOUT);
|
||||
|
||||
virtual status_t SetDPMSMode(const uint32 &state);
|
||||
virtual status_t WaitForRetrace(
|
||||
bigtime_t timeout = B_INFINITE_TIMEOUT);
|
||||
|
||||
virtual status_t SetDPMSMode(uint32 state);
|
||||
virtual uint32 DPMSMode();
|
||||
virtual uint32 DPMSCapabilities();
|
||||
|
||||
@ -54,8 +57,8 @@ class BitmapHWInterface : public HWInterface {
|
||||
virtual bool IsDoubleBuffered() const;
|
||||
|
||||
private:
|
||||
BBitmapBuffer* fBackBuffer;
|
||||
BitmapBuffer* fFrontBuffer;
|
||||
BBitmapBuffer* fBackBuffer;
|
||||
BitmapBuffer* fFrontBuffer;
|
||||
};
|
||||
|
||||
#endif // BITMAP_HW_INTERFACE_H
|
||||
|
@ -1,15 +1,19 @@
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku.
|
||||
* Copyright 2001-2009, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
||||
* Michael Lotz <mmlr@mlotz.ch>
|
||||
* Stephan Aßmus <superstippi@gmx.de>
|
||||
* Michael Lotz <mmlr@mlotz.ch>
|
||||
* Stephan Aßmus <superstippi@gmx.de>
|
||||
*/
|
||||
|
||||
/** BView/BDirectWindow/Accelerant combination HWInterface
|
||||
implementation */
|
||||
|
||||
/*! BView/BDirectWindow/Accelerant combination HWInterface implementation
|
||||
*/
|
||||
|
||||
|
||||
#include "DWindowHWInterface.h"
|
||||
|
||||
#include <malloc.h>
|
||||
#include <new>
|
||||
@ -45,7 +49,6 @@
|
||||
#include "ServerCursor.h"
|
||||
#include "UpdateQueue.h"
|
||||
|
||||
#include "DWindowHWInterface.h"
|
||||
|
||||
#ifdef DEBUG_DRIVER_MODULE
|
||||
# include <stdio.h>
|
||||
@ -54,13 +57,14 @@
|
||||
# define STRACE(x) ;
|
||||
#endif
|
||||
|
||||
|
||||
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};
|
||||
|
||||
|
||||
// run_app_thread
|
||||
static int32
|
||||
run_app_thread(void* cookie)
|
||||
{
|
||||
@ -74,8 +78,9 @@ run_app_thread(void* cookie)
|
||||
|
||||
//#define INPUTSERVER_TEST_MODE 1
|
||||
|
||||
|
||||
class DView : public BView {
|
||||
public:
|
||||
public:
|
||||
DView(BRect bounds);
|
||||
virtual ~DView();
|
||||
|
||||
@ -87,10 +92,10 @@ private:
|
||||
};
|
||||
|
||||
class DWindow : public BWindow {
|
||||
public:
|
||||
public:
|
||||
DWindow(BRect frame,
|
||||
DWindowHWInterface* interface,
|
||||
DWindowBuffer* buffer);
|
||||
DWindowHWInterface* interface,
|
||||
DWindowBuffer* buffer);
|
||||
virtual ~DWindow();
|
||||
|
||||
virtual bool QuitRequested();
|
||||
@ -99,26 +104,28 @@ class DWindow : public BWindow {
|
||||
|
||||
virtual void FrameMoved(BPoint newOffset);
|
||||
|
||||
private:
|
||||
private:
|
||||
DWindowHWInterface* fHWInterface;
|
||||
DWindowBuffer* fBuffer;
|
||||
};
|
||||
|
||||
class DirectMessageFilter : public BMessageFilter {
|
||||
public:
|
||||
DirectMessageFilter(DView* view);
|
||||
public:
|
||||
DirectMessageFilter(DView* view);
|
||||
|
||||
virtual filter_result Filter(BMessage *message, BHandler **_target);
|
||||
virtual filter_result Filter(BMessage *message, BHandler** _target);
|
||||
|
||||
private:
|
||||
DView* fView;
|
||||
private:
|
||||
DView* fView;
|
||||
};
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
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);
|
||||
#ifndef INPUTSERVER_TEST_MODE
|
||||
@ -138,10 +145,10 @@ DView::~DView()
|
||||
}
|
||||
|
||||
|
||||
// This function emulates 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.
|
||||
|
||||
/*! This function emulates 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
|
||||
DView::ForwardMessage(BMessage* message)
|
||||
{
|
||||
@ -169,14 +176,15 @@ DView::ForwardMessage(BMessage* message)
|
||||
|
||||
|
||||
DirectMessageFilter::DirectMessageFilter(DView* view)
|
||||
: BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE),
|
||||
:
|
||||
BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE),
|
||||
fView(view)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
filter_result
|
||||
DirectMessageFilter::Filter(BMessage *message, BHandler **target)
|
||||
DirectMessageFilter::Filter(BMessage* message, BHandler** target)
|
||||
{
|
||||
switch (message->what) {
|
||||
case B_KEY_DOWN:
|
||||
@ -211,11 +219,14 @@ DirectMessageFilter::Filter(BMessage *message, BHandler **target)
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
DWindow::DWindow(BRect frame, DWindowHWInterface* interface, DWindowBuffer* buffer)
|
||||
: 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),
|
||||
fBuffer(buffer)
|
||||
DWindow::DWindow(BRect frame, DWindowHWInterface* interface,
|
||||
DWindowBuffer* buffer)
|
||||
:
|
||||
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),
|
||||
fBuffer(buffer)
|
||||
{
|
||||
DView* view = new DView(Bounds());
|
||||
AddChild(view);
|
||||
@ -229,7 +240,6 @@ DWindow::~DWindow()
|
||||
}
|
||||
|
||||
|
||||
// QuitRequested
|
||||
bool
|
||||
DWindow::QuitRequested()
|
||||
{
|
||||
@ -245,15 +255,16 @@ DWindow::QuitRequested()
|
||||
// we don't quit on ourself, we let us be Quit()!
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// DirectConnected
|
||||
void
|
||||
DWindow::DirectConnected(direct_buffer_info* info)
|
||||
{
|
||||
// fDesktop->LockClipping();
|
||||
//
|
||||
// fEngine.Lock();
|
||||
//
|
||||
//
|
||||
switch(info->buffer_state & B_DIRECT_MODE_MASK) {
|
||||
case B_DIRECT_START:
|
||||
case B_DIRECT_MODIFY:
|
||||
@ -273,57 +284,59 @@ DWindow::DirectConnected(direct_buffer_info* info)
|
||||
}
|
||||
*/
|
||||
|
||||
// FrameMoved
|
||||
|
||||
void
|
||||
DWindow::FrameMoved(BPoint newOffset)
|
||||
{
|
||||
fHWInterface->SetOffset((int32)newOffset.x, (int32)newOffset.y);
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
const int32 kDefaultParamsCount = 64;
|
||||
|
||||
DWindowHWInterface::DWindowHWInterface()
|
||||
: HWInterface(),
|
||||
fFrontBuffer(new DWindowBuffer()),
|
||||
fWindow(NULL),
|
||||
:
|
||||
HWInterface(),
|
||||
fFrontBuffer(new DWindowBuffer()),
|
||||
fWindow(NULL),
|
||||
|
||||
fXOffset(50),
|
||||
fYOffset(50),
|
||||
fXOffset(50),
|
||||
fYOffset(50),
|
||||
|
||||
fCardFD(-1),
|
||||
fAccelerantImage(-1),
|
||||
fAccelerantHook(NULL),
|
||||
fEngineToken(NULL),
|
||||
fSyncToken(),
|
||||
fCardFD(-1),
|
||||
fAccelerantImage(-1),
|
||||
fAccelerantHook(NULL),
|
||||
fEngineToken(NULL),
|
||||
fSyncToken(),
|
||||
|
||||
// required hooks
|
||||
fAccAcquireEngine(NULL),
|
||||
fAccReleaseEngine(NULL),
|
||||
fAccSyncToToken(NULL),
|
||||
fAccGetModeCount(NULL),
|
||||
fAccGetModeList(NULL),
|
||||
fAccGetFrameBufferConfig(NULL),
|
||||
fAccSetDisplayMode(NULL),
|
||||
fAccGetDisplayMode(NULL),
|
||||
fAccGetPixelClockLimits(NULL),
|
||||
// required hooks
|
||||
fAccAcquireEngine(NULL),
|
||||
fAccReleaseEngine(NULL),
|
||||
fAccSyncToToken(NULL),
|
||||
fAccGetModeCount(NULL),
|
||||
fAccGetModeList(NULL),
|
||||
fAccGetFrameBufferConfig(NULL),
|
||||
fAccSetDisplayMode(NULL),
|
||||
fAccGetDisplayMode(NULL),
|
||||
fAccGetPixelClockLimits(NULL),
|
||||
|
||||
// optional accelerant hooks
|
||||
fAccGetTimingConstraints(NULL),
|
||||
fAccProposeDisplayMode(NULL),
|
||||
fAccFillRect(NULL),
|
||||
fAccInvertRect(NULL),
|
||||
fAccScreenBlit(NULL),
|
||||
fAccSetCursorShape(NULL),
|
||||
fAccMoveCursor(NULL),
|
||||
fAccShowCursor(NULL),
|
||||
// optional accelerant hooks
|
||||
fAccGetTimingConstraints(NULL),
|
||||
fAccProposeDisplayMode(NULL),
|
||||
fAccFillRect(NULL),
|
||||
fAccInvertRect(NULL),
|
||||
fAccScreenBlit(NULL),
|
||||
fAccSetCursorShape(NULL),
|
||||
fAccMoveCursor(NULL),
|
||||
fAccShowCursor(NULL),
|
||||
|
||||
fRectParams(new (nothrow) fill_rect_params[kDefaultParamsCount]),
|
||||
fRectParamsCount(kDefaultParamsCount),
|
||||
fBlitParams(new (nothrow) blit_params[kDefaultParamsCount]),
|
||||
fBlitParamsCount(kDefaultParamsCount)
|
||||
fRectParams(new (nothrow) fill_rect_params[kDefaultParamsCount]),
|
||||
fRectParamsCount(kDefaultParamsCount),
|
||||
fBlitParams(new (nothrow) blit_params[kDefaultParamsCount]),
|
||||
fBlitParamsCount(kDefaultParamsCount)
|
||||
{
|
||||
fDisplayMode.virtual_width = 800;
|
||||
fDisplayMode.virtual_height = 600;
|
||||
@ -350,7 +363,7 @@ DWindowHWInterface::~DWindowHWInterface()
|
||||
delete be_app;
|
||||
}
|
||||
|
||||
// Initialize
|
||||
|
||||
status_t
|
||||
DWindowHWInterface::Initialize()
|
||||
{
|
||||
@ -366,28 +379,28 @@ DWindowHWInterface::Initialize()
|
||||
STRACE(("Failed to open graphics device\n"));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (_OpenAccelerant(fCardFD) == B_OK)
|
||||
break;
|
||||
|
||||
|
||||
close(fCardFD);
|
||||
// _OpenAccelerant() failed, try to open next graphics card
|
||||
}
|
||||
|
||||
|
||||
return fCardFD >= 0 ? B_OK : fCardFD;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Opens a graphics device for read-write access
|
||||
\param deviceNumber Number identifying which graphics card to open (1 for first card)
|
||||
/*! \brief Opens a graphics device for read-write access
|
||||
\param deviceNumber Number identifying which graphics card to open (1 for
|
||||
first card)
|
||||
\return The file descriptor for the opened graphics device
|
||||
|
||||
The deviceNumber is relative to the number of graphics devices that can be successfully
|
||||
opened. One represents the first card that can be successfully opened (not necessarily
|
||||
the first one listed in the directory).
|
||||
|
||||
The deviceNumber is relative to the number of graphics devices that can be
|
||||
successfully opened. One represents the first card that can be successfully
|
||||
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
|
||||
the first working entry.
|
||||
*/
|
||||
@ -444,7 +457,7 @@ status_t
|
||||
DWindowHWInterface::_OpenAccelerant(int device)
|
||||
{
|
||||
char signature[1024];
|
||||
if (ioctl(device, B_GET_ACCELERANT_SIGNATURE,
|
||||
if (ioctl(device, B_GET_ACCELERANT_SIGNATURE,
|
||||
&signature, sizeof(signature)) != B_OK)
|
||||
return B_ERROR;
|
||||
|
||||
@ -481,7 +494,8 @@ DWindowHWInterface::_OpenAccelerant(int device)
|
||||
|
||||
|
||||
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) {
|
||||
STRACE(("unable to get B_ACCELERANT_CLONE_INFO_SIZE (%s)\n", path));
|
||||
unload_add_on(fAccelerantImage);
|
||||
@ -554,12 +568,17 @@ DWindowHWInterface::_SetupDefaultHooks()
|
||||
fAccAcquireEngine = (acquire_engine)fAccelerantHook(B_ACQUIRE_ENGINE, NULL);
|
||||
fAccReleaseEngine = (release_engine)fAccelerantHook(B_RELEASE_ENGINE, 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);
|
||||
fAccGetFrameBufferConfig = (get_frame_buffer_config)fAccelerantHook(B_GET_FRAME_BUFFER_CONFIG, NULL);
|
||||
fAccSetDisplayMode = (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);
|
||||
fAccGetFrameBufferConfig = (get_frame_buffer_config)fAccelerantHook(
|
||||
B_GET_FRAME_BUFFER_CONFIG, NULL);
|
||||
fAccSetDisplayMode = (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
|
||||
|| !fAccGetModeCount || !fAccGetModeList || !fAccSetDisplayMode
|
||||
@ -568,24 +587,28 @@ DWindowHWInterface::_SetupDefaultHooks()
|
||||
}
|
||||
|
||||
// optional
|
||||
fAccGetTimingConstraints = (get_timing_constraints)fAccelerantHook(B_GET_TIMING_CONSTRAINTS, NULL);
|
||||
fAccProposeDisplayMode = (propose_display_mode)fAccelerantHook(B_PROPOSE_DISPLAY_MODE, NULL);
|
||||
fAccGetTimingConstraints = (get_timing_constraints)fAccelerantHook(
|
||||
B_GET_TIMING_CONSTRAINTS, NULL);
|
||||
fAccProposeDisplayMode = (propose_display_mode)fAccelerantHook(
|
||||
B_PROPOSE_DISPLAY_MODE, NULL);
|
||||
|
||||
// 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);
|
||||
fAccShowCursor = (show_cursor)fAccelerantHook(B_SHOW_CURSOR, NULL);
|
||||
|
||||
// update acceleration hooks
|
||||
// TODO: would actually have to pass a valid display_mode!
|
||||
fAccFillRect = (fill_rectangle)fAccelerantHook(B_FILL_RECTANGLE, NULL);
|
||||
fAccInvertRect = (invert_rectangle)fAccelerantHook(B_INVERT_RECTANGLE, NULL);
|
||||
fAccScreenBlit = (screen_to_screen_blit)fAccelerantHook(B_SCREEN_TO_SCREEN_BLIT, NULL);
|
||||
// update acceleration hooks
|
||||
// TODO: would actually have to pass a valid display_mode!
|
||||
fAccFillRect = (fill_rectangle)fAccelerantHook(B_FILL_RECTANGLE, NULL);
|
||||
fAccInvertRect = (invert_rectangle)fAccelerantHook(B_INVERT_RECTANGLE, NULL);
|
||||
fAccScreenBlit = (screen_to_screen_blit)fAccelerantHook(
|
||||
B_SCREEN_TO_SCREEN_BLIT, NULL);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// _UpdateFrameBufferConfig
|
||||
|
||||
status_t
|
||||
DWindowHWInterface::_UpdateFrameBufferConfig()
|
||||
{
|
||||
@ -595,38 +618,36 @@ DWindowHWInterface::_UpdateFrameBufferConfig()
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
fFrontBuffer->SetTo(&config, fXOffset, fYOffset,
|
||||
fDisplayMode.virtual_width,
|
||||
fDisplayMode.virtual_height,
|
||||
(color_space)fDisplayMode.space);
|
||||
fFrontBuffer->SetTo(&config, fXOffset, fYOffset, fDisplayMode.virtual_width,
|
||||
fDisplayMode.virtual_height, (color_space)fDisplayMode.space);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
// Shutdown
|
||||
status_t
|
||||
DWindowHWInterface::Shutdown()
|
||||
{
|
||||
printf("DWindowHWInterface::Shutdown()\n");
|
||||
printf("DWindowHWInterface::Shutdown()\n");
|
||||
if (fAccelerantHook) {
|
||||
uninit_accelerant UninitAccelerant = (uninit_accelerant)fAccelerantHook(B_UNINIT_ACCELERANT, NULL);
|
||||
uninit_accelerant UninitAccelerant
|
||||
= (uninit_accelerant)fAccelerantHook(B_UNINIT_ACCELERANT, NULL);
|
||||
if (UninitAccelerant)
|
||||
UninitAccelerant();
|
||||
}
|
||||
|
||||
|
||||
if (fAccelerantImage >= 0)
|
||||
unload_add_on(fAccelerantImage);
|
||||
|
||||
|
||||
if (fCardFD >= 0)
|
||||
close(fCardFD);
|
||||
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// SetMode
|
||||
|
||||
status_t
|
||||
DWindowHWInterface::SetMode(const display_mode &mode)
|
||||
DWindowHWInterface::SetMode(const display_mode& mode)
|
||||
{
|
||||
AutoWriteLocker _(this);
|
||||
|
||||
@ -684,7 +705,8 @@ DWindowHWInterface::SetMode(const display_mode &mode)
|
||||
if (ret < B_OK)
|
||||
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
|
||||
fWindow->Hide();
|
||||
@ -692,7 +714,7 @@ DWindowHWInterface::SetMode(const display_mode &mode)
|
||||
}
|
||||
|
||||
if (fWindow->Lock()) {
|
||||
// free and reallocate the bitmaps while the window is locked,
|
||||
// free and reallocate the bitmaps while the window is locked,
|
||||
// so that the view does not accidentally draw a freed bitmap
|
||||
|
||||
if (ret >= B_OK) {
|
||||
@ -715,7 +737,7 @@ DWindowHWInterface::SetMode(const display_mode &mode)
|
||||
return ret;
|
||||
}
|
||||
|
||||
// GetMode
|
||||
|
||||
void
|
||||
DWindowHWInterface::GetMode(display_mode* mode)
|
||||
{
|
||||
@ -725,9 +747,9 @@ DWindowHWInterface::GetMode(display_mode* mode)
|
||||
}
|
||||
}
|
||||
|
||||
// GetDeviceInfo
|
||||
|
||||
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
|
||||
// a software-only driver, but we'll have some fun, anyway.
|
||||
@ -761,7 +783,7 @@ DWindowHWInterface::GetFrameBufferConfig(frame_buffer_config& config)
|
||||
|
||||
|
||||
status_t
|
||||
DWindowHWInterface::GetModeList(display_mode **_modes, uint32 *_count)
|
||||
DWindowHWInterface::GetModeList(display_mode** _modes, uint32* _count)
|
||||
{
|
||||
AutoReadLocker _(this);
|
||||
|
||||
@ -775,7 +797,7 @@ DWindowHWInterface::GetModeList(display_mode **_modes, uint32 *_count)
|
||||
// const uint32 colors[] = {B_CMAP8, B_RGB15, B_RGB16, B_RGB32};
|
||||
uint32 count = resolutionCount/* * 4*/;
|
||||
|
||||
display_mode *modes = new(nothrow) display_mode[count];
|
||||
display_mode* modes = new(nothrow) display_mode[count];
|
||||
if (modes == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
@ -815,35 +837,42 @@ DWindowHWInterface::GetModeList(display_mode **_modes, uint32 *_count)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
DWindowHWInterface::GetPixelClockLimits(display_mode *mode, uint32 *low, uint32 *high)
|
||||
DWindowHWInterface::GetPixelClockLimits(display_mode* mode, uint32* low,
|
||||
uint32* high)
|
||||
{
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
DWindowHWInterface::GetTimingConstraints(display_timing_constraints *dtc)
|
||||
DWindowHWInterface::GetTimingConstraints(
|
||||
display_timing_constraints* constraints)
|
||||
{
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
// specific hardware. This is a Good Thing(TM) because we can support any hardware
|
||||
// we wish within reasonable expectaions and programmer laziness. :P
|
||||
// We should be able to get away with this because we're not dealing with
|
||||
// any specific hardware. This is a Good Thing(TM) because we can support
|
||||
// any hardware we wish within reasonable expectaions and programmer
|
||||
// laziness. :P
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// RetraceSemaphore
|
||||
|
||||
sem_id
|
||||
DWindowHWInterface::RetraceSemaphore()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// WaitForRetrace
|
||||
|
||||
status_t
|
||||
DWindowHWInterface::WaitForRetrace(bigtime_t timeout = B_INFINITE_TIMEOUT)
|
||||
{
|
||||
@ -852,16 +881,16 @@ DWindowHWInterface::WaitForRetrace(bigtime_t timeout = B_INFINITE_TIMEOUT)
|
||||
return screen.WaitForRetrace(timeout);
|
||||
}
|
||||
|
||||
// SetDPMSMode
|
||||
|
||||
status_t
|
||||
DWindowHWInterface::SetDPMSMode(const uint32 &state)
|
||||
DWindowHWInterface::SetDPMSMode(uint32 state)
|
||||
{
|
||||
AutoWriteLocker _(this);
|
||||
|
||||
return BScreen().SetDPMS(state);
|
||||
}
|
||||
|
||||
// DPMSMode
|
||||
|
||||
uint32
|
||||
DWindowHWInterface::DPMSMode()
|
||||
{
|
||||
@ -870,7 +899,7 @@ DWindowHWInterface::DPMSMode()
|
||||
return BScreen().DPMSState();
|
||||
}
|
||||
|
||||
// DPMSCapabilities
|
||||
|
||||
uint32
|
||||
DWindowHWInterface::DPMSCapabilities()
|
||||
{
|
||||
@ -879,7 +908,7 @@ DWindowHWInterface::DPMSCapabilities()
|
||||
return BScreen().DPMSCapabilites();
|
||||
}
|
||||
|
||||
// AvailableHardwareAcceleration
|
||||
|
||||
uint32
|
||||
DWindowHWInterface::AvailableHWAcceleration() const
|
||||
{
|
||||
@ -897,19 +926,21 @@ DWindowHWInterface::AvailableHWAcceleration() const
|
||||
return flags;
|
||||
}
|
||||
|
||||
// CopyRegion
|
||||
|
||||
void
|
||||
DWindowHWInterface::CopyRegion(const clipping_rect* sortedRectList,
|
||||
uint32 count, int32 xOffset, int32 yOffset)
|
||||
uint32 count, int32 xOffset, int32 yOffset)
|
||||
{
|
||||
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
|
||||
if (fBlitParamsCount < count) {
|
||||
fBlitParamsCount = (count / kDefaultParamsCount + 1) * kDefaultParamsCount;
|
||||
fBlitParamsCount = (count / kDefaultParamsCount + 1)
|
||||
* kDefaultParamsCount;
|
||||
// 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) {
|
||||
delete[] fBlitParams;
|
||||
fBlitParams = params;
|
||||
@ -919,15 +950,21 @@ DWindowHWInterface::CopyRegion(const clipping_rect* sortedRectList,
|
||||
}
|
||||
// convert the rects
|
||||
for (uint32 i = 0; i < count; i++) {
|
||||
fBlitParams[i].src_left = (uint16)sortedRectList[i].left + fXOffset;
|
||||
fBlitParams[i].src_top = (uint16)sortedRectList[i].top + fYOffset;
|
||||
fBlitParams[i].src_left
|
||||
= (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_top = (uint16)sortedRectList[i].top + yOffset + fYOffset;
|
||||
fBlitParams[i].dest_left
|
||||
= (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!
|
||||
fBlitParams[i].width = (uint16)(sortedRectList[i].right - sortedRectList[i].left);
|
||||
fBlitParams[i].height = (uint16)(sortedRectList[i].bottom - sortedRectList[i].top);
|
||||
// NOTE: width and height are expressed as distance, not count!
|
||||
fBlitParams[i].width = (uint16)(sortedRectList[i].right
|
||||
- sortedRectList[i].left);
|
||||
fBlitParams[i].height = (uint16)(sortedRectList[i].bottom
|
||||
- sortedRectList[i].top);
|
||||
}
|
||||
|
||||
// go
|
||||
@ -944,15 +981,14 @@ DWindowHWInterface::CopyRegion(const clipping_rect* sortedRectList,
|
||||
}
|
||||
}
|
||||
|
||||
// FillRegion
|
||||
|
||||
void
|
||||
DWindowHWInterface::FillRegion(/*const*/ BRegion& region,
|
||||
const rgb_color& color, bool autoSync)
|
||||
{
|
||||
if (fAccFillRect && fAccAcquireEngine) {
|
||||
if (fAccAcquireEngine(B_2D_ACCELERATION, 0xff, &fSyncToken,
|
||||
&fEngineToken) >= B_OK) {
|
||||
|
||||
&fEngineToken) >= B_OK) {
|
||||
// convert the region
|
||||
uint32 count;
|
||||
_RegionToRectParams(®ion, &count);
|
||||
@ -971,13 +1007,13 @@ DWindowHWInterface::FillRegion(/*const*/ BRegion& region,
|
||||
}
|
||||
}
|
||||
|
||||
// InvertRegion
|
||||
|
||||
void
|
||||
DWindowHWInterface::InvertRegion(/*const*/ BRegion& region)
|
||||
{
|
||||
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
|
||||
uint32 count;
|
||||
_RegionToRectParams(®ion, &count);
|
||||
@ -997,11 +1033,12 @@ DWindowHWInterface::InvertRegion(/*const*/ BRegion& region)
|
||||
fprintf(stderr, "AcquireEngine failed!\n");
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "AccelerantHWInterface::InvertRegion() called, but hook not available!\n");
|
||||
fprintf(stderr, "AccelerantHWInterface::InvertRegion() called, but "
|
||||
"hook not available!\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Sync
|
||||
|
||||
void
|
||||
DWindowHWInterface::Sync()
|
||||
{
|
||||
@ -1009,35 +1046,35 @@ DWindowHWInterface::Sync()
|
||||
fAccSyncToToken(&fSyncToken);
|
||||
}
|
||||
|
||||
// FrontBuffer
|
||||
|
||||
RenderingBuffer*
|
||||
DWindowHWInterface::FrontBuffer() const
|
||||
{
|
||||
return fFrontBuffer;
|
||||
}
|
||||
|
||||
// BackBuffer
|
||||
|
||||
RenderingBuffer*
|
||||
DWindowHWInterface::BackBuffer() const
|
||||
{
|
||||
return fFrontBuffer;
|
||||
}
|
||||
|
||||
// IsDoubleBuffered
|
||||
|
||||
bool
|
||||
DWindowHWInterface::IsDoubleBuffered() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Invalidate
|
||||
|
||||
status_t
|
||||
DWindowHWInterface::Invalidate(const BRect& frame)
|
||||
{
|
||||
return HWInterface::Invalidate(frame);
|
||||
}
|
||||
|
||||
// SetOffset
|
||||
|
||||
void
|
||||
DWindowHWInterface::SetOffset(int32 left, int32 top)
|
||||
{
|
||||
@ -1054,16 +1091,18 @@ DWindowHWInterface::SetOffset(int32 left, int32 top)
|
||||
WriteUnlock();
|
||||
}
|
||||
|
||||
// _RegionToRectParams
|
||||
|
||||
void
|
||||
DWindowHWInterface::_RegionToRectParams(/*const*/ BRegion* region,
|
||||
uint32* count) const
|
||||
uint32* count) const
|
||||
{
|
||||
*count = region->CountRects();
|
||||
if (fRectParamsCount < *count) {
|
||||
fRectParamsCount = (*count / kDefaultParamsCount + 1) * kDefaultParamsCount;
|
||||
fRectParamsCount = (*count / kDefaultParamsCount + 1)
|
||||
* kDefaultParamsCount;
|
||||
// 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) {
|
||||
delete[] fRectParams;
|
||||
fRectParams = params;
|
||||
@ -1081,7 +1120,7 @@ DWindowHWInterface::_RegionToRectParams(/*const*/ BRegion* region,
|
||||
}
|
||||
}
|
||||
|
||||
// _NativeColor
|
||||
|
||||
uint32
|
||||
DWindowHWInterface::_NativeColor(const rgb_color& color) const
|
||||
{
|
||||
@ -1106,10 +1145,8 @@ DWindowHWInterface::_NativeColor(const rgb_color& color) const
|
||||
case B_RGBA32_BIG:
|
||||
case B_RGB32_LITTLE:
|
||||
case B_RGBA32_LITTLE: {
|
||||
uint32 native = (color.alpha << 24) |
|
||||
(color.red << 16) |
|
||||
(color.green << 8) |
|
||||
(color.blue);
|
||||
uint32 native = (color.alpha << 24) | (color.red << 16)
|
||||
| (color.green << 8) | (color.blue);
|
||||
return native;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005, Haiku.
|
||||
* Copyright 2005-2009, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -10,11 +10,12 @@
|
||||
#define D_WINDOW_HW_INTERACE_H
|
||||
|
||||
|
||||
#include "HWInterface.h"
|
||||
|
||||
#include <Accelerant.h>
|
||||
#include <Region.h>
|
||||
#include <String.h>
|
||||
|
||||
#include "HWInterface.h"
|
||||
|
||||
class DWindowBuffer;
|
||||
class DWindow;
|
||||
@ -22,33 +23,35 @@ class UpdateQueue;
|
||||
|
||||
|
||||
class DWindowHWInterface : public HWInterface {
|
||||
public:
|
||||
public:
|
||||
DWindowHWInterface();
|
||||
virtual ~DWindowHWInterface();
|
||||
|
||||
virtual status_t Initialize();
|
||||
virtual status_t Shutdown();
|
||||
|
||||
virtual status_t SetMode(const display_mode &mode);
|
||||
virtual void GetMode(display_mode *mode);
|
||||
virtual status_t SetMode(const display_mode& mode);
|
||||
virtual void GetMode(display_mode* mode);
|
||||
|
||||
virtual status_t GetDeviceInfo(accelerant_device_info *info);
|
||||
virtual status_t GetFrameBufferConfig(frame_buffer_config& config);
|
||||
virtual status_t GetDeviceInfo(accelerant_device_info* info);
|
||||
virtual status_t GetFrameBufferConfig(
|
||||
frame_buffer_config& config);
|
||||
|
||||
virtual status_t GetModeList(display_mode **mode_list,
|
||||
uint32 *count);
|
||||
virtual status_t GetPixelClockLimits(display_mode *mode,
|
||||
uint32 *low,
|
||||
uint32 *high);
|
||||
virtual status_t GetTimingConstraints(display_timing_constraints *dtc);
|
||||
virtual status_t ProposeMode(display_mode *candidate,
|
||||
const display_mode *low,
|
||||
const display_mode *high);
|
||||
virtual status_t GetModeList(display_mode** _modeList,
|
||||
uint32* _count);
|
||||
virtual status_t GetPixelClockLimits(display_mode* mode,
|
||||
uint32* _low, uint32* _high);
|
||||
virtual status_t GetTimingConstraints(display_timing_constraints*
|
||||
constraints);
|
||||
virtual status_t ProposeMode(display_mode* candidate,
|
||||
const display_mode* low,
|
||||
const display_mode* high);
|
||||
|
||||
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 DPMSCapabilities();
|
||||
|
||||
@ -56,11 +59,9 @@ class DWindowHWInterface : public HWInterface {
|
||||
virtual uint32 AvailableHWAcceleration() const;
|
||||
|
||||
virtual void CopyRegion(const clipping_rect* sortedRectList,
|
||||
uint32 count,
|
||||
int32 xOffset, int32 yOffset);
|
||||
uint32 count, int32 xOffset, int32 yOffset);
|
||||
virtual void FillRegion(/*const*/ BRegion& region,
|
||||
const rgb_color& color,
|
||||
bool autoSync);
|
||||
const rgb_color& color, bool autoSync);
|
||||
virtual void InvertRegion(/*const*/ BRegion& region);
|
||||
|
||||
virtual void Sync();
|
||||
@ -75,7 +76,7 @@ class DWindowHWInterface : public HWInterface {
|
||||
// DWindowHWInterface
|
||||
void SetOffset(int32 left, int32 top);
|
||||
|
||||
private:
|
||||
private:
|
||||
DWindowBuffer* fFrontBuffer;
|
||||
|
||||
DWindow* fWindow;
|
||||
@ -91,46 +92,45 @@ class DWindowHWInterface : public HWInterface {
|
||||
status_t _UpdateFrameBufferConfig();
|
||||
|
||||
void _RegionToRectParams(/*const*/ BRegion* region,
|
||||
uint32* count) const;
|
||||
uint32* count) const;
|
||||
uint32 _NativeColor(const rgb_color& color) const;
|
||||
|
||||
private:
|
||||
int fCardFD;
|
||||
image_id fAccelerantImage;
|
||||
GetAccelerantHook fAccelerantHook;
|
||||
engine_token* fEngineToken;
|
||||
sync_token fSyncToken;
|
||||
|
||||
// required hooks - guaranteed to be valid
|
||||
acquire_engine fAccAcquireEngine;
|
||||
release_engine fAccReleaseEngine;
|
||||
sync_to_token fAccSyncToToken;
|
||||
accelerant_mode_count fAccGetModeCount;
|
||||
get_mode_list fAccGetModeList;
|
||||
get_frame_buffer_config fAccGetFrameBufferConfig;
|
||||
set_display_mode fAccSetDisplayMode;
|
||||
get_display_mode fAccGetDisplayMode;
|
||||
get_pixel_clock_limits fAccGetPixelClockLimits;
|
||||
|
||||
int fCardFD;
|
||||
image_id fAccelerantImage;
|
||||
GetAccelerantHook fAccelerantHook;
|
||||
engine_token *fEngineToken;
|
||||
sync_token fSyncToken;
|
||||
// optional accelerant hooks
|
||||
get_timing_constraints fAccGetTimingConstraints;
|
||||
propose_display_mode fAccProposeDisplayMode;
|
||||
fill_rectangle fAccFillRect;
|
||||
invert_rectangle fAccInvertRect;
|
||||
screen_to_screen_blit fAccScreenBlit;
|
||||
set_cursor_shape fAccSetCursorShape;
|
||||
move_cursor fAccMoveCursor;
|
||||
show_cursor fAccShowCursor;
|
||||
|
||||
// required hooks - guaranteed to be valid
|
||||
acquire_engine fAccAcquireEngine;
|
||||
release_engine fAccReleaseEngine;
|
||||
sync_to_token fAccSyncToToken;
|
||||
accelerant_mode_count fAccGetModeCount;
|
||||
get_mode_list fAccGetModeList;
|
||||
get_frame_buffer_config fAccGetFrameBufferConfig;
|
||||
set_display_mode fAccSetDisplayMode;
|
||||
get_display_mode fAccGetDisplayMode;
|
||||
get_pixel_clock_limits fAccGetPixelClockLimits;
|
||||
frame_buffer_config fFrameBufferConfig;
|
||||
|
||||
// optional accelerant hooks
|
||||
get_timing_constraints fAccGetTimingConstraints;
|
||||
propose_display_mode fAccProposeDisplayMode;
|
||||
fill_rectangle fAccFillRect;
|
||||
invert_rectangle fAccInvertRect;
|
||||
screen_to_screen_blit fAccScreenBlit;
|
||||
set_cursor_shape fAccSetCursorShape;
|
||||
move_cursor fAccMoveCursor;
|
||||
show_cursor fAccShowCursor;
|
||||
BString fCardNameInDevFS;
|
||||
|
||||
frame_buffer_config fFrameBufferConfig;
|
||||
|
||||
BString fCardNameInDevFS;
|
||||
|
||||
mutable fill_rect_params* fRectParams;
|
||||
mutable uint32 fRectParamsCount;
|
||||
mutable blit_params* fBlitParams;
|
||||
mutable uint32 fBlitParamsCount;
|
||||
mutable fill_rect_params* fRectParams;
|
||||
mutable uint32 fRectParamsCount;
|
||||
mutable blit_params* fBlitParams;
|
||||
mutable uint32 fBlitParamsCount;
|
||||
};
|
||||
|
||||
#endif // D_WINDOW_HW_INTERACE_H
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2007, Haiku.
|
||||
* Copyright 2005-2009, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -40,25 +40,26 @@ HWInterfaceListener::~HWInterfaceListener()
|
||||
|
||||
|
||||
HWInterface::HWInterface(bool doubleBuffered, bool enableUpdateQueue)
|
||||
: MultiLocker("hw interface lock"),
|
||||
fCursorAreaBackup(NULL),
|
||||
fFloatingOverlaysLock("floating overlays lock"),
|
||||
fCursor(NULL),
|
||||
fDragBitmap(NULL),
|
||||
fDragBitmapOffset(0, 0),
|
||||
fCursorAndDragBitmap(NULL),
|
||||
fCursorVisible(false),
|
||||
fCursorObscured(false),
|
||||
fCursorLocation(0, 0),
|
||||
fDoubleBuffered(doubleBuffered),
|
||||
fVGADevice(-1),
|
||||
fUpdateExecutor(NULL),
|
||||
fListeners(20)
|
||||
:
|
||||
MultiLocker("hw interface lock"),
|
||||
fCursorAreaBackup(NULL),
|
||||
fFloatingOverlaysLock("floating overlays lock"),
|
||||
fCursor(NULL),
|
||||
fDragBitmap(NULL),
|
||||
fDragBitmapOffset(0, 0),
|
||||
fCursorAndDragBitmap(NULL),
|
||||
fCursorVisible(false),
|
||||
fCursorObscured(false),
|
||||
fCursorLocation(0, 0),
|
||||
fDoubleBuffered(doubleBuffered),
|
||||
fVGADevice(-1),
|
||||
fUpdateExecutor(NULL),
|
||||
fListeners(20)
|
||||
{
|
||||
SetAsyncDoubleBuffered(doubleBuffered && enableUpdateQueue);
|
||||
}
|
||||
|
||||
// destructor
|
||||
|
||||
HWInterface::~HWInterface()
|
||||
{
|
||||
SetAsyncDoubleBuffered(false);
|
||||
@ -70,7 +71,7 @@ HWInterface::~HWInterface()
|
||||
delete fCursorAndDragBitmap;
|
||||
}
|
||||
|
||||
// Initialize
|
||||
|
||||
status_t
|
||||
HWInterface::Initialize()
|
||||
{
|
||||
@ -151,18 +152,19 @@ HWInterface::SetCursor(ServerCursor* cursor)
|
||||
fFloatingOverlaysLock.Unlock();
|
||||
}
|
||||
|
||||
// Cursor
|
||||
|
||||
ServerCursorReference
|
||||
HWInterface::Cursor() const
|
||||
{
|
||||
if (!fFloatingOverlaysLock.Lock())
|
||||
return ServerCursorReference(NULL);
|
||||
|
||||
ServerCursorReference reference(fCursor);
|
||||
fFloatingOverlaysLock.Unlock();
|
||||
return reference;
|
||||
}
|
||||
|
||||
// SetCursorVisible
|
||||
|
||||
void
|
||||
HWInterface::SetCursorVisible(bool visible)
|
||||
{
|
||||
@ -191,7 +193,7 @@ HWInterface::SetCursorVisible(bool visible)
|
||||
fFloatingOverlaysLock.Unlock();
|
||||
}
|
||||
|
||||
// IsCursorVisible
|
||||
|
||||
bool
|
||||
HWInterface::IsCursorVisible()
|
||||
{
|
||||
@ -203,7 +205,7 @@ HWInterface::IsCursorVisible()
|
||||
return visible;
|
||||
}
|
||||
|
||||
// ObscureCursor
|
||||
|
||||
void
|
||||
HWInterface::ObscureCursor()
|
||||
{
|
||||
@ -217,9 +219,9 @@ HWInterface::ObscureCursor()
|
||||
fFloatingOverlaysLock.Unlock();
|
||||
}
|
||||
|
||||
// MoveCursorTo
|
||||
|
||||
void
|
||||
HWInterface::MoveCursorTo(const float& x, const float& y)
|
||||
HWInterface::MoveCursorTo(float x, float y)
|
||||
{
|
||||
if (!fFloatingOverlaysLock.Lock())
|
||||
return;
|
||||
@ -269,7 +271,7 @@ HWInterface::CursorPosition()
|
||||
|
||||
void
|
||||
HWInterface::SetDragBitmap(const ServerBitmap* bitmap,
|
||||
const BPoint& offsetFromCursor)
|
||||
const BPoint& offsetFromCursor)
|
||||
{
|
||||
if (fFloatingOverlaysLock.Lock()) {
|
||||
_AdoptDragBitmap(bitmap, offsetFromCursor);
|
||||
@ -315,7 +317,8 @@ HWInterface::IsDoubleBuffered() const
|
||||
}
|
||||
|
||||
|
||||
// * the object needs to be already locked!
|
||||
/*! The object needs to be already locked!
|
||||
*/
|
||||
status_t
|
||||
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
|
||||
HWInterface::CopyBackToFront(const BRect& frame)
|
||||
{
|
||||
@ -464,10 +468,8 @@ HWInterface::HideFloatingOverlays(const BRect& area)
|
||||
if (!fFloatingOverlaysLock.Lock())
|
||||
return false;
|
||||
if (fCursorAreaBackup && !fCursorAreaBackup->cursor_hidden) {
|
||||
BRect backupArea(fCursorAreaBackup->left,
|
||||
fCursorAreaBackup->top,
|
||||
fCursorAreaBackup->right,
|
||||
fCursorAreaBackup->bottom);
|
||||
BRect backupArea(fCursorAreaBackup->left, fCursorAreaBackup->top,
|
||||
fCursorAreaBackup->right, fCursorAreaBackup->bottom);
|
||||
if (area.Intersects(backupArea)) {
|
||||
_RestoreCursorArea();
|
||||
// do not unlock the cursor lock
|
||||
@ -495,9 +497,9 @@ HWInterface::HideFloatingOverlays()
|
||||
void
|
||||
HWInterface::ShowFloatingOverlays()
|
||||
{
|
||||
if (fCursorAreaBackup && fCursorAreaBackup->cursor_hidden) {
|
||||
if (fCursorAreaBackup && fCursorAreaBackup->cursor_hidden)
|
||||
_DrawCursor(_CursorFrame());
|
||||
}
|
||||
|
||||
fFloatingOverlaysLock.Unlock();
|
||||
}
|
||||
|
||||
@ -524,10 +526,10 @@ HWInterface::RemoveListener(HWInterfaceListener* listener)
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
// * default implementation, can be used as fallback or for
|
||||
// software cursor
|
||||
// * area is where we potentially draw the cursor, the cursor
|
||||
// might be somewhere else, in which case this function does nothing
|
||||
/*! Default implementation, can be used as fallback or for software cursor.
|
||||
\param area is where we potentially draw the cursor, the cursor
|
||||
might be somewhere else, in which case this function does nothing
|
||||
*/
|
||||
void
|
||||
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 in B_RGBA32 format
|
||||
// * location in front buffer is calculated
|
||||
// * conversion from B_RGBA32 to format of front buffer is taken care of
|
||||
/*! - source is assumed to be already at the right offset
|
||||
- source is assumed to be in B_RGBA32 format
|
||||
- location in front buffer is calculated
|
||||
- conversion from B_RGBA32 to format of front buffer is taken care of
|
||||
*/
|
||||
void
|
||||
HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
|
||||
int32 right, int32 bottom) const
|
||||
@ -657,7 +660,8 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
|
||||
// transfer, handle colorspace conversion
|
||||
switch (frontBuffer->ColorSpace()) {
|
||||
case B_RGB32:
|
||||
case B_RGBA32: {
|
||||
case B_RGBA32:
|
||||
{
|
||||
int32 bytes = (right - x + 1) * 4;
|
||||
|
||||
if (bytes > 0) {
|
||||
@ -673,8 +677,9 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
|
||||
}
|
||||
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
|
||||
dst += y * dstBPR + x * 3;
|
||||
int32 left = x;
|
||||
@ -694,7 +699,9 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
|
||||
}
|
||||
break;
|
||||
}
|
||||
case B_RGB16: {
|
||||
|
||||
case B_RGB16:
|
||||
{
|
||||
// offset to left top pixel in dest buffer
|
||||
dst += y * dstBPR + x * 2;
|
||||
int32 left = x;
|
||||
@ -704,9 +711,8 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
|
||||
uint8* srcHandle = src;
|
||||
uint16* dstHandle = (uint16*)dst;
|
||||
for (x = left; x <= right; x++) {
|
||||
*dstHandle = (uint16)(((srcHandle[2] & 0xf8) << 8) |
|
||||
((srcHandle[1] & 0xfc) << 3) |
|
||||
(srcHandle[0] >> 3));
|
||||
*dstHandle = (uint16)(((srcHandle[2] & 0xf8) << 8)
|
||||
| ((srcHandle[1] & 0xfc) << 3) | (srcHandle[0] >> 3));
|
||||
dstHandle ++;
|
||||
srcHandle += 4;
|
||||
}
|
||||
@ -715,8 +721,10 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case B_RGB15:
|
||||
case B_RGBA15: {
|
||||
case B_RGBA15:
|
||||
{
|
||||
// offset to left top pixel in dest buffer
|
||||
dst += y * dstBPR + x * 2;
|
||||
int32 left = x;
|
||||
@ -726,9 +734,8 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
|
||||
uint8* srcHandle = src;
|
||||
uint16* dstHandle = (uint16*)dst;
|
||||
for (x = left; x <= right; x++) {
|
||||
*dstHandle = (uint16)(((srcHandle[2] & 0xf8) << 7) |
|
||||
((srcHandle[1] & 0xf8) << 2) |
|
||||
(srcHandle[0] >> 3));
|
||||
*dstHandle = (uint16)(((srcHandle[2] & 0xf8) << 7)
|
||||
| ((srcHandle[1] & 0xf8) << 2) | (srcHandle[0] >> 3));
|
||||
dstHandle ++;
|
||||
srcHandle += 4;
|
||||
}
|
||||
@ -737,7 +744,9 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
|
||||
}
|
||||
break;
|
||||
}
|
||||
case B_CMAP8: {
|
||||
|
||||
case B_CMAP8:
|
||||
{
|
||||
const color_map *colorMap = SystemColorMap();
|
||||
// offset to left top pixel in dest buffer
|
||||
dst += y * dstBPR + x;
|
||||
@ -749,7 +758,8 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
|
||||
uint8* srcHandle = src;
|
||||
uint8* dstHandle = dst;
|
||||
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 ++;
|
||||
srcHandle += 4;
|
||||
@ -760,6 +770,7 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case B_GRAY8:
|
||||
if (frontBuffer->Width() > dstBPR) {
|
||||
// VGA 16 color grayscale planar mode
|
||||
@ -771,7 +782,8 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
|
||||
args.top = y;
|
||||
args.right = right;
|
||||
args.bottom = bottom;
|
||||
if (ioctl(fVGADevice, VGA_PLANAR_BLIT, &args, sizeof(args)) == 0)
|
||||
if (ioctl(fVGADevice, VGA_PLANAR_BLIT, &args, sizeof(args))
|
||||
== 0)
|
||||
break;
|
||||
}
|
||||
|
||||
@ -822,7 +834,8 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
|
||||
uint8* srcHandle = src;
|
||||
uint8* dstHandle = dst;
|
||||
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 ++;
|
||||
srcHandle += 4;
|
||||
}
|
||||
@ -833,14 +846,15 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "HWInterface::CopyBackToFront() - unsupported front "
|
||||
"buffer format! (0x%x)\n", frontBuffer->ColorSpace());
|
||||
fprintf(stderr, "HWInterface::CopyBackToFront() - unsupported "
|
||||
"front buffer format! (0x%x)\n", frontBuffer->ColorSpace());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// PRE: the object must be locked
|
||||
/*! The object must be locked
|
||||
*/
|
||||
IntRect
|
||||
HWInterface::_CursorFrame() const
|
||||
{
|
||||
@ -857,25 +871,23 @@ void
|
||||
HWInterface::_RestoreCursorArea() const
|
||||
{
|
||||
if (fCursorAreaBackup && !fCursorAreaBackup->cursor_hidden) {
|
||||
_CopyToFront(fCursorAreaBackup->buffer,
|
||||
fCursorAreaBackup->bpr,
|
||||
fCursorAreaBackup->left,
|
||||
fCursorAreaBackup->top,
|
||||
fCursorAreaBackup->right,
|
||||
fCursorAreaBackup->bottom);
|
||||
_CopyToFront(fCursorAreaBackup->buffer, fCursorAreaBackup->bpr,
|
||||
fCursorAreaBackup->left, fCursorAreaBackup->top,
|
||||
fCursorAreaBackup->right, fCursorAreaBackup->bottom);
|
||||
|
||||
fCursorAreaBackup->cursor_hidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
// _AdoptDragBitmap
|
||||
|
||||
void
|
||||
HWInterface::_AdoptDragBitmap(const ServerBitmap* bitmap, const BPoint& offset)
|
||||
{
|
||||
// TODO: support other colorspaces/convert bitmap
|
||||
if (bitmap && !(bitmap->ColorSpace() == B_RGB32
|
||||
|| 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;
|
||||
}
|
||||
|
||||
@ -910,8 +922,7 @@ HWInterface::_AdoptDragBitmap(const ServerBitmap* bitmap, const BPoint& offset)
|
||||
bitmapFrame.OffsetBy(shift);
|
||||
|
||||
fCursorAndDragBitmap = new ServerCursor(combindedBounds,
|
||||
bitmap->ColorSpace(), 0,
|
||||
hotspot + shift);
|
||||
bitmap->ColorSpace(), 0, hotspot + shift);
|
||||
|
||||
// clear the combined buffer
|
||||
uint8* dst = (uint8*)fCursorAndDragBitmap->Bits();
|
||||
@ -923,7 +934,8 @@ HWInterface::_AdoptDragBitmap(const ServerBitmap* bitmap, const BPoint& offset)
|
||||
uint8* src = (uint8*)bitmap->Bits();
|
||||
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 height = bitmapFrame.IntegerHeight() + 1;
|
||||
@ -936,7 +948,8 @@ HWInterface::_AdoptDragBitmap(const ServerBitmap* bitmap, const BPoint& offset)
|
||||
|
||||
// compose cursor into combined buffer
|
||||
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();
|
||||
srcBPR = fCursor->BytesPerRow();
|
||||
@ -959,12 +972,16 @@ HWInterface::_AdoptDragBitmap(const ServerBitmap* bitmap, const BPoint& offset)
|
||||
d[3] = 255;
|
||||
} else {
|
||||
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 alphaSrc = 255 * s[3];
|
||||
d[0] = (d[0] * alphaDest + s[0] * alphaSrc) / alphaTemp;
|
||||
d[1] = (d[1] * alphaDest + s[1] * alphaSrc) / alphaTemp;
|
||||
d[2] = (d[2] * alphaDest + s[2] * alphaSrc) / alphaTemp;
|
||||
d[0] = (d[0] * alphaDest + s[0] * alphaSrc)
|
||||
/ alphaTemp;
|
||||
d[1] = (d[1] * alphaDest + s[1] * alphaSrc)
|
||||
/ alphaTemp;
|
||||
d[2] = (d[2] * alphaDest + s[2] * alphaSrc)
|
||||
/ alphaTemp;
|
||||
d[3] = alphaTemp / 255;
|
||||
}
|
||||
}
|
||||
@ -998,9 +1015,8 @@ HWInterface::_AdoptDragBitmap(const ServerBitmap* bitmap, const BPoint& offset)
|
||||
}
|
||||
} else {
|
||||
fCursorAndDragBitmap = new ServerCursor(bitmap->Bits(),
|
||||
bitmapFrame.IntegerWidth() + 1,
|
||||
bitmapFrame.IntegerHeight() + 1,
|
||||
bitmap->ColorSpace());
|
||||
bitmapFrame.IntegerWidth() + 1, bitmapFrame.IntegerHeight() + 1,
|
||||
bitmap->ColorSpace());
|
||||
fCursorAndDragBitmap->SetHotSpot(BPoint(-offset.x, -offset.y));
|
||||
}
|
||||
} else {
|
||||
@ -1029,7 +1045,7 @@ HWInterface::_AdoptDragBitmap(const ServerBitmap* bitmap, const BPoint& offset)
|
||||
if (fCursorAndDragBitmap && !IsDoubleBuffered()) {
|
||||
BRect cursorBounds = fCursorAndDragBitmap->Bounds();
|
||||
fCursorAreaBackup = new buffer_clip(cursorBounds.IntegerWidth() + 1,
|
||||
cursorBounds.IntegerHeight() + 1);
|
||||
cursorBounds.IntegerHeight() + 1);
|
||||
}
|
||||
_DrawCursor(_CursorFrame());
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2007, Haiku.
|
||||
* Copyright 2005-2009, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -9,12 +9,6 @@
|
||||
#define HW_INTERFACE_H
|
||||
|
||||
|
||||
#include "IntRect.h"
|
||||
#include "MultiLocker.h"
|
||||
#include "ServerCursor.h"
|
||||
|
||||
#include <video_overlay.h>
|
||||
|
||||
#include <Accelerant.h>
|
||||
#include <GraphicsCard.h>
|
||||
#include <List.h>
|
||||
@ -22,6 +16,12 @@
|
||||
#include <OS.h>
|
||||
#include <Region.h>
|
||||
|
||||
#include <video_overlay.h>
|
||||
|
||||
#include "IntRect.h"
|
||||
#include "MultiLocker.h"
|
||||
#include "ServerCursor.h"
|
||||
|
||||
|
||||
class Overlay;
|
||||
class RenderingBuffer;
|
||||
@ -29,22 +29,25 @@ class ServerBitmap;
|
||||
class UpdateQueue;
|
||||
class BString;
|
||||
|
||||
|
||||
enum {
|
||||
HW_ACC_COPY_REGION = 0x00000001,
|
||||
HW_ACC_FILL_REGION = 0x00000002,
|
||||
HW_ACC_INVERT_REGION = 0x00000004,
|
||||
};
|
||||
|
||||
|
||||
class HWInterfaceListener {
|
||||
public:
|
||||
public:
|
||||
HWInterfaceListener();
|
||||
virtual ~HWInterfaceListener();
|
||||
|
||||
virtual void FrameBufferChanged() = 0;
|
||||
};
|
||||
|
||||
|
||||
class HWInterface : protected MultiLocker {
|
||||
public:
|
||||
public:
|
||||
HWInterface(bool doubleBuffered = false,
|
||||
bool enableUpdateQueue = true);
|
||||
virtual ~HWInterface();
|
||||
@ -52,12 +55,14 @@ class HWInterface : protected MultiLocker {
|
||||
// locking
|
||||
bool LockParallelAccess() { return ReadLock(); }
|
||||
#if DEBUG
|
||||
bool IsParallelAccessLocked() { return IsReadLocked(); }
|
||||
bool IsParallelAccessLocked()
|
||||
{ return IsReadLocked(); }
|
||||
#endif
|
||||
void UnlockParallelAccess() { ReadUnlock(); }
|
||||
|
||||
bool LockExclusiveAccess() { return WriteLock(); }
|
||||
bool IsExclusiveAccessLocked() { return IsWriteLocked(); }
|
||||
bool IsExclusiveAccessLocked()
|
||||
{ return IsWriteLocked(); }
|
||||
void UnlockExclusiveAccess() { WriteUnlock(); }
|
||||
|
||||
// You need to WriteLock
|
||||
@ -65,32 +70,34 @@ class HWInterface : protected MultiLocker {
|
||||
virtual status_t Shutdown() = 0;
|
||||
|
||||
// screen mode stuff
|
||||
virtual status_t SetMode(const display_mode &mode) = 0;
|
||||
virtual void GetMode(display_mode *mode) = 0;
|
||||
virtual status_t SetMode(const display_mode& mode) = 0;
|
||||
virtual void GetMode(display_mode* mode) = 0;
|
||||
|
||||
virtual status_t GetDeviceInfo(accelerant_device_info *info) = 0;
|
||||
virtual status_t GetFrameBufferConfig(frame_buffer_config& config) = 0;
|
||||
virtual status_t GetModeList(display_mode **mode_list,
|
||||
uint32 *count) = 0;
|
||||
virtual status_t GetPixelClockLimits(display_mode *mode,
|
||||
uint32 *low,
|
||||
uint32 *high) = 0;
|
||||
virtual status_t GetTimingConstraints(display_timing_constraints *dtc) = 0;
|
||||
virtual status_t ProposeMode(display_mode *candidate,
|
||||
const display_mode *low,
|
||||
const display_mode *high) = 0;
|
||||
virtual status_t GetDeviceInfo(accelerant_device_info* info) = 0;
|
||||
virtual status_t GetFrameBufferConfig(
|
||||
frame_buffer_config& config) = 0;
|
||||
virtual status_t GetModeList(display_mode** _modeList,
|
||||
uint32* _count) = 0;
|
||||
virtual status_t GetPixelClockLimits(display_mode* mode,
|
||||
uint32* _low, uint32* _high) = 0;
|
||||
virtual status_t GetTimingConstraints(display_timing_constraints*
|
||||
constraints) = 0;
|
||||
virtual status_t ProposeMode(display_mode* candidate,
|
||||
const display_mode* low,
|
||||
const display_mode* high) = 0;
|
||||
virtual status_t GetPreferredMode(display_mode* mode);
|
||||
virtual status_t GetMonitorInfo(monitor_info* info);
|
||||
|
||||
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 DPMSCapabilities() = 0;
|
||||
|
||||
virtual status_t GetAccelerantPath(BString &path);
|
||||
virtual status_t GetDriverPath(BString &path);
|
||||
virtual status_t GetAccelerantPath(BString& path);
|
||||
virtual status_t GetDriverPath(BString& path);
|
||||
|
||||
// query for available hardware accleration and perform it
|
||||
// (Initialize() must have been called already)
|
||||
@ -98,11 +105,10 @@ class HWInterface : protected MultiLocker {
|
||||
{ return 0; }
|
||||
|
||||
virtual void CopyRegion(const clipping_rect* sortedRectList,
|
||||
uint32 count,
|
||||
int32 xOffset, int32 yOffset) {}
|
||||
uint32 count, int32 xOffset, int32 yOffset)
|
||||
{}
|
||||
virtual void FillRegion(/*const*/ BRegion& region,
|
||||
const rgb_color& color,
|
||||
bool autoSync) {}
|
||||
const rgb_color& color, bool autoSync) {}
|
||||
virtual void InvertRegion(/*const*/ BRegion& region) {}
|
||||
|
||||
virtual void Sync() {}
|
||||
@ -113,12 +119,11 @@ class HWInterface : protected MultiLocker {
|
||||
virtual void SetCursorVisible(bool visible);
|
||||
bool IsCursorVisible();
|
||||
virtual void ObscureCursor();
|
||||
virtual void MoveCursorTo(const float& x,
|
||||
const float& y);
|
||||
virtual void MoveCursorTo(float x, float y);
|
||||
BPoint CursorPosition();
|
||||
|
||||
void SetDragBitmap(const ServerBitmap* bitmap,
|
||||
const BPoint& offsetFromCursor);
|
||||
const BPoint& offsetFromCursor);
|
||||
|
||||
// overlay support
|
||||
virtual overlay_token AcquireOverlayChannel();
|
||||
@ -174,19 +179,18 @@ public:
|
||||
bool AddListener(HWInterfaceListener* listener);
|
||||
void RemoveListener(HWInterfaceListener* listener);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
// implement this in derived classes
|
||||
virtual void _DrawCursor(IntRect area) const;
|
||||
|
||||
// does the actual transfer and handles color space conversion
|
||||
void _CopyToFront(uint8* src, uint32 srcBPR,
|
||||
int32 x, int32 y,
|
||||
int32 right, int32 bottom) const;
|
||||
void _CopyToFront(uint8* src, uint32 srcBPR, int32 x,
|
||||
int32 y, int32 right, int32 bottom) const;
|
||||
|
||||
IntRect _CursorFrame() const;
|
||||
void _RestoreCursorArea() const;
|
||||
void _AdoptDragBitmap(const ServerBitmap* bitmap,
|
||||
const BPoint& offset);
|
||||
const BPoint& offset);
|
||||
|
||||
void _NotifyFrameBufferChanged();
|
||||
|
||||
@ -197,23 +201,25 @@ public:
|
||||
// we can restore that area when the cursor needs to be
|
||||
// drawn somewhere else.
|
||||
struct buffer_clip {
|
||||
buffer_clip(int32 width, int32 height)
|
||||
{
|
||||
bpr = width * 4;
|
||||
if (bpr > 0 && height > 0)
|
||||
buffer = new uint8[bpr * height];
|
||||
else
|
||||
buffer = NULL;
|
||||
left = 0;
|
||||
top = 0;
|
||||
right = -1;
|
||||
bottom = -1;
|
||||
cursor_hidden = true;
|
||||
}
|
||||
~buffer_clip()
|
||||
{
|
||||
delete[] buffer;
|
||||
}
|
||||
buffer_clip(int32 width, int32 height)
|
||||
{
|
||||
bpr = width * 4;
|
||||
if (bpr > 0 && height > 0)
|
||||
buffer = new uint8[bpr * height];
|
||||
else
|
||||
buffer = NULL;
|
||||
left = 0;
|
||||
top = 0;
|
||||
right = -1;
|
||||
bottom = -1;
|
||||
cursor_hidden = true;
|
||||
}
|
||||
|
||||
~buffer_clip()
|
||||
{
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
uint8* buffer;
|
||||
int32 left;
|
||||
int32 top;
|
||||
@ -239,7 +245,7 @@ public:
|
||||
bool fDoubleBuffered;
|
||||
int fVGADevice;
|
||||
|
||||
private:
|
||||
private:
|
||||
UpdateQueue* fUpdateExecutor;
|
||||
|
||||
BList fListeners;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku.
|
||||
* Copyright 2001-2009, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -7,7 +7,11 @@
|
||||
* Stephan Aßmus <superstippi@gmx.de>
|
||||
*/
|
||||
|
||||
/** BView/BWindow combination HWInterface implementation */
|
||||
|
||||
/*! BView/BWindow combination HWInterface implementation */
|
||||
|
||||
|
||||
#include "ViewHWInterface.h"
|
||||
|
||||
#include <new>
|
||||
#include <stdio.h>
|
||||
@ -33,7 +37,6 @@
|
||||
#include "ServerCursor.h"
|
||||
#include "UpdateQueue.h"
|
||||
|
||||
#include "ViewHWInterface.h"
|
||||
|
||||
#ifdef DEBUG_DRIVER_MODULE
|
||||
# include <stdio.h>
|
||||
@ -42,17 +45,20 @@
|
||||
# define STRACE(x) ;
|
||||
#endif
|
||||
|
||||
|
||||
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 };
|
||||
|
||||
static const bool kDefaultDoubleBuffered = true;
|
||||
|
||||
enum {
|
||||
MSG_UPDATE = 'updt',
|
||||
MSG_UPDATE = 'updt'
|
||||
};
|
||||
|
||||
// string_for_color_space
|
||||
|
||||
const char*
|
||||
string_for_color_space(color_space format)
|
||||
{
|
||||
@ -91,7 +97,7 @@ string_for_color_space(color_space format)
|
||||
return name;
|
||||
}
|
||||
|
||||
// run_app_thread
|
||||
|
||||
static int32
|
||||
run_app_thread(void* cookie)
|
||||
{
|
||||
@ -105,8 +111,9 @@ run_app_thread(void* cookie)
|
||||
|
||||
//#define INPUTSERVER_TEST_MODE 1
|
||||
|
||||
|
||||
class CardView : public BView {
|
||||
public:
|
||||
public:
|
||||
CardView(BRect bounds);
|
||||
virtual ~CardView();
|
||||
|
||||
@ -115,7 +122,7 @@ class CardView : public BView {
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
|
||||
// CardView
|
||||
void SetBitmap(const BBitmap* bimtap);
|
||||
void SetBitmap(const BBitmap* bitmap);
|
||||
|
||||
void ForwardMessage(BMessage* message = NULL);
|
||||
|
||||
@ -125,7 +132,7 @@ private:
|
||||
};
|
||||
|
||||
class CardWindow : public BWindow {
|
||||
public:
|
||||
public:
|
||||
CardWindow(BRect frame);
|
||||
virtual ~CardWindow();
|
||||
|
||||
@ -136,7 +143,7 @@ class CardWindow : public BWindow {
|
||||
void SetBitmap(const BBitmap* bitmap);
|
||||
void Invalidate(const BRect& area);
|
||||
|
||||
private:
|
||||
private:
|
||||
CardView* fView;
|
||||
BMessageRunner* fUpdateRunner;
|
||||
BRegion fUpdateRegion;
|
||||
@ -144,21 +151,23 @@ class CardWindow : public BWindow {
|
||||
};
|
||||
|
||||
class CardMessageFilter : public BMessageFilter {
|
||||
public:
|
||||
CardMessageFilter(CardView* view);
|
||||
public:
|
||||
CardMessageFilter(CardView* view);
|
||||
|
||||
virtual filter_result Filter(BMessage *message, BHandler **_target);
|
||||
virtual filter_result Filter(BMessage* message, BHandler** _target);
|
||||
|
||||
private:
|
||||
CardView* fView;
|
||||
private:
|
||||
CardView* fView;
|
||||
};
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
CardView::CardView(BRect bounds)
|
||||
: BView(bounds, "graphics card view", B_FOLLOW_ALL, B_WILL_DRAW),
|
||||
fBitmap(NULL)
|
||||
:
|
||||
BView(bounds, "graphics card view", B_FOLLOW_ALL, B_WILL_DRAW),
|
||||
fBitmap(NULL)
|
||||
{
|
||||
SetViewColor(B_TRANSPARENT_32_BIT);
|
||||
|
||||
@ -179,25 +188,24 @@ CardView::~CardView()
|
||||
}
|
||||
|
||||
|
||||
// AttachedToWindow
|
||||
void
|
||||
CardView::AttachedToWindow()
|
||||
{
|
||||
}
|
||||
|
||||
// Draw
|
||||
|
||||
void
|
||||
CardView::Draw(BRect updateRect)
|
||||
{
|
||||
if (fBitmap) {
|
||||
if (fBitmap != NULL)
|
||||
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
|
||||
CardView::ForwardMessage(BMessage* message)
|
||||
{
|
||||
@ -232,7 +240,6 @@ CardView::MessageReceived(BMessage* message)
|
||||
}
|
||||
|
||||
|
||||
// SetBitmap
|
||||
void
|
||||
CardView::SetBitmap(const BBitmap* bitmap)
|
||||
{
|
||||
@ -249,14 +256,15 @@ CardView::SetBitmap(const BBitmap* bitmap)
|
||||
|
||||
|
||||
CardMessageFilter::CardMessageFilter(CardView* view)
|
||||
: BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE),
|
||||
:
|
||||
BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE),
|
||||
fView(view)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
filter_result
|
||||
CardMessageFilter::Filter(BMessage *message, BHandler **target)
|
||||
CardMessageFilter::Filter(BMessage* message, BHandler** target)
|
||||
{
|
||||
switch (message->what) {
|
||||
case B_KEY_DOWN:
|
||||
@ -292,11 +300,12 @@ CardMessageFilter::Filter(BMessage *message, BHandler **target)
|
||||
|
||||
|
||||
CardWindow::CardWindow(BRect frame)
|
||||
: BWindow(frame, "Haiku App Server", B_TITLED_WINDOW,
|
||||
B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
|
||||
fUpdateRunner(NULL),
|
||||
fUpdateRegion(),
|
||||
fUpdateLock("update lock")
|
||||
:
|
||||
BWindow(frame, "Haiku App Server", B_TITLED_WINDOW,
|
||||
B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
|
||||
fUpdateRunner(NULL),
|
||||
fUpdateRegion(),
|
||||
fUpdateLock("update lock")
|
||||
{
|
||||
fView = new CardView(Bounds());
|
||||
AddChild(fView);
|
||||
@ -312,7 +321,7 @@ CardWindow::~CardWindow()
|
||||
|
||||
|
||||
void
|
||||
CardWindow::MessageReceived(BMessage *msg)
|
||||
CardWindow::MessageReceived(BMessage* msg)
|
||||
{
|
||||
STRACE("CardWindow::MessageReceived()\n");
|
||||
switch (msg->what) {
|
||||
@ -343,7 +352,6 @@ CardWindow::MessageReceived(BMessage *msg)
|
||||
}
|
||||
|
||||
|
||||
// QuitRequested
|
||||
bool
|
||||
CardWindow::QuitRequested()
|
||||
{
|
||||
@ -360,21 +368,22 @@ CardWindow::QuitRequested()
|
||||
return false;
|
||||
}
|
||||
|
||||
// SetBitmap
|
||||
|
||||
void
|
||||
CardWindow::SetBitmap(const BBitmap* bitmap)
|
||||
{
|
||||
fView->SetBitmap(bitmap);
|
||||
}
|
||||
|
||||
// Invalidate
|
||||
|
||||
void
|
||||
CardWindow::Invalidate(const BRect& frame)
|
||||
{
|
||||
if (fUpdateLock.Lock()) {
|
||||
if (!fUpdateRunner) {
|
||||
BMessage message(MSG_UPDATE);
|
||||
fUpdateRunner = new BMessageRunner(BMessenger(this, this), &message, 20000);
|
||||
fUpdateRunner = new BMessageRunner(BMessenger(this, this), &message,
|
||||
20000);
|
||||
}
|
||||
fUpdateRegion.Include(frame);
|
||||
fUpdateLock.Unlock();
|
||||
@ -385,14 +394,12 @@ CardWindow::Invalidate(const BRect& frame)
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
static const bool kDefaultDoubleBuffered = true;
|
||||
|
||||
|
||||
ViewHWInterface::ViewHWInterface()
|
||||
: HWInterface(kDefaultDoubleBuffered),
|
||||
fBackBuffer(NULL),
|
||||
fFrontBuffer(NULL),
|
||||
fWindow(NULL)
|
||||
:
|
||||
HWInterface(kDefaultDoubleBuffered),
|
||||
fBackBuffer(NULL),
|
||||
fFrontBuffer(NULL),
|
||||
fWindow(NULL)
|
||||
{
|
||||
fDisplayMode.virtual_width = 640;
|
||||
fDisplayMode.virtual_height = 480;
|
||||
@ -415,23 +422,23 @@ ViewHWInterface::~ViewHWInterface()
|
||||
delete be_app;
|
||||
}
|
||||
|
||||
// Initialize
|
||||
|
||||
status_t
|
||||
ViewHWInterface::Initialize()
|
||||
{
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// Shutdown
|
||||
|
||||
status_t
|
||||
ViewHWInterface::Shutdown()
|
||||
{
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// SetMode
|
||||
|
||||
status_t
|
||||
ViewHWInterface::SetMode(const display_mode &mode)
|
||||
ViewHWInterface::SetMode(const display_mode& mode)
|
||||
{
|
||||
AutoWriteLocker _(this);
|
||||
|
||||
@ -445,7 +452,7 @@ ViewHWInterface::SetMode(const display_mode &mode)
|
||||
|
||||
// check if we support the mode
|
||||
|
||||
display_mode *modes;
|
||||
display_mode* modes;
|
||||
uint32 modeCount, i;
|
||||
if (GetModeList(&modes, &modeCount) != B_OK)
|
||||
return B_NO_MEMORY;
|
||||
@ -466,9 +473,8 @@ ViewHWInterface::SetMode(const display_mode &mode)
|
||||
if (i == modeCount)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
BRect frame(0.0, 0.0,
|
||||
fDisplayMode.virtual_width - 1,
|
||||
fDisplayMode.virtual_height - 1);
|
||||
BRect frame(0.0, 0.0, fDisplayMode.virtual_width - 1,
|
||||
fDisplayMode.virtual_height - 1);
|
||||
|
||||
// create the window if we don't have one already
|
||||
if (!fWindow) {
|
||||
@ -480,7 +486,7 @@ ViewHWInterface::SetMode(const display_mode &mode)
|
||||
app->Unlock();
|
||||
|
||||
thread_id appThread = spawn_thread(run_app_thread, "app thread",
|
||||
B_NORMAL_PRIORITY, app);
|
||||
B_NORMAL_PRIORITY, app);
|
||||
if (appThread >= B_OK)
|
||||
ret = resume_thread(appThread);
|
||||
else
|
||||
@ -488,7 +494,7 @@ ViewHWInterface::SetMode(const display_mode &mode)
|
||||
|
||||
if (ret < B_OK)
|
||||
return ret;
|
||||
|
||||
|
||||
fWindow = new CardWindow(frame.OffsetToCopy(BPoint(50.0, 50.0)));
|
||||
|
||||
// fire up the window thread but don't show it on screen yet
|
||||
@ -500,7 +506,7 @@ ViewHWInterface::SetMode(const display_mode &mode)
|
||||
// just to be save
|
||||
fWindow->SetBitmap(NULL);
|
||||
|
||||
// free and reallocate the bitmaps while the window is locked,
|
||||
// free and reallocate the bitmaps while the window is locked,
|
||||
// so that the view does not accidentally draw a freed bitmap
|
||||
delete fBackBuffer;
|
||||
fBackBuffer = NULL;
|
||||
@ -514,11 +520,12 @@ ViewHWInterface::SetMode(const display_mode &mode)
|
||||
// -> fall back to double buffer for fDisplayMode.space != B_RGB32
|
||||
// as intermediate solution...
|
||||
bool doubleBuffered = HWInterface::IsDoubleBuffered();
|
||||
if ((color_space)fDisplayMode.space != B_RGB32 &&
|
||||
(color_space)fDisplayMode.space != B_RGBA32)
|
||||
if ((color_space)fDisplayMode.space != B_RGB32
|
||||
&& (color_space)fDisplayMode.space != B_RGBA32)
|
||||
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);
|
||||
|
||||
status_t err = fFrontBuffer->InitCheck();
|
||||
@ -534,7 +541,7 @@ ViewHWInterface::SetMode(const display_mode &mode)
|
||||
// is in effect also always B_RGBA32.
|
||||
BBitmap* backBitmap = new BBitmap(frame, 0, B_RGBA32);
|
||||
fBackBuffer = new BBitmapBuffer(backBitmap);
|
||||
|
||||
|
||||
err = fBackBuffer->InitCheck();
|
||||
if (err < B_OK) {
|
||||
delete fBackBuffer;
|
||||
@ -551,7 +558,7 @@ ViewHWInterface::SetMode(const display_mode &mode)
|
||||
if (fBackBuffer)
|
||||
memset(fBackBuffer->Bits(), 255, fBackBuffer->BitsLength());
|
||||
memset(fFrontBuffer->Bits(), 255, fFrontBuffer->BitsLength());
|
||||
|
||||
|
||||
// change the window size and update the bitmap used for drawing
|
||||
fWindow->ResizeTo(frame.Width(), frame.Height());
|
||||
fWindow->SetBitmap(fFrontBuffer->Bitmap());
|
||||
@ -568,7 +575,7 @@ ViewHWInterface::SetMode(const display_mode &mode)
|
||||
return ret;
|
||||
}
|
||||
|
||||
// GetMode
|
||||
|
||||
void
|
||||
ViewHWInterface::GetMode(display_mode* mode)
|
||||
{
|
||||
@ -578,9 +585,9 @@ ViewHWInterface::GetMode(display_mode* mode)
|
||||
}
|
||||
}
|
||||
|
||||
// GetDeviceInfo
|
||||
|
||||
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
|
||||
// a software-only driver, but we'll have some fun, anyway.
|
||||
@ -614,7 +621,7 @@ ViewHWInterface::GetFrameBufferConfig(frame_buffer_config& config)
|
||||
|
||||
|
||||
status_t
|
||||
ViewHWInterface::GetModeList(display_mode **_modes, uint32 *_count)
|
||||
ViewHWInterface::GetModeList(display_mode** _modes, uint32* _count)
|
||||
{
|
||||
AutoReadLocker _(this);
|
||||
|
||||
@ -628,7 +635,7 @@ ViewHWInterface::GetModeList(display_mode **_modes, uint32 *_count)
|
||||
const uint32 colors[] = {B_CMAP8, B_RGB15, B_RGB16, B_RGB32};
|
||||
uint32 count = resolutionCount * 4;
|
||||
|
||||
display_mode *modes = new(nothrow) display_mode[count];
|
||||
display_mode* modes = new(std::nothrow) display_mode[count];
|
||||
if (modes == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
@ -670,37 +677,43 @@ ViewHWInterface::GetModeList(display_mode **_modes, uint32 *_count)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
ViewHWInterface::GetPixelClockLimits(display_mode *mode, uint32 *low, uint32 *high)
|
||||
ViewHWInterface::GetPixelClockLimits(display_mode* mode, uint32* low,
|
||||
uint32* high)
|
||||
{
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
ViewHWInterface::GetTimingConstraints(display_timing_constraints *dtc)
|
||||
ViewHWInterface::GetTimingConstraints(display_timing_constraints* constraints)
|
||||
{
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
// specific hardware. This is a Good Thing(TM) because we can support any hardware
|
||||
// we wish within reasonable expectaions and programmer laziness. :P
|
||||
// We should be able to get away with this because we're not dealing with
|
||||
// any specific hardware. This is a Good Thing(TM) because we can support
|
||||
// any hardware we wish within reasonable expectaions and programmer
|
||||
// laziness. :P
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// SetDPMSMode
|
||||
|
||||
status_t
|
||||
ViewHWInterface::SetDPMSMode(const uint32 &state)
|
||||
ViewHWInterface::SetDPMSMode(uint32 state)
|
||||
{
|
||||
AutoWriteLocker _(this);
|
||||
|
||||
return BScreen().SetDPMS(state);
|
||||
}
|
||||
|
||||
// DPMSMode
|
||||
|
||||
uint32
|
||||
ViewHWInterface::DPMSMode()
|
||||
{
|
||||
@ -709,7 +722,7 @@ ViewHWInterface::DPMSMode()
|
||||
return BScreen().DPMSState();
|
||||
}
|
||||
|
||||
// DPMSCapabilities
|
||||
|
||||
uint32
|
||||
ViewHWInterface::DPMSCapabilities()
|
||||
{
|
||||
@ -718,14 +731,14 @@ ViewHWInterface::DPMSCapabilities()
|
||||
return BScreen().DPMSCapabilites();
|
||||
}
|
||||
|
||||
// RetraceSemaphore
|
||||
|
||||
sem_id
|
||||
ViewHWInterface::RetraceSemaphore()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// WaitForRetrace
|
||||
|
||||
status_t
|
||||
ViewHWInterface::WaitForRetrace(bigtime_t timeout = B_INFINITE_TIMEOUT)
|
||||
{
|
||||
@ -734,21 +747,21 @@ ViewHWInterface::WaitForRetrace(bigtime_t timeout = B_INFINITE_TIMEOUT)
|
||||
return screen.WaitForRetrace(timeout);
|
||||
}
|
||||
|
||||
// FrontBuffer
|
||||
|
||||
RenderingBuffer*
|
||||
ViewHWInterface::FrontBuffer() const
|
||||
{
|
||||
return fFrontBuffer;
|
||||
}
|
||||
|
||||
// BackBuffer
|
||||
|
||||
RenderingBuffer*
|
||||
ViewHWInterface::BackBuffer() const
|
||||
{
|
||||
return fBackBuffer;
|
||||
}
|
||||
|
||||
// IsDoubleBuffered
|
||||
|
||||
bool
|
||||
ViewHWInterface::IsDoubleBuffered() const
|
||||
{
|
||||
@ -758,7 +771,7 @@ ViewHWInterface::IsDoubleBuffered() const
|
||||
return HWInterface::IsDoubleBuffered();
|
||||
}
|
||||
|
||||
// Invalidate
|
||||
|
||||
status_t
|
||||
ViewHWInterface::Invalidate(const BRect& frame)
|
||||
{
|
||||
@ -769,7 +782,7 @@ ViewHWInterface::Invalidate(const BRect& frame)
|
||||
return ret;
|
||||
}
|
||||
|
||||
// CopyBackToFront
|
||||
|
||||
status_t
|
||||
ViewHWInterface::CopyBackToFront(const BRect& frame)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005, Haiku.
|
||||
* Copyright 2005-2009, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -11,6 +11,7 @@
|
||||
|
||||
#include "HWInterface.h"
|
||||
|
||||
|
||||
class BBitmap;
|
||||
class BBitmapBuffer;
|
||||
class CardWindow;
|
||||
@ -18,33 +19,35 @@ class UpdateQueue;
|
||||
|
||||
|
||||
class ViewHWInterface : public HWInterface {
|
||||
public:
|
||||
public:
|
||||
ViewHWInterface();
|
||||
virtual ~ViewHWInterface();
|
||||
|
||||
virtual status_t Initialize();
|
||||
virtual status_t Shutdown();
|
||||
|
||||
virtual status_t SetMode(const display_mode &mode);
|
||||
virtual void GetMode(display_mode *mode);
|
||||
virtual status_t SetMode(const display_mode& mode);
|
||||
virtual void GetMode(display_mode* mode);
|
||||
|
||||
virtual status_t GetDeviceInfo(accelerant_device_info *info);
|
||||
virtual status_t GetFrameBufferConfig(frame_buffer_config& config);
|
||||
virtual status_t GetDeviceInfo(accelerant_device_info* info);
|
||||
virtual status_t GetFrameBufferConfig(
|
||||
frame_buffer_config& config);
|
||||
|
||||
virtual status_t GetModeList(display_mode **mode_list,
|
||||
uint32 *count);
|
||||
virtual status_t GetPixelClockLimits(display_mode *mode,
|
||||
uint32 *low,
|
||||
uint32 *high);
|
||||
virtual status_t GetTimingConstraints(display_timing_constraints *dtc);
|
||||
virtual status_t ProposeMode(display_mode *candidate,
|
||||
const display_mode *low,
|
||||
const display_mode *high);
|
||||
virtual status_t GetModeList(display_mode** _modeList,
|
||||
uint32* _count);
|
||||
virtual status_t GetPixelClockLimits(display_mode* mode,
|
||||
uint32* _low, uint32* _high);
|
||||
virtual status_t GetTimingConstraints(display_timing_constraints*
|
||||
constraints);
|
||||
virtual status_t ProposeMode(display_mode* candidate,
|
||||
const display_mode* low,
|
||||
const display_mode* high);
|
||||
|
||||
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 DPMSCapabilities();
|
||||
|
||||
@ -56,7 +59,7 @@ class ViewHWInterface : public HWInterface {
|
||||
virtual status_t Invalidate(const BRect& frame);
|
||||
virtual status_t CopyBackToFront(const BRect& frame);
|
||||
|
||||
private:
|
||||
private:
|
||||
BBitmapBuffer* fBackBuffer;
|
||||
BBitmapBuffer* fFrontBuffer;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user