23class VideoDriver_Cocoa :
public VideoDriver {
38 VideoDriver_Cocoa(
bool uses_hardware_acceleration =
false);
43 void MakeDirty(
int left,
int top,
int width,
int height)
override;
60 virtual void AllocateBackingStore(
bool force =
false) = 0;
80 virtual NSView *AllocateDrawView() = 0;
91class VideoDriver_CocoaQuartz :
public VideoDriver_Cocoa {
109 VideoDriver_CocoaQuartz();
111 std::optional<std::string_view>
Start(
const StringList ¶m)
override;
112 void Stop()
override;
115 std::string_view
GetName()
const override {
return "cocoa"; }
120 void Paint()
override;
123 NSView *AllocateDrawView()
override;
125 void *
GetVideoPointer()
override {
return this->buffer_depth == 8 ?
static_cast<void *
>(this->pixel_buffer.get()) :
static_cast<void *
>(this->window_buffer.get()); }
131 std::unique_ptr<Driver>
CreateInstance()
const override {
return std::make_unique<VideoDriver_CocoaQuartz>(); }
DriverFactoryBase(Driver::Type type, int priority, std::string_view name, std::string_view description)
Construct a new DriverFactory.
@ DT_VIDEO
A video driver.
std::unique_ptr< Driver > CreateInstance() const override
Create an instance of this driver-class.
std::optional< std::string_view > Start(const StringList ¶m) override
Start this driver.
std::string_view GetName() const override
Return driver name.
CGContextRef cgcontext
Context reference for Quartz subdriver.
uint32_t palette[256]
Colour Palette.
int buffer_depth
Colour depth of used frame buffer.
int window_width
Current window width in pixel.
void CheckPaletteAnim() override
Process any pending palette animation.
std::unique_ptr< uint32_t[]> window_buffer
Colour translation from palette to screen.
void AllocateBackingStore(bool force=false) override
Resize the window.
void BlitIndexedToView32(int left, int top, int right, int bottom)
This function copies 8bpp pixels from the screen buffer in 32bpp windowed mode.
std::unique_ptr< uint8_t[]> pixel_buffer
used for direct pixel access
void UpdatePalette(uint first_colour, uint num_colours)
Update the palette.
void Stop() override
Stop Cocoa video driver.
void Paint() override
Draw window.
void * GetVideoPointer() override
Get a pointer to the video buffer.
int window_height
Current window height in pixel.
void GameSizeChanged()
Handle a change of the display area.
bool ToggleFullscreen(bool fullscreen) override
Toggle between windowed and full screen mode for cocoa display driver.
void UpdateVideoModes()
Update the video mode.
std::vector< int > GetListOfMonitorRefreshRates() override
Get refresh rates of all connected monitors.
Dimension GetScreenSize() const override
Get the resolution of the main screen.
std::optional< std::string_view > Initialize()
Common driver initialization.
bool refresh_sys_sprites
System sprites need refreshing.
void MainLoop() override
Start the main programme loop when using a cocoa video driver.
OTTD_CocoaWindow * window
Pointer to window object.
OTTD_CocoaView * cocoaview
Pointer to view object.
virtual void ReleaseVideoPointer()
Hand video buffer back to the drawing backend.
virtual void * GetVideoPointer()=0
Get a pointer to the video buffer.
OTTD_CocoaWindowDelegate * delegate
Window delegate object.
bool IsFullscreen()
Are we in fullscreen mode?
void InputLoop() override
Handle input logic, is CTRL pressed, should we fast-forward, etc.
bool MakeWindow(int width, int height)
Build window and view with a given size.
bool PollEvent() override
Poll and handle a single event from the OS.
void MakeDirty(int left, int top, int width, int height) override
Set dirty a rectangle managed by a cocoa video subdriver.
void PopulateSystemSprites() override
Populate all sprites in cache.
bool LockVideoBuffer() override
Lock video buffer for drawing if it isn't already mapped.
void EditBoxLostFocus() override
An edit box lost the input focus.
void ClearSystemSprites() override
Clear all cached sprites.
Rect dirty_rect
Region of the screen that needs redrawing.
void UnlockVideoBuffer() override
Unlock video buffer.
void Stop() override
Stop Cocoa video driver.
bool buffer_locked
Video buffer was locked by the main thread.
Dimension orig_res
Saved window size for non-fullscreen mode.
bool setup
Window is currently being created.
bool ChangeResolution(int w, int h) override
Change the resolution when using a cocoa video driver.
bool AfterBlitterChange() override
Callback invoked after the blitter was changed.
CGColorSpaceRef colour_space
Window colour space.
void MainLoopReal()
Main game loop.
bool _cocoa_video_started
Is the Cocoa video driver running.
All geometry types in OpenTTD.
Subclass of NSView to support mouse awareness and text input.
Delegate for our NSWindow to send ask for quit on close.
Subclass of NSWindow to cater our special needs.
#define Rect
Macro that prevents name conflicts between included headers.
std::vector< std::string > StringList
Type for a list of strings.
Dimensions (a width and height) of a rectangle in 2D.
Base of all video drivers.