Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-06-16 20:45:57 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-06-16 20:58:26 +0300
commit087a4898676d744d4aaa46a59b47186825495820 (patch)
treea3ec2cbd2060a567f87dcd6790f507e7641187a8 /intern
parent5767dcbe60c07cd9ef113e2f54eaad6981a47bce (diff)
Cleanup: simplify GHOST cursor API, no functional changes
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/GHOST_C-api.h33
-rw-r--r--intern/ghost/GHOST_IWindow.h8
-rw-r--r--intern/ghost/intern/GHOST_C-api.cpp26
-rw-r--r--intern/ghost/intern/GHOST_Window.cpp14
-rw-r--r--intern/ghost/intern/GHOST_Window.h16
-rw-r--r--intern/ghost/intern/GHOST_WindowCocoa.h8
-rw-r--r--intern/ghost/intern/GHOST_WindowCocoa.mm22
-rw-r--r--intern/ghost/intern/GHOST_WindowNULL.h10
-rw-r--r--intern/ghost/intern/GHOST_WindowSDL.cpp12
-rw-r--r--intern/ghost/intern/GHOST_WindowSDL.h8
-rw-r--r--intern/ghost/intern/GHOST_WindowWin32.cpp11
-rw-r--r--intern/ghost/intern/GHOST_WindowWin32.h8
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.cpp12
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.h12
-rw-r--r--intern/ghost/test/multitest/MultiTest.c2
15 files changed, 39 insertions, 163 deletions
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index b54c097c2ab..0f735711b24 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -325,20 +325,6 @@ extern GHOST_TSuccess GHOST_SetCursorShape(GHOST_WindowHandle windowhandle,
GHOST_TStandardCursor cursorshape);
/**
- * Set the shape of the cursor to a custom cursor.
- * \param windowhandle The handle to the window
- * \param bitmap The bitmap data for the cursor.
- * \param mask The mask data for the cursor.
- * \param hotX The X coordinate of the cursor hotspot.
- * \param hotY The Y coordinate of the cursor hotspot.
- * \return Indication of success.
- */
-extern GHOST_TSuccess GHOST_SetCustomCursorShape(GHOST_WindowHandle windowhandle,
- GHOST_TUns8 bitmap[16][2],
- GHOST_TUns8 mask[16][2],
- int hotX,
- int hotY);
-/**
* Set the shape of the cursor to a custom cursor of specified size.
* \param windowhandle The handle to the window
* \param bitmap The bitmap data for the cursor.
@@ -347,18 +333,17 @@ extern GHOST_TSuccess GHOST_SetCustomCursorShape(GHOST_WindowHandle windowhandle
* \param sizey The height of the cursor
* \param hotX The X coordinate of the cursor hotspot.
* \param hotY The Y coordinate of the cursor hotspot.
- * \param fg_color, bg_color Colors of the cursor
+ * \param canInvertColor Let macOS invert cursor color to match platform convention.
* \return Indication of success.
*/
-extern GHOST_TSuccess GHOST_SetCustomCursorShapeEx(GHOST_WindowHandle windowhandle,
- GHOST_TUns8 *bitmap,
- GHOST_TUns8 *mask,
- int sizex,
- int sizey,
- int hotX,
- int hotY,
- int fg_color,
- int bg_color);
+extern GHOST_TSuccess GHOST_SetCustomCursorShape(GHOST_WindowHandle windowhandle,
+ GHOST_TUns8 *bitmap,
+ GHOST_TUns8 *mask,
+ int sizex,
+ int sizey,
+ int hotX,
+ int hotY,
+ GHOST_TUns8 canInvertColor);
/**
* Returns the visibility state of the cursor.
diff --git a/intern/ghost/GHOST_IWindow.h b/intern/ghost/GHOST_IWindow.h
index 52894a7c38d..1a1844bfe41 100644
--- a/intern/ghost/GHOST_IWindow.h
+++ b/intern/ghost/GHOST_IWindow.h
@@ -287,19 +287,13 @@ class GHOST_IWindow {
* \param hotY The Y coordinate of the cursor hotspot.
* \return Indication of success.
*/
- virtual GHOST_TSuccess setCustomCursorShape(GHOST_TUns8 bitmap[16][2],
- GHOST_TUns8 mask[16][2],
- int hotX,
- int hotY) = 0;
-
virtual GHOST_TSuccess setCustomCursorShape(GHOST_TUns8 *bitmap,
GHOST_TUns8 *mask,
int sizex,
int sizey,
int hotX,
int hotY,
- int fg_color,
- int bg_color) = 0;
+ bool canInvertColor) = 0;
/**
* Returns the visibility state of the cursor.
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index ef653c114e8..78f171af7d1 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -265,29 +265,17 @@ GHOST_TSuccess GHOST_SetCursorShape(GHOST_WindowHandle windowhandle,
}
GHOST_TSuccess GHOST_SetCustomCursorShape(GHOST_WindowHandle windowhandle,
- GHOST_TUns8 bitmap[16][2],
- GHOST_TUns8 mask[16][2],
+ GHOST_TUns8 *bitmap,
+ GHOST_TUns8 *mask,
+ int sizex,
+ int sizey,
int hotX,
- int hotY)
+ int hotY,
+ GHOST_TUns8 canInvertColor)
{
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
- return window->setCustomCursorShape(bitmap, mask, hotX, hotY);
-}
-
-GHOST_TSuccess GHOST_SetCustomCursorShapeEx(GHOST_WindowHandle windowhandle,
- GHOST_TUns8 *bitmap,
- GHOST_TUns8 *mask,
- int sizex,
- int sizey,
- int hotX,
- int hotY,
- int fg_color,
- int bg_color)
-{
- GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
-
- return window->setCustomCursorShape(bitmap, mask, sizex, sizey, hotX, hotY, fg_color, bg_color);
+ return window->setCustomCursorShape(bitmap, mask, sizex, sizey, hotX, hotY, canInvertColor);
}
int GHOST_GetCursorVisibility(GHOST_WindowHandle windowhandle)
diff --git a/intern/ghost/intern/GHOST_Window.cpp b/intern/ghost/intern/GHOST_Window.cpp
index 76f2d2347db..ca19e251279 100644
--- a/intern/ghost/intern/GHOST_Window.cpp
+++ b/intern/ghost/intern/GHOST_Window.cpp
@@ -192,25 +192,15 @@ GHOST_TSuccess GHOST_Window::setCursorShape(GHOST_TStandardCursor cursorShape)
}
}
-GHOST_TSuccess GHOST_Window::setCustomCursorShape(GHOST_TUns8 bitmap[16][2],
- GHOST_TUns8 mask[16][2],
- int hotX,
- int hotY)
-{
- return setCustomCursorShape(
- (GHOST_TUns8 *)bitmap, (GHOST_TUns8 *)mask, 16, 16, hotX, hotY, 0, 1);
-}
-
GHOST_TSuccess GHOST_Window::setCustomCursorShape(GHOST_TUns8 *bitmap,
GHOST_TUns8 *mask,
int sizex,
int sizey,
int hotX,
int hotY,
- int fg_color,
- int bg_color)
+ bool canInvertColor)
{
- if (setWindowCustomCursorShape(bitmap, mask, sizex, sizey, hotX, hotY, fg_color, bg_color)) {
+ if (setWindowCustomCursorShape(bitmap, mask, sizex, sizey, hotX, hotY, canInvertColor)) {
m_cursorShape = GHOST_kStandardCursorCustom;
return GHOST_kSuccess;
}
diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h
index 50a563453f6..5f9e8ffdd5e 100644
--- a/intern/ghost/intern/GHOST_Window.h
+++ b/intern/ghost/intern/GHOST_Window.h
@@ -124,19 +124,13 @@ class GHOST_Window : public GHOST_IWindow {
* \param hotY The Y coordinate of the cursor hotspot.
* \return Indication of success.
*/
- GHOST_TSuccess setCustomCursorShape(GHOST_TUns8 bitmap[16][2],
- GHOST_TUns8 mask[16][2],
- int hotX,
- int hotY);
-
GHOST_TSuccess setCustomCursorShape(GHOST_TUns8 *bitmap,
GHOST_TUns8 *mask,
int sizex,
int sizey,
int hotX,
int hotY,
- int fg_color,
- int bg_color);
+ bool canInvertColor);
/**
* Returns the visibility state of the cursor.
@@ -347,19 +341,13 @@ class GHOST_Window : public GHOST_IWindow {
* Sets the cursor shape on the window using
* native window system calls.
*/
- virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
- GHOST_TUns8 mask[16][2],
- int hotX,
- int hotY) = 0;
-
virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 *bitmap,
GHOST_TUns8 *mask,
int szx,
int szy,
int hotX,
int hotY,
- int fg,
- int bg) = 0;
+ bool canInvertColor) = 0;
GHOST_TSuccess releaseNativeHandles();
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.h b/intern/ghost/intern/GHOST_WindowCocoa.h
index 5300b07523c..5e857c05a09 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.h
+++ b/intern/ghost/intern/GHOST_WindowCocoa.h
@@ -307,13 +307,7 @@ class GHOST_WindowCocoa : public GHOST_Window {
int sizey,
int hotX,
int hotY,
- int fg_color,
- int bg_color);
-
- GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
- GHOST_TUns8 mask[16][2],
- int hotX,
- int hotY);
+ bool canInvertColor);
/** The window containing the view */
CocoaWindow *m_window;
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm
index 45ea3c85005..9c988d075cd 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.mm
+++ b/intern/ghost/intern/GHOST_WindowCocoa.mm
@@ -1086,8 +1086,7 @@ GHOST_TSuccess GHOST_WindowCocoa::setWindowCustomCursorShape(GHOST_TUns8 *bitmap
int sizey,
int hotX,
int hotY,
- int fg_color,
- int bg_color)
+ bool canInvertColor)
{
int y, nbUns16;
NSPoint hotSpotPoint;
@@ -1120,12 +1119,18 @@ GHOST_TSuccess GHOST_WindowCocoa::setWindowCustomCursorShape(GHOST_TUns8 *bitmap
for (y = 0; y < nbUns16; y++) {
#if !defined(__LITTLE_ENDIAN__)
- cursorBitmap[y] = ~uns16ReverseBits((bitmap[2 * y] << 0) | (bitmap[2 * y + 1] << 8));
+ cursorBitmap[y] = uns16ReverseBits((bitmap[2 * y] << 0) | (bitmap[2 * y + 1] << 8));
cursorBitmap[nbUns16 + y] = uns16ReverseBits((mask[2 * y] << 0) | (mask[2 * y + 1] << 8));
#else
- cursorBitmap[y] = ~uns16ReverseBits((bitmap[2 * y + 1] << 0) | (bitmap[2 * y] << 8));
+ cursorBitmap[y] = uns16ReverseBits((bitmap[2 * y + 1] << 0) | (bitmap[2 * y] << 8));
cursorBitmap[nbUns16 + y] = uns16ReverseBits((mask[2 * y + 1] << 0) | (mask[2 * y] << 8));
#endif
+
+ /* Flip white cursor with black outline to black cursor with white outline
+ * to match macOS platform conventions. */
+ if (canInvertColor) {
+ cursorBitmap[y] = ~cursorBitmap[y];
+ }
}
imSize.width = sizex;
@@ -1148,12 +1153,3 @@ GHOST_TSuccess GHOST_WindowCocoa::setWindowCustomCursorShape(GHOST_TUns8 *bitmap
[pool drain];
return GHOST_kSuccess;
}
-
-GHOST_TSuccess GHOST_WindowCocoa::setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
- GHOST_TUns8 mask[16][2],
- int hotX,
- int hotY)
-{
- return setWindowCustomCursorShape(
- (GHOST_TUns8 *)bitmap, (GHOST_TUns8 *)mask, 16, 16, hotX, hotY, 0, 1);
-}
diff --git a/intern/ghost/intern/GHOST_WindowNULL.h b/intern/ghost/intern/GHOST_WindowNULL.h
index 0ea33710ef6..1d332a7dc3e 100644
--- a/intern/ghost/intern/GHOST_WindowNULL.h
+++ b/intern/ghost/intern/GHOST_WindowNULL.h
@@ -68,21 +68,13 @@ class GHOST_WindowNULL : public GHOST_Window {
{
return GHOST_kSuccess;
}
- GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
- GHOST_TUns8 mask[16][2],
- int hotX,
- int hotY)
- {
- return GHOST_kSuccess;
- }
GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 *bitmap,
GHOST_TUns8 *mask,
int sizex,
int sizey,
int hotX,
int hotY,
- int fg_color,
- int bg_color)
+ bool canInvertColor)
{
return GHOST_kSuccess;
}
diff --git a/intern/ghost/intern/GHOST_WindowSDL.cpp b/intern/ghost/intern/GHOST_WindowSDL.cpp
index 9c9fffdba50..cd9863d7e72 100644
--- a/intern/ghost/intern/GHOST_WindowSDL.cpp
+++ b/intern/ghost/intern/GHOST_WindowSDL.cpp
@@ -642,23 +642,13 @@ GHOST_TSuccess GHOST_WindowSDL::setWindowCursorShape(GHOST_TStandardCursor shape
return GHOST_kSuccess;
}
-GHOST_TSuccess GHOST_WindowSDL::setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
- GHOST_TUns8 mask[16][2],
- int hotX,
- int hotY)
-{
- return setWindowCustomCursorShape(
- (GHOST_TUns8 *)bitmap, (GHOST_TUns8 *)mask, 16, 16, hotX, hotY, 0, 1);
-}
-
GHOST_TSuccess GHOST_WindowSDL::setWindowCustomCursorShape(GHOST_TUns8 *bitmap,
GHOST_TUns8 *mask,
int sizex,
int sizey,
int hotX,
int hotY,
- int fg_color,
- int bg_color)
+ bool canInvertColor)
{
if (m_sdl_custom_cursor) {
SDL_FreeCursor(m_sdl_custom_cursor);
diff --git a/intern/ghost/intern/GHOST_WindowSDL.h b/intern/ghost/intern/GHOST_WindowSDL.h
index 7b3cddc5f17..bb19b62e06d 100644
--- a/intern/ghost/intern/GHOST_WindowSDL.h
+++ b/intern/ghost/intern/GHOST_WindowSDL.h
@@ -101,19 +101,13 @@ class GHOST_WindowSDL : public GHOST_Window {
GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape);
- GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
- GHOST_TUns8 mask[16][2],
- int hotX,
- int hotY);
-
GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 *bitmap,
GHOST_TUns8 *mask,
int sizex,
int sizey,
int hotX,
int hotY,
- int fg_color,
- int bg_color);
+ bool canInvertColor);
GHOST_TSuccess setWindowCursorVisibility(bool visible);
diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp
index def075bd47c..e8b36c59366 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@ -1189,14 +1189,6 @@ static GHOST_TUns16 uns16ReverseBits(GHOST_TUns16 shrt)
return shrt;
}
#endif
-GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
- GHOST_TUns8 mask[16][2],
- int hotX,
- int hotY)
-{
- return setWindowCustomCursorShape(
- (GHOST_TUns8 *)bitmap, (GHOST_TUns8 *)mask, 16, 16, hotX, hotY, 0, 1);
-}
GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(GHOST_TUns8 *bitmap,
GHOST_TUns8 *mask,
@@ -1204,8 +1196,7 @@ GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(GHOST_TUns8 *bitmap
int sizeY,
int hotX,
int hotY,
- int fg_color,
- int bg_color)
+ bool canInvertColor)
{
GHOST_TUns32 andData[32];
GHOST_TUns32 xorData[32];
diff --git a/intern/ghost/intern/GHOST_WindowWin32.h b/intern/ghost/intern/GHOST_WindowWin32.h
index 2f1f3a53c81..cf7177b0062 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.h
+++ b/intern/ghost/intern/GHOST_WindowWin32.h
@@ -461,19 +461,13 @@ class GHOST_WindowWin32 : public GHOST_Window {
* Sets the cursor shape on the window using
* native window system calls.
*/
- GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
- GHOST_TUns8 mask[16][2],
- int hotX,
- int hotY);
-
GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 *bitmap,
GHOST_TUns8 *mask,
int sizex,
int sizey,
int hotX,
int hotY,
- int fg_color,
- int bg_color);
+ bool canInvertColor);
/** Pointer to system */
GHOST_SystemWin32 *m_system;
diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp
index 48bdfa37565..166fea8a84b 100644
--- a/intern/ghost/intern/GHOST_WindowX11.cpp
+++ b/intern/ghost/intern/GHOST_WindowX11.cpp
@@ -1473,23 +1473,13 @@ GHOST_TSuccess GHOST_WindowX11::setWindowCursorShape(GHOST_TStandardCursor shape
return GHOST_kSuccess;
}
-GHOST_TSuccess GHOST_WindowX11::setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
- GHOST_TUns8 mask[16][2],
- int hotX,
- int hotY)
-{
- setWindowCustomCursorShape((GHOST_TUns8 *)bitmap, (GHOST_TUns8 *)mask, 16, 16, hotX, hotY, 0, 1);
- return GHOST_kSuccess;
-}
-
GHOST_TSuccess GHOST_WindowX11::setWindowCustomCursorShape(GHOST_TUns8 *bitmap,
GHOST_TUns8 *mask,
int sizex,
int sizey,
int hotX,
int hotY,
- int /*fg_color*/,
- int /*bg_color*/)
+ bool /*canInvertColor*/)
{
Colormap colormap = DefaultColormap(m_display, m_visualInfo->screen);
Pixmap bitmap_pix, mask_pix;
diff --git a/intern/ghost/intern/GHOST_WindowX11.h b/intern/ghost/intern/GHOST_WindowX11.h
index a39a186406f..83e0a2b59db 100644
--- a/intern/ghost/intern/GHOST_WindowX11.h
+++ b/intern/ghost/intern/GHOST_WindowX11.h
@@ -216,15 +216,6 @@ class GHOST_WindowX11 : public GHOST_Window {
/**
* Sets the cursor shape on the window using
- * native window system calls.
- */
- GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
- GHOST_TUns8 mask[16][2],
- int hotX,
- int hotY);
-
- /**
- * Sets the cursor shape on the window using
* native window system calls (Arbitrary size/color).
*/
GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 *bitmap,
@@ -233,8 +224,7 @@ class GHOST_WindowX11 : public GHOST_Window {
int sizey,
int hotX,
int hotY,
- int fg_color,
- int bg_color);
+ bool canInvertColor);
private:
/// Force use of public constructor.
diff --git a/intern/ghost/test/multitest/MultiTest.c b/intern/ghost/test/multitest/MultiTest.c
index 25e9f6b2bf1..5c8d3527869 100644
--- a/intern/ghost/test/multitest/MultiTest.c
+++ b/intern/ghost/test/multitest/MultiTest.c
@@ -736,7 +736,7 @@ static void extrawindow_spin_cursor(ExtraWindow *ew, GHOST_TUns64 time)
mask[y][x / 8] |= (1 << (x % 8));
}
- GHOST_SetCustomCursorShape(ew->win, bitmap, mask, 0, 0);
+ GHOST_SetCustomCursorShape(ew->win, bitmap, mask, 16, 16, 0, 0, true);
}
static void extrawindow_handle(void *priv, GHOST_EventHandle evt)