src/blitter/base.hpp
branchnoai
changeset 9629 66dde6412125
parent 9628 b5c2449616b5
child 9723 eee46cb39750
equal deleted inserted replaced
9628:b5c2449616b5 9629:66dde6412125
    27 		int sprite_height;       ///< Real height of the sprite
    27 		int sprite_height;       ///< Real height of the sprite
    28 		int left, top;           ///< The offset in the 'dst' in pixels to start drawing
    28 		int left, top;           ///< The offset in the 'dst' in pixels to start drawing
    29 
    29 
    30 		void *dst;               ///< Destination buffer
    30 		void *dst;               ///< Destination buffer
    31 		int pitch;               ///< The pitch of the destination buffer
    31 		int pitch;               ///< The pitch of the destination buffer
       
    32 	};
       
    33 
       
    34 	enum PaletteAnimation {
       
    35 		PALETTE_ANIMATION_NONE,           ///< No palette animation
       
    36 		PALETTE_ANIMATION_VIDEO_BACKEND,  ///< Palette animation should be done by video backend (8bpp only!)
       
    37 		PALETTE_ANIMATION_BLITTER,        ///< The blitter takes care of the palette animation
    32 	};
    38 	};
    33 
    39 
    34 	typedef void *AllocatorProc(size_t size);
    40 	typedef void *AllocatorProc(size_t size);
    35 
    41 
    36 	/**
    42 	/**
    92 	 * Make a single horizontal line in a single color on the video-buffer.
    98 	 * Make a single horizontal line in a single color on the video-buffer.
    93 	 * @param video The destination pointer (video-buffer).
    99 	 * @param video The destination pointer (video-buffer).
    94 	 * @param width The lenght of the line.
   100 	 * @param width The lenght of the line.
    95 	 * @param color A 8bpp mapping color.
   101 	 * @param color A 8bpp mapping color.
    96 	 */
   102 	 */
    97 	virtual void SetHorizontalLine(void *video, int width, uint8 color) = 0;
   103 	virtual void DrawRect(void *video, int width, int height, uint8 color) = 0;
       
   104 
       
   105 	/**
       
   106 	 * Draw a line with a given color.
       
   107 	 * @param video The destination pointer (video-buffer).
       
   108 	 * @param x The x coordinate from where the line starts.
       
   109 	 * @param y The y coordinate from where the line starts.
       
   110 	 * @param x2 The x coordinate to where the line goes.
       
   111 	 * @param y2 The y coordinate to where the lines goes.
       
   112 	 * @param screen_width The width of the screen you are drawing in (to avoid buffer-overflows).
       
   113 	 * @param screen_height The height of the screen you are drawing in (to avoid buffer-overflows).
       
   114 	 * @param color A 8bpp mapping color.
       
   115 	 */
       
   116 	virtual void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 color) = 0;
    98 
   117 
    99 	/**
   118 	/**
   100 	 * Copy from a buffer to the screen.
   119 	 * Copy from a buffer to the screen.
   101 	 * @param video The destionation pointer (video-buffer).
   120 	 * @param video The destionation pointer (video-buffer).
   102 	 * @param src The buffer from which the data will be read.
   121 	 * @param src The buffer from which the data will be read.
   103 	 * @param width The width of the buffer.
   122 	 * @param width The width of the buffer.
   104 	 * @param height The height of the buffer.
   123 	 * @param height The height of the buffer.
   105 	 * @param src_pitch The pitch (byte per line) of the source buffer.
   124 	 * @note You can not do anything with the content of the buffer, as the blitter can store non-pixel data in it too!
   106 	 */
   125 	 */
   107 	virtual void CopyFromBuffer(void *video, const void *src, int width, int height, int src_pitch) = 0;
   126 	virtual void CopyFromBuffer(void *video, const void *src, int width, int height) = 0;
   108 
   127 
   109 	/**
   128 	/**
   110 	 * Copy from the screen to a buffer.
   129 	 * Copy from the screen to a buffer.
   111 	 * @param video The destination pointer (video-buffer).
   130 	 * @param video The destination pointer (video-buffer).
   112 	 * @param dst The buffer in which the data will be stored.
   131 	 * @param dst The buffer in which the data will be stored.
   113 	 * @param width The width of the buffer.
   132 	 * @param width The width of the buffer.
   114 	 * @param height The height of the buffer.
   133 	 * @param height The height of the buffer.
       
   134 	 * @note You can not do anything with the content of the buffer, as the blitter can store non-pixel data in it too!
       
   135 	 */
       
   136 	virtual void CopyToBuffer(const void *video, void *dst, int width, int height) = 0;
       
   137 
       
   138 	/**
       
   139 	 * Copy from the screen to a buffer in a palette format for 8bpp and RGBA format for 32bpp.
       
   140 	 * @param video The destination pointer (video-buffer).
       
   141 	 * @param dst The buffer in which the data will be stored.
       
   142 	 * @param width The width of the buffer.
       
   143 	 * @param height The height of the buffer.
   115 	 * @param dst_pitch The pitch (byte per line) of the destination buffer.
   144 	 * @param dst_pitch The pitch (byte per line) of the destination buffer.
   116 	 */
   145 	 */
   117 	virtual void CopyToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) = 0;
   146 	virtual void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) = 0;
   118 
   147 
   119 	/**
   148 	/**
   120 	 * Move the videobuffer some places (via memmove).
   149 	 * Scroll the videobuffer some 'x' and 'y' value.
   121 	 * @param video_dst The destination pointer (video-buffer).
   150 	 * @param video The buffer to scroll into.
   122 	 * @param video_src The source pointer (video-buffer).
   151 	 * @param left The left value of the screen to scroll.
   123 	 * @param width The width of the buffer to move.
   152 	 * @param top The top value of the screen to scroll.
   124 	 * @param height The height of the buffer to move.
   153 	 * @param width The width of the screen to scroll.
       
   154 	 * @param height The height of the screen to scroll.
       
   155 	 * @param scroll_x How much to scroll in X.
       
   156 	 * @param scroll_y How much to scroll in Y.
   125 	 */
   157 	 */
   126 	virtual void MoveBuffer(void *video_dst, const void *video_src, int width, int height) = 0;
   158 	virtual void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) = 0;
   127 
   159 
   128 	/**
   160 	/**
   129 	 * Calculate how much memory there is needed for an image of this size in the video-buffer.
   161 	 * Calculate how much memory there is needed for an image of this size in the video-buffer.
   130 	 * @param width The width of the buffer-to-be.
   162 	 * @param width The width of the buffer-to-be.
   131 	 * @param height The height of the buffer-to-be.
   163 	 * @param height The height of the buffer-to-be.
   132 	 * @return The size needed for the buffer.
   164 	 * @return The size needed for the buffer.
   133 	 */
   165 	 */
   134 	virtual int BufferSize(int width, int height) = 0;
   166 	virtual int BufferSize(int width, int height) = 0;
   135 
   167 
       
   168 	/**
       
   169 	 * Called when the 8bpp palette is changed; you should redraw all pixels on the screen that
       
   170 	 *  are equal to the 8bpp palette indexes 'start' to 'start + count'.
       
   171 	 * @param start The start index in the 8bpp palette.
       
   172 	 * @param count The amount of indexes that are (possible) changed.
       
   173 	 */
       
   174 	virtual void PaletteAnimate(uint start, uint count) = 0;
       
   175 
       
   176 	/**
       
   177 	 * Check if the blitter uses palette animation at all.
       
   178 	 * @return True if it uses palette animation.
       
   179 	 */
       
   180 	virtual Blitter::PaletteAnimation UsePaletteAnimation() = 0;
       
   181 
       
   182 	/**
       
   183 	 * Get the naem of the blitter, the same as the Factory-instance returns.
       
   184 	 */
       
   185 	virtual const char *GetName() = 0;
       
   186 
   136 	virtual ~Blitter() { }
   187 	virtual ~Blitter() { }
   137 };
   188 };
   138 
   189 
   139 #endif /* BLITTER_BASE_HPP */
   190 #endif /* BLITTER_BASE_HPP */