Skip to content

Commit

Permalink
OGSMOD-2430 OGSMOD-2478 Support underline&overline color and consiste…
Browse files Browse the repository at this point in the history
…nt height for GenericText. (PixarAnimationStudios#150)

TextSytem introduces a DecorationLayout structure which is composed of some contiguous line sections, and the section data is calculated by textLayout.
GenericText --(1:m)-- Final decoration(s) --(1:m)-- TextLine decoration(s) --(1:m)-- Section(s) --(1:m)-- Same Color TextRun(s)
Fix line color: Every section will be created to one underline/overline curve drawItem in USD. The _lineColor of Section will be converted to displayColor for every curve drawItem.
Fix line breaking result from different font size in one line: Contiguous line sections in one line is stored in same Decoration, and Decoration has only one yPosition.
  • Loading branch information
sophie749 authored and PierreWang committed Jan 17, 2023
1 parent 673ec07 commit f346589
Show file tree
Hide file tree
Showing 14 changed files with 551 additions and 203 deletions.
8 changes: 4 additions & 4 deletions build_scripts/build_usd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1481,11 +1481,11 @@ def InstallOpenSubdiv(context, force, buildArgs):
# TextSystem

if MacOS():
TEXTSYSTEM_RELEASE_URL = "https://art-bobcat.autodesk.com/artifactory/team-gfx-generic/Components/master/textsystem/1.2.1-ea698c5/textsystem_Darwin_ea698c5_Release.zip"
TEXTSYSTEM_DEBUG_URL = "https://art-bobcat.autodesk.com/artifactory/team-gfx-generic/Components/master/textsystem/1.2.1-ea698c5/textsystem_Darwin_ea698c5_Debug.zip"
TEXTSYSTEM_RELEASE_URL = "https://art-bobcat.autodesk.com/artifactory/team-gfx-generic/Components/master/textsystem/1.2.1-13336e4/textsystem_Darwin_13336e4_Release.zip"
TEXTSYSTEM_DEBUG_URL = "https://art-bobcat.autodesk.com/artifactory/team-gfx-generic/Components/master/textsystem/1.2.1-13336e4/textsystem_Darwin_13336e4_Debug.zip"
elif Windows():
TEXTSYSTEM_RELEASE_URL = "https://art-bobcat.autodesk.com/artifactory/team-gfx-generic/Components/master/textsystem/1.2.1-ea698c5/textsystem_Windows_ea698c5_Release.zip"
TEXTSYSTEM_DEBUG_URL = "https://art-bobcat.autodesk.com/artifactory/team-gfx-generic/Components/master/textsystem/1.2.1-ea698c5/textsystem_Windows_ea698c5_Debug.zip"
TEXTSYSTEM_RELEASE_URL = "https://art-bobcat.autodesk.com/artifactory/team-gfx-generic/Components/master/textsystem/1.2.1-13336e4/textsystem_Windows_13336e4_Release.zip"
TEXTSYSTEM_DEBUG_URL = "https://art-bobcat.autodesk.com/artifactory/team-gfx-generic/Components/master/textsystem/1.2.1-13336e4/textsystem_Windows_13336e4_Debug.zip"

def InstallTextSystem(context, force, buildArgs):
if context.buildDebug:
Expand Down
2 changes: 1 addition & 1 deletion extras/usd/examples/usdGeomExamples/multilineText.usda
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def Xform "Text1" {
uniform token[] xformOpOrder = ["xformOp:translate"]
float3 xformOp:translate = (3, 0, 0)

string markupString = "\\fArial|b0|i0|p34|c0;\\H20;\\c65300;\\l\\oPipelines capable of producing computer graphics films and games typically generate, store, and transmit large quantities of 3D data, which we call \\H30;\\c42137;scene description\\H20;\\c65300;. Each of many cooperating applications in the pipeline (modeling, shading, animation, lighting, fx, rendering) typically has its own special form \\Oof scene description tailored to the specific needs and workflows of the application, which is neither readable nor editable by any other application.\\o \\P\\fArial|b0|i1|p34|c0;\\H30;\\c12255232;Universal Scene Description (USD)\\fArial|b0|i0|p34|c0;\\H20;\\c65300; is the first publicly available software that addresses the need to robustly and scalably interchange and augment arbitrary 3D scenes that may be composed from many elemental assets.\\PUSD organizes data into hierarchical namespaces of \\H30;\\c42137;Prims\\H20;\\c65300; (short for \"primitive\"). Built on top of this low-level, \\Ogeneric scene description, USD provides a set of schemas that establish\\o a standard encoding and client API for common 3D computer graphics concepts like:\n\tGeometry\tShading\tModel and Asset\\L\\P\\H30;\\c42137;Composition arcs\\H20;\\c65300; are the \"operators\" that allow USD to create rich compositions of many layers containing mixes of \"base\" scene description and overrides. Composition arcs include:\n\tsublayers\tinherits\tvariantSets\treferences\n\tpayloads\tspecializes\tTestA\tTestB\n\tTestC\tTestD\tTestE\\l"
string markupString = "\\fArial|b0|i0|p34|c0;\\H20;\\c65300;\\l\\oPipelines capable of producing computer graphics films and games typically generate, store, and transmit large quantities of 3D data, \\Owhich we call \\H30;\\c42137;scene description\\H20;\\o\\c65300;. Each of many cooperating applications in the pipeline (modeling, shading, animation, lighting, fx, rendering) typically has its own special form \\Oof scene description tailored to the specific needs and workflows of the application, which is neither readable nor editable by any other application.\\o \\P\\fArial|b0|i1|p34|c0;\\H30;\\c12255232;\\OUniversal Scene Description (USD)\\fArial|b0|i0|p34|c0;\\H20;\\c65300; is the first\\o publicly available \\Osoftware that \\oaddresses the need to robustly and scalably interchange and augment arbitrary 3D scenes that may be composed from many elemental assets.\\PUSD organizes data into hierarchical \\Lnamespaces of \\H30;\\c42137;Prims\\H20;\\c65300; (short for \"primitive\").\\lBuilt on top of this low-level, \\Lgeneric scene description, USD provides a set of schemas that establish\\l a standard encoding and client API for common 3D computer graphics concepts like:\n\tGeometry\tShading\tModel and Asset\\P\\H30;\\c42137;\\LComposition arcs\\H20;\\c65300; are the \"operators\" that \\lallow USD to create\\L rich compositions of many \\llayers containing \\Lmixes of \"base\" scene description and overrides. Composition arcs include:\n\tsublayers\tinherits\tvariantSets\treferences\n\tpayloads\tspecializes\tTestA\tTestB\n\tTestC\tTestD\tTestE\\l"
uniform token markupLanguage = "mtext"
color3f[] primvars:displayColor = [(0, 1, 0)]
rel textStyle:binding = </StyleA>
Expand Down
10 changes: 9 additions & 1 deletion pxr/imaging/hd/dataSourceLegacyPrim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,8 @@ class Hd_GenericTextTopologyStore

DEFINE_GENERICTEXT_TOPOLOGY_ACCESSOR_DATASOURCE(
PointCountDataSource, int, GetPointCount);
DEFINE_GENERICTEXT_TOPOLOGY_ACCESSOR_DATASOURCE(
DecorationCountDataSource, int, GetDecorationCount);

private:
SdfPath _id;
Expand All @@ -1357,7 +1359,8 @@ class Hd_DataSourceGenericTextTopology : public HdContainerDataSource

bool Has(const TfToken &name) override
{
if (name == HdGenericTextTopologySchemaTokens->pointCount) {
if (name == HdGenericTextTopologySchemaTokens->pointCount ||
name == HdGenericTextTopologySchemaTokens->decorationCount) {
return true;
}
return false;
Expand All @@ -1367,6 +1370,7 @@ class Hd_DataSourceGenericTextTopology : public HdContainerDataSource
{
return{
HdGenericTextTopologySchemaTokens->pointCount,
HdGenericTextTopologySchemaTokens->decorationCount,
};
}

Expand All @@ -1376,6 +1380,10 @@ class Hd_DataSourceGenericTextTopology : public HdContainerDataSource
return Hd_GenericTextTopologyStore::
PointCountDataSource::New(_stts);
}
if (name == HdGenericTextTopologySchemaTokens->decorationCount) {
return Hd_GenericTextTopologyStore::
DecorationCountDataSource::New(_stts);
}
return nullptr;
}

Expand Down
6 changes: 3 additions & 3 deletions pxr/imaging/hd/genericText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ HdGenericText::GetBuiltinPrimvarNames() const
HdTokens->triType,
HdTokens->textColor,
HdTokens->textOpacity,
HdTokens->overlinePoints,
HdTokens->underlinePoints

HdTokens->linePoints,
HdTokens->lineColors,
HdTokens->lineOpacities
};
return primvarNames;
}
Expand Down
14 changes: 8 additions & 6 deletions pxr/imaging/hd/genericTextTopology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@ PXR_NAMESPACE_OPEN_SCOPE
HdGenericTextTopology::HdGenericTextTopology()
: HdTopology()
, _pointCount(0)
, _decorationCount(0)
{
HD_PERF_COUNTER_INCR(HdPerfTokens->genericTextTopology);
}
HdGenericTextTopology::HdGenericTextTopology(size_t pointCount)
: HdTopology(), _pointCount(pointCount)
HdGenericTextTopology::HdGenericTextTopology(size_t pointCount, size_t decorationCount)
: HdTopology(), _pointCount(pointCount), _decorationCount(decorationCount)
{
HD_PERF_COUNTER_INCR(HdPerfTokens->genericTextTopology);
}

