Showing preview only (597K chars total). Download the full file or copy to clipboard to get everything.
Repository: cats-oss/android-gpuimage
Branch: master
Commit: ceea576ec931
Files: 135
Total size: 549.6 KB
Directory structure:
gitextract_jngkckqx/
├── .github/
│ ├── ISSUE_TEMPLATE.md
│ └── PULL_REQUEST_TEMPLATE.md
├── .gitignore
├── CHANGELOG.md
├── CONTRIBUTING.md
├── README.md
├── build.gradle
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── library/
│ ├── build.gradle
│ ├── gradle.properties
│ ├── proguard-rules.txt
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ ├── cpp/
│ │ ├── CMakeLists.txt
│ │ └── yuv-decoder.c
│ ├── java/
│ │ └── jp/
│ │ └── co/
│ │ └── cyberagent/
│ │ └── android/
│ │ └── gpuimage/
│ │ ├── GLTextureView.java
│ │ ├── GPUImage.java
│ │ ├── GPUImageNativeLibrary.java
│ │ ├── GPUImageRenderer.java
│ │ ├── GPUImageView.java
│ │ ├── PixelBuffer.java
│ │ ├── filter/
│ │ │ ├── GPUImage3x3ConvolutionFilter.java
│ │ │ ├── GPUImage3x3TextureSamplingFilter.java
│ │ │ ├── GPUImageAddBlendFilter.java
│ │ │ ├── GPUImageAlphaBlendFilter.java
│ │ │ ├── GPUImageBilateralBlurFilter.java
│ │ │ ├── GPUImageBoxBlurFilter.java
│ │ │ ├── GPUImageBrightnessFilter.java
│ │ │ ├── GPUImageBulgeDistortionFilter.java
│ │ │ ├── GPUImageCGAColorspaceFilter.java
│ │ │ ├── GPUImageChromaKeyBlendFilter.java
│ │ │ ├── GPUImageColorBalanceFilter.java
│ │ │ ├── GPUImageColorBlendFilter.java
│ │ │ ├── GPUImageColorBurnBlendFilter.java
│ │ │ ├── GPUImageColorDodgeBlendFilter.java
│ │ │ ├── GPUImageColorInvertFilter.java
│ │ │ ├── GPUImageColorMatrixFilter.java
│ │ │ ├── GPUImageContrastFilter.java
│ │ │ ├── GPUImageCrosshatchFilter.java
│ │ │ ├── GPUImageDarkenBlendFilter.java
│ │ │ ├── GPUImageDifferenceBlendFilter.java
│ │ │ ├── GPUImageDilationFilter.java
│ │ │ ├── GPUImageDirectionalSobelEdgeDetectionFilter.java
│ │ │ ├── GPUImageDissolveBlendFilter.java
│ │ │ ├── GPUImageDivideBlendFilter.java
│ │ │ ├── GPUImageEmbossFilter.java
│ │ │ ├── GPUImageExclusionBlendFilter.java
│ │ │ ├── GPUImageExposureFilter.java
│ │ │ ├── GPUImageFalseColorFilter.java
│ │ │ ├── GPUImageFilter.java
│ │ │ ├── GPUImageFilterGroup.java
│ │ │ ├── GPUImageGammaFilter.java
│ │ │ ├── GPUImageGaussianBlurFilter.java
│ │ │ ├── GPUImageGlassSphereFilter.java
│ │ │ ├── GPUImageGrayscaleFilter.java
│ │ │ ├── GPUImageHalftoneFilter.java
│ │ │ ├── GPUImageHardLightBlendFilter.java
│ │ │ ├── GPUImageHazeFilter.java
│ │ │ ├── GPUImageHighlightShadowFilter.java
│ │ │ ├── GPUImageHueBlendFilter.java
│ │ │ ├── GPUImageHueFilter.java
│ │ │ ├── GPUImageKuwaharaFilter.java
│ │ │ ├── GPUImageLaplacianFilter.java
│ │ │ ├── GPUImageLevelsFilter.java
│ │ │ ├── GPUImageLightenBlendFilter.java
│ │ │ ├── GPUImageLinearBurnBlendFilter.java
│ │ │ ├── GPUImageLookupFilter.java
│ │ │ ├── GPUImageLuminanceFilter.java
│ │ │ ├── GPUImageLuminanceThresholdFilter.java
│ │ │ ├── GPUImageLuminosityBlendFilter.java
│ │ │ ├── GPUImageMixBlendFilter.java
│ │ │ ├── GPUImageMonochromeFilter.java
│ │ │ ├── GPUImageMultiplyBlendFilter.java
│ │ │ ├── GPUImageNonMaximumSuppressionFilter.java
│ │ │ ├── GPUImageNormalBlendFilter.java
│ │ │ ├── GPUImageOpacityFilter.java
│ │ │ ├── GPUImageOverlayBlendFilter.java
│ │ │ ├── GPUImagePixelationFilter.java
│ │ │ ├── GPUImagePosterizeFilter.java
│ │ │ ├── GPUImageRGBDilationFilter.java
│ │ │ ├── GPUImageRGBFilter.java
│ │ │ ├── GPUImageSaturationBlendFilter.java
│ │ │ ├── GPUImageSaturationFilter.java
│ │ │ ├── GPUImageScreenBlendFilter.java
│ │ │ ├── GPUImageSepiaToneFilter.java
│ │ │ ├── GPUImageSharpenFilter.java
│ │ │ ├── GPUImageSketchFilter.java
│ │ │ ├── GPUImageSmoothToonFilter.java
│ │ │ ├── GPUImageSobelEdgeDetectionFilter.java
│ │ │ ├── GPUImageSobelThresholdFilter.java
│ │ │ ├── GPUImageSoftLightBlendFilter.java
│ │ │ ├── GPUImageSolarizeFilter.java
│ │ │ ├── GPUImageSourceOverBlendFilter.java
│ │ │ ├── GPUImageSphereRefractionFilter.java
│ │ │ ├── GPUImageSubtractBlendFilter.java
│ │ │ ├── GPUImageSwirlFilter.java
│ │ │ ├── GPUImageThresholdEdgeDetectionFilter.java
│ │ │ ├── GPUImageToneCurveFilter.java
│ │ │ ├── GPUImageToonFilter.java
│ │ │ ├── GPUImageTransformFilter.java
│ │ │ ├── GPUImageTwoInputFilter.java
│ │ │ ├── GPUImageTwoPassFilter.java
│ │ │ ├── GPUImageTwoPassTextureSamplingFilter.java
│ │ │ ├── GPUImageVibranceFilter.java
│ │ │ ├── GPUImageVignetteFilter.java
│ │ │ ├── GPUImageWeakPixelInclusionFilter.java
│ │ │ ├── GPUImageWhiteBalanceFilter.java
│ │ │ └── GPUImageZoomBlurFilter.java
│ │ └── util/
│ │ ├── OpenGlUtils.java
│ │ ├── Rotation.java
│ │ └── TextureRotationUtil.java
│ └── res/
│ └── values/
│ └── attrs.xml
├── sample/
│ ├── build.gradle
│ ├── proguard-project.txt
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ ├── java/
│ │ └── jp/
│ │ └── co/
│ │ └── cyberagent/
│ │ └── android/
│ │ └── gpuimage/
│ │ └── sample/
│ │ ├── GPUImageFilterTools.kt
│ │ ├── activity/
│ │ │ ├── CameraActivity.kt
│ │ │ ├── GalleryActivity.kt
│ │ │ └── MainActivity.kt
│ │ └── utils/
│ │ ├── Camera1Loader.kt
│ │ ├── Camera2Loader.kt
│ │ ├── CameraLoader.kt
│ │ ├── ImageExt.kt
│ │ └── ViewExt.kt
│ └── res/
│ ├── layout/
│ │ ├── activity_camera.xml
│ │ ├── activity_gallery.xml
│ │ └── activity_main.xml
│ ├── raw/
│ │ └── tone_cuver_sample.acv
│ └── values/
│ ├── strings.xml
│ └── styles.xml
├── settings.gradle
└── utils/
└── Shader2String.py
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/ISSUE_TEMPLATE.md
================================================
# Future Task
## What is the motivation?
## What kind of solution can be considered?
## What do you want to discuss?
*Please add relevant labels*
-----
# Bug Reporting
## Steps to Reproduce
## Actual Results (include screenshots)
## Expected Results (include screenshots)
## URL
## OS details
- Device:
- OS:
*Please add relevant labels*
================================================
FILE: .github/PULL_REQUEST_TEMPLATE.md
================================================
## What does this change?
## What is the value of this and can you measure success?
## Screenshots
================================================
FILE: .gitignore
================================================
# Mac OS
.DS_store
# Built application files
*.apk
*.ap_
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.idea/
projectFilesBackup/
# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
#*.jks
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
# Google Services (e.g. APIs or Firebase)
google-services.json
# Freeline
fastlane/README.md
fastlane/report.xml
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
# NDK
.externalNativeBuild
.cxx
================================================
FILE: CHANGELOG.md
================================================
Change Log
==========
Version 2.1.0 *(2020-09-21)*
----------------------------
* Update
* Kotlin to 1.3.72
* The targetSdkVersion from 28 to 30
* The compileSdkVersion from 28 to 30
Version 2.0.4 *(2019-08-13)*
----------------------------
* Update
* Kotlin to 1.3.41
* Android Gradle tools to 3.6.0-alpha05
* Gradle wrapper to 5.5
* Add
64bit build settings for clearly
Can get size of rescaled image [#443](https://github.com/cats-oss/android-gpuimage/pull/443)
* Bug fix
GPUImageZoomBlurFilter incorrect args [#454](https://github.com/cats-oss/android-gpuimage/pull/454)
Version 2.0.3 *(2018-11-09)*
----------------------------
* Add GPUImageVibranceFilter (by @itome)
Version 2.0.2 *(2018-11-01)*
----------------------------
* Add GPUImageSolarizeFilter (by @kettsun0123)
* Change attr/names
`show_loading` to `gpuimage_show_loading`
`surface_type` to `gpuimage_surface_type`
* Fix a bug about filter init [#420](https://github.com/cats-oss/android-gpuimage/pull/420)
Version 2.0.1 *(2018-10-24)*
----------------------------
* Add GPUImageLuminanceFilter (by @takasfz)
* Add GPUImageLuminanceThresholdFilter (by @takasfz)
Version 2.0.0 *(2018-10-23)*
----------------------------
* Change the minSdkVersion 9 to 14
* Change the targetSdkVersion 23 to 28
* Update project settings
* Support TextureView via GLTexureView
* Support Camera2 API
* Fix some bugs
Version 1.4.1 *(2016-03-15)*
----------------------------
Using Bintray's JCenter.
Version 1.4.0 *(2016-02-28)*
----------------------------
* added GPUImageHalftoneFilter (by @ryohey)
* added GPUImageTransformFilter (by @jonan)
* fixed GPUImageChromaKeyBlendFilter (by @badjano)
* fixed GPUImageLookupFilter (by @jonan)
Version 1.3.0 *(2015-09-04)*
----------------------------
* added GPUImageBilateralFilter (by @wysaid)
* added flip options to `GPUImage#setRotation`
Version 1.2.3-SNAPSHOT *(2014-12-15)*
----------------------------
* added GPUImageLevelsFilter (by @vashisthg)
================================================
FILE: CONTRIBUTING.md
================================================
# How to Contribute
We'd love to accept your patches and contributions to this project. There are
just a few small guidelines you need to follow.
## Contributor License Agreement
Contributions to this project must be accompanied by a Contributor License
Agreement. You (or your employer) retain the copyright to your contribution,
this simply gives us permission to use and redistribute your contributions as
part of the project. Head over to <https://cla-assistant.io/cats-oss/android-gpuimage> to see
your current agreements on file or to sign a new one.
You generally only need to submit a CLA once, so if you've already submitted one
(even if it was for a different project), you probably don't need to do it
again.
## Code reviews
All submissions, including submissions by project members, require review. We
use GitHub pull requests for this purpose. Consult
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
information on using pull requests.
## Community Guidelines
This project follows [Google's Open Source Community Guidelines](https://opensource.google.com/conduct/).
================================================
FILE: README.md
================================================
# GPUImage for Android
[](https://www.apache.org/licenses/LICENSE-2.0)
[ ](https://bintray.com/cats-oss/maven/gpuimage/_latestVersion)
[](https://search.maven.org/artifact/jp.co.cyberagent.android/gpuimage)
[](https://app.bitrise.io/app/d8d8090a71066e7c)
Idea from: [iOS GPUImage framework](https://github.com/BradLarson/GPUImage2)
Goal is to have something as similar to GPUImage as possible. Vertex and fragment shaders are exactly the same. That way it makes it easier to port filters from GPUImage iOS to Android.
## Requirements
* Android 2.2 or higher (OpenGL ES 2.0)
## Usage
### Gradle dependency
```groovy
repositories {
mavenCentral()
}
dependencies {
implementation 'jp.co.cyberagent.android:gpuimage:2.x.x'
}
```
### Sample Code
#### With preview:
Java:
```java
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity);
Uri imageUri = ...;
gpuImage = new GPUImage(this);
gpuImage.setGLSurfaceView((GLSurfaceView) findViewById(R.id.surfaceView));
gpuImage.setImage(imageUri); // this loads image on the current thread, should be run in a thread
gpuImage.setFilter(new GPUImageSepiaFilter());
// Later when image should be saved saved:
gpuImage.saveToPictures("GPUImage", "ImageWithFilter.jpg", null);
}
```
Kotlin:
```kotlin
public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_gallery)
val imageUri: Uri = ...
gpuImage = GPUImage(this)
gpuImage.setGLSurfaceView(findViewById<GLSurfaceView>(R.id.surfaceView))
gpuImage.setImage(imageUri) // this loads image on the current thread, should be run in a thread
gpuImage.setFilter(GPUImageSepiaFilter())
// Later when image should be saved saved:
gpuImage.saveToPictures("GPUImage", "ImageWithFilter.jpg", null)
}
```
#### Using GPUImageView
```xml
<jp.co.cyberagent.android.gpuimage.GPUImageView
android:id="@+id/gpuimageview"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:gpuimage_show_loading="false"
app:gpuimage_surface_type="texture_view" /> <!-- surface_view or texture_view -->
```
Java:
```java
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity);
Uri imageUri = ...;
gpuImageView = findViewById(R.id.gpuimageview);
gpuImageView.setImage(imageUri); // this loads image on the current thread, should be run in a thread
gpuImageView.setFilter(new GPUImageSepiaFilter());
// Later when image should be saved saved:
gpuImageView.saveToPictures("GPUImage", "ImageWithFilter.jpg", null);
}
```
Kotlin:
```kotlin
public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_gallery)
val imageUri: Uri = ...
gpuImageView = findViewById<GPUImageView>(R.id.gpuimageview)
gpuImageView.setImage(imageUri) // this loads image on the current thread, should be run in a thread
gpuImageView.setFilter(GPUImageSepiaFilter())
// Later when image should be saved saved:
gpuImageView.saveToPictures("GPUImage", "ImageWithFilter.jpg", null)
}
```
#### Without preview:
Java:
```java
public void onCreate(final Bundle savedInstanceState) {
public void onCreate(final Bundle savedInstanceState) {
Uri imageUri = ...;
gpuImage = new GPUImage(context);
gpuImage.setFilter(new GPUImageSobelEdgeDetection());
gpuImage.setImage(imageUri);
gpuImage.saveToPictures("GPUImage", "ImageWithFilter.jpg", null);
}
```
Kotlin:
```kotlin
public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_gallery)
val imageUri: Uri = ...
gpuImage = GPUImage(this)
gpuImage.setFilter(GPUImageSepiaFilter())
gpuImage.setImage(imageUri)
gpuImage.saveToPictures("GPUImage", "ImageWithFilter.jpg", null)
}
```
### Support status of [GPUImage for iOS](https://github.com/BradLarson/GPUImage2) shaders
- [x] Saturation
- [x] Contrast
- [x] Brightness
- [x] Levels
- [x] Exposure
- [x] RGB
- [x] RGB Diation
- [x] Hue
- [x] White Balance
- [x] Monochrome
- [x] False Color
- [x] Sharpen
- [ ] Unsharp Mask
- [x] Transform Operation
- [ ] Crop
- [x] Gamma
- [x] Highlights and Shadows
- [x] Haze
- [x] Sepia Tone
- [ ] Amatorka
- [ ] Miss Etikate
- [ ] Soft Elegance
- [x] Color Inversion
- [x] Solarize
- [x] Vibrance
- [ ] Highlight and Shadow Tint
- [x] Luminance
- [x] Luminance Threshold
- [ ] Average Color
- [ ] Average Luminance
- [ ] Average Luminance Threshold
- [ ] Adaptive Threshold
- [ ] Polar Pixellate
- [x] Pixellate
- [ ] Polka Dot
- [x] Halftone
- [x] Crosshatch
- [x] Sobel Edge Detection
- [ ] Prewitt Edge Detection
- [ ] Canny Edge Detection
- [x] Threshold Sobel EdgeDetection
- [ ] Harris Corner Detector
- [ ] Noble Corner Detector
- [ ] Shi Tomasi Feature Detector
- [ ] Colour FAST Feature Detector
- [ ] Low Pass Filter
- [ ] High Pass Filter
- [x] Sketch Filter
- [ ] Threshold Sketch Filter
- [x] Toon Filter
- [x] SmoothToon Filter
- [ ] Tilt Shift
- [x] CGA Colorspace Filter
- [x] Posterize
- [x] Convolution 3x3
- [x] Emboss Filter
- [x] Laplacian
- [x] Chroma Keying
- [x] Kuwahara Filter
- [ ] Kuwahara Radius3 Filter
- [x] Vignette
- [x] Gaussian Blur
- [x] Box Blur
- [x] Bilateral Blur
- [ ] Motion Blur
- [x] Zoom Blur
- [ ] iOS Blur
- [ ] Median Filter
- [x] Swirl Distortion
- [x] Bulge Distortion
- [ ] Pinch Distortion
- [x] Sphere Refraction
- [x] Glass Sphere Refraction
- [ ] Stretch Distortion
- [x] Dilation
- [ ] Erosion
- [ ] Opening Filter
- [ ] Closing Filter
- [ ] Local Binary Pattern
- [ ] Color Local Binary Pattern
- [x] Dissolve Blend
- [x] Chroma Key Blend
- [x] Add Blend
- [x] Divide Blend
- [x] Multiply Blend
- [x] Overlay Blend
- [x] Lighten Blend
- [x] Darken Blend
- [x] Color Burn Blend
- [x] Color Dodge Blend
- [x] Linear Burn Blend
- [x] Screen Blend
- [x] Difference Blend
- [x] Subtract Blend
- [x] Exclusion Blend
- [x] HardLight Blend
- [x] SoftLight Blend
- [x] Color Blend
- [x] Hue Blend
- [x] Saturation Blend
- [x] Luminosity Blend
- [x] Normal Blend
- [x] Source Over Blend
- [x] Alpha Blend
- [x] Non Maximum Suppression
- [ ] Thresholded Non Maximum Suppression
- [ ] Directional Non Maximum Suppression
- [x] Opacity
- [x] Weak Pixel Inclusion Filter
- [x] Color Matrix
- [x] Directional Sobel Edge Detection
- [x] Lookup
- [x] Tone Curve (*.acv files)
## Others
- [x] Texture 3x3
- [x] Gray Scale
### Gradle
Make sure that you run the clean target when using maven.
```groovy
gradle clean assemble
```
## License
Copyright 2018 CyberAgent, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: build.gradle
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.0-beta04'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// TODO: Close JCenter on May 1st https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/
// classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
// classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
}
allprojects {
repositories {
google()
mavenCentral()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-6.7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
================================================
FILE: gradle.properties
================================================
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.configureondemand=true
org.gradle.caching=true
android.enableBuildCache=true
VERSION_NAME=2.1.0
VERSION_CODE=14
COMPILE_SDK_VERSION=30
TARGET_SDK_VERSION=30
MIN_SDK_VERSION=14
android.useAndroidX=true
android.enableJetifier=true
================================================
FILE: gradlew
================================================
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"
================================================
FILE: gradlew.bat
================================================
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: library/build.gradle
================================================
apply plugin: 'com.android.library'
android {
compileSdkVersion COMPILE_SDK_VERSION as int
defaultConfig {
minSdkVersion MIN_SDK_VERSION as int
targetSdkVersion TARGET_SDK_VERSION as int
versionCode = VERSION_CODE as int
versionName = VERSION_NAME
ndk.abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
externalNativeBuild {
cmake { cppFlags "" }
}
}
externalNativeBuild {
cmake { path "src/main/cpp/CMakeLists.txt" }
}
buildTypes {
debug {
debuggable true
}
release {
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
ext {
bintrayRepo = 'maven'
bintrayName = 'gpuimage'
bintrayUserOrg = 'cats-oss'
publishedGroupId = 'jp.co.cyberagent.android'
libraryName = 'gpuimage'
artifact = 'gpuimage'
libraryDescription = 'Image filters for Android with OpenGL (based on GPUImage for iOS)'
siteUrl = 'https://github.com/cats-oss/android-gpuimage'
gitUrl = 'https://github.com/cats-oss/android-gpuimage.git'
issueUrl = 'https://github.com/cats-oss/android-gpuimage/issues'
libraryVersion = VERSION_NAME
developerId = 'cats'
developerName = 'CATS'
developerEmail = 'dadadada.chop@gmail.com'
licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}
// TODO: Close JCenter on May 1st https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/
// apply from: 'https://gist.githubusercontent.com/wasabeef/cf14805bee509baf7461974582f17d26/raw/bintray-v1.gradle'
// apply from: 'https://gist.githubusercontent.com/wasabeef/cf14805bee509baf7461974582f17d26/raw/install-v1.gradle'
apply from: 'https://gist.githubusercontent.com/wasabeef/2f2ae8d97b429e7d967128125dc47854/raw/maven-central-v1.gradle'
================================================
FILE: library/gradle.properties
================================================
POM_NAME=GPUImage for Android Library
POM_ARTIFACT_ID=gpuimage-library
POM_PACKAGING=aar
================================================
FILE: library/proguard-rules.txt
================================================
-dontwarn jp.co.cyberagent.android.gpuimage.**
================================================
FILE: library/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest package="jp.co.cyberagent.android.gpuimage" />
================================================
FILE: library/src/main/cpp/CMakeLists.txt
================================================
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html
# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.4.1)
# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.
add_library( # Sets the name of the library.
yuv-decoder
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
yuv-decoder.c)
# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log)
# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.
target_link_libraries( # Specifies the target library.
yuv-decoder
# Links the target library to the log library
# included in the NDK.
${log-lib}
GLESv2
jnigraphics)
================================================
FILE: library/src/main/cpp/yuv-decoder.c
================================================
#include <jni.h>
#include <android/bitmap.h>
#include <GLES2/gl2.h>
JNIEXPORT void JNICALL
Java_jp_co_cyberagent_android_gpuimage_GPUImageNativeLibrary_YUVtoRBGA(JNIEnv *env, jobject obj,
jbyteArray yuv420sp,
jint width, jint height,
jintArray rgbOut) {
int sz;
int i;
int j;
int Y;
int Cr = 0;
int Cb = 0;
int pixPtr = 0;
int jDiv2 = 0;
int R = 0;
int G = 0;
int B = 0;
int cOff;
int w = width;
int h = height;
sz = w * h;
jint *rgbData = (jint *) ((*env)->GetPrimitiveArrayCritical(env, rgbOut, 0));
jbyte *yuv = (jbyte *) (*env)->GetPrimitiveArrayCritical(env, yuv420sp, 0);
for (j = 0; j < h; j++) {
pixPtr = j * w;
jDiv2 = j >> 1;
for (i = 0; i < w; i++) {
Y = yuv[pixPtr];
if (Y < 0) Y += 255;
if ((i & 0x1) != 1) {
cOff = sz + jDiv2 * w + (i >> 1) * 2;
Cb = yuv[cOff];
if (Cb < 0) Cb += 127; else Cb -= 128;
Cr = yuv[cOff + 1];
if (Cr < 0) Cr += 127; else Cr -= 128;
}
//ITU-R BT.601 conversion
//
//R = 1.164*(Y-16) + 2.018*(Cr-128);
//G = 1.164*(Y-16) - 0.813*(Cb-128) - 0.391*(Cr-128);
//B = 1.164*(Y-16) + 1.596*(Cb-128);
//
Y = Y + (Y >> 3) + (Y >> 5) + (Y >> 7);
R = Y + (Cr << 1) + (Cr >> 6);
if (R < 0) R = 0; else if (R > 255) R = 255;
G = Y - Cb + (Cb >> 3) + (Cb >> 4) - (Cr >> 1) + (Cr >> 3);
if (G < 0) G = 0; else if (G > 255) G = 255;
B = Y + Cb + (Cb >> 1) + (Cb >> 4) + (Cb >> 5);
if (B < 0) B = 0; else if (B > 255) B = 255;
rgbData[pixPtr++] = 0xff000000 + (R << 16) + (G << 8) + B;
}
}
(*env)->ReleasePrimitiveArrayCritical(env, rgbOut, rgbData, 0);
(*env)->ReleasePrimitiveArrayCritical(env, yuv420sp, yuv, 0);
}
JNIEXPORT void JNICALL
Java_jp_co_cyberagent_android_gpuimage_GPUImageNativeLibrary_YUVtoARBG(JNIEnv *env, jobject obj,
jbyteArray yuv420sp,
jint width, jint height,
jintArray rgbOut) {
int sz;
int i;
int j;
int Y;
int Cr = 0;
int Cb = 0;
int pixPtr = 0;
int jDiv2 = 0;
int R = 0;
int G = 0;
int B = 0;
int cOff;
int w = width;
int h = height;
sz = w * h;
jint *rgbData = (jint *) ((*env)->GetPrimitiveArrayCritical(env, rgbOut, 0));
jbyte *yuv = (jbyte *) (*env)->GetPrimitiveArrayCritical(env, yuv420sp, 0);
for (j = 0; j < h; j++) {
pixPtr = j * w;
jDiv2 = j >> 1;
for (i = 0; i < w; i++) {
Y = yuv[pixPtr];
if (Y < 0) Y += 255;
if ((i & 0x1) != 1) {
cOff = sz + jDiv2 * w + (i >> 1) * 2;
Cb = yuv[cOff];
if (Cb < 0) Cb += 127; else Cb -= 128;
Cr = yuv[cOff + 1];
if (Cr < 0) Cr += 127; else Cr -= 128;
}
//ITU-R BT.601 conversion
//
//R = 1.164*(Y-16) + 2.018*(Cr-128);
//G = 1.164*(Y-16) - 0.813*(Cb-128) - 0.391*(Cr-128);
//B = 1.164*(Y-16) + 1.596*(Cb-128);
//
Y = Y + (Y >> 3) + (Y >> 5) + (Y >> 7);
R = Y + (Cr << 1) + (Cr >> 6);
if (R < 0) R = 0; else if (R > 255) R = 255;
G = Y - Cb + (Cb >> 3) + (Cb >> 4) - (Cr >> 1) + (Cr >> 3);
if (G < 0) G = 0; else if (G > 255) G = 255;
B = Y + Cb + (Cb >> 1) + (Cb >> 4) + (Cb >> 5);
if (B < 0) B = 0; else if (B > 255) B = 255;
rgbData[pixPtr++] = 0xff000000 + (B << 16) + (G << 8) + R;
}
}
(*env)->ReleasePrimitiveArrayCritical(env, rgbOut, rgbData, 0);
(*env)->ReleasePrimitiveArrayCritical(env, yuv420sp, yuv, 0);
}
JNIEXPORT void JNICALL
Java_jp_co_cyberagent_android_gpuimage_GPUImageNativeLibrary_adjustBitmap(JNIEnv *jenv, jclass thiz,
jobject src) {
unsigned char *srcByteBuffer;
int result = 0;
int i, j;
AndroidBitmapInfo srcInfo;
result = AndroidBitmap_getInfo(jenv, src, &srcInfo);
if (result != ANDROID_BITMAP_RESULT_SUCCESS) {
return;
}
result = AndroidBitmap_lockPixels(jenv, src, (void **) &srcByteBuffer);
if (result != ANDROID_BITMAP_RESULT_SUCCESS) {
return;
}
int width = srcInfo.width;
int height = srcInfo.height;
glReadPixels(0, 0, srcInfo.width, srcInfo.height, GL_RGBA, GL_UNSIGNED_BYTE, srcByteBuffer);
int *pIntBuffer = (int *) srcByteBuffer;
for (i = 0; i < height / 2; i++) {
for (j = 0; j < width; j++) {
int temp = pIntBuffer[(height - i - 1) * width + j];
pIntBuffer[(height - i - 1) * width + j] = pIntBuffer[i * width + j];
pIntBuffer[i * width + j] = temp;
}
}
AndroidBitmap_unlockPixels(jenv, src);
}
================================================
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/GLTextureView.java
================================================
package jp.co.cyberagent.android.gpuimage;
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.opengl.GLDebugHelper;
import android.util.AttributeSet;
import android.util.Log;
import android.view.TextureView;
import android.view.View;
import java.io.Writer;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGL11;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.egl.EGLSurface;
import javax.microedition.khronos.opengles.GL;
import javax.microedition.khronos.opengles.GL10;
/*
* Copyright (C) 2018 Wasabeef
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
public class GLTextureView extends TextureView
implements TextureView.SurfaceTextureListener, View.OnLayoutChangeListener {
private final static String TAG = GLTextureView.class.getSimpleName();
private final static boolean LOG_ATTACH_DETACH = false;
private final static boolean LOG_THREADS = false;
private final static boolean LOG_PAUSE_RESUME = false;
private final static boolean LOG_SURFACE = false;
private final static boolean LOG_RENDERER = false;
private final static boolean LOG_RENDERER_DRAW_FRAME = false;
private final static boolean LOG_EGL = false;
/**
* The renderer only renders
* when the surface is created, or when {@link #requestRender} is called.
*
* @see #getRenderMode()
* @see #setRenderMode(int)
* @see #requestRender()
*/
public final static int RENDERMODE_WHEN_DIRTY = 0;
/**
* The renderer is called
* continuously to re-render the scene.
*
* @see #getRenderMode()
* @see #setRenderMode(int)
*/
public final static int RENDERMODE_CONTINUOUSLY = 1;
/**
* Check glError() after every GL call and throw an exception if glError indicates
* that an error has occurred. This can be used to help track down which OpenGL ES call
* is causing an error.
*
* @see #getDebugFlags
* @see #setDebugFlags
*/
public final static int DEBUG_CHECK_GL_ERROR = 1;
/**
* Log GL calls to the system log at "verbose" level with tag "GLTextureView".
*
* @see #getDebugFlags
* @see #setDebugFlags
*/
public final static int DEBUG_LOG_GL_CALLS = 2;
/**
* Standard View constructor. In order to render something, you
* must call {@link #setRenderer} to register a renderer.
*/
public GLTextureView(Context context) {
super(context);
init();
}
/**
* Standard View constructor. In order to render something, you
* must call {@link #setRenderer} to register a renderer.
*/
public GLTextureView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
@Override
protected void finalize() throws Throwable {
try {
if (glThread != null) {
// GLThread may still be running if this view was never
// attached to a window.
glThread.requestExitAndWait();
}
} finally {
super.finalize();
}
}
private void init() {
setSurfaceTextureListener(this);
}
/**
* Set the glWrapper. If the glWrapper is not null, its
* {@link GLWrapper#wrap(javax.microedition.khronos.opengles.GL)} method is called
* whenever a surface is created. A GLWrapper can be used to wrap
* the GL object that's passed to the renderer. Wrapping a GL
* object enables examining and modifying the behavior of the
* GL calls made by the renderer.
* <p>
* Wrapping is typically used for debugging purposes.
* <p>
* The default value is null.
*
* @param glWrapper the new GLWrapper
*/
public void setGLWrapper(GLWrapper glWrapper) {
this.glWrapper = glWrapper;
}
/**
* Set the debug flags to a new value. The value is
* constructed by OR-together zero or more
* of the DEBUG_CHECK_* constants. The debug flags take effect
* whenever a surface is created. The default value is zero.
*
* @param debugFlags the new debug flags
* @see #DEBUG_CHECK_GL_ERROR
* @see #DEBUG_LOG_GL_CALLS
*/
public void setDebugFlags(int debugFlags) {
this.debugFlags = debugFlags;
}
/**
* Get the current value of the debug flags.
*
* @return the current value of the debug flags.
*/
public int getDebugFlags() {
return debugFlags;
}
/**
* Control whether the EGL context is preserved when the GLTextureView is paused and
* resumed.
* <p>
* If set to true, then the EGL context may be preserved when the GLTextureView is paused.
* Whether the EGL context is actually preserved or not depends upon whether the
* Android device that the program is running on can support an arbitrary number of EGL
* contexts or not. Devices that can only support a limited number of EGL contexts must
* release the EGL context in order to allow multiple applications to share the GPU.
* <p>
* If set to false, the EGL context will be released when the GLTextureView is paused,
* and recreated when the GLTextureView is resumed.
* <p>
* <p>
* The default is false.
*
* @param preserveOnPause preserve the EGL context when paused
*/
public void setPreserveEGLContextOnPause(boolean preserveOnPause) {
preserveEGLContextOnPause = preserveOnPause;
}
/**
* @return true if the EGL context will be preserved when paused
*/
public boolean getPreserveEGLContextOnPause() {
return preserveEGLContextOnPause;
}
/**
* Set the renderer associated with this view. Also starts the thread that
* will call the renderer, which in turn causes the rendering to start.
* <p>This method should be called once and only once in the life-cycle of
* a GLTextureView.
* <p>The following GLTextureView methods can only be called <em>before</em>
* setRenderer is called:
* <ul>
* <li>{@link #setEGLConfigChooser(boolean)}
* <li>{@link #setEGLConfigChooser(EGLConfigChooser)}
* <li>{@link #setEGLConfigChooser(int, int, int, int, int, int)}
* </ul>
* <p>
* The following GLTextureView methods can only be called <em>after</em>
* setRenderer is called:
* <ul>
* <li>{@link #getRenderMode()}
* <li>{@link #onPause()}
* <li>{@link #onResume()}
* <li>{@link #queueEvent(Runnable)}
* <li>{@link #requestRender()}
* <li>{@link #setRenderMode(int)}
* </ul>
*
* @param renderer the renderer to use to perform OpenGL drawing.
*/
public void setRenderer(Renderer renderer) {
checkRenderThreadState();
if (eglConfigChooser == null) {
eglConfigChooser = new SimpleEGLConfigChooser(true);
}
if (eglContextFactory == null) {
eglContextFactory = new DefaultContextFactory();
}
if (eglWindowSurfaceFactory == null) {
eglWindowSurfaceFactory = new DefaultWindowSurfaceFactory();
}
this.renderer = renderer;
glThread = new GLThread(mThisWeakRef);
glThread.start();
}
/**
* Install a custom EGLContextFactory.
* <p>If this method is
* called, it must be called before {@link #setRenderer(Renderer)}
* is called.
* <p>
* If this method is not called, then by default
* a context will be created with no shared context and
* with a null attribute list.
*/
public void setEGLContextFactory(EGLContextFactory factory) {
checkRenderThreadState();
eglContextFactory = factory;
}
/**
* Install a custom EGLWindowSurfaceFactory.
* <p>If this method is
* called, it must be called before {@link #setRenderer(Renderer)}
* is called.
* <p>
* If this method is not called, then by default
* a window surface will be created with a null attribute list.
*/
public void setEGLWindowSurfaceFactory(EGLWindowSurfaceFactory factory) {
checkRenderThreadState();
eglWindowSurfaceFactory = factory;
}
/**
* Install a custom EGLConfigChooser.
* <p>If this method is
* called, it must be called before {@link #setRenderer(Renderer)}
* is called.
* <p>
* If no setEGLConfigChooser method is called, then by default the
* view will choose an EGLConfig that is compatible with the current
* android.view.Surface, with a depth buffer depth of
* at least 16 bits.
*/
public void setEGLConfigChooser(EGLConfigChooser configChooser) {
checkRenderThreadState();
eglConfigChooser = configChooser;
}
/**
* Install a config chooser which will choose a config
* as close to 16-bit RGB as possible, with or without an optional depth
* buffer as close to 16-bits as possible.
* <p>If this method is
* called, it must be called before {@link #setRenderer(Renderer)}
* is called.
* <p>
* If no setEGLConfigChooser method is called, then by default the
* view will choose an RGB_888 surface with a depth buffer depth of
* at least 16 bits.
*/
public void setEGLConfigChooser(boolean needDepth) {
setEGLConfigChooser(new SimpleEGLConfigChooser(needDepth));
}
/**
* Install a config chooser which will choose a config
* with at least the specified depthSize and stencilSize,
* and exactly the specified redSize, greenSize, blueSize and alphaSize.
* <p>If this method is
* called, it must be called before {@link #setRenderer(Renderer)}
* is called.
* <p>
* If no setEGLConfigChooser method is called, then by default the
* view will choose an RGB_888 surface with a depth buffer depth of
* at least 16 bits.
*/
public void setEGLConfigChooser(int redSize, int greenSize, int blueSize, int alphaSize,
int depthSize, int stencilSize) {
setEGLConfigChooser(
new ComponentSizeChooser(redSize, greenSize, blueSize, alphaSize, depthSize, stencilSize));
}
/**
* Inform the default EGLContextFactory and default EGLConfigChooser
* which EGLContext client version to pick.
* <p>Use this method to create an OpenGL ES 2.0-compatible context.
* Example:
* <pre class="prettyprint">
* public MyView(Context context) {
* super(context);
* setEGLContextClientVersion(2); // Pick an OpenGL ES 2.0 context.
* setRenderer(new MyRenderer());
* }
* </pre>
* <p>Note: Activities which require OpenGL ES 2.0 should indicate this by
* setting @lt;uses-feature android:glEsVersion="0x00020000" /> in the activity's
* AndroidManifest.xml file.
* <p>If this method is called, it must be called before {@link #setRenderer(Renderer)}
* is called.
* <p>This method only affects the behavior of the default EGLContexFactory and the
* default EGLConfigChooser. If
* {@link #setEGLContextFactory(EGLContextFactory)} has been called, then the supplied
* EGLContextFactory is responsible for creating an OpenGL ES 2.0-compatible context.
* If
* {@link #setEGLConfigChooser(EGLConfigChooser)} has been called, then the supplied
* EGLConfigChooser is responsible for choosing an OpenGL ES 2.0-compatible config.
*
* @param version The EGLContext client version to choose. Use 2 for OpenGL ES 2.0
*/
public void setEGLContextClientVersion(int version) {
checkRenderThreadState();
eglContextClientVersion = version;
}
/**
* Set the rendering mode. When renderMode is
* RENDERMODE_CONTINUOUSLY, the renderer is called
* repeatedly to re-render the scene. When renderMode
* is RENDERMODE_WHEN_DIRTY, the renderer only rendered when the surface
* is created, or when {@link #requestRender} is called. Defaults to RENDERMODE_CONTINUOUSLY.
* <p>
* Using RENDERMODE_WHEN_DIRTY can improve battery life and overall system performance
* by allowing the GPU and CPU to idle when the view does not need to be updated.
* <p>
* This method can only be called after {@link #setRenderer(Renderer)}
*
* @param renderMode one of the RENDERMODE_X constants
* @see #RENDERMODE_CONTINUOUSLY
* @see #RENDERMODE_WHEN_DIRTY
*/
public void setRenderMode(int renderMode) {
glThread.setRenderMode(renderMode);
}
/**
* Get the current rendering mode. May be called
* from any thread. Must not be called before a renderer has been set.
*
* @return the current rendering mode.
* @see #RENDERMODE_CONTINUOUSLY
* @see #RENDERMODE_WHEN_DIRTY
*/
public int getRenderMode() {
return glThread.getRenderMode();
}
/**
* Request that the renderer render a frame.
* This method is typically used when the render mode has been set to
* {@link #RENDERMODE_WHEN_DIRTY}, so that frames are only rendered on demand.
* May be called
* from any thread. Must not be called before a renderer has been set.
*/
public void requestRender() {
glThread.requestRender();
}
/**
* This method is part of the SurfaceHolder.Callback interface, and is
* not normally called or subclassed by clients of GLTextureView.
*/
public void surfaceCreated(SurfaceTexture texture) {
glThread.surfaceCreated();
}
/**
* This method is part of the SurfaceHolder.Callback interface, and is
* not normally called or subclassed by clients of GLTextureView.
*/
public void surfaceDestroyed(SurfaceTexture texture) {
// Surface will be destroyed when we return
glThread.surfaceDestroyed();
}
/**
* This method is part of the SurfaceHolder.Callback interface, and is
* not normally called or subclassed by clients of GLTextureView.
*/
public void surfaceChanged(SurfaceTexture texture, int format, int w, int h) {
glThread.onWindowResize(w, h);
}
/**
* Inform the view that the activity is paused. The owner of this view must
* call this method when the activity is paused. Calling this method will
* pause the rendering thread.
* Must not be called before a renderer has been set.
*/
public void onPause() {
glThread.onPause();
}
/**
* Inform the view that the activity is resumed. The owner of this view must
* call this method when the activity is resumed. Calling this method will
* recreate the OpenGL display and resume the rendering
* thread.
* Must not be called before a renderer has been set.
*/
public void onResume() {
glThread.onResume();
}
/**
* Queue a runnable to be run on the GL rendering thread. This can be used
* to communicate with the Renderer on the rendering thread.
* Must not be called before a renderer has been set.
*
* @param r the runnable to be run on the GL rendering thread.
*/
public void queueEvent(Runnable r) {
glThread.queueEvent(r);
}
/**
* This method is used as part of the View class and is not normally
* called or subclassed by clients of GLTextureView.
*/
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (LOG_ATTACH_DETACH) {
Log.d(TAG, "onAttachedToWindow reattach =" + detached);
}
if (detached && (renderer != null)) {
int renderMode = RENDERMODE_CONTINUOUSLY;
if (glThread != null) {
renderMode = glThread.getRenderMode();
}
glThread = new GLThread(mThisWeakRef);
if (renderMode != RENDERMODE_CONTINUOUSLY) {
glThread.setRenderMode(renderMode);
}
glThread.start();
}
detached = false;
}
/**
* This method is used as part of the View class and is not normally
* called or subclassed by clients of GLTextureView.
* Must not be called before a renderer has been set.
*/
@Override
protected void onDetachedFromWindow() {
if (LOG_ATTACH_DETACH) {
Log.d(TAG, "onDetachedFromWindow");
}
if (glThread != null) {
glThread.requestExitAndWait();
}
detached = true;
super.onDetachedFromWindow();
}
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft,
int oldTop, int oldRight, int oldBottom) {
surfaceChanged(getSurfaceTexture(), 0, right - left, bottom - top);
}
public void addSurfaceTextureListener(SurfaceTextureListener listener) {
surfaceTextureListeners.add(listener);
}
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
surfaceCreated(surface);
surfaceChanged(surface, 0, width, height);
for (SurfaceTextureListener l : surfaceTextureListeners) {
l.onSurfaceTextureAvailable(surface, width, height);
}
}
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
surfaceChanged(surface, 0, width, height);
for (SurfaceTextureListener l : surfaceTextureListeners) {
l.onSurfaceTextureSizeChanged(surface, width, height);
}
}
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
surfaceDestroyed(surface);
for (SurfaceTextureListener l : surfaceTextureListeners) {
l.onSurfaceTextureDestroyed(surface);
}
return true;
}
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
requestRender();
for (SurfaceTextureListener l : surfaceTextureListeners) {
l.onSurfaceTextureUpdated(surface);
}
}
// ----------------------------------------------------------------------
/**
* An interface used to wrap a GL interface.
* <p>Typically
* used for implementing debugging and tracing on top of the default
* GL interface. You would typically use this by creating your own class
* that implemented all the GL methods by delegating to another GL instance.
* Then you could add your own behavior before or after calling the
* delegate. All the GLWrapper would do was instantiate and return the
* wrapper GL instance:
* <pre class="prettyprint">
* class MyGLWrapper implements GLWrapper {
* GL wrap(GL gl) {
* return new MyGLImplementation(gl);
* }
* static class MyGLImplementation implements GL,GL10,GL11,... {
* ...
* }
* }
* </pre>
*
* @see #setGLWrapper(GLWrapper)
*/
public interface GLWrapper {
/**
* Wraps a gl interface in another gl interface.
*
* @param gl a GL interface that is to be wrapped.
* @return either the input argument or another GL object that wraps the input argument.
*/
GL wrap(GL gl);
}
/**
* A generic renderer interface.
* <p>
* The renderer is responsible for making OpenGL calls to render a frame.
* <p>
* GLTextureView clients typically create their own classes that implement
* this interface, and then call {@link GLTextureView#setRenderer} to
* register the renderer with the GLTextureView.
* <p>
*
* <div class="special reference">
* <h3>Developer Guides</h3>
* <p>For more information about how to use OpenGL, read the
* <a href="{@docRoot}guide/topics/graphics/opengl.html">OpenGL</a> developer guide.</p>
* </div>
*
* <h3>Threading</h3>
* The renderer will be called on a separate thread, so that rendering
* performance is decoupled from the UI thread. Clients typically need to
* communicate with the renderer from the UI thread, because that's where
* input events are received. Clients can communicate using any of the
* standard Java techniques for cross-thread communication, or they can
* use the {@link GLTextureView#queueEvent(Runnable)} convenience method.
* <p>
* <h3>EGL Context Lost</h3>
* There are situations where the EGL rendering context will be lost. This
* typically happens when device wakes up after going to sleep. When
* the EGL context is lost, all OpenGL resources (such as textures) that are
* associated with that context will be automatically deleted. In order to
* keep rendering correctly, a renderer must recreate any lost resources
* that it still needs. The {@link #onSurfaceCreated(javax.microedition.khronos.opengles.GL10,
* javax.microedition.khronos.egl.EGLConfig)} method
* is a convenient place to do this.
*
* @see #setRenderer(Renderer)
*/
public interface Renderer {
/**
* Called when the surface is created or recreated.
* <p>
* Called when the rendering thread
* starts and whenever the EGL context is lost. The EGL context will typically
* be lost when the Android device awakes after going to sleep.
* <p>
* Since this method is called at the beginning of rendering, as well as
* every time the EGL context is lost, this method is a convenient place to put
* code to create resources that need to be created when the rendering
* starts, and that need to be recreated when the EGL context is lost.
* Textures are an example of a resource that you might want to create
* here.
* <p>
* Note that when the EGL context is lost, all OpenGL resources associated
* with that context will be automatically deleted. You do not need to call
* the corresponding "glDelete" methods such as glDeleteTextures to
* manually delete these lost resources.
* <p>
*
* @param gl the GL interface. Use <code>instanceof</code> to
* test if the interface supports GL11 or higher interfaces.
* @param config the EGLConfig of the created surface. Can be used
* to create matching pbuffers.
*/
void onSurfaceCreated(GL10 gl, EGLConfig config);
/**
* Called when the surface changed size.
* <p>
* Called after the surface is created and whenever
* the OpenGL ES surface size changes.
* <p>
* Typically you will set your viewport here. If your camera
* is fixed then you could also set your projection matrix here:
* <pre class="prettyprint">
* void onSurfaceChanged(GL10 gl, int width, int height) {
* gl.glViewport(0, 0, width, height);
* // for a fixed camera, set the projection too
* float ratio = (float) width / height;
* gl.glMatrixMode(GL10.GL_PROJECTION);
* gl.glLoadIdentity();
* gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10);
* }
* </pre>
*
* @param gl the GL interface. Use <code>instanceof</code> to
* test if the interface supports GL11 or higher interfaces.
*/
void onSurfaceChanged(GL10 gl, int width, int height);
/**
* Called to draw the current frame.
* <p>
* This method is responsible for drawing the current frame.
* <p>
* The implementation of this method typically looks like this:
* <pre class="prettyprint">
* void onDrawFrame(GL10 gl) {
* gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
* //... other gl calls to render the scene ...
* }
* </pre>
*
* @param gl the GL interface. Use <code>instanceof</code> to
* test if the interface supports GL11 or higher interfaces.
*/
void onDrawFrame(GL10 gl);
}
/**
* An interface for customizing the eglCreateContext and eglDestroyContext calls.
* <p>
* This interface must be implemented by clients wishing to call
* {@link GLTextureView#setEGLContextFactory(EGLContextFactory)}
*/
public interface EGLContextFactory {
EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig);
void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context);
}
private class DefaultContextFactory implements EGLContextFactory {
private int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig config) {
int[] attrib_list = {
EGL_CONTEXT_CLIENT_VERSION, eglContextClientVersion, EGL10.EGL_NONE
};
return egl.eglCreateContext(display, config, EGL10.EGL_NO_CONTEXT,
eglContextClientVersion != 0 ? attrib_list : null);
}
public void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context) {
if (!egl.eglDestroyContext(display, context)) {
Log.e("DefaultContextFactory", "display:" + display + " context: " + context);
if (LOG_THREADS) {
Log.i("DefaultContextFactory", "tid=" + Thread.currentThread().getId());
}
EglHelper.throwEglException("eglDestroyContex", egl.eglGetError());
}
}
}
/**
* An interface for customizing the eglCreateWindowSurface and eglDestroySurface calls.
* <p>
* This interface must be implemented by clients wishing to call
* {@link GLTextureView#setEGLWindowSurfaceFactory(EGLWindowSurfaceFactory)}
*/
public interface EGLWindowSurfaceFactory {
/**
* @return null if the surface cannot be constructed.
*/
EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display, EGLConfig config,
Object nativeWindow);
void destroySurface(EGL10 egl, EGLDisplay display, EGLSurface surface);
}
private static class DefaultWindowSurfaceFactory implements EGLWindowSurfaceFactory {
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display, EGLConfig config,
Object nativeWindow) {
EGLSurface result = null;
try {
result = egl.eglCreateWindowSurface(display, config, nativeWindow, null);
} catch (IllegalArgumentException e) {
// This exception indicates that the surface flinger surface
// is not valid. This can happen if the surface flinger surface has
// been torn down, but the application has not yet been
// notified via SurfaceHolder.Callback.surfaceDestroyed.
// In theory the application should be notified first,
// but in practice sometimes it is not. See b/4588890
Log.e(TAG, "eglCreateWindowSurface", e);
}
return result;
}
public void destroySurface(EGL10 egl, EGLDisplay display, EGLSurface surface) {
egl.eglDestroySurface(display, surface);
}
}
/**
* An interface for choosing an EGLConfig configuration from a list of
* potential configurations.
* <p>
* This interface must be implemented by clients wishing to call
* {@link GLTextureView#setEGLConfigChooser(EGLConfigChooser)}
*/
public interface EGLConfigChooser {
/**
* Choose a configuration from the list. Implementors typically
* implement this method by calling
* {@link EGL10#eglChooseConfig} and iterating through the results. Please consult the
* EGL specification available from The Khronos Group to learn how to call eglChooseConfig.
*
* @param egl the EGL10 for the current display.
* @param display the current display.
* @return the chosen configuration.
*/
EGLConfig chooseConfig(EGL10 egl, EGLDisplay display);
}
private abstract class BaseConfigChooser implements EGLConfigChooser {
public BaseConfigChooser(int[] configSpec) {
mConfigSpec = filterConfigSpec(configSpec);
}
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
int[] num_config = new int[1];
if (!egl.eglChooseConfig(display, mConfigSpec, null, 0, num_config)) {
throw new IllegalArgumentException("eglChooseConfig failed");
}
int numConfigs = num_config[0];
if (numConfigs <= 0) {
throw new IllegalArgumentException("No configs match configSpec");
}
EGLConfig[] configs = new EGLConfig[numConfigs];
if (!egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs, num_config)) {
throw new IllegalArgumentException("eglChooseConfig#2 failed");
}
EGLConfig config = chooseConfig(egl, display, configs);
if (config == null) {
throw new IllegalArgumentException("No config chosen");
}
return config;
}
abstract EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs);
protected int[] mConfigSpec;
private int[] filterConfigSpec(int[] configSpec) {
if (eglContextClientVersion != 2) {
return configSpec;
}
/* We know none of the subclasses define EGL_RENDERABLE_TYPE.
* And we know the configSpec is well formed.
*/
int len = configSpec.length;
int[] newConfigSpec = new int[len + 2];
System.arraycopy(configSpec, 0, newConfigSpec, 0, len - 1);
newConfigSpec[len - 1] = EGL10.EGL_RENDERABLE_TYPE;
newConfigSpec[len] = 0x0004; /* EGL_OPENGL_ES2_BIT */
newConfigSpec[len + 1] = EGL10.EGL_NONE;
return newConfigSpec;
}
}
/**
* Choose a configuration with exactly the specified r,g,b,a sizes,
* and at least the specified depth and stencil sizes.
*/
private class ComponentSizeChooser extends BaseConfigChooser {
public ComponentSizeChooser(int redSize, int greenSize, int blueSize, int alphaSize,
int depthSize, int stencilSize) {
super(new int[]{
EGL10.EGL_RED_SIZE, redSize, EGL10.EGL_GREEN_SIZE, greenSize, EGL10.EGL_BLUE_SIZE,
blueSize, EGL10.EGL_ALPHA_SIZE, alphaSize, EGL10.EGL_DEPTH_SIZE, depthSize,
EGL10.EGL_STENCIL_SIZE, stencilSize, EGL10.EGL_NONE
});
value = new int[1];
this.redSize = redSize;
this.greenSize = greenSize;
this.blueSize = blueSize;
this.alphaSize = alphaSize;
this.depthSize = depthSize;
this.stencilSize = stencilSize;
}
@Override
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs) {
for (EGLConfig config : configs) {
int d = findConfigAttrib(egl, display, config, EGL10.EGL_DEPTH_SIZE, 0);
int s = findConfigAttrib(egl, display, config, EGL10.EGL_STENCIL_SIZE, 0);
if ((d >= depthSize) && (s >= stencilSize)) {
int r = findConfigAttrib(egl, display, config, EGL10.EGL_RED_SIZE, 0);
int g = findConfigAttrib(egl, display, config, EGL10.EGL_GREEN_SIZE, 0);
int b = findConfigAttrib(egl, display, config, EGL10.EGL_BLUE_SIZE, 0);
int a = findConfigAttrib(egl, display, config, EGL10.EGL_ALPHA_SIZE, 0);
if ((r == redSize) && (g == greenSize) && (b == blueSize) && (a == alphaSize)) {
return config;
}
}
}
return null;
}
private int findConfigAttrib(EGL10 egl, EGLDisplay display, EGLConfig config, int attribute,
int defaultValue) {
if (egl.eglGetConfigAttrib(display, config, attribute, value)) {
return value[0];
}
return defaultValue;
}
private int[] value;
// Subclasses can adjust these values:
protected int redSize;
protected int greenSize;
protected int blueSize;
protected int alphaSize;
protected int depthSize;
protected int stencilSize;
}
/**
* This class will choose a RGB_888 surface with
* or without a depth buffer.
*/
private class SimpleEGLConfigChooser extends ComponentSizeChooser {
public SimpleEGLConfigChooser(boolean withDepthBuffer) {
super(8, 8, 8, 0, withDepthBuffer ? 16 : 0, 0);
}
}
/**
* An EGL helper class.
*/
private static class EglHelper {
public EglHelper(WeakReference<GLTextureView> glTextureViewWeakReference) {
this.glTextureViewWeakRef = glTextureViewWeakReference;
}
/**
* Initialize EGL for a given configuration spec.
*/
public void start() {
if (LOG_EGL) {
Log.w("EglHelper", "start() tid=" + Thread.currentThread().getId());
}
/*
* Get an EGL instance
*/
egl = (EGL10) EGLContext.getEGL();
/*
* Get to the default display.
*/
eglDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
if (eglDisplay == EGL10.EGL_NO_DISPLAY) {
throw new RuntimeException("eglGetDisplay failed");
}
/*
* We can now initialize EGL for that display
*/
int[] version = new int[2];
if (!egl.eglInitialize(eglDisplay, version)) {
throw new RuntimeException("eglInitialize failed");
}
GLTextureView view = glTextureViewWeakRef.get();
if (view == null) {
eglConfig = null;
eglContext = null;
} else {
eglConfig = view.eglConfigChooser.chooseConfig(egl, eglDisplay);
/*
* Create an EGL context. We want to do this as rarely as we can, because an
* EGL context is a somewhat heavy object.
*/
eglContext = view.eglContextFactory.createContext(egl, eglDisplay, eglConfig);
}
if (eglContext == null || eglContext == EGL10.EGL_NO_CONTEXT) {
eglContext = null;
throwEglException("createContext");
}
if (LOG_EGL) {
Log.w("EglHelper",
"createContext " + eglContext + " tid=" + Thread.currentThread().getId());
}
eglSurface = null;
}
/**
* Create an egl surface for the current SurfaceHolder surface. If a surface
* already exists, destroy it before creating the new surface.
*
* @return true if the surface was created successfully.
*/
public boolean createSurface() {
if (LOG_EGL) {
Log.w("EglHelper", "createSurface() tid=" + Thread.currentThread().getId());
}
/*
* Check preconditions.
*/
if (egl == null) {
throw new RuntimeException("egl not initialized");
}
if (eglDisplay == null) {
throw new RuntimeException("eglDisplay not initialized");
}
if (eglConfig == null) {
throw new RuntimeException("eglConfig not initialized");
}
/*
* The window size has changed, so we need to create a new
* surface.
*/
destroySurfaceImp();
/*
* Create an EGL surface we can render into.
*/
GLTextureView view = glTextureViewWeakRef.get();
if (view != null) {
eglSurface = view.eglWindowSurfaceFactory.createWindowSurface(egl, eglDisplay, eglConfig,
view.getSurfaceTexture());
} else {
eglSurface = null;
}
if (eglSurface == null || eglSurface == EGL10.EGL_NO_SURFACE) {
int error = egl.eglGetError();
if (error == EGL10.EGL_BAD_NATIVE_WINDOW) {
Log.e("EglHelper", "createWindowSurface returned EGL_BAD_NATIVE_WINDOW.");
}
return false;
}
/*
* Before we can issue GL commands, we need to make sure
* the context is current and bound to a surface.
*/
if (!egl.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) {
/*
* Could not make the context current, probably because the underlying
* TextureView surface has been destroyed.
*/
logEglErrorAsWarning("EGLHelper", "eglMakeCurrent", egl.eglGetError());
return false;
}
return true;
}
/**
* Create a GL object for the current EGL context.
*/
GL createGL() {
GL gl = eglContext.getGL();
GLTextureView view = glTextureViewWeakRef.get();
if (view != null) {
if (view.glWrapper != null) {
gl = view.glWrapper.wrap(gl);
}
if ((view.debugFlags & (DEBUG_CHECK_GL_ERROR | DEBUG_LOG_GL_CALLS)) != 0) {
int configFlags = 0;
Writer log = null;
if ((view.debugFlags & DEBUG_CHECK_GL_ERROR) != 0) {
configFlags |= GLDebugHelper.CONFIG_CHECK_GL_ERROR;
}
if ((view.debugFlags & DEBUG_LOG_GL_CALLS) != 0) {
log = new LogWriter();
}
gl = GLDebugHelper.wrap(gl, configFlags, log);
}
}
return gl;
}
/**
* Display the current render surface.
*
* @return the EGL error code from eglSwapBuffers.
*/
public int swap() {
if (!egl.eglSwapBuffers(eglDisplay, eglSurface)) {
return egl.eglGetError();
}
return EGL10.EGL_SUCCESS;
}
public void destroySurface() {
if (LOG_EGL) {
Log.w("EglHelper", "destroySurface() tid=" + Thread.currentThread().getId());
}
destroySurfaceImp();
}
private void destroySurfaceImp() {
if (eglSurface != null && eglSurface != EGL10.EGL_NO_SURFACE) {
egl.eglMakeCurrent(eglDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE,
EGL10.EGL_NO_CONTEXT);
GLTextureView view = glTextureViewWeakRef.get();
if (view != null) {
view.eglWindowSurfaceFactory.destroySurface(egl, eglDisplay, eglSurface);
}
eglSurface = null;
}
}
public void finish() {
if (LOG_EGL) {
Log.w("EglHelper", "finish() tid=" + Thread.currentThread().getId());
}
if (eglContext != null) {
GLTextureView view = glTextureViewWeakRef.get();
if (view != null) {
view.eglContextFactory.destroyContext(egl, eglDisplay, eglContext);
}
eglContext = null;
}
if (eglDisplay != null) {
egl.eglTerminate(eglDisplay);
eglDisplay = null;
}
}
private void throwEglException(String function) {
throwEglException(function, egl.eglGetError());
}
public static void throwEglException(String function, int error) {
String message = formatEglError(function, error);
if (LOG_THREADS) {
Log.e("EglHelper",
"throwEglException tid=" + Thread.currentThread().getId() + " " + message);
}
throw new RuntimeException(message);
}
public static void logEglErrorAsWarning(String tag, String function, int error) {
Log.w(tag, formatEglError(function, error));
}
public static String formatEglError(String function, int error) {
return function + " failed: " + error;
}
private WeakReference<GLTextureView> glTextureViewWeakRef;
EGL10 egl;
EGLDisplay eglDisplay;
EGLSurface eglSurface;
EGLConfig eglConfig;
EGLContext eglContext;
}
/**
* A generic GL Thread. Takes care of initializing EGL and GL. Delegates
* to a Renderer instance to do the actual drawing. Can be configured to
* render continuously or on request.
* <p>
* All potentially blocking synchronization is done through the
* glThreadManager object. This avoids multiple-lock ordering issues.
*/
static class GLThread extends Thread {
GLThread(WeakReference<GLTextureView> glTextureViewWeakRef) {
super();
width = 0;
height = 0;
requestRender = true;
renderMode = RENDERMODE_CONTINUOUSLY;
this.glTextureViewWeakRef = glTextureViewWeakRef;
}
@Override
public void run() {
setName("GLThread " + getId());
if (LOG_THREADS) {
Log.i("GLThread", "starting tid=" + getId());
}
try {
guardedRun();
} catch (InterruptedException e) {
// fall thru and exit normally
} finally {
glThreadManager.threadExiting(this);
}
}
/*
* This private method should only be called inside a
* synchronized(glThreadManager) block.
*/
private void stopEglSurfaceLocked() {
if (haveEglSurface) {
haveEglSurface = false;
eglHelper.destroySurface();
}
}
/*
* This private method should only be called inside a
* synchronized(glThreadManager) block.
*/
private void stopEglContextLocked() {
if (haveEglContext) {
eglHelper.finish();
haveEglContext = false;
glThreadManager.releaseEglContextLocked(this);
}
}
private void guardedRun() throws InterruptedException {
eglHelper = new EglHelper(glTextureViewWeakRef);
haveEglContext = false;
haveEglSurface = false;
try {
GL10 gl = null;
boolean createEglContext = false;
boolean createEglSurface = false;
boolean createGlInterface = false;
boolean lostEglContext = false;
boolean sizeChanged = false;
boolean wantRenderNotification = false;
boolean doRenderNotification = false;
boolean askedToReleaseEglContext = false;
int w = 0;
int h = 0;
Runnable event = null;
while (true) {
synchronized (glThreadManager) {
while (true) {
if (shouldExit) {
return;
}
if (!eventQueue.isEmpty()) {
event = eventQueue.remove(0);
break;
}
// Update the pause state.
boolean pausing = false;
if (paused != requestPaused) {
pausing = requestPaused;
paused = requestPaused;
glThreadManager.notifyAll();
if (LOG_PAUSE_RESUME) {
Log.i("GLThread", "paused is now " + paused + " tid=" + getId());
}
}
// Do we need to give up the EGL context?
if (shouldReleaseEglContext) {
if (LOG_SURFACE) {
Log.i("GLThread", "releasing EGL context because asked to tid=" + getId());
}
stopEglSurfaceLocked();
stopEglContextLocked();
shouldReleaseEglContext = false;
askedToReleaseEglContext = true;
}
// Have we lost the EGL context?
if (lostEglContext) {
stopEglSurfaceLocked();
stopEglContextLocked();
lostEglContext = false;
}
// When pausing, release the EGL surface:
if (pausing && haveEglSurface) {
if (LOG_SURFACE) {
Log.i("GLThread", "releasing EGL surface because paused tid=" + getId());
}
stopEglSurfaceLocked();
}
// When pausing, optionally release the EGL Context:
if (pausing && haveEglContext) {
GLTextureView view = glTextureViewWeakRef.get();
boolean preserveEglContextOnPause =
view == null ? false : view.preserveEGLContextOnPause;
if (!preserveEglContextOnPause
|| glThreadManager.shouldReleaseEGLContextWhenPausing()) {
stopEglContextLocked();
if (LOG_SURFACE) {
Log.i("GLThread", "releasing EGL context because paused tid=" + getId());
}
}
}
// When pausing, optionally terminate EGL:
if (pausing) {
if (glThreadManager.shouldTerminateEGLWhenPausing()) {
eglHelper.finish();
if (LOG_SURFACE) {
Log.i("GLThread", "terminating EGL because paused tid=" + getId());
}
}
}
// Have we lost the TextureView surface?
if ((!hasSurface) && (!waitingForSurface)) {
if (LOG_SURFACE) {
Log.i("GLThread", "noticed textureView surface lost tid=" + getId());
}
if (haveEglSurface) {
stopEglSurfaceLocked();
}
waitingForSurface = true;
surfaceIsBad = false;
glThreadManager.notifyAll();
}
// Have we acquired the surface view surface?
if (hasSurface && waitingForSurface) {
if (LOG_SURFACE) {
Log.i("GLThread", "noticed textureView surface acquired tid=" + getId());
}
waitingForSurface = false;
glThreadManager.notifyAll();
}
if (doRenderNotification) {
if (LOG_SURFACE) {
Log.i("GLThread", "sending render notification tid=" + getId());
}
wantRenderNotification = false;
doRenderNotification = false;
renderComplete = true;
glThreadManager.notifyAll();
}
// Ready to draw?
if (readyToDraw()) {
// If we don't have an EGL context, try to acquire one.
if (!haveEglContext) {
if (askedToReleaseEglContext) {
askedToReleaseEglContext = false;
} else if (glThreadManager.tryAcquireEglContextLocked(this)) {
try {
eglHelper.start();
} catch (RuntimeException t) {
glThreadManager.releaseEglContextLocked(this);
throw t;
}
haveEglContext = true;
createEglContext = true;
glThreadManager.notifyAll();
}
}
if (haveEglContext && !haveEglSurface) {
haveEglSurface = true;
createEglSurface = true;
createGlInterface = true;
sizeChanged = true;
}
if (haveEglSurface) {
if (this.sizeChanged) {
sizeChanged = true;
w = width;
h = height;
wantRenderNotification = true;
if (LOG_SURFACE) {
Log.i("GLThread", "noticing that we want render notification tid=" + getId());
}
// Destroy and recreate the EGL surface.
createEglSurface = true;
this.sizeChanged = false;
}
requestRender = false;
glThreadManager.notifyAll();
break;
}
}
// By design, this is the only place in a GLThread thread where we wait().
if (LOG_THREADS) {
Log.i("GLThread", "waiting tid=" + getId() + " haveEglContext: " + haveEglContext
+ " haveEglSurface: " + haveEglSurface + " paused: " + paused + " hasSurface: "
+ hasSurface + " surfaceIsBad: " + surfaceIsBad + " waitingForSurface: "
+ waitingForSurface + " width: " + width + " height: " + height
+ " requestRender: " + requestRender + " renderMode: " + renderMode);
}
glThreadManager.wait();
}
} // end of synchronized(glThreadManager)
if (event != null) {
event.run();
event = null;
continue;
}
if (createEglSurface) {
if (LOG_SURFACE) {
Log.w("GLThread", "egl createSurface");
}
if (!eglHelper.createSurface()) {
synchronized (glThreadManager) {
surfaceIsBad = true;
glThreadManager.notifyAll();
}
continue;
}
createEglSurface = false;
}
if (createGlInterface) {
gl = (GL10) eglHelper.createGL();
glThreadManager.checkGLDriver(gl);
createGlInterface = false;
}
if (createEglContext) {
if (LOG_RENDERER) {
Log.w("GLThread", "onSurfaceCreated");
}
GLTextureView view = glTextureViewWeakRef.get();
if (view != null) {
view.renderer.onSurfaceCreated(gl, eglHelper.eglConfig);
}
createEglContext = false;
}
if (sizeChanged) {
if (LOG_RENDERER) {
Log.w("GLThread", "onSurfaceChanged(" + w + ", " + h + ")");
}
GLTextureView view = glTextureViewWeakRef.get();
if (view != null) {
view.renderer.onSurfaceChanged(gl, w, h);
}
sizeChanged = false;
}
if (LOG_RENDERER_DRAW_FRAME) {
Log.w("GLThread", "onDrawFrame tid=" + getId());
}
{
GLTextureView view = glTextureViewWeakRef.get();
if (view != null) {
view.renderer.onDrawFrame(gl);
}
}
int swapError = eglHelper.swap();
switch (swapError) {
case EGL10.EGL_SUCCESS:
break;
case EGL11.EGL_CONTEXT_LOST:
if (LOG_SURFACE) {
Log.i("GLThread", "egl context lost tid=" + getId());
}
lostEglContext = true;
break;
default:
// Other errors typically mean that the current surface is bad,
// probably because the TextureView surface has been destroyed,
// but we haven't been notified yet.
// Log the error to help developers understand why rendering stopped.
EglHelper.logEglErrorAsWarning("GLThread", "eglSwapBuffers", swapError);
synchronized (glThreadManager) {
surfaceIsBad = true;
glThreadManager.notifyAll();
}
break;
}
if (wantRenderNotification) {
doRenderNotification = true;
}
}
} finally {
/*
* clean-up everything...
*/
synchronized (glThreadManager) {
stopEglSurfaceLocked();
stopEglContextLocked();
}
}
}
public boolean ableToDraw() {
return haveEglContext && haveEglSurface && readyToDraw();
}
private boolean readyToDraw() {
return (!paused) && hasSurface && (!surfaceIsBad) && (width > 0) && (height > 0) && (
requestRender || (renderMode == RENDERMODE_CONTINUOUSLY));
}
public void setRenderMode(int renderMode) {
if (!((RENDERMODE_WHEN_DIRTY <= renderMode) && (renderMode <= RENDERMODE_CONTINUOUSLY))) {
throw new IllegalArgumentException("renderMode");
}
synchronized (glThreadManager) {
this.renderMode = renderMode;
glThreadManager.notifyAll();
}
}
public int getRenderMode() {
synchronized (glThreadManager) {
return renderMode;
}
}
public void requestRender() {
synchronized (glThreadManager) {
requestRender = true;
glThreadManager.notifyAll();
}
}
public void surfaceCreated() {
synchronized (glThreadManager) {
if (LOG_THREADS) {
Log.i("GLThread", "surfaceCreated tid=" + getId());
}
hasSurface = true;
glThreadManager.notifyAll();
while ((waitingForSurface) && (!exited)) {
try {
glThreadManager.wait();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}
}
public void surfaceDestroyed() {
synchronized (glThreadManager) {
if (LOG_THREADS) {
Log.i("GLThread", "surfaceDestroyed tid=" + getId());
}
hasSurface = false;
glThreadManager.notifyAll();
while ((!waitingForSurface) && (!exited)) {
try {
glThreadManager.wait();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}
}
public void onPause() {
synchronized (glThreadManager) {
if (LOG_PAUSE_RESUME) {
Log.i("GLThread", "onPause tid=" + getId());
}
requestPaused = true;
glThreadManager.notifyAll();
while ((!exited) && (!paused)) {
if (LOG_PAUSE_RESUME) {
Log.i("Main thread", "onPause waiting for paused.");
}
try {
glThreadManager.wait();
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
}
}
}
public void onResume() {
synchronized (glThreadManager) {
if (LOG_PAUSE_RESUME) {
Log.i("GLThread", "onResume tid=" + getId());
}
requestPaused = false;
requestRender = true;
renderComplete = false;
glThreadManager.notifyAll();
while ((!exited) && paused && (!renderComplete)) {
if (LOG_PAUSE_RESUME) {
Log.i("Main thread", "onResume waiting for !paused.");
}
try {
glThreadManager.wait();
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
}
}
}
public void onWindowResize(int w, int h) {
synchronized (glThreadManager) {
width = w;
height = h;
sizeChanged = true;
requestRender = true;
renderComplete = false;
glThreadManager.notifyAll();
// Wait for thread to react to resize and render a frame
while (!exited && !paused && !renderComplete && ableToDraw()) {
if (LOG_SURFACE) {
Log.i("Main thread", "onWindowResize waiting for render complete from tid=" + getId());
}
try {
glThreadManager.wait();
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
}
}
}
public void requestExitAndWait() {
// don't call this from GLThread thread or it is a guaranteed
// deadlock!
synchronized (glThreadManager) {
shouldExit = true;
glThreadManager.notifyAll();
while (!exited) {
try {
glThreadManager.wait();
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
}
}
}
public void requestReleaseEglContextLocked() {
shouldReleaseEglContext = true;
glThreadManager.notifyAll();
}
/**
* Queue an "event" to be run on the GL rendering thread.
*
* @param r the runnable to be run on the GL rendering thread.
*/
public void queueEvent(Runnable r) {
if (r == null) {
throw new IllegalArgumentException("r must not be null");
}
synchronized (glThreadManager) {
eventQueue.add(r);
glThreadManager.notifyAll();
}
}
// Once the thread is started, all accesses to the following member
// variables are protected by the glThreadManager monitor
private boolean shouldExit;
private boolean exited;
private boolean requestPaused;
private boolean paused;
private boolean hasSurface;
private boolean surfaceIsBad;
private boolean waitingForSurface;
private boolean haveEglContext;
private boolean haveEglSurface;
private boolean shouldReleaseEglContext;
private int width;
private int height;
private int renderMode;
private boolean requestRender;
private boolean renderComplete;
private ArrayList<Runnable> eventQueue = new ArrayList<>();
private boolean sizeChanged = true;
// End of member variables protected by the glThreadManager monitor.
private EglHelper eglHelper;
/**
* Set once at thread construction time, nulled out when the parent view is garbage
* called. This weak reference allows the GLTextureView to be garbage collected while
* the GLThread is still alive.
*/
private WeakReference<GLTextureView> glTextureViewWeakRef;
}
static class LogWriter extends Writer {
@Override
public void close() {
flushBuilder();
}
@Override
public void flush() {
flushBuilder();
}
@Override
public void write(char[] buf, int offset, int count) {
for (int i = 0; i < count; i++) {
char c = buf[offset + i];
if (c == '\n') {
flushBuilder();
} else {
builder.append(c);
}
}
}
private void flushBuilder() {
if (builder.length() > 0) {
Log.v("GLTextureView", builder.toString());
builder.delete(0, builder.length());
}
}
private StringBuilder builder = new StringBuilder();
}
private void checkRenderThreadState() {
if (glThread != null) {
throw new IllegalStateException("setRenderer has already been called for this instance.");
}
}
private static class GLThreadManager {
private static String TAG = "GLThreadManager";
public synchronized void threadExiting(GLThread thread) {
if (LOG_THREADS) {
Log.i("GLThread", "exiting tid=" + thread.getId());
}
thread.exited = true;
if (eglOwner == thread) {
eglOwner = null;
}
notifyAll();
}
/*
* Tries once to acquire the right to use an EGL
* context. Does not block. Requires that we are already
* in the glThreadManager monitor when this is called.
*
* @return true if the right to use an EGL context was acquired.
*/
public boolean tryAcquireEglContextLocked(GLThread thread) {
if (eglOwner == thread || eglOwner == null) {
eglOwner = thread;
notifyAll();
return true;
}
checkGLESVersion();
if (multipleGLESContextsAllowed) {
return true;
}
// Notify the owning thread that it should release the context.
// TODO: implement a fairness policy. Currently
// if the owning thread is drawing continuously it will just
// reacquire the EGL context.
if (eglOwner != null) {
eglOwner.requestReleaseEglContextLocked();
}
return false;
}
/*
* Releases the EGL context. Requires that we are already in the
* glThreadManager monitor when this is called.
*/
public void releaseEglContextLocked(GLThread thread) {
if (eglOwner == thread) {
eglOwner = null;
}
notifyAll();
}
public synchronized boolean shouldReleaseEGLContextWhenPausing() {
// Release the EGL context when pausing even if
// the hardware supports multiple EGL contexts.
// Otherwise the device could run out of EGL contexts.
return limitedGLESContexts;
}
public synchronized boolean shouldTerminateEGLWhenPausing() {
checkGLESVersion();
return !multipleGLESContextsAllowed;
}
public synchronized void checkGLDriver(GL10 gl) {
if (!glesDriverCheckComplete) {
checkGLESVersion();
String renderer = gl.glGetString(GL10.GL_RENDERER);
if (glesVersion < kGLES_20) {
multipleGLESContextsAllowed = !renderer.startsWith(kMSM7K_RENDERER_PREFIX);
notifyAll();
}
limitedGLESContexts = !multipleGLESContextsAllowed;
if (LOG_SURFACE) {
Log.w(TAG, "checkGLDriver renderer = \"" + renderer + "\" multipleContextsAllowed = "
+ multipleGLESContextsAllowed + " limitedGLESContexts = " + limitedGLESContexts);
}
glesDriverCheckComplete = true;
}
}
private void checkGLESVersion() {
if (!glesVersionCheckComplete) {
glesVersionCheckComplete = true;
}
}
/**
* This check was required for some pre-Android-3.0 hardware. Android 3.0 provides
* support for hardware-accelerated views, therefore multiple EGL contexts are
* supported on all Android 3.0+ EGL drivers.
*/
private boolean glesVersionCheckComplete;
private int glesVersion;
private boolean glesDriverCheckComplete;
private boolean multipleGLESContextsAllowed;
private boolean limitedGLESContexts;
private static final int kGLES_20 = 0x20000;
private static final String kMSM7K_RENDERER_PREFIX = "Q3Dimension MSM7500 ";
private GLThread eglOwner;
}
private static final GLThreadManager glThreadManager = new GLThreadManager();
private final WeakReference<GLTextureView> mThisWeakRef = new WeakReference<>(this);
private GLThread glThread;
private Renderer renderer;
private boolean detached;
private EGLConfigChooser eglConfigChooser;
private EGLContextFactory eglContextFactory;
private EGLWindowSurfaceFactory eglWindowSurfaceFactory;
private GLWrapper glWrapper;
private int debugFlags;
private int eglContextClientVersion;
private boolean preserveEGLContextOnPause;
private List<SurfaceTextureListener> surfaceTextureListeners = new ArrayList<>();
}
================================================
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/GPUImage.java
================================================
/*
* Copyright (C) 2018 CyberAgent, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jp.co.cyberagent.android.gpuimage;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ConfigurationInfo;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.PixelFormat;
import android.hardware.Camera;
import android.media.ExifInterface;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.opengl.GLSurfaceView;
import android.os.AsyncTask;
import android.os.Environment;
import android.os.Handler;
import android.provider.MediaStore;
import android.view.Display;
import android.view.WindowManager;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.List;
import jp.co.cyberagent.android.gpuimage.filter.GPUImageFilter;
import jp.co.cyberagent.android.gpuimage.util.Rotation;
/**
* The main accessor for GPUImage functionality. This class helps to do common
* tasks through a simple interface.
*/
public class GPUImage {
public enum ScaleType {CENTER_INSIDE, CENTER_CROP}
static final int SURFACE_TYPE_SURFACE_VIEW = 0;
static final int SURFACE_TYPE_TEXTURE_VIEW = 1;
private final Context context;
private final GPUImageRenderer renderer;
private int surfaceType = SURFACE_TYPE_SURFACE_VIEW;
private GLSurfaceView glSurfaceView;
private GLTextureView glTextureView;
private GPUImageFilter filter;
private Bitmap currentBitmap;
private ScaleType scaleType = ScaleType.CENTER_CROP;
private int scaleWidth, scaleHeight;
/**
* Instantiates a new GPUImage object.
*
* @param context the context
*/
public GPUImage(final Context context) {
if (!supportsOpenGLES2(context)) {
throw new IllegalStateException("OpenGL ES 2.0 is not supported on this phone.");
}
this.context = context;
filter = new GPUImageFilter();
renderer = new GPUImageRenderer(filter);
}
/**
* Checks if OpenGL ES 2.0 is supported on the current device.
*
* @param context the context
* @return true, if successful
*/
private boolean supportsOpenGLES2(final Context context) {
final ActivityManager activityManager = (ActivityManager)
context.getSystemService(Context.ACTIVITY_SERVICE);
final ConfigurationInfo configurationInfo =
activityManager.getDeviceConfigurationInfo();
return configurationInfo.reqGlEsVersion >= 0x20000;
}
/**
* Sets the GLSurfaceView which will display the preview.
*
* @param view the GLSurfaceView
*/
public void setGLSurfaceView(final GLSurfaceView view) {
surfaceType = SURFACE_TYPE_SURFACE_VIEW;
glSurfaceView = view;
glSurfaceView.setEGLContextClientVersion(2);
glSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
glSurfaceView.getHolder().setFormat(PixelFormat.RGBA_8888);
glSurfaceView.setRenderer(renderer);
glSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
glSurfaceView.requestRender();
}
/**
* Sets the GLTextureView which will display the preview.
*
* @param view the GLTextureView
*/
public void setGLTextureView(final GLTextureView view) {
surfaceType = SURFACE_TYPE_TEXTURE_VIEW;
glTextureView = view;
glTextureView.setEGLContextClientVersion(2);
glTextureView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
glTextureView.setOpaque(false);
glTextureView.setRenderer(renderer);
glTextureView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
glTextureView.requestRender();
}
/**
* Sets the background color
*
* @param red red color value
* @param green green color value
* @param blue red color value
*/
public void setBackgroundColor(float red, float green, float blue) {
renderer.setBackgroundColor(red, green, blue);
}
/**
* Request the preview to be rendered again.
*/
public void requestRender() {
if (surfaceType == SURFACE_TYPE_SURFACE_VIEW) {
if (glSurfaceView != null) {
glSurfaceView.requestRender();
}
} else if (surfaceType == SURFACE_TYPE_TEXTURE_VIEW) {
if (glTextureView != null) {
glTextureView.requestRender();
}
}
}
/**
* Deprecated: Please call
* {@link GPUImage#updatePreviewFrame(byte[], int, int)} frame by frame
* <p>
* Sets the up camera to be connected to GPUImage to get a filtered preview.
*
* @param camera the camera
*/
@Deprecated
public void setUpCamera(final Camera camera) {
setUpCamera(camera, 0, false, false);
}
/**
* Deprecated: Please call
* {@link GPUImage#updatePreviewFrame(byte[], int, int)} frame by frame
* <p>
* Sets the up camera to be connected to GPUImage to get a filtered preview.
*
* @param camera the camera
* @param degrees by how many degrees the image should be rotated
* @param flipHorizontal if the image should be flipped horizontally
* @param flipVertical if the image should be flipped vertically
*/
@Deprecated
public void setUpCamera(final Camera camera, final int degrees, final boolean flipHorizontal,
final boolean flipVertical) {
if (surfaceType == SURFACE_TYPE_SURFACE_VIEW) {
glSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
} else if (surfaceType == SURFACE_TYPE_TEXTURE_VIEW) {
glTextureView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
}
renderer.setUpSurfaceTexture(camera);
Rotation rotation = Rotation.NORMAL;
switch (degrees) {
case 90:
rotation = Rotation.ROTATION_90;
break;
case 180:
rotation = Rotation.ROTATION_180;
break;
case 270:
rotation = Rotation.ROTATION_270;
break;
}
renderer.setRotationCamera(rotation, flipHorizontal, flipVertical);
}
/**
* Sets the filter which should be applied to the image which was (or will
* be) set by setImage(...).
*
* @param filter the new filter
*/
public void setFilter(final GPUImageFilter filter) {
this.filter = filter;
renderer.setFilter(this.filter);
requestRender();
}
/**
* Sets the image on which the filter should be applied.
*
* @param bitmap the new image
*/
public void setImage(final Bitmap bitmap) {
currentBitmap = bitmap;
renderer.setImageBitmap(bitmap, false);
requestRender();
}
/**
* Update camera preview frame with YUV format data.
*
* @param data Camera preview YUV data for frame.
* @param width width of camera preview
* @param height height of camera preview
*/
public void updatePreviewFrame(final byte[] data, final int width, final int height) {
renderer.onPreviewFrame(data, width, height);
}
/**
* This sets the scale type of GPUImage. This has to be run before setting the image.
* If image is set and scale type changed, image needs to be reset.
*
* @param scaleType The new ScaleType
*/
public void setScaleType(ScaleType scaleType) {
this.scaleType = scaleType;
renderer.setScaleType(scaleType);
renderer.deleteImage();
currentBitmap = null;
requestRender();
}
/**
* This gets the size of the image. This makes it easier to adjust
* the size of your imagePreview to the the size of the scaled image.
*
* @return array with width and height of bitmap image
*/
public int[] getScaleSize() {
return new int[] {scaleWidth, scaleHeight};
}
/**
* Sets the rotation of the displayed image.
*
* @param rotation new rotation
*/
public void setRotation(Rotation rotation) {
renderer.setRotation(rotation);
}
/**
* Sets the rotation of the displayed image with flip options.
*
* @param rotation new rotation
*/
public void setRotation(Rotation rotation, boolean flipHorizontal, boolean flipVertical) {
renderer.setRotation(rotation, flipHorizontal, flipVertical);
}
/**
* Deletes the current image.
*/
public void deleteImage() {
renderer.deleteImage();
currentBitmap = null;
requestRender();
}
/**
* Sets the image on which the filter should be applied from a Uri.
*
* @param uri the uri of the new image
*/
public void setImage(final Uri uri) {
new LoadImageUriTask(this, uri).execute();
}
/**
* Sets the image on which the filter should be applied from a File.
*
* @param file the file of the new image
*/
public void setImage(final File file) {
new LoadImageFileTask(this, file).execute();
}
private String getPath(final Uri uri) {
String[] projection = {
MediaStore.Images.Media.DATA,
};
Cursor cursor = context.getContentResolver()
.query(uri, projection, null, null, null);
String path = null;
if (cursor == null) {
return null;
}
if (cursor.moveToFirst()) {
int pathIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
path = cursor.getString(pathIndex);
}
cursor.close();
return path;
}
/**
* Gets the current displayed image with applied filter as a Bitmap.
*
* @return the current image with filter applied
*/
public Bitmap getBitmapWithFilterApplied() {
return getBitmapWithFilterApplied(currentBitmap);
}
/**
* Gets the given bitmap with current filter applied as a Bitmap.
*
* @param bitmap the bitmap on which the current filter should be applied
* @return the bitmap with filter applied
*/
public Bitmap getBitmapWithFilterApplied(final Bitmap bitmap) {
return getBitmapWithFilterApplied(bitmap, false);
}
/**
* Gets the given bitmap with current filter applied as a Bitmap.
*
* @param bitmap the bitmap on which the current filter should be applied
* @param recycle recycle the bitmap or not.
* @return the bitmap with filter applied
*/
public Bitmap getBitmapWithFilterApplied(final Bitmap bitmap, boolean recycle) {
if (glSurfaceView != null || glTextureView != null) {
renderer.deleteImage();
renderer.runOnDraw(new Runnable() {
@Override
public void run() {
synchronized (filter) {
filter.destroy();
filter.notify();
}
}
});
synchronized (filter) {
requestRender();
try {
filter.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
GPUImageRenderer renderer = new GPUImageRenderer(filter);
renderer.setRotation(Rotation.NORMAL,
this.renderer.isFlippedHorizontally(), this.renderer.isFlippedVertically());
renderer.setScaleType(scaleType);
PixelBuffer buffer = new PixelBuffer(bitmap.getWidth(), bitmap.getHeight());
buffer.setRenderer(renderer);
renderer.setImageBitmap(bitmap, recycle);
Bitmap result = buffer.getBitmap();
filter.destroy();
renderer.deleteImage();
buffer.destroy();
this.renderer.setFilter(filter);
if (currentBitmap != null) {
this.renderer.setImageBitmap(currentBitmap, false);
}
requestRender();
return result;
}
/**
* Gets the images for multiple filters on a image. This can be used to
* quickly get thumbnail images for filters. <br>
* Whenever a new Bitmap is ready, the listener will be called with the
* bitmap. The order of the calls to the listener will be the same as the
* filter order.
*
* @param bitmap the bitmap on which the filters will be applied
* @param filters the filters which will be applied on the bitmap
* @param listener the listener on which the results will be notified
*/
public static void getBitmapForMultipleFilters(final Bitmap bitmap,
final List<GPUImageFilter> filters, final ResponseListener<Bitmap> listener) {
if (filters.isEmpty()) {
return;
}
GPUImageRenderer renderer = new GPUImageRenderer(filters.get(0));
renderer.setImageBitmap(bitmap, false);
PixelBuffer buffer = new PixelBuffer(bitmap.getWidth(), bitmap.getHeight());
buffer.setRenderer(renderer);
for (GPUImageFilter filter : filters) {
renderer.setFilter(filter);
listener.response(buffer.getBitmap());
filter.destroy();
}
renderer.deleteImage();
buffer.destroy();
}
/**
* Save current image with applied filter to Pictures. It will be stored on
* the default Picture folder on the phone below the given folderName and
* fileName. <br>
* This method is async and will notify when the image was saved through the
* listener.
*
* @param folderName the folder name
* @param fileName the file name
* @param listener the listener
*/
public void saveToPictures(final String folderName, final String fileName,
final OnPictureSavedListener listener) {
saveToPictures(currentBitmap, folderName, fileName, listener);
}
/**
* Apply and save the given bitmap with applied filter to Pictures. It will
* be stored on the default Picture folder on the phone below the given
* folerName and fileName. <br>
* This method is async and will notify when the image was saved through the
* listener.
*
* @param bitmap the bitmap
* @param folderName the folder name
* @param fileName the file name
* @param listener the listener
*/
public void saveToPictures(final Bitmap bitmap, final String folderName, final String fileName,
final OnPictureSavedListener listener) {
new SaveTask(bitmap, folderName, fileName, listener).execute();
}
/**
* Runs the given Runnable on the OpenGL thread.
*
* @param runnable The runnable to be run on the OpenGL thread.
*/
void runOnGLThread(Runnable runnable) {
renderer.runOnDrawEnd(runnable);
}
private int getOutputWidth() {
if (renderer != null && renderer.getFrameWidth() != 0) {
return renderer.getFrameWidth();
} else if (currentBitmap != null) {
return currentBitmap.getWidth();
} else {
WindowManager windowManager =
(WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = windowManager.getDefaultDisplay();
return display.getWidth();
}
}
private int getOutputHeight() {
if (renderer != null && renderer.getFrameHeight() != 0) {
return renderer.getFrameHeight();
} else if (currentBitmap != null) {
return currentBitmap.getHeight();
} else {
WindowManager windowManager =
(WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = windowManager.getDefaultDisplay();
return display.getHeight();
}
}
@Deprecated
private class SaveTask extends AsyncTask<Void, Void, Void> {
private final Bitmap bitmap;
private final String folderName;
private final String fileName;
private final OnPictureSavedListener listener;
private final Handler handler;
public SaveTask(final Bitmap bitmap, final String folderName, final String fileName,
final OnPictureSavedListener listener) {
this.bitmap = bitmap;
this.folderName = folderName;
this.fileName = fileName;
this.listener = listener;
handler = new Handler();
}
@Override
protected Void doInBackground(final Void... params) {
Bitmap result = getBitmapWithFilterApplied(bitmap);
saveImage(folderName, fileName, result);
return null;
}
private void saveImage(final String folderName, final String fileName, final Bitmap image) {
File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File file = new File(path, folderName + "/" + fileName);
try {
file.getParentFile().mkdirs();
image.compress(CompressFormat.JPEG, 80, new FileOutputStream(file));
MediaScannerConnection.scanFile(context,
new String[]{
file.toString()
}, null,
new MediaScannerConnection.OnScanCompletedListener() {
@Override
public void onScanCompleted(final String path, final Uri uri) {
if (listener != null) {
handler.post(new Runnable() {
@Override
public void run() {
listener.onPictureSaved(uri);
}
});
}
}
});
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
public interface OnPictureSavedListener {
void onPictureSaved(Uri uri);
}
private class LoadImageUriTask extends LoadImageTask {
private final Uri uri;
public LoadImageUriTask(GPUImage gpuImage, Uri uri) {
super(gpuImage);
this.uri = uri;
}
@Override
protected Bitmap decode(BitmapFactory.Options options) {
try {
InputStream inputStream;
if (uri.getScheme().startsWith("http") || uri.getScheme().startsWith("https")) {
inputStream = new URL(uri.toString()).openStream();
} else if (uri.getPath().startsWith("/android_asset/")) {
inputStream = context.getAssets().open(uri.getPath().substring(("/android_asset/").length()));
} else {
inputStream = context.getContentResolver().openInputStream(uri);
}
return BitmapFactory.decodeStream(inputStream, null, options);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
protected int getImageOrientation() throws IOException {
Cursor cursor = context.getContentResolver().query(uri,
new String[]{MediaStore.Images.ImageColumns.ORIENTATION}, null, null, null);
if (cursor == null || cursor.getCount() != 1) {
return 0;
}
cursor.moveToFirst();
int orientation = cursor.getInt(0);
cursor.close();
return orientation;
}
}
private class LoadImageFileTask extends LoadImageTask {
private final File imageFile;
public LoadImageFileTask(GPUImage gpuImage, File file) {
super(gpuImage);
imageFile = file;
}
@Override
protected Bitmap decode(BitmapFactory.Options options) {
return BitmapFactory.decodeFile(imageFile.getAbsolutePath(), options);
}
@Override
protected int getImageOrientation() throws IOException {
ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath());
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
switch (orientation) {
case ExifInterface.ORIENTATION_NORMAL:
return 0;
case ExifInterface.ORIENTATION_ROTATE_90:
return 90;
case ExifInterface.ORIENTATION_ROTATE_180:
return 180;
case ExifInterface.ORIENTATION_ROTATE_270:
return 270;
default:
return 0;
}
}
}
private abstract class LoadImageTask extends AsyncTask<Void, Void, Bitmap> {
private final GPUImage gpuImage;
private int outputWidth;
private int outputHeight;
public LoadImageTask(final GPUImage gpuImage) {
this.gpuImage = gpuImage;
}
@Override
protected Bitmap doInBackground(Void... params) {
if (renderer != null && renderer.getFrameWidth() == 0) {
try {
synchronized (renderer.surfaceChangedWaiter) {
renderer.surfaceChangedWaiter.wait(3000);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
outputWidth = getOutputWidth();
outputHeight = getOutputHeight();
return loadResizedImage();
}
@Override
protected void onPostExecute(Bitmap bitmap) {
super.onPostExecute(bitmap);
gpuImage.deleteImage();
gpuImage.setImage(bitmap);
}
protected abstract Bitmap decode(BitmapFactory.Options options);
private Bitmap loadResizedImage() {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
decode(options);
int scale = 1;
while (checkSize(options.outWidth / scale > outputWidth, options.outHeight / scale > outputHeight)) {
scale++;
}
scale--;
if (scale < 1) {
scale = 1;
}
options = new BitmapFactory.Options();
options.inSampleSize = scale;
options.inPreferredConfig = Bitmap.Config.RGB_565;
options.inPurgeable = true;
options.inTempStorage = new byte[32 * 1024];
Bitmap bitmap = decode(options);
if (bitmap == null) {
return null;
}
bitmap = rotateImage(bitmap);
bitmap = scaleBitmap(bitmap);
return bitmap;
}
private Bitmap scaleBitmap(Bitmap bitmap) {
// resize to desired dimensions
int width = bitmap.getWidth();
int height = bitmap.getHeight();
int[] newSize = getScaleSize(width, height);
Bitmap workBitmap = Bitmap.createScaledBitmap(bitmap, newSize[0], newSize[1], true);
if (workBitmap != bitmap) {
bitmap.recycle();
bitmap = workBitmap;
System.gc();
}
if (scaleType == ScaleType.CENTER_CROP) {
// Crop it
int diffWidth = newSize[0] - outputWidth;
int diffHeight = newSize[1] - outputHeight;
workBitmap = Bitmap.createBitmap(bitmap, diffWidth / 2, diffHeight / 2,
newSize[0] - diffWidth, newSize[1] - diffHeight);
if (workBitmap != bitmap) {
bitmap.recycle();
bitmap = workBitmap;
}
}
return bitmap;
}
/**
* Retrieve the scaling size for the image dependent on the ScaleType.<br>
* <br>
* If CROP: sides are same size or bigger than output's sides<br>
* Else : sides are same size or smaller than output's sides
*/
private int[] getScaleSize(int width, int height) {
float newWidth;
float newHeight;
float withRatio = (float) width / outputWidth;
float heightRatio = (float) height / outputHeight;
boolean adjustWidth = scaleType == ScaleType.CENTER_CROP
? withRatio > heightRatio : withRatio < heightRatio;
if (adjustWidth) {
newHeight = outputHeight;
newWidth = (newHeight / height) * width;
} else {
newWidth = outputWidth;
newHeight = (newWidth / width) * height;
}
scaleWidth = Math.round(newWidth);
scaleHeight = Math.round(newHeight);
return new int[]{Math.round(newWidth), Math.round(newHeight)};
}
private boolean checkSize(boolean widthBigger, boolean heightBigger) {
if (scaleType == ScaleType.CENTER_CROP) {
return widthBigger && heightBigger;
} else {
return widthBigger || heightBigger;
}
}
private Bitmap rotateImage(final Bitmap bitmap) {
if (bitmap == null) {
return null;
}
Bitmap rotatedBitmap = bitmap;
try {
int orientation = getImageOrientation();
if (orientation != 0) {
Matrix matrix = new Matrix();
matrix.postRotate(orientation);
rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),
bitmap.getHeight(), matrix, true);
bitmap.recycle();
}
} catch (IOException e) {
e.printStackTrace();
}
return rotatedBitmap;
}
protected abstract int getImageOrientation() throws IOException;
}
public interface ResponseListener<T> {
void response(T item);
}
public GPUImageRenderer getRenderer() {
return renderer;
}
}
================================================
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/GPUImageNativeLibrary.java
================================================
/*
* Copyright (C) 2018 CyberAgent, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jp.co.cyberagent.android.gpuimage;
import android.graphics.Bitmap;
public class GPUImageNativeLibrary {
static {
System.loadLibrary("yuv-decoder");
}
public static native void YUVtoRBGA(byte[] yuv, int width, int height, int[] out);
public static native void YUVtoARBG(byte[] yuv, int width, int height, int[] out);
public static native void adjustBitmap(Bitmap srcBitmap);
}
================================================
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/GPUImageRenderer.java
================================================
/*
* Copyright (C) 2018 CyberAgent, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jp.co.cyberagent.android.gpuimage;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.SurfaceTexture;
import android.hardware.Camera;
import android.hardware.Camera.PreviewCallback;
import android.hardware.Camera.Size;
import android.opengl.GLES20;
import android.opengl.GLSurfaceView;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.util.LinkedList;
import java.util.Queue;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import jp.co.cyberagent.android.gpuimage.filter.GPUImageFilter;
import jp.co.cyberagent.android.gpuimage.util.OpenGlUtils;
import jp.co.cyberagent.android.gpuimage.util.Rotation;
import jp.co.cyberagent.android.gpuimage.util.TextureRotationUtil;
import static jp.co.cyberagent.android.gpuimage.util.TextureRotationUtil.TEXTURE_NO_ROTATION;
public class GPUImageRenderer implements GLSurfaceView.Renderer, GLTextureView.Renderer, PreviewCallback {
private static final int NO_IMAGE = -1;
public static final float CUBE[] = {
-1.0f, -1.0f,
1.0f, -1.0f,
-1.0f, 1.0f,
1.0f, 1.0f,
};
private GPUImageFilter filter;
public final Object surfaceChangedWaiter = new Object();
private int glTextureId = NO_IMAGE;
private SurfaceTexture surfaceTexture = null;
private final FloatBuffer glCubeBuffer;
private final FloatBuffer glTextureBuffer;
private IntBuffer glRgbBuffer;
private int outputWidth;
private int outputHeight;
private int imageWidth;
private int imageHeight;
private int addedPadding;
private final Queue<Runnable> runOnDraw;
private final Queue<Runnable> runOnDrawEnd;
private Rotation rotation;
private boolean flipHorizontal;
private boolean flipVertical;
private GPUImage.ScaleType scaleType = GPUImage.ScaleType.CENTER_CROP;
private float backgroundRed = 0;
private float backgroundGreen = 0;
private float backgroundBlue = 0;
public GPUImageRenderer(final GPUImageFilter filter) {
this.filter = filter;
runOnDraw = new LinkedList<>();
runOnDrawEnd = new LinkedList<>();
glCubeBuffer = ByteBuffer.allocateDirect(CUBE.length * 4)
.order(ByteOrder.nativeOrder())
.asFloatBuffer();
glCubeBuffer.put(CUBE).position(0);
glTextureBuffer = ByteBuffer.allocateDirect(TEXTURE_NO_ROTATION.length * 4)
.order(ByteOrder.nativeOrder())
.asFloatBuffer();
setRotation(Rotation.NORMAL, false, false);
}
@Override
public void onSurfaceCreated(final GL10 unused, final EGLConfig config) {
GLES20.glClearColor(backgroundRed, backgroundGreen, backgroundBlue, 1);
GLES20.glDisable(GLES20.GL_DEPTH_TEST);
filter.ifNeedInit();
}
@Override
public void onSurfaceChanged(final GL10 gl, final int width, final int height) {
outputWidth = width;
outputHeight = height;
GLES20.glViewport(0, 0, width, height);
GLES20.glUseProgram(filter.getProgram());
filter.onOutputSizeChanged(width, height);
adjustImageScaling();
synchronized (surfaceChangedWaiter) {
surfaceChangedWaiter.notifyAll();
}
}
@Override
public void onDrawFrame(final GL10 gl) {
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
runAll(runOnDraw);
filter.onDraw(glTextureId, glCubeBuffer, glTextureBuffer);
runAll(runOnDrawEnd);
if (surfaceTexture != null) {
surfaceTexture.updateTexImage();
}
}
/**
* Sets the background color
*
* @param red red color value
* @param green green color value
* @param blue red color value
*/
public void setBackgroundColor(float red, float green, float blue) {
backgroundRed = red;
backgroundGreen = green;
backgroundBlue = blue;
}
private void runAll(Queue<Runnable> queue) {
synchronized (queue) {
while (!queue.isEmpty()) {
queue.poll().run();
}
}
}
@Override
public void onPreviewFrame(final byte[] data, final Camera camera) {
final Size previewSize = camera.getParameters().getPreviewSize();
onPreviewFrame(data, previewSize.width, previewSize.height);
}
public void onPreviewFrame(final byte[] data, final int width, final int height) {
if (glRgbBuffer == null) {
glRgbBuffer = IntBuffer.allocate(width * height);
}
if (runOnDraw.isEmpty()) {
runOnDraw(new Runnable() {
@Override
public void run() {
GPUImageNativeLibrary.YUVtoRBGA(data, width, height, glRgbBuffer.array());
glTextureId = OpenGlUtils.loadTexture(glRgbBuffer, width, height, glTextureId);
if (imageWidth != width) {
imageWidth = width;
imageHeight = height;
adjustImageScaling();
}
}
});
}
}
public void setUpSurfaceTexture(final Camera camera) {
runOnDraw(new Runnable() {
@Override
public void run() {
int[] textures = new int[1];
GLES20.glGenTextures(1, textures, 0);
surfaceTexture = new SurfaceTexture(textures[0]);
try {
camera.setPreviewTexture(surfaceTexture);
camera.setPreviewCallback(GPUImageRenderer.this);
camera.startPreview();
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
public void setFilter(final GPUImageFilter filter) {
runOnDraw(new Runnable() {
@Override
public void run() {
final GPUImageFilter oldFilter = GPUImageRenderer.this.filter;
GPUImageRenderer.this.filter = filter;
if (oldFilter != null) {
oldFilter.destroy();
}
GPUImageRenderer.this.filter.ifNeedInit();
GLES20.glUseProgram(GPUImageRenderer.this.filter.getProgram());
GPUImageRenderer.this.filter.onOutputSizeChanged(outputWidth, outputHeight);
}
});
}
public void deleteImage() {
runOnDraw(new Runnable() {
@Override
public void run() {
GLES20.glDeleteTextures(1, new int[]{
glTextureId
}, 0);
glTextureId = NO_IMAGE;
}
});
}
public void setImageBitmap(final Bitmap bitmap) {
setImageBitmap(bitmap, true);
}
public void setImageBitmap(final Bitmap bitmap, final boolean recycle) {
if (bitmap == null) {
return;
}
runOnDraw(new Runnable() {
@Override
public void run() {
Bitmap resizedBitmap = null;
if (bitmap.getWidth() % 2 == 1) {
resizedBitmap = Bitmap.createBitmap(bitmap.getWidth() + 1, bitmap.getHeight(),
Bitmap.Config.ARGB_8888);
resizedBitmap.setDensity(bitmap.getDensity());
Canvas can = new Canvas(resizedBitmap);
can.drawARGB(0x00, 0x00, 0x00, 0x00);
can.drawBitmap(bitmap, 0, 0, null);
addedPadding = 1;
} else {
addedPadding = 0;
}
glTextureId = OpenGlUtils.loadTexture(
resizedBitmap != null ? resizedBitmap : bitmap, glTextureId, recycle);
if (resizedBitmap != null) {
resizedBitmap.recycle();
}
imageWidth = bitmap.getWidth();
imageHeight = bitmap.getHeight();
adjustImageScaling();
}
});
}
public void setScaleType(GPUImage.ScaleType scaleType) {
this.scaleType = scaleType;
}
protected int getFrameWidth() {
return outputWidth;
}
protected int getFrameHeight() {
return outputHeight;
}
private void adjustImageScaling() {
float outputWidth = this.outputWidth;
float outputHeight = this.outputHeight;
if (rotation == Rotation.ROTATION_270 || rotation == Rotation.ROTATION_90) {
outputWidth = this.outputHeight;
outputHeight = this.outputWidth;
}
float ratio1 = outputWidth / imageWidth;
float ratio2 = outputHeight / imageHeight;
float ratioMax = Math.max(ratio1, ratio2);
int imageWidthNew = Math.round(imageWidth * ratioMax);
int imageHeightNew = Math.round(imageHeight * ratioMax);
float ratioWidth = imageWidthNew / outputWidth;
float ratioHeight = imageHeightNew / outputHeight;
float[] cube = CUBE;
float[] textureCords = TextureRotationUtil.getRotation(rotation, flipHorizontal, flipVertical);
if (scaleType == GPUImage.ScaleType.CENTER_CROP) {
float distHorizontal = (1 - 1 / ratioWidth) / 2;
float distVertical = (1 - 1 / ratioHeight) / 2;
textureCords = new float[]{
addDistance(textureCords[0], distHorizontal), addDistance(textureCords[1], distVertical),
addDistance(textureCords[2], distHorizontal), addDistance(textureCords[3], distVertical),
addDistance(textureCords[4], distHorizontal), addDistance(textureCords[5], distVertical),
addDistance(textureCords[6], distHorizontal), addDistance(textureCords[7], distVertical),
};
} else {
cube = new float[]{
CUBE[0] / ratioHeight, CUBE[1] / ratioWidth,
CUBE[2] / ratioHeight, CUBE[3] / ratioWidth,
CUBE[4] / ratioHeight, CUBE[5] / ratioWidth,
CUBE[6] / ratioHeight, CUBE[7] / ratioWidth,
};
}
glCubeBuffer.clear();
glCubeBuffer.put(cube).position(0);
glTextureBuffer.clear();
glTextureBuffer.put(textureCords).position(0);
}
private float addDistance(float coordinate, float distance) {
return coordinate == 0.0f ? distance : 1 - distance;
}
public void setRotationCamera(final Rotation rotation, final boolean flipHorizontal,
final boolean flipVertical) {
setRotation(rotation, flipVertical, flipHorizontal);
}
public void setRotation(final Rotation rotation) {
this.rotation = rotation;
adjustImageScaling();
}
public void setRotation(final Rotation rotation,
final boolean flipHorizontal, final boolean flipVertical) {
this.flipHorizontal = flipHorizontal;
this.flipVertical = flipVertical;
setRotation(rotation);
}
public Rotation getRotation() {
return rotation;
}
public boolean isFlippedHorizontally() {
return flipHorizontal;
}
public boolean isFlippedVertically() {
return flipVertical;
}
protected void runOnDraw(final Runnable runnable) {
synchronized (runOnDraw) {
runOnDraw.add(runnable);
}
}
protected void runOnDrawEnd(final Runnable runnable) {
synchronized (runOnDrawEnd) {
runOnDrawEnd.add(runnable);
}
}
}
================================================
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/GPUImageView.java
================================================
/*
* Copyright (C) 2018 CyberAgent, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jp.co.cyberagent.android.gpuimage;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.hardware.Camera;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.opengl.GLSurfaceView;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.concurrent.Semaphore;
import jp.co.cyberagent.android.gpuimage.filter.GPUImageFilter;
import jp.co.cyberagent.android.gpuimage.util.Rotation;
import static jp.co.cyberagent.android.gpuimage.GPUImage.SURFACE_TYPE_SURFACE_VIEW;
import static jp.co.cyberagent.android.gpuimage.GPUImage.SURFACE_TYPE_TEXTURE_VIEW;
public class GPUImageView extends FrameLayout {
private int surfaceType = SURFACE_TYPE_SURFACE_VIEW;
private View surfaceView;
private GPUImage gpuImage;
private boolean isShowLoading = true;
private GPUImageFilter filter;
public Size forceSize = null;
private float ratio = 0.0f;
public final static int RENDERMODE_WHEN_DIRTY = 0;
public final static int RENDERMODE_CONTINUOUSLY = 1;
public GPUImageView(Context context) {
super(context);
init(context, null);
}
public GPUImageView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs);
}
private void init(Context context, AttributeSet attrs) {
if (attrs != null) {
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.GPUImageView, 0, 0);
try {
surfaceType = a.getInt(R.styleable.GPUImageView_gpuimage_surface_type, surfaceType);
isShowLoading = a.getBoolean(R.styleable.GPUImageView_gpuimage_show_loading, isShowLoading);
} finally {
a.recycle();
}
}
gpuImage = new GPUImage(context);
if (surfaceType == SURFACE_TYPE_TEXTURE_VIEW) {
surfaceView = new GPUImageGLTextureView(context, attrs);
gpuImage.setGLTextureView((GLTextureView) surfaceView);
} else {
surfaceView = new GPUImageGLSurfaceView(context, attrs);
gpuImage.setGLSurfaceView((GLSurfaceView) surfaceView);
}
addView(surfaceView);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (ratio != 0.0f) {
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
int newHeight;
int newWidth;
if (width / ratio < height) {
newWidth = width;
newHeight = Math.round(width / ratio);
} else {
newHeight = height;
newWidth = Math.round(height * ratio);
}
int newWidthSpec = MeasureSpec.makeMeasureSpec(newWidth, MeasureSpec.EXACTLY);
int newHeightSpec = MeasureSpec.makeMeasureSpec(newHeight, MeasureSpec.EXACTLY);
super.onMeasure(newWidthSpec, newHeightSpec);
} else {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
/**
* Retrieve the GPUImage instance used by this view.
*
* @return used GPUImage instance
*/
public GPUImage getGPUImage() {
return gpuImage;
}
/**
* Deprecated: Please call
* {@link GPUImageView#updatePreviewFrame(byte[], int, int)} frame by frame
* <p>
* Sets the up camera to be connected to GPUImage to get a filtered preview.
*
* @param camera the camera
*/
@Deprecated
public void setUpCamera(final Camera camera) {
gpuImage.setUpCamera(camera);
}
/**
* Deprecated: Please call
* {@link GPUImageView#updatePreviewFrame(byte[], int, int)} frame by frame
* <p>
* Sets the up camera to be connected to GPUImage to get a filtered preview.
*
* @param camera the camera
* @param degrees by how many degrees the image should be rotated
* @param flipHorizontal if the image should be flipped horizontally
* @param flipVertical if the image should be flipped vertically
*/
@Deprecated
public void setUpCamera(final Camera camera, final int degrees, final boolean flipHorizontal,
final boolean flipVertical) {
gpuImage.setUpCamera(camera, degrees, flipHorizontal, flipVertical);
}
/**
* Update camera preview frame with YUV format data.
*
* @param data Camera preview YUV data for frame.
* @param width width of camera preview
* @param height height of camera preview
*/
public void updatePreviewFrame(byte[] data, int width, int height) {
gpuImage.updatePreviewFrame(data, width, height);
}
/**
* Sets the background color
*
* @param red red color value
* @param green green color value
* @param blue red color value
*/
public void setBackgroundColor(float red, float green, float blue) {
gpuImage.setBackgroundColor(red, green, blue);
}
/**
* Set the rendering mode. When renderMode is
* RENDERMODE_CONTINUOUSLY, the renderer is called
* repeatedly to re-render the scene. When renderMode
* is RENDERMODE_WHEN_DIRTY, the renderer only rendered when the surface
* is created, or when {@link #requestRender} is called. Defaults to RENDERMODE_CONTINUOUSLY.
*
* @param renderMode one of the RENDERMODE_X constants
* @see #RENDERMODE_CONTINUOUSLY
* @see #RENDERMODE_WHEN_DIRTY
* @see GLSurfaceView#setRenderMode(int)
* @see GLTextureView#setRenderMode(int)
*/
public void setRenderMode(int renderMode) {
if (surfaceView instanceof GLSurfaceView) {
((GLSurfaceView) surfaceView).setRenderMode(renderMode);
} else if (surfaceView instanceof GLTextureView) {
((GLTextureView) surfaceView).setRenderMode(renderMode);
}
}
// TODO Should be an xml attribute. But then GPUImage can not be distributed as .jar anymore.
public void setRatio(float ratio) {
this.ratio = ratio;
surfaceView.requestLayout();
gpuImage.deleteImage();
}
/**
* Set the scale type of GPUImage.
*
* @param scaleType the new ScaleType
*/
public void setScaleType(GPUImage.ScaleType scaleType) {
gpuImage.setScaleType(scaleType);
}
/**
* Sets the rotation of the displayed image.
*
* @param rotation new rotation
*/
public void setRotation(Rotation rotation) {
gpuImage.setRotation(rotation);
requestRender();
}
/**
* Set the filter to be applied on the image.
*
* @param filter Filter that should be applied on the image.
*/
public void setFilter(GPUImageFilter filter) {
this.filter = filter;
gpuImage.setFilter(filter);
requestRender();
}
/**
* Get the current applied filter.
*
* @return the current filter
*/
public GPUImageFilter getFilter() {
return filter;
}
/**
* Sets the image on which the filter should be applied.
*
* @param bitmap the new image
*/
public void setImage(final Bitmap bitmap) {
gpuImage.setImage(bitmap);
}
/**
* Sets the image on which the filter should be applied from a Uri.
*
* @param uri the uri of the new image
*/
public void setImage(final Uri uri) {
gpuImage.setImage(uri);
}
/**
* Sets the image on which the filter should be applied from a File.
*
* @param file the file of the new image
*/
public void setImage(final File file) {
gpuImage.setImage(file);
}
public void requestRender() {
if (surfaceView instanceof GLSurfaceView) {
((GLSurfaceView) surfaceView).requestRender();
} else if (surfaceView instanceof GLTextureView) {
((GLTextureView) surfaceView).requestRender();
}
}
/**
* Save current image with applied filter to Pictures. It will be stored on
* the default Picture folder on the phone below the given folderName and
* fileName. <br>
* This method is async and will notify when the image was saved through the
* listener.
*
* @param folderName the folder name
* @param fileName the file name
* @param listener the listener
*/
public void saveToPictures(final String folderName, final String fileName,
final OnPictureSavedListener listener) {
new SaveTask(folderName, fileName, listener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
/**
* Save current image with applied filter to Pictures. It will be stored on
* the default Picture folder on the phone below the given folderName and
* fileName. <br>
* This method is async and will notify when the image was saved through the
* listener.
*
* @param folderName the folder name
* @param fileName the file name
* @param width requested output width
* @param height requested output height
* @param listener the listener
*/
public void saveToPictures(final String folderName, final String fileName,
int width, int height,
final OnPictureSavedListener listener) {
new SaveTask(folderName, fileName, width, height, listener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
/**
* Retrieve current image with filter applied and given size as Bitmap.
*
* @param width requested Bitmap width
* @param height requested Bitmap height
* @return Bitmap of picture with given size
* @throws InterruptedException
*/
public Bitmap capture(final int width, final int height) throws InterruptedException {
// This method needs to run on a background thread because it will take a longer time
if (Looper.myLooper() == Looper.getMainLooper()) {
throw new IllegalStateException("Do not call this method from the UI thread!");
}
forceSize = new Size(width, height);
final Semaphore waiter = new Semaphore(0);
// Layout with new size
getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
getViewTreeObserver().removeGlobalOnLayoutListener(this);
} else {
getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
waiter.release();
}
});
post(new Runnable() {
@Override
public void run() {
// Optionally, show loading view:
if (isShowLoading) {
addView(new LoadingView(getContext()));
}
// Request layout to release waiter:
surfaceView.requestLayout();
}
});
waiter.acquire();
// Run one render pass
gpuImage.runOnGLThread(new Runnable() {
@Override
public void run() {
waiter.release();
}
});
requestRender();
waiter.acquire();
Bitmap bitmap = capture();
forceSize = null;
post(new Runnable() {
@Override
public void run() {
surfaceView.requestLayout();
}
});
requestRender();
if (isShowLoading) {
postDelayed(new Runnable() {
@Override
public void run() {
// Remove loading view
removeViewAt(1);
}
}, 300);
}
return bitmap;
}
/**
* Capture the current image with the size as it is displayed and retrieve it as Bitmap.
*
* @return current output as Bitmap
* @throws InterruptedException
*/
public Bitmap capture() throws InterruptedException {
final Semaphore waiter = new Semaphore(0);
final int width = surfaceView.getMeasuredWidth();
final int height = surfaceView.getMeasuredHeight();
// Take picture on OpenGL thread
final Bitmap resultBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
gpuImage.runOnGLThread(new Runnable() {
@Override
public void run() {
GPUImageNativeLibrary.adjustBitmap(resultBitmap);
waiter.release();
}
});
requestRender();
waiter.acquire();
return resultBitmap;
}
/**
* Pauses the Surface.
*/
public void onPause() {
if (surfaceView instanceof GLSurfaceView) {
((GLSurfaceView) surfaceView).onPause();
} else if (surfaceView instanceof GLTextureView) {
((GLTextureView) surfaceView).onPause();
}
}
/**
* Resumes the Surface.
*/
public void onResume() {
if (surfaceView instanceof GLSurfaceView) {
((GLSurfaceView) surfaceView).onResume();
} else if (surfaceView instanceof GLTextureView) {
((GLTextureView) surfaceView).onResume();
}
}
public static class Size {
int width;
int height;
public Size(int width, int height) {
this.width = width;
this.height = height;
}
}
private class GPUImageGLSurfaceView extends GLSurfaceView {
public GPUImageGLSurfaceView(Context context) {
super(context);
}
public GPUImageGLSurfaceView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (forceSize != null) {
super.onMeasure(MeasureSpec.makeMeasureSpec(forceSize.width, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(forceSize.height, MeasureSpec.EXACTLY));
} else {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
}
private class GPUImageGLTextureView extends GLTextureView {
public GPUImageGLTextureView(Context context) {
super(context);
}
public GPUImageGLTextureView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (forceSize != null) {
super.onMeasure(MeasureSpec.makeMeasureSpec(forceSize.width, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(forceSize.height, MeasureSpec.EXACTLY));
} else {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
}
private class LoadingView extends FrameLayout {
public LoadingView(Context context) {
super(context);
init();
}
public LoadingView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public LoadingView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
private void init() {
ProgressBar view = new ProgressBar(getContext());
view.setLayoutParams(
new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER));
addView(view);
setBackgroundColor(Color.BLACK);
}
}
private class SaveTask extends AsyncTask<Void, Void, Void> {
private final String folderName;
private final String fileName;
private final int width;
private final int height;
private final OnPictureSavedListener listener;
private final Handler handler;
public SaveTask(final String folderName, final String fileName,
final OnPictureSavedListener listener) {
this(folderName, fileName, 0, 0, listener);
}
public SaveTask(final String folderName, final String fileName, int width, int height,
final OnPictureSavedListener listener) {
this.folderName = folderName;
this.fileName = fileName;
this.width = width;
this.height = height;
this.listener = listener;
handler = new Handler();
}
@Override
protected Void doInBackground(final Void... params) {
try {
Bitmap result = width != 0 ? capture(width, height) : capture();
saveImage(folderName, fileName, result);
} catch (InterruptedException e) {
e.printStackTrace();
}
return null;
}
private void saveImage(final String folderName, final String fileName, final Bitmap image) {
File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File file = new File(path, folderName + "/" + fileName);
try {
file.getParentFile().mkdirs();
image.compress(Bitmap.CompressFormat.JPEG, 80, new FileOutputStream(file));
MediaScannerConnection.scanFile(getContext(),
new String[]{
file.toString()
}, null,
new MediaScannerConnection.OnScanCompletedListener() {
@Override
public void onScanCompleted(final String path, final Uri uri) {
if (listener != null) {
handler.post(new Runnable() {
@Override
public void run() {
listener.onPictureSaved(uri);
}
});
}
}
});
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
public interface OnPictureSavedListener {
void onPictureSaved(Uri uri);
}
}
================================================
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/PixelBuffer.java
================================================
/*
* Copyright (C) 2018 CyberAgent, Inc.
* Copyright (C) 2010 jsemler
*
* Original publication without License
* http://www.anddev.org/android-2d-3d-graphics-opengl-tutorials-f2/possible-to-do-opengl-off-screen-rendering-in-android-t13232.html#p41662
*/
package jp.co.cyberagent.android.gpuimage;
import android.graphics.Bitmap;
import android.opengl.GLSurfaceView;
import android.util.Log;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.egl.EGLSurface;
import javax.microedition.khronos.opengles.GL10;
import static javax.microedition.khronos.egl.EGL10.EGL_ALPHA_SIZE;
import static javax.microedition.khronos.egl.EGL10.EGL_BLUE_SIZE;
import static javax.microedition.khronos.egl.EGL10.EGL_DEFAULT_DISPLAY;
import static javax.microedition.khronos.egl.EGL10.EGL_DEPTH_SIZE;
import static javax.microedition.khronos.egl.EGL10.EGL_GREEN_SIZE;
import static javax.microedition.khronos.egl.EGL10.EGL_HEIGHT;
import static javax.microedition.khronos.egl.EGL10.EGL_NONE;
import static javax.microedition.khronos.egl.EGL10.EGL_NO_CONTEXT;
import static javax.microedition.khronos.egl.EGL10.EGL_RED_SIZE;
import static javax.microedition.khronos.egl.EGL10.EGL_STENCIL_SIZE;
import static javax.microedition.khronos.egl.EGL10.EGL_WIDTH;
public class PixelBuffer {
private final static String TAG = "PixelBuffer";
private final static boolean LIST_CONFIGS = false;
private GLSurfaceView.Renderer renderer; // borrow this interface
private int width, height;
private Bitmap bitmap;
private EGL10 egl10;
private EGLDisplay eglDisplay;
private EGLConfig[] eglConfigs;
private EGLConfig eglConfig;
private EGLContext eglContext;
private EGLSurface eglSurface;
private GL10 gl10;
private String mThreadOwner;
public PixelBuffer(final int width, final int height) {
this.width = width;
this.height = height;
int[] version = new int[2];
int[] attribList = new int[]{
EGL_WIDTH, this.width,
EGL_HEIGHT, this.height,
EGL_NONE
};
// No error checking performed, minimum required code to elucidate logic
egl10 = (EGL10) EGLContext.getEGL();
eglDisplay = egl10.eglGetDisplay(EGL_DEFAULT_DISPLAY);
egl10.eglInitialize(eglDisplay, version);
eglConfig = chooseConfig(); // Choosing a config is a little more
// complicated
// eglContext = egl10.eglCreateContext(eglDisplay, eglConfig,
// EGL_NO_CONTEXT, null);
int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
int[] attrib_list = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL10.EGL_NONE
};
eglContext = egl10.eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, attrib_list);
eglSurface = egl10.eglCreatePbufferSurface(eglDisplay, eglConfig, attribList);
egl10.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);
gl10 = (GL10) eglContext.getGL();
// Record thread owner of OpenGL context
mThreadOwner = Thread.currentThread().getName();
}
public void setRenderer(final GLSurfaceView.Renderer renderer) {
this.renderer = renderer;
// Does this thread own the OpenGL context?
if (!Thread.currentThread().getName().equals(mThreadOwner)) {
Log.e(TAG, "setRenderer: This thread does not own the OpenGL context.");
return;
}
// Call the renderer initialization routines
this.renderer.onSurfaceCreated(gl10, eglConfig);
this.renderer.onSurfaceChanged(gl10, width, height);
}
public Bitmap getBitmap() {
// Do we have a renderer?
if (renderer == null) {
Log.e(TAG, "getBitmap: Renderer was not set.");
return null;
}
// Does this thread own the OpenGL context?
if (!Thread.currentThread().getName().equals(mThreadOwner)) {
Log.e(TAG, "getBitmap: This thread does not own the OpenGL context.");
return null;
}
// Call the renderer draw routine (it seems that some filters do not
// work if this is only called once)
renderer.onDrawFrame(gl10);
renderer.onDrawFrame(gl10);
convertToBitmap();
return bitmap;
}
public void destroy() {
renderer.onDrawFrame(gl10);
renderer.onDrawFrame(gl10);
egl10.eglMakeCurrent(eglDisplay, EGL10.EGL_NO_SURFACE,
EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
egl10.eglDestroySurface(eglDisplay, eglSurface);
egl10.eglDestroyContext(eglDisplay, eglContext);
egl10.eglTerminate(eglDisplay);
}
private EGLConfig chooseConfig() {
int[] attribList = new int[]{
EGL_DEPTH_SIZE, 0,
EGL_STENCIL_SIZE, 0,
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL10.EGL_RENDERABLE_TYPE, 4,
EGL_NONE
};
// No error checking performed, minimum required code to elucidate logic
// Expand on this logic to be more selective in choosing a configuration
int[] numConfig = new int[1];
egl10.eglChooseConfig(eglDisplay, attribList, null, 0, numConfig);
int configSize = numConfig[0];
eglConfigs = new EGLConfig[configSize];
egl10.eglChooseConfig(eglDisplay, attribList, eglConfigs, configSize, numConfig);
if (LIST_CONFIGS) {
listConfig();
}
return eglConfigs[0]; // Best match is probably the first configuration
}
private void listConfig() {
Log.i(TAG, "Config List {");
for (EGLConfig config : eglConfigs) {
int d, s, r, g, b, a;
// Expand on this logic to dump other attributes
d = getConfigAttrib(config, EGL_DEPTH_SIZE);
s = getConfigAttrib(config, EGL_STENCIL_SIZE);
r = getConfigAttrib(config, EGL_RED_SIZE);
g = getConfigAttrib(config, EGL_GREEN_SIZE);
b = getConfigAttrib(config, EGL_BLUE_SIZE);
a = getConfigAttrib(config, EGL_ALPHA_SIZE);
Log.i(TAG, " <d,s,r,g,b,a> = <" + d + "," + s + "," +
r + "," + g + "," + b + "," + a + ">");
}
Log.i(TAG, "}");
}
private int getConfigAttrib(final EGLConfig config, final int attribute) {
int[] value = new int[1];
return egl10.eglGetConfigAttrib(eglDisplay, config,
attribute, value) ? value[0] : 0;
}
private void convertToBitmap() {
bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
GPUImageNativeLibrary.adjustBitmap(bitmap);
}
}
================================================
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImage3x3ConvolutionFilter.java
================================================
/*
* Copyright (C) 2018 CyberAgent, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jp.co.cyberagent.android.gpuimage.filter;
import android.opengl.GLES20;
/**
* Runs a 3x3 convolution kernel against the image
*/
public class GPUImage3x3ConvolutionFilter extends GPUImage3x3TextureSamplingFilter {
public static final String THREE_X_THREE_TEXTURE_SAMPLING_FRAGMENT_SHADER = "" +
"precision highp float;\n" +
"\n" +
"uniform sampler2D inputImageTexture;\n" +
"\n" +
"uniform mediump mat3 convolutionMatrix;\n" +
"\n" +
"varying vec2 textureCoordinate;\n" +
"varying vec2 leftTextureCoordinate;\n" +
"varying vec2 rightTextureCoordinate;\n" +
"\n" +
"varying vec2 topTextureCoordinate;\n" +
"varying vec2 topLeftTextureCoordinate;\n" +
"varying vec2 topRightTextureCoordinate;\n" +
"\n" +
"varying vec2 bottomTextureCoordinate;\n" +
"varying vec2 bottomLeftTextureCoordinate;\n" +
"varying vec2 bottomRightTextureCoordinate;\n" +
"\n" +
"void main()\n" +
"{\n" +
" mediump vec4 bottomColor = texture2D(inputImageTexture, bottomTextureCoordinate);\n" +
" mediump vec4 bottomLeftColor = texture2D(inputImageTexture, bottomLeftTextureCoordinate);\n" +
" mediump vec4 bottomRightColor = texture2D(inputImageTexture, bottomRightTextureCoordinate);\n" +
" mediump vec4 centerColor = texture2D(inputImageTexture, textureCoordinate);\n" +
" mediump vec4 leftColor = texture2D(inputImageTexture, leftTextureCoordinate);\n" +
" mediump vec4 rightColor = texture2D(inputImageTexture, rightTextureCoordinate);\n" +
" mediump vec4 topColor = texture2D(inputImageTexture, topTextureCoordinate);\n" +
" mediump vec4 topRightColor = texture2D(inputImageTexture, topRightTextureCoordinate);\n" +
" mediump vec4 topLeftColor = texture2D(inputImageTexture, topLeftTextureCoordinate);\n" +
"\n" +
" mediump vec4 resultColor = topLeftColor * convolutionMatrix[0][0] + topColor * convolutionMatrix[0][1] + topRightColor * convolutionMatrix[0][2];\n" +
" resultColor += leftColor * convolutionMatrix[1][0] + centerColor * convolutionMatrix[1][1] + rightColor * convolutionMatrix[1][2];\n" +
" resultColor += bottomLeftColor * convolutionMatrix[2][0] + bottomColor * convolutionMatrix[2][1] + bottomRightColor * convolutionMatrix[2][2];\n" +
"\n" +
" gl_FragColor = resultColor;\n" +
"}";
private float[] convolutionKernel;
private int uniformConvolutionMatrix;
/**
* Instantiates a new GPUimage3x3ConvolutionFilter with default values, that
* will look like the original image.
*/
public GPUImage3x3ConvolutionFilter() {
this(new float[]{
0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f
});
}
/**
* Instantiates a new GPUimage3x3ConvolutionFilter with given convolution kernel.
*
* @param convolutionKernel the convolution kernel
*/
public GPUImage3x3ConvolutionFilter(final float[] convolutionKernel) {
super(THREE_X_THREE_TEXTURE_SAMPLING_FRAGMENT_SHADER);
this.convolutionKernel = convolutionKernel;
}
@Override
public void onInit() {
super.onInit();
uniformConvolutionMatrix = GLES20.glGetUniformLocation(getProgram(), "convolutionMatrix");
}
@Override
public void onInitialized() {
super.onInitialized();
setConvolutionKernel(convolutionKernel);
}
/**
* Sets the convolution kernel.
*
* @param convolutionKernel the new convolution kernel
*/
public void setConvolutionKernel(final float[] convolutionKernel) {
this.convolutionKernel = convolutionKernel;
setUniformMatrix3f(uniformConvolutionMatrix, this.convolutionKernel);
}
}
================================================
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImage3x3TextureSamplingFilter.java
================================================
/*
* Copyright (C) 2018 CyberAgent, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jp.co.cyberagent.android.gpuimage.filter;
import android.opengl.GLES20;
public class GPUImage3x3TextureSamplingFilter extends GPUImageFilter {
public static final String THREE_X_THREE_TEXTURE_SAMPLING_VERTEX_SHADER = "" +
"attribute vec4 position;\n" +
"attribute vec4 inputTextureCoordinate;\n" +
"\n" +
"uniform highp float texelWidth; \n" +
"uniform highp float texelHeight; \n" +
"\n" +
"varying vec2 textureCoordinate;\n" +
"varying vec2 leftTextureCoordinate;\n" +
"varying vec2 rightTextureCoordinate;\n" +
"\n" +
"varying vec2 topTextureCoordinate;\n" +
"varying vec2 topLeftTextureCoordinate;\n" +
"varying vec2 topRightTextureCoordinate;\n" +
"\n" +
"varying vec2 bottomTextureCoordinate;\n" +
"varying vec2 bottomLeftTextureCoordinate;\n" +
"varying vec2 bottomRightTextureCoordinate;\n" +
"\n" +
"void main()\n" +
"{\n" +
" gl_Position = position;\n" +
"\n" +
" vec2 widthStep = vec2(texelWidth, 0.0);\n" +
" vec2 heightStep = vec2(0.0, texelHeight);\n" +
" vec2 widthHeightStep = vec2(texelWidth, texelHeight);\n" +
" vec2 widthNegativeHeightStep = vec2(texelWidth, -texelHeight);\n" +
"\n" +
" textureCoordinate = inputTextureCoordinate.xy;\n" +
" leftTextureCoordinate = inputTextureCoordinate.xy - widthStep;\n" +
" rightTextureCoordinate = inputTextureCoordinate.xy + widthStep;\n" +
"\n" +
" topTextureCoordinate = inputTextureCoordinate.xy - heightStep;\n" +
" topLeftTextureCoordinate = inputTextureCoordinate.xy - widthHeightStep;\n" +
" topRightTextureCoordinate = inputTextureCoordinate.xy + widthNegativeHeightStep;\n" +
"\n" +
" bottomTextureCoordinate = inputTextureCoordinate.xy + heightStep;\n" +
" bottomLeftTextureCoordinate = inputTextureCoordinate.xy - widthNegativeHeightStep;\n" +
" bottomRightTextureCoordinate = inputTextureCoordinate.xy + widthHeightStep;\n" +
"}";
private int uniformTexelWidthLocation;
private int uniformTexelHeightLocation;
private boolean hasOverriddenImageSizeFactor = false;
private float texelWidth;
private float texelHeight;
private float lineSize = 1.0f;
public GPUImage3x3TextureSamplingFilter() {
this(NO_FILTER_VERTEX_SHADER);
}
public GPUImage3x3TextureSamplingFilter(final String fragmentShader) {
super(THREE_X_THREE_TEXTURE_SAMPLING_VERTEX_SHADER, fragmentShader);
}
@Override
public void onInit() {
super.onInit();
uniformTexelWidthLocation = GLES20.glGetUniformLocation(getProgram(), "texelWidth");
uniformTexelHeightLocation = GLES20.glGetUniformLocation(getProgram(), "texelHeight");
}
@Override
public void onInitialized() {
super.onInitialized();
if (texelWidth != 0) {
updateTexelValues();
}
}
@Override
public void onOutputSizeChanged(final int width, final int height) {
super.onOutputSizeChanged(width, height);
if (!hasOverriddenImageSizeFactor) {
setLineSize(lineSize);
}
}
public void setTexelWidth(final float texelWidth) {
hasOverriddenImageSizeFactor = true;
this.texelWidth = texelWidth;
setFloat(uniformTexelWidthLocation, texelWidth);
}
public void setTexelHeight(final float texelHeight) {
hasOverriddenImageSizeFactor = true;
this.texelHeight = texelHeight;
setFloat(uniformTexelHeightLocation, texelHeight);
}
public void setLineSize(final float size) {
lineSize = size;
texelWidth = size / getOutputWidth();
texelHeight = size / getOutputHeight();
updateTexelValues();
}
private void updateTexelValues() {
setFloat(uniformTexelWidthLocation, texelWidth);
setFloat(uniformTexelHeightLocation, texelHeight);
}
}
================================================
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageAddBlendFilter.java
================================================
/*
* Copyright (C) 2018 CyberAgent, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jp.co.cyberagent.android.gpuimage.filter;
public class GPUImageAddBlendFilter extends GPUImageTwoInputFilter {
public static final String ADD_BLEND_FRAGMENT_SHADER = "varying highp vec2 textureCoordinate;\n" +
" varying highp vec2 textureCoordinate2;\n" +
"\n" +
" uniform sampler2D inputImageTexture;\n" +
" uniform sampler2D inputImageTexture2;\n" +
" \n" +
" void main()\n" +
" {\n" +
" lowp vec4 base = texture2D(inputImageTexture, textureCoordinate);\n" +
" lowp vec4 overlay = texture2D(inputImageTexture2, textureCoordinate2);\n" +
"\n" +
" mediump float r;\n" +
" if (overlay.r * base.a + base.r * overlay.a >= overlay.a * base.a) {\n" +
" r = overlay.a * base.a + overlay.r * (1.0 - base.a) + base.r * (1.0 - overlay.a);\n" +
" } else {\n" +
" r = overlay.r + base.r;\n" +
" }\n" +
"\n" +
" mediump float g;\n" +
" if (overlay.g * base.a + base.g * overlay.a >= overlay.a * base.a) {\n" +
" g = overlay.a * base.a + overlay.g * (1.0 - base.a) + base.g * (1.0 - overlay.a);\n" +
" } else {\n" +
" g = overlay.g + base.g;\n" +
" }\n" +
"\n" +
" mediump float b;\n" +
" if (overlay.b * base.a + base.b * overlay.a >= overlay.a * base.a) {\n" +
" b = overlay.a * base.a + overlay.b * (1.0 - base.a) + base.b * (1.0 - overlay.a);\n" +
" } else {\n" +
" b = overlay.b + base.b;\n" +
" }\n" +
"\n" +
" mediump float a = overlay.a + base.a - overlay.a * base.a;\n" +
" \n" +
" gl_FragColor = vec4(r, g, b, a);\n" +
" }";
public GPUImageAddBlendFilter() {
super(ADD_BLEND_FRAGMENT_SHADER);
}
}
================================================
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageAlphaBlendFilter.java
================================================
/*
* Copyright (C) 2018 CyberAgent, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jp.co.cyberagent.android.gpuimage.filter;
/**
* Mix ranges from 0.0 (only image 1) to 1.0 (only image 2), with 0.5 (half of either) as the normal level
*/
public class GPUImageAlphaBlendFilter extends GPUImageMixBlendFilter {
public static final String ALPHA_BLEND_FRAGMENT_SHADER = "varying highp vec2 textureCoordinate;\n" +
" varying highp vec2 textureCoordinate2;\n" +
"\n" +
" uniform sampler2D inputImageTexture;\n" +
" uniform sampler2D inputImageTexture2;\n" +
" \n" +
" uniform lowp float mixturePercent;\n" +
"\n" +
" void main()\n" +
" {\n" +
" lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
" lowp vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);\n" +
"\n" +
" gl_FragColor = vec4(mix(textureColor.rgb, textureColor2.rgb, textureColor2.a * mixturePercent), textureColor.a);\n" +
" }";
public GPUImageAlphaBlendFilter() {
super(ALPHA_BLEND_FRAGMENT_SHADER);
}
public GPUImageAlphaBlendFilter(float mix) {
super(ALPHA_BLEND_FRAGMENT_SHADER, mix);
}
}
================================================
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageBilateralBlurFilter.java
================================================
/**
* @author wysaid
* @mail admin@wysaid.org
*/
package jp.co.cyberagent.android.gpuimage.filter;
import android.opengl.GLES20;
public class GPUImageBilateralBlurFilter extends GPUImageFilter {
public static final String BILATERAL_VERTEX_SHADER = "" +
"attribute vec4 position;\n" +
"attribute vec4 inputTextureCoordinate;\n" +
"const int GAUSSIAN_SAMPLES = 9;\n" +
"uniform vec2 singleStepOffset;\n" +
"varying vec2 textureCoordinate;\n" +
"varying vec2 blurCoordinates[GAUSSIAN_SAMPLES];\n" +
"void main()\n" +
"{\n" +
" gl_Position = position;\n" +
" textureCoordinate = inputTextureCoordinate.xy;\n" +
" int multiplier = 0;\n" +
" vec2 blurStep;\n" +
" for (int i = 0; i < GAUSSIAN_SAMPLES; i++)\n" +
" {\n" +
" multiplier = (i - ((GAUSSIAN_SAMPLES - 1) / 2));\n" +
" blurStep = float(multiplier) * singleStepOffset;\n" +
" blurCoordinates[i] = inputTextureCoordinate.xy + blurStep;\n" +
" }\n" +
"}";
public static final String BILATERAL_FRAGMENT_SHADER = "" +
"uniform sampler2D inputImageTexture;\n" +
" const lowp int GAUSSIAN_SAMPLES = 9;\n" +
" varying highp vec2 textureCoordinate;\n" +
" varying highp vec2 blurCoordinates[GAUSSIAN_SAMPLES];\n" +
" uniform mediump float distanceNormalizationFactor;\n" +
" void main()\n" +
" {\n" +
" lowp vec4 centralColor;\n" +
" lowp float gaussianWeightTotal;\n" +
" lowp vec4 sum;\n" +
" lowp vec4 sampleColor;\n" +
" lowp float distanceFromCentralColor;\n" +
" lowp float gaussianWeight;\n" +
" \n" +
" centralColor = texture2D(inputImageTexture, blurCoordinates[4]);\n" +
" gaussianWeightTotal = 0.18;\n" +
" sum = centralColor * 0.18;\n" +
" \n" +
" sampleColor = texture2D(inputImageTexture, blurCoordinates[0]);\n" +
" distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);\n" +
" gaussianWeight = 0.05 * (1.0 - distanceFromCentralColor);\n" +
" gaussianWeightTotal += gaussianWeight;\n" +
" sum += sampleColor * gaussianWeight;\n" +
" sampleColor = texture2D(inputImageTexture, blurCoordinates[1]);\n" +
" distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);\n" +
" gaussianWeight = 0.09 * (1.0 - distanceFromCentralColor);\n" +
" gaussianWeightTotal += gaussianWeight;\n" +
" sum += sampleColor * gaussianWeight;\n" +
" sampleColor = texture2D(inputImageTexture, blurCoordinates[2]);\n" +
" distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);\n" +
" gaussianWeight = 0.12 * (1.0 - distanceFromCentralColor);\n" +
" gaussianWeightTotal += gaussianWeight;\n" +
" sum += sampleColor * gaussianWeight;\n" +
" sampleColor = texture2D(inputImageTexture, blurCoordinates[3]);\n" +
" distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);\n" +
" gaussianWeight = 0.15 * (1.0 - distanceFromCentralColor);\n" +
" gaussianWeightTotal += gaussianWeight;\n" +
" sum += sampleColor * gaussianWeight;\n" +
" sampleColor = texture2D(inputImageTexture, blurCoordinates[5]);\n" +
" distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);\n" +
" gaussianWeight = 0.15 * (1.0 - distanceFromCentralColor);\n" +
" gaussianWeightTotal += gaussianWeight;\n" +
" sum += sampleColor * gaussianWeight;\n" +
" sampleColor = texture2D(inputImageTexture, blurCoordinates[6]);\n" +
" distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);\n" +
" gaussianWeight = 0.12 * (1.0 - distanceFromCentralColor);\n" +
" gaussianWeightTotal += gaussianWeight;\n" +
" sum += sampleColor * gaussianWeight;\n" +
" sampleColor = texture2D(inputImageTexture, blurCoordinates[7]);\n" +
" distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);\n" +
" gaussianWeight = 0.09 * (1.0 - distanceFromCentralColor);\n" +
" gaussianWeightTotal += gaussianWeight;\n" +
" sum += sampleColor * gaussianWeight;\n" +
" sampleColor = texture2D(inputImageTexture, blurCoordinates[8]);\n" +
" distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);\n" +
" gaussianWeight = 0.05 * (1.0 - distanceFromCentralColor);\n" +
" gaussianWeightTotal += gaussianWeight;\n" +
" sum += sampleColor * gaussianWeight;\n" +
" gl_FragColor = sum / gaussianWeightTotal;\n" +
" }";
private float distanceNormalizationFactor;
private int disFactorLocation;
private int singleStepOffsetLocation;
public GPUImageBilateralBlurFilter() {
this(8.0f);
}
public GPUImageBilateralBlurFilter(final float distanceNormalizationFactor) {
super(BILATERAL_VERTEX_SHADER, BILATERAL_FRAGMENT_SHADER);
this.distanceNormalizationFactor = distanceNormalizationFactor;
}
@Override
public void onInit() {
super.onInit();
disFactorLocation = GLES20.glGetUniformLocation(getProgram(), "distanceNormalizationFactor");
singleStepOffsetLocation = GLES20.glGetUniformLocation(getProgram(), "singleStepOffset");
}
@Override
public void onInitialized() {
super.onInitialized();
setDistanceNormalizationFactor(distanceNormalizationFactor);
}
public void setDistanceNormalizationFactor(final float newValue) {
distanceNormalizationFactor = newValue;
setFloat(disFactorLocation, newValue);
}
private void setTexelSize(final float w, final float h) {
setFloatVec2(singleStepOffsetLocation, new float[]{1.0f / w, 1.0f / h});
}
@Override
public void onOutputSizeChanged(final int width, final int height) {
super.onOutputSizeChanged(width, height);
setTexelSize(width, height);
}
}
================================================
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageBoxBlurFilter.java
================================================
/*
* Copyright (C) 2018 CyberAgent, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jp.co.cyberagent.android.gpuimage.filter;
/**
* A hardware-accelerated 9-hit box blur of an image
* <p>
* scaling: for the size of the applied blur, default of 1.0
*/
public class GPUImageBoxBlurFilter extends GPUImageTwoPassTextureSamplingFilter {
public static final String VERTEX_SHADER =
"attribute vec4 position;\n" +
"attribute vec2 inputTextureCoordinate;\n" +
"\n" +
"uniform float texelWidthOffset; \n" +
"uniform float texelHeightOffset; \n" +
"\n" +
"varying vec2 centerTextureCoordinate;\n" +
"varying vec2 oneStepLeftTextureCoordinate;\n" +
"varying vec2 twoStepsLeftTextureCoordinate;\n" +
"varying vec2 oneStepRightTextureCoordinate;\n" +
"varying vec2 twoStepsRightTextureCoordinate;\n" +
"\n" +
"void main()\n" +
"{\n" +
"gl_Position = position;\n" +
"\n" +
"vec2 firstOffset = vec2(1.5 * texelWidthOffset, 1.5 * texelHeightOffset);\n" +
"vec2 secondOffset = vec2(3.5 * texelWidthOffset, 3.5 * texelHeightOffset);\n" +
"\n" +
"centerTextureCoordinate = inputTextureCoordinate;\n" +
"oneStepLeftTextureCoordinate = inputTextureCoordinate - firstOffset;\n" +
"twoStepsLeftTextureCoordinate = inputTextureCoordinate - secondOffset;\n" +
"oneStepRightTextureCoordinate = inputTextureCoordinate + firstOffset;\n" +
"twoStepsRightTextureCoordinate = inputTextureCoordinate + secondOffset;\n" +
"}\n";
public static final String FRAGMENT_SHADER =
"precision highp float;\n" +
"\n" +
"uniform sampler2D inputImageTexture;\n" +
"\n" +
"varying vec2 centerTextureCoordinate;\n" +
"varying vec2 oneStepLeftTextureCoordinate;\n" +
"varying vec2 twoStepsLeftTextureCoordinate;\n" +
"varying vec2 oneStepRightTextureCoordinate;\n" +
"varying vec2 twoStepsRightTextureCoordinate;\n" +
"\n" +
"void main()\n" +
"{\n" +
"lowp vec4 fragmentColor = texture2D(inputImageTexture, centerTextureCoordinate) * 0.2;\n" +
"fragmentColor += texture2D(inputImageTexture, oneStepLeftTextureCoordinate) * 0.2;\n" +
"fragmentColor += texture2D(inputImageTexture, oneStepRightTextureCoordinate) * 0.2;\n" +
"fragmentColor += texture2D(inputImageTexture, twoStepsLeftTextureCoordinate) * 0.2;\n" +
"fragmentColor += texture2D(inputImageTexture, twoStepsRightTextureCoordinate) * 0.2;\n" +
"\n" +
"gl_FragColor = fragmentColor;\n" +
"}\n";
private float blurSize;
/**
* Construct new BoxBlurFilter with default blur size of 1.0.
*/
public GPUImageBoxBlurFilter() {
this(1f);
}
public GPUImageBoxBlurFilter(float blurSize) {
super(VERTEX_SHADER, FRAGMENT_SHADER, VERTEX_SHADER, FRAGMENT_SHADER);
this.blurSize = blurSize;
}
@Override
public void onInitialized() {
super.onInitialized();
setBlurSize(blurSize);
}
/**
* A scaling for the size of the applied blur, default of 1.0
*
* @param blurSize
*/
public void setBlurSize(float blurSize) {
this.blurSize = blurSize;
runOnDraw(new Runnable() {
@Override
public void run() {
initTexelOffsets();
}
});
}
@Override
public float getVerticalTexelOffsetRatio() {
gitextract_jngkckqx/
├── .github/
│ ├── ISSUE_TEMPLATE.md
│ └── PULL_REQUEST_TEMPLATE.md
├── .gitignore
├── CHANGELOG.md
├── CONTRIBUTING.md
├── README.md
├── build.gradle
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── library/
│ ├── build.gradle
│ ├── gradle.properties
│ ├── proguard-rules.txt
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ ├── cpp/
│ │ ├── CMakeLists.txt
│ │ └── yuv-decoder.c
│ ├── java/
│ │ └── jp/
│ │ └── co/
│ │ └── cyberagent/
│ │ └── android/
│ │ └── gpuimage/
│ │ ├── GLTextureView.java
│ │ ├── GPUImage.java
│ │ ├── GPUImageNativeLibrary.java
│ │ ├── GPUImageRenderer.java
│ │ ├── GPUImageView.java
│ │ ├── PixelBuffer.java
│ │ ├── filter/
│ │ │ ├── GPUImage3x3ConvolutionFilter.java
│ │ │ ├── GPUImage3x3TextureSamplingFilter.java
│ │ │ ├── GPUImageAddBlendFilter.java
│ │ │ ├── GPUImageAlphaBlendFilter.java
│ │ │ ├── GPUImageBilateralBlurFilter.java
│ │ │ ├── GPUImageBoxBlurFilter.java
│ │ │ ├── GPUImageBrightnessFilter.java
│ │ │ ├── GPUImageBulgeDistortionFilter.java
│ │ │ ├── GPUImageCGAColorspaceFilter.java
│ │ │ ├── GPUImageChromaKeyBlendFilter.java
│ │ │ ├── GPUImageColorBalanceFilter.java
│ │ │ ├── GPUImageColorBlendFilter.java
│ │ │ ├── GPUImageColorBurnBlendFilter.java
│ │ │ ├── GPUImageColorDodgeBlendFilter.java
│ │ │ ├── GPUImageColorInvertFilter.java
│ │ │ ├── GPUImageColorMatrixFilter.java
│ │ │ ├── GPUImageContrastFilter.java
│ │ │ ├── GPUImageCrosshatchFilter.java
│ │ │ ├── GPUImageDarkenBlendFilter.java
│ │ │ ├── GPUImageDifferenceBlendFilter.java
│ │ │ ├── GPUImageDilationFilter.java
│ │ │ ├── GPUImageDirectionalSobelEdgeDetectionFilter.java
│ │ │ ├── GPUImageDissolveBlendFilter.java
│ │ │ ├── GPUImageDivideBlendFilter.java
│ │ │ ├── GPUImageEmbossFilter.java
│ │ │ ├── GPUImageExclusionBlendFilter.java
│ │ │ ├── GPUImageExposureFilter.java
│ │ │ ├── GPUImageFalseColorFilter.java
│ │ │ ├── GPUImageFilter.java
│ │ │ ├── GPUImageFilterGroup.java
│ │ │ ├── GPUImageGammaFilter.java
│ │ │ ├── GPUImageGaussianBlurFilter.java
│ │ │ ├── GPUImageGlassSphereFilter.java
│ │ │ ├── GPUImageGrayscaleFilter.java
│ │ │ ├── GPUImageHalftoneFilter.java
│ │ │ ├── GPUImageHardLightBlendFilter.java
│ │ │ ├── GPUImageHazeFilter.java
│ │ │ ├── GPUImageHighlightShadowFilter.java
│ │ │ ├── GPUImageHueBlendFilter.java
│ │ │ ├── GPUImageHueFilter.java
│ │ │ ├── GPUImageKuwaharaFilter.java
│ │ │ ├── GPUImageLaplacianFilter.java
│ │ │ ├── GPUImageLevelsFilter.java
│ │ │ ├── GPUImageLightenBlendFilter.java
│ │ │ ├── GPUImageLinearBurnBlendFilter.java
│ │ │ ├── GPUImageLookupFilter.java
│ │ │ ├── GPUImageLuminanceFilter.java
│ │ │ ├── GPUImageLuminanceThresholdFilter.java
│ │ │ ├── GPUImageLuminosityBlendFilter.java
│ │ │ ├── GPUImageMixBlendFilter.java
│ │ │ ├── GPUImageMonochromeFilter.java
│ │ │ ├── GPUImageMultiplyBlendFilter.java
│ │ │ ├── GPUImageNonMaximumSuppressionFilter.java
│ │ │ ├── GPUImageNormalBlendFilter.java
│ │ │ ├── GPUImageOpacityFilter.java
│ │ │ ├── GPUImageOverlayBlendFilter.java
│ │ │ ├── GPUImagePixelationFilter.java
│ │ │ ├── GPUImagePosterizeFilter.java
│ │ │ ├── GPUImageRGBDilationFilter.java
│ │ │ ├── GPUImageRGBFilter.java
│ │ │ ├── GPUImageSaturationBlendFilter.java
│ │ │ ├── GPUImageSaturationFilter.java
│ │ │ ├── GPUImageScreenBlendFilter.java
│ │ │ ├── GPUImageSepiaToneFilter.java
│ │ │ ├── GPUImageSharpenFilter.java
│ │ │ ├── GPUImageSketchFilter.java
│ │ │ ├── GPUImageSmoothToonFilter.java
│ │ │ ├── GPUImageSobelEdgeDetectionFilter.java
│ │ │ ├── GPUImageSobelThresholdFilter.java
│ │ │ ├── GPUImageSoftLightBlendFilter.java
│ │ │ ├── GPUImageSolarizeFilter.java
│ │ │ ├── GPUImageSourceOverBlendFilter.java
│ │ │ ├── GPUImageSphereRefractionFilter.java
│ │ │ ├── GPUImageSubtractBlendFilter.java
│ │ │ ├── GPUImageSwirlFilter.java
│ │ │ ├── GPUImageThresholdEdgeDetectionFilter.java
│ │ │ ├── GPUImageToneCurveFilter.java
│ │ │ ├── GPUImageToonFilter.java
│ │ │ ├── GPUImageTransformFilter.java
│ │ │ ├── GPUImageTwoInputFilter.java
│ │ │ ├── GPUImageTwoPassFilter.java
│ │ │ ├── GPUImageTwoPassTextureSamplingFilter.java
│ │ │ ├── GPUImageVibranceFilter.java
│ │ │ ├── GPUImageVignetteFilter.java
│ │ │ ├── GPUImageWeakPixelInclusionFilter.java
│ │ │ ├── GPUImageWhiteBalanceFilter.java
│ │ │ └── GPUImageZoomBlurFilter.java
│ │ └── util/
│ │ ├── OpenGlUtils.java
│ │ ├── Rotation.java
│ │ └── TextureRotationUtil.java
│ └── res/
│ └── values/
│ └── attrs.xml
├── sample/
│ ├── build.gradle
│ ├── proguard-project.txt
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ ├── java/
│ │ └── jp/
│ │ └── co/
│ │ └── cyberagent/
│ │ └── android/
│ │ └── gpuimage/
│ │ └── sample/
│ │ ├── GPUImageFilterTools.kt
│ │ ├── activity/
│ │ │ ├── CameraActivity.kt
│ │ │ ├── GalleryActivity.kt
│ │ │ └── MainActivity.kt
│ │ └── utils/
│ │ ├── Camera1Loader.kt
│ │ ├── Camera2Loader.kt
│ │ ├── CameraLoader.kt
│ │ ├── ImageExt.kt
│ │ └── ViewExt.kt
│ └── res/
│ ├── layout/
│ │ ├── activity_camera.xml
│ │ ├── activity_gallery.xml
│ │ └── activity_main.xml
│ ├── raw/
│ │ └── tone_cuver_sample.acv
│ └── values/
│ ├── strings.xml
│ └── styles.xml
├── settings.gradle
└── utils/
└── Shader2String.py
SYMBOL INDEX (771 symbols across 97 files)
FILE: library/src/main/cpp/yuv-decoder.c
function JNICALL (line 7) | JNICALL
function JNICALL (line 66) | JNICALL
function JNICALL (line 126) | JNICALL
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/GLTextureView.java
class GLTextureView (line 40) | public class GLTextureView extends TextureView
method GLTextureView (line 93) | public GLTextureView(Context context) {
method GLTextureView (line 102) | public GLTextureView(Context context, AttributeSet attrs) {
method finalize (line 107) | @Override
method init (line 120) | private void init() {
method setGLWrapper (line 138) | public void setGLWrapper(GLWrapper glWrapper) {
method setDebugFlags (line 152) | public void setDebugFlags(int debugFlags) {
method getDebugFlags (line 161) | public int getDebugFlags() {
method setPreserveEGLContextOnPause (line 183) | public void setPreserveEGLContextOnPause(boolean preserveOnPause) {
method getPreserveEGLContextOnPause (line 190) | public boolean getPreserveEGLContextOnPause() {
method setRenderer (line 220) | public void setRenderer(Renderer renderer) {
method setEGLContextFactory (line 246) | public void setEGLContextFactory(EGLContextFactory factory) {
method setEGLWindowSurfaceFactory (line 260) | public void setEGLWindowSurfaceFactory(EGLWindowSurfaceFactory factory) {
method setEGLConfigChooser (line 276) | public void setEGLConfigChooser(EGLConfigChooser configChooser) {
method setEGLConfigChooser (line 293) | public void setEGLConfigChooser(boolean needDepth) {
method setEGLConfigChooser (line 309) | public void setEGLConfigChooser(int redSize, int greenSize, int blueSi...
method setEGLContextClientVersion (line 342) | public void setEGLContextClientVersion(int version) {
method setRenderMode (line 363) | public void setRenderMode(int renderMode) {
method getRenderMode (line 375) | public int getRenderMode() {
method requestRender (line 386) | public void requestRender() {
method surfaceCreated (line 394) | public void surfaceCreated(SurfaceTexture texture) {
method surfaceDestroyed (line 402) | public void surfaceDestroyed(SurfaceTexture texture) {
method surfaceChanged (line 411) | public void surfaceChanged(SurfaceTexture texture, int format, int w, ...
method onPause (line 421) | public void onPause() {
method onResume (line 432) | public void onResume() {
method queueEvent (line 443) | public void queueEvent(Runnable r) {
method onAttachedToWindow (line 451) | @Override
method onDetachedFromWindow (line 476) | @Override
method onLayoutChange (line 488) | public void onLayoutChange(View v, int left, int top, int right, int b...
method addSurfaceTextureListener (line 493) | public void addSurfaceTextureListener(SurfaceTextureListener listener) {
method onSurfaceTextureAvailable (line 497) | public void onSurfaceTextureAvailable(SurfaceTexture surface, int widt...
method onSurfaceTextureSizeChanged (line 506) | public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int wi...
method onSurfaceTextureDestroyed (line 514) | public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
method onSurfaceTextureUpdated (line 524) | public void onSurfaceTextureUpdated(SurfaceTexture surface) {
type GLWrapper (line 556) | public interface GLWrapper {
method wrap (line 563) | GL wrap(GL gl);
type Renderer (line 602) | public interface Renderer {
method onSurfaceCreated (line 628) | void onSurfaceCreated(GL10 gl, EGLConfig config);
method onSurfaceChanged (line 652) | void onSurfaceChanged(GL10 gl, int width, int height);
method onDrawFrame (line 670) | void onDrawFrame(GL10 gl);
type EGLContextFactory (line 679) | public interface EGLContextFactory {
method createContext (line 680) | EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eg...
method destroyContext (line 682) | void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context);
class DefaultContextFactory (line 685) | private class DefaultContextFactory implements EGLContextFactory {
method createContext (line 688) | public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLCo...
method destroyContext (line 697) | public void destroyContext(EGL10 egl, EGLDisplay display, EGLContext...
type EGLWindowSurfaceFactory (line 714) | public interface EGLWindowSurfaceFactory {
method createWindowSurface (line 718) | EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display, EGLCon...
method destroySurface (line 721) | void destroySurface(EGL10 egl, EGLDisplay display, EGLSurface surface);
class DefaultWindowSurfaceFactory (line 724) | private static class DefaultWindowSurfaceFactory implements EGLWindowS...
method createWindowSurface (line 726) | public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,...
method destroySurface (line 743) | public void destroySurface(EGL10 egl, EGLDisplay display, EGLSurface...
type EGLConfigChooser (line 755) | public interface EGLConfigChooser {
method chooseConfig (line 766) | EGLConfig chooseConfig(EGL10 egl, EGLDisplay display);
class BaseConfigChooser (line 769) | private abstract class BaseConfigChooser implements EGLConfigChooser {
method BaseConfigChooser (line 770) | public BaseConfigChooser(int[] configSpec) {
method chooseConfig (line 774) | public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
method chooseConfig (line 797) | abstract EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, EGLCo...
method filterConfigSpec (line 801) | private int[] filterConfigSpec(int[] configSpec) {
class ComponentSizeChooser (line 822) | private class ComponentSizeChooser extends BaseConfigChooser {
method ComponentSizeChooser (line 823) | public ComponentSizeChooser(int redSize, int greenSize, int blueSize...
method chooseConfig (line 839) | @Override
method findConfigAttrib (line 857) | private int findConfigAttrib(EGL10 egl, EGLDisplay display, EGLConfi...
class SimpleEGLConfigChooser (line 880) | private class SimpleEGLConfigChooser extends ComponentSizeChooser {
method SimpleEGLConfigChooser (line 881) | public SimpleEGLConfigChooser(boolean withDepthBuffer) {
class EglHelper (line 890) | private static class EglHelper {
method EglHelper (line 891) | public EglHelper(WeakReference<GLTextureView> glTextureViewWeakRefer...
method start (line 898) | public void start() {
method createSurface (line 954) | public boolean createSurface() {
method createGL (line 1015) | GL createGL() {
method swap (line 1044) | public int swap() {
method destroySurface (line 1051) | public void destroySurface() {
method destroySurfaceImp (line 1058) | private void destroySurfaceImp() {
method finish (line 1070) | public void finish() {
method throwEglException (line 1087) | private void throwEglException(String function) {
method throwEglException (line 1091) | public static void throwEglException(String function, int error) {
method logEglErrorAsWarning (line 1100) | public static void logEglErrorAsWarning(String tag, String function,...
method formatEglError (line 1104) | public static String formatEglError(String function, int error) {
class GLThread (line 1124) | static class GLThread extends Thread {
method GLThread (line 1125) | GLThread(WeakReference<GLTextureView> glTextureViewWeakRef) {
method run (line 1134) | @Override
method stopEglSurfaceLocked (line 1154) | private void stopEglSurfaceLocked() {
method stopEglContextLocked (line 1165) | private void stopEglContextLocked() {
method guardedRun (line 1173) | private void guardedRun() throws InterruptedException {
method ableToDraw (line 1454) | public boolean ableToDraw() {
method readyToDraw (line 1458) | private boolean readyToDraw() {
method setRenderMode (line 1463) | public void setRenderMode(int renderMode) {
method getRenderMode (line 1473) | public int getRenderMode() {
method requestRender (line 1479) | public void requestRender() {
method surfaceCreated (line 1486) | public void surfaceCreated() {
method surfaceDestroyed (line 1503) | public void surfaceDestroyed() {
method onPause (line 1520) | public void onPause() {
method onResume (line 1540) | public void onResume() {
method onWindowResize (line 1562) | public void onWindowResize(int w, int h) {
method requestExitAndWait (line 1585) | public void requestExitAndWait() {
method requestReleaseEglContextLocked (line 1601) | public void requestReleaseEglContextLocked() {
method queueEvent (line 1611) | public void queueEvent(Runnable r) {
class LogWriter (line 1653) | static class LogWriter extends Writer {
method close (line 1655) | @Override
method flush (line 1660) | @Override
method write (line 1665) | @Override
method flushBuilder (line 1677) | private void flushBuilder() {
method checkRenderThreadState (line 1687) | private void checkRenderThreadState() {
class GLThreadManager (line 1693) | private static class GLThreadManager {
method threadExiting (line 1696) | public synchronized void threadExiting(GLThread thread) {
method tryAcquireEglContextLocked (line 1714) | public boolean tryAcquireEglContextLocked(GLThread thread) {
method releaseEglContextLocked (line 1738) | public void releaseEglContextLocked(GLThread thread) {
method shouldReleaseEGLContextWhenPausing (line 1745) | public synchronized boolean shouldReleaseEGLContextWhenPausing() {
method shouldTerminateEGLWhenPausing (line 1752) | public synchronized boolean shouldTerminateEGLWhenPausing() {
method checkGLDriver (line 1757) | public synchronized void checkGLDriver(GL10 gl) {
method checkGLESVersion (line 1774) | private void checkGLESVersion() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/GPUImage.java
class GPUImage (line 55) | public class GPUImage {
type ScaleType (line 57) | public enum ScaleType {CENTER_INSIDE, CENTER_CROP}
method GPUImage (line 77) | public GPUImage(final Context context) {
method supportsOpenGLES2 (line 93) | private boolean supportsOpenGLES2(final Context context) {
method setGLSurfaceView (line 106) | public void setGLSurfaceView(final GLSurfaceView view) {
method setGLTextureView (line 122) | public void setGLTextureView(final GLTextureView view) {
method setBackgroundColor (line 140) | public void setBackgroundColor(float red, float green, float blue) {
method requestRender (line 147) | public void requestRender() {
method setUpCamera (line 167) | @Deprecated
method setUpCamera (line 183) | @Deprecated
method setFilter (line 213) | public void setFilter(final GPUImageFilter filter) {
method setImage (line 224) | public void setImage(final Bitmap bitmap) {
method updatePreviewFrame (line 237) | public void updatePreviewFrame(final byte[] data, final int width, fin...
method setScaleType (line 247) | public void setScaleType(ScaleType scaleType) {
method getScaleSize (line 261) | public int[] getScaleSize() {
method setRotation (line 270) | public void setRotation(Rotation rotation) {
method setRotation (line 279) | public void setRotation(Rotation rotation, boolean flipHorizontal, boo...
method deleteImage (line 286) | public void deleteImage() {
method setImage (line 297) | public void setImage(final Uri uri) {
method setImage (line 306) | public void setImage(final File file) {
method getPath (line 310) | private String getPath(final Uri uri) {
method getBitmapWithFilterApplied (line 333) | public Bitmap getBitmapWithFilterApplied() {
method getBitmapWithFilterApplied (line 343) | public Bitmap getBitmapWithFilterApplied(final Bitmap bitmap) {
method getBitmapWithFilterApplied (line 354) | public Bitmap getBitmapWithFilterApplied(final Bitmap bitmap, boolean ...
method getBitmapForMultipleFilters (line 409) | public static void getBitmapForMultipleFilters(final Bitmap bitmap,
method saveToPictures (line 439) | public void saveToPictures(final String folderName, final String fileN...
method saveToPictures (line 456) | public void saveToPictures(final Bitmap bitmap, final String folderNam...
method runOnGLThread (line 466) | void runOnGLThread(Runnable runnable) {
method getOutputWidth (line 470) | private int getOutputWidth() {
method getOutputHeight (line 483) | private int getOutputHeight() {
class SaveTask (line 496) | @Deprecated
method SaveTask (line 505) | public SaveTask(final Bitmap bitmap, final String folderName, final ...
method doInBackground (line 514) | @Override
method saveImage (line 521) | private void saveImage(final String folderName, final String fileNam...
type OnPictureSavedListener (line 551) | public interface OnPictureSavedListener {
method onPictureSaved (line 552) | void onPictureSaved(Uri uri);
class LoadImageUriTask (line 555) | private class LoadImageUriTask extends LoadImageTask {
method LoadImageUriTask (line 559) | public LoadImageUriTask(GPUImage gpuImage, Uri uri) {
method decode (line 564) | @Override
method getImageOrientation (line 582) | @Override
class LoadImageFileTask (line 598) | private class LoadImageFileTask extends LoadImageTask {
method LoadImageFileTask (line 602) | public LoadImageFileTask(GPUImage gpuImage, File file) {
method decode (line 607) | @Override
method getImageOrientation (line 612) | @Override
class LoadImageTask (line 631) | private abstract class LoadImageTask extends AsyncTask<Void, Void, Bit...
method LoadImageTask (line 637) | public LoadImageTask(final GPUImage gpuImage) {
method doInBackground (line 641) | @Override
method onPostExecute (line 657) | @Override
method decode (line 664) | protected abstract Bitmap decode(BitmapFactory.Options options);
method loadResizedImage (line 666) | private Bitmap loadResizedImage() {
method scaleBitmap (line 693) | private Bitmap scaleBitmap(Bitmap bitmap) {
method getScaleSize (line 726) | private int[] getScaleSize(int width, int height) {
method checkSize (line 748) | private boolean checkSize(boolean widthBigger, boolean heightBigger) {
method rotateImage (line 756) | private Bitmap rotateImage(final Bitmap bitmap) {
method getImageOrientation (line 776) | protected abstract int getImageOrientation() throws IOException;
type ResponseListener (line 779) | public interface ResponseListener<T> {
method response (line 780) | void response(T item);
method getRenderer (line 783) | public GPUImageRenderer getRenderer() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/GPUImageNativeLibrary.java
class GPUImageNativeLibrary (line 21) | public class GPUImageNativeLibrary {
method YUVtoRBGA (line 26) | public static native void YUVtoRBGA(byte[] yuv, int width, int height,...
method YUVtoARBG (line 28) | public static native void YUVtoARBG(byte[] yuv, int width, int height,...
method adjustBitmap (line 30) | public static native void adjustBitmap(Bitmap srcBitmap);
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/GPUImageRenderer.java
class GPUImageRenderer (line 46) | public class GPUImageRenderer implements GLSurfaceView.Renderer, GLTextu...
method GPUImageRenderer (line 82) | public GPUImageRenderer(final GPUImageFilter filter) {
method onSurfaceCreated (line 98) | @Override
method onSurfaceChanged (line 105) | @Override
method onDrawFrame (line 118) | @Override
method setBackgroundColor (line 136) | public void setBackgroundColor(float red, float green, float blue) {
method runAll (line 142) | private void runAll(Queue<Runnable> queue) {
method onPreviewFrame (line 150) | @Override
method onPreviewFrame (line 156) | public void onPreviewFrame(final byte[] data, final int width, final i...
method setUpSurfaceTexture (line 177) | public void setUpSurfaceTexture(final Camera camera) {
method setFilter (line 195) | public void setFilter(final GPUImageFilter filter) {
method deleteImage (line 212) | public void deleteImage() {
method setImageBitmap (line 225) | public void setImageBitmap(final Bitmap bitmap) {
method setImageBitmap (line 229) | public void setImageBitmap(final Bitmap bitmap, final boolean recycle) {
method setScaleType (line 263) | public void setScaleType(GPUImage.ScaleType scaleType) {
method getFrameWidth (line 267) | protected int getFrameWidth() {
method getFrameHeight (line 271) | protected int getFrameHeight() {
method adjustImageScaling (line 275) | private void adjustImageScaling() {
method addDistance (line 318) | private float addDistance(float coordinate, float distance) {
method setRotationCamera (line 322) | public void setRotationCamera(final Rotation rotation, final boolean f...
method setRotation (line 327) | public void setRotation(final Rotation rotation) {
method setRotation (line 332) | public void setRotation(final Rotation rotation,
method getRotation (line 339) | public Rotation getRotation() {
method isFlippedHorizontally (line 343) | public boolean isFlippedHorizontally() {
method isFlippedVertically (line 347) | public boolean isFlippedVertically() {
method runOnDraw (line 351) | protected void runOnDraw(final Runnable runnable) {
method runOnDrawEnd (line 357) | protected void runOnDrawEnd(final Runnable runnable) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/GPUImageView.java
class GPUImageView (line 50) | public class GPUImageView extends FrameLayout {
method GPUImageView (line 63) | public GPUImageView(Context context) {
method GPUImageView (line 68) | public GPUImageView(Context context, AttributeSet attrs) {
method init (line 73) | private void init(Context context, AttributeSet attrs) {
method onMeasure (line 94) | @Override
method getGPUImage (line 123) | public GPUImage getGPUImage() {
method setUpCamera (line 135) | @Deprecated
method setUpCamera (line 151) | @Deprecated
method updatePreviewFrame (line 164) | public void updatePreviewFrame(byte[] data, int width, int height) {
method setBackgroundColor (line 175) | public void setBackgroundColor(float red, float green, float blue) {
method setRenderMode (line 192) | public void setRenderMode(int renderMode) {
method setRatio (line 201) | public void setRatio(float ratio) {
method setScaleType (line 212) | public void setScaleType(GPUImage.ScaleType scaleType) {
method setRotation (line 221) | public void setRotation(Rotation rotation) {
method setFilter (line 231) | public void setFilter(GPUImageFilter filter) {
method getFilter (line 242) | public GPUImageFilter getFilter() {
method setImage (line 251) | public void setImage(final Bitmap bitmap) {
method setImage (line 260) | public void setImage(final Uri uri) {
method setImage (line 269) | public void setImage(final File file) {
method requestRender (line 273) | public void requestRender() {
method saveToPictures (line 292) | public void saveToPictures(final String folderName, final String fileN...
method saveToPictures (line 310) | public void saveToPictures(final String folderName, final String fileN...
method capture (line 324) | public Bitmap capture(final int width, final int height) throws Interr...
method capture (line 401) | public Bitmap capture() throws InterruptedException {
method onPause (line 425) | public void onPause() {
method onResume (line 436) | public void onResume() {
class Size (line 444) | public static class Size {
method Size (line 448) | public Size(int width, int height) {
class GPUImageGLSurfaceView (line 454) | private class GPUImageGLSurfaceView extends GLSurfaceView {
method GPUImageGLSurfaceView (line 455) | public GPUImageGLSurfaceView(Context context) {
method GPUImageGLSurfaceView (line 459) | public GPUImageGLSurfaceView(Context context, AttributeSet attrs) {
method onMeasure (line 463) | @Override
class GPUImageGLTextureView (line 474) | private class GPUImageGLTextureView extends GLTextureView {
method GPUImageGLTextureView (line 475) | public GPUImageGLTextureView(Context context) {
method GPUImageGLTextureView (line 479) | public GPUImageGLTextureView(Context context, AttributeSet attrs) {
method onMeasure (line 483) | @Override
class LoadingView (line 494) | private class LoadingView extends FrameLayout {
method LoadingView (line 495) | public LoadingView(Context context) {
method LoadingView (line 500) | public LoadingView(Context context, AttributeSet attrs) {
method LoadingView (line 505) | public LoadingView(Context context, AttributeSet attrs, int defStyle) {
method init (line 510) | private void init() {
class SaveTask (line 519) | private class SaveTask extends AsyncTask<Void, Void, Void> {
method SaveTask (line 527) | public SaveTask(final String folderName, final String fileName,
method SaveTask (line 532) | public SaveTask(final String folderName, final String fileName, int ...
method doInBackground (line 542) | @Override
method saveImage (line 553) | private void saveImage(final String folderName, final String fileNam...
type OnPictureSavedListener (line 583) | public interface OnPictureSavedListener {
method onPictureSaved (line 584) | void onPictureSaved(Uri uri);
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/PixelBuffer.java
class PixelBuffer (line 34) | public class PixelBuffer {
method PixelBuffer (line 52) | public PixelBuffer(final int width, final int height) {
method setRenderer (line 88) | public void setRenderer(final GLSurfaceView.Renderer renderer) {
method getBitmap (line 102) | public Bitmap getBitmap() {
method destroy (line 123) | public void destroy() {
method chooseConfig (line 134) | private EGLConfig chooseConfig() {
method listConfig (line 161) | private void listConfig() {
method getConfigAttrib (line 181) | private int getConfigAttrib(final EGLConfig config, final int attribut...
method convertToBitmap (line 187) | private void convertToBitmap() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImage3x3ConvolutionFilter.java
class GPUImage3x3ConvolutionFilter (line 24) | public class GPUImage3x3ConvolutionFilter extends GPUImage3x3TextureSamp...
method GPUImage3x3ConvolutionFilter (line 70) | public GPUImage3x3ConvolutionFilter() {
method GPUImage3x3ConvolutionFilter (line 83) | public GPUImage3x3ConvolutionFilter(final float[] convolutionKernel) {
method onInit (line 88) | @Override
method onInitialized (line 94) | @Override
method setConvolutionKernel (line 105) | public void setConvolutionKernel(final float[] convolutionKernel) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImage3x3TextureSamplingFilter.java
class GPUImage3x3TextureSamplingFilter (line 21) | public class GPUImage3x3TextureSamplingFilter extends GPUImageFilter {
method GPUImage3x3TextureSamplingFilter (line 71) | public GPUImage3x3TextureSamplingFilter() {
method GPUImage3x3TextureSamplingFilter (line 75) | public GPUImage3x3TextureSamplingFilter(final String fragmentShader) {
method onInit (line 79) | @Override
method onInitialized (line 86) | @Override
method onOutputSizeChanged (line 94) | @Override
method setTexelWidth (line 102) | public void setTexelWidth(final float texelWidth) {
method setTexelHeight (line 108) | public void setTexelHeight(final float texelHeight) {
method setLineSize (line 114) | public void setLineSize(final float size) {
method updateTexelValues (line 121) | private void updateTexelValues() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageAddBlendFilter.java
class GPUImageAddBlendFilter (line 19) | public class GPUImageAddBlendFilter extends GPUImageTwoInputFilter {
method GPUImageAddBlendFilter (line 57) | public GPUImageAddBlendFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageAlphaBlendFilter.java
class GPUImageAlphaBlendFilter (line 22) | public class GPUImageAlphaBlendFilter extends GPUImageMixBlendFilter {
method GPUImageAlphaBlendFilter (line 39) | public GPUImageAlphaBlendFilter() {
method GPUImageAlphaBlendFilter (line 43) | public GPUImageAlphaBlendFilter(float mix) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageBilateralBlurFilter.java
class GPUImageBilateralBlurFilter (line 11) | public class GPUImageBilateralBlurFilter extends GPUImageFilter {
method GPUImageBilateralBlurFilter (line 117) | public GPUImageBilateralBlurFilter() {
method GPUImageBilateralBlurFilter (line 121) | public GPUImageBilateralBlurFilter(final float distanceNormalizationFa...
method onInit (line 126) | @Override
method onInitialized (line 133) | @Override
method setDistanceNormalizationFactor (line 139) | public void setDistanceNormalizationFactor(final float newValue) {
method setTexelSize (line 144) | private void setTexelSize(final float w, final float h) {
method onOutputSizeChanged (line 148) | @Override
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageBoxBlurFilter.java
class GPUImageBoxBlurFilter (line 24) | public class GPUImageBoxBlurFilter extends GPUImageTwoPassTextureSamplin...
method GPUImageBoxBlurFilter (line 79) | public GPUImageBoxBlurFilter() {
method GPUImageBoxBlurFilter (line 84) | public GPUImageBoxBlurFilter(float blurSize) {
method onInitialized (line 89) | @Override
method setBlurSize (line 100) | public void setBlurSize(float blurSize) {
method getVerticalTexelOffsetRatio (line 110) | @Override
method getHorizontalTexelOffsetRatio (line 115) | @Override
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageBrightnessFilter.java
class GPUImageBrightnessFilter (line 24) | public class GPUImageBrightnessFilter extends GPUImageFilter {
method GPUImageBrightnessFilter (line 41) | public GPUImageBrightnessFilter() {
method GPUImageBrightnessFilter (line 45) | public GPUImageBrightnessFilter(final float brightness) {
method onInit (line 50) | @Override
method onInitialized (line 56) | @Override
method setBrightness (line 62) | public void setBrightness(final float brightness) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageBulgeDistortionFilter.java
class GPUImageBulgeDistortionFilter (line 22) | public class GPUImageBulgeDistortionFilter extends GPUImageFilter {
method GPUImageBulgeDistortionFilter (line 61) | public GPUImageBulgeDistortionFilter() {
method GPUImageBulgeDistortionFilter (line 65) | public GPUImageBulgeDistortionFilter(float radius, float scale, PointF...
method onInit (line 72) | @Override
method onInitialized (line 81) | @Override
method onOutputSizeChanged (line 90) | @Override
method setAspectRatio (line 97) | private void setAspectRatio(float aspectRatio) {
method setRadius (line 107) | public void setRadius(float radius) {
method setScale (line 117) | public void setScale(float scale) {
method setCenter (line 127) | public void setCenter(PointF center) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageCGAColorspaceFilter.java
class GPUImageCGAColorspaceFilter (line 19) | public class GPUImageCGAColorspaceFilter extends GPUImageFilter {
method GPUImageCGAColorspaceFilter (line 64) | public GPUImageCGAColorspaceFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageChromaKeyBlendFilter.java
class GPUImageChromaKeyBlendFilter (line 24) | public class GPUImageChromaKeyBlendFilter extends GPUImageTwoInputFilter {
method GPUImageChromaKeyBlendFilter (line 60) | public GPUImageChromaKeyBlendFilter() {
method onInit (line 65) | @Override
method onInitialized (line 73) | @Override
method setSmoothing (line 85) | public void setSmoothing(final float smoothing) {
method setThresholdSensitivity (line 94) | public void setThresholdSensitivity(final float thresholdSensitivity) {
method setColorToReplace (line 107) | public void setColorToReplace(float redComponent, float greenComponent...
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageColorBalanceFilter.java
class GPUImageColorBalanceFilter (line 8) | public class GPUImageColorBalanceFilter extends GPUImageFilter {
method GPUImageColorBalanceFilter (line 152) | public GPUImageColorBalanceFilter() {
method onInit (line 160) | @Override
method onInitialized (line 169) | @Override
method setShowdows (line 178) | public void setShowdows(float[] showdows) {
method setMidtones (line 183) | public void setMidtones(float[] midtones) {
method setHighlights (line 188) | public void setHighlights(float[] highlights) {
method setPreserveLuminosity (line 193) | public void setPreserveLuminosity(boolean preserveLuminosity) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageColorBlendFilter.java
class GPUImageColorBlendFilter (line 19) | public class GPUImageColorBlendFilter extends GPUImageTwoInputFilter {
method GPUImageColorBlendFilter (line 63) | public GPUImageColorBlendFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageColorBurnBlendFilter.java
class GPUImageColorBurnBlendFilter (line 19) | public class GPUImageColorBurnBlendFilter extends GPUImageTwoInputFilter {
method GPUImageColorBurnBlendFilter (line 34) | public GPUImageColorBurnBlendFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageColorDodgeBlendFilter.java
class GPUImageColorDodgeBlendFilter (line 19) | public class GPUImageColorDodgeBlendFilter extends GPUImageTwoInputFilter {
method GPUImageColorDodgeBlendFilter (line 46) | public GPUImageColorDodgeBlendFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageColorInvertFilter.java
class GPUImageColorInvertFilter (line 22) | public class GPUImageColorInvertFilter extends GPUImageFilter {
method GPUImageColorInvertFilter (line 35) | public GPUImageColorInvertFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageColorMatrixFilter.java
class GPUImageColorMatrixFilter (line 24) | public class GPUImageColorMatrixFilter extends GPUImageFilter {
method GPUImageColorMatrixFilter (line 46) | public GPUImageColorMatrixFilter() {
method GPUImageColorMatrixFilter (line 55) | public GPUImageColorMatrixFilter(final float intensity, final float[] ...
method onInit (line 61) | @Override
method onInitialized (line 68) | @Override
method setIntensity (line 75) | public void setIntensity(final float intensity) {
method setColorMatrix (line 80) | public void setColorMatrix(final float[] colorMatrix) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageContrastFilter.java
class GPUImageContrastFilter (line 26) | public class GPUImageContrastFilter extends GPUImageFilter {
method GPUImageContrastFilter (line 43) | public GPUImageContrastFilter() {
method GPUImageContrastFilter (line 47) | public GPUImageContrastFilter(float contrast) {
method onInit (line 52) | @Override
method onInitialized (line 58) | @Override
method setContrast (line 64) | public void setContrast(final float contrast) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageCrosshatchFilter.java
class GPUImageCrosshatchFilter (line 25) | public class GPUImageCrosshatchFilter extends GPUImageFilter {
method GPUImageCrosshatchFilter (line 75) | public GPUImageCrosshatchFilter() {
method GPUImageCrosshatchFilter (line 79) | public GPUImageCrosshatchFilter(float crossHatchSpacing, float lineWid...
method onInit (line 85) | @Override
method onInitialized (line 92) | @Override
method setCrossHatchSpacing (line 104) | public void setCrossHatchSpacing(final float crossHatchSpacing) {
method setLineWidth (line 126) | public void setLineWidth(final float lineWidth) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageDarkenBlendFilter.java
class GPUImageDarkenBlendFilter (line 19) | public class GPUImageDarkenBlendFilter extends GPUImageTwoInputFilter {
method GPUImageDarkenBlendFilter (line 34) | public GPUImageDarkenBlendFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageDifferenceBlendFilter.java
class GPUImageDifferenceBlendFilter (line 19) | public class GPUImageDifferenceBlendFilter extends GPUImageTwoInputFilter {
method GPUImageDifferenceBlendFilter (line 33) | public GPUImageDifferenceBlendFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageDilationFilter.java
class GPUImageDilationFilter (line 24) | public class GPUImageDilationFilter extends GPUImageTwoPassTextureSampli...
method GPUImageDilationFilter (line 260) | public GPUImageDilationFilter() {
method GPUImageDilationFilter (line 270) | public GPUImageDilationFilter(int radius) {
method GPUImageDilationFilter (line 274) | private GPUImageDilationFilter(String vertexShader, String fragmentSha...
method getVertexShader (line 278) | private static String getVertexShader(int radius) {
method getFragmentShader (line 292) | private static String getFragmentShader(int radius) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageDirectionalSobelEdgeDetectionFilter.java
class GPUImageDirectionalSobelEdgeDetectionFilter (line 20) | public class GPUImageDirectionalSobelEdgeDetectionFilter extends GPUImag...
method GPUImageDirectionalSobelEdgeDetectionFilter (line 61) | public GPUImageDirectionalSobelEdgeDetectionFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageDissolveBlendFilter.java
class GPUImageDissolveBlendFilter (line 22) | public class GPUImageDissolveBlendFilter extends GPUImageMixBlendFilter {
method GPUImageDissolveBlendFilter (line 38) | public GPUImageDissolveBlendFilter() {
method GPUImageDissolveBlendFilter (line 42) | public GPUImageDissolveBlendFilter(float mix) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageDivideBlendFilter.java
class GPUImageDivideBlendFilter (line 19) | public class GPUImageDivideBlendFilter extends GPUImageTwoInputFilter {
method GPUImageDivideBlendFilter (line 56) | public GPUImageDivideBlendFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageEmbossFilter.java
class GPUImageEmbossFilter (line 24) | public class GPUImageEmbossFilter extends GPUImage3x3ConvolutionFilter {
method GPUImageEmbossFilter (line 27) | public GPUImageEmbossFilter() {
method GPUImageEmbossFilter (line 31) | public GPUImageEmbossFilter(final float intensity) {
method onInit (line 36) | @Override
method onInitialized (line 41) | @Override
method setIntensity (line 47) | public void setIntensity(final float intensity) {
method getIntensity (line 56) | public float getIntensity() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageExclusionBlendFilter.java
class GPUImageExclusionBlendFilter (line 19) | public class GPUImageExclusionBlendFilter extends GPUImageTwoInputFilter {
method GPUImageExclusionBlendFilter (line 36) | public GPUImageExclusionBlendFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageExposureFilter.java
class GPUImageExposureFilter (line 24) | public class GPUImageExposureFilter extends GPUImageFilter {
method GPUImageExposureFilter (line 41) | public GPUImageExposureFilter() {
method GPUImageExposureFilter (line 45) | public GPUImageExposureFilter(final float exposure) {
method onInit (line 50) | @Override
method onInitialized (line 56) | @Override
method setExposure (line 62) | public void setExposure(final float exposure) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageFalseColorFilter.java
class GPUImageFalseColorFilter (line 21) | public class GPUImageFalseColorFilter extends GPUImageFilter {
method GPUImageFalseColorFilter (line 47) | public GPUImageFalseColorFilter() {
method GPUImageFalseColorFilter (line 51) | public GPUImageFalseColorFilter(float firstRed, float firstGreen, floa...
method GPUImageFalseColorFilter (line 55) | public GPUImageFalseColorFilter(float[] firstColor, float[] secondColo...
method onInit (line 61) | @Override
method onInitialized (line 68) | @Override
method setFirstColor (line 75) | public void setFirstColor(final float[] firstColor) {
method setSecondColor (line 80) | public void setSecondColor(final float[] secondColor) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageFilter.java
class GPUImageFilter (line 30) | public class GPUImageFilter {
method GPUImageFilter (line 63) | public GPUImageFilter() {
method GPUImageFilter (line 67) | public GPUImageFilter(final String vertexShader, final String fragment...
method init (line 73) | private final void init() {
method onInit (line 78) | public void onInit() {
method onInitialized (line 86) | public void onInitialized() {
method ifNeedInit (line 89) | public void ifNeedInit() {
method destroy (line 93) | public final void destroy() {
method onDestroy (line 99) | public void onDestroy() {
method onOutputSizeChanged (line 102) | public void onOutputSizeChanged(final int width, final int height) {
method onDraw (line 107) | public void onDraw(final int textureId, final FloatBuffer cubeBuffer,
method onDrawArraysPre (line 134) | protected void onDrawArraysPre() {
method runPendingOnDrawTasks (line 137) | protected void runPendingOnDrawTasks() {
method isInitialized (line 145) | public boolean isInitialized() {
method getOutputWidth (line 149) | public int getOutputWidth() {
method getOutputHeight (line 153) | public int getOutputHeight() {
method getProgram (line 157) | public int getProgram() {
method getAttribPosition (line 161) | public int getAttribPosition() {
method getAttribTextureCoordinate (line 165) | public int getAttribTextureCoordinate() {
method getUniformTexture (line 169) | public int getUniformTexture() {
method setInteger (line 173) | protected void setInteger(final int location, final int intValue) {
method setFloat (line 183) | protected void setFloat(final int location, final float floatValue) {
method setFloatVec2 (line 193) | protected void setFloatVec2(final int location, final float[] arrayVal...
method setFloatVec3 (line 203) | protected void setFloatVec3(final int location, final float[] arrayVal...
method setFloatVec4 (line 213) | protected void setFloatVec4(final int location, final float[] arrayVal...
method setFloatArray (line 223) | protected void setFloatArray(final int location, final float[] arrayVa...
method setPoint (line 233) | protected void setPoint(final int location, final PointF point) {
method setUniformMatrix3f (line 246) | protected void setUniformMatrix3f(final int location, final float[] ma...
method setUniformMatrix4f (line 257) | protected void setUniformMatrix4f(final int location, final float[] ma...
method runOnDraw (line 268) | protected void runOnDraw(final Runnable runnable) {
method loadShader (line 274) | public static String loadShader(String file, Context context) {
method convertStreamToString (line 289) | public static String convertStreamToString(java.io.InputStream is) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageFilterGroup.java
class GPUImageFilterGroup (line 38) | public class GPUImageFilterGroup extends GPUImageFilter {
method GPUImageFilterGroup (line 52) | public GPUImageFilterGroup() {
method GPUImageFilterGroup (line 61) | public GPUImageFilterGroup(List<GPUImageFilter> filters) {
method addFilter (line 86) | public void addFilter(GPUImageFilter aFilter) {
method onInit (line 98) | @Override
method onDestroy (line 110) | @Override
method destroyFramebuffers (line 119) | private void destroyFramebuffers() {
method onOutputSizeChanged (line 136) | @Override
method onDraw (line 183) | @SuppressLint("WrongCall")
method getFilters (line 223) | public List<GPUImageFilter> getFilters() {
method getMergedFilters (line 227) | public List<GPUImageFilter> getMergedFilters() {
method updateMergedFilters (line 231) | public void updateMergedFilters() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageGammaFilter.java
class GPUImageGammaFilter (line 24) | public class GPUImageGammaFilter extends GPUImageFilter {
method GPUImageGammaFilter (line 41) | public GPUImageGammaFilter() {
method GPUImageGammaFilter (line 45) | public GPUImageGammaFilter(final float gamma) {
method onInit (line 50) | @Override
method onInitialized (line 56) | @Override
method setGamma (line 62) | public void setGamma(final float gamma) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageGaussianBlurFilter.java
class GPUImageGaussianBlurFilter (line 23) | public class GPUImageGaussianBlurFilter extends GPUImageTwoPassTextureSa...
method GPUImageGaussianBlurFilter (line 83) | public GPUImageGaussianBlurFilter() {
method GPUImageGaussianBlurFilter (line 87) | public GPUImageGaussianBlurFilter(float blurSize) {
method onInitialized (line 92) | @Override
method getVerticalTexelOffsetRatio (line 98) | @Override
method getHorizontalTexelOffsetRatio (line 103) | @Override
method setBlurSize (line 113) | public void setBlurSize(float blurSize) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageGlassSphereFilter.java
class GPUImageGlassSphereFilter (line 22) | public class GPUImageGlassSphereFilter extends GPUImageFilter {
method GPUImageGlassSphereFilter (line 73) | public GPUImageGlassSphereFilter() {
method GPUImageGlassSphereFilter (line 77) | public GPUImageGlassSphereFilter(PointF center, float radius, float re...
method onInit (line 84) | @Override
method onInitialized (line 93) | @Override
method onOutputSizeChanged (line 102) | @Override
method setAspectRatio (line 109) | private void setAspectRatio(float aspectRatio) {
method setRefractiveIndex (line 114) | public void setRefractiveIndex(float refractiveIndex) {
method setCenter (line 119) | public void setCenter(PointF center) {
method setRadius (line 124) | public void setRadius(float radius) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageGrayscaleFilter.java
class GPUImageGrayscaleFilter (line 22) | public class GPUImageGrayscaleFilter extends GPUImageFilter {
method GPUImageGrayscaleFilter (line 40) | public GPUImageGrayscaleFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageHalftoneFilter.java
class GPUImageHalftoneFilter (line 5) | public class GPUImageHalftoneFilter extends GPUImageFilter {
method GPUImageHalftoneFilter (line 35) | public GPUImageHalftoneFilter() {
method GPUImageHalftoneFilter (line 39) | public GPUImageHalftoneFilter(float fractionalWidthOfAPixel) {
method onInit (line 44) | @Override
method onInitialized (line 51) | @Override
method onOutputSizeChanged (line 58) | @Override
method setFractionalWidthOfAPixel (line 64) | public void setFractionalWidthOfAPixel(final float fractionalWidthOfAP...
method setAspectRatio (line 69) | public void setAspectRatio(final float aspectRatio) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageHardLightBlendFilter.java
class GPUImageHardLightBlendFilter (line 19) | public class GPUImageHardLightBlendFilter extends GPUImageTwoInputFilter {
method GPUImageHardLightBlendFilter (line 57) | public GPUImageHardLightBlendFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageHazeFilter.java
class GPUImageHazeFilter (line 26) | public class GPUImageHazeFilter extends GPUImageFilter {
method GPUImageHazeFilter (line 54) | public GPUImageHazeFilter() {
method GPUImageHazeFilter (line 58) | public GPUImageHazeFilter(float distance, float slope) {
method onInit (line 64) | @Override
method onInitialized (line 71) | @Override
method setDistance (line 83) | public void setDistance(float distance) {
method setSlope (line 93) | public void setSlope(float slope) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageHighlightShadowFilter.java
class GPUImageHighlightShadowFilter (line 26) | public class GPUImageHighlightShadowFilter extends GPUImageFilter {
method GPUImageHighlightShadowFilter (line 53) | public GPUImageHighlightShadowFilter() {
method GPUImageHighlightShadowFilter (line 57) | public GPUImageHighlightShadowFilter(final float shadows, final float ...
method onInit (line 63) | @Override
method onInitialized (line 70) | @Override
method setHighlights (line 77) | public void setHighlights(final float highlights) {
method setShadows (line 82) | public void setShadows(final float shadows) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageHueBlendFilter.java
class GPUImageHueBlendFilter (line 19) | public class GPUImageHueBlendFilter extends GPUImageTwoInputFilter {
method GPUImageHueBlendFilter (line 113) | public GPUImageHueBlendFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageHueFilter.java
class GPUImageHueFilter (line 21) | public class GPUImageHueFilter extends GPUImageFilter {
method GPUImageHueFilter (line 70) | public GPUImageHueFilter() {
method GPUImageHueFilter (line 74) | public GPUImageHueFilter(final float hue) {
method onInit (line 79) | @Override
method onInitialized (line 85) | @Override
method setHue (line 91) | public void setHue(final float hue) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageKuwaharaFilter.java
class GPUImageKuwaharaFilter (line 27) | public class GPUImageKuwaharaFilter extends GPUImageFilter {
method GPUImageKuwaharaFilter (line 120) | public GPUImageKuwaharaFilter() {
method GPUImageKuwaharaFilter (line 124) | public GPUImageKuwaharaFilter(int radius) {
method onInit (line 129) | @Override
method onInitialized (line 135) | @Override
method setRadius (line 147) | public void setRadius(final int radius) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageLaplacianFilter.java
class GPUImageLaplacianFilter (line 21) | public class GPUImageLaplacianFilter extends GPUImage3x3TextureSamplingF...
method GPUImageLaplacianFilter (line 66) | public GPUImageLaplacianFilter() {
method GPUImageLaplacianFilter (line 74) | private GPUImageLaplacianFilter(final float[] convolutionKernel) {
method onInit (line 79) | @Override
method onInitialized (line 85) | @Override
method setConvolutionKernel (line 91) | private void setConvolutionKernel(final float[] convolutionKernel) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageLevelsFilter.java
class GPUImageLevelsFilter (line 8) | public class GPUImageLevelsFilter extends GPUImageFilter {
method GPUImageLevelsFilter (line 41) | public GPUImageLevelsFilter() {
method GPUImageLevelsFilter (line 45) | private GPUImageLevelsFilter(final float[] min, final float[] mid, fin...
method onInit (line 55) | @Override
method onInitialized (line 65) | @Override
method updateUniforms (line 73) | public void updateUniforms() {
method setMin (line 81) | public void setMin(float min, float mid, float max, float minOut, floa...
method setMin (line 87) | public void setMin(float min, float mid, float max) {
method setRedMin (line 91) | public void setRedMin(float min, float mid, float max, float minOut, f...
method setRedMin (line 100) | public void setRedMin(float min, float mid, float max) {
method setGreenMin (line 104) | public void setGreenMin(float min, float mid, float max, float minOut,...
method setGreenMin (line 113) | public void setGreenMin(float min, float mid, float max) {
method setBlueMin (line 117) | public void setBlueMin(float min, float mid, float max, float minOut, ...
method setBlueMin (line 126) | public void setBlueMin(float min, float mid, float max) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageLightenBlendFilter.java
class GPUImageLightenBlendFilter (line 19) | public class GPUImageLightenBlendFilter extends GPUImageTwoInputFilter {
method GPUImageLightenBlendFilter (line 34) | public GPUImageLightenBlendFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageLinearBurnBlendFilter.java
class GPUImageLinearBurnBlendFilter (line 19) | public class GPUImageLinearBurnBlendFilter extends GPUImageTwoInputFilter {
method GPUImageLinearBurnBlendFilter (line 34) | public GPUImageLinearBurnBlendFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageLookupFilter.java
class GPUImageLookupFilter (line 21) | public class GPUImageLookupFilter extends GPUImageTwoInputFilter {
method GPUImageLookupFilter (line 63) | public GPUImageLookupFilter() {
method GPUImageLookupFilter (line 67) | public GPUImageLookupFilter(final float intensity) {
method onInit (line 72) | @Override
method onInitialized (line 78) | @Override
method setIntensity (line 84) | public void setIntensity(final float intensity) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageLuminanceFilter.java
class GPUImageLuminanceFilter (line 19) | public class GPUImageLuminanceFilter extends GPUImageFilter {
method GPUImageLuminanceFilter (line 39) | public GPUImageLuminanceFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageLuminanceThresholdFilter.java
class GPUImageLuminanceThresholdFilter (line 21) | public class GPUImageLuminanceThresholdFilter extends GPUImageFilter {
method GPUImageLuminanceThresholdFilter (line 43) | public GPUImageLuminanceThresholdFilter() {
method GPUImageLuminanceThresholdFilter (line 47) | public GPUImageLuminanceThresholdFilter(float threshold) {
method onInit (line 52) | @Override
method onInitialized (line 58) | @Override
method setThreshold (line 64) | public void setThreshold(final float threshold) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageLuminosityBlendFilter.java
class GPUImageLuminosityBlendFilter (line 19) | public class GPUImageLuminosityBlendFilter extends GPUImageTwoInputFilter {
method GPUImageLuminosityBlendFilter (line 63) | public GPUImageLuminosityBlendFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageMixBlendFilter.java
class GPUImageMixBlendFilter (line 21) | public class GPUImageMixBlendFilter extends GPUImageTwoInputFilter {
method GPUImageMixBlendFilter (line 26) | public GPUImageMixBlendFilter(String fragmentShader) {
method GPUImageMixBlendFilter (line 30) | public GPUImageMixBlendFilter(String fragmentShader, float mix) {
method onInit (line 35) | @Override
method onInitialized (line 41) | @Override
method setMix (line 50) | public void setMix(final float mix) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageMonochromeFilter.java
class GPUImageMonochromeFilter (line 26) | public class GPUImageMonochromeFilter extends GPUImageFilter {
method GPUImageMonochromeFilter (line 63) | public GPUImageMonochromeFilter() {
method GPUImageMonochromeFilter (line 67) | public GPUImageMonochromeFilter(final float intensity, final float[] c...
method onInit (line 73) | @Override
method onInitialized (line 80) | @Override
method setIntensity (line 87) | public void setIntensity(final float intensity) {
method setColor (line 92) | public void setColor(final float[] color) {
method setColor (line 98) | public void setColor(final float red, final float green, final float b...
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageMultiplyBlendFilter.java
class GPUImageMultiplyBlendFilter (line 19) | public class GPUImageMultiplyBlendFilter extends GPUImageTwoInputFilter {
method GPUImageMultiplyBlendFilter (line 34) | public GPUImageMultiplyBlendFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageNonMaximumSuppressionFilter.java
class GPUImageNonMaximumSuppressionFilter (line 19) | public class GPUImageNonMaximumSuppressionFilter extends GPUImage3x3Text...
method GPUImageNonMaximumSuppressionFilter (line 61) | public GPUImageNonMaximumSuppressionFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageNormalBlendFilter.java
class GPUImageNormalBlendFilter (line 33) | public class GPUImageNormalBlendFilter extends GPUImageTwoInputFilter {
method GPUImageNormalBlendFilter (line 58) | public GPUImageNormalBlendFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageOpacityFilter.java
class GPUImageOpacityFilter (line 25) | public class GPUImageOpacityFilter extends GPUImageFilter {
method GPUImageOpacityFilter (line 42) | public GPUImageOpacityFilter() {
method GPUImageOpacityFilter (line 46) | public GPUImageOpacityFilter(final float opacity) {
method onInit (line 51) | @Override
method onInitialized (line 57) | @Override
method setOpacity (line 63) | public void setOpacity(final float opacity) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageOverlayBlendFilter.java
class GPUImageOverlayBlendFilter (line 19) | public class GPUImageOverlayBlendFilter extends GPUImageTwoInputFilter {
method GPUImageOverlayBlendFilter (line 55) | public GPUImageOverlayBlendFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImagePixelationFilter.java
class GPUImagePixelationFilter (line 24) | public class GPUImagePixelationFilter extends GPUImageFilter {
method GPUImagePixelationFilter (line 50) | public GPUImagePixelationFilter() {
method onInit (line 55) | @Override
method onInitialized (line 63) | @Override
method onOutputSizeChanged (line 69) | @Override
method setPixel (line 76) | public void setPixel(final float pixel) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImagePosterizeFilter.java
class GPUImagePosterizeFilter (line 26) | public class GPUImagePosterizeFilter extends GPUImageFilter {
method GPUImagePosterizeFilter (line 43) | public GPUImagePosterizeFilter() {
method GPUImagePosterizeFilter (line 47) | public GPUImagePosterizeFilter(final int colorLevels) {
method onInit (line 52) | @Override
method onInitialized (line 58) | @Override
method setColorLevels (line 64) | public void setColorLevels(final int colorLevels) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageRGBDilationFilter.java
class GPUImageRGBDilationFilter (line 24) | public class GPUImageRGBDilationFilter extends GPUImageTwoPassTextureSam...
method GPUImageRGBDilationFilter (line 256) | public GPUImageRGBDilationFilter() {
method GPUImageRGBDilationFilter (line 266) | public GPUImageRGBDilationFilter(int radius) {
method GPUImageRGBDilationFilter (line 270) | private GPUImageRGBDilationFilter(String vertexShader, String fragment...
method getVertexShader (line 274) | private static String getVertexShader(int radius) {
method getFragmentShader (line 288) | private static String getFragmentShader(int radius) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageRGBFilter.java
class GPUImageRGBFilter (line 27) | public class GPUImageRGBFilter extends GPUImageFilter {
method GPUImageRGBFilter (line 50) | public GPUImageRGBFilter() {
method GPUImageRGBFilter (line 54) | public GPUImageRGBFilter(final float red, final float green, final flo...
method onInit (line 61) | @Override
method onInitialized (line 69) | @Override
method setRed (line 77) | public void setRed(final float red) {
method setGreen (line 82) | public void setGreen(final float green) {
method setBlue (line 87) | public void setBlue(final float blue) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSaturationBlendFilter.java
class GPUImageSaturationBlendFilter (line 19) | public class GPUImageSaturationBlendFilter extends GPUImageTwoInputFilter {
method GPUImageSaturationBlendFilter (line 113) | public GPUImageSaturationBlendFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSaturationFilter.java
class GPUImageSaturationFilter (line 24) | public class GPUImageSaturationFilter extends GPUImageFilter {
method GPUImageSaturationFilter (line 47) | public GPUImageSaturationFilter() {
method GPUImageSaturationFilter (line 51) | public GPUImageSaturationFilter(final float saturation) {
method onInit (line 56) | @Override
method onInitialized (line 62) | @Override
method setSaturation (line 68) | public void setSaturation(final float saturation) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageScreenBlendFilter.java
class GPUImageScreenBlendFilter (line 19) | public class GPUImageScreenBlendFilter extends GPUImageTwoInputFilter {
method GPUImageScreenBlendFilter (line 34) | public GPUImageScreenBlendFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSepiaToneFilter.java
class GPUImageSepiaToneFilter (line 22) | public class GPUImageSepiaToneFilter extends GPUImageColorMatrixFilter {
method GPUImageSepiaToneFilter (line 24) | public GPUImageSepiaToneFilter() {
method GPUImageSepiaToneFilter (line 28) | public GPUImageSepiaToneFilter(final float intensity) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSharpenFilter.java
class GPUImageSharpenFilter (line 26) | public class GPUImageSharpenFilter extends GPUImageFilter {
method GPUImageSharpenFilter (line 91) | public GPUImageSharpenFilter() {
method GPUImageSharpenFilter (line 95) | public GPUImageSharpenFilter(final float sharpness) {
method onInit (line 100) | @Override
method onInitialized (line 108) | @Override
method onOutputSizeChanged (line 114) | @Override
method setSharpness (line 121) | public void setSharpness(final float sharpness) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSketchFilter.java
class GPUImageSketchFilter (line 23) | public class GPUImageSketchFilter extends GPUImageFilterGroup {
method GPUImageSketchFilter (line 59) | public GPUImageSketchFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSmoothToonFilter.java
class GPUImageSmoothToonFilter (line 23) | public class GPUImageSmoothToonFilter extends GPUImageFilterGroup {
method GPUImageSmoothToonFilter (line 31) | public GPUImageSmoothToonFilter() {
method onInitialized (line 43) | @Override
method setTexelWidth (line 54) | public void setTexelWidth(float value) {
method setTexelHeight (line 58) | public void setTexelHeight(float value) {
method setBlurSize (line 62) | public void setBlurSize(float value) {
method setThreshold (line 66) | public void setThreshold(float value) {
method setQuantizationLevels (line 70) | public void setQuantizationLevels(float value) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSobelEdgeDetectionFilter.java
class GPUImageSobelEdgeDetectionFilter (line 22) | public class GPUImageSobelEdgeDetectionFilter extends GPUImageFilterGroup {
method GPUImageSobelEdgeDetectionFilter (line 58) | public GPUImageSobelEdgeDetectionFilter() {
method setLineSize (line 64) | public void setLineSize(final float size) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSobelThresholdFilter.java
class GPUImageSobelThresholdFilter (line 5) | public class GPUImageSobelThresholdFilter extends
method GPUImageSobelThresholdFilter (line 49) | public GPUImageSobelThresholdFilter() {
method GPUImageSobelThresholdFilter (line 53) | public GPUImageSobelThresholdFilter(float threshold) {
method onInit (line 58) | @Override
method onInitialized (line 64) | @Override
method setThreshold (line 70) | public void setThreshold(final float threshold) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSoftLightBlendFilter.java
class GPUImageSoftLightBlendFilter (line 19) | public class GPUImageSoftLightBlendFilter extends GPUImageTwoInputFilter {
method GPUImageSoftLightBlendFilter (line 34) | public GPUImageSoftLightBlendFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSolarizeFilter.java
class GPUImageSolarizeFilter (line 5) | public class GPUImageSolarizeFilter extends GPUImageFilter {
method GPUImageSolarizeFilter (line 27) | public GPUImageSolarizeFilter() {
method GPUImageSolarizeFilter (line 31) | public GPUImageSolarizeFilter(float threshold) {
method onInit (line 36) | @Override
method onInitialized (line 42) | @Override
method setThreshold (line 48) | public void setThreshold(final float threshold) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSourceOverBlendFilter.java
class GPUImageSourceOverBlendFilter (line 19) | public class GPUImageSourceOverBlendFilter extends GPUImageTwoInputFilter {
method GPUImageSourceOverBlendFilter (line 34) | public GPUImageSourceOverBlendFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSphereRefractionFilter.java
class GPUImageSphereRefractionFilter (line 22) | public class GPUImageSphereRefractionFilter extends GPUImageFilter {
method GPUImageSphereRefractionFilter (line 58) | public GPUImageSphereRefractionFilter() {
method GPUImageSphereRefractionFilter (line 62) | public GPUImageSphereRefractionFilter(PointF center, float radius, flo...
method onInit (line 69) | @Override
method onInitialized (line 78) | @Override
method onOutputSizeChanged (line 87) | @Override
method setAspectRatio (line 94) | private void setAspectRatio(float aspectRatio) {
method setRefractiveIndex (line 104) | public void setRefractiveIndex(float refractiveIndex) {
method setCenter (line 114) | public void setCenter(PointF center) {
method setRadius (line 124) | public void setRadius(float radius) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSubtractBlendFilter.java
class GPUImageSubtractBlendFilter (line 19) | public class GPUImageSubtractBlendFilter extends GPUImageTwoInputFilter {
method GPUImageSubtractBlendFilter (line 34) | public GPUImageSubtractBlendFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSwirlFilter.java
class GPUImageSwirlFilter (line 25) | public class GPUImageSwirlFilter extends GPUImageFilter {
method GPUImageSwirlFilter (line 61) | public GPUImageSwirlFilter() {
method GPUImageSwirlFilter (line 65) | public GPUImageSwirlFilter(float radius, float angle, PointF center) {
method onInit (line 72) | @Override
method onInitialized (line 80) | @Override
method setRadius (line 93) | public void setRadius(float radius) {
method setAngle (line 103) | public void setAngle(float angle) {
method setCenter (line 113) | public void setCenter(PointF center) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageThresholdEdgeDetectionFilter.java
class GPUImageThresholdEdgeDetectionFilter (line 6) | public class GPUImageThresholdEdgeDetectionFilter extends GPUImageFilter...
method GPUImageThresholdEdgeDetectionFilter (line 7) | public GPUImageThresholdEdgeDetectionFilter() {
method setLineSize (line 13) | public void setLineSize(final float size) {
method setThreshold (line 17) | public void setThreshold(final float threshold) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageToneCurveFilter.java
class GPUImageToneCurveFilter (line 32) | public class GPUImageToneCurveFilter extends GPUImageFilter {
method GPUImageToneCurveFilter (line 62) | public GPUImageToneCurveFilter() {
method onInit (line 72) | @Override
method onInitialized (line 85) | @Override
method onDrawArraysPre (line 94) | @Override
method setFromCurveFileInputStream (line 103) | public void setFromCurveFileInputStream(InputStream input) {
method readShort (line 141) | private short readShort(InputStream input) throws IOException {
method setRgbCompositeControlPoints (line 145) | public void setRgbCompositeControlPoints(PointF[] points) {
method setRedControlPoints (line 151) | public void setRedControlPoints(PointF[] points) {
method setGreenControlPoints (line 157) | public void setGreenControlPoints(PointF[] points) {
method setBlueControlPoints (line 163) | public void setBlueControlPoints(PointF[] points) {
method updateToneCurveTexture (line 169) | private void updateToneCurveTexture() {
method createSplineCurve (line 202) | private ArrayList<Float> createSplineCurve(PointF[] points) {
method createSplineCurve2 (line 265) | private ArrayList<Point> createSplineCurve2(Point[] points) {
method createSecondDerivative (line 314) | private ArrayList<Double> createSecondDerivative(Point[] points) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageToonFilter.java
class GPUImageToonFilter (line 25) | public class GPUImageToonFilter extends GPUImage3x3TextureSamplingFilter {
method GPUImageToonFilter (line 78) | public GPUImageToonFilter() {
method GPUImageToonFilter (line 82) | public GPUImageToonFilter(float threshold, float quantizationLevels) {
method onInit (line 88) | @Override
method onInitialized (line 95) | @Override
method setThreshold (line 107) | public void setThreshold(final float threshold) {
method setQuantizationLevels (line 117) | public void setQuantizationLevels(final float quantizationLevels) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageTransformFilter.java
class GPUImageTransformFilter (line 26) | public class GPUImageTransformFilter extends GPUImageFilter {
method GPUImageTransformFilter (line 54) | public GPUImageTransformFilter() {
method onInit (line 64) | @Override
method onInitialized (line 71) | @Override
method onOutputSizeChanged (line 78) | @Override
method onDraw (line 88) | @Override
method setTransform3D (line 117) | public void setTransform3D(float[] transform3D) {
method getTransform3D (line 122) | public float[] getTransform3D() {
method setIgnoreAspectRatio (line 126) | public void setIgnoreAspectRatio(boolean ignoreAspectRatio) {
method ignoreAspectRatio (line 137) | public boolean ignoreAspectRatio() {
method setAnchorTopLeft (line 141) | public void setAnchorTopLeft(boolean anchorTopLeft) {
method anchorTopLeft (line 146) | public boolean anchorTopLeft() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageTwoInputFilter.java
class GPUImageTwoInputFilter (line 30) | public class GPUImageTwoInputFilter extends GPUImageFilter {
method GPUImageTwoInputFilter (line 51) | public GPUImageTwoInputFilter(String fragmentShader) {
method GPUImageTwoInputFilter (line 55) | public GPUImageTwoInputFilter(String vertexShader, String fragmentShad...
method onInit (line 60) | @Override
method onInitialized (line 69) | @Override
method setBitmap (line 77) | public void setBitmap(final Bitmap bitmap) {
method getBitmap (line 98) | public Bitmap getBitmap() {
method recycleBitmap (line 102) | public void recycleBitmap() {
method onDestroy (line 109) | public void onDestroy() {
method onDrawArraysPre (line 117) | @Override
method setRotation (line 128) | public void setRotation(final Rotation rotation, final boolean flipHor...
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageTwoPassFilter.java
class GPUImageTwoPassFilter (line 19) | public class GPUImageTwoPassFilter extends GPUImageFilterGroup {
method GPUImageTwoPassFilter (line 20) | public GPUImageTwoPassFilter(String firstVertexShader, String firstFra...
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageTwoPassTextureSamplingFilter.java
class GPUImageTwoPassTextureSamplingFilter (line 21) | public class GPUImageTwoPassTextureSamplingFilter extends GPUImageTwoPas...
method GPUImageTwoPassTextureSamplingFilter (line 22) | public GPUImageTwoPassTextureSamplingFilter(String firstVertexShader, ...
method onInit (line 28) | @Override
method initTexelOffsets (line 34) | protected void initTexelOffsets() {
method onOutputSizeChanged (line 50) | @Override
method getVerticalTexelOffsetRatio (line 56) | public float getVerticalTexelOffsetRatio() {
method getHorizontalTexelOffsetRatio (line 60) | public float getHorizontalTexelOffsetRatio() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageVibranceFilter.java
class GPUImageVibranceFilter (line 5) | public class GPUImageVibranceFilter extends GPUImageFilter {
method onInit (line 24) | @Override
method GPUImageVibranceFilter (line 30) | public GPUImageVibranceFilter() {
method GPUImageVibranceFilter (line 34) | public GPUImageVibranceFilter(float vibrance) {
method onInitialized (line 39) | @Override
method setVibrance (line 45) | public void setVibrance(final float vibrance) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageVignetteFilter.java
class GPUImageVignetteFilter (line 27) | public class GPUImageVignetteFilter extends GPUImageFilter {
method GPUImageVignetteFilter (line 61) | public GPUImageVignetteFilter() {
method GPUImageVignetteFilter (line 65) | public GPUImageVignetteFilter(final PointF vignetteCenter, final float...
method onInit (line 74) | @Override
method onInitialized (line 83) | @Override
method setVignetteCenter (line 92) | public void setVignetteCenter(final PointF vignetteCenter) {
method setVignetteColor (line 97) | public void setVignetteColor(final float[] vignetteColor) {
method setVignetteStart (line 102) | public void setVignetteStart(final float vignetteStart) {
method setVignetteEnd (line 107) | public void setVignetteEnd(final float vignetteEnd) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageWeakPixelInclusionFilter.java
class GPUImageWeakPixelInclusionFilter (line 19) | public class GPUImageWeakPixelInclusionFilter extends GPUImage3x3Texture...
method GPUImageWeakPixelInclusionFilter (line 56) | public GPUImageWeakPixelInclusionFilter() {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageWhiteBalanceFilter.java
class GPUImageWhiteBalanceFilter (line 27) | public class GPUImageWhiteBalanceFilter extends GPUImageFilter {
method GPUImageWhiteBalanceFilter (line 61) | public GPUImageWhiteBalanceFilter() {
method GPUImageWhiteBalanceFilter (line 65) | public GPUImageWhiteBalanceFilter(final float temperature, final float...
method onInit (line 71) | @Override
method onInitialized (line 78) | @Override
method setTemperature (line 85) | public void setTemperature(final float temperature) {
method setTint (line 90) | public void setTint(final float tint) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageZoomBlurFilter.java
class GPUImageZoomBlurFilter (line 6) | public class GPUImageZoomBlurFilter extends GPUImageFilter {
method GPUImageZoomBlurFilter (line 38) | public GPUImageZoomBlurFilter() {
method GPUImageZoomBlurFilter (line 42) | public GPUImageZoomBlurFilter(PointF blurCenter, float blurSize) {
method onInit (line 48) | @Override
method onInitialized (line 55) | @Override
method setBlurCenter (line 62) | public void setBlurCenter(final PointF blurCenter) {
method setBlurSize (line 67) | public void setBlurSize(final float blurSize) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/util/OpenGlUtils.java
class OpenGlUtils (line 28) | public class OpenGlUtils {
method loadTexture (line 31) | public static int loadTexture(final Bitmap img, final int usedTexId) {
method loadTexture (line 35) | public static int loadTexture(final Bitmap img, final int usedTexId, f...
method loadTexture (line 61) | public static int loadTexture(final IntBuffer data, final int width, f...
method loadTextureAsBitmap (line 85) | public static int loadTextureAsBitmap(final IntBuffer data, final Size...
method loadShader (line 91) | public static int loadShader(final String strSource, final int iType) {
method loadProgram (line 104) | public static int loadProgram(final String strVSource, final String st...
method rnd (line 137) | public static float rnd(final float min, final float max) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/util/Rotation.java
type Rotation (line 19) | public enum Rotation {
method asInt (line 27) | public int asInt() {
method fromInt (line 48) | public static Rotation fromInt(int rotation) {
FILE: library/src/main/java/jp/co/cyberagent/android/gpuimage/util/TextureRotationUtil.java
class TextureRotationUtil (line 19) | public class TextureRotationUtil {
method TextureRotationUtil (line 47) | private TextureRotationUtil() {
method getRotation (line 50) | public static float[] getRotation(final Rotation rotation, final boole...
method flip (line 88) | private static float flip(final float i) {
Condensed preview — 135 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (601K chars).
[
{
"path": ".github/ISSUE_TEMPLATE.md",
"chars": 351,
"preview": "# Future Task\n\n## What is the motivation?\n\n## What kind of solution can be considered?\n\n## What do you want to discuss?\n"
},
{
"path": ".github/PULL_REQUEST_TEMPLATE.md",
"chars": 102,
"preview": "## What does this change?\n\n## What is the value of this and can you measure success?\n\n## Screenshots\n\n"
},
{
"path": ".gitignore",
"chars": 934,
"preview": "# Mac OS\n.DS_store\n\n# Built application files\n*.apk\n*.ap_\n\n# Files for the ART/Dalvik VM\n*.dex\n\n# Java class files\n*.cla"
},
{
"path": "CHANGELOG.md",
"chars": 2003,
"preview": "Change Log\n==========\n\nVersion 2.1.0 *(2020-09-21)*\n----------------------------\n\n* Update\n * Kotlin to 1.3.72\n * The "
},
{
"path": "CONTRIBUTING.md",
"chars": 1116,
"preview": "# How to Contribute\n\nWe'd love to accept your patches and contributions to this project. There are\njust a few small guid"
},
{
"path": "README.md",
"chars": 7738,
"preview": "# GPUImage for Android\n[](https://www.apache.org/lic"
},
{
"path": "build.gradle",
"chars": 805,
"preview": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n e"
},
{
"path": "gradle/wrapper/gradle-wrapper.properties",
"chars": 200,
"preview": "distributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\ndistributionUrl=https://services.gradle.org/distributio"
},
{
"path": "gradle.properties",
"chars": 1034,
"preview": "# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will override*\n# any settings specified"
},
{
"path": "gradlew",
"chars": 5766,
"preview": "#!/usr/bin/env sh\n\n#\n# Copyright 2015 the original author or authors.\n#\n# Licensed under the Apache License, Version 2.0"
},
{
"path": "gradlew.bat",
"chars": 2763,
"preview": "@rem\r\n@rem Copyright 2015 the original author or authors.\r\n@rem\r\n@rem Licensed under the Apache License, Version 2.0 (th"
},
{
"path": "library/build.gradle",
"chars": 2000,
"preview": "apply plugin: 'com.android.library'\n\nandroid {\n compileSdkVersion COMPILE_SDK_VERSION as int\n\n defaultConfig {\n "
},
{
"path": "library/gradle.properties",
"chars": 88,
"preview": "POM_NAME=GPUImage for Android Library\nPOM_ARTIFACT_ID=gpuimage-library\nPOM_PACKAGING=aar"
},
{
"path": "library/proguard-rules.txt",
"chars": 46,
"preview": "-dontwarn jp.co.cyberagent.android.gpuimage.**"
},
{
"path": "library/src/main/AndroidManifest.xml",
"chars": 95,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest package=\"jp.co.cyberagent.android.gpuimage\" />"
},
{
"path": "library/src/main/cpp/CMakeLists.txt",
"chars": 1626,
"preview": "# For more information about using CMake with Android Studio, read the\n# documentation: https://d.android.com/studio/pro"
},
{
"path": "library/src/main/cpp/yuv-decoder.c",
"chars": 5407,
"preview": "#include <jni.h>\n\n#include <android/bitmap.h>\n#include <GLES2/gl2.h>\n\n\nJNIEXPORT void JNICALL\nJava_jp_co_cyberagent_andr"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/GLTextureView.java",
"chars": 70342,
"preview": "package jp.co.cyberagent.android.gpuimage;\n\nimport android.content.Context;\nimport android.graphics.SurfaceTexture;\nimpo"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/GPUImage.java",
"chars": 27425,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/GPUImageNativeLibrary.java",
"chars": 1018,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/GPUImageRenderer.java",
"chars": 12432,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/GPUImageView.java",
"chars": 19771,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/PixelBuffer.java",
"chars": 6978,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n * Copyright (C) 2010 jsemler\n *\n * Original publication without License\n * ht"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImage3x3ConvolutionFilter.java",
"chars": 4674,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImage3x3TextureSamplingFilter.java",
"chars": 4857,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageAddBlendFilter.java",
"chars": 2603,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageAlphaBlendFilter.java",
"chars": 1840,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageBilateralBlurFilter.java",
"chars": 6903,
"preview": "/**\n * @author wysaid\n * @mail admin@wysaid.org\n */\n\npackage jp.co.cyberagent.android.gpuimage.filter;\n\nimport android.o"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageBoxBlurFilter.java",
"chars": 4736,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageBrightnessFilter.java",
"chars": 2131,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageBulgeDistortionFilter.java",
"chars": 4458,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageCGAColorspaceFilter.java",
"chars": 3009,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageChromaKeyBlendFilter.java",
"chars": 4735,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageColorBalanceFilter.java",
"chars": 7960,
"preview": "package jp.co.cyberagent.android.gpuimage.filter;\n\nimport android.opengl.GLES20;\n\n/**\n * Created by edward_chiang on 13/"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageColorBlendFilter.java",
"chars": 2849,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageColorBurnBlendFilter.java",
"chars": 1574,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageColorDodgeBlendFilter.java",
"chars": 2319,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageColorInvertFilter.java",
"chars": 1370,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageColorMatrixFilter.java",
"chars": 2831,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageContrastFilter.java",
"chars": 2148,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageCrosshatchFilter.java",
"chars": 4777,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageDarkenBlendFilter.java",
"chars": 1578,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageDifferenceBlendFilter.java",
"chars": 1527,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageDilationFilter.java",
"chars": 17033,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageDirectionalSobelEdgeDetectionFilter.java",
"chars": 3580,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageDissolveBlendFilter.java",
"chars": 1798,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageDivideBlendFilter.java",
"chars": 2857,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageEmbossFilter.java",
"chars": 1624,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageExclusionBlendFilter.java",
"chars": 1742,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageExposureFilter.java",
"chars": 2094,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageFalseColorFilter.java",
"chars": 3063,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageFilter.java",
"chars": 8934,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageFilterGroup.java",
"chars": 8759,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageGammaFilter.java",
"chars": 2017,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageGaussianBlurFilter.java",
"chars": 5011,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageGlassSphereFilter.java",
"chars": 5187,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageGrayscaleFilter.java",
"chars": 1554,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageHalftoneFilter.java",
"chars": 3056,
"preview": "package jp.co.cyberagent.android.gpuimage.filter;\n\nimport android.opengl.GLES20;\n\npublic class GPUImageHalftoneFilter ex"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageHardLightBlendFilter.java",
"chars": 2944,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageHazeFilter.java",
"chars": 3086,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageHighlightShadowFilter.java",
"chars": 3365,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageHueBlendFilter.java",
"chars": 5153,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageHueFilter.java",
"chars": 3588,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageKuwaharaFilter.java",
"chars": 5332,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageLaplacianFilter.java",
"chars": 4318,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageLevelsFilter.java",
"chars": 4493,
"preview": "package jp.co.cyberagent.android.gpuimage.filter;\n\nimport android.opengl.GLES20;\n\n/**\n * Created by vashisthg 30/05/14.\n"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageLightenBlendFilter.java",
"chars": 1498,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageLinearBurnBlendFilter.java",
"chars": 1590,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageLookupFilter.java",
"chars": 3498,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageLuminanceFilter.java",
"chars": 1613,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageLuminanceThresholdFilter.java",
"chars": 2302,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageLuminosityBlendFilter.java",
"chars": 2875,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageMixBlendFilter.java",
"chars": 1551,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageMonochromeFilter.java",
"chars": 4142,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageMultiplyBlendFilter.java",
"chars": 1541,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageNonMaximumSuppressionFilter.java",
"chars": 3400,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageNormalBlendFilter.java",
"chars": 2728,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageOpacityFilter.java",
"chars": 2164,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageOverlayBlendFilter.java",
"chars": 2839,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImagePixelationFilter.java",
"chars": 2719,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImagePosterizeFilter.java",
"chars": 2177,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageRGBDilationFilter.java",
"chars": 16900,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageRGBFilter.java",
"chars": 2885,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSaturationBlendFilter.java",
"chars": 5181,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSaturationFilter.java",
"chars": 2570,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageScreenBlendFilter.java",
"chars": 1581,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSepiaToneFilter.java",
"chars": 1132,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSharpenFilter.java",
"chars": 5296,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSketchFilter.java",
"chars": 3126,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSmoothToonFilter.java",
"chars": 2109,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSobelEdgeDetectionFilter.java",
"chars": 3256,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSobelThresholdFilter.java",
"chars": 3239,
"preview": "package jp.co.cyberagent.android.gpuimage.filter;\n\nimport android.opengl.GLES20;\n\npublic class GPUImageSobelThresholdFil"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSoftLightBlendFilter.java",
"chars": 1606,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSolarizeFilter.java",
"chars": 1724,
"preview": "package jp.co.cyberagent.android.gpuimage.filter;\n\nimport android.opengl.GLES20;\n\npublic class GPUImageSolarizeFilter ex"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSourceOverBlendFilter.java",
"chars": 1526,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSphereRefractionFilter.java",
"chars": 4722,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSubtractBlendFilter.java",
"chars": 1521,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageSwirlFilter.java",
"chars": 3861,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageThresholdEdgeDetectionFilter.java",
"chars": 653,
"preview": "package jp.co.cyberagent.android.gpuimage.filter;\n\n/**\n * Applies sobel edge detection on the image.\n */\npublic class GP"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageToneCurveFilter.java",
"chars": 14057,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageToonFilter.java",
"chars": 5160,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageTransformFilter.java",
"chars": 5114,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageTwoInputFilter.java",
"chars": 4945,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageTwoPassFilter.java",
"chars": 1084,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageTwoPassTextureSamplingFilter.java",
"chars": 2444,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageVibranceFilter.java",
"chars": 1622,
"preview": "package jp.co.cyberagent.android.gpuimage.filter;\n\nimport android.opengl.GLES20;\n\npublic class GPUImageVibranceFilter ex"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageVignetteFilter.java",
"chars": 4473,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageWeakPixelInclusionFilter.java",
"chars": 3013,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageWhiteBalanceFilter.java",
"chars": 3642,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/filter/GPUImageZoomBlurFilter.java",
"chars": 3035,
"preview": "package jp.co.cyberagent.android.gpuimage.filter;\n\nimport android.graphics.PointF;\nimport android.opengl.GLES20;\n\npublic"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/util/OpenGlUtils.java",
"chars": 5553,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/util/Rotation.java",
"chars": 1946,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/java/jp/co/cyberagent/android/gpuimage/util/TextureRotationUtil.java",
"chars": 2825,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "library/src/main/res/values/attrs.xml",
"chars": 370,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <declare-styleable name=\"GPUImageView\">\n <attr name=\"gpuim"
},
{
"path": "sample/build.gradle",
"chars": 989,
"preview": "apply plugin: 'com.android.application'\napply plugin: 'kotlin-android-extensions'\napply plugin: 'kotlin-android'\n\nandroi"
},
{
"path": "sample/proguard-project.txt",
"chars": 781,
"preview": "# To enable ProGuard in your project, edit project.properties\n# to define the proguard.config property as described in t"
},
{
"path": "sample/src/main/AndroidManifest.xml",
"chars": 1533,
"preview": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:tools=\"http://schemas.android.com/tools\"\n"
},
{
"path": "sample/src/main/java/jp/co/cyberagent/android/gpuimage/sample/GPUImageFilterTools.kt",
"chars": 30914,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "sample/src/main/java/jp/co/cyberagent/android/gpuimage/sample/activity/CameraActivity.kt",
"chars": 4639,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "sample/src/main/java/jp/co/cyberagent/android/gpuimage/sample/activity/GalleryActivity.kt",
"chars": 3901,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "sample/src/main/java/jp/co/cyberagent/android/gpuimage/sample/activity/MainActivity.kt",
"chars": 2888,
"preview": "/*\n * Copyright (C) 2018 CyberAgent, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "sample/src/main/java/jp/co/cyberagent/android/gpuimage/sample/utils/Camera1Loader.kt",
"chars": 3147,
"preview": "@file:Suppress(\"DEPRECATION\")\n\npackage jp.co.cyberagent.android.gpuimage.sample.utils\n\nimport android.app.Activity\nimpor"
},
{
"path": "sample/src/main/java/jp/co/cyberagent/android/gpuimage/sample/utils/Camera2Loader.kt",
"chars": 6448,
"preview": "package jp.co.cyberagent.android.gpuimage.sample.utils\n\nimport android.annotation.SuppressLint\nimport android.app.Activi"
},
{
"path": "sample/src/main/java/jp/co/cyberagent/android/gpuimage/sample/utils/CameraLoader.kt",
"chars": 546,
"preview": "package jp.co.cyberagent.android.gpuimage.sample.utils\n\n\nabstract class CameraLoader {\n\n protected var onPreviewFrame"
},
{
"path": "sample/src/main/java/jp/co/cyberagent/android/gpuimage/sample/utils/ImageExt.kt",
"chars": 2009,
"preview": "package jp.co.cyberagent.android.gpuimage.sample.utils\n\nimport android.graphics.ImageFormat\nimport android.media.Image\ni"
},
{
"path": "sample/src/main/java/jp/co/cyberagent/android/gpuimage/sample/utils/ViewExt.kt",
"chars": 843,
"preview": "package jp.co.cyberagent.android.gpuimage.sample.utils\n\nimport android.view.View\nimport androidx.core.view.ViewCompat\n\ni"
},
{
"path": "sample/src/main/res/layout/activity_camera.xml",
"chars": 2533,
"preview": "<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:app=\"http://schemas.android.com/apk"
},
{
"path": "sample/src/main/res/layout/activity_gallery.xml",
"chars": 1587,
"preview": "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:tools=\"http://schemas.android.com/too"
},
{
"path": "sample/src/main/res/layout/activity_main.xml",
"chars": 1117,
"preview": "<FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:tools=\"http://schemas.android.com/tool"
},
{
"path": "sample/src/main/res/values/strings.xml",
"chars": 157,
"preview": "<resources>\n\n <string name=\"app_name\">GPUImage for Android</string>\n <string name=\"title_activity_activity_main\">G"
},
{
"path": "sample/src/main/res/values/styles.xml",
"chars": 173,
"preview": "<resources>\n\n <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light\" />\n\n <style name=\"AppTheme.NoActionBar\" parent"
},
{
"path": "settings.gradle",
"chars": 37,
"preview": "include ':library'\ninclude ':sample'\n"
},
{
"path": "utils/Shader2String.py",
"chars": 230,
"preview": "#!/usr/bin/python\n\nimport sys\n\nf = sys.stdin\nif len(sys.argv) > 1:\n f = open(sys.argv[1])\n\nlines = f.readlines()\nfor li"
}
]
// ... and 2 more files (download for full content)
About this extraction
This page contains the full source code of the cats-oss/android-gpuimage GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 135 files (549.6 KB), approximately 138.6k tokens, and a symbol index with 771 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.