mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
api: polish the thorvg API usages.
API Modification: - SwCanvas::Colorspace -> ColorSpace API Addition: - ColorSpace::Unknown issue: https://github.com/thorvg/thorvg/issues/1372
This commit is contained in:
parent
eb1208414d
commit
9bc900206b
17 changed files with 79 additions and 83 deletions
|
@ -295,7 +295,7 @@ struct SwWindow : Window
|
||||||
if (!surface) return;
|
if (!surface) return;
|
||||||
|
|
||||||
//Set the canvas target and draw on it.
|
//Set the canvas target and draw on it.
|
||||||
verify(canvas->target((uint32_t*)surface->pixels, surface->w, surface->pitch / 4, surface->h, tvg::SwCanvas::ARGB8888));
|
verify(canvas->target((uint32_t*)surface->pixels, surface->w, surface->pitch / 4, surface->h, tvg::ColorSpace::ARGB8888));
|
||||||
}
|
}
|
||||||
|
|
||||||
void refresh() override
|
void refresh() override
|
||||||
|
|
|
@ -107,7 +107,7 @@ void runSw()
|
||||||
auto offy = SIZE * (counter / NUM_PER_LINE);
|
auto offy = SIZE * (counter / NUM_PER_LINE);
|
||||||
auto w = surface->w - offx;
|
auto w = surface->w - offx;
|
||||||
auto h = surface->h - offy;
|
auto h = surface->h - offy;
|
||||||
tvgexam::verify(canvas->target((uint32_t*)surface->pixels + SIZE * (counter / NUM_PER_LINE) * (surface->pitch / 4) + (counter % NUM_PER_LINE) * SIZE, surface->pitch / 4, w, h, tvg::SwCanvas::ARGB8888));
|
tvgexam::verify(canvas->target((uint32_t*)surface->pixels + SIZE * (counter / NUM_PER_LINE) * (surface->pitch / 4) + (counter % NUM_PER_LINE) * SIZE, surface->pitch / 4, w, h, tvg::ColorSpace::ARGB8888));
|
||||||
content(canvas.get());
|
content(canvas.get());
|
||||||
if (tvgexam::verify(canvas->draw())) {
|
if (tvgexam::verify(canvas->draw())) {
|
||||||
tvgexam::verify(canvas->sync());
|
tvgexam::verify(canvas->sync());
|
||||||
|
|
27
inc/thorvg.h
27
inc/thorvg.h
|
@ -89,6 +89,20 @@ enum class Result
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enumeration specifying the methods of combining the 8-bit color channels into 32-bit color.
|
||||||
|
*/
|
||||||
|
enum class ColorSpace : uint8_t
|
||||||
|
{
|
||||||
|
ABGR8888 = 0, ///< The channels are joined in the order: alpha, blue, green, red. Colors are alpha-premultiplied.
|
||||||
|
ARGB8888, ///< The channels are joined in the order: alpha, red, green, blue. Colors are alpha-premultiplied.
|
||||||
|
ABGR8888S, ///< The channels are joined in the order: alpha, blue, green, red. Colors are un-alpha-premultiplied. @since 0.12
|
||||||
|
ARGB8888S, ///< The channels are joined in the order: alpha, red, green, blue. Colors are un-alpha-premultiplied. @since 0.12
|
||||||
|
Grayscale8, ///< One single channel data.
|
||||||
|
Unknown = 255 ///< Unknown channel data. This is reserved for an initial ColorSpace value. @since 1.0
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enumeration specifying the values of the path commands accepted by TVG.
|
* @brief Enumeration specifying the values of the path commands accepted by TVG.
|
||||||
*
|
*
|
||||||
|
@ -1574,17 +1588,6 @@ class TVG_API SwCanvas final : public Canvas
|
||||||
public:
|
public:
|
||||||
~SwCanvas();
|
~SwCanvas();
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enumeration specifying the methods of combining the 8-bit color channels into 32-bit color.
|
|
||||||
*/
|
|
||||||
enum Colorspace : uint8_t
|
|
||||||
{
|
|
||||||
ABGR8888 = 0, ///< The channels are joined in the order: alpha, blue, green, red. Colors are alpha-premultiplied. (a << 24 | b << 16 | g << 8 | r)
|
|
||||||
ARGB8888, ///< The channels are joined in the order: alpha, red, green, blue. Colors are alpha-premultiplied. (a << 24 | r << 16 | g << 8 | b)
|
|
||||||
ABGR8888S, ///< The channels are joined in the order: alpha, blue, green, red. Colors are un-alpha-premultiplied. @since 0.12
|
|
||||||
ARGB8888S, ///< The channels are joined in the order: alpha, red, green, blue. Colors are un-alpha-premultiplied. @since 0.12
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enumeration specifying the methods of Memory Pool behavior policy.
|
* @brief Enumeration specifying the methods of Memory Pool behavior policy.
|
||||||
* @since 0.4
|
* @since 0.4
|
||||||
|
@ -1616,7 +1619,7 @@ public:
|
||||||
* @see Canvas::viewport()
|
* @see Canvas::viewport()
|
||||||
* @see Canvas::sync()
|
* @see Canvas::sync()
|
||||||
*/
|
*/
|
||||||
Result target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h, Colorspace cs) noexcept;
|
Result target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h, ColorSpace cs) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set sw engine memory pool behavior policy.
|
* @brief Set sw engine memory pool behavior policy.
|
||||||
|
|
|
@ -437,10 +437,11 @@ typedef enum {
|
||||||
* \brief Enumeration specifying the methods of combining the 8-bit color channels into 32-bit color.
|
* \brief Enumeration specifying the methods of combining the 8-bit color channels into 32-bit color.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TVG_COLORSPACE_ABGR8888 = 0, ///< The channels are joined in the order: alpha, blue, green, red. Colors are alpha-premultiplied. (a << 24 | b << 16 | g << 8 | r)
|
TVG_COLORSPACE_ABGR8888 = 0, ///< The channels are joined in the order: alpha, blue, green, red. Colors are alpha-premultiplied.
|
||||||
TVG_COLORSPACE_ARGB8888, ///< The channels are joined in the order: alpha, red, green, blue. Colors are alpha-premultiplied. (a << 24 | r << 16 | g << 8 | b)
|
TVG_COLORSPACE_ARGB8888, ///< The channels are joined in the order: alpha, red, green, blue. Colors are alpha-premultiplied.
|
||||||
TVG_COLORSPACE_ABGR8888S, ///< The channels are joined in the order: alpha, blue, green, red. Colors are un-alpha-premultiplied. @since 0.13
|
TVG_COLORSPACE_ABGR8888S, ///< The channels are joined in the order: alpha, blue, green, red. Colors are un-alpha-premultiplied. @since 0.13
|
||||||
TVG_COLORSPACE_ARGB8888S ///< The channels are joined in the order: alpha, red, green, blue. Colors are un-alpha-premultiplied. @since 0.13
|
TVG_COLORSPACE_ARGB8888S, ///< The channels are joined in the order: alpha, red, green, blue. Colors are un-alpha-premultiplied. @since 0.13
|
||||||
|
TVG_COLORSPACE_UNKNOWN = 255, ///< Unknown channel data. This is reserved for an initial ColorSpace value. @since 1.0
|
||||||
} Tvg_Colorspace;
|
} Tvg_Colorspace;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ TVG_API Tvg_Result tvg_swcanvas_set_mempool(Tvg_Canvas* canvas, Tvg_Mempool_Poli
|
||||||
TVG_API Tvg_Result tvg_swcanvas_set_target(Tvg_Canvas* canvas, uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h, Tvg_Colorspace cs)
|
TVG_API Tvg_Result tvg_swcanvas_set_target(Tvg_Canvas* canvas, uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h, Tvg_Colorspace cs)
|
||||||
{
|
{
|
||||||
if (!canvas) return TVG_RESULT_INVALID_ARGUMENT;
|
if (!canvas) return TVG_RESULT_INVALID_ARGUMENT;
|
||||||
return (Tvg_Result) reinterpret_cast<SwCanvas*>(canvas)->target(buffer, stride, w, h, static_cast<SwCanvas::Colorspace>(cs));
|
return (Tvg_Result) reinterpret_cast<SwCanvas*>(canvas)->target(buffer, stride, w, h, static_cast<ColorSpace>(cs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ struct TvgSwEngine : TvgEngineMethod
|
||||||
{
|
{
|
||||||
free(buffer);
|
free(buffer);
|
||||||
buffer = (uint8_t*)malloc(w * h * sizeof(uint32_t));
|
buffer = (uint8_t*)malloc(w * h * sizeof(uint32_t));
|
||||||
static_cast<SwCanvas*>(canvas)->target((uint32_t *)buffer, w, w, h, SwCanvas::ABGR8888S);
|
static_cast<SwCanvas*>(canvas)->target((uint32_t *)buffer, w, w, h, ColorSpace::ABGR8888S);
|
||||||
}
|
}
|
||||||
|
|
||||||
val output(int w, int h) override
|
val output(int w, int h) override
|
||||||
|
|
|
@ -870,7 +870,7 @@ void GlRenderer::endRenderPass(RenderCompositor* cmp)
|
||||||
}
|
}
|
||||||
// image info
|
// image info
|
||||||
{
|
{
|
||||||
uint32_t info[4] = {ABGR8888, 0, cmp->opacity, 0};
|
uint32_t info[4] = {(uint32_t)ColorSpace::ABGR8888, 0, cmp->opacity, 0};
|
||||||
uint32_t loc = task->getProgram()->getUniformBlockIndex("ColorInfo");
|
uint32_t loc = task->getProgram()->getUniformBlockIndex("ColorInfo");
|
||||||
|
|
||||||
task->addBindResource(GlBindingResource{
|
task->addBindResource(GlBindingResource{
|
||||||
|
@ -1079,7 +1079,7 @@ bool GlRenderer::effect(TVG_UNUSED RenderCompositor* cmp, TVG_UNUSED const Rende
|
||||||
|
|
||||||
ColorSpace GlRenderer::colorSpace()
|
ColorSpace GlRenderer::colorSpace()
|
||||||
{
|
{
|
||||||
return ColorSpace::Unsupported;
|
return ColorSpace::Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1156,7 +1156,7 @@ bool GlRenderer::renderImage(void* data)
|
||||||
}
|
}
|
||||||
// image info
|
// image info
|
||||||
{
|
{
|
||||||
uint32_t info[4] = {sdata->texColorSpace, sdata->texFlipY, sdata->opacity, 0};
|
uint32_t info[4] = {(uint32_t)sdata->texColorSpace, sdata->texFlipY, sdata->opacity, 0};
|
||||||
uint32_t loc = task->getProgram()->getUniformBlockIndex("ColorInfo");
|
uint32_t loc = task->getProgram()->getUniformBlockIndex("ColorInfo");
|
||||||
|
|
||||||
task->addBindResource(GlBindingResource{
|
task->addBindResource(GlBindingResource{
|
||||||
|
|
|
@ -662,7 +662,7 @@ bool SwRenderer::effect(RenderCompositor* cmp, const RenderEffect* effect)
|
||||||
ColorSpace SwRenderer::colorSpace()
|
ColorSpace SwRenderer::colorSpace()
|
||||||
{
|
{
|
||||||
if (surface) return surface->cs;
|
if (surface) return surface->cs;
|
||||||
else return ColorSpace::Unsupported;
|
else return ColorSpace::Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,17 +37,6 @@ using pixel_t = uint32_t;
|
||||||
|
|
||||||
enum RenderUpdateFlag : uint8_t {None = 0, Path = 1, Color = 2, Gradient = 4, Stroke = 8, Transform = 16, Image = 32, GradientStroke = 64, Blend = 128, All = 255};
|
enum RenderUpdateFlag : uint8_t {None = 0, Path = 1, Color = 2, Gradient = 4, Stroke = 8, Transform = 16, Image = 32, GradientStroke = 64, Blend = 128, All = 255};
|
||||||
|
|
||||||
//TODO: Move this in public header unifying with SwCanvas::Colorspace
|
|
||||||
enum ColorSpace : uint8_t
|
|
||||||
{
|
|
||||||
ABGR8888 = 0, //The channels are joined in the order: alpha, blue, green, red. Colors are alpha-premultiplied.
|
|
||||||
ARGB8888, //The channels are joined in the order: alpha, red, green, blue. Colors are alpha-premultiplied.
|
|
||||||
ABGR8888S, //The channels are joined in the order: alpha, blue, green, red. Colors are un-alpha-premultiplied.
|
|
||||||
ARGB8888S, //The channels are joined in the order: alpha, red, green, blue. Colors are un-alpha-premultiplied.
|
|
||||||
Grayscale8, //One single channel data.
|
|
||||||
Unsupported //TODO: Change to the default, At the moment, we put it in the last to align with SwCanvas::Colorspace.
|
|
||||||
};
|
|
||||||
|
|
||||||
struct RenderSurface
|
struct RenderSurface
|
||||||
{
|
{
|
||||||
union {
|
union {
|
||||||
|
@ -58,7 +47,7 @@ struct RenderSurface
|
||||||
Key key; //a reserved lock for the thread safety
|
Key key; //a reserved lock for the thread safety
|
||||||
uint32_t stride = 0;
|
uint32_t stride = 0;
|
||||||
uint32_t w = 0, h = 0;
|
uint32_t w = 0, h = 0;
|
||||||
ColorSpace cs = ColorSpace::Unsupported;
|
ColorSpace cs = ColorSpace::Unknown;
|
||||||
uint8_t channelSize = 0;
|
uint8_t channelSize = 0;
|
||||||
bool premultiplied = false; //Alpha-premultiplied
|
bool premultiplied = false; //Alpha-premultiplied
|
||||||
|
|
||||||
|
@ -364,7 +353,7 @@ static inline uint8_t CHANNEL_SIZE(ColorSpace cs)
|
||||||
return sizeof(uint32_t);
|
return sizeof(uint32_t);
|
||||||
case ColorSpace::Grayscale8:
|
case ColorSpace::Grayscale8:
|
||||||
return sizeof(uint8_t);
|
return sizeof(uint8_t);
|
||||||
case ColorSpace::Unsupported:
|
case ColorSpace::Unknown:
|
||||||
default:
|
default:
|
||||||
TVGERR("RENDERER", "Unsupported Channel Size! = %d", (int)cs);
|
TVGERR("RENDERER", "Unsupported Channel Size! = %d", (int)cs);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -389,7 +378,7 @@ static inline ColorSpace COMPOSITE_TO_COLORSPACE(RenderMethod* renderer, Composi
|
||||||
return renderer->colorSpace();
|
return renderer->colorSpace();
|
||||||
default:
|
default:
|
||||||
TVGERR("RENDERER", "Unsupported Composite Size! = %d", (int)method);
|
TVGERR("RENDERER", "Unsupported Composite Size! = %d", (int)method);
|
||||||
return ColorSpace::Unsupported;
|
return ColorSpace::Unknown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,9 +79,12 @@ Result SwCanvas::mempool(MempoolPolicy policy) noexcept
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Result SwCanvas::target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h, Colorspace cs) noexcept
|
Result SwCanvas::target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h, ColorSpace cs) noexcept
|
||||||
{
|
{
|
||||||
#ifdef THORVG_SW_RASTER_SUPPORT
|
#ifdef THORVG_SW_RASTER_SUPPORT
|
||||||
|
if (cs == ColorSpace::Unknown) return Result::InvalidArguments;
|
||||||
|
if (cs == ColorSpace::Grayscale8) return Result::NonSupport;
|
||||||
|
|
||||||
if (Canvas::pImpl->status != Status::Damaged && Canvas::pImpl->status != Status::Synced) {
|
if (Canvas::pImpl->status != Status::Damaged && Canvas::pImpl->status != Status::Synced) {
|
||||||
return Result::InsufficientCondition;
|
return Result::InsufficientCondition;
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,7 +232,7 @@ bool WgRenderer::blend(BlendMethod method)
|
||||||
|
|
||||||
ColorSpace WgRenderer::colorSpace()
|
ColorSpace WgRenderer::colorSpace()
|
||||||
{
|
{
|
||||||
return ColorSpace::Unsupported;
|
return ColorSpace::Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ void GifSaver::run(unsigned tid)
|
||||||
auto h = static_cast<uint32_t>(vsize[1]);
|
auto h = static_cast<uint32_t>(vsize[1]);
|
||||||
|
|
||||||
buffer = (uint32_t*)realloc(buffer, sizeof(uint32_t) * w * h);
|
buffer = (uint32_t*)realloc(buffer, sizeof(uint32_t) * w * h);
|
||||||
canvas->target(buffer, w, w, h, tvg::SwCanvas::ABGR8888S);
|
canvas->target(buffer, w, w, h, ColorSpace::ABGR8888S);
|
||||||
canvas->push(cast(bg));
|
canvas->push(cast(bg));
|
||||||
bg = nullptr;
|
bg = nullptr;
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ TEST_CASE("Set", "[tvgAccessor]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
auto picture = Picture::gen();
|
auto picture = Picture::gen();
|
||||||
REQUIRE(picture);
|
REQUIRE(picture);
|
||||||
|
|
|
@ -76,7 +76,7 @@ TEST_CASE("Load RAW file and render", "[tvgPicture]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
auto picture = Picture::gen();
|
auto picture = Picture::gen();
|
||||||
REQUIRE(picture);
|
REQUIRE(picture);
|
||||||
|
@ -211,7 +211,7 @@ TEST_CASE("Load SVG file and render", "[tvgPicture]")
|
||||||
auto buffer = new uint32_t[1000*1000];
|
auto buffer = new uint32_t[1000*1000];
|
||||||
if (!buffer) return;
|
if (!buffer) return;
|
||||||
|
|
||||||
REQUIRE(canvas->target(buffer, 1000, 1000, 1000, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 1000, 1000, 1000, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
auto picture = Picture::gen();
|
auto picture = Picture::gen();
|
||||||
REQUIRE(picture);
|
REQUIRE(picture);
|
||||||
|
@ -281,7 +281,7 @@ TEST_CASE("Load PNG file and render", "[tvgPicture]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
auto picture = Picture::gen();
|
auto picture = Picture::gen();
|
||||||
REQUIRE(picture);
|
REQUIRE(picture);
|
||||||
|
@ -351,7 +351,7 @@ TEST_CASE("Load JPG file and render", "[tvgPicture]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
auto picture = Picture::gen();
|
auto picture = Picture::gen();
|
||||||
REQUIRE(picture);
|
REQUIRE(picture);
|
||||||
|
@ -421,7 +421,7 @@ TEST_CASE("Load TVG file and render", "[tvgPicture]")
|
||||||
auto buffer = new uint32_t[1000*1000];
|
auto buffer = new uint32_t[1000*1000];
|
||||||
if (!buffer) return;
|
if (!buffer) return;
|
||||||
|
|
||||||
REQUIRE(canvas->target(buffer, 1000, 1000, 1000, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 1000, 1000, 1000, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
auto pictureTag = Picture::gen();
|
auto pictureTag = Picture::gen();
|
||||||
REQUIRE(pictureTag);
|
REQUIRE(pictureTag);
|
||||||
|
@ -491,7 +491,7 @@ TEST_CASE("Load WEBP file and render", "[tvgPicture]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
auto picture = Picture::gen();
|
auto picture = Picture::gen();
|
||||||
REQUIRE(picture);
|
REQUIRE(picture);
|
||||||
|
|
|
@ -57,14 +57,14 @@ TEST_CASE("Target Buffer", "[tvgSwCanvas]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ARGB8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ARGB8888) == Result::Success);
|
||||||
|
|
||||||
REQUIRE(canvas->target(nullptr, 100, 100, 100, SwCanvas::Colorspace::ARGB8888) == Result::InvalidArguments);
|
REQUIRE(canvas->target(nullptr, 100, 100, 100, ColorSpace::ARGB8888) == Result::InvalidArguments);
|
||||||
REQUIRE(canvas->target(buffer, 0, 100, 100, SwCanvas::Colorspace::ARGB8888) == Result::InvalidArguments);
|
REQUIRE(canvas->target(buffer, 0, 100, 100, ColorSpace::ARGB8888) == Result::InvalidArguments);
|
||||||
REQUIRE(canvas->target(buffer, 100, 0, 100, SwCanvas::Colorspace::ARGB8888) == Result::InvalidArguments);
|
REQUIRE(canvas->target(buffer, 100, 0, 100, ColorSpace::ARGB8888) == Result::InvalidArguments);
|
||||||
REQUIRE(canvas->target(buffer, 100, 200, 100, SwCanvas::Colorspace::ARGB8888) == Result::InvalidArguments);
|
REQUIRE(canvas->target(buffer, 100, 200, 100, ColorSpace::ARGB8888) == Result::InvalidArguments);
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 0, SwCanvas::Colorspace::ARGB8888) == Result::InvalidArguments);
|
REQUIRE(canvas->target(buffer, 100, 100, 0, ColorSpace::ARGB8888) == Result::InvalidArguments);
|
||||||
|
|
||||||
REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success);
|
REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success);
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ TEST_CASE("Pushing Paints", "[tvgSwCanvas]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ARGB8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ARGB8888) == Result::Success);
|
||||||
|
|
||||||
//Try all types of paints.
|
//Try all types of paints.
|
||||||
REQUIRE(canvas->push(Shape::gen()) == Result::Success);
|
REQUIRE(canvas->push(Shape::gen()) == Result::Success);
|
||||||
|
@ -172,10 +172,10 @@ TEST_CASE("Clear", "[tvgSwCanvas]")
|
||||||
REQUIRE(canvas2->clear(false) == Result::InsufficientCondition);
|
REQUIRE(canvas2->clear(false) == Result::InsufficientCondition);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ARGB8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ARGB8888) == Result::Success);
|
||||||
|
|
||||||
uint32_t buffer2[100*100];
|
uint32_t buffer2[100*100];
|
||||||
REQUIRE(canvas2->target(buffer2, 100, 100, 100, SwCanvas::Colorspace::ARGB8888) == Result::Success);
|
REQUIRE(canvas2->target(buffer2, 100, 100, 100, ColorSpace::ARGB8888) == Result::Success);
|
||||||
|
|
||||||
//Try 1: Push -> Clear
|
//Try 1: Push -> Clear
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i < 5; ++i) {
|
||||||
|
@ -221,7 +221,7 @@ TEST_CASE("Update", "[tvgSwCanvas]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ARGB8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ARGB8888) == Result::Success);
|
||||||
|
|
||||||
REQUIRE(canvas->update() == Result::InsufficientCondition);
|
REQUIRE(canvas->update() == Result::InsufficientCondition);
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ TEST_CASE("Synchronized Drawing", "[tvgSwCanvas]")
|
||||||
REQUIRE(canvas->draw() == Result::InsufficientCondition);
|
REQUIRE(canvas->draw() == Result::InsufficientCondition);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ARGB8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ARGB8888) == Result::Success);
|
||||||
|
|
||||||
REQUIRE(canvas->draw() == Result::InsufficientCondition);
|
REQUIRE(canvas->draw() == Result::InsufficientCondition);
|
||||||
REQUIRE(canvas->sync() == Result::InsufficientCondition);
|
REQUIRE(canvas->sync() == Result::InsufficientCondition);
|
||||||
|
@ -295,7 +295,7 @@ TEST_CASE("Asynchronous Drawing", "[tvgSwCanvas]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ARGB8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ARGB8888) == Result::Success);
|
||||||
|
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
auto shape = Shape::gen();
|
auto shape = Shape::gen();
|
||||||
|
@ -322,7 +322,7 @@ TEST_CASE("Viewport", "[tvgSwCanvas]")
|
||||||
REQUIRE(canvas->viewport(25, 25, 100, 100) == Result::Success);
|
REQUIRE(canvas->viewport(25, 25, 100, 100) == Result::Success);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ARGB8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ARGB8888) == Result::Success);
|
||||||
|
|
||||||
REQUIRE(canvas->viewport(25, 25, 50, 50) == Result::Success);
|
REQUIRE(canvas->viewport(25, 25, 50, 50) == Result::Success);
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ TEST_CASE("Basic draw", "[tvgSwEngine]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100] = {0, };
|
uint32_t buffer[100*100] = {0, };
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888S) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888S) == Result::Success);
|
||||||
|
|
||||||
//Arc Line
|
//Arc Line
|
||||||
auto shape1 = tvg::Shape::gen();
|
auto shape1 = tvg::Shape::gen();
|
||||||
|
@ -100,7 +100,7 @@ TEST_CASE("Image Draw", "[tvgSwEngine]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
//raw image
|
//raw image
|
||||||
ifstream file(TEST_DIR"/rawimage_200x300.raw");
|
ifstream file(TEST_DIR"/rawimage_200x300.raw");
|
||||||
|
@ -385,7 +385,7 @@ TEST_CASE("Rect Draw", "[tvgSwEngine]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
//Basic shapes and masking
|
//Basic shapes and masking
|
||||||
auto basicShape = tvg::Shape::gen();
|
auto basicShape = tvg::Shape::gen();
|
||||||
|
@ -443,7 +443,7 @@ TEST_CASE("RLE Draw", "[tvgSwEngine]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
//Basic shapes and masking
|
//Basic shapes and masking
|
||||||
auto basicShape = tvg::Shape::gen();
|
auto basicShape = tvg::Shape::gen();
|
||||||
|
@ -501,7 +501,7 @@ TEST_CASE("Filling Draw", "[tvgSwEngine]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
//Fill
|
//Fill
|
||||||
auto linearFill = LinearGradient::gen();
|
auto linearFill = LinearGradient::gen();
|
||||||
|
@ -552,7 +552,7 @@ TEST_CASE("Filling Opaque Draw", "[tvgSwEngine]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
//Fill
|
//Fill
|
||||||
auto linearFill = LinearGradient::gen();
|
auto linearFill = LinearGradient::gen();
|
||||||
|
@ -601,7 +601,7 @@ TEST_CASE("Filling AlphaMask", "[tvgSwEngine]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
//Fill
|
//Fill
|
||||||
auto linearFill = LinearGradient::gen();
|
auto linearFill = LinearGradient::gen();
|
||||||
|
@ -660,7 +660,7 @@ TEST_CASE("Filling InvAlphaMask", "[tvgSwEngine]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
//Fill
|
//Fill
|
||||||
auto linearFill = LinearGradient::gen();
|
auto linearFill = LinearGradient::gen();
|
||||||
|
@ -719,7 +719,7 @@ TEST_CASE("Filling LumaMask", "[tvgSwEngine]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
//Fill
|
//Fill
|
||||||
auto linearFill = LinearGradient::gen();
|
auto linearFill = LinearGradient::gen();
|
||||||
|
@ -778,7 +778,7 @@ TEST_CASE("Filling Clipping", "[tvgSwEngine]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
//Fill
|
//Fill
|
||||||
auto linearFill = LinearGradient::gen();
|
auto linearFill = LinearGradient::gen();
|
||||||
|
@ -837,7 +837,7 @@ TEST_CASE("RLE Filling Draw", "[tvgSwEngine]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
//Fill
|
//Fill
|
||||||
auto linearFill = LinearGradient::gen();
|
auto linearFill = LinearGradient::gen();
|
||||||
|
@ -886,7 +886,7 @@ TEST_CASE("RLE Filling Opaque Draw", "[tvgSwEngine]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
//Fill
|
//Fill
|
||||||
auto linearFill = LinearGradient::gen();
|
auto linearFill = LinearGradient::gen();
|
||||||
|
@ -935,7 +935,7 @@ TEST_CASE("RLE Filling AlphaMask", "[tvgSwEngine]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
//Fill
|
//Fill
|
||||||
auto linearFill = LinearGradient::gen();
|
auto linearFill = LinearGradient::gen();
|
||||||
|
@ -994,7 +994,7 @@ TEST_CASE("RLE Filling InvAlphaMask", "[tvgSwEngine]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
//Fill
|
//Fill
|
||||||
auto linearFill = LinearGradient::gen();
|
auto linearFill = LinearGradient::gen();
|
||||||
|
@ -1053,7 +1053,7 @@ TEST_CASE("RLE Filling LumaMask", "[tvgSwEngine]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ARGB8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ARGB8888) == Result::Success);
|
||||||
|
|
||||||
//Fill
|
//Fill
|
||||||
auto linearFill = LinearGradient::gen();
|
auto linearFill = LinearGradient::gen();
|
||||||
|
@ -1112,7 +1112,7 @@ TEST_CASE("RLE Filling InvLumaMask", "[tvgSwEngine]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ARGB8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ARGB8888) == Result::Success);
|
||||||
|
|
||||||
//Fill
|
//Fill
|
||||||
auto linearFill = LinearGradient::gen();
|
auto linearFill = LinearGradient::gen();
|
||||||
|
@ -1171,7 +1171,7 @@ TEST_CASE("RLE Filling Clipping", "[tvgSwEngine]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
//Fill
|
//Fill
|
||||||
auto linearFill = LinearGradient::gen();
|
auto linearFill = LinearGradient::gen();
|
||||||
|
@ -1230,7 +1230,7 @@ TEST_CASE("Blending Shapes", "[tvgSwEngine]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
BlendMethod methods[14] = {
|
BlendMethod methods[14] = {
|
||||||
BlendMethod::Normal,
|
BlendMethod::Normal,
|
||||||
|
@ -1282,7 +1282,7 @@ TEST_CASE("Blending Images", "[tvgSwEngine]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
//raw image
|
//raw image
|
||||||
ifstream file(TEST_DIR"/rawimage_200x300.raw");
|
ifstream file(TEST_DIR"/rawimage_200x300.raw");
|
||||||
|
@ -1365,7 +1365,7 @@ TEST_CASE("Blending with Gradient Filling", "[tvgSwEngine]")
|
||||||
REQUIRE(canvas);
|
REQUIRE(canvas);
|
||||||
|
|
||||||
uint32_t buffer[100*100];
|
uint32_t buffer[100*100];
|
||||||
REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success);
|
REQUIRE(canvas->target(buffer, 100, 100, 100, ColorSpace::ABGR8888) == Result::Success);
|
||||||
|
|
||||||
Fill::ColorStop cs[4] = {
|
Fill::ColorStop cs[4] = {
|
||||||
{0.0f, 0, 0, 0, 0},
|
{0.0f, 0, 0, 0, 0},
|
||||||
|
|
|
@ -126,7 +126,7 @@ public:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canvas->target(buffer, w, w, h, tvg::SwCanvas::ARGB8888S) != tvg::Result::Success) {
|
if (canvas->target(buffer, w, w, h, tvg::ColorSpace::ARGB8888S) != tvg::Result::Success) {
|
||||||
cout << "Error: Canvas target failure" << endl;
|
cout << "Error: Canvas target failure" << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue