@Override
 protected void updateSceneLayer(
     Rect viewport,
     Rect contentViewport,
     LayerTitleCache layerTitleCache,
     TabContentManager tabContentManager,
     ResourceManager resourceManager,
     ChromeFullscreenManager fullscreenManager) {
   super.updateSceneLayer(
       viewport,
       contentViewport,
       layerTitleCache,
       tabContentManager,
       resourceManager,
       fullscreenManager);
   assert mSceneLayer != null;
   mSceneLayer.pushLayers(
       getContext(),
       viewport,
       contentViewport,
       this,
       layerTitleCache,
       tabContentManager,
       resourceManager);
 }
  @Override
  public void onTabCreating(int sourceTabId) {
    super.onTabCreating(sourceTabId);
    reset();

    // Make sure any currently running animations can't influence tab if we are reusing it.
    forceAnimationToFinish();

    ensureSourceTabCreated(sourceTabId);
  }
 @Override
 protected void updateLayout(long time, long dt) {
   super.updateLayout(time, dt);
   if (mLayoutTabs == null) return;
   boolean needUpdate = false;
   for (int i = mLayoutTabs.length - 1; i >= 0; i--) {
     needUpdate = mLayoutTabs[i].updateSnap(dt) || needUpdate;
   }
   if (needUpdate) requestUpdate();
 }
 @Override
 public void onTabCreated(
     long time,
     int id,
     int index,
     int sourceId,
     boolean newIsIncognito,
     boolean background,
     float originX,
     float originY) {
   super.onTabCreated(time, id, index, sourceId, newIsIncognito, background, originX, originY);
   ensureSourceTabCreated(sourceId);
   if (background && mLayoutTabs != null && mLayoutTabs.length > 0) {
     tabCreatedInBackground(id, sourceId, newIsIncognito, originX, originY);
   } else {
     tabCreatedInForeground(id, sourceId, newIsIncognito, originX, originY);
   }
 }
  /** Set up for the tab closing animation */
  @Override
  public void onTabClosing(long time, int id) {
    reset();

    // Make sure any currently running animations can't influence tab if we are reusing it.
    forceAnimationToFinish();

    // Create the {@link LayoutTab} for the tab before it is destroyed.
    TabModel model = mTabModelSelector.getModelForTabId(id);
    if (model != null) {
      mClosedTab = createLayoutTab(id, model.isIncognito(), NO_CLOSE_BUTTON, NO_TITLE);
      mClosedTab.setBorderAlpha(0.0f);
      mLayoutTabs = new LayoutTab[] {mClosedTab};
      updateCacheVisibleIds(new LinkedList<Integer>(Arrays.asList(id)));
    } else {
      mLayoutTabs = null;
      mClosedTab = null;
    }
    // Only close the id at the end when we are done querying the model.
    super.onTabClosing(time, id);
  }
  /** Animate the closing of a tab */
  @Override
  public void onTabClosed(long time, int id, int nextId, boolean incognito) {
    super.onTabClosed(time, id, nextId, incognito);

    if (mClosedTab != null) {
      TabModel nextModel = mTabModelSelector.getModelForTabId(nextId);
      if (nextModel != null) {
        LayoutTab nextLayoutTab =
            createLayoutTab(nextId, nextModel.isIncognito(), NO_CLOSE_BUTTON, NO_TITLE);
        nextLayoutTab.setDrawDecoration(false);

        mLayoutTabs = new LayoutTab[] {nextLayoutTab, mClosedTab};
        updateCacheVisibleIds(new LinkedList<Integer>(Arrays.asList(nextId, mClosedTab.getId())));
      } else {
        mLayoutTabs = new LayoutTab[] {mClosedTab};
      }

      forceAnimationToFinish();
      mAnimatedTab = mClosedTab;
      addToAnimation(
          this,
          Property.DISCARD_AMOUNT,
          0,
          getDiscardRange(),
          TAB_CLOSED_ANIMATION_DURATION,
          0,
          false,
          BakedBezierInterpolator.FADE_OUT_CURVE);

      mClosedTab = null;
      if (nextModel != null) {
        mTabModelSelector.selectModel(nextModel.isIncognito());
      }
    }
    startHiding(nextId, false);
  }
 @Override
 public void show(long time, boolean animate) {
   super.show(time, animate);
   reset();
 }