HdGenericTextTopology::HdGenericTextTopology(const HdGenericTextTopology& src)
: HdTopology(src), _pointCount(src._pointCount)
: HdTopology(src), _pointCount(src._pointCount), _decorationCount(src._decorationCount)
{
HD_PERF_COUNTER_INCR(HdPerfTokens->genericTextTopology);
}
Expand All @@ -59,7 +60,7 @@ HdGenericTextTopology::operator==(HdGenericTextTopology const &other) const
HD_TRACE_FUNCTION();

// The topology is the same if the pointCount is the same.
return _pointCount == other._pointCount;
return _pointCount == other._pointCount && _decorationCount == other._decorationCount;
}

bool
Expand All @@ -68,7 +69,7 @@ HdGenericTextTopology::operator!=(HdGenericTextTopology const &other) const
HD_TRACE_FUNCTION();

// The topology is not the same if the pointCount is not the same.
return _pointCount != other._pointCount;
return _pointCount != other._pointCount && _decorationCount != other._decorationCount;
}

HdTopology::ID
Expand All @@ -79,6 +80,7 @@ HdGenericTextTopology::ComputeHash() const
HdTopology::ID hash = 0;
// We only need to hash the point count.
hash = ArchHash64((const char*)&_pointCount, sizeof(size_t), hash);
hash = ArchHash64((const char*)&_decorationCount, sizeof(size_t), hash);

