| 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_full.h" |
| 9 |
#include "modules/skunicode/src/SkUnicode_icupriv.h" |
| 10 |
|
| 11 |
#include <unicode/ubidi.h> |
| 12 |
#include <unicode/umachine.h> |
| 13 |
#include <unicode/utypes.h> |
| 14 |
|
| 15 |
const char* SkBidiICUFactory::errorName(UErrorCode status) const { |
| 16 |
return SkGetICULib()->f_u_errorName(status); |
| 17 |
} |
| 18 |
|
| 19 |
SkBidiFactory::BidiCloseCallback SkBidiICUFactory::bidi_close_callback() const { |
| 20 |
return SkGetICULib()->f_ubidi_close; |
| 21 |
} |
| 22 |
|
| 23 |
UBiDiDirection SkBidiICUFactory::bidi_getDirection(const UBiDi* bidi) const { |
| 24 |
return SkGetICULib()->f_ubidi_getDirection(bidi); |
| 25 |
} |
| 26 |
|
| 27 |
SkBidiIterator::Position SkBidiICUFactory::bidi_getLength(const UBiDi* bidi) const { |
| 28 |
return SkGetICULib()->f_ubidi_getLength(bidi); |
| 29 |
} |
| 30 |
|
| 31 |
SkBidiIterator::Level SkBidiICUFactory::bidi_getLevelAt(const UBiDi* bidi, int pos) const { |
| 32 |
return SkGetICULib()->f_ubidi_getLevelAt(bidi, pos); |
| 33 |
} |
| 34 |
|
| 35 |
UBiDi* SkBidiICUFactory::bidi_openSized(int32_t maxLength, |
| 36 |
int32_t maxRunCount, |
| 37 |
UErrorCode* pErrorCode) const { |
| 38 |
return SkGetICULib()->f_ubidi_openSized(maxLength, maxRunCount, pErrorCode); |
| 39 |
} |
| 40 |
|
| 41 |
void SkBidiICUFactory::bidi_setPara(UBiDi* bidi, |
| 42 |
const UChar* text, |
| 43 |
int32_t length, |
| 44 |
UBiDiLevel paraLevel, |
| 45 |
UBiDiLevel* embeddingLevels, |
| 46 |
UErrorCode* status) const { |
| 47 |
return SkGetICULib()->f_ubidi_setPara(bidi, text, length, paraLevel, embeddingLevels, status); |
| 48 |
} |
| 49 |
|
| 50 |
void SkBidiICUFactory::bidi_reorderVisual(const SkUnicode::BidiLevel runLevels[], |
| 51 |
int levelsCount, |
| 52 |
int32_t logicalFromVisual[]) const { |
| 53 |
if (levelsCount == 0) { |
| 54 |
// To avoid an assert in unicode |
| 55 |
return; |
| 56 |
} |
| 57 |
SkASSERT(runLevels != nullptr); |
| 58 |
SkGetICULib()->f_ubidi_reorderVisual(runLevels, levelsCount, logicalFromVisual); |
| 59 |
} |