Compare commits

...

10 Commits

Author SHA1 Message Date
1074a1e59a integrate RMLUI library 2026-01-03 12:17:19 +01:00
784e054105 setup vcpkg 2026-01-02 21:38:41 +01:00
16dd10f9a6 support multiple listeners based on pid 2026-01-02 15:01:16 +01:00
3a410775b5 async tasks 2025-12-31 16:12:43 +01:00
f3a69571a2 more refactoring 2025-12-30 19:05:02 +01:00
ce19309e05 refactor into files 2025-12-30 15:17:18 +01:00
d3eae79aa3 assets manager and shader classes 2025-12-30 14:19:13 +01:00
e576011ebb fix hardware buffer aidl 2025-12-30 13:49:01 +01:00
2ee6543d51 fix egl extensions loader 2025-12-30 09:58:43 +01:00
66df0e66e2 add events listener object, create kernel context and some gl resources 2025-12-29 19:16:05 +01:00
116 changed files with 5136 additions and 60 deletions

View File

@@ -4,6 +4,9 @@ plugins {
alias(libs.plugins.kotlin.compose)
}
val vcpkgHome = "/Users/omar/vcpkg"
val ndkHome = "/Users/omar/Library/Android/sdk/ndk/29.0.14206865"
android {
namespace = "com.omixlab.mosis"
@@ -14,13 +17,23 @@ android {
defaultConfig {
applicationId = "com.omixlab.mosis"
minSdk = 33
minSdk = 34
targetSdk = 36
versionCode = 1
versionName = "1.0"
ndk {
abiFilters += listOf("arm64-v8a")
}
externalNativeBuild {
cmake {
//arguments += "--trace-expand"
cppFlags += ""
arguments += "-DANDROID_STL=c++_shared"
arguments += "-DCMAKE_TOOLCHAIN_FILE=$vcpkgHome/scripts/buildsystems/vcpkg.cmake"
arguments += "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=$ndkHome/build/cmake/android.toolchain.cmake"
arguments += "-DVCPKG_TARGET_TRIPLET=arm64-android"
targets += "mosis-service"
targets += "mosis-test"
}
}
}

View File

@@ -0,0 +1,3 @@
package android.hardware;
@JavaOnlyStableParcelable @NdkOnlyStableParcelable parcelable HardwareBuffer ndk_header "android/hardware_buffer_aidl.h";

View File

@@ -0,0 +1,10 @@
package com.omixlab.mosis;
import android.hardware.HardwareBuffer;
// oneway = fire-and-forget (asynchronous)
oneway interface IMosisListener {
void onServiceInitialized(boolean success);
void onBufferAvailable(in HardwareBuffer buffer);
void onFrameAvailable();
}

View File

@@ -1,6 +1,8 @@
package com.omixlab.mosis;
import com.omixlab.mosis.IMosisListener;
interface IMosisService {
boolean initOS();
boolean initOS(IMosisListener listener);
int getNumber();
}

212
src/main/assets/LICENSE.txt Normal file
View File

@@ -0,0 +1,212 @@
The RmlUi samples include fonts that are separately licensed. They are listed
below along with their licenses.
-----------------------------------------------------------
-----------------------------------------------------------
--- Lato ---
--- http://www.latofonts.com/ ---
--- ---
--- LatoLatin-Bold.ttf ---
--- LatoLatin-BoldItalic.ttf ---
--- LatoLatin-Italic.ttf ---
--- LatoLatin-Regular.ttf ---
-----------------------------------------------------------
-----------------------------------------------------------
Copyright (c) 2010-2015, Łukasz Dziedzic (dziedzic@typoland.com),
with Reserved Font Name Lato.
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
-----------------------------------------------------------
-----------------------------------------------------------
--- Noto Emoji ---
--- https://www.google.com/get/noto/ ---
--- ---
--- NotoEmoji-Regular.ttf ---
-----------------------------------------------------------
-----------------------------------------------------------
This Font Software is licensed under the SIL Open Font License,
Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font
creation efforts of academic and linguistic communities, and to
provide a free and open framework in which fonts may be shared and
improved in partnership with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply to
any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software
components as distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to,
deleting, or substituting -- in part or in whole -- any of the
components of the Original Version, by changing formats or by porting
the Font Software to a new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed,
modify, redistribute, and sell modified and unmodified copies of the
Font Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components, in
Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the
corresponding Copyright Holder. This restriction only applies to the
primary font name as presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created using
the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,93 @@
Copyright 2011 The Roboto Project Authors (https://github.com/googlefonts/roboto-classic)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://openfontlicense.org
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

View File

@@ -0,0 +1,118 @@
Roboto Variable Font
====================
This download contains Roboto as both variable fonts and static fonts.
Roboto is a variable font with these axes:
wdth
wght
This means all the styles are contained in these files:
Roboto-VariableFont_wdth,wght.ttf
Roboto-Italic-VariableFont_wdth,wght.ttf
If your app fully supports variable fonts, you can now pick intermediate styles
that arent available as static fonts. Not all apps support variable fonts, and
in those cases you can use the static font files for Roboto:
static/Roboto_Condensed-Thin.ttf
static/Roboto_Condensed-ExtraLight.ttf
static/Roboto_Condensed-Light.ttf
static/Roboto_Condensed-Regular.ttf
static/Roboto_Condensed-Medium.ttf
static/Roboto_Condensed-SemiBold.ttf
static/Roboto_Condensed-Bold.ttf
static/Roboto_Condensed-ExtraBold.ttf
static/Roboto_Condensed-Black.ttf
static/Roboto_SemiCondensed-Thin.ttf
static/Roboto_SemiCondensed-ExtraLight.ttf
static/Roboto_SemiCondensed-Light.ttf
static/Roboto_SemiCondensed-Regular.ttf
static/Roboto_SemiCondensed-Medium.ttf
static/Roboto_SemiCondensed-SemiBold.ttf
static/Roboto_SemiCondensed-Bold.ttf
static/Roboto_SemiCondensed-ExtraBold.ttf
static/Roboto_SemiCondensed-Black.ttf
static/Roboto-Thin.ttf
static/Roboto-ExtraLight.ttf
static/Roboto-Light.ttf
static/Roboto-Regular.ttf
static/Roboto-Medium.ttf
static/Roboto-SemiBold.ttf
static/Roboto-Bold.ttf
static/Roboto-ExtraBold.ttf
static/Roboto-Black.ttf
static/Roboto_Condensed-ThinItalic.ttf
static/Roboto_Condensed-ExtraLightItalic.ttf
static/Roboto_Condensed-LightItalic.ttf
static/Roboto_Condensed-Italic.ttf
static/Roboto_Condensed-MediumItalic.ttf
static/Roboto_Condensed-SemiBoldItalic.ttf
static/Roboto_Condensed-BoldItalic.ttf
static/Roboto_Condensed-ExtraBoldItalic.ttf
static/Roboto_Condensed-BlackItalic.ttf
static/Roboto_SemiCondensed-ThinItalic.ttf
static/Roboto_SemiCondensed-ExtraLightItalic.ttf
static/Roboto_SemiCondensed-LightItalic.ttf
static/Roboto_SemiCondensed-Italic.ttf
static/Roboto_SemiCondensed-MediumItalic.ttf
static/Roboto_SemiCondensed-SemiBoldItalic.ttf
static/Roboto_SemiCondensed-BoldItalic.ttf
static/Roboto_SemiCondensed-ExtraBoldItalic.ttf
static/Roboto_SemiCondensed-BlackItalic.ttf
static/Roboto-ThinItalic.ttf
static/Roboto-ExtraLightItalic.ttf
static/Roboto-LightItalic.ttf
static/Roboto-Italic.ttf
static/Roboto-MediumItalic.ttf
static/Roboto-SemiBoldItalic.ttf
static/Roboto-BoldItalic.ttf
static/Roboto-ExtraBoldItalic.ttf
static/Roboto-BlackItalic.ttf
Get started
-----------
1. Install the font files you want to use
2. Use your app's font picker to view the font family and all the
available styles
Learn more about variable fonts
-------------------------------
https://developers.google.com/web/fundamentals/design-and-ux/typography/variable-fonts
https://variablefonts.typenetwork.com
https://medium.com/variable-fonts
In desktop apps
https://theblog.adobe.com/can-variable-fonts-illustrator-cc
https://helpx.adobe.com/nz/photoshop/using/fonts.html#variable_fonts
Online
https://developers.google.com/fonts/docs/getting_started
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Fonts/Variable_Fonts_Guide
https://developer.microsoft.com/en-us/microsoft-edge/testdrive/demos/variable-fonts
Installing fonts
MacOS: https://support.apple.com/en-us/HT201749
Linux: https://www.google.com/search?q=how+to+install+a+font+on+gnu%2Blinux
Windows: https://support.microsoft.com/en-us/help/314960/how-to-install-or-remove-a-font-in-windows
Android Apps
https://developers.google.com/fonts/docs/android
https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts
License
-------
Please read the full license text (OFL.txt) to understand the permissions,
restrictions and requirements for usage, redistribution, and modification.
You can use them in your products & projects print or digital,
commercial or otherwise.
This isn't legal advice, please consider consulting a lawyer and see the full
license for all details.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

28
src/main/assets/demo.rml Normal file
View File

@@ -0,0 +1,28 @@
<rml>
<head>
<title>Demo</title>
<link type="text/template" href="window.rml" />
<style>
body
{
width: 300dp;
height: 225dp;
margin: auto;
}
div#title_bar div#icon
{
display: none;
}
div#content
{
text-align: left;
}
</style>
</head>
<body template="window">
This is a sample.
</body>
</rml>

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -0,0 +1,13 @@
<rml>
<head>
<title>Hello world</title>
<link type="text/rcss" href="rml.rcss"/>
<link type="text/rcss" href="window.rcss"/>
</head>
<body data-model="animals">
<h1>RmlUi</h1>
<p>Hello <span id="world">world</span>!</p>
<p data-if="show_text">The quick brown fox jumps over the lazy {{animal}}.</p>
<input type="text" data-value="animal"/>
</body>
</rml>

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@@ -0,0 +1,765 @@
@spritesheet theme
{
src: invader.tga;
/* For high dpi screens, designates the scaling it is intended to be shown at. */
resolution: 1x;
/**
The following specifies a list of sprite names and associated rectangles into the image given above.
Any sprite given here can be specified in a decorator. Their names must be globally unique.
Rectangles are specified as: x y width height. With the origin assumed to be at the top left corner.
*/
title-bar-l: 147px 0px 82px 85px;
title-bar-c: 229px 0px 1px 85px;
title-bar-r: 231px 0px 15px 85px;
/* huditems are vertically flipped titlebars */
huditem-l: 147px 55px 82px -55px;
huditem-c: 229px 55px 1px -55px;
huditem-r: 231px 55px 15px -55px;
icon-help: 128px 152px 51px 39px;
icon-invader: 179px 152px 51px 39px;
icon-game: 230px 152px 51px 39px;
icon-hiscore: 281px 152px 51px 39px;
icon-waves: 332px 152px 51px 39px;
icon-flag: 336px 191px 51px 39px;
icon-lives: 383px 152px 51px 39px;
icon-score: 434px 152px 51px 39px;
window-tl: 0px 0px 133px 140px;
window-t: 134px 0px 1px 140px;
window-tr: 136px 0px 10px 140px;
window-l: 0px 139px 10px 1px;
window-c: 11px 139px 1px 1px;
window-r: 10px 139px -10px 1px; /* mirrored left */
window-bl: 0px 140px 11px 11px;
window-b: 11px 140px 1px 11px;
window-br: 136px 140px 10px 11px;
button: 247px 0px 159px 45px;
button-hover: 247px 45px 159px 45px;
button-active: 247px 90px 159px 45px;
button-inner: 259px 19px 135px 1px;
button-inner-hover: 259px 64px 135px 1px;
button-inner-active: 259px 109px 135px 1px;
text-l: 162px 192px 14px 31px;
text-c: 176px 192px 1px 31px;
text-focus-l: 162px 230px 14px 31px;
text-focus-c: 176px 230px 1px 31px;
textarea: 162px 193px 145px 31px;
textarea-inner: 173px 206px 127px 10px;
textarea-focus: 162px 231px 145px 31px;
textarea-focus-inner: 173px 244px 127px 10px;
selectbox-tl: 281px 275px 11px 9px;
selectbox-t: 292px 275px 1px 9px;
selectbox-tr: 294px 275px 11px 9px;
selectbox-l: 281px 283px 11px 1px;
selectbox-c: 292px 283px 1px 1px;
selectbox-bl: 281px 285px 11px 11px;
selectbox-b: 292px 285px 1px 11px;
selectbox-br: 294px 285px 11px 11px;
selectvalue: 162px 192px 145px 37px;
selectvalue-hover: 162px 230px 145px 37px;
selectarrow: 307px 192px 30px 37px;
selectarrow-hover: 307px 230px 30px 37px;
selectarrow-active: 307px 268px 30px 37px;
radio: 407px 0px 30px 30px;
radio-hover: 437px 0px 30px 30px;
radio-active: 467px 0px 30px 30px;
radio-checked: 407px 30px 30px 30px;
radio-checked-hover: 437px 30px 30px 30px;
radio-checked-active: 467px 30px 30px 30px;
checkbox: 407px 60px 30px 30px;
checkbox-hover: 437px 60px 30px 30px;
checkbox-active: 467px 60px 30px 30px;
checkbox-checked: 407px 90px 30px 30px;
checkbox-checked-hover: 437px 90px 30px 30px;
checkbox-checked-active: 467px 90px 30px 30px;
tableheader-l: 127px 192px 16px 31px;
tableheader-c: 143px 192px 2px 31px;
tableheader-r: 145px 192px 15px 31px;
expand: 3px 232px 17px 17px;
expand-hover: 21px 232px 17px 17px;
expand-active: 39px 232px 17px 17px;
expand-collapsed: 3px 250px 17px 17px;
expand-collapsed-hover: 21px 250px 17px 17px;
expand-collapsed-active: 39px 250px 17px 17px;
slidertrack-t: 70px 199px 27px 2px;
slidertrack-c: 70px 201px 27px 1px;
slidertrack-b: 70px 202px 27px 2px;
sliderbar-t: 56px 152px 23px 23px;
sliderbar-c: 56px 175px 23px 1px;
sliderbar-b: 56px 176px 23px 22px;
sliderbar-hover-t: 80px 152px 23px 23px;
sliderbar-hover-c: 80px 175px 23px 1px;
sliderbar-hover-b: 80px 176px 23px 22px;
sliderbar-active-t: 104px 152px 23px 23px;
sliderbar-active-c: 104px 175px 23px 1px;
sliderbar-active-b: 104px 176px 23px 22px;
sliderarrowdec: 0px 152px 27px 24px;
sliderarrowdec-hover: 0px 177px 27px 24px;
sliderarrowdec-active: 0px 202px 27px 24px;
sliderarrowinc: 28px 152px 27px 24px;
sliderarrowinc-hover: 28px 177px 27px 24px;
sliderarrowinc-active: 28px 202px 27px 24px;
range-track: 219px 194px 3px 32px;
range-track-inner: 220px 204px 1px 14px;
range-track-focus: 219px 232px 3px 32px;
range-track-focus-inner: 220px 242px 1px 14px;
range-bar: 127px 191px 34px 32px;
range-dec: 3px 232px 17px 17px;
range-dec-hover: 21px 232px 17px 17px;
range-dec-active: 39px 232px 17px 17px;
range-inc: 3px 250px 17px 17px;
range-inc-hover: 21px 250px 17px 17px;
range-inc-active: 39px 250px 17px 17px;
progress-l: 103px 267px 13px 34px;
progress-c: 116px 267px 54px 34px;
progress-r: 170px 267px 13px 34px;
progress-fill-l: 110px 302px 6px 34px;
progress-fill-c: 140px 302px 6px 34px;
progress-fill-r: 170px 302px 6px 34px;
gauge: 0px 271px 100px 86px;
gauge-fill: 0px 356px 100px 86px;
}
body
{
font-family: LatoLatin;
font-weight: normal;
font-style: normal;
font-size: 15dp;
color: white;
nav: auto;
}
body.window
{
padding-top: 43dp;
padding-bottom: 20dp;
min-width: 250dp;
max-width: 800dp;
min-height: 135dp;
max-height: 700dp;
}
div#title_bar
{
z-index: 1;
position: absolute;
top: 7dp;
left: 0;
text-align: left;
vertical-align: bottom;
}
div#title_bar div#icon
{
position: absolute;
left: 15dp;
top: -4dp;
width: 51dp;
height: 39dp;
}
div#title_bar span
{
padding-left: 85dp;
padding-right: 25dp;
padding-top: 18dp;
padding-bottom: 43dp;
vertical-align: top;
line-height: 24dp;
font-size: 20dp;
font-weight: bold;
font-effect: glow(1dp black);
decorator: tiled-horizontal( title-bar-l, title-bar-c, title-bar-r );
}
div#window
{
width: auto;
height: 100%;
padding: 10dp 15dp;
decorator: tiled-box(
window-tl, window-t, window-tr,
window-l, window-c, window-r,
window-bl, window-b, window-br
);
}
div#content
{
z-index: 2;
width: auto;
height: 100%;
overflow: hidden auto;
text-align: center;
}
p
{
text-align: left;
margin-bottom: 1em;
}
h1
{
margin-left: 0.4em;
margin-bottom: 0.4em;
text-align: left;
font-size: 16dp;
font-weight: bold;
font-effect: glow(1dp 1dp 1dp 1dp #1117);
}
input,
select
{
margin-left: 20dp;
}
input.submit
{
margin-left: 0;
}
input, button, select {
nav: auto;
}
button,
input.submit
{
display: inline-block;
width: 159dp;
height: 33dp;
padding-top: 12dp;
font-size: 16dp;
text-align: center;
tab-index: auto;
decorator: image(button);
}
button:focus,
input.submit:focus
{
font-effect: blur(3dp #fff);
}
button:hover, button:focus-visible,
input.submit:hover, input.submit:focus-visible
{
decorator: image(button-hover);
}
button:active,
input.submit:active
{
decorator: image(button-active);
}
input.submit:disabled
{
decorator: image(button);
image-color: rgba(50, 150, 150, 120);
cursor: unavailable;
}
input.text, input.password
{
box-sizing: border-box;
height: 31dp;
padding: 11dp 10dp 0;
decorator: tiled-horizontal( text-l, text-c, auto ); /* Right becomes mirrored left */
cursor: text;
text-align: left;
}
input.text:focus-visible, input.password:focus-visible
{
decorator: tiled-horizontal( text-focus-l, text-focus-c, auto );
}
textarea
{
padding: 5dp 8dp;
decorator: ninepatch(textarea, textarea-inner, 1.0) border-box;
cursor: text;
text-align: left;
line-height: 1.3;
border-width: 14dp 12dp 10dp;
border-color: transparent;
}
textarea:focus-visible
{
decorator: ninepatch(textarea-focus, textarea-focus-inner, 1.0) border-box;
}
input.text,
input.password,
select,
textarea
{
color: #333;
font-size: 13dp;
}
table input.text
{
box-sizing: border-box;
width: 100%;
margin: 0;
padding: 1dp 5dp;
height: auto;
line-height: 16dp;
text-align: center;
border-width: 1dp;
border-color: black;
background-color: white;
font-size: 15dp;
}
table input.text, table input.text:focus-visible
{
decorator: none;
}
select
{
width: 175dp;
height: 37dp;
}
select selectvalue
{
width: auto;
margin-right: 30dp;
height: 25dp;
padding: 12dp 10dp 0dp 10dp;
decorator: image( selectvalue );
}
select:focus-visible selectvalue {
decorator: image( selectvalue-hover );
}
select selectarrow
{
width: 30dp;
height: 37dp;
decorator: image( selectarrow );
}
select:hover selectarrow, select:focus-visible selectarrow
{
decorator: image( selectarrow-hover );
}
select:active selectarrow,
select selectarrow:checked
{
decorator: image( selectarrow-active );
}
select selectbox
{
margin-left: 1dp;
margin-top: -7dp;
margin-bottom: -10dp;
width: 162dp;
padding: 1dp 4dp 4dp 4dp;
}
select selectbox,
tbody
{
decorator: tiled-box(
selectbox-tl, selectbox-t, selectbox-tr,
selectbox-l, selectbox-c, auto, /* auto mirrors left */
selectbox-bl, selectbox-b, selectbox-br
);
}
select selectbox option
{
width: auto;
padding: 3dp 0 3dp 6dp;
background: #DDDD;
}
select selectbox option:nth-child(even),
tr:nth-child(even)
{
background: #FFFFFFA0;
}
select selectbox option:checked
{
font-weight: bold;
}
select selectbox option:hover
{
background: #FF5D5D;
}
input.radio,
input.checkbox
{
width: 30dp;
height: 30dp;
vertical-align: -11dp;
}
input.radio
{
decorator: image(radio);
}
input.radio:hover, input.radio:focus-visible
{
decorator: image(radio-hover);
}
input.radio:active
{
decorator: image(radio-active);
}
input.radio:checked
{
decorator: image(radio-checked);
}
input.radio:checked:hover, input.radio:checked:focus-visible
{
decorator: image(radio-checked-hover);
}
input.radio:checked:active
{
decorator: image(radio-checked-active);
}
input.checkbox
{
decorator: image(checkbox);
}
input.checkbox:hover, input.checkbox:focus-visible
{
decorator: image(checkbox-hover);
}
input.checkbox:active
{
decorator: image(checkbox-active);
}
input.checkbox:checked
{
decorator: image(checkbox-checked);
}
input.checkbox:checked:hover, input.checkbox:checked:focus-visible
{
decorator: image(checkbox-checked-hover);
}
input.checkbox:checked:active
{
decorator: image(checkbox-checked-active);
}
input.range {
width: 200dp;
height: 32dp;
vertical-align: -12dp;
}
input.range slidertrack {
margin-top: 3dp;
height: 22dp;
image-color: #ecc;
decorator: ninepatch( range-track, range-track-inner, 1.0 );
}
input.range:focus-visible slidertrack {
decorator: ninepatch( range-track-focus, range-track-focus-inner, 1.0 );
}
input.range sliderprogress {
background: rgba(100, 0, 0, 80);
margin-top: 8dp;
height: 7dp;
}
input.range sliderbar {
margin-left: -8dp;
margin-right: -7dp;
margin-top: -3dp;
width: 34dp;
height: 23dp;
decorator: image( range-bar );
}
input.range sliderbar:hover, input.range slidertrack:hover + sliderbar {
image-color: #cc0;
}
input.range sliderbar:active, input.range slidertrack:active + sliderbar {
image-color: #c80;
}
input.range sliderarrowdec, input.range sliderarrowinc {
width: 17dp;
height: 17dp;
margin-top: 6dp;
}
input.range sliderarrowdec { decorator: image( range-dec ); }
input.range sliderarrowinc { decorator: image( range-inc ); }
input.range sliderarrowdec:hover { decorator: image( range-dec-hover ); }
input.range sliderarrowinc:hover { decorator: image( range-inc-hover ); }
input.range sliderarrowdec:active { decorator: image( range-dec-active ); }
input.range sliderarrowinc:active { decorator: image( range-inc-active ); }
thead tr {
height: 35dp;
decorator: tiled-horizontal( tableheader-l, tableheader-c, tableheader-r );
}
thead td {
padding-top: 11dp;
}
tbody {
/* Margin left/right only affects the background positioning for the decorator, not the cell placement */
margin-left: 5dp;
margin-right: 4dp;
/* Padding top/bottom adds extra spacing between the header row and the body, and between the body and table bottom */
padding-top: 4dp;
padding-bottom: 4dp;
}
tbody tr {
margin-left: 9dp;
margin-right: 8dp;
color: black;
}
expand
{
display: block;
margin: 1dp 0 1dp 5dp;
height: 17dp;
width: 17dp;
decorator: image( expand );
}
expand:hover
{
decorator: image( expand-hover );
}
expand:active
{
decorator: image( expand-active );
}
expand.collapsed
{
decorator: image( expand-collapsed );
}
expand.collapsed:hover
{
decorator: image( expand-collapsed-hover );
}
expand.collapsed:active
{
decorator: image( expand-collapsed-active );
}
scrollbarvertical
{
margin-top: -6dp;
margin-bottom: -6dp;
margin-right: -11dp;
width: 27dp;
}
scrollbarvertical slidertrack
{
decorator: tiled-vertical( slidertrack-t, slidertrack-c, slidertrack-b );
}
scrollbarvertical slidertrack:active
{
image-color: #aaa;
}
scrollbarvertical sliderbar
{
margin-left: 4dp;
width: 23dp;
min-height: 46dp;
decorator: tiled-vertical( sliderbar-t, sliderbar-c, sliderbar-b );
}
scrollbarvertical sliderbar:hover
{
decorator: tiled-vertical( sliderbar-hover-t, sliderbar-hover-c, sliderbar-hover-b );
}
scrollbarvertical sliderbar:active
{
decorator: tiled-vertical( sliderbar-active-t, sliderbar-active-c, sliderbar-active-b );
}
scrollbarvertical sliderarrowdec,
scrollbarvertical sliderarrowinc
{
width: 27dp;
height: 24dp;
}
scrollbarvertical sliderarrowdec
{
decorator: image( sliderarrowdec );
}
scrollbarvertical sliderarrowdec:hover
{
decorator: image( sliderarrowdec-hover );
}
scrollbarvertical sliderarrowdec:active
{
decorator: image( sliderarrowdec-active );
}
scrollbarvertical sliderarrowinc
{
decorator: image( sliderarrowinc );
}
scrollbarvertical sliderarrowinc:hover
{
decorator: image( sliderarrowinc-hover );
}
scrollbarvertical sliderarrowinc:active
{
decorator: image( sliderarrowinc-active );
}
scrollbarhorizontal
{
width: 0;
height: 0;
}
textarea scrollbarvertical
{
cursor: arrow;
width: 12dp;
margin: -3dp -7dp -3dp 7dp;
}
textarea scrollbarvertical slidertrack
{
decorator: none;
background-color: #eee;
}
textarea scrollbarvertical sliderbar
{
decorator: none;
background-color: #bc0000;
border-left: 5dp #cc7272;
width: 7dp;
min-height: 16dp;
margin: 0;
}
textarea scrollbarvertical sliderbar:hover
{
decorator: none;
background-color: #ca3535;
}
textarea scrollbarvertical sliderbar:active
{
decorator: none;
background-color: #880000;
}
textarea scrollbarvertical sliderarrowdec,
textarea scrollbarvertical sliderarrowinc
{
width: 0;
height: 0;
}
textarea scrollbarhorizontal
{
cursor: arrow;
height: 10dp;
margin: 3dp -7dp -3dp -3dp;
}
textarea scrollbarhorizontal sliderbar
{
background-color: #bc0000;
border-top: 4dp #cc7272;
height: 6dp;
min-width: 10dp;
}
textarea scrollbarhorizontal sliderbar:hover
{
background-color: #ca3535;
}
textarea scrollbarhorizontal sliderbar:active
{
background-color: #880000;
}
textarea scrollbarhorizontal slidertrack
{
background-color: #eee;
}
textarea scrollbarcorner
{
cursor: arrow;
background-color: #ccc;
margin-top: 3dp;
margin-left: 7dp;
}

BIN
src/main/assets/invader.tga Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

BIN
src/main/assets/present.tga Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

@@ -0,0 +1,14 @@
#version 300 es
#extension GL_OES_EGL_image_external_essl3 : require
precision mediump float;
uniform samplerExternalOES uTexture;
in vec2 vTexCoord;
out vec4 fragColor;
void main()
{
fragColor = texture(uTexture, vTexCoord);
}

View File

@@ -0,0 +1,12 @@
#version 300 es
layout(location = 0) in vec4 aPosition;
layout(location = 1) in vec2 aTexCoord;
out vec2 vTexCoord;
void main()
{
gl_Position = aPosition;
vTexCoord = aTexCoord;
}

61
src/main/assets/rml.rcss Normal file
View File

@@ -0,0 +1,61 @@
/*
* Default styles for all the basic elements.
*/
div
{
display: block;
}
p
{
display: block;
}
h1
{
display: block;
}
em
{
font-style: italic;
}
strong
{
font-weight: bold;
}
select
{
text-align: left;
}
tabset tabs
{
display: block;
}
table {
box-sizing: border-box;
display: table;
}
tr {
box-sizing: border-box;
display: table-row;
}
td {
box-sizing: border-box;
display: table-cell;
}
col {
box-sizing: border-box;
display: table-column;
}
colgroup {
display: table-column-group;
}
thead, tbody, tfoot {
display: table-row-group;
}

View File

@@ -0,0 +1,36 @@
body {
font-family: LatoLatin;
font-size: 18px;
color: #02475e;
background: #fefecc;
text-align: center;
padding: 2em 1em;
position: absolute;
border: 2px #ccc;
width: 500px;
height: 200px;
margin: auto;
}
h1 {
color: #f6470a;
font-size: 1.5em;
font-weight: bold;
margin-bottom: 0.7em;
}
p {
margin: 0.7em 0;
}
input.text {
background-color: #fff;
color: #555;
border: 2px #999;
padding: 5px;
tab-index: auto;
cursor: text;
box-sizing: border-box;
width: 200px;
font-size: 0.9em;
}

View File

@@ -0,0 +1,19 @@
<template name="window" content="content">
<head>
<link type="text/rcss" href="rml.rcss"/>
<link type="text/rcss" href="invader.rcss"/>
</head>
<body class="window">
<div id="title_bar">
<handle move_target="#document">
<div id="icon"></div>
<span id="title">Title</span>
</handle>
</div>
<div id="window">
<div id="content">
</div>
</div>
<handle size_target="#document" style="position: absolute; width: 16dp; height: 16dp; bottom: 0px; right: 0px; cursor: resize;"></handle>
</body>
</template>

View File

@@ -7,27 +7,63 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(ANDROID_SDK "/Users/omar/Library/Android/sdk")
set(BINDER_DIR "${ANDROID_SDK}/platforms/android-36/optional/libbinder_ndk_cpp")
find_package(RmlUi CONFIG REQUIRED)
#get_cmake_property(_variableNames VARIABLES)
#list(SORT _variableNames)
#foreach(_variableName ${_variableNames})
# message(STATUS "${_variableName}=${${_variableName}}")
#endforeach()
add_library(mosis-service SHARED
mosis-service.cpp
com/omixlab/mosis/IMosisService.cpp
com/omixlab/mosis/IMosisListener.cpp
assets_manager.cpp
shader.cpp
external_texture.cpp
quad.cpp
egl_context.cpp
render_target.cpp
logger.cpp
kernel.cpp
glad/src/egl.c
glad/src/gles2.c)
glad/src/gles2.c
RmlUi_Renderer_GL3.cpp
)
target_compile_definitions(mosis-service PUBLIC
RMLUI_NUM_MSAA_SAMPLES=2
RMLUI_GL3_CUSTOM_LOADER=<glad/gles2.h>
)
target_include_directories(mosis-service PUBLIC
${CMAKE_CURRENT_LIST_DIR} ${BINDER_DIR} glad/include)
${CMAKE_CURRENT_LIST_DIR}
${BINDER_DIR}
glad/include
)
target_link_libraries(mosis-service
android log binder_ndk EGL GLESv2)
android log binder_ndk EGL GLESv2 nativewindow
RmlUi::RmlUi
)
add_library(mosis-test SHARED
com/omixlab/mosis/IMosisService.cpp
com/omixlab/mosis/IMosisListener.cpp
mosis-test.cpp
assets_manager.cpp
shader.cpp
external_texture.cpp
quad.cpp
egl_context.cpp
render_target.cpp
logger.cpp
glad/src/egl.c
glad/src/gles2.c)
glad/src/gles2.c
)
target_include_directories(mosis-test PUBLIC
${CMAKE_CURRENT_LIST_DIR} ${BINDER_DIR} glad/include)
${CMAKE_CURRENT_LIST_DIR}
${BINDER_DIR}
glad/include
)
target_link_libraries(mosis-test
android log binder_ndk EGL GLESv2)
android log binder_ndk EGL GLESv2 nativewindow
)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,241 @@
/*
* This source file is part of RmlUi, the HTML/CSS Interface Middleware
*
* For the latest information, see http://github.com/mikke89/RmlUi
*
* Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
* Copyright (c) 2019-2023 The RmlUi Team, and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#ifndef RMLUI_BACKENDS_RENDERER_GL3_H
#define RMLUI_BACKENDS_RENDERER_GL3_H
#include <RmlUi/Core/RenderInterface.h>
#include <RmlUi/Core/Types.h>
#include <bitset>
enum class ProgramId;
enum class UniformId;
class RenderLayerStack;
namespace Gfx {
struct ProgramData;
struct FramebufferData;
} // namespace Gfx
class RenderInterface_GL3 : public Rml::RenderInterface {
public:
RenderInterface_GL3();
~RenderInterface_GL3();
// Returns true if the renderer was successfully constructed.
explicit operator bool() const { return static_cast<bool>(program_data); }
// The viewport should be updated whenever the window size changes.
void SetViewport(int viewport_width, int viewport_height, int viewport_offset_x = 0, int viewport_offset_y = 0);
// Sets up OpenGL states for taking rendering commands from RmlUi.
void BeginFrame();
// Draws the result to the backbuffer and restores OpenGL state.
void EndFrame(unsigned int fb0);
// Optional, can be used to clear the active framebuffer.
void Clear();
// -- Inherited from Rml::RenderInterface --
Rml::CompiledGeometryHandle CompileGeometry(Rml::Span<const Rml::Vertex> vertices, Rml::Span<const int> indices) override;
void RenderGeometry(Rml::CompiledGeometryHandle handle, Rml::Vector2f translation, Rml::TextureHandle texture) override;
void ReleaseGeometry(Rml::CompiledGeometryHandle handle) override;
Rml::TextureHandle LoadTexture(Rml::Vector2i& texture_dimensions, const Rml::String& source) override;
Rml::TextureHandle GenerateTexture(Rml::Span<const Rml::byte> source_data, Rml::Vector2i source_dimensions) override;
void ReleaseTexture(Rml::TextureHandle texture_handle) override;
void EnableScissorRegion(bool enable) override;
void SetScissorRegion(Rml::Rectanglei region) override;
void EnableClipMask(bool enable) override;
void RenderToClipMask(Rml::ClipMaskOperation mask_operation, Rml::CompiledGeometryHandle geometry, Rml::Vector2f translation) override;
void SetTransform(const Rml::Matrix4f* transform) override;
Rml::LayerHandle PushLayer() override;
void CompositeLayers(Rml::LayerHandle source, Rml::LayerHandle destination, Rml::BlendMode blend_mode,
Rml::Span<const Rml::CompiledFilterHandle> filters) override;
void PopLayer() override;
Rml::TextureHandle SaveLayerAsTexture() override;
Rml::CompiledFilterHandle SaveLayerAsMaskImage() override;
Rml::CompiledFilterHandle CompileFilter(const Rml::String& name, const Rml::Dictionary& parameters) override;
void ReleaseFilter(Rml::CompiledFilterHandle filter) override;
Rml::CompiledShaderHandle CompileShader(const Rml::String& name, const Rml::Dictionary& parameters) override;
void RenderShader(Rml::CompiledShaderHandle shader_handle, Rml::CompiledGeometryHandle geometry_handle, Rml::Vector2f translation,
Rml::TextureHandle texture) override;
void ReleaseShader(Rml::CompiledShaderHandle effect_handle) override;
// Can be passed to RenderGeometry() to enable texture rendering without changing the bound texture.
static constexpr Rml::TextureHandle TextureEnableWithoutBinding = Rml::TextureHandle(-1);
// Can be passed to RenderGeometry() to leave the bound texture and used program unchanged.
static constexpr Rml::TextureHandle TexturePostprocess = Rml::TextureHandle(-2);
// -- Utility functions for clients --
const Rml::Matrix4f& GetTransform() const;
void ResetProgram();
private:
void UseProgram(ProgramId program_id);
int GetUniformLocation(UniformId uniform_id) const;
void SubmitTransformUniform(Rml::Vector2f translation);
void BlitLayerToPostprocessPrimary(Rml::LayerHandle layer_handle);
void RenderFilters(Rml::Span<const Rml::CompiledFilterHandle> filter_handles);
void SetScissor(Rml::Rectanglei region, bool vertically_flip = false);
void DrawFullscreenQuad();
void DrawFullscreenQuad(Rml::Vector2f uv_offset, Rml::Vector2f uv_scaling = Rml::Vector2f(1.f));
void RenderBlur(float sigma, const Gfx::FramebufferData& source_destination, const Gfx::FramebufferData& temp, Rml::Rectanglei window_flipped);
static constexpr size_t MaxNumPrograms = 32;
std::bitset<MaxNumPrograms> program_transform_dirty;
Rml::Matrix4f transform;
Rml::Matrix4f projection;
ProgramId active_program = {};
Rml::Rectanglei scissor_state;
int viewport_width = 0;
int viewport_height = 0;
int viewport_offset_x = 0;
int viewport_offset_y = 0;
Rml::CompiledGeometryHandle fullscreen_quad_geometry = {};
Rml::UniquePtr<const Gfx::ProgramData> program_data;
/*
Manages render targets, including the layer stack and postprocessing framebuffers.
Layers can be pushed and popped, creating new framebuffers as needed. Typically, geometry is rendered to the top
layer. The layer framebuffers may have MSAA enabled.
Postprocessing framebuffers are separate from the layers, and are commonly used to apply texture-wide effects
such as filters. They are used both as input and output during rendering, and do not use MSAA.
*/
class RenderLayerStack {
public:
RenderLayerStack();
~RenderLayerStack();
// Push a new layer. All references to previously retrieved layers are invalidated.
Rml::LayerHandle PushLayer();
// Pop the top layer. All references to previously retrieved layers are invalidated.
void PopLayer();
const Gfx::FramebufferData& GetLayer(Rml::LayerHandle layer) const;
const Gfx::FramebufferData& GetTopLayer() const;
Rml::LayerHandle GetTopLayerHandle() const;
const Gfx::FramebufferData& GetPostprocessPrimary() { return EnsureFramebufferPostprocess(0); }
const Gfx::FramebufferData& GetPostprocessSecondary() { return EnsureFramebufferPostprocess(1); }
const Gfx::FramebufferData& GetPostprocessTertiary() { return EnsureFramebufferPostprocess(2); }
const Gfx::FramebufferData& GetBlendMask() { return EnsureFramebufferPostprocess(3); }
void SwapPostprocessPrimarySecondary();
void BeginFrame(int new_width, int new_height);
void EndFrame();
private:
void DestroyFramebuffers();
const Gfx::FramebufferData& EnsureFramebufferPostprocess(int index);
int width = 0, height = 0;
// The number of active layers is manually tracked since we re-use the framebuffers stored in the fb_layers stack.
int layers_size = 0;
Rml::Vector<Gfx::FramebufferData> fb_layers;
Rml::Vector<Gfx::FramebufferData> fb_postprocess;
};
RenderLayerStack render_layers;
struct GLStateBackup {
bool enable_cull_face;
bool enable_blend;
bool enable_stencil_test;
bool enable_scissor_test;
bool enable_depth_test;
int viewport[4];
int scissor[4];
int active_texture;
int stencil_clear_value;
float color_clear_value[4];
unsigned char color_writemask[4];
int blend_equation_rgb;
int blend_equation_alpha;
int blend_src_rgb;
int blend_dst_rgb;
int blend_src_alpha;
int blend_dst_alpha;
struct Stencil {
int func;
int ref;
int value_mask;
int writemask;
int fail;
int pass_depth_fail;
int pass_depth_pass;
};
Stencil stencil_front;
Stencil stencil_back;
};
GLStateBackup glstate_backup = {};
};
/**
Helper functions for the OpenGL 3 renderer.
*/
namespace RmlGL3 {
// Loads OpenGL functions. Optionally, the out message describes the loaded GL version or an error message on failure.
bool Initialize(Rml::String* out_message = nullptr);
// Unloads OpenGL functions.
void Shutdown();
} // namespace RmlGL3
#endif

