PageRenderTime 28ms CodeModel.GetById 11ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 1ms

/platform/osx/scaffold/view.d

http://github.com/wilkie/djehuty
D | 74 lines | 53 code | 19 blank | 2 comment | 1 complexity | f3ad190f3f535f235dfcbe19053cfcca MD5 | raw file
 1module scaffold.view;
 2
 3import platform.vars.view;
 4import platform.vars.window;
 5import platform.osx.common;
 6
 7import graphics.view;
 8import graphics.graphics;
 9
10import gui.window;
11import platform.osx.main;
12import core.string;
13import io.file;
14import io.console;
15
16import core.main;
17
18import graphics.bitmap;
19
20import core.definitions;
21
22extern (C) void _OSXViewCreate(_OSXViewPlatformVars** viewVars, int width, int height);
23extern (C) void _OSXViewCreateDIB(_OSXViewPlatformVars** viewVars, int width, int height);
24extern (C) void _OSXViewDestroy(_OSXViewPlatformVars* viewVars, int isDIB, int isWindow);
25
26extern (C) void* _OSXGetBytes(_OSXViewPlatformVars* viewVars);
27// views
28void ViewCreate(ref View view, ViewPlatformVars* viewVars) {
29	_OSXViewCreate(&viewVars.vars, view.width(), view.height());
30}
31
32void ViewDestroy(ref View view, ViewPlatformVars* viewVars) {
33	_OSXViewDestroy(viewVars.vars, cast(Bitmap)view !is null, viewVars.fromWindow == 1);
34	viewVars.fromWindow = 0;
35}
36
37void ViewCreateDIB(ref Bitmap view, ViewPlatformVars* viewVars) {
38	_OSXViewCreateDIB(&viewVars.vars, view.width(), view.height());
39
40	viewVars.dibBytes = view.width() * view.height() * 4;
41}
42
43void ViewCreateForWindow(ref WindowView view, ViewPlatformVars* viewVars, ref Window window, WindowPlatformVars* windowVars) {
44	// is done via WindowCreate
45	viewVars.fromWindow = 1;
46	viewVars.vars = windowVars.viewVars;
47}
48
49void ViewResizeForWindow(ref WindowView view, ViewPlatformVars* viewVars, ref Window window, WindowPlatformVars* windowVars) {
50}
51
52void ViewResize(ref View view, ViewPlatformVars* viewVars) {
53}
54
55void* ViewGetBytes(ViewPlatformVars* viewVars, ref ulong length) {
56	length = viewVars.dibBytes;
57	return _OSXGetBytes(viewVars.vars);
58}
59
60void* ViewGetBytes(ViewPlatformVars* viewVars) {
61	return _OSXGetBytes(viewVars.vars);
62}
63
64void ViewUnlockBytes(ViewPlatformVars* viewVars) {
65	return _OSXGetBytes(viewVars.vars);
66}
67
68uint ViewRGBAToInt32(ref bool _forcenopremultiply, ViewPlatformVars* _pfvars, ref uint r, ref uint g, ref uint b, ref uint a){
69	return (b << 16) | (g << 8) | (r) | (a << 24);
70}
71
72uint ViewRGBAToInt32(ViewPlatformVars* _pfvars, ref uint r, ref uint g, ref uint b) {
73	return (b << 16) | (g << 8) | (r) | 0xFF000000;
74}