| 1 |
/* |
| 2 |
* Copyright 2024 Google LLC |
| 3 |
* |
| 4 |
* Use of this source code is governed by a BSD-style license that can be |
| 5 |
* found in the LICENSE file. |
| 6 |
*/ |
| 7 |
#include "include/private/base/SkAssert.h" |
| 8 |
#include "modules/skunicode/src/SkBidiFactory_icu_subset.h" |
| 9 |
|
| 10 |
#include <unicode/umachine.h> |
| 11 |
|
| 12 |
const char* SkBidiSubsetFactory::errorName(UErrorCode status) const { |
| 13 |
return u_errorName_skia(status); |
| 14 |
} |
| 15 |
|
| 16 |
SkBidiFactory::BidiCloseCallback SkBidiSubsetFactory::bidi_close_callback() const { |
| 17 |
return ubidi_close_skia; |
| 18 |
} |
| 19 |
|
| 20 |
UBiDiDirection SkBidiSubsetFactory::bidi_getDirection(const UBiDi* bidi) const { |
| 21 |
return ubidi_getDirection_skia(bidi); |
| 22 |
} |
| 23 |
|
| 24 |
SkBidiIterator::Position SkBidiSubsetFactory::bidi_getLength(const UBiDi* bidi) const { |
| 25 |
return ubidi_getLength_skia(bidi); |
| 26 |
} |
| 27 |
|
| 28 |
SkBidiIterator::Level SkBidiSubsetFactory::bidi_getLevelAt(const UBiDi* bidi, int pos) const { |
| 29 |
return ubidi_getLevelAt_skia(bidi, pos); |
| 30 |
} |
| 31 |
|
| 32 |
UBiDi* SkBidiSubsetFactory::bidi_openSized(int32_t maxLength, |
| 33 |
int32_t maxRunCount, |
| 34 |
UErrorCode* pErrorCode) const { |
| 35 |
return ubidi_openSized_skia(maxLength, maxRunCount, pErrorCode); |
| 36 |
} |
| 37 |
|
| 38 |
void SkBidiSubsetFactory::bidi_setPara(UBiDi* bidi, |
| 39 |
const UChar* text, |
| 40 |
int32_t length, |
| 41 |
UBiDiLevel paraLevel, |
| 42 |
UBiDiLevel* embeddingLevels, |
| 43 |
UErrorCode* status) const { |
| 44 |
return ubidi_setPara_skia(bidi, text, length, paraLevel, embeddingLevels, status); |
| 45 |
} |
| 46 |
|
| 47 |
void SkBidiSubsetFactory::bidi_reorderVisual(const SkUnicode::BidiLevel runLevels[], |
| 48 |
int levelsCount, |
| 49 |
int32_t logicalFromVisual[]) const { |
| 50 |
if (levelsCount == 0) { |
| 51 |
// To avoid an assert in unicode |
| 52 |
return; |
| 53 |
} |
| 54 |
SkASSERT(runLevels != nullptr); |
| 55 |
ubidi_reorderVisual_skia(runLevels, levelsCount, logicalFromVisual); |
| 56 |
} |