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
4af27175
Commit
4af27175
authored
Sep 18, 2015
by
Gaëtan Renaudeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify code of genPixelsWithView
parent
6598fcac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
11 deletions
+8
-11
RNGL/GLTexture.m
RNGL/GLTexture.m
+8
-11
No files found.
RNGL/GLTexture.m
View file @
4af27175
...
@@ -2,6 +2,9 @@
...
@@ -2,6 +2,9 @@
#import "RCTLog.h"
#import "RCTLog.h"
#import "RCTUtils.h"
#import "RCTUtils.h"
// FIXME: the current approach of using a byte array is probably a bottleneck
// this should be investigated: https://github.com/ProjectSeptemberInc/gl-react-native/issues/6
GLImageData
*
genPixelsEmpty
(
int
width
,
int
height
)
GLImageData
*
genPixelsEmpty
(
int
width
,
int
height
)
{
{
GLubyte
*
data
=
(
GLubyte
*
)
malloc
(
width
*
height
*
4
*
sizeof
(
GLubyte
));
GLubyte
*
data
=
(
GLubyte
*
)
malloc
(
width
*
height
*
4
*
sizeof
(
GLubyte
));
...
@@ -54,17 +57,11 @@ GLImageData* genPixelsWithImage (UIImage *image)
...
@@ -54,17 +57,11 @@ GLImageData* genPixelsWithImage (UIImage *image)
GLImageData
*
genPixelsWithView
(
UIView
*
view
)
GLImageData
*
genPixelsWithView
(
UIView
*
view
)
{
{
float
width
=
RCTScreenScale
()
*
view
.
bounds
.
size
.
width
;
UIGraphicsBeginImageContextWithOptions
(
view
.
frame
.
size
,
NO
,
RCTScreenScale
());
float
height
=
RCTScreenScale
()
*
view
.
bounds
.
size
.
height
;
[
view
drawViewHierarchyInRect
:
view
.
frame
afterScreenUpdates
:
YES
];
GLubyte
*
data
=
(
GLubyte
*
)
malloc
(
4
*
width
*
height
);
UIImage
*
snapshot
=
UIGraphicsGetImageFromCurrentImageContext
();
CGColorSpaceRef
colourSpace
=
CGColorSpaceCreateDeviceRGB
();
UIGraphicsEndImageContext
();
CGContextRef
ctx
=
CGBitmapContextCreate
(
data
,
width
,
height
,
8
,
4
*
width
,
colourSpace
,
kCGImageAlphaPremultipliedLast
|
kCGBitmapByteOrder32Big
);
return
genPixelsWithImage
(
snapshot
);
CGColorSpaceRelease
(
colourSpace
);
CGContextClearRect
(
ctx
,
CGRectMake
(
0
.
0
,
0
.
0
,
width
,
height
));
CGContextScaleCTM
(
ctx
,
RCTScreenScale
(),
RCTScreenScale
());
[
view
.
layer
renderInContext
:
ctx
];
CGContextRelease
(
ctx
);
return
[[
GLImageData
alloc
]
initWithData
:
data
withWidth
:
width
withHeight
:
height
];
}
}
@implementation
GLTexture
@implementation
GLTexture
...
...
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