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.cpp56
1 files changed, 11 insertions, 45 deletions
diff --git a/libs/hwui/tests/common/TestUtils.cpp b/libs/hwui/tests/common/TestUtils.cpp
index 02ac97e0ed5c..69586345319e 100644
--- a/libs/hwui/tests/common/TestUtils.cpp
+++ b/libs/hwui/tests/common/TestUtils.cpp
@@ -19,16 +19,15 @@
#include "DeferredLayerUpdater.h"
#include "hwui/Paint.h"
-#include <SkClipStack.h>
#include <minikin/Layout.h>
#include <pipeline/skia/SkiaOpenGLPipeline.h>
#include <pipeline/skia/SkiaVulkanPipeline.h>
#include <renderthread/EglManager.h>
-#include <renderthread/OpenGLPipeline.h>
#include <renderthread/VulkanManager.h>
#include <utils/Unicode.h>
-#include <SkGlyphCache.h>
+#include "SkColorData.h"
+#include "SkUnPreMultiply.h"
namespace android {
namespace uirenderer {
@@ -53,9 +52,7 @@ SkColor TestUtils::interpolateColor(float fraction, SkColor start, SkColor end)
sp<DeferredLayerUpdater> TestUtils::createTextureLayerUpdater(
renderthread::RenderThread& renderThread) {
android::uirenderer::renderthread::IRenderPipeline* pipeline;
- if (Properties::getRenderPipelineType() == RenderPipelineType::OpenGL) {
- pipeline = new renderthread::OpenGLPipeline(renderThread);
- } else if (Properties::getRenderPipelineType() == RenderPipelineType::SkiaGL) {
+ if (Properties::getRenderPipelineType() == RenderPipelineType::SkiaGL) {
pipeline = new skiapipeline::SkiaOpenGLPipeline(renderThread);
} else {
pipeline = new skiapipeline::SkiaVulkanPipeline(renderThread);
@@ -83,48 +80,17 @@ sp<DeferredLayerUpdater> TestUtils::createTextureLayerUpdater(
return layerUpdater;
}
-void TestUtils::layoutTextUnscaled(const SkPaint& paint, const char* text,
- std::vector<glyph_t>* outGlyphs,
- std::vector<float>* outPositions, float* outTotalAdvance,
- Rect* outBounds) {
- Rect bounds;
- float totalAdvance = 0;
- SkSurfaceProps surfaceProps(0, kUnknown_SkPixelGeometry);
- SkAutoGlyphCacheNoGamma autoCache(paint, &surfaceProps, &SkMatrix::I());
- while (*text != '\0') {
- 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);
-
- // push glyph and its relative position
- outGlyphs->push_back(glyph);
- outPositions->push_back(totalAdvance);
- outPositions->push_back(0);
-
- // compute bounds
- SkGlyph skGlyph = autoCache.getCache()->getUnicharMetrics(unichar);
- Rect glyphBounds(skGlyph.fWidth, skGlyph.fHeight);
- glyphBounds.translate(totalAdvance + skGlyph.fLeft, skGlyph.fTop);
- bounds.unionWith(glyphBounds);
-
- // advance next character
- SkScalar skWidth;
- paint.getTextWidths(&glyph, sizeof(glyph), &skWidth, NULL);
- totalAdvance += skWidth;
- }
- *outBounds = bounds;
- *outTotalAdvance = totalAdvance;
-}
-
void TestUtils::drawUtf8ToCanvas(Canvas* canvas, const char* text, const SkPaint& paint, float x,
float y) {
auto utf16 = asciiToUtf16(text);
+ uint32_t length = strlen(text);
SkPaint glyphPaint(paint);
glyphPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
- canvas->drawText(utf16.get(), 0, strlen(text), strlen(text), x, y, minikin::Bidi::LTR,
+ canvas->drawText(
+ utf16.get(), length, // text buffer
+ 0, length, // draw range
+ 0, length, // context range
+ x, y, minikin::Bidi::LTR,
glyphPaint, nullptr, nullptr /* measured text */);
}
@@ -143,7 +109,7 @@ void TestUtils::TestTask::run() {
if (Properties::getRenderPipelineType() == RenderPipelineType::SkiaVulkan) {
renderThread.vulkanManager().initialize();
} else {
- renderThread.eglManager().initialize();
+ renderThread.requireGlContext();
}
rtCallback(renderThread);
@@ -152,7 +118,7 @@ void TestUtils::TestTask::run() {
renderThread.vulkanManager().destroy();
} else {
renderThread.renderState().flush(Caches::FlushMode::Full);
- renderThread.eglManager().destroy();
+ renderThread.destroyGlContext();
}
}