xref: /haiku/src/servers/app/OffscreenWindow.cpp (revision cfc3fa87da824bdf593eb8b817a83b6376e77935)
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 "BitmapHWInterface.h"
18 #include "DrawingEngine.h"
19 #include "ServerBitmap.h"
20 
21 using std::nothrow;
22 
23 
24 OffscreenWindow::OffscreenWindow(ServerBitmap* bitmap,
25 		const char* name, ::ServerWindow* window)
26 	: Window(bitmap->Bounds(), name,
27 			B_NO_BORDER_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
28 			0, 0, window, new (nothrow) DrawingEngine()),
29 	fBitmap(bitmap),
30 	fHWInterface(new (nothrow) BitmapHWInterface(fBitmap))
31 {
32 	if (!fHWInterface || !GetDrawingEngine())
33 		return;
34 
35 	fHWInterface->Initialize();
36 	GetDrawingEngine()->SetHWInterface(fHWInterface);
37 
38 	fVisibleRegion.Set(fFrame);
39 	fVisibleContentRegion.Set(fFrame);
40 	fVisibleContentRegionValid = true;
41 	fContentRegion.Set(fFrame);
42 	fContentRegionValid = true;
43 }
44 
45 
46 OffscreenWindow::~OffscreenWindow()
47 {
48 	if (GetDrawingEngine())
49 		GetDrawingEngine()->SetHWInterface(NULL);
50 
51 	if (fHWInterface) {
52 		fHWInterface->LockExclusiveAccess();
53 		fHWInterface->Shutdown();
54 		fHWInterface->UnlockExclusiveAccess();
55 		delete fHWInterface;
56 	}
57 }
58 
59