View File

@@ -0,0 +1,56 @@
/*
* This file is auto-generated. DO NOT MODIFY.
* Using: /Users/omar/Library/Android/sdk/build-tools/36.1.0/aidl --lang=ndk --min_sdk_version=36 -o src/main/cpp -h src/main/cpp -I src/main/aidl src/main/aidl/com/omixlab/mosis/IMosisListener.aidl
*
* DO NOT CHECK THIS FILE INTO A CODE TREE (e.g. git, etc..).
* ALWAYS GENERATE THIS FILE FROM UPDATED AIDL COMPILER
* AS A BUILD INTERMEDIATE ONLY. THIS IS NOT SOURCE CODE.
*/
#pragma once
#include "aidl/com/omixlab/mosis/IMosisListener.h"
#include <android/binder_ibinder.h>
#include <cassert>
#ifndef __BIONIC__
#ifndef __assert2
#define __assert2(a,b,c,d) ((void)0)
#endif
#endif
namespace aidl {
namespace com {
namespace omixlab {
namespace mosis {
class BnMosisListener : public ::ndk::BnCInterface<IMosisListener> {
public:
BnMosisListener();
virtual ~BnMosisListener();
protected:
::ndk::SpAIBinder createBinder() override;
private:
};
class IMosisListenerDelegator : public BnMosisListener {
public:
explicit IMosisListenerDelegator(const std::shared_ptr<IMosisListener> &impl) : _impl(impl) {
}
::ndk::ScopedAStatus onServiceInitialized(bool in_success) override {
return _impl->onServiceInitialized(in_success);
}
::ndk::ScopedAStatus onBufferAvailable(const ::aidl::android::hardware::HardwareBuffer& in_buffer) override {
return _impl->onBufferAvailable(in_buffer);
}
::ndk::ScopedAStatus onFrameAvailable() override {
return _impl->onFrameAvailable();
}
protected:
private:
std::shared_ptr<IMosisListener> _impl;
};
} // namespace mosis
} // namespace omixlab
} // namespace com
} // namespace aidl

