Applied an updated patch by looncraz to enable hardware cursor.

I made the following changes to the original patch:
 * Add const to the cursor setting functions.
 * Removed the legacy cursor copying code.
 * Minor coding style cleanup.
This commit is contained in:
Axel Dörfler 2012-11-28 22:29:30 +01:00
parent 133a094f80
commit ed80f189ce
7 changed files with 113 additions and 51 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2009, Haiku, Inc. All rights reserved.
* Copyright 2009-2012, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _ACCELERANT_H_
@ -38,7 +38,7 @@ enum {
B_ACCELERANT_MODE_COUNT = 0x100, /* required */
B_GET_MODE_LIST, /* required */
B_PROPOSE_DISPLAY_MODE, /* optional */
B_SET_DISPLAY_MODE, /* required */
B_SET_DISPLAY_MODE, /* required */
B_GET_DISPLAY_MODE, /* required */
B_GET_FRAME_BUFFER_CONFIG, /* required */
B_GET_PIXEL_CLOCK_LIMITS, /* required */
@ -57,6 +57,7 @@ enum {
B_MOVE_CURSOR = 0x200, /* optional */
B_SET_CURSOR_SHAPE, /* optional */
B_SHOW_CURSOR, /* optional */
B_SET_CURSOR_BITMAP, /* optional */
/* synchronization */
B_ACCELERANT_ENGINE_COUNT = 0x300, /* required */
@ -72,9 +73,9 @@ enum {
B_INVERT_RECTANGLE, /* optional */
B_FILL_SPAN, /* optional */
B_SCREEN_TO_SCREEN_TRANSPARENT_BLIT, /* optional */
B_SCREEN_TO_SCREEN_SCALED_FILTERED_BLIT, /* optional.
B_SCREEN_TO_SCREEN_SCALED_FILTERED_BLIT, /* optional.
NOTE: source and dest may NOT overlap */
/* 3D acceleration */
B_ACCELERANT_PRIVATE_START = (int)0x80000000
};
@ -105,6 +106,7 @@ typedef struct {
uint32 flags; /* sync polarity, etc. */
} display_timing;
typedef struct {
display_timing timing; /* CTRC info */
uint32 space; /* pixel configuration */
@ -129,6 +131,7 @@ typedef struct {
/* virtual_width * byte_per_pixel */
} frame_buffer_config;
typedef struct {
uint16 h_res; /* minimum effective change in */
/* horizontal pixels, usually 8 */
@ -286,17 +289,16 @@ typedef uint32 (*accelerant_mode_count)(void);
typedef status_t (*get_mode_list)(display_mode*);
typedef status_t (*propose_display_mode)(display_mode* target,
display_mode* low, display_mode* high);
typedef status_t (*set_display_mode)(display_mode* mode_to_set);
typedef status_t (*get_display_mode)(display_mode* current_mode);
typedef status_t (*get_frame_buffer_config)(frame_buffer_config*
a_frame_buffer);
typedef status_t (*set_display_mode)(display_mode* modeToSet);
typedef status_t (*get_display_mode)(display_mode* currentMode);
typedef status_t (*get_frame_buffer_config)(frame_buffer_config* frameBuffer);
typedef status_t (*get_pixel_clock_limits)(display_mode* dm, uint32* low,
uint32* high);
typedef status_t (*move_display_area)(uint16 h_display_start,
uint16 v_display_start);
typedef status_t (*move_display_area)(uint16 hDisplayStart,
uint16 vDisplayStart);
typedef status_t (*get_timing_constraints)(display_timing_constraints* dtc);
typedef void (*set_indexed_colors)(uint count, uint8 first, uint8* color_data,
uint32 flags);
typedef void (*set_indexed_colors)(uint count, uint8 first,
const uint8* colorData, uint32 flags);
typedef uint32 (*dpms_capabilities)(void);
typedef uint32 (*dpms_mode)(void);
typedef status_t (*set_dpms_mode)(uint32 dpms_flags);
@ -306,12 +308,15 @@ typedef status_t (*get_edid_info)(void* info, uint32 size, uint32* _version);
typedef sem_id (*accelerant_retrace_semaphore)(void);
typedef status_t (*set_cursor_shape)(uint16 width, uint16 height,
uint16 hot_x, uint16 hot_y, uint8* andMask, uint8* xorMask);
uint16 hotX, uint16 hotY, const uint8* andMask, const uint8* xorMask);
typedef status_t (*set_cursor_bitmap)(uint16 width, uint16 height,
uint16 hotX, uint16 hotY, color_space colorSpace, uint16 bytesPerRow,
const uint8* bitmapData);
typedef void (*move_cursor)(uint16 x, uint16 y);
typedef void (*show_cursor)(bool is_visible);
typedef void (*show_cursor)(bool isVisible);
typedef uint32 (*accelerant_engine_count)(void);
typedef status_t (*acquire_engine)(uint32 capabilities, uint32 max_wait,
typedef status_t (*acquire_engine)(uint32 capabilities, uint32 maxWait,
sync_token* st, engine_token** et);
typedef status_t (*release_engine)(engine_token* et, sync_token* st);
typedef void (*wait_engine_idle)(void);

View File

@ -47,6 +47,8 @@ status_t vesa_set_dpms_mode(uint32 dpmsFlags);
// cursor
status_t vesa_set_cursor_shape(uint16 width, uint16 height, uint16 hotX,
uint16 hotY, uint8 *andMask, uint8 *xorMask);
status_t vesa_set_cursor_bitmap(uint16 width, uint16 height, uint16 hotX,
uint16 hotY, uint32 colorSpace, uint16 bytesPerRow, uint8* bitmapData);
void vesa_move_cursor(uint16 x, uint16 y);
void vesa_show_cursor(bool is_visible);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2005-2009, Axel Dörfler, axeld@pinc-software.de.
* Copyright 2005-2012, Axel Dörfler, axeld@pinc-software.de.
* All rights reserved. Distributed under the terms of the MIT License.
*/
@ -12,8 +12,12 @@
#define FAKE_OVERLAY_SUPPORT 0
// Enables a fake overlay support, making the app_server believe it can
// use overlays with this driver; the actual buffers are in the frame buffer
// so the on-screen graphics will be messed up.
// use overlays with this driver; the actual buffers are in the frame
// buffer so the on-screen graphics will be messed up.
#define FAKE_HARDWARE_CURSOR_SUPPORT 0
// Enables the faking of a hardware cursor. The cursor will not be
// visible, but it will still function.
#if FAKE_OVERLAY_SUPPORT
@ -158,12 +162,18 @@ vesa_configure_overlay(overlay_token overlayToken, const overlay_buffer *buffer,
#endif // FAKE_OVERLAY_SUPPORT
// TODO: these are some temporary dummy functions to see if this helps with our
// current app_server
#if FAKE_HARDWARE_CURSOR_SUPPORT
status_t
vesa_set_cursor_shape(uint16 width, uint16 height, uint16 hotX, uint16 hotY,
const uint8* andMask, const uint8* xorMask)
{
return B_OK;
}
status_t
vesa_set_cursor_shape(uint16 width, uint16 height, uint16 hot_x, uint16 hot_y,
uint8 *andMask, uint8 *xorMask)
vesa_set_cursor_bitmap(uint16 width, uint16 height, uint16 hotX, uint16 hotY,
color_space colorSpace, uint16 bytesPerRow, const uint8* bitmapData)
{
return B_OK;
}
@ -179,6 +189,7 @@ void
vesa_show_cursor(bool is_visible)
{
}
#endif // # FAKE_HARDWARE_CURSOR_SUPPORT
extern "C" void *
@ -234,12 +245,16 @@ get_accelerant_hook(uint32 feature, void *data)
return (void*)vesa_set_dpms_mode;
/* cursor managment */
#if FAKE_HARDWARE_CURSOR_SUPPORT
case B_SET_CURSOR_SHAPE:
return (void*)vesa_set_cursor_shape;
case B_MOVE_CURSOR:
return (void*)vesa_move_cursor;
case B_SHOW_CURSOR:
return (void*)vesa_show_cursor;
case B_SET_CURSOR_BITMAP:
return (void*)vesa_set_cursor_bitmap;
#endif
/* engine/synchronization */
case B_ACCELERANT_ENGINE_COUNT:

View File

@ -1,5 +1,5 @@
/*
* Copyright 2001-2010, Haiku.
* Copyright 2001-2012, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -121,6 +121,7 @@ AccelerantHWInterface::AccelerantHWInterface()
fAccInvertRect(NULL),
fAccScreenBlit(NULL),
fAccSetCursorShape(NULL),
fAccSetCursorBitmap(NULL),
fAccMoveCursor(NULL),
fAccShowCursor(NULL),
@ -372,6 +373,8 @@ AccelerantHWInterface::_SetupDefaultHooks()
// cursor
fAccSetCursorShape
= (set_cursor_shape)fAccelerantHook(B_SET_CURSOR_SHAPE, NULL);
fAccSetCursorBitmap
= (set_cursor_bitmap)fAccelerantHook(B_SET_CURSOR_BITMAP, NULL);
fAccMoveCursor = (move_cursor)fAccelerantHook(B_MOVE_CURSOR, NULL);
fAccShowCursor = (show_cursor)fAccelerantHook(B_SHOW_CURSOR, NULL);
@ -1328,19 +1331,45 @@ AccelerantHWInterface::HideOverlay(Overlay* overlay)
// #pragma mark - cursor
void
AccelerantHWInterface::SetCursor(ServerCursor* cursor)
{
HWInterface::SetCursor(cursor);
// if (LockExclusiveAccess()) {
// TODO: implement setting the hard ware cursor
// NOTE: cursor should be always B_RGBA32
// NOTE: The HWInterface implementation should
// still be called, since it takes ownership of
// the cursor.
// UnlockExclusiveAccess();
// }
// HWInterface claims ownership of cursor.
// cursor should never be NULL, but let us be safe!!
if (cursor == NULL || LockExclusiveAccess() == false)
return;
if (cursor->CursorData() != NULL && fAccSetCursorShape != NULL) {
// BeOS BCursor, 16x16 monochrome
uint8 size = cursor->CursorData()[0];
// CursorData()[1] is color depth (always monochrome)
uint8 xHotSpot = cursor->CursorData()[2];
uint8 yHotSpot = cursor->CursorData()[3];
// Create pointers to the cursor and/xor bit arrays
const uint8* andMask = cursor->CursorData() + 4;
const uint8* xorMask = cursor->CursorData() + 36;
// Time to talk to the accelerant!
fHardwareCursorEnabled = fAccSetCursorShape(size, size, xHotSpot,
yHotSpot, andMask, xorMask) == B_OK;
} else if (fAccSetCursorBitmap != NULL) {
// Bitmap cursor
uint16 xHotSpot = (uint16)cursor->GetHotSpot().x;
uint16 yHotSpot = (uint16)cursor->GetHotSpot().y;
uint16 width = (uint16)cursor->Bounds().Width();
uint16 height = (uint16)cursor->Bounds().Height();
// Time to talk to the accelerant!
fHardwareCursorEnabled = fAccSetCursorBitmap(width, height, xHotSpot,
yHotSpot, cursor->ColorSpace(), (uint16)cursor->BytesPerRow(),
cursor->Bits()) == B_OK;
}
UnlockExclusiveAccess();
}
@ -1348,10 +1377,15 @@ void
AccelerantHWInterface::SetCursorVisible(bool visible)
{
HWInterface::SetCursorVisible(visible);
// if (LockExclusiveAccess()) {
// TODO: update graphics hardware
// UnlockExclusiveAccess();
// }
if (fHardwareCursorEnabled && LockExclusiveAccess()) {
if (fAccShowCursor != NULL)
fAccShowCursor(visible);
else
fHardwareCursorEnabled = false;
UnlockExclusiveAccess();
}
}
@ -1359,10 +1393,15 @@ void
AccelerantHWInterface::MoveCursorTo(float x, float y)
{
HWInterface::MoveCursorTo(x, y);
// if (LockExclusiveAccess()) {
// TODO: update graphics hardware
// UnlockExclusiveAccess();
// }
if (fHardwareCursorEnabled && LockExclusiveAccess()) {
if (fAccMoveCursor != NULL)
fAccMoveCursor((uint16)x, (uint16)y);
else
fHardwareCursorEnabled = false;
UnlockExclusiveAccess();
}
}
@ -1420,11 +1459,8 @@ AccelerantHWInterface::_CopyBackToFront(/*const*/ BRegion& region)
void
AccelerantHWInterface::_DrawCursor(IntRect area) const
{
// use the default implementation for now,
// until we have a hardware cursor
HWInterface::_DrawCursor(area);
// TODO: this would only be called, if we don't have
// a hardware cursor for some reason
if (!fHardwareCursorEnabled)
HWInterface::_DrawCursor(area);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2005-2009, Haiku.
* Copyright 2005-2012, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -15,6 +15,7 @@
#include <image.h>
#include <video_overlay.h>
class AccelerantBuffer;
class RenderingBuffer;
@ -147,6 +148,7 @@ private:
invert_rectangle fAccInvertRect;
screen_to_screen_blit fAccScreenBlit;
set_cursor_shape fAccSetCursorShape;
set_cursor_bitmap fAccSetCursorBitmap;
move_cursor fAccMoveCursor;
show_cursor fAccShowCursor;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2005-2009, Haiku.
* Copyright 2005-2012, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -51,6 +51,7 @@ HWInterface::HWInterface(bool doubleBuffered, bool enableUpdateQueue)
fCursorAndDragBitmap(NULL),
fCursorVisible(false),
fCursorObscured(false),
fHardwareCursorEnabled(false),
fCursorLocation(0, 0),
fDoubleBuffered(doubleBuffered),
fVGADevice(-1),
@ -890,7 +891,7 @@ IntRect
HWInterface::_CursorFrame() const
{
IntRect frame(0, 0, -1, -1);
if (fCursorAndDragBitmap && fCursorVisible) {
if (fCursorAndDragBitmap && fCursorVisible && !fHardwareCursorEnabled) {
frame = fCursorAndDragBitmap->Bounds();
frame.OffsetTo(fCursorLocation - fCursorAndDragBitmap->GetHotSpot());
}
@ -930,7 +931,7 @@ HWInterface::_AdoptDragBitmap(const ServerBitmap* bitmap, const BPoint& offset)
fCursorAndDragBitmap = NULL;
}
if (bitmap) {
if (bitmap != NULL) {
BRect bitmapFrame = bitmap->Bounds();
if (fCursor) {
// put bitmap frame and cursor frame into the same

View File

@ -1,5 +1,5 @@
/*
* Copyright 2005-2009, Haiku.
* Copyright 2005-2012, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -174,7 +174,7 @@ public:
// It seems to me BeOS hides the cursor (in laymans words) before
// BView::Draw() is called (if the cursor is within that views clipping region),
// then, after all drawing commands that triggered have been caried out,
// it shows the cursor again. This approach would have the adventage of
// it shows the cursor again. This approach would have the advantage of
// the code not cluttering/slowing down DrawingEngine.
// For now, we hide the cursor for any drawing operation that has
// a bounding box containing the cursor (in DrawingEngine) so
@ -249,6 +249,7 @@ protected:
ServerCursor* fCursorAndDragBitmap;
bool fCursorVisible;
bool fCursorObscured;
bool fHardwareCursorEnabled;
BPoint fCursorLocation;
BRect fTrackingRect;