Skip to content

Commit

Permalink
Pass context through symbol instance accessor methods
Browse files Browse the repository at this point in the history
  • Loading branch information
TimSylvester committed Jun 24, 2024
1 parent 61a2e16 commit 8fb459a
Show file tree
Hide file tree
Showing 6 changed files with 274 additions and 271 deletions.
143 changes: 73 additions & 70 deletions src/mbgl/layout/symbol_instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define STRINGIZE(x) STRINGIZE2(x)
#define STRINGIZE2(x) #x
#define __LINE_STRING__ STRINGIZE(__LINE__)
#define __SOURCE_LOCATION__ __FILE__ ":" __LINE_STRING__

namespace mbgl {

Expand Down Expand Up @@ -89,37 +90,39 @@ class SymbolInstance {
const optional<SymbolQuads>& verticalIconQuads() const;
void releaseSharedData();

bool check(std::string_view source = std::string_view()) const {
return !isFailed &&
check(check01, 1, source) &&
check(check02, 2, source) &&
check(check03, 3, source) &&
check(check04, 4, source) &&
check(check05, 5, source) &&
check(check06, 6, source) &&
check(check07, 7, source) &&
check(check08, 8, source) &&
check(check09, 9, source) &&
check(check10, 10, source) &&
check(check11, 11, source) &&
check(check12, 12, source) &&
check(check13, 13, source) &&
check(check14, 14, source) &&
check(check15, 15, source) &&
check(check16, 16, source) &&
check(check17, 17, source) &&
check(check18, 18, source) &&
check(check19, 19, source) &&
check(check20, 20, source) &&
check(check21, 21, source) &&
check(check22, 22, source) &&
check(check23, 23, source) &&
check(check24, 24, source) &&
check(check25, 25, source) &&
check(check26, 26, source) &&
check(check27, 27, source) &&
check(check28, 28, source) &&
check(check29, 29, source);
bool check(std::string_view source) const {
if (isFailed)
return false;
check(check01, 1, source);
check(check02, 2, source);
check(check03, 3, source);
check(check04, 4, source);
check(check05, 5, source);
check(check06, 6, source);
check(check07, 7, source);
check(check08, 8, source);
check(check09, 9, source);
check(check10, 10, source);
check(check11, 11, source);
check(check12, 12, source);
check(check13, 13, source);
check(check14, 14, source);
check(check15, 15, source);
check(check16, 16, source);
check(check17, 17, source);
check(check18, 18, source);
check(check19, 19, source);
check(check20, 20, source);
check(check21, 21, source);
check(check22, 22, source);
check(check23, 23, source);
check(check24, 24, source);
check(check25, 25, source);
check(check26, 26, source);
check(check27, 27, source);
check(check28, 28, source);
check(check29, 29, source);
return !isFailed;
}
bool checkIndex(const optional<std::size_t>& index, std::size_t size, std::string_view source) const;
bool checkIndexes(std::size_t textCount, std::size_t iconSize, std::size_t sdfSize, std::string_view source) const {
Expand All @@ -132,45 +135,45 @@ class SymbolInstance {
checkIndex(placedVerticalIconIndex, hasSdfIcon() ? sdfSize : iconSize, source);
}

const Anchor& getAnchor() const { check(); return anchor; }
std::size_t getRightJustifiedGlyphQuadsSize() const { check(); return rightJustifiedGlyphQuadsSize; }
std::size_t getCenterJustifiedGlyphQuadsSize() const { check(); return centerJustifiedGlyphQuadsSize; }
std::size_t getLeftJustifiedGlyphQuadsSize() const { check(); return leftJustifiedGlyphQuadsSize; }
std::size_t getVerticalGlyphQuadsSize() const { check(); return verticalGlyphQuadsSize; }
std::size_t getIconQuadsSize() const { check(); return iconQuadsSize; }
const CollisionFeature& getTextCollisionFeature() const { check(); return textCollisionFeature; }
const CollisionFeature& getIconCollisionFeature() const { check(); return iconCollisionFeature; }
const optional<CollisionFeature>& getVerticalTextCollisionFeature() const { check(); return verticalTextCollisionFeature; }
const optional<CollisionFeature>& getVerticalIconCollisionFeature() const { check(); return verticalIconCollisionFeature; }
WritingModeType getWritingModes() const { check(); return writingModes; }
std::size_t getLayoutFeatureIndex() const { check(); return layoutFeatureIndex; }
std::size_t getDataFeatureIndex() const { check(); return dataFeatureIndex; }
std::array<float, 2> getTextOffset() const { check(); return textOffset; }
std::array<float, 2> getIconOffset() const { check(); return iconOffset; }
const std::u16string& getKey() const { check(); checkKey(); return key; }
optional<size_t> getPlacedRightTextIndex() const { check(); return placedRightTextIndex; }
optional<size_t> getPlacedCenterTextIndex() const { check(); return placedCenterTextIndex; }
optional<size_t> getPlacedLeftTextIndex() const { check(); return placedLeftTextIndex; }
optional<size_t> getPlacedVerticalTextIndex() const { check(); return placedVerticalTextIndex; }
optional<size_t> getPlacedIconIndex() const { check(); return placedIconIndex; }
optional<size_t> getPlacedVerticalIconIndex() const { check(); return placedVerticalIconIndex; }
float getTextBoxScale() const { check(); return textBoxScale; }
std::array<float, 2> getVariableTextOffset() const { check(); return variableTextOffset; }
bool getSingleLine() const { check(); return singleLine; }

uint32_t getCrossTileID() const { check(); return crossTileID; }
void setCrossTileID(uint32_t x) { check(); crossTileID = x; check(); }

optional<size_t>& refPlacedRightTextIndex() { check(); return placedRightTextIndex; }
optional<size_t>& refPlacedCenterTextIndex() { check(); return placedCenterTextIndex; }
optional<size_t>& refPlacedLeftTextIndex() { check(); return placedLeftTextIndex; }
optional<size_t>& refPlacedVerticalTextIndex() { check(); return placedVerticalTextIndex; }
optional<size_t>& refPlacedIconIndex() { check(); return placedIconIndex; }
optional<size_t>& refPlacedVerticalIconIndex() { check(); return placedVerticalIconIndex; }

void setPlacedRightTextIndex(optional<size_t> x) { check(); placedRightTextIndex = x; check(); }
void setPlacedCenterTextIndex(optional<size_t> x) { check(); placedCenterTextIndex = x; check(); }
void setPlacedLeftTextIndex(optional<size_t> x) { check(); placedLeftTextIndex = x; check(); }
const Anchor& getAnchor(std::string_view source) const { check(source); return anchor; }
std::size_t getRightJustifiedGlyphQuadsSize(std::string_view source) const { check(source); return rightJustifiedGlyphQuadsSize; }
std::size_t getCenterJustifiedGlyphQuadsSize(std::string_view source) const { check(source); return centerJustifiedGlyphQuadsSize; }
std::size_t getLeftJustifiedGlyphQuadsSize(std::string_view source) const { check(source); return leftJustifiedGlyphQuadsSize; }
std::size_t getVerticalGlyphQuadsSize(std::string_view source) const { check(source); return verticalGlyphQuadsSize; }
std::size_t getIconQuadsSize(std::string_view source) const { check(source); return iconQuadsSize; }
const CollisionFeature& getTextCollisionFeature(std::string_view source) const { check(source); return textCollisionFeature; }
const CollisionFeature& getIconCollisionFeature(std::string_view source) const { check(source); return iconCollisionFeature; }
const optional<CollisionFeature>& getVerticalTextCollisionFeature(std::string_view source) const { check(source); return verticalTextCollisionFeature; }
const optional<CollisionFeature>& getVerticalIconCollisionFeature(std::string_view source) const { check(source); return verticalIconCollisionFeature; }
WritingModeType getWritingModes(std::string_view source) const { check(source); return writingModes; }
std::size_t getLayoutFeatureIndex(std::string_view source) const { check(source); return layoutFeatureIndex; }
std::size_t getDataFeatureIndex(std::string_view source) const { check(source); return dataFeatureIndex; }
std::array<float, 2> getTextOffset(std::string_view source) const { check(source); return textOffset; }
std::array<float, 2> getIconOffset(std::string_view source) const { check(source); return iconOffset; }
const std::u16string& getKey(std::string_view source) const { check(source); checkKey(); return key; }
optional<size_t> getPlacedRightTextIndex(std::string_view source) const { check(source); return placedRightTextIndex; }
optional<size_t> getPlacedCenterTextIndex(std::string_view source) const { check(source); return placedCenterTextIndex; }
optional<size_t> getPlacedLeftTextIndex(std::string_view source) const { check(source); return placedLeftTextIndex; }
optional<size_t> getPlacedVerticalTextIndex(std::string_view source) const { check(source); return placedVerticalTextIndex; }
optional<size_t> getPlacedIconIndex(std::string_view source) const { check(source); return placedIconIndex; }
optional<size_t> getPlacedVerticalIconIndex(std::string_view source) const { check(source); return placedVerticalIconIndex; }
float getTextBoxScale(std::string_view source) const { check(source); return textBoxScale; }
std::array<float, 2> getVariableTextOffset(std::string_view source) const { check(source); return variableTextOffset; }
bool getSingleLine(std::string_view source) const { check(source); return singleLine; }

uint32_t getCrossTileID(std::string_view source) const { check(source); return crossTileID; }
void setCrossTileID(uint32_t x, std::string_view source) { check(source); crossTileID = x; }

optional<size_t>& refPlacedRightTextIndex(std::string_view source) { check(source); return placedRightTextIndex; }
optional<size_t>& refPlacedCenterTextIndex(std::string_view source) { check(source); return placedCenterTextIndex; }
optional<size_t>& refPlacedLeftTextIndex(std::string_view source) { check(source); return placedLeftTextIndex; }
optional<size_t>& refPlacedVerticalTextIndex(std::string_view source) { check(source); return placedVerticalTextIndex; }
optional<size_t>& refPlacedIconIndex(std::string_view source) { check(source); return placedIconIndex; }
optional<size_t>& refPlacedVerticalIconIndex(std::string_view source) { check(source); return placedVerticalIconIndex; }

void setPlacedRightTextIndex(optional<size_t> x, std::string_view source) { check(source); placedRightTextIndex = x; }
void setPlacedCenterTextIndex(optional<size_t> x, std::string_view source) { check(source); placedCenterTextIndex = x; }
void setPlacedLeftTextIndex(optional<size_t> x, std::string_view source) { check(source); placedLeftTextIndex = x; }

static constexpr uint32_t invalidCrossTileID() { return std::numeric_limits<uint32_t>::max(); }

Expand Down
Loading

0 comments on commit 8fb459a

Please sign in to comment.