hrev44922 adds 2 changesets to branch 'master' old head: 133a094f800056ab5f6c4ec44cf8a8a20c38a701 new head: 8df20d2c850097dd8980beb383ba683c748dd691 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=8df20d2+%5E133a094 ---------------------------------------------------------------------------- ed80f18: 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. 8df20d2: Minor coding style cleanup. [ Axel DÃrfler <axeld@xxxxxxxxxxxxxxxx> ] ---------------------------------------------------------------------------- 7 files changed, 125 insertions(+), 63 deletions(-) headers/os/add-ons/graphics/Accelerant.h | 35 +++++---- src/add-ons/accelerants/vesa/accelerant_protos.h | 2 + src/add-ons/accelerants/vesa/hooks.cpp | 53 ++++++++----- .../app/drawing/AccelerantHWInterface.cpp | 82 ++++++++++++++------ src/servers/app/drawing/AccelerantHWInterface.h | 4 +- src/servers/app/drawing/HWInterface.cpp | 7 +- src/servers/app/drawing/HWInterface.h | 5 +- ############################################################################ Commit: ed80f189ce473ee4241de0d9a5e45e384508a0c3 URL: http://cgit.haiku-os.org/haiku/commit/?id=ed80f18 Author: Axel DÃrfler <axeld@xxxxxxxxxxxxxxxx> Date: Wed Nov 28 21:29:30 2012 UTC 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. ---------------------------------------------------------------------------- diff --git a/headers/os/add-ons/graphics/Accelerant.h b/headers/os/add-ons/graphics/Accelerant.h index 185af4e..1322c35 100644 --- a/headers/os/add-ons/graphics/Accelerant.h +++ b/headers/os/add-ons/graphics/Accelerant.h @@ -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); diff --git a/src/add-ons/accelerants/vesa/accelerant_protos.h b/src/add-ons/accelerants/vesa/accelerant_protos.h index 96ad152..81c566c 100644 --- a/src/add-ons/accelerants/vesa/accelerant_protos.h +++ b/src/add-ons/accelerants/vesa/accelerant_protos.h @@ -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); diff --git a/src/add-ons/accelerants/vesa/hooks.cpp b/src/add-ons/accelerants/vesa/hooks.cpp index 634af8d..ae2b825 100644 --- a/src/add-ons/accelerants/vesa/hooks.cpp +++ b/src/add-ons/accelerants/vesa/hooks.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2005-2009, Axel DÃrfler, axeld@xxxxxxxxxxxxxxxxx + * Copyright 2005-2012, Axel DÃrfler, axeld@xxxxxxxxxxxxxxxxx * 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: diff --git a/src/servers/app/drawing/AccelerantHWInterface.cpp b/src/servers/app/drawing/AccelerantHWInterface.cpp index 5c60695..48a2b37 100644 --- a/src/servers/app/drawing/AccelerantHWInterface.cpp +++ b/src/servers/app/drawing/AccelerantHWInterface.cpp @@ -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); } diff --git a/src/servers/app/drawing/AccelerantHWInterface.h b/src/servers/app/drawing/AccelerantHWInterface.h index fd81fd2..b9192fc 100644 --- a/src/servers/app/drawing/AccelerantHWInterface.h +++ b/src/servers/app/drawing/AccelerantHWInterface.h @@ -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; diff --git a/src/servers/app/drawing/HWInterface.cpp b/src/servers/app/drawing/HWInterface.cpp index 2faa738..bea94ca 100644 --- a/src/servers/app/drawing/HWInterface.cpp +++ b/src/servers/app/drawing/HWInterface.cpp @@ -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 diff --git a/src/servers/app/drawing/HWInterface.h b/src/servers/app/drawing/HWInterface.h index ab0f7bb..822825d 100644 --- a/src/servers/app/drawing/HWInterface.h +++ b/src/servers/app/drawing/HWInterface.h @@ -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; ############################################################################ Revision: hrev44922 Commit: 8df20d2c850097dd8980beb383ba683c748dd691 URL: http://cgit.haiku-os.org/haiku/commit/?id=8df20d2 Author: Axel DÃrfler <axeld@xxxxxxxxxxxxxxxx> Date: Wed Nov 28 21:34:48 2012 UTC Minor coding style cleanup. ---------------------------------------------------------------------------- diff --git a/src/add-ons/accelerants/vesa/hooks.cpp b/src/add-ons/accelerants/vesa/hooks.cpp index ae2b825..5563119 100644 --- a/src/add-ons/accelerants/vesa/hooks.cpp +++ b/src/add-ons/accelerants/vesa/hooks.cpp @@ -26,14 +26,14 @@ static int32 sOverlayChannelUsed; static uint32 -vesa_overlay_count(const display_mode *mode) +vesa_overlay_count(const display_mode* mode) { return 1; } static const uint32* -vesa_overlay_supported_spaces(const display_mode *mode) +vesa_overlay_supported_spaces(const display_mode* mode) { static const uint32 kSupportedSpaces[] = {B_RGB15, B_RGB16, B_RGB32, B_YCbCr422, 0}; @@ -69,14 +69,14 @@ vesa_allocate_overlay_buffer(color_space colorSpace, uint16 width, buffer->bytes_per_row = gInfo->shared_info->bytes_per_row; buffer->buffer = gInfo->shared_info->frame_buffer; - buffer->buffer_dma = (uint8 *)gInfo->shared_info->physical_frame_buffer; + buffer->buffer_dma = (uint8*)gInfo->shared_info->physical_frame_buffer; return buffer; } static status_t -vesa_release_overlay_buffer(const overlay_buffer *buffer) +vesa_release_overlay_buffer(const overlay_buffer* buffer) { debug_printf("release_overlay_buffer(buffer %p)\n", buffer); @@ -86,8 +86,8 @@ vesa_release_overlay_buffer(const overlay_buffer *buffer) static status_t -vesa_get_overlay_constraints(const display_mode *mode, - const overlay_buffer *buffer, overlay_constraints *constraints) +vesa_get_overlay_constraints(const display_mode* mode, + const overlay_buffer* buffer, overlay_constraints* constraints) { debug_printf("get_overlay_constraints(buffer %p)\n", buffer); @@ -125,7 +125,7 @@ vesa_get_overlay_constraints(const display_mode *mode, static overlay_token -vesa_allocate_overlay(void) +vesa_allocate_overlay() { debug_printf("allocate_overlay()\n"); @@ -152,8 +152,8 @@ vesa_release_overlay(overlay_token overlayToken) static status_t -vesa_configure_overlay(overlay_token overlayToken, const overlay_buffer *buffer, - const overlay_window *window, const overlay_view *view) +vesa_configure_overlay(overlay_token overlayToken, const overlay_buffer* buffer, + const overlay_window* window, const overlay_view* view) { debug_printf("configure_overlay: buffer %p, window %p, view %p\n", buffer, window, view); @@ -186,14 +186,14 @@ vesa_move_cursor(uint16 x, uint16 y) void -vesa_show_cursor(bool is_visible) +vesa_show_cursor(bool isVisible) { } #endif // # FAKE_HARDWARE_CURSOR_SUPPORT -extern "C" void * -get_accelerant_hook(uint32 feature, void *data) +extern "C" void* +get_accelerant_hook(uint32 feature, void* data) { switch (feature) { /* general */