diff options
Diffstat (limited to 'native')
| -rw-r--r-- | native/android/OWNERS | 3 | ||||
| -rw-r--r-- | native/android/input.cpp | 2 | ||||
| -rw-r--r-- | native/android/libandroid.map.txt | 3 | ||||
| -rw-r--r-- | native/android/surface_control.cpp | 58 | ||||
| -rw-r--r-- | native/android/system_fonts.cpp | 40 | ||||
| -rw-r--r-- | native/graphics/jni/imagedecoder.cpp | 6 |
6 files changed, 80 insertions, 32 deletions
diff --git a/native/android/OWNERS b/native/android/OWNERS index cfe973400c98..d41652f2ad17 100644 --- a/native/android/OWNERS +++ b/native/android/OWNERS @@ -23,3 +23,6 @@ per-file hardware_buffer_jni.cpp = file:/graphics/java/android/graphics/OWNERS per-file native_window_jni.cpp = file:/graphics/java/android/graphics/OWNERS per-file surface_control.cpp = file:/graphics/java/android/graphics/OWNERS per-file surface_texture.cpp = file:/graphics/java/android/graphics/OWNERS + +# Input +per-file input.cpp = file:/INPUT_OWNERS diff --git a/native/android/input.cpp b/native/android/input.cpp index a231d8f153e7..812db0f1c507 100644 --- a/native/android/input.cpp +++ b/native/android/input.cpp @@ -295,6 +295,8 @@ int32_t AMotionEvent_getClassification(const AInputEvent* motion_event) { return AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE; case android::MotionClassification::DEEP_PRESS: return AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS; + case android::MotionClassification::TWO_FINGER_SWIPE: + return AMOTION_EVENT_CLASSIFICATION_TWO_FINGER_SWIPE; } } diff --git a/native/android/libandroid.map.txt b/native/android/libandroid.map.txt index 4aa5bbf19682..cb0f22f974ad 100644 --- a/native/android/libandroid.map.txt +++ b/native/android/libandroid.map.txt @@ -238,6 +238,7 @@ LIBANDROID { ASurfaceControl_createFromWindow; # introduced=29 ASurfaceControl_acquire; # introduced=31 ASurfaceControl_release; # introduced=29 + ASurfaceControl_fromSurfaceControl; # introduced=34 ASurfaceTexture_acquireANativeWindow; # introduced=28 ASurfaceTexture_attachToGLContext; # introduced=28 ASurfaceTexture_detachFromGLContext; # introduced=28 @@ -255,6 +256,7 @@ LIBANDROID { ASurfaceTransaction_apply; # introduced=29 ASurfaceTransaction_create; # introduced=29 ASurfaceTransaction_delete; # introduced=29 + ASurfaceTransaction_fromTransaction; # introduced=34 ASurfaceTransaction_reparent; # introduced=29 ASurfaceTransaction_setBuffer; # introduced=29 ASurfaceTransaction_setBufferAlpha; # introduced=29 @@ -266,6 +268,7 @@ LIBANDROID { ASurfaceTransaction_setEnableBackPressure; # introduced=31 ASurfaceTransaction_setFrameRate; # introduced=30 ASurfaceTransaction_setFrameRateWithChangeStrategy; # introduced=31 + ASurfaceTransaction_clearFrameRate; # introduced=34 ASurfaceTransaction_setFrameTimeline; # introduced=Tiramisu ASurfaceTransaction_setGeometry; # introduced=29 ASurfaceTransaction_setHdrMetadata_cta861_3; # introduced=29 diff --git a/native/android/surface_control.cpp b/native/android/surface_control.cpp index 795af8a58351..891379977a6c 100644 --- a/native/android/surface_control.cpp +++ b/native/android/surface_control.cpp @@ -17,6 +17,8 @@ #include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h> #include <android/native_window.h> #include <android/surface_control.h> +#include <android/surface_control_jni.h> +#include <android_runtime/android_view_SurfaceControl.h> #include <configstore/Utils.h> #include <gui/HdrMetadata.h> #include <gui/ISurfaceComposer.h> @@ -28,6 +30,8 @@ #include <ui/DynamicDisplayInfo.h> #include <utils/Timers.h> +#include <utility> + using namespace android::hardware::configstore; using namespace android::hardware::configstore::V1_0; using namespace android; @@ -80,7 +84,7 @@ ASurfaceControl* ASurfaceControl_createFromWindow(ANativeWindow* window, const c Surface* surface = static_cast<Surface*>(window); sp<IBinder> parentHandle = surface->getSurfaceControlHandle(); - uint32_t flags = ISurfaceComposerClient::eFXSurfaceBufferState; + int32_t flags = ISurfaceComposerClient::eFXSurfaceBufferState; sp<SurfaceControl> surfaceControl; if (parentHandle) { surfaceControl = @@ -88,11 +92,8 @@ ASurfaceControl* ASurfaceControl_createFromWindow(ANativeWindow* window, const c // Format is only relevant for buffer queue layers. PIXEL_FORMAT_UNKNOWN /* format */, flags, parentHandle); } else { - surfaceControl = - client->createWithSurfaceParent(String8(debug_name), 0 /* width */, 0 /* height */, - // Format is only relevant for buffer queue layers. - PIXEL_FORMAT_UNKNOWN /* format */, flags, - static_cast<Surface*>(window)); + // deprecated, this should no longer be used + surfaceControl = nullptr; } if (!surfaceControl) { @@ -137,6 +138,21 @@ void ASurfaceControl_release(ASurfaceControl* aSurfaceControl) { SurfaceControl_release(surfaceControl); } +ASurfaceControl* ASurfaceControl_fromSurfaceControl(JNIEnv* env, jobject surfaceControlObj) { + LOG_ALWAYS_FATAL_IF(!env, + "nullptr passed to ASurfaceControl_fromSurfaceControl as env argument"); + LOG_ALWAYS_FATAL_IF(!surfaceControlObj, + "nullptr passed to ASurfaceControl_fromSurfaceControl as surfaceControlObj " + "argument"); + SurfaceControl* surfaceControl = + android_view_SurfaceControl_getNativeSurfaceControl(env, surfaceControlObj); + LOG_ALWAYS_FATAL_IF(!surfaceControl, + "surfaceControlObj passed to ASurfaceControl_fromSurfaceControl is not " + "valid"); + SurfaceControl_acquire(surfaceControl); + return reinterpret_cast<ASurfaceControl*>(surfaceControl); +} + struct ASurfaceControlStats { std::variant<int64_t, sp<Fence>> acquireTimeOrFence; sp<Fence> previousReleaseFence; @@ -193,6 +209,20 @@ void ASurfaceTransaction_delete(ASurfaceTransaction* aSurfaceTransaction) { delete transaction; } +ASurfaceTransaction* ASurfaceTransaction_fromTransaction(JNIEnv* env, jobject transactionObj) { + LOG_ALWAYS_FATAL_IF(!env, + "nullptr passed to ASurfaceTransaction_fromTransaction as env argument"); + LOG_ALWAYS_FATAL_IF(!transactionObj, + "nullptr passed to ASurfaceTransaction_fromTransaction as transactionObj " + "argument"); + Transaction* transaction = + android_view_SurfaceTransaction_getNativeSurfaceTransaction(env, transactionObj); + LOG_ALWAYS_FATAL_IF(!transaction, + "surfaceControlObj passed to ASurfaceTransaction_fromTransaction is not " + "valid"); + return reinterpret_cast<ASurfaceTransaction*>(transaction); +} + void ASurfaceTransaction_apply(ASurfaceTransaction* aSurfaceTransaction) { CHECK_NOT_NULL(aSurfaceTransaction); @@ -622,6 +652,16 @@ void ASurfaceTransaction_setFrameRateWithChangeStrategy(ASurfaceTransaction* aSu transaction->setFrameRate(surfaceControl, frameRate, compatibility, changeFrameRateStrategy); } +void ASurfaceTransaction_clearFrameRate(ASurfaceTransaction* aSurfaceTransaction, + ASurfaceControl* aSurfaceControl) { + CHECK_NOT_NULL(aSurfaceTransaction); + CHECK_NOT_NULL(aSurfaceControl); + Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction); + sp<SurfaceControl> surfaceControl = ASurfaceControl_to_SurfaceControl(aSurfaceControl); + transaction->setFrameRate(surfaceControl, 0, ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT, + ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS); +} + void ASurfaceTransaction_setEnableBackPressure(ASurfaceTransaction* aSurfaceTransaction, ASurfaceControl* aSurfaceControl, bool enableBackpressure) { @@ -669,6 +709,8 @@ void ASurfaceTransaction_setFrameTimeline(ASurfaceTransaction* aSurfaceTransacti AVsyncId vsyncId) { CHECK_NOT_NULL(aSurfaceTransaction); const auto startTime = AChoreographer_getStartTimeNanosForVsyncId(vsyncId); - ASurfaceTransaction_to_Transaction(aSurfaceTransaction) - ->setFrameTimelineInfo({.vsyncId = vsyncId, .startTimeNanos = startTime}); + FrameTimelineInfo ftInfo; + ftInfo.vsyncId = vsyncId; + ftInfo.startTimeNanos = startTime; + ASurfaceTransaction_to_Transaction(aSurfaceTransaction)->setFrameTimelineInfo(ftInfo); } diff --git a/native/android/system_fonts.cpp b/native/android/system_fonts.cpp index 9fe792958cef..30d0c35bcbb0 100644 --- a/native/android/system_fonts.cpp +++ b/native/android/system_fonts.cpp @@ -245,31 +245,23 @@ ASystemFontIterator* ASystemFontIterator_open() { std::unique_ptr<ASystemFontIterator> ite(new ASystemFontIterator()); std::unordered_set<AFont, FontHasher> fonts; - minikin::SystemFonts::getFontMap( - [&fonts](const std::vector<std::shared_ptr<minikin::FontCollection>>& collections) { - for (const auto& fc : collections) { - for (const auto& family : fc->getFamilies()) { - for (uint32_t i = 0; i < family->getNumFonts(); ++i) { - const minikin::Font* font = family->getFont(i); - - std::optional<std::string> locale; - uint32_t localeId = font->getLocaleListId(); - if (localeId != minikin::kEmptyLocaleListId) { - locale.emplace(minikin::getLocaleString(localeId)); - } - std::vector<std::pair<uint32_t, float>> axes; - for (const auto& [tag, value] : font->typeface()->GetAxes()) { - axes.push_back(std::make_pair(tag, value)); - } - - fonts.insert( - {font->typeface()->GetFontPath(), std::move(locale), - font->style().weight(), - font->style().slant() == minikin::FontStyle::Slant::ITALIC, - static_cast<uint32_t>(font->typeface()->GetFontIndex()), - axes}); - } + minikin::SystemFonts::getFontSet( + [&fonts](const std::vector<std::shared_ptr<minikin::Font>>& fontSet) { + for (const auto& font : fontSet) { + std::optional<std::string> locale; + uint32_t localeId = font->getLocaleListId(); + if (localeId != minikin::kEmptyLocaleListId) { + locale.emplace(minikin::getLocaleString(localeId)); } + std::vector<std::pair<uint32_t, float>> axes; + for (const auto& [tag, value] : font->typeface()->GetAxes()) { + axes.push_back(std::make_pair(tag, value)); + } + + fonts.insert({font->typeface()->GetFontPath(), std::move(locale), + font->style().weight(), + font->style().slant() == minikin::FontStyle::Slant::ITALIC, + static_cast<uint32_t>(font->typeface()->GetFontIndex()), axes}); } }); diff --git a/native/graphics/jni/imagedecoder.cpp b/native/graphics/jni/imagedecoder.cpp index bb25274e3136..cd6ed2391608 100644 --- a/native/graphics/jni/imagedecoder.cpp +++ b/native/graphics/jni/imagedecoder.cpp @@ -25,6 +25,12 @@ #include <hwui/ImageDecoder.h> #include <log/log.h> #include <SkAndroidCodec.h> +#include <SkCodec.h> +#include <SkColorSpace.h> +#include <SkImageInfo.h> +#include <SkRect.h> +#include <SkSize.h> +#include <SkStream.h> #include <utils/Color.h> #include <fcntl.h> |