1 /* 2 * Copyright 2006, 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 private: 32 void _MakeSpace(uint32 size); 33 void _Write(uint32 data); 34 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 } 69 70 dest_bytes_per_row = gInfo->shared_info->bytes_per_row; 71 dest_base = gInfo->shared_info->frame_buffer_offset; 72 raster_operation = rop; 73 } 74 }; 75 76 struct xy_source_blit_command : xy_command { 77 uint16 source_left; 78 uint16 source_top; 79 uint16 source_bytes_per_row; 80 uint16 reserved; 81 uint32 source_base; 82 83 xy_source_blit_command() 84 : xy_command(XY_COMMAND_SOURCE_BLIT, 0xcc) 85 { 86 source_bytes_per_row = dest_bytes_per_row; 87 source_base = dest_base; 88 reserved = 0; 89 } 90 }; 91 92 struct xy_color_blit_command : xy_command { 93 uint32 color; 94 95 xy_color_blit_command(bool invert) 96 : xy_command(XY_COMMAND_COLOR_BLIT, invert ? 0x55 : 0xf0) 97 { 98 } 99 }; 100 101 struct xy_setup_mono_pattern_command : xy_command { 102 uint32 background_color; 103 uint32 foreground_color; 104 uint64 pattern; 105 106 xy_setup_mono_pattern_command() 107 : xy_command(XY_COMMAND_SETUP_MONO_PATTERN, 0xf0) 108 { 109 mode |= COMMAND_MODE_SOLID_PATTERN; 110 111 // this defines the clipping window (but clipping is disabled) 112 dest_left = 0; 113 dest_top = 0; 114 dest_right = 0; 115 dest_bottom = 0; 116 } 117 }; 118 119 struct xy_scanline_blit_command : command { 120 uint16 dest_left; 121 uint16 dest_top; 122 uint16 dest_right; 123 uint16 dest_bottom; 124 125 xy_scanline_blit_command() 126 { 127 opcode = XY_COMMAND_SCANLINE_BLIT; 128 } 129 }; 130 131 #endif // COMMANDS_H 132