View File

@@ -36,8 +36,8 @@ public:
explicit IMosisServiceDelegator(const std::shared_ptr<IMosisService> &impl) : _impl(impl) {
}
::ndk::ScopedAStatus initOS(bool* _aidl_return) override {
return _impl->initOS(_aidl_return);
::ndk::ScopedAStatus initOS(const std::shared_ptr<::aidl::com::omixlab::mosis::IMosisListener>& in_listener, bool* _aidl_return) override {
return _impl->initOS(in_listener, _aidl_return);
}
::ndk::ScopedAStatus getNumber(int32_t* _aidl_return) override {
return _impl->getNumber(_aidl_return);

View File

@@ -0,0 +1,31 @@
/*
* This file is auto-generated. DO NOT MODIFY.
* Using: /Users/omar/Library/Android/sdk/build-tools/36.1.0/aidl --lang=ndk --min_sdk_version=36 -o src/main/cpp -h src/main/cpp -I src/main/aidl src/main/aidl/com/omixlab/mosis/IMosisListener.aidl
*
* DO NOT CHECK THIS FILE INTO A CODE TREE (e.g. git, etc..).
* ALWAYS GENERATE THIS FILE FROM UPDATED AIDL COMPILER
* AS A BUILD INTERMEDIATE ONLY. THIS IS NOT SOURCE CODE.
*/
#pragma once
#include "aidl/com/omixlab/mosis/IMosisListener.h"
#include <android/binder_ibinder.h>
namespace aidl {
namespace com {
namespace omixlab {
namespace mosis {
class BpMosisListener : public ::ndk::BpCInterface<IMosisListener> {
public:
explicit BpMosisListener(const ::ndk::SpAIBinder& binder);
virtual ~BpMosisListener();
::ndk::ScopedAStatus onServiceInitialized(bool in_success) override;
::ndk::ScopedAStatus onBufferAvailable(const ::aidl::android::hardware::HardwareBuffer& in_buffer) override;
::ndk::ScopedAStatus onFrameAvailable() override;
};
} // namespace mosis
} // namespace omixlab
} // namespace com
} // namespace aidl

View File

@@ -21,7 +21,7 @@ public:
explicit BpMosisService(const ::ndk::SpAIBinder& binder);
virtual ~BpMosisService();
::ndk::ScopedAStatus initOS(bool* _aidl_return) override;
::ndk::ScopedAStatus initOS(const std::shared_ptr<::aidl::com::omixlab::mosis::IMosisListener>& in_listener, bool* _aidl_return) override;
::ndk::ScopedAStatus getNumber(int32_t* _aidl_return) override;
};
} // namespace mosis

