Reland: Move text logic from jni to hwui level
Initial CL: https://googleplex-android-review.git.corp.google.com/#/c/886854/
Change-Id: I9dfd85fe1d2a2c44f4360c8a29fd58d80e6f31c8
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index c6db0ed..c685b0c 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -117,13 +117,10 @@
android/graphics/Interpolator.cpp \
android/graphics/MaskFilter.cpp \
android/graphics/Matrix.cpp \
- android/graphics/MinikinSkia.cpp \
- android/graphics/MinikinUtils.cpp \
android/graphics/Movie.cpp \
android/graphics/NinePatch.cpp \
android/graphics/NinePatchPeeker.cpp \
android/graphics/Paint.cpp \
- android/graphics/PaintImpl.cpp \
android/graphics/Path.cpp \
android/graphics/PathMeasure.cpp \
android/graphics/PathEffect.cpp \
@@ -135,7 +132,6 @@
android/graphics/Shader.cpp \
android/graphics/SurfaceTexture.cpp \
android/graphics/Typeface.cpp \
- android/graphics/TypefaceImpl.cpp \
android/graphics/Utils.cpp \
android/graphics/Xfermode.cpp \
android/graphics/YuvToJpegEncoder.cpp \
diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp
index 43e26b3..27b9830 100755
--- a/core/jni/android/graphics/Bitmap.cpp
+++ b/core/jni/android/graphics/Bitmap.cpp
@@ -1,7 +1,6 @@
#define LOG_TAG "Bitmap"
#include "Bitmap.h"
-#include "Paint.h"
#include "SkBitmap.h"
#include "SkPixelRef.h"
#include "SkImageEncoder.h"
@@ -18,6 +17,7 @@
#include "android_nio_utils.h"
#include "CreateJavaOutputStreamAdaptor.h"
#include <Caches.h>
+#include <hwui/Paint.h>
#include "core_jni_helpers.h"
diff --git a/core/jni/android/graphics/Camera.cpp b/core/jni/android/graphics/Camera.cpp
index 6fcf689..76d6851 100644
--- a/core/jni/android/graphics/Camera.cpp
+++ b/core/jni/android/graphics/Camera.cpp
@@ -3,8 +3,8 @@
#include "SkCamera.h"
-#include "Canvas.h"
#include "GraphicsJNI.h"
+#include <hwui/Canvas.h>
static jfieldID gNativeInstanceFieldID;
diff --git a/core/jni/android/graphics/CanvasProperty.cpp b/core/jni/android/graphics/CanvasProperty.cpp
index 728bc1c..c841d6a 100644
--- a/core/jni/android/graphics/CanvasProperty.cpp
+++ b/core/jni/android/graphics/CanvasProperty.cpp
@@ -16,9 +16,9 @@
#include "jni.h"
#include "GraphicsJNI.h"
-#include "Paint.h"
#include <core_jni_helpers.h>
+#include <hwui/Paint.h>
#include <utils/RefBase.h>
#include <CanvasProperty.h>
diff --git a/core/jni/android/graphics/FontFamily.cpp b/core/jni/android/graphics/FontFamily.cpp
index 2e974a3..a24af29 100644
--- a/core/jni/android/graphics/FontFamily.cpp
+++ b/core/jni/android/graphics/FontFamily.cpp
@@ -31,9 +31,9 @@
#include <androidfw/AssetManager.h>
#include "Utils.h"
-#include "TypefaceImpl.h"
+#include <hwui/MinikinSkia.h>
+#include <hwui/TypefaceImpl.h>
#include <minikin/FontFamily.h>
-#include "MinikinSkia.h"
#include <memory>
diff --git a/core/jni/android/graphics/Graphics.cpp b/core/jni/android/graphics/Graphics.cpp
index bd01c73..1ead618 100644
--- a/core/jni/android/graphics/Graphics.cpp
+++ b/core/jni/android/graphics/Graphics.cpp
@@ -7,13 +7,13 @@
#include "JNIHelp.h"
#include "GraphicsJNI.h"
-#include "Canvas.h"
#include "SkCanvas.h"
#include "SkDevice.h"
#include "SkMath.h"
#include "SkRegion.h"
#include <android_runtime/AndroidRuntime.h>
#include <cutils/ashmem.h>
+#include <hwui/Canvas.h>
#include <Caches.h>
#include <TextureCache.h>
diff --git a/core/jni/android/graphics/GraphicsJNI.h b/core/jni/android/graphics/GraphicsJNI.h
index e99a3ff..8108e0a 100644
--- a/core/jni/android/graphics/GraphicsJNI.h
+++ b/core/jni/android/graphics/GraphicsJNI.h
@@ -11,8 +11,8 @@
#include "SkPoint.h"
#include "SkRect.h"
#include "SkImageDecoder.h"
-#include <Canvas.h>
#include <jni.h>
+#include <hwui/Canvas.h>
class SkBitmapRegionDecoder;
class SkCanvas;
diff --git a/core/jni/android/graphics/MinikinSkia.cpp b/core/jni/android/graphics/MinikinSkia.cpp
deleted file mode 100644
index 8ac5d46..0000000
--- a/core/jni/android/graphics/MinikinSkia.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <SkTypeface.h>
-#include <SkPaint.h>
-
-#define LOG_TAG "Minikin"
-#include <cutils/log.h>
-
-#include "MinikinSkia.h"
-
-namespace android {
-
-MinikinFontSkia::MinikinFontSkia(SkTypeface *typeface) :
- mTypeface(typeface) {
-}
-
-MinikinFontSkia::~MinikinFontSkia() {
- SkSafeUnref(mTypeface);
-}
-
-static void MinikinFontSkia_SetSkiaPaint(const MinikinFont* font, SkPaint* skPaint, const MinikinPaint& paint) {
- skPaint->setTextEncoding(SkPaint::kGlyphID_TextEncoding);
- skPaint->setTextSize(paint.size);
- skPaint->setTextScaleX(paint.scaleX);
- skPaint->setTextSkewX(paint.skewX);
- MinikinFontSkia::unpackPaintFlags(skPaint, paint.paintFlags);
- // Apply font fakery on top of user-supplied flags.
- MinikinFontSkia::populateSkPaint(skPaint, font, paint.fakery);
-}
-
-float MinikinFontSkia::GetHorizontalAdvance(uint32_t glyph_id,
- const MinikinPaint &paint) const {
- SkPaint skPaint;
- uint16_t glyph16 = glyph_id;
- SkScalar skWidth;
- MinikinFontSkia_SetSkiaPaint(this, &skPaint, paint);
- skPaint.getTextWidths(&glyph16, sizeof(glyph16), &skWidth, NULL);
-#ifdef VERBOSE
- ALOGD("width for typeface %d glyph %d = %f", mTypeface->uniqueID(), glyph_id, skWidth);
-#endif
- return skWidth;
-}
-
-void MinikinFontSkia::GetBounds(MinikinRect* bounds, uint32_t glyph_id,
- const MinikinPaint& paint) const {
- SkPaint skPaint;
- uint16_t glyph16 = glyph_id;
- SkRect skBounds;
- MinikinFontSkia_SetSkiaPaint(this, &skPaint, paint);
- skPaint.getTextWidths(&glyph16, sizeof(glyph16), NULL, &skBounds);
- bounds->mLeft = skBounds.fLeft;
- bounds->mTop = skBounds.fTop;
- bounds->mRight = skBounds.fRight;
- bounds->mBottom = skBounds.fBottom;
-}
-
-bool MinikinFontSkia::GetTable(uint32_t tag, uint8_t *buf, size_t *size) {
- if (buf == NULL) {
- const size_t tableSize = mTypeface->getTableSize(tag);
- *size = tableSize;
- return tableSize != 0;
- } else {
- const size_t actualSize = mTypeface->getTableData(tag, 0, *size, buf);
- *size = actualSize;
- return actualSize != 0;
- }
-}
-
-SkTypeface *MinikinFontSkia::GetSkTypeface() const {
- return mTypeface;
-}
-
-int32_t MinikinFontSkia::GetUniqueId() const {
- return mTypeface->uniqueID();
-}
-
-uint32_t MinikinFontSkia::packPaintFlags(const SkPaint* paint) {
- uint32_t flags = paint->getFlags();
- SkPaint::Hinting hinting = paint->getHinting();
- // select only flags that might affect text layout
- flags &= (SkPaint::kAntiAlias_Flag | SkPaint::kFakeBoldText_Flag | SkPaint::kLinearText_Flag |
- SkPaint::kSubpixelText_Flag | SkPaint::kDevKernText_Flag |
- SkPaint::kEmbeddedBitmapText_Flag | SkPaint::kAutoHinting_Flag |
- SkPaint::kVerticalText_Flag);
- flags |= (hinting << 16);
- return flags;
-}
-
-void MinikinFontSkia::unpackPaintFlags(SkPaint* paint, uint32_t paintFlags) {
- paint->setFlags(paintFlags & SkPaint::kAllFlags);
- paint->setHinting(static_cast<SkPaint::Hinting>(paintFlags >> 16));
-}
-
-void MinikinFontSkia::populateSkPaint(SkPaint* paint, const MinikinFont* font, FontFakery fakery) {
- paint->setTypeface(reinterpret_cast<const MinikinFontSkia*>(font)->GetSkTypeface());
- paint->setFakeBoldText(paint->isFakeBoldText() || fakery.isFakeBold());
- if (fakery.isFakeItalic()) {
- paint->setTextSkewX(paint->getTextSkewX() - 0.25f);
- }
-}
-
-}
diff --git a/core/jni/android/graphics/MinikinSkia.h b/core/jni/android/graphics/MinikinSkia.h
deleted file mode 100644
index 8f469ba..0000000
--- a/core/jni/android/graphics/MinikinSkia.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _ANDROID_GRAPHICS_MINIKIN_SKIA_H_
-#define _ANDROID_GRAPHICS_MINIKIN_SKIA_H_
-
-#include <minikin/MinikinFont.h>
-
-namespace android {
-
-class MinikinFontSkia : public MinikinFont {
-public:
- // Note: this takes ownership of the reference (will unref on dtor)
- explicit MinikinFontSkia(SkTypeface *typeface);
-
- ~MinikinFontSkia();
-
- float GetHorizontalAdvance(uint32_t glyph_id,
- const MinikinPaint &paint) const;
-
- void GetBounds(MinikinRect* bounds, uint32_t glyph_id,
- const MinikinPaint &paint) const;
-
- // If buf is NULL, just update size
- bool GetTable(uint32_t tag, uint8_t *buf, size_t *size);
-
- int32_t GetUniqueId() const;
-
- SkTypeface* GetSkTypeface() const;
-
- static uint32_t packPaintFlags(const SkPaint* paint);
- static void unpackPaintFlags(SkPaint* paint, uint32_t paintFlags);
-
- // set typeface and fake bold/italic parameters
- static void populateSkPaint(SkPaint* paint, const MinikinFont* font, FontFakery fakery);
-private:
- SkTypeface *mTypeface;
-};
-
-} // namespace android
-
-#endif // _ANDROID_GRAPHICS_MINIKIN_SKIA_H_
diff --git a/core/jni/android/graphics/MinikinUtils.cpp b/core/jni/android/graphics/MinikinUtils.cpp
deleted file mode 100644
index 309d35b..0000000
--- a/core/jni/android/graphics/MinikinUtils.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "Minikin"
-#include <cutils/log.h>
-#include <string>
-
-#include "SkPathMeasure.h"
-#include "Paint.h"
-#include "TypefaceImpl.h"
-
-#include "MinikinUtils.h"
-
-namespace android {
-
-FontStyle MinikinUtils::prepareMinikinPaint(MinikinPaint* minikinPaint, FontCollection** pFont,
- const Paint* paint, TypefaceImpl* typeface) {
- const TypefaceImpl* resolvedFace = TypefaceImpl_resolveDefault(typeface);
- *pFont = resolvedFace->fFontCollection;
- FontStyle resolved = resolvedFace->fStyle;
-
- /* Prepare minikin FontStyle */
- FontVariant minikinVariant = (paint->getFontVariant() == VARIANT_ELEGANT) ? VARIANT_ELEGANT
- : VARIANT_COMPACT;
- const uint32_t langListId = paint->getMinikinLangListId();
- FontStyle minikinStyle(langListId, minikinVariant, resolved.getWeight(), resolved.getItalic());
-
- /* Prepare minikin Paint */
- // Note: it would be nice to handle fractional size values (it would improve smooth zoom
- // behavior), but historically size has been treated as an int.
- // TODO: explore whether to enable fractional sizes, possibly when linear text flag is set.
- minikinPaint->size = (int)paint->getTextSize();
- minikinPaint->scaleX = paint->getTextScaleX();
- minikinPaint->skewX = paint->getTextSkewX();
- minikinPaint->letterSpacing = paint->getLetterSpacing();
- minikinPaint->paintFlags = MinikinFontSkia::packPaintFlags(paint);
- minikinPaint->fontFeatureSettings = paint->getFontFeatureSettings();
- minikinPaint->hyphenEdit = HyphenEdit(paint->getHyphenEdit());
- return minikinStyle;
-}
-
-void MinikinUtils::doLayout(Layout* layout, const Paint* paint, int bidiFlags,
- TypefaceImpl* typeface, const uint16_t* buf, size_t start, size_t count,
- size_t bufSize) {
- FontCollection *font;
- MinikinPaint minikinPaint;
- FontStyle minikinStyle = prepareMinikinPaint(&minikinPaint, &font, paint, typeface);
- layout->setFontCollection(font);
- layout->doLayout(buf, start, count, bufSize, bidiFlags, minikinStyle, minikinPaint);
-}
-
-float MinikinUtils::measureText(const Paint* paint, int bidiFlags, TypefaceImpl* typeface,
- const uint16_t* buf, size_t start, size_t count, size_t bufSize, float *advances) {
- FontCollection *font;
- MinikinPaint minikinPaint;
- FontStyle minikinStyle = prepareMinikinPaint(&minikinPaint, &font, paint, typeface);
- return Layout::measureText(buf, start, count, bufSize, bidiFlags, minikinStyle, minikinPaint,
- font, advances);
-}
-
-bool MinikinUtils::hasVariationSelector(TypefaceImpl* typeface, uint32_t codepoint, uint32_t vs) {
- const TypefaceImpl* resolvedFace = TypefaceImpl_resolveDefault(typeface);
- return resolvedFace->fFontCollection->hasVariationSelector(codepoint, vs);
-}
-
-float MinikinUtils::xOffsetForTextAlign(Paint* paint, const Layout& layout) {
- switch (paint->getTextAlign()) {
- case Paint::kCenter_Align:
- return layout.getAdvance() * -0.5f;
- break;
- case Paint::kRight_Align:
- return -layout.getAdvance();
- break;
- default:
- break;
- }
- return 0;
-}
-
-float MinikinUtils::hOffsetForTextAlign(Paint* paint, const Layout& layout, const SkPath& path) {
- float align = 0;
- switch (paint->getTextAlign()) {
- case Paint::kCenter_Align:
- align = -0.5f;
- break;
- case Paint::kRight_Align:
- align = -1;
- break;
- default:
- return 0;
- }
- SkPathMeasure measure(path, false);
- return align * (layout.getAdvance() - measure.getLength());
-}
-
-}
diff --git a/core/jni/android/graphics/MinikinUtils.h b/core/jni/android/graphics/MinikinUtils.h
deleted file mode 100644
index 9152539..0000000
--- a/core/jni/android/graphics/MinikinUtils.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Utilities for making Minikin work, especially from existing objects like
- * Paint and so on.
- **/
-
- // TODO: does this really need to be separate from MinikinSkia?
-
-#ifndef _ANDROID_GRAPHICS_MINIKIN_UTILS_H_
-#define _ANDROID_GRAPHICS_MINIKIN_UTILS_H_
-
-#include <minikin/Layout.h>
-#include "Paint.h"
-#include "MinikinSkia.h"
-#include "TypefaceImpl.h"
-
-namespace android {
-
-class MinikinUtils {
-public:
- static FontStyle prepareMinikinPaint(MinikinPaint* minikinPaint, FontCollection** pFont,
- const Paint* paint, TypefaceImpl* typeface);
-
- static void doLayout(Layout* layout, const Paint* paint, int bidiFlags,
- TypefaceImpl* typeface, const uint16_t* buf, size_t start, size_t count,
- size_t bufSize);
-
- static float measureText(const Paint* paint, int bidiFlags, TypefaceImpl* typeface,
- const uint16_t* buf, size_t start, size_t count, size_t bufSize, float *advances);
-
- static bool hasVariationSelector(TypefaceImpl* typeface, uint32_t codepoint, uint32_t vs);
-
- static float xOffsetForTextAlign(Paint* paint, const Layout& layout);
-
- static float hOffsetForTextAlign(Paint* paint, const Layout& layout, const SkPath& path);
- // f is a functor of type void f(size_t start, size_t end);
- template <typename F>
- static void forFontRun(const Layout& layout, Paint* paint, F& f) {
- float saveSkewX = paint->getTextSkewX();
- bool savefakeBold = paint->isFakeBoldText();
- MinikinFont* curFont = NULL;
- size_t start = 0;
- size_t nGlyphs = layout.nGlyphs();
- for (size_t i = 0; i < nGlyphs; i++) {
- MinikinFont* nextFont = layout.getFont(i);
- if (i > 0 && nextFont != curFont) {
- MinikinFontSkia::populateSkPaint(paint, curFont, layout.getFakery(start));
- f(start, i);
- paint->setTextSkewX(saveSkewX);
- paint->setFakeBoldText(savefakeBold);
- start = i;
- }
- curFont = nextFont;
- }
- if (nGlyphs > start) {
- MinikinFontSkia::populateSkPaint(paint, curFont, layout.getFakery(start));
- f(start, nGlyphs);
- paint->setTextSkewX(saveSkewX);
- paint->setFakeBoldText(savefakeBold);
- }
- }
-};
-
-} // namespace android
-
-#endif // _ANDROID_GRAPHICS_MINIKIN_UTILS_H_
diff --git a/core/jni/android/graphics/Movie.cpp b/core/jni/android/graphics/Movie.cpp
index 498c590..71988f9c 100644
--- a/core/jni/android/graphics/Movie.cpp
+++ b/core/jni/android/graphics/Movie.cpp
@@ -1,7 +1,5 @@
-#include "Canvas.h"
#include "CreateJavaOutputStreamAdaptor.h"
#include "GraphicsJNI.h"
-#include "Paint.h"
#include "ScopedLocalRef.h"
#include "SkFrontBufferedStream.h"
#include "SkMovie.h"
@@ -12,6 +10,8 @@
#include <androidfw/Asset.h>
#include <androidfw/ResourceTypes.h>
+#include <hwui/Canvas.h>
+#include <hwui/Paint.h>
#include <jni.h>
#include <netinet/in.h>
diff --git a/core/jni/android/graphics/NinePatch.cpp b/core/jni/android/graphics/NinePatch.cpp
index 3ccbb35..4f2f389 100644
--- a/core/jni/android/graphics/NinePatch.cpp
+++ b/core/jni/android/graphics/NinePatch.cpp
@@ -19,12 +19,12 @@
#define LOG_NDEBUG 1
#include <androidfw/ResourceTypes.h>
+#include <hwui/Canvas.h>
+#include <hwui/Paint.h>
#include <utils/Log.h>
#include <ResourceCache.h>
-#include "Paint.h"
-#include "Canvas.h"
#include "SkCanvas.h"
#include "SkRegion.h"
#include "GraphicsJNI.h"
diff --git a/core/jni/android/graphics/Paint.cpp b/core/jni/android/graphics/Paint.cpp
index d00e94c..d222a4b 100644
--- a/core/jni/android/graphics/Paint.cpp
+++ b/core/jni/android/graphics/Paint.cpp
@@ -37,13 +37,13 @@
#include "unicode/ushape.h"
#include "utils/Blur.h"
+#include <hwui/MinikinSkia.h>
+#include <hwui/MinikinUtils.h>
+#include <hwui/Paint.h>
+#include <hwui/TypefaceImpl.h>
#include <minikin/GraphemeBreak.h>
#include <minikin/Measurement.h>
#include <unicode/utf16.h>
-#include "MinikinSkia.h"
-#include "MinikinUtils.h"
-#include "Paint.h"
-#include "TypefaceImpl.h"
#include <cassert>
#include <cstring>
diff --git a/core/jni/android/graphics/Paint.h b/core/jni/android/graphics/Paint.h
deleted file mode 100644
index cb6e622..0000000
--- a/core/jni/android/graphics/Paint.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_GRAPHICS_PAINT_H_
-#define ANDROID_GRAPHICS_PAINT_H_
-
-#include <SkPaint.h>
-#include <string>
-
-#include <minikin/FontFamily.h>
-
-namespace android {
-
-class Paint : public SkPaint {
-public:
- Paint();
- Paint(const Paint& paint);
- ~Paint();
-
- Paint& operator=(const Paint& other);
-
- friend bool operator==(const Paint& a, const Paint& b);
- friend bool operator!=(const Paint& a, const Paint& b) {
- return !(a == b);
- }
-
- void setLetterSpacing(float letterSpacing) {
- mLetterSpacing = letterSpacing;
- }
-
- float getLetterSpacing() const {
- return mLetterSpacing;
- }
-
- void setFontFeatureSettings(const std::string &fontFeatureSettings) {
- mFontFeatureSettings = fontFeatureSettings;
- }
-
- std::string getFontFeatureSettings() const {
- return mFontFeatureSettings;
- }
-
- void setMinikinLangListId(uint32_t minikinLangListId) {
- mMinikinLangListId = minikinLangListId;
- }
-
- uint32_t getMinikinLangListId() const {
- return mMinikinLangListId;
- }
-
- void setFontVariant(FontVariant variant) {
- mFontVariant = variant;
- }
-
- FontVariant getFontVariant() const {
- return mFontVariant;
- }
-
- void setHyphenEdit(uint32_t hyphen) {
- mHyphenEdit = hyphen;
- }
-
- uint32_t getHyphenEdit() const {
- return mHyphenEdit;
- }
-
-private:
- float mLetterSpacing = 0;
- std::string mFontFeatureSettings;
- uint32_t mMinikinLangListId;
- FontVariant mFontVariant;
- uint32_t mHyphenEdit = 0;
-};
-
-} // namespace android
-
-#endif // ANDROID_GRAPHICS_PAINT_H_
diff --git a/core/jni/android/graphics/PaintImpl.cpp b/core/jni/android/graphics/PaintImpl.cpp
deleted file mode 100644
index bd513ae..0000000
--- a/core/jni/android/graphics/PaintImpl.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "Paint.h"
-#include <SkPaint.h>
-
-#define LOG_TAG "Paint"
-#include <cutils/log.h>
-
-namespace android {
-
-Paint::Paint() :
- SkPaint(), mLetterSpacing(0), mFontFeatureSettings(), mMinikinLangListId(0),
- mFontVariant(VARIANT_DEFAULT) {
-}
-
-Paint::Paint(const Paint& paint) : SkPaint(paint),
- mLetterSpacing(paint.mLetterSpacing), mFontFeatureSettings(paint.mFontFeatureSettings),
- mMinikinLangListId(paint.mMinikinLangListId), mFontVariant(paint.mFontVariant),
- mHyphenEdit(paint.mHyphenEdit) {
-}
-
-Paint::~Paint() {
-}
-
-Paint& Paint::operator=(const Paint& other) {
- SkPaint::operator=(other);
- mLetterSpacing = other.mLetterSpacing;
- mFontFeatureSettings = other.mFontFeatureSettings;
- mMinikinLangListId = other.mMinikinLangListId;
- mFontVariant = other.mFontVariant;
- mHyphenEdit = other.mHyphenEdit;
- return *this;
-}
-
-bool operator==(const Paint& a, const Paint& b) {
- return static_cast<const SkPaint&>(a) == static_cast<const SkPaint&>(b)
- && a.mLetterSpacing == b.mLetterSpacing
- && a.mFontFeatureSettings == b.mFontFeatureSettings
- && a.mMinikinLangListId == b.mMinikinLangListId
- && a.mFontVariant == b.mFontVariant
- && a.mHyphenEdit == b.mHyphenEdit;
-}
-
-}
diff --git a/core/jni/android/graphics/Picture.cpp b/core/jni/android/graphics/Picture.cpp
index 6e83f1b..07e14a2 100644
--- a/core/jni/android/graphics/Picture.cpp
+++ b/core/jni/android/graphics/Picture.cpp
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-#include "Canvas.h"
#include "Picture.h"
#include "SkStream.h"
#include <memory>
+#include <hwui/Canvas.h>
namespace android {
diff --git a/core/jni/android/graphics/Rasterizer.cpp b/core/jni/android/graphics/Rasterizer.cpp
index a106ecf..3784f0d 100644
--- a/core/jni/android/graphics/Rasterizer.cpp
+++ b/core/jni/android/graphics/Rasterizer.cpp
@@ -22,10 +22,11 @@
#include "jni.h"
#include "GraphicsJNI.h"
-#include "Paint.h"
#include "SkLayerRasterizer.h"
#include "core_jni_helpers.h"
+#include <hwui/Paint.h>
+
// Rasterizer.java holds a pointer (jlong) to this guy
class NativeRasterizer {
public:
diff --git a/core/jni/android/graphics/Typeface.cpp b/core/jni/android/graphics/Typeface.cpp
index e97b768..8e2572c 100644
--- a/core/jni/android/graphics/Typeface.cpp
+++ b/core/jni/android/graphics/Typeface.cpp
@@ -20,9 +20,9 @@
#include "GraphicsJNI.h"
#include "ScopedPrimitiveArray.h"
#include "SkTypeface.h"
-#include "TypefaceImpl.h"
#include <android_runtime/android_util_AssetManager.h>
#include <androidfw/AssetManager.h>
+#include <hwui/TypefaceImpl.h>
using namespace android;
@@ -58,7 +58,12 @@
static jlong Typeface_createFromArray(JNIEnv *env, jobject, jlongArray familyArray) {
ScopedLongArrayRO families(env, familyArray);
- return reinterpret_cast<jlong>(TypefaceImpl_createFromFamilies(families.get(), families.size()));
+ std::vector<FontFamily*> familyVec;
+ for (size_t i = 0; i < families.size(); i++) {
+ FontFamily* family = reinterpret_cast<FontFamily*>(families[i]);
+ familyVec.push_back(family);
+ }
+ return reinterpret_cast<jlong>(TypefaceImpl_createFromFamilies(familyVec));
}
static void Typeface_setDefault(JNIEnv *env, jobject, jlong faceHandle) {
diff --git a/core/jni/android/graphics/TypefaceImpl.cpp b/core/jni/android/graphics/TypefaceImpl.cpp
deleted file mode 100644
index da56290..0000000
--- a/core/jni/android/graphics/TypefaceImpl.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * This is the implementation of the Typeface object. Historically, it has
- * just been SkTypeface, but we are migrating to Minikin. For the time
- * being, that choice is hidden under the USE_MINIKIN compile-time flag.
- */
-
-#define LOG_TAG "TypefaceImpl"
-
-#include "jni.h" // for jlong, remove when being passed proper type
-
-#include "SkTypeface.h"
-
-#include <vector>
-#include <minikin/FontCollection.h>
-#include <minikin/FontFamily.h>
-#include <minikin/Layout.h>
-#include "SkPaint.h"
-#include "MinikinSkia.h"
-
-#include "TypefaceImpl.h"
-#include "Utils.h"
-
-namespace android {
-
-// Resolve the 1..9 weight based on base weight and bold flag
-static void resolveStyle(TypefaceImpl* typeface) {
- int weight = typeface->fBaseWeight / 100;
- if (typeface->fSkiaStyle & SkTypeface::kBold) {
- weight += 3;
- }
- if (weight > 9) {
- weight = 9;
- }
- bool italic = (typeface->fSkiaStyle & SkTypeface::kItalic) != 0;
- typeface->fStyle = FontStyle(weight, italic);
-}
-
-TypefaceImpl* gDefaultTypeface = NULL;
-pthread_once_t gDefaultTypefaceOnce = PTHREAD_ONCE_INIT;
-
-// This installs a default typeface (from a hardcoded path) that allows
-// layouts to work (not crash on null pointer) before the default
-// typeface is set.
-// TODO: investigate why layouts are being created before Typeface.java
-// class initialization.
-static FontCollection *makeFontCollection() {
- std::vector<FontFamily *>typefaces;
- const char *fns[] = {
- "/system/fonts/Roboto-Regular.ttf",
- };
-
- FontFamily *family = new FontFamily();
- for (size_t i = 0; i < sizeof(fns)/sizeof(fns[0]); i++) {
- const char *fn = fns[i];
- ALOGD("makeFontCollection adding %s", fn);
- SkTypeface *skFace = SkTypeface::CreateFromFile(fn);
- if (skFace != NULL) {
- MinikinFont *font = new MinikinFontSkia(skFace);
- family->addFont(font);
- font->Unref();
- } else {
- ALOGE("failed to create font %s", fn);
- }
- }
- typefaces.push_back(family);
-
- FontCollection *result = new FontCollection(typefaces);
- family->Unref();
- return result;
-}
-
-static void getDefaultTypefaceOnce() {
- Layout::init();
- if (gDefaultTypeface == NULL) {
- // We expect the client to set a default typeface, but provide a
- // default so we can make progress before that happens.
- gDefaultTypeface = new TypefaceImpl;
- gDefaultTypeface->fFontCollection = makeFontCollection();
- gDefaultTypeface->fSkiaStyle = SkTypeface::kNormal;
- gDefaultTypeface->fBaseWeight = 400;
- resolveStyle(gDefaultTypeface);
- }
-}
-
-TypefaceImpl* TypefaceImpl_resolveDefault(TypefaceImpl* src) {
- if (src == NULL) {
- pthread_once(&gDefaultTypefaceOnce, getDefaultTypefaceOnce);
- return gDefaultTypeface;
- } else {
- return src;
- }
-}
-
-TypefaceImpl* TypefaceImpl_createFromTypeface(TypefaceImpl* src, SkTypeface::Style style) {
- TypefaceImpl* resolvedFace = TypefaceImpl_resolveDefault(src);
- TypefaceImpl* result = new TypefaceImpl;
- if (result != 0) {
- result->fFontCollection = resolvedFace->fFontCollection;
- result->fFontCollection->Ref();
- result->fSkiaStyle = style;
- result->fBaseWeight = resolvedFace->fBaseWeight;
- resolveStyle(result);
- }
- return result;
-}
-
-TypefaceImpl* TypefaceImpl_createWeightAlias(TypefaceImpl* src, int weight) {
- TypefaceImpl* resolvedFace = TypefaceImpl_resolveDefault(src);
- TypefaceImpl* result = new TypefaceImpl;
- if (result != 0) {
- result->fFontCollection = resolvedFace->fFontCollection;
- result->fFontCollection->Ref();
- result->fSkiaStyle = resolvedFace->fSkiaStyle;
- result->fBaseWeight = weight;
- resolveStyle(result);
- }
- return result;
-}
-
-TypefaceImpl* TypefaceImpl_createFromFamilies(const jlong* families, size_t size) {
- std::vector<FontFamily *>familyVec;
- for (size_t i = 0; i < size; i++) {
- FontFamily* family = reinterpret_cast<FontFamily*>(families[i]);
- familyVec.push_back(family);
- }
- TypefaceImpl* result = new TypefaceImpl;
- result->fFontCollection = new FontCollection(familyVec);
- if (size == 0) {
- ALOGW("createFromFamilies creating empty collection");
- result->fSkiaStyle = SkTypeface::kNormal;
- } else {
- const FontStyle defaultStyle;
- FontFamily* firstFamily = reinterpret_cast<FontFamily*>(families[0]);
- MinikinFont* mf = firstFamily->getClosestMatch(defaultStyle).font;
- if (mf != NULL) {
- SkTypeface* skTypeface = reinterpret_cast<MinikinFontSkia*>(mf)->GetSkTypeface();
- // TODO: probably better to query more precise style from family, will be important
- // when we open up API to access 100..900 weights
- result->fSkiaStyle = skTypeface->style();
- } else {
- result->fSkiaStyle = SkTypeface::kNormal;
- }
- }
- result->fBaseWeight = 400;
- resolveStyle(result);
- return result;
-}
-
-void TypefaceImpl_unref(TypefaceImpl* face) {
- if (face != NULL) {
- face->fFontCollection->Unref();
- }
- delete face;
-}
-
-int TypefaceImpl_getStyle(TypefaceImpl* face) {
- return face->fSkiaStyle;
-}
-
-void TypefaceImpl_setDefault(TypefaceImpl* face) {
- gDefaultTypeface = face;
-}
-
-}
diff --git a/core/jni/android/graphics/TypefaceImpl.h b/core/jni/android/graphics/TypefaceImpl.h
deleted file mode 100644
index 4b14917..0000000
--- a/core/jni/android/graphics/TypefaceImpl.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef _ANDROID_GRAPHICS_TYPEFACE_IMPL_H_
-#define _ANDROID_GRAPHICS_TYPEFACE_IMPL_H_
-
-#include "jni.h" // for jlong, eventually remove
-#include "SkTypeface.h"
-#include <androidfw/AssetManager.h>
-
-#include <minikin/FontCollection.h>
-
-namespace android {
-
-struct TypefaceImpl {
- FontCollection *fFontCollection;
-
- // style used for constructing and querying Typeface objects
- SkTypeface::Style fSkiaStyle;
- // base weight in CSS-style units, 100..900
- int fBaseWeight;
-
- // resolved style actually used for rendering
- FontStyle fStyle;
-};
-
-// Note: it would be cleaner if the following functions were member
-// functions (static or otherwise) of the TypefaceImpl class. However,
-// that can't be easily accommodated in the case where TypefaceImpl
-// is just a pointer to SkTypeface, in the non-USE_MINIKIN case.
-// TODO: when #ifdef USE_MINIKIN is removed, move to member functions.
-
-TypefaceImpl* TypefaceImpl_resolveDefault(TypefaceImpl* src);
-
-TypefaceImpl* TypefaceImpl_createFromTypeface(TypefaceImpl* src, SkTypeface::Style style);
-
-TypefaceImpl* TypefaceImpl_createWeightAlias(TypefaceImpl* src, int baseweight);
-
-// When we remove the USE_MINIKIN ifdef, probably a good idea to move the casting
-// (from jlong to FontFamily*) to the caller in Typeface.cpp.
-TypefaceImpl* TypefaceImpl_createFromFamilies(const jlong* families, size_t size);
-
-void TypefaceImpl_unref(TypefaceImpl* face);
-
-int TypefaceImpl_getStyle(TypefaceImpl* face);
-
-void TypefaceImpl_setDefault(TypefaceImpl* face);
-
-}
-
-#endif // _ANDROID_GRAPHICS_TYPEFACE_IMPL_H_
diff --git a/core/jni/android/graphics/pdf/PdfDocument.cpp b/core/jni/android/graphics/pdf/PdfDocument.cpp
index 5d496e5..88e37e5 100644
--- a/core/jni/android/graphics/pdf/PdfDocument.cpp
+++ b/core/jni/android/graphics/pdf/PdfDocument.cpp
@@ -19,7 +19,6 @@
#include "core_jni_helpers.h"
#include <vector>
-#include "Canvas.h"
#include "CreateJavaOutputStreamAdaptor.h"
#include "SkDocument.h"
@@ -28,6 +27,8 @@
#include "SkStream.h"
#include "SkRect.h"
+#include <hwui/Canvas.h>
+
namespace android {
struct PageRecord {
diff --git a/core/jni/android_graphics_Canvas.cpp b/core/jni/android_graphics_Canvas.cpp
index cf73316..094f3c5 100644
--- a/core/jni/android_graphics_Canvas.cpp
+++ b/core/jni/android_graphics_Canvas.cpp
@@ -19,15 +19,14 @@
#include "core_jni_helpers.h"
#include <androidfw/ResourceTypes.h>
-#include <Canvas.h>
+#include <hwui/Canvas.h>
+#include <hwui/Paint.h>
+#include <hwui/TypefaceImpl.h>
+#include <minikin/Layout.h>
#include "Bitmap.h"
#include "SkDrawFilter.h"
#include "SkGraphics.h"
-#include "Paint.h"
-#include "TypefaceImpl.h"
-
-#include "MinikinUtils.h"
namespace android {
@@ -475,111 +474,13 @@
vertA.ptr(), colorA.ptr(), paint);
}
-static void simplifyPaint(int color, SkPaint* paint) {
- paint->setColor(color);
- paint->setShader(nullptr);
- paint->setColorFilter(nullptr);
- paint->setLooper(nullptr);
- paint->setStrokeWidth(4 + 0.04 * paint->getTextSize());
- paint->setStrokeJoin(SkPaint::kRound_Join);
- paint->setLooper(nullptr);
-}
-
-class DrawTextFunctor {
-public:
- DrawTextFunctor(const Layout& layout, Canvas* canvas, uint16_t* glyphs, float* pos,
- const SkPaint& paint, float x, float y, MinikinRect& bounds,
- float totalAdvance)
- : layout(layout), canvas(canvas), glyphs(glyphs), pos(pos), paint(paint),
- x(x), y(y), bounds(bounds), totalAdvance(totalAdvance) { }
-
- void operator()(size_t start, size_t end) {
- if (canvas->drawTextAbsolutePos()) {
- for (size_t i = start; i < end; i++) {
- glyphs[i] = layout.getGlyphId(i);
- pos[2 * i] = x + layout.getX(i);
- pos[2 * i + 1] = y + layout.getY(i);
- }
- } else {
- for (size_t i = start; i < end; i++) {
- glyphs[i] = layout.getGlyphId(i);
- pos[2 * i] = layout.getX(i);
- pos[2 * i + 1] = layout.getY(i);
- }
- }
-
- size_t glyphCount = end - start;
-
- if (CC_UNLIKELY(canvas->isHighContrastText() && paint.getAlpha() != 0)) {
- // high contrast draw path
- int color = paint.getColor();
- int channelSum = SkColorGetR(color) + SkColorGetG(color) + SkColorGetB(color);
- bool darken = channelSum < (128 * 3);
-
- // outline
- SkPaint outlinePaint(paint);
- simplifyPaint(darken ? SK_ColorWHITE : SK_ColorBLACK, &outlinePaint);
- outlinePaint.setStyle(SkPaint::kStrokeAndFill_Style);
- canvas->drawText(glyphs + start, pos + (2 * start), glyphCount, outlinePaint, x, y,
- bounds.mLeft, bounds.mTop, bounds.mRight, bounds.mBottom, totalAdvance);
-
- // inner
- SkPaint innerPaint(paint);
- simplifyPaint(darken ? SK_ColorBLACK : SK_ColorWHITE, &innerPaint);
- innerPaint.setStyle(SkPaint::kFill_Style);
- canvas->drawText(glyphs + start, pos + (2 * start), glyphCount, innerPaint, x, y,
- bounds.mLeft, bounds.mTop, bounds.mRight, bounds.mBottom, totalAdvance);
- } else {
- // standard draw path
- canvas->drawText(glyphs + start, pos + (2 * start), glyphCount, paint, x, y,
- bounds.mLeft, bounds.mTop, bounds.mRight, bounds.mBottom,
- totalAdvance);
- }
- }
-private:
- const Layout& layout;
- Canvas* canvas;
- uint16_t* glyphs;
- float* pos;
- const SkPaint& paint;
- float x;
- float y;
- MinikinRect& bounds;
- float totalAdvance;
-};
-
-void drawText(Canvas* canvas, const uint16_t* text, int start, int count, int contextCount,
- float x, float y, int bidiFlags, const Paint& origPaint, TypefaceImpl* typeface) {
- // minikin may modify the original paint
- Paint paint(origPaint);
-
- Layout layout;
- MinikinUtils::doLayout(&layout, &paint, bidiFlags, typeface, text, start, count, contextCount);
-
- size_t nGlyphs = layout.nGlyphs();
- std::unique_ptr<uint16_t[]> glyphs(new uint16_t[nGlyphs]);
- std::unique_ptr<float[]> pos(new float[nGlyphs * 2]);
-
- x += MinikinUtils::xOffsetForTextAlign(&paint, layout);
-
- MinikinRect bounds;
- layout.getBounds(&bounds);
- if (!canvas->drawTextAbsolutePos()) {
- bounds.offset(x, y);
- }
-
- DrawTextFunctor f(layout, canvas, glyphs.get(), pos.get(),
- paint, x, y, bounds, layout.getAdvance());
- MinikinUtils::forFontRun(layout, &paint, f);
-}
-
static void drawTextChars(JNIEnv* env, jobject, jlong canvasHandle, jcharArray text,
jint index, jint count, jfloat x, jfloat y, jint bidiFlags,
jlong paintHandle, jlong typefaceHandle) {
Paint* paint = reinterpret_cast<Paint*>(paintHandle);
TypefaceImpl* typeface = reinterpret_cast<TypefaceImpl*>(typefaceHandle);
jchar* jchars = env->GetCharArrayElements(text, NULL);
- drawText(get_canvas(canvasHandle), jchars + index, 0, count, count, x, y,
+ get_canvas(canvasHandle)->drawText(jchars + index, 0, count, count, x, y,
bidiFlags, *paint, typeface);
env->ReleaseCharArrayElements(text, jchars, JNI_ABORT);
}
@@ -591,7 +492,7 @@
TypefaceImpl* typeface = reinterpret_cast<TypefaceImpl*>(typefaceHandle);
const int count = end - start;
const jchar* jchars = env->GetStringChars(text, NULL);
- drawText(get_canvas(canvasHandle), jchars + start, 0, count, count, x, y,
+ get_canvas(canvasHandle)->drawText(jchars + start, 0, count, count, x, y,
bidiFlags, *paint, typeface);
env->ReleaseStringChars(text, jchars);
}
@@ -604,7 +505,7 @@
const int bidiFlags = isRtl ? kBidi_Force_RTL : kBidi_Force_LTR;
jchar* jchars = env->GetCharArrayElements(text, NULL);
- drawText(get_canvas(canvasHandle), jchars + contextIndex, index - contextIndex, count,
+ get_canvas(canvasHandle)->drawText(jchars + contextIndex, index - contextIndex, count,
contextCount, x, y, bidiFlags, *paint, typeface);
env->ReleaseCharArrayElements(text, jchars, JNI_ABORT);
}
@@ -620,53 +521,11 @@
jint count = end - start;
jint contextCount = contextEnd - contextStart;
const jchar* jchars = env->GetStringChars(text, NULL);
- drawText(get_canvas(canvasHandle), jchars + contextStart, start - contextStart, count,
+ get_canvas(canvasHandle)->drawText(jchars + contextStart, start - contextStart, count,
contextCount, x, y, bidiFlags, *paint, typeface);
env->ReleaseStringChars(text, jchars);
}
-class DrawTextOnPathFunctor {
-public:
- DrawTextOnPathFunctor(const Layout& layout, Canvas* canvas, float hOffset,
- float vOffset, const Paint& paint, const SkPath& path)
- : layout(layout), canvas(canvas), hOffset(hOffset), vOffset(vOffset),
- paint(paint), path(path) {
- }
- void operator()(size_t start, size_t end) {
- uint16_t glyphs[1];
- for (size_t i = start; i < end; i++) {
- glyphs[0] = layout.getGlyphId(i);
- float x = hOffset + layout.getX(i);
- float y = vOffset + layout.getY(i);
- canvas->drawTextOnPath(glyphs, 1, path, x, y, paint);
- }
- }
-private:
- const Layout& layout;
- Canvas* canvas;
- float hOffset;
- float vOffset;
- const Paint& paint;
- const SkPath& path;
-};
-
-static void drawTextOnPath(Canvas* canvas, const uint16_t* text, int count, int bidiFlags,
- const SkPath& path, float hOffset, float vOffset,
- const Paint& paint, TypefaceImpl* typeface) {
- Paint paintCopy(paint);
- Layout layout;
- MinikinUtils::doLayout(&layout, &paintCopy, bidiFlags, typeface, text, 0, count, count);
- hOffset += MinikinUtils::hOffsetForTextAlign(&paintCopy, layout, path);
-
- // Set align to left for drawing, as we don't want individual
- // glyphs centered or right-aligned; the offset above takes
- // care of all alignment.
- paintCopy.setTextAlign(Paint::kLeft_Align);
-
- DrawTextOnPathFunctor f(layout, canvas, hOffset, vOffset, paintCopy, path);
- MinikinUtils::forFontRun(layout, &paintCopy, f);
-}
-
static void drawTextOnPathChars(JNIEnv* env, jobject, jlong canvasHandle, jcharArray text,
jint index, jint count, jlong pathHandle, jfloat hOffset,
jfloat vOffset, jint bidiFlags, jlong paintHandle,
@@ -677,7 +536,7 @@
jchar* jchars = env->GetCharArrayElements(text, NULL);
- drawTextOnPath(get_canvas(canvasHandle), jchars + index, count, bidiFlags, *path,
+ get_canvas(canvasHandle)->drawTextOnPath(jchars + index, count, bidiFlags, *path,
hOffset, vOffset, *paint, typeface);
env->ReleaseCharArrayElements(text, jchars, 0);
@@ -693,7 +552,7 @@
const jchar* jchars = env->GetStringChars(text, NULL);
int count = env->GetStringLength(text);
- drawTextOnPath(get_canvas(canvasHandle), jchars, count, bidiFlags, *path,
+ get_canvas(canvasHandle)->drawTextOnPath(jchars, count, bidiFlags, *path,
hOffset, vOffset, *paint, typeface);
env->ReleaseStringChars(text, jchars);
diff --git a/core/jni/android_graphics_drawable_VectorDrawable.cpp b/core/jni/android_graphics_drawable_VectorDrawable.cpp
index e17de17..a2662f9 100644
--- a/core/jni/android_graphics_drawable_VectorDrawable.cpp
+++ b/core/jni/android_graphics_drawable_VectorDrawable.cpp
@@ -19,9 +19,10 @@
#include "core_jni_helpers.h"
#include "log/log.h"
-#include "Paint.h"
#include "VectorDrawable.h"
+#include <hwui/Paint.h>
+
namespace android {
using namespace uirenderer;
using namespace uirenderer::VectorDrawable;
diff --git a/core/jni/android_text_StaticLayout.cpp b/core/jni/android_text_StaticLayout.cpp
index 83f76ea..fddcfa8 100644
--- a/core/jni/android_text_StaticLayout.cpp
+++ b/core/jni/android_text_StaticLayout.cpp
@@ -32,10 +32,12 @@
#include "SkPaint.h"
#include "SkTypeface.h"
-#include "MinikinSkia.h"
-#include "MinikinUtils.h"
-#include "Paint.h"
-#include "minikin/LineBreaker.h"
+#include <hwui/MinikinSkia.h>
+#include <hwui/MinikinUtils.h>
+#include <hwui/Paint.h>
+#include <minikin/FontCollection.h>
+#include <minikin/LineBreaker.h>
+#include <minikin/MinikinFont.h>
namespace android {
diff --git a/core/jni/android_view_DisplayListCanvas.cpp b/core/jni/android_view_DisplayListCanvas.cpp
index c87a770..6aac0e4 100644
--- a/core/jni/android_view_DisplayListCanvas.cpp
+++ b/core/jni/android_view_DisplayListCanvas.cpp
@@ -28,11 +28,11 @@
#include <SkRegion.h>
-#include <Canvas.h>
#include <Rect.h>
#include <RenderNode.h>
#include <CanvasProperty.h>
-#include <Paint.h>
+#include <hwui/Canvas.h>
+#include <hwui/Paint.h>
#include <renderthread/RenderProxy.h>
#include "core_jni_helpers.h"
diff --git a/core/jni/android_view_HardwareLayer.cpp b/core/jni/android_view_HardwareLayer.cpp
index 3a0ddc9..6b774e8 100644
--- a/core/jni/android_view_HardwareLayer.cpp
+++ b/core/jni/android_view_HardwareLayer.cpp
@@ -24,8 +24,8 @@
#include <android_runtime/android_graphics_SurfaceTexture.h>
#include <gui/GLConsumer.h>
+#include <hwui/Paint.h>
-#include <Paint.h>
#include <SkBitmap.h>
#include <SkCanvas.h>
#include <SkMatrix.h>
diff --git a/core/jni/android_view_RenderNode.cpp b/core/jni/android_view_RenderNode.cpp
index a7ac5b8..79b518f 100644
--- a/core/jni/android_view_RenderNode.cpp
+++ b/core/jni/android_view_RenderNode.cpp
@@ -30,7 +30,7 @@
#include <RenderNode.h>
#include <renderthread/CanvasContext.h>
#include <TreeInfo.h>
-#include <Paint.h>
+#include <hwui/Paint.h>
#include "core_jni_helpers.h"