Beispiel #8
0
  /**
   * Pushes all relevant {@link LayoutTab}s from a {@link Layout} to the CC Layer tree. This will
   * let them be rendered on the screen. This should only be called when the Compositor has disabled
   * ScheduleComposite calls as this will change the tree and could subsequently cause unnecessary
   * follow up renders.
   *
   * @param context The {@link Context} to use to query device information.
   * @param layout The {@link Layout} to push to the screen.
   */
  public void pushLayers(
      Context context,
      Rect viewport,
      Rect contentViewport,
      Layout layout,
      LayerTitleCache layerTitleCache,
      TabContentManager tabContentManager,
      ResourceManager resourceManager) {
    if (mNativePtr == 0) return;

    Resources res = context.getResources();
    final float dpToPx = res.getDisplayMetrics().density;

    LayoutTab[] tabs = layout.getLayoutTabsToRender();
    int tabsCount = tabs != null ? tabs.length : 0;

    nativeBeginBuildingFrame(mNativePtr);
    for (int i = 0; i < tabsCount; i++) {
      LayoutTab t = tabs[i];
      assert t.isVisible() : "LayoutTab in that list should be visible";
      final float decoration = t.getDecorationAlpha();

      int borderResource =
          t.isIncognito()
              ? R.drawable.tabswitcher_border_frame_incognito
              : R.drawable.tabswitcher_border_frame;
      int closeBtnResource =
          t.isIncognito() ? R.drawable.btn_tab_close_white_normal : R.drawable.btn_tab_close_normal;
      int borderColorResource = t.isIncognito() ? R.color.tab_back_incognito : R.color.tab_back;
      // TODO(dtrainor, clholgat): remove "* dpToPx" once the native part fully supports dp.
      nativePutLayer(
          mNativePtr,
          t.getId(),
          R.id.control_container,
          closeBtnResource,
          R.drawable.tabswitcher_border_frame_shadow,
          R.drawable.tabswitcher_border_frame_decoration,
          R.drawable.logo_card_back,
          borderResource,
          t.canUseLiveTexture(),
          (t.getFallbackThumbnailId() == ChromeTab.NTP_TAB_ID),
          t.getBackgroundColor(),
          ApiCompatibilityUtils.getColor(res, R.color.tab_switcher_background),
          ApiCompatibilityUtils.getColor(res, borderColorResource),
          t.isIncognito(),
          layout.getOrientation() == Orientation.PORTRAIT,
          t.getRenderX() * dpToPx,
          t.getRenderY() * dpToPx,
          t.getScaledContentWidth() * dpToPx,
          t.getScaledContentHeight() * dpToPx,
          t.getOriginalContentWidth() * dpToPx,
          t.getOriginalContentHeight() * dpToPx,
          contentViewport.height(),
          viewport.left,
          viewport.top,
          viewport.width(),
          viewport.height(),
          t.getClippedX() * dpToPx,
          t.getClippedY() * dpToPx,
          Math.min(t.getClippedWidth(), t.getScaledContentWidth()) * dpToPx,
          Math.min(t.getClippedHeight(), t.getScaledContentHeight()) * dpToPx,
          t.getTiltXPivotOffset() * dpToPx,
          t.getTiltYPivotOffset() * dpToPx,
          t.getTiltX(),
          t.getTiltY(),
          t.getAlpha(),
          t.getBorderAlpha() * decoration,
          decoration,
          t.getShadowOpacity() * decoration,
          t.getBorderCloseButtonAlpha() * decoration,
          LayoutTab.CLOSE_BUTTON_WIDTH_DP * dpToPx,
          t.getStaticToViewBlend(),
          t.getBorderScale(),
          t.getSaturation(),
          t.getBrightness(),
          t.showToolbar(),
          t.anonymizeToolbar(),
          t.getTextBoxBackgroundColor(),
          t.getToolbarAlpha(),
          t.getToolbarYOffset() * dpToPx,
          t.getSideBorderScale(),
          true,
          t.insetBorderVertical(),
          layerTitleCache,
          tabContentManager,
          resourceManager);
    }
    nativeFinishBuildingFrame(mNativePtr);
  }