View File

@@ -0,0 +1,61 @@
/*
* This file is auto-generated. DO NOT MODIFY.
* Using: /Users/omar/Library/Android/sdk/build-tools/36.1.0/aidl --lang=ndk --min_sdk_version=36 -o src/main/cpp -h src/main/cpp -I src/main/aidl src/main/aidl/com/omixlab/mosis/IMosisListener.aidl
*
* DO NOT CHECK THIS FILE INTO A CODE TREE (e.g. git, etc..).
* ALWAYS GENERATE THIS FILE FROM UPDATED AIDL COMPILER
* AS A BUILD INTERMEDIATE ONLY. THIS IS NOT SOURCE CODE.
*/
#pragma once
#include <cstdint>
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include <android/binder_interface_utils.h>
#include <android/hardware_buffer_aidl.h>
#ifdef BINDER_STABILITY_SUPPORT
#include <android/binder_stability.h>
#endif // BINDER_STABILITY_SUPPORT
namespace aidl {
namespace com {
namespace omixlab {
namespace mosis {
class IMosisListenerDelegator;
class IMosisListener : public ::ndk::ICInterface {
public:
typedef IMosisListenerDelegator DefaultDelegator;
static const char* descriptor;
IMosisListener();
virtual ~IMosisListener();
static constexpr uint32_t TRANSACTION_onServiceInitialized = FIRST_CALL_TRANSACTION + 0;
static constexpr uint32_t TRANSACTION_onBufferAvailable = FIRST_CALL_TRANSACTION + 1;
static constexpr uint32_t TRANSACTION_onFrameAvailable = FIRST_CALL_TRANSACTION + 2;
static std::shared_ptr<IMosisListener> fromBinder(const ::ndk::SpAIBinder& binder);
static binder_status_t writeToParcel(AParcel* parcel, const std::shared_ptr<IMosisListener>& instance);
static binder_status_t readFromParcel(const AParcel* parcel, std::shared_ptr<IMosisListener>* instance);
static bool setDefaultImpl(const std::shared_ptr<IMosisListener>& impl);
static const std::shared_ptr<IMosisListener>& getDefaultImpl();
virtual ::ndk::ScopedAStatus onServiceInitialized(bool in_success) = 0;
virtual ::ndk::ScopedAStatus onBufferAvailable(const ::aidl::android::hardware::HardwareBuffer& in_buffer) = 0;
virtual ::ndk::ScopedAStatus onFrameAvailable() = 0;
private:
static std::shared_ptr<IMosisListener> default_impl;
};
class IMosisListenerDefault : public IMosisListener {
public:
::ndk::ScopedAStatus onServiceInitialized(bool in_success) override;
::ndk::ScopedAStatus onBufferAvailable(const ::aidl::android::hardware::HardwareBuffer& in_buffer) override;
::ndk::ScopedAStatus onFrameAvailable() override;
::ndk::SpAIBinder asBinder() override;
bool isRemote() override;
};
} // namespace mosis
} // namespace omixlab
} // namespace com
} // namespace aidl

