1#include <DirectWindow.h>
2
3#include "DirectWindowBuffer.h"
4
5// constructor
6DirectWindowBuffer::DirectWindowBuffer()
7	: fBits(NULL),
8	  fWidth(0),
9	  fHeight(0),
10	  fBytesPerRow(0),
11	  fFormat(B_NO_COLOR_SPACE),
12	  fWindowClipping()
13{
14}
15
16// destructor
17DirectWindowBuffer::~DirectWindowBuffer()
18{
19}
20
21// InitCheck
22status_t
23DirectWindowBuffer::InitCheck() const
24{
25	if (fBits)
26		return B_OK;
27
28	return B_NO_INIT;
29}
30
31// ColorSpace
32color_space
33DirectWindowBuffer::ColorSpace() const
34{
35	return fFormat;
36}
37
38// Bits
39void*
40DirectWindowBuffer::Bits() const
41{
42	return fBits;
43}
44
45// BytesPerRow
46uint32
47DirectWindowBuffer::BytesPerRow() const
48{
49	return fBytesPerRow;
50}
51
52// Width
53uint32
54DirectWindowBuffer::Width() const
55{
56	return fWidth;
57}
58
59// Height
60uint32
61DirectWindowBuffer::Height() const
62{
63	return fHeight;
64}
65
66// Set
67void
68DirectWindowBuffer::SetTo(direct_buffer_info* info)
69{
70	fWindowClipping.MakeEmpty();
71
72	if (info) {
73		int32 xOffset = info->window_bounds.left;
74		int32 yOffset = info->window_bounds.top;
75		// Get clipping information
76		for (int32 i = 0; i < info->clip_list_count; i++) {
77			fWindowClipping.Include(info->clip_list[i]);
78		}
79		fBytesPerRow = info->bytes_per_row;
80		fBits = (void*)info->bits;
81		fFormat = info->pixel_format;
82	//	fBounds = info->window_bounds;
83	//	fDirty = true;
84		fWidth = info->window_bounds.right - info->window_bounds.left + 1;
85		fHeight = info->window_bounds.bottom - info->window_bounds.top + 1;
86	} else {
87		fBits = NULL;
88		fWidth = 0;
89		fHeight = 0;
90		fBytesPerRow = 0;
91		fFormat = B_NO_COLOR_SPACE;
92	}
93}
94
95