1 /* 2 * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Axel Dörfler, axeld@pinc-software.de 7 */ 8 #ifndef COMMANDS_H 9 #define COMMANDS_H 10 11 12 #include "accelerant.h" 13 14 15 struct command { 16 uint32 opcode; 17 18 uint32* Data() { return &opcode; } 19 }; 20 21 class QueueCommands { 22 public: 23 QueueCommands(ring_buffer &ring); 24 ~QueueCommands(); 25 26 void Put(struct command &command, size_t size); 27 void PutFlush(); 28 void PutWaitFor(uint32 event); 29 void PutOverlayFlip(uint32 code, bool updateCoefficients); 30 31 void MakeSpace(uint32 size); 32 void Write(uint32 data); 33 34 private: 35 ring_buffer &fRingBuffer; 36 }; 37 38 39 // commands 40 41 struct xy_command : command { 42 uint16 dest_bytes_per_row; 43 uint8 raster_operation; 44 uint8 mode; 45 uint16 dest_left; 46 uint16 dest_top; 47 uint16 dest_right; 48 uint16 dest_bottom; 49 uint32 dest_base; 50 51 xy_command(uint32 command, uint16 rop) 52 { 53 opcode = command; 54 switch (gInfo->shared_info->bits_per_pixel) { 55 case 8: 56 mode = COMMAND_MODE_CMAP8; 57 break; 58 case 15: 59 mode = COMMAND_MODE_RGB15; 60 break; 61 case 16: 62 mode = COMMAND_MODE_RGB16; 63 break; 64 case 32: 65 mode = COMMAND_MODE_RGB32; 66 opcode |= COMMAND_BLIT_RGBA; 67 break; 68 default: 69 debugger("invalid bits_per_pixel for xy_command"); 70 mode = 0; 71 break; 72 } 73 74 dest_bytes_per_row = gInfo->shared_info->bytes_per_row; 75 dest_base = gInfo->shared_info->frame_buffer_offset; 76 raster_operation = rop; 77 } 78 }; 79 80 struct xy_source_blit_command : xy_command { 81 uint16 source_left; 82 uint16 source_top; 83 uint16 source_bytes_per_row; 84 uint16 reserved; 85 uint32 source_base; 86 87 xy_source_blit_command() 88 : xy_command(XY_COMMAND_SOURCE_BLIT, 0xcc) 89 { 90 source_bytes_per_row = dest_bytes_per_row; 91 source_base = dest_base; 92 reserved = 0; 93 } 94 }; 95 96 struct xy_color_blit_command : xy_command { 97 uint32 color; 98 99 xy_color_blit_command(bool invert) 100 : xy_command(XY_COMMAND_COLOR_BLIT, invert ? 0x55 : 0xf0) 101 { 102 } 103 }; 104 105 struct xy_setup_mono_pattern_command : xy_command { 106 uint32 background_color; 107 uint32 foreground_color; 108 uint64 pattern; 109 110 xy_setup_mono_pattern_command() 111 : xy_command(XY_COMMAND_SETUP_MONO_PATTERN, 0xf0) 112 { 113 mode |= COMMAND_MODE_SOLID_PATTERN; 114 115 // this defines the clipping window (but clipping is disabled) 116 dest_left = 0; 117 dest_top = 0; 118 dest_right = 0; 119 dest_bottom = 0; 120 } 121 }; 122 123 struct xy_scanline_blit_command : command { 124 uint16 dest_left; 125 uint16 dest_top; 126 uint16 dest_right; 127 uint16 dest_bottom; 128 129 xy_scanline_blit_command() 130 { 131 opcode = XY_COMMAND_SCANLINE_BLIT; 132 } 133 }; 134 135 #endif // COMMANDS_H 136