Пример #1
0
void fill_impl( SurfaceT<T> *surface, const ColorAT<T> &color, const Area &area )
{
	// if no alpha we'll fail over the to alpha-less fill
	if( ! surface->hasAlpha() ) {
		fill_impl( surface, ColorT<T>( color.r, color.g, color.b ), area );
		return;
	}
	
	const Area clippedArea = area.getClipBy( surface->getBounds() );

	ptrdiff_t rowBytes = surface->getRowBytes();
	uint8_t pixelInc = surface->getPixelInc();
	const T red = color.r, green = color.g, blue = color.b, alpha = color.a;
	uint8_t redOffset = surface->getRedOffset(), greenOffset = surface->getGreenOffset(), blueOffset = surface->getBlueOffset(), alphaOffset = surface->getAlphaOffset();
	for( int32_t y = clippedArea.getY1(); y < clippedArea.getY2(); ++y ) {
		T *dstPtr = reinterpret_cast<T*>( reinterpret_cast<uint8_t*>( surface->getData() + clippedArea.getX1() * pixelInc ) + y * rowBytes );
		for( int32_t x = 0; x < clippedArea.getWidth(); ++x ) {
			dstPtr[redOffset] = red;
			dstPtr[greenOffset] = green;
			dstPtr[blueOffset] = blue;
			dstPtr[alphaOffset] = alpha;
			dstPtr += pixelInc;
		}
	}
}
Пример #2
0
		inline void fill_impl(vector_expression<Expr>& e, T&& t) noexcept
		{
			using type = std::remove_cv_t<T>;

			fill_impl(e, std::forward<T>(t), std::conditional_t<
				and<
				or <std::is_same<type, uint8_t>, std::is_same<type, int8_t>>,
				std::is_same<type, typename Expr::value_type>
				>::value,
				vector_fill_tag_memset, vector_fill_tag_memberwise> {}
			);
		}
Пример #3
0
void fill( SurfaceT<T> *surface, const ColorAT<Y> &color, const Area &area )
{
	ColorAT<T> nativeColor( color );
	fill_impl( surface, nativeColor, area );
}
Пример #4
0
void fill( SurfaceT<T> *surface, const ColorAT<Y> &color )
{
	ColorAT<T> nativeColor( color );
	fill_impl( surface, nativeColor, surface->getBounds() );
}