common engine: code refactoring

Unify renderImage and renderImageMesh and hide their routines in backends.
This commit is contained in:
Hermet Park 2023-04-26 16:26:02 +09:00
parent 65116b87ad
commit 6d08586883
8 changed files with 10 additions and 44 deletions

View file

@ -132,12 +132,7 @@ int32_t GlRenderer::colorSpace()
bool GlRenderer::renderImage(TVG_UNUSED void* data)
{
return false;
}
bool GlRenderer::renderImageMesh(TVG_UNUSED void* data)
{
//TODO: render requested images
return false;
}

View file

@ -36,7 +36,6 @@ public:
bool preRender() override;
bool renderShape(RenderData data) override;
bool renderImage(RenderData data) override;
bool renderImageMesh(RenderData data) override;
bool postRender() override;
bool dispose(RenderData data) override;;
RenderRegion region(RenderData data) override;

View file

@ -353,8 +353,7 @@ void mpoolRetStrokeOutline(SwMpool* mpool, unsigned idx);
bool rasterCompositor(SwSurface* surface);
bool rasterGradientShape(SwSurface* surface, SwShape* shape, unsigned id);
bool rasterShape(SwSurface* surface, SwShape* shape, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
bool rasterImage(SwSurface* surface, SwImage* image, const Matrix* transform, const SwBBox& bbox, uint32_t opacity);
bool rasterImageMesh(SwSurface* surface, SwImage* image, const Polygon* triangles, const uint32_t triangleCount, const Matrix* transform, const SwBBox& bbox, uint32_t opacity);
bool rasterImage(SwSurface* surface, SwImage* image, const Polygon* triangles, uint32_t triangleCount, const Matrix* transform, const SwBBox& bbox, uint32_t opacity);
bool rasterStroke(SwSurface* surface, SwShape* shape, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
bool rasterGradientStroke(SwSurface* surface, SwShape* shape, unsigned id);
bool rasterClear(SwSurface* surface);

View file

@ -1561,19 +1561,7 @@ bool rasterStroke(SwSurface* surface, SwShape* shape, uint8_t r, uint8_t g, uint
}
bool rasterImage(SwSurface* surface, SwImage* image, const Matrix* transform, const SwBBox& bbox, uint32_t opacity)
{
//Verify Boundary
if (bbox.max.x < 0 || bbox.max.y < 0 || bbox.min.x >= static_cast<SwCoord>(surface->w) || bbox.min.y >= static_cast<SwCoord>(surface->h)) return false;
//TOOD: switch (image->format)
//TODO: case: _rasterRGBImage()
//TODO: case: _rasterGrayscaleImage()
//TODO: case: _rasterAlphaImage()
return _rasterRGBAImage(surface, image, transform, bbox, opacity);
}
bool rasterImageMesh(SwSurface* surface, SwImage* image, const Polygon* triangles, const uint32_t count, const Matrix* transform, const SwBBox& bbox, uint32_t opacity)
bool rasterImage(SwSurface* surface, SwImage* image, const Polygon* triangles, uint32_t triangleCnt, const Matrix* transform, const SwBBox& bbox, uint32_t opacity)
{
//Verify Boundary
if (bbox.max.x < 0 || bbox.max.y < 0 || bbox.min.x >= static_cast<SwCoord>(surface->w) || bbox.min.y >= static_cast<SwCoord>(surface->h)) return false;
@ -1582,5 +1570,6 @@ bool rasterImageMesh(SwSurface* surface, SwImage* image, const Polygon* triangle
//TODO: case: _rasterRGBImageMesh()
//TODO: case: _rasterGrayscaleImageMesh()
//TODO: case: _rasterAlphaImageMesh()
return _transformedRGBAImageMesh(surface, image, triangles, count, transform, &bbox, opacity);
if (triangles) return _transformedRGBAImageMesh(surface, image, triangles, triangleCnt, transform, &bbox, opacity);
else return _rasterRGBAImage(surface, image, transform, bbox, opacity);
}

View file

@ -258,8 +258,8 @@ struct SwSceneTask : SwTask
struct SwImageTask : SwTask
{
SwImage image;
Polygon* triangles;
uint32_t triangleCnt;
Polygon* triangles = nullptr;
uint32_t triangleCnt = 0;
bool clip(SwRleData* target) override
{
@ -469,18 +469,7 @@ bool SwRenderer::renderImage(RenderData data)
if (task->opacity == 0) return true;
return rasterImage(surface, &task->image, task->transform, task->bbox, task->opacity);
}
bool SwRenderer::renderImageMesh(RenderData data)
{
auto task = static_cast<SwImageTask*>(data);
task->done();
if (task->opacity == 0) return true;
return rasterImageMesh(surface, &task->image, task->triangles, task->triangleCnt, task->transform, task->bbox, task->opacity);
return rasterImage(surface, &task->image, task->triangles, task->triangleCnt, task->transform, task->bbox, task->opacity);
}
@ -662,7 +651,7 @@ bool SwRenderer::endComposite(Compositor* cmp)
//Default is alpha blending
if (p->method == CompositeMethod::None) {
return rasterImage(surface, &p->image, nullptr, p->bbox, p->opacity);
return rasterImage(surface, &p->image, nullptr, 0, nullptr, p->bbox, p->opacity);
}
return true;

View file

@ -42,7 +42,6 @@ public:
bool preRender() override;
bool renderShape(RenderData data) override;
bool renderImage(RenderData data) override;
bool renderImageMesh(RenderData data) override;
bool postRender() override;
bool dispose(RenderData data) override;
RenderRegion region(RenderData data) override;

View file

@ -149,10 +149,7 @@ struct Picture::Impl
bool render(RenderMethod &renderer)
{
if (surface) {
if (triangles) return renderer.renderImageMesh(rd);
else return renderer.renderImage(rd);
}
if (surface) return renderer.renderImage(rd);
else if (paint) return paint->pImpl->render(renderer);
return false;
}

View file

@ -192,7 +192,6 @@ public:
virtual bool preRender() = 0;
virtual bool renderShape(RenderData data) = 0;
virtual bool renderImage(RenderData data) = 0;
virtual bool renderImageMesh(RenderData data) = 0;
virtual bool postRender() = 0;
virtual bool dispose(RenderData data) = 0;
virtual RenderRegion region(RenderData data) = 0;