1 /* 2 * Copyright 2005-2008, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT license. 4 * 5 * Author: 6 * Stephan Aßmus <superstippi@gmx.de> 7 */ 8 9 10 #include "OffscreenWindow.h" 11 12 #include <new> 13 #include <stdio.h> 14 15 #include <Debug.h> 16 17 #include <WindowPrivate.h> 18 19 #include "BitmapHWInterface.h" 20 #include "DrawingEngine.h" 21 #include "ServerBitmap.h" 22 23 using std::nothrow; 24 25 26 OffscreenWindow::OffscreenWindow(ServerBitmap* bitmap, 27 const char* name, ::ServerWindow* window) 28 : Window(bitmap->Bounds(), name, 29 B_NO_BORDER_WINDOW_LOOK, kOffscreenWindowFeel, 30 0, 0, window, new (nothrow) DrawingEngine()), 31 fBitmap(bitmap), 32 fHWInterface(new (nothrow) BitmapHWInterface(fBitmap)) 33 { 34 if (!fHWInterface || !GetDrawingEngine()) 35 return; 36 37 fHWInterface->Initialize(); 38 GetDrawingEngine()->SetHWInterface(fHWInterface); 39 40 fVisibleRegion.Set(fFrame); 41 fVisibleContentRegion.Set(fFrame); 42 fVisibleContentRegionValid = true; 43 fContentRegion.Set(fFrame); 44 fContentRegionValid = true; 45 } 46 47 48 OffscreenWindow::~OffscreenWindow() 49 { 50 if (GetDrawingEngine()) 51 GetDrawingEngine()->SetHWInterface(NULL); 52 53 if (fHWInterface) { 54 fHWInterface->LockExclusiveAccess(); 55 fHWInterface->Shutdown(); 56 fHWInterface->UnlockExclusiveAccess(); 57 delete fHWInterface; 58 } 59 } 60 61