OpenToonz - An open-source full-featured 2D animation creation software
C
fix vector aliased line
shun-iwasawa288b973c1e63
diff --git a/toonz/sources/common/tvrender/tsimplecolorstyles.cpp b/toonz/sources/common/tvrender/tsimplecolorstyles.cppindex 7b745d41c..349a8bfb7 100644--- a/toonz/sources/common/tvrender/tsimplecolorstyles.cpp+++ b/toonz/sources/common/tvrender/tsimplecolorstyles.cpp@@ -311,6 +311,21 @@ void drawAntialiasedOutline(const std::vector<TOutlinePoint> &_v,outline.finish();}+void drawAliasedOutline(const std::vector<TOutlinePoint> &_v,+ const TStroke *stroke) {+ static const int stride = 2 * sizeof(TOutlinePoint);++ glEnableClientState(GL_VERTEX_ARRAY);++ glVertexPointer(2, GL_DOUBLE, stride, &_v[0]);+ glDrawArrays(GL_LINE_STRIP, 0, _v.size() / 2);++ glVertexPointer(2, GL_DOUBLE, stride, &_v[1]);+ glDrawArrays(GL_LINE_STRIP, 0, _v.size() / 2);++ glDisableClientState(GL_VERTEX_ARRAY);+}+} // namespace//*************************************************************************************@@ -609,9 +624,10 @@ void TSolidColorStyle::drawRegion(const TColorFunction *cf,//=============================================================================-void TSolidColorStyle::drawStroke(const TColorFunction *cf,- TStrokeOutline *outline,- const TStroke *stroke) const {+void TSolidColorStyle::doDrawStroke(const TColorFunction *cf,+ TStrokeOutline *outline,+ const TStroke *stroke,+ bool antialias) const {struct locals {static inline void fillOutlinedStroke(const std::vector<TOutlinePoint> &v) {static const int stride = sizeof(TOutlinePoint);@@ -655,12 +671,20 @@ stencil->endMask();locals::fillOutlinedStroke(v);stencil->endMask();stencil->enableMask(TStencilControl::SHOW_OUTSIDE);- drawAntialiasedOutline(v, stroke);++ if (antialias)+ drawAntialiasedOutline(v, stroke);+ else+ drawAliasedOutline(v, stroke);+stencil->disableMask();} else {// outline with antialiasing- drawAntialiasedOutline(v, stroke);+ if (antialias)+ drawAntialiasedOutline(v, stroke);+ else+ drawAliasedOutline(v, stroke);// center linelocals::fillOutlinedStroke(v);diff --git a/toonz/sources/common/tvrender/tstrokeprop.cpp b/toonz/sources/common/tvrender/tstrokeprop.cppindex 518df3e63..33efcc9b4 100644--- a/toonz/sources/common/tvrender/tstrokeprop.cpp+++ b/toonz/sources/common/tvrender/tstrokeprop.cpp@@ -247,7 +247,10 @@ void OutlineStrokeProp::draw(const TVectorRenderData &rd) {m_styleVersionNumber = m_colorStyle->getVersionNumber();}- m_colorStyle->drawStroke(rd.m_cf, &m_outline, m_stroke);+ if (rd.m_antiAliasing)+ m_colorStyle->drawStroke(rd.m_cf, &m_outline, m_stroke);+ else+ m_colorStyle->drawAliasedStroke(rd.m_cf, &m_outline, m_stroke);}glPopMatrix();diff --git a/toonz/sources/include/tsimplecolorstyles.h b/toonz/sources/include/tsimplecolorstyles.hindex f28ebfc44..a337f10ef 100644--- a/toonz/sources/include/tsimplecolorstyles.h+++ b/toonz/sources/include/tsimplecolorstyles.h@@ -118,6 +118,12 @@ public:virtual void drawStroke(const TColorFunction *cf, TStrokeOutline *outline,const TStroke *stroke) const = 0;+ // draw aliased stroke. currently reimplemented by TSolidColorStyle only+ virtual void drawAliasedStroke(const TColorFunction *cf,+ TStrokeOutline *outline,+ const TStroke *stroke) const {+ drawStroke(cf, outline, stroke);+ };protected:// Not assignable@@ -158,8 +164,17 @@ public:void drawRegion(const TColorFunction *cf, const bool antiAliasing,TRegionOutline &outline) const override;+ void doDrawStroke(const TColorFunction *cf, TStrokeOutline *outline,+ const TStroke *s, bool antialias) const;+void drawStroke(const TColorFunction *cf, TStrokeOutline *outline,- const TStroke *s) const override;+ const TStroke *s) const override {+ doDrawStroke(cf, outline, s, true);+ }+ void drawAliasedStroke(const TColorFunction *cf, TStrokeOutline *outline,+ const TStroke *s) const override {+ doDrawStroke(cf, outline, s, false);+ }int getTagId() const override;diff --git a/toonz/sources/toonzlib/tcolumnfx.cpp b/toonz/sources/toonzlib/tcolumnfx.cppindex 8d58dad0c..20877c72d 100644--- a/toonz/sources/toonzlib/tcolumnfx.cpp+++ b/toonz/sources/toonzlib/tcolumnfx.cpp@@ -1042,6 +1042,10 @@ void TLevelColumnFx::doCompute(TTile &tile, double frame,TVectorRenderData rd(TVectorRenderData::ProductionSettings(), aff,TRect(size), vpalette);+ // obtain jaggy image when the Closest Pixel is set+ if (info.m_quality == TRenderSettings::ClosestPixel_FilterResampleQuality)+ rd.m_antiAliasing = false;+if (!m_offlineContext || m_offlineContext->getLx() < size.lx ||m_offlineContext->getLy() < size.ly) {if (m_offlineContext) delete m_offlineContext;