View File

@@ -14,10 +14,14 @@
#include <string>
#include <vector>
#include <android/binder_interface_utils.h>
#include <aidl/com/omixlab/mosis/IMosisListener.h>
#ifdef BINDER_STABILITY_SUPPORT
#include <android/binder_stability.h>
#endif // BINDER_STABILITY_SUPPORT
namespace aidl::com::omixlab::mosis {
class IMosisListener;
} // namespace aidl::com::omixlab::mosis
namespace aidl {
namespace com {
namespace omixlab {
@@ -39,14 +43,14 @@ public:
static binder_status_t readFromParcel(const AParcel* parcel, std::shared_ptr<IMosisService>* instance);
static bool setDefaultImpl(const std::shared_ptr<IMosisService>& impl);
static const std::shared_ptr<IMosisService>& getDefaultImpl();
virtual ::ndk::ScopedAStatus initOS(bool* _aidl_return) = 0;
virtual ::ndk::ScopedAStatus initOS(const std::shared_ptr<::aidl::com::omixlab::mosis::IMosisListener>& in_listener, bool* _aidl_return) = 0;
virtual ::ndk::ScopedAStatus getNumber(int32_t* _aidl_return) = 0;
private:
static std::shared_ptr<IMosisService> default_impl;
};
class IMosisServiceDefault : public IMosisService {
public:
::ndk::ScopedAStatus initOS(bool* _aidl_return) override;
::ndk::ScopedAStatus initOS(const std::shared_ptr<::aidl::com::omixlab::mosis::IMosisListener>& in_listener, bool* _aidl_return) override;
::ndk::ScopedAStatus getNumber(int32_t* _aidl_return) override;
::ndk::SpAIBinder asBinder() override;
bool isRemote() override;

View File

@@ -0,0 +1,26 @@
#include "assets_manager.h"
#include <android/asset_manager.h>
void AssetsManager::Init(AAssetManager *asset_manager)
{
m_asset_manager = asset_manager;
}
std::vector<uint8_t> AssetsManager::ReadAll(const std::string &filename)
{
if (AAsset* asset = AAssetManager_open(m_asset_manager,
filename.c_str(), AASSET_MODE_BUFFER))
{
const auto size = AAsset_getLength(asset);
auto buffer = std::vector<uint8_t>(size);
AAsset_read(asset, buffer.data(), size);
AAsset_close(asset);
return buffer;
}
return {};
}
AAssetManager *AssetsManager::Native()
{
return m_asset_manager;
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include <vector>
struct AAssetManager;
struct AAsset;
class AssetsManager
{
static inline AAssetManager* m_asset_manager = nullptr;
public:
static void Init(AAssetManager* asset_manager);
static std::vector<uint8_t> ReadAll(const std::string& filename);
static AAssetManager* Native();
};

View File

@@ -0,0 +1,242 @@
/*
* This file is auto-generated. DO NOT MODIFY.
* Using: /Users/omar/Library/Android/sdk/build-tools/36.1.0/aidl --lang=ndk --min_sdk_version=36 -o src/main/cpp -h src/main/cpp -I src/main/aidl src/main/aidl/com/omixlab/mosis/IMosisListener.aidl
*
* DO NOT CHECK THIS FILE INTO A CODE TREE (e.g. git, etc..).
* ALWAYS GENERATE THIS FILE FROM UPDATED AIDL COMPILER
* AS A BUILD INTERMEDIATE ONLY. THIS IS NOT SOURCE CODE.
*/
#include "aidl/com/omixlab/mosis/IMosisListener.h"
#include <cstdint>
#include <android/binder_parcel.h>
#include <android/binder_parcel_utils.h>
#include <android/binder_status.h>
#include <aidl/com/omixlab/mosis/BnMosisListener.h>
#include <aidl/com/omixlab/mosis/BpMosisListener.h>
namespace aidl {
namespace com {
namespace omixlab {
namespace mosis {
static binder_status_t _aidl_com_omixlab_mosis_IMosisListener_onTransact(AIBinder* _aidl_binder, transaction_code_t _aidl_code, const AParcel* _aidl_in, AParcel* _aidl_out) {
(void)_aidl_in;
(void)_aidl_out;
binder_status_t _aidl_ret_status = STATUS_UNKNOWN_TRANSACTION;
std::shared_ptr<BnMosisListener> _aidl_impl = std::static_pointer_cast<BnMosisListener>(::ndk::ICInterface::asInterface(_aidl_binder));
switch (_aidl_code) {
case (FIRST_CALL_TRANSACTION + 0 /*onServiceInitialized*/): {
bool in_success;
_aidl_ret_status = ::ndk::AParcel_readData(_aidl_in, &in_success);
if (_aidl_ret_status != STATUS_OK) break;
::ndk::ScopedAStatus _aidl_status = _aidl_impl->onServiceInitialized(in_success);
_aidl_ret_status = STATUS_OK;
break;
}
case (FIRST_CALL_TRANSACTION + 1 /*onBufferAvailable*/): {
::aidl::android::hardware::HardwareBuffer in_buffer;
_aidl_ret_status = ::ndk::AParcel_readData(_aidl_in, &in_buffer);
if (_aidl_ret_status != STATUS_OK) break;
::ndk::ScopedAStatus _aidl_status = _aidl_impl->onBufferAvailable(in_buffer);
_aidl_ret_status = STATUS_OK;
break;
}
case (FIRST_CALL_TRANSACTION + 2 /*onFrameAvailable*/): {
::ndk::ScopedAStatus _aidl_status = _aidl_impl->onFrameAvailable();
_aidl_ret_status = STATUS_OK;
break;
}
}
return _aidl_ret_status;
}
static AIBinder_Class* _g_aidl_com_omixlab_mosis_IMosisListener_clazz = ::ndk::ICInterface::defineClass(IMosisListener::descriptor, _aidl_com_omixlab_mosis_IMosisListener_onTransact, nullptr, 0);
BpMosisListener::BpMosisListener(const ::ndk::SpAIBinder& binder) : BpCInterface(binder) {}
BpMosisListener::~BpMosisListener() {}
::ndk::ScopedAStatus BpMosisListener::onServiceInitialized(bool in_success) {
binder_status_t _aidl_ret_status = STATUS_OK;
::ndk::ScopedAStatus _aidl_status;
::ndk::ScopedAParcel _aidl_in;
::ndk::ScopedAParcel _aidl_out;
_aidl_ret_status = AIBinder_prepareTransaction(asBinderReference().get(), _aidl_in.getR());
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = ::ndk::AParcel_writeData(_aidl_in.get(), in_success);
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = AIBinder_transact(
asBinderReference().get(),
(FIRST_CALL_TRANSACTION + 0 /*onServiceInitialized*/),
_aidl_in.getR(),
_aidl_out.getR(),
FLAG_ONEWAY
#ifdef BINDER_STABILITY_SUPPORT
| static_cast<int>(FLAG_PRIVATE_LOCAL)
#endif // BINDER_STABILITY_SUPPORT
);
if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && IMosisListener::getDefaultImpl()) {
_aidl_status = IMosisListener::getDefaultImpl()->onServiceInitialized(in_success);
goto _aidl_status_return;
}
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_error:
_aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
_aidl_status_return:
return _aidl_status;
}
::ndk::ScopedAStatus BpMosisListener::onBufferAvailable(const ::aidl::android::hardware::HardwareBuffer& in_buffer) {
binder_status_t _aidl_ret_status = STATUS_OK;
::ndk::ScopedAStatus _aidl_status;
::ndk::ScopedAParcel _aidl_in;
::ndk::ScopedAParcel _aidl_out;
_aidl_ret_status = AIBinder_prepareTransaction(asBinderReference().get(), _aidl_in.getR());
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = ::ndk::AParcel_writeData(_aidl_in.get(), in_buffer);
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = AIBinder_transact(
asBinderReference().get(),
(FIRST_CALL_TRANSACTION + 1 /*onBufferAvailable*/),
_aidl_in.getR(),
_aidl_out.getR(),
FLAG_ONEWAY
#ifdef BINDER_STABILITY_SUPPORT
| static_cast<int>(FLAG_PRIVATE_LOCAL)
#endif // BINDER_STABILITY_SUPPORT
);
if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && IMosisListener::getDefaultImpl()) {
_aidl_status = IMosisListener::getDefaultImpl()->onBufferAvailable(in_buffer);
goto _aidl_status_return;
}
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_error:
_aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
_aidl_status_return:
return _aidl_status;
}
::ndk::ScopedAStatus BpMosisListener::onFrameAvailable() {
binder_status_t _aidl_ret_status = STATUS_OK;
::ndk::ScopedAStatus _aidl_status;
::ndk::ScopedAParcel _aidl_in;
::ndk::ScopedAParcel _aidl_out;
_aidl_ret_status = AIBinder_prepareTransaction(asBinderReference().get(), _aidl_in.getR());
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = AIBinder_transact(
asBinderReference().get(),
(FIRST_CALL_TRANSACTION + 2 /*onFrameAvailable*/),
_aidl_in.getR(),
_aidl_out.getR(),
FLAG_ONEWAY
#ifdef BINDER_STABILITY_SUPPORT
| static_cast<int>(FLAG_PRIVATE_LOCAL)
#endif // BINDER_STABILITY_SUPPORT
);
if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && IMosisListener::getDefaultImpl()) {
_aidl_status = IMosisListener::getDefaultImpl()->onFrameAvailable();
goto _aidl_status_return;
}
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_error:
_aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
_aidl_status_return:
return _aidl_status;
}
// Source for BnMosisListener
BnMosisListener::BnMosisListener() {}
BnMosisListener::~BnMosisListener() {}
::ndk::SpAIBinder BnMosisListener::createBinder() {
AIBinder* binder = AIBinder_new(_g_aidl_com_omixlab_mosis_IMosisListener_clazz, static_cast<void*>(this));
#ifdef BINDER_STABILITY_SUPPORT
AIBinder_markCompilationUnitStability(binder);
#endif // BINDER_STABILITY_SUPPORT
return ::ndk::SpAIBinder(binder);
}
// Source for IMosisListener
const char* IMosisListener::descriptor = "com.omixlab.mosis.IMosisListener";
IMosisListener::IMosisListener() {}
IMosisListener::~IMosisListener() {}
std::shared_ptr<IMosisListener> IMosisListener::fromBinder(const ::ndk::SpAIBinder& binder) {
if (!AIBinder_associateClass(binder.get(), _g_aidl_com_omixlab_mosis_IMosisListener_clazz)) {
#if __ANDROID_API__ >= 31
const AIBinder_Class* originalClass = AIBinder_getClass(binder.get());
if (originalClass == nullptr) return nullptr;
if (0 == strcmp(AIBinder_Class_getDescriptor(originalClass), descriptor)) {
return ::ndk::SharedRefBase::make<BpMosisListener>(binder);
}
#endif
return nullptr;
}
std::shared_ptr<::ndk::ICInterface> interface = ::ndk::ICInterface::asInterface(binder.get());
if (interface) {
return std::static_pointer_cast<IMosisListener>(interface);
}
return ::ndk::SharedRefBase::make<BpMosisListener>(binder);
}
binder_status_t IMosisListener::writeToParcel(AParcel* parcel, const std::shared_ptr<IMosisListener>& instance) {
return AParcel_writeStrongBinder(parcel, instance ? instance->asBinder().get() : nullptr);
}
binder_status_t IMosisListener::readFromParcel(const AParcel* parcel, std::shared_ptr<IMosisListener>* instance) {
::ndk::SpAIBinder binder;
binder_status_t status = AParcel_readStrongBinder(parcel, binder.getR());
if (status != STATUS_OK) return status;
*instance = IMosisListener::fromBinder(binder);
return STATUS_OK;
}
bool IMosisListener::setDefaultImpl(const std::shared_ptr<IMosisListener>& impl) {
// Only one user of this interface can use this function
// at a time. This is a heuristic to detect if two different
// users in the same process use this function.
assert(!IMosisListener::default_impl);
if (impl) {
IMosisListener::default_impl = impl;
return true;
}
return false;
}
const std::shared_ptr<IMosisListener>& IMosisListener::getDefaultImpl() {
return IMosisListener::default_impl;
}
std::shared_ptr<IMosisListener> IMosisListener::default_impl = nullptr;
::ndk::ScopedAStatus IMosisListenerDefault::onServiceInitialized(bool /*in_success*/) {
::ndk::ScopedAStatus _aidl_status;
_aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
return _aidl_status;
}
::ndk::ScopedAStatus IMosisListenerDefault::onBufferAvailable(const ::aidl::android::hardware::HardwareBuffer& /*in_buffer*/) {
::ndk::ScopedAStatus _aidl_status;
_aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
return _aidl_status;
}
::ndk::ScopedAStatus IMosisListenerDefault::onFrameAvailable() {
::ndk::ScopedAStatus _aidl_status;
_aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
return _aidl_status;
}
::ndk::SpAIBinder IMosisListenerDefault::asBinder() {
return ::ndk::SpAIBinder();
}
bool IMosisListenerDefault::isRemote() {
return false;
}
} // namespace mosis
} // namespace omixlab
} // namespace com
} // namespace aidl

View File

@@ -12,8 +12,11 @@
#include <android/binder_parcel.h>
#include <android/binder_parcel_utils.h>
#include <android/binder_status.h>
#include <aidl/com/omixlab/mosis/BnMosisListener.h>
#include <aidl/com/omixlab/mosis/BnMosisService.h>
#include <aidl/com/omixlab/mosis/BpMosisListener.h>
#include <aidl/com/omixlab/mosis/BpMosisService.h>
#include <aidl/com/omixlab/mosis/IMosisListener.h>
namespace aidl {
namespace com {
@@ -26,9 +29,13 @@ static binder_status_t _aidl_com_omixlab_mosis_IMosisService_onTransact(AIBinder
std::shared_ptr<BnMosisService> _aidl_impl = std::static_pointer_cast<BnMosisService>(::ndk::ICInterface::asInterface(_aidl_binder));
switch (_aidl_code) {
case (FIRST_CALL_TRANSACTION + 0 /*initOS*/): {
std::shared_ptr<::aidl::com::omixlab::mosis::IMosisListener> in_listener;
bool _aidl_return;
::ndk::ScopedAStatus _aidl_status = _aidl_impl->initOS(&_aidl_return);
_aidl_ret_status = ::ndk::AParcel_readData(_aidl_in, &in_listener);
if (_aidl_ret_status != STATUS_OK) break;
::ndk::ScopedAStatus _aidl_status = _aidl_impl->initOS(in_listener, &_aidl_return);
_aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
if (_aidl_ret_status != STATUS_OK) break;
@@ -62,7 +69,7 @@ static AIBinder_Class* _g_aidl_com_omixlab_mosis_IMosisService_clazz = ::ndk::IC
BpMosisService::BpMosisService(const ::ndk::SpAIBinder& binder) : BpCInterface(binder) {}
BpMosisService::~BpMosisService() {}
::ndk::ScopedAStatus BpMosisService::initOS(bool* _aidl_return) {
::ndk::ScopedAStatus BpMosisService::initOS(const std::shared_ptr<::aidl::com::omixlab::mosis::IMosisListener>& in_listener, bool* _aidl_return) {
binder_status_t _aidl_ret_status = STATUS_OK;
::ndk::ScopedAStatus _aidl_status;
::ndk::ScopedAParcel _aidl_in;
@@ -71,6 +78,9 @@ BpMosisService::~BpMosisService() {}
_aidl_ret_status = AIBinder_prepareTransaction(asBinderReference().get(), _aidl_in.getR());
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = ::ndk::AParcel_writeData(_aidl_in.get(), in_listener);
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = AIBinder_transact(
asBinderReference().get(),
(FIRST_CALL_TRANSACTION + 0 /*initOS*/),
@@ -82,7 +92,7 @@ BpMosisService::~BpMosisService() {}
#endif // BINDER_STABILITY_SUPPORT
);
if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && IMosisService::getDefaultImpl()) {
_aidl_status = IMosisService::getDefaultImpl()->initOS(_aidl_return);
_aidl_status = IMosisService::getDefaultImpl()->initOS(in_listener, _aidl_return);
goto _aidl_status_return;
}
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
@@ -195,7 +205,7 @@ const std::shared_ptr<IMosisService>& IMosisService::getDefaultImpl() {
return IMosisService::default_impl;
}
std::shared_ptr<IMosisService> IMosisService::default_impl = nullptr;
::ndk::ScopedAStatus IMosisServiceDefault::initOS(bool* /*_aidl_return*/) {
::ndk::ScopedAStatus IMosisServiceDefault::initOS(const std::shared_ptr<::aidl::com::omixlab::mosis::IMosisListener>& /*in_listener*/, bool* /*_aidl_return*/) {
::ndk::ScopedAStatus _aidl_status;
_aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
return _aidl_status;

View File

@@ -4,6 +4,14 @@
#include <glad/egl.h>
#include <android/native_window_jni.h>
#include <vector>
#include <format>
static void debug_handler(GLenum source, GLenum type,
GLuint id, GLenum severity, GLsizei length, const GLchar* message,
const void* userParam)
{
Logger::Log(std::format("GL Error: {}", std::string_view(message, length)));
}
bool egl::Context::create(ANativeWindow* window)
{
@@ -25,7 +33,7 @@ bool egl::Context::create(ANativeWindow* window)
Logger::Log("eglInitialize failed");
return false;
}
version = gladLoaderLoadEGL(EGL_DEFAULT_DISPLAY);
version = gladLoadEGL(m_display, eglGetProcAddress);
std::vector<EGLint> config_attribs =
{
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT,
@@ -61,6 +69,7 @@ bool egl::Context::create(ANativeWindow* window)
if (window)
{
m_surface = eglCreateWindowSurface(m_display, m_config, window, nullptr);
ANativeWindow_acquire(window);
m_native_window = window;
}
if (!eglMakeCurrent(m_display, m_surface, m_surface, m_context))
@@ -74,6 +83,12 @@ bool egl::Context::create(ANativeWindow* window)
Logger::Log("glad failed to load GLES2");
return false;
}
if (glDebugMessageCallback)
{
glDebugMessageCallback(debug_handler, nullptr);
glEnable(GL_DEBUG_OUTPUT);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
}
return true;
}
@@ -115,3 +130,34 @@ void egl::Context::swap()
{
eglSwapBuffers(m_display, m_surface);
}
bool egl::Context::make_current(ANativeWindow* window)
{
if (window == m_native_window)
{
return true;
}
eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (m_surface != EGL_NO_SURFACE)
{
eglDestroySurface(m_display, m_surface);
m_surface = EGL_NO_SURFACE;
}
if (m_native_window)
{
ANativeWindow_release(m_native_window);
m_native_window = nullptr;
}
if (window)
{
m_surface = eglCreateWindowSurface(m_display, m_config, window, nullptr);
ANativeWindow_acquire(window);
m_native_window = window;
if (!eglMakeCurrent(m_display, m_surface, m_surface, m_context))
{
Logger::Log("eglMakeCurrent failed");
return false;
}
}
return true;
}

View File

@@ -20,5 +20,6 @@ public:
bool create(ANativeWindow* window = nullptr);
void destroy();
void swap();
bool make_current(ANativeWindow* window = nullptr);
};
}

View File

@@ -0,0 +1,47 @@
#include "external_texture.h"
#include <android/hardware_buffer.h>
#include <glad/egl.h>
#include "logger.h"
bool ExternalTexture::create(AHardwareBuffer *hardwareBuffer)
{
AHardwareBuffer_Desc desc{};
AHardwareBuffer_describe(hardwareBuffer, &desc);
EGLClientBuffer clientBuffer = eglGetNativeClientBufferANDROID(hardwareBuffer);
EGLImageKHR eglImage = eglCreateImageKHR(eglGetCurrentDisplay(), EGL_NO_CONTEXT,
EGL_NATIVE_BUFFER_ANDROID, clientBuffer, nullptr);
if (eglImage == EGL_NO_IMAGE_KHR)
{
Logger::Log("Failed to create EGL image");
return false;
}
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture);
glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, eglImage);
eglDestroyImageKHR(eglGetCurrentDisplay(), eglImage);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
return true;
}
void ExternalTexture::destroy()
{
if (texture)
glDeleteTextures(1, &texture);
texture = 0;
}
void ExternalTexture::bind() const
{
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture);
}
void ExternalTexture::unbind() const
{
glBindTexture(GL_TEXTURE_EXTERNAL_OES, 0);
}
GLuint ExternalTexture::texture_id() const
{
return texture;
}

Some files were not shown because too many files have changed in this diff Show More