Skip to content

Commit

Permalink
Adapt new wpebackend-android API
Browse files Browse the repository at this point in the history
New WPEBackend-android API introduces sync fence which
is used when posting buffers to surface control
  • Loading branch information
zhani committed Nov 7, 2023
1 parent 5fb3088 commit c61a88f
Show file tree
Hide file tree
Showing 22 changed files with 782 additions and 326 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
java-version: 17
- name: Check Code Format
uses: gradle/gradle-build-action@v2
uses: gradle/gradle-build-action@v2.4.2
with:
arguments: checkFormat

Expand All @@ -31,7 +31,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
java-version: 17
- name: Check JNI
run: |
cd tools/jni-test && \
Expand All @@ -50,13 +50,13 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
java-version: 17
- name: Execute Android Linter
uses: gradle/gradle-build-action@v2
uses: gradle/gradle-build-action@v2.4.2
with:
arguments: lint
- name: Build Project
uses: gradle/gradle-build-action@v2
uses: gradle/gradle-build-action@v2.4.2
with:
arguments: assemble${{ inputs.build_type }}
- name: Save MiniBrowser Artifacts
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ You can optionally create a debug build of WPEWebKit passing the `--debug` optio
```

Finally, the bootstrap option accepts the `--arch` option to set the target architecture.
Currently supported architectures are `arm64`, `armv7`, `x86` and `x86_64`.
Currently supported architectures are `arm64` and `x86_64`.


### Android Studio
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'com.android.application' version '8.0.2' apply false
id 'com.android.library' version '8.0.2' apply false
id 'com.android.application' version '8.1.2' apply false
id 'com.android.library' version '8.1.2' apply false
}

tasks.register("clean", Delete) {
Expand Down
3 changes: 1 addition & 2 deletions tools/mediaplayer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ plugins {
android {
namespace 'com.wpe.tools.mediaplayer'
compileSdk 33
buildToolsVersion '33.0.1'

defaultConfig {
minSdk 29
minSdk 31
targetSdk 33
versionCode 1
versionName '1.0'
Expand Down
15 changes: 7 additions & 8 deletions tools/minibrowser/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ plugins {
android {
namespace 'com.wpe.tools.minibrowser'
compileSdk 33
buildToolsVersion '33.0.1'

defaultConfig {
minSdk 29
minSdk 31
targetSdk 33
versionCode 1
versionName '1.0'
Expand Down Expand Up @@ -46,12 +45,12 @@ android {
dependencies {
implementation project(':wpe')
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.fragment:fragment-ktx:1.6.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.6.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.6.0'
implementation 'androidx.preference:preference-ktx:1.2.0'
implementation 'com.google.android.material:material:1.10.0'
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.fragment:fragment-ktx:1.6.1'
implementation 'androidx.navigation:navigation-fragment-ktx:2.7.4'
implementation 'androidx.navigation:navigation-ui-ktx:2.7.4'
implementation 'androidx.preference:preference-ktx:1.2.1'

modules {
module("org.jetbrains.kotlin:kotlin-stdlib-jdk7") {
Expand Down
8 changes: 2 additions & 6 deletions tools/scripts/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,6 @@ def install_deps(self):

if self._arch == "arm64":
android_abi = "arm64-v8a"
elif self._arch == "armv7":
android_abi = "armeabi-v7a"
elif self._arch == "x86":
android_abi = "x86"
elif self._arch == "x86_64":
android_abi = "x86_64"
else:
Expand Down Expand Up @@ -493,7 +489,7 @@ def run(self):
)

parser.add_argument("-a", "--arch", metavar="architecture", required=False, default=Bootstrap.default_arch,
choices=["arm64", "armv7", "x86", "x86_64", "all"], help="The target architecture")
choices=["arm64", "x86_64", "all"], help="The target architecture")
parser.add_argument("-v", "--version", metavar="version", required=False, default=Bootstrap.default_version,
help="Specify the wpewebkit version to use (ignored if using --cerbero or --build, "
"in these cases the version is taken from the Cerbero build)")
Expand All @@ -510,7 +506,7 @@ def run(self):

args = parser.parse_args()
if args.arch == "all":
for arch in ["arm64", "armv7", "x86", "x86_64"]:
for arch in ["arm64", "x86_64"]:
args.arch = arch
print(args)
Bootstrap(args).run()
Expand Down
2 changes: 1 addition & 1 deletion tools/scripts/build-patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def run(self):
)

parser.add_argument("-a", "--arch", metavar="architecture", required=False, default=Bootstrap.default_arch,
choices=["arm64", "armv7", "x86", "x86_64"], help="The target architecture")
choices=["arm64", "x86_64"], help="The target architecture")
parser.add_argument("-r", "--recipe", metavar="recipe", required=False, default=BuildPatch.default_recipe,
help="Specify the Cerbero recipe to build")
parser.add_argument("-c", "--cerbero", metavar="path", required=False, help="Path to an external Cerbero build")
Expand Down
7 changes: 3 additions & 4 deletions wpe/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ plugins {
android {
namespace 'com.wpe.wpe'
compileSdk 33
buildToolsVersion '34.0.0'
ndkVersion '25.2.9519653'

defaultConfig {
minSdk 29
minSdk 31
targetSdk 33
}

Expand Down Expand Up @@ -86,13 +85,13 @@ android {
}

dependencies {
implementation 'androidx.annotation:annotation:1.6.0'
implementation 'androidx.annotation:annotation:1.7.0'
}

gradle.afterProject { project ->
if (project == getProject()) {
def abiList = []
for (abi in ['x86_64', 'x86', 'arm64-v8a', 'armeabi-v7a']) {
for (abi in ['x86_64', 'arm64-v8a']) {
if (file("src/main/jniLibs/$abi").isDirectory())
abiList.add(abi)
}
Expand Down
48 changes: 48 additions & 0 deletions wpe/src/main/cpp/Browser/Fence.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Copyright (C) 2023 Igalia S.L. <[email protected]>
* Author: Jani Hautakangas <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "Fence.h"

#include <algorithm>
#include <android/sync.h>
#include <memory>
#include <poll.h>

using sync_file_info_data = struct sync_file_info;

Fence::FenceStatus Fence::getStatus(int fileDescriptor)
{
auto info = std::unique_ptr<sync_file_info_data, void (*)(sync_file_info_data*)> {
sync_file_info(fileDescriptor), sync_file_info_free};
if (info == nullptr) {
return FenceStatus::Invalid;
}

if (info->status != 1) {
return FenceStatus::NotSignaled;
}

__u64 timestamp = 0U;
auto* fenceInfo = sync_get_fence_info(info.get());
for (size_t i = 0; i < info->num_fences; i++) {
timestamp = std::max(timestamp, fenceInfo->timestamp_ns);
}

return FenceStatus::Signaled;
}
31 changes: 31 additions & 0 deletions wpe/src/main/cpp/Browser/Fence.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright (C) 2023 Igalia S.L. <[email protected]>
* Author: Jani Hautakangas <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#pragma once

class Fence {
public:
enum FenceStatus {
Signaled,
NotSignaled,
Invalid
};

static FenceStatus getStatus(int fileDescriptor);
};
Loading

0 comments on commit c61a88f

Please sign in to comment.