1 /* 2 * Copyright 2020 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stefano Ceccherini <stefano.ceccherini@gmail.com> 7 */ 8 #ifndef _DIRECT_WINDOW_H 9 #define _DIRECT_WINDOW_H 10 11 12 #include <Region.h> 13 #include <Window.h> 14 15 16 enum direct_buffer_state { 17 B_DIRECT_MODE_MASK = 15, 18 B_DIRECT_START = 0, 19 B_DIRECT_STOP = 1, 20 B_DIRECT_MODIFY = 2, 21 B_CLIPPING_MODIFIED = 16, 22 B_BUFFER_RESIZED = 32, 23 B_BUFFER_MOVED = 64, 24 B_BUFFER_RESET = 128 25 }; 26 27 28 enum direct_driver_state { 29 B_DRIVER_CHANGED = 0x0001, 30 B_MODE_CHANGED = 0x0002 31 }; 32 33 34 typedef struct { 35 direct_buffer_state buffer_state; 36 direct_driver_state driver_state; 37 void *bits; 38 void *pci_bits; 39 int32 bytes_per_row; 40 uint32 bits_per_pixel; 41 color_space pixel_format; 42 buffer_layout layout; 43 buffer_orientation orientation; 44 uint32 _reserved[9]; 45 uint32 _dd_type_; 46 uint32 _dd_token_; 47 uint32 clip_list_count; 48 clipping_rect window_bounds; 49 clipping_rect clip_bounds; 50 clipping_rect clip_list[1]; 51 } direct_buffer_info; 52 53 54 class BDirectWindow : public BWindow { 55 public: 56 BDirectWindow(BRect frame, const char* title, 57 window_type type, uint32 flags, 58 uint32 workspace = B_CURRENT_WORKSPACE); 59 60 BDirectWindow(BRect frame, const char* title, 61 window_look look, window_feel feel, 62 uint32 flags, 63 uint32 workspace = B_CURRENT_WORKSPACE); 64 65 virtual ~BDirectWindow(); 66 67 static BArchivable* Instantiate(BMessage* data); 68 virtual status_t Archive(BMessage* data, 69 bool deep = true) const; 70 71 virtual void Quit(); 72 73 virtual void DispatchMessage(BMessage* message, 74 BHandler* handler); 75 76 virtual void MessageReceived(BMessage* message); 77 78 virtual void FrameMoved(BPoint newPosition); 79 virtual void FrameResized(float newWidth, float newHeight); 80 81 virtual void WorkspacesChanged(uint32 oldWorkspaces, 82 uint32 newWorkspaces); 83 84 virtual void WorkspaceActivated(int32 workspaceIndex, 85 bool state); 86 87 virtual void Minimize(bool minimize); 88 virtual void Zoom(BPoint recPosition, float recWidth, 89 float recHeight); 90 91 virtual void ScreenChanged(BRect screenFrame, 92 color_space depth); 93 94 virtual void MenusBeginning(); 95 virtual void MenusEnded(); 96 virtual void WindowActivated(bool state); 97 virtual void Show(); 98 virtual void Hide(); 99 100 virtual BHandler* ResolveSpecifier(BMessage* message, 101 int32 index, BMessage* specifier, 102 int32 what, const char* property); 103 104 virtual status_t GetSupportedSuites(BMessage* data); 105 virtual status_t Perform(perform_code code, void* arg); 106 107 virtual void DirectConnected(direct_buffer_info* info); 108 109 status_t GetClippingRegion(BRegion* region, 110 BPoint* origin = NULL) const; 111 112 status_t SetFullScreen(bool enable); 113 bool IsFullScreen() const; 114 115 static bool SupportsWindowMode( 116 screen_id id = B_MAIN_SCREEN_ID); 117 private: 118 BDirectWindow(); 119 BDirectWindow(BDirectWindow& other); 120 121 BDirectWindow& operator=(BDirectWindow& other); 122 123 typedef BWindow inherited; 124 125 virtual void _ReservedDirectWindow1(); 126 virtual void _ReservedDirectWindow2(); 127 virtual void _ReservedDirectWindow3(); 128 virtual void _ReservedDirectWindow4(); 129 130 virtual void task_looper(); 131 virtual BMessage* ConvertToMessage(void* raw, int32 code); 132 133 static int32 _daemon_thread(void* arg); 134 int32 _DirectDaemon(); 135 bool _LockDirect() const; 136 void _UnlockDirect() const; 137 void _InitData(); 138 void _DisposeData(); 139 private: 140 bool fDaemonKiller; 141 bool fConnectionEnable; 142 bool fIsFullScreen; 143 bool _unused; 144 bool fInDirectConnect; 145 int32 fDirectLock; 146 sem_id fDirectSem; 147 uint32 fDirectLockCount; 148 thread_id fDirectLockOwner; 149 char* fDirectLockStack; 150 sem_id fDisableSem; 151 sem_id fDisableSemAck; 152 153 uint32 fInitStatus; 154 uint32 fInfoAreaSize; 155 156 uint32 _reserved[2]; 157 158 area_id fClonedClippingArea; 159 area_id fSourceClippingArea; 160 thread_id fDirectDaemonId; 161 direct_buffer_info* fBufferDesc; 162 163 uint32 _more_reserved_[17]; 164 }; 165 166 #endif 167