changed just internal variable & method names.
no logical changes.
Change-Id: I01782ec59dec3ff2232e03de7b3863100d9cc27f
if (!renderer->clear()) return Result::InsufficientCondition;
for (auto paint : paints) {
- paint->IMPL->method->dispose(*renderer);
+ paint->IMPL->method()->dispose(*renderer);
delete(paint);
}
paints.clear();
//Update single paint node
if (paint) {
- if (!paint->IMPL->method->update(*renderer, nullptr, RenderUpdateFlag::None)) {
+ if (!paint->IMPL->method()->update(*renderer, nullptr, RenderUpdateFlag::None)) {
return Result::InsufficientCondition;
}
//Update retained all paint nodes
} else {
for(auto paint: paints) {
- if (!paint->IMPL->method->update(*renderer, nullptr, RenderUpdateFlag::None)) {
+ if (!paint->IMPL->method()->update(*renderer, nullptr, RenderUpdateFlag::None)) {
return Result::InsufficientCondition;
}
}
if (!renderer->preRender()) return Result::InsufficientCondition;
for(auto paint: paints) {
- if(!paint->IMPL->method->render(*renderer)) return Result::InsufficientCondition;
+ if(!paint->IMPL->method()->render(*renderer)) return Result::InsufficientCondition;
}
if (!renderer->postRender()) return Result::InsufficientCondition;
Result Paint::rotate(float degree) noexcept
{
- if (IMPL->method->rotate(degree)) return Result::Success;
+ if (IMPL->method()->rotate(degree)) return Result::Success;
return Result::FailedAllocation;
}
Result Paint::scale(float factor) noexcept
{
- if (IMPL->method->scale(factor)) return Result::Success;
+ if (IMPL->method()->scale(factor)) return Result::Success;
return Result::FailedAllocation;
}
Result Paint::translate(float x, float y) noexcept
{
- if (IMPL->method->translate(x, y)) return Result::Success;
+ if (IMPL->method()->translate(x, y)) return Result::Success;
return Result::FailedAllocation;
}
Result Paint::transform(const Matrix& m) noexcept
{
- if (IMPL->method->transform(m)) return Result::Success;
+ if (IMPL->method()->transform(m)) return Result::Success;
return Result::FailedAllocation;
}
Result Paint::bounds(float* x, float* y, float* w, float* h) const noexcept
{
- if (IMPL->method->bounds(x, y, w, h)) return Result::Success;
+ if (IMPL->method()->bounds(x, y, w, h)) return Result::Success;
return Result::InsufficientCondition;
}
namespace tvg
{
- struct PaintMethod
+ struct StrategyMethod
{
- virtual ~PaintMethod(){}
+ virtual ~StrategyMethod(){}
virtual bool dispose(RenderMethod& renderer) = 0;
virtual bool update(RenderMethod& renderer, const RenderTransform* pTransform, uint32_t pFlag) = 0;
struct Paint::Impl
{
- PaintMethod* method = nullptr;
+ StrategyMethod* smethod = nullptr;
~Impl() {
- if (method) delete(method);
+ if (smethod) delete(smethod);
+ }
+
+ void method(StrategyMethod* method)
+ {
+ smethod = method;
+ }
+
+ StrategyMethod* method()
+ {
+ return smethod;
}
};
template<class T>
- struct TransformMethod : PaintMethod
+ struct PaintMethod : StrategyMethod
{
T* inst = nullptr;
- TransformMethod(T* inst) : inst(_inst) {}
- ~TransformMethod(){}
+ PaintMethod(T* _inst) : inst(_inst) {}
+ ~PaintMethod(){}
bool rotate(float degree) override
{
Scene::Scene() : pImpl(make_unique<Impl>())
{
- Paint::IMPL->method = IMPL->transformMethod();
+ Paint::IMPL->method(new PaintMethod<Scene::Impl>(IMPL));
}
bool dispose(RenderMethod& renderer)
{
for (auto paint : paints) {
- paint->IMPL->method->dispose(renderer);
+ paint->IMPL->method()->dispose(renderer);
delete(paint);
}
paints.clear();
bool updateInternal(RenderMethod &renderer, const RenderTransform* transform, uint32_t flag)
{
for(auto paint: paints) {
- if (!paint->IMPL->method->update(renderer, transform, flag)) return false;
+ if (!paint->IMPL->method()->update(renderer, transform, flag)) return false;
}
return true;
}
bool render(RenderMethod &renderer)
{
for(auto paint: paints) {
- if(!paint->IMPL->method->render(renderer)) return false;
+ if(!paint->IMPL->method()->render(renderer)) return false;
}
return true;
}
auto w2 = 0.0f;
auto h2 = 0.0f;
- if (paint->IMPL->method->bounds(&x2, &y2, &w2, &h2)) return false;
+ if (paint->IMPL->method()->bounds(&x2, &y2, &w2, &h2)) return false;
//Merge regions
if (x2 < x) x = x2;
if (!loader->read()) return Result::Unknown;
return Result::Success;
}
-
- PaintMethod* transformMethod()
- {
- return new TransformMethod<Scene::Impl>(this);
- }
-
};
#endif //_TVG_SCENE_IMPL_H_
\ No newline at end of file
Shape :: Shape() : pImpl(make_unique<Impl>(this))
{
- Paint::IMPL->method = IMPL->transformMethod();
+ Paint::IMPL->method(new PaintMethod<Shape::Impl>(IMPL));
}
return true;
}
-
-
- PaintMethod* transformMethod()
- {
- return new TransformMethod<Shape::Impl>(this);
- }
};
#endif //_TVG_SHAPE_IMPL_H_
\ No newline at end of file