mirror of
https://github.com/aseprite/aseprite.git
synced 2024-10-03 21:46:20 +00:00
Improve put/get_pixel_fast() functions to avoid virtual function call
This commit is contained in:
parent
48864b440b
commit
5b8d000171
@ -37,10 +37,6 @@ namespace raster {
|
||||
address_t m_bits;
|
||||
address_t* m_rows;
|
||||
|
||||
inline address_t address(int x, int y) const {
|
||||
return (address_t)(m_rows[y] + x / (Traits::pixels_per_byte == 0 ? 1 : Traits::pixels_per_byte));
|
||||
}
|
||||
|
||||
inline address_t getBitsAddress() {
|
||||
return m_bits;
|
||||
}
|
||||
@ -60,6 +56,10 @@ namespace raster {
|
||||
}
|
||||
|
||||
public:
|
||||
inline address_t address(int x, int y) const {
|
||||
return (address_t)(m_rows[y] + x / (Traits::pixels_per_byte == 0 ? 1 : Traits::pixels_per_byte));
|
||||
}
|
||||
|
||||
ImageImpl(int width, int height,
|
||||
const ImageBufferPtr& buffer)
|
||||
: Image(static_cast<PixelFormat>(Traits::pixel_format), width, height)
|
||||
|
@ -20,6 +20,7 @@
|
||||
#define RASTER_PRIMITIVES_FAST_H_INCLUDED
|
||||
|
||||
#include "raster/color.h"
|
||||
#include "raster/image_impl.h"
|
||||
|
||||
namespace raster {
|
||||
class Image;
|
||||
@ -29,7 +30,7 @@ namespace raster {
|
||||
ASSERT(x >= 0 && x < image->getWidth());
|
||||
ASSERT(y >= 0 && y < image->getHeight());
|
||||
|
||||
return *((typename Traits::address_t)image->getPixelAddress(x, y));
|
||||
return *(((ImageImpl<Traits>*)image)->address(x, y));
|
||||
}
|
||||
|
||||
template<class Traits>
|
||||
@ -37,7 +38,7 @@ namespace raster {
|
||||
ASSERT(x >= 0 && x < image->getWidth());
|
||||
ASSERT(y >= 0 && y < image->getHeight());
|
||||
|
||||
*((typename Traits::address_t)image->getPixelAddress(x, y)) = color;
|
||||
*(((ImageImpl<Traits>*)image)->address(x, y)) = color;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user