Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gl-react-native-v2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ym
gl-react-native-v2
Commits
3430bf61
Commit
3430bf61
authored
Nov 21, 2015
by
Gaëtan Renaudeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
e5de2a1a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
41 deletions
+10
-41
android/src/main/java/com/projectseptember/RNGL/GLCanvas.java
...oid/src/main/java/com/projectseptember/RNGL/GLCanvas.java
+1
-1
android/src/main/java/com/projectseptember/RNGL/GLImage.java
android/src/main/java/com/projectseptember/RNGL/GLImage.java
+9
-40
No files found.
android/src/main/java/com/projectseptember/RNGL/GLCanvas.java
View file @
3430bf61
...
...
@@ -205,7 +205,7 @@ public class GLCanvas
if
(
preloadingDone
)
return
;
List
<
Uri
>
imagesToPreload
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
imagesToPreloadRA
.
size
();
i
++)
{
imagesToPreload
.
add
(
resolveSrc
(
imagesToPreloadRA
.
get
String
(
i
)));
imagesToPreload
.
add
(
resolveSrc
(
imagesToPreloadRA
.
get
Map
(
i
).
getString
(
"uri"
)));
}
if
(
imagesToPreload
.
size
()
==
0
)
{
dispatchOnLoad
();
...
...
android/src/main/java/com/projectseptember/RNGL/GLImage.java
View file @
3430bf61
...
...
@@ -9,6 +9,7 @@ import android.net.Uri;
import
android.os.AsyncTask
;
import
android.provider.MediaStore
;
import
android.support.annotation.Nullable
;
import
android.util.Log
;
import
com.facebook.common.util.UriUtil
;
...
...
@@ -52,6 +53,7 @@ public class GLImage { // TODO : we need to check support for local images
public
void
onLoad
(
final
Bitmap
bitmap
)
{
glScheduler
.
runInGLThread
(
new
Runnable
()
{
public
void
run
()
{
Log
.
i
(
"GLImage"
,
"loaded="
+
src
.
getPath
());
texture
.
setPixels
(
bitmap
);
onload
.
run
();
}
...
...
@@ -83,7 +85,7 @@ public class GLImage { // TODO : we need to check support for local images
}
private
class
LoadImageUriTask
extends
LoadImageTask
{
private
static
class
LoadImageUriTask
extends
LoadImageTask
{
private
final
Uri
mUri
;
...
...
@@ -94,12 +96,14 @@ public class GLImage { // TODO : we need to check support for local images
@Override
protected
Bitmap
decode
(
BitmapFactory
.
Options
options
)
{
Log
.
i
(
"GLImage"
,
"loading...="
+
mUri
.
getPath
());
// FIXME: image loading is very long (probably decoding)... possible to re-use some React Native work ?
try
{
InputStream
inputStream
;
if
(
mUri
.
getScheme
().
startsWith
(
"http"
)
||
mUri
.
getScheme
().
startsWith
(
"https"
))
{
inputStream
=
new
URL
(
mUri
.
toString
()).
openStream
();
}
else
{
inputStream
=
context
.
getContentResolver
().
openInputStream
(
mUri
);
inputStream
=
glImage
.
context
.
getContentResolver
().
openInputStream
(
mUri
);
}
return
BitmapFactory
.
decodeStream
(
inputStream
,
null
,
options
);
}
catch
(
Exception
e
)
{
...
...
@@ -110,7 +114,7 @@ public class GLImage { // TODO : we need to check support for local images
@Override
protected
int
getImageOrientation
()
throws
IOException
{
Cursor
cursor
=
context
.
getContentResolver
().
query
(
mUri
,
Cursor
cursor
=
glImage
.
context
.
getContentResolver
().
query
(
mUri
,
new
String
[]
{
MediaStore
.
Images
.
ImageColumns
.
ORIENTATION
},
null
,
null
,
null
);
if
(
cursor
==
null
||
cursor
.
getCount
()
!=
1
)
{
...
...
@@ -124,44 +128,9 @@ public class GLImage { // TODO : we need to check support for local images
}
}
/*
private class LoadImageFileTask extends LoadImageTask {
private
static
abstract
class
LoadImageTask
extends
AsyncTask
<
Void
,
Void
,
Bitmap
>
{
private final File mImageFile;
public LoadImageFileTask(GLImage gpuImage, File file) {
super(gpuImage);
mImageFile = file;
}
@Override
protected Bitmap decode(BitmapFactory.Options options) {
return BitmapFactory.decodeFile(mImageFile.getAbsolutePath(), options);
}
@Override
protected int getImageOrientation() throws IOException {
ExifInterface exif = new ExifInterface(mImageFile.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
GLImage
glImage
;
protected
GLImage
glImage
;
public
LoadImageTask
(
GLImage
glImage
)
{
this
.
glImage
=
glImage
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment