use of org.chromium.chrome.browser.compositor.scene_layer.SceneLayer in project AndroidChromium by JackyAndroid.
the class Layout method getUpdatedSceneLayer.
/**
* Build a {@link SceneLayer} if it hasn't already been built, and update it and return it.
*
* @param viewport A viewport in which to display content.
* @param contentViewport The visible section of the viewport.
* @param layerTitleCache A layer title cache.
* @param tabContentManager A tab content manager.
* @param resourceManager A resource manager.
* @param fullscreenManager A fullscreen manager.
* @return A {@link SceneLayer} that represents the content for this
* {@link Layout}.
*/
public final SceneLayer getUpdatedSceneLayer(Rect viewport, Rect contentViewport, LayerTitleCache layerTitleCache, TabContentManager tabContentManager, ResourceManager resourceManager, ChromeFullscreenManager fullscreenManager) {
updateSceneLayer(viewport, contentViewport, layerTitleCache, tabContentManager, resourceManager, fullscreenManager);
float offsetPx = fullscreenManager != null ? fullscreenManager.getControlOffset() : 0.f;
float dpToPx = getContext().getResources().getDisplayMetrics().density;
float offsetDp = offsetPx / dpToPx;
SceneLayer content = getSceneLayer();
for (int i = 0; i < mSceneOverlays.size(); i++) {
// If the SceneOverlay is not showing, don't bother adding it to the tree.
if (!mSceneOverlays.get(i).isSceneOverlayTreeShowing())
continue;
SceneOverlayLayer overlayLayer = mSceneOverlays.get(i).getUpdatedSceneOverlayTree(layerTitleCache, resourceManager, offsetDp);
overlayLayer.setContentTree(content);
content = overlayLayer;
}
return content;
}
use of org.chromium.chrome.browser.compositor.scene_layer.SceneLayer in project AndroidChromium by JackyAndroid.
the class CompositorView method finalizeLayers.
/**
* Converts the layout into compositor layers. This is to be called on every frame the layout
* is changing.
* @param provider Provides the layout to be rendered.
* @param forRotation Whether or not this is a special draw during a rotation.
*/
public void finalizeLayers(final LayoutProvider provider, boolean forRotation, final DrawingInfo progressBarDrawingInfo) {
TraceEvent.begin("CompositorView:finalizeLayers");
Layout layout = provider.getActiveLayout();
if (layout == null || mNativeCompositorView == 0) {
TraceEvent.end("CompositorView:finalizeLayers");
return;
}
if (!mPreloadedResources) {
// Attempt to prefetch any necessary resources
mResourceManager.preloadResources(AndroidResourceType.STATIC, StaticResourcePreloads.getSynchronousResources(getContext()), StaticResourcePreloads.getAsynchronousResources(getContext()));
mPreloadedResources = true;
}
// IMPORTANT: Do not do anything that impacts the compositor layer tree before this line.
// If you do, you could inadvertently trigger follow up renders. For further information
// see dtrainor@, tedchoc@, or klobag@.
// TODO(jscholler): change 1.0f to dpToPx once the native part is fully supporting dp.
mRenderHost.getVisibleViewport(mCacheVisibleViewport);
mCacheVisibleViewport.right = mCacheVisibleViewport.left + mSurfaceWidth;
mCacheVisibleViewport.bottom = mCacheVisibleViewport.top + mSurfaceHeight;
provider.getViewportPixel(mCacheViewport);
nativeSetLayoutViewport(mNativeCompositorView, mCacheViewport.left, mCacheViewport.top, mCacheViewport.width(), mCacheViewport.height(), mCacheVisibleViewport.left, mCacheVisibleViewport.top, 1.0f);
SceneLayer sceneLayer = provider.getUpdatedActiveSceneLayer(mCacheViewport, mCacheVisibleViewport, mLayerTitleCache, mTabContentManager, mResourceManager, provider.getFullscreenManager());
nativeSetSceneLayer(mNativeCompositorView, sceneLayer);
final LayoutTab[] tabs = layout.getLayoutTabsToRender();
final int tabsCount = tabs != null ? tabs.length : 0;
mLastLayerCount = tabsCount;
TabModelImpl.flushActualTabSwitchLatencyMetric();
nativeFinalizeLayers(mNativeCompositorView);
TraceEvent.end("CompositorView:finalizeLayers");
}
Aggregations