// Note: We don't hash topological visibility, because it is treated as a
// per-prim opinion, and hence, shouldn't break topology sharing.
Expand All @@ -88,7 +90,7 @@ HdGenericTextTopology::ComputeHash() const
std::ostream&
operator << (std::ostream &out, HdGenericTextTopology const &topo)
{
out << "(" << topo.GetPointCount() << ")";
out << "(" << topo.GetPointCount() << ", " << topo.GetDecorationCount() << ")";
return out;
}

Expand Down
8 changes: 7 additions & 1 deletion pxr/imaging/hd/genericTextTopology.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ PXR_NAMESPACE_OPEN_SCOPE
class HdGenericTextTopology : public HdTopology {
public:
HD_API HdGenericTextTopology();
HD_API HdGenericTextTopology(size_t pointCount);
HD_API HdGenericTextTopology(size_t pointCount, size_t decorationCount);
HD_API HdGenericTextTopology(const HdGenericTextTopology& src);
HD_API virtual ~HdGenericTextTopology();

Expand All @@ -52,6 +52,11 @@ class HdGenericTextTopology : public HdTopology {
/// Returns point count of the text geometry.
size_t GetPointCount() const {
return _pointCount;
}

/// Returns point count of the text geometry.
size_t GetDecorationCount() const {
return _decorationCount;
}

/// Equality check between two genericText topologies.
Expand All @@ -60,6 +65,7 @@ class HdGenericTextTopology : public HdTopology {

private:
size_t _pointCount;
size_t _decorationCount;
};

HD_API
Expand Down
23 changes: 21 additions & 2 deletions pxr/imaging/hd/genericTextTopologySchema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,18 @@ HdGenericTextTopologySchema::GetPointCount()
HdGenericTextTopologySchemaTokens->pointCount);
}

HdIntDataSourceHandle
HdGenericTextTopologySchema::GetDecorationCount()
{
return _GetTypedDataSource<HdIntDataSource>(
HdGenericTextTopologySchemaTokens->decorationCount);
}

/*static*/
HdContainerDataSourceHandle
HdGenericTextTopologySchema::BuildRetained(
const HdIntDataSourceHandle &pointCount
const HdIntDataSourceHandle &pointCount,
const HdIntDataSourceHandle &decorationCount
)
{
TfToken names[1];
Expand All @@ -58,6 +66,10 @@ HdGenericTextTopologySchema::BuildRetained(
names[count] = HdGenericTextTopologySchemaTokens->pointCount;
values[count++] = pointCount;
}
if (decorationCount) {
names[count] = HdGenericTextTopologySchemaTokens->decorationCount;
values[count++] = decorationCount;
}

return HdRetainedContainerDataSource::New(count, names, values);
}
Expand Down Expand Up @@ -91,12 +103,19 @@ HdGenericTextTopologySchema::Builder::SetPointCount(
_pointCount = pointCount;
return *this;
}
HdGenericTextTopologySchema::Builder &
HdGenericTextTopologySchema::Builder::SetDecorationCount(
const HdIntDataSourceHandle &decorationCount)
{
_decorationCount = decorationCount;
return *this;
}

HdContainerDataSourceHandle
HdGenericTextTopologySchema::Builder::Build()
{
return HdGenericTextTopologySchema::BuildRetained(
_pointCount
_pointCount, _decorationCount
);
}

Expand Down
13 changes: 10 additions & 3 deletions pxr/imaging/hd/genericTextTopologySchema.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ PXR_NAMESPACE_OPEN_SCOPE
#define HDGENERICTEXTTOPOLOGY_SCHEMA_TOKENS \
(topology) \
(pointCount) \
(overlineTopology) \
(underlineTopology) \
(decorationCount) \
(lineTopology)

TF_DECLARE_PUBLIC_TOKENS(HdGenericTextTopologySchemaTokens, HD_API,
HDGENERICTEXTTOPOLOGY_SCHEMA_TOKENS);
Expand All @@ -57,6 +57,8 @@ class HdGenericTextTopologySchema : public HdSchema

HD_API
HdIntDataSourceHandle GetPointCount();
HD_API
HdIntDataSourceHandle GetDecorationCount();

// RETRIEVING AND CONSTRUCTING

Expand All @@ -68,7 +70,7 @@ class HdGenericTextTopologySchema : public HdSchema
HD_API
static HdContainerDataSourceHandle
BuildRetained(
const HdIntDataSourceHandle &pointCount
const HdIntDataSourceHandle &pointCount, const HdIntDataSourceHandle &decorationCount
);

/// \class HdGenericTextTopologySchema::Builder
Expand All @@ -84,12 +86,17 @@ class HdGenericTextTopologySchema : public HdSchema
Builder &SetPointCount(
const HdIntDataSourceHandle &pointCount);

HD_API
Builder &SetDecorationCount(
const HdIntDataSourceHandle &decorationCount);

/// Returns a container data source containing the members set thus far.
HD_API
HdContainerDataSourceHandle Build();

private:
HdIntDataSourceHandle _pointCount;
HdIntDataSourceHandle _decorationCount;
};

/// Retrieves a container data source with the schema's default name token
Expand Down
10 changes: 9 additions & 1 deletion pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -823,10 +823,18 @@ HdSceneIndexAdapterSceneDelegate::GetGenericTextTopology(SdfPath const &id)
if (!pointCountDataSource) {
return HdGenericTextTopology();
}
// Get the decorationCount.
HdIntDataSourceHandle decorationCountDataSource =
gtTopologySchema.GetDecorationCount();

if (!decorationCountDataSource) {
return HdGenericTextTopology();
}

// Create the topology.
HdGenericTextTopology result(
pointCountDataSource->GetTypedValue(0.0f));
pointCountDataSource->GetTypedValue(0.0f),
decorationCountDataSource->GetTypedValue(0.0f));

return result;
}
Expand Down
3 changes: 3 additions & 0 deletions pxr/imaging/hd/tokens.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ PXR_NAMESPACE_OPEN_SCOPE
(visibility) \
(widths) \
(isLight) \
(linePoints) \
(lineColors) \
(lineOpacities) \
(overlinePoints) \
(underlinePoints)

Expand Down
Loading

0 comments on commit f346589

Please sign in to comment.