forked from PixarAnimationStudios/OpenUSD
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OGSMOD-3248] Move the ScriptInfo and WordBreakIndexList into interme…
…diateInfo. (PixarAnimationStudios#679) ### Description of Change(s) Move the ScriptInfo and WordBreakIndexList into intermediateInfo. ### Fixes Issue(s) - <!-- Please follow the Contributing and Building guidelines to run tests against your change. Place an X in the box if tests are run and are all tests passing. --> - [ ] I have verified that all unit tests pass with the proposed changes <!-- Place an X in the box if you have submitted a signed Contributor License Agreement. A signed CLA must be received before pull requests can be merged. For instructions, see: http://openusd.org/release/contributing_to_usd.html --> - [ ] I have submitted a signed Contributor License Agreement (cherry picked from commit 5fe87842f8b9569ec9ddb29a752ce48b2491742d)
- Loading branch information
1 parent
3b2571a
commit 4d5264c
Showing
13 changed files
with
460 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
pxr/usdImaging/plugin/usdImagingCommonText/CommonText/intermediateInfo.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// | ||
// Copyright 2023 Pixar | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "Apache License") | ||
// with the following modification; you may not use this file except in | ||
// compliance with the Apache License and the following modification to it: | ||
// Section 6. Trademarks. is deleted and replaced with: | ||
// | ||
// 6. Trademarks. This License does not grant permission to use the trade | ||
// names, trademarks, service marks, or product names of the Licensor | ||
// and its affiliates, except as required to comply with Section 4(c) of | ||
// the License and to reproduce the content of the NOTICE file. | ||
// | ||
// You may obtain a copy of the Apache License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the Apache License with the above modification is | ||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the Apache License for the specific | ||
// language governing permissions and limitations under the Apache License. | ||
// | ||
#include "intermediateInfo.h" | ||
|
||
PXR_NAMESPACE_OPEN_SCOPE | ||
namespace CommonText | ||
{ | ||
CommonTextRunInfo CommonTextIntermediateInfo::_defaultTextRunInfo; | ||
WordBreakIndexList CommonTextIntermediateInfo::_defaultWordBreakIndexList; | ||
void | ||
CommonTextRunInfo::CopyPartOfData( | ||
const CommonTextRunInfo& fromInfo, | ||
int startOffset, | ||
int length) | ||
{ | ||
// Copy the CommonTextScriptInfo. | ||
CommonTextScriptInfo lastInfo; | ||
for (auto info : fromInfo._scriptInfoArray) | ||
{ | ||
if (info._indexOfFirstCharacter >= (int)startOffset && | ||
info._indexOfFirstCharacter < (int)(startOffset + length)) | ||
{ | ||
info._indexOfFirstCharacter -= startOffset; | ||
if (_scriptInfoArray.size() == 0) | ||
{ | ||
lastInfo._indexOfFirstCharacter = 0; | ||
_scriptInfoArray.push_back(lastInfo); | ||
} | ||
_scriptInfoArray.push_back(info); | ||
} | ||
else | ||
lastInfo = info; | ||
} | ||
|
||
// Copy the complex information. | ||
if (fromInfo._complexScriptInfo != nullptr) | ||
{ | ||
_complexScriptInfo = | ||
std::make_shared<CommonTextComplexScriptInfo>(*(fromInfo._complexScriptInfo.get())); | ||
} | ||
} | ||
|
||
CommonTextIntermediateInfo::CommonTextIntermediateInfo(std::shared_ptr<CommonTextGenericText> genericText) | ||
{ | ||
const std::shared_ptr<CommonTextRunList> textRunList = genericText->ListOfTextRuns(); | ||
for (auto textRunIter = textRunList->begin(); textRunIter != textRunList->end(); ++textRunIter) | ||
{ | ||
// For each TextRun, add a default information. | ||
_AddTextRunInfo(textRunIter, CommonTextRunInfo()); | ||
} | ||
|
||
const std::shared_ptr<CommonTextLineList> textLineList = genericText->ListOfTextLines(); | ||
for (auto textLineIter = textLineList->begin(); textLineIter != textLineList->end(); ++textLineIter) | ||
{ | ||
// For each TextLine, add a default WordBreakIndexList. | ||
_AddWordBreakIndexList(textLineIter, WordBreakIndexList()); | ||
} | ||
} | ||
|
||
} // namespace CommonText | ||
PXR_NAMESPACE_CLOSE_SCOPE |
Oops, something went wrong.