org.chromium.chrome.browser.compositor.resources.StaticResourcePreloads Java Examples

The following examples show how to use org.chromium.chrome.browser.compositor.resources.StaticResourcePreloads. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CompositorView.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * 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@.

    provider.getViewportPixel(mCacheViewport);

    nativeSetLayoutBounds(mNativeCompositorView);

    SceneLayer sceneLayer =
            provider.getUpdatedActiveSceneLayer(mCacheViewport, 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");
}
 
Example #2
Source File: CompositorView.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * 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@.

    nativeSetLayoutBounds(mNativeCompositorView);

    SceneLayer sceneLayer =
            provider.getUpdatedActiveSceneLayer(mLayerTitleCache, mTabContentManager,
            mResourceManager, provider.getFullscreenManager());

    nativeSetSceneLayer(mNativeCompositorView, sceneLayer);

    TabModelImpl.flushActualTabSwitchLatencyMetric();
    nativeFinalizeLayers(mNativeCompositorView);
    TraceEvent.end("CompositorView:finalizeLayers");
}
 
Example #3
Source File: CompositorView.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * 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");
}