Files @ r24848:4573f310a629
Branch filter:

Location: cpp/openttd-patchpack/source/src/video/cocoa/cocoa_v.h - annotation

Patric Stout
Codechange: [Win32] make fast-forward check the same as with other drivers

It was of all the drivers the only one doing this slightly different.
When trying to unify more code, that was rather annoying.
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r9111:983de9c5a848
r9111:983de9c5a848
r7939:523d421f9d0c
r7939:523d421f9d0c
r7939:523d421f9d0c
r7939:523d421f9d0c
r24565:5dd2777a6959
r24565:5dd2777a6959
r7939:523d421f9d0c
r24556:fb8120e96ffe
r24556:fb8120e96ffe
r24768:48450d9ea0c2
r24772:2d660991e437
r24772:2d660991e437
r24768:48450d9ea0c2
r21028:e5db3f83cafa
r24565:5dd2777a6959
r24764:1ef60c5f1172
r24764:1ef60c5f1172
r24764:1ef60c5f1172
r24764:1ef60c5f1172
r24764:1ef60c5f1172
r24764:1ef60c5f1172
r24764:1ef60c5f1172
r24764:1ef60c5f1172
r24764:1ef60c5f1172
r24764:1ef60c5f1172
r24765:2c3933a09d54
r24765:2c3933a09d54
r24764:1ef60c5f1172
r24765:2c3933a09d54
r24764:1ef60c5f1172
r24565:5dd2777a6959
r7939:523d421f9d0c
r24781:5fac82465296
r24764:1ef60c5f1172
r24772:2d660991e437
r24772:2d660991e437
r24764:1ef60c5f1172
r24764:1ef60c5f1172
r24764:1ef60c5f1172
r24768:48450d9ea0c2
r24768:48450d9ea0c2
r24764:1ef60c5f1172
r24764:1ef60c5f1172
r24764:1ef60c5f1172
r24218:c32caa9f014d
r23497:a0ab44ebd2fa
r23497:a0ab44ebd2fa
r7939:523d421f9d0c
r24767:dedfc39121ac
r24767:dedfc39121ac
r24767:dedfc39121ac
r23497:a0ab44ebd2fa
r23497:a0ab44ebd2fa
r12935:993da883d0df
r23497:a0ab44ebd2fa
r20648:393668109c79
r23497:a0ab44ebd2fa
r24565:5dd2777a6959
r24565:5dd2777a6959
r24565:5dd2777a6959
r24776:fef5522d8f0f
r24565:5dd2777a6959
r24768:48450d9ea0c2
r24764:1ef60c5f1172
r24665:20a8caea4459
r24665:20a8caea4459
r24798:b9ee83bbe580
r24665:20a8caea4459
r24565:5dd2777a6959
r24782:080a46243662
r7939:523d421f9d0c
r24767:dedfc39121ac
r24767:dedfc39121ac
r24762:5a4d1e409614
r24767:dedfc39121ac
r24768:48450d9ea0c2
r24768:48450d9ea0c2
r24762:5a4d1e409614
r24762:5a4d1e409614
r24767:dedfc39121ac
r18063:14deaddcaab9
r24767:dedfc39121ac
r24767:dedfc39121ac
r7939:523d421f9d0c
r7939:523d421f9d0c
r24764:1ef60c5f1172
r24764:1ef60c5f1172
r24764:1ef60c5f1172
r24764:1ef60c5f1172
r24764:1ef60c5f1172
r7939:523d421f9d0c
r7939:523d421f9d0c
/*
 * This file is part of OpenTTD.
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 */

/** @file cocoa_v.h The Cocoa video driver. */

#ifndef VIDEO_COCOA_H
#define VIDEO_COCOA_H

#include "../video_driver.hpp"
#include "../../core/geometry_type.hpp"


extern bool _cocoa_video_started;

@class OTTD_CocoaWindowDelegate;
@class OTTD_CocoaWindow;
@class OTTD_CocoaView;

class VideoDriver_Cocoa : public VideoDriver {
private:
	Dimension orig_res;   ///< Saved window size for non-fullscreen mode.

	int window_width;     ///< Current window width in pixel
	int window_height;    ///< Current window height in pixel
	int window_pitch;

	int buffer_depth;     ///< Colour depth of used frame buffer
	void *pixel_buffer;   ///< used for direct pixel access
	void *window_buffer;  ///< Colour translation from palette to screen

	static const int MAX_DIRTY_RECTS = 100;

	Rect dirty_rects[MAX_DIRTY_RECTS]; ///< dirty rectangles
	uint num_dirty_rects;  ///< Number of dirty rectangles
	uint32 palette[256];  ///< Colour Palette

public:
	bool setup; ///< Window is currently being created.

	OTTD_CocoaWindow *window;    ///< Pointer to window object
	OTTD_CocoaView *cocoaview;   ///< Pointer to view object
	CGColorSpaceRef color_space; ///< Window color space
	CGContextRef cgcontext;      ///< Context reference for Quartz subdriver

	OTTD_CocoaWindowDelegate *delegate; //!< Window delegate object

public:
	VideoDriver_Cocoa();

	const char *Start(const StringList &param) override;
	void Stop() override;
	void MainLoop() override;

	void MakeDirty(int left, int top, int width, int height) override;
	bool AfterBlitterChange() override;

	bool ChangeResolution(int w, int h) override;
	bool ToggleFullscreen(bool fullscreen) override;

	void EditBoxLostFocus() override;

	const char *GetName() const override { return "cocoa"; }

	/* --- The following methods should be private, but can't be due to Obj-C limitations. --- */

	void GameLoop();

	void AllocateBackingStore();

protected:
	Dimension GetScreenSize() const override;
	float GetDPIScale() override;

private:
	bool PollEvent();

	bool IsFullscreen();
	void GameSizeChanged();

	void UpdateVideoModes();

	bool MakeWindow(int width, int height);

	void UpdatePalette(uint first_color, uint num_colors);
	void CheckPaletteAnim();

	void Draw(bool force_update = false);
	void BlitIndexedToView32(int left, int top, int right, int bottom);
};

class FVideoDriver_Cocoa : public DriverFactoryBase {
public:
	FVideoDriver_Cocoa() : DriverFactoryBase(Driver::DT_VIDEO, 10, "cocoa", "Cocoa Video Driver") {}
	Driver *CreateInstance() const override { return new VideoDriver_Cocoa(); }
};

#endif /* VIDEO_COCOA_H */