Browse Source

🔥 Mark core CL2 and CEL functions as inline hot

pull/1958/head
Gleb Mazovetskiy 5 years ago committed by Anders Jenbo
parent
commit
29a488738e
  1. 11
      Source/engine/render/cel_render.cpp
  2. 13
      Source/engine/render/cl2_render.cpp

11
Source/engine/render/cel_render.cpp

@ -13,6 +13,7 @@
#include "options.h"
#include "palette.h"
#include "scrollrt.h"
#include "utils/attributes.h"
namespace devilution {
@ -29,7 +30,7 @@ constexpr std::uint8_t GetCelTransparentWidth(std::uint8_t control)
return -static_cast<std::int8_t>(control);
}
const byte *SkipRestOfCelLine(const byte *src, std::int_fast16_t remainingWidth)
DVL_ALWAYS_INLINE DVL_ATTRIBUTE_HOT const byte *SkipRestOfCelLine(const byte *src, std::int_fast16_t remainingWidth)
{
while (remainingWidth > 0) {
const auto v = static_cast<std::int8_t>(*src++);
@ -47,7 +48,7 @@ constexpr auto NullLineEndFn = []() {};
/** Renders a CEL with only vertical clipping to the output buffer. */
template <typename RenderLine, typename LineEndFn>
void RenderCelClipY(const CelOutputBuffer &out, Point position, const byte *src, std::size_t srcSize, std::size_t srcWidth,
DVL_ALWAYS_INLINE DVL_ATTRIBUTE_HOT void RenderCelClipY(const CelOutputBuffer &out, Point position, const byte *src, std::size_t srcSize, std::size_t srcWidth,
const RenderLine &renderLine, const LineEndFn &lineEndFn)
{
const auto *srcEnd = src + srcSize;
@ -82,7 +83,8 @@ void RenderCelClipY(const CelOutputBuffer &out, Point position, const byte *src,
/** Renders a CEL with both horizontal and vertical clipping to the output buffer. */
template <typename RenderLine, typename LineEndFn>
void RenderCelClipXY(const CelOutputBuffer &out, Point position, const byte *src, std::size_t srcSize, std::size_t srcWidth, ClipX clipX,
DVL_ALWAYS_INLINE DVL_ATTRIBUTE_HOT void RenderCelClipXY( // NOLINT(readability-function-cognitive-complexity)
const CelOutputBuffer &out, Point position, const byte *src, std::size_t srcSize, std::size_t srcWidth, ClipX clipX,
const RenderLine &renderLine, const LineEndFn &lineEndFn)
{
const auto *srcEnd = src + srcSize;
@ -161,7 +163,8 @@ void RenderCelClipXY(const CelOutputBuffer &out, Point position, const byte *src
}
template <typename RenderLine, typename LineEndFn>
void RenderCel(const CelOutputBuffer &out, Point position, const byte *src, std::size_t srcSize, std::size_t srcWidth,
DVL_ALWAYS_INLINE DVL_ATTRIBUTE_HOT void RenderCel(
const CelOutputBuffer &out, Point position, const byte *src, std::size_t srcSize, std::size_t srcWidth,
const RenderLine &renderLine, const LineEndFn &lineEndFn)
{
const ClipX clipX = CalculateClipX(position.x, srcWidth, out);

13
Source/engine/render/cl2_render.cpp

@ -9,6 +9,7 @@
#include "engine/render/common_impl.h"
#include "scrollrt.h"
#include "utils/attributes.h"
namespace devilution {
namespace {
@ -48,7 +49,7 @@ struct SkipSize {
std::int_fast16_t wholeLines;
std::int_fast16_t xOffset;
};
SkipSize GetSkipSize(std::int_fast16_t overrun, std::int_fast16_t srcWidth)
DVL_ALWAYS_INLINE DVL_ATTRIBUTE_HOT SkipSize GetSkipSize(std::int_fast16_t overrun, std::int_fast16_t srcWidth)
{
SkipSize result;
result.wholeLines = overrun / srcWidth;
@ -59,7 +60,7 @@ SkipSize GetSkipSize(std::int_fast16_t overrun, std::int_fast16_t srcWidth)
// Debugging variables
// #define DEBUG_RENDER_COLOR 213 // orange-ish hue
const byte *SkipRestOfCl2Line(
DVL_ALWAYS_INLINE DVL_ATTRIBUTE_HOT const byte *SkipRestOfCl2Line(
const byte *src, std::int_fast16_t srcWidth,
std::int_fast16_t remainingWidth, SkipSize &skipSize)
{
@ -90,7 +91,8 @@ const byte *SkipRestOfCl2Line(
/** Renders a CL2 sprite with only vertical clipping to the output buffer. */
template <typename RenderPixels, typename RenderFill>
void RenderCl2ClipY(const CelOutputBuffer &out, Point position, const byte *src, std::size_t srcSize, std::size_t srcWidth,
DVL_ALWAYS_INLINE DVL_ATTRIBUTE_HOT void RenderCl2ClipY(
const CelOutputBuffer &out, Point position, const byte *src, std::size_t srcSize, std::size_t srcWidth,
const RenderPixels &renderPixels, const RenderFill &renderFill)
{
const auto *srcEnd = src + srcSize;
@ -142,7 +144,7 @@ void RenderCl2ClipY(const CelOutputBuffer &out, Point position, const byte *src,
/** Renders a CEL with both horizontal and vertical clipping to the output buffer. */
template <typename RenderPixels, typename RenderFill>
void RenderCl2ClipXY( // NOLINT(readability-function-cognitive-complexity)
DVL_ALWAYS_INLINE DVL_ATTRIBUTE_HOT void RenderCl2ClipXY( // NOLINT(readability-function-cognitive-complexity)
const CelOutputBuffer &out, Point position, const byte *src, std::size_t srcSize, std::size_t srcWidth, ClipX clipX,
const RenderPixels &renderPixels, const RenderFill &renderFill)
{
@ -245,7 +247,8 @@ void RenderCl2ClipXY( // NOLINT(readability-function-cognitive-complexity)
}
template <typename RenderPixels, typename RenderFill>
void RenderCl2(const CelOutputBuffer &out, Point position, const byte *src, std::size_t srcSize, std::size_t srcWidth,
DVL_ALWAYS_INLINE DVL_ATTRIBUTE_HOT void RenderCl2(
const CelOutputBuffer &out, Point position, const byte *src, std::size_t srcSize, std::size_t srcWidth,
const RenderPixels &renderPixels, const RenderFill &renderFill)
{
const ClipX clipX = CalculateClipX(position.x, srcWidth, out);

Loading…
Cancel
Save