1 #include <DirectWindow.h> 2 3 #include "DirectWindowBuffer.h" 4 5 // constructor 6 DirectWindowBuffer::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 17 DirectWindowBuffer::~DirectWindowBuffer() 18 { 19 } 20 21 // InitCheck 22 status_t 23 DirectWindowBuffer::InitCheck() const 24 { 25 if (fBits) 26 return B_OK; 27 28 return B_NO_INIT; 29 } 30 31 // ColorSpace 32 color_space 33 DirectWindowBuffer::ColorSpace() const 34 { 35 return fFormat; 36 } 37 38 // Bits 39 void* 40 DirectWindowBuffer::Bits() const 41 { 42 return fBits; 43 } 44 45 // BytesPerRow 46 uint32 47 DirectWindowBuffer::BytesPerRow() const 48 { 49 return fBytesPerRow; 50 } 51 52 // Width 53 uint32 54 DirectWindowBuffer::Width() const 55 { 56 return fWidth; 57 } 58 59 // Height 60 uint32 61 DirectWindowBuffer::Height() const 62 { 63 return fHeight; 64 } 65 66 // Set 67 void 68 DirectWindowBuffer::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