-
Notifications
You must be signed in to change notification settings - Fork 24.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Two ReactART TODOs implemented on Android #9486
Closed
+64
−46
Closed
Changes from 20 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
b00f700
[0.32.0-rc.0] Bump version numbers
grabbou d402a91
Implemented TODO 7255985: ReactART Surface rendering via TextureView …
tepamid 0ecb47a
Merge pull request #1 from facebook/master
tepamid 9d73091
TODO(6352067) implemented: support for dashes in React ART on Android
tepamid 4733329
TODO(7255985): implemented ARTSurface via TextureView in Android
tepamid 163dcaa
Merge branch 'master' into master
tepamid b368f4b
Merge branch 'master' into master
tepamid 97dfe1b
Merge branch 'master' into master
tepamid ff0047b
Merge branch 'master' into master
tepamid a76dbc5
Should be R.string, not R.strings
geof90 c732ca4
Fix params patch
geof90 be92179
Use React 15.3.0 instead of 15.3.0-rc.2
ide 01c78be
Unbreak upgrade to React 15.3.0
javache 0d5fa74
Specify React dependency correctly
javache 4f5fe81
Have React only as a peer dependency
javache ff1c6f9
[0.32.0] Bump version numbers
grabbou ac9622f
Merge branch 'master' into master
tepamid 9dad980
TODO(7255985): refactoring of ARTSurface
tepamid 8a1de61
Merge branch 'master' into master
tepamid c516125
Merge branch 'master' into master
tepamid 2a5c9a1
Don't clear queue in ProxyExecutor
lexs 37a05ed
Bring back missing android command
grabbou fa660c6
Revert "[0.32.0] Bump version numbers"
grabbou 96877a0
[0.32.0] Bump version numbers
grabbou e721814
Fixes paths to robolectric when they are downloaded from maven into b…
bestander 3a3ecc4
Make sure layout happens after setFrame:forView:
javache 7a1410a
[0.32.1] Bump version numbers
bestander 1311c45
WebSocket onError fix; Dashes in Android; ARTSurface via TextureView
tepamid 4b80730
Fixed: CSSNodeAPI instad of CSSNode
tepamid dc97901
Added IllegalStateException in ArtSurfaceViewShadowNode
tepamid 09a22fc
Removed throwing exception "Cannot send a message. Unknown WebSocket id"
tepamid 945322c
Merge branch 'master' into master
tepamid bacce99
TODO 7255985: added exception handling to drawing in ARTSurfaceView
tepamid fd49719
Merge branch 'master' into master
tepamid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ | |
import android.graphics.SurfaceTexture; | ||
import android.view.TextureView; | ||
|
||
import com.facebook.common.logging.FLog; | ||
import com.facebook.react.common.ReactConstants; | ||
import com.facebook.react.uimanager.LayoutShadowNode; | ||
import com.facebook.react.uimanager.UIViewOperationQueue; | ||
import com.facebook.react.uimanager.ReactShadowNode; | ||
|
@@ -47,39 +49,48 @@ public void onCollectExtraUpdates(UIViewOperationQueue uiUpdater) { | |
} | ||
|
||
private void drawOutput() { | ||
if (mSurface == null) { | ||
if (mSurface == null || !mSurface.isValid()) { | ||
markChildrenUpdatesSeen(this); | ||
return; | ||
} | ||
|
||
Canvas canvas = mSurface.lockCanvas(null); | ||
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR); | ||
try { | ||
Canvas canvas = mSurface.lockCanvas(null); | ||
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR); | ||
|
||
Paint paint = new Paint(); | ||
for (int i = 0; i < getChildCount(); i++) { | ||
ARTVirtualNode child = (ARTVirtualNode) getChildAt(i); | ||
child.draw(canvas, paint, 1f); | ||
child.markUpdateSeen(); | ||
} | ||
Paint paint = new Paint(); | ||
for (int i = 0; i < getChildCount(); i++) { | ||
ARTVirtualNode child = (ARTVirtualNode) getChildAt(i); | ||
child.draw(canvas, paint, 1f); | ||
child.markUpdateSeen(); | ||
} | ||
|
||
mSurface.unlockCanvasAndPost(canvas); | ||
if (mSurface == null) { | ||
return; | ||
} | ||
|
||
mSurface.unlockCanvasAndPost(canvas); | ||
} catch(IllegalArgumentException | IllegalStateException e) { | ||
FLog.e(ReactConstants.TAG, e.getClass().getSimpleName() + " in Surface.unlockCanvasAndPost"); | ||
} | ||
} | ||
|
||
private void markChildrenUpdatesSeen(ReactShadowNode shadowNode) { | ||
for (int i = 0; i < shadowNode.getChildCount(); i++) { | ||
ReactShadowNode child = (ReactShadowNode) shadowNode.getChildAt(i); | ||
child.markUpdateSeen(); | ||
markChildrenUpdatesSeen(child); | ||
} | ||
ReactShadowNode child = (ReactShadowNode) shadowNode.getChildAt(i); | ||
child.markUpdateSeen(); | ||
markChildrenUpdatesSeen(child); | ||
} | ||
} | ||
|
||
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { | ||
mSurface = new Surface(surface); | ||
mSurface = new Surface(surface); | ||
} | ||
|
||
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) { | ||
mSurface = null; | ||
return true; | ||
mSurface.release(); | ||
mSurface = null; | ||
return true; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small nit: only two spaces of indentation please. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. I'll fix it. |
||
|
||
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I do not markUpdateSeen each child in the entire Surface subtree, then ARTSurface's method onCollectExtraUpdates is called ONLY ONCE right after the app start. As I understood from the react-native sources when a child is updated it is marked "update not seen" (i.e. some ARTShape on a ARTSurface) and also it tries to mark its parent as "update not seen" only if parent doesn't have any pending updates. Otherwise if parent itself is already marked "update not seen", then an update is not propagated further to even more distant ancestors and obviously to the ultimate ancestor ARTSurface.
That's why I need to mark all ARTSurface's children as "UpdateSeen" even if TextureView's Android.Surface is not ready for drawing.
Or is there a pre-built method in ReactNative for this?