common: retyped the color value size_t -> uint8_t

since it's range is 0 - 255.

Change-Id: I16e0569341c4a94acab9488d076f235bf90ff4db
This commit is contained in:
Hermet Park 2020-06-04 17:49:10 +09:00
parent 98edb4112b
commit dc5f9f7430
4 changed files with 13 additions and 13 deletions

View file

@ -142,13 +142,13 @@ public:
//Stroke
int stroke(float width) noexcept;
int stroke(size_t r, size_t g, size_t b, size_t a) noexcept;
int stroke(uint8_t r, uint8_t g, uint8_t b, uint8_t a) noexcept;
int stroke(const size_t* dashPattern, size_t cnt) noexcept;
int stroke(StrokeCap cap) noexcept;
int stroke(StrokeJoin join) noexcept;
//Fill
int fill(size_t r, size_t g, size_t b, size_t a) noexcept;
int fill(uint8_t r, uint8_t g, uint8_t b, uint8_t a) noexcept;
//Transform
int rotate(float degree) noexcept override;
@ -158,11 +158,11 @@ public:
//Getters
size_t pathCommands(const PathCommand** cmds) const noexcept;
size_t pathCoords(const Point** pts) const noexcept;
int fill(size_t* r, size_t* g, size_t* b, size_t* a) const noexcept;
int fill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) const noexcept;
int bounds(float* x, float* y, float* w, float* h) const noexcept override;
float strokeWidth() const noexcept;
int strokeColor(size_t* r, size_t* g, size_t* b, size_t* a) const noexcept;
int strokeColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) const noexcept;
size_t strokeDash(const size_t** dashPattern) const noexcept;
StrokeCap strokeCap() const noexcept;
StrokeJoin strokeJoin() const noexcept;

View file

@ -62,7 +62,7 @@ bool SwRenderer::render(const Shape& shape, void *data)
SwShape* sdata = static_cast<SwShape*>(data);
if (!sdata) return false;
size_t r, g, b, a;
uint8_t r, g, b, a;
shape.fill(&r, &g, &b, &a);
if (a > 0) rasterShape(surface, *sdata, r, g, b, a);
@ -100,7 +100,7 @@ void* SwRenderer::prepare(const Shape& shape, void* data, const RenderTransform*
//Shape
if (flags & (RenderUpdateFlag::Path | RenderUpdateFlag::Transform)) {
size_t alpha = 0;
uint8_t alpha = 0;
shape.fill(nullptr, nullptr, nullptr, &alpha);
if (alpha > 0) {
@ -116,7 +116,7 @@ void* SwRenderer::prepare(const Shape& shape, void* data, const RenderTransform*
if (shape.strokeWidth() > 0.5) {
shapeResetStroke(shape, *sdata);
size_t alpha = 0;
uint8_t alpha = 0;
shape.strokeColor(nullptr, nullptr, nullptr, &alpha);
if (alpha > 0) {
if (!shapeGenStrokeRle(shape, *sdata, clip)) return sdata;

View file

@ -213,7 +213,7 @@ int Shape::appendRect(float x, float y, float w, float h, float cornerRadius) no
}
int Shape::fill(size_t r, size_t g, size_t b, size_t a) noexcept
int Shape::fill(uint8_t r, uint8_t g, uint8_t b, uint8_t a) noexcept
{
auto impl = pImpl.get();
assert(impl);
@ -228,7 +228,7 @@ int Shape::fill(size_t r, size_t g, size_t b, size_t a) noexcept
}
int Shape::fill(size_t* r, size_t* g, size_t* b, size_t* a) const noexcept
int Shape::fill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) const noexcept
{
auto impl = pImpl.get();
assert(impl);
@ -301,7 +301,7 @@ float Shape::strokeWidth() const noexcept
}
int Shape::stroke(size_t r, size_t g, size_t b, size_t a) noexcept
int Shape::stroke(uint8_t r, uint8_t g, uint8_t b, uint8_t a) noexcept
{
auto impl = pImpl.get();
assert(impl);
@ -312,7 +312,7 @@ int Shape::stroke(size_t r, size_t g, size_t b, size_t a) noexcept
}
int Shape::strokeColor(size_t* r, size_t* g, size_t* b, size_t* a) const noexcept
int Shape::strokeColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) const noexcept
{
auto impl = pImpl.get();
assert(impl);

View file

@ -31,7 +31,7 @@ struct ShapeFill
struct ShapeStroke
{
float width = 0;
size_t color[4] = {0, 0, 0, 0};
uint8_t color[4] = {0, 0, 0, 0};
size_t* dashPattern = nullptr;
size_t dashCnt = 0;
StrokeCap cap = StrokeCap::Square;
@ -188,7 +188,7 @@ struct Shape::Impl
return 0;
}
bool strokeColor(size_t r, size_t g, size_t b, size_t a)
bool strokeColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
{
if (!stroke) stroke = new ShapeStroke();
assert(stroke);