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
6ae34c45
Commit
6ae34c45
authored
Dec 20, 2015
by
Gaëtan Renaudeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add pixelRatio and context
parent
0a4c758f
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
20 additions
and
12 deletions
+20
-12
ios/GLCanvas.h
ios/GLCanvas.h
+1
-0
ios/GLCanvas.m
ios/GLCanvas.m
+8
-3
ios/GLCanvasManager.m
ios/GLCanvasManager.m
+1
-0
ios/GLImageData.h
ios/GLImageData.h
+1
-1
ios/GLImageData.m
ios/GLImageData.m
+4
-5
src/Surface.js
src/Surface.js
+5
-3
No files found.
ios/GLCanvas.h
View file @
6ae34c45
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
@property
(
nonatomic
)
BOOL
visibleContent
;
@property
(
nonatomic
)
BOOL
visibleContent
;
@property
(
nonatomic
)
NSNumber
*
nbContentTextures
;
@property
(
nonatomic
)
NSNumber
*
nbContentTextures
;
@property
(
nonatomic
)
NSNumber
*
renderId
;
@property
(
nonatomic
)
NSNumber
*
renderId
;
@property
(
nonatomic
)
NSNumber
*
pixelRatio
;
@property
(
nonatomic
)
NSArray
*
imagesToPreload
;
@property
(
nonatomic
)
NSArray
*
imagesToPreload
;
@property
(
nonatomic
,
copy
)
RCTBubblingEventBlock
onGLProgress
;
@property
(
nonatomic
,
copy
)
RCTBubblingEventBlock
onGLProgress
;
@property
(
nonatomic
,
copy
)
RCTBubblingEventBlock
onGLLoad
;
@property
(
nonatomic
,
copy
)
RCTBubblingEventBlock
onGLLoad
;
...
...
ios/GLCanvas.m
View file @
6ae34c45
...
@@ -62,7 +62,6 @@ NSString* srcResource (id res)
...
@@ -62,7 +62,6 @@ NSString* srcResource (id res)
_captureFrameRequested
=
false
;
_captureFrameRequested
=
false
;
_preloadingDone
=
false
;
_preloadingDone
=
false
;
self
.
context
=
[
bridge
.
rnglContext
getContext
];
self
.
context
=
[
bridge
.
rnglContext
getContext
];
self
.
contentScaleFactor
=
RCTScreenScale
();
}
}
return
self
;
return
self
;
}
}
...
@@ -129,6 +128,12 @@ RCT_NOT_IMPLEMENTED(-init)
...
@@ -129,6 +128,12 @@ RCT_NOT_IMPLEMENTED(-init)
}
}
}
}
-
(
void
)
setPixelRatio
:(
NSNumber
*
)
pixelRatio
{
self
.
contentScaleFactor
=
[
pixelRatio
floatValue
];
[
self
setNeedsDisplay
];
}
-
(
void
)
setData
:(
GLData
*
)
data
-
(
void
)
setData
:(
GLData
*
)
data
{
{
_data
=
data
;
_data
=
data
;
...
@@ -284,7 +289,7 @@ RCT_NOT_IMPLEMENTED(-init)
...
@@ -284,7 +289,7 @@ RCT_NOT_IMPLEMENTED(-init)
UIView
*
v
=
[
view
.
subviews
count
]
==
1
?
UIView
*
v
=
[
view
.
subviews
count
]
==
1
?
view
.
subviews
[
0
]
:
view
.
subviews
[
0
]
:
view
;
view
;
imgData
=
[
GLImageData
genPixelsWithView
:
v
];
imgData
=
[
GLImageData
genPixelsWithView
:
v
withPixelRatio
:
self
.
contentScaleFactor
];
}
else
{
}
else
{
imgData
=
nil
;
imgData
=
nil
;
}
}
...
@@ -352,7 +357,7 @@ RCT_NOT_IMPLEMENTED(-init)
...
@@ -352,7 +357,7 @@ RCT_NOT_IMPLEMENTED(-init)
{
{
if
(
!
_renderData
)
return
;
if
(
!
_renderData
)
return
;
CGFloat
scale
=
RCTScreenScale
()
;
CGFloat
scale
=
self
.
contentScaleFactor
;
@autoreleasepool
{
@autoreleasepool
{
void
(
^
recDraw
)
(
GLRenderData
*
renderData
);
void
(
^
recDraw
)
(
GLRenderData
*
renderData
);
...
...
ios/GLCanvasManager.m
View file @
6ae34c45
...
@@ -22,6 +22,7 @@ RCT_EXPORT_VIEW_PROPERTY(opaque, BOOL);
...
@@ -22,6 +22,7 @@ RCT_EXPORT_VIEW_PROPERTY(opaque, BOOL);
RCT_EXPORT_VIEW_PROPERTY
(
autoRedraw
,
BOOL
);
RCT_EXPORT_VIEW_PROPERTY
(
autoRedraw
,
BOOL
);
RCT_EXPORT_VIEW_PROPERTY
(
data
,
GLData
);
RCT_EXPORT_VIEW_PROPERTY
(
data
,
GLData
);
RCT_EXPORT_VIEW_PROPERTY
(
renderId
,
NSNumber
);
RCT_EXPORT_VIEW_PROPERTY
(
renderId
,
NSNumber
);
RCT_EXPORT_VIEW_PROPERTY
(
pixelRatio
,
NSNumber
);
RCT_EXPORT_VIEW_PROPERTY
(
imagesToPreload
,
NSArray
);
RCT_EXPORT_VIEW_PROPERTY
(
imagesToPreload
,
NSArray
);
RCT_EXPORT_VIEW_PROPERTY
(
onGLLoad
,
RCTBubblingEventBlock
);
RCT_EXPORT_VIEW_PROPERTY
(
onGLLoad
,
RCTBubblingEventBlock
);
RCT_EXPORT_VIEW_PROPERTY
(
onGLProgress
,
RCTBubblingEventBlock
);
RCT_EXPORT_VIEW_PROPERTY
(
onGLProgress
,
RCTBubblingEventBlock
);
...
...
ios/GLImageData.h
View file @
6ae34c45
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
+
(
GLImageData
*
)
empty
;
+
(
GLImageData
*
)
empty
;
+
(
GLImageData
*
)
genPixelsWithImage
:
(
UIImage
*
)
image
;
+
(
GLImageData
*
)
genPixelsWithImage
:
(
UIImage
*
)
image
;
+
(
GLImageData
*
)
genPixelsWithView
:
(
UIView
*
)
view
;
+
(
GLImageData
*
)
genPixelsWithView
:
(
UIView
*
)
view
withPixelRatio
:(
float
)
pixelRatio
;
-
(
instancetype
)
initWithData
:
(
GLubyte
*
)
data
withWidth
:(
int
)
width
withHeight
:(
int
)
height
;
-
(
instancetype
)
initWithData
:
(
GLubyte
*
)
data
withWidth
:(
int
)
width
withHeight
:(
int
)
height
;
...
...
ios/GLImageData.m
View file @
6ae34c45
#import "GLImageData.h"
#import "GLImageData.h"
#import "RCTUtils.h"
#import "RCTLog.h"
#import "RCTLog.h"
// This structure aims to be used in an immutable way
// This structure aims to be used in an immutable way
...
@@ -55,16 +54,16 @@ GLImageData *EMPTY_PIXELS;
...
@@ -55,16 +54,16 @@ GLImageData *EMPTY_PIXELS;
return
[[
GLImageData
alloc
]
initWithData
:
data
withWidth
:
width
withHeight
:
height
];
return
[[
GLImageData
alloc
]
initWithData
:
data
withWidth
:
width
withHeight
:
height
];
}
}
+
(
GLImageData
*
)
genPixelsWithView
:
(
UIView
*
)
view
+
(
GLImageData
*
)
genPixelsWithView
:
(
UIView
*
)
view
withPixelRatio
:(
float
)
pixelRatio
{
{
float
width
=
RCTScreenScale
()
*
view
.
bounds
.
size
.
width
;
float
width
=
pixelRatio
*
view
.
bounds
.
size
.
width
;
float
height
=
RCTScreenScale
()
*
view
.
bounds
.
size
.
height
;
float
height
=
pixelRatio
*
view
.
bounds
.
size
.
height
;
GLubyte
*
data
=
(
GLubyte
*
)
malloc
(
4
*
width
*
height
);
GLubyte
*
data
=
(
GLubyte
*
)
malloc
(
4
*
width
*
height
);
CGColorSpaceRef
colourSpace
=
CGColorSpaceCreateDeviceRGB
();
CGColorSpaceRef
colourSpace
=
CGColorSpaceCreateDeviceRGB
();
CGContextRef
ctx
=
CGBitmapContextCreate
(
data
,
width
,
height
,
8
,
4
*
width
,
colourSpace
,
kCGImageAlphaPremultipliedLast
|
kCGBitmapByteOrder32Big
);
CGContextRef
ctx
=
CGBitmapContextCreate
(
data
,
width
,
height
,
8
,
4
*
width
,
colourSpace
,
kCGImageAlphaPremultipliedLast
|
kCGBitmapByteOrder32Big
);
CGColorSpaceRelease
(
colourSpace
);
CGColorSpaceRelease
(
colourSpace
);
CGContextClearRect
(
ctx
,
CGRectMake
(
0
.
0
,
0
.
0
,
width
,
height
));
CGContextClearRect
(
ctx
,
CGRectMake
(
0
.
0
,
0
.
0
,
width
,
height
));
CGContextScaleCTM
(
ctx
,
RCTScreenScale
(),
RCTScreenScale
()
);
CGContextScaleCTM
(
ctx
,
pixelRatio
,
pixelRatio
);
[
view
.
layer
renderInContext
:
ctx
];
[
view
.
layer
renderInContext
:
ctx
];
CGContextRelease
(
ctx
);
CGContextRelease
(
ctx
);
return
[[
GLImageData
alloc
]
initWithData
:
data
withWidth
:
width
withHeight
:
height
];
return
[[
GLImageData
alloc
]
initWithData
:
data
withWidth
:
width
withHeight
:
height
];
...
...
src/Surface.js
View file @
6ae34c45
...
@@ -2,11 +2,13 @@ const invariant = require("invariant");
...
@@ -2,11 +2,13 @@ const invariant = require("invariant");
const
{
createSurface
}
=
require
(
"
gl-react
"
);
const
{
createSurface
}
=
require
(
"
gl-react
"
);
invariant
(
typeof
createSurface
===
"
function
"
,
"
gl-react createSurface is not a function. Check your gl-react dependency
"
);
invariant
(
typeof
createSurface
===
"
function
"
,
"
gl-react createSurface is not a function. Check your gl-react dependency
"
);
const
React
=
require
(
"
react-native
"
);
const
React
=
require
(
"
react-native
"
);
const
GLCanvas
=
require
(
"
./GLCanvas
"
);
const
{
const
{
View
,
View
,
PixelRatio
}
=
React
;
}
=
React
;
const
GLCanvas
=
require
(
"
./GLCanvas
"
);
const
getPixelRatio
=
props
=>
props
.
scale
||
PixelRatio
.
get
();
function
renderVcontent
(
width
,
height
,
id
,
children
,
{
visibleContent
})
{
function
renderVcontent
(
width
,
height
,
id
,
children
,
{
visibleContent
})
{
const
childrenStyle
=
{
const
childrenStyle
=
{
...
@@ -40,4 +42,4 @@ function renderVcontainer ({ style, width, height, visibleContent, eventsThrough
...
@@ -40,4 +42,4 @@ function renderVcontainer ({ style, width, height, visibleContent, eventsThrough
<
/View>
;
<
/View>
;
}
}
module
.
exports
=
createSurface
(
renderVcontainer
,
renderVcontent
,
renderVGL
);
module
.
exports
=
createSurface
(
renderVcontainer
,
renderVcontent
,
renderVGL
,
getPixelRatio
);
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