1af69d88dSmrg/* 2af69d88dSmrg * Copyright 2006-2012, Haiku. All rights reserved. 3af69d88dSmrg * Distributed under the terms of the MIT License. 4af69d88dSmrg * 5af69d88dSmrg * Authors: 6af69d88dSmrg * Jérôme Duval, korli@users.berlios.de 7af69d88dSmrg * Philippe Houdoin, philippe.houdoin@free.fr 8af69d88dSmrg * Stefano Ceccherini, burton666@libero.it 9af69d88dSmrg */ 10af69d88dSmrg 11af69d88dSmrg#include <kernel/image.h> 12af69d88dSmrg 13af69d88dSmrg#include <GLView.h> 14af69d88dSmrg 15af69d88dSmrg#include <assert.h> 16af69d88dSmrg#include <stdio.h> 17af69d88dSmrg#include <stdlib.h> 18af69d88dSmrg#include <string.h> 19af69d88dSmrg 20af69d88dSmrg#include <DirectWindow.h> 217ec681f3Smrg#include "GLRenderer.h" 22af69d88dSmrg 237ec681f3Smrg#include <private/interface/DirectWindowPrivate.h> 24af69d88dSmrg#include "GLRendererRoster.h" 25af69d88dSmrg 267ec681f3Smrg#include "glapi/glapi.h" 27af69d88dSmrg 28af69d88dSmrgstruct glview_direct_info { 29af69d88dSmrg direct_buffer_info* direct_info; 30af69d88dSmrg bool direct_connected; 31af69d88dSmrg bool enable_direct_mode; 32af69d88dSmrg 33af69d88dSmrg glview_direct_info(); 34af69d88dSmrg ~glview_direct_info(); 35af69d88dSmrg}; 36af69d88dSmrg 37af69d88dSmrg 38af69d88dSmrgBGLView::BGLView(BRect rect, const char* name, ulong resizingMode, ulong mode, 39af69d88dSmrg ulong options) 40af69d88dSmrg : 41af69d88dSmrg BView(rect, name, B_FOLLOW_ALL_SIDES, mode | B_WILL_DRAW | B_FRAME_EVENTS), 42af69d88dSmrg fGc(NULL), 43af69d88dSmrg fOptions(options), 44af69d88dSmrg fDitherCount(0), 45af69d88dSmrg fDrawLock("BGLView draw lock"), 46af69d88dSmrg fDisplayLock("BGLView display lock"), 47af69d88dSmrg fClipInfo(NULL), 48af69d88dSmrg fRenderer(NULL), 49af69d88dSmrg fDitherMap(NULL) 50af69d88dSmrg{ 517ec681f3Smrg fRenderer = GLRendererRoster::Roster()->GetRenderer(this, options); 52af69d88dSmrg} 53af69d88dSmrg 54af69d88dSmrg 55af69d88dSmrgBGLView::~BGLView() 56af69d88dSmrg{ 57af69d88dSmrg delete fClipInfo; 58af69d88dSmrg if (fRenderer) 59af69d88dSmrg fRenderer->Release(); 60af69d88dSmrg} 61af69d88dSmrg 62af69d88dSmrg 63af69d88dSmrgvoid 64af69d88dSmrgBGLView::LockGL() 65af69d88dSmrg{ 66af69d88dSmrg // TODO: acquire the OpenGL API lock it on this glview 67af69d88dSmrg 68af69d88dSmrg fDisplayLock.Lock(); 697ec681f3Smrg if (fRenderer != NULL && fDisplayLock.CountLocks() == 1) 70af69d88dSmrg fRenderer->LockGL(); 71af69d88dSmrg} 72af69d88dSmrg 73af69d88dSmrg 74af69d88dSmrgvoid 75af69d88dSmrgBGLView::UnlockGL() 76af69d88dSmrg{ 777ec681f3Smrg thread_id lockerThread = fDisplayLock.LockingThread(); 787ec681f3Smrg thread_id callerThread = find_thread(NULL); 797ec681f3Smrg 807ec681f3Smrg if (lockerThread != B_ERROR && lockerThread != callerThread) { 817ec681f3Smrg printf("UnlockGL is called from wrong thread, lockerThread: %d, callerThread: %d\n", 827ec681f3Smrg (int)lockerThread, (int)callerThread); 837ec681f3Smrg debugger("[!]"); 847ec681f3Smrg } 857ec681f3Smrg 867ec681f3Smrg if (fRenderer != NULL && fDisplayLock.CountLocks() == 1) 87af69d88dSmrg fRenderer->UnlockGL(); 88af69d88dSmrg fDisplayLock.Unlock(); 89af69d88dSmrg 90af69d88dSmrg // TODO: release the GL API lock to others glviews 91af69d88dSmrg} 92af69d88dSmrg 93af69d88dSmrg 94af69d88dSmrgvoid 95af69d88dSmrgBGLView::SwapBuffers() 96af69d88dSmrg{ 97af69d88dSmrg SwapBuffers(false); 98af69d88dSmrg} 99af69d88dSmrg 100af69d88dSmrg 101af69d88dSmrgvoid 102af69d88dSmrgBGLView::SwapBuffers(bool vSync) 103af69d88dSmrg{ 104af69d88dSmrg if (fRenderer) { 105af69d88dSmrg _LockDraw(); 106af69d88dSmrg fRenderer->SwapBuffers(vSync); 107af69d88dSmrg _UnlockDraw(); 108af69d88dSmrg } 109af69d88dSmrg} 110af69d88dSmrg 111af69d88dSmrg 112af69d88dSmrgBView* 113af69d88dSmrgBGLView::EmbeddedView() 114af69d88dSmrg{ 115af69d88dSmrg return NULL; 116af69d88dSmrg} 117af69d88dSmrg 118af69d88dSmrg 119af69d88dSmrgvoid* 120af69d88dSmrgBGLView::GetGLProcAddress(const char* procName) 121af69d88dSmrg{ 1227ec681f3Smrg return (void*)_glapi_get_proc_address(procName); 123af69d88dSmrg} 124af69d88dSmrg 125af69d88dSmrg 126af69d88dSmrgstatus_t 127af69d88dSmrgBGLView::CopyPixelsOut(BPoint source, BBitmap* dest) 128af69d88dSmrg{ 129af69d88dSmrg if (!fRenderer) 130af69d88dSmrg return B_ERROR; 131af69d88dSmrg 132af69d88dSmrg if (!dest || !dest->Bounds().IsValid()) 133af69d88dSmrg return B_BAD_VALUE; 134af69d88dSmrg 135af69d88dSmrg return fRenderer->CopyPixelsOut(source, dest); 136af69d88dSmrg} 137af69d88dSmrg 138af69d88dSmrg 139af69d88dSmrgstatus_t 140af69d88dSmrgBGLView::CopyPixelsIn(BBitmap* source, BPoint dest) 141af69d88dSmrg{ 142af69d88dSmrg if (!fRenderer) 143af69d88dSmrg return B_ERROR; 144af69d88dSmrg 145af69d88dSmrg if (!source || !source->Bounds().IsValid()) 146af69d88dSmrg return B_BAD_VALUE; 147af69d88dSmrg 148af69d88dSmrg return fRenderer->CopyPixelsIn(source, dest); 149af69d88dSmrg} 150af69d88dSmrg 151af69d88dSmrg 152af69d88dSmrg/*! Mesa's GLenum is not ulong but uint, so we can't use GLenum 153af69d88dSmrg without breaking this method signature. 154af69d88dSmrg Instead, we have to use the effective BeOS's SGI OpenGL GLenum type: 155af69d88dSmrg unsigned long. 156af69d88dSmrg */ 157af69d88dSmrgvoid 158af69d88dSmrgBGLView::ErrorCallback(unsigned long errorCode) 159af69d88dSmrg{ 160af69d88dSmrg char msg[32]; 161af69d88dSmrg sprintf(msg, "GL: Error code $%04lx.", errorCode); 162af69d88dSmrg // TODO: under BeOS R5, it call debugger(msg); 163af69d88dSmrg fprintf(stderr, "%s\n", msg); 164af69d88dSmrg} 165af69d88dSmrg 166af69d88dSmrg 167af69d88dSmrgvoid 168af69d88dSmrgBGLView::Draw(BRect updateRect) 169af69d88dSmrg{ 170af69d88dSmrg if (fRenderer) { 1717ec681f3Smrg if (!fClipInfo || !fClipInfo->enable_direct_mode) 1727ec681f3Smrg fRenderer->Draw(updateRect); 173af69d88dSmrg return; 174af69d88dSmrg } 175af69d88dSmrg // TODO: auto-size and center the string 176af69d88dSmrg MovePenTo(8, 32); 177af69d88dSmrg DrawString("No OpenGL renderer available!"); 178af69d88dSmrg} 179af69d88dSmrg 180af69d88dSmrg 181af69d88dSmrgvoid 182af69d88dSmrgBGLView::AttachedToWindow() 183af69d88dSmrg{ 184af69d88dSmrg BView::AttachedToWindow(); 185af69d88dSmrg 186af69d88dSmrg fBounds = Bounds(); 187af69d88dSmrg for (BView* view = this; view != NULL; view = view->Parent()) 188af69d88dSmrg view->ConvertToParent(&fBounds); 189af69d88dSmrg 190af69d88dSmrg if (fRenderer != NULL) { 191af69d88dSmrg // Jackburton: The following code was commented because it doesn't look 192af69d88dSmrg // good in "direct" mode: 193af69d88dSmrg // when the window is moved, the app_server doesn't paint the view's 194af69d88dSmrg // background, and the stuff behind the window itself shows up. 195af69d88dSmrg // Setting the view color to black, instead, looks a bit more elegant. 196af69d88dSmrg#if 0 197af69d88dSmrg // Don't paint white window background when resized 198af69d88dSmrg SetViewColor(B_TRANSPARENT_32_BIT); 199af69d88dSmrg#else 200af69d88dSmrg SetViewColor(0, 0, 0); 201af69d88dSmrg#endif 202af69d88dSmrg 203af69d88dSmrg // Set default OpenGL viewport: 204af69d88dSmrg LockGL(); 205af69d88dSmrg glViewport(0, 0, Bounds().IntegerWidth(), Bounds().IntegerHeight()); 206af69d88dSmrg UnlockGL(); 207af69d88dSmrg fRenderer->FrameResized(Bounds().IntegerWidth(), 208af69d88dSmrg Bounds().IntegerHeight()); 209af69d88dSmrg 210af69d88dSmrg if (fClipInfo) { 211af69d88dSmrg fRenderer->DirectConnected(fClipInfo->direct_info); 212af69d88dSmrg fRenderer->EnableDirectMode(fClipInfo->enable_direct_mode); 213af69d88dSmrg } 214af69d88dSmrg 215af69d88dSmrg return; 216af69d88dSmrg } 217af69d88dSmrg 218af69d88dSmrg fprintf(stderr, "no renderer found! \n"); 219af69d88dSmrg 220af69d88dSmrg // No Renderer, no rendering. Setup a minimal "No Renderer" string drawing 221af69d88dSmrg // context 222af69d88dSmrg SetFont(be_bold_font); 223af69d88dSmrg // SetFontSize(16); 224af69d88dSmrg} 225af69d88dSmrg 226af69d88dSmrg 227af69d88dSmrgvoid 228af69d88dSmrgBGLView::AllAttached() 229af69d88dSmrg{ 230af69d88dSmrg BView::AllAttached(); 231af69d88dSmrg} 232af69d88dSmrg 233af69d88dSmrg 234af69d88dSmrgvoid 235af69d88dSmrgBGLView::DetachedFromWindow() 236af69d88dSmrg{ 237af69d88dSmrg BView::DetachedFromWindow(); 238af69d88dSmrg} 239af69d88dSmrg 240af69d88dSmrg 241af69d88dSmrgvoid 242af69d88dSmrgBGLView::AllDetached() 243af69d88dSmrg{ 244af69d88dSmrg BView::AllDetached(); 245af69d88dSmrg} 246af69d88dSmrg 247af69d88dSmrg 248af69d88dSmrgvoid 249af69d88dSmrgBGLView::FrameResized(float width, float height) 250af69d88dSmrg{ 251af69d88dSmrg fBounds = Bounds(); 252af69d88dSmrg for (BView* v = this; v; v = v->Parent()) 253af69d88dSmrg v->ConvertToParent(&fBounds); 254af69d88dSmrg 255af69d88dSmrg if (fRenderer) { 2567ec681f3Smrg //_LockDraw(); 257af69d88dSmrg fRenderer->FrameResized(width, height); 2587ec681f3Smrg //_UnlockDraw(); 259af69d88dSmrg } 260af69d88dSmrg 261af69d88dSmrg BView::FrameResized(width, height); 262af69d88dSmrg} 263af69d88dSmrg 264af69d88dSmrg 265af69d88dSmrgstatus_t 266af69d88dSmrgBGLView::Perform(perform_code d, void* arg) 267af69d88dSmrg{ 268af69d88dSmrg return BView::Perform(d, arg); 269af69d88dSmrg} 270af69d88dSmrg 271af69d88dSmrg 272af69d88dSmrgstatus_t 273af69d88dSmrgBGLView::Archive(BMessage* data, bool deep) const 274af69d88dSmrg{ 275af69d88dSmrg return BView::Archive(data, deep); 276af69d88dSmrg} 277af69d88dSmrg 278af69d88dSmrg 279af69d88dSmrgvoid 280af69d88dSmrgBGLView::MessageReceived(BMessage* msg) 281af69d88dSmrg{ 282af69d88dSmrg BView::MessageReceived(msg); 283af69d88dSmrg} 284af69d88dSmrg 285af69d88dSmrg 286af69d88dSmrgvoid 287af69d88dSmrgBGLView::SetResizingMode(uint32 mode) 288af69d88dSmrg{ 289af69d88dSmrg BView::SetResizingMode(mode); 290af69d88dSmrg} 291af69d88dSmrg 292af69d88dSmrg 293af69d88dSmrgvoid 294af69d88dSmrgBGLView::GetPreferredSize(float* _width, float* _height) 295af69d88dSmrg{ 296af69d88dSmrg if (_width) 297af69d88dSmrg *_width = 0; 298af69d88dSmrg if (_height) 299af69d88dSmrg *_height = 0; 300af69d88dSmrg} 301af69d88dSmrg 302af69d88dSmrg 303af69d88dSmrgvoid 304af69d88dSmrgBGLView::Show() 305af69d88dSmrg{ 306af69d88dSmrg BView::Show(); 307af69d88dSmrg} 308af69d88dSmrg 309af69d88dSmrg 310af69d88dSmrgvoid 311af69d88dSmrgBGLView::Hide() 312af69d88dSmrg{ 313af69d88dSmrg BView::Hide(); 314af69d88dSmrg} 315af69d88dSmrg 316af69d88dSmrg 317af69d88dSmrgBHandler* 318af69d88dSmrgBGLView::ResolveSpecifier(BMessage* msg, int32 index, BMessage* specifier, 319af69d88dSmrg int32 form, const char* property) 320af69d88dSmrg{ 321af69d88dSmrg return BView::ResolveSpecifier(msg, index, specifier, form, property); 322af69d88dSmrg} 323af69d88dSmrg 324af69d88dSmrg 325af69d88dSmrgstatus_t 326af69d88dSmrgBGLView::GetSupportedSuites(BMessage* data) 327af69d88dSmrg{ 328af69d88dSmrg return BView::GetSupportedSuites(data); 329af69d88dSmrg} 330af69d88dSmrg 331af69d88dSmrg 332af69d88dSmrgvoid 333af69d88dSmrgBGLView::DirectConnected(direct_buffer_info* info) 334af69d88dSmrg{ 3357ec681f3Smrg printf("BGLView::DirectConnected\n"); 336af69d88dSmrg if (fClipInfo == NULL) { 337af69d88dSmrg fClipInfo = new (std::nothrow) glview_direct_info(); 338af69d88dSmrg if (fClipInfo == NULL) 339af69d88dSmrg return; 340af69d88dSmrg } 341af69d88dSmrg 342af69d88dSmrg direct_buffer_info* localInfo = fClipInfo->direct_info; 343af69d88dSmrg 3447ec681f3Smrg _LockDraw(); 345af69d88dSmrg switch (info->buffer_state & B_DIRECT_MODE_MASK) { 346af69d88dSmrg case B_DIRECT_START: 347af69d88dSmrg fClipInfo->direct_connected = true; 348af69d88dSmrg memcpy(localInfo, info, DIRECT_BUFFER_INFO_AREA_SIZE); 349af69d88dSmrg break; 350af69d88dSmrg 351af69d88dSmrg case B_DIRECT_MODIFY: 352af69d88dSmrg memcpy(localInfo, info, DIRECT_BUFFER_INFO_AREA_SIZE); 353af69d88dSmrg break; 354af69d88dSmrg 355af69d88dSmrg case B_DIRECT_STOP: 356af69d88dSmrg fClipInfo->direct_connected = false; 357af69d88dSmrg break; 358af69d88dSmrg } 359af69d88dSmrg 360af69d88dSmrg if (fRenderer) 361af69d88dSmrg _CallDirectConnected(); 3627ec681f3Smrg 3637ec681f3Smrg _UnlockDraw(); 364af69d88dSmrg} 365af69d88dSmrg 366af69d88dSmrg 367af69d88dSmrgvoid 368af69d88dSmrgBGLView::EnableDirectMode(bool enabled) 369af69d88dSmrg{ 3707ec681f3Smrg printf("BGLView::EnableDirectMode: %d\n", (int)enabled); 371af69d88dSmrg if (fRenderer) 372af69d88dSmrg fRenderer->EnableDirectMode(enabled); 373af69d88dSmrg if (fClipInfo == NULL) { 374af69d88dSmrg fClipInfo = new (std::nothrow) glview_direct_info(); 375af69d88dSmrg if (fClipInfo == NULL) 376af69d88dSmrg return; 377af69d88dSmrg } 378af69d88dSmrg 379af69d88dSmrg fClipInfo->enable_direct_mode = enabled; 380af69d88dSmrg} 381af69d88dSmrg 382af69d88dSmrg 383af69d88dSmrgvoid 384af69d88dSmrgBGLView::_LockDraw() 385af69d88dSmrg{ 386af69d88dSmrg if (!fClipInfo || !fClipInfo->enable_direct_mode) 387af69d88dSmrg return; 388af69d88dSmrg 389af69d88dSmrg fDrawLock.Lock(); 390af69d88dSmrg} 391af69d88dSmrg 392af69d88dSmrg 393af69d88dSmrgvoid 394af69d88dSmrgBGLView::_UnlockDraw() 395af69d88dSmrg{ 396af69d88dSmrg if (!fClipInfo || !fClipInfo->enable_direct_mode) 397af69d88dSmrg return; 398af69d88dSmrg 399af69d88dSmrg fDrawLock.Unlock(); 400af69d88dSmrg} 401af69d88dSmrg 402af69d88dSmrg 403af69d88dSmrgvoid 404af69d88dSmrgBGLView::_CallDirectConnected() 405af69d88dSmrg{ 4067ec681f3Smrg if (!fClipInfo || !fClipInfo->direct_connected) { 4077ec681f3Smrg fRenderer->DirectConnected(NULL); 408af69d88dSmrg return; 4097ec681f3Smrg } 410af69d88dSmrg 411af69d88dSmrg direct_buffer_info* localInfo = fClipInfo->direct_info; 412af69d88dSmrg direct_buffer_info* info = (direct_buffer_info*)malloc( 413af69d88dSmrg DIRECT_BUFFER_INFO_AREA_SIZE); 414af69d88dSmrg if (info == NULL) 415af69d88dSmrg return; 416af69d88dSmrg 417af69d88dSmrg memcpy(info, localInfo, DIRECT_BUFFER_INFO_AREA_SIZE); 418af69d88dSmrg 419af69d88dSmrg // Collect the rects into a BRegion, then clip to the view's bounds 420af69d88dSmrg BRegion region; 421af69d88dSmrg for (uint32 c = 0; c < localInfo->clip_list_count; c++) 422af69d88dSmrg region.Include(localInfo->clip_list[c]); 423af69d88dSmrg BRegion boundsRegion = fBounds.OffsetByCopy(localInfo->window_bounds.left, 424af69d88dSmrg localInfo->window_bounds.top); 425af69d88dSmrg info->window_bounds = boundsRegion.RectAtInt(0); 426af69d88dSmrg // window_bounds are now view bounds 427af69d88dSmrg region.IntersectWith(&boundsRegion); 428af69d88dSmrg 429af69d88dSmrg info->clip_list_count = region.CountRects(); 430af69d88dSmrg info->clip_bounds = region.FrameInt(); 431af69d88dSmrg 432af69d88dSmrg for (uint32 c = 0; c < info->clip_list_count; c++) 433af69d88dSmrg info->clip_list[c] = region.RectAtInt(c); 434af69d88dSmrg fRenderer->DirectConnected(info); 435af69d88dSmrg free(info); 436af69d88dSmrg} 437af69d88dSmrg 438af69d88dSmrg 439af69d88dSmrg//---- virtual reserved methods ---------- 440af69d88dSmrg 441af69d88dSmrg 442af69d88dSmrgvoid BGLView::_ReservedGLView1() {} 443af69d88dSmrgvoid BGLView::_ReservedGLView2() {} 444af69d88dSmrgvoid BGLView::_ReservedGLView3() {} 445af69d88dSmrgvoid BGLView::_ReservedGLView4() {} 446af69d88dSmrgvoid BGLView::_ReservedGLView5() {} 447af69d88dSmrgvoid BGLView::_ReservedGLView6() {} 448af69d88dSmrgvoid BGLView::_ReservedGLView7() {} 449af69d88dSmrgvoid BGLView::_ReservedGLView8() {} 450af69d88dSmrg 451af69d88dSmrg 452af69d88dSmrg// #pragma mark - 453af69d88dSmrg 454af69d88dSmrg 455af69d88dSmrg// BeOS compatibility: contrary to others BView's contructors, 456af69d88dSmrg// BGLView one wants a non-const name argument. 457af69d88dSmrgBGLView::BGLView(BRect rect, char* name, ulong resizingMode, ulong mode, 458af69d88dSmrg ulong options) 459af69d88dSmrg : 460af69d88dSmrg BView(rect, name, B_FOLLOW_ALL_SIDES, mode | B_WILL_DRAW | B_FRAME_EVENTS), 461af69d88dSmrg fGc(NULL), 462af69d88dSmrg fOptions(options), 463af69d88dSmrg fDitherCount(0), 464af69d88dSmrg fDrawLock("BGLView draw lock"), 465af69d88dSmrg fDisplayLock("BGLView display lock"), 466af69d88dSmrg fClipInfo(NULL), 467af69d88dSmrg fRenderer(NULL), 468af69d88dSmrg fDitherMap(NULL) 469af69d88dSmrg{ 4707ec681f3Smrg fRenderer = GLRendererRoster::Roster()->GetRenderer(this, options); 471af69d88dSmrg} 472af69d88dSmrg 473af69d88dSmrg 474af69d88dSmrg#if 0 475af69d88dSmrg// TODO: implement BGLScreen class... 476af69d88dSmrg 477af69d88dSmrg 478af69d88dSmrgBGLScreen::BGLScreen(char* name, ulong screenMode, ulong options, 479af69d88dSmrg status_t* error, bool debug) 480af69d88dSmrg : 481af69d88dSmrg BWindowScreen(name, screenMode, error, debug) 482af69d88dSmrg{ 483af69d88dSmrg} 484af69d88dSmrg 485af69d88dSmrg 486af69d88dSmrgBGLScreen::~BGLScreen() 487af69d88dSmrg{ 488af69d88dSmrg} 489af69d88dSmrg 490af69d88dSmrg 491af69d88dSmrgvoid 492af69d88dSmrgBGLScreen::LockGL() 493af69d88dSmrg{ 494af69d88dSmrg} 495af69d88dSmrg 496af69d88dSmrg 497af69d88dSmrgvoid 498af69d88dSmrgBGLScreen::UnlockGL() 499af69d88dSmrg{ 500af69d88dSmrg} 501af69d88dSmrg 502af69d88dSmrg 503af69d88dSmrgvoid 504af69d88dSmrgBGLScreen::SwapBuffers() 505af69d88dSmrg{ 506af69d88dSmrg} 507af69d88dSmrg 508af69d88dSmrg 509af69d88dSmrgvoid 510af69d88dSmrgBGLScreen::ErrorCallback(unsigned long errorCode) 511af69d88dSmrg{ 512af69d88dSmrg // Mesa's GLenum is not ulong but uint! 513af69d88dSmrg char msg[32]; 514af69d88dSmrg sprintf(msg, "GL: Error code $%04lx.", errorCode); 515af69d88dSmrg // debugger(msg); 516af69d88dSmrg fprintf(stderr, "%s\n", msg); 517af69d88dSmrg return; 518af69d88dSmrg} 519af69d88dSmrg 520af69d88dSmrg 521af69d88dSmrgvoid 522af69d88dSmrgBGLScreen::ScreenConnected(bool enabled) 523af69d88dSmrg{ 524af69d88dSmrg} 525af69d88dSmrg 526af69d88dSmrg 527af69d88dSmrgvoid 528af69d88dSmrgBGLScreen::FrameResized(float width, float height) 529af69d88dSmrg{ 530af69d88dSmrg return BWindowScreen::FrameResized(width, height); 531af69d88dSmrg} 532af69d88dSmrg 533af69d88dSmrg 534af69d88dSmrgstatus_t 535af69d88dSmrgBGLScreen::Perform(perform_code d, void* arg) 536af69d88dSmrg{ 537af69d88dSmrg return BWindowScreen::Perform(d, arg); 538af69d88dSmrg} 539af69d88dSmrg 540af69d88dSmrg 541af69d88dSmrgstatus_t 542af69d88dSmrgBGLScreen::Archive(BMessage* data, bool deep) const 543af69d88dSmrg{ 544af69d88dSmrg return BWindowScreen::Archive(data, deep); 545af69d88dSmrg} 546af69d88dSmrg 547af69d88dSmrg 548af69d88dSmrgvoid 549af69d88dSmrgBGLScreen::MessageReceived(BMessage* msg) 550af69d88dSmrg{ 551af69d88dSmrg BWindowScreen::MessageReceived(msg); 552af69d88dSmrg} 553af69d88dSmrg 554af69d88dSmrg 555af69d88dSmrgvoid 556af69d88dSmrgBGLScreen::Show() 557af69d88dSmrg{ 558af69d88dSmrg BWindowScreen::Show(); 559af69d88dSmrg} 560af69d88dSmrg 561af69d88dSmrg 562af69d88dSmrgvoid 563af69d88dSmrgBGLScreen::Hide() 564af69d88dSmrg{ 565af69d88dSmrg BWindowScreen::Hide(); 566af69d88dSmrg} 567af69d88dSmrg 568af69d88dSmrg 569af69d88dSmrgBHandler* 570af69d88dSmrgBGLScreen::ResolveSpecifier(BMessage* msg, int32 index, BMessage* specifier, 571af69d88dSmrg int32 form, const char* property) 572af69d88dSmrg{ 573af69d88dSmrg return BWindowScreen::ResolveSpecifier(msg, index, specifier, 574af69d88dSmrg form, property); 575af69d88dSmrg} 576af69d88dSmrg 577af69d88dSmrg 578af69d88dSmrgstatus_t 579af69d88dSmrgBGLScreen::GetSupportedSuites(BMessage* data) 580af69d88dSmrg{ 581af69d88dSmrg return BWindowScreen::GetSupportedSuites(data); 582af69d88dSmrg} 583af69d88dSmrg 584af69d88dSmrg 585af69d88dSmrg//---- virtual reserved methods ---------- 586af69d88dSmrg 587af69d88dSmrgvoid BGLScreen::_ReservedGLScreen1() {} 588af69d88dSmrgvoid BGLScreen::_ReservedGLScreen2() {} 589af69d88dSmrgvoid BGLScreen::_ReservedGLScreen3() {} 590af69d88dSmrgvoid BGLScreen::_ReservedGLScreen4() {} 591af69d88dSmrgvoid BGLScreen::_ReservedGLScreen5() {} 592af69d88dSmrgvoid BGLScreen::_ReservedGLScreen6() {} 593af69d88dSmrgvoid BGLScreen::_ReservedGLScreen7() {} 594af69d88dSmrgvoid BGLScreen::_ReservedGLScreen8() {} 595af69d88dSmrg#endif 596af69d88dSmrg 597af69d88dSmrg 598af69d88dSmrgconst char* color_space_name(color_space space) 599af69d88dSmrg{ 600af69d88dSmrg#define C2N(a) case a: return #a 601af69d88dSmrg 602af69d88dSmrg switch (space) { 603af69d88dSmrg C2N(B_RGB24); 604af69d88dSmrg C2N(B_RGB32); 605af69d88dSmrg C2N(B_RGBA32); 606af69d88dSmrg C2N(B_RGB32_BIG); 607af69d88dSmrg C2N(B_RGBA32_BIG); 608af69d88dSmrg C2N(B_GRAY8); 609af69d88dSmrg C2N(B_GRAY1); 610af69d88dSmrg C2N(B_RGB16); 611af69d88dSmrg C2N(B_RGB15); 612af69d88dSmrg C2N(B_RGBA15); 613af69d88dSmrg C2N(B_CMAP8); 614af69d88dSmrg default: 615af69d88dSmrg return "Unknown!"; 616af69d88dSmrg }; 617af69d88dSmrg 618af69d88dSmrg#undef C2N 619af69d88dSmrg}; 620af69d88dSmrg 621af69d88dSmrg 622af69d88dSmrgglview_direct_info::glview_direct_info() 623af69d88dSmrg{ 624af69d88dSmrg // TODO: See direct_window_data() in app_server's ServerWindow.cpp 625af69d88dSmrg direct_info = (direct_buffer_info*)calloc(1, DIRECT_BUFFER_INFO_AREA_SIZE); 626af69d88dSmrg direct_connected = false; 627af69d88dSmrg enable_direct_mode = false; 628af69d88dSmrg} 629af69d88dSmrg 630af69d88dSmrg 631af69d88dSmrgglview_direct_info::~glview_direct_info() 632af69d88dSmrg{ 633af69d88dSmrg free(direct_info); 634af69d88dSmrg} 635af69d88dSmrg 636