summaryrefslogtreecommitdiff
path: root/libs/hwui/tests/common/TestUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui/tests/common/TestUtils.cpp')
-rw-r--r--libs/hwui/tests/common/TestUtils.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/libs/hwui/tests/common/TestUtils.cpp b/libs/hwui/tests/common/TestUtils.cpp
index c762eed616e4..930067a9b2cc 100644
--- a/libs/hwui/tests/common/TestUtils.cpp
+++ b/libs/hwui/tests/common/TestUtils.cpp
@@ -20,6 +20,9 @@
#include "DeferredLayerUpdater.h"
#include "LayerRenderer.h"
+#include <renderthread/EglManager.h>
+#include <utils/Unicode.h>
+
namespace android {
namespace uirenderer {
@@ -68,7 +71,10 @@ void TestUtils::layoutTextUnscaled(const SkPaint& paint, const char* text,
SkSurfaceProps surfaceProps(0, kUnknown_SkPixelGeometry);
SkAutoGlyphCacheNoGamma autoCache(paint, &surfaceProps, &SkMatrix::I());
while (*text != '\0') {
- SkUnichar unichar = SkUTF8_NextUnichar(&text);
+ size_t nextIndex = 0;
+ int32_t unichar = utf32_from_utf8_at(text, 4, 0, &nextIndex);
+ text += nextIndex;
+
glyph_t glyph = autoCache.getCache()->unicharToGlyph(unichar);
autoCache.getCache()->unicharToGlyph(unichar);
@@ -107,12 +113,18 @@ void TestUtils::drawUtf8ToCanvas(Canvas* canvas, const char* text,
void TestUtils::TestTask::run() {
// RenderState only valid once RenderThread is running, so queried here
- RenderState& renderState = renderthread::RenderThread::getInstance().renderState();
+ renderthread::RenderThread& renderThread = renderthread::RenderThread::getInstance();
+ bool hasEglContext = renderThread.eglManager().hasEglContext();
+ RenderState& renderState = renderThread.renderState();
+ if (!hasEglContext) {
+ renderState.onGLContextCreated();
+ }
- renderState.onGLContextCreated();
- rtCallback(renderthread::RenderThread::getInstance());
- renderState.flush(Caches::FlushMode::Full);
- renderState.onGLContextDestroyed();
+ rtCallback(renderThread);
+ if (!hasEglContext) {
+ renderState.flush(Caches::FlushMode::Full);
+ renderState.onGLContextDestroyed();
+ }
}
std::unique_ptr<uint16_t[]> TestUtils::asciiToUtf16(const char* str) {