Implement DrawImage using Drawee

Summary: Alternative implementation of DrawImage using DraweeHierarchy instead of ImagePipeline directly. Yields same results, but potentially more stable. We'll run tests to measure performance of both.

Reviewed By: ahmedre

Differential Revision: D2746197
This commit is contained in:
Denis Koroskin
2016-01-08 16:33:38 -08:00
committed by Ahmed El-Helw
parent 2daf696064
commit 7075744b94
5 changed files with 249 additions and 10 deletions

View File

@@ -43,13 +43,6 @@ public class FlatUIImplementation extends UIImplementation {
}
};
/**
* Temporary storage for elements that need to be moved within a parent.
* Only used inside #manageChildren() and always empty outside of it.
*/
private final ArrayList<FlatShadowNode> mNodesToMove = new ArrayList<>();
private final StateBuilder mStateBuilder;
public static FlatUIImplementation createInstance(
ReactApplicationContext reactContext,
List<ViewManager> viewManagers) {
@@ -61,6 +54,7 @@ public class FlatUIImplementation extends UIImplementation {
RCTImageView.setCallerContext(callerContext);
}
}
DraweeRequestHelper.setResources(reactContext.getResources());
TypefaceCache.setAssetManager(reactContext.getAssets());
@@ -78,18 +72,38 @@ public class FlatUIImplementation extends UIImplementation {
FlatUIViewOperationQueue operationsQueue = new FlatUIViewOperationQueue(
reactContext,
nativeViewHierarchyManager);
return new FlatUIImplementation(viewManagerRegistry, operationsQueue);
return new FlatUIImplementation(reactImageManager, viewManagerRegistry, operationsQueue);
}
/**
* Temporary storage for elements that need to be moved within a parent.
* Only used inside #manageChildren() and always empty outside of it.
*/
private final ArrayList<FlatShadowNode> mNodesToMove = new ArrayList<>();
private final StateBuilder mStateBuilder;
private @Nullable ReactImageManager mReactImageManager;
private FlatUIImplementation(
@Nullable ReactImageManager reactImageManager,
ViewManagerRegistry viewManagers,
FlatUIViewOperationQueue operationsQueue) {
super(viewManagers, operationsQueue);
mStateBuilder = new StateBuilder(operationsQueue);
mReactImageManager = reactImageManager;
}
@Override
protected ReactShadowNode createRootShadowNode() {
if (mReactImageManager != null) {
// This is not the best place to initialize DraweeRequestHelper, but order of module
// initialization is undefined, and this is pretty much the earliest when we are guarantied
// that Fresco is initalized and DraweeControllerBuilder can be queried. This also happens
// relatively rarely to have any performance considerations.
DraweeRequestHelper.setDraweeControllerBuilder(
mReactImageManager.getDraweeControllerBuilder());
mReactImageManager = null;
}
return new FlatRootShadowNode();
}