uint8_t Paint::opacity() const noexcept
{
return pImpl->opacity;
-}
+}
\ No newline at end of file
#include <math.h>
#include "tvgRender.h"
-
namespace tvg
{
+ enum class PaintType { Shape = 0, Scene, Picture };
+
struct StrategyMethod
{
virtual ~StrategyMethod() {}
uint8_t opacity = 255;
+ PaintType type;
+
~Impl() {
if (cmpTarget) delete(cmpTarget);
if (smethod) delete(smethod);
Picture::Picture() : pImpl(new Impl(this))
{
+ Paint::pImpl->type = PaintType::Picture;
Paint::pImpl->method(new PaintMethod<Picture::Impl>(pImpl));
}
Scene::Scene() : pImpl(new Impl())
{
+ Paint::pImpl->type = PaintType::Scene;
Paint::pImpl->method(new PaintMethod<Scene::Impl>(pImpl));
}
{
Compositor* cmp = nullptr;
+ //If scene has several children or only scene, it may require composition.
+ auto condition = false;
+ if ((paints.count > 1) || (paints.count == 1 && (*paints.data)->pImpl->type == PaintType::Scene)) {
+ condition = true;
+ }
+
//Half translucent. This condition requires intermediate composition.
- if ((opacity < 255 && opacity > 0) && (paints.count > 0)) {
+ if ((opacity < 255 && opacity > 0) && condition) {
uint32_t x, y, w, h;
if (!bounds(renderer, &x, &y, &w, &h)) return false;
cmp = renderer.target(x, y, w, h);
Shape :: Shape() : pImpl(new Impl(this))
{
+ Paint::pImpl->type = PaintType::Shape;
Paint::pImpl->method(new PaintMethod<Shape::Impl>(pImpl));
}