1
0
Fork 0

Cleanup: [OSX] Doxygen comment style in video driver.

pull/8672/head
Michael Lutz 2021-01-24 13:13:25 +01:00
parent 8ced72ab10
commit 0eff7de659
2 changed files with 48 additions and 81 deletions

View File

@ -50,47 +50,18 @@ public:
VideoDriver_Cocoa(); VideoDriver_Cocoa();
const char *Start(const StringList &param) override; const char *Start(const StringList &param) override;
/** Stop the video driver */
void Stop() override; void Stop() override;
/** Mark dirty a screen region
* @param left x-coordinate of left border
* @param top y-coordinate of top border
* @param width width or dirty rectangle
* @param height height of dirty rectangle
*/
void MakeDirty(int left, int top, int width, int height) override;
/** Programme main loop */
void MainLoop() override; void MainLoop() override;
/** Change window resolution void MakeDirty(int left, int top, int width, int height) override;
* @param w New window width
* @param h New window height
* @return Whether change was successful
*/
bool ChangeResolution(int w, int h) override;
/** Set a new window mode
* @param fullscreen Whether to set fullscreen mode or not
* @return Whether changing the screen mode was successful
*/
bool ToggleFullscreen(bool fullscreen) override;
/** Callback invoked after the blitter was changed.
* @return True if no error.
*/
bool AfterBlitterChange() override; bool AfterBlitterChange() override;
/** bool ChangeResolution(int w, int h) override;
* An edit box lost the input focus. Abort character compositing if necessary. bool ToggleFullscreen(bool fullscreen) override;
*/
void EditBoxLostFocus() override; void EditBoxLostFocus() override;
/** Return driver name /** Return driver name */
* @return driver name
*/
const char *GetName() const override { return "cocoa"; } const char *GetName() const override { return "cocoa"; }
/* --- The following methods should be private, but can't be due to Obj-C limitations. --- */ /* --- The following methods should be private, but can't be due to Obj-C limitations. --- */
@ -98,67 +69,30 @@ public:
/** Main game loop. */ /** Main game loop. */
void GameLoop(); // In event.mm. void GameLoop(); // In event.mm.
/** Resize the window.
* @return whether the window was successfully resized
*/
bool WindowResized(); bool WindowResized();
/** Convert local coordinate to window server (CoreGraphics) coordinate
* @param p local coordinates
* @return window driver coordinates
*/
CGPoint PrivateLocalToCG(NSPoint *p);
protected: protected:
Dimension GetScreenSize() const override; Dimension GetScreenSize() const override;
private: private:
NSPoint GetMouseLocation(NSEvent *event);
bool MouseIsInsideView(NSPoint *pt);
CGPoint PrivateLocalToCG(NSPoint *p);
bool PollEvent(); // In event.mm. bool PollEvent(); // In event.mm.
void MouseMovedEvent(int x, int y); // In event.mm. void MouseMovedEvent(int x, int y); // In event.mm.
void WarpCursor(int x, int y); // In event.mm.
bool IsFullscreen();
void GameSizeChanged(); void GameSizeChanged();
void UpdateVideoModes(); void UpdateVideoModes();
/**
* This function copies 8bpp pixels from the screen buffer in 32bpp windowed mode.
*
* @param left The x coord for the left edge of the box to blit.
* @param top The y coord for the top edge of the box to blit.
* @param right The x coord for the right edge of the box to blit.
* @param bottom The y coord for the bottom edge of the box to blit.
*/
void BlitIndexedToView32(int left, int top, int right, int bottom);
void GetDeviceInfo(); void GetDeviceInfo();
bool SetVideoMode(int width, int height, int bpp); bool SetVideoMode(int width, int height, int bpp);
/** Draw window
* @param force_update Whether to redraw unconditionally
*/
void Draw(bool force_update = false);
/** Update the palette */
void UpdatePalette(uint first_color, uint num_colors); void UpdatePalette(uint first_color, uint num_colors);
/** Are we in fullscreen mode
* @return whether fullscreen mode is currently used
*/
bool IsFullscreen();
/** Return the mouse location
* @param event UI event
* @return mouse location as NSPoint
*/
NSPoint GetMouseLocation(NSEvent *event);
/** Return whether the mouse is within our view
* @param pt Mouse coordinates
* @return Whether mouse coordinates are within view
*/
bool MouseIsInsideView(NSPoint *pt);
void CheckPaletteAnim(); void CheckPaletteAnim();
void Draw(bool force_update = false);
void BlitIndexedToView32(int left, int top, int right, int bottom);
}; };
class FVideoDriver_Cocoa : public DriverFactoryBase { class FVideoDriver_Cocoa : public DriverFactoryBase {

View File

@ -406,6 +406,10 @@ void VideoDriver_Cocoa::GetDeviceInfo()
CGDisplayModeRelease(cur_mode); CGDisplayModeRelease(cur_mode);
} }
/**
* Are we in fullscreen mode
* @return whether fullscreen mode is currently used
*/
bool VideoDriver_Cocoa::IsFullscreen() bool VideoDriver_Cocoa::IsFullscreen()
{ {
return this->window != nil && ([ this->window styleMask ] & NSWindowStyleMaskFullScreen) != 0; return this->window != nil && ([ this->window styleMask ] & NSWindowStyleMaskFullScreen) != 0;
@ -524,6 +528,14 @@ bool VideoDriver_Cocoa::SetVideoMode(int width, int height, int bpp)
return ret; return ret;
} }
/**
* This function copies 8bpp pixels from the screen buffer in 32bpp windowed mode.
*
* @param left The x coord for the left edge of the box to blit.
* @param top The y coord for the top edge of the box to blit.
* @param right The x coord for the right edge of the box to blit.
* @param bottom The y coord for the bottom edge of the box to blit.
*/
void VideoDriver_Cocoa::BlitIndexedToView32(int left, int top, int right, int bottom) void VideoDriver_Cocoa::BlitIndexedToView32(int left, int top, int right, int bottom)
{ {
const uint32 *pal = this->palette; const uint32 *pal = this->palette;
@ -539,7 +551,9 @@ void VideoDriver_Cocoa::BlitIndexedToView32(int left, int top, int right, int bo
} }
} }
/** Draw window
* @param force_update Whether to redraw unconditionally
*/
void VideoDriver_Cocoa::Draw(bool force_update) void VideoDriver_Cocoa::Draw(bool force_update)
{ {
PerformanceMeasurer framerate(PFE_VIDEO); PerformanceMeasurer framerate(PFE_VIDEO);
@ -582,6 +596,7 @@ void VideoDriver_Cocoa::Draw(bool force_update)
this->num_dirty_rects = 0; this->num_dirty_rects = 0;
} }
/** Update the palette */
void VideoDriver_Cocoa::UpdatePalette(uint first_color, uint num_colors) void VideoDriver_Cocoa::UpdatePalette(uint first_color, uint num_colors)
{ {
if (this->buffer_depth != 8) return; if (this->buffer_depth != 8) return;
@ -597,7 +612,11 @@ void VideoDriver_Cocoa::UpdatePalette(uint first_color, uint num_colors)
this->num_dirty_rects = lengthof(this->dirty_rects); this->num_dirty_rects = lengthof(this->dirty_rects);
} }
/* Convert local coordinate to window server (CoreGraphics) coordinate */ /**
* Convert local coordinate to window server (CoreGraphics) coordinate
* @param p local coordinates
* @return window driver coordinates
*/
CGPoint VideoDriver_Cocoa::PrivateLocalToCG(NSPoint *p) CGPoint VideoDriver_Cocoa::PrivateLocalToCG(NSPoint *p)
{ {
@ -614,6 +633,11 @@ CGPoint VideoDriver_Cocoa::PrivateLocalToCG(NSPoint *p)
return cgp; return cgp;
} }
/**
* Return the mouse location
* @param event UI event
* @return mouse location as NSPoint
*/
NSPoint VideoDriver_Cocoa::GetMouseLocation(NSEvent *event) NSPoint VideoDriver_Cocoa::GetMouseLocation(NSEvent *event)
{ {
NSPoint pt; NSPoint pt;
@ -629,6 +653,11 @@ NSPoint VideoDriver_Cocoa::GetMouseLocation(NSEvent *event)
return pt; return pt;
} }
/**
* Return whether the mouse is within our view
* @param pt Mouse coordinates
* @return Whether mouse coordinates are within view
*/
bool VideoDriver_Cocoa::MouseIsInsideView(NSPoint *pt) bool VideoDriver_Cocoa::MouseIsInsideView(NSPoint *pt)
{ {
return [ cocoaview mouse:*pt inRect:[ this->cocoaview bounds ] ]; return [ cocoaview mouse:*pt inRect:[ this->cocoaview bounds ] ];
@ -645,6 +674,10 @@ static void ClearWindowBuffer(uint32 *buffer, uint32 pitch, uint32 height)
} }
} }
/**
* Resize the window.
* @return whether the window was successfully resized
*/
bool VideoDriver_Cocoa::WindowResized() bool VideoDriver_Cocoa::WindowResized()
{ {
if (this->window == nil || this->cocoaview == nil) return true; if (this->window == nil || this->cocoaview == nil) return true;