Ticket #9261: AHWI.diff

File AHWI.diff, 4.2 KB (added by Ziusudra, 11 years ago)

not a proper patch

  • src/servers/app/drawing/AccelerantHWInterface.cpp

    diff --git a/src/servers/app/drawing/AccelerantHWInterface.cpp b/src/servers/app/drawing/AccelerantHWInterface.cpp
    index 48a2b37..e1f9a7d 100644
    a b AccelerantHWInterface::HideOverlay(Overlay* overlay)  
    13341334void
    13351335AccelerantHWInterface::SetCursor(ServerCursor* cursor)
    13361336{
    1337     HWInterface::SetCursor(cursor);
    1338         // HWInterface claims ownership of cursor.
    1339 
    13401337    // cursor should never be NULL, but let us be safe!!
    13411338    if (cursor == NULL || LockExclusiveAccess() == false)
    13421339        return;
    13431340
    1344     if (cursor->CursorData() != NULL && fAccSetCursorShape != NULL) {
    1345         // BeOS BCursor, 16x16 monochrome
    1346         uint8 size = cursor->CursorData()[0];
    1347         // CursorData()[1] is color depth (always monochrome)
    1348         uint8 xHotSpot = cursor->CursorData()[2];
    1349         uint8 yHotSpot = cursor->CursorData()[3];
    1350 
    1351         // Create pointers to the cursor and/xor bit arrays
    1352         const uint8* andMask = cursor->CursorData() + 4;
    1353         const uint8* xorMask = cursor->CursorData() + 36;
     1341    bool cursorSet = false;
    13541342
    1355         // Time to talk to the accelerant!
    1356         fHardwareCursorEnabled = fAccSetCursorShape(size, size, xHotSpot,
    1357             yHotSpot, andMask, xorMask) == B_OK;
    1358     } else if (fAccSetCursorBitmap != NULL) {
     1343    if (fAccSetCursorBitmap != NULL) {
    13591344        // Bitmap cursor
     1345        // TODO are x and y switched for this, too?
    13601346        uint16 xHotSpot = (uint16)cursor->GetHotSpot().x;
    13611347        uint16 yHotSpot = (uint16)cursor->GetHotSpot().y;
    13621348
    AccelerantHWInterface::SetCursor(ServerCursor* cursor)  
    13641350        uint16 height = (uint16)cursor->Bounds().Height();
    13651351
    13661352        // Time to talk to the accelerant!
    1367         fHardwareCursorEnabled = fAccSetCursorBitmap(width, height, xHotSpot,
     1353        cursorSet = fAccSetCursorBitmap(width, height, xHotSpot,
    13681354            yHotSpot, cursor->ColorSpace(), (uint16)cursor->BytesPerRow(),
    13691355            cursor->Bits()) == B_OK;
     1356    } else if (cursor->CursorData() != NULL && fAccSetCursorShape != NULL) {
     1357        // BeOS BCursor, 16x16 monochrome
     1358        uint8 size = cursor->CursorData()[0];
     1359        // CursorData()[1] is color depth (always monochrome)
     1360        // x and y are switched
     1361        uint8 xHotSpot = cursor->CursorData()[3];
     1362        uint8 yHotSpot = cursor->CursorData()[2];
     1363
     1364        // Create pointers to the cursor and/xor bit arrays
     1365        // for the BeOS BCursor there are two 32 byte, 16x16 bit arrays
     1366        // in the first:  1 is black,  0 is white
     1367        // in the second: 1 is opaque, 0 is transparent
     1368        // 1st  2nd
     1369        //  0    0   transparent
     1370        //  0    1   white
     1371        //  1    0   transparent
     1372        //  1    1   black
     1373        // for the HW cursor the first is ANDed and the second is XORed
     1374        // AND  XOR
     1375        //  0    0   white
     1376        //  0    1   black
     1377        //  1    0   transparent
     1378        //  1    1   reverse
     1379        // so, the first 32 bytes are the XOR mask
     1380        const uint8* xorMask = cursor->CursorData() + 4;
     1381        // the second 32 bytes *NOTed* are the AND mask
     1382        // TODO maybe this should be NOTed when copied to the ServerCursor
     1383        uint8 andMask[32];
     1384        const uint8* transMask = cursor->CursorData() + 36;
     1385        for (int32 i = 0; i < 32; i++)
     1386            andMask[i] = ~transMask[i];
     1387
     1388        // Time to talk to the accelerant!
     1389        cursorSet = fAccSetCursorShape(size, size, xHotSpot,
     1390            yHotSpot, andMask, xorMask) == B_OK;
     1391    }
     1392
     1393    if (cursorSet && !fHardwareCursorEnabled) {
     1394        // we switched from SW to HW, so we need to erase the SW cursor
     1395        if (fCursorVisible && fFloatingOverlaysLock.Lock()) {
     1396            IntRect r = _CursorFrame();
     1397            fCursorVisible = false;
     1398                // so the Invalidate doesn't draw it again
     1399            _RestoreCursorArea();
     1400            Invalidate(r);
     1401            fCursorVisible = true;
     1402            fFloatingOverlaysLock.Unlock();
     1403        }
     1404        // and we need to update our position
     1405        if (fAccMoveCursor != NULL)
     1406            fAccMoveCursor((uint16)fCursorLocation.x,
     1407                (uint16)fCursorLocation.y);
    13701408    }
    13711409
     1410    if (fAccShowCursor != NULL)
     1411        fAccShowCursor(cursorSet);
     1412
    13721413    UnlockExclusiveAccess();
     1414
     1415    fHardwareCursorEnabled = cursorSet;
     1416
     1417    HWInterface::SetCursor(cursor);
     1418        // HWInterface claims ownership of cursor.
    13731419}
    13741420
    13751421
    AccelerantHWInterface::MoveCursorTo(float x, float y)  
    13971443    if (fHardwareCursorEnabled && LockExclusiveAccess()) {
    13981444        if (fAccMoveCursor != NULL)
    13991445                fAccMoveCursor((uint16)x, (uint16)y);
    1400         else
     1446        else {
    14011447            fHardwareCursorEnabled = false;
     1448            if (fAccShowCursor != NULL)
     1449                fAccShowCursor(false);
     1450        }
    14021451
    14031452        UnlockExclusiveAccess();
    14041453    }