am 50fddb72: am bbe02dec: am 79f95ce3: Add ActionBarDrawerToggle
* commit '50fddb72c23917e121f99e2cc2ec20370ea4a351':
Add ActionBarDrawerToggle
diff --git a/CleanSpec.mk b/CleanSpec.mk
new file mode 100644
index 0000000..1c592d5
--- /dev/null
+++ b/CleanSpec.mk
@@ -0,0 +1,51 @@
+# Copyright (C) 2013 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# If you don't need to do a full clean build but would like to touch
+# a file or delete some intermediate files, add a clean step to the end
+# of the list. These steps will only be run once, if they haven't been
+# run before.
+#
+# E.g.:
+# $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
+# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
+#
+# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
+# files that are missing or have been moved.
+#
+# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
+# Use $(OUT_DIR) to refer to the "out" directory.
+#
+# If you need to re-do something that's already mentioned, just copy
+# the command and add it to the bottom of the list. E.g., if a change
+# that you made last week required touching a file and a change you
+# made today requires touching the same file, just copy the old
+# touch step and add it to the end of the list.
+#
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+
+# For example:
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
+#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
+
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/android-support-v*)
+
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
diff --git a/appcompat/README.txt b/appcompat/README.txt
deleted file mode 100644
index 9216fd2..0000000
--- a/appcompat/README.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-Library Project including compatibility ActionBar.
-
-This can be used by an Android project to provide
-access to ActionBar on applications running on API X+
-
-There is technically no source, but the src folder is necessary
-to ensure that the build system works. The content is actually
-located in libs/android-support-???.jar
-
-
diff --git a/appcompat/eclair/android/support/appcompat/view/MenuCompat.java b/appcompat/eclair/android/support/appcompat/view/MenuCompat.java
deleted file mode 100644
index e7131d6..0000000
--- a/appcompat/eclair/android/support/appcompat/view/MenuCompat.java
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-
-package android.support.appcompat.view;
-
-import android.view.Menu;
-
-/**
- * @author trevorjohns@google.com (Trevor Johns)
- */
-public abstract class MenuCompat implements Menu {
-
- /**
- * This is the part of an order integer that the user can provide.
- *
- * @hide
- */
- protected static final int USER_MASK = 0x0000ffff;
-
- /**
- * This is the part of an order integer that supplies the category of the item.
- *
- * @hide
- */
- protected static final int CATEGORY_MASK = 0xffff0000;
-
- /**
- * Bit shift of the category portion of the order integer.
- *
- * @hide
- */
- protected static final int CATEGORY_SHIFT = 16;
-
-}
diff --git a/appcompat/eclair/android/support/appcompat/widget/ActionBarOverlayLayout.java b/appcompat/eclair/android/support/appcompat/widget/ActionBarOverlayLayout.java
deleted file mode 100644
index c2fa241..0000000
--- a/appcompat/eclair/android/support/appcompat/widget/ActionBarOverlayLayout.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.support.appcompat.widget;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Rect;
-import android.support.appcompat.R;
-import android.support.appcompat.app.ActionBar;
-import android.support.appcompat.app.ActionBarImplCompat;
-import android.util.AttributeSet;
-import android.view.View;
-import android.widget.FrameLayout;
-
-/**
- * Special layout for the containing of an overlay action bar (and its content) to correctly handle
- * fitting system windows when the content has request that its layout ignore them.
- */
-public class ActionBarOverlayLayout extends FrameLayout {
-
- private int mActionBarHeight;
- private ActionBar mActionBar;
- // TODO(trevorjohns): Should this be ActionBarImplCompat?
- private int mWindowVisibility = View.VISIBLE;
- private View mContent;
- private View mActionBarTop;
- private ActionBarContainer mContainerView;
- private ActionBarView mActionView;
- private View mActionBarBottom;
- private int mLastSystemUiVisibility;
- private final Rect mZeroRect = new Rect(0, 0, 0, 0);
-
- static final int[] mActionBarSizeAttr = new int[]{
- android.support.appcompat.R.attr.actionBarSize
- };
-
- public ActionBarOverlayLayout(Context context) {
- super(context);
- init(context);
- }
-
- public ActionBarOverlayLayout(Context context, AttributeSet attrs) {
- super(context, attrs);
- init(context);
- }
-
- private void init(Context context) {
- TypedArray ta = getContext().getTheme().obtainStyledAttributes(mActionBarSizeAttr);
- mActionBarHeight = ta.getDimensionPixelSize(0, 0);
- ta.recycle();
- }
-
- public void setActionBar(ActionBarImplCompat impl) {
- mActionBar = impl;
- if (getWindowToken() != null) {
- // This is being initialized after being added to a window;
- // make sure to update all state now.
- // TODO(trevorjohns): Non-public method. Probably okay, but test. (Also below.)
- // TOOD(trevorjohns): Might make sense to strip out visibility handling in general.
- // mActionBar.setWindowVisibility(mWindowVisibility);
- if (mLastSystemUiVisibility != 0) {
- int newVis = mLastSystemUiVisibility;
- // Removed: Not relevant on older devices
- // onWindowSystemUiVisibilityChanged(newVis);
- // requestFitSystemWindows();
- }
- }
- }
-
- // Removed: Not relevant for older devices
- /*public void setShowingForActionMode(boolean showing) {
- if (showing) {
- // Here's a fun hack: if the status bar is currently being hidden,
- // and the application has asked for stable content insets, then
- // we will end up with the action mode action bar being shown
- // without the status bar, but moved below where the status bar
- // would be. Not nice. Trying to have this be positioned
- // correctly is not easy (basically we need yet *another* content
- // inset from the window manager to know where to put it), so
- // instead we will just temporarily force the status bar to be shown.
- if ((getWindowSystemUiVisibility() & (SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
- | SYSTEM_UI_FLAG_LAYOUT_STABLE))
- == (SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | SYSTEM_UI_FLAG_LAYOUT_STABLE)) {
- setDisabledSystemUiVisibility(SYSTEM_UI_FLAG_FULLSCREEN);
- }
- } else {
- setDisabledSystemUiVisibility(0);
- }
- }*/
-
- // Removed: Not relevant for older devices
- /*@Override
- public void onWindowSystemUiVisibilityChanged(int visible) {
- super.onWindowSystemUiVisibilityChanged(visible);
- pullChildren();
- final int diff = mLastSystemUiVisibility ^ visible;
- mLastSystemUiVisibility = visible;
- final boolean barVisible = (visible&SYSTEM_UI_FLAG_FULLSCREEN) == 0;
- final boolean wasVisible = mActionBar != null ? mActionBar.isSystemShowing() : true;
- if (mActionBar != null) {
- if (barVisible) mActionBar.showForSystem();
- else mActionBar.hideForSystem();
- }
- if ((diff&SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) {
- if (mActionBar != null) {
- requestFitSystemWindows();
- }
- }
- }*/
-
- @Override
- protected void onWindowVisibilityChanged(int visibility) {
- super.onWindowVisibilityChanged(visibility);
- mWindowVisibility = visibility;
- // See above.
- //if (mActionBar != null) {
- // mActionBar.setWindowVisibility(visibility);
- //}
- }
-
- private boolean applyInsets(View view, Rect insets, boolean left, boolean top,
- boolean bottom, boolean right) {
- boolean changed = false;
- FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) view.getLayoutParams();
- if (left && lp.leftMargin != insets.left) {
- changed = true;
- lp.leftMargin = insets.left;
- }
- if (top && lp.topMargin != insets.top) {
- changed = true;
- lp.topMargin = insets.top;
- }
- if (right && lp.rightMargin != insets.right) {
- changed = true;
- lp.rightMargin = insets.right;
- }
- if (bottom && lp.bottomMargin != insets.bottom) {
- changed = true;
- lp.bottomMargin = insets.bottom;
- }
- return changed;
- }
-
- // Removed:
- /*@Override
- protected boolean fitSystemWindows(Rect insets) {
- pullChildren();
-
- final int vis = getWindowSystemUiVisibility();
- final boolean stable = (vis & SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0;
-
- // The top and bottom action bars are always within the content area.
- boolean changed = applyInsets(mActionBarTop, insets, true, true, false, true);
- if (mActionBarBottom != null) {
- changed |= applyInsets(mActionBarBottom, insets, true, false, true, true);
- }
-
- // If the window has not requested system UI layout flags, we need to
- // make sure its content is not being covered by system UI... though it
- // will still be covered by the action bar since they have requested it to
- // overlay.
- if ((vis & SYSTEM_UI_LAYOUT_FLAGS) == 0) {
- changed |= applyInsets(mContent, insets, true, true, true, true);
- // The insets are now consumed.
- insets.set(0, 0, 0, 0);
- } else {
- changed |= applyInsets(mContent, mZeroRect, true, true, true, true);
- }
-
-
- if (stable || mActionBarTop.getVisibility() == VISIBLE) {
- // The action bar creates additional insets for its content to use.
- insets.top += mActionBarHeight;
- }
-
- if (mActionBar != null && mActionBar.hasNonEmbeddedTabs()) {
- View tabs = mContainerView.getTabContainer();
- if (stable || (tabs != null && tabs.getVisibility() == VISIBLE)) {
- // If tabs are not embedded, adjust insets to account for them.
- insets.top += mActionBarHeight;
- }
- }
-
- if (mActionView.isSplitActionBar()) {
- if (stable || (mActionBarBottom != null
- && mActionBarBottom.getVisibility() == VISIBLE)) {
- // If action bar is split, adjust buttom insets for it.
- insets.bottom += mActionBarHeight;
- }
- }
-
- if (changed) {
- requestLayout();
- }
-
- return super.fitSystemWindows(insets);
- }*/
-
- void pullChildren() {
- if (mContent == null) {
- mContent = findViewById(R.id.action_bar_activity_content);
- mActionBarTop = findViewById(R.id.top_action_bar);
- mContainerView = (ActionBarContainer) findViewById(
- R.id.action_bar_container);
- mActionView = (ActionBarView) findViewById(R.id.action_bar);
- mActionBarBottom = findViewById(R.id.split_action_bar);
- }
- }
-}
diff --git a/appcompat/java/android/support/appcompat/app/ActionBarActivity.java b/appcompat/java/android/support/appcompat/app/ActionBarActivity.java
deleted file mode 100644
index a78f7eb..0000000
--- a/appcompat/java/android/support/appcompat/app/ActionBarActivity.java
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.support.appcompat.app;
-
-import android.content.res.TypedArray;
-import android.os.Bundle;
-import android.support.appcompat.R;
-import android.support.v4.app.FragmentActivity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-public class ActionBarActivity extends FragmentActivity implements ActionBar.Callback {
-
- private static final int FEATURE_ACTION_BAR = 8;
- private static final int FEATURE_ACTION_BAR_OVERLAY = 9;
-
- interface ActionBarActivityImpl {
- void onCreate(ActionBarActivity activity, Bundle savedInstanceState);
- void setContentView(ActionBarActivity activity, View v);
- void setContentView(ActionBarActivity activity, int resId);
- void setContentView(ActionBarActivity activity, View v, ViewGroup.LayoutParams lp);
- void addContentView(ActionBarActivity activity, View v, ViewGroup.LayoutParams lp);
- ActionBar createActionBar(ActionBarActivity activity);
- void requestWindowFeature(ActionBarActivity activity, int feature);
- }
-
- static class ActionBarActivityImplBase implements ActionBarActivityImpl {
-
- @Override
- public void onCreate(ActionBarActivity activity, Bundle savedInstanceState) {
- }
-
- private void ensureSubDecor(ActionBarActivity activity) {
- if (activity.mHasActionBar && !activity.mSubDecorInstalled) {
- if (activity.mOverlayActionBar) {
- activity.superSetContentView(R.layout.action_bar_decor_overlay);
- } else {
- activity.superSetContentView(R.layout.action_bar_decor);
- }
- }
- }
-
- @Override
- public void setContentView(ActionBarActivity activity, View v) {
- ensureSubDecor(activity);
- if (activity.mHasActionBar) {
- final ViewGroup contentParent =
- (ViewGroup) activity.findViewById(R.id.action_bar_activity_content);
- contentParent.removeAllViews();
- contentParent.addView(v);
- } else {
- activity.superSetContentView(v);
- }
- }
-
- @Override
- public void setContentView(ActionBarActivity activity, int resId) {
- ensureSubDecor(activity);
- if (activity.mHasActionBar) {
- final ViewGroup contentParent =
- (ViewGroup) activity.findViewById(R.id.action_bar_activity_content);
- contentParent.removeAllViews();
- final LayoutInflater inflater = activity.getLayoutInflater();
- inflater.inflate(resId, contentParent);
- } else {
- activity.superSetContentView(resId);
- }
- }
-
- @Override
- public void setContentView(ActionBarActivity activity, View v, ViewGroup.LayoutParams lp) {
- ensureSubDecor(activity);
- if (activity.mHasActionBar) {
- final ViewGroup contentParent =
- (ViewGroup) activity.findViewById(R.id.action_bar_activity_content);
- contentParent.removeAllViews();
- contentParent.addView(v, lp);
- } else {
- activity.superSetContentView(v, lp);
- }
- }
-
- @Override
- public void addContentView(ActionBarActivity activity, View v, ViewGroup.LayoutParams lp) {
- ensureSubDecor(activity);
- if (activity.mHasActionBar) {
- final ViewGroup contentParent =
- (ViewGroup) activity.findViewById(R.id.action_bar_activity_content);
- contentParent.addView(v, lp);
- } else {
- activity.superSetContentView(v, lp);
- }
- }
-
- @Override
- public ActionBar createActionBar(ActionBarActivity activity) {
- return new ActionBarImplCompat(activity, activity);
- }
-
- @Override
- public void requestWindowFeature(ActionBarActivity activity, int feature) {
- if (feature == FEATURE_ACTION_BAR) {
- activity.mHasActionBar = true;
- } else if (feature == FEATURE_ACTION_BAR_OVERLAY) {
- activity.mOverlayActionBar = true;
- }
- }
-
- }
-
- static class ActionBarActivityImplHC implements ActionBarActivityImpl {
-
- @Override
- public void onCreate(ActionBarActivity activity, Bundle savedInstanceState) {
- if (activity.mHasActionBar) {
- // If action bar is requested by inheriting from the appcompat theme,
- // the system will not know about that. So explicitly request for an action bar.
- activity.superRequestWindowFeature(FEATURE_ACTION_BAR);
- }
- if (activity.mOverlayActionBar) {
- activity.superRequestWindowFeature(FEATURE_ACTION_BAR_OVERLAY);
- }
- }
-
- @Override
- public void setContentView(ActionBarActivity activity, View v) {
- activity.superSetContentView(v);
- }
-
- @Override
- public void setContentView(ActionBarActivity activity, int resId) {
- activity.superSetContentView(resId);
- }
-
- @Override
- public void setContentView(ActionBarActivity activity, View v, ViewGroup.LayoutParams lp) {
- activity.superSetContentView(v, lp);
- }
-
- @Override
- public void addContentView(ActionBarActivity activity, View v, ViewGroup.LayoutParams lp) {
- activity.superAddContentView(v, lp);
- }
-
- @Override
- public ActionBar createActionBar(ActionBarActivity activity) {
- return new ActionBarImplHC(activity, activity);
- }
-
- @Override
- public void requestWindowFeature(ActionBarActivity activity, int feature) {
- activity.superRequestWindowFeature(feature);
- }
-
- }
-
- static class ActionBarActivityImplICS extends ActionBarActivityImplHC {
-
- @Override
- public ActionBar createActionBar(ActionBarActivity activity) {
- return new ActionBarImplICS(activity, activity);
- }
- }
-
- static final ActionBarActivityImpl IMPL;
-
- static {
- final int version = android.os.Build.VERSION.SDK_INT;
- if (version >= 14) {
- IMPL = new ActionBarActivityImplICS();
- } else if (version >= 11) {
- IMPL = new ActionBarActivityImplHC();
- } else {
- IMPL = new ActionBarActivityImplBase();
- }
- }
-
- private ActionBar mActionBar;
-
- // true if the compatibility implementation has installed a window sub-decor layout.
- boolean mSubDecorInstalled;
-
- // true if this activity has an action bar.
- boolean mHasActionBar;
-
- // true if this activity's action bar overlays other activity content.
- boolean mOverlayActionBar;
-
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- TypedArray a = obtainStyledAttributes(R.styleable.ActionBarWindow);
- mHasActionBar = a.getBoolean(R.styleable.ActionBarWindow_windowActionBar, false);
- mOverlayActionBar = a.getBoolean(R.styleable.ActionBarWindow_windowActionBarOverlay,
- false);
- a.recycle();
-
- IMPL.onCreate(this, savedInstanceState);
- }
-
- public ActionBar getSupportActionBar() {
- initActionBar();
- return mActionBar;
- }
-
- private void initActionBar() {
- if (mActionBar == null && mHasActionBar) {
- mActionBar = IMPL.createActionBar(this);
- }
- }
-
- /**
- * Set the activity content from a layout resource. The resource will be inflated, adding all
- * top-level views to the activity.
- *
- * @param layoutResID Resource ID to be inflated.
- * @see #setContentView(android.view.View)
- * @see #setContentView(android.view.View, android.view.ViewGroup.LayoutParams)
- */
- @Override
- public void setContentView(int layoutResID) {
- IMPL.setContentView(this, layoutResID);
- }
-
- /**
- * Set the activity content to an explicit view. This view is placed directly into the
- * activity's view hierarchy. It can itself be a complex view hierarchy. When calling this
- * method, the layout parameters of the specified view are ignored. Both the width and the
- * height of the view are set by default to {@link ViewGroup.LayoutParams#MATCH_PARENT}. To use
- * your own layout parameters, invoke {@link #setContentView(android.view.View,
- * android.view.ViewGroup.LayoutParams)} instead.
- *
- * @param view The desired content to display.
- * @see #setContentView(int)
- * @see #setContentView(android.view.View, android.view.ViewGroup.LayoutParams)
- */
- @Override
- public void setContentView(View view) {
- IMPL.setContentView(this, view);
- }
-
- /**
- * Set the activity content to an explicit view. This view is placed directly into the
- * activity's view hierarchy. It can itself be a complex view hierarchy.
- *
- * @param view The desired content to display.
- * @param params Layout parameters for the view.
- * @see #setContentView(android.view.View)
- * @see #setContentView(int)
- */
- @Override
- public void setContentView(View view, ViewGroup.LayoutParams params) {
- IMPL.setContentView(this, view, params);
- }
-
- void superSetContentView(int resId) {
- super.setContentView(resId);
- }
-
- void superSetContentView(View v) {
- super.setContentView(v);
- }
-
- void superSetContentView(View v, ViewGroup.LayoutParams lp) {
- super.setContentView(v, lp);
- }
-
- void superAddContentView(View v, ViewGroup.LayoutParams lp) {
- super.addContentView(v, lp);
- }
-
- void superRequestWindowFeature(int feature) {
- super.requestWindowFeature(feature);
- }
-}
diff --git a/appcompat/proguard-project.txt b/appcompat/proguard-project.txt
deleted file mode 100644
index f2fe155..0000000
--- a/appcompat/proguard-project.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# To enable ProGuard in your project, edit project.properties
-# to define the proguard.config property as described in that file.
-#
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in ${sdk.dir}/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the ProGuard
-# include property in project.properties.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/appcompat/res/drawable-hdpi/ab_bottom_solid_inverse_holo.9.png b/appcompat/res/drawable-hdpi/ab_bottom_solid_inverse_holo.9.png
deleted file mode 100644
index 88f11dc..0000000
--- a/appcompat/res/drawable-hdpi/ab_bottom_solid_inverse_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/list_selector_background_disabled.9.png b/appcompat/res/drawable-hdpi/list_selector_background_disabled.9.png
deleted file mode 100644
index 05b1419..0000000
--- a/appcompat/res/drawable-hdpi/list_selector_background_disabled.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/list_selector_background_focused.9.png b/appcompat/res/drawable-hdpi/list_selector_background_focused.9.png
deleted file mode 100644
index 60bb454..0000000
--- a/appcompat/res/drawable-hdpi/list_selector_background_focused.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/list_selector_background_longpress.9.png b/appcompat/res/drawable-hdpi/list_selector_background_longpress.9.png
deleted file mode 100644
index 19558e9..0000000
--- a/appcompat/res/drawable-hdpi/list_selector_background_longpress.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/list_selector_background_pressed.9.png b/appcompat/res/drawable-hdpi/list_selector_background_pressed.9.png
deleted file mode 100644
index 0f3b444..0000000
--- a/appcompat/res/drawable-hdpi/list_selector_background_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/minitab_lt_focus.9.png b/appcompat/res/drawable-hdpi/minitab_lt_focus.9.png
deleted file mode 100644
index 3ba8376..0000000
--- a/appcompat/res/drawable-hdpi/minitab_lt_focus.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/minitab_lt_press.9.png b/appcompat/res/drawable-hdpi/minitab_lt_press.9.png
deleted file mode 100644
index df226c7..0000000
--- a/appcompat/res/drawable-hdpi/minitab_lt_press.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/minitab_lt_selected.9.png b/appcompat/res/drawable-hdpi/minitab_lt_selected.9.png
deleted file mode 100644
index bb417e6..0000000
--- a/appcompat/res/drawable-hdpi/minitab_lt_selected.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/minitab_lt_unselected.9.png b/appcompat/res/drawable-hdpi/minitab_lt_unselected.9.png
deleted file mode 100644
index d9ef49e..0000000
--- a/appcompat/res/drawable-hdpi/minitab_lt_unselected.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/minitab_lt_unselected_press.9.png b/appcompat/res/drawable-hdpi/minitab_lt_unselected_press.9.png
deleted file mode 100644
index 383c4fc..0000000
--- a/appcompat/res/drawable-hdpi/minitab_lt_unselected_press.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/spinner_white_16.png b/appcompat/res/drawable-hdpi/spinner_white_16.png
deleted file mode 100644
index 32fa447..0000000
--- a/appcompat/res/drawable-hdpi/spinner_white_16.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-ldpi/list_selector_background_disabled.9.png b/appcompat/res/drawable-ldpi/list_selector_background_disabled.9.png
deleted file mode 100644
index b94396b..0000000
--- a/appcompat/res/drawable-ldpi/list_selector_background_disabled.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-ldpi/list_selector_background_longpress.9.png b/appcompat/res/drawable-ldpi/list_selector_background_longpress.9.png
deleted file mode 100644
index 1fb46bb..0000000
--- a/appcompat/res/drawable-ldpi/list_selector_background_longpress.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-ldpi/list_selector_background_pressed.9.png b/appcompat/res/drawable-ldpi/list_selector_background_pressed.9.png
deleted file mode 100644
index 4980eab..0000000
--- a/appcompat/res/drawable-ldpi/list_selector_background_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-ldpi/spinner_white_16.png b/appcompat/res/drawable-ldpi/spinner_white_16.png
deleted file mode 100644
index 0ad9eb0..0000000
--- a/appcompat/res/drawable-ldpi/spinner_white_16.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/ab_bottom_solid_inverse_holo.9.png b/appcompat/res/drawable-mdpi/ab_bottom_solid_inverse_holo.9.png
deleted file mode 100644
index c65f443..0000000
--- a/appcompat/res/drawable-mdpi/ab_bottom_solid_inverse_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/list_selector_background_disabled.9.png b/appcompat/res/drawable-mdpi/list_selector_background_disabled.9.png
deleted file mode 100644
index 8ad0b32..0000000
--- a/appcompat/res/drawable-mdpi/list_selector_background_disabled.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/list_selector_background_focused.9.png b/appcompat/res/drawable-mdpi/list_selector_background_focused.9.png
deleted file mode 100644
index 5b1f195..0000000
--- a/appcompat/res/drawable-mdpi/list_selector_background_focused.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/list_selector_background_longpress.9.png b/appcompat/res/drawable-mdpi/list_selector_background_longpress.9.png
deleted file mode 100644
index fbf7ef0..0000000
--- a/appcompat/res/drawable-mdpi/list_selector_background_longpress.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/list_selector_background_pressed.9.png b/appcompat/res/drawable-mdpi/list_selector_background_pressed.9.png
deleted file mode 100644
index dd2a024..0000000
--- a/appcompat/res/drawable-mdpi/list_selector_background_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/minitab_lt_focus.9.png b/appcompat/res/drawable-mdpi/minitab_lt_focus.9.png
deleted file mode 100644
index 415c571..0000000
--- a/appcompat/res/drawable-mdpi/minitab_lt_focus.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/minitab_lt_press.9.png b/appcompat/res/drawable-mdpi/minitab_lt_press.9.png
deleted file mode 100644
index 4166543..0000000
--- a/appcompat/res/drawable-mdpi/minitab_lt_press.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/minitab_lt_selected.9.png b/appcompat/res/drawable-mdpi/minitab_lt_selected.9.png
deleted file mode 100644
index fefa27e..0000000
--- a/appcompat/res/drawable-mdpi/minitab_lt_selected.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/minitab_lt_unselected.9.png b/appcompat/res/drawable-mdpi/minitab_lt_unselected.9.png
deleted file mode 100644
index 0051cd5..0000000
--- a/appcompat/res/drawable-mdpi/minitab_lt_unselected.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/minitab_lt_unselected_press.9.png b/appcompat/res/drawable-mdpi/minitab_lt_unselected_press.9.png
deleted file mode 100644
index 69444dd..0000000
--- a/appcompat/res/drawable-mdpi/minitab_lt_unselected_press.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/spinner_white_16.png b/appcompat/res/drawable-mdpi/spinner_white_16.png
deleted file mode 100644
index 650e315..0000000
--- a/appcompat/res/drawable-mdpi/spinner_white_16.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/ab_bottom_solid_inverse_holo.9.png b/appcompat/res/drawable-xhdpi/ab_bottom_solid_inverse_holo.9.png
deleted file mode 100644
index 7e6c047..0000000
--- a/appcompat/res/drawable-xhdpi/ab_bottom_solid_inverse_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/list_selector_background_disabled.9.png b/appcompat/res/drawable-xhdpi/list_selector_background_disabled.9.png
deleted file mode 100644
index f039081..0000000
--- a/appcompat/res/drawable-xhdpi/list_selector_background_disabled.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/list_selector_background_focused.9.png b/appcompat/res/drawable-xhdpi/list_selector_background_focused.9.png
deleted file mode 100644
index c8e7681..0000000
--- a/appcompat/res/drawable-xhdpi/list_selector_background_focused.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/list_selector_background_longpress.9.png b/appcompat/res/drawable-xhdpi/list_selector_background_longpress.9.png
deleted file mode 100644
index 73fc783..0000000
--- a/appcompat/res/drawable-xhdpi/list_selector_background_longpress.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/list_selector_background_pressed.9.png b/appcompat/res/drawable-xhdpi/list_selector_background_pressed.9.png
deleted file mode 100644
index 5b3ebe1..0000000
--- a/appcompat/res/drawable-xhdpi/list_selector_background_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/minitab_lt_focus.9.png b/appcompat/res/drawable-xhdpi/minitab_lt_focus.9.png
deleted file mode 100644
index 7a0995b..0000000
--- a/appcompat/res/drawable-xhdpi/minitab_lt_focus.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/minitab_lt_press.9.png b/appcompat/res/drawable-xhdpi/minitab_lt_press.9.png
deleted file mode 100644
index 7602d3e..0000000
--- a/appcompat/res/drawable-xhdpi/minitab_lt_press.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/minitab_lt_selected.9.png b/appcompat/res/drawable-xhdpi/minitab_lt_selected.9.png
deleted file mode 100644
index 544fad5..0000000
--- a/appcompat/res/drawable-xhdpi/minitab_lt_selected.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/minitab_lt_unselected.9.png b/appcompat/res/drawable-xhdpi/minitab_lt_unselected.9.png
deleted file mode 100644
index bcdb9d7..0000000
--- a/appcompat/res/drawable-xhdpi/minitab_lt_unselected.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/minitab_lt_unselected_press.9.png b/appcompat/res/drawable-xhdpi/minitab_lt_unselected_press.9.png
deleted file mode 100644
index 8aabb89..0000000
--- a/appcompat/res/drawable-xhdpi/minitab_lt_unselected_press.9.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/spinner_white_16.png b/appcompat/res/drawable-xhdpi/spinner_white_16.png
deleted file mode 100644
index 69be752..0000000
--- a/appcompat/res/drawable-xhdpi/spinner_white_16.png
+++ /dev/null
Binary files differ
diff --git a/appcompat/res/drawable/action_bar_divider.xml b/appcompat/res/drawable/action_bar_divider.xml
deleted file mode 100644
index 3e0bff2..0000000
--- a/appcompat/res/drawable/action_bar_divider.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<shape xmlns:android="http://schemas.android.com/apk/res/android">
- <gradient
- android:startColor="#ffe1e2e4"
- android:endColor="#ff95979a"
- android:angle="270"/>
-</shape>
diff --git a/appcompat/res/values-v11/styles.xml b/appcompat/res/values-v11/styles.xml
deleted file mode 100644
index ddcd918..0000000
--- a/appcompat/res/values-v11/styles.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<resources>
- <!-- Patterned after style name="Widget.Holo.Light.ActionBar.Solid" -->
- <style name="Widget.AppCompat.ActionBar.Solid" parent="@android:style/Widget.Holo.ActionBar">
- <item name="android:background">@drawable/ab_solid_light_holo</item>
- <item name="android:backgroundStacked">@drawable/ab_stacked_solid_light_holo</item>
- <item name="android:backgroundSplit">@drawable/ab_bottom_solid_light_holo</item>
- </style>
-
- <!-- Patterned after style name="Widget.Holo.Light.ActionBar.Solid.Inverse" -->
- <style name="Widget.AppCompat.ActionBar.Solid.Inverse"
- parent="@android:style/Widget.Holo.ActionBar">
- <item name="android:background">@drawable/ab_solid_dark_holo</item>
- <item name="android:backgroundStacked">@drawable/ab_stacked_solid_dark_holo</item>
- <item name="android:backgroundSplit">@drawable/ab_bottom_solid_inverse_holo</item>
- </style>
-</resources>
diff --git a/appcompat/res/values-v11/themes.xml b/appcompat/res/values-v11/themes.xml
deleted file mode 100644
index 1ab948b..0000000
--- a/appcompat/res/values-v11/themes.xml
+++ /dev/null
@@ -1,110 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<resources>
- <!-- Themes in the "Theme.Base" family vary based on the current platform
- version to provide the correct basis on each device. You probably don't
- want to use them directly in your apps.
-
- Themes in the "Theme.AppCompat" family are meant to be extended or used
- directly by apps.
-
- This is the values-v11/ file that only declares the Base themes for
- Honeycomb+. You probably want to edit values/themes.xml instead. -->
- <eat-comment/>
-
- <!-- Base platform-dependent theme providing an action bar in a dark-themed activity. -->
- <style name="Theme.Base.AppCompat" parent="@android:style/Theme.Holo">
-
- <item name="buttonBarStyle">?attr/buttonBarStyle</item>
- <item name="buttonBarButtonStyle">?attr/buttonBarButtonStyle</item>
- <item name="selectableItemBackground">?attr/selectableItemBackground</item>
-
- <item name="dividerVertical">?attr/dividerVertical</item>
- <item name="dividerHorizontal">?attr/dividerHorizontal</item>
- <item name="actionBarDivider">?attr/dividerVertical</item>
-
- <item name="listPreferredItemHeight">?android:attr/listPreferredItemHeight</item>
- <item name="listPreferredItemHeightSmall">48dp</item>
- <item name="listPreferredItemHeightLarge">80dp</item>
-
- <item name="listPreferredItemPaddingLeft">8dip</item>
- <item name="listPreferredItemPaddingRight">8dip</item>
-
- <item name="textAppearanceListItem">?android:attr/textAppearanceMedium</item>
- <item name="textAppearanceListItemSmall">?android:attr/textAppearanceMedium</item>
-
- <item name="actionBarSize">?attr/actionBarSize</item>
-
- <!-- Redirect compatibility styles to the real ones that exist here -->
- <item name="actionBarStyle">?attr/actionBarStyle</item>
- <item name="actionBarTabStyle">?attr/actionBarTabStyle</item>
- <item name="actionBarTabBarStyle">?attr/actionBarTabBarStyle</item>
- </style>
-
- <!-- Base platform-dependent theme providing an action bar in a light-themed activity. -->
- <style name="Theme.Base.AppCompat.Light" parent="@android:style/Theme.Holo.Light">
- <item name="buttonBarStyle">?attr/buttonBarStyle</item>
- <item name="buttonBarButtonStyle">?attr/buttonBarButtonStyle</item>
- <item name="selectableItemBackground">?attr/selectableItemBackground</item>
-
- <item name="dividerVertical">?attr/dividerVertical</item>
- <item name="dividerHorizontal">?attr/dividerHorizontal</item>
- <item name="actionBarDivider">?attr/dividerVertical</item>
-
- <item name="listPreferredItemHeight">?android:attr/listPreferredItemHeight</item>
- <item name="listPreferredItemHeightSmall">48dp</item>
- <item name="listPreferredItemHeightLarge">80dp</item>
-
- <item name="listPreferredItemPaddingLeft">8dip</item>
- <item name="listPreferredItemPaddingRight">8dip</item>
-
- <item name="textAppearanceListItem">@android:attr/textAppearanceMedium</item>
- <item name="textAppearanceListItemSmall">@android:attr/textAppearanceMedium</item>
-
- <!-- Redirect compatibility styles to the real ones that exist here -->
- <item name="actionBarStyle">?attr/actionBarStyle</item>
- <item name="actionBarTabStyle">?attr/actionBarTabStyle</item>
- <item name="actionBarTabBarStyle">?attr/actionBarTabBarStyle</item>
- </style>
-
- <!-- Base platform-dependent theme providing a dark action bar in a light-themed activity. -->
- <style name="Theme.Base.AppCompat.Light.DarkActionBar" parent="Theme.Base.AppCompat.Light">
- <item name="actionBarDivider">@drawable/appcompat_divider_dark</item>
- <item name="android:actionBarStyle">@style/Widget.AppCompat.ActionBar.Solid.Inverse</item>
- </style>
-
- <!-- Base platform-dependent theme providing an action bar in a dark-themed activity.
- This theme will follow the device's default styling if available. -->
- <style name="Theme.Base.AppCompat.DeviceDefault" parent="Theme.Base.AppCompat">
- <!-- Remove system title bars; we will add the action bar ourselves. -->
- <item name="android:windowNoTitle">true</item>
- </style>
-
- <!-- Base platform-dependent theme providing an action bar in a light-themed activity.
- This theme will follow the device's default styling if available. -->
- <style name="Theme.Base.AppCompat.DeviceDefault.Light" parent="Theme.Base.AppCompat.Light">
- <!-- Remove system title bars; we will add the action bar ourselves. -->
- <item name="android:windowNoTitle">true</item>
- </style>
-
- <!-- Base platform-dependent theme providing a dark action bar in a light-themed activity.
- This theme will follow the device's default styling if available. -->
- <style name="Theme.Base.AppCompat.DeviceDefault.Light.DarkActionBar"
- parent="Theme.Base.AppCompat.Light.DarkActionBar">
- </style>
-
-</resources>
diff --git a/appcompat/res/values-v14/themes.xml b/appcompat/res/values-v14/themes.xml
deleted file mode 100644
index 3255b6f..0000000
--- a/appcompat/res/values-v14/themes.xml
+++ /dev/null
@@ -1,113 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<resources>
- <!-- Themes in the "Theme.Base" family vary based on the current platform
- version to provide the correct basis on each device. You probably don't
- want to use them directly in your apps.
-
- Themes in the "Theme.AppCompat" family are meant to be extended or used
- directly by apps.
-
- This is the values-v14/ file that only declares the Base themes for
- Ice Cream Sandwich+. You probably want to edit values/themes.xml instead. -->
- <eat-comment/>
-
- <!-- Base platform-dependent theme providing an action bar in a dark-themed activity. -->
- <style name="Theme.Base.AppCompat" parent="@android:style/Theme.Holo">
- <item name="buttonBarStyle">?attr/buttonBarStyle</item>
- <item name="buttonBarButtonStyle">?attr/buttonBarButtonStyle</item>
- <item name="selectableItemBackground">?attr/selectableItemBackground</item>
-
- <item name="dividerVertical">?attr/dividerVertical</item>
- <item name="dividerHorizontal">?attr/dividerHorizontal</item>
- <item name="actionBarDivider">?attr/actionBarDivider</item>
-
- <item name="listPreferredItemHeight">?attr/listPreferredItemHeight</item>
- <item name="listPreferredItemHeightSmall">?attr/listPreferredItemHeightSmall</item>
- <item name="listPreferredItemHeightLarge">?attr/listPreferredItemHeightLarge</item>
-
- <item name="listPreferredItemPaddingLeft">?attr/listPreferredItemPaddingLeft</item>
- <item name="listPreferredItemPaddingRight">?attr/listPreferredItemPaddingRight</item>
-
- <item name="textAppearanceListItem">?android:attr/textAppearanceMedium</item>
- <item name="textAppearanceListItemSmall">?android:attr/textAppearanceMedium</item>
-
- <!-- Redirect compatibility styles to the real ones that exist here -->
- <item name="actionBarStyle">?attr/actionBarStyle</item>
- <item name="actionBarTabStyle">?attr/actionBarTabStyle</item>
- <item name="actionBarTabBarStyle">?attr/actionBarTabBarStyle</item>
- <item name="actionBarWidgetTheme">?attr/actionBarWidgetTheme</item>
- </style>
-
- <!-- Base platform-dependent theme providing an action bar in a light-themed activity. -->
- <style name="Theme.Base.AppCompat.Light" parent="@android:style/Theme.Holo.Light">
- <item name="buttonBarStyle">?attr/buttonBarStyle</item>
- <item name="buttonBarButtonStyle">?attr/buttonBarButtonStyle</item>
- <item name="selectableItemBackground">?attr/selectableItemBackground</item>
-
- <item name="dividerVertical">?attr/dividerVertical</item>
- <item name="dividerHorizontal">?attr/dividerHorizontal</item>
- <item name="actionBarDivider">?attr/actionBarDivider</item>
-
- <item name="listPreferredItemHeight">?attr/listPreferredItemHeight</item>
- <item name="listPreferredItemHeightSmall">?attr/listPreferredItemHeightSmall</item>
- <item name="listPreferredItemHeightLarge">?attr/listPreferredItemHeightLarge</item>
-
- <item name="listPreferredItemPaddingLeft">?attr/listPreferredItemPaddingLeft</item>
- <item name="listPreferredItemPaddingRight">?attr/listPreferredItemPaddingRight</item>
-
- <item name="textAppearanceListItem">@android:attr/textAppearanceMedium</item>
- <item name="textAppearanceListItemSmall">@android:attr/textAppearanceMedium</item>
-
- <!-- Redirect compatibility styles to the real ones that exist here -->
- <item name="actionBarStyle">?attr/actionBarStyle</item>
- <item name="actionBarTabStyle">?attr/actionBarTabStyle</item>
- <item name="actionBarTabBarStyle">?attr/actionBarTabBarStyle</item>
- <item name="actionBarWidgetTheme">?attr/actionBarWidgetTheme</item>
- </style>
-
- <!-- Base platform-dependent theme providing a dark action bar in a light-themed activity. -->
- <!--<style name="Theme.Base.AppCompat.Light.DarkActionBar"
- parent="@android:style/Theme.Holo.Light.DarkActionBar">-->
- <style name="Theme.Base.AppCompat.Light.DarkActionBar"
- parent="@android:style/Theme.Holo.Light.DarkActionBar">
- <item name="actionBarDivider">?attr/actionBarDivider</item>
- <item name="actionBarWidgetTheme">?attr/actionBarWidgetTheme</item>
- </style>
-
- <!-- Base platform-dependent theme providing an action bar in a dark-themed activity.
- This theme will follow the device's default styling if available. -->
- <!-- TODO(trevorjohns): DeviceDefault is not available. What do we do? -->
- <!--<style name="Theme.Base.AppCompat.DeviceDefault"
- parent="@android:style/Theme.DeviceDefault">
- </style>-->
-
- <!-- Base platform-dependent theme providing an action bar in a light-themed activity.
- This theme will follow the device's default styling if available. -->
- <!-- TODO(trevorjohns): DeviceDefault is not available. What do we do? -->
- <!--<style name="Theme.Base.AppCompat.DeviceDefault.Light"-->
- <!--parent="@android:style/Theme.DeviceDefault.Light">-->
- <!--</style>-->
-
- <!-- Base platform-dependent theme providing a dark action bar in a light-themed activity.
- This theme will follow the device's default styling if available. -->
- <!-- TODO(trevorjohns): DeviceDefault is not available. What do we do? -->
- <!--<style name="Theme.Base.AppCompat.DeviceDefault.Light.DarkActionBar"-->
- <!--parent="@android:style/Theme.DeviceDefault.Light.DarkActionBar">-->
- <!--</style>-->
-
-</resources>
diff --git a/appcompat/res/values/styles.xml b/appcompat/res/values/styles.xml
deleted file mode 100644
index 429ef2f..0000000
--- a/appcompat/res/values/styles.xml
+++ /dev/null
@@ -1,167 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<resources>
- <!-- Like in themes.xml, the namespace "*.AppCompat.Base" is used to
- define base styles for the platform version. The "*.AppCompat"
- variants are for direct use or use as parent styles by the app. -->
- <eat-comment/>
-
- <style name="Widget.AppCompat.Base.ActionBar" parent="">
- </style>
-
- <style name="Widget.AppCompat.Base.ActionButton" parent="">
- </style>
-
- <style name="Widget.AppCompat.Base.ActionButton.Overflow">
- </style>
-
- <style name="Widget.AppCompat.Base.ActionBar.TabBar" parent="">
- </style>
-
- <style name="Widget.AppCompat.Base.ActionBar.TabView" parent="">
- </style>
-
- <style name="Widget.AppCompat.Base.ActionBar.TabText" parent="">
- </style>
-
- <style name="Widget.AppCompat.Base.ActionMode" parent="">
- </style>
-
-
- <style name="TextAppearance.AppCompat.Base.Widget.ActionBar.Menu"
- parent="@android:style/TextAppearance.Small">
- </style>
-
- <!-- Default action bar style. Remember that if you are overriding
- any attributes here in a derived style, you should declare each
- item twice - both with and without the "android:" namespace prefix. -->
- <style name="Widget.AppCompat.ActionBar" parent="Widget.AppCompat.Base.ActionBar">
- <item name="background">@drawable/action_bar_background</item>
- <item name="displayOptions">useLogo|showHome|showTitle</item>
- <item name="divider">@drawable/action_bar_divider</item>
- <item name="height">?attr/actionBarSize</item>
- <item name="titleTextStyle">@style/TextAppearance.Widget.AppCompat.ActionBar.Title</item>
- <item name="subtitleTextStyle">@style/TextAppearance.Widget.AppCompat.ActionBar.Subtitle
- </item>
- <item name="progressBarStyle">@style/Widget.AppCompat.ProgressBar.Horizontal</item>
- <item name="indeterminateProgressStyle">@style/Widget.AppCompat.ProgressBar.Small</item>
- <item name="homeLayout">@layout/action_bar_home</item>
- </style>
-
- <style name="Widget.AppCompat.Light.ActionBar" parent="Widget.AppCompat.ActionBar">
- <item name="titleTextStyle">@style/TextAppearance.Widget.AppCompat.ActionBar.Title</item>
- <item name="subtitleTextStyle">@style/TextAppearance.Widget.AppCompat.ActionBar.Subtitle
- </item>
- <item name="background">@drawable/ab_transparent_light_holo</item>
- <item name="backgroundStacked">@drawable/ab_stacked_transparent_light_holo</item>
- <item name="backgroundSplit">@drawable/ab_bottom_transparent_light_holo</item>
- <item name="homeAsUpIndicator">@drawable/ic_ab_back_holo_light</item>
- <!-- TODO(trevorjohns): Action Bar styles below are from Holo. Port over rest of Holo? -->
- <!--<item name="progressBarStyle">@style/Widget.AppCompat.Light.ProgressBar.Horizontal</item>-->
- <!--<item name="indeterminateProgressStyle">@style/Widget.AppCompat.Light.ProgressBar</item>-->
- </style>
-
- <style name="TextAppearance.Widget.AppCompat.ActionBar.Title"
- parent="@android:style/TextAppearance.Medium">
- </style>
- <style name="TextAppearance.Widget.AppCompat.ActionBar.Subtitle"
- parent="@android:style/TextAppearance.Small">
- </style>
-
- <style name="Widget.AppCompat.ProgressBar.Horizontal" parent="android:Widget.ProgressBar">
- <item name="android:indeterminateOnly">false</item>
- <item name="android:progressDrawable">@android:drawable/progress_horizontal</item>
- <item name="android:indeterminateDrawable">
- @android:drawable/progress_indeterminate_horizontal
- </item>
- <item name="android:minHeight">20dip</item>
- <item name="android:maxHeight">20dip</item>
- </style>
-
- <style name="Widget.AppCompat.ProgressBar.Small" parent="android:Widget.ProgressBar">
- <item name="android:indeterminateDrawable">@drawable/progress_small_white</item>
- <item name="android:minWidth">16dip</item>
- <item name="android:maxWidth">16dip</item>
- <item name="android:minHeight">16dip</item>
- <item name="android:maxHeight">16dip</item>
- </style>
-
-
- <!-- TODO(anirudhd): The item below doesn't work. -->
- <!--<style name="Widget.AppCompat.ListPopupWindow">-->
- <!--<item name="android:dropDownSelector">@android:drawable/list_selector_background</item>-->
- <!--<item name="android:popupBackground">@android:drawable/spinner_dropdown_background</item>-->
- <!--<item name="android:dropDownWidth">wrap_content</item>-->
- <!--</style>-->
-
- <!--<style name="Widget.AppCompat.PopupMenu" parent="Widget.AppCompat.ListPopupWindow">-->
- <!--</style>-->
-
- <style name="Widget.AppCompat.ActionButton" parent="Widget.AppCompat.Base.ActionButton">
- </style>
-
- <style name="Widget.AppCompat.ActionButton.Overflow">
- </style>
-
- <style name="Widget.AppCompat.ActionBar.TabBar" parent="Widget.AppCompat.Base.ActionBar.TabBar">
- </style>
-
- <style name="Widget.AppCompat.ActionBar.TabView"
- parent="Widget.AppCompat.Base.ActionBar.TabView">
- </style>
-
- <style name="Widget.AppCompat.ActionBar.TabText"
- parent="Widget.AppCompat.Base.ActionBar.TabText">
- <item name="android:maxWidth">180dip</item>
- <item name="android:textAppearance">@android:style/TextAppearance.Widget.TextView</item>
- <item name="android:textColor">?android:attr/textColorPrimary</item>
- <item name="android:textSize">18sp</item>
- </style>
-
- <style name="TextAppearance.AppCompat.Widget.ActionBar.Menu"
- parent="TextAppearance.AppCompat.Base.Widget.ActionBar.Menu">
- <item name="android:textSize">12sp</item>
- <item name="android:textStyle">bold</item>
- <item name="android:textColor">?attr/actionMenuTextColor</item>
- </style>
-
-
- <style name="Widget.AppCompat.ActionMode" parent="Widget.AppCompat.Base.ActionMode">
- <item name="android:background">?attr/actionModeBackground</item>
- <item name="backgroundSplit">?attr/actionModeSplitBackground</item>
- <item name="android:height">?attr/actionBarSize</item>
- <item name="titleTextStyle">@style/TextAppearance.Widget.ActionMode.Title</item>
- <item name="subtitleTextStyle">@style/TextAppearance.Widget.ActionMode.Subtitle</item>
- </style>
-
- <style name="TextAppearance.Widget.ActionMode.Title"
- parent="@android:style/TextAppearance.Medium">
- </style>
-
- <style name="TextAppearance.Widget.ActionMode.Subtitle"
- parent="@android:style/TextAppearance.Small">
- <item name="android:textColor">?android:attr/textColorSecondary</item>
- </style>
-
- <style name="Widget.ActionBar.TabView" parent="Widget.AppCompat.ActionBar">
- <item name="android:gravity">center_horizontal</item>
- <item name="android:background">@drawable/minitab_lt</item>
- <item name="paddingStart">4dip</item>
- <item name="paddingEnd">4dip</item>
- </style>
-
-</resources>
diff --git a/appcompat/res/values/themes.xml b/appcompat/res/values/themes.xml
deleted file mode 100644
index 20dc19c..0000000
--- a/appcompat/res/values/themes.xml
+++ /dev/null
@@ -1,198 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<resources>
- <!-- Themes in the "Theme.Base" family vary based on the current platform
- version to provide the correct basis on each device. You probably don't
- want to use them directly in your apps.
-
- Themes in the "Theme.AppCompat" family are meant to be extended or used
- directly by apps. -->
- <eat-comment/>
-
- <!-- Base platform-dependent theme providing an action bar in a dark-themed activity. -->
- <style name="Theme.Base.AppCompat" parent="@android:style/Theme">
- <!-- Remove system title bars; we will add the action bar ourselves. -->
- <item name="android:windowNoTitle">true</item>
-
- <item name="buttonBarStyle">@android:style/ButtonBar</item>
- <item name="buttonBarButtonStyle">@android:style/Widget.Button</item>
- <item name="selectableItemBackground">@drawable/item_background</item>
-
- <item name="dividerVertical">@drawable/appcompat_divider_dark</item>
- <item name="dividerHorizontal">@drawable/appcompat_divider_dark</item>
- <item name="actionBarDivider">?attr/dividerVertical</item>
-
- <item name="listPreferredItemHeight">?android:attr/listPreferredItemHeight</item>
- <item name="listPreferredItemHeightSmall">48dp</item>
- <item name="listPreferredItemHeightLarge">80dp</item>
-
- <item name="listPreferredItemPaddingLeft">8dip</item>
- <item name="listPreferredItemPaddingRight">8dip</item>
-
- <item name="textAppearanceListItem">?android:attr/textAppearanceMedium</item>
- <item name="textAppearanceListItemSmall">?android:attr/textAppearanceMedium</item>
-
- <!-- Button attributes -->
- <item name="homeAsUpIndicator">@drawable/ic_ab_back_holo_dark</item>
-
- <!-- List attributes -->
- <item name="dropdownListPreferredItemHeight">64dip</item>
- <item name="dropDownListViewStyle">@android:style/Widget.ListView.DropDown</item>
-
- <!-- TODO(trevorjohns): The item below doesn't work. -->
- <!-- <item name="popupMenuStyle">@android:style/Widget.PopupMenu</item> -->
- <!-- <item name="listPopupWindowStyle">@android:style/ListPopupWindow</item>-->
-
-
- </style>
-
- <!-- Base platform-dependent theme providing an action bar in a light-themed activity. -->
- <style name="Theme.Base.AppCompat.Light" parent="@android:style/Theme.Light">
- <!-- Remove system title bars; we will add the action bar ourselves. -->
- <item name="android:windowNoTitle">true</item>
-
- <item name="buttonBarStyle">@android:style/ButtonBar</item>
- <item name="buttonBarButtonStyle">@android:style/Widget.Button</item>
- <item name="selectableItemBackground">@drawable/item_background</item>
-
- <item name="dividerVertical">@drawable/appcompat_divider_light</item>
- <item name="dividerHorizontal">@drawable/appcompat_divider_light</item>
- <item name="actionBarDivider">?attr/dividerVertical</item>
-
- <item name="listPreferredItemHeight">?android:attr/listPreferredItemHeight</item>
- <item name="listPreferredItemHeightSmall">48dp</item>
- <item name="listPreferredItemHeightLarge">80dp</item>
-
- <item name="listPreferredItemPaddingLeft">8dip</item>
- <item name="listPreferredItemPaddingRight">8dip</item>
-
- <item name="textAppearanceListItem">?android:attr/textAppearanceMedium</item>
- <item name="textAppearanceListItemSmall">?android:attr/textAppearanceMedium</item>
-
- <!-- List attributes -->
- <item name="dropdownListPreferredItemHeight">64dip</item>
- <item name="dropDownListViewStyle">@android:style/Widget.ListView.DropDown</item>
-
- <!-- Button attributes -->
- <item name="homeAsUpIndicator">@drawable/ic_ab_back_holo_light</item>
- </style>
-
- <!-- Base platform-dependent theme providing a dark action bar in a light-themed activity. -->
- <style name="Theme.Base.AppCompat.Light.DarkActionBar" parent="Theme.Base.AppCompat.Light">
- <item name="actionBarDivider">@drawable/appcompat_divider_dark</item>
- </style>
-
- <!-- Base platform-dependent theme providing an action bar in a dark-themed activity.
- This theme will follow the device's default styling if available. -->
- <style name="Theme.Base.AppCompat.DeviceDefault" parent="Theme.Base.AppCompat">
- <!-- Remove system title bars; we will add the action bar ourselves. -->
- <item name="android:windowNoTitle">true</item>
- </style>
-
- <!-- Base platform-dependent theme providing an action bar in a light-themed activity.
- This theme will follow the device's default styling if available. -->
- <style name="Theme.Base.AppCompat.DeviceDefault.Light" parent="Theme.Base.AppCompat.Light">
- <!-- Remove system title bars; we will add the action bar ourselves. -->
- <item name="android:windowNoTitle">true</item>
- </style>
-
- <!-- Base platform-dependent theme providing a dark action bar in a light-themed activity.
- This theme will follow the device's default styling if available. -->
- <style name="Theme.Base.AppCompat.DeviceDefault.Light.DarkActionBar"
- parent="Theme.Base.AppCompat.Light.DarkActionBar">
- </style>
-
- <!-- Themes in the "Theme.AppCompat" family will contain an action bar by default.
- If Holo themes are available on the current platform version they will be used.
- A limited Holo-styled action bar will be provided on platform versions older
- than 3.0. (API 11)
-
- These theme declarations contain any version-independent specification. Items
- that need to vary based on platform version should be defined in the corresponding
- "Theme.Base" theme. -->
-
- <!-- Platform-independent theme providing an action bar in a dark-themed activity. -->
- <style name="Theme.AppCompat" parent="Theme.Base.AppCompat">
- <item name="windowActionBar">true</item>
- <item name="actionBarTabStyle">@style/Widget.AppCompat.ActionBar.TabView</item>
- <item name="actionBarTabBarStyle">@style/Widget.AppCompat.ActionBar.TabBar</item>
- <item name="actionBarTabTextStyle">@style/Widget.AppCompat.ActionBar.TabText</item>
- <item name="actionOverflowButtonStyle">@style/Widget.AppCompat.ActionButton.Overflow</item>
- <item name="actionBarStyle">@style/Widget.AppCompat.ActionBar</item>
- <item name="actionBarWidgetTheme">@null</item>
- <item name="actionBarSize">@dimen/action_bar_size</item>
- <item name="actionBarDivider">?attr/dividerHorizontal</item>
- <item name="actionBarItemBackground">?attr/selectableItemBackground</item>
- <item name="actionMenuTextAppearance">
- @style/TextAppearance.AppCompat.Widget.ActionBar.Menu
- </item>
- <item name="actionMenuTextColor">?android:attr/textColorPrimary</item>
- <item name="homeAsUpIndicator">@drawable/ic_ab_back_holo_dark</item>
- <!-- TODO(trevorjohns): Does not exist on API < 11. -->
- <!-- <item name="actionDropDownStyle">@android:style/Widget_Spinner_DropDown</item> -->
- </style>
-
- <!-- Platform-independent theme providing an action bar in a light-themed activity. -->
- <style name="Theme.AppCompat.Light" parent="Theme.Base.AppCompat.Light">
- <item name="windowActionBar">true</item>
- <item name="actionBarTabStyle">@style/Widget.AppCompat.ActionBar.TabView</item>
- <item name="actionBarTabBarStyle">@style/Widget.AppCompat.ActionBar.TabBar</item>
- <item name="actionBarTabTextStyle">@style/Widget.AppCompat.ActionBar.TabText</item>
- <item name="actionOverflowButtonStyle">@style/Widget.AppCompat.ActionButton.Overflow</item>
- <item name="actionBarStyle">@style/Widget.AppCompat.ActionBar</item>
- <item name="actionBarWidgetTheme">@null</item>
- <item name="actionBarSize">@dimen/action_bar_size</item>
- <item name="actionBarDivider">?attr/dividerHorizontal</item>
- <item name="actionBarItemBackground">?attr/selectableItemBackground</item>
- <item name="actionMenuTextAppearance">
- @style/TextAppearance.AppCompat.Widget.ActionBar.Menu
- </item>
- <item name="actionMenuTextColor">?android:attr/textColorPrimary</item>
- <item name="homeAsUpIndicator">@drawable/ic_ab_back_holo_light</item>
- <!-- TODO(trevorjohns): Does not exist on API < 11. -->
- <!-- <item name="actionDropDownStyle">@android:style/Widget_Spinner_DropDown</item> -->
- </style>
-
- <!-- Platform-independent theme providing an action bar in a dark-themed activity. -->
- <style name="Theme.AppCompat.Light.DarkActionBar"
- parent="Theme.Base.AppCompat.Light.DarkActionBar">
- <item name="windowActionBar">true</item>
- <!-- TODO(trevorjohns): Implement other values for theme. -->
- </style>
-
- <!-- Platform-independent theme providing an action bar in a dark-themed activity.
- This theme will follow the device's default styling if available. -->
- <style name="Theme.AppCompat.DeviceDefault" parent="Theme.Base.AppCompat.DeviceDefault">
- <item name="windowActionBar">true</item>
- <!-- TODO(trevorjohns): Implement other values for theme. -->
- </style>
-
- <!-- Platform-independent theme providing an action bar in a light-themed activity.
- This theme will follow the device's default styling if available. -->
- <style name="Theme.AppCompat.DeviceDefault.Light"
- parent="Theme.Base.AppCompat.DeviceDefault.Light">
- <item name="windowActionBar">true</item>
- <!-- TODO(trevorjohns): Implement other values for theme. -->
- </style>
-
- <!-- Platform-independent theme providing a dark action bar in a light-themed activity.
- This theme will follow the device's default styling if available. -->
- <style name="Theme.AppCompat.DeviceDefault.Light.DarkActionBar"
- parent="Theme.Base.AppCompat.DeviceDefault.Light.DarkActionBar">
- <item name="windowActionBar">true</item>
- </style>
-</resources>
diff --git a/renderscript/v8/Android.mk b/renderscript/v8/Android.mk
index e443480..5d9671a 100644
--- a/renderscript/v8/Android.mk
+++ b/renderscript/v8/Android.mk
@@ -35,4 +35,5 @@
include $(call all-makefiles-under, $(LOCAL_PATH))
-endif
\ No newline at end of file
+endif
+
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/Allocation.java b/renderscript/v8/java/src/android/support/v8/renderscript/Allocation.java
index 91cccab..31bfe72 100644
--- a/renderscript/v8/java/src/android/support/v8/renderscript/Allocation.java
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/Allocation.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2008-2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,8 @@
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.view.Surface;
import android.util.Log;
import android.util.TypedValue;
@@ -108,6 +110,35 @@
public static final int USAGE_GRAPHICS_TEXTURE = 0x0002;
/**
+ * USAGE_IO_INPUT The allocation will be used as SurfaceTexture
+ * consumer. This usage will cause the allocation to be created
+ * read only.
+ *
+ */
+ public static final int USAGE_IO_INPUT = 0x0020;
+
+ /**
+ * USAGE_IO_OUTPUT The allocation will be used as a
+ * SurfaceTexture producer. The dimensions and format of the
+ * SurfaceTexture will be forced to those of the allocation.
+ *
+ */
+ public static final int USAGE_IO_OUTPUT = 0x0040;
+
+ /**
+ * USAGE_SHARED The allocation's backing store will be inherited
+ * from another object (usually a Bitmap); calling appropriate
+ * copy methods will be significantly faster than if the entire
+ * allocation were copied every time.
+ *
+ * This is set by default for allocations created with
+ * CreateFromBitmap(RenderScript, Bitmap) in API version 18 and
+ * higher.
+ *
+ */
+ public static final int USAGE_SHARED = 0x0080;
+
+ /**
* Controls mipmap behavior when using the bitmap creation and
* update functions.
*/
@@ -193,12 +224,30 @@
}
}
+ private void setBitmap(Bitmap b) {
+ mBitmap = b;
+ }
+
Allocation(int id, RenderScript rs, Type t, int usage) {
super(id, rs);
- if ((usage & ~(USAGE_SCRIPT | USAGE_GRAPHICS_TEXTURE)) != 0) {
+ if ((usage & ~(USAGE_SCRIPT |
+ USAGE_GRAPHICS_TEXTURE |
+ USAGE_IO_INPUT |
+ USAGE_IO_OUTPUT |
+ USAGE_SHARED)) != 0) {
throw new RSIllegalArgumentException("Unknown usage specified.");
}
+ if ((usage & USAGE_IO_INPUT) != 0) {
+ mWriteAllowed = false;
+
+ if ((usage & ~(USAGE_IO_INPUT |
+ USAGE_GRAPHICS_TEXTURE |
+ USAGE_SCRIPT)) != 0) {
+ throw new RSIllegalArgumentException("Invalid usage combination.");
+ }
+ }
+
mType = t;
mUsage = usage;
@@ -281,6 +330,40 @@
mRS.nAllocationSyncAll(getIDSafe(), srcLocation);
}
+ /**
+ * Send a buffer to the output stream. The contents of the
+ * Allocation will be undefined after this operation.
+ *
+ */
+ public void ioSend() {
+ if ((mUsage & USAGE_IO_OUTPUT) == 0) {
+ throw new RSIllegalArgumentException(
+ "Can only send buffer if IO_OUTPUT usage specified.");
+ }
+ mRS.validate();
+ mRS.nAllocationIoSend(getID(mRS));
+ }
+
+ /**
+ * Delete once code is updated.
+ * @hide
+ */
+ public void ioSendOutput() {
+ ioSend();
+ }
+
+ /**
+ * Receive the latest input into the Allocation.
+ *
+ */
+ public void ioReceive() {
+ if ((mUsage & USAGE_IO_INPUT) == 0) {
+ throw new RSIllegalArgumentException(
+ "Can only receive if IO_INPUT usage specified.");
+ }
+ mRS.validate();
+ mRS.nAllocationIoReceive(getID(mRS));
+ }
/**
* Copy an array of RS objects to the allocation.
@@ -303,6 +386,9 @@
private void validateBitmapFormat(Bitmap b) {
Bitmap.Config bc = b.getConfig();
+ if (bc == null) {
+ throw new RSIllegalArgumentException("Bitmap has an unsupported format for this operation");
+ }
switch (bc) {
case ALPHA_8:
if (mType.getElement().mKind != Element.DataKind.PIXEL_A) {
@@ -362,7 +448,13 @@
*/
public void copyFromUnchecked(int[] d) {
mRS.validate();
- copy1DRangeFromUnchecked(0, mCurrentCount, d);
+ if (mCurrentDimZ > 0) {
+ copy3DRangeFromUnchecked(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
+ } else if (mCurrentDimY > 0) {
+ copy2DRangeFromUnchecked(0, 0, mCurrentDimX, mCurrentDimY, d);
+ } else {
+ copy1DRangeFromUnchecked(0, mCurrentCount, d);
+ }
}
/**
* Copy an allocation from an array. This variant is not type
@@ -373,7 +465,13 @@
*/
public void copyFromUnchecked(short[] d) {
mRS.validate();
- copy1DRangeFromUnchecked(0, mCurrentCount, d);
+ if (mCurrentDimZ > 0) {
+ copy3DRangeFromUnchecked(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
+ } else if (mCurrentDimY > 0) {
+ copy2DRangeFromUnchecked(0, 0, mCurrentDimX, mCurrentDimY, d);
+ } else {
+ copy1DRangeFromUnchecked(0, mCurrentCount, d);
+ }
}
/**
* Copy an allocation from an array. This variant is not type
@@ -384,7 +482,13 @@
*/
public void copyFromUnchecked(byte[] d) {
mRS.validate();
- copy1DRangeFromUnchecked(0, mCurrentCount, d);
+ if (mCurrentDimZ > 0) {
+ copy3DRangeFromUnchecked(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
+ } else if (mCurrentDimY > 0) {
+ copy2DRangeFromUnchecked(0, 0, mCurrentDimX, mCurrentDimY, d);
+ } else {
+ copy1DRangeFromUnchecked(0, mCurrentCount, d);
+ }
}
/**
* Copy an allocation from an array. This variant is not type
@@ -395,7 +499,13 @@
*/
public void copyFromUnchecked(float[] d) {
mRS.validate();
- copy1DRangeFromUnchecked(0, mCurrentCount, d);
+ if (mCurrentDimZ > 0) {
+ copy3DRangeFromUnchecked(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
+ } else if (mCurrentDimY > 0) {
+ copy2DRangeFromUnchecked(0, 0, mCurrentDimX, mCurrentDimY, d);
+ } else {
+ copy1DRangeFromUnchecked(0, mCurrentCount, d);
+ }
}
/**
@@ -407,7 +517,13 @@
*/
public void copyFrom(int[] d) {
mRS.validate();
- copy1DRangeFrom(0, mCurrentCount, d);
+ if (mCurrentDimZ > 0) {
+ copy3DRangeFrom(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
+ } else if (mCurrentDimY > 0) {
+ copy2DRangeFrom(0, 0, mCurrentDimX, mCurrentDimY, d);
+ } else {
+ copy1DRangeFrom(0, mCurrentCount, d);
+ }
}
/**
@@ -419,7 +535,13 @@
*/
public void copyFrom(short[] d) {
mRS.validate();
- copy1DRangeFrom(0, mCurrentCount, d);
+ if (mCurrentDimZ > 0) {
+ copy3DRangeFrom(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
+ } else if (mCurrentDimY > 0) {
+ copy2DRangeFrom(0, 0, mCurrentDimX, mCurrentDimY, d);
+ } else {
+ copy1DRangeFrom(0, mCurrentCount, d);
+ }
}
/**
@@ -431,7 +553,13 @@
*/
public void copyFrom(byte[] d) {
mRS.validate();
- copy1DRangeFrom(0, mCurrentCount, d);
+ if (mCurrentDimZ > 0) {
+ copy3DRangeFrom(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
+ } else if (mCurrentDimY > 0) {
+ copy2DRangeFrom(0, 0, mCurrentDimX, mCurrentDimY, d);
+ } else {
+ copy1DRangeFrom(0, mCurrentCount, d);
+ }
}
/**
@@ -443,7 +571,13 @@
*/
public void copyFrom(float[] d) {
mRS.validate();
- copy1DRangeFrom(0, mCurrentCount, d);
+ if (mCurrentDimZ > 0) {
+ copy3DRangeFrom(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
+ } else if (mCurrentDimY > 0) {
+ copy2DRangeFrom(0, 0, mCurrentDimX, mCurrentDimY, d);
+ } else {
+ copy1DRangeFrom(0, mCurrentCount, d);
+ }
}
/**
@@ -454,12 +588,34 @@
*/
public void copyFrom(Bitmap b) {
mRS.validate();
+ if (b.getConfig() == null) {
+ Bitmap newBitmap = Bitmap.createBitmap(b.getWidth(), b.getHeight(), Bitmap.Config.ARGB_8888);
+ Canvas c = new Canvas(newBitmap);
+ c.drawBitmap(b, 0, 0, null);
+ copyFrom(newBitmap);
+ return;
+ }
validateBitmapSize(b);
validateBitmapFormat(b);
mRS.nAllocationCopyFromBitmap(getID(mRS), b);
}
/**
+ * Copy an allocation from an allocation. The types of both allocations
+ * must be identical.
+ *
+ * @param a the source allocation
+ */
+ public void copyFrom(Allocation a) {
+ mRS.validate();
+ if (!mType.equals(a.getType())) {
+ throw new RSIllegalArgumentException("Types of allocations must match.");
+ }
+ copy2DRangeFrom(0, 0, mCurrentDimX, mCurrentDimY, a, 0, 0);
+ }
+
+
+ /**
* This is only intended to be used by auto-generate code reflected from the
* renderscript script files.
*
@@ -686,6 +842,35 @@
}
}
+ void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, byte[] data) {
+ mRS.validate();
+ validate2DRange(xoff, yoff, w, h);
+ mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
+ w, h, data, data.length);
+ }
+
+ void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, short[] data) {
+ mRS.validate();
+ validate2DRange(xoff, yoff, w, h);
+ mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
+ w, h, data, data.length * 2);
+ }
+
+ void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, int[] data) {
+ mRS.validate();
+ validate2DRange(xoff, yoff, w, h);
+ mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
+ w, h, data, data.length * 4);
+ }
+
+ void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, float[] data) {
+ mRS.validate();
+ validate2DRange(xoff, yoff, w, h);
+ mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
+ w, h, data, data.length * 4);
+ }
+
+
/**
* Copy a rectangular region from the array into the allocation.
* The incoming array is assumed to be tightly packed.
@@ -697,31 +882,23 @@
* @param data to be placed into the allocation
*/
public void copy2DRangeFrom(int xoff, int yoff, int w, int h, byte[] data) {
- mRS.validate();
- validate2DRange(xoff, yoff, w, h);
- mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
- w, h, data, data.length);
+ validateIsInt8();
+ copy2DRangeFromUnchecked(xoff, yoff, w, h, data);
}
public void copy2DRangeFrom(int xoff, int yoff, int w, int h, short[] data) {
- mRS.validate();
- validate2DRange(xoff, yoff, w, h);
- mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
- w, h, data, data.length * 2);
+ validateIsInt16();
+ copy2DRangeFromUnchecked(xoff, yoff, w, h, data);
}
public void copy2DRangeFrom(int xoff, int yoff, int w, int h, int[] data) {
- mRS.validate();
- validate2DRange(xoff, yoff, w, h);
- mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
- w, h, data, data.length * 4);
+ validateIsInt32();
+ copy2DRangeFromUnchecked(xoff, yoff, w, h, data);
}
public void copy2DRangeFrom(int xoff, int yoff, int w, int h, float[] data) {
- mRS.validate();
- validate2DRange(xoff, yoff, w, h);
- mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
- w, h, data, data.length * 4);
+ validateIsFloat32();
+ copy2DRangeFromUnchecked(xoff, yoff, w, h, data);
}
/**
@@ -757,11 +934,149 @@
*/
public void copy2DRangeFrom(int xoff, int yoff, Bitmap data) {
mRS.validate();
+ if (data.getConfig() == null) {
+ Bitmap newBitmap = Bitmap.createBitmap(data.getWidth(), data.getHeight(), Bitmap.Config.ARGB_8888);
+ Canvas c = new Canvas(newBitmap);
+ c.drawBitmap(data, 0, 0, null);
+ copy2DRangeFrom(xoff, yoff, newBitmap);
+ return;
+ }
validateBitmapFormat(data);
validate2DRange(xoff, yoff, data.getWidth(), data.getHeight());
mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, data);
}
+ private void validate3DRange(int xoff, int yoff, int zoff, int w, int h, int d) {
+ if (mAdaptedAllocation != null) {
+
+ } else {
+
+ if (xoff < 0 || yoff < 0 || zoff < 0) {
+ throw new RSIllegalArgumentException("Offset cannot be negative.");
+ }
+ if (h < 0 || w < 0 || d < 0) {
+ throw new RSIllegalArgumentException("Height or width cannot be negative.");
+ }
+ if (((xoff + w) > mCurrentDimX) || ((yoff + h) > mCurrentDimY) || ((zoff + d) > mCurrentDimZ)) {
+ throw new RSIllegalArgumentException("Updated region larger than allocation.");
+ }
+ }
+ }
+
+ /**
+ * @hide
+ *
+ */
+ void copy3DRangeFromUnchecked(int xoff, int yoff, int zoff, int w, int h, int d, byte[] data) {
+ mRS.validate();
+ validate3DRange(xoff, yoff, zoff, w, h, d);
+ mRS.nAllocationData3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD,
+ w, h, d, data, data.length);
+ }
+
+ /**
+ * @hide
+ *
+ */
+ void copy3DRangeFromUnchecked(int xoff, int yoff, int zoff, int w, int h, int d, short[] data) {
+ mRS.validate();
+ validate3DRange(xoff, yoff, zoff, w, h, d);
+ mRS.nAllocationData3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD,
+ w, h, d, data, data.length * 2);
+ }
+
+ /**
+ * @hide
+ *
+ */
+ void copy3DRangeFromUnchecked(int xoff, int yoff, int zoff, int w, int h, int d, int[] data) {
+ mRS.validate();
+ validate3DRange(xoff, yoff, zoff, w, h, d);
+ mRS.nAllocationData3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD,
+ w, h, d, data, data.length * 4);
+ }
+
+ /**
+ * @hide
+ *
+ */
+ void copy3DRangeFromUnchecked(int xoff, int yoff, int zoff, int w, int h, int d, float[] data) {
+ mRS.validate();
+ validate3DRange(xoff, yoff, zoff, w, h, d);
+ mRS.nAllocationData3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD,
+ w, h, d, data, data.length * 4);
+ }
+
+
+ /**
+ * @hide
+ * Copy a rectangular region from the array into the allocation.
+ * The incoming array is assumed to be tightly packed.
+ *
+ * @param xoff X offset of the region to update
+ * @param yoff Y offset of the region to update
+ * @param zoff Z offset of the region to update
+ * @param w Width of the incoming region to update
+ * @param h Height of the incoming region to update
+ * @param d Depth of the incoming region to update
+ * @param data to be placed into the allocation
+ */
+ public void copy3DRangeFrom(int xoff, int yoff, int zoff, int w, int h, int d, byte[] data) {
+ validateIsInt8();
+ copy3DRangeFromUnchecked(xoff, yoff, zoff, w, h, d, data);
+ }
+
+ /**
+ * @hide
+ *
+ */
+ public void copy3DRangeFrom(int xoff, int yoff, int zoff, int w, int h, int d, short[] data) {
+ validateIsInt16();
+ copy3DRangeFromUnchecked(xoff, yoff, zoff, w, h, d, data);
+ }
+
+ /**
+ * @hide
+ *
+ */
+ public void copy3DRangeFrom(int xoff, int yoff, int zoff, int w, int h, int d, int[] data) {
+ validateIsInt32();
+ copy3DRangeFromUnchecked(xoff, yoff, zoff, w, h, d, data);
+ }
+
+ /**
+ * @hide
+ *
+ */
+ public void copy3DRangeFrom(int xoff, int yoff, int zoff, int w, int h, int d, float[] data) {
+ validateIsFloat32();
+ copy3DRangeFromUnchecked(xoff, yoff, zoff, w, h, d, data);
+ }
+
+ /**
+ * @hide
+ * Copy a rectangular region into the allocation from another
+ * allocation.
+ *
+ * @param xoff X offset of the region to update.
+ * @param yoff Y offset of the region to update.
+ * @param w Width of the incoming region to update.
+ * @param h Height of the incoming region to update.
+ * @param d Depth of the incoming region to update.
+ * @param data source allocation.
+ * @param dataXoff X offset in data of the region to update.
+ * @param dataYoff Y offset in data of the region to update.
+ * @param dataZoff Z offset in data of the region to update
+ */
+ public void copy3DRangeFrom(int xoff, int yoff, int zoff, int w, int h, int d,
+ Allocation data, int dataXoff, int dataYoff, int dataZoff) {
+ mRS.validate();
+ validate3DRange(xoff, yoff, zoff, w, h, d);
+ mRS.nAllocationData3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD,
+ w, h, d, data.getID(mRS), dataXoff, dataYoff, dataZoff,
+ data.mSelectedLOD);
+ }
+
/**
* Copy from the Allocation into a Bitmap. The bitmap must
@@ -828,65 +1143,6 @@
mRS.nAllocationRead(getID(mRS), d);
}
- /**
- * Resize a 1D allocation. The contents of the allocation are
- * preserved. If new elements are allocated objects are created
- * with null contents and the new region is otherwise undefined.
- *
- * If the new region is smaller the references of any objects
- * outside the new region will be released.
- *
- * A new type will be created with the new dimension.
- *
- * @param dimX The new size of the allocation.
- */
- /*public synchronized void resize(int dimX) {
- if ((mType.getY() > 0)|| (mType.getZ() > 0) || mType.hasFaces() || mType.hasMipmaps()) {
- throw new RSInvalidStateException("Resize only support for 1D allocations at this time.");
- }
- mRS.nAllocationResize1D(getID(mRS), dimX);
- mRS.finish(); // Necessary because resize is fifoed and update is async.
-
- int typeID = mRS.nAllocationGetType(getID(mRS));
- mType = new Type(typeID, mRS);
- mType.updateFromNative();
- updateCacheInfo(mType);
- }*/
-
- /**
- * Resize a 2D allocation. The contents of the allocation are
- * preserved. If new elements are allocated objects are created
- * with null contents and the new region is otherwise undefined.
- *
- * If the new region is smaller the references of any objects
- * outside the new region will be released.
- *
- * A new type will be created with the new dimension.
- *
- * @hide
- * @param dimX The new size of the allocation.
- * @param dimY The new size of the allocation.
- */
- /*public void resize(int dimX, int dimY) {
- if ((mType.getZ() > 0) || mType.hasFaces() || mType.hasMipmaps()) {
- throw new RSInvalidStateException(
- "Resize only support for 2D allocations at this time.");
- }
- if (mType.getY() == 0) {
- throw new RSInvalidStateException(
- "Resize only support for 2D allocations at this time.");
- }
- mRS.nAllocationResize2D(getID(mRS), dimX, dimY);
- mRS.finish(); // Necessary because resize is fifoed and update is async.
-
- int typeID = mRS.nAllocationGetType(getID(mRS));
- mType = new Type(typeID, mRS);
- mType.updateFromNative();
- updateCacheInfo(mType);
- }*/
-
-
-
// creation
static BitmapFactory.Options mBitmapOptions = new BitmapFactory.Options();
@@ -903,6 +1159,10 @@
* utilized
*/
static public Allocation createTyped(RenderScript rs, Type type, MipmapControl mips, int usage) {
+ if (rs.isNative) {
+ RenderScriptThunker rst = (RenderScriptThunker)rs;
+ return AllocationThunker.createTyped(rst, type, mips, usage);
+ }
rs.validate();
if (type.getID(rs) == 0) {
throw new RSInvalidStateException("Bad Type");
@@ -957,6 +1217,10 @@
*/
static public Allocation createSized(RenderScript rs, Element e,
int count, int usage) {
+ if (rs.isNative) {
+ RenderScriptThunker rst = (RenderScriptThunker)rs;
+ return AllocationThunker.createSized(rs, e, count, usage);
+ }
rs.validate();
Type.Builder b = new Type.Builder(rs, e);
b.setX(count);
@@ -1026,9 +1290,41 @@
static public Allocation createFromBitmap(RenderScript rs, Bitmap b,
MipmapControl mips,
int usage) {
+ if (rs.isNative) {
+ RenderScriptThunker rst = (RenderScriptThunker)rs;
+ return AllocationThunker.createFromBitmap(rst, b, mips, usage);
+ }
rs.validate();
+
+ // WAR undocumented color formats
+ if (b.getConfig() == null) {
+ if ((usage & USAGE_SHARED) != 0) {
+ throw new RSIllegalArgumentException("USAGE_SHARED cannot be used with a Bitmap that has a null config.");
+ }
+ Bitmap newBitmap = Bitmap.createBitmap(b.getWidth(), b.getHeight(), Bitmap.Config.ARGB_8888);
+ Canvas c = new Canvas(newBitmap);
+ c.drawBitmap(b, 0, 0, null);
+ return createFromBitmap(rs, newBitmap, mips, usage);
+ }
+
Type t = typeFromBitmap(rs, b, mips);
+ // enable optimized bitmap path only with no mipmap and script-only usage
+ if (mips == MipmapControl.MIPMAP_NONE &&
+ t.getElement().isCompatible(Element.RGBA_8888(rs)) &&
+ usage == (USAGE_SHARED | USAGE_SCRIPT)) {
+ int id = rs.nAllocationCreateBitmapBackedAllocation(t.getID(rs), mips.mID, b, usage);
+ if (id == 0) {
+ throw new RSRuntimeException("Load failed.");
+ }
+
+ // keep a reference to the Bitmap around to prevent GC
+ Allocation alloc = new Allocation(id, rs, t, usage);
+ alloc.setBitmap(b);
+ return alloc;
+ }
+
+
int id = rs.nAllocationCreateFromBitmap(t.getID(rs), mips.mID, b, usage);
if (id == 0) {
throw new RSRuntimeException("Load failed.");
@@ -1037,8 +1333,10 @@
}
/**
- * Creates a non-mipmapped renderscript allocation to use as a
- * graphics texture
+ * Creates a RenderScript allocation from a bitmap.
+ *
+ * This allocation will be created with MIPMAP_NONE and
+ * USAGE_SHARED | USAGE_SCRIPT.
*
* @param rs Context to which the allocation will belong.
* @param b bitmap source for the allocation data
@@ -1048,7 +1346,7 @@
*/
static public Allocation createFromBitmap(RenderScript rs, Bitmap b) {
return createFromBitmap(rs, b, MipmapControl.MIPMAP_NONE,
- USAGE_GRAPHICS_TEXTURE);
+ USAGE_SHARED | USAGE_SCRIPT);
}
/**
@@ -1145,6 +1443,7 @@
Bitmap zneg,
MipmapControl mips,
int usage) {
+ /*
int height = xpos.getHeight();
if (xpos.getWidth() != height ||
xneg.getWidth() != height || xneg.getHeight() != height ||
@@ -1183,6 +1482,8 @@
adapter.copyFrom(zneg);
return cubemap;
+ */
+ return null;
}
/**
@@ -1213,6 +1514,79 @@
zpos, zneg, MipmapControl.MIPMAP_NONE,
USAGE_GRAPHICS_TEXTURE);
}
+
+ /**
+ * Creates a renderscript allocation from the bitmap referenced
+ * by resource id
+ *
+ * @param rs Context to which the allocation will belong.
+ * @param res application resources
+ * @param id resource id to load the data from
+ * @param mips specifies desired mipmap behaviour for the
+ * allocation
+ * @param usage bit field specifying how the allocation is
+ * utilized
+ *
+ * @return renderscript allocation containing resource data
+ *
+ */
+ static public Allocation createFromBitmapResource(RenderScript rs,
+ Resources res,
+ int id,
+ MipmapControl mips,
+ int usage) {
+
+ rs.validate();
+ Bitmap b = BitmapFactory.decodeResource(res, id);
+ Allocation alloc = createFromBitmap(rs, b, mips, usage);
+ b.recycle();
+ return alloc;
+ }
+
+ /**
+ * Creates a non-mipmapped renderscript allocation to use as a
+ * graphics texture from the bitmap referenced by resource id
+ *
+ * @param rs Context to which the allocation will belong.
+ * @param res application resources
+ * @param id resource id to load the data from
+ *
+ * @return renderscript allocation containing resource data
+ *
+ */
+ static public Allocation createFromBitmapResource(RenderScript rs,
+ Resources res,
+ int id) {
+ return createFromBitmapResource(rs, res, id,
+ MipmapControl.MIPMAP_NONE,
+ USAGE_SHARED | USAGE_SCRIPT);
+ }
+
+ /**
+ * Creates a renderscript allocation containing string data
+ * encoded in UTF-8 format
+ *
+ * @param rs Context to which the allocation will belong.
+ * @param str string to create the allocation from
+ * @param usage bit field specifying how the allocaiton is
+ * utilized
+ *
+ */
+ static public Allocation createFromString(RenderScript rs,
+ String str,
+ int usage) {
+ rs.validate();
+ byte[] allocArray = null;
+ try {
+ allocArray = str.getBytes("UTF-8");
+ Allocation alloc = Allocation.createSized(rs, Element.U8(rs), allocArray.length, usage);
+ alloc.copyFrom(allocArray);
+ return alloc;
+ }
+ catch (Exception e) {
+ throw new RSRuntimeException("Could not convert string to utf-8.");
+ }
+ }
}
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/AllocationAdapter.java b/renderscript/v8/java/src/android/support/v8/renderscript/AllocationAdapter.java
deleted file mode 100644
index 40ac32c..0000000
--- a/renderscript/v8/java/src/android/support/v8/renderscript/AllocationAdapter.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.support.v8.renderscript;
-
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.util.TypedValue;
-
-/**
- *
- **/
-public class AllocationAdapter extends Allocation {
- AllocationAdapter(int id, RenderScript rs, Allocation alloc) {
- super(id, rs, alloc.mType, alloc.mUsage);
- mAdaptedAllocation = alloc;
- }
-
- int getID(RenderScript rs) {
- throw new RSInvalidStateException(
- "This operation is not supported with adapters at this time.");
- }
-
- /**
- * @hide
- */
- public void subData(int xoff, FieldPacker fp) {
- super.setFromFieldPacker(xoff, fp);
- }
- /**
- * @hide
- */
- public void subElementData(int xoff, int component_number, FieldPacker fp) {
- super.setFromFieldPacker(xoff, component_number, fp);
- }
- /**
- * @hide
- */
- public void subData1D(int off, int count, int[] d) {
- super.copy1DRangeFrom(off, count, d);
- }
- /**
- * @hide
- */
- public void subData1D(int off, int count, short[] d) {
- super.copy1DRangeFrom(off, count, d);
- }
- /**
- * @hide
- */
- public void subData1D(int off, int count, byte[] d) {
- super.copy1DRangeFrom(off, count, d);
- }
- /**
- * @hide
- */
- public void subData1D(int off, int count, float[] d) {
- super.copy1DRangeFrom(off, count, d);
- }
- /**
- * @hide
- */
- public void subData2D(int xoff, int yoff, int w, int h, int[] d) {
- super.copy2DRangeFrom(xoff, yoff, w, h, d);
- }
- /**
- * @hide
- */
- public void subData2D(int xoff, int yoff, int w, int h, float[] d) {
- super.copy2DRangeFrom(xoff, yoff, w, h, d);
- }
- /**
- * @hide
- */
- public void readData(int[] d) {
- super.copyTo(d);
- }
- /**
- * @hide
- */
- public void readData(float[] d) {
- super.copyTo(d);
- }
-
- void initLOD(int lod) {
- if (lod < 0) {
- throw new RSIllegalArgumentException("Attempting to set negative lod (" + lod + ").");
- }
-
- int tx = mAdaptedAllocation.mType.getX();
- int ty = mAdaptedAllocation.mType.getY();
- int tz = mAdaptedAllocation.mType.getZ();
-
- for (int ct=0; ct < lod; ct++) {
- if ((tx==1) && (ty == 1) && (tz == 1)) {
- throw new RSIllegalArgumentException("Attempting to set lod (" + lod + ") out of range.");
- }
-
- if (tx > 1) tx >>= 1;
- if (ty > 1) ty >>= 1;
- if (tz > 1) tz >>= 1;
- }
-
- mCurrentDimX = tx;
- mCurrentDimY = ty;
- mCurrentDimZ = tz;
- mCurrentCount = mCurrentDimX;
- if (mCurrentDimY > 1) {
- mCurrentCount *= mCurrentDimY;
- }
- if (mCurrentDimZ > 1) {
- mCurrentCount *= mCurrentDimZ;
- }
- mSelectedY = 0;
- mSelectedZ = 0;
- }
-
- /**
- * Set the active LOD. The LOD must be within the range for the
- * type being adapted. The base allocation must have mipmaps.
- *
- * Because this changes the dimensions of the adapter the
- * current Y and Z will be reset.
- *
- * @param lod The LOD to make active.
- */
- public void setLOD(int lod) {
- if (!mAdaptedAllocation.getType().hasMipmaps()) {
- throw new RSInvalidStateException("Cannot set LOD when the allocation type does not include mipmaps.");
- }
- if (!mConstrainedLOD) {
- throw new RSInvalidStateException("Cannot set LOD when the adapter includes mipmaps.");
- }
-
- initLOD(lod);
- }
-
- /**
- * Set the active Face. The base allocation must be of a type
- * that includes faces.
- *
- * @param cf The face to make active.
- */
- public void setFace(Type.CubemapFace cf) {
- if (!mAdaptedAllocation.getType().hasFaces()) {
- throw new RSInvalidStateException("Cannot set Face when the allocation type does not include faces.");
- }
- if (!mConstrainedFace) {
- throw new RSInvalidStateException("Cannot set LOD when the adapter includes mipmaps.");
- }
- if (cf == null) {
- throw new RSIllegalArgumentException("Cannot set null face.");
- }
-
- mSelectedFace = cf;
- }
-
- /**
- * Set the active Y. The y value must be within the range for
- * the allocation being adapted. The base allocation must
- * contain the Y dimension.
- *
- * @param y The y to make active.
- */
- public void setY(int y) {
- if (mAdaptedAllocation.getType().getY() == 0) {
- throw new RSInvalidStateException("Cannot set Y when the allocation type does not include Y dim.");
- }
- if (mAdaptedAllocation.getType().getY() <= y) {
- throw new RSInvalidStateException("Cannot set Y greater than dimension of allocation.");
- }
- if (!mConstrainedY) {
- throw new RSInvalidStateException("Cannot set Y when the adapter includes Y.");
- }
-
- mSelectedY = y;
- }
-
- /**
- * Set the active Z. The z value must be within the range for
- * the allocation being adapted. The base allocation must
- * contain the Z dimension.
- *
- * @param z The z to make active.
- */
- public void setZ(int z) {
- if (mAdaptedAllocation.getType().getZ() == 0) {
- throw new RSInvalidStateException("Cannot set Z when the allocation type does not include Z dim.");
- }
- if (mAdaptedAllocation.getType().getZ() <= z) {
- throw new RSInvalidStateException("Cannot set Z greater than dimension of allocation.");
- }
- if (!mConstrainedZ) {
- throw new RSInvalidStateException("Cannot set Z when the adapter includes Z.");
- }
-
- mSelectedZ = z;
- }
-
- static public AllocationAdapter create1D(RenderScript rs, Allocation a) {
- rs.validate();
- AllocationAdapter aa = new AllocationAdapter(0, rs, a);
- aa.mConstrainedLOD = true;
- aa.mConstrainedFace = true;
- aa.mConstrainedY = true;
- aa.mConstrainedZ = true;
- aa.initLOD(0);
- return aa;
- }
-
- static public AllocationAdapter create2D(RenderScript rs, Allocation a) {
- android.util.Log.e("rs", "create2d " + a);
- rs.validate();
- AllocationAdapter aa = new AllocationAdapter(0, rs, a);
- aa.mConstrainedLOD = true;
- aa.mConstrainedFace = true;
- aa.mConstrainedY = false;
- aa.mConstrainedZ = true;
- aa.initLOD(0);
- return aa;
- }
-
-
- /**
- * Override the Allocation resize. Resizing adapters is not
- * allowed and will throw a RSInvalidStateException.
- *
- * @param dimX ignored.
- */
- public synchronized void resize(int dimX) {
- throw new RSInvalidStateException("Resize not allowed for Adapters.");
- }
-
-}
-
-
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/AllocationThunker.java b/renderscript/v8/java/src/android/support/v8/renderscript/AllocationThunker.java
new file mode 100644
index 0000000..72bb023
--- /dev/null
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/AllocationThunker.java
@@ -0,0 +1,312 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v8.renderscript;
+
+import java.io.IOException;
+import java.io.InputStream;
+import android.content.res.Resources;
+import android.content.res.AssetManager;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.view.Surface;
+import android.util.Log;
+import android.util.TypedValue;
+
+class AllocationThunker extends Allocation {
+ android.renderscript.Allocation mN;
+ //Allocation mAdaptedAllocation;
+
+ android.renderscript.Allocation getNObj() {
+ return mN;
+ }
+
+ static android.renderscript.Allocation.MipmapControl
+ convertMipmapControl(MipmapControl mc) {
+
+ switch(mc) {
+ case MIPMAP_NONE:
+ return android.renderscript.Allocation.MipmapControl.MIPMAP_NONE;
+ case MIPMAP_FULL:
+ return android.renderscript.Allocation.MipmapControl.MIPMAP_FULL;
+ case MIPMAP_ON_SYNC_TO_TEXTURE:
+ return android.renderscript.Allocation.MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE;
+ }
+ return null;
+ }
+
+ public Type getType() {
+ return TypeThunker.find(mN.getType());
+ }
+
+ public Element getElement() {
+ return getType().getElement();
+ }
+
+ public int getUsage() {
+ return mN.getUsage();
+ }
+
+ public int getBytesSize() {
+ return mN.getBytesSize();
+ }
+
+ AllocationThunker(RenderScript rs, Type t, int usage, android.renderscript.Allocation na) {
+ super(0, rs, t, usage);
+
+ mType = t;
+ mUsage = usage;
+ mN = na;
+ }
+
+ public void syncAll(int srcLocation) {
+ mN.syncAll(srcLocation);
+ }
+
+ public void ioSend() {
+ mN.ioSend();
+ }
+
+ public void ioReceive() {
+ mN.ioReceive();
+ }
+
+ public void copyFrom(BaseObj[] d) {
+ if (d == null) {
+ return;
+ }
+ android.renderscript.BaseObj[] dN = new android.renderscript.BaseObj[d.length];
+ for (int i = 0; i < d.length; i++) {
+ dN[i] = d[i].getNObj();
+ }
+ mN.copyFrom(dN);
+ }
+
+ public void copyFromUnchecked(int[] d) {
+ mN.copyFromUnchecked(d);
+ }
+ public void copyFromUnchecked(short[] d) {
+ mN.copyFromUnchecked(d);
+ }
+ public void copyFromUnchecked(byte[] d) {
+ mN.copyFromUnchecked(d);
+ }
+ public void copyFromUnchecked(float[] d) {
+ mN.copyFromUnchecked(d);
+ }
+
+ public void copyFrom(int[] d) {
+ mN.copyFrom(d);
+ }
+ public void copyFrom(short[] d) {
+ mN.copyFrom(d);
+ }
+ public void copyFrom(byte[] d) {
+ mN.copyFrom(d);
+ }
+ public void copyFrom(float[] d) {
+ mN.copyFrom(d);
+ }
+ public void copyFrom(Bitmap b) {
+ mN.copyFrom(b);
+ }
+ public void copyFrom(Allocation a) {
+ AllocationThunker at = (AllocationThunker)a;
+ mN.copyFrom(at.mN);
+ }
+
+
+ public void setFromFieldPacker(int xoff, FieldPacker fp) {
+ android.renderscript.FieldPacker nfp =
+ new android.renderscript.FieldPacker(fp.getData());
+ mN.setFromFieldPacker(xoff, nfp);
+ }
+ public void setFromFieldPacker(int xoff, int component_number, FieldPacker fp) {
+ android.renderscript.FieldPacker nfp =
+ new android.renderscript.FieldPacker(fp.getData());
+ mN.setFromFieldPacker(xoff, component_number, nfp);
+ }
+
+ public void generateMipmaps() {
+ mN.generateMipmaps();
+ }
+
+ public void copy1DRangeFromUnchecked(int off, int count, int[] d) {
+ mN.copy1DRangeFromUnchecked(off, count, d);
+ }
+ public void copy1DRangeFromUnchecked(int off, int count, short[] d) {
+ mN.copy1DRangeFromUnchecked(off, count, d);
+ }
+ public void copy1DRangeFromUnchecked(int off, int count, byte[] d) {
+ mN.copy1DRangeFromUnchecked(off, count, d);
+ }
+ public void copy1DRangeFromUnchecked(int off, int count, float[] d) {
+ mN.copy1DRangeFromUnchecked(off, count, d);
+ }
+
+ public void copy1DRangeFrom(int off, int count, int[] d) {
+ mN.copy1DRangeFrom(off, count, d);
+ }
+ public void copy1DRangeFrom(int off, int count, short[] d) {
+ mN.copy1DRangeFrom(off, count, d);
+ }
+ public void copy1DRangeFrom(int off, int count, byte[] d) {
+ mN.copy1DRangeFrom(off, count, d);
+ }
+ public void copy1DRangeFrom(int off, int count, float[] d) {
+ mN.copy1DRangeFrom(off, count, d);
+ }
+
+ public void copy1DRangeFrom(int off, int count, Allocation data, int dataOff) {
+ AllocationThunker at = (AllocationThunker)data;
+ mN.copy1DRangeFrom(off, count, at.mN, dataOff);
+ }
+
+ public void copy2DRangeFrom(int xoff, int yoff, int w, int h, byte[] data) {
+ mN.copy2DRangeFrom(xoff, yoff, w, h, data);
+ }
+ public void copy2DRangeFrom(int xoff, int yoff, int w, int h, short[] data) {
+ mN.copy2DRangeFrom(xoff, yoff, w, h, data);
+ }
+ public void copy2DRangeFrom(int xoff, int yoff, int w, int h, int[] data) {
+ mN.copy2DRangeFrom(xoff, yoff, w, h, data);
+ }
+ public void copy2DRangeFrom(int xoff, int yoff, int w, int h, float[] data) {
+ mN.copy2DRangeFrom(xoff, yoff, w, h, data);
+ }
+
+ public void copy2DRangeFrom(int xoff, int yoff, int w, int h,
+ Allocation data, int dataXoff, int dataYoff) {
+ AllocationThunker at = (AllocationThunker)data;
+ mN.copy2DRangeFrom(xoff, yoff, w, h, at.mN, dataXoff, dataYoff);
+ }
+ public void copy2DRangeFrom(int xoff, int yoff, Bitmap data) {
+ mN.copy2DRangeFrom(xoff, yoff, data);
+ }
+
+
+ public void copyTo(Bitmap b) {
+ mN.copyTo(b);
+ }
+ public void copyTo(byte[] d) {
+ mN.copyTo(d);
+ }
+ public void copyTo(short[] d) {
+ mN.copyTo(d);
+ }
+ public void copyTo(int[] d) {
+ mN.copyTo(d);
+ }
+ public void copyTo(float[] d) {
+ mN.copyTo(d);
+ }
+
+ // creation
+
+ static BitmapFactory.Options mBitmapOptions = new BitmapFactory.Options();
+ static {
+ mBitmapOptions.inScaled = false;
+ }
+
+ static public Allocation createTyped(RenderScript rs, Type type, MipmapControl mips, int usage) {
+ RenderScriptThunker rst = (RenderScriptThunker)rs;
+ TypeThunker tt = (TypeThunker)type;
+
+ android.renderscript.Allocation a =
+ android.renderscript.Allocation.createTyped(rst.mN, tt.mN,
+ convertMipmapControl(mips), usage);
+
+ return new AllocationThunker(rs, type, usage, a);
+ }
+
+ static public Allocation createFromBitmap(RenderScript rs, Bitmap b,
+ MipmapControl mips,
+ int usage) {
+
+ RenderScriptThunker rst = (RenderScriptThunker)rs;
+ android.renderscript.Allocation a =
+ android.renderscript.Allocation.createFromBitmap(
+ rst.mN, b, convertMipmapControl(mips), usage);
+ TypeThunker tt = new TypeThunker(rs, a.getType());
+
+ return new AllocationThunker(rs, tt, usage, a);
+ }
+
+ static public Allocation createCubemapFromBitmap(RenderScript rs, Bitmap b,
+ MipmapControl mips,
+ int usage) {
+ RenderScriptThunker rst = (RenderScriptThunker)rs;
+ android.renderscript.Allocation a =
+ android.renderscript.Allocation.createCubemapFromBitmap(
+ rst.mN, b, convertMipmapControl(mips), usage);
+ TypeThunker tt = new TypeThunker(rs, a.getType());
+ return new AllocationThunker(rs, tt, usage, a);
+ }
+
+ static public Allocation createCubemapFromCubeFaces(RenderScript rs,
+ Bitmap xpos,
+ Bitmap xneg,
+ Bitmap ypos,
+ Bitmap yneg,
+ Bitmap zpos,
+ Bitmap zneg,
+ MipmapControl mips,
+ int usage) {
+ RenderScriptThunker rst = (RenderScriptThunker)rs;
+ android.renderscript.Allocation a =
+ android.renderscript.Allocation.createCubemapFromCubeFaces(
+ rst.mN, xpos, xneg, ypos, yneg, zpos, zneg,
+ convertMipmapControl(mips), usage);
+ TypeThunker tt = new TypeThunker(rs, a.getType());
+ return new AllocationThunker(rs, tt, usage, a);
+ }
+
+ static public Allocation createFromBitmapResource(RenderScript rs,
+ Resources res,
+ int id,
+ MipmapControl mips,
+ int usage) {
+
+ RenderScriptThunker rst = (RenderScriptThunker)rs;
+ android.renderscript.Allocation a =
+ android.renderscript.Allocation.createFromBitmapResource(
+ rst.mN, res, id, convertMipmapControl(mips), usage);
+ TypeThunker tt = new TypeThunker(rs, a.getType());
+ return new AllocationThunker(rs, tt, usage, a);
+ }
+
+ static public Allocation createFromString(RenderScript rs,
+ String str,
+ int usage) {
+ RenderScriptThunker rst = (RenderScriptThunker)rs;
+ android.renderscript.Allocation a =
+ android.renderscript.Allocation.createFromString(
+ rst.mN, str, usage);
+ TypeThunker tt = new TypeThunker(rs, a.getType());
+ return new AllocationThunker(rs, tt, usage, a);
+ }
+
+ static public Allocation createSized(RenderScript rs, Element e,
+ int count, int usage) {
+ RenderScriptThunker rst = (RenderScriptThunker)rs;
+ ElementThunker et = (ElementThunker) e;
+ android.renderscript.Allocation a =
+ android.renderscript.Allocation.createSized(rst.mN, (android.renderscript.Element)e.getNObj(), count, usage);
+ TypeThunker tt = new TypeThunker(rs, a.getType());
+ return new AllocationThunker(rs, tt, usage, a);
+ }
+
+}
\ No newline at end of file
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/BaseObj.java b/renderscript/v8/java/src/android/support/v8/renderscript/BaseObj.java
index 878a8d8..2c97b08 100644
--- a/renderscript/v8/java/src/android/support/v8/renderscript/BaseObj.java
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/BaseObj.java
@@ -50,6 +50,12 @@
*/
int getID(RenderScript rs) {
mRS.validate();
+ if (rs.isNative) {
+ RenderScriptThunker rst = (RenderScriptThunker)rs;
+ if (getNObj() != null) {
+ return getNObj().hashCode();
+ }
+ }
if (mDestroyed) {
throw new RSInvalidStateException("using a destroyed object.");
}
@@ -62,8 +68,12 @@
return mID;
}
+ android.renderscript.BaseObj getNObj() {
+ return null;
+ }
+
void checkValid() {
- if (mID == 0) {
+ if ((mID == 0) && (getNObj() == null)) {
throw new RSIllegalArgumentException("Invalid object.");
}
}
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/Element.java b/renderscript/v8/java/src/android/support/v8/renderscript/Element.java
index 98decce..cffb706 100644
--- a/renderscript/v8/java/src/android/support/v8/renderscript/Element.java
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/Element.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,27 +49,11 @@
* </div>
**/
public class Element extends BaseObj {
- static class NElement {
- android.renderscript.Element mE;
-
- NElement(android.renderscript.Element e) {
- mE = e;
- }
-/*
- int getID() {
- return mE.getID();
- }
- */
- }
- NElement mNE;
-
-
int mSize;
Element[] mElements;
String[] mElementNames;
int[] mArraySizes;
int[] mOffsetInBytes;
-
int[] mVisibleElementMap;
DataType mType;
@@ -103,14 +87,18 @@
/**
* @return element size in bytes
*/
- public int getBytesSize() {return mSize;}
+ public int getBytesSize() {
+ return mSize;
+ }
/**
* Returns the number of vector components. 2 for float2, 4 for
* float4, etc.
* @return element vector size
*/
- public int getVectorSize() {return mVectorSize;}
+ public int getVectorSize() {
+ return mVectorSize;
+ }
/**
@@ -180,7 +168,9 @@
PIXEL_A (8),
PIXEL_LA (9),
PIXEL_RGB (10),
- PIXEL_RGBA (11);
+ PIXEL_RGBA (11),
+ PIXEL_DEPTH (12),
+ PIXEL_YUV(13);
int mID;
DataKind(int id) {
@@ -746,7 +736,6 @@
super(id, rs);
}
-
/**
* Create a custom Element of the specified DataType. The DataKind will be
* set to USER and the vector size to 1 indicating non-vector.
@@ -756,6 +745,10 @@
* @return Element
*/
static Element createUser(RenderScript rs, DataType dt) {
+ if (rs.isNative) {
+ RenderScriptThunker rst = (RenderScriptThunker)rs;
+ return ElementThunker.create(rst, dt);
+ }
DataKind dk = DataKind.USER;
boolean norm = false;
int vecSize = 1;
@@ -777,6 +770,10 @@
* @return Element
*/
public static Element createVector(RenderScript rs, DataType dt, int size) {
+ if (rs.isNative) {
+ RenderScriptThunker rst = (RenderScriptThunker)rs;
+ return ElementThunker.createVector(rst, dt, size);
+ }
if (size < 2 || size > 4) {
throw new RSIllegalArgumentException("Vector size out of range 2-4.");
}
@@ -820,11 +817,18 @@
* @return Element
*/
public static Element createPixel(RenderScript rs, DataType dt, DataKind dk) {
+ if (rs.isNative) {
+ RenderScriptThunker rst = (RenderScriptThunker)rs;
+ return ElementThunker.createPixel(rst, dt, dk);
+ }
+
if (!(dk == DataKind.PIXEL_L ||
dk == DataKind.PIXEL_A ||
dk == DataKind.PIXEL_LA ||
dk == DataKind.PIXEL_RGB ||
- dk == DataKind.PIXEL_RGBA)) {
+ dk == DataKind.PIXEL_RGBA ||
+ dk == DataKind.PIXEL_DEPTH ||
+ dk == DataKind.PIXEL_YUV)) {
throw new RSIllegalArgumentException("Unsupported DataKind");
}
if (!(dt == DataType.UNSIGNED_8 ||
@@ -843,6 +847,10 @@
if (dt == DataType.UNSIGNED_4_4_4_4 && dk != DataKind.PIXEL_RGBA) {
throw new RSIllegalArgumentException("Bad kind and type combo");
}
+ if (dt == DataType.UNSIGNED_16 &&
+ dk != DataKind.PIXEL_DEPTH) {
+ throw new RSIllegalArgumentException("Bad kind and type combo");
+ }
int size = 1;
switch (dk) {
@@ -889,22 +897,6 @@
(mVectorSize == e.mVectorSize));
}
- static class NBuilder {
- android.renderscript.Element.Builder mB;
-
- NBuilder(RenderScript rs) {
- mB = new android.renderscript.Element.Builder(rs.mNRS.getRS());
- }
-
- void add(Element element, String name, int arraySize) {
- mB.add(element.mNE.mE, name, arraySize);
- }
-
- NElement create() {
- return new NElement(mB.create());
- }
- }
-
/**
* Builder class for producing complex elements with matching field and name
* pairs. The builder starts empty. The order in which elements are added
@@ -912,7 +904,7 @@
*
*/
public static class Builder {
- NBuilder mNB;
+ ElementThunker.BuilderThunker mT;
RenderScript mRS;
Element[] mElements;
@@ -927,6 +919,10 @@
* @param rs
*/
public Builder(RenderScript rs) {
+ if (rs.isNative) {
+ RenderScriptThunker rst = (RenderScriptThunker)rs;
+ mT = new ElementThunker.BuilderThunker(rs);
+ }
mRS = rs;
mCount = 0;
mElements = new Element[8];
@@ -942,6 +938,11 @@
* @param arraySize
*/
public Builder add(Element element, String name, int arraySize) {
+ if (mT != null) {
+ mT.add(element, name, arraySize);
+ return this;
+ }
+
if (arraySize < 1) {
throw new RSIllegalArgumentException("Array size cannot be less than 1.");
}
@@ -976,9 +977,6 @@
mArraySizes[mCount] = arraySize;
mCount++;
- if (mRS.mUseNativeRS) {
- mNB.add(element, name, arraySize);
- }
return this;
}
@@ -999,6 +997,10 @@
* @return Element
*/
public Element create() {
+ if (mT != null) {
+ return mT.create(mRS);
+ }
+
mRS.validate();
Element[] ein = new Element[mCount];
String[] sin = new String[mCount];
@@ -1012,13 +1014,6 @@
ids[ct] = ein[ct].getID(mRS);
}
- if (mRS.mUseNativeRS) {
- NElement ne = mNB.create();
- Element e = new Element(-1, mRS, ein, sin, asin);
- e.mNE = ne;
- return e;
- }
-
int id = mRS.nElementCreate2(ids, sin, asin);
return new Element(id, mRS, ein, sin, asin);
}
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/ElementThunker.java b/renderscript/v8/java/src/android/support/v8/renderscript/ElementThunker.java
new file mode 100644
index 0000000..4ac16f6
--- /dev/null
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/ElementThunker.java
@@ -0,0 +1,252 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v8.renderscript;
+
+import java.lang.reflect.Field;
+
+import android.util.Log;
+
+class ElementThunker extends Element {
+ android.renderscript.Element mN;
+
+ android.renderscript.Element getNObj() {
+ return mN;
+ }
+
+ public int getBytesSize() {
+ return mN.getBytesSize();
+ }
+
+ public int getVectorSize() {
+ return mN.getVectorSize();
+ }
+
+ static android.renderscript.Element.DataKind convertKind(DataKind cdk) {
+ switch(cdk) {
+ case USER:
+ return android.renderscript.Element.DataKind.USER;
+ case PIXEL_L:
+ return android.renderscript.Element.DataKind.PIXEL_L;
+ case PIXEL_A:
+ return android.renderscript.Element.DataKind.PIXEL_A;
+ case PIXEL_LA:
+ return android.renderscript.Element.DataKind.PIXEL_LA;
+ case PIXEL_RGB:
+ return android.renderscript.Element.DataKind.PIXEL_RGB;
+ case PIXEL_RGBA:
+ return android.renderscript.Element.DataKind.PIXEL_RGBA;
+ }
+ return null;
+ }
+
+ static android.renderscript.Element.DataType convertType(DataType cdt) {
+ switch(cdt) {
+ case NONE:
+ return android.renderscript.Element.DataType.NONE;
+ //case DataType.FLOAT_16:
+ case FLOAT_32:
+ return android.renderscript.Element.DataType.FLOAT_32;
+ case FLOAT_64:
+ return android.renderscript.Element.DataType.FLOAT_64;
+ case SIGNED_8:
+ return android.renderscript.Element.DataType.SIGNED_8;
+ case SIGNED_16:
+ return android.renderscript.Element.DataType.SIGNED_16;
+ case SIGNED_32:
+ return android.renderscript.Element.DataType.SIGNED_32;
+ case SIGNED_64:
+ return android.renderscript.Element.DataType.SIGNED_64;
+ case UNSIGNED_8:
+ return android.renderscript.Element.DataType.UNSIGNED_8;
+ case UNSIGNED_16:
+ return android.renderscript.Element.DataType.UNSIGNED_16;
+ case UNSIGNED_32:
+ return android.renderscript.Element.DataType.UNSIGNED_32;
+ case UNSIGNED_64:
+ return android.renderscript.Element.DataType.UNSIGNED_64;
+
+ case BOOLEAN:
+ return android.renderscript.Element.DataType.BOOLEAN;
+
+ case MATRIX_4X4:
+ return android.renderscript.Element.DataType.MATRIX_4X4;
+ case MATRIX_3X3:
+ return android.renderscript.Element.DataType.MATRIX_3X3;
+ case MATRIX_2X2:
+ return android.renderscript.Element.DataType.MATRIX_2X2;
+
+ case RS_ELEMENT:
+ return android.renderscript.Element.DataType.RS_ELEMENT;
+ case RS_TYPE:
+ return android.renderscript.Element.DataType.RS_TYPE;
+ case RS_ALLOCATION:
+ return android.renderscript.Element.DataType.RS_ALLOCATION;
+ case RS_SAMPLER:
+ return android.renderscript.Element.DataType.RS_SAMPLER;
+ case RS_SCRIPT:
+ return android.renderscript.Element.DataType.RS_SCRIPT;
+ }
+ return null;
+ }
+
+ public boolean isComplex() {
+ return mN.isComplex();
+ }
+
+ public int getSubElementCount() {
+ return mN.getSubElementCount();
+ }
+
+ public Element getSubElement(int index) {
+ return new ElementThunker(mRS, mN.getSubElement(index));
+ }
+
+ public String getSubElementName(int index) {
+ return mN.getSubElementName(index);
+ }
+
+ public int getSubElementArraySize(int index) {
+ return mN.getSubElementArraySize(index);
+ }
+
+ public int getSubElementOffsetBytes(int index) {
+ return mN.getSubElementOffsetBytes(index);
+ }
+
+ public DataType getDataType() {
+ return mType;
+ }
+
+ public DataKind getDataKind() {
+ return mKind;
+ }
+
+
+ ElementThunker(RenderScript rs, android.renderscript.Element e) {
+ super(0, rs);
+ mN = e;
+ }
+
+
+ static Element create(RenderScript rs, DataType dt) {
+ RenderScriptThunker rst = (RenderScriptThunker)rs;
+ android.renderscript.Element e = null;
+ switch(dt) {
+ case FLOAT_32:
+ e = android.renderscript.Element.F32(rst.mN);
+ break;
+ case FLOAT_64:
+ e = android.renderscript.Element.F64(rst.mN);
+ break;
+ case SIGNED_8:
+ e = android.renderscript.Element.I8(rst.mN);
+ break;
+ case SIGNED_16:
+ e = android.renderscript.Element.I16(rst.mN);
+ break;
+ case SIGNED_32:
+ e = android.renderscript.Element.I32(rst.mN);
+ break;
+ case SIGNED_64:
+ e = android.renderscript.Element.I64(rst.mN);
+ break;
+ case UNSIGNED_8:
+ e = android.renderscript.Element.U8(rst.mN);
+ break;
+ case UNSIGNED_16:
+ e = android.renderscript.Element.U16(rst.mN);
+ break;
+ case UNSIGNED_32:
+ e = android.renderscript.Element.U32(rst.mN);
+ break;
+ case UNSIGNED_64:
+ e = android.renderscript.Element.U64(rst.mN);
+ break;
+
+ case BOOLEAN:
+ e = android.renderscript.Element.BOOLEAN(rst.mN);
+ break;
+
+ case MATRIX_4X4:
+ e = android.renderscript.Element.MATRIX_4X4(rst.mN);
+ break;
+ case MATRIX_3X3:
+ e = android.renderscript.Element.MATRIX_3X3(rst.mN);
+ break;
+ case MATRIX_2X2:
+ e = android.renderscript.Element.MATRIX_2X2(rst.mN);
+ break;
+
+ case RS_ELEMENT:
+ e = android.renderscript.Element.ELEMENT(rst.mN);
+ break;
+ case RS_TYPE:
+ e = android.renderscript.Element.TYPE(rst.mN);
+ break;
+ case RS_ALLOCATION:
+ e = android.renderscript.Element.ALLOCATION(rst.mN);
+ break;
+ case RS_SAMPLER:
+ e = android.renderscript.Element.SAMPLER(rst.mN);
+ break;
+ case RS_SCRIPT:
+ e = android.renderscript.Element.SCRIPT(rst.mN);
+ break;
+ }
+
+ return new ElementThunker(rs, e);
+ }
+
+ public static Element createVector(RenderScript rs, DataType dt, int size) {
+ RenderScriptThunker rst = (RenderScriptThunker)rs;
+ android.renderscript.Element e;
+ e = android.renderscript.Element.createVector(rst.mN, convertType(dt), size);
+ return new ElementThunker(rs, e);
+ }
+
+ public static Element createPixel(RenderScript rs, DataType dt, DataKind dk) {
+ RenderScriptThunker rst = (RenderScriptThunker)rs;
+ android.renderscript.Element e;
+ e = android.renderscript.Element.createPixel(rst.mN, convertType(dt), convertKind(dk));
+ return new ElementThunker(rs, e);
+ }
+
+ public boolean isCompatible(Element e) {
+ ElementThunker et = (ElementThunker)e;
+ return et.mN.isCompatible(mN);
+ }
+
+ static class BuilderThunker {
+ android.renderscript.Element.Builder mN;
+
+ public BuilderThunker(RenderScript rs) {
+ RenderScriptThunker rst = (RenderScriptThunker)rs;
+ mN = new android.renderscript.Element.Builder(rst.mN);
+ }
+
+ public void add(Element e, String name, int arraySize) {
+ ElementThunker et = (ElementThunker)e;
+ mN.add(et.mN, name, arraySize);
+ }
+
+ public Element create(RenderScript rs) {
+ android.renderscript.Element e = mN.create();
+ return new ElementThunker(rs, e);
+ }
+ }
+}
+
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/FieldPacker.java b/renderscript/v8/java/src/android/support/v8/renderscript/FieldPacker.java
index 37d5218..fc659b9 100644
--- a/renderscript/v8/java/src/android/support/v8/renderscript/FieldPacker.java
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/FieldPacker.java
@@ -16,6 +16,7 @@
package android.support.v8.renderscript;
+import android.os.SystemProperties;
/**
* Utility class for packing arguments and structures from Android system objects to
@@ -23,13 +24,40 @@
*
**/
public class FieldPacker {
+ private static int thunk = 0;
+
+ private android.renderscript.FieldPacker mN;
+
+ private boolean shouldThunk() {
+ if (thunk == 0) {
+ if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.JELLY_BEAN_MR1 ||
+ SystemProperties.getInt("debug.rs.forcenative", 0) != 0) {
+
+ thunk = 1;
+ } else {
+ thunk = -1;
+ }
+ }
+ if (thunk == 1) {
+ return true;
+ }
+ return false;
+ }
+
public FieldPacker(int len) {
mPos = 0;
mLen = len;
mData = new byte[len];
+ if (shouldThunk()) {
+ mN = new android.renderscript.FieldPacker(len);
+ }
}
public void align(int v) {
+ if (shouldThunk()) {
+ mN.align(v);
+ return;
+ }
if ((v <= 0) || ((v & (v - 1)) != 0)) {
throw new RSIllegalArgumentException("argument must be a non-negative non-zero power of 2: " + v);
}
@@ -40,9 +68,17 @@
}
public void reset() {
+ if (shouldThunk()) {
+ mN.reset();
+ return;
+ }
mPos = 0;
}
public void reset(int i) {
+ if (shouldThunk()) {
+ mN.reset(i);
+ return;
+ }
if ((i < 0) || (i >= mLen)) {
throw new RSIllegalArgumentException("out of range argument: " + i);
}
@@ -50,6 +86,10 @@
}
public void skip(int i) {
+ if (shouldThunk()) {
+ mN.skip(i);
+ return;
+ }
int res = mPos + i;
if ((res < 0) || (res > mLen)) {
throw new RSIllegalArgumentException("out of range argument: " + i);
@@ -58,16 +98,28 @@
}
public void addI8(byte v) {
+ if (shouldThunk()) {
+ mN.addI8(v);
+ return;
+ }
mData[mPos++] = v;
}
public void addI16(short v) {
+ if (shouldThunk()) {
+ mN.addI16(v);
+ return;
+ }
align(2);
mData[mPos++] = (byte)(v & 0xff);
mData[mPos++] = (byte)(v >> 8);
}
public void addI32(int v) {
+ if (shouldThunk()) {
+ mN.addI32(v);
+ return;
+ }
align(4);
mData[mPos++] = (byte)(v & 0xff);
mData[mPos++] = (byte)((v >> 8) & 0xff);
@@ -76,6 +128,10 @@
}
public void addI64(long v) {
+ if (shouldThunk()) {
+ mN.addI64(v);
+ return;
+ }
align(8);
mData[mPos++] = (byte)(v & 0xff);
mData[mPos++] = (byte)((v >> 8) & 0xff);
@@ -88,14 +144,21 @@
}
public void addU8(short v) {
+ if (shouldThunk()) {
+ mN.addU8(v);
+ return;
+ }
if ((v < 0) || (v > 0xff)) {
- android.util.Log.e("rs", "FieldPacker.addU8( " + v + " )");
throw new IllegalArgumentException("Saving value out of range for type");
}
mData[mPos++] = (byte)v;
}
public void addU16(int v) {
+ if (shouldThunk()) {
+ mN.addU16(v);
+ return;
+ }
if ((v < 0) || (v > 0xffff)) {
android.util.Log.e("rs", "FieldPacker.addU16( " + v + " )");
throw new IllegalArgumentException("Saving value out of range for type");
@@ -106,6 +169,10 @@
}
public void addU32(long v) {
+ if (shouldThunk()) {
+ mN.addU32(v);
+ return;
+ }
if ((v < 0) || (v > 0xffffffffL)) {
android.util.Log.e("rs", "FieldPacker.addU32( " + v + " )");
throw new IllegalArgumentException("Saving value out of range for type");
@@ -118,6 +185,10 @@
}
public void addU64(long v) {
+ if (shouldThunk()) {
+ mN.addU64(v);
+ return;
+ }
if (v < 0) {
android.util.Log.e("rs", "FieldPacker.addU64( " + v + " )");
throw new IllegalArgumentException("Saving value out of range for type");
@@ -134,14 +205,26 @@
}
public void addF32(float v) {
+ if (shouldThunk()) {
+ mN.addF32(v);
+ return;
+ }
addI32(Float.floatToRawIntBits(v));
}
public void addF64(double v) {
+ if (shouldThunk()) {
+ mN.addF64(v);
+ return;
+ }
addI64(Double.doubleToRawLongBits(v));
}
public void addObj(BaseObj obj) {
+ if (shouldThunk()) {
+ mN.addObj(obj.getNObj());
+ return;
+ }
if (obj != null) {
addI32(obj.getID(null));
} else {
@@ -150,15 +233,27 @@
}
public void addF32(Float2 v) {
+ if (shouldThunk()) {
+ mN.addF32(new android.renderscript.Float2(v.x, v.y));
+ return;
+ }
addF32(v.x);
addF32(v.y);
}
public void addF32(Float3 v) {
+ if (shouldThunk()) {
+ mN.addF32(new android.renderscript.Float3(v.x, v.y, v.z));
+ return;
+ }
addF32(v.x);
addF32(v.y);
addF32(v.z);
}
public void addF32(Float4 v) {
+ if (shouldThunk()) {
+ mN.addF32(new android.renderscript.Float4(v.x, v.y, v.z, v.w));
+ return;
+ }
addF32(v.x);
addF32(v.y);
addF32(v.z);
@@ -166,15 +261,27 @@
}
public void addF64(Double2 v) {
+ if (shouldThunk()) {
+ mN.addF64(new android.renderscript.Double2(v.x, v.y));
+ return;
+ }
addF64(v.x);
addF64(v.y);
}
public void addF64(Double3 v) {
+ if (shouldThunk()) {
+ mN.addF64(new android.renderscript.Double3(v.x, v.y, v.z));
+ return;
+ }
addF64(v.x);
addF64(v.y);
addF64(v.z);
}
public void addF64(Double4 v) {
+ if (shouldThunk()) {
+ mN.addF64(new android.renderscript.Double4(v.x, v.y, v.z, v.w));
+ return;
+ }
addF64(v.x);
addF64(v.y);
addF64(v.z);
@@ -182,15 +289,27 @@
}
public void addI8(Byte2 v) {
+ if (shouldThunk()) {
+ mN.addI8(new android.renderscript.Byte2(v.x, v.y));
+ return;
+ }
addI8(v.x);
addI8(v.y);
}
public void addI8(Byte3 v) {
+ if (shouldThunk()) {
+ mN.addI8(new android.renderscript.Byte3(v.x, v.y, v.z));
+ return;
+ }
addI8(v.x);
addI8(v.y);
addI8(v.z);
}
public void addI8(Byte4 v) {
+ if (shouldThunk()) {
+ mN.addI8(new android.renderscript.Byte4(v.x, v.y, v.z, v.w));
+ return;
+ }
addI8(v.x);
addI8(v.y);
addI8(v.z);
@@ -198,15 +317,27 @@
}
public void addU8(Short2 v) {
+ if (shouldThunk()) {
+ mN.addU8(new android.renderscript.Short2(v.x, v.y));
+ return;
+ }
addU8(v.x);
addU8(v.y);
}
public void addU8(Short3 v) {
+ if (shouldThunk()) {
+ mN.addU8(new android.renderscript.Short3(v.x, v.y, v.z));
+ return;
+ }
addU8(v.x);
addU8(v.y);
addU8(v.z);
}
public void addU8(Short4 v) {
+ if (shouldThunk()) {
+ mN.addU8(new android.renderscript.Short4(v.x, v.y, v.z, v.w));
+ return;
+ }
addU8(v.x);
addU8(v.y);
addU8(v.z);
@@ -214,15 +345,27 @@
}
public void addI16(Short2 v) {
+ if (shouldThunk()) {
+ mN.addI16(new android.renderscript.Short2(v.x, v.y));
+ return;
+ }
addI16(v.x);
addI16(v.y);
}
public void addI16(Short3 v) {
+ if (shouldThunk()) {
+ mN.addI16(new android.renderscript.Short3(v.x, v.y, v.z));
+ return;
+ }
addI16(v.x);
addI16(v.y);
addI16(v.z);
}
public void addI16(Short4 v) {
+ if (shouldThunk()) {
+ mN.addI16(new android.renderscript.Short4(v.x, v.y, v.z, v.w));
+ return;
+ }
addI16(v.x);
addI16(v.y);
addI16(v.z);
@@ -230,15 +373,27 @@
}
public void addU16(Int2 v) {
+ if (shouldThunk()) {
+ mN.addU16(new android.renderscript.Int2(v.x, v.y));
+ return;
+ }
addU16(v.x);
addU16(v.y);
}
public void addU16(Int3 v) {
+ if (shouldThunk()) {
+ mN.addU16(new android.renderscript.Int3(v.x, v.y, v.z));
+ return;
+ }
addU16(v.x);
addU16(v.y);
addU16(v.z);
}
public void addU16(Int4 v) {
+ if (shouldThunk()) {
+ mN.addU16(new android.renderscript.Int4(v.x, v.y, v.z, v.w));
+ return;
+ }
addU16(v.x);
addU16(v.y);
addU16(v.z);
@@ -246,15 +401,27 @@
}
public void addI32(Int2 v) {
+ if (shouldThunk()) {
+ mN.addI32(new android.renderscript.Int2(v.x, v.y));
+ return;
+ }
addI32(v.x);
addI32(v.y);
}
public void addI32(Int3 v) {
+ if (shouldThunk()) {
+ mN.addI32(new android.renderscript.Int3(v.x, v.y, v.z));
+ return;
+ }
addI32(v.x);
addI32(v.y);
addI32(v.z);
}
public void addI32(Int4 v) {
+ if (shouldThunk()) {
+ mN.addI32(new android.renderscript.Int4(v.x, v.y, v.z, v.w));
+ return;
+ }
addI32(v.x);
addI32(v.y);
addI32(v.z);
@@ -262,15 +429,27 @@
}
public void addU32(Long2 v) {
+ if (shouldThunk()) {
+ mN.addU32(new android.renderscript.Long2(v.x, v.y));
+ return;
+ }
addU32(v.x);
addU32(v.y);
}
public void addU32(Long3 v) {
+ if (shouldThunk()) {
+ mN.addU32(new android.renderscript.Long3(v.x, v.y, v.z));
+ return;
+ }
addU32(v.x);
addU32(v.y);
addU32(v.z);
}
public void addU32(Long4 v) {
+ if (shouldThunk()) {
+ mN.addU32(new android.renderscript.Long4(v.x, v.y, v.z, v.w));
+ return;
+ }
addU32(v.x);
addU32(v.y);
addU32(v.z);
@@ -278,15 +457,27 @@
}
public void addI64(Long2 v) {
+ if (shouldThunk()) {
+ mN.addI64(new android.renderscript.Long2(v.x, v.y));
+ return;
+ }
addI64(v.x);
addI64(v.y);
}
public void addI64(Long3 v) {
+ if (shouldThunk()) {
+ mN.addI64(new android.renderscript.Long3(v.x, v.y, v.z));
+ return;
+ }
addI64(v.x);
addI64(v.y);
addI64(v.z);
}
public void addI64(Long4 v) {
+ if (shouldThunk()) {
+ mN.addI64(new android.renderscript.Long4(v.x, v.y, v.z, v.w));
+ return;
+ }
addI64(v.x);
addI64(v.y);
addI64(v.z);
@@ -294,15 +485,27 @@
}
public void addU64(Long2 v) {
+ if (shouldThunk()) {
+ mN.addU64(new android.renderscript.Long2(v.x, v.y));
+ return;
+ }
addU64(v.x);
addU64(v.y);
}
public void addU64(Long3 v) {
+ if (shouldThunk()) {
+ mN.addU64(new android.renderscript.Long3(v.x, v.y, v.z));
+ return;
+ }
addU64(v.x);
addU64(v.y);
addU64(v.z);
}
public void addU64(Long4 v) {
+ if (shouldThunk()) {
+ mN.addU64(new android.renderscript.Long4(v.x, v.y, v.z, v.w));
+ return;
+ }
addU64(v.x);
addU64(v.y);
addU64(v.z);
@@ -310,28 +513,47 @@
}
public void addMatrix(Matrix4f v) {
+ if (shouldThunk()) {
+ mN.addMatrix(new android.renderscript.Matrix4f(v.getArray()));
+ return;
+ }
for (int i=0; i < v.mMat.length; i++) {
addF32(v.mMat[i]);
}
}
public void addMatrix(Matrix3f v) {
+ if (shouldThunk()) {
+ mN.addMatrix(new android.renderscript.Matrix3f(v.getArray()));
+ return;
+ }
for (int i=0; i < v.mMat.length; i++) {
addF32(v.mMat[i]);
}
}
public void addMatrix(Matrix2f v) {
+ if (shouldThunk()) {
+ mN.addMatrix(new android.renderscript.Matrix2f(v.getArray()));
+ return;
+ }
for (int i=0; i < v.mMat.length; i++) {
addF32(v.mMat[i]);
}
}
public void addBoolean(boolean v) {
+ if (shouldThunk()) {
+ mN.addBoolean(v);
+ return;
+ }
addI8((byte)(v ? 1 : 0));
}
public final byte[] getData() {
+ if (shouldThunk()) {
+ return mN.getData();
+ }
return mData;
}
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/Matrix3f.java b/renderscript/v8/java/src/android/support/v8/renderscript/Matrix3f.java
index 9edb487..fb9542a 100644
--- a/renderscript/v8/java/src/android/support/v8/renderscript/Matrix3f.java
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/Matrix3f.java
@@ -138,9 +138,9 @@
mMat[6] = zx*nc + ys;
mMat[1] = xy*nc + zs;
mMat[4] = y*y*nc + c;
- mMat[9] = yz*nc - xs;
+ mMat[7] = yz*nc - xs;
mMat[2] = zx*nc - ys;
- mMat[6] = yz*nc + xs;
+ mMat[5] = yz*nc + xs;
mMat[8] = z*z*nc + c;
}
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/RSReflect.java b/renderscript/v8/java/src/android/support/v8/renderscript/RSReflect.java
deleted file mode 100644
index e06c2c1..0000000
--- a/renderscript/v8/java/src/android/support/v8/renderscript/RSReflect.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.renderscript;
-
-
-import java.lang.reflect.Field;
-import java.lang.Class;
-import java.lang.reflect.Method;
-import java.lang.reflect.Constructor;
-
-import android.util.Log;
-
-class RSReflect {
- Class mElement;
- Class mElementBuilder;
- Class mElementDataType;
- Class mElementDataKind;
- Method mElement_createUser;
- Method mElement_createVector;
- Method mElement_createPixel;
- Constructor mElementBuilder_constructor;
- Method mElementBuilder_add;
- Method mElementBuilder_create;
-
- Class mType;
- Class mTypeBuilder;
- Class mTypeCubemapFace;
- Constructor mTypeBuilder_constructor;
- Method mTypeBuilder_setX;
- Method mTypeBuilder_setY;
- Method mTypeBuilder_setMipmaps;
- Method mTypeBuilder_setFaces;
-
- Class mAllocation;
- Class mAllocationMipmapControl;
- Method mAllocation_syncAll;
- Method mAllocation_copyFrom_O;
- Method mAllocation_copyFromUnchecked_I;
- Method mAllocation_copyFromUnchecked_S;
- Method mAllocation_copyFromUnchecked_B;
- Method mAllocation_copyFromUnchecked_F;
- Method mAllocation_copyFrom_I;
- Method mAllocation_copyFrom_S;
- Method mAllocation_copyFrom_B;
- Method mAllocation_copyFrom_F;
- Method mAllocation_setFromFieldPacker;
- Method mAllocation_setFromFieldPacker_component;
- Method mAllocation_generateMipmaps;
- Method mAllocation_copy1DRangeFromUnchecked;
-
-
- Class mBaseObj;
- Class mRenderScript;
- Class mSampler;
- Class mScript;
- Class mScriptC;
- Class mScriptGroup;
-
-
- private RSReflect() {
- }
-
- private boolean init() {
- try {
- Method m[];
-
- mElement = Class.forName("android.renderscript.Element");
- mElementBuilder = Class.forName("android.renderscript.Element$Builder");
- mElementDataType = Class.forName("android.renderscript.Element$DataType");
- mElementDataKind = Class.forName("android.renderscript.Element$DataKind");
-
- mType = Class.forName("android.renderscript.Type");
- mTypeBuilder = Class.forName("android.renderscript.Type$Builder");
- mTypeCubemapFace = Class.forName("android.renderscript.Type$CubemapFace");
-
- mAllocation = Class.forName("android.renderscript.Allocation");
- mBaseObj = Class.forName("android.renderscript.BaseObj");
- mRenderScript = Class.forName("android.renderscript.RenderScript");
- mSampler = Class.forName("android.renderscript.Sampler");
- mScript = Class.forName("android.renderscript.Script");
- mScriptC = Class.forName("android.renderscript.ScriptC");
-
- mElement_createUser = mElement.getDeclaredMethod("createUser",
- new Class[] { mRenderScript, mElementDataType });
- mElement_createVector = mElement.getDeclaredMethod("createVector",
- new Class[] { mRenderScript, mElementDataType, Integer.TYPE });
- mElement_createPixel = mElement.getDeclaredMethod("createPixel",
- new Class[] { mRenderScript, mElementDataType, mElementDataKind });
- mElementBuilder_constructor = mElementBuilder.getDeclaredConstructor(
- new Class[] { mRenderScript });
- mElementBuilder_add = mElementBuilder.getDeclaredMethod("add",
- new Class[] { mElement, String.class, Integer.TYPE });
- mElementBuilder_create = mElementBuilder.getDeclaredMethod("create",
- new Class[] {});
-
- mTypeBuilder_constructor = mTypeBuilder.getDeclaredConstructor(
- new Class[] { mRenderScript, mElement });
- mTypeBuilder_setX = mTypeBuilder.getDeclaredMethod("setX",
- new Class[] { Integer.TYPE });
- mTypeBuilder_setY = mTypeBuilder.getDeclaredMethod("setY",
- new Class[] { Integer.TYPE });
- mTypeBuilder_setMipmaps = mTypeBuilder.getDeclaredMethod("setMipmaps",
- new Class[] { Boolean.TYPE });
- mTypeBuilder_setFaces = mTypeBuilder.getDeclaredMethod("setFaces",
- new Class[] { Boolean.TYPE });
-
-
-
-
-
- //mScriptGroup = Class.forName("android.renderscript.Element");
-
-
- } catch (Throwable e) {
- android.util.Log.w("RSR", "Using native RS failed. " + e);
- return false;
- }
- return true;
- }
-
- static RSReflect create() {
- android.util.Log.v("RSR", "create");
- RSReflect r = new RSReflect();
- if (r.init()) {
- android.util.Log.v("RSR", "create ok");
- return r;
- }
- android.util.Log.v("RSR", "create fail");
- return null;
- }
-
- private Method findMethod(Method m[], String name) {
- for (int ct=0; ct < m.length; ct++) {
- if (m[ct].getName().equals(name)) {
- return m[ct];
- }
- }
- return null;
- }
-
-
- //Class c = Class.forName("java.lang.String");
-
-}
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/RenderScript.java b/renderscript/v8/java/src/android/support/v8/renderscript/RenderScript.java
index baef1a6..5eec999 100644
--- a/renderscript/v8/java/src/android/support/v8/renderscript/RenderScript.java
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/RenderScript.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@
import android.util.Log;
import android.view.Surface;
-
+import android.os.SystemProperties;
/**
* Renderscript base master class. An instance of this class creates native
@@ -40,7 +40,7 @@
* <div class="special reference">
* <h3>Developer Guides</h3>
* <p>For more information about creating an application that uses Renderscript, read the
- * <a href="{@docRoot}guide/topics/graphics/renderscript.html">Renderscript</a> developer guide.</p>
+ * <a href="{@docRoot}guide/topics/renderscript/index.html">Renderscript</a> developer guide.</p>
* </div>
**/
public class RenderScript {
@@ -50,16 +50,6 @@
static final boolean LOG_ENABLED = false;
private Context mApplicationContext;
- boolean mUseNativeRS;
-
- static class NRS {
- android.renderscript.RenderScript mRS;
-
- android.renderscript.RenderScript getRS() {
- return mRS;
- }
- }
- NRS mNRS;
/*
* We use a class initializer to allow the native code to cache some
@@ -73,6 +63,7 @@
static {
sInitialized = false;
try {
+ System.loadLibrary("RSSupport");
System.loadLibrary("rsjni");
_nInit();
sInitialized = true;
@@ -92,6 +83,8 @@
native void nContextInitToClient(int con);
native void nContextDeinitToClient(int con);
+ static boolean isNative = false;
+
/**
* Name of the file that holds the object cache.
*/
@@ -111,12 +104,22 @@
f.mkdirs();
}
+ public enum ContextType {
+ NORMAL (0),
+ DEBUG (1),
+ PROFILE (2);
+
+ int mID;
+ ContextType(int id) {
+ mID = id;
+ }
+ }
// Methods below are wrapped to protect the non-threadsafe
// lockless fifo.
- native int rsnContextCreate(int dev, int ver, int sdkVer);
- synchronized int nContextCreate(int dev, int ver, int sdkVer) {
- return rsnContextCreate(dev, ver, sdkVer);
+ native int rsnContextCreate(int dev, int ver, int sdkVer, int contextType);
+ synchronized int nContextCreate(int dev, int ver, int sdkVer, int contextType) {
+ return rsnContextCreate(dev, ver, sdkVer, contextType);
}
native void rsnContextDestroy(int con);
synchronized void nContextDestroy() {
@@ -139,6 +142,12 @@
rsnContextFinish(mContext);
}
+ native void rsnContextSendMessage(int con, int id, int[] data);
+ synchronized void nContextSendMessage(int id, int[] data) {
+ validate();
+ rsnContextSendMessage(mContext, id, data);
+ }
+
native void rsnObjDestroy(int con, int id);
synchronized void nObjDestroy(int id) {
// There is a race condition here. The calling code may be run
@@ -171,10 +180,10 @@
rsnElementGetSubElements(mContext, id, IDs, names, arraySizes);
}
- native int rsnTypeCreate(int con, int eid, int x, int y, int z, boolean mips, boolean faces);
- synchronized int nTypeCreate(int eid, int x, int y, int z, boolean mips, boolean faces) {
+ native int rsnTypeCreate(int con, int eid, int x, int y, int z, boolean mips, boolean faces, int yuv);
+ synchronized int nTypeCreate(int eid, int x, int y, int z, boolean mips, boolean faces, int yuv) {
validate();
- return rsnTypeCreate(mContext, eid, x, y, z, mips, faces);
+ return rsnTypeCreate(mContext, eid, x, y, z, mips, faces, yuv);
}
native void rsnTypeGetNativeData(int con, int id, int[] typeData);
synchronized void nTypeGetNativeData(int id, int[] typeData) {
@@ -192,6 +201,14 @@
validate();
return rsnAllocationCreateFromBitmap(mContext, type, mip, bmp, usage);
}
+
+ native int rsnAllocationCreateBitmapBackedAllocation(int con, int type, int mip, Bitmap bmp, int usage);
+ synchronized int nAllocationCreateBitmapBackedAllocation(int type, int mip, Bitmap bmp, int usage) {
+ validate();
+ return rsnAllocationCreateBitmapBackedAllocation(mContext, type, mip, bmp, usage);
+ }
+
+
native int rsnAllocationCubeCreateFromBitmap(int con, int type, int mip, Bitmap bmp, int usage);
synchronized int nAllocationCubeCreateFromBitmap(int type, int mip, Bitmap bmp, int usage) {
validate();
@@ -220,6 +237,16 @@
validate();
rsnAllocationSyncAll(mContext, alloc, src);
}
+ native void rsnAllocationIoSend(int con, int alloc);
+ synchronized void nAllocationIoSend(int alloc) {
+ validate();
+ rsnAllocationIoSend(mContext, alloc);
+ }
+ native void rsnAllocationIoReceive(int con, int alloc);
+ synchronized void nAllocationIoReceive(int alloc) {
+ validate();
+ rsnAllocationIoReceive(mContext, alloc);
+ }
native void rsnAllocationGenerateMipmaps(int con, int alloc);
@@ -307,6 +334,46 @@
rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, b);
}
+ native void rsnAllocationData3D(int con,
+ int dstAlloc, int dstXoff, int dstYoff, int dstZoff,
+ int dstMip,
+ int width, int height, int depth,
+ int srcAlloc, int srcXoff, int srcYoff, int srcZoff,
+ int srcMip);
+ synchronized void nAllocationData3D(int dstAlloc, int dstXoff, int dstYoff, int dstZoff,
+ int dstMip,
+ int width, int height, int depth,
+ int srcAlloc, int srcXoff, int srcYoff, int srcZoff,
+ int srcMip) {
+ validate();
+ rsnAllocationData3D(mContext,
+ dstAlloc, dstXoff, dstYoff, dstZoff,
+ dstMip, width, height, depth,
+ srcAlloc, srcXoff, srcYoff, srcZoff, srcMip);
+ }
+
+ native void rsnAllocationData3D(int con, int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, byte[] d, int sizeBytes);
+ synchronized void nAllocationData3D(int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, byte[] d, int sizeBytes) {
+ validate();
+ rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes);
+ }
+ native void rsnAllocationData3D(int con, int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, short[] d, int sizeBytes);
+ synchronized void nAllocationData3D(int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, short[] d, int sizeBytes) {
+ validate();
+ rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes);
+ }
+ native void rsnAllocationData3D(int con, int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, int[] d, int sizeBytes);
+ synchronized void nAllocationData3D(int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, int[] d, int sizeBytes) {
+ validate();
+ rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes);
+ }
+ native void rsnAllocationData3D(int con, int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, float[] d, int sizeBytes);
+ synchronized void nAllocationData3D(int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, float[] d, int sizeBytes) {
+ validate();
+ rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes);
+ }
+
+
native void rsnAllocationRead(int con, int id, byte[] d);
synchronized void nAllocationRead(int id, byte[] d) {
validate();
@@ -361,6 +428,10 @@
}
native void rsnScriptForEach(int con, int id, int slot, int ain, int aout, byte[] params);
native void rsnScriptForEach(int con, int id, int slot, int ain, int aout);
+ native void rsnScriptForEachClipped(int con, int id, int slot, int ain, int aout, byte[] params,
+ int xstart, int xend, int ystart, int yend, int zstart, int zend);
+ native void rsnScriptForEachClipped(int con, int id, int slot, int ain, int aout,
+ int xstart, int xend, int ystart, int yend, int zstart, int zend);
synchronized void nScriptForEach(int id, int slot, int ain, int aout, byte[] params) {
validate();
if (params == null) {
@@ -369,6 +440,17 @@
rsnScriptForEach(mContext, id, slot, ain, aout, params);
}
}
+
+ synchronized void nScriptForEachClipped(int id, int slot, int ain, int aout, byte[] params,
+ int xstart, int xend, int ystart, int yend, int zstart, int zend) {
+ validate();
+ if (params == null) {
+ rsnScriptForEachClipped(mContext, id, slot, ain, aout, xstart, xend, ystart, yend, zstart, zend);
+ } else {
+ rsnScriptForEachClipped(mContext, id, slot, ain, aout, params, xstart, xend, ystart, yend, zstart, zend);
+ }
+ }
+
native void rsnScriptInvokeV(int con, int id, int slot, byte[] params);
synchronized void nScriptInvokeV(int id, int slot, byte[] params) {
validate();
@@ -551,6 +633,10 @@
Sampler mSampler_WRAP_NEAREST;
Sampler mSampler_WRAP_LINEAR;
Sampler mSampler_WRAP_LINEAR_MIP_LINEAR;
+ Sampler mSampler_MIRRORED_REPEAT_NEAREST;
+ Sampler mSampler_MIRRORED_REPEAT_LINEAR;
+ Sampler mSampler_MIRRORED_REPEAT_LINEAR_MIP_LINEAR;
+
///////////////////////////////////////////////////////////////////////////////////
//
@@ -580,12 +666,35 @@
public void setMessageHandler(RSMessageHandler msg) {
mMessageCallback = msg;
+ if (isNative) {
+ RenderScriptThunker rst = (RenderScriptThunker) this;
+ android.renderscript.RenderScript.RSMessageHandler newmsg =
+ new android.renderscript.RenderScript.RSMessageHandler() {
+ public void run() {
+ mMessageCallback.mData = mData;
+ mMessageCallback.mID = mID;
+ mMessageCallback.mLength = mLength;
+ mMessageCallback.run();
+ }
+ };
+ rst.mN.setMessageHandler(newmsg);
+ }
}
public RSMessageHandler getMessageHandler() {
return mMessageCallback;
}
/**
+ * @hide
+ *
+ * @param id
+ * @param data
+ */
+ public void sendMessage(int id, int[] data) {
+ nContextSendMessage(id, data);
+ }
+
+ /**
* Runtime error base class. An application should derive from this class
* if it wishes to install an error handler. When errors occur at runtime
* the fields in this class will be filled and the run method called.
@@ -609,6 +718,18 @@
public void setErrorHandler(RSErrorHandler msg) {
mErrorCallback = msg;
+ if (isNative) {
+ RenderScriptThunker rst = (RenderScriptThunker) this;
+ android.renderscript.RenderScript.RSErrorHandler newmsg =
+ new android.renderscript.RenderScript.RSErrorHandler() {
+ public void run() {
+ mErrorCallback.mErrorMessage = mErrorMessage;
+ mErrorCallback.mErrorNum = mErrorNum;
+ mErrorCallback.run();
+ }
+ };
+ rst.mN.setErrorHandler(newmsg);
+ }
}
public RSErrorHandler getErrorHandler() {
return mErrorCallback;
@@ -709,6 +830,7 @@
mRS.mErrorCallback.mErrorNum = subID;
mRS.mErrorCallback.run();
} else {
+ android.util.Log.e(LOG_TAG, "non fatal RS error, " + e);
// Do not throw here. In these cases, we do not have
// a fatal error.
}
@@ -744,23 +866,45 @@
}
/**
+ * @hide
+ */
+ public static RenderScript create(Context ctx, int sdkVersion) {
+ return create(ctx, sdkVersion, ContextType.NORMAL);
+ }
+
+ /**
* Create a basic RenderScript context.
*
* @hide
* @param ctx The context.
* @return RenderScript
*/
- public static RenderScript create(Context ctx, int sdkVersion) {
+ public static RenderScript create(Context ctx, int sdkVersion, ContextType ct) {
RenderScript rs = new RenderScript(ctx);
+ // !!!!!!!!!!!!!! FIXME BEFORE MR2 SHIP !!!!!!!!!!!!!!
+ // This forces the compatibility library on
+ // All bundled builds will work, but any prebuilts built from this will cause catastrophic problems
+
+ // if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1 ||
+ // SystemProperties.getInt("debug.rs.forcenative", 0) != 0) {
+ {
+ android.util.Log.v(LOG_TAG, "RS native mode");
+ return RenderScriptThunker.create(ctx, sdkVersion);
+ }
+
+ // !!!!!!!!!!!!!! FIXME BEFORE MR2 SHIP !!!!!!!!!!!!!!
+ // This forces the compatibility library on
+ // All bundled builds will work, but any prebuilts built from this will cause catastrophic problems
+ /* android.util.Log.v(LOG_TAG, "RS compat mode");
rs.mDev = rs.nDeviceCreate();
- rs.mContext = rs.nContextCreate(rs.mDev, 0, sdkVersion);
+ rs.mContext = rs.nContextCreate(rs.mDev, 0, sdkVersion, ct.mID);
if (rs.mContext == 0) {
throw new RSDriverException("Failed to create RS context.");
}
rs.mMessageThread = new MessageThread(rs);
rs.mMessageThread.start();
- return rs;
+ return rs;*/
}
/**
@@ -770,8 +914,20 @@
* @return RenderScript
*/
public static RenderScript create(Context ctx) {
+ return create(ctx, ContextType.NORMAL);
+ }
+
+ /**
+ * Create a basic RenderScript context.
+ *
+ * @hide
+ *
+ * @param ctx The context.
+ * @return RenderScript
+ */
+ public static RenderScript create(Context ctx, ContextType ct) {
int v = ctx.getApplicationInfo().targetSdkVersion;
- return create(ctx, v);
+ return create(ctx, v, ct);
}
/**
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/RenderScriptThunker.java b/renderscript/v8/java/src/android/support/v8/renderscript/RenderScriptThunker.java
new file mode 100644
index 0000000..5ba76df
--- /dev/null
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/RenderScriptThunker.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v8.renderscript;
+
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.res.AssetManager;
+import android.os.Process;
+import android.util.Log;
+import android.view.Surface;
+
+
+
+class RenderScriptThunker extends RenderScript {
+ android.renderscript.RenderScript mN;
+
+ void validate() {
+ if (mN == null) {
+ throw new RSInvalidStateException("Calling RS with no Context active.");
+ }
+ }
+
+ public void setPriority(Priority p) {
+ if (p == Priority.LOW) mN.setPriority(android.renderscript.RenderScript.Priority.LOW);
+ if (p == Priority.NORMAL) mN.setPriority(android.renderscript.RenderScript.Priority.NORMAL);
+ }
+
+ RenderScriptThunker(Context ctx) {
+ super(ctx);
+ isNative = true;
+ }
+
+ public static RenderScript create(Context ctx, int sdkVersion) {
+ RenderScriptThunker rs = new RenderScriptThunker(ctx);
+ rs.mN = android.renderscript.RenderScript.create(ctx, sdkVersion);
+ return rs;
+ }
+
+ public void contextDump() {
+ mN.contextDump();
+ }
+
+ public void finish() {
+ mN.finish();
+ }
+
+ public void destroy() {
+ mN.destroy();
+ mN = null;
+ }
+}
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/Sampler.java b/renderscript/v8/java/src/android/support/v8/renderscript/Sampler.java
index d6a45e4..13ccc03 100644
--- a/renderscript/v8/java/src/android/support/v8/renderscript/Sampler.java
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/Sampler.java
@@ -39,7 +39,8 @@
LINEAR_MIP_LINEAR (2),
LINEAR_MIP_NEAREST (5),
WRAP (3),
- CLAMP (4);
+ CLAMP (4),
+ MIRRORED_REPEAT (6);
int mID;
Value(int id) {
@@ -134,8 +135,8 @@
}
/**
- * Retrieve a sampler with ag set to linear, min linear mipmap linear, and
- * to and wrap modes set to clamp.
+ * Retrieve a sampler with mag set to linear, min linear mipmap linear, and
+ * wrap modes set to clamp.
*
* @param rs Context to which the sampler will belong.
*
@@ -174,7 +175,7 @@
}
/**
- * Retrieve a sampler with min and mag set to nearest and wrap modes set to
+ * Retrieve a sampler with min and mag set to linear and wrap modes set to
* wrap.
*
* @param rs Context to which the sampler will belong.
@@ -194,8 +195,8 @@
}
/**
- * Retrieve a sampler with ag set to linear, min linear mipmap linear, and
- * to and wrap modes set to wrap.
+ * Retrieve a sampler with mag set to linear, min linear mipmap linear, and
+ * wrap modes set to wrap.
*
* @param rs Context to which the sampler will belong.
*
@@ -213,6 +214,45 @@
return rs.mSampler_WRAP_LINEAR_MIP_LINEAR;
}
+ /**
+ * Retrieve a sampler with min and mag set to nearest and wrap modes set to
+ * mirrored repeat.
+ *
+ * @param rs Context to which the sampler will belong.
+ *
+ * @return Sampler
+ */
+ public static Sampler MIRRORED_REPEAT_NEAREST(RenderScript rs) {
+ if(rs.mSampler_MIRRORED_REPEAT_NEAREST == null) {
+ Builder b = new Builder(rs);
+ b.setMinification(Value.NEAREST);
+ b.setMagnification(Value.NEAREST);
+ b.setWrapS(Value.MIRRORED_REPEAT);
+ b.setWrapT(Value.MIRRORED_REPEAT);
+ rs.mSampler_MIRRORED_REPEAT_NEAREST = b.create();
+ }
+ return rs.mSampler_MIRRORED_REPEAT_NEAREST;
+ }
+
+ /**
+ * Retrieve a sampler with min and mag set to linear and wrap modes set to
+ * mirrored repeat.
+ *
+ * @param rs Context to which the sampler will belong.
+ *
+ * @return Sampler
+ */
+ public static Sampler MIRRORED_REPEAT_LINEAR(RenderScript rs) {
+ if(rs.mSampler_MIRRORED_REPEAT_LINEAR == null) {
+ Builder b = new Builder(rs);
+ b.setMinification(Value.LINEAR);
+ b.setMagnification(Value.LINEAR);
+ b.setWrapS(Value.MIRRORED_REPEAT);
+ b.setWrapT(Value.MIRRORED_REPEAT);
+ rs.mSampler_MIRRORED_REPEAT_LINEAR = b.create();
+ }
+ return rs.mSampler_MIRRORED_REPEAT_LINEAR;
+ }
/**
* Builder for creating non-standard samplers. Usefull if mix and match of
@@ -258,7 +298,7 @@
}
public void setWrapS(Value v) {
- if (v == Value.WRAP || v == Value.CLAMP) {
+ if (v == Value.WRAP || v == Value.CLAMP || v == Value.MIRRORED_REPEAT) {
mWrapS = v;
} else {
throw new IllegalArgumentException("Invalid value");
@@ -266,7 +306,7 @@
}
public void setWrapT(Value v) {
- if (v == Value.WRAP || v == Value.CLAMP) {
+ if (v == Value.WRAP || v == Value.CLAMP || v == Value.MIRRORED_REPEAT) {
mWrapT = v;
} else {
throw new IllegalArgumentException("Invalid value");
@@ -282,6 +322,16 @@
}
public Sampler create() {
+ if (mRS.isNative) {
+ RenderScriptThunker rst = (RenderScriptThunker)mRS;
+ SamplerThunker.Builder b = new SamplerThunker.Builder(rst);
+ b.setMinification(mMin);
+ b.setMagnification(mMag);
+ b.setWrapS(mWrapS);
+ b.setWrapT(mWrapT);
+ b.setAnisotropy(mAniso);
+ return b.create();
+ }
mRS.validate();
int id = mRS.nSamplerCreate(mMag.mID, mMin.mID,
mWrapS.mID, mWrapT.mID, mWrapR.mID, mAniso);
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/SamplerThunker.java b/renderscript/v8/java/src/android/support/v8/renderscript/SamplerThunker.java
new file mode 100644
index 0000000..56d9487
--- /dev/null
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/SamplerThunker.java
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v8.renderscript;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.util.Log;
+import android.os.Bundle;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+
+/**
+ *
+ **/
+class SamplerThunker extends Sampler {
+ android.renderscript.Sampler mN;
+
+ protected SamplerThunker(int id, RenderScript rs) {
+ super(id, rs);
+ }
+
+ android.renderscript.BaseObj getNObj() {
+ return mN;
+ }
+
+ static android.renderscript.Sampler.Value convertValue (Value v) {
+ switch (v) {
+ case NEAREST:
+ return android.renderscript.Sampler.Value.NEAREST;
+ case LINEAR:
+ return android.renderscript.Sampler.Value.LINEAR;
+ case LINEAR_MIP_LINEAR:
+ return android.renderscript.Sampler.Value.LINEAR_MIP_LINEAR;
+ case LINEAR_MIP_NEAREST:
+ return android.renderscript.Sampler.Value.LINEAR_MIP_NEAREST;
+ case WRAP:
+ return android.renderscript.Sampler.Value.WRAP;
+ case CLAMP:
+ return android.renderscript.Sampler.Value.CLAMP;
+ case MIRRORED_REPEAT:
+ return android.renderscript.Sampler.Value.MIRRORED_REPEAT;
+ }
+ return null;
+ }
+
+ /**
+ * Builder for creating non-standard samplers. Useful if mix and match of
+ * wrap modes is necesary or if anisotropic filtering is desired.
+ *
+ */
+ public static class Builder {
+ RenderScriptThunker mRS;
+ Value mMin;
+ Value mMag;
+ Value mWrapS;
+ Value mWrapT;
+ Value mWrapR;
+ float mAniso;
+
+ public Builder(RenderScriptThunker rs) {
+ mRS = rs;
+ mMin = Value.NEAREST;
+ mMag = Value.NEAREST;
+ mWrapS = Value.WRAP;
+ mWrapT = Value.WRAP;
+ mWrapR = Value.WRAP;
+ }
+
+ public void setMinification(Value v) {
+ if (v == Value.NEAREST ||
+ v == Value.LINEAR ||
+ v == Value.LINEAR_MIP_LINEAR ||
+ v == Value.LINEAR_MIP_NEAREST) {
+ mMin = v;
+ } else {
+ throw new IllegalArgumentException("Invalid value");
+ }
+ }
+
+ public void setMagnification(Value v) {
+ if (v == Value.NEAREST || v == Value.LINEAR) {
+ mMag = v;
+ } else {
+ throw new IllegalArgumentException("Invalid value");
+ }
+ }
+
+ public void setWrapS(Value v) {
+ if (v == Value.WRAP || v == Value.CLAMP || v == Value.MIRRORED_REPEAT) {
+ mWrapS = v;
+ } else {
+ throw new IllegalArgumentException("Invalid value");
+ }
+ }
+
+ public void setWrapT(Value v) {
+ if (v == Value.WRAP || v == Value.CLAMP || v == Value.MIRRORED_REPEAT) {
+ mWrapT = v;
+ } else {
+ throw new IllegalArgumentException("Invalid value");
+ }
+ }
+
+ public void setAnisotropy(float v) {
+ if(v >= 0.0f) {
+ mAniso = v;
+ } else {
+ throw new IllegalArgumentException("Invalid value");
+ }
+ }
+
+ public Sampler create() {
+ mRS.validate();
+ android.renderscript.Sampler.Builder b = new android.renderscript.Sampler.Builder(mRS.mN);
+ b.setMinification(convertValue(mMin));
+ b.setMagnification(convertValue(mMag));
+ b.setWrapS(convertValue(mWrapS));
+ b.setWrapT(convertValue(mWrapT));
+ b.setAnisotropy(mAniso);
+ android.renderscript.Sampler s = b.create();
+
+ SamplerThunker sampler = new SamplerThunker(0, mRS);
+ sampler.mMin = mMin;
+ sampler.mMag = mMag;
+ sampler.mWrapS = mWrapS;
+ sampler.mWrapT = mWrapT;
+ sampler.mWrapR = mWrapR;
+ sampler.mAniso = mAniso;
+ sampler.mN = s;
+
+ return sampler;
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/Script.java b/renderscript/v8/java/src/android/support/v8/renderscript/Script.java
index ebf91b3..33dd4ed 100644
--- a/renderscript/v8/java/src/android/support/v8/renderscript/Script.java
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/Script.java
@@ -22,6 +22,12 @@
*
**/
public class Script extends BaseObj {
+ ScriptCThunker mT;
+
+ android.renderscript.Script getNObj() {
+ return mT;
+ }
+
/**
* KernelID is an identifier for a Script + root function pair. It is used
@@ -32,6 +38,7 @@
*
*/
public static final class KernelID extends BaseObj {
+ android.renderscript.Script.KernelID mN;
Script mScript;
int mSlot;
int mSig;
@@ -61,12 +68,25 @@
return k;
}
+ // Any native callers to createKernelID must initialize their own native IDs
+ // excpet ScriptCThunker
+ if (mRS.isNative == true) {
+ k = new KernelID(0, mRS, this, slot, sig);
+ if (mT != null) {
+ k.mN = mT.thunkCreateKernelID(slot, sig, ein, eout);
+ }
+ mKIDs.put(slot, k);
+ return k;
+ }
+
+
int id = mRS.nScriptKernelIDCreate(getID(mRS), slot, sig);
if (id == 0) {
throw new RSDriverException("Failed to create KernelID");
}
k = new KernelID(id, mRS, this, slot, sig);
+
mKIDs.put(slot, k);
return k;
}
@@ -80,6 +100,7 @@
*
*/
public static final class FieldID extends BaseObj {
+ android.renderscript.Script.FieldID mN;
Script mScript;
int mSlot;
FieldID(int id, RenderScript rs, Script s, int slot) {
@@ -99,6 +120,17 @@
* @return FieldID
*/
protected FieldID createFieldID(int slot, Element e) {
+
+ // Any thunking caller to createFieldID must create its own native IDs
+ // except ScriptC
+ if (mRS.isNative == true) {
+ FieldID f = new FieldID(0, mRS, this, slot);
+ if (mT != null) {
+ f.mN = mT.thunkCreateFieldID(slot, e);
+ }
+ mFIDs.put(slot, f);
+ return f;
+ }
FieldID f = mFIDs.get(slot);
if (f != null) {
return f;
@@ -121,6 +153,11 @@
* @param slot
*/
protected void invoke(int slot) {
+ if (mT != null) {
+ mT.thunkInvoke(slot);
+ return;
+ }
+
mRS.nScriptInvoke(getID(mRS), slot);
}
@@ -131,6 +168,11 @@
* @param v
*/
protected void invoke(int slot, FieldPacker v) {
+ if (mT != null) {
+ mT.thunkInvoke(slot, v);
+ return;
+ }
+
if (v != null) {
mRS.nScriptInvokeV(getID(mRS), slot, v.getData());
} else {
@@ -141,12 +183,52 @@
/**
* Only intended for use by generated reflected code.
*
+ * @param va
+ * @param slot
+ */
+ public void bindAllocation(Allocation va, int slot) {
+ if (mT != null) {
+ mT.thunkBindAllocation(va, slot);
+ return;
+ }
+
+ mRS.validate();
+ if (va != null) {
+ mRS.nScriptBindAllocation(getID(mRS), va.getID(mRS), slot);
+ } else {
+ mRS.nScriptBindAllocation(getID(mRS), 0, slot);
+ }
+ }
+
+ public void setTimeZone(String timeZone) {
+ if (mT != null) {
+ mT.thunkSetTimeZone(timeZone);
+ return;
+ }
+
+ mRS.validate();
+ try {
+ mRS.nScriptSetTimeZone(getID(mRS), timeZone.getBytes("UTF-8"));
+ } catch (java.io.UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ /**
+ * Only intended for use by generated reflected code.
+ *
* @param slot
* @param ain
* @param aout
* @param v
*/
protected void forEach(int slot, Allocation ain, Allocation aout, FieldPacker v) {
+ if (mT != null) {
+ mT.thunkForEach(slot, ain, aout, v);
+ return;
+ }
+
if (ain == null && aout == null) {
throw new RSIllegalArgumentException(
"At least one of ain or aout is required to be non-null.");
@@ -166,27 +248,35 @@
mRS.nScriptForEach(getID(mRS), slot, in_id, out_id, params);
}
+ protected void forEach(int slot, Allocation ain, Allocation aout, FieldPacker v, LaunchOptions sc) {
+ if (ain == null && aout == null) {
+ throw new RSIllegalArgumentException(
+ "At least one of ain or aout is required to be non-null.");
+ }
+
+ if (sc == null) {
+ forEach(slot, ain, aout, v);
+ return;
+ }
+ int in_id = 0;
+ if (ain != null) {
+ in_id = ain.getID(mRS);
+ }
+ int out_id = 0;
+ if (aout != null) {
+ out_id = aout.getID(mRS);
+ }
+ byte[] params = null;
+ if (v != null) {
+ params = v.getData();
+ }
+ mRS.nScriptForEachClipped(getID(mRS), slot, in_id, out_id, params, sc.xstart, sc.xend, sc.ystart, sc.yend, sc.zstart, sc.zend);
+ }
Script(int id, RenderScript rs) {
super(id, rs);
}
-
- /**
- * Only intended for use by generated reflected code.
- *
- * @param va
- * @param slot
- */
- public void bindAllocation(Allocation va, int slot) {
- mRS.validate();
- if (va != null) {
- mRS.nScriptBindAllocation(getID(mRS), va.getID(mRS), slot);
- } else {
- mRS.nScriptBindAllocation(getID(mRS), 0, slot);
- }
- }
-
/**
* Only intended for use by generated reflected code.
*
@@ -194,6 +284,11 @@
* @param v
*/
public void setVar(int index, float v) {
+ if (mT != null) {
+ mT.thunkSetVar(index, v);
+ return;
+ }
+
mRS.nScriptSetVarF(getID(mRS), index, v);
}
@@ -204,6 +299,11 @@
* @param v
*/
public void setVar(int index, double v) {
+ if (mT != null) {
+ mT.thunkSetVar(index, v);
+ return;
+ }
+
mRS.nScriptSetVarD(getID(mRS), index, v);
}
@@ -214,6 +314,11 @@
* @param v
*/
public void setVar(int index, int v) {
+ if (mT != null) {
+ mT.thunkSetVar(index, v);
+ return;
+ }
+
mRS.nScriptSetVarI(getID(mRS), index, v);
}
@@ -224,6 +329,11 @@
* @param v
*/
public void setVar(int index, long v) {
+ if (mT != null) {
+ mT.thunkSetVar(index, v);
+ return;
+ }
+
mRS.nScriptSetVarJ(getID(mRS), index, v);
}
@@ -234,6 +344,11 @@
* @param v
*/
public void setVar(int index, boolean v) {
+ if (mT != null) {
+ mT.thunkSetVar(index, v);
+ return;
+ }
+
mRS.nScriptSetVarI(getID(mRS), index, v ? 1 : 0);
}
@@ -244,6 +359,11 @@
* @param o
*/
public void setVar(int index, BaseObj o) {
+ if (mT != null) {
+ mT.thunkSetVar(index, o);
+ return;
+ }
+
mRS.nScriptSetVarObj(getID(mRS), index, (o == null) ? 0 : o.getID(mRS));
}
@@ -254,6 +374,11 @@
* @param v
*/
public void setVar(int index, FieldPacker v) {
+ if (mT != null) {
+ mT.thunkSetVar(index, v);
+ return;
+ }
+
mRS.nScriptSetVarV(getID(mRS), index, v.getData());
}
@@ -266,16 +391,12 @@
* @param dims
*/
public void setVar(int index, FieldPacker v, Element e, int[] dims) {
- mRS.nScriptSetVarVE(getID(mRS), index, v.getData(), e.getID(mRS), dims);
- }
-
- public void setTimeZone(String timeZone) {
- mRS.validate();
- try {
- mRS.nScriptSetTimeZone(getID(mRS), timeZone.getBytes("UTF-8"));
- } catch (java.io.UnsupportedEncodingException e) {
- throw new RuntimeException(e);
+ if (mT != null) {
+ mT.thunkSetVar(index, v, e, dims);
+ return;
}
+
+ mRS.nScriptSetVarVE(getID(mRS), index, v.getData(), e.getID(mRS), dims);
}
public static class Builder {
@@ -318,5 +439,64 @@
public void updateAllocation() {
}
}
+
+ public static final class LaunchOptions {
+ protected int xstart = 0;
+ protected int ystart = 0;
+ protected int xend = 0;
+ protected int yend = 0;
+ protected int zstart = 0;
+ protected int zend = 0;
+
+ protected int strategy;
+
+ public LaunchOptions setX(int xstartArg, int xendArg) {
+ if (xstartArg < 0 || xendArg <= xstartArg) {
+ throw new RSIllegalArgumentException("Invalid dimensions");
+ }
+ xstart = xstartArg;
+ xend = xendArg;
+ return this;
+ }
+
+ public LaunchOptions setY(int ystartArg, int yendArg) {
+ if (ystartArg < 0 || yendArg <= ystartArg) {
+ throw new RSIllegalArgumentException("Invalid dimensions");
+ }
+ ystart = ystartArg;
+ yend = yendArg;
+ return this;
+ }
+
+ public LaunchOptions setZ(int zstartArg, int zendArg) {
+ if (zstartArg < 0 || zendArg <= zstartArg) {
+ throw new RSIllegalArgumentException("Invalid dimensions");
+ }
+ zstart = zstartArg;
+ zend = zendArg;
+ return this;
+ }
+
+
+ public int getXStart() {
+ return xstart;
+ }
+ public int getXEnd() {
+ return xend;
+ }
+ public int getYStart() {
+ return ystart;
+ }
+ public int getYEnd() {
+ return yend;
+ }
+ public int getZStart() {
+ return zstart;
+ }
+ public int getZEnd() {
+ return zend;
+ }
+
+ }
}
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptC.java b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptC.java
index ec625ae..2807ea6 100644
--- a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptC.java
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptC.java
@@ -55,6 +55,14 @@
*/
protected ScriptC(RenderScript rs, Resources resources, int resourceID) {
super(0, rs);
+
+ if (rs.isNative) {
+ RenderScriptThunker rst = (RenderScriptThunker)rs;
+ ScriptCThunker s = new ScriptCThunker(rst, resources, resourceID);
+ mT = s;
+ return;
+ }
+
int id = internalCreate(rs, resources, resourceID);
if (id == 0) {
throw new RSRuntimeException("Loading of ScriptC script failed.");
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptCThunker.java b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptCThunker.java
new file mode 100644
index 0000000..50b7904
--- /dev/null
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptCThunker.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v8.renderscript;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.util.Log;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map.Entry;
+import java.util.HashMap;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+
+/**
+ *
+ **/
+class ScriptCThunker extends android.renderscript.ScriptC {
+ private static final String TAG = "ScriptC";
+
+ protected ScriptCThunker(RenderScriptThunker rs, Resources resources, int resourceID) {
+ super(rs.mN, resources, resourceID);
+ }
+
+ android.renderscript.Script.KernelID thunkCreateKernelID(
+ int slot, int sig, Element ein, Element eout) {
+
+ android.renderscript.Element nein = null;
+ android.renderscript.Element neout = null;
+ if (ein != null) {
+ nein = ((ElementThunker)ein).mN;
+ }
+ if (eout != null) {
+ neout = ((ElementThunker)eout).mN;
+ }
+ return createKernelID(slot, sig, nein, neout);
+ }
+
+
+ void thunkInvoke(int slot) {
+ invoke(slot);
+ }
+
+ void thunkBindAllocation(Allocation va, int slot) {
+ android.renderscript.Allocation nva = null;
+ if (va != null) {
+ nva = ((AllocationThunker)va).mN;
+ }
+ bindAllocation(nva, slot);
+ }
+
+ void thunkSetTimeZone(String timeZone) {
+ setTimeZone(timeZone);
+ }
+
+ void thunkInvoke(int slot, FieldPacker v) {
+ android.renderscript.FieldPacker nfp =
+ new android.renderscript.FieldPacker(v.getData());
+ invoke(slot, nfp);
+ }
+
+ void thunkForEach(int slot, Allocation ain, Allocation aout, FieldPacker v) {
+ android.renderscript.Allocation nin = null;
+ android.renderscript.Allocation nout = null;
+ android.renderscript.FieldPacker nfp = null;
+ if (ain != null) {
+ nin = ((AllocationThunker)ain).mN;
+ }
+ if (aout != null) {
+ nout = ((AllocationThunker)aout).mN;
+ }
+ if (v != null) {
+ nfp = new android.renderscript.FieldPacker(v.getData());
+ }
+ forEach(slot, nin, nout, nfp);
+ }
+
+ void thunkSetVar(int index, float v) {
+ setVar(index, v);
+ }
+ void thunkSetVar(int index, double v) {
+ setVar(index, v);
+ }
+ void thunkSetVar(int index, int v) {
+ setVar(index, v);
+ }
+ void thunkSetVar(int index, long v) {
+ setVar(index, v);
+ }
+ void thunkSetVar(int index, boolean v) {
+ setVar(index, v);
+ }
+
+ void thunkSetVar(int index, BaseObj o) {
+ setVar(index, o.getNObj());
+ }
+ void thunkSetVar(int index, FieldPacker v) {
+ android.renderscript.FieldPacker nfp =
+ new android.renderscript.FieldPacker(v.getData());
+ setVar(index, nfp);
+ }
+
+ void thunkSetVar(int index, FieldPacker v, Element e, int[] dims) {
+ android.renderscript.FieldPacker nfp =
+ new android.renderscript.FieldPacker(v.getData());
+ ElementThunker et = (ElementThunker)e;
+ setVar(index, nfp, et.mN, dims);
+ }
+
+ android.renderscript.Script.FieldID thunkCreateFieldID(int slot, Element e) {
+ ElementThunker et = (ElementThunker) e;
+ return createFieldID(slot, et.getNObj());
+ }
+
+}
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptGroup.java b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptGroup.java
index cf51d1b..1d63708 100644
--- a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptGroup.java
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptGroup.java
@@ -32,9 +32,15 @@
* user supplied allocation. Inputs are similar but supply the
* input of a kernal. Inputs bounds to a script are set directly
* upon the script.
+ * <p>
+ * A ScriptGroup must contain at least one kernel. A ScriptGroup
+ * must contain only a single directed acyclic graph (DAG) of
+ * script kernels and connections. Attempting to create a
+ * ScriptGroup with multiple DAGs or attempting to create
+ * a cycle within a ScriptGroup will throw an exception.
*
**/
-public final class ScriptGroup extends BaseObj {
+public class ScriptGroup extends BaseObj {
IO mOutputs[];
IO mInputs[];
@@ -71,7 +77,7 @@
ArrayList<Script.KernelID> mKernels = new ArrayList<Script.KernelID>();
ArrayList<ConnectLine> mInputs = new ArrayList<ConnectLine>();
ArrayList<ConnectLine> mOutputs = new ArrayList<ConnectLine>();
- boolean mSeen;
+ int dagNumber;
Node mNext;
@@ -159,6 +165,8 @@
private ArrayList<ConnectLine> mLines = new ArrayList<ConnectLine>();
private int mKernelCount;
+ private ScriptGroupThunker.Builder mT;
+
/**
* Create a builder for generating a ScriptGroup.
*
@@ -166,42 +174,76 @@
* @param rs The Renderscript context.
*/
public Builder(RenderScript rs) {
+ if (rs.isNative) {
+ mT = new ScriptGroupThunker.Builder(rs);
+ }
mRS = rs;
}
- private void validateRecurse(Node n, int depth) {
- n.mSeen = true;
-
- //android.util.Log.v("RSR", " validateRecurse outputCount " + n.mOutputs.size());
- for (int ct=0; ct < n.mOutputs.size(); ct++) {
- final ConnectLine cl = n.mOutputs.get(ct);
+ // do a DFS from original node, looking for original node
+ // any cycle that could be created must contain original node
+ private void validateCycle(Node target, Node original) {
+ for (int ct = 0; ct < target.mOutputs.size(); ct++) {
+ final ConnectLine cl = target.mOutputs.get(ct);
if (cl.mToK != null) {
Node tn = findNode(cl.mToK.mScript);
- if (tn.mSeen) {
+ if (tn.equals(original)) {
throw new RSInvalidStateException("Loops in group not allowed.");
}
- validateRecurse(tn, depth + 1);
+ validateCycle(tn, original);
}
if (cl.mToF != null) {
Node tn = findNode(cl.mToF.mScript);
- if (tn.mSeen) {
+ if (tn.equals(original)) {
throw new RSInvalidStateException("Loops in group not allowed.");
}
- validateRecurse(tn, depth + 1);
+ validateCycle(tn, original);
}
}
}
- private void validate() {
- //android.util.Log.v("RSR", "validate");
-
+ private void mergeDAGs(int valueUsed, int valueKilled) {
for (int ct=0; ct < mNodes.size(); ct++) {
- for (int ct2=0; ct2 < mNodes.size(); ct2++) {
- mNodes.get(ct2).mSeen = false;
+ if (mNodes.get(ct).dagNumber == valueKilled)
+ mNodes.get(ct).dagNumber = valueUsed;
+ }
+ }
+
+ private void validateDAGRecurse(Node n, int dagNumber) {
+ // combine DAGs if this node has been seen already
+ if (n.dagNumber != 0 && n.dagNumber != dagNumber) {
+ mergeDAGs(n.dagNumber, dagNumber);
+ return;
+ }
+
+ n.dagNumber = dagNumber;
+ for (int ct=0; ct < n.mOutputs.size(); ct++) {
+ final ConnectLine cl = n.mOutputs.get(ct);
+ if (cl.mToK != null) {
+ Node tn = findNode(cl.mToK.mScript);
+ validateDAGRecurse(tn, dagNumber);
}
+ if (cl.mToF != null) {
+ Node tn = findNode(cl.mToF.mScript);
+ validateDAGRecurse(tn, dagNumber);
+ }
+ }
+ }
+
+ private void validateDAG() {
+ for (int ct=0; ct < mNodes.size(); ct++) {
Node n = mNodes.get(ct);
if (n.mInputs.size() == 0) {
- validateRecurse(n, 0);
+ if (n.mOutputs.size() == 0 && mNodes.size() > 1) {
+ throw new RSInvalidStateException("Groups cannot contain unconnected scripts");
+ }
+ validateDAGRecurse(n, ct+1);
+ }
+ }
+ int dagNumber = mNodes.get(0).dagNumber;
+ for (int ct=0; ct < mNodes.size(); ct++) {
+ if (mNodes.get(ct).dagNumber != dagNumber) {
+ throw new RSInvalidStateException("Multiple DAGs in group not allowed.");
}
}
}
@@ -236,6 +278,11 @@
* @return Builder Returns this.
*/
public Builder addKernel(Script.KernelID k) {
+ if (mT != null) {
+ mT.addKernel(k);
+ return this;
+ }
+
if (mLines.size() != 0) {
throw new RSInvalidStateException(
"Kernels may not be added once connections exist.");
@@ -272,9 +319,14 @@
public Builder addConnection(Type t, Script.KernelID from, Script.FieldID to) {
//android.util.Log.v("RSR", "addConnection " + t +", " + from + ", " + to);
+ if (mT != null) {
+ mT.addConnection(t, from, to);
+ return this;
+ }
+
Node nf = findNode(from);
if (nf == null) {
- throw new RSInvalidStateException("From kernel not found.");
+ throw new RSInvalidStateException("From script not found.");
}
Node nt = findNode(to.mScript);
@@ -288,7 +340,7 @@
nf.mOutputs.add(cl);
nt.mInputs.add(cl);
- validate();
+ validateCycle(nf, nf);
return this;
}
@@ -307,9 +359,14 @@
public Builder addConnection(Type t, Script.KernelID from, Script.KernelID to) {
//android.util.Log.v("RSR", "addConnection " + t +", " + from + ", " + to);
+ if (mT != null) {
+ mT.addConnection(t, from, to);
+ return this;
+ }
+
Node nf = findNode(from);
if (nf == null) {
- throw new RSInvalidStateException("From kernel not found.");
+ throw new RSInvalidStateException("From script not found.");
}
Node nt = findNode(to);
@@ -323,7 +380,7 @@
nf.mOutputs.add(cl);
nt.mInputs.add(cl);
- validate();
+ validateCycle(nf, nf);
return this;
}
@@ -336,6 +393,21 @@
* @return ScriptGroup The new ScriptGroup
*/
public ScriptGroup create() {
+
+ if (mT != null) {
+ return mT.create();
+ }
+
+ if (mNodes.size() == 0) {
+ throw new RSInvalidStateException("Empty script groups are not allowed");
+ }
+
+ // reset DAG numbers in case we're building a second group
+ for (int ct=0; ct < mNodes.size(); ct++) {
+ mNodes.get(ct).dagNumber = 0;
+ }
+ validateDAG();
+
ArrayList<IO> inputs = new ArrayList<IO>();
ArrayList<IO> outputs = new ArrayList<IO>();
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptGroupThunker.java b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptGroupThunker.java
new file mode 100644
index 0000000..f6e8bc4
--- /dev/null
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptGroupThunker.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v8.renderscript;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+
+class ScriptGroupThunker extends ScriptGroup {
+ android.renderscript.ScriptGroup mN;
+
+ android.renderscript.ScriptGroup getNObj() {
+ return mN;
+ }
+
+ ScriptGroupThunker(int id, RenderScript rs) {
+ super(id, rs);
+ }
+
+ public void setInput(Script.KernelID s, Allocation a) {
+ AllocationThunker at = (AllocationThunker) a;
+ mN.setInput(s.mN, at.getNObj());
+ }
+
+ public void setOutput(Script.KernelID s, Allocation a) {
+ AllocationThunker at = (AllocationThunker) a;
+ mN.setOutput(s.mN, at.getNObj());
+ }
+
+ public void execute() {
+ mN.execute();
+ }
+
+
+ public static final class Builder {
+
+ android.renderscript.ScriptGroup.Builder bN;
+ RenderScript mRS;
+
+ Builder(RenderScript rs) {
+ RenderScriptThunker rst = (RenderScriptThunker) rs;
+ mRS = rs;
+ bN = new android.renderscript.ScriptGroup.Builder(rst.mN);
+ }
+
+ public Builder addKernel(Script.KernelID k) {
+ bN.addKernel(k.mN);
+ return this;
+ }
+
+ public Builder addConnection(Type t, Script.KernelID from, Script.FieldID to) {
+ TypeThunker tt = (TypeThunker) t;
+ bN.addConnection(tt.getNObj(), from.mN, to.mN);
+ return this;
+ }
+
+ public Builder addConnection(Type t, Script.KernelID from, Script.KernelID to) {
+ TypeThunker tt = (TypeThunker) t;
+ bN.addConnection(tt.getNObj(), from.mN, to.mN);
+ return this;
+ }
+
+
+
+ public ScriptGroupThunker create() {
+ ScriptGroupThunker sg = new ScriptGroupThunker(0, mRS);
+ sg.mN = bN.create();
+ return sg;
+ }
+ }
+
+
+}
+
+
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsic3DLUT.java b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsic3DLUT.java
new file mode 100644
index 0000000..bcf1313
--- /dev/null
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsic3DLUT.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v8.renderscript;
+
+import android.util.Log;
+
+/**
+ *
+ * @hide
+ **/
+public class ScriptIntrinsic3DLUT extends ScriptIntrinsic {
+ private Allocation mLUT;
+ private Element mElement;
+
+ protected ScriptIntrinsic3DLUT(int id, RenderScript rs, Element e) {
+ super(id, rs);
+ mElement = e;
+ }
+
+ /**
+ * Supported elements types are {@link Element#U8_4}
+ *
+ * The defaults tables are identity.
+ *
+ * @param rs The Renderscript context
+ * @param e Element type for intputs and outputs
+ *
+ * @return ScriptIntrinsic3DLUT
+ */
+ public static ScriptIntrinsic3DLUT create(RenderScript rs, Element e) {
+ if (rs.isNative) {
+ RenderScriptThunker rst = (RenderScriptThunker) rs;
+ return ScriptIntrinsic3DLUTThunker.create(rs, e);
+ }
+ int id = rs.nScriptIntrinsicCreate(8, e.getID(rs));
+
+ if (!e.isCompatible(Element.U8_4(rs))) {
+ throw new RSIllegalArgumentException("Element must be compatible with uchar4.");
+ }
+
+ return new ScriptIntrinsic3DLUT(id, rs, e);
+ }
+
+ public void setLUT(Allocation lut) {
+ final Type t = lut.getType();
+
+ if (t.getZ() == 0) {
+ throw new RSIllegalArgumentException("LUT must be 3d.");
+ }
+
+ if (!t.getElement().isCompatible(mElement)) {
+ throw new RSIllegalArgumentException("LUT element type must match.");
+ }
+
+ mLUT = lut;
+ setVar(0, mLUT);
+ }
+
+
+ /**
+ * Invoke the kernel and apply the lookup to each cell of ain
+ * and copy to aout.
+ *
+ * @param ain Input allocation
+ * @param aout Output allocation
+ */
+ public void forEach(Allocation ain, Allocation aout) {
+ forEach(0, ain, aout, null);
+ }
+
+ /**
+ * Get a KernelID for this intrinsic kernel.
+ *
+ * @return Script.KernelID The KernelID object.
+ */
+ public Script.KernelID getKernelID() {
+ return createKernelID(0, 3, null, null);
+ }
+}
+
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsic3DLUTThunker.java b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsic3DLUTThunker.java
new file mode 100644
index 0000000..ce11a4d
--- /dev/null
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsic3DLUTThunker.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v8.renderscript;
+
+import android.util.Log;
+
+/**
+ *
+ * @hide
+ **/
+class ScriptIntrinsic3DLUTThunker extends ScriptIntrinsic3DLUT {
+ android.renderscript.ScriptIntrinsic3DLUT mN;
+
+ android.renderscript.ScriptIntrinsic3DLUT getNObj() {
+ return mN;
+ }
+
+ private ScriptIntrinsic3DLUTThunker(int id, RenderScript rs, Element e) {
+ super(id, rs, e);
+ }
+
+ public static ScriptIntrinsic3DLUTThunker create(RenderScript rs, Element e) {
+ RenderScriptThunker rst = (RenderScriptThunker) rs;
+ ElementThunker et = (ElementThunker) e;
+
+ ScriptIntrinsic3DLUTThunker lut = new ScriptIntrinsic3DLUTThunker(0, rs, e);
+ lut.mN = android.renderscript.ScriptIntrinsic3DLUT.create(rst.mN, et.getNObj());
+ return lut;
+ }
+
+ public void setLUT(Allocation lut) {
+ AllocationThunker lutt = (AllocationThunker) lut;
+ mN.setLUT(lutt.getNObj());
+ }
+
+
+ /**
+ * Invoke the kernel and apply the lookup to each cell of ain
+ * and copy to aout.
+ *
+ * @param ain Input allocation
+ * @param aout Output allocation
+ */
+ public void forEach(Allocation ain, Allocation aout) {
+ AllocationThunker aint = (AllocationThunker)ain;
+ AllocationThunker aoutt = (AllocationThunker)aout;
+ mN.forEach(aint.getNObj(), aoutt.getNObj());
+ }
+
+ /**
+ * Get a KernelID for this intrinsic kernel.
+ *
+ * @return Script.KernelID The KernelID object.
+ */
+ public Script.KernelID getKernelID() {
+ Script.KernelID k = createKernelID(0, 3, null, null);
+ k.mN = mN.getKernelID();
+ return k;
+ }
+}
+
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicBlend.java b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicBlend.java
index a7e2588..db45a19 100644
--- a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicBlend.java
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicBlend.java
@@ -36,6 +36,10 @@
* @return ScriptIntrinsicBlend
*/
public static ScriptIntrinsicBlend create(RenderScript rs, Element e) {
+ if (rs.isNative) {
+ RenderScriptThunker rst = (RenderScriptThunker) rs;
+ return ScriptIntrinsicBlendThunker.create(rs, e);
+ }
// 7 comes from RS_SCRIPT_INTRINSIC_ID_BLEND in rsDefines.h
int id = rs.nScriptIntrinsicCreate(7, e.getID(rs));
return new ScriptIntrinsicBlend(id, rs);
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicBlendThunker.java b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicBlendThunker.java
new file mode 100644
index 0000000..2836034
--- /dev/null
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicBlendThunker.java
@@ -0,0 +1,235 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v8.renderscript;
+
+class ScriptIntrinsicBlendThunker extends ScriptIntrinsicBlend {
+ android.renderscript.ScriptIntrinsicBlend mN;
+
+ android.renderscript.ScriptIntrinsicBlend getNObj() {
+ return mN;
+ }
+
+ ScriptIntrinsicBlendThunker(int id, RenderScript rs) {
+ super(id, rs);
+ }
+
+ public static ScriptIntrinsicBlendThunker create(RenderScript rs, Element e) {
+ RenderScriptThunker rst = (RenderScriptThunker) rs;
+ ElementThunker et = (ElementThunker)e;
+
+ ScriptIntrinsicBlendThunker blend = new ScriptIntrinsicBlendThunker(0, rs);
+ blend.mN = android.renderscript.ScriptIntrinsicBlend.create(rst.mN, et.getNObj());
+ return blend;
+ }
+
+ public void forEachClear(Allocation ain, Allocation aout) {
+ AllocationThunker aint = (AllocationThunker)ain;
+ AllocationThunker aoutt = (AllocationThunker)aout;
+
+ mN.forEachClear(aint.getNObj(), aoutt.getNObj());
+ }
+
+ public Script.KernelID getKernelIDClear() {
+ Script.KernelID k = createKernelID(0, 3, null, null);
+ k.mN = mN.getKernelIDClear();
+ return k;
+ }
+
+ public void forEachSrc(Allocation ain, Allocation aout) {
+ AllocationThunker aint = (AllocationThunker)ain;
+ AllocationThunker aoutt = (AllocationThunker)aout;
+
+ mN.forEachSrc(aint.getNObj(), aoutt.getNObj());
+ }
+
+ public Script.KernelID getKernelIDSrc() {
+ Script.KernelID k = createKernelID(1, 3, null, null);
+ k.mN = mN.getKernelIDSrc();
+ return k;
+ }
+
+ public void forEachDst(Allocation ain, Allocation aout) {
+ AllocationThunker aint = (AllocationThunker)ain;
+ AllocationThunker aoutt = (AllocationThunker)aout;
+
+ mN.forEachDst(aint.getNObj(), aoutt.getNObj());
+ }
+
+ public Script.KernelID getKernelIDDst() {
+ Script.KernelID k = createKernelID(2, 3, null, null);
+ k.mN = mN.getKernelIDDst();
+ return k;
+ }
+
+ public void forEachSrcOver(Allocation ain, Allocation aout) {
+ AllocationThunker aint = (AllocationThunker)ain;
+ AllocationThunker aoutt = (AllocationThunker)aout;
+
+ mN.forEachSrcOver(aint.getNObj(), aoutt.getNObj());
+ }
+
+ public Script.KernelID getKernelIDSrcOver() {
+ Script.KernelID k = createKernelID(3, 3, null, null);
+ k.mN = mN.getKernelIDSrcOver();
+ return k;
+ }
+
+ public void forEachDstOver(Allocation ain, Allocation aout) {
+ AllocationThunker aint = (AllocationThunker)ain;
+ AllocationThunker aoutt = (AllocationThunker)aout;
+
+ mN.forEachDstOver(aint.getNObj(), aoutt.getNObj());
+ }
+
+ public Script.KernelID getKernelIDDstOver() {
+ Script.KernelID k = createKernelID(4, 3, null, null);
+ k.mN = mN.getKernelIDDstOver();
+ return k;
+ }
+
+ public void forEachSrcIn(Allocation ain, Allocation aout) {
+ AllocationThunker aint = (AllocationThunker)ain;
+ AllocationThunker aoutt = (AllocationThunker)aout;
+
+ mN.forEachSrcIn(aint.getNObj(), aoutt.getNObj());
+ }
+
+ public Script.KernelID getKernelIDSrcIn() {
+ Script.KernelID k = createKernelID(5, 3, null, null);
+ k.mN = mN.getKernelIDSrcIn();
+ return k;
+ }
+
+ public void forEachDstIn(Allocation ain, Allocation aout) {
+ AllocationThunker aint = (AllocationThunker)ain;
+ AllocationThunker aoutt = (AllocationThunker)aout;
+
+ mN.forEachDstIn(aint.getNObj(), aoutt.getNObj());
+ }
+
+ public Script.KernelID getKernelIDDstIn() {
+ Script.KernelID k = createKernelID(6, 3, null, null);
+ k.mN = mN.getKernelIDDstIn();
+ return k;
+ }
+
+ public void forEachSrcOut(Allocation ain, Allocation aout) {
+ AllocationThunker aint = (AllocationThunker)ain;
+ AllocationThunker aoutt = (AllocationThunker)aout;
+
+ mN.forEachSrcOut(aint.getNObj(), aoutt.getNObj());
+ }
+
+ public Script.KernelID getKernelIDSrcOut() {
+ Script.KernelID k = createKernelID(7, 3, null, null);
+ k.mN = mN.getKernelIDSrcOut();
+ return k;
+ }
+
+ public void forEachDstOut(Allocation ain, Allocation aout) {
+ AllocationThunker aint = (AllocationThunker)ain;
+ AllocationThunker aoutt = (AllocationThunker)aout;
+
+ mN.forEachDstOut(aint.getNObj(), aoutt.getNObj());
+ }
+
+ public Script.KernelID getKernelIDDstOut() {
+ Script.KernelID k = createKernelID(8, 3, null, null);
+ k.mN = mN.getKernelIDDstOut();
+ return k;
+ }
+
+ public void forEachSrcAtop(Allocation ain, Allocation aout) {
+ AllocationThunker aint = (AllocationThunker)ain;
+ AllocationThunker aoutt = (AllocationThunker)aout;
+
+ mN.forEachSrcAtop(aint.getNObj(), aoutt.getNObj());
+ }
+
+ public Script.KernelID getKernelIDSrcAtop() {
+ Script.KernelID k = createKernelID(9, 3, null, null);
+ k.mN = mN.getKernelIDSrcAtop();
+ return k;
+ }
+
+ public void forEachDstAtop(Allocation ain, Allocation aout) {
+ AllocationThunker aint = (AllocationThunker)ain;
+ AllocationThunker aoutt = (AllocationThunker)aout;
+
+ mN.forEachDstAtop(aint.getNObj(), aoutt.getNObj());
+ }
+
+ public Script.KernelID getKernelIDDstAtop() {
+ Script.KernelID k = createKernelID(10, 3, null, null);
+ k.mN = mN.getKernelIDDstAtop();
+ return k;
+ }
+
+ public void forEachXor(Allocation ain, Allocation aout) {
+ AllocationThunker aint = (AllocationThunker)ain;
+ AllocationThunker aoutt = (AllocationThunker)aout;
+
+ mN.forEachXor(aint.getNObj(), aoutt.getNObj());
+ }
+
+ public Script.KernelID getKernelIDXor() {
+ Script.KernelID k = createKernelID(11, 3, null, null);
+ k.mN = mN.getKernelIDXor();
+ return k;
+ }
+
+ public void forEachMultiply(Allocation ain, Allocation aout) {
+ AllocationThunker aint = (AllocationThunker)ain;
+ AllocationThunker aoutt = (AllocationThunker)aout;
+
+ mN.forEachMultiply(aint.getNObj(), aoutt.getNObj());
+ }
+
+ public Script.KernelID getKernelIDMultiply() {
+ Script.KernelID k = createKernelID(14, 3, null, null);
+ k.mN = mN.getKernelIDMultiply();
+ return k;
+ }
+
+ public void forEachAdd(Allocation ain, Allocation aout) {
+ AllocationThunker aint = (AllocationThunker)ain;
+ AllocationThunker aoutt = (AllocationThunker)aout;
+
+ mN.forEachAdd(aint.getNObj(), aoutt.getNObj());
+ }
+
+ public Script.KernelID getKernelIDAdd() {
+ Script.KernelID k = createKernelID(34, 3, null, null);
+ k.mN = mN.getKernelIDAdd();
+ return k;
+ }
+
+ public void forEachSubtract(Allocation ain, Allocation aout) {
+ AllocationThunker aint = (AllocationThunker)ain;
+ AllocationThunker aoutt = (AllocationThunker)aout;
+
+ mN.forEachSubtract(aint.getNObj(), aoutt.getNObj());
+ }
+
+ public Script.KernelID getKernelIDSubtract() {
+ Script.KernelID k = createKernelID(35, 3, null, null);
+ k.mN = mN.getKernelIDSubtract();
+ return k;
+ }
+
+}
+
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicBlur.java b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicBlur.java
index 686936a..302b8e8 100644
--- a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicBlur.java
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicBlur.java
@@ -26,11 +26,11 @@
*
*
**/
-public final class ScriptIntrinsicBlur extends ScriptIntrinsic {
+public class ScriptIntrinsicBlur extends ScriptIntrinsic {
private final float[] mValues = new float[9];
private Allocation mInput;
- private ScriptIntrinsicBlur(int id, RenderScript rs) {
+ protected ScriptIntrinsicBlur(int id, RenderScript rs) {
super(id, rs);
}
@@ -46,7 +46,11 @@
* @return ScriptIntrinsicBlur
*/
public static ScriptIntrinsicBlur create(RenderScript rs, Element e) {
- if (e != Element.U8_4(rs)) {
+ if (rs.isNative) {
+ RenderScriptThunker rst = (RenderScriptThunker) rs;
+ return ScriptIntrinsicBlurThunker.create(rs, e);
+ }
+ if ((e != Element.U8_4(rs)) && e != (Element.U8(rs))) {
throw new RSIllegalArgumentException("Unsuported element type.");
}
int id = rs.nScriptIntrinsicCreate(5, e.getID(rs));
@@ -63,7 +67,7 @@
*/
public void setInput(Allocation ain) {
mInput = ain;
- bindAllocation(ain, 1);
+ setVar(1, ain);
}
/**
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicBlurThunker.java b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicBlurThunker.java
new file mode 100644
index 0000000..9be99cb
--- /dev/null
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicBlurThunker.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v8.renderscript;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.util.Log;
+
+class ScriptIntrinsicBlurThunker extends ScriptIntrinsicBlur {
+
+ android.renderscript.ScriptIntrinsicBlur mN;
+
+ android.renderscript.ScriptIntrinsicBlur getNObj() {
+ return mN;
+ }
+
+ protected ScriptIntrinsicBlurThunker(int id, RenderScript rs) {
+ super(id, rs);
+ }
+
+ public static ScriptIntrinsicBlurThunker create(RenderScript rs, Element e) {
+ RenderScriptThunker rst = (RenderScriptThunker) rs;
+ ElementThunker et = (ElementThunker) e;
+
+ ScriptIntrinsicBlurThunker blur = new ScriptIntrinsicBlurThunker(0, rs);
+ blur.mN = android.renderscript.ScriptIntrinsicBlur.create(rst.mN, et.getNObj());
+ return blur;
+ }
+
+ public void setInput(Allocation ain) {
+ AllocationThunker aint = (AllocationThunker) ain;
+ mN.setInput(aint.getNObj());
+ }
+
+ public void setRadius(float radius) {
+ mN.setRadius(radius);
+ }
+
+ public void forEach(Allocation aout) {
+ AllocationThunker aoutt = (AllocationThunker) aout;
+ if (aoutt != null) {
+ mN.forEach(aoutt.getNObj());
+ }
+ }
+
+ public Script.KernelID getKernelID() {
+ Script.KernelID k = createKernelID(0, 2, null, null);
+ k.mN = mN.getKernelID();
+ return k;
+ }
+
+ public Script.FieldID getFieldID_Input() {
+ Script.FieldID f = createFieldID(1, null);
+ f.mN = mN.getFieldID_Input();
+ return f;
+ }
+}
+
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicColorMatrix.java b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicColorMatrix.java
index 6c3445e..9337303 100644
--- a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicColorMatrix.java
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicColorMatrix.java
@@ -27,11 +27,11 @@
* rsMatrixMultiply() and writing it to the output after
* conversion back to {@link Element#U8_4}.
**/
-public final class ScriptIntrinsicColorMatrix extends ScriptIntrinsic {
+public class ScriptIntrinsicColorMatrix extends ScriptIntrinsic {
private final Matrix4f mMatrix = new Matrix4f();
private Allocation mInput;
- private ScriptIntrinsicColorMatrix(int id, RenderScript rs) {
+ protected ScriptIntrinsicColorMatrix(int id, RenderScript rs) {
super(id, rs);
}
@@ -47,7 +47,12 @@
* @return ScriptIntrinsicColorMatrix
*/
public static ScriptIntrinsicColorMatrix create(RenderScript rs, Element e) {
- if (e != Element.U8_4(rs)) {
+ if (rs.isNative) {
+ RenderScriptThunker rst = (RenderScriptThunker) rs;
+ return ScriptIntrinsicColorMatrixThunker.create(rs, e);
+ }
+
+ if (!e.isCompatible(Element.U8_4(rs))) {
throw new RSIllegalArgumentException("Unsuported element type.");
}
int id = rs.nScriptIntrinsicCreate(2, e.getID(rs));
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicColorMatrixThunker.java b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicColorMatrixThunker.java
new file mode 100644
index 0000000..28c2a7b
--- /dev/null
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicColorMatrixThunker.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v8.renderscript;
+
+import android.util.Log;
+
+class ScriptIntrinsicColorMatrixThunker extends ScriptIntrinsicColorMatrix {
+ android.renderscript.ScriptIntrinsicColorMatrix mN;
+
+ android.renderscript.ScriptIntrinsicColorMatrix getNObj() {
+ return mN;
+ }
+
+ private ScriptIntrinsicColorMatrixThunker(int id, RenderScript rs) {
+ super(id, rs);
+ }
+
+ public static ScriptIntrinsicColorMatrixThunker create(RenderScript rs, Element e) {
+ RenderScriptThunker rst = (RenderScriptThunker) rs;
+ ElementThunker et = (ElementThunker)e;
+
+ ScriptIntrinsicColorMatrixThunker cm = new ScriptIntrinsicColorMatrixThunker(0, rs);
+ cm.mN = android.renderscript.ScriptIntrinsicColorMatrix.create(rst.mN, et.getNObj());
+ return cm;
+
+ }
+
+ public void setColorMatrix(Matrix4f m) {
+ mN.setColorMatrix(new android.renderscript.Matrix4f(m.getArray()));
+ }
+
+ public void setColorMatrix(Matrix3f m) {
+ mN.setColorMatrix(new android.renderscript.Matrix3f(m.getArray()));
+ }
+
+ public void setGreyscale() {
+ mN.setGreyscale();
+ }
+
+ public void setYUVtoRGB() {
+ mN.setYUVtoRGB();
+ }
+
+ public void setRGBtoYUV() {
+ mN.setRGBtoYUV();
+ }
+
+
+ public void forEach(Allocation ain, Allocation aout) {
+ AllocationThunker aint = (AllocationThunker)ain;
+ AllocationThunker aoutt = (AllocationThunker)aout;
+ mN.forEach(aint.getNObj(), aoutt.getNObj());
+ }
+
+ public Script.KernelID getKernelID() {
+ Script.KernelID k = createKernelID(0, 3, null, null);
+ k.mN = mN.getKernelID();
+ return k;
+ }
+
+}
+
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicConvolve3x3.java b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicConvolve3x3.java
index 2871173..f3f8686 100644
--- a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicConvolve3x3.java
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicConvolve3x3.java
@@ -22,11 +22,11 @@
* Intrinsic for applying a 3x3 convolve to an allocation.
*
**/
-public final class ScriptIntrinsicConvolve3x3 extends ScriptIntrinsic {
+public class ScriptIntrinsicConvolve3x3 extends ScriptIntrinsic {
private final float[] mValues = new float[9];
private Allocation mInput;
- private ScriptIntrinsicConvolve3x3(int id, RenderScript rs) {
+ ScriptIntrinsicConvolve3x3(int id, RenderScript rs) {
super(id, rs);
}
@@ -47,8 +47,13 @@
* @return ScriptIntrinsicConvolve3x3
*/
public static ScriptIntrinsicConvolve3x3 create(RenderScript rs, Element e) {
+ if (rs.isNative) {
+ RenderScriptThunker rst = (RenderScriptThunker) rs;
+ return ScriptIntrinsicConvolve3x3Thunker.create(rs, e);
+ }
+
float f[] = { 0, 0, 0, 0, 1, 0, 0, 0, 0};
- if (e != Element.U8_4(rs)) {
+ if (!e.isCompatible(Element.U8_4(rs))) {
throw new RSIllegalArgumentException("Unsuported element type.");
}
int id = rs.nScriptIntrinsicCreate(1, e.getID(rs));
@@ -66,7 +71,7 @@
*/
public void setInput(Allocation ain) {
mInput = ain;
- bindAllocation(ain, 1);
+ setVar(1, ain);
}
/**
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicConvolve3x3Thunker.java b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicConvolve3x3Thunker.java
new file mode 100644
index 0000000..2645fbf
--- /dev/null
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicConvolve3x3Thunker.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v8.renderscript;
+
+import android.util.Log;
+
+class ScriptIntrinsicConvolve3x3Thunker extends ScriptIntrinsicConvolve3x3 {
+ android.renderscript.ScriptIntrinsicConvolve3x3 mN;
+
+ android.renderscript.ScriptIntrinsicConvolve3x3 getNObj() {
+ return mN;
+ }
+
+
+ ScriptIntrinsicConvolve3x3Thunker(int id, RenderScript rs) {
+ super(id, rs);
+ }
+
+ public static ScriptIntrinsicConvolve3x3Thunker create(RenderScript rs, Element e) {
+ RenderScriptThunker rst = (RenderScriptThunker) rs;
+ ElementThunker et = (ElementThunker) e;
+
+ ScriptIntrinsicConvolve3x3Thunker si = new ScriptIntrinsicConvolve3x3Thunker(0, rs);
+ si.mN = android.renderscript.ScriptIntrinsicConvolve3x3.create(rst.mN, et.getNObj());
+ return si;
+ }
+
+ public void setInput(Allocation ain) {
+ AllocationThunker aint = (AllocationThunker)ain;
+ mN.setInput(aint.getNObj());
+ }
+
+ public void setCoefficients(float v[]) {
+ mN.setCoefficients(v);
+ }
+
+ public void forEach(Allocation aout) {
+ AllocationThunker aoutt = (AllocationThunker)aout;
+ mN.forEach(aoutt.getNObj());
+
+ }
+
+ public Script.KernelID getKernelID() {
+ Script.KernelID k = createKernelID(0, 2, null, null);
+ k.mN = mN.getKernelID();
+ return k;
+ }
+
+ public Script.FieldID getFieldID_Input() {
+ Script.FieldID f = createFieldID(1, null);
+ f.mN = mN.getFieldID_Input();
+ return f;
+ }
+
+}
+
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicConvolve5x5.java b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicConvolve5x5.java
index 8d75b51..bb64090 100644
--- a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicConvolve5x5.java
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicConvolve5x5.java
@@ -22,11 +22,11 @@
* Intrinsic for applying a 5x5 convolve to an allocation.
*
**/
-public final class ScriptIntrinsicConvolve5x5 extends ScriptIntrinsic {
+public class ScriptIntrinsicConvolve5x5 extends ScriptIntrinsic {
private final float[] mValues = new float[25];
private Allocation mInput;
- private ScriptIntrinsicConvolve5x5(int id, RenderScript rs) {
+ ScriptIntrinsicConvolve5x5(int id, RenderScript rs) {
super(id, rs);
}
@@ -48,6 +48,10 @@
* @return ScriptIntrinsicConvolve5x5
*/
public static ScriptIntrinsicConvolve5x5 create(RenderScript rs, Element e) {
+ if (rs.isNative) {
+ RenderScriptThunker rst = (RenderScriptThunker) rs;
+ return ScriptIntrinsicConvolve5x5Thunker.create(rs, e);
+ }
int id = rs.nScriptIntrinsicCreate(4, e.getID(rs));
return new ScriptIntrinsicConvolve5x5(id, rs);
@@ -61,7 +65,7 @@
*/
public void setInput(Allocation ain) {
mInput = ain;
- bindAllocation(ain, 1);
+ setVar(1, ain);
}
/**
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicConvolve5x5Thunker.java b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicConvolve5x5Thunker.java
new file mode 100644
index 0000000..4430f9e
--- /dev/null
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicConvolve5x5Thunker.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v8.renderscript;
+
+import android.util.Log;
+
+class ScriptIntrinsicConvolve5x5Thunker extends ScriptIntrinsicConvolve5x5 {
+ android.renderscript.ScriptIntrinsicConvolve5x5 mN;
+
+ android.renderscript.ScriptIntrinsicConvolve5x5 getNObj() {
+ return mN;
+ }
+
+
+ ScriptIntrinsicConvolve5x5Thunker(int id, RenderScript rs) {
+ super(id, rs);
+ }
+
+ public static ScriptIntrinsicConvolve5x5Thunker create(RenderScript rs, Element e) {
+ RenderScriptThunker rst = (RenderScriptThunker) rs;
+ ElementThunker et = (ElementThunker) e;
+
+ ScriptIntrinsicConvolve5x5Thunker si = new ScriptIntrinsicConvolve5x5Thunker(0, rs);
+ si.mN = android.renderscript.ScriptIntrinsicConvolve5x5.create(rst.mN, et.getNObj());
+ return si;
+ }
+
+ public void setInput(Allocation ain) {
+ AllocationThunker aint = (AllocationThunker)ain;
+ mN.setInput(aint.getNObj());
+ }
+
+ public void setCoefficients(float v[]) {
+ mN.setCoefficients(v);
+ }
+
+ public void forEach(Allocation aout) {
+ AllocationThunker aoutt = (AllocationThunker)aout;
+ mN.forEach(aoutt.getNObj());
+
+ }
+
+ public Script.KernelID getKernelID() {
+ Script.KernelID k = createKernelID(0, 2, null, null);
+ k.mN = mN.getKernelID();
+ return k;
+ }
+
+ public Script.FieldID getFieldID_Input() {
+ Script.FieldID f = createFieldID(1, null);
+ f.mN = mN.getFieldID_Input();
+ return f;
+ }
+
+}
+
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicLUT.java b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicLUT.java
index 676021d..0445a65 100644
--- a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicLUT.java
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicLUT.java
@@ -24,22 +24,14 @@
* tables are 256 entries in size and can cover the full value
* range of {@link Element#U8_4}.
**/
-public final class ScriptIntrinsicLUT extends ScriptIntrinsic {
+public class ScriptIntrinsicLUT extends ScriptIntrinsic {
private final Matrix4f mMatrix = new Matrix4f();
private Allocation mTables;
private final byte mCache[] = new byte[1024];
private boolean mDirty = true;
- private ScriptIntrinsicLUT(int id, RenderScript rs) {
+ protected ScriptIntrinsicLUT(int id, RenderScript rs) {
super(id, rs);
- mTables = Allocation.createSized(rs, Element.U8(rs), 1024);
- for (int ct=0; ct < 256; ct++) {
- mCache[ct] = (byte)ct;
- mCache[ct + 256] = (byte)ct;
- mCache[ct + 512] = (byte)ct;
- mCache[ct + 768] = (byte)ct;
- }
- bindAllocation(mTables, 0);
}
/**
@@ -53,9 +45,23 @@
* @return ScriptIntrinsicLUT
*/
public static ScriptIntrinsicLUT create(RenderScript rs, Element e) {
- int id = rs.nScriptIntrinsicCreate(3, e.getID(rs));
- return new ScriptIntrinsicLUT(id, rs);
+ if (rs.isNative) {
+ RenderScriptThunker rst = (RenderScriptThunker) rs;
+ return ScriptIntrinsicLUTThunker.create(rs, e);
+ }
+ int id = rs.nScriptIntrinsicCreate(3, e.getID(rs));
+
+ ScriptIntrinsicLUT si = new ScriptIntrinsicLUT(id, rs);
+ si.mTables = Allocation.createSized(rs, Element.U8(rs), 1024);
+ for (int ct=0; ct < 256; ct++) {
+ si.mCache[ct] = (byte)ct;
+ si.mCache[ct + 256] = (byte)ct;
+ si.mCache[ct + 512] = (byte)ct;
+ si.mCache[ct + 768] = (byte)ct;
+ }
+ si.setVar(0, si.mTables);
+ return si;
}
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicLUTThunker.java b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicLUTThunker.java
new file mode 100644
index 0000000..547b679
--- /dev/null
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicLUTThunker.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v8.renderscript;
+
+import android.util.Log;
+
+class ScriptIntrinsicLUTThunker extends ScriptIntrinsicLUT {
+ android.renderscript.ScriptIntrinsicLUT mN;
+
+ android.renderscript.ScriptIntrinsicLUT getNObj() {
+ return mN;
+ }
+
+ private ScriptIntrinsicLUTThunker(int id, RenderScript rs) {
+ super(id, rs);
+ }
+
+ public static ScriptIntrinsicLUTThunker create(RenderScript rs, Element e) {
+ RenderScriptThunker rst = (RenderScriptThunker) rs;
+ ElementThunker et = (ElementThunker) e;
+
+ ScriptIntrinsicLUTThunker si = new ScriptIntrinsicLUTThunker(0, rs);
+ si.mN = android.renderscript.ScriptIntrinsicLUT.create(rst.mN, et.getNObj());
+ return si;
+ }
+
+ public void setRed(int index, int value) {
+ mN.setRed(index, value);
+ }
+
+ public void setGreen(int index, int value) {
+ mN.setGreen(index, value);
+ }
+
+ public void setBlue(int index, int value) {
+ mN.setBlue(index, value);
+ }
+
+ public void setAlpha(int index, int value) {
+ mN.setAlpha(index, value);
+ }
+
+ public void forEach(Allocation ain, Allocation aout) {
+ AllocationThunker aint = (AllocationThunker)ain;
+ AllocationThunker aoutt = (AllocationThunker)aout;
+ mN.forEach(aint.getNObj(), aoutt.getNObj());
+ }
+
+ public Script.KernelID getKernelID() {
+ Script.KernelID k = createKernelID(0, 3, null, null);
+ k.mN = mN.getKernelID();
+ return k;
+ }
+}
+
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicYuvToRGB.java b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicYuvToRGB.java
index 6643272..7bd19c8 100644
--- a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicYuvToRGB.java
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicYuvToRGB.java
@@ -24,7 +24,7 @@
* element type. The output is RGBA, the alpha channel will be
* set to 255.
*/
-public final class ScriptIntrinsicYuvToRGB extends ScriptIntrinsic {
+public class ScriptIntrinsicYuvToRGB extends ScriptIntrinsic {
private Allocation mInput;
ScriptIntrinsicYuvToRGB(int id, RenderScript rs) {
@@ -42,6 +42,11 @@
* @return ScriptIntrinsicYuvToRGB
*/
public static ScriptIntrinsicYuvToRGB create(RenderScript rs, Element e) {
+ if (rs.isNative) {
+ RenderScriptThunker rst = (RenderScriptThunker) rs;
+ return ScriptIntrinsicYuvToRGBThunker.create(rs, e);
+ }
+
// 6 comes from RS_SCRIPT_INTRINSIC_YUV_TO_RGB in rsDefines.h
int id = rs.nScriptIntrinsicCreate(6, e.getID(rs));
ScriptIntrinsicYuvToRGB si = new ScriptIntrinsicYuvToRGB(id, rs);
@@ -56,7 +61,7 @@
*/
public void setInput(Allocation ain) {
mInput = ain;
- bindAllocation(ain, 0);
+ setVar(0, ain);
}
/**
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicYuvToRGBThunker.java b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicYuvToRGBThunker.java
new file mode 100644
index 0000000..fa7db4c
--- /dev/null
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptIntrinsicYuvToRGBThunker.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v8.renderscript;
+
+
+public class ScriptIntrinsicYuvToRGBThunker extends ScriptIntrinsicYuvToRGB {
+ android.renderscript.ScriptIntrinsicYuvToRGB mN;
+
+ android.renderscript.ScriptIntrinsicYuvToRGB getNObj() {
+ return mN;
+ }
+
+
+ private ScriptIntrinsicYuvToRGBThunker(int id, RenderScript rs) {
+ super(id, rs);
+ }
+
+ public static ScriptIntrinsicYuvToRGBThunker create(RenderScript rs, Element e) {
+ RenderScriptThunker rst = (RenderScriptThunker) rs;
+ ElementThunker et = (ElementThunker) e;
+
+ ScriptIntrinsicYuvToRGBThunker si = new ScriptIntrinsicYuvToRGBThunker(0, rs);
+ si.mN = android.renderscript.ScriptIntrinsicYuvToRGB.create(rst.mN, et.getNObj());
+ return si;
+ }
+
+
+ public void setInput(Allocation ain) {
+ AllocationThunker aint = (AllocationThunker)ain;
+ mN.setInput(aint.getNObj());
+ }
+
+ public void forEach(Allocation aout) {
+ AllocationThunker aoutt = (AllocationThunker)aout;
+ mN.setInput(aoutt.getNObj());
+ }
+
+ public Script.KernelID getKernelID() {
+ Script.KernelID k = createKernelID(0, 2, null, null);
+ k.mN = mN.getKernelID();
+ return k;
+ }
+
+ public Script.FieldID getFieldID_Input() {
+ Script.FieldID f = createFieldID(0, null);
+ f.mN = mN.getFieldID_Input();
+ return f;
+ }
+}
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/Type.java b/renderscript/v8/java/src/android/support/v8/renderscript/Type.java
index 5b9312d..ed29954 100644
--- a/renderscript/v8/java/src/android/support/v8/renderscript/Type.java
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/Type.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,8 @@
import java.lang.reflect.Field;
+
+import android.graphics.ImageFormat;
import android.util.Log;
/**
@@ -47,6 +49,7 @@
int mDimZ;
boolean mDimMipmaps;
boolean mDimFaces;
+ int mDimYuv;
int mElementCount;
Element mElement;
@@ -119,6 +122,13 @@
}
/**
+ * @hide
+ */
+ public int getYuv() {
+ return mDimYuv;
+ }
+
+ /**
* Return the total number of accessable cells in the Type.
*
* @return int
@@ -180,6 +190,7 @@
int mDimZ;
boolean mDimMipmaps;
boolean mDimFaces;
+ int mYuv;
Element mElement;
@@ -217,6 +228,14 @@
return this;
}
+ public Builder setZ(int value) {
+ if(value < 1) {
+ throw new RSIllegalArgumentException("Values of less than 1 for Dimension Z are not valid.");
+ }
+ mDimZ = value;
+ return this;
+ }
+
public Builder setMipmaps(boolean value) {
mDimMipmaps = value;
return this;
@@ -227,6 +246,25 @@
return this;
}
+ /**
+ * @hide
+ *
+ * only NV21, YV12. Enums from ImageFormat
+ */
+ public Builder setYuvFormat(int yuvFormat) {
+ switch (yuvFormat) {
+ case android.graphics.ImageFormat.NV21:
+ case android.graphics.ImageFormat.YV12:
+ break;
+
+ default:
+ throw new RSIllegalArgumentException("Only NV21 and YV12 are supported..");
+ }
+
+ mYuv = yuvFormat;
+ return this;
+ }
+
/**
* Validate structure and create a new type.
@@ -253,15 +291,29 @@
}
}
- int id = mRS.nTypeCreate(mElement.getID(mRS),
- mDimX, mDimY, mDimZ, mDimMipmaps, mDimFaces);
- Type t = new Type(id, mRS);
+ if (mYuv != 0) {
+ if ((mDimZ != 0) || mDimFaces || mDimMipmaps) {
+ throw new RSInvalidStateException("YUV only supports basic 2D.");
+ }
+ }
+
+ Type t;
+ if (mRS.isNative) {
+ RenderScriptThunker rst = (RenderScriptThunker)mRS;
+ t = TypeThunker.create(rst, mElement, mDimX, mDimY, mDimZ,
+ mDimMipmaps, mDimFaces, mYuv);
+ } else {
+ int id = mRS.nTypeCreate(mElement.getID(mRS),
+ mDimX, mDimY, mDimZ, mDimMipmaps, mDimFaces, mYuv);
+ t = new Type(id, mRS);
+ }
t.mElement = mElement;
t.mDimX = mDimX;
t.mDimY = mDimY;
t.mDimZ = mDimZ;
t.mDimMipmaps = mDimMipmaps;
t.mDimFaces = mDimFaces;
+ t.mDimYuv = mYuv;
t.calcElementCount();
return t;
diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/TypeThunker.java b/renderscript/v8/java/src/android/support/v8/renderscript/TypeThunker.java
new file mode 100644
index 0000000..279d9ba
--- /dev/null
+++ b/renderscript/v8/java/src/android/support/v8/renderscript/TypeThunker.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v8.renderscript;
+
+import android.graphics.ImageFormat;
+import android.util.Log;
+import java.util.HashMap;
+
+class TypeThunker extends Type {
+ android.renderscript.Type mN;
+
+ android.renderscript.Type getNObj() {
+ return mN;
+ }
+
+ static HashMap<android.renderscript.Type, Type> mMap = new HashMap();
+
+ void internalCalc() {
+ mDimX = mN.getX();
+ mDimY = mN.getY();
+ mDimZ = mN.getZ();
+ mDimFaces = mN.hasFaces();
+ mDimMipmaps = mN.hasMipmaps();
+ mDimYuv = mN.getYuv();
+ calcElementCount();
+ }
+
+ TypeThunker(RenderScript rs, android.renderscript.Type t) {
+ super(0, rs);
+ mN = t;
+ internalCalc();
+ mElement = new ElementThunker(rs, t.getElement());
+
+ synchronized(mMap) {
+ mMap.put(mN, this);
+ }
+ }
+
+ static Type find(android.renderscript.Type nt) {
+ return mMap.get(nt);
+ }
+
+ static Type create(RenderScript rs, Element e,
+ int dx, int dy, int dz, boolean dmip, boolean dfaces, int yuv) {
+ ElementThunker et = (ElementThunker)e;
+ RenderScriptThunker rst = (RenderScriptThunker)rs;
+ android.renderscript.Type.Builder tb =
+ new android.renderscript.Type.Builder(rst.mN, et.mN);
+ if (dx > 0) tb.setX(dx);
+ if (dy > 0) tb.setY(dy);
+ if (dz > 0) tb.setZ(dz);
+ if (dmip) tb.setMipmaps(dmip);
+ if (dfaces) tb.setFaces(dfaces);
+ if (yuv > 0) tb.setYuvFormat(yuv);
+ android.renderscript.Type nt = tb.create();
+ TypeThunker tt = new TypeThunker(rs, nt);
+ tt.internalCalc();
+
+ return tt;
+ }
+}
diff --git a/renderscript/v8/jni/Android.mk b/renderscript/v8/jni/Android.mk
index 8802837..a45969f 100644
--- a/renderscript/v8/jni/Android.mk
+++ b/renderscript/v8/jni/Android.mk
@@ -8,7 +8,9 @@
libandroid_runtime \
libRSSupport \
libcutils \
- libjnigraphics
+ liblog \
+ libjnigraphics \
+ libskia
LOCAL_STATIC_LIBRARIES :=
diff --git a/renderscript/v8/jni/android_renderscript_RenderScript.cpp b/renderscript/v8/jni/android_renderscript_RenderScript.cpp
index 5606381..d771875 100644
--- a/renderscript/v8/jni/android_renderscript_RenderScript.cpp
+++ b/renderscript/v8/jni/android_renderscript_RenderScript.cpp
@@ -29,6 +29,12 @@
#include <rs.h>
#include <rsEnv.h>
+#include <core/SkBitmap.h>
+#include <core/SkPixelRef.h>
+#include <core/SkStream.h>
+#include <core/SkTemplates.h>
+//#include <images/SkImageDecoder.h>
+
//#define LOG_API ALOG
#define LOG_API(...)
@@ -143,10 +149,10 @@
}
static jint
-nContextCreate(JNIEnv *_env, jobject _this, jint dev, jint ver, jint sdkVer)
+nContextCreate(JNIEnv *_env, jobject _this, jint dev, jint ver, jint sdkVer, jint ct)
{
LOG_API("nContextCreate");
- return (jint)rsContextCreate((RsDevice)dev, ver, sdkVer);
+ return (jint)rsContextCreate((RsDevice)dev, ver, sdkVer, (RsContextType)ct, false, false);
}
@@ -238,6 +244,23 @@
rsContextDeinitToClient(con);
}
+static void
+nContextSendMessage(JNIEnv *_env, jobject _this, RsContext con, jint id, jintArray data)
+{
+ jint *ptr = NULL;
+ jint len = 0;
+ if (data) {
+ len = _env->GetArrayLength(data);
+ jint *ptr = _env->GetIntArrayElements(data, NULL);
+ }
+ LOG_API("nContextSendMessage, con(%p), id(%i), len(%i)", con, id, len);
+ rsContextSendMessage(con, id, (const uint8_t *)ptr, len * sizeof(int));
+ if (data) {
+ _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT);
+ }
+}
+
+
static jint
nElementCreate(JNIEnv *_env, jobject _this, RsContext con, jint type, jint kind, jboolean norm, jint size)
@@ -303,12 +326,12 @@
static int
nTypeCreate(JNIEnv *_env, jobject _this, RsContext con, RsElement eid,
- jint dimx, jint dimy, jint dimz, jboolean mips, jboolean faces)
+ jint dimx, jint dimy, jint dimz, jboolean mips, jboolean faces, jint yuv)
{
- LOG_API("nTypeCreate, con(%p) eid(%p), x(%i), y(%i), z(%i), mips(%i), faces(%i)",
- con, eid, dimx, dimy, dimz, mips, faces);
+ LOG_API("nTypeCreate, con(%p) eid(%p), x(%i), y(%i), z(%i), mips(%i), faces(%i), yuv(%i)",
+ con, eid, dimx, dimy, dimz, mips, faces, yuv);
- jint id = (jint)rsTypeCreate(con, (RsElement)eid, dimx, dimy, dimz, mips, faces);
+ jint id = (jint)rsTypeCreate(con, (RsElement)eid, dimx, dimy, dimz, mips, faces, yuv);
return (jint)id;
}
@@ -351,16 +374,32 @@
static int
nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage)
{
- void *pixels = NULL;
- AndroidBitmap_lockPixels(_env, jbitmap, &pixels);
+ SkBitmap const * nativeBitmap =
+ (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID);
+ const SkBitmap& bitmap(*nativeBitmap);
- jint id = 0;
- if (pixels != NULL) {
- id = (jint)rsAllocationCreateFromBitmap(con, (RsType)type,
- (RsAllocationMipmapControl)mip, pixels,
- GetBitmapSize(_env, jbitmap), usage);
- AndroidBitmap_unlockPixels(_env, jbitmap);
- }
+ bitmap.lockPixels();
+ const void* ptr = bitmap.getPixels();
+ jint id = (jint)rsAllocationCreateFromBitmap(con,
+ (RsType)type, (RsAllocationMipmapControl)mip,
+ ptr, bitmap.getSize(), usage);
+ bitmap.unlockPixels();
+ return id;
+}
+
+static int
+nAllocationCreateBitmapBackedAllocation(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage)
+{
+ SkBitmap const * nativeBitmap =
+ (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID);
+ const SkBitmap& bitmap(*nativeBitmap);
+
+ bitmap.lockPixels();
+ const void* ptr = bitmap.getPixels();
+ jint id = (jint)rsAllocationCreateTyped(con,
+ (RsType)type, (RsAllocationMipmapControl)mip,
+ (uint32_t)usage, (size_t)ptr);
+ bitmap.unlockPixels();
return id;
}
@@ -393,7 +432,7 @@
if (pixels != NULL) {
rsAllocation2DData(con, (RsAllocation)alloc, 0, 0,
0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X,
- info.width, info.height, pixels, GetBitmapSize(_env, jbitmap));
+ info.width, info.height, pixels, GetBitmapSize(_env, jbitmap), 0);
AndroidBitmap_unlockPixels(_env, jbitmap);
}
}
@@ -474,7 +513,7 @@
jint len = _env->GetArrayLength(data);
LOG_API("nAllocation2DData_s, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len);
jshort *ptr = _env->GetShortArrayElements(data, NULL);
- rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes);
+ rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0);
_env->ReleaseShortArrayElements(data, ptr, JNI_ABORT);
}
@@ -485,7 +524,7 @@
jint len = _env->GetArrayLength(data);
LOG_API("nAllocation2DData_b, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len);
jbyte *ptr = _env->GetByteArrayElements(data, NULL);
- rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes);
+ rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0);
_env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
}
@@ -496,7 +535,7 @@
jint len = _env->GetArrayLength(data);
LOG_API("nAllocation2DData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len);
jint *ptr = _env->GetIntArrayElements(data, NULL);
- rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes);
+ rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0);
_env->ReleaseIntArrayElements(data, ptr, JNI_ABORT);
}
@@ -507,7 +546,7 @@
jint len = _env->GetArrayLength(data);
LOG_API("nAllocation2DData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len);
jfloat *ptr = _env->GetFloatArrayElements(data, NULL);
- rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes);
+ rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0);
_env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT);
}
@@ -536,6 +575,72 @@
}
static void
+nAllocationData3D_s(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint zoff, jint lod,
+ jint w, jint h, jint d, jshortArray data, int sizeBytes)
+{
+ jint len = _env->GetArrayLength(data);
+ LOG_API("nAllocation3DData_s, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, zoff, w, h, d, len);
+ jshort *ptr = _env->GetShortArrayElements(data, NULL);
+ rsAllocation3DData(con, (RsAllocation)alloc, xoff, yoff, zoff, lod, w, h, d, ptr, sizeBytes, 0);
+ _env->ReleaseShortArrayElements(data, ptr, JNI_ABORT);
+}
+
+static void
+nAllocationData3D_b(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint zoff, jint lod,
+ jint w, jint h, jint d, jbyteArray data, int sizeBytes)
+{
+ jint len = _env->GetArrayLength(data);
+ LOG_API("nAllocation3DData_b, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, zoff, w, h, d, len);
+ jbyte *ptr = _env->GetByteArrayElements(data, NULL);
+ rsAllocation3DData(con, (RsAllocation)alloc, xoff, yoff, zoff, lod, w, h, d, ptr, sizeBytes, 0);
+ _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
+}
+
+static void
+nAllocationData3D_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint zoff, jint lod,
+ jint w, jint h, jint d, jintArray data, int sizeBytes)
+{
+ jint len = _env->GetArrayLength(data);
+ LOG_API("nAllocation3DData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, zoff, w, h, d, len);
+ jint *ptr = _env->GetIntArrayElements(data, NULL);
+ rsAllocation3DData(con, (RsAllocation)alloc, xoff, yoff, zoff, lod, w, h, d, ptr, sizeBytes, 0);
+ _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT);
+}
+
+static void
+nAllocationData3D_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint zoff, jint lod,
+ jint w, jint h, jint d, jfloatArray data, int sizeBytes)
+{
+ jint len = _env->GetArrayLength(data);
+ LOG_API("nAllocation3DData_f, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, zoff, w, h, d, len);
+ jfloat *ptr = _env->GetFloatArrayElements(data, NULL);
+ rsAllocation3DData(con, (RsAllocation)alloc, xoff, yoff, zoff, lod, w, h, d, ptr, sizeBytes, 0);
+ _env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT);
+}
+
+static void
+nAllocationData3D_alloc(JNIEnv *_env, jobject _this, RsContext con,
+ jint dstAlloc, jint dstXoff, jint dstYoff, jint dstZoff,
+ jint dstMip,
+ jint width, jint height, jint depth,
+ jint srcAlloc, jint srcXoff, jint srcYoff, jint srcZoff,
+ jint srcMip)
+{
+ LOG_API("nAllocationData3D_alloc, con(%p), dstAlloc(%p), dstXoff(%i), dstYoff(%i),"
+ " dstMip(%i), width(%i), height(%i),"
+ " srcAlloc(%p), srcXoff(%i), srcYoff(%i), srcMip(%i)",
+ con, (RsAllocation)dstAlloc, dstXoff, dstYoff, dstMip, dstFace,
+ width, height, (RsAllocation)srcAlloc, srcXoff, srcYoff, srcMip, srcFace);
+
+ rsAllocationCopy3DRange(con,
+ (RsAllocation)dstAlloc,
+ dstXoff, dstYoff, dstZoff, dstMip,
+ width, height, depth,
+ (RsAllocation)srcAlloc,
+ srcXoff, srcYoff, srcZoff, srcMip);
+}
+
+static void
nAllocationRead_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jintArray data)
{
jint len = _env->GetArrayLength(data);
@@ -593,13 +698,6 @@
rsAllocationResize1D(con, (RsAllocation)alloc, dimX);
}
-static void
-nAllocationResize2D(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint dimX, jint dimY)
-{
- LOG_API("nAllocationResize1D, con(%p), alloc(%p), sizeX(%i), sizeY(%i)", con, (RsAllocation)alloc, dimX, dimY);
- rsAllocationResize2D(con, (RsAllocation)alloc, dimX, dimY);
-}
-
// -----------------------------------
static void
@@ -707,7 +805,7 @@
jint script, jint slot, jint ain, jint aout)
{
LOG_API("nScriptForEach, con(%p), s(%p), slot(%i)", con, (void *)script, slot);
- rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, NULL, 0);
+ rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, NULL, 0, NULL, 0);
}
static void
nScriptForEachV(JNIEnv *_env, jobject _this, RsContext con,
@@ -716,10 +814,52 @@
LOG_API("nScriptForEach, con(%p), s(%p), slot(%i)", con, (void *)script, slot);
jint len = _env->GetArrayLength(params);
jbyte *ptr = _env->GetByteArrayElements(params, NULL);
- rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, ptr, len);
+ rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, ptr, len, NULL, 0);
_env->ReleaseByteArrayElements(params, ptr, JNI_ABORT);
}
+static void
+nScriptForEachClipped(JNIEnv *_env, jobject _this, RsContext con,
+ jint script, jint slot, jint ain, jint aout,
+ jint xstart, jint xend,
+ jint ystart, jint yend, jint zstart, jint zend)
+{
+ LOG_API("nScriptForEachClipped, con(%p), s(%p), slot(%i)", con, (void *)script, slot);
+ RsScriptCall sc;
+ sc.xStart = xstart;
+ sc.xEnd = xend;
+ sc.yStart = ystart;
+ sc.yEnd = yend;
+ sc.zStart = zstart;
+ sc.zEnd = zend;
+ sc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE;
+ sc.arrayStart = 0;
+ sc.arrayEnd = 0;
+ rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, NULL, 0, &sc, sizeof(sc));
+}
+
+static void
+nScriptForEachClippedV(JNIEnv *_env, jobject _this, RsContext con,
+ jint script, jint slot, jint ain, jint aout,
+ jbyteArray params, jint xstart, jint xend,
+ jint ystart, jint yend, jint zstart, jint zend)
+{
+ LOG_API("nScriptForEachClipped, con(%p), s(%p), slot(%i)", con, (void *)script, slot);
+ jint len = _env->GetArrayLength(params);
+ jbyte *ptr = _env->GetByteArrayElements(params, NULL);
+ RsScriptCall sc;
+ sc.xStart = xstart;
+ sc.xEnd = xend;
+ sc.yStart = ystart;
+ sc.yEnd = yend;
+ sc.zStart = zstart;
+ sc.zEnd = zend;
+ sc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE;
+ sc.arrayStart = 0;
+ sc.arrayEnd = 0;
+ rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, ptr, len, &sc, sizeof(sc));
+ _env->ReleaseByteArrayElements(params, ptr, JNI_ABORT);
+}
// -----------------------------------
@@ -772,6 +912,82 @@
return ret;
}
+static jint
+nScriptIntrinsicCreate(JNIEnv *_env, jobject _this, RsContext con, jint id, jint eid)
+{
+ LOG_API("nScriptIntrinsicCreate, con(%p) id(%i) element(%p)", con, id, (void *)eid);
+ return (jint)rsScriptIntrinsicCreate(con, id, (RsElement)eid);
+}
+
+static jint
+nScriptKernelIDCreate(JNIEnv *_env, jobject _this, RsContext con, jint sid, jint slot, jint sig)
+{
+ LOG_API("nScriptKernelIDCreate, con(%p) script(%p), slot(%i), sig(%i)", con, (void *)sid, slot, sig);
+ return (jint)rsScriptKernelIDCreate(con, (RsScript)sid, slot, sig);
+}
+
+static jint
+nScriptFieldIDCreate(JNIEnv *_env, jobject _this, RsContext con, jint sid, jint slot)
+{
+ LOG_API("nScriptFieldIDCreate, con(%p) script(%p), slot(%i)", con, (void *)sid, slot);
+ return (jint)rsScriptFieldIDCreate(con, (RsScript)sid, slot);
+}
+
+static jint
+nScriptGroupCreate(JNIEnv *_env, jobject _this, RsContext con, jintArray _kernels, jintArray _src,
+ jintArray _dstk, jintArray _dstf, jintArray _types)
+{
+ LOG_API("nScriptGroupCreate, con(%p)", con);
+
+ jint kernelsLen = _env->GetArrayLength(_kernels) * sizeof(int);
+ jint *kernelsPtr = _env->GetIntArrayElements(_kernels, NULL);
+ jint srcLen = _env->GetArrayLength(_src) * sizeof(int);
+ jint *srcPtr = _env->GetIntArrayElements(_src, NULL);
+ jint dstkLen = _env->GetArrayLength(_dstk) * sizeof(int);
+ jint *dstkPtr = _env->GetIntArrayElements(_dstk, NULL);
+ jint dstfLen = _env->GetArrayLength(_dstf) * sizeof(int);
+ jint *dstfPtr = _env->GetIntArrayElements(_dstf, NULL);
+ jint typesLen = _env->GetArrayLength(_types) * sizeof(int);
+ jint *typesPtr = _env->GetIntArrayElements(_types, NULL);
+
+ int id = (int)rsScriptGroupCreate(con,
+ (RsScriptKernelID *)kernelsPtr, kernelsLen,
+ (RsScriptKernelID *)srcPtr, srcLen,
+ (RsScriptKernelID *)dstkPtr, dstkLen,
+ (RsScriptFieldID *)dstfPtr, dstfLen,
+ (RsType *)typesPtr, typesLen);
+
+ _env->ReleaseIntArrayElements(_kernels, kernelsPtr, 0);
+ _env->ReleaseIntArrayElements(_src, srcPtr, 0);
+ _env->ReleaseIntArrayElements(_dstk, dstkPtr, 0);
+ _env->ReleaseIntArrayElements(_dstf, dstfPtr, 0);
+ _env->ReleaseIntArrayElements(_types, typesPtr, 0);
+ return id;
+}
+
+static void
+nScriptGroupSetInput(JNIEnv *_env, jobject _this, RsContext con, jint gid, jint kid, jint alloc)
+{
+ LOG_API("nScriptGroupSetInput, con(%p) group(%p), kernelId(%p), alloc(%p)", con,
+ (void *)gid, (void *)kid, (void *)alloc);
+ rsScriptGroupSetInput(con, (RsScriptGroup)gid, (RsScriptKernelID)kid, (RsAllocation)alloc);
+}
+
+static void
+nScriptGroupSetOutput(JNIEnv *_env, jobject _this, RsContext con, jint gid, jint kid, jint alloc)
+{
+ LOG_API("nScriptGroupSetOutput, con(%p) group(%p), kernelId(%p), alloc(%p)", con,
+ (void *)gid, (void *)kid, (void *)alloc);
+ rsScriptGroupSetOutput(con, (RsScriptGroup)gid, (RsScriptKernelID)kid, (RsAllocation)alloc);
+}
+
+static void
+nScriptGroupExecute(JNIEnv *_env, jobject _this, RsContext con, jint gid)
+{
+ LOG_API("nScriptGroupSetOutput, con(%p) group(%p)", con, (void *)gid);
+ rsScriptGroupExecute(con, (RsScriptGroup)gid);
+}
+
// ---------------------------------------------------------------------------
static jint
@@ -808,21 +1024,23 @@
// All methods below are thread protected in java.
-{"rsnContextCreate", "(III)I", (void*)nContextCreate },
+{"rsnContextCreate", "(IIII)I", (void*)nContextCreate },
{"rsnContextFinish", "(I)V", (void*)nContextFinish },
{"rsnContextSetPriority", "(II)V", (void*)nContextSetPriority },
{"rsnContextDestroy", "(I)V", (void*)nContextDestroy },
{"rsnContextDump", "(II)V", (void*)nContextDump },
+{"rsnContextSendMessage", "(II[I)V", (void*)nContextSendMessage },
{"rsnObjDestroy", "(II)V", (void*)nObjDestroy },
{"rsnElementCreate", "(IIIZI)I", (void*)nElementCreate },
{"rsnElementCreate2", "(I[I[Ljava/lang/String;[I)I", (void*)nElementCreate2 },
{"rsnElementGetSubElements", "(II[I[Ljava/lang/String;[I)V", (void*)nElementGetSubElements },
-{"rsnTypeCreate", "(IIIIIZZ)I", (void*)nTypeCreate },
+{"rsnTypeCreate", "(IIIIIZZI)I", (void*)nTypeCreate },
{"rsnAllocationCreateTyped", "(IIIII)I", (void*)nAllocationCreateTyped },
{"rsnAllocationCreateFromBitmap", "(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCreateFromBitmap },
+{"rsnAllocationCreateBitmapBackedAllocation", "(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCreateBitmapBackedAllocation },
{"rsnAllocationCubeCreateFromBitmap","(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCubeCreateFromBitmap },
{"rsnAllocationCopyFromBitmap", "(IILandroid/graphics/Bitmap;)V", (void*)nAllocationCopyFromBitmap },
@@ -839,13 +1057,17 @@
{"rsnAllocationData2D", "(IIIIIIII[BI)V", (void*)nAllocationData2D_b },
{"rsnAllocationData2D", "(IIIIIIII[FI)V", (void*)nAllocationData2D_f },
{"rsnAllocationData2D", "(IIIIIIIIIIIII)V", (void*)nAllocationData2D_alloc },
+{"rsnAllocationData3D", "(IIIIIIIII[II)V", (void*)nAllocationData3D_i },
+{"rsnAllocationData3D", "(IIIIIIIII[SI)V", (void*)nAllocationData3D_s },
+{"rsnAllocationData3D", "(IIIIIIIII[BI)V", (void*)nAllocationData3D_b },
+{"rsnAllocationData3D", "(IIIIIIIII[FI)V", (void*)nAllocationData3D_f },
+{"rsnAllocationData3D", "(IIIIIIIIIIIIII)V", (void*)nAllocationData3D_alloc },
{"rsnAllocationRead", "(II[I)V", (void*)nAllocationRead_i },
{"rsnAllocationRead", "(II[S)V", (void*)nAllocationRead_s },
{"rsnAllocationRead", "(II[B)V", (void*)nAllocationRead_b },
{"rsnAllocationRead", "(II[F)V", (void*)nAllocationRead_f },
{"rsnAllocationGetType", "(II)I", (void*)nAllocationGetType},
{"rsnAllocationResize1D", "(III)V", (void*)nAllocationResize1D },
-{"rsnAllocationResize2D", "(IIII)V", (void*)nAllocationResize2D },
{"rsnAllocationGenerateMipmaps", "(II)V", (void*)nAllocationGenerateMipmaps },
{"rsnScriptBindAllocation", "(IIII)V", (void*)nScriptBindAllocation },
@@ -854,6 +1076,8 @@
{"rsnScriptInvokeV", "(III[B)V", (void*)nScriptInvokeV },
{"rsnScriptForEach", "(IIIII)V", (void*)nScriptForEach },
{"rsnScriptForEach", "(IIIII[B)V", (void*)nScriptForEachV },
+{"rsnScriptForEachClipped", "(IIIIIIIIIII)V", (void*)nScriptForEachClipped },
+{"rsnScriptForEachClipped", "(IIIII[BIIIIII)V", (void*)nScriptForEachClippedV },
{"rsnScriptSetVarI", "(IIII)V", (void*)nScriptSetVarI },
{"rsnScriptSetVarJ", "(IIIJ)V", (void*)nScriptSetVarJ },
{"rsnScriptSetVarF", "(IIIF)V", (void*)nScriptSetVarF },
@@ -863,6 +1087,13 @@
{"rsnScriptSetVarObj", "(IIII)V", (void*)nScriptSetVarObj },
{"rsnScriptCCreate", "(ILjava/lang/String;Ljava/lang/String;[BI)I", (void*)nScriptCCreate },
+{"rsnScriptIntrinsicCreate", "(III)I", (void*)nScriptIntrinsicCreate },
+{"rsnScriptKernelIDCreate", "(IIII)I", (void*)nScriptKernelIDCreate },
+{"rsnScriptFieldIDCreate", "(III)I", (void*)nScriptFieldIDCreate },
+{"rsnScriptGroupCreate", "(I[I[I[I[I[I)I", (void*)nScriptGroupCreate },
+{"rsnScriptGroupSetInput", "(IIII)V", (void*)nScriptGroupSetInput },
+{"rsnScriptGroupSetOutput", "(IIII)V", (void*)nScriptGroupSetOutput },
+{"rsnScriptGroupExecute", "(II)V", (void*)nScriptGroupExecute },
{"rsnSamplerCreate", "(IIIIIIF)I", (void*)nSamplerCreate },
diff --git a/renderscript/v8/rs_support/Android.mk b/renderscript/v8/rs_support/Android.mk
index a2a3674..967392c 100644
--- a/renderscript/v8/rs_support/Android.mk
+++ b/renderscript/v8/rs_support/Android.mk
@@ -1,7 +1,12 @@
-LOCAL_PATH:=$(call my-dir)
+LOCAL_PATH:=frameworks/rs
rs_base_CFLAGS := -Werror -Wall -Wno-unused-parameter -Wno-unused-variable \
- -Wno-overloaded-virtual
+ -Wno-overloaded-virtual -DRS_COMPATIBILITY_LIB
+
+ifeq ($(ARCH_ARM_HAVE_NEON),true)
+rs_base_CFLAGS += -DARCH_ARM_HAVE_NEON
+endif
+
ifeq ($(TARGET_BUILD_PDK), true)
rs_base_CFLAGS += -D__RS_PDK__
endif
@@ -97,22 +102,31 @@
driver/rsdAllocation.cpp \
driver/rsdBcc.cpp \
driver/rsdCore.cpp \
- driver/rsdRuntimeMath.cpp \
driver/rsdRuntimeStubs.cpp \
driver/rsdSampler.cpp \
- driver/rsdIntrinsics.cpp \
- driver/rsdIntrinsicBlend.cpp \
- driver/rsdIntrinsicBlur.cpp \
- driver/rsdIntrinsicConvolve3x3.cpp \
- driver/rsdIntrinsicConvolve5x5.cpp \
- driver/rsdIntrinsicLUT.cpp \
- driver/rsdIntrinsicColorMatrix.cpp \
- driver/rsdIntrinsicYuvToRGB.cpp \
- driver/rsdScriptGroup.cpp
+ driver/rsdScriptGroup.cpp \
+ cpu_ref/rsCpuCore.cpp \
+ cpu_ref/rsCpuScript.cpp \
+ cpu_ref/rsCpuRuntimeMath.cpp \
+ cpu_ref/rsCpuRuntimeStubs.cpp \
+ cpu_ref/rsCpuScriptGroup.cpp \
+ cpu_ref/rsCpuIntrinsic.cpp \
+ cpu_ref/rsCpuIntrinsic3DLUT.cpp \
+ cpu_ref/rsCpuIntrinsicBlend.cpp \
+ cpu_ref/rsCpuIntrinsicBlur.cpp \
+ cpu_ref/rsCpuIntrinsicColorMatrix.cpp \
+ cpu_ref/rsCpuIntrinsicConvolve3x3.cpp \
+ cpu_ref/rsCpuIntrinsicConvolve5x5.cpp \
+ cpu_ref/rsCpuIntrinsicLUT.cpp \
+ cpu_ref/rsCpuIntrinsicYuvToRGB.cpp \
+ cpu_ref/rsCpuRuntimeMathFuncs.cpp
+ifeq ($(ARCH_ARM_HAVE_NEON),true)
+LOCAL_SRC_FILES += \
+ cpu_ref/rsCpuIntrinsics_neon.S
+endif
-
-LOCAL_SHARED_LIBRARIES += libcutils libutils libdl
+LOCAL_SHARED_LIBRARIES += libcutils libutils liblog libdl
LOCAL_C_INCLUDES += system/core/include
LOCAL_C_INCLUDES += frameworks/native/include
diff --git a/renderscript/v8/rs_support/driver/rsdAllocation.cpp b/renderscript/v8/rs_support/driver/rsdAllocation.cpp
deleted file mode 100644
index 7c7755e..0000000
--- a/renderscript/v8/rs_support/driver/rsdAllocation.cpp
+++ /dev/null
@@ -1,542 +0,0 @@
-/*
- * Copyright (C) 2011-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include "rsdCore.h"
-#include "rsdBcc.h"
-#include "rsdRuntime.h"
-#include "rsdAllocation.h"
-//#include "rsdFrameBufferObj.h"
-
-#include "rsAllocation.h"
-
-#include "system/window.h"
-/*#include "hardware/gralloc.h"
-#include "ui/Rect.h"
-#include "ui/GraphicBufferMapper.h"
-#include "gui/SurfaceTexture.h"*/
-
-//#include <GLES/gl.h>
-//#include <GLES2/gl2.h>
-//#include <GLES/glext.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-
-uint8_t *GetOffsetPtr(const android::renderscript::Allocation *alloc,
- uint32_t xoff, uint32_t yoff, uint32_t lod,
- RsAllocationCubemapFace face) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
- uint8_t *ptr = (uint8_t *)drv->lod[lod].mallocPtr;
- ptr += face * drv->faceOffset;
- ptr += yoff * drv->lod[lod].stride;
- ptr += xoff * alloc->mHal.state.elementSizeBytes;
- return ptr;
-}
-
-
-static void Update2DTexture(const Context *rsc, const Allocation *alloc, const void *ptr,
- uint32_t xoff, uint32_t yoff, uint32_t lod,
- RsAllocationCubemapFace face, uint32_t w, uint32_t h) {
-}
-
-
-static void UploadToTexture(const Context *rsc, const Allocation *alloc) {
-}
-
-static void AllocateRenderTarget(const Context *rsc, const Allocation *alloc) {
-}
-
-static void UploadToBufferObject(const Context *rsc, const Allocation *alloc) {
-}
-
-static size_t AllocationBuildPointerTable(const Context *rsc, const Allocation *alloc,
- const Type *type, uint8_t *ptr) {
-
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- drv->lod[0].dimX = type->getDimX();
- drv->lod[0].dimY = type->getDimY();
- drv->lod[0].mallocPtr = 0;
- drv->lod[0].stride = drv->lod[0].dimX * type->getElementSizeBytes();
- drv->lodCount = type->getLODCount();
- drv->faceCount = type->getDimFaces();
-
- size_t offsets[Allocation::MAX_LOD];
- memset(offsets, 0, sizeof(offsets));
-
- size_t o = drv->lod[0].stride * rsMax(drv->lod[0].dimY, 1u) * rsMax(drv->lod[0].dimZ, 1u);
- if(drv->lodCount > 1) {
- uint32_t tx = drv->lod[0].dimX;
- uint32_t ty = drv->lod[0].dimY;
- uint32_t tz = drv->lod[0].dimZ;
- for (uint32_t lod=1; lod < drv->lodCount; lod++) {
- drv->lod[lod].dimX = tx;
- drv->lod[lod].dimY = ty;
- drv->lod[lod].dimZ = tz;
- drv->lod[lod].stride = tx * type->getElementSizeBytes();
- offsets[lod] = o;
- o += drv->lod[lod].stride * rsMax(ty, 1u) * rsMax(tz, 1u);
- if (tx > 1) tx >>= 1;
- if (ty > 1) ty >>= 1;
- if (tz > 1) tz >>= 1;
- }
- }
- drv->faceOffset = o;
-
- drv->lod[0].mallocPtr = ptr;
- for (uint32_t lod=1; lod < drv->lodCount; lod++) {
- drv->lod[lod].mallocPtr = ptr + offsets[lod];
- }
- alloc->mHal.drvState.strideLOD0 = drv->lod[0].stride;
- alloc->mHal.drvState.mallocPtrLOD0 = ptr;
-
- size_t allocSize = drv->faceOffset;
- if(drv->faceCount) {
- allocSize *= 6;
- }
-
- return allocSize;
-}
-
-bool rsdAllocationInit(const Context *rsc, Allocation *alloc, bool forceZero) {
- DrvAllocation *drv = (DrvAllocation *)calloc(1, sizeof(DrvAllocation));
- if (!drv) {
- return false;
- }
- alloc->mHal.drv = drv;
-
- // Calculate the object size.
- size_t allocSize = AllocationBuildPointerTable(rsc, alloc, alloc->getType(), NULL);
-
- ALOGE("alloc usage %i", alloc->mHal.state.usageFlags);
-
- uint8_t * ptr = NULL;
- if (alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_IO_OUTPUT) {
- } else {
-
- ptr = (uint8_t *)malloc(allocSize);
- if (!ptr) {
- free(drv);
- return false;
- }
- }
- // Build the pointer tables
- size_t verifySize = AllocationBuildPointerTable(rsc, alloc, alloc->getType(), ptr);
- if(allocSize != verifySize) {
- rsAssert(!"Size mismatch");
- }
-
- drv->glTarget = GL_NONE;
- if (alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE) {
- if (alloc->mHal.state.hasFaces) {
- drv->glTarget = GL_TEXTURE_CUBE_MAP;
- } else {
- drv->glTarget = GL_TEXTURE_2D;
- }
- } else {
- if (alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_GRAPHICS_VERTEX) {
- drv->glTarget = GL_ARRAY_BUFFER;
- }
- }
-
- drv->glType = 0;
- drv->glFormat = 0;
-
- if (forceZero && ptr) {
- memset(ptr, 0, alloc->mHal.state.type->getSizeBytes());
- }
-
- if (alloc->mHal.state.usageFlags & ~RS_ALLOCATION_USAGE_SCRIPT) {
- drv->uploadDeferred = true;
- }
-
-
- drv->readBackFBO = NULL;
-
- return true;
-}
-
-void rsdAllocationDestroy(const Context *rsc, Allocation *alloc) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- if (alloc->mHal.drvState.mallocPtrLOD0) {
- free(alloc->mHal.drvState.mallocPtrLOD0);
- alloc->mHal.drvState.mallocPtrLOD0 = NULL;
- }
- free(drv);
- alloc->mHal.drv = NULL;
-}
-
-void rsdAllocationResize(const Context *rsc, const Allocation *alloc,
- const Type *newType, bool zeroNew) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- void * oldPtr = drv->lod[0].mallocPtr;
- // Calculate the object size
- size_t s = AllocationBuildPointerTable(rsc, alloc, newType, NULL);
- uint8_t *ptr = (uint8_t *)realloc(oldPtr, s);
- // Build the relative pointer tables.
- size_t verifySize = AllocationBuildPointerTable(rsc, alloc, newType, ptr);
- if(s != verifySize) {
- rsAssert(!"Size mismatch");
- }
-
- const uint32_t oldDimX = alloc->mHal.state.dimensionX;
- const uint32_t dimX = newType->getDimX();
-
- if (dimX > oldDimX) {
- uint32_t stride = alloc->mHal.state.elementSizeBytes;
- memset(((uint8_t *)alloc->mHal.drvState.mallocPtrLOD0) + stride * oldDimX,
- 0, stride * (dimX - oldDimX));
- }
-}
-
-static void rsdAllocationSyncFromFBO(const Context *rsc, const Allocation *alloc) {
-}
-
-
-void rsdAllocationSyncAll(const Context *rsc, const Allocation *alloc,
- RsAllocationUsageType src) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- if (src == RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET) {
- if(!alloc->getIsRenderTarget()) {
- rsc->setError(RS_ERROR_FATAL_DRIVER,
- "Attempting to sync allocation from render target, "
- "for non-render target allocation");
- } else if (alloc->getType()->getElement()->getKind() != RS_KIND_PIXEL_RGBA) {
- rsc->setError(RS_ERROR_FATAL_DRIVER, "Cannot only sync from RGBA"
- "render target");
- } else {
- rsdAllocationSyncFromFBO(rsc, alloc);
- }
- return;
- }
-
- rsAssert(src == RS_ALLOCATION_USAGE_SCRIPT);
-
- if (alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE) {
- UploadToTexture(rsc, alloc);
- } else {
- if ((alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET) &&
- !(alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_IO_OUTPUT)) {
- AllocateRenderTarget(rsc, alloc);
- }
- }
- if (alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_GRAPHICS_VERTEX) {
- UploadToBufferObject(rsc, alloc);
- }
-
- drv->uploadDeferred = false;
-}
-
-void rsdAllocationMarkDirty(const Context *rsc, const Allocation *alloc) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
- drv->uploadDeferred = true;
-}
-
-int32_t rsdAllocationInitSurfaceTexture(const Context *rsc, const Allocation *alloc) {
- return 0;
-}
-
-void rsdAllocationSetSurfaceTexture(const Context *rsc, Allocation *alloc, ANativeWindow *nw) {
-}
-
-void rsdAllocationIoSend(const Context *rsc, Allocation *alloc) {
-}
-
-void rsdAllocationIoReceive(const Context *rsc, Allocation *alloc) {
-}
-
-
-void rsdAllocationData1D(const Context *rsc, const Allocation *alloc,
- uint32_t xoff, uint32_t lod, uint32_t count,
- const void *data, size_t sizeBytes) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- const uint32_t eSize = alloc->mHal.state.type->getElementSizeBytes();
- uint8_t * ptr = GetOffsetPtr(alloc, xoff, 0, 0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X);
- uint32_t size = count * eSize;
-
- if (alloc->mHal.state.hasReferences) {
- alloc->incRefs(data, count);
- alloc->decRefs(ptr, count);
- }
-
- memcpy(ptr, data, size);
- drv->uploadDeferred = true;
-}
-
-void rsdAllocationData2D(const Context *rsc, const Allocation *alloc,
- uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, const void *data, size_t sizeBytes) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- uint32_t eSize = alloc->mHal.state.elementSizeBytes;
- uint32_t lineSize = eSize * w;
-
- if (drv->lod[0].mallocPtr) {
- const uint8_t *src = static_cast<const uint8_t *>(data);
- uint8_t *dst = GetOffsetPtr(alloc, xoff, yoff, lod, face);
-
- for (uint32_t line=yoff; line < (yoff+h); line++) {
- if (alloc->mHal.state.hasReferences) {
- alloc->incRefs(src, w);
- alloc->decRefs(dst, w);
- }
- memcpy(dst, src, lineSize);
- src += lineSize;
- dst += drv->lod[lod].stride;
- }
- drv->uploadDeferred = true;
- } else {
- Update2DTexture(rsc, alloc, data, xoff, yoff, lod, face, w, h);
- }
-}
-
-void rsdAllocationData3D(const Context *rsc, const Allocation *alloc,
- uint32_t xoff, uint32_t yoff, uint32_t zoff,
- uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes) {
-
-}
-
-void rsdAllocationRead1D(const Context *rsc, const Allocation *alloc,
- uint32_t xoff, uint32_t lod, uint32_t count,
- void *data, size_t sizeBytes) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- const uint32_t eSize = alloc->mHal.state.type->getElementSizeBytes();
- const uint8_t * ptr = GetOffsetPtr(alloc, xoff, 0, 0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X);
- memcpy(data, ptr, count * eSize);
-}
-
-void rsdAllocationRead2D(const Context *rsc, const Allocation *alloc,
- uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, void *data, size_t sizeBytes) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- uint32_t eSize = alloc->mHal.state.elementSizeBytes;
- uint32_t lineSize = eSize * w;
-
- if (drv->lod[0].mallocPtr) {
- uint8_t *dst = static_cast<uint8_t *>(data);
- const uint8_t *src = GetOffsetPtr(alloc, xoff, yoff, lod, face);
-
- for (uint32_t line=yoff; line < (yoff+h); line++) {
- memcpy(dst, src, lineSize);
- dst += lineSize;
- src += drv->lod[lod].stride;
- }
- } else {
- ALOGE("Add code to readback from non-script memory");
- }
-}
-
-void rsdAllocationRead3D(const Context *rsc, const Allocation *alloc,
- uint32_t xoff, uint32_t yoff, uint32_t zoff,
- uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, uint32_t d, void *data, uint32_t sizeBytes) {
-
-}
-
-void * rsdAllocationLock1D(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
- return drv->lod[0].mallocPtr;
-}
-
-void rsdAllocationUnlock1D(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc) {
-
-}
-
-void rsdAllocationData1D_alloc(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstLod, uint32_t count,
- const android::renderscript::Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcLod) {
-}
-
-
-void rsdAllocationData2D_alloc_script(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
- RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
- const android::renderscript::Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
- RsAllocationCubemapFace srcFace) {
- uint32_t elementSize = dstAlloc->getType()->getElementSizeBytes();
- for (uint32_t i = 0; i < h; i ++) {
- uint8_t *dstPtr = GetOffsetPtr(dstAlloc, dstXoff, dstYoff + i, dstLod, dstFace);
- uint8_t *srcPtr = GetOffsetPtr(srcAlloc, srcXoff, srcYoff + i, srcLod, srcFace);
- memcpy(dstPtr, srcPtr, w * elementSize);
-
- //ALOGE("COPIED dstXoff(%u), dstYoff(%u), dstLod(%u), dstFace(%u), w(%u), h(%u), srcXoff(%u), srcYoff(%u), srcLod(%u), srcFace(%u)",
- // dstXoff, dstYoff, dstLod, dstFace, w, h, srcXoff, srcYoff, srcLod, srcFace);
- }
-}
-
-void rsdAllocationData2D_alloc(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
- RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
- const android::renderscript::Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
- RsAllocationCubemapFace srcFace) {
- if (!dstAlloc->getIsScript() && !srcAlloc->getIsScript()) {
- rsc->setError(RS_ERROR_FATAL_DRIVER, "Non-script allocation copies not "
- "yet implemented.");
- return;
- }
- rsdAllocationData2D_alloc_script(rsc, dstAlloc, dstXoff, dstYoff,
- dstLod, dstFace, w, h, srcAlloc,
- srcXoff, srcYoff, srcLod, srcFace);
-}
-
-void rsdAllocationData3D_alloc(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
- uint32_t dstLod, RsAllocationCubemapFace dstFace,
- uint32_t w, uint32_t h, uint32_t d,
- const android::renderscript::Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
- uint32_t srcLod, RsAllocationCubemapFace srcFace) {
-}
-
-void rsdAllocationElementData1D(const Context *rsc, const Allocation *alloc,
- uint32_t x,
- const void *data, uint32_t cIdx, uint32_t sizeBytes) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- uint32_t eSize = alloc->mHal.state.elementSizeBytes;
- uint8_t * ptr = GetOffsetPtr(alloc, x, 0, 0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X);
-
- const Element * e = alloc->mHal.state.type->getElement()->getField(cIdx);
- ptr += alloc->mHal.state.type->getElement()->getFieldOffsetBytes(cIdx);
-
- if (alloc->mHal.state.hasReferences) {
- e->incRefs(data);
- e->decRefs(ptr);
- }
-
- memcpy(ptr, data, sizeBytes);
- drv->uploadDeferred = true;
-}
-
-void rsdAllocationElementData2D(const Context *rsc, const Allocation *alloc,
- uint32_t x, uint32_t y,
- const void *data, uint32_t cIdx, uint32_t sizeBytes) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- uint32_t eSize = alloc->mHal.state.elementSizeBytes;
- uint8_t * ptr = GetOffsetPtr(alloc, x, y, 0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X);
-
- const Element * e = alloc->mHal.state.type->getElement()->getField(cIdx);
- ptr += alloc->mHal.state.type->getElement()->getFieldOffsetBytes(cIdx);
-
- if (alloc->mHal.state.hasReferences) {
- e->incRefs(data);
- e->decRefs(ptr);
- }
-
- memcpy(ptr, data, sizeBytes);
- drv->uploadDeferred = true;
-}
-
-static void mip565(const Allocation *alloc, int lod, RsAllocationCubemapFace face) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
- uint32_t w = drv->lod[lod + 1].dimX;
- uint32_t h = drv->lod[lod + 1].dimY;
-
- for (uint32_t y=0; y < h; y++) {
- uint16_t *oPtr = (uint16_t *)GetOffsetPtr(alloc, 0, y, lod + 1, face);
- const uint16_t *i1 = (uint16_t *)GetOffsetPtr(alloc, 0, y*2, lod, face);
- const uint16_t *i2 = (uint16_t *)GetOffsetPtr(alloc, 0, y*2+1, lod, face);
-
- for (uint32_t x=0; x < w; x++) {
- *oPtr = rsBoxFilter565(i1[0], i1[1], i2[0], i2[1]);
- oPtr ++;
- i1 += 2;
- i2 += 2;
- }
- }
-}
-
-static void mip8888(const Allocation *alloc, int lod, RsAllocationCubemapFace face) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
- uint32_t w = drv->lod[lod + 1].dimX;
- uint32_t h = drv->lod[lod + 1].dimY;
-
- for (uint32_t y=0; y < h; y++) {
- uint32_t *oPtr = (uint32_t *)GetOffsetPtr(alloc, 0, y, lod + 1, face);
- const uint32_t *i1 = (uint32_t *)GetOffsetPtr(alloc, 0, y*2, lod, face);
- const uint32_t *i2 = (uint32_t *)GetOffsetPtr(alloc, 0, y*2+1, lod, face);
-
- for (uint32_t x=0; x < w; x++) {
- *oPtr = rsBoxFilter8888(i1[0], i1[1], i2[0], i2[1]);
- oPtr ++;
- i1 += 2;
- i2 += 2;
- }
- }
-}
-
-static void mip8(const Allocation *alloc, int lod, RsAllocationCubemapFace face) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
- uint32_t w = drv->lod[lod + 1].dimX;
- uint32_t h = drv->lod[lod + 1].dimY;
-
- for (uint32_t y=0; y < h; y++) {
- uint8_t *oPtr = GetOffsetPtr(alloc, 0, y, lod + 1, face);
- const uint8_t *i1 = GetOffsetPtr(alloc, 0, y*2, lod, face);
- const uint8_t *i2 = GetOffsetPtr(alloc, 0, y*2+1, lod, face);
-
- for (uint32_t x=0; x < w; x++) {
- *oPtr = (uint8_t)(((uint32_t)i1[0] + i1[1] + i2[0] + i2[1]) * 0.25f);
- oPtr ++;
- i1 += 2;
- i2 += 2;
- }
- }
-}
-
-void rsdAllocationGenerateMipmaps(const Context *rsc, const Allocation *alloc) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
- if(!drv->lod[0].mallocPtr) {
- return;
- }
- uint32_t numFaces = alloc->getType()->getDimFaces() ? 6 : 1;
- for (uint32_t face = 0; face < numFaces; face ++) {
- for (uint32_t lod=0; lod < (alloc->getType()->getLODCount() -1); lod++) {
- switch (alloc->getType()->getElement()->getSizeBits()) {
- case 32:
- mip8888(alloc, lod, (RsAllocationCubemapFace)face);
- break;
- case 16:
- mip565(alloc, lod, (RsAllocationCubemapFace)face);
- break;
- case 8:
- mip8(alloc, lod, (RsAllocationCubemapFace)face);
- break;
- }
- }
- }
-}
-
-
diff --git a/renderscript/v8/rs_support/driver/rsdAllocation.h b/renderscript/v8/rs_support/driver/rsdAllocation.h
deleted file mode 100644
index 9e46ebb..0000000
--- a/renderscript/v8/rs_support/driver/rsdAllocation.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef RSD_ALLOCATION_H
-#define RSD_ALLOCATION_H
-
-#include <rs_hal.h>
-#include <rsRuntime.h>
-#include <rsAllocation.h>
-
-#include <GLES/gl.h>
-#include <GLES2/gl2.h>
-
-class RsdFrameBufferObj;
-struct ANativeWindowBuffer;
-
-struct DrvAllocation {
- // Is this a legal structure to be used as a texture source.
- // Initially this will require 1D or 2D and color data
- uint32_t textureID;
-
- // Is this a legal structure to be used as a vertex source.
- // Initially this will require 1D and x(yzw). Additional per element data
- // is allowed.
- uint32_t bufferID;
-
- // Is this a legal structure to be used as an FBO render target
- uint32_t renderTargetID;
-
- int glTarget;
- int glType;
- int glFormat;
-
- bool uploadDeferred;
-
- void * readBackFBO;
- void *wnd;
- void *wndBuffer;
-
- struct LodState {
- void * mallocPtr;
- size_t stride;
- uint32_t dimX;
- uint32_t dimY;
- uint32_t dimZ;
- } lod[android::renderscript::Allocation::MAX_LOD];
- size_t faceOffset;
- uint32_t lodCount;
- uint32_t faceCount;
-
-
-};
-
-
-bool rsdAllocationInit(const android::renderscript::Context *rsc,
- android::renderscript::Allocation *alloc,
- bool forceZero);
-void rsdAllocationDestroy(const android::renderscript::Context *rsc,
- android::renderscript::Allocation *alloc);
-
-void rsdAllocationResize(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc,
- const android::renderscript::Type *newType, bool zeroNew);
-void rsdAllocationSyncAll(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc,
- RsAllocationUsageType src);
-void rsdAllocationMarkDirty(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc);
-
-void rsdAllocationData1D(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc,
- uint32_t xoff, uint32_t lod, uint32_t count,
- const void *data, uint32_t sizeBytes);
-void rsdAllocationData2D(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc,
- uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h,
- const void *data, uint32_t sizeBytes);
-void rsdAllocationData3D(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc,
- uint32_t xoff, uint32_t yoff, uint32_t zoff,
- uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes);
-
-void rsdAllocationRead1D(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc,
- uint32_t xoff, uint32_t lod, uint32_t count,
- void *data, uint32_t sizeBytes);
-void rsdAllocationRead2D(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc,
- uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h,
- void *data, uint32_t sizeBytes);
-void rsdAllocationRead3D(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc,
- uint32_t xoff, uint32_t yoff, uint32_t zoff,
- uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, uint32_t d, void *data, uint32_t sizeBytes);
-
-void * rsdAllocationLock1D(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc);
-void rsdAllocationUnlock1D(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc);
-
-
-void rsdAllocationData1D_alloc(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstLod, uint32_t count,
- const android::renderscript::Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcLod);
-void rsdAllocationData2D_alloc(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
- RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
- const android::renderscript::Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
- RsAllocationCubemapFace srcFace);
-void rsdAllocationData3D_alloc(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
- uint32_t dstLod, RsAllocationCubemapFace dstFace,
- uint32_t w, uint32_t h, uint32_t d,
- const android::renderscript::Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
- uint32_t srcLod, RsAllocationCubemapFace srcFace);
-
-void rsdAllocationElementData1D(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc,
- uint32_t x,
- const void *data, uint32_t elementOff, uint32_t sizeBytes);
-void rsdAllocationElementData2D(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc,
- uint32_t x, uint32_t y,
- const void *data, uint32_t elementOff, uint32_t sizeBytes);
-
-void rsdAllocationGenerateMipmaps(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc);
-
-
-
-#endif
diff --git a/renderscript/v8/rs_support/driver/rsdBcc.cpp b/renderscript/v8/rs_support/driver/rsdBcc.cpp
deleted file mode 100644
index db2a462..0000000
--- a/renderscript/v8/rs_support/driver/rsdBcc.cpp
+++ /dev/null
@@ -1,790 +0,0 @@
-/*
- * Copyright (C) 2011-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsdCore.h"
-#include "rsdBcc.h"
-#include "rsdRuntime.h"
-#include "rsdAllocation.h"
-#include "rsdIntrinsics.h"
-
-#include "rsContext.h"
-#include "rsElement.h"
-#include "rsScriptC.h"
-
-#include "utils/Vector.h"
-#include "utils/Timers.h"
-#include "utils/StopWatch.h"
-#include "utils/String8.h"
-
-#include <dlfcn.h>
-#include <stdio.h>
-#include <string.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-#define MAXLINE 500
-#define MAKE_STR_HELPER(S) #S
-#define MAKE_STR(S) MAKE_STR_HELPER(S)
-#define EXPORT_VAR_STR "exportVarCount: "
-#define EXPORT_VAR_STR_LEN strlen(EXPORT_VAR_STR)
-#define EXPORT_FUNC_STR "exportFuncCount: "
-#define EXPORT_FUNC_STR_LEN strlen(EXPORT_FUNC_STR)
-#define EXPORT_FOREACH_STR "exportForEachCount: "
-#define EXPORT_FOREACH_STR_LEN strlen(EXPORT_FOREACH_STR)
-#define OBJECT_SLOT_STR "objectSlotCount: "
-#define OBJECT_SLOT_STR_LEN strlen(OBJECT_SLOT_STR)
-
-// Copy up to a newline or size chars from str -> s, updating str
-// Returns s when successful and NULL when '\0' is finally reached.
-static char* strgets(char *s, int size, const char **ppstr) {
- if (!ppstr || !*ppstr || **ppstr == '\0' || size < 1) {
- return NULL;
- }
-
- int i;
- for (i = 0; i < (size - 1); i++) {
- s[i] = **ppstr;
- (*ppstr)++;
- if (s[i] == '\0') {
- return s;
- } else if (s[i] == '\n') {
- s[i+1] = '\0';
- return s;
- }
- }
-
- // size has been exceeded.
- s[i] = '\0';
-
- return s;
-}
-
-
-static Script * setTLS(Script *sc) {
- ScriptTLSStruct * tls = (ScriptTLSStruct *)pthread_getspecific(rsdgThreadTLSKey);
- rsAssert(tls);
- Script *old = tls->mScript;
- tls->mScript = sc;
- return old;
-}
-
-
-bool rsdScriptInit(const Context *rsc,
- ScriptC *script,
- char const *resName,
- char const *cacheDir,
- uint8_t const *bitcode,
- size_t bitcodeSize,
- uint32_t flags) {
- //ALOGE("rsdScriptCreate %p %p %p %p %i %i %p", rsc, resName, cacheDir, bitcode, bitcodeSize, flags, lookupFunc);
- //ALOGE("rsdScriptInit %p %p", rsc, script);
-
- pthread_mutex_lock(&rsdgInitMutex);
-
- String8 scriptSOName(cacheDir);
- scriptSOName = scriptSOName.getPathDir();
- scriptSOName.appendPath("lib");
- scriptSOName.append("/lib");
- scriptSOName.append(resName);
- scriptSOName.append(".so");
-
- void *scriptSO = NULL;
- DrvScript *drv = (DrvScript *)calloc(1, sizeof(DrvScript));
- if (drv == NULL) {
- goto error;
- }
- script->mHal.drv = drv;
-
- ALOGE("Opening up shared object: %s", scriptSOName.string());
- scriptSO = dlopen(scriptSOName.string(), RTLD_NOW | RTLD_LOCAL);
- if (scriptSO == NULL) {
- ALOGE("Unable to open shared library (%s): %s",
- scriptSOName.string(), dlerror());
- goto error;
- }
- drv->mScriptSO = scriptSO;
-
- if (scriptSO) {
- char line[MAXLINE];
- drv->mScriptSO = scriptSO;
- drv->mRoot = (RootFunc_t) dlsym(scriptSO, "root");
- if (drv->mRoot) {
- ALOGE("Found root(): %p", drv->mRoot);
- }
- drv->mRootExpand = (RootFunc_t) dlsym(scriptSO, "root.expand");
- if (drv->mRootExpand) {
- ALOGE("Found root.expand(): %p", drv->mRootExpand);
- }
- drv->mInit = (InvokeFunc_t) dlsym(scriptSO, "init");
- if (drv->mInit) {
- ALOGE("Found init(): %p", drv->mInit);
- }
- drv->mFreeChildren = (InvokeFunc_t) dlsym(scriptSO, ".rs.dtor");
- if (drv->mFreeChildren) {
- ALOGE("Found .rs.dtor(): %p", drv->mFreeChildren);
- }
-
- const char *rsInfo = (const char *) dlsym(scriptSO, ".rs.info");
- if (rsInfo) {
- ALOGE("Found .rs.info(): %p - %s", rsInfo, rsInfo);
- }
-
- size_t varCount = 0;
- if (strgets(line, MAXLINE, &rsInfo) == NULL) {
- goto error;
- }
- if (sscanf(line, EXPORT_VAR_STR "%zu", &varCount) != 1) {
- ALOGE("Invalid export var count!: %s", line);
- goto error;
- }
-
- script->mHal.info.exportedVariableCount = varCount;
- ALOGE("varCount: %zu", varCount);
- if (varCount > 0) {
- // Start by creating/zeroing this member, since we don't want to
- // accidentally clean up invalid pointers later (if we error out).
- drv->mFieldIsObject = new bool[varCount];
- if (drv->mFieldIsObject == NULL) {
- goto error;
- }
- memset(drv->mFieldIsObject, 0,
- varCount * sizeof(*drv->mFieldIsObject));
- drv->mFieldAddress = new void*[varCount];
- if (drv->mFieldAddress == NULL) {
- goto error;
- }
- for (size_t i = 0; i < varCount; ++i) {
- if (strgets(line, MAXLINE, &rsInfo) == NULL) {
- goto error;
- }
- char *c = strrchr(line, '\n');
- if (c) {
- *c = '\0';
- }
- drv->mFieldAddress[i] = dlsym(scriptSO, line);
- if (drv->mFieldAddress[i] == NULL) {
- ALOGE("Failed to find variable address for %s: %s",
- line, dlerror());
- // Not a critical error if we don't find a global variable.
- }
- else {
- ALOGE("Found variable %s at %p", line,
- drv->mFieldAddress[i]);
- }
- }
- }
-
- size_t funcCount = 0;
- if (strgets(line, MAXLINE, &rsInfo) == NULL) {
- goto error;
- }
- if (sscanf(line, EXPORT_FUNC_STR "%zu", &funcCount) != 1) {
- ALOGE("Invalid export func count!: %s", line);
- goto error;
- }
-
- script->mHal.info.exportedFunctionCount = funcCount;
- ALOGE("funcCount: %zu", funcCount);
-
- if (funcCount > 0) {
- drv->mInvokeFunctions = new InvokeFunc_t[funcCount];
- if (drv->mInvokeFunctions == NULL) {
- goto error;
- }
- for (size_t i = 0; i < funcCount; ++i) {
- if (strgets(line, MAXLINE, &rsInfo) == NULL) {
- goto error;
- }
- char *c = strrchr(line, '\n');
- if (c) {
- *c = '\0';
- }
-
- drv->mInvokeFunctions[i] =
- (InvokeFunc_t) dlsym(scriptSO, line);
- if (drv->mInvokeFunctions[i] == NULL) {
- ALOGE("Failed to get function address for %s(): %s",
- line, dlerror());
- goto error;
- }
- else {
- ALOGE("Found InvokeFunc_t %s at %p", line,
- drv->mInvokeFunctions[i]);
- }
- }
- }
-
- size_t forEachCount = 0;
- if (strgets(line, MAXLINE, &rsInfo) == NULL) {
- goto error;
- }
- if (sscanf(line, EXPORT_FOREACH_STR "%zu", &forEachCount) != 1) {
- ALOGE("Invalid export forEach count!: %s", line);
- goto error;
- }
-
- if (forEachCount > 0) {
-
- drv->mForEachSignatures = new uint32_t[forEachCount];
- if (drv->mForEachSignatures == NULL) {
- goto error;
- }
- drv->mForEachFunctions = new ForEachFunc_t[forEachCount];
- if (drv->mForEachFunctions == NULL) {
- goto error;
- }
- for (size_t i = 0; i < forEachCount; ++i) {
- unsigned int tmpSig = 0;
- char tmpName[MAXLINE];
-
- if (strgets(line, MAXLINE, &rsInfo) == NULL) {
- goto error;
- }
- if (sscanf(line, "%u - %" MAKE_STR(MAXLINE) "s",
- &tmpSig, tmpName) != 2) {
- ALOGE("Invalid export forEach!: %s", line);
- goto error;
- }
-
- // Lookup the expanded ForEach kernel.
- strncat(tmpName, ".expand", MAXLINE-1-strlen(tmpName));
- drv->mForEachSignatures[i] = tmpSig;
- drv->mForEachFunctions[i] =
- (ForEachFunc_t) dlsym(scriptSO, tmpName);
- if (drv->mForEachFunctions[i] == NULL) {
- ALOGE("Failed to find forEach function address for %s: %s",
- tmpName, dlerror());
- // Ignore missing root.expand functions.
- // root() is always specified at location 0.
- if (i != 0) {
- goto error;
- }
- }
- else {
- ALOGE("Found forEach %s at %p", tmpName,
- drv->mForEachFunctions[i]);
- }
- }
- }
-
- size_t objectSlotCount = 0;
- if (strgets(line, MAXLINE, &rsInfo) == NULL) {
- goto error;
- }
- if (sscanf(line, OBJECT_SLOT_STR "%zu", &objectSlotCount) != 1) {
- ALOGE("Invalid object slot count!: %s", line);
- goto error;
- }
-
- if (objectSlotCount > 0) {
- rsAssert(varCount > 0);
- for (size_t i = 0; i < objectSlotCount; ++i) {
- uint32_t varNum = 0;
- if (strgets(line, MAXLINE, &rsInfo) == NULL) {
- goto error;
- }
- if (sscanf(line, "%u", &varNum) != 1) {
- ALOGE("Invalid object slot!: %s", line);
- goto error;
- }
-
- if (varNum < varCount) {
- drv->mFieldIsObject[varNum] = true;
- }
- }
- }
-
- script->mHal.info.exportedPragmaCount = 0;
-
- if (drv->mRootExpand) {
- script->mHal.info.root = drv->mRootExpand;
- } else {
- script->mHal.info.root = drv->mRoot;
- }
-
- if (varCount > 0) {
- drv->mBoundAllocs = new Allocation *[varCount];
- memset(drv->mBoundAllocs, 0, varCount * sizeof(*drv->mBoundAllocs));
- }
-
- script->mHal.info.isThreadable = true;
-
- if (scriptSO == (void*)1) {
- rsdLookupRuntimeStub(script, "acos");
- }
- }
-
- pthread_mutex_unlock(&rsdgInitMutex);
- return true;
-
-error:
-
- pthread_mutex_unlock(&rsdgInitMutex);
- if (drv) {
- delete[] drv->mInvokeFunctions;
- delete[] drv->mForEachFunctions;
- delete[] drv->mFieldAddress;
- delete[] drv->mFieldIsObject;
- delete[] drv->mForEachSignatures;
- delete[] drv->mBoundAllocs;
- if (drv->mScriptSO) {
- dlclose(drv->mScriptSO);
- }
- free(drv);
- }
- script->mHal.drv = NULL;
- return false;
-
-}
-
-bool rsdInitIntrinsic(const Context *rsc, Script *s, RsScriptIntrinsicID iid, Element *e) {
- pthread_mutex_lock(&rsdgInitMutex);
-
- DrvScript *drv = (DrvScript *)calloc(1, sizeof(DrvScript));
- if (drv == NULL) {
- goto error;
- }
- s->mHal.drv = drv;
- drv->mIntrinsicID = iid;
- drv->mIntrinsicData = rsdIntrinsic_Init(rsc, s, iid, &drv->mIntrinsicFuncs);
- s->mHal.info.isThreadable = true;
-
- pthread_mutex_unlock(&rsdgInitMutex);
- return true;
-
-error:
- pthread_mutex_unlock(&rsdgInitMutex);
- return false;
-}
-
-static void wc_xy(void *usr, uint32_t idx) {
- MTLaunchStruct *mtls = (MTLaunchStruct *)usr;
- RsForEachStubParamStruct p;
- memcpy(&p, &mtls->fep, sizeof(p));
- //p.lid = idx;
- RsdHal * dc = (RsdHal *)mtls->rsc->mHal.drv;
- uint32_t sig = mtls->sig;
-
- outer_foreach_t fn = (outer_foreach_t) mtls->kernel;
- while (1) {
- uint32_t slice = (uint32_t)android_atomic_inc(&mtls->mSliceNum);
- uint32_t yStart = mtls->yStart + slice * mtls->mSliceSize;
- uint32_t yEnd = yStart + mtls->mSliceSize;
- yEnd = rsMin(yEnd, mtls->yEnd);
- if (yEnd <= yStart) {
- return;
- }
-
- //ALOGE("usr idx %i, x %i,%i y %i,%i", idx, mtls->xStart, mtls->xEnd, yStart, yEnd);
- //ALOGE("usr ptr in %p, out %p", mtls->fep.ptrIn, mtls->fep.ptrOut);
- for (p.y = yStart; p.y < yEnd; p.y++) {
- p.out = mtls->fep.ptrOut + (mtls->fep.yStrideOut * p.y) +
- (mtls->fep.eStrideOut * mtls->xStart);
- p.in = mtls->fep.ptrIn + (mtls->fep.yStrideIn * p.y) +
- (mtls->fep.eStrideIn * mtls->xStart);
- fn(&p, mtls->xStart, mtls->xEnd, mtls->fep.eStrideIn, mtls->fep.eStrideOut);
- }
- }
-}
-
-static void wc_x(void *usr, uint32_t idx) {
- MTLaunchStruct *mtls = (MTLaunchStruct *)usr;
- RsForEachStubParamStruct p;
- memcpy(&p, &mtls->fep, sizeof(p));
- //p.lid = idx;
- RsdHal * dc = (RsdHal *)mtls->rsc->mHal.drv;
- uint32_t sig = mtls->sig;
-
- outer_foreach_t fn = (outer_foreach_t) mtls->kernel;
- while (1) {
- uint32_t slice = (uint32_t)android_atomic_inc(&mtls->mSliceNum);
- uint32_t xStart = mtls->xStart + slice * mtls->mSliceSize;
- uint32_t xEnd = xStart + mtls->mSliceSize;
- xEnd = rsMin(xEnd, mtls->xEnd);
- if (xEnd <= xStart) {
- return;
- }
-
- //ALOGE("usr slice %i idx %i, x %i,%i", slice, idx, xStart, xEnd);
- //ALOGE("usr ptr in %p, out %p", mtls->fep.ptrIn, mtls->fep.ptrOut);
-
- p.out = mtls->fep.ptrOut + (mtls->fep.eStrideOut * xStart);
- p.in = mtls->fep.ptrIn + (mtls->fep.eStrideIn * xStart);
- fn(&p, xStart, xEnd, mtls->fep.eStrideIn, mtls->fep.eStrideOut);
- }
-}
-
-void rsdScriptInvokeForEachMtlsSetup(const Context *rsc,
- const Allocation * ain,
- Allocation * aout,
- const void * usr,
- uint32_t usrLen,
- const RsScriptCall *sc,
- MTLaunchStruct *mtls) {
-
- memset(mtls, 0, sizeof(MTLaunchStruct));
-
- if (ain) {
- mtls->fep.dimX = ain->getType()->getDimX();
- mtls->fep.dimY = ain->getType()->getDimY();
- mtls->fep.dimZ = ain->getType()->getDimZ();
- //mtls->dimArray = ain->getType()->getDimArray();
- } else if (aout) {
- mtls->fep.dimX = aout->getType()->getDimX();
- mtls->fep.dimY = aout->getType()->getDimY();
- mtls->fep.dimZ = aout->getType()->getDimZ();
- //mtls->dimArray = aout->getType()->getDimArray();
- } else {
- rsc->setError(RS_ERROR_BAD_SCRIPT, "rsForEach called with null allocations");
- return;
- }
-
- if (!sc || (sc->xEnd == 0)) {
- mtls->xEnd = mtls->fep.dimX;
- } else {
- rsAssert(sc->xStart < mtls->fep.dimX);
- rsAssert(sc->xEnd <= mtls->fep.dimX);
- rsAssert(sc->xStart < sc->xEnd);
- mtls->xStart = rsMin(mtls->fep.dimX, sc->xStart);
- mtls->xEnd = rsMin(mtls->fep.dimX, sc->xEnd);
- if (mtls->xStart >= mtls->xEnd) return;
- }
-
- if (!sc || (sc->yEnd == 0)) {
- mtls->yEnd = mtls->fep.dimY;
- } else {
- rsAssert(sc->yStart < mtls->fep.dimY);
- rsAssert(sc->yEnd <= mtls->fep.dimY);
- rsAssert(sc->yStart < sc->yEnd);
- mtls->yStart = rsMin(mtls->fep.dimY, sc->yStart);
- mtls->yEnd = rsMin(mtls->fep.dimY, sc->yEnd);
- if (mtls->yStart >= mtls->yEnd) return;
- }
-
- mtls->xEnd = rsMax((uint32_t)1, mtls->xEnd);
- mtls->yEnd = rsMax((uint32_t)1, mtls->yEnd);
- mtls->zEnd = rsMax((uint32_t)1, mtls->zEnd);
- mtls->arrayEnd = rsMax((uint32_t)1, mtls->arrayEnd);
-
- rsAssert(!ain || (ain->getType()->getDimZ() == 0));
-
- Context *mrsc = (Context *)rsc;
- mtls->rsc = mrsc;
- mtls->ain = ain;
- mtls->aout = aout;
- mtls->fep.usr = usr;
- mtls->fep.usrLen = usrLen;
- mtls->mSliceSize = 10;
- mtls->mSliceNum = 0;
-
- mtls->fep.ptrIn = NULL;
- mtls->fep.eStrideIn = 0;
-
- if (ain) {
- DrvAllocation *aindrv = (DrvAllocation *)ain->mHal.drv;
- mtls->fep.ptrIn = (const uint8_t *)aindrv->lod[0].mallocPtr;
- mtls->fep.eStrideIn = ain->getType()->getElementSizeBytes();
- mtls->fep.yStrideIn = aindrv->lod[0].stride;
- }
-
- mtls->fep.ptrOut = NULL;
- mtls->fep.eStrideOut = 0;
- if (aout) {
- DrvAllocation *aoutdrv = (DrvAllocation *)aout->mHal.drv;
- mtls->fep.ptrOut = (uint8_t *)aoutdrv->lod[0].mallocPtr;
- mtls->fep.eStrideOut = aout->getType()->getElementSizeBytes();
- mtls->fep.yStrideOut = aoutdrv->lod[0].stride;
- }
-}
-
-void rsdScriptLaunchThreads(const Context *rsc,
- Script *s,
- uint32_t slot,
- const Allocation * ain,
- Allocation * aout,
- const void * usr,
- uint32_t usrLen,
- const RsScriptCall *sc,
- MTLaunchStruct *mtls) {
-
- Script * oldTLS = setTLS(s);
- Context *mrsc = (Context *)rsc;
- RsdHal * dc = (RsdHal *)mtls->rsc->mHal.drv;
-
- if ((dc->mWorkers.mCount > 1) && s->mHal.info.isThreadable && !dc->mInForEach) {
- dc->mInForEach = true;
- if (mtls->fep.dimY > 1) {
- mtls->mSliceSize = mtls->fep.dimY / (dc->mWorkers.mCount * 4);
- if(mtls->mSliceSize < 1) {
- mtls->mSliceSize = 1;
- }
-
- rsdLaunchThreads(mrsc, wc_xy, mtls);
- } else {
- mtls->mSliceSize = mtls->fep.dimX / (dc->mWorkers.mCount * 4);
- if(mtls->mSliceSize < 1) {
- mtls->mSliceSize = 1;
- }
-
- rsdLaunchThreads(mrsc, wc_x, mtls);
- }
- dc->mInForEach = false;
-
- //ALOGE("launch 1");
- } else {
- RsForEachStubParamStruct p;
- memcpy(&p, &mtls->fep, sizeof(p));
- uint32_t sig = mtls->sig;
-
- //ALOGE("launch 3");
- outer_foreach_t fn = (outer_foreach_t) mtls->kernel;
- for (p.ar[0] = mtls->arrayStart; p.ar[0] < mtls->arrayEnd; p.ar[0]++) {
- for (p.z = mtls->zStart; p.z < mtls->zEnd; p.z++) {
- for (p.y = mtls->yStart; p.y < mtls->yEnd; p.y++) {
- uint32_t offset = mtls->fep.dimY * mtls->fep.dimZ * p.ar[0] +
- mtls->fep.dimY * p.z + p.y;
- p.out = mtls->fep.ptrOut + (mtls->fep.yStrideOut * offset);
- p.in = mtls->fep.ptrIn + (mtls->fep.yStrideIn * offset);
- fn(&p, mtls->xStart, mtls->xEnd, mtls->fep.eStrideIn, mtls->fep.eStrideOut);
- }
- }
- }
- }
-
- setTLS(oldTLS);
-}
-
-void rsdScriptInvokeForEach(const Context *rsc,
- Script *s,
- uint32_t slot,
- const Allocation * ain,
- Allocation * aout,
- const void * usr,
- uint32_t usrLen,
- const RsScriptCall *sc) {
-
- RsdHal * dc = (RsdHal *)rsc->mHal.drv;
-
- MTLaunchStruct mtls;
- rsdScriptInvokeForEachMtlsSetup(rsc, ain, aout, usr, usrLen, sc, &mtls);
- mtls.script = s;
- mtls.fep.slot = slot;
-
- DrvScript *drv = (DrvScript *)s->mHal.drv;
- if (drv->mIntrinsicID) {
- mtls.kernel = (void (*)())drv->mIntrinsicFuncs.root;
- mtls.fep.usr = drv->mIntrinsicData;
- } else {
- mtls.kernel = drv->mForEachFunctions[slot];
- rsAssert(mtls.kernel != NULL);
- mtls.sig = drv->mForEachSignatures[slot];
- }
-
-
- rsdScriptLaunchThreads(rsc, s, slot, ain, aout, usr, usrLen, sc, &mtls);
-}
-
-
-int rsdScriptInvokeRoot(const Context *dc, Script *script) {
- DrvScript *drv = (DrvScript *)script->mHal.drv;
-
- Script * oldTLS = setTLS(script);
- int ret = drv->mRoot();
- setTLS(oldTLS);
-
- return ret;
-}
-
-void rsdScriptInvokeInit(const Context *dc, Script *script) {
- DrvScript *drv = (DrvScript *)script->mHal.drv;
-
- if (drv->mInit) {
- drv->mInit();
- }
-}
-
-void rsdScriptInvokeFreeChildren(const Context *dc, Script *script) {
- DrvScript *drv = (DrvScript *)script->mHal.drv;
-
- if (drv->mFreeChildren) {
- drv->mFreeChildren();
- }
-}
-
-void rsdScriptInvokeFunction(const Context *dc, Script *script,
- uint32_t slot,
- const void *params,
- size_t paramLength) {
- DrvScript *drv = (DrvScript *)script->mHal.drv;
- //ALOGE("invoke %p %p %i %p %i", dc, script, slot, params, paramLength);
-
- Script * oldTLS = setTLS(script);
- reinterpret_cast<void (*)(const void *, uint32_t)>(
- drv->mInvokeFunctions[slot])(params, paramLength);
- setTLS(oldTLS);
-}
-
-void rsdScriptSetGlobalVar(const Context *dc, const Script *script,
- uint32_t slot, void *data, size_t dataLength) {
- DrvScript *drv = (DrvScript *)script->mHal.drv;
- //rsAssert(!script->mFieldIsObject[slot]);
- //ALOGE("setGlobalVar %p %p %i %p %i", dc, script, slot, data, dataLength);
-
- if (drv->mIntrinsicID) {
- drv->mIntrinsicFuncs.setVar(dc, script, drv->mIntrinsicData, slot, data, dataLength);
- return;
- }
-
- int32_t *destPtr = reinterpret_cast<int32_t *>(drv->mFieldAddress[slot]);
- if (!destPtr) {
- //ALOGV("Calling setVar on slot = %i which is null", slot);
- return;
- }
-
- memcpy(destPtr, data, dataLength);
-}
-
-void rsdScriptSetGlobalVarWithElemDims(
- const android::renderscript::Context *dc,
- const android::renderscript::Script *script,
- uint32_t slot, void *data, size_t dataLength,
- const android::renderscript::Element *elem,
- const size_t *dims, size_t dimLength) {
- DrvScript *drv = (DrvScript *)script->mHal.drv;
-
- int32_t *destPtr = reinterpret_cast<int32_t *>(drv->mFieldAddress[slot]);
- if (!destPtr) {
- //ALOGV("Calling setVar on slot = %i which is null", slot);
- return;
- }
-
- // We want to look at dimension in terms of integer components,
- // but dimLength is given in terms of bytes.
- dimLength /= sizeof(int);
-
- // Only a single dimension is currently supported.
- rsAssert(dimLength == 1);
- if (dimLength == 1) {
- // First do the increment loop.
- size_t stride = elem->getSizeBytes();
- char *cVal = reinterpret_cast<char *>(data);
- for (size_t i = 0; i < dims[0]; i++) {
- elem->incRefs(cVal);
- cVal += stride;
- }
-
- // Decrement loop comes after (to prevent race conditions).
- char *oldVal = reinterpret_cast<char *>(destPtr);
- for (size_t i = 0; i < dims[0]; i++) {
- elem->decRefs(oldVal);
- oldVal += stride;
- }
- }
-
- memcpy(destPtr, data, dataLength);
-}
-
-void rsdScriptSetGlobalBind(const Context *dc, const Script *script, uint32_t slot, Allocation *data) {
- DrvScript *drv = (DrvScript *)script->mHal.drv;
-
- //rsAssert(!script->mFieldIsObject[slot]);
- //ALOGE("setGlobalBind %p %p %i %p", dc, script, slot, data);
-
- if (drv->mIntrinsicID) {
- drv->mIntrinsicFuncs.bind(dc, script, drv->mIntrinsicData, slot, data);
- return;
- }
-
- int32_t *destPtr = reinterpret_cast<int32_t *>(drv->mFieldAddress[slot]);
- if (!destPtr) {
- //ALOGV("Calling setVar on slot = %i which is null", slot);
- return;
- }
-
- void *ptr = NULL;
- drv->mBoundAllocs[slot] = data;
- if(data) {
- DrvAllocation *allocDrv = (DrvAllocation *)data->mHal.drv;
- ptr = allocDrv->lod[0].mallocPtr;
- }
- memcpy(destPtr, &ptr, sizeof(void *));
-}
-
-void rsdScriptSetGlobalObj(const Context *dc, const Script *script, uint32_t slot, ObjectBase *data) {
- DrvScript *drv = (DrvScript *)script->mHal.drv;
- //rsAssert(script->mFieldIsObject[slot]);
- //ALOGE("setGlobalObj %p %p %i %p", dc, script, slot, data);
-
- int32_t *destPtr = reinterpret_cast<int32_t *>(drv->mFieldAddress[slot]);
- if (!destPtr) {
- //ALOGV("Calling setVar on slot = %i which is null", slot);
- return;
- }
-
- rsrSetObject(dc, script, (ObjectBase **)destPtr, data);
-}
-
-void rsdScriptDestroy(const Context *dc, Script *script) {
- DrvScript *drv = (DrvScript *)script->mHal.drv;
-
- if (drv == NULL) {
- return;
- }
-
- for (size_t i = 0; i < script->mHal.info.exportedVariableCount; ++i) {
- if (drv->mFieldIsObject[i]) {
- if (drv->mFieldAddress[i] != NULL) {
- ObjectBase **obj_addr =
- reinterpret_cast<ObjectBase **>(drv->mFieldAddress[i]);
- rsrClearObject(dc, script, obj_addr);
- }
- }
- }
-
- delete[] drv->mInvokeFunctions;
- delete[] drv->mForEachFunctions;
- delete[] drv->mFieldAddress;
- delete[] drv->mFieldIsObject;
- delete[] drv->mForEachSignatures;
- delete[] drv->mBoundAllocs;
- if (drv->mScriptSO) {
- dlclose(drv->mScriptSO);
- }
- free(drv);
- script->mHal.drv = NULL;
-}
-
-Allocation * rsdScriptGetAllocationForPointer(const android::renderscript::Context *dc,
- const android::renderscript::Script *sc,
- const void *ptr) {
- DrvScript *drv = (DrvScript *)sc->mHal.drv;
- if (!ptr) {
- return NULL;
- }
-
- for (uint32_t ct=0; ct < sc->mHal.info.exportedVariableCount; ct++) {
- Allocation *a = drv->mBoundAllocs[ct];
- if (!a) continue;
- DrvAllocation *adrv = (DrvAllocation *)a->mHal.drv;
- if (adrv->lod[0].mallocPtr == ptr) {
- return a;
- }
- }
- ALOGE("rsGetAllocation, failed to find %p", ptr);
- return NULL;
-}
-
diff --git a/renderscript/v8/rs_support/driver/rsdBcc.h b/renderscript/v8/rs_support/driver/rsdBcc.h
deleted file mode 100644
index f97b50b..0000000
--- a/renderscript/v8/rs_support/driver/rsdBcc.h
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright (C) 2011-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef RSD_BCC_H
-#define RSD_BCC_H
-
-#include <rs_hal.h>
-#include <rsRuntime.h>
-
-
-bool rsdScriptInit(const android::renderscript::Context *, android::renderscript::ScriptC *,
- char const *resName, char const *cacheDir,
- uint8_t const *bitcode, size_t bitcodeSize, uint32_t flags);
-bool rsdInitIntrinsic(const android::renderscript::Context *rsc,
- android::renderscript::Script *s,
- RsScriptIntrinsicID iid,
- android::renderscript::Element *e);
-
-void rsdScriptInvokeFunction(const android::renderscript::Context *dc,
- android::renderscript::Script *script,
- uint32_t slot,
- const void *params,
- size_t paramLength);
-
-void rsdScriptInvokeForEach(const android::renderscript::Context *rsc,
- android::renderscript::Script *s,
- uint32_t slot,
- const android::renderscript::Allocation * ain,
- android::renderscript::Allocation * aout,
- const void * usr,
- uint32_t usrLen,
- const RsScriptCall *sc);
-
-int rsdScriptInvokeRoot(const android::renderscript::Context *dc,
- android::renderscript::Script *script);
-void rsdScriptInvokeInit(const android::renderscript::Context *dc,
- android::renderscript::Script *script);
-void rsdScriptInvokeFreeChildren(const android::renderscript::Context *dc,
- android::renderscript::Script *script);
-
-void rsdScriptSetGlobalVar(const android::renderscript::Context *,
- const android::renderscript::Script *,
- uint32_t slot, void *data, size_t dataLen);
-void rsdScriptSetGlobalVarWithElemDims(const android::renderscript::Context *,
- const android::renderscript::Script *,
- uint32_t slot, void *data,
- size_t dataLength,
- const android::renderscript::Element *,
- const size_t *dims,
- size_t dimLength);
-void rsdScriptSetGlobalBind(const android::renderscript::Context *,
- const android::renderscript::Script *,
- uint32_t slot, android::renderscript::Allocation *data);
-void rsdScriptSetGlobalObj(const android::renderscript::Context *,
- const android::renderscript::Script *,
- uint32_t slot, android::renderscript::ObjectBase *data);
-
-void rsdScriptSetGlobal(const android::renderscript::Context *dc,
- const android::renderscript::Script *script,
- uint32_t slot,
- void *data,
- size_t dataLength);
-void rsdScriptGetGlobal(const android::renderscript::Context *dc,
- const android::renderscript::Script *script,
- uint32_t slot,
- void *data,
- size_t dataLength);
-void rsdScriptDestroy(const android::renderscript::Context *dc,
- android::renderscript::Script *script);
-
-android::renderscript::Allocation * rsdScriptGetAllocationForPointer(
- const android::renderscript::Context *dc,
- const android::renderscript::Script *script,
- const void *);
-
-
-typedef void (*outer_foreach_t)(
- const android::renderscript::RsForEachStubParamStruct *,
- uint32_t x1, uint32_t x2,
- uint32_t instep, uint32_t outstep);
-
-typedef struct RsdIntriniscFuncs_rec {
-
- void (*bind)(const android::renderscript::Context *dc,
- const android::renderscript::Script *script,
- void * intrinsicData,
- uint32_t slot, android::renderscript::Allocation *data);
- void (*setVar)(const android::renderscript::Context *dc,
- const android::renderscript::Script *script,
- void * intrinsicData,
- uint32_t slot, void *data, size_t dataLength);
- void (*root)(const android::renderscript::RsForEachStubParamStruct *,
- uint32_t x1, uint32_t x2, uint32_t instep, uint32_t outstep);
-
- void (*destroy)(const android::renderscript::Context *dc,
- const android::renderscript::Script *script,
- void * intrinsicData);
-} RsdIntriniscFuncs_t;
-
-struct DrvScript {
- RsScriptIntrinsicID mIntrinsicID;
- void *mScriptSO;
- RootFunc_t mRoot;
- RootFunc_t mRootExpand;
- InvokeFunc_t mInit;
- InvokeFunc_t mFreeChildren;
-
- InvokeFunc_t *mInvokeFunctions;
- ForEachFunc_t *mForEachFunctions;
- void **mFieldAddress;
- bool *mFieldIsObject;
- uint32_t *mForEachSignatures;
-
- android::renderscript::Allocation **mBoundAllocs;
- RsdIntriniscFuncs_t mIntrinsicFuncs;
- void * mIntrinsicData;
-};
-
-typedef struct {
- android::renderscript::RsForEachStubParamStruct fep;
- uint32_t cpuIdx;
-
-} MTThreadStuct;
-
-typedef struct {
- android::renderscript::RsForEachStubParamStruct fep;
-
- android::renderscript::Context *rsc;
- android::renderscript::Script *script;
- ForEachFunc_t kernel;
- uint32_t sig;
- const android::renderscript::Allocation * ain;
- android::renderscript::Allocation * aout;
-
- uint32_t mSliceSize;
- volatile int mSliceNum;
-
- uint32_t xStart;
- uint32_t xEnd;
- uint32_t yStart;
- uint32_t yEnd;
- uint32_t zStart;
- uint32_t zEnd;
- uint32_t arrayStart;
- uint32_t arrayEnd;
-} MTLaunchStruct;
-
-void rsdScriptLaunchThreads(const android::renderscript::Context *rsc,
- android::renderscript::Script *s,
- uint32_t slot,
- const android::renderscript::Allocation * ain,
- android::renderscript::Allocation * aout,
- const void * usr,
- uint32_t usrLen,
- const RsScriptCall *sc,
- MTLaunchStruct *mtls);
-
-void rsdScriptInvokeForEachMtlsSetup(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation * ain,
- android::renderscript::Allocation * aout,
- const void * usr,
- uint32_t usrLen,
- const RsScriptCall *sc,
- MTLaunchStruct *mtls);
-
-
-
-
-#endif
diff --git a/renderscript/v8/rs_support/driver/rsdCore.cpp b/renderscript/v8/rs_support/driver/rsdCore.cpp
deleted file mode 100644
index 977a788..0000000
--- a/renderscript/v8/rs_support/driver/rsdCore.cpp
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * Copyright (C) 2011-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsdCore.h"
-#include "rsdAllocation.h"
-#include "rsdBcc.h"
-#include "rsdSampler.h"
-#include "rsdScriptGroup.h"
-
-#include <malloc.h>
-#include "rsContext.h"
-
-#include <sys/types.h>
-#include <sys/resource.h>
-#include <sched.h>
-#include <cutils/properties.h>
-#include <sys/syscall.h>
-#include <string.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-static void Shutdown(Context *rsc);
-static void SetPriority(const Context *rsc, int32_t priority);
-
-static RsdHalFunctions FunctionTable = {
- NULL,
- NULL,
- NULL,
- NULL,
-
- Shutdown,
- NULL,
- SetPriority,
- {
- rsdScriptInit,
- rsdInitIntrinsic,
- rsdScriptInvokeFunction,
- rsdScriptInvokeRoot,
- rsdScriptInvokeForEach,
- rsdScriptInvokeInit,
- rsdScriptInvokeFreeChildren,
- rsdScriptSetGlobalVar,
- rsdScriptSetGlobalVarWithElemDims,
- rsdScriptSetGlobalBind,
- rsdScriptSetGlobalObj,
- rsdScriptDestroy
- },
-
- {
- rsdAllocationInit,
- rsdAllocationDestroy,
- rsdAllocationResize,
- rsdAllocationSyncAll,
- rsdAllocationMarkDirty,
- NULL,
- NULL,
- NULL,
- NULL,
- rsdAllocationData1D,
- rsdAllocationData2D,
- rsdAllocationData3D,
- rsdAllocationRead1D,
- rsdAllocationRead2D,
- rsdAllocationRead3D,
- rsdAllocationLock1D,
- rsdAllocationUnlock1D,
- rsdAllocationData1D_alloc,
- rsdAllocationData2D_alloc,
- rsdAllocationData3D_alloc,
- rsdAllocationElementData1D,
- rsdAllocationElementData2D,
- rsdAllocationGenerateMipmaps
- },
-
-
- {
- NULL,
- NULL,
- NULL
- },
-
- {
- NULL,
- NULL,
- NULL
- },
-
- {
- NULL,
- NULL,
- NULL
- },
-
- {
- NULL,
- NULL,
- NULL
- },
-
- {
- NULL,
- NULL,
- NULL
- },
-
- {
- NULL,
- NULL,
- NULL,
- NULL
- },
-
- {
- rsdSamplerInit,
- rsdSamplerDestroy
- },
-
- {
- NULL,
- NULL,
- NULL
- },
-
- {
- rsdScriptGroupInit,
- rsdScriptGroupSetInput,
- rsdScriptGroupSetOutput,
- rsdScriptGroupExecute,
- rsdScriptGroupDestroy
- }
-
-
-};
-
-pthread_key_t rsdgThreadTLSKey = 0;
-uint32_t rsdgThreadTLSKeyCount = 0;
-pthread_mutex_t rsdgInitMutex = PTHREAD_MUTEX_INITIALIZER;
-
-
-static void * HelperThreadProc(void *vrsc) {
- Context *rsc = static_cast<Context *>(vrsc);
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
-
-
- uint32_t idx = (uint32_t)android_atomic_inc(&dc->mWorkers.mLaunchCount);
-
- //ALOGV("RS helperThread starting %p idx=%i", rsc, idx);
-
- dc->mWorkers.mLaunchSignals[idx].init();
- dc->mWorkers.mNativeThreadId[idx] = gettid();
-
- int status = pthread_setspecific(rsdgThreadTLSKey, &dc->mTlsStruct);
- if (status) {
- ALOGE("pthread_setspecific %i", status);
- }
-
-#if 0
- typedef struct {uint64_t bits[1024 / 64]; } cpu_set_t;
- cpu_set_t cpuset;
- memset(&cpuset, 0, sizeof(cpuset));
- cpuset.bits[idx / 64] |= 1ULL << (idx % 64);
- int ret = syscall(241, rsc->mWorkers.mNativeThreadId[idx],
- sizeof(cpuset), &cpuset);
- ALOGE("SETAFFINITY ret = %i %s", ret, EGLUtils::strerror(ret));
-#endif
-
- while (!dc->mExit) {
- dc->mWorkers.mLaunchSignals[idx].wait();
- if (dc->mWorkers.mLaunchCallback) {
- dc->mWorkers.mLaunchCallback(dc->mWorkers.mLaunchData, idx);
- }
- android_atomic_dec(&dc->mWorkers.mRunningCount);
- dc->mWorkers.mCompleteSignal.set();
- }
-
- //ALOGV("RS helperThread exited %p idx=%i", rsc, idx);
- return NULL;
-}
-
-void rsdLaunchThreads(Context *rsc, WorkerCallback_t cbk, void *data) {
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
-
- dc->mWorkers.mLaunchData = data;
- dc->mWorkers.mLaunchCallback = cbk;
- android_atomic_release_store(dc->mWorkers.mCount, &dc->mWorkers.mRunningCount);
- for (uint32_t ct = 0; ct < dc->mWorkers.mCount; ct++) {
- dc->mWorkers.mLaunchSignals[ct].set();
- }
- while (android_atomic_acquire_load(&dc->mWorkers.mRunningCount) != 0) {
- dc->mWorkers.mCompleteSignal.wait();
- }
-}
-
-extern "C" bool rsdHalInit(RsContext c, uint32_t version_major,
- uint32_t version_minor) {
- Context *rsc = (Context*) c;
- rsc->mHal.funcs = FunctionTable;
-
- RsdHal *dc = (RsdHal *)calloc(1, sizeof(RsdHal));
- if (!dc) {
- ALOGE("Calloc for driver hal failed.");
- return false;
- }
- rsc->mHal.drv = dc;
-
- pthread_mutex_lock(&rsdgInitMutex);
- if (!rsdgThreadTLSKeyCount) {
- int status = pthread_key_create(&rsdgThreadTLSKey, NULL);
- if (status) {
- ALOGE("Failed to init thread tls key.");
- pthread_mutex_unlock(&rsdgInitMutex);
- return false;
- }
- }
- rsdgThreadTLSKeyCount++;
- pthread_mutex_unlock(&rsdgInitMutex);
-
- dc->mTlsStruct.mContext = rsc;
- dc->mTlsStruct.mScript = NULL;
- int status = pthread_setspecific(rsdgThreadTLSKey, &dc->mTlsStruct);
- if (status) {
- ALOGE("pthread_setspecific %i", status);
- }
-
-
- int cpu = sysconf(_SC_NPROCESSORS_ONLN);
- if(rsc->props.mDebugMaxThreads) {
- cpu = rsc->props.mDebugMaxThreads;
- }
- if (cpu < 2) {
- cpu = 0;
- }
- ALOGV("%p Launching thread(s), CPUs %i", rsc, cpu);
-
- dc->mWorkers.mCount = (uint32_t)cpu;
- dc->mWorkers.mThreadId = (pthread_t *) calloc(dc->mWorkers.mCount, sizeof(pthread_t));
- dc->mWorkers.mNativeThreadId = (pid_t *) calloc(dc->mWorkers.mCount, sizeof(pid_t));
- dc->mWorkers.mLaunchSignals = new Signal[dc->mWorkers.mCount];
- dc->mWorkers.mLaunchCallback = NULL;
-
- dc->mWorkers.mCompleteSignal.init();
-
- android_atomic_release_store(dc->mWorkers.mCount, &dc->mWorkers.mRunningCount);
- android_atomic_release_store(0, &dc->mWorkers.mLaunchCount);
-
- pthread_attr_t threadAttr;
- status = pthread_attr_init(&threadAttr);
- if (status) {
- ALOGE("Failed to init thread attribute.");
- return false;
- }
-
- for (uint32_t ct=0; ct < dc->mWorkers.mCount; ct++) {
- status = pthread_create(&dc->mWorkers.mThreadId[ct], &threadAttr, HelperThreadProc, rsc);
- if (status) {
- dc->mWorkers.mCount = ct;
- ALOGE("Created fewer than expected number of RS threads.");
- break;
- }
- }
- while (android_atomic_acquire_load(&dc->mWorkers.mRunningCount) != 0) {
- usleep(100);
- }
-
- pthread_attr_destroy(&threadAttr);
- return true;
-}
-
-
-void SetPriority(const Context *rsc, int32_t priority) {
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
- for (uint32_t ct=0; ct < dc->mWorkers.mCount; ct++) {
- setpriority(PRIO_PROCESS, dc->mWorkers.mNativeThreadId[ct], priority);
- }
- if (dc->mHasGraphics) {
- //rsdGLSetPriority(rsc, priority);
- }
-}
-
-void Shutdown(Context *rsc) {
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
-
- dc->mExit = true;
- dc->mWorkers.mLaunchData = NULL;
- dc->mWorkers.mLaunchCallback = NULL;
- android_atomic_release_store(dc->mWorkers.mCount, &dc->mWorkers.mRunningCount);
- for (uint32_t ct = 0; ct < dc->mWorkers.mCount; ct++) {
- dc->mWorkers.mLaunchSignals[ct].set();
- }
- void *res;
- for (uint32_t ct = 0; ct < dc->mWorkers.mCount; ct++) {
- pthread_join(dc->mWorkers.mThreadId[ct], &res);
- }
- rsAssert(android_atomic_acquire_load(&dc->mWorkers.mRunningCount) == 0);
-
- // Global structure cleanup.
- pthread_mutex_lock(&rsdgInitMutex);
- --rsdgThreadTLSKeyCount;
- if (!rsdgThreadTLSKeyCount) {
- pthread_key_delete(rsdgThreadTLSKey);
- }
- pthread_mutex_unlock(&rsdgInitMutex);
-
-}
-
diff --git a/renderscript/v8/rs_support/driver/rsdCore.h b/renderscript/v8/rs_support/driver/rsdCore.h
deleted file mode 100644
index 6b844e9..0000000
--- a/renderscript/v8/rs_support/driver/rsdCore.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2011-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef RSD_CORE_H
-#define RSD_CORE_H
-
-#include <rs_hal.h>
-
-#include "rsMutex.h"
-#include "rsSignal.h"
-
-typedef void (* InvokeFunc_t)(void);
-typedef void (* ForEachFunc_t)(void);
-typedef int (* RootFunc_t)(void);
-
-typedef void (*WorkerCallback_t)(void *usr, uint32_t idx);
-
-typedef struct RsdSymbolTableRec {
- const char * mName;
- void * mPtr;
- bool threadable;
-} RsdSymbolTable;
-
-typedef struct ScriptTLSStructRec {
- android::renderscript::Context * mContext;
- android::renderscript::Script * mScript;
-} ScriptTLSStruct;
-
-typedef struct RsdHalRec {
- uint32_t version_major;
- uint32_t version_minor;
- bool mHasGraphics;
- bool mInForEach;
-
- struct Workers {
- volatile int mRunningCount;
- volatile int mLaunchCount;
- uint32_t mCount;
- pthread_t *mThreadId;
- pid_t *mNativeThreadId;
- android::renderscript::Signal mCompleteSignal;
-
- android::renderscript::Signal *mLaunchSignals;
- WorkerCallback_t mLaunchCallback;
- void *mLaunchData;
- };
- Workers mWorkers;
- bool mExit;
-
- ScriptTLSStruct mTlsStruct;
-
- //RsdGL gl;
-} RsdHal;
-
-extern pthread_key_t rsdgThreadTLSKey;
-extern uint32_t rsdgThreadTLSKeyCount;
-extern pthread_mutex_t rsdgInitMutex;
-
-
-void rsdLaunchThreads(android::renderscript::Context *rsc, WorkerCallback_t cbk, void *data);
-
-#endif
-
diff --git a/renderscript/v8/rs_support/driver/rsdIntrinsicBlend.cpp b/renderscript/v8/rs_support/driver/rsdIntrinsicBlend.cpp
deleted file mode 100644
index 22ad108..0000000
--- a/renderscript/v8/rs_support/driver/rsdIntrinsicBlend.cpp
+++ /dev/null
@@ -1,459 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include "rsdCore.h"
-#include "rsdIntrinsics.h"
-#include "rsdAllocation.h"
-
-#include "rsdIntrinsicInlines.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-struct ConvolveParams {
- float f[4];
-};
-
-
-enum {
- BLEND_CLEAR = 0,
- BLEND_SRC = 1,
- BLEND_DST = 2,
- BLEND_SRC_OVER = 3,
- BLEND_DST_OVER = 4,
- BLEND_SRC_IN = 5,
- BLEND_DST_IN = 6,
- BLEND_SRC_OUT = 7,
- BLEND_DST_OUT = 8,
- BLEND_SRC_ATOP = 9,
- BLEND_DST_ATOP = 10,
- BLEND_XOR = 11,
-
- BLEND_NORMAL = 12,
- BLEND_AVERAGE = 13,
- BLEND_MULTIPLY = 14,
- BLEND_SCREEN = 15,
- BLEND_DARKEN = 16,
- BLEND_LIGHTEN = 17,
- BLEND_OVERLAY = 18,
- BLEND_HARDLIGHT = 19,
- BLEND_SOFTLIGHT = 20,
- BLEND_DIFFERENCE = 21,
- BLEND_NEGATION = 22,
- BLEND_EXCLUSION = 23,
- BLEND_COLOR_DODGE = 24,
- BLEND_INVERSE_COLOR_DODGE = 25,
- BLEND_SOFT_DODGE = 26,
- BLEND_COLOR_BURN = 27,
- BLEND_INVERSE_COLOR_BURN = 28,
- BLEND_SOFT_BURN = 29,
- BLEND_REFLECT = 30,
- BLEND_GLOW = 31,
- BLEND_FREEZE = 32,
- BLEND_HEAT = 33,
- BLEND_ADD = 34,
- BLEND_SUBTRACT = 35,
- BLEND_STAMP = 36,
- BLEND_RED = 37,
- BLEND_GREEN = 38,
- BLEND_BLUE = 39,
- BLEND_HUE = 40,
- BLEND_SATURATION = 41,
- BLEND_COLOR = 42,
- BLEND_LUMINOSITY = 43
-};
-
-extern "C" void rsdIntrinsicBlendSrcOver_K(void *dst, const void *src, uint32_t count8);
-extern "C" void rsdIntrinsicBlendDstOver_K(void *dst, const void *src, uint32_t count8);
-extern "C" void rsdIntrinsicBlendSrcIn_K(void *dst, const void *src, uint32_t count8);
-extern "C" void rsdIntrinsicBlendDstIn_K(void *dst, const void *src, uint32_t count8);
-extern "C" void rsdIntrinsicBlendSrcOut_K(void *dst, const void *src, uint32_t count8);
-extern "C" void rsdIntrinsicBlendDstOut_K(void *dst, const void *src, uint32_t count8);
-extern "C" void rsdIntrinsicBlendSrcAtop_K(void *dst, const void *src, uint32_t count8);
-extern "C" void rsdIntrinsicBlendDstAtop_K(void *dst, const void *src, uint32_t count8);
-extern "C" void rsdIntrinsicBlendXor_K(void *dst, const void *src, uint32_t count8);
-extern "C" void rsdIntrinsicBlendMultiply_K(void *dst, const void *src, uint32_t count8);
-extern "C" void rsdIntrinsicBlendAdd_K(void *dst, const void *src, uint32_t count8);
-extern "C" void rsdIntrinsicBlendSub_K(void *dst, const void *src, uint32_t count8);
-
-//#undef ARCH_ARM_HAVE_NEON
-
-static void ColorMatrix_uchar4(const RsForEachStubParamStruct *p,
- uint32_t xstart, uint32_t xend,
- uint32_t instep, uint32_t outstep) {
- ConvolveParams *cp = (ConvolveParams *)p->usr;
-
- // instep/outstep can be ignored--sizeof(uchar4) known at compile time
- uchar4 *out = (uchar4 *)p->out;
- uchar4 *in = (uchar4 *)p->in;
- uint32_t x1 = xstart;
- uint32_t x2 = xend;
-
- in += xstart;
- out += xstart;
-
- switch (p->slot) {
- case BLEND_CLEAR:
- for (;x1 < x2; x1++, out++) {
- *out = 0;
- }
- break;
- case BLEND_SRC:
- for (;x1 < x2; x1++, out++, in++) {
- *out = *in;
- }
- break;
- //BLEND_DST is a NOP
- case BLEND_DST:
- break;
- case BLEND_SRC_OVER:
-#if defined(ARCH_ARM_HAVE_NEON)
- if((x1 + 8) < x2) {
- uint32_t len = (x2 - x1) >> 3;
- rsdIntrinsicBlendSrcOver_K(out, in, len);
- x1 += len << 3;
- out += len << 3;
- in += len << 3;
- }
-#endif
- for (;x1 < x2; x1++, out++, in++) {
- short4 in_s = convert_short4(*in);
- short4 out_s = convert_short4(*out);
- in_s = in_s + ((out_s * (short4)(255 - in_s.a)) >> (short4)8);
- *out = convert_uchar4(in_s);
- }
- break;
- case BLEND_DST_OVER:
-#if defined(ARCH_ARM_HAVE_NEON)
- if((x1 + 8) < x2) {
- uint32_t len = (x2 - x1) >> 3;
- rsdIntrinsicBlendDstOver_K(out, in, len);
- x1 += len << 3;
- out += len << 3;
- in += len << 3;
- }
-#endif
- for (;x1 < x2; x1++, out++, in++) {
- short4 in_s = convert_short4(*in);
- short4 out_s = convert_short4(*out);
- in_s = out_s + ((in_s * (short4)(255 - out_s.a)) >> (short4)8);
- *out = convert_uchar4(in_s);
- }
- break;
- case BLEND_SRC_IN:
-#if defined(ARCH_ARM_HAVE_NEON)
- if((x1 + 8) < x2) {
- uint32_t len = (x2 - x1) >> 3;
- rsdIntrinsicBlendSrcIn_K(out, in, len);
- x1 += len << 3;
- out += len << 3;
- in += len << 3;
- }
-#endif
- for (;x1 < x2; x1++, out++, in++) {
- short4 in_s = convert_short4(*in);
- in_s = (in_s * out->a) >> (short4)8;
- *out = convert_uchar4(in_s);
- }
- break;
- case BLEND_DST_IN:
-#if defined(ARCH_ARM_HAVE_NEON)
- if((x1 + 8) < x2) {
- uint32_t len = (x2 - x1) >> 3;
- rsdIntrinsicBlendDstIn_K(out, in, len);
- x1 += len << 3;
- out += len << 3;
- in += len << 3;
- }
-#endif
- for (;x1 < x2; x1++, out++, in++) {
- short4 out_s = convert_short4(*out);
- out_s = (out_s * in->a) >> (short4)8;
- *out = convert_uchar4(out_s);
- }
- break;
- case BLEND_SRC_OUT:
-#if defined(ARCH_ARM_HAVE_NEON)
- if((x1 + 8) < x2) {
- uint32_t len = (x2 - x1) >> 3;
- rsdIntrinsicBlendSrcOut_K(out, in, len);
- x1 += len << 3;
- out += len << 3;
- in += len << 3;
- }
-#endif
- for (;x1 < x2; x1++, out++, in++) {
- short4 in_s = convert_short4(*in);
- in_s = (in_s * (short4)(255 - out->a)) >> (short4)8;
- *out = convert_uchar4(in_s);
- }
- break;
- case BLEND_DST_OUT:
-#if defined(ARCH_ARM_HAVE_NEON)
- if((x1 + 8) < x2) {
- uint32_t len = (x2 - x1) >> 3;
- rsdIntrinsicBlendDstOut_K(out, in, len);
- x1 += len << 3;
- out += len << 3;
- in += len << 3;
- }
-#endif
- for (;x1 < x2; x1++, out++, in++) {
- short4 out_s = convert_short4(*out);
- out_s = (out_s * (short4)(255 - in->a)) >> (short4)8;
- *out = convert_uchar4(out_s);
- }
- break;
- case BLEND_SRC_ATOP:
-#if defined(ARCH_ARM_HAVE_NEON)
- if((x1 + 8) < x2) {
- uint32_t len = (x2 - x1) >> 3;
- rsdIntrinsicBlendSrcAtop_K(out, in, len);
- x1 += len << 3;
- out += len << 3;
- in += len << 3;
- }
-#endif
- for (;x1 < x2; x1++, out++, in++) {
- short4 in_s = convert_short4(*in);
- short4 out_s = convert_short4(*out);
- out_s.rgb = ((in_s.rgb * out_s.a) +
- (out_s.rgb * ((short3)255 - (short3)in_s.a))) >> (short3)8;
- *out = convert_uchar4(out_s);
- }
- break;
- case BLEND_DST_ATOP:
-#if defined(ARCH_ARM_HAVE_NEON)
- if((x1 + 8) < x2) {
- uint32_t len = (x2 - x1) >> 3;
- rsdIntrinsicBlendDstAtop_K(out, in, len);
- x1 += len << 3;
- out += len << 3;
- in += len << 3;
- }
-#endif
- for (;x1 < x2; x1++, out++, in++) {
- short4 in_s = convert_short4(*in);
- short4 out_s = convert_short4(*out);
- out_s.rgb = ((out_s.rgb * in_s.a) +
- (in_s.rgb * ((short3)255 - (short3)out_s.a))) >> (short3)8;
- *out = convert_uchar4(out_s);
- }
- break;
- case BLEND_XOR:
-#if defined(ARCH_ARM_HAVE_NEON)
- if((x1 + 8) < x2) {
- uint32_t len = (x2 - x1) >> 3;
- rsdIntrinsicBlendXor_K(out, in, len);
- x1 += len << 3;
- out += len << 3;
- in += len << 3;
- }
-#endif
- for (;x1 < x2; x1++, out++, in++) {
- *out = *in ^ *out;
- }
- break;
- case BLEND_NORMAL:
- ALOGE("Called unimplemented blend intrinsic BLEND_NORMAL");
- rsAssert(false);
- break;
- case BLEND_AVERAGE:
- ALOGE("Called unimplemented blend intrinsic BLEND_AVERAGE");
- rsAssert(false);
- break;
- case BLEND_MULTIPLY:
-#if defined(ARCH_ARM_HAVE_NEON)
- if((x1 + 8) < x2) {
- uint32_t len = (x2 - x1) >> 3;
- rsdIntrinsicBlendMultiply_K(out, in, len);
- x1 += len << 3;
- out += len << 3;
- in += len << 3;
- }
-#endif
- for (;x1 < x2; x1++, out++, in++) {
- *out = convert_uchar4((convert_short4(*in) * convert_short4(*out))
- >> (short4)8);
- }
- break;
- case BLEND_SCREEN:
- ALOGE("Called unimplemented blend intrinsic BLEND_SCREEN");
- rsAssert(false);
- break;
- case BLEND_DARKEN:
- ALOGE("Called unimplemented blend intrinsic BLEND_DARKEN");
- rsAssert(false);
- break;
- case BLEND_LIGHTEN:
- ALOGE("Called unimplemented blend intrinsic BLEND_LIGHTEN");
- rsAssert(false);
- break;
- case BLEND_OVERLAY:
- ALOGE("Called unimplemented blend intrinsic BLEND_OVERLAY");
- rsAssert(false);
- break;
- case BLEND_HARDLIGHT:
- ALOGE("Called unimplemented blend intrinsic BLEND_HARDLIGHT");
- rsAssert(false);
- break;
- case BLEND_SOFTLIGHT:
- ALOGE("Called unimplemented blend intrinsic BLEND_SOFTLIGHT");
- rsAssert(false);
- break;
- case BLEND_DIFFERENCE:
- ALOGE("Called unimplemented blend intrinsic BLEND_DIFFERENCE");
- rsAssert(false);
- break;
- case BLEND_NEGATION:
- ALOGE("Called unimplemented blend intrinsic BLEND_NEGATION");
- rsAssert(false);
- break;
- case BLEND_EXCLUSION:
- ALOGE("Called unimplemented blend intrinsic BLEND_EXCLUSION");
- rsAssert(false);
- break;
- case BLEND_COLOR_DODGE:
- ALOGE("Called unimplemented blend intrinsic BLEND_COLOR_DODGE");
- rsAssert(false);
- break;
- case BLEND_INVERSE_COLOR_DODGE:
- ALOGE("Called unimplemented blend intrinsic BLEND_INVERSE_COLOR_DODGE");
- rsAssert(false);
- break;
- case BLEND_SOFT_DODGE:
- ALOGE("Called unimplemented blend intrinsic BLEND_SOFT_DODGE");
- rsAssert(false);
- break;
- case BLEND_COLOR_BURN:
- ALOGE("Called unimplemented blend intrinsic BLEND_COLOR_BURN");
- rsAssert(false);
- break;
- case BLEND_INVERSE_COLOR_BURN:
- ALOGE("Called unimplemented blend intrinsic BLEND_INVERSE_COLOR_BURN");
- rsAssert(false);
- break;
- case BLEND_SOFT_BURN:
- ALOGE("Called unimplemented blend intrinsic BLEND_SOFT_BURN");
- rsAssert(false);
- break;
- case BLEND_REFLECT:
- ALOGE("Called unimplemented blend intrinsic BLEND_REFLECT");
- rsAssert(false);
- break;
- case BLEND_GLOW:
- ALOGE("Called unimplemented blend intrinsic BLEND_GLOW");
- rsAssert(false);
- break;
- case BLEND_FREEZE:
- ALOGE("Called unimplemented blend intrinsic BLEND_FREEZE");
- rsAssert(false);
- break;
- case BLEND_HEAT:
- ALOGE("Called unimplemented blend intrinsic BLEND_HEAT");
- rsAssert(false);
- break;
- case BLEND_ADD:
-#if defined(ARCH_ARM_HAVE_NEON)
- if((x1 + 8) < x2) {
- uint32_t len = (x2 - x1) >> 3;
- rsdIntrinsicBlendAdd_K(out, in, len);
- x1 += len << 3;
- out += len << 3;
- in += len << 3;
- }
-#endif
- for (;x1 < x2; x1++, out++, in++) {
- uint32_t iR = in->r, iG = in->g, iB = in->b, iA = in->a,
- oR = out->r, oG = out->g, oB = out->b, oA = out->a;
- out->r = (oR + iR) > 255 ? 255 : oR + iR;
- out->g = (oG + iG) > 255 ? 255 : oG + iG;
- out->b = (oB + iB) > 255 ? 255 : oB + iB;
- out->a = (oA + iA) > 255 ? 255 : oA + iA;
- }
- break;
- case BLEND_SUBTRACT:
-#if defined(ARCH_ARM_HAVE_NEON)
- if((x1 + 8) < x2) {
- uint32_t len = (x2 - x1) >> 3;
- rsdIntrinsicBlendSub_K(out, in, len);
- x1 += len << 3;
- out += len << 3;
- in += len << 3;
- }
-#endif
- for (;x1 < x2; x1++, out++, in++) {
- int32_t iR = in->r, iG = in->g, iB = in->b, iA = in->a,
- oR = out->r, oG = out->g, oB = out->b, oA = out->a;
- out->r = (oR - iR) < 0 ? 0 : oR - iR;
- out->g = (oG - iG) < 0 ? 0 : oG - iG;
- out->b = (oB - iB) < 0 ? 0 : oB - iB;
- out->a = (oA - iA) < 0 ? 0 : oA - iA;
- }
- break;
- case BLEND_STAMP:
- ALOGE("Called unimplemented blend intrinsic BLEND_STAMP");
- rsAssert(false);
- break;
- case BLEND_RED:
- ALOGE("Called unimplemented blend intrinsic BLEND_RED");
- rsAssert(false);
- break;
- case BLEND_GREEN:
- ALOGE("Called unimplemented blend intrinsic BLEND_GREEN");
- rsAssert(false);
- break;
- case BLEND_BLUE:
- ALOGE("Called unimplemented blend intrinsic BLEND_BLUE");
- rsAssert(false);
- break;
- case BLEND_HUE:
- ALOGE("Called unimplemented blend intrinsic BLEND_HUE");
- rsAssert(false);
- break;
- case BLEND_SATURATION:
- ALOGE("Called unimplemented blend intrinsic BLEND_SATURATION");
- rsAssert(false);
- break;
- case BLEND_COLOR:
- ALOGE("Called unimplemented blend intrinsic BLEND_COLOR");
- rsAssert(false);
- break;
- case BLEND_LUMINOSITY:
- ALOGE("Called unimplemented blend intrinsic BLEND_LUMINOSITY");
- rsAssert(false);
- break;
-
- default:
- ALOGE("Called unimplemented value %d", p->slot);
- rsAssert(false);
-
- }
-}
-
-void * rsdIntrinsic_InitBlend(const android::renderscript::Context *dc,
- android::renderscript::Script *script,
- RsdIntriniscFuncs_t *funcs) {
-
- script->mHal.info.exportedVariableCount = 0;
- funcs->root = ColorMatrix_uchar4;
-
- ConvolveParams *cp = (ConvolveParams *)calloc(1, sizeof(ConvolveParams));
- return cp;
-}
-
-
diff --git a/renderscript/v8/rs_support/driver/rsdIntrinsicBlur.cpp b/renderscript/v8/rs_support/driver/rsdIntrinsicBlur.cpp
deleted file mode 100644
index c394cc0..0000000
--- a/renderscript/v8/rs_support/driver/rsdIntrinsicBlur.cpp
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include "rsdCore.h"
-#include "rsdIntrinsics.h"
-#include "rsdAllocation.h"
-
-#include "rsdIntrinsicInlines.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-struct ConvolveParams {
- float fp[104];
- short ip[104];
- float radius;
- int iradius;
- ObjectBaseRef<Allocation> alloc;
-};
-
-static void ComputeGaussianWeights(ConvolveParams *cp) {
- // Compute gaussian weights for the blur
- // e is the euler's number
- float e = 2.718281828459045f;
- float pi = 3.1415926535897932f;
- // g(x) = ( 1 / sqrt( 2 * pi ) * sigma) * e ^ ( -x^2 / 2 * sigma^2 )
- // x is of the form [-radius .. 0 .. radius]
- // and sigma varies with radius.
- // Based on some experimental radius values and sigma's
- // we approximately fit sigma = f(radius) as
- // sigma = radius * 0.4 + 0.6
- // The larger the radius gets, the more our gaussian blur
- // will resemble a box blur since with large sigma
- // the gaussian curve begins to lose its shape
- float sigma = 0.4f * cp->radius + 0.6f;
-
- // Now compute the coefficients. We will store some redundant values to save
- // some math during the blur calculations precompute some values
- float coeff1 = 1.0f / (sqrtf(2.0f * pi) * sigma);
- float coeff2 = - 1.0f / (2.0f * sigma * sigma);
-
- float normalizeFactor = 0.0f;
- float floatR = 0.0f;
- int r;
- cp->iradius = (float)ceil(cp->radius) + 0.5f;
- for (r = -cp->iradius; r <= cp->iradius; r ++) {
- floatR = (float)r;
- cp->fp[r + cp->iradius] = coeff1 * powf(e, floatR * floatR * coeff2);
- normalizeFactor += cp->fp[r + cp->iradius];
- }
-
- //Now we need to normalize the weights because all our coefficients need to add up to one
- normalizeFactor = 1.0f / normalizeFactor;
- for (r = -cp->iradius; r <= cp->iradius; r ++) {
- cp->fp[r + cp->iradius] *= normalizeFactor;
- cp->ip[r + cp->iradius] = (short)(cp->ip[r + cp->iradius] * 32768);
- }
-}
-
-static void Blur_Bind(const Context *dc, const Script *script,
- void * intrinsicData, uint32_t slot, Allocation *data) {
- ConvolveParams *cp = (ConvolveParams *)intrinsicData;
- rsAssert(slot == 1);
- cp->alloc.set(data);
-}
-
-static void Blur_SetVar(const Context *dc, const Script *script, void * intrinsicData,
- uint32_t slot, void *data, size_t dataLength) {
- ConvolveParams *cp = (ConvolveParams *)intrinsicData;
- rsAssert(slot == 0);
-
- cp->radius = ((const float *)data)[0];
- ComputeGaussianWeights(cp);
-}
-
-
-
-static void OneV(const RsForEachStubParamStruct *p, float4 *out, int32_t x, int32_t y,
- const uchar *ptrIn, int iStride, const float* gPtr, int iradius) {
-
- const uchar *pi = ptrIn + x*4;
-
- float4 blurredPixel = 0;
- for (int r = -iradius; r <= iradius; r ++) {
- int validY = rsMax((y + r), 0);
- validY = rsMin(validY, (int)(p->dimY - 1));
- const uchar4 *pvy = (const uchar4 *)&pi[validY * iStride];
- float4 pf = convert_float4(pvy[0]);
- blurredPixel += pf * gPtr[0];
- gPtr++;
- }
-
- out->xyzw = blurredPixel;
-}
-
-extern "C" void rsdIntrinsicBlurVF_K(void *dst, const void *pin, int stride, const void *gptr, int rct, int x1, int x2);
-extern "C" void rsdIntrinsicBlurHF_K(void *dst, const void *pin, const void *gptr, int rct, int x1, int x2);
-
-static void OneVF(float4 *out,
- const uchar *ptrIn, int iStride, const float* gPtr, int ct,
- int x1, int x2) {
-
-#if defined(ARCH_ARM_HAVE_NEON)
- {
- int t = (x2 - x1);
- t &= ~1;
- if(t) {
- rsdIntrinsicBlurVF_K(out, ptrIn, iStride, gPtr, ct, x1, x1 + t);
- }
- x1 += t;
- }
-#endif
-
- while(x2 > x1) {
- const uchar *pi = ptrIn + x1 * 4;
- float4 blurredPixel = 0;
- const float* gp = gPtr;
-
- for (int r = 0; r < ct; r++) {
- float4 pf = convert_float4(((const uchar4 *)pi)[0]);
- blurredPixel += pf * gp[0];
- pi += iStride;
- gp++;
- }
- out->xyzw = blurredPixel;
- x1++;
- out++;
- }
-}
-
-static void OneH(const RsForEachStubParamStruct *p, uchar4 *out, int32_t x,
- const float4 *ptrIn, const float* gPtr, int iradius) {
-
- float4 blurredPixel = 0;
- for (int r = -iradius; r <= iradius; r ++) {
- int validX = rsMax((x + r), 0);
- validX = rsMin(validX, (int)(p->dimX - 1));
- float4 pf = ptrIn[validX];
- blurredPixel += pf * gPtr[0];
- gPtr++;
- }
-
- out->xyzw = convert_uchar4(blurredPixel);
-}
-
-
-static void Blur_uchar4(const RsForEachStubParamStruct *p,
- uint32_t xstart, uint32_t xend,
- uint32_t instep, uint32_t outstep) {
- float buf[4 * 2048];
- ConvolveParams *cp = (ConvolveParams *)p->usr;
- DrvAllocation *din = (DrvAllocation *)cp->alloc->mHal.drv;
- const uchar *pin = (const uchar *)din->lod[0].mallocPtr;
-
- uchar4 *out = (uchar4 *)p->out;
- uint32_t x1 = xstart;
- uint32_t x2 = xend;
-
- float4 *fout = (float4 *)buf;
- int y = p->y;
- if ((y > cp->iradius) && (y < ((int)p->dimY - cp->iradius))) {
- const uchar *pi = pin + (y - cp->iradius) * din->lod[0].stride;
- OneVF(fout, pi, din->lod[0].stride, cp->fp, cp->iradius * 2 + 1, x1, x2);
- } else {
- while(x2 > x1) {
- OneV(p, fout, x1, y, pin, din->lod[0].stride, cp->fp, cp->iradius);
- fout++;
- x1++;
- }
- }
-
- x1 = xstart;
- while ((x1 < (uint32_t)cp->iradius) && (x1 < x2)) {
- OneH(p, out, x1, (float4 *)buf, cp->fp, cp->iradius);
- out++;
- x1++;
- }
-#if defined(ARCH_ARM_HAVE_NEON)
- if ((x1 + cp->iradius) < x2) {
- rsdIntrinsicBlurHF_K(out, ((float4 *)buf) - cp->iradius, cp->fp, cp->iradius * 2 + 1, x1, x2 - cp->iradius);
- out += (x2 - cp->iradius) - x1;
- x1 = x2 - cp->iradius;
- }
-#endif
- while(x2 > x1) {
- OneH(p, out, x1, (float4 *)buf, cp->fp, cp->iradius);
- out++;
- x1++;
- }
-
-}
-
-void * rsdIntrinsic_InitBlur(const android::renderscript::Context *dc,
- android::renderscript::Script *script,
- RsdIntriniscFuncs_t *funcs) {
-
- script->mHal.info.exportedVariableCount = 2;
- funcs->bind = Blur_Bind;
- funcs->setVar = Blur_SetVar;
- funcs->root = Blur_uchar4;
-
- ConvolveParams *cp = (ConvolveParams *)calloc(1, sizeof(ConvolveParams));
- cp->radius = 5;
- ComputeGaussianWeights(cp);
- return cp;
-}
-
-
diff --git a/renderscript/v8/rs_support/driver/rsdIntrinsicColorMatrix.cpp b/renderscript/v8/rs_support/driver/rsdIntrinsicColorMatrix.cpp
deleted file mode 100644
index 8f6c70c..0000000
--- a/renderscript/v8/rs_support/driver/rsdIntrinsicColorMatrix.cpp
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include "rsdCore.h"
-#include "rsdIntrinsics.h"
-#include "rsdAllocation.h"
-
-#include "rsdIntrinsicInlines.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-struct ConvolveParams {
- float fp[16];
- short ip[16];
- bool use3x3;
- bool useDot;
-};
-
-static void ColorMatrix_SetVar(const Context *dc, const Script *script, void * intrinsicData,
- uint32_t slot, void *data, size_t dataLength) {
- ConvolveParams *cp = (ConvolveParams *)intrinsicData;
-
- rsAssert(slot == 0);
- memcpy (cp->fp, data, dataLength);
- for(int ct=0; ct < 16; ct++) {
- cp->ip[ct] = (short)(cp->fp[ct] * 255.f + 0.5f);
- }
-
- if ((cp->ip[3] == 0) && (cp->ip[7] == 0) && (cp->ip[11] == 0) &&
- (cp->ip[12] == 0) && (cp->ip[13] == 0) && (cp->ip[14] == 0) &&
- (cp->ip[15] == 255)) {
- cp->use3x3 = true;
-
- if ((cp->ip[0] == cp->ip[1]) && (cp->ip[0] == cp->ip[2]) &&
- (cp->ip[4] == cp->ip[5]) && (cp->ip[4] == cp->ip[6]) &&
- (cp->ip[8] == cp->ip[9]) && (cp->ip[8] == cp->ip[10])) {
- cp->useDot = true;
- }
- }
-}
-
-extern "C" void rsdIntrinsicColorMatrix4x4_K(void *dst, const void *src, const short *coef, uint32_t count);
-extern "C" void rsdIntrinsicColorMatrix3x3_K(void *dst, const void *src, const short *coef, uint32_t count);
-extern "C" void rsdIntrinsicColorMatrixDot_K(void *dst, const void *src, const short *coef, uint32_t count);
-
-static void One(const RsForEachStubParamStruct *p, uchar4 *out,
- const uchar4 *py, const float* coeff) {
- float4 i = convert_float4(py[0]);
-
- float4 sum;
- sum.x = i.x * coeff[0] +
- i.y * coeff[4] +
- i.z * coeff[8] +
- i.w * coeff[12];
- sum.y = i.x * coeff[1] +
- i.y * coeff[5] +
- i.z * coeff[9] +
- i.w * coeff[13];
- sum.z = i.x * coeff[2] +
- i.y * coeff[6] +
- i.z * coeff[10] +
- i.w * coeff[14];
- sum.w = i.x * coeff[3] +
- i.y * coeff[7] +
- i.z * coeff[11] +
- i.w * coeff[15];
-
- sum.x = sum.x < 0 ? 0 : (sum.x > 255 ? 255 : sum.x);
- sum.y = sum.y < 0 ? 0 : (sum.y > 255 ? 255 : sum.y);
- sum.z = sum.z < 0 ? 0 : (sum.z > 255 ? 255 : sum.z);
- sum.w = sum.w < 0 ? 0 : (sum.w > 255 ? 255 : sum.w);
-
- *out = convert_uchar4(sum);
-}
-
-static void ColorMatrix_uchar4(const RsForEachStubParamStruct *p,
- uint32_t xstart, uint32_t xend,
- uint32_t instep, uint32_t outstep) {
- ConvolveParams *cp = (ConvolveParams *)p->usr;
- uchar4 *out = (uchar4 *)p->out;
- uchar4 *in = (uchar4 *)p->in;
- uint32_t x1 = xstart;
- uint32_t x2 = xend;
-
- in += xstart;
- out += xstart;
-
- if(x2 > x1) {
-#if defined(ARCH_ARM_HAVE_NEON)
- int32_t len = (x2 - x1) >> 2;
- if(len > 0) {
- if (cp->use3x3) {
- if (cp->useDot) {
- rsdIntrinsicColorMatrixDot_K(out, in, cp->ip, len);
- } else {
- rsdIntrinsicColorMatrix3x3_K(out, in, cp->ip, len);
- }
- } else {
- rsdIntrinsicColorMatrix4x4_K(out, in, cp->ip, len);
- }
- x1 += len << 2;
- out += len << 2;
- in += len << 2;
- }
-#endif
-
- while(x1 != x2) {
- One(p, out++, in++, cp->fp);
- x1++;
- }
- }
-}
-
-void * rsdIntrinsic_InitColorMatrix(const android::renderscript::Context *dc,
- android::renderscript::Script *script,
- RsdIntriniscFuncs_t *funcs) {
-
- script->mHal.info.exportedVariableCount = 1;
- funcs->setVar = ColorMatrix_SetVar;
- funcs->root = ColorMatrix_uchar4;
-
- ConvolveParams *cp = (ConvolveParams *)calloc(1, sizeof(ConvolveParams));
- cp->fp[0] = 1.f;
- cp->fp[5] = 1.f;
- cp->fp[10] = 1.f;
- cp->fp[15] = 1.f;
- for(int ct=0; ct < 16; ct++) {
- cp->ip[ct] = (short)(cp->fp[ct] * 255.f + 0.5f);
- }
- return cp;
-}
-
-
diff --git a/renderscript/v8/rs_support/driver/rsdIntrinsicConvolve3x3.cpp b/renderscript/v8/rs_support/driver/rsdIntrinsicConvolve3x3.cpp
deleted file mode 100644
index 8dc7977..0000000
--- a/renderscript/v8/rs_support/driver/rsdIntrinsicConvolve3x3.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include "rsdCore.h"
-#include "rsdIntrinsics.h"
-#include "rsdAllocation.h"
-
-#include "rsdIntrinsicInlines.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-struct ConvolveParams {
- float fp[16];
- short ip[16];
- ObjectBaseRef<Allocation> alloc;
-};
-
-static void Convolve3x3_Bind(const Context *dc, const Script *script,
- void * intrinsicData, uint32_t slot, Allocation *data) {
- ConvolveParams *cp = (ConvolveParams *)intrinsicData;
- rsAssert(slot == 1);
- cp->alloc.set(data);
-}
-
-static void Convolve3x3_SetVar(const Context *dc, const Script *script, void * intrinsicData,
- uint32_t slot, void *data, size_t dataLength) {
- ConvolveParams *cp = (ConvolveParams *)intrinsicData;
-
- rsAssert(slot == 0);
- memcpy (cp->fp, data, dataLength);
- for(int ct=0; ct < 9; ct++) {
- cp->ip[ct] = (short)(cp->fp[ct] * 255.f + 0.5f);
- }
-}
-
-extern "C" void rsdIntrinsicConvolve3x3_K(void *dst, const void *y0, const void *y1, const void *y2, const short *coef, uint32_t count);
-
-
-static void ConvolveOne(const RsForEachStubParamStruct *p, uint32_t x, uchar4 *out,
- const uchar4 *py0, const uchar4 *py1, const uchar4 *py2,
- const float* coeff) {
-
- uint32_t x1 = rsMax((int32_t)x-1, 0);
- uint32_t x2 = rsMin((int32_t)x+1, (int32_t)p->dimX);
-
- float4 px = convert_float4(py0[x1]) * coeff[0] +
- convert_float4(py0[x]) * coeff[1] +
- convert_float4(py0[x2]) * coeff[2] +
- convert_float4(py1[x1]) * coeff[3] +
- convert_float4(py1[x]) * coeff[4] +
- convert_float4(py1[x2]) * coeff[5] +
- convert_float4(py2[x1]) * coeff[6] +
- convert_float4(py2[x]) * coeff[7] +
- convert_float4(py2[x2]) * coeff[8];
-
- px = clamp(px, 0.f, 255.f);
- uchar4 o = {(uchar)px.x, (uchar)px.y, (uchar)px.z, (uchar)px.w};
- *out = o;
-}
-
-static void Convolve3x3_uchar4(const RsForEachStubParamStruct *p,
- uint32_t xstart, uint32_t xend,
- uint32_t instep, uint32_t outstep) {
- ConvolveParams *cp = (ConvolveParams *)p->usr;
- DrvAllocation *din = (DrvAllocation *)cp->alloc->mHal.drv;
- const uchar *pin = (const uchar *)din->lod[0].mallocPtr;
-
- uint32_t y1 = rsMin((int32_t)p->y + 1, (int32_t)(p->dimY-1));
- uint32_t y2 = rsMax((int32_t)p->y - 1, 0);
- const uchar4 *py0 = (const uchar4 *)(pin + din->lod[0].stride * y2);
- const uchar4 *py1 = (const uchar4 *)(pin + din->lod[0].stride * p->y);
- const uchar4 *py2 = (const uchar4 *)(pin + din->lod[0].stride * y1);
-
- uchar4 *out = (uchar4 *)p->out;
- uint32_t x1 = xstart;
- uint32_t x2 = xend;
- if(x1 == 0) {
- ConvolveOne(p, 0, out, py0, py1, py2, cp->fp);
- x1 ++;
- out++;
- }
-
- if(x2 > x1) {
-#if defined(ARCH_ARM_HAVE_NEON)
- int32_t len = (x2 - x1 - 1) >> 1;
- if(len > 0) {
- rsdIntrinsicConvolve3x3_K(out, &py0[x1-1], &py1[x1-1], &py2[x1-1], cp->ip, len);
- x1 += len << 1;
- out += len << 1;
- }
-#endif
-
- while(x1 != x2) {
- ConvolveOne(p, x1, out, py0, py1, py2, cp->fp);
- out++;
- x1++;
- }
- }
-}
-
-void * rsdIntrinsic_InitConvolve3x3(const android::renderscript::Context *dc,
- android::renderscript::Script *script,
- RsdIntriniscFuncs_t *funcs) {
-
- script->mHal.info.exportedVariableCount = 2;
- funcs->bind = Convolve3x3_Bind;
- funcs->setVar = Convolve3x3_SetVar;
- funcs->root = Convolve3x3_uchar4;
-
- ConvolveParams *cp = (ConvolveParams *)calloc(1, sizeof(ConvolveParams));
- for(int ct=0; ct < 9; ct++) {
- cp->fp[ct] = 1.f / 9.f;
- cp->ip[ct] = (short)(cp->fp[ct] * 255.f + 0.5f);
- }
- return cp;
-}
-
-
diff --git a/renderscript/v8/rs_support/driver/rsdIntrinsicConvolve5x5.cpp b/renderscript/v8/rs_support/driver/rsdIntrinsicConvolve5x5.cpp
deleted file mode 100644
index 2dacbec..0000000
--- a/renderscript/v8/rs_support/driver/rsdIntrinsicConvolve5x5.cpp
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include "rsdCore.h"
-#include "rsdIntrinsics.h"
-#include "rsdAllocation.h"
-
-#include "rsdIntrinsicInlines.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-struct ConvolveParams {
- float fp[28];
- short ip[28];
- ObjectBaseRef<Allocation> alloc;
-};
-
-static void Convolve5x5_Bind(const Context *dc, const Script *script,
- void * intrinsicData, uint32_t slot, Allocation *data) {
- ConvolveParams *cp = (ConvolveParams *)intrinsicData;
- rsAssert(slot == 1);
- cp->alloc.set(data);
-}
-
-static void Convolve5x5_SetVar(const Context *dc, const Script *script, void * intrinsicData,
- uint32_t slot, void *data, size_t dataLength) {
- ConvolveParams *cp = (ConvolveParams *)intrinsicData;
-
- rsAssert(slot == 0);
- memcpy (cp->fp, data, dataLength);
- for(int ct=0; ct < 25; ct++) {
- cp->ip[ct] = (short)(cp->fp[ct] * 255.f + 0.5f);
- }
-}
-
-
-static void One(const RsForEachStubParamStruct *p, uint32_t x, uchar4 *out,
- const uchar4 *py0, const uchar4 *py1, const uchar4 *py2, const uchar4 *py3, const uchar4 *py4,
- const float* coeff) {
-
- uint32_t x0 = rsMax((int32_t)x-2, 0);
- uint32_t x1 = rsMax((int32_t)x-1, 0);
- uint32_t x2 = x;
- uint32_t x3 = rsMin((int32_t)x+1, (int32_t)(p->dimX-1));
- uint32_t x4 = rsMin((int32_t)x+2, (int32_t)(p->dimX-1));
-
- float4 px = convert_float4(py0[x0]) * coeff[0] +
- convert_float4(py0[x1]) * coeff[1] +
- convert_float4(py0[x2]) * coeff[2] +
- convert_float4(py0[x3]) * coeff[3] +
- convert_float4(py0[x4]) * coeff[4] +
-
- convert_float4(py1[x0]) * coeff[5] +
- convert_float4(py1[x1]) * coeff[6] +
- convert_float4(py1[x2]) * coeff[7] +
- convert_float4(py1[x3]) * coeff[8] +
- convert_float4(py1[x4]) * coeff[9] +
-
- convert_float4(py2[x0]) * coeff[10] +
- convert_float4(py2[x1]) * coeff[11] +
- convert_float4(py2[x2]) * coeff[12] +
- convert_float4(py2[x3]) * coeff[13] +
- convert_float4(py2[x4]) * coeff[14] +
-
- convert_float4(py3[x0]) * coeff[15] +
- convert_float4(py3[x1]) * coeff[16] +
- convert_float4(py3[x2]) * coeff[17] +
- convert_float4(py3[x3]) * coeff[18] +
- convert_float4(py3[x4]) * coeff[19] +
-
- convert_float4(py4[x0]) * coeff[20] +
- convert_float4(py4[x1]) * coeff[21] +
- convert_float4(py4[x2]) * coeff[22] +
- convert_float4(py4[x3]) * coeff[23] +
- convert_float4(py4[x4]) * coeff[24];
-
- px = clamp(px, 0.f, 255.f);
- uchar4 o = {(uchar)px.x, (uchar)px.y, (uchar)px.z, (uchar)px.w};
- *out = o;
-}
-
-extern "C" void rsdIntrinsicConvolve5x5_K(void *dst, const void *y0, const void *y1,
- const void *y2, const void *y3, const void *y4,
- const short *coef, uint32_t count);
-
-static void Convolve5x5_uchar4(const RsForEachStubParamStruct *p,
- uint32_t xstart, uint32_t xend,
- uint32_t instep, uint32_t outstep) {
- ConvolveParams *cp = (ConvolveParams *)p->usr;
- DrvAllocation *din = (DrvAllocation *)cp->alloc->mHal.drv;
- const uchar *pin = (const uchar *)din->lod[0].mallocPtr;
-
- uint32_t y0 = rsMax((int32_t)p->y-2, 0);
- uint32_t y1 = rsMax((int32_t)p->y-1, 0);
- uint32_t y2 = p->y;
- uint32_t y3 = rsMin((int32_t)p->y+1, (int32_t)(p->dimY-1));
- uint32_t y4 = rsMin((int32_t)p->y+2, (int32_t)(p->dimY-1));
-
- const uchar4 *py0 = (const uchar4 *)(pin + din->lod[0].stride * y0);
- const uchar4 *py1 = (const uchar4 *)(pin + din->lod[0].stride * y1);
- const uchar4 *py2 = (const uchar4 *)(pin + din->lod[0].stride * y2);
- const uchar4 *py3 = (const uchar4 *)(pin + din->lod[0].stride * y3);
- const uchar4 *py4 = (const uchar4 *)(pin + din->lod[0].stride * y4);
-
- uchar4 *out = (uchar4 *)p->out;
- uint32_t x1 = xstart;
- uint32_t x2 = xend;
-
- while((x1 < x2) && (x1 < 2)) {
- One(p, x1, out, py0, py1, py2, py3, py4, cp->fp);
- out++;
- x1++;
- }
-
-#if defined(ARCH_ARM_HAVE_NEON)
- if((x1 + 3) < x2) {
- uint32_t len = (x2 - x1 - 3) >> 1;
- rsdIntrinsicConvolve5x5_K(out, py0, py1, py2, py3, py4, cp->ip, len);
- out += len << 1;
- x1 += len << 1;
- }
-#endif
-
- while(x1 < x2) {
- One(p, x1, out, py0, py1, py2, py3, py4, cp->fp);
- out++;
- x1++;
- }
-}
-
-void * rsdIntrinsic_InitConvolve5x5(const android::renderscript::Context *dc,
- android::renderscript::Script *script,
- RsdIntriniscFuncs_t *funcs) {
-
- script->mHal.info.exportedVariableCount = 2;
- funcs->bind = Convolve5x5_Bind;
- funcs->setVar = Convolve5x5_SetVar;
- funcs->root = Convolve5x5_uchar4;
-
- ConvolveParams *cp = (ConvolveParams *)calloc(1, sizeof(ConvolveParams));
- for(int ct=0; ct < 25; ct++) {
- cp->fp[ct] = 1.f / 25.f;
- cp->ip[ct] = (short)(cp->fp[ct] * 255.f + 0.5f);
- }
- return cp;
-}
-
-
diff --git a/renderscript/v8/rs_support/driver/rsdIntrinsicInlines.h b/renderscript/v8/rs_support/driver/rsdIntrinsicInlines.h
deleted file mode 100644
index ab11b4f..0000000
--- a/renderscript/v8/rs_support/driver/rsdIntrinsicInlines.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-typedef uint8_t uchar;
-typedef uint16_t ushort;
-typedef uint32_t uint;
-
-typedef float float2 __attribute__((ext_vector_type(2)));
-typedef float float3 __attribute__((ext_vector_type(3)));
-typedef float float4 __attribute__((ext_vector_type(4)));
-typedef uchar uchar2 __attribute__((ext_vector_type(2)));
-typedef uchar uchar3 __attribute__((ext_vector_type(3)));
-typedef uchar uchar4 __attribute__((ext_vector_type(4)));
-typedef ushort ushort2 __attribute__((ext_vector_type(2)));
-typedef ushort ushort3 __attribute__((ext_vector_type(3)));
-typedef ushort ushort4 __attribute__((ext_vector_type(4)));
-typedef uint uint2 __attribute__((ext_vector_type(2)));
-typedef uint uint3 __attribute__((ext_vector_type(3)));
-typedef uint uint4 __attribute__((ext_vector_type(4)));
-typedef char char2 __attribute__((ext_vector_type(2)));
-typedef char char3 __attribute__((ext_vector_type(3)));
-typedef char char4 __attribute__((ext_vector_type(4)));
-typedef short short2 __attribute__((ext_vector_type(2)));
-typedef short short3 __attribute__((ext_vector_type(3)));
-typedef short short4 __attribute__((ext_vector_type(4)));
-typedef int int2 __attribute__((ext_vector_type(2)));
-typedef int int3 __attribute__((ext_vector_type(3)));
-typedef int int4 __attribute__((ext_vector_type(4)));
-typedef long long2 __attribute__((ext_vector_type(2)));
-typedef long long3 __attribute__((ext_vector_type(3)));
-typedef long long4 __attribute__((ext_vector_type(4)));
-
-enum IntrinsicEnums {
- INTRINSIC_UNDEFINED,
- INTRINSIC_CONVOLVE_3x3,
- INTRINXIC_COLORMATRIX
-
-};
-
-static inline int4 convert_int4(uchar4 i) {
- int4 f4 = {i.x, i.y, i.z, i.w};
- return f4;
-}
-
-static inline short4 convert_short4(uchar4 i) {
- short4 f4 = {i.x, i.y, i.z, i.w};
- return f4;
-}
-
-static inline float4 convert_float4(uchar4 i) {
- float4 f4 = {i.x, i.y, i.z, i.w};
- return f4;
-}
-
-static inline uchar4 convert_uchar4(short4 i) {
- uchar4 f4 = {(uchar)i.x, (uchar)i.y, (uchar)i.z, (uchar)i.w};
- return f4;
-}
-
-static inline uchar4 convert_uchar4(int4 i) {
- uchar4 f4 = {(uchar)i.x, (uchar)i.y, (uchar)i.z, (uchar)i.w};
- return f4;
-}
-
-static inline uchar4 convert_uchar4(float4 i) {
- uchar4 f4 = {(uchar)i.x, (uchar)i.y, (uchar)i.z, (uchar)i.w};
- return f4;
-}
-
-
-static inline int4 clamp(int4 amount, int low, int high) {
- int4 r;
- r.x = amount.x < low ? low : (amount.x > high ? high : amount.x);
- r.y = amount.y < low ? low : (amount.y > high ? high : amount.y);
- r.z = amount.z < low ? low : (amount.z > high ? high : amount.z);
- r.w = amount.w < low ? low : (amount.w > high ? high : amount.w);
- return r;
-}
-
-static inline float4 clamp(float4 amount, float low, float high) {
- float4 r;
- r.x = amount.x < low ? low : (amount.x > high ? high : amount.x);
- r.y = amount.y < low ? low : (amount.y > high ? high : amount.y);
- r.z = amount.z < low ? low : (amount.z > high ? high : amount.z);
- r.w = amount.w < low ? low : (amount.w > high ? high : amount.w);
- return r;
-}
-
-
diff --git a/renderscript/v8/rs_support/driver/rsdIntrinsicLUT.cpp b/renderscript/v8/rs_support/driver/rsdIntrinsicLUT.cpp
deleted file mode 100644
index 298d4d4..0000000
--- a/renderscript/v8/rs_support/driver/rsdIntrinsicLUT.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include "rsdCore.h"
-#include "rsdIntrinsics.h"
-#include "rsdAllocation.h"
-
-#include "rsdIntrinsicInlines.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-struct ConvolveParams {
- ObjectBaseRef<Allocation> lut;
-};
-
-static void LUT_Bind(const Context *dc, const Script *script,
- void * intrinsicData, uint32_t slot, Allocation *data) {
- ConvolveParams *cp = (ConvolveParams *)intrinsicData;
- rsAssert(slot == 0);
- cp->lut.set(data);
-}
-
-static void LUT_uchar4(const RsForEachStubParamStruct *p,
- uint32_t xstart, uint32_t xend,
- uint32_t instep, uint32_t outstep) {
- ConvolveParams *cp = (ConvolveParams *)p->usr;
- uchar4 *out = (uchar4 *)p->out;
- uchar4 *in = (uchar4 *)p->in;
- uint32_t x1 = xstart;
- uint32_t x2 = xend;
-
- in += xstart;
- out += xstart;
-
- DrvAllocation *din = (DrvAllocation *)cp->lut->mHal.drv;
- const uchar *tr = (const uchar *)din->lod[0].mallocPtr;
- const uchar *tg = &tr[256];
- const uchar *tb = &tg[256];
- const uchar *ta = &tb[256];
-
- while (x1 < x2) {
- uchar4 p = *in;
- uchar4 o = {tr[p.x], tg[p.y], tb[p.z], ta[p.w]};
- *out = o;
- in++;
- out++;
- x1++;
- }
-}
-
-void * rsdIntrinsic_InitLUT(const android::renderscript::Context *dc,
- android::renderscript::Script *script,
- RsdIntriniscFuncs_t *funcs) {
-
- script->mHal.info.exportedVariableCount = 1;
- funcs->bind = LUT_Bind;
- funcs->root = LUT_uchar4;
- ConvolveParams *cp = (ConvolveParams *)calloc(1, sizeof(ConvolveParams));
- return cp;
-}
-
-
diff --git a/renderscript/v8/rs_support/driver/rsdIntrinsicYuvToRGB.cpp b/renderscript/v8/rs_support/driver/rsdIntrinsicYuvToRGB.cpp
deleted file mode 100644
index 89b3d20..0000000
--- a/renderscript/v8/rs_support/driver/rsdIntrinsicYuvToRGB.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include "rsdCore.h"
-#include "rsdIntrinsics.h"
-#include "rsdAllocation.h"
-
-#include "rsdIntrinsicInlines.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-struct YuvParams {
- ObjectBaseRef<Allocation> alloc;
-};
-
-static void YuvToRGB_Bind(const Context *dc, const Script *script,
- void * intrinsicData, uint32_t slot, Allocation *data) {
- YuvParams *cp = (YuvParams *)intrinsicData;
- rsAssert(slot == 0);
- cp->alloc.set(data);
-}
-
-
-
-static uchar4 rsYuvToRGBA_uchar4(uchar y, uchar u, uchar v) {
- short Y = ((short)y) - 16;
- short U = ((short)u) - 128;
- short V = ((short)v) - 128;
-
- short4 p;
- p.r = (Y * 298 + V * 409 + 128) >> 8;
- p.g = (Y * 298 - U * 100 - V * 208 + 128) >> 8;
- p.b = (Y * 298 + U * 516 + 128) >> 8;
- p.a = 255;
- if(p.r < 0) {
- p.r = 0;
- }
- if(p.r > 255) {
- p.r = 255;
- }
- if(p.g < 0) {
- p.g = 0;
- }
- if(p.g > 255) {
- p.g = 255;
- }
- if(p.b < 0) {
- p.b = 0;
- }
- if(p.b > 255) {
- p.b = 255;
- }
-
- return (uchar4){p.r, p.g, p.b, p.a};
-}
-
-
-static short YuvCoeff[] = {
- 298, 409, -100, 516, -208, 255, 0, 0,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 128, 128, 128, 128, 128, 128, 128, 128,
- 298, 298, 298, 298, 298, 298, 298, 298,
- 255, 255, 255, 255, 255, 255, 255, 255
-
-
-};
-
-extern "C" void rsdIntrinsicYuv_K(void *dst, const uchar *Y, const uchar *uv, uint32_t count, const short *param);
-
-static void YuvToRGB_uchar4(const RsForEachStubParamStruct *p,
- uint32_t xstart, uint32_t xend,
- uint32_t instep, uint32_t outstep) {
- YuvParams *cp = (YuvParams *)p->usr;
- DrvAllocation *din = (DrvAllocation *)cp->alloc->mHal.drv;
- const uchar *pin = (const uchar *)din->lod[0].mallocPtr;
-
- const uchar *Y = pin + (p->y * p->dimX);
- const uchar *uv = pin + (p->dimX * p->dimY);
- uv += (p->y>>1) * p->dimX;
-
- uchar4 *out = (uchar4 *)p->out;
- uint32_t x1 = xstart;
- uint32_t x2 = xend;
-
- if(x2 > x1) {
-#if defined(ARCH_ARM_HAVE_NEON)
- int32_t len = (x2 - x1 - 1) >> 3;
- if(len > 0) {
- rsdIntrinsicYuv_K(out, Y, uv, len, YuvCoeff);
- x1 += len << 3;
- out += len << 3;
- }
-#endif
-
- // ALOGE("y %i %i %i", p->y, x1, x2);
- while(x1 < x2) {
- uchar u = uv[(x1 & 0xffffe) + 1];
- uchar v = uv[(x1 & 0xffffe) + 0];
- *out = rsYuvToRGBA_uchar4(Y[x1], u, v);
- out++;
- x1++;
- *out = rsYuvToRGBA_uchar4(Y[x1], u, v);
- out++;
- x1++;
- }
- }
-}
-
-void * rsdIntrinsic_InitYuvToRGB(const android::renderscript::Context *dc,
- android::renderscript::Script *script,
- RsdIntriniscFuncs_t *funcs) {
-
- script->mHal.info.exportedVariableCount = 1;
- funcs->bind = YuvToRGB_Bind;
- funcs->root = YuvToRGB_uchar4;
- YuvParams *cp = (YuvParams *)calloc(1, sizeof(YuvParams));
- return cp;
-}
-
-
diff --git a/renderscript/v8/rs_support/driver/rsdIntrinsics.cpp b/renderscript/v8/rs_support/driver/rsdIntrinsics.cpp
deleted file mode 100644
index 348bcf1..0000000
--- a/renderscript/v8/rs_support/driver/rsdIntrinsics.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include "rsdCore.h"
-#include "rsdIntrinsics.h"
-#include "rsdAllocation.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-void * rsdIntrinsic_InitBlur(const Context *, Script *, RsdIntriniscFuncs_t *);
-void * rsdIntrinsic_InitConvolve3x3(const Context *, Script *, RsdIntriniscFuncs_t *);
-void * rsdIntrinsic_InitConvolve5x5(const Context *, Script *, RsdIntriniscFuncs_t *);
-void * rsdIntrinsic_InitColorMatrix(const Context *, Script *, RsdIntriniscFuncs_t *);
-void * rsdIntrinsic_InitLUT(const Context *, Script *, RsdIntriniscFuncs_t *);
-void * rsdIntrinsic_InitYuvToRGB(const Context *, Script *, RsdIntriniscFuncs_t *);
-void * rsdIntrinsic_InitBlend(const Context *, Script *, RsdIntriniscFuncs_t *);
-
-static void Bind(const Context *, const Script *, void *, uint32_t, Allocation *) {
- rsAssert(!"Intrinsic_Bind unexpectedly called");
-}
-
-static void SetVar(const Context *, const Script *, void *, uint32_t, void *, size_t) {
- rsAssert(!"Intrinsic_Bind unexpectedly called");
-}
-
-static void Destroy(const Context *dc, const Script *script, void * intrinsicData) {
- free(intrinsicData);
-}
-
-void * rsdIntrinsic_Init(const android::renderscript::Context *dc,
- android::renderscript::Script *script,
- RsScriptIntrinsicID iid,
- RsdIntriniscFuncs_t *funcs) {
-
- funcs->bind = Bind;
- funcs->setVar = SetVar;
- funcs->destroy = Destroy;
-
- switch(iid) {
- case RS_SCRIPT_INTRINSIC_ID_CONVOLVE_3x3:
- return rsdIntrinsic_InitConvolve3x3(dc, script, funcs);
- case RS_SCRIPT_INTRINSIC_ID_CONVOLVE_5x5:
- return rsdIntrinsic_InitConvolve5x5(dc, script, funcs);
- case RS_SCRIPT_INTRINSIC_ID_COLOR_MATRIX:
- return rsdIntrinsic_InitColorMatrix(dc, script, funcs);
- case RS_SCRIPT_INTRINSIC_ID_LUT:
- return rsdIntrinsic_InitLUT(dc, script, funcs);
- case RS_SCRIPT_INTRINSIC_ID_BLUR:
- return rsdIntrinsic_InitBlur(dc, script, funcs);
- case RS_SCRIPT_INTRINSIC_ID_YUV_TO_RGB:
- return rsdIntrinsic_InitYuvToRGB(dc, script, funcs);
- case RS_SCRIPT_INTRINSIC_ID_BLEND:
- return rsdIntrinsic_InitBlend(dc, script, funcs);
-
- default:
- return NULL;
- }
- return NULL;
-}
-
-
-
diff --git a/renderscript/v8/rs_support/driver/rsdIntrinsics.h b/renderscript/v8/rs_support/driver/rsdIntrinsics.h
deleted file mode 100644
index 221a81a..0000000
--- a/renderscript/v8/rs_support/driver/rsdIntrinsics.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef RSD_INTRINSICS_H
-#define RSD_INTRINSICS_H
-
-#include <rs_hal.h>
-#include "rsdBcc.h"
-
-void * rsdIntrinsic_Init(const android::renderscript::Context *dc,
- android::renderscript::Script *script,
- RsScriptIntrinsicID id, RsdIntriniscFuncs_t *funcs);
-
-#endif // RSD_INTRINSICS_H
-
diff --git a/renderscript/v8/rs_support/driver/rsdIntrinsics_Convolve.S b/renderscript/v8/rs_support/driver/rsdIntrinsics_Convolve.S
deleted file mode 100644
index beb7d14..0000000
--- a/renderscript/v8/rs_support/driver/rsdIntrinsics_Convolve.S
+++ /dev/null
@@ -1,1527 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-#include <machine/cpu-features.h>
-#include <machine/asm.h>
-
-/*
- r0 = dst
- r1 = y0 base pointer
- r2 = y1 base pointer
- r3 = y2 base pointer
- sp = coeffs
- sp = length / 2
-*/
-
-ENTRY(rsdIntrinsicConvolve3x3_K)
- push {r4-r8, r10, r11, lr}
- vpush {q4-q7}
-
- /* Get the coeffs pointer from the stack and load the
- coefficients in the q0, q1 NEON registers */
- ldr r4, [sp, #32+64]
- vld1.16 {q0, q1}, [r4]
-
- /* Get count from the stack */
- ldr r4, [sp, #36+64]
-
- /* Load the frequently used immediate in a register */
- mov r5, #8
-
-1:
- /* Load and post-increase the address by r5=#8 */
- vld1.8 {q13}, [r1], r5
- vld1.8 {q14}, [r2], r5
- vld1.8 {q15}, [r3], r5
-
- /* Signal memory for data that will be used in the loop after the next */
- PLD (r1, r5)
- PLD (r2, r5)
- PLD (r3, r5)
-
- vmovl.u8 q2, d26
- vmovl.u8 q3, d27
- vmovl.u8 q4, d28
- vmovl.u8 q5, d29
- vmovl.u8 q6, d30
- vmovl.u8 q7, d31
-
-/*
- The two pixel source array is
- d4, d5, d6, d7
- d8, d9, d10, d11
- d12, d13, d14, d15
-*/
-
- vmull.s16 q8, d4, d0[0]
- vmlal.s16 q8, d5, d0[1]
- vmlal.s16 q8, d6, d0[2]
- vmlal.s16 q8, d8, d0[3]
- vmlal.s16 q8, d9, d1[0]
- vmlal.s16 q8, d10, d1[1]
- vmlal.s16 q8, d12, d1[2]
- vmlal.s16 q8, d13, d1[3]
- vmlal.s16 q8, d14, d2[0]
-
- vmull.s16 q9, d5, d0[0]
- vmlal.s16 q9, d6, d0[1]
- vmlal.s16 q9, d7, d0[2]
- vmlal.s16 q9, d9, d0[3]
- vmlal.s16 q9, d10, d1[0]
- vmlal.s16 q9, d11, d1[1]
- vmlal.s16 q9, d13, d1[2]
- vmlal.s16 q9, d14, d1[3]
- vmlal.s16 q9, d15, d2[0]
-
- vshrn.i32 d16, q8, #8
- vshrn.i32 d17, q9, #8
-
- vqmovun.s16 d16, q8
- vst1.8 d16, [r0]!
-
- /* Are we done yet? */
- subs r4, r4, #1
- bne 1b
-
- /* We're done, bye! */
- vpop {q4-q7}
- pop {r4-r8, r10, r11, lr}
- bx lr
-END(TestConvolveK)
-
-/*
- r0 = dst
- r1 = src
- r2 = matrix
- r3 = length
-*/
-ENTRY(rsdIntrinsicColorMatrix4x4_K)
- .save {r4, lr}
- stmfd sp!, {r4, lr}
- vpush {q4-q7}
-
- vld1.16 {q2}, [r2]!
- vld1.16 {q3}, [r2]!
-
-1:
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r1]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r1]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r1]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r1]!
-
- vmovl.u8 q12, d0 /* R */
- vmovl.u8 q13, d1 /* G */
- vmovl.u8 q14, d2 /* B */
- vmovl.u8 q15, d3 /* A */
-
- vmull.s16 q8, d24, d4[0]
- vmull.s16 q9, d24, d4[1]
- vmull.s16 q10, d24, d4[2]
- vmull.s16 q11, d24, d4[3]
-
- vmlal.s16 q8, d26, d5[0]
- vmlal.s16 q9, d26, d5[1]
- vmlal.s16 q10, d26, d5[2]
- vmlal.s16 q11, d26, d5[3]
-
- vmlal.s16 q8, d28, d6[0]
- vmlal.s16 q9, d28, d6[1]
- vmlal.s16 q10, d28, d6[2]
- vmlal.s16 q11, d28, d6[3]
-
- vmlal.s16 q8, d30, d7[0]
- vmlal.s16 q9, d30, d7[1]
- vmlal.s16 q10, d30, d7[2]
- vmlal.s16 q11, d30, d7[3]
-
- vshrn.i32 d24, q8, #8
- vshrn.i32 d26, q9, #8
- vshrn.i32 d28, q10, #8
- vshrn.i32 d30, q11, #8
-
- vqmovun.s16 d0, q12
- vqmovun.s16 d1, q13
- vqmovun.s16 d2, q14
- vqmovun.s16 d3, q15
-
- vst4.8 {d0[0],d1[0],d2[0],d3[0]}, [r0]!
- vst4.8 {d0[1],d1[1],d2[1],d3[1]}, [r0]!
- vst4.8 {d0[2],d1[2],d2[2],d3[2]}, [r0]!
- vst4.8 {d0[3],d1[3],d2[3],d3[3]}, [r0]!
-
- subs r3, r3, #1
- bne 1b
-
- vpop {q4-q7}
- ldmfd sp!, {r4, lr}
- bx lr
-END(rsdIntrinsicColorMatrix4x4_K)
-
-/*
- r0 = dst
- r1 = src
- r2 = matrix
- r3 = length
-*/
-ENTRY(rsdIntrinsicColorMatrix3x3_K)
- .save {r4, lr}
- stmfd sp!, {r4, lr}
- vpush {q4-q7}
-
- vld1.16 {q2}, [r2]!
- vld1.16 {q3}, [r2]!
-
-1:
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r1]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r1]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r1]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r1]!
-
- vmovl.u8 q12, d0
- vmovl.u8 q13, d1
- vmovl.u8 q14, d2
-
- vmull.s16 q8, d24, d4[0]
- vmull.s16 q9, d24, d4[1]
- vmull.s16 q10, d24, d4[2]
-
- vmlal.s16 q8, d26, d5[0]
- vmlal.s16 q9, d26, d5[1]
- vmlal.s16 q10, d26, d5[2]
-
- vmlal.s16 q8, d28, d6[0]
- vmlal.s16 q9, d28, d6[1]
- vmlal.s16 q10, d28, d6[2]
-
- vshrn.i32 d24, q8, #8
- vshrn.i32 d26, q9, #8
- vshrn.i32 d28, q10, #8
-
- vqmovun.s16 d0, q12
- vqmovun.s16 d1, q13
- vqmovun.s16 d2, q14
-
- vst4.8 {d0[0],d1[0],d2[0],d3[0]}, [r0]!
- vst4.8 {d0[1],d1[1],d2[1],d3[1]}, [r0]!
- vst4.8 {d0[2],d1[2],d2[2],d3[2]}, [r0]!
- vst4.8 {d0[3],d1[3],d2[3],d3[3]}, [r0]!
-
- subs r3, r3, #1
- bne 1b
-
- vpop {q4-q7}
- ldmfd sp!, {r4, lr}
- bx lr
-END(rsdIntrinsicColorMatrix3x3_K)
-
-/*
- r0 = dst
- r1 = src
- r2 = matrix
- r3 = length
-*/
-ENTRY(rsdIntrinsicColorMatrixDot_K)
- .save {r4, lr}
- stmfd sp!, {r4, lr}
- vpush {q4-q7}
-
- vld1.16 {q2}, [r2]!
- vld1.16 {q3}, [r2]!
-
-1:
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r1]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r1]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r1]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r1]!
-
- vmovl.u8 q12, d0
- vmovl.u8 q13, d1
- vmovl.u8 q14, d2
-
- vmull.s16 q8, d24, d4[0]
- vmlal.s16 q8, d26, d5[0]
- vmlal.s16 q8, d28, d6[0]
- vshrn.i32 d24, q8, #8
- vqmovun.s16 d0, q12
- vmov.u8 d1, d0
- vmov.u8 d2, d0
-
- vst4.8 {d0[0],d1[0],d2[0],d3[0]}, [r0]!
- vst4.8 {d0[1],d1[1],d2[1],d3[1]}, [r0]!
- vst4.8 {d0[2],d1[2],d2[2],d3[2]}, [r0]!
- vst4.8 {d0[3],d1[3],d2[3],d3[3]}, [r0]!
-
- subs r3, r3, #1
- bne 1b
-
- vpop {q4-q7}
- ldmfd sp!, {r4, lr}
- bx lr
-END(rsdIntrinsicColorMatrixDot_K)
-
-
-/*
-static void OneVF(float4 *out, const uchar *ptrIn, int iStride,
- const float* gPtr, int iradius, int x1, int x2)
-
- r0 = out
- r1 = pin
- r2 = stride
- r3 = gptr
- r4 = sp, ct
- r5 = sp+4, x1
- r6 = sp+8, x2
-*/
-ENTRY(rsdIntrinsicBlurVF_K)
- push {r4-r8, r10, r11, lr}
- vpush {q4-q7}
-
- ldr r4, [sp, #32+64]
- ldr r5, [sp, #32+64 + 4]
- ldr r6, [sp, #32+64 + 8]
-
-1:
- veor q10, q10, q10 /* float4 blurredPixel = 0; */
- veor q11, q11, q11 /* float4 blurredPixel = 0; */
- add r7, r1, r5, lsl #2 /* const uchar *pi = ptrIn + x1 * 4; */
- mov r10, r3
-
- mov r11, r4
-
-2:
- vld1.32 {d2}, [r7]
- vmovl.u8 q1, d2
- vmovl.u16 q3, d2
- vmovl.u16 q4, d3
- vcvt.f32.s32 q3, q3
- vcvt.f32.s32 q4, q4
- vld1.32 {d0[0]}, [r10]!
- add r7, r7, r2
- vmla.f32 q10, q3, d0[0]
- vmla.f32 q11, q4, d0[0]
- subs r11, r11, #1
- bne 2b
-
- vst1.32 {q10}, [r0]!
- vst1.32 {q11}, [r0]!
- add r5, r5, #2
- cmp r5, r6
- bne 1b
-
-
- vpop {q4-q7}
- pop {r4-r8, r10, r11, lr}
- bx lr
-END(rsdIntrinsicBlurVF_K)
-
-/*
-static void OneVF(float4 *out, const uchar *ptrIn, int iStride,
- const float* gPtr, int iradius, int x1, int x2)
-
- r0 = out
- r1 = pin
- r2 = gptr
- r3 = ct
- r4 = sp, x1
- r5 = sp+4, x2
-*/
-ENTRY(rsdIntrinsicBlurHF_K)
- push {r4-r8, r10, r11, lr}
- vpush {q4-q7}
-
- ldr r4, [sp, #32+64]
- ldr r5, [sp, #32+64 + 4]
-
-1:
- add r7, r1, r4, lsl #4 /* const uchar *pi = ptrIn + x1 * 4; */
- mov r10, r2
- mov r11, r3
-
- vld1.32 {q1}, [r7]!
- vld1.32 {d6[0]}, [r10]!
- vmul.f32 q0, q1, d6[0]
- sub r11, r11, #1
-
-2:
- vld1.32 {q1}, [r7]!
- vld1.32 {q2}, [r7]!
- vld1.32 {d6[0]}, [r10]!
- vld1.32 {d6[1]}, [r10]!
- vmla.f32 q0, q1, d6[0]
- vmla.f32 q0, q2, d6[1]
- subs r11, r11, #2
- bne 2b
-
- vcvt.s32.f32 q0, q0
- vmovn.u32 d0, q0
- vmovn.u16 d0, q0
-
- vst1.32 {d0[0]}, [r0]!
- add r4, r4, #1
- cmp r4, r5
- bne 1b
-
- vpop {q4-q7}
- pop {r4-r8, r10, r11, lr}
- bx lr
-END(rsdIntrinsicBlurHF_K)
-
-/*
- r0 = dst
- r1 = Y
- r2 = VU
- r3 = length (pixels / 8)
- r4 = sp, params
-
- This function converts 8 pixels per iteration
-*/
-ENTRY(rsdIntrinsicYuv_K)
- push {r4-r8, r10, r11, lr}
- vpush {q4-q7}
-
- ldr r4, [sp, #32+64]
- vld1.16 {q2}, [r4]! // mults
- vld1.16 {q3}, [r4]! // y offset
- vld1.16 {q4}, [r4]! // 128
- vdup.8 d3, d5[1]
-
-1:
- vld1.8 {d10}, [r1]!
- vld1.8 {d12}, [r2]!
- vmovl.u8 q5, d10 // Y at .16
- vmovl.u8 q6, d12 // vu at .16
-
- vsub.i16 q5, q5, q3
- vsub.i16 q6, q6, q4
- vtrn.16 d12, d13 // d12 = u, d13 = v
- vmov q7, q6
- vtrn.16 d12, d14
- vtrn.32 d12, d14
- vtrn.16 d13, d15
- vtrn.32 d13, d15
-
- vmull.s16 q8, d10, d4[0]
- vmull.s16 q11, d11, d4[0]
- vmov q9, q8
- vmov q10, q8
- vmov q12, q11
- vmov q13, q11
-
- vmlal.s16 q8, d12, d4[1]
- vmlal.s16 q9, d12, d5[0]
- vmlal.s16 q10, d13, d4[3]
- vmlal.s16 q9, d13, d4[2]
-
- vmlal.s16 q11, d14, d4[1]
- vmlal.s16 q12, d14, d5[0]
- vmlal.s16 q13, d15, d4[3]
- vmlal.s16 q12, d15, d4[2]
-
-
- vshrn.i32 d16, q8, #8
- vshrn.i32 d18, q9, #8
- vshrn.i32 d20, q10, #8
- vqmovun.s16 d0, q8
- vqmovun.s16 d1, q9
- vqmovun.s16 d2, q10
- vst4.8 {d0[0],d1[0],d2[0],d3[0]}, [r0]!
- vst4.8 {d0[1],d1[1],d2[1],d3[1]}, [r0]!
- vst4.8 {d0[2],d1[2],d2[2],d3[2]}, [r0]!
- vst4.8 {d0[3],d1[3],d2[3],d3[3]}, [r0]!
-
- vshrn.i32 d16, q11, #8
- vshrn.i32 d18, q12, #8
- vshrn.i32 d20, q13, #8
- vqmovun.s16 d0, q8
- vqmovun.s16 d1, q9
- vqmovun.s16 d2, q10
- vst4.8 {d0[0],d1[0],d2[0],d3[0]}, [r0]!
- vst4.8 {d0[1],d1[1],d2[1],d3[1]}, [r0]!
- vst4.8 {d0[2],d1[2],d2[2],d3[2]}, [r0]!
- vst4.8 {d0[3],d1[3],d2[3],d3[3]}, [r0]!
-
- subs r3, r3, #1
- bne 1b
-
- vpop {q4-q7}
- pop {r4-r8, r10, r11, lr}
- bx lr
-END(rsdIntrinsicYuv_K)
-
-/* Convolve 5x5 */
-
-/*
- r0 = dst
- r1 = y0 base pointer
- r2 = y1 base pointer
- r3 = y2 base pointer
- r4 = y3 base pointer
- r5 = y4 base pointer
- r6 = coeffs
- r7 = length
-*/
-ENTRY(rsdIntrinsicConvolve5x5_K)
- push {r4-r7, lr}
- vpush {q4-q7}
-
- /* load y3 in r4 */
- ldr r4, [sp, #20 + 64]
-
- /* load y4 in r5 */
- ldr r5, [sp, #24 + 64]
-
- /* Load the coefficients pointer */
- ldr r6, [sp, #28 + 64]
-
- /* Create the coefficients vector */
- vld1.16 {d0, d1, d2, d3}, [r6]!
- vld1.16 {d4, d5, d6}, [r6]
-
- /* load the count */
- ldr r6, [sp, #32 + 64]
-
- /* Load the frequently used immediate in a register */
- mov r7, #8
-
-1:
- /* Load the y base pointers in Qregs and post-increase the address by r7=#8 */
- vld1.8 {d24, d25, d26}, [r1], r7 @ y0 ( y - 2 )
- vld1.8 {d27, d28, d29}, [r2], r7 @ y0 ( y - 1 )
-
- /* Signal memory for data that will be used in the loop after the next */
- PLD (r1, r7)
- PLD (r2, r7)
-
- /* Promoting the 8bit channels to 16bit */
- vmovl.u8 q9, d24
- vmovl.u8 q10, d25
- vmovl.u8 q11, d26
- vmovl.u8 q12, d27
- vmovl.u8 q13, d28
- vmovl.u8 q14, d29
-
-/*
- d18, d19, d20, d21, d22, d23,
- d24, d25
-*/
- vmull.s16 q4, d18, d0[0]
- vmlal.s16 q4, d19, d0[1]
- vmlal.s16 q4, d20, d0[2]
- vmlal.s16 q4, d21, d0[3]
- vmlal.s16 q4, d22, d1[0]
-
- vmlal.s16 q4, d24, d1[1]
- vmlal.s16 q4, d25, d1[2]
- vmlal.s16 q4, d26, d1[3]
- vmlal.s16 q4, d27, d2[0]
- vmlal.s16 q4, d28, d2[1]
-
- vmull.s16 q5, d19, d0[0]
- vmlal.s16 q5, d20, d0[1]
- vmlal.s16 q5, d21, d0[2]
- vmlal.s16 q5, d22, d0[3]
- vmlal.s16 q5, d23, d1[0]
-
- vmlal.s16 q5, d25, d1[1]
- vmlal.s16 q5, d26, d1[2]
- vmlal.s16 q5, d27, d1[3]
- vmlal.s16 q5, d28, d2[0]
- vmlal.s16 q5, d29, d2[1]
-
-
- /* Next 2 rows */
- /* Load the y base pointers in Qregs and post-increase the address by r7=#8 */
- vld1.8 {d24, d25, d26}, [r3], r7 @ y0 ( y )
- vld1.8 {d27, d28, d29}, [r4], r7 @ y0 ( y + 1 )
-
- /* Signal memory for data that will be used in the loop after the next */
- PLD (r3, r7)
- PLD (r4, r7)
-
- /* Promoting the 8bit channels to 16bit */
- vmovl.u8 q9, d24
- vmovl.u8 q10, d25
- vmovl.u8 q11, d26
- vmovl.u8 q12, d27
- vmovl.u8 q13, d28
- vmovl.u8 q14, d29
-
-/*
- d18, d19, d20, d21, d22, d23,
- d24, d25
-*/
- vmlal.s16 q4, d18, d2[2]
- vmlal.s16 q4, d19, d2[3]
- vmlal.s16 q4, d20, d3[0]
- vmlal.s16 q4, d21, d3[1]
- vmlal.s16 q4, d22, d3[2]
-
- vmlal.s16 q4, d24, d3[3]
- vmlal.s16 q4, d25, d4[0]
- vmlal.s16 q4, d26, d4[1]
- vmlal.s16 q4, d27, d4[2]
- vmlal.s16 q4, d28, d4[3]
-
- vmlal.s16 q5, d19, d2[2]
- vmlal.s16 q5, d20, d2[3]
- vmlal.s16 q5, d21, d3[0]
- vmlal.s16 q5, d22, d3[1]
- vmlal.s16 q5, d23, d3[2]
-
- vmlal.s16 q5, d25, d3[3]
- vmlal.s16 q5, d26, d4[0]
- vmlal.s16 q5, d27, d4[1]
- vmlal.s16 q5, d28, d4[2]
- vmlal.s16 q5, d29, d4[3]
-
- /* Last row */
- /* Load the y base pointers in Qregs and post-increase the address by r7=#8 */
- vld1.8 {d24, d25, d26}, [r5], r7 @ y0 ( y + 2 )
-
- /* Signal memory for data that will be used in the loop after the next */
- PLD (r5, r7)
-
- /* Promoting the 8bit channels to 16bit */
- vmovl.u8 q9, d24
- vmovl.u8 q10, d25
- vmovl.u8 q11, d26
-
-/*
- d18, d19, d20, d21, d22, d23,
- d24, d25
-*/
-
- vmlal.s16 q4, d18, d5[0]
- vmlal.s16 q4, d19, d5[1]
- vmlal.s16 q4, d20, d5[2]
- vmlal.s16 q4, d21, d5[3]
- vmlal.s16 q4, d22, d6[0]
-
- vmlal.s16 q5, d19, d5[0]
- vmlal.s16 q5, d20, d5[1]
- vmlal.s16 q5, d21, d5[2]
- vmlal.s16 q5, d22, d5[3]
- vmlal.s16 q5, d23, d6[0]
-
-
-
-
-/* Narrow it to a d-reg 32 -> 16 bit */
- vshrn.i32 d8, q4, #8
- vshrn.i32 d9, q5, #8
-
-/* Pack 16 -> 8 bit, saturate, put two pixels into D reg */
- vqmovun.s16 d8, q4
-
- vst1.8 d8, [r0]! @ return the output and increase the address of r0
-
- /* Are we done? */
- subs r6, r6, #1
- bne 1b
-
- /* Yup, bye */
- vpop {q4-q7}
- pop {r4-r7, lr}
- bx lr
-
-END(rsdIntrinsicConvolve5x5_K)
-
-
-
-
-/*
- dst = src + dst * (1.0 - src.a)
-
- r0 = dst
- r1 = src
- r2 = length
-*/
-ENTRY(rsdIntrinsicBlendSrcOver_K)
- .save {r4, lr}
- stmfd sp!, {r4, lr}
- vpush {q4-q7}
-
- mov r4, #255
- vdup.16 q7, r4
-
- mov r4, r0
-1:
-
- /* src */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r1]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r1]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r1]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r1]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r1]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r1]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r1]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r1]!
- vshll.u8 q12, d0, #8
- vshll.u8 q13, d1, #8
- vshll.u8 q14, d2, #8
- vmovl.u8 q6, d3
- vsub.i16 q6, q7, q6 // q6 = 1 - src.a
- vshll.u8 q15, d3, #8
-
- /* dst */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r0]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r0]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r0]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r0]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r0]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r0]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r0]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r0]!
- vmovl.u8 q8, d0
- vmovl.u8 q9, d1
- vmovl.u8 q10, d2
- vmovl.u8 q11, d3
-
- vmla.i16 q12, q8, q6
- vmla.i16 q13, q9, q6
- vmla.i16 q14, q10, q6
- vmla.i16 q15, q11, q6
-
- vshrn.i16 d0, q12, #8
- vshrn.i16 d1, q13, #8
- vshrn.i16 d2, q14, #8
- vshrn.i16 d3, q15, #8
- vst4.8 {d0[0],d1[0],d2[0],d3[0]}, [r4]!
- vst4.8 {d0[1],d1[1],d2[1],d3[1]}, [r4]!
- vst4.8 {d0[2],d1[2],d2[2],d3[2]}, [r4]!
- vst4.8 {d0[3],d1[3],d2[3],d3[3]}, [r4]!
- vst4.8 {d0[4],d1[4],d2[4],d3[4]}, [r4]!
- vst4.8 {d0[5],d1[5],d2[5],d3[5]}, [r4]!
- vst4.8 {d0[6],d1[6],d2[6],d3[6]}, [r4]!
- vst4.8 {d0[7],d1[7],d2[7],d3[7]}, [r4]!
-
- subs r2, r2, #1
- bne 1b
-
- vpop {q4-q7}
- ldmfd sp!, {r4, lr}
- bx lr
-END(rsdIntrinsicBlendSrcOver_K)
-
-/*
- dst = dst + src * (1.0 - dst.a)
-
- r0 = dst
- r1 = src
- r2 = length
-*/
-ENTRY(rsdIntrinsicBlendDstOver_K)
- .save {r4, lr}
- stmfd sp!, {r4, lr}
- vpush {q4-q7}
-
- mov r4, #255
- vdup.16 q7, r4
-
- mov r4, r0
-1:
-
- /* src */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r1]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r1]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r1]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r1]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r1]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r1]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r1]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r1]!
- vmovl.u8 q12, d0
- vmovl.u8 q13, d1
- vmovl.u8 q14, d2
- vmovl.u8 q15, d3
-
- /* dst */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r0]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r0]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r0]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r0]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r0]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r0]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r0]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r0]!
- vshll.u8 q8, d0, #8
- vshll.u8 q9, d1, #8
- vshll.u8 q10, d2, #8
- vmovl.u8 q6, d3
- vsub.i16 q6, q7, q6 // q6 = 1 - dst.a
- vshll.u8 q11, d3, #8
-
-
- vmla.i16 q8, q12, q6
- vmla.i16 q9, q13, q6
- vmla.i16 q10, q14, q6
- vmla.i16 q11, q15, q6
-
- vshrn.i16 d0, q8, #8
- vshrn.i16 d1, q9, #8
- vshrn.i16 d2, q10, #8
- vshrn.i16 d3, q11, #8
- vst4.8 {d0[0],d1[0],d2[0],d3[0]}, [r4]!
- vst4.8 {d0[1],d1[1],d2[1],d3[1]}, [r4]!
- vst4.8 {d0[2],d1[2],d2[2],d3[2]}, [r4]!
- vst4.8 {d0[3],d1[3],d2[3],d3[3]}, [r4]!
- vst4.8 {d0[4],d1[4],d2[4],d3[4]}, [r4]!
- vst4.8 {d0[5],d1[5],d2[5],d3[5]}, [r4]!
- vst4.8 {d0[6],d1[6],d2[6],d3[6]}, [r4]!
- vst4.8 {d0[7],d1[7],d2[7],d3[7]}, [r4]!
-
- subs r2, r2, #1
- bne 1b
-
- vpop {q4-q7}
- ldmfd sp!, {r4, lr}
- bx lr
-END(rsdIntrinsicBlendDstOver_K)
-
-/*
- dst = src * dst.a
-
- r0 = dst
- r1 = src
- r2 = length
-*/
-ENTRY(rsdIntrinsicBlendSrcIn_K)
- .save {r4, lr}
- stmfd sp!, {r4, lr}
- vpush {q4-q7}
-
- mov r4, r0
-1:
-
- /* src */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r1]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r1]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r1]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r1]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r1]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r1]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r1]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r1]!
- vmovl.u8 q12, d0
- vmovl.u8 q13, d1
- vmovl.u8 q14, d2
- vmovl.u8 q15, d3
-
- /* dst */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r0]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r0]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r0]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r0]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r0]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r0]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r0]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r0]!
- //vmovl.u8 q8, d0
- //vmovl.u8 q9, d1
- //vmovl.u8 q10, d2
- vmovl.u8 q11, d3
-
- vmul.i16 q12, q12, q11
- vmul.i16 q13, q13, q11
- vmul.i16 q14, q14, q11
- vmul.i16 q15, q15, q11
-
- vshrn.i16 d0, q12, #8
- vshrn.i16 d1, q13, #8
- vshrn.i16 d2, q14, #8
- vshrn.i16 d3, q15, #8
- vst4.8 {d0[0],d1[0],d2[0],d3[0]}, [r4]!
- vst4.8 {d0[1],d1[1],d2[1],d3[1]}, [r4]!
- vst4.8 {d0[2],d1[2],d2[2],d3[2]}, [r4]!
- vst4.8 {d0[3],d1[3],d2[3],d3[3]}, [r4]!
- vst4.8 {d0[4],d1[4],d2[4],d3[4]}, [r4]!
- vst4.8 {d0[5],d1[5],d2[5],d3[5]}, [r4]!
- vst4.8 {d0[6],d1[6],d2[6],d3[6]}, [r4]!
- vst4.8 {d0[7],d1[7],d2[7],d3[7]}, [r4]!
-
- subs r2, r2, #1
- bne 1b
-
- vpop {q4-q7}
- ldmfd sp!, {r4, lr}
- bx lr
-END(rsdIntrinsicBlendSrcIn_K)
-
-/*
- dst = dst * src.a
-
- r0 = dst
- r1 = src
- r2 = length
-*/
-ENTRY(rsdIntrinsicBlendDstIn_K)
- .save {r4, lr}
- stmfd sp!, {r4, lr}
- vpush {q4-q7}
-
- mov r4, r0
-1:
-
- /* src */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r1]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r1]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r1]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r1]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r1]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r1]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r1]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r1]!
- //vmovl.u8 q12, d0
- //vmovl.u8 q13, d1
- //vmovl.u8 q14, d2
- vmovl.u8 q15, d3
-
- /* dst */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r0]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r0]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r0]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r0]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r0]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r0]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r0]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r0]!
- vmovl.u8 q8, d0
- vmovl.u8 q9, d1
- vmovl.u8 q10, d2
- vmovl.u8 q11, d3
-
- vmul.i16 q8, q8, q15
- vmul.i16 q9, q9, q15
- vmul.i16 q10, q10, q15
- vmul.i16 q11, q11, q15
-
- vshrn.i16 d0, q8, #8
- vshrn.i16 d1, q9, #8
- vshrn.i16 d2, q10, #8
- vshrn.i16 d3, q11, #8
- vst4.8 {d0[0],d1[0],d2[0],d3[0]}, [r4]!
- vst4.8 {d0[1],d1[1],d2[1],d3[1]}, [r4]!
- vst4.8 {d0[2],d1[2],d2[2],d3[2]}, [r4]!
- vst4.8 {d0[3],d1[3],d2[3],d3[3]}, [r4]!
- vst4.8 {d0[4],d1[4],d2[4],d3[4]}, [r4]!
- vst4.8 {d0[5],d1[5],d2[5],d3[5]}, [r4]!
- vst4.8 {d0[6],d1[6],d2[6],d3[6]}, [r4]!
- vst4.8 {d0[7],d1[7],d2[7],d3[7]}, [r4]!
-
- subs r2, r2, #1
- bne 1b
-
- vpop {q4-q7}
- ldmfd sp!, {r4, lr}
- bx lr
-END(rsdIntrinsicBlendDstIn_K)
-
-
-
-/*
- dst = src * (1.0 - dst.a)
-
- r0 = dst
- r1 = src
- r2 = length
-*/
-ENTRY(rsdIntrinsicBlendSrcOut_K)
- .save {r4, lr}
- stmfd sp!, {r4, lr}
- vpush {q4-q7}
-
- mov r4, #255
- vdup.16 q7, r4
-
- mov r4, r0
-1:
-
- /* src */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r1]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r1]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r1]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r1]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r1]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r1]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r1]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r1]!
- vmovl.u8 q12, d0
- vmovl.u8 q13, d1
- vmovl.u8 q14, d2
- vmovl.u8 q15, d3
-
- /* dst */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r0]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r0]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r0]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r0]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r0]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r0]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r0]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r0]!
- //vmovl.u8 q8, d0
- //vmovl.u8 q9, d1
- //vmovl.u8 q10, d2
- vmovl.u8 q11, d3
-
-
- vsub.i16 q6, q7, q11 // q6 = 1 - dst.a
- vmul.i16 q12, q12, q6
- vmul.i16 q13, q13, q6
- vmul.i16 q14, q14, q6
- vmul.i16 q15, q15, q6
-
- vshrn.i16 d0, q12, #8
- vshrn.i16 d1, q13, #8
- vshrn.i16 d2, q14, #8
- vshrn.i16 d3, q15, #8
- vst4.8 {d0[0],d1[0],d2[0],d3[0]}, [r4]!
- vst4.8 {d0[1],d1[1],d2[1],d3[1]}, [r4]!
- vst4.8 {d0[2],d1[2],d2[2],d3[2]}, [r4]!
- vst4.8 {d0[3],d1[3],d2[3],d3[3]}, [r4]!
- vst4.8 {d0[4],d1[4],d2[4],d3[4]}, [r4]!
- vst4.8 {d0[5],d1[5],d2[5],d3[5]}, [r4]!
- vst4.8 {d0[6],d1[6],d2[6],d3[6]}, [r4]!
- vst4.8 {d0[7],d1[7],d2[7],d3[7]}, [r4]!
-
- subs r2, r2, #1
- bne 1b
-
- vpop {q4-q7}
- ldmfd sp!, {r4, lr}
- bx lr
-END(rsdIntrinsicBlendSrcOut_K)
-
-
-/*
- dst = dst * (1.0 - src.a)
-
- r0 = dst
- r1 = src
- r2 = length
-*/
-ENTRY(rsdIntrinsicBlendDstOut_K)
- .save {r4, lr}
- stmfd sp!, {r4, lr}
- vpush {q4-q7}
-
- mov r4, #255
- vdup.16 q7, r4
-
- mov r4, r0
-1:
-
- /* src */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r1]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r1]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r1]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r1]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r1]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r1]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r1]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r1]!
- //vmovl.u8 q12, d0
- //vmovl.u8 q13, d1
- //vmovl.u8 q14, d2
- vmovl.u8 q15, d3
-
- /* dst */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r0]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r0]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r0]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r0]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r0]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r0]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r0]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r0]!
- vmovl.u8 q8, d0
- vmovl.u8 q9, d1
- vmovl.u8 q10, d2
- vmovl.u8 q11, d3
-
-
- vsub.i16 q6, q7, q15 // q6 = 1 - src.a
- vmul.i16 q12, q8, q6
- vmul.i16 q13, q9, q6
- vmul.i16 q14, q10, q6
- vmul.i16 q15, q11, q6
-
- vshrn.i16 d0, q12, #8
- vshrn.i16 d1, q13, #8
- vshrn.i16 d2, q14, #8
- vshrn.i16 d3, q15, #8
- vst4.8 {d0[0],d1[0],d2[0],d3[0]}, [r4]!
- vst4.8 {d0[1],d1[1],d2[1],d3[1]}, [r4]!
- vst4.8 {d0[2],d1[2],d2[2],d3[2]}, [r4]!
- vst4.8 {d0[3],d1[3],d2[3],d3[3]}, [r4]!
- vst4.8 {d0[4],d1[4],d2[4],d3[4]}, [r4]!
- vst4.8 {d0[5],d1[5],d2[5],d3[5]}, [r4]!
- vst4.8 {d0[6],d1[6],d2[6],d3[6]}, [r4]!
- vst4.8 {d0[7],d1[7],d2[7],d3[7]}, [r4]!
-
- subs r2, r2, #1
- bne 1b
-
- vpop {q4-q7}
- ldmfd sp!, {r4, lr}
- bx lr
-END(rsdIntrinsicBlendDstOut_K)
-
-
-/*
- dst.rgb = src.rgb * dst.a + (1.0 - src.a) * dst.rgb
- dst.a = dst.a
-
- r0 = dst
- r1 = src
- r2 = length
-*/
-ENTRY(rsdIntrinsicBlendSrcAtop_K)
- .save {r4, lr}
- stmfd sp!, {r4, lr}
- vpush {q4-q7}
-
- mov r4, #255
- vdup.16 q7, r4
-
- mov r4, r0
-1:
-
- /* src */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r1]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r1]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r1]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r1]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r1]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r1]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r1]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r1]!
- vmovl.u8 q12, d0
- vmovl.u8 q13, d1
- vmovl.u8 q14, d2
- vmovl.u8 q15, d3
-
- /* dst */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r0]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r0]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r0]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r0]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r0]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r0]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r0]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r0]!
- vmovl.u8 q8, d0
- vmovl.u8 q9, d1
- vmovl.u8 q10, d2
- vmovl.u8 q11, d3
-
-
- vsub.i16 q6, q7, q15 // q6 = 1 - src.a
- vmul.i16 q8, q8, q6
- vmul.i16 q9, q9, q6
- vmul.i16 q10, q10, q6
-
- vmla.i16 q8, q12, q11
- vmla.i16 q9, q13, q11
- vmla.i16 q10, q14, q11
-
-
- vshrn.i16 d0, q8, #8
- vshrn.i16 d1, q9, #8
- vshrn.i16 d2, q10, #8
- //vshrn.i16 d3, q15, #8
- vst4.8 {d0[0],d1[0],d2[0],d3[0]}, [r4]!
- vst4.8 {d0[1],d1[1],d2[1],d3[1]}, [r4]!
- vst4.8 {d0[2],d1[2],d2[2],d3[2]}, [r4]!
- vst4.8 {d0[3],d1[3],d2[3],d3[3]}, [r4]!
- vst4.8 {d0[4],d1[4],d2[4],d3[4]}, [r4]!
- vst4.8 {d0[5],d1[5],d2[5],d3[5]}, [r4]!
- vst4.8 {d0[6],d1[6],d2[6],d3[6]}, [r4]!
- vst4.8 {d0[7],d1[7],d2[7],d3[7]}, [r4]!
-
- subs r2, r2, #1
- bne 1b
-
- vpop {q4-q7}
- ldmfd sp!, {r4, lr}
- bx lr
-END(rsdIntrinsicBlendSrcAtop_K)
-
-/*
- dst = dst.rgb * src.a + (1.0 - dst.a) * src.rgb
- dst.a = src.a
-
- r0 = dst
- r1 = src
- r2 = length
-*/
-ENTRY(rsdIntrinsicBlendDstAtop_K)
- .save {r4, lr}
- stmfd sp!, {r4, lr}
- vpush {q4-q7}
-
- mov r4, #255
- vdup.16 q7, r4
-
- mov r4, r0
-1:
-
- /* src */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r1]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r1]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r1]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r1]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r1]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r1]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r1]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r1]!
- vmovl.u8 q12, d0
- vmovl.u8 q13, d1
- vmovl.u8 q14, d2
- vmovl.u8 q15, d3
-
- /* dst */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r0]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r0]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r0]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r0]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r0]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r0]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r0]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r0]!
- vmovl.u8 q8, d0
- vmovl.u8 q9, d1
- vmovl.u8 q10, d2
- vmovl.u8 q11, d3
-
-
- vsub.i16 q6, q7, q11 // q6 = 1 - dst.a
- vmul.i16 q12, q12, q6
- vmul.i16 q13, q13, q6
- vmul.i16 q14, q14, q6
-
- vmla.i16 q12, q8, q15
- vmla.i16 q13, q9, q15
- vmla.i16 q14, q10, q15
-
-
- vshrn.i16 d0, q12, #8
- vshrn.i16 d1, q13, #8
- vshrn.i16 d2, q14, #8
- //vshrn.i16 d3, q15, #8
- vst4.8 {d0[0],d1[0],d2[0],d3[0]}, [r4]!
- vst4.8 {d0[1],d1[1],d2[1],d3[1]}, [r4]!
- vst4.8 {d0[2],d1[2],d2[2],d3[2]}, [r4]!
- vst4.8 {d0[3],d1[3],d2[3],d3[3]}, [r4]!
- vst4.8 {d0[4],d1[4],d2[4],d3[4]}, [r4]!
- vst4.8 {d0[5],d1[5],d2[5],d3[5]}, [r4]!
- vst4.8 {d0[6],d1[6],d2[6],d3[6]}, [r4]!
- vst4.8 {d0[7],d1[7],d2[7],d3[7]}, [r4]!
-
- subs r2, r2, #1
- bne 1b
-
- vpop {q4-q7}
- ldmfd sp!, {r4, lr}
- bx lr
-END(rsdIntrinsicBlendDstAtop_K)
-
-/*
- dst = dst ^ src
-
- r0 = dst
- r1 = src
- r2 = length
-*/
-ENTRY(rsdIntrinsicBlendXor_K)
- .save {r4, lr}
- stmfd sp!, {r4, lr}
- vpush {q4-q7}
-
- mov r4, #255
- vdup.16 q7, r4
-
- mov r4, r0
-1:
-
- /* src */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r1]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r1]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r1]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r1]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r1]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r1]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r1]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r1]!
- vmov.u8 d4, d0
- vmov.u8 d5, d1
- vmov.u8 d6, d2
- vmov.u8 d7, d3
-
- /* dst */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r0]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r0]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r0]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r0]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r0]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r0]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r0]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r0]!
-
- veor d0, d0, d4
- veor d1, d1, d5
- veor d2, d2, d6
- veor d3, d3, d7
-
- vst4.8 {d0[0],d1[0],d2[0],d3[0]}, [r4]!
- vst4.8 {d0[1],d1[1],d2[1],d3[1]}, [r4]!
- vst4.8 {d0[2],d1[2],d2[2],d3[2]}, [r4]!
- vst4.8 {d0[3],d1[3],d2[3],d3[3]}, [r4]!
- vst4.8 {d0[4],d1[4],d2[4],d3[4]}, [r4]!
- vst4.8 {d0[5],d1[5],d2[5],d3[5]}, [r4]!
- vst4.8 {d0[6],d1[6],d2[6],d3[6]}, [r4]!
- vst4.8 {d0[7],d1[7],d2[7],d3[7]}, [r4]!
-
- subs r2, r2, #1
- bne 1b
-
- vpop {q4-q7}
- ldmfd sp!, {r4, lr}
- bx lr
-END(rsdIntrinsicBlendXor_K)
-
-/*
- dst = dst * src
-
- r0 = dst
- r1 = src
- r2 = length
-*/
-ENTRY(rsdIntrinsicBlendMultiply_K)
- .save {r4, lr}
- stmfd sp!, {r4, lr}
- vpush {q4-q7}
-
- mov r4, #255
- vdup.16 q7, r4
-
- mov r4, r0
-1:
-
- /* src */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r1]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r1]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r1]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r1]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r1]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r1]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r1]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r1]!
- vmovl.u8 q12, d0
- vmovl.u8 q13, d1
- vmovl.u8 q14, d2
- vmovl.u8 q15, d3
-
- /* dst */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r0]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r0]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r0]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r0]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r0]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r0]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r0]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r0]!
- vmovl.u8 q8, d0
- vmovl.u8 q9, d1
- vmovl.u8 q10, d2
- vmovl.u8 q11, d3
-
-
- vmul.i16 q8, q8, q12
- vmul.i16 q9, q9, q13
- vmul.i16 q10, q10, q14
- vmul.i16 q11, q11, q15
-
- vshrn.i16 d0, q8, #8
- vshrn.i16 d1, q9, #8
- vshrn.i16 d2, q10, #8
- vshrn.i16 d3, q11, #8
- vst4.8 {d0[0],d1[0],d2[0],d3[0]}, [r4]!
- vst4.8 {d0[1],d1[1],d2[1],d3[1]}, [r4]!
- vst4.8 {d0[2],d1[2],d2[2],d3[2]}, [r4]!
- vst4.8 {d0[3],d1[3],d2[3],d3[3]}, [r4]!
- vst4.8 {d0[4],d1[4],d2[4],d3[4]}, [r4]!
- vst4.8 {d0[5],d1[5],d2[5],d3[5]}, [r4]!
- vst4.8 {d0[6],d1[6],d2[6],d3[6]}, [r4]!
- vst4.8 {d0[7],d1[7],d2[7],d3[7]}, [r4]!
-
- subs r2, r2, #1
- bne 1b
-
- vpop {q4-q7}
- ldmfd sp!, {r4, lr}
- bx lr
-END(rsdIntrinsicBlendMultiply_K)
-
-/*
- dst = min(src + dst, 1.0)
-
- r0 = dst
- r1 = src
- r2 = length
-*/
-ENTRY(rsdIntrinsicBlendAdd_K)
- .save {r4, lr}
- stmfd sp!, {r4, lr}
- vpush {q4-q7}
-
- mov r4, #255
- vdup.16 q7, r4
-
- mov r4, r0
-1:
-
- /* src */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r1]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r1]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r1]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r1]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r1]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r1]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r1]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r1]!
- vmovl.u8 q12, d0
- vmovl.u8 q13, d1
- vmovl.u8 q14, d2
- vmovl.u8 q15, d3
-
- /* dst */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r0]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r0]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r0]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r0]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r0]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r0]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r0]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r0]!
- vmovl.u8 q8, d0
- vmovl.u8 q9, d1
- vmovl.u8 q10, d2
- vmovl.u8 q11, d3
-
-
- vadd.i16 q8, q8, q12
- vadd.i16 q9, q9, q13
- vadd.i16 q10, q10, q14
- vadd.i16 q11, q11, q15
-
- vqmovun.s16 d0, q8
- vqmovun.s16 d1, q9
- vqmovun.s16 d2, q10
- vqmovun.s16 d3, q11
- vst4.8 {d0[0],d1[0],d2[0],d3[0]}, [r4]!
- vst4.8 {d0[1],d1[1],d2[1],d3[1]}, [r4]!
- vst4.8 {d0[2],d1[2],d2[2],d3[2]}, [r4]!
- vst4.8 {d0[3],d1[3],d2[3],d3[3]}, [r4]!
- vst4.8 {d0[4],d1[4],d2[4],d3[4]}, [r4]!
- vst4.8 {d0[5],d1[5],d2[5],d3[5]}, [r4]!
- vst4.8 {d0[6],d1[6],d2[6],d3[6]}, [r4]!
- vst4.8 {d0[7],d1[7],d2[7],d3[7]}, [r4]!
-
- subs r2, r2, #1
- bne 1b
-
- vpop {q4-q7}
- ldmfd sp!, {r4, lr}
- bx lr
-END(rsdIntrinsicBlendAdd_K)
-
-
-/*
- dst = max(dst - src, 0.0)
-
- r0 = dst
- r1 = src
- r2 = length
-*/
-ENTRY(rsdIntrinsicBlendSub_K)
- .save {r4, lr}
- stmfd sp!, {r4, lr}
- vpush {q4-q7}
-
- mov r4, #255
- vdup.16 q7, r4
-
- mov r4, r0
-1:
-
- /* src */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r1]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r1]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r1]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r1]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r1]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r1]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r1]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r1]!
- vmovl.u8 q12, d0
- vmovl.u8 q13, d1
- vmovl.u8 q14, d2
- vmovl.u8 q15, d3
-
- /* dst */
- vld4.8 {d0[0],d1[0],d2[0],d3[0]}, [r0]!
- vld4.8 {d0[1],d1[1],d2[1],d3[1]}, [r0]!
- vld4.8 {d0[2],d1[2],d2[2],d3[2]}, [r0]!
- vld4.8 {d0[3],d1[3],d2[3],d3[3]}, [r0]!
- vld4.8 {d0[4],d1[4],d2[4],d3[4]}, [r0]!
- vld4.8 {d0[5],d1[5],d2[5],d3[5]}, [r0]!
- vld4.8 {d0[6],d1[6],d2[6],d3[6]}, [r0]!
- vld4.8 {d0[7],d1[7],d2[7],d3[7]}, [r0]!
- vmovl.u8 q8, d0
- vmovl.u8 q9, d1
- vmovl.u8 q10, d2
- vmovl.u8 q11, d3
-
-
- vsub.i16 q8, q8, q12
- vsub.i16 q9, q9, q13
- vsub.i16 q10, q10, q14
- vsub.i16 q11, q11, q15
-
- vqmovun.s16 d0, q8
- vqmovun.s16 d1, q9
- vqmovun.s16 d2, q10
- vqmovun.s16 d3, q11
- vst4.8 {d0[0],d1[0],d2[0],d3[0]}, [r4]!
- vst4.8 {d0[1],d1[1],d2[1],d3[1]}, [r4]!
- vst4.8 {d0[2],d1[2],d2[2],d3[2]}, [r4]!
- vst4.8 {d0[3],d1[3],d2[3],d3[3]}, [r4]!
- vst4.8 {d0[4],d1[4],d2[4],d3[4]}, [r4]!
- vst4.8 {d0[5],d1[5],d2[5],d3[5]}, [r4]!
- vst4.8 {d0[6],d1[6],d2[6],d3[6]}, [r4]!
- vst4.8 {d0[7],d1[7],d2[7],d3[7]}, [r4]!
-
- subs r2, r2, #1
- bne 1b
-
- vpop {q4-q7}
- ldmfd sp!, {r4, lr}
- bx lr
-END(rsdIntrinsicBlendSub_K)
-
diff --git a/renderscript/v8/rs_support/driver/rsdRuntime.h b/renderscript/v8/rs_support/driver/rsdRuntime.h
deleted file mode 100644
index dc84032..0000000
--- a/renderscript/v8/rs_support/driver/rsdRuntime.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef RSD_RUNTIME_STUBS_H
-#define RSD_RUNTIME_STUBS_H
-
-#include <rs_hal.h>
-
-#include "rsMutex.h"
-
-const RsdSymbolTable * rsdLookupSymbolMath(const char *sym);
-
-void* rsdLookupRuntimeStub(void* pContext, char const* name);
-
-#endif
diff --git a/renderscript/v8/rs_support/driver/rsdRuntimeMath.cpp b/renderscript/v8/rs_support/driver/rsdRuntimeMath.cpp
deleted file mode 100644
index 51716ab..0000000
--- a/renderscript/v8/rs_support/driver/rsdRuntimeMath.cpp
+++ /dev/null
@@ -1,1099 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <cutils/compiler.h>
-
-#include "rsContext.h"
-#include "rsScriptC.h"
-#include "rsMatrix4x4.h"
-#include "rsMatrix3x3.h"
-#include "rsMatrix2x2.h"
-
-#include "rsdCore.h"
-#include "rsdRuntime.h"
-
-
-using namespace android;
-using namespace android::renderscript;
-
-static float SC_tgamma(float v) {
- return float(tgamma((double)v));
-}
-
-static float SC_exp10(float v) {
- return pow(10.f, v);
-}
-
-static float SC_fract(float v, float *iptr) {
- int i = (int)floor(v);
- iptr[0] = (float)i;
- return fmin(v - i, 0x1.fffffep-1f);
-}
-
-static float SC_log2(float v) {
- return log10(v) / log10(2.f);
-}
-
-#if 0
-static float SC_pown(float v, int p) {
- return powf(v, (float)p);
-}
-
-static float SC_powr(float v, float p) {
- return powf(v, p);
-}
-#endif
-
-float SC_rootn(float v, int r) {
- return pow(v, 1.f / r);
-}
-
-float SC_rsqrt(float v) {
- return 1.f / sqrtf(v);
-}
-
-float SC_sincos(float v, float *cosptr) {
- *cosptr = cosf(v);
- return sinf(v);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// Integer
-//////////////////////////////////////////////////////////////////////////////
-
-
-static uint32_t SC_abs_i32(int32_t v) {return abs(v);}
-static uint16_t SC_abs_i16(int16_t v) {return (uint16_t)abs(v);}
-static uint8_t SC_abs_i8(int8_t v) {return (uint8_t)abs(v);}
-
-static uint32_t SC_clz_u32(uint32_t v) {return __builtin_clz(v);}
-static uint16_t SC_clz_u16(uint16_t v) {return (uint16_t)__builtin_clz(v);}
-static uint8_t SC_clz_u8(uint8_t v) {return (uint8_t)__builtin_clz(v);}
-static int32_t SC_clz_i32(int32_t v) {return (int32_t)__builtin_clz((uint32_t)v);}
-static int16_t SC_clz_i16(int16_t v) {return (int16_t)__builtin_clz(v);}
-static int8_t SC_clz_i8(int8_t v) {return (int8_t)__builtin_clz(v);}
-
-static uint32_t SC_max_u32(uint32_t v, uint32_t v2) {return rsMax(v, v2);}
-static uint16_t SC_max_u16(uint16_t v, uint16_t v2) {return rsMax(v, v2);}
-static uint8_t SC_max_u8(uint8_t v, uint8_t v2) {return rsMax(v, v2);}
-static int32_t SC_max_i32(int32_t v, int32_t v2) {return rsMax(v, v2);}
-static int16_t SC_max_i16(int16_t v, int16_t v2) {return rsMax(v, v2);}
-static int8_t SC_max_i8(int8_t v, int8_t v2) {return rsMax(v, v2);}
-
-static uint32_t SC_min_u32(uint32_t v, uint32_t v2) {return rsMin(v, v2);}
-static uint16_t SC_min_u16(uint16_t v, uint16_t v2) {return rsMin(v, v2);}
-static uint8_t SC_min_u8(uint8_t v, uint8_t v2) {return rsMin(v, v2);}
-static int32_t SC_min_i32(int32_t v, int32_t v2) {return rsMin(v, v2);}
-static int16_t SC_min_i16(int16_t v, int16_t v2) {return rsMin(v, v2);}
-static int8_t SC_min_i8(int8_t v, int8_t v2) {return rsMin(v, v2);}
-
-//////////////////////////////////////////////////////////////////////////////
-// Float util
-//////////////////////////////////////////////////////////////////////////////
-
-static float SC_clamp_f32(float amount, float low, float high) {
- return amount < low ? low : (amount > high ? high : amount);
-}
-
-static float SC_max_f32(float v, float v2) {
- return rsMax(v, v2);
-}
-
-static float SC_min_f32(float v, float v2) {
- return rsMin(v, v2);
-}
-
-static float SC_step_f32(float edge, float v) {
- if (v < edge) return 0.f;
- return 1.f;
-}
-
-static float SC_sign_f32(float value) {
- if (value > 0) return 1.f;
- if (value < 0) return -1.f;
- return value;
-}
-
-static void SC_MatrixLoadIdentity_4x4(Matrix4x4 *m) {
- m->loadIdentity();
-}
-static void SC_MatrixLoadIdentity_3x3(Matrix3x3 *m) {
- m->loadIdentity();
-}
-static void SC_MatrixLoadIdentity_2x2(Matrix2x2 *m) {
- m->loadIdentity();
-}
-
-static void SC_MatrixLoad_4x4_f(Matrix4x4 *m, const float *f) {
- m->load(f);
-}
-static void SC_MatrixLoad_3x3_f(Matrix3x3 *m, const float *f) {
- m->load(f);
-}
-static void SC_MatrixLoad_2x2_f(Matrix2x2 *m, const float *f) {
- m->load(f);
-}
-
-static void SC_MatrixLoad_4x4_4x4(Matrix4x4 *m, const Matrix4x4 *s) {
- m->load(s);
-}
-static void SC_MatrixLoad_4x4_3x3(Matrix4x4 *m, const Matrix3x3 *s) {
- m->load(s);
-}
-static void SC_MatrixLoad_4x4_2x2(Matrix4x4 *m, const Matrix2x2 *s) {
- m->load(s);
-}
-static void SC_MatrixLoad_3x3_3x3(Matrix3x3 *m, const Matrix3x3 *s) {
- m->load(s);
-}
-static void SC_MatrixLoad_2x2_2x2(Matrix2x2 *m, const Matrix2x2 *s) {
- m->load(s);
-}
-
-static void SC_MatrixLoadRotate(Matrix4x4 *m, float rot, float x, float y, float z) {
- m->loadRotate(rot, x, y, z);
-}
-static void SC_MatrixLoadScale(Matrix4x4 *m, float x, float y, float z) {
- m->loadScale(x, y, z);
-}
-static void SC_MatrixLoadTranslate(Matrix4x4 *m, float x, float y, float z) {
- m->loadTranslate(x, y, z);
-}
-static void SC_MatrixRotate(Matrix4x4 *m, float rot, float x, float y, float z) {
- m->rotate(rot, x, y, z);
-}
-static void SC_MatrixScale(Matrix4x4 *m, float x, float y, float z) {
- m->scale(x, y, z);
-}
-static void SC_MatrixTranslate(Matrix4x4 *m, float x, float y, float z) {
- m->translate(x, y, z);
-}
-
-static void SC_MatrixLoadMultiply_4x4_4x4_4x4(Matrix4x4 *m, const Matrix4x4 *lhs, const Matrix4x4 *rhs) {
- m->loadMultiply(lhs, rhs);
-}
-static void SC_MatrixLoadMultiply_3x3_3x3_3x3(Matrix3x3 *m, const Matrix3x3 *lhs, const Matrix3x3 *rhs) {
- m->loadMultiply(lhs, rhs);
-}
-static void SC_MatrixLoadMultiply_2x2_2x2_2x2(Matrix2x2 *m, const Matrix2x2 *lhs, const Matrix2x2 *rhs) {
- m->loadMultiply(lhs, rhs);
-}
-
-static void SC_MatrixMultiply_4x4_4x4(Matrix4x4 *m, const Matrix4x4 *rhs) {
- m->multiply(rhs);
-}
-static void SC_MatrixMultiply_3x3_3x3(Matrix3x3 *m, const Matrix3x3 *rhs) {
- m->multiply(rhs);
-}
-static void SC_MatrixMultiply_2x2_2x2(Matrix2x2 *m, const Matrix2x2 *rhs) {
- m->multiply(rhs);
-}
-
-static void SC_MatrixLoadOrtho(Matrix4x4 *m, float l, float r, float b, float t, float n, float f) {
- m->loadOrtho(l, r, b, t, n, f);
-}
-static void SC_MatrixLoadFrustum(Matrix4x4 *m, float l, float r, float b, float t, float n, float f) {
- m->loadFrustum(l, r, b, t, n, f);
-}
-static void SC_MatrixLoadPerspective(Matrix4x4 *m, float fovy, float aspect, float near, float far) {
- m->loadPerspective(fovy, aspect, near, far);
-}
-
-static bool SC_MatrixInverse_4x4(Matrix4x4 *m) {
- return m->inverse();
-}
-static bool SC_MatrixInverseTranspose_4x4(Matrix4x4 *m) {
- return m->inverseTranspose();
-}
-static void SC_MatrixTranspose_4x4(Matrix4x4 *m) {
- m->transpose();
-}
-static void SC_MatrixTranspose_3x3(Matrix3x3 *m) {
- m->transpose();
-}
-static void SC_MatrixTranspose_2x2(Matrix2x2 *m) {
- m->transpose();
-}
-
-static float SC_randf(float max) {
- float r = (float)rand();
- r *= max;
- r /= RAND_MAX;
- return r;
-}
-
-static float SC_randf2(float min, float max) {
- float r = (float)rand();
- r /= RAND_MAX;
- r = r * (max - min) + min;
- return r;
-}
-
-static int SC_randi(int max) {
- return (int)SC_randf(max);
-}
-
-static int SC_randi2(int min, int max) {
- return (int)SC_randf2(min, max);
-}
-
-static float SC_frac(float v) {
- int i = (int)floor(v);
- return fmin(v - i, 0x1.fffffep-1f);
-}
-
-
-static int32_t SC_AtomicCas(volatile int32_t *ptr, int32_t expectedValue, int32_t newValue) {
- int32_t prev;
-
- do {
- int32_t ret = android_atomic_release_cas(expectedValue, newValue, ptr);
- if (!ret) {
- // The android cas return 0 if it wrote the value. This means the
- // previous value was the expected value and we can return.
- return expectedValue;
- }
- // We didn't write the value and need to load the "previous" value.
- prev = *ptr;
-
- // A race condition exists where the expected value could appear after our cas failed
- // above. In this case loop until we have a legit previous value or the
- // write passes.
- } while (prev == expectedValue);
- return prev;
-}
-
-
-static int32_t SC_AtomicInc(volatile int32_t *ptr) {
- return android_atomic_inc(ptr);
-}
-
-static int32_t SC_AtomicDec(volatile int32_t *ptr) {
- return android_atomic_dec(ptr);
-}
-
-static int32_t SC_AtomicAdd(volatile int32_t *ptr, int32_t value) {
- return android_atomic_add(value, ptr);
-}
-
-static int32_t SC_AtomicSub(volatile int32_t *ptr, int32_t value) {
- int32_t prev, status;
- do {
- prev = *ptr;
- status = android_atomic_release_cas(prev, prev - value, ptr);
- } while (CC_UNLIKELY(status != 0));
- return prev;
-}
-
-static int32_t SC_AtomicAnd(volatile int32_t *ptr, int32_t value) {
- return android_atomic_and(value, ptr);
-}
-
-static int32_t SC_AtomicOr(volatile int32_t *ptr, int32_t value) {
- return android_atomic_or(value, ptr);
-}
-
-static int32_t SC_AtomicXor(volatile int32_t *ptr, int32_t value) {
- int32_t prev, status;
- do {
- prev = *ptr;
- status = android_atomic_release_cas(prev, prev ^ value, ptr);
- } while (CC_UNLIKELY(status != 0));
- return prev;
-}
-
-static uint32_t SC_AtomicUMin(volatile uint32_t *ptr, uint32_t value) {
- uint32_t prev, status;
- do {
- prev = *ptr;
- uint32_t n = rsMin(value, prev);
- status = android_atomic_release_cas((int32_t) prev, (int32_t)n, (volatile int32_t*) ptr);
- } while (CC_UNLIKELY(status != 0));
- return prev;
-}
-
-static int32_t SC_AtomicMin(volatile int32_t *ptr, int32_t value) {
- int32_t prev, status;
- do {
- prev = *ptr;
- int32_t n = rsMin(value, prev);
- status = android_atomic_release_cas(prev, n, ptr);
- } while (CC_UNLIKELY(status != 0));
- return prev;
-}
-
-static uint32_t SC_AtomicUMax(volatile uint32_t *ptr, uint32_t value) {
- uint32_t prev, status;
- do {
- prev = *ptr;
- uint32_t n = rsMax(value, prev);
- status = android_atomic_release_cas((int32_t) prev, (int32_t) n, (volatile int32_t*) ptr);
- } while (CC_UNLIKELY(status != 0));
- return prev;
-}
-
-static int32_t SC_AtomicMax(volatile int32_t *ptr, int32_t value) {
- int32_t prev, status;
- do {
- prev = *ptr;
- int32_t n = rsMax(value, prev);
- status = android_atomic_release_cas(prev, n, ptr);
- } while (CC_UNLIKELY(status != 0));
- return prev;
-}
-
-
-
-//////////////////////////////////////////////////////////////////////////////
-// Class implementation
-//////////////////////////////////////////////////////////////////////////////
-
-// llvm name mangling ref
-// <builtin-type> ::= v # void
-// ::= b # bool
-// ::= c # char
-// ::= a # signed char
-// ::= h # unsigned char
-// ::= s # short
-// ::= t # unsigned short
-// ::= i # int
-// ::= j # unsigned int
-// ::= l # long
-// ::= m # unsigned long
-// ::= x # long long, __int64
-// ::= y # unsigned long long, __int64
-// ::= f # float
-// ::= d # double
-
-float acos(float x) {
- return acosf(x);
-}
-
-float acosh(float x) {
- return acoshf(x);
-}
-
-float asin(float x) {
- return asinf(x);
-}
-
-float asinh(float x) {
- return asinhf(x);
-}
-
-float atan(float x) {
- return atanf(x);
-}
-
-float atan2(float y, float x) {
- return atan2f(y, x);
-}
-
-float atanh(float x) {
- return atanhf(x);
-}
-
-float cbrt(float x) {
- return cbrtf(x);
-}
-
-float ceil(float x) {
- return ceilf(x);
-}
-
-float copysign(float x, float y) {
- return copysignf(x, y);
-}
-
-float cos(float x) {
- return cosf(x);
-}
-
-float cosh(float x) {
- return coshf(x);
-}
-
-float erfc(float x) {
- return erfcf(x);
-}
-
-float erf(float x) {
- return erff(x);
-}
-
-float exp(float x) {
- return expf(x);
-}
-
-float exp2(float x) {
- return exp2f(x);
-}
-
-float exp10(float x) {
- return SC_exp10(x);
-}
-
-float expm1(float x) {
- return expm1f(x);
-}
-
-float fabs(float x) {
- return fabsf(x);
-}
-
-float fdim(float x, float y) {
- return fdimf(x, y);
-}
-
-float floor(float x) {
- return floorf(x);
-}
-
-float fma(float x, float y, float z) {
- return fmaf(x, y, z);
-}
-
-float fmax(float x, float y) {
- return fmaxf(x, y);
-}
-
-float fmin(float x, float y) {
- return fminf(x, y);
-}
-
-float fmod(float x, float y) {
- return fmodf(x, y);
-}
-
-float fract(float x, float *y) {
- return SC_fract(x, y);
-}
-
-float frexp(float x, int *y) {
- return frexpf(x, y);
-}
-
-float hypot(float x, float y) {
- return hypotf(x, y);
-}
-
-int ilogb(float x) {
- return ilogbf(x);
-}
-
-float ldexp(float x, int y) {
- return ldexpf(x, y);
-}
-
-float lgamma(float x) {
- return lgammaf(x);
-}
-
-float lgamma(float x, int *y) {
- return lgammaf_r(x, y);
-}
-
-float log(float x) {
- return logf(x);
-}
-
-float log2(float x) {
- return SC_log2(x);
-}
-
-float log10(float x) {
- return log10f(x);
-}
-
-float log1p(float x) {
- return log1pf(x);
-}
-
-float logb(float x) {
- return logbf(x);
-}
-
-float modf(float x, float *y) {
- return modff(x, y);
-}
-
-float nextafter(float x, float y) {
- return nextafterf(x, y);
-}
-
-float pow(float x, float y) {
- return powf(x, y);
-}
-
-float remainder(float x, float y) {
- return remainderf(x, y);
-}
-
-float remquo(float x, float y, int *z) {
- return remquof(x, y, z);
-}
-
-float rint(float x) {
- return rintf(x);
-}
-
-float rootn(float x, int y) {
- return SC_rootn(x, y);
-}
-
-float round(float x) {
- return roundf(x);
-}
-
-float rsqrt(float x) {
- return SC_rsqrt(x);
-}
-
-float sin(float x) {
- return sinf(x);
-}
-
-float sincos(float x, float *y) {
- return SC_sincos(x, y);
-}
-
-float sinh(float x) {
- return sinhf(x);
-}
-
-float sqrt(float x) {
- return sqrtf(x);
-}
-
-float tan(float x) {
- return tanf(x);
-}
-
-float tanh(float x) {
- return tanhf(x);
-}
-
-float tgamma(float x) {
- return SC_tgamma(x);
-}
-
-float trunc(float x) {
- return truncf(x);
-}
-
-#if 1
-// Bionic stdlib.h defines int abs(int) as a static __inline__ function.
-// This makes it difficult for us to override the implementation.
-extern "C" {
-int _Z3absi(int v) {
- return SC_abs_i32(v);
-}
-}
-#else
-int abs(int v) {
- return SC_abs_i32(v);
-}
-#endif
-
-int16_t abs(int16_t v) {
- return SC_abs_i16(v);
-}
-
-char abs(char v) {
- return SC_abs_i8(v);
-}
-
-uint32_t clz(uint32_t v) {
- return SC_clz_u32(v);
-}
-
-uint16_t clz(uint16_t v) {
- return SC_clz_u16(v);
-}
-
-uint8_t clz(uint8_t v) {
- return SC_clz_u8(v);
-}
-
-int32_t clz(int32_t v) {
- return SC_clz_i32(v);
-}
-
-int16_t clz(int16_t v) {
- return SC_clz_i16(v);
-}
-
-char clz(char v) {
- return SC_clz_i8(v);
-}
-
-uint32_t max(uint32_t v1, uint32_t v2) {
- return SC_max_u32(v1, v2);
-}
-
-uint16_t max(uint16_t v1, uint16_t v2) {
- return SC_max_u16(v1, v2);
-}
-
-uint8_t max(uint8_t v1, uint8_t v2) {
- return SC_max_u8(v1, v2);
-}
-
-int32_t max(int32_t v1, int32_t v2) {
- return SC_max_i32(v1, v2);
-}
-
-int16_t max(int16_t v1, int16_t v2) {
- return SC_max_i16(v1, v2);
-}
-
-int8_t max(int8_t v1, int8_t v2) {
- return SC_max_i8(v1, v2);
-}
-
-uint32_t min(uint32_t v1, uint32_t v2) {
- return SC_min_u32(v1, v2);
-}
-
-uint16_t min(uint16_t v1, uint16_t v2) {
- return SC_min_u16(v1, v2);
-}
-
-uint8_t min(uint8_t v1, uint8_t v2) {
- return SC_min_u8(v1, v2);
-}
-
-int32_t min(int32_t v1, int32_t v2) {
- return SC_min_i32(v1, v2);
-}
-
-int16_t min(int16_t v1, int16_t v2) {
- return SC_min_i16(v1, v2);
-}
-
-int8_t min(int8_t v1, int8_t v2) {
- return SC_min_i8(v1, v2);
-}
-
-float clamp(float amount, float low, float high) {
- return SC_clamp_f32(amount, low, high);
-}
-
-float max(float v1, float v2) {
- return SC_max_f32(v1, v2);
-}
-
-float min(float v1, float v2) {
- return SC_min_f32(v1, v2);
-}
-
-float step(float edge, float v) {
- return SC_step_f32(edge, v);
-}
-
-float sign(float v) {
- return SC_sign_f32(v);
-}
-
-void rsMatrixLoadIdentity(rs_matrix4x4 *m) {
- SC_MatrixLoadIdentity_4x4((Matrix4x4 *) m);
-}
-
-void rsMatrixLoadIdentity(rs_matrix3x3 *m) {
- SC_MatrixLoadIdentity_3x3((Matrix3x3 *) m);
-}
-
-void rsMatrixLoadIdentity(rs_matrix2x2 *m) {
- SC_MatrixLoadIdentity_2x2((Matrix2x2 *) m);
-}
-
-void rsMatrixLoad(rs_matrix4x4 *m, const float *v) {
- SC_MatrixLoad_4x4_f((Matrix4x4 *) m, v);
-}
-
-void rsMatrixLoad(rs_matrix3x3 *m, const float *v) {
- SC_MatrixLoad_3x3_f((Matrix3x3 *) m, v);
-}
-
-void rsMatrixLoad(rs_matrix2x2 *m, const float *v) {
- SC_MatrixLoad_2x2_f((Matrix2x2 *) m, v);
-}
-
-void rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix4x4 *v) {
- SC_MatrixLoad_4x4_4x4((Matrix4x4 *) m, (Matrix4x4 *) v);
-}
-
-void rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix3x3 *v) {
- SC_MatrixLoad_4x4_3x3((Matrix4x4 *) m, (Matrix3x3 *) v);
-}
-
-void rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix2x2 *v) {
- SC_MatrixLoad_4x4_2x2((Matrix4x4 *) m, (Matrix2x2 *) v);
-}
-
-void rsMatrixLoad(rs_matrix3x3 *m, const rs_matrix3x3 *v) {
- SC_MatrixLoad_3x3_3x3((Matrix3x3 *) m, (Matrix3x3 *) v);
-}
-
-void rsMatrixLoad(rs_matrix2x2 *m, const rs_matrix2x2 *v) {
- SC_MatrixLoad_2x2_2x2((Matrix2x2 *) m, (Matrix2x2 *) v);
-}
-
-void rsMatrixLoadRotate(rs_matrix4x4 *m, float rot, float x, float y, float z) {
- SC_MatrixLoadRotate((Matrix4x4 *) m, rot, x, y, z);
-}
-
-void rsMatrixLoadScale(rs_matrix4x4 *m, float x, float y, float z) {
- SC_MatrixLoadScale((Matrix4x4 *) m, x, y, z);
-}
-
-void rsMatrixLoadTranslate(rs_matrix4x4 *m, float x, float y, float z) {
- SC_MatrixLoadTranslate((Matrix4x4 *) m, x, y, z);
-}
-
-void rsMatrixLoadMultiply(rs_matrix4x4 *m, const rs_matrix4x4 *lhs,
- const rs_matrix4x4 *rhs) {
- SC_MatrixLoadMultiply_4x4_4x4_4x4((Matrix4x4 *) m, (Matrix4x4 *) lhs,
- (Matrix4x4 *) rhs);
-}
-
-void rsMatrixLoadMultiply(rs_matrix3x3 *m, const rs_matrix3x3 *lhs,
- const rs_matrix3x3 *rhs) {
- SC_MatrixLoadMultiply_3x3_3x3_3x3((Matrix3x3 *) m, (Matrix3x3 *) lhs,
- (Matrix3x3 *) rhs);
-}
-
-void rsMatrixLoadMultiply(rs_matrix2x2 *m, const rs_matrix2x2 *lhs,
- const rs_matrix2x2 *rhs) {
- SC_MatrixLoadMultiply_2x2_2x2_2x2((Matrix2x2 *) m, (Matrix2x2 *) lhs,
- (Matrix2x2 *) rhs);
-}
-
-void rsMatrixMultiply(rs_matrix4x4 *m, const rs_matrix4x4 *rhs) {
- SC_MatrixMultiply_4x4_4x4((Matrix4x4 *) m, (Matrix4x4 *) rhs);
-}
-
-void rsMatrixMultiply(rs_matrix3x3 *m, const rs_matrix3x3 *rhs) {
- SC_MatrixMultiply_3x3_3x3((Matrix3x3 *) m, (Matrix3x3 *) rhs);
-}
-
-void rsMatrixMultiply(rs_matrix2x2 *m, const rs_matrix2x2 *rhs) {
- SC_MatrixMultiply_2x2_2x2((Matrix2x2 *) m, (Matrix2x2 *) rhs);
-}
-
-void rsMatrixRotate(rs_matrix4x4 *m, float rot, float x, float y, float z) {
- SC_MatrixRotate((Matrix4x4 *) m, rot, x, y, z);
-}
-
-void rsMatrixScale(rs_matrix4x4 *m, float x, float y, float z) {
- SC_MatrixScale((Matrix4x4 *) m, x, y, z);
-}
-
-void rsMatrixTranslate(rs_matrix4x4 *m, float x, float y, float z) {
- SC_MatrixTranslate((Matrix4x4 *) m, x, y, z);
-}
-
-void rsMatrixLoadOrtho(rs_matrix4x4 *m, float left, float right, float bottom,
- float top, float near, float far) {
- SC_MatrixLoadOrtho((Matrix4x4 *) m, left, right, bottom, top, near, far);
-}
-
-void rsMatrixLoadFrustum(rs_matrix4x4 *m, float left, float right, float bottom,
- float top, float near, float far) {
- SC_MatrixLoadFrustum((Matrix4x4 *) m, left, right, bottom, top, near, far);
-}
-
-void rsMatrixLoadPerspective(rs_matrix4x4* m, float fovy, float aspect,
- float near, float far) {
- SC_MatrixLoadPerspective((Matrix4x4 *) m, fovy, aspect, near, far);
-}
-
-bool rsMatrixInverse(rs_matrix4x4 *m) {
- return SC_MatrixInverse_4x4((Matrix4x4 *) m);
-}
-
-bool rsMatrixInverseTranspose(rs_matrix4x4 *m) {
- return SC_MatrixInverseTranspose_4x4((Matrix4x4 *) m);
-}
-
-void rsMatrixTranspose(rs_matrix4x4 *m) {
- SC_MatrixTranspose_4x4((Matrix4x4 *) m);
-}
-
-void rsMatrixTranspose(rs_matrix3x3 *m) {
- SC_MatrixTranspose_3x3((Matrix3x3 *) m);
-}
-
-void rsMatrixTranspose(rs_matrix2x2 *m) {
- SC_MatrixTranspose_2x2((Matrix2x2 *) m);
-}
-
-
-int rsRand(int max) {
- return SC_randi(max);
-}
-
-int rsRand(int min, int max) {
- return SC_randi2(min, max);
-}
-
-float rsRand(float max) {
- return SC_randf(max);
-}
-
-float rsRand(float min, float max) {
- return SC_randf2(min, max);
-}
-
-float rsFrac(float v) {
- return SC_frac(v);
-}
-
-
-int32_t rsAtomicInc(volatile int32_t* addr) {
- return SC_AtomicInc(addr);
-}
-
-uint32_t rsAtomicInc(volatile uint32_t* addr) {
- return SC_AtomicInc((volatile int32_t*) addr);
-}
-
-int32_t rsAtomicDec(volatile int32_t* addr) {
- return SC_AtomicDec(addr);
-}
-
-uint32_t rsAtomicDec(volatile uint32_t* addr) {
- return SC_AtomicDec((volatile int32_t*) addr);
-}
-
-#define RS_ATOMIC_OP(OPNAME) \
-int32_t rsAtomic##OPNAME(volatile int32_t* addr, int32_t value) { \
- return SC_Atomic##OPNAME(addr, value); \
-} \
-\
-uint32_t rsAtomic##OPNAME(volatile uint32_t* addr, uint32_t value) { \
- int32_t ival; \
- memcpy(&ival, &value, sizeof(int32_t)); \
- return SC_Atomic##OPNAME((volatile int32_t *) addr, ival); \
-}
-
-RS_ATOMIC_OP(Add);
-RS_ATOMIC_OP(Sub);
-RS_ATOMIC_OP(And);
-RS_ATOMIC_OP(Or);
-RS_ATOMIC_OP(Xor);
-
-#undef RS_ATOMIC_OP
-
-int32_t rsAtomicMin(volatile int32_t* addr, int32_t value) {
- return SC_AtomicMin(addr, value);
-}
-
-uint32_t rsAtomicMin(volatile uint32_t* addr, uint32_t value) {
- return SC_AtomicUMin(addr, value);
-}
-
-int32_t rsAtomicMax(volatile int32_t* addr, int32_t value) {
- return SC_AtomicMax(addr, value);
-}
-
-uint32_t rsAtomicMax(volatile uint32_t* addr, uint32_t value) {
- return SC_AtomicUMax(addr, value);
-}
-
-int32_t rsAtomicCas(volatile int32_t* addr, int32_t compareValue,
- int32_t newValue) {
- return SC_AtomicCas(addr, compareValue, newValue);
-}
-
-uint32_t rsAtomicCas(volatile uint32_t* addr, uint32_t compareValue,
- uint32_t newValue) {
- int32_t iCompareValue, iNewValue;
- memcpy(&iCompareValue, &compareValue, sizeof(int32_t));
- memcpy(&iNewValue, &newValue, sizeof(int32_t));
- return SC_AtomicCas((volatile int32_t *) addr, iCompareValue, iNewValue);
-}
-
-
-static RsdSymbolTable gSyms[] = {
- { "_Z4acosf", (void *)&acosf, true },
- { "_Z5acoshf", (void *)&acoshf, true },
- { "_Z4asinf", (void *)&asinf, true },
- { "_Z5asinhf", (void *)&asinhf, true },
- { "_Z4atanf", (void *)&atanf, true },
- { "_Z5atan2ff", (void *)&atan2f, true },
- { "_Z5atanhf", (void *)&atanhf, true },
- { "_Z4cbrtf", (void *)&cbrtf, true },
- { "_Z4ceilf", (void *)&ceilf, true },
- { "_Z8copysignff", (void *)©signf, true },
- { "_Z3cosf", (void *)&cosf, true },
- { "_Z4coshf", (void *)&coshf, true },
- { "_Z4erfcf", (void *)&erfcf, true },
- { "_Z3erff", (void *)&erff, true },
- { "_Z3expf", (void *)&expf, true },
- { "_Z4exp2f", (void *)&exp2f, true },
- { "_Z5exp10f", (void *)&SC_exp10, true },
- { "_Z5expm1f", (void *)&expm1f, true },
- { "_Z4fabsf", (void *)&fabsf, true },
- { "_Z4fdimff", (void *)&fdimf, true },
- { "_Z5floorf", (void *)&floorf, true },
- { "_Z3fmafff", (void *)&fmaf, true },
- { "_Z4fmaxff", (void *)&fmaxf, true },
- { "_Z4fminff", (void *)&fminf, true }, // float fmin(float, float)
- { "_Z4fmodff", (void *)&fmodf, true },
- { "_Z5fractfPf", (void *)&SC_fract, true },
- { "_Z5frexpfPi", (void *)&frexpf, true },
- { "_Z5hypotff", (void *)&hypotf, true },
- { "_Z5ilogbf", (void *)&ilogbf, true },
- { "_Z5ldexpfi", (void *)&ldexpf, true },
- { "_Z6lgammaf", (void *)&lgammaf, true },
- { "_Z6lgammafPi", (void *)&lgammaf_r, true },
- { "_Z3logf", (void *)&logf, true },
- { "_Z4log2f", (void *)&SC_log2, true },
- { "_Z5log10f", (void *)&log10f, true },
- { "_Z5log1pf", (void *)&log1pf, true },
- { "_Z4logbf", (void *)&logbf, true },
- { "_Z4modffPf", (void *)&modff, true },
- //{ "_Z3nanj", (void *)&SC_nan, true },
- { "_Z9nextafterff", (void *)&nextafterf, true },
- { "_Z3powff", (void *)&powf, true },
- { "_Z9remainderff", (void *)&remainderf, true },
- { "_Z6remquoffPi", (void *)&remquof, true },
- { "_Z4rintf", (void *)&rintf, true },
- { "_Z5rootnfi", (void *)&SC_rootn, true },
- { "_Z5roundf", (void *)&roundf, true },
- { "_Z5rsqrtf", (void *)&SC_rsqrt, true },
- { "_Z3sinf", (void *)&sinf, true },
- { "_Z6sincosfPf", (void *)&SC_sincos, true },
- { "_Z4sinhf", (void *)&sinhf, true },
- { "_Z4sqrtf", (void *)&sqrtf, true },
- { "_Z3tanf", (void *)&tanf, true },
- { "_Z4tanhf", (void *)&tanhf, true },
- { "_Z6tgammaf", (void *)&SC_tgamma, true },
- { "_Z5truncf", (void *)&truncf, true },
-
- { "_Z3absi", (void *)&SC_abs_i32, true },
- { "_Z3abss", (void *)&SC_abs_i16, true },
- { "_Z3absc", (void *)&SC_abs_i8, true },
- { "_Z3clzj", (void *)&SC_clz_u32, true },
- { "_Z3clzt", (void *)&SC_clz_u16, true },
- { "_Z3clzh", (void *)&SC_clz_u8, true },
- { "_Z3clzi", (void *)&SC_clz_i32, true },
- { "_Z3clzs", (void *)&SC_clz_i16, true },
- { "_Z3clzc", (void *)&SC_clz_i8, true },
- { "_Z3maxjj", (void *)&SC_max_u32, true },
- { "_Z3maxtt", (void *)&SC_max_u16, true },
- { "_Z3maxhh", (void *)&SC_max_u8, true },
- { "_Z3maxii", (void *)&SC_max_i32, true },
- { "_Z3maxss", (void *)&SC_max_i16, true },
- { "_Z3maxcc", (void *)&SC_max_i8, true },
- { "_Z3minjj", (void *)&SC_min_u32, true },
- { "_Z3mintt", (void *)&SC_min_u16, true },
- { "_Z3minhh", (void *)&SC_min_u8, true },
- { "_Z3minii", (void *)&SC_min_i32, true },
- { "_Z3minss", (void *)&SC_min_i16, true },
- { "_Z3mincc", (void *)&SC_min_i8, true },
-
- { "_Z5clampfff", (void *)&SC_clamp_f32, true },
- { "_Z3maxff", (void *)&SC_max_f32, true },
- { "_Z3minff", (void *)&SC_min_f32, true },
- { "_Z4stepff", (void *)&SC_step_f32, true },
- //{ "smoothstep", (void *)&, true },
- { "_Z4signf", (void *)&SC_sign_f32, true },
-
- // matrix
- { "_Z20rsMatrixLoadIdentityP12rs_matrix4x4", (void *)&SC_MatrixLoadIdentity_4x4, true },
- { "_Z20rsMatrixLoadIdentityP12rs_matrix3x3", (void *)&SC_MatrixLoadIdentity_3x3, true },
- { "_Z20rsMatrixLoadIdentityP12rs_matrix2x2", (void *)&SC_MatrixLoadIdentity_2x2, true },
-
- { "_Z12rsMatrixLoadP12rs_matrix4x4PKf", (void *)&SC_MatrixLoad_4x4_f, true },
- { "_Z12rsMatrixLoadP12rs_matrix3x3PKf", (void *)&SC_MatrixLoad_3x3_f, true },
- { "_Z12rsMatrixLoadP12rs_matrix2x2PKf", (void *)&SC_MatrixLoad_2x2_f, true },
-
- { "_Z12rsMatrixLoadP12rs_matrix4x4PKS_", (void *)&SC_MatrixLoad_4x4_4x4, true },
- { "_Z12rsMatrixLoadP12rs_matrix4x4PK12rs_matrix3x3", (void *)&SC_MatrixLoad_4x4_3x3, true },
- { "_Z12rsMatrixLoadP12rs_matrix4x4PK12rs_matrix2x2", (void *)&SC_MatrixLoad_4x4_2x2, true },
- { "_Z12rsMatrixLoadP12rs_matrix3x3PKS_", (void *)&SC_MatrixLoad_3x3_3x3, true },
- { "_Z12rsMatrixLoadP12rs_matrix2x2PKS_", (void *)&SC_MatrixLoad_2x2_2x2, true },
-
- { "_Z18rsMatrixLoadRotateP12rs_matrix4x4ffff", (void *)&SC_MatrixLoadRotate, true },
- { "_Z17rsMatrixLoadScaleP12rs_matrix4x4fff", (void *)&SC_MatrixLoadScale, true },
- { "_Z21rsMatrixLoadTranslateP12rs_matrix4x4fff", (void *)&SC_MatrixLoadTranslate, true },
- { "_Z14rsMatrixRotateP12rs_matrix4x4ffff", (void *)&SC_MatrixRotate, true },
- { "_Z13rsMatrixScaleP12rs_matrix4x4fff", (void *)&SC_MatrixScale, true },
- { "_Z17rsMatrixTranslateP12rs_matrix4x4fff", (void *)&SC_MatrixTranslate, true },
-
- { "_Z20rsMatrixLoadMultiplyP12rs_matrix4x4PKS_S2_", (void *)&SC_MatrixLoadMultiply_4x4_4x4_4x4, true },
- { "_Z16rsMatrixMultiplyP12rs_matrix4x4PKS_", (void *)&SC_MatrixMultiply_4x4_4x4, true },
- { "_Z20rsMatrixLoadMultiplyP12rs_matrix3x3PKS_S2_", (void *)&SC_MatrixLoadMultiply_3x3_3x3_3x3, true },
- { "_Z16rsMatrixMultiplyP12rs_matrix3x3PKS_", (void *)&SC_MatrixMultiply_3x3_3x3, true },
- { "_Z20rsMatrixLoadMultiplyP12rs_matrix2x2PKS_S2_", (void *)&SC_MatrixLoadMultiply_2x2_2x2_2x2, true },
- { "_Z16rsMatrixMultiplyP12rs_matrix2x2PKS_", (void *)&SC_MatrixMultiply_2x2_2x2, true },
-
- { "_Z17rsMatrixLoadOrthoP12rs_matrix4x4ffffff", (void *)&SC_MatrixLoadOrtho, true },
- { "_Z19rsMatrixLoadFrustumP12rs_matrix4x4ffffff", (void *)&SC_MatrixLoadFrustum, true },
- { "_Z23rsMatrixLoadPerspectiveP12rs_matrix4x4ffff", (void *)&SC_MatrixLoadPerspective, true },
-
- { "_Z15rsMatrixInverseP12rs_matrix4x4", (void *)&SC_MatrixInverse_4x4, true },
- { "_Z24rsMatrixInverseTransposeP12rs_matrix4x4", (void *)&SC_MatrixInverseTranspose_4x4, true },
- { "_Z17rsMatrixTransposeP12rs_matrix4x4", (void *)&SC_MatrixTranspose_4x4, true },
- { "_Z17rsMatrixTransposeP12rs_matrix3x3", (void *)&SC_MatrixTranspose_3x3, true },
- { "_Z17rsMatrixTransposeP12rs_matrix2x2", (void *)&SC_MatrixTranspose_2x2, true },
-
- // RS Math
- { "_Z6rsRandi", (void *)&SC_randi, true },
- { "_Z6rsRandii", (void *)&SC_randi2, true },
- { "_Z6rsRandf", (void *)&SC_randf, true },
- { "_Z6rsRandff", (void *)&SC_randf2, true },
- { "_Z6rsFracf", (void *)&SC_frac, true },
-
- // Atomics
- { "_Z11rsAtomicIncPVi", (void *)&SC_AtomicInc, true },
- { "_Z11rsAtomicIncPVj", (void *)&SC_AtomicInc, true },
- { "_Z11rsAtomicDecPVi", (void *)&SC_AtomicDec, true },
- { "_Z11rsAtomicDecPVj", (void *)&SC_AtomicDec, true },
- { "_Z11rsAtomicAddPVii", (void *)&SC_AtomicAdd, true },
- { "_Z11rsAtomicAddPVjj", (void *)&SC_AtomicAdd, true },
- { "_Z11rsAtomicSubPVii", (void *)&SC_AtomicSub, true },
- { "_Z11rsAtomicSubPVjj", (void *)&SC_AtomicSub, true },
- { "_Z11rsAtomicAndPVii", (void *)&SC_AtomicAnd, true },
- { "_Z11rsAtomicAndPVjj", (void *)&SC_AtomicAnd, true },
- { "_Z10rsAtomicOrPVii", (void *)&SC_AtomicOr, true },
- { "_Z10rsAtomicOrPVjj", (void *)&SC_AtomicOr, true },
- { "_Z11rsAtomicXorPVii", (void *)&SC_AtomicXor, true },
- { "_Z11rsAtomicXorPVjj", (void *)&SC_AtomicXor, true },
- { "_Z11rsAtomicMinPVii", (void *)&SC_AtomicMin, true },
- { "_Z11rsAtomicMinPVjj", (void *)&SC_AtomicUMin, true },
- { "_Z11rsAtomicMaxPVii", (void *)&SC_AtomicMax, true },
- { "_Z11rsAtomicMaxPVjj", (void *)&SC_AtomicUMax, true },
- { "_Z11rsAtomicCasPViii", (void *)&SC_AtomicCas, true },
- { "_Z11rsAtomicCasPVjjj", (void *)&SC_AtomicCas, true },
-
- { NULL, NULL, false }
-};
-
-const RsdSymbolTable * rsdLookupSymbolMath(const char *sym) {
- const RsdSymbolTable *syms = gSyms;
-
- while (syms->mPtr) {
- if (!strcmp(syms->mName, sym)) {
- return syms;
- }
- syms++;
- }
- return NULL;
-}
-
diff --git a/renderscript/v8/rs_support/driver/rsdRuntimeStubs.cpp b/renderscript/v8/rs_support/driver/rsdRuntimeStubs.cpp
deleted file mode 100644
index 0629d96..0000000
--- a/renderscript/v8/rs_support/driver/rsdRuntimeStubs.cpp
+++ /dev/null
@@ -1,792 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsContext.h"
-#include "rsScriptC.h"
-#include "rsMatrix4x4.h"
-#include "rsMatrix3x3.h"
-#include "rsMatrix2x2.h"
-#include "rsRuntime.h"
-
-#include "utils/Timers.h"
-#include "rsdCore.h"
-#include "rsdBcc.h"
-
-#include "rsdRuntime.h"
-//#include "rsdPath.h"
-#include "rsdAllocation.h"
-
-#include <time.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-#define GET_TLS() ScriptTLSStruct * tls = \
- (ScriptTLSStruct *)pthread_getspecific(rsdgThreadTLSKey); \
- Context * rsc = tls->mContext; \
- ScriptC * sc = (ScriptC *) tls->mScript
-
-typedef float float2 __attribute__((ext_vector_type(2)));
-typedef float float3 __attribute__((ext_vector_type(3)));
-typedef float float4 __attribute__((ext_vector_type(4)));
-typedef char char2 __attribute__((ext_vector_type(2)));
-typedef char char3 __attribute__((ext_vector_type(3)));
-typedef char char4 __attribute__((ext_vector_type(4)));
-typedef unsigned char uchar2 __attribute__((ext_vector_type(2)));
-typedef unsigned char uchar3 __attribute__((ext_vector_type(3)));
-typedef unsigned char uchar4 __attribute__((ext_vector_type(4)));
-typedef short short2 __attribute__((ext_vector_type(2)));
-typedef short short3 __attribute__((ext_vector_type(3)));
-typedef short short4 __attribute__((ext_vector_type(4)));
-typedef unsigned short ushort2 __attribute__((ext_vector_type(2)));
-typedef unsigned short ushort3 __attribute__((ext_vector_type(3)));
-typedef unsigned short ushort4 __attribute__((ext_vector_type(4)));
-typedef int32_t int2 __attribute__((ext_vector_type(2)));
-typedef int32_t int3 __attribute__((ext_vector_type(3)));
-typedef int32_t int4 __attribute__((ext_vector_type(4)));
-typedef uint32_t uint2 __attribute__((ext_vector_type(2)));
-typedef uint32_t uint3 __attribute__((ext_vector_type(3)));
-typedef uint32_t uint4 __attribute__((ext_vector_type(4)));
-typedef long long long2 __attribute__((ext_vector_type(2)));
-typedef long long long3 __attribute__((ext_vector_type(3)));
-typedef long long long4 __attribute__((ext_vector_type(4)));
-typedef unsigned long long ulong2 __attribute__((ext_vector_type(2)));
-typedef unsigned long long ulong3 __attribute__((ext_vector_type(3)));
-typedef unsigned long long ulong4 __attribute__((ext_vector_type(4)));
-
-
-#define OPAQUETYPE(t) \
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) t;
-
-OPAQUETYPE(rs_element)
-OPAQUETYPE(rs_type)
-OPAQUETYPE(rs_allocation)
-OPAQUETYPE(rs_sampler)
-OPAQUETYPE(rs_script)
-#undef OPAQUETYPE
-
-
-//////////////////////////////////////////////////////////////////////////////
-// Allocation
-//////////////////////////////////////////////////////////////////////////////
-
-
-static void SC_AllocationSyncAll2(Allocation *a, RsAllocationUsageType source) {
- GET_TLS();
- rsrAllocationSyncAll(rsc, sc, a, source);
-}
-
-static void SC_AllocationSyncAll(Allocation *a) {
- GET_TLS();
- rsrAllocationSyncAll(rsc, sc, a, RS_ALLOCATION_USAGE_SCRIPT);
-}
-
-static void SC_AllocationCopy1DRange(Allocation *dstAlloc,
- uint32_t dstOff,
- uint32_t dstMip,
- uint32_t count,
- Allocation *srcAlloc,
- uint32_t srcOff, uint32_t srcMip) {
- GET_TLS();
- rsrAllocationCopy1DRange(rsc, dstAlloc, dstOff, dstMip, count,
- srcAlloc, srcOff, srcMip);
-}
-
-static void SC_AllocationCopy2DRange(Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff,
- uint32_t dstMip, uint32_t dstFace,
- uint32_t width, uint32_t height,
- Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff,
- uint32_t srcMip, uint32_t srcFace) {
- GET_TLS();
- rsrAllocationCopy2DRange(rsc, dstAlloc,
- dstXoff, dstYoff, dstMip, dstFace,
- width, height,
- srcAlloc,
- srcXoff, srcYoff, srcMip, srcFace);
-}
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-
-static void SC_SetObject(ObjectBase **dst, ObjectBase * src) {
- GET_TLS();
- rsrSetObject(rsc, sc, dst, src);
-}
-
-static void SC_ClearObject(ObjectBase **dst) {
- GET_TLS();
- rsrClearObject(rsc, sc, dst);
-}
-
-static bool SC_IsObject(const ObjectBase *src) {
- GET_TLS();
- return rsrIsObject(rsc, sc, src);
-}
-
-
-
-
-static const Allocation * SC_GetAllocation(const void *ptr) {
- GET_TLS();
- return rsdScriptGetAllocationForPointer(rsc, sc, ptr);
-}
-
-static void SC_ForEach_SAA(Script *target,
- Allocation *in,
- Allocation *out) {
- GET_TLS();
- rsrForEach(rsc, sc, target, in, out, NULL, 0, NULL);
-}
-
-static void SC_ForEach_SAAU(Script *target,
- Allocation *in,
- Allocation *out,
- const void *usr) {
- GET_TLS();
- rsrForEach(rsc, sc, target, in, out, usr, 0, NULL);
-}
-
-static void SC_ForEach_SAAUS(Script *target,
- Allocation *in,
- Allocation *out,
- const void *usr,
- const RsScriptCall *call) {
- GET_TLS();
- rsrForEach(rsc, sc, target, in, out, usr, 0, call);
-}
-
-static void SC_ForEach_SAAUL(Script *target,
- Allocation *in,
- Allocation *out,
- const void *usr,
- uint32_t usrLen) {
- GET_TLS();
- rsrForEach(rsc, sc, target, in, out, usr, usrLen, NULL);
-}
-
-static void SC_ForEach_SAAULS(Script *target,
- Allocation *in,
- Allocation *out,
- const void *usr,
- uint32_t usrLen,
- const RsScriptCall *call) {
- GET_TLS();
- rsrForEach(rsc, sc, target, in, out, usr, usrLen, call);
-}
-
-
-
-//////////////////////////////////////////////////////////////////////////////
-// Time routines
-//////////////////////////////////////////////////////////////////////////////
-
-static float SC_GetDt() {
- GET_TLS();
- return rsrGetDt(rsc, sc);
-}
-
-time_t SC_Time(time_t *timer) {
- GET_TLS();
- return rsrTime(rsc, sc, timer);
-}
-
-tm* SC_LocalTime(tm *local, time_t *timer) {
- GET_TLS();
- return rsrLocalTime(rsc, sc, local, timer);
-}
-
-int64_t SC_UptimeMillis() {
- GET_TLS();
- return rsrUptimeMillis(rsc, sc);
-}
-
-int64_t SC_UptimeNanos() {
- GET_TLS();
- return rsrUptimeNanos(rsc, sc);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// Message routines
-//////////////////////////////////////////////////////////////////////////////
-
-static uint32_t SC_ToClient2(int cmdID, void *data, int len) {
- GET_TLS();
- return rsrToClient(rsc, sc, cmdID, data, len);
-}
-
-static uint32_t SC_ToClient(int cmdID) {
- GET_TLS();
- return rsrToClient(rsc, sc, cmdID, NULL, 0);
-}
-
-static uint32_t SC_ToClientBlocking2(int cmdID, void *data, int len) {
- GET_TLS();
- return rsrToClientBlocking(rsc, sc, cmdID, data, len);
-}
-
-static uint32_t SC_ToClientBlocking(int cmdID) {
- GET_TLS();
- return rsrToClientBlocking(rsc, sc, cmdID, NULL, 0);
-}
-
-int SC_divsi3(int a, int b) {
- return a / b;
-}
-
-int SC_modsi3(int a, int b) {
- return a % b;
-}
-
-unsigned int SC_udivsi3(unsigned int a, unsigned int b) {
- return a / b;
-}
-
-unsigned int SC_umodsi3(unsigned int a, unsigned int b) {
- return a % b;
-}
-
-static void SC_debugF(const char *s, float f) {
- ALOGD("%s %f, 0x%08x", s, f, *((int *) (&f)));
-}
-static void SC_debugFv2(const char *s, float f1, float f2) {
- ALOGD("%s {%f, %f}", s, f1, f2);
-}
-static void SC_debugFv3(const char *s, float f1, float f2, float f3) {
- ALOGD("%s {%f, %f, %f}", s, f1, f2, f3);
-}
-static void SC_debugFv4(const char *s, float f1, float f2, float f3, float f4) {
- ALOGD("%s {%f, %f, %f, %f}", s, f1, f2, f3, f4);
-}
-static void SC_debugF2(const char *s, float2 f) {
- ALOGD("%s {%f, %f}", s, f.x, f.y);
-}
-static void SC_debugF3(const char *s, float3 f) {
- ALOGD("%s {%f, %f, %f}", s, f.x, f.y, f.z);
-}
-static void SC_debugF4(const char *s, float4 f) {
- ALOGD("%s {%f, %f, %f, %f}", s, f.x, f.y, f.z, f.w);
-}
-static void SC_debugD(const char *s, double d) {
- ALOGD("%s %f, 0x%08llx", s, d, *((long long *) (&d)));
-}
-static void SC_debugFM4v4(const char *s, const float *f) {
- ALOGD("%s {%f, %f, %f, %f", s, f[0], f[4], f[8], f[12]);
- ALOGD("%s %f, %f, %f, %f", s, f[1], f[5], f[9], f[13]);
- ALOGD("%s %f, %f, %f, %f", s, f[2], f[6], f[10], f[14]);
- ALOGD("%s %f, %f, %f, %f}", s, f[3], f[7], f[11], f[15]);
-}
-static void SC_debugFM3v3(const char *s, const float *f) {
- ALOGD("%s {%f, %f, %f", s, f[0], f[3], f[6]);
- ALOGD("%s %f, %f, %f", s, f[1], f[4], f[7]);
- ALOGD("%s %f, %f, %f}",s, f[2], f[5], f[8]);
-}
-static void SC_debugFM2v2(const char *s, const float *f) {
- ALOGD("%s {%f, %f", s, f[0], f[2]);
- ALOGD("%s %f, %f}",s, f[1], f[3]);
-}
-static void SC_debugI8(const char *s, char c) {
- ALOGD("%s %hhd 0x%hhx", s, c, (unsigned char)c);
-}
-static void SC_debugC2(const char *s, char2 c) {
- ALOGD("%s {%hhd, %hhd} 0x%hhx 0x%hhx", s, c.x, c.y, (unsigned char)c.x, (unsigned char)c.y);
-}
-static void SC_debugC3(const char *s, char3 c) {
- ALOGD("%s {%hhd, %hhd, %hhd} 0x%hhx 0x%hhx 0x%hhx", s, c.x, c.y, c.z, (unsigned char)c.x, (unsigned char)c.y, (unsigned char)c.z);
-}
-static void SC_debugC4(const char *s, char4 c) {
- ALOGD("%s {%hhd, %hhd, %hhd, %hhd} 0x%hhx 0x%hhx 0x%hhx 0x%hhx", s, c.x, c.y, c.z, c.w, (unsigned char)c.x, (unsigned char)c.y, (unsigned char)c.z, (unsigned char)c.w);
-}
-static void SC_debugU8(const char *s, unsigned char c) {
- ALOGD("%s %hhu 0x%hhx", s, c, c);
-}
-static void SC_debugUC2(const char *s, uchar2 c) {
- ALOGD("%s {%hhu, %hhu} 0x%hhx 0x%hhx", s, c.x, c.y, c.x, c.y);
-}
-static void SC_debugUC3(const char *s, uchar3 c) {
- ALOGD("%s {%hhu, %hhu, %hhu} 0x%hhx 0x%hhx 0x%hhx", s, c.x, c.y, c.z, c.x, c.y, c.z);
-}
-static void SC_debugUC4(const char *s, uchar4 c) {
- ALOGD("%s {%hhu, %hhu, %hhu, %hhu} 0x%hhx 0x%hhx 0x%hhx 0x%hhx", s, c.x, c.y, c.z, c.w, c.x, c.y, c.z, c.w);
-}
-static void SC_debugI16(const char *s, short c) {
- ALOGD("%s %hd 0x%hx", s, c, c);
-}
-static void SC_debugS2(const char *s, short2 c) {
- ALOGD("%s {%hd, %hd} 0x%hx 0x%hx", s, c.x, c.y, c.x, c.y);
-}
-static void SC_debugS3(const char *s, short3 c) {
- ALOGD("%s {%hd, %hd, %hd} 0x%hx 0x%hx 0x%hx", s, c.x, c.y, c.z, c.x, c.y, c.z);
-}
-static void SC_debugS4(const char *s, short4 c) {
- ALOGD("%s {%hd, %hd, %hd, %hd} 0x%hx 0x%hx 0x%hx 0x%hx", s, c.x, c.y, c.z, c.w, c.x, c.y, c.z, c.w);
-}
-static void SC_debugU16(const char *s, unsigned short c) {
- ALOGD("%s %hu 0x%hx", s, c, c);
-}
-static void SC_debugUS2(const char *s, ushort2 c) {
- ALOGD("%s {%hu, %hu} 0x%hx 0x%hx", s, c.x, c.y, c.x, c.y);
-}
-static void SC_debugUS3(const char *s, ushort3 c) {
- ALOGD("%s {%hu, %hu, %hu} 0x%hx 0x%hx 0x%hx", s, c.x, c.y, c.z, c.x, c.y, c.z);
-}
-static void SC_debugUS4(const char *s, ushort4 c) {
- ALOGD("%s {%hu, %hu, %hu, %hu} 0x%hx 0x%hx 0x%hx 0x%hx", s, c.x, c.y, c.z, c.w, c.x, c.y, c.z, c.w);
-}
-static void SC_debugI32(const char *s, int32_t i) {
- ALOGD("%s %d 0x%x", s, i, i);
-}
-static void SC_debugI2(const char *s, int2 i) {
- ALOGD("%s {%d, %d} 0x%x 0x%x", s, i.x, i.y, i.x, i.y);
-}
-static void SC_debugI3(const char *s, int3 i) {
- ALOGD("%s {%d, %d, %d} 0x%x 0x%x 0x%x", s, i.x, i.y, i.z, i.x, i.y, i.z);
-}
-static void SC_debugI4(const char *s, int4 i) {
- ALOGD("%s {%d, %d, %d, %d} 0x%x 0x%x 0x%x 0x%x", s, i.x, i.y, i.z, i.w, i.x, i.y, i.z, i.w);
-}
-static void SC_debugU32(const char *s, uint32_t i) {
- ALOGD("%s %u 0x%x", s, i, i);
-}
-static void SC_debugUI2(const char *s, uint2 i) {
- ALOGD("%s {%u, %u} 0x%x 0x%x", s, i.x, i.y, i.x, i.y);
-}
-static void SC_debugUI3(const char *s, uint3 i) {
- ALOGD("%s {%u, %u, %u} 0x%x 0x%x 0x%x", s, i.x, i.y, i.z, i.x, i.y, i.z);
-}
-static void SC_debugUI4(const char *s, uint4 i) {
- ALOGD("%s {%u, %u, %u, %u} 0x%x 0x%x 0x%x 0x%x", s, i.x, i.y, i.z, i.w, i.x, i.y, i.z, i.w);
-}
-static void SC_debugLL64(const char *s, long long ll) {
- ALOGD("%s %lld 0x%llx", s, ll, ll);
-}
-static void SC_debugL2(const char *s, long2 ll) {
- ALOGD("%s {%lld, %lld} 0x%llx 0x%llx", s, ll.x, ll.y, ll.x, ll.y);
-}
-static void SC_debugL3(const char *s, long3 ll) {
- ALOGD("%s {%lld, %lld, %lld} 0x%llx 0x%llx 0x%llx", s, ll.x, ll.y, ll.z, ll.x, ll.y, ll.z);
-}
-static void SC_debugL4(const char *s, long4 ll) {
- ALOGD("%s {%lld, %lld, %lld, %lld} 0x%llx 0x%llx 0x%llx 0x%llx", s, ll.x, ll.y, ll.z, ll.w, ll.x, ll.y, ll.z, ll.w);
-}
-static void SC_debugULL64(const char *s, unsigned long long ll) {
- ALOGD("%s %llu 0x%llx", s, ll, ll);
-}
-static void SC_debugUL2(const char *s, ulong2 ll) {
- ALOGD("%s {%llu, %llu} 0x%llx 0x%llx", s, ll.x, ll.y, ll.x, ll.y);
-}
-static void SC_debugUL3(const char *s, ulong3 ll) {
- ALOGD("%s {%llu, %llu, %llu} 0x%llx 0x%llx 0x%llx", s, ll.x, ll.y, ll.z, ll.x, ll.y, ll.z);
-}
-static void SC_debugUL4(const char *s, ulong4 ll) {
- ALOGD("%s {%llu, %llu, %llu, %llu} 0x%llx 0x%llx 0x%llx 0x%llx", s, ll.x, ll.y, ll.z, ll.w, ll.x, ll.y, ll.z, ll.w);
-}
-static void SC_debugP(const char *s, const void *p) {
- ALOGD("%s %p", s, p);
-}
-
-
-//////////////////////////////////////////////////////////////////////////////
-// Stub implementation
-//////////////////////////////////////////////////////////////////////////////
-
-// llvm name mangling ref
-// <builtin-type> ::= v # void
-// ::= b # bool
-// ::= c # char
-// ::= a # signed char
-// ::= h # unsigned char
-// ::= s # short
-// ::= t # unsigned short
-// ::= i # int
-// ::= j # unsigned int
-// ::= l # long
-// ::= m # unsigned long
-// ::= x # long long, __int64
-// ::= y # unsigned long long, __int64
-// ::= f # float
-// ::= d # double
-
-static RsdSymbolTable gSyms[] = {
- { "memset", (void *)&memset, true },
- { "memcpy", (void *)&memcpy, true },
-
- // Refcounting
- { "_Z11rsSetObjectP10rs_elementS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP10rs_element", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject10rs_element", (void *)&SC_IsObject, true },
-
- { "_Z11rsSetObjectP7rs_typeS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP7rs_type", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject7rs_type", (void *)&SC_IsObject, true },
-
- { "_Z11rsSetObjectP13rs_allocationS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP13rs_allocation", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject13rs_allocation", (void *)&SC_IsObject, true },
-
- { "_Z11rsSetObjectP10rs_samplerS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP10rs_sampler", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject10rs_sampler", (void *)&SC_IsObject, true },
-
- { "_Z11rsSetObjectP9rs_scriptS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP9rs_script", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject9rs_script", (void *)&SC_IsObject, true },
-
- { "_Z11rsSetObjectP7rs_pathS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP7rs_path", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject7rs_path", (void *)&SC_IsObject, true },
-
- { "_Z11rsSetObjectP7rs_meshS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP7rs_mesh", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject7rs_mesh", (void *)&SC_IsObject, true },
-
- { "_Z11rsSetObjectP19rs_program_fragmentS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP19rs_program_fragment", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject19rs_program_fragment", (void *)&SC_IsObject, true },
-
- { "_Z11rsSetObjectP17rs_program_vertexS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP17rs_program_vertex", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject17rs_program_vertex", (void *)&SC_IsObject, true },
-
- { "_Z11rsSetObjectP17rs_program_rasterS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP17rs_program_raster", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject17rs_program_raster", (void *)&SC_IsObject, true },
-
- { "_Z11rsSetObjectP16rs_program_storeS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP16rs_program_store", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject16rs_program_store", (void *)&SC_IsObject, true },
-
- { "_Z11rsSetObjectP7rs_fontS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP7rs_font", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject7rs_font", (void *)&SC_IsObject, true },
-
- // Allocation ops
- { "_Z21rsAllocationMarkDirty13rs_allocation", (void *)&SC_AllocationSyncAll, true },
- { "_Z20rsgAllocationSyncAll13rs_allocation", (void *)&SC_AllocationSyncAll, false },
- { "_Z20rsgAllocationSyncAll13rs_allocationj", (void *)&SC_AllocationSyncAll2, false },
- { "_Z20rsgAllocationSyncAll13rs_allocation24rs_allocation_usage_type", (void *)&SC_AllocationSyncAll2, false },
- { "_Z15rsGetAllocationPKv", (void *)&SC_GetAllocation, true },
- { "_Z23rsAllocationCopy1DRange13rs_allocationjjjS_jj", (void *)&SC_AllocationCopy1DRange, false },
- { "_Z23rsAllocationCopy2DRange13rs_allocationjjj26rs_allocation_cubemap_facejjS_jjjS0_", (void *)&SC_AllocationCopy2DRange, false },
-
- // Messaging
-
- { "_Z14rsSendToClienti", (void *)&SC_ToClient, false },
- { "_Z14rsSendToClientiPKvj", (void *)&SC_ToClient2, false },
- { "_Z22rsSendToClientBlockingi", (void *)&SC_ToClientBlocking, false },
- { "_Z22rsSendToClientBlockingiPKvj", (void *)&SC_ToClientBlocking2, false },
-
- { "_Z9rsForEach9rs_script13rs_allocationS0_", (void *)&SC_ForEach_SAA, true },
- { "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach_SAAU, true },
- { "_Z9rsForEach9rs_script13rs_allocationS0_PKvPK16rs_script_call_t", (void *)&SC_ForEach_SAAUS, true },
- { "_Z9rsForEach9rs_script13rs_allocationS0_PKvj", (void *)&SC_ForEach_SAAUL, true },
- { "_Z9rsForEach9rs_script13rs_allocationS0_PKvjPK16rs_script_call_t", (void *)&SC_ForEach_SAAULS, true },
-
- // time
- { "_Z6rsTimePi", (void *)&SC_Time, true },
- { "_Z11rsLocaltimeP5rs_tmPKi", (void *)&SC_LocalTime, true },
- { "_Z14rsUptimeMillisv", (void*)&SC_UptimeMillis, true },
- { "_Z13rsUptimeNanosv", (void*)&SC_UptimeNanos, true },
- { "_Z7rsGetDtv", (void*)&SC_GetDt, false },
-
- // Debug
- { "_Z7rsDebugPKcf", (void *)&SC_debugF, true },
- { "_Z7rsDebugPKcff", (void *)&SC_debugFv2, true },
- { "_Z7rsDebugPKcfff", (void *)&SC_debugFv3, true },
- { "_Z7rsDebugPKcffff", (void *)&SC_debugFv4, true },
- { "_Z7rsDebugPKcDv2_f", (void *)&SC_debugF2, true },
- { "_Z7rsDebugPKcDv3_f", (void *)&SC_debugF3, true },
- { "_Z7rsDebugPKcDv4_f", (void *)&SC_debugF4, true },
- { "_Z7rsDebugPKcd", (void *)&SC_debugD, true },
- { "_Z7rsDebugPKcPK12rs_matrix4x4", (void *)&SC_debugFM4v4, true },
- { "_Z7rsDebugPKcPK12rs_matrix3x3", (void *)&SC_debugFM3v3, true },
- { "_Z7rsDebugPKcPK12rs_matrix2x2", (void *)&SC_debugFM2v2, true },
- { "_Z7rsDebugPKcc", (void *)&SC_debugI8, true },
- { "_Z7rsDebugPKcDv2_c", (void *)&SC_debugC2, true },
- { "_Z7rsDebugPKcDv3_c", (void *)&SC_debugC3, true },
- { "_Z7rsDebugPKcDv4_c", (void *)&SC_debugC4, true },
- { "_Z7rsDebugPKch", (void *)&SC_debugU8, true },
- { "_Z7rsDebugPKcDv2_h", (void *)&SC_debugUC2, true },
- { "_Z7rsDebugPKcDv3_h", (void *)&SC_debugUC3, true },
- { "_Z7rsDebugPKcDv4_h", (void *)&SC_debugUC4, true },
- { "_Z7rsDebugPKcs", (void *)&SC_debugI16, true },
- { "_Z7rsDebugPKcDv2_s", (void *)&SC_debugS2, true },
- { "_Z7rsDebugPKcDv3_s", (void *)&SC_debugS3, true },
- { "_Z7rsDebugPKcDv4_s", (void *)&SC_debugS4, true },
- { "_Z7rsDebugPKct", (void *)&SC_debugU16, true },
- { "_Z7rsDebugPKcDv2_t", (void *)&SC_debugUS2, true },
- { "_Z7rsDebugPKcDv3_t", (void *)&SC_debugUS3, true },
- { "_Z7rsDebugPKcDv4_t", (void *)&SC_debugUS4, true },
- { "_Z7rsDebugPKci", (void *)&SC_debugI32, true },
- { "_Z7rsDebugPKcDv2_i", (void *)&SC_debugI2, true },
- { "_Z7rsDebugPKcDv3_i", (void *)&SC_debugI3, true },
- { "_Z7rsDebugPKcDv4_i", (void *)&SC_debugI4, true },
- { "_Z7rsDebugPKcj", (void *)&SC_debugU32, true },
- { "_Z7rsDebugPKcDv2_j", (void *)&SC_debugUI2, true },
- { "_Z7rsDebugPKcDv3_j", (void *)&SC_debugUI3, true },
- { "_Z7rsDebugPKcDv4_j", (void *)&SC_debugUI4, true },
- // Both "long" and "unsigned long" need to be redirected to their
- // 64-bit counterparts, since we have hacked Slang to use 64-bit
- // for "long" on Arm (to be similar to Java).
- { "_Z7rsDebugPKcl", (void *)&SC_debugLL64, true },
- { "_Z7rsDebugPKcDv2_l", (void *)&SC_debugL2, true },
- { "_Z7rsDebugPKcDv3_l", (void *)&SC_debugL3, true },
- { "_Z7rsDebugPKcDv4_l", (void *)&SC_debugL4, true },
- { "_Z7rsDebugPKcm", (void *)&SC_debugULL64, true },
- { "_Z7rsDebugPKcDv2_m", (void *)&SC_debugUL2, true },
- { "_Z7rsDebugPKcDv3_m", (void *)&SC_debugUL3, true },
- { "_Z7rsDebugPKcDv4_m", (void *)&SC_debugUL4, true },
- { "_Z7rsDebugPKcx", (void *)&SC_debugLL64, true },
- { "_Z7rsDebugPKcDv2_x", (void *)&SC_debugL2, true },
- { "_Z7rsDebugPKcDv3_x", (void *)&SC_debugL3, true },
- { "_Z7rsDebugPKcDv4_x", (void *)&SC_debugL4, true },
- { "_Z7rsDebugPKcy", (void *)&SC_debugULL64, true },
- { "_Z7rsDebugPKcDv2_y", (void *)&SC_debugUL2, true },
- { "_Z7rsDebugPKcDv3_y", (void *)&SC_debugUL3, true },
- { "_Z7rsDebugPKcDv4_y", (void *)&SC_debugUL4, true },
- { "_Z7rsDebugPKcPKv", (void *)&SC_debugP, true },
-
- { NULL, NULL, false }
-};
-
-#define CLEAR_SET_OBJ(t) \
-void __attribute__((overloadable)) rsClearObject(t *dst) { \
- return SC_ClearObject((ObjectBase**) dst); \
-} \
-void __attribute__((overloadable)) rsSetObject(t *dst, t src) { \
- return SC_SetObject((ObjectBase**) dst, (ObjectBase*) src.p); \
-}
-
-CLEAR_SET_OBJ(rs_element)
-CLEAR_SET_OBJ(rs_type)
-CLEAR_SET_OBJ(rs_allocation)
-CLEAR_SET_OBJ(rs_sampler)
-CLEAR_SET_OBJ(rs_script)
-#undef CLEAR_SET_OBJ
-
-// TODO: allocation ops, messaging, time
-
-void rsDebug(const char *s, float f) {
- SC_debugF(s, f);
-}
-
-void rsDebug(const char *s, float f1, float f2) {
- SC_debugFv2(s, f1, f2);
-}
-
-void rsDebug(const char *s, float f1, float f2, float f3) {
- SC_debugFv3(s, f1, f2, f3);
-}
-
-void rsDebug(const char *s, float f1, float f2, float f3, float f4) {
- SC_debugFv4(s, f1, f2, f3, f4);
-}
-
-void rsDebug(const char *s, float2 f) {
- SC_debugF2(s, f);
-}
-
-void rsDebug(const char *s, float3 f) {
- SC_debugF3(s, f);
-}
-
-void rsDebug(const char *s, float4 f) {
- SC_debugF4(s, f);
-}
-
-void rsDebug(const char *s, double d) {
- SC_debugD(s, d);
-}
-
-void rsDebug(const char *s, rs_matrix4x4 *m) {
- SC_debugFM4v4(s, (float *) m);
-}
-
-void rsDebug(const char *s, rs_matrix3x3 *m) {
- SC_debugFM4v4(s, (float *) m);
-}
-
-void rsDebug(const char *s, rs_matrix2x2 *m) {
- SC_debugFM4v4(s, (float *) m);
-}
-
-void rsDebug(const char *s, char c) {
- SC_debugI8(s, c);
-}
-
-void rsDebug(const char *s, char2 c) {
- SC_debugC2(s, c);
-}
-
-void rsDebug(const char *s, char3 c) {
- SC_debugC3(s, c);
-}
-
-void rsDebug(const char *s, char4 c) {
- SC_debugC4(s, c);
-}
-
-void rsDebug(const char *s, unsigned char c) {
- SC_debugU8(s, c);
-}
-
-void rsDebug(const char *s, uchar2 c) {
- SC_debugUC2(s, c);
-}
-
-void rsDebug(const char *s, uchar3 c) {
- SC_debugUC3(s, c);
-}
-
-void rsDebug(const char *s, uchar4 c) {
- SC_debugUC4(s, c);
-}
-
-void rsDebug(const char *s, short c) {
- SC_debugI16(s, c);
-}
-
-void rsDebug(const char *s, short2 c) {
- SC_debugS2(s, c);
-}
-
-void rsDebug(const char *s, short3 c) {
- SC_debugS3(s, c);
-}
-
-void rsDebug(const char *s, short4 c) {
- SC_debugS4(s, c);
-}
-
-void rsDebug(const char *s, unsigned short c) {
- SC_debugU16(s, c);
-}
-
-void rsDebug(const char *s, ushort2 c) {
- SC_debugUS2(s, c);
-}
-
-void rsDebug(const char *s, ushort3 c) {
- SC_debugUS3(s, c);
-}
-
-void rsDebug(const char *s, ushort4 c) {
- SC_debugUS4(s, c);
-}
-
-void rsDebug(const char *s, int c) {
- SC_debugI32(s, c);
-}
-
-void rsDebug(const char *s, int2 c) {
- SC_debugI2(s, c);
-}
-
-void rsDebug(const char *s, int3 c) {
- SC_debugI3(s, c);
-}
-
-void rsDebug(const char *s, int4 c) {
- SC_debugI4(s, c);
-}
-
-void rsDebug(const char *s, unsigned int c) {
- SC_debugU32(s, c);
-}
-
-void rsDebug(const char *s, uint2 c) {
- SC_debugUI2(s, c);
-}
-
-void rsDebug(const char *s, uint3 c) {
- SC_debugUI3(s, c);
-}
-
-void rsDebug(const char *s, uint4 c) {
- SC_debugUI4(s, c);
-}
-
-void rsDebug(const char *s, long c) {
- SC_debugLL64(s, c);
-}
-
-void rsDebug(const char *s, long long c) {
- SC_debugLL64(s, c);
-}
-
-void rsDebug(const char *s, long2 c) {
- SC_debugL2(s, c);
-}
-
-void rsDebug(const char *s, long3 c) {
- SC_debugL3(s, c);
-}
-
-void rsDebug(const char *s, long4 c) {
- SC_debugL4(s, c);
-}
-
-void rsDebug(const char *s, unsigned long c) {
- SC_debugULL64(s, c);
-}
-
-void rsDebug(const char *s, unsigned long long c) {
- SC_debugULL64(s, c);
-}
-
-void rsDebug(const char *s, ulong2 c) {
- SC_debugUL2(s, c);
-}
-
-void rsDebug(const char *s, ulong3 c) {
- SC_debugUL3(s, c);
-}
-
-void rsDebug(const char *s, ulong4 c) {
- SC_debugUL4(s, c);
-}
-
-void rsDebug(const char *s, const void *p) {
- SC_debugP(s, p);
-}
-
-
-void* rsdLookupRuntimeStub(void* pContext, char const* name) {
- ScriptC *s = (ScriptC *)pContext;
- RsdSymbolTable *syms = gSyms;
- const RsdSymbolTable *sym = rsdLookupSymbolMath(name);
-
- if (!sym) {
- while (syms->mPtr) {
- if (!strcmp(syms->mName, name)) {
- sym = syms;
- }
- syms++;
- }
- }
-
- if (sym) {
- s->mHal.info.isThreadable &= sym->threadable;
- return sym->mPtr;
- }
- ALOGE("ScriptC sym lookup failed for %s", name);
- return NULL;
-}
-
-
diff --git a/renderscript/v8/rs_support/driver/rsdSampler.cpp b/renderscript/v8/rs_support/driver/rsdSampler.cpp
deleted file mode 100644
index af32e34..0000000
--- a/renderscript/v8/rs_support/driver/rsdSampler.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include "rsdCore.h"
-#include "rsdSampler.h"
-
-#include "rsContext.h"
-#include "rsSampler.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-bool rsdSamplerInit(const android::renderscript::Context *,
- const android::renderscript::Sampler *) {
- return true;
-}
-
-void rsdSamplerDestroy(const android::renderscript::Context *rsc,
- const android::renderscript::Sampler *s) {
-}
diff --git a/renderscript/v8/rs_support/driver/rsdSampler.h b/renderscript/v8/rs_support/driver/rsdSampler.h
deleted file mode 100644
index 3a64e9e..0000000
--- a/renderscript/v8/rs_support/driver/rsdSampler.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef RSD_SAMPLER_H
-#define RSD_SAMPLER_H
-
-#include <rs_hal.h>
-
-
-bool rsdSamplerInit(const android::renderscript::Context *rsc,
- const android::renderscript::Sampler *);
-
-void rsdSamplerDestroy(const android::renderscript::Context *rsc,
- const android::renderscript::Sampler *);
-
-
-#endif // RSD_SAMPLER_H
diff --git a/renderscript/v8/rs_support/driver/rsdScriptGroup.cpp b/renderscript/v8/rs_support/driver/rsdScriptGroup.cpp
deleted file mode 100644
index e50cfc3..0000000
--- a/renderscript/v8/rs_support/driver/rsdScriptGroup.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsdCore.h"
-
-#include <bcc/BCCContext.h>
-#include <bcc/Renderscript/RSCompilerDriver.h>
-#include <bcc/Renderscript/RSExecutable.h>
-#include <bcc/Renderscript/RSInfo.h>
-
-#include "rsScript.h"
-#include "rsScriptGroup.h"
-#include "rsdScriptGroup.h"
-#include "rsdBcc.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-
-bool rsdScriptGroupInit(const android::renderscript::Context *rsc,
- const android::renderscript::ScriptGroup *sg) {
- return true;
-}
-
-void rsdScriptGroupSetInput(const android::renderscript::Context *rsc,
- const android::renderscript::ScriptGroup *sg,
- const android::renderscript::ScriptKernelID *kid,
- android::renderscript::Allocation *) {
-}
-
-void rsdScriptGroupSetOutput(const android::renderscript::Context *rsc,
- const android::renderscript::ScriptGroup *sg,
- const android::renderscript::ScriptKernelID *kid,
- android::renderscript::Allocation *) {
-}
-
-void rsdScriptGroupExecute(const android::renderscript::Context *rsc,
- const android::renderscript::ScriptGroup *sg) {
-
- Vector<Allocation *> ins;
- Vector<Allocation *> outs;
- Vector<const ScriptKernelID *> kernels;
-
- for (size_t ct=0; ct < sg->mNodes.size(); ct++) {
- ScriptGroup::Node *n = sg->mNodes[ct];
- //ALOGE("node %i, order %i, in %i out %i", (int)ct, n->mOrder, (int)n->mInputs.size(), (int)n->mOutputs.size());
-
- for (size_t ct2=0; ct2 < n->mKernels.size(); ct2++) {
- const ScriptKernelID *k = n->mKernels[ct2];
- Allocation *ain = NULL;
- Allocation *aout = NULL;
-
- for (size_t ct3=0; ct3 < n->mInputs.size(); ct3++) {
- if (n->mInputs[ct3]->mDstKernel.get() == k) {
- ain = n->mInputs[ct3]->mAlloc.get();
- //ALOGE(" link in %p", ain);
- }
- }
- for (size_t ct3=0; ct3 < sg->mInputs.size(); ct3++) {
- if (sg->mInputs[ct3]->mKernel == k) {
- ain = sg->mInputs[ct3]->mAlloc.get();
- //ALOGE(" io in %p", ain);
- }
- }
-
- for (size_t ct3=0; ct3 < n->mOutputs.size(); ct3++) {
- if (n->mOutputs[ct3]->mSource.get() == k) {
- aout = n->mOutputs[ct3]->mAlloc.get();
- //ALOGE(" link out %p", aout);
- }
- }
- for (size_t ct3=0; ct3 < sg->mOutputs.size(); ct3++) {
- if (sg->mOutputs[ct3]->mKernel == k) {
- aout = sg->mOutputs[ct3]->mAlloc.get();
- //ALOGE(" io out %p", aout);
- }
- }
-
- ins.add(ain);
- outs.add(aout);
- kernels.add(k);
- }
-
- }
-
- RsdHal * dc = (RsdHal *)rsc->mHal.drv;
- MTLaunchStruct mtls;
- for (size_t ct=0; ct < ins.size(); ct++) {
-
- Script *s = kernels[ct]->mScript;
- DrvScript *drv = (DrvScript *)s->mHal.drv;
- uint32_t slot = kernels[ct]->mSlot;
-
- rsdScriptInvokeForEachMtlsSetup(rsc, ins[ct], outs[ct], NULL, 0, NULL, &mtls);
- mtls.script = s;
- mtls.fep.slot = slot;
-
- if (drv->mIntrinsicID) {
- mtls.kernel = (void (*)())drv->mIntrinsicFuncs.root;
- mtls.fep.usr = drv->mIntrinsicData;
- } else {
- mtls.kernel = drv->mForEachFunctions[slot];
- rsAssert(mtls.kernel != NULL);
- mtls.sig = drv->mForEachSignatures[slot];
- }
-
-// typedef void (*outer_foreach_t)(
- // const android::renderscript::RsForEachStubParamStruct *,
- // uint32_t x1, uint32_t x2,
- // uint32_t instep, uint32_t outstep);
- //outer_foreach_t fn = (outer_foreach_t) mtls->kernel;
-
- rsdScriptLaunchThreads(rsc, s, slot, ins[ct], outs[ct], NULL, 0, NULL, &mtls);
- }
-
-}
-
-void rsdScriptGroupDestroy(const android::renderscript::Context *rsc,
- const android::renderscript::ScriptGroup *sg) {
-}
-
-
diff --git a/renderscript/v8/rs_support/driver/rsdScriptGroup.h b/renderscript/v8/rs_support/driver/rsdScriptGroup.h
deleted file mode 100644
index a817aef..0000000
--- a/renderscript/v8/rs_support/driver/rsdScriptGroup.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef RSD_SCRIPT_GROUP_H
-#define RSD_SCRIPT_GROUP_H
-
-#include <rs_hal.h>
-
-bool rsdScriptGroupInit(const android::renderscript::Context *rsc,
- const android::renderscript::ScriptGroup *sg);
-void rsdScriptGroupSetInput(const android::renderscript::Context *rsc,
- const android::renderscript::ScriptGroup *sg,
- const android::renderscript::ScriptKernelID *kid,
- android::renderscript::Allocation *);
-void rsdScriptGroupSetOutput(const android::renderscript::Context *rsc,
- const android::renderscript::ScriptGroup *sg,
- const android::renderscript::ScriptKernelID *kid,
- android::renderscript::Allocation *);
-void rsdScriptGroupExecute(const android::renderscript::Context *rsc,
- const android::renderscript::ScriptGroup *sg);
-void rsdScriptGroupDestroy(const android::renderscript::Context *rsc,
- const android::renderscript::ScriptGroup *sg);
-
-
-#endif // RSD_SCRIPT_GROUP_H
diff --git a/renderscript/v8/rs_support/rs.h b/renderscript/v8/rs_support/rs.h
deleted file mode 100644
index 825b9b8..0000000
--- a/renderscript/v8/rs_support/rs.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef RENDER_SCRIPT_H
-#define RENDER_SCRIPT_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "rsDefines.h"
-
-//
-// A3D loading and object update code.
-// Should only be called at object creation, not thread safe
-RsObjectBase rsaFileA3DGetEntryByIndex(RsContext, uint32_t idx, RsFile);
-RsFile rsaFileA3DCreateFromMemory(RsContext, const void *data, uint32_t len);
-RsFile rsaFileA3DCreateFromAsset(RsContext, void *asset);
-RsFile rsaFileA3DCreateFromFile(RsContext, const char *path);
-void rsaFileA3DGetNumIndexEntries(RsContext, int32_t *numEntries, RsFile);
-void rsaFileA3DGetIndexEntries(RsContext, RsFileIndexEntry *fileEntries,
- uint32_t numEntries, RsFile);
-void rsaGetName(RsContext, void * obj, const char **name);
-// Mesh update functions
-void rsaMeshGetVertexBufferCount(RsContext, RsMesh, int32_t *vtxCount);
-void rsaMeshGetIndexCount(RsContext, RsMesh, int32_t *idxCount);
-void rsaMeshGetVertices(RsContext, RsMesh, RsAllocation *vtxData, uint32_t vtxDataCount);
-void rsaMeshGetIndices(RsContext, RsMesh, RsAllocation *va,
- uint32_t *primType, uint32_t idxDataCount);
-// Allocation update
-const void* rsaAllocationGetType(RsContext con, RsAllocation va);
-// Type update
-void rsaTypeGetNativeData(RsContext, RsType, uint32_t *typeData, uint32_t typeDataSize);
-// Element update
-void rsaElementGetNativeData(RsContext, RsElement, uint32_t *elemData, uint32_t elemDataSize);
-void rsaElementGetSubElements(RsContext, RsElement, uint32_t *ids, const char **names,
- uint32_t *arraySizes, uint32_t dataSize);
-
-RsDevice rsDeviceCreate();
-void rsDeviceDestroy(RsDevice dev);
-void rsDeviceSetConfig(RsDevice dev, RsDeviceParam p, int32_t value);
-RsContext rsContextCreate(RsDevice dev, uint32_t version, uint32_t sdkVersion);
-RsContext rsContextCreateGL(RsDevice dev, uint32_t version, uint32_t sdkVersion,
- RsSurfaceConfig sc, uint32_t dpi);
-
-#include "rsgApiFuncDecl.h"
-
-#endif // RENDER_SCRIPT_H
-
-
-
diff --git a/renderscript/v8/rs_support/rs.spec b/renderscript/v8/rs_support/rs.spec
deleted file mode 100644
index 4fcee13..0000000
--- a/renderscript/v8/rs_support/rs.spec
+++ /dev/null
@@ -1,332 +0,0 @@
-
-ContextDestroy {
- direct
-}
-
-ContextGetMessage {
- direct
- param void *data
- param size_t *receiveLen
- param uint32_t *usrID
- ret RsMessageToClientType
-}
-
-ContextPeekMessage {
- direct
- param size_t *receiveLen
- param uint32_t *usrID
- ret RsMessageToClientType
-}
-
-ContextInitToClient {
- direct
-}
-
-ContextDeinitToClient {
- direct
-}
-
-TypeCreate {
- direct
- param RsElement e
- param uint32_t dimX
- param uint32_t dimY
- param uint32_t dimZ
- param bool mips
- param bool faces
- ret RsType
-}
-
-AllocationCreateTyped {
- direct
- param RsType vtype
- param RsAllocationMipmapControl mips
- param uint32_t usages
- param uint32_t ptr
- ret RsAllocation
-}
-
-AllocationCreateFromBitmap {
- direct
- param RsType vtype
- param RsAllocationMipmapControl mips
- param const void *data
- param uint32_t usages
- ret RsAllocation
-}
-
-AllocationCubeCreateFromBitmap {
- direct
- param RsType vtype
- param RsAllocationMipmapControl mips
- param const void *data
- param uint32_t usages
- ret RsAllocation
-}
-
-
-ContextFinish {
- sync
- }
-
-ContextDump {
- param int32_t bits
-}
-
-ContextSetPriority {
- param int32_t priority
- }
-
-ContextDestroyWorker {
- sync
-}
-
-AssignName {
- param RsObjectBase obj
- param const char *name
- }
-
-ObjDestroy {
- param RsAsyncVoidPtr objPtr
- }
-
-ElementCreate {
- direct
- param RsDataType mType
- param RsDataKind mKind
- param bool mNormalized
- param uint32_t mVectorSize
- ret RsElement
- }
-
-ElementCreate2 {
- direct
- param const RsElement * elements
- param const char ** names
- param const uint32_t * arraySize
- ret RsElement
- }
-
-AllocationCopyToBitmap {
- param RsAllocation alloc
- param void * data
- }
-
-
-Allocation1DData {
- param RsAllocation va
- param uint32_t xoff
- param uint32_t lod
- param uint32_t count
- param const void *data
- }
-
-Allocation1DElementData {
- param RsAllocation va
- param uint32_t x
- param uint32_t lod
- param const void *data
- param size_t comp_offset
- }
-
-Allocation2DData {
- param RsAllocation va
- param uint32_t xoff
- param uint32_t yoff
- param uint32_t lod
- param RsAllocationCubemapFace face
- param uint32_t w
- param uint32_t h
- param const void *data
- }
-
-Allocation2DElementData {
- param RsAllocation va
- param uint32_t x
- param uint32_t y
- param uint32_t lod
- param RsAllocationCubemapFace face
- param const void *data
- param size_t element_offset
- }
-
-AllocationGenerateMipmaps {
- param RsAllocation va
-}
-
-AllocationRead {
- param RsAllocation va
- param void * data
- }
-
-AllocationSyncAll {
- param RsAllocation va
- param RsAllocationUsageType src
-}
-
-
-AllocationResize1D {
- param RsAllocation va
- param uint32_t dimX
- }
-
-AllocationResize2D {
- param RsAllocation va
- param uint32_t dimX
- param uint32_t dimY
- }
-
-AllocationCopy2DRange {
- param RsAllocation dest
- param uint32_t destXoff
- param uint32_t destYoff
- param uint32_t destMip
- param uint32_t destFace
- param uint32_t width
- param uint32_t height
- param RsAllocation src
- param uint32_t srcXoff
- param uint32_t srcYoff
- param uint32_t srcMip
- param uint32_t srcFace
- }
-
-SamplerCreate {
- direct
- param RsSamplerValue magFilter
- param RsSamplerValue minFilter
- param RsSamplerValue wrapS
- param RsSamplerValue wrapT
- param RsSamplerValue wrapR
- param float mAniso
- ret RsSampler
-}
-
-ScriptBindAllocation {
- param RsScript vtm
- param RsAllocation va
- param uint32_t slot
- }
-
-ScriptSetTimeZone {
- param RsScript s
- param const char * timeZone
- }
-
-ScriptInvoke {
- param RsScript s
- param uint32_t slot
- }
-
-ScriptInvokeV {
- param RsScript s
- param uint32_t slot
- param const void * data
- }
-
-ScriptForEach {
- param RsScript s
- param uint32_t slot
- param RsAllocation ain
- param RsAllocation aout
- param const void * usr
-}
-
-ScriptSetVarI {
- param RsScript s
- param uint32_t slot
- param int value
- }
-
-ScriptSetVarObj {
- param RsScript s
- param uint32_t slot
- param RsObjectBase value
- }
-
-ScriptSetVarJ {
- param RsScript s
- param uint32_t slot
- param int64_t value
- }
-
-ScriptSetVarF {
- param RsScript s
- param uint32_t slot
- param float value
- }
-
-ScriptSetVarD {
- param RsScript s
- param uint32_t slot
- param double value
- }
-
-ScriptSetVarV {
- param RsScript s
- param uint32_t slot
- param const void * data
- }
-
-ScriptSetVarVE {
- param RsScript s
- param uint32_t slot
- param const void * data
- param RsElement e
- param const size_t * dims
- }
-
-
-ScriptCCreate {
- param const char * resName
- param const char * cacheDir
- param const char * text
- ret RsScript
- }
-
-ScriptIntrinsicCreate {
- param uint32_t id
- param RsElement eid
- ret RsScript
- }
-
-ScriptKernelIDCreate {
- direct
- param RsScript sid
- param int slot
- param int sig
- ret RsScriptKernelID
- }
-
-ScriptFieldIDCreate {
- direct
- param RsScript sid
- param int slot
- ret RsScriptFieldID
- }
-
-ScriptGroupCreate {
- direct
- param RsScriptKernelID * kernels
- param RsScriptKernelID * src
- param RsScriptKernelID * dstK
- param RsScriptFieldID * dstF
- param const RsType * type
- ret RsScriptGroup
-}
-
-ScriptGroupSetOutput {
- param RsScriptGroup group
- param RsScriptKernelID kernel
- param RsAllocation alloc
-}
-
-ScriptGroupSetInput {
- param RsScriptGroup group
- param RsScriptKernelID kernel
- param RsAllocation alloc
-}
-
-ScriptGroupExecute {
- param RsScriptGroup group
-}
diff --git a/renderscript/v8/rs_support/rsAdapter.cpp b/renderscript/v8/rs_support/rsAdapter.cpp
deleted file mode 100644
index 13a728f..0000000
--- a/renderscript/v8/rs_support/rsAdapter.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsContext.h"
-#include "rsAdapter.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-Adapter1D::Adapter1D(Context *rsc) : ObjectBase(rsc) {
- reset();
-}
-
-Adapter1D::Adapter1D(Context *rsc, Allocation *a) : ObjectBase(rsc) {
- reset();
- setAllocation(a);
-}
-
-void Adapter1D::reset() {
- mY = 0;
- mZ = 0;
- mLOD = 0;
- mFace = RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X;
-}
-
-void Adapter1D::data(Context *rsc, uint32_t x, uint32_t count, const void *data, size_t sizeBytes) {
- mAllocation->data(rsc, x, mY, mLOD, mFace, count, 1, data, sizeBytes);
-}
-
-void Adapter1D::serialize(Context *rsc, OStream *stream) const {
-}
-
-Adapter1D *Adapter1D::createFromStream(Context *rsc, IStream *stream) {
- return NULL;
-}
-
-namespace android {
-namespace renderscript {
-
-RsAdapter1D rsi_Adapter1DCreate(Context *rsc) {
- Adapter1D *a = new Adapter1D(rsc);
- a->incUserRef();
- return a;
-}
-
-void rsi_Adapter1DBindAllocation(Context *rsc, RsAdapter1D va, RsAllocation valloc) {
- Adapter1D * a = static_cast<Adapter1D *>(va);
- Allocation * alloc = static_cast<Allocation *>(valloc);
- a->setAllocation(alloc);
-}
-
-void rsi_Adapter1DSetConstraint(Context *rsc, RsAdapter1D va, RsDimension dim, uint32_t value) {
- Adapter1D * a = static_cast<Adapter1D *>(va);
- switch (dim) {
- case RS_DIMENSION_X:
- rsAssert(!"Cannot contrain X in an 1D adapter");
- return;
- case RS_DIMENSION_Y:
- a->setY(value);
- break;
- case RS_DIMENSION_Z:
- a->setZ(value);
- break;
- case RS_DIMENSION_LOD:
- a->setLOD(value);
- break;
- case RS_DIMENSION_FACE:
- a->setFace((RsAllocationCubemapFace)value);
- break;
- default:
- rsAssert(!"Unimplemented constraint");
- return;
- }
-}
-
-}
-}
-
-//////////////////////////
-
-Adapter2D::Adapter2D(Context *rsc) : ObjectBase(rsc) {
- reset();
-}
-
-Adapter2D::Adapter2D(Context *rsc, Allocation *a) : ObjectBase(rsc) {
- reset();
- setAllocation(a);
-}
-
-void Adapter2D::reset() {
- mZ = 0;
- mLOD = 0;
- mFace = RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X;
-}
-
-
-void Adapter2D::data(Context *rsc, uint32_t x, uint32_t y, uint32_t w, uint32_t h,
- const void *data, size_t sizeBytes) {
- mAllocation->data(rsc, x, y, mLOD, mFace, w, h, data, sizeBytes);
-}
-
-
-void Adapter2D::serialize(Context *rsc, OStream *stream) const {
-}
-
-Adapter2D *Adapter2D::createFromStream(Context *rsc, IStream *stream) {
- return NULL;
-}
-
-
-namespace android {
-namespace renderscript {
-
-RsAdapter2D rsi_Adapter2DCreate(Context *rsc) {
- Adapter2D *a = new Adapter2D(rsc);
- a->incUserRef();
- return a;
-}
-
-void rsi_Adapter2DBindAllocation(Context *rsc, RsAdapter2D va, RsAllocation valloc) {
- Adapter2D * a = static_cast<Adapter2D *>(va);
- Allocation * alloc = static_cast<Allocation *>(valloc);
- a->setAllocation(alloc);
-}
-
-void rsi_Adapter2DSetConstraint(Context *rsc, RsAdapter2D va, RsDimension dim, uint32_t value) {
- Adapter2D * a = static_cast<Adapter2D *>(va);
- switch (dim) {
- case RS_DIMENSION_X:
- rsAssert(!"Cannot contrain X in an 2D adapter");
- return;
- case RS_DIMENSION_Y:
- rsAssert(!"Cannot contrain Y in an 2D adapter");
- break;
- case RS_DIMENSION_Z:
- a->setZ(value);
- break;
- case RS_DIMENSION_LOD:
- a->setLOD(value);
- break;
- case RS_DIMENSION_FACE:
- a->setFace((RsAllocationCubemapFace)value);
- break;
- default:
- rsAssert(!"Unimplemented constraint");
- return;
- }
-}
-
-
-}
-}
diff --git a/renderscript/v8/rs_support/rsAdapter.h b/renderscript/v8/rs_support/rsAdapter.h
deleted file mode 100644
index 7b189cf..0000000
--- a/renderscript/v8/rs_support/rsAdapter.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_RS_ADAPTER_H
-#define ANDROID_RS_ADAPTER_H
-
-#include "rsAllocation.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-
-class Adapter1D : public ObjectBase {
-
-public:
- // By policy this allocation will hold a pointer to the type
- // but will not destroy it on destruction.
- Adapter1D(Context *);
- Adapter1D(Context *, Allocation *);
- void reset();
-
- void setAllocation(Allocation *a) {mAllocation.set(a);}
-
- uint32_t getDimX() const {return mAllocation->getType()->getLODDimX(mLOD);}
-
- const Type * getBaseType() const {return mAllocation->getType();}
-
- inline void setY(uint32_t y) {mY = y;}
- inline void setZ(uint32_t z) {mZ = z;}
- inline void setLOD(uint32_t lod) {mLOD = lod;}
- inline void setFace(RsAllocationCubemapFace face) {mFace = face;}
-
- void data(Context *rsc, uint32_t xoff, uint32_t count, const void *data, size_t sizeBytes);
-
- virtual void serialize(Context *rsc, OStream *stream) const;
- virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_ADAPTER_1D; }
- static Adapter1D *createFromStream(Context *rsc, IStream *stream);
-
-protected:
- ObjectBaseRef<Allocation> mAllocation;
- uint32_t mY;
- uint32_t mZ;
- uint32_t mLOD;
- RsAllocationCubemapFace mFace;
-};
-
-class Adapter2D : public ObjectBase {
-
-public:
- // By policy this allocation will hold a pointer to the type
- // but will not destroy it on destruction.
- Adapter2D(Context *);
- Adapter2D(Context *, Allocation *);
- void reset();
-
- uint32_t getDimX() const {return mAllocation->getType()->getLODDimX(mLOD);}
- uint32_t getDimY() const {return mAllocation->getType()->getLODDimY(mLOD);}
- const Type * getBaseType() const {return mAllocation->getType();}
-
- void setAllocation(Allocation *a) {mAllocation.set(a);}
- inline void setZ(uint32_t z) {mZ = z;}
- inline void setLOD(uint32_t lod) {mLOD = lod;}
- inline void setFace(RsAllocationCubemapFace face) {mFace = face;}
-
- void data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
- const void *data, size_t sizeBytes);
-
- virtual void serialize(Context *rsc, OStream *stream) const;
- virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_ADAPTER_2D; }
- static Adapter2D *createFromStream(Context *rsc, IStream *stream);
-
-protected:
- ObjectBaseRef<Allocation> mAllocation;
- uint32_t mZ;
- uint32_t mLOD;
- RsAllocationCubemapFace mFace;
-};
-
-}
-}
-#endif
-
diff --git a/renderscript/v8/rs_support/rsAllocation.cpp b/renderscript/v8/rs_support/rsAllocation.cpp
deleted file mode 100644
index 6a7a5ab..0000000
--- a/renderscript/v8/rs_support/rsAllocation.cpp
+++ /dev/null
@@ -1,584 +0,0 @@
-/*
- * Copyright (C) 2009-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsContext.h"
-#include "rsAllocation.h"
-#include "rsAdapter.h"
-#include "rs_hal.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-Allocation::Allocation(Context *rsc, const Type *type, uint32_t usages,
- RsAllocationMipmapControl mc, void * ptr)
- : ObjectBase(rsc) {
-
- memset(&mHal, 0, sizeof(mHal));
- mHal.state.mipmapControl = RS_ALLOCATION_MIPMAP_NONE;
- mHal.state.usageFlags = usages;
- mHal.state.mipmapControl = mc;
-
- setType(type);
- updateCache();
-}
-
-Allocation * Allocation::createAllocation(Context *rsc, const Type *type, uint32_t usages,
- RsAllocationMipmapControl mc, void * ptr) {
- Allocation *a = new Allocation(rsc, type, usages, mc, ptr);
-
- if (!rsc->mHal.funcs.allocation.init(rsc, a, type->getElement()->getHasReferences())) {
- rsc->setError(RS_ERROR_FATAL_DRIVER, "Allocation::Allocation, alloc failure");
- delete a;
- return NULL;
- }
-
- return a;
-}
-
-void Allocation::updateCache() {
- const Type *type = mHal.state.type;
- mHal.state.dimensionX = type->getDimX();
- mHal.state.dimensionY = type->getDimY();
- mHal.state.dimensionZ = type->getDimZ();
- mHal.state.hasFaces = type->getDimFaces();
- mHal.state.hasMipmaps = type->getDimLOD();
- mHal.state.elementSizeBytes = type->getElementSizeBytes();
- mHal.state.hasReferences = mHal.state.type->getElement()->getHasReferences();
-}
-
-Allocation::~Allocation() {
- freeChildrenUnlocked();
- mRSC->mHal.funcs.allocation.destroy(mRSC, this);
-}
-
-void Allocation::syncAll(Context *rsc, RsAllocationUsageType src) {
- rsc->mHal.funcs.allocation.syncAll(rsc, this, src);
-}
-
-void Allocation::data(Context *rsc, uint32_t xoff, uint32_t lod,
- uint32_t count, const void *data, size_t sizeBytes) {
- const size_t eSize = mHal.state.type->getElementSizeBytes();
-
- if ((count * eSize) != sizeBytes) {
- ALOGE("Allocation::subData called with mismatched size expected %zu, got %zu",
- (count * eSize), sizeBytes);
- mHal.state.type->dumpLOGV("type info");
- return;
- }
-
- rsc->mHal.funcs.allocation.data1D(rsc, this, xoff, lod, count, data, sizeBytes);
- sendDirty(rsc);
-}
-
-void Allocation::data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, const void *data, size_t sizeBytes) {
- const size_t eSize = mHal.state.elementSizeBytes;
- const size_t lineSize = eSize * w;
-
- //ALOGE("data2d %p, %i %i %i %i %i %i %p %i", this, xoff, yoff, lod, face, w, h, data, sizeBytes);
-
- if ((lineSize * h) != sizeBytes) {
- ALOGE("Allocation size mismatch, expected %zu, got %zu", (lineSize * h), sizeBytes);
- rsAssert(!"Allocation::subData called with mismatched size");
- return;
- }
-
- rsc->mHal.funcs.allocation.data2D(rsc, this, xoff, yoff, lod, face, w, h, data, sizeBytes);
- sendDirty(rsc);
-}
-
-void Allocation::data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t zoff,
- uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, uint32_t d, const void *data, size_t sizeBytes) {
-}
-
-void Allocation::read(Context *rsc, uint32_t xoff, uint32_t lod,
- uint32_t count, void *data, size_t sizeBytes) {
- const size_t eSize = mHal.state.type->getElementSizeBytes();
-
- if ((count * eSize) != sizeBytes) {
- ALOGE("Allocation::read called with mismatched size expected %zu, got %zu",
- (count * eSize), sizeBytes);
- mHal.state.type->dumpLOGV("type info");
- return;
- }
-
- rsc->mHal.funcs.allocation.read1D(rsc, this, xoff, lod, count, data, sizeBytes);
-}
-
-void Allocation::read(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, void *data, size_t sizeBytes) {
- const size_t eSize = mHal.state.elementSizeBytes;
- const size_t lineSize = eSize * w;
-
- if ((lineSize * h) != sizeBytes) {
- ALOGE("Allocation size mismatch, expected %zu, got %zu", (lineSize * h), sizeBytes);
- rsAssert(!"Allocation::read called with mismatched size");
- return;
- }
-
- rsc->mHal.funcs.allocation.read2D(rsc, this, xoff, yoff, lod, face, w, h, data, sizeBytes);
-}
-
-void Allocation::read(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t zoff,
- uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, uint32_t d, void *data, size_t sizeBytes) {
-}
-
-void Allocation::elementData(Context *rsc, uint32_t x, const void *data,
- uint32_t cIdx, size_t sizeBytes) {
- size_t eSize = mHal.state.elementSizeBytes;
-
- if (cIdx >= mHal.state.type->getElement()->getFieldCount()) {
- ALOGE("Error Allocation::subElementData component %i out of range.", cIdx);
- rsc->setError(RS_ERROR_BAD_VALUE, "subElementData component out of range.");
- return;
- }
-
- if (x >= mHal.state.dimensionX) {
- ALOGE("Error Allocation::subElementData X offset %i out of range.", x);
- rsc->setError(RS_ERROR_BAD_VALUE, "subElementData X offset out of range.");
- return;
- }
-
- const Element * e = mHal.state.type->getElement()->getField(cIdx);
- uint32_t elemArraySize = mHal.state.type->getElement()->getFieldArraySize(cIdx);
- if (sizeBytes != e->getSizeBytes() * elemArraySize) {
- ALOGE("Error Allocation::subElementData data size %zu does not match field size %zu.", sizeBytes, e->getSizeBytes());
- rsc->setError(RS_ERROR_BAD_VALUE, "subElementData bad size.");
- return;
- }
-
- rsc->mHal.funcs.allocation.elementData1D(rsc, this, x, data, cIdx, sizeBytes);
- sendDirty(rsc);
-}
-
-void Allocation::elementData(Context *rsc, uint32_t x, uint32_t y,
- const void *data, uint32_t cIdx, size_t sizeBytes) {
- size_t eSize = mHal.state.elementSizeBytes;
-
- if (x >= mHal.state.dimensionX) {
- ALOGE("Error Allocation::subElementData X offset %i out of range.", x);
- rsc->setError(RS_ERROR_BAD_VALUE, "subElementData X offset out of range.");
- return;
- }
-
- if (y >= mHal.state.dimensionY) {
- ALOGE("Error Allocation::subElementData X offset %i out of range.", x);
- rsc->setError(RS_ERROR_BAD_VALUE, "subElementData X offset out of range.");
- return;
- }
-
- if (cIdx >= mHal.state.type->getElement()->getFieldCount()) {
- ALOGE("Error Allocation::subElementData component %i out of range.", cIdx);
- rsc->setError(RS_ERROR_BAD_VALUE, "subElementData component out of range.");
- return;
- }
-
- const Element * e = mHal.state.type->getElement()->getField(cIdx);
- uint32_t elemArraySize = mHal.state.type->getElement()->getFieldArraySize(cIdx);
- if (sizeBytes != e->getSizeBytes() * elemArraySize) {
- ALOGE("Error Allocation::subElementData data size %zu does not match field size %zu.", sizeBytes, e->getSizeBytes());
- rsc->setError(RS_ERROR_BAD_VALUE, "subElementData bad size.");
- return;
- }
-
- rsc->mHal.funcs.allocation.elementData2D(rsc, this, x, y, data, cIdx, sizeBytes);
- sendDirty(rsc);
-}
-
-void Allocation::dumpLOGV(const char *prefix) const {
- ObjectBase::dumpLOGV(prefix);
-
- String8 s(prefix);
- s.append(" type ");
- if (mHal.state.type) {
- mHal.state.type->dumpLOGV(s.string());
- }
-
- ALOGV("%s allocation ptr=%p mUsageFlags=0x04%x, mMipmapControl=0x%04x",
- prefix, mHal.drvState.mallocPtrLOD0, mHal.state.usageFlags, mHal.state.mipmapControl);
-}
-
-uint32_t Allocation::getPackedSize() const {
- uint32_t numItems = mHal.state.type->getSizeBytes() / mHal.state.type->getElementSizeBytes();
- return numItems * mHal.state.type->getElement()->getSizeBytesUnpadded();
-}
-
-void Allocation::writePackedData(Context *rsc, const Type *type,
- uint8_t *dst, const uint8_t *src, bool dstPadded) {
- const Element *elem = type->getElement();
- uint32_t unpaddedBytes = elem->getSizeBytesUnpadded();
- uint32_t paddedBytes = elem->getSizeBytes();
- uint32_t numItems = type->getSizeBytes() / paddedBytes;
-
- uint32_t srcInc = !dstPadded ? paddedBytes : unpaddedBytes;
- uint32_t dstInc = dstPadded ? paddedBytes : unpaddedBytes;
-
- // no sub-elements
- uint32_t fieldCount = elem->getFieldCount();
- if (fieldCount == 0) {
- for (uint32_t i = 0; i < numItems; i ++) {
- memcpy(dst, src, unpaddedBytes);
- src += srcInc;
- dst += dstInc;
- }
- return;
- }
-
- // Cache offsets
- uint32_t *offsetsPadded = new uint32_t[fieldCount];
- uint32_t *offsetsUnpadded = new uint32_t[fieldCount];
- uint32_t *sizeUnpadded = new uint32_t[fieldCount];
-
- for (uint32_t i = 0; i < fieldCount; i++) {
- offsetsPadded[i] = elem->getFieldOffsetBytes(i);
- offsetsUnpadded[i] = elem->getFieldOffsetBytesUnpadded(i);
- sizeUnpadded[i] = elem->getField(i)->getSizeBytesUnpadded();
- }
-
- uint32_t *srcOffsets = !dstPadded ? offsetsPadded : offsetsUnpadded;
- uint32_t *dstOffsets = dstPadded ? offsetsPadded : offsetsUnpadded;
-
- // complex elements, need to copy subelem after subelem
- for (uint32_t i = 0; i < numItems; i ++) {
- for (uint32_t fI = 0; fI < fieldCount; fI++) {
- memcpy(dst + dstOffsets[fI], src + srcOffsets[fI], sizeUnpadded[fI]);
- }
- src += srcInc;
- dst += dstInc;
- }
-
- delete[] offsetsPadded;
- delete[] offsetsUnpadded;
- delete[] sizeUnpadded;
-}
-
-void Allocation::unpackVec3Allocation(Context *rsc, const void *data, size_t dataSize) {
- const uint8_t *src = (const uint8_t*)data;
- uint8_t *dst = (uint8_t *)rsc->mHal.funcs.allocation.lock1D(rsc, this);
-
- writePackedData(rsc, getType(), dst, src, true);
- rsc->mHal.funcs.allocation.unlock1D(rsc, this);
-}
-
-void Allocation::packVec3Allocation(Context *rsc, OStream *stream) const {
- uint32_t paddedBytes = getType()->getElement()->getSizeBytes();
- uint32_t unpaddedBytes = getType()->getElement()->getSizeBytesUnpadded();
- uint32_t numItems = mHal.state.type->getSizeBytes() / paddedBytes;
-
- const uint8_t *src = (const uint8_t*)rsc->mHal.funcs.allocation.lock1D(rsc, this);
- uint8_t *dst = new uint8_t[numItems * unpaddedBytes];
-
- writePackedData(rsc, getType(), dst, src, false);
- stream->addByteArray(dst, getPackedSize());
-
- delete[] dst;
- rsc->mHal.funcs.allocation.unlock1D(rsc, this);
-}
-
-void Allocation::serialize(Context *rsc, OStream *stream) const {
- // Need to identify ourselves
- stream->addU32((uint32_t)getClassId());
-
- String8 name(getName());
- stream->addString(&name);
-
- // First thing we need to serialize is the type object since it will be needed
- // to initialize the class
- mHal.state.type->serialize(rsc, stream);
-
- uint32_t dataSize = mHal.state.type->getSizeBytes();
- // 3 element vectors are padded to 4 in memory, but padding isn't serialized
- uint32_t packedSize = getPackedSize();
- // Write how much data we are storing
- stream->addU32(packedSize);
- if (dataSize == packedSize) {
- // Now write the data
- stream->addByteArray(rsc->mHal.funcs.allocation.lock1D(rsc, this), dataSize);
- rsc->mHal.funcs.allocation.unlock1D(rsc, this);
- } else {
- // Now write the data
- packVec3Allocation(rsc, stream);
- }
-}
-
-Allocation *Allocation::createFromStream(Context *rsc, IStream *stream) {
- // First make sure we are reading the correct object
- RsA3DClassID classID = (RsA3DClassID)stream->loadU32();
- if (classID != RS_A3D_CLASS_ID_ALLOCATION) {
- ALOGE("allocation loading skipped due to invalid class id\n");
- return NULL;
- }
-
- String8 name;
- stream->loadString(&name);
-
- Type *type = Type::createFromStream(rsc, stream);
- if (!type) {
- return NULL;
- }
- type->compute();
-
- Allocation *alloc = Allocation::createAllocation(rsc, type, RS_ALLOCATION_USAGE_SCRIPT);
- type->decUserRef();
-
- // Number of bytes we wrote out for this allocation
- uint32_t dataSize = stream->loadU32();
- // 3 element vectors are padded to 4 in memory, but padding isn't serialized
- uint32_t packedSize = alloc->getPackedSize();
- if (dataSize != type->getSizeBytes() &&
- dataSize != packedSize) {
- ALOGE("failed to read allocation because numbytes written is not the same loaded type wants\n");
- ObjectBase::checkDelete(alloc);
- ObjectBase::checkDelete(type);
- return NULL;
- }
-
- alloc->setName(name.string(), name.size());
-
- if (dataSize == type->getSizeBytes()) {
- uint32_t count = dataSize / type->getElementSizeBytes();
- // Read in all of our allocation data
- alloc->data(rsc, 0, 0, count, stream->getPtr() + stream->getPos(), dataSize);
- } else {
- alloc->unpackVec3Allocation(rsc, stream->getPtr() + stream->getPos(), dataSize);
- }
- stream->reset(stream->getPos() + dataSize);
-
- return alloc;
-}
-
-void Allocation::sendDirty(const Context *rsc) const {
- mRSC->mHal.funcs.allocation.markDirty(rsc, this);
-}
-
-void Allocation::incRefs(const void *ptr, size_t ct, size_t startOff) const {
- mHal.state.type->incRefs(ptr, ct, startOff);
-}
-
-void Allocation::decRefs(const void *ptr, size_t ct, size_t startOff) const {
- if (!mHal.state.hasReferences || !getIsScript()) {
- return;
- }
- mHal.state.type->decRefs(ptr, ct, startOff);
-}
-
-void Allocation::freeChildrenUnlocked () {
- void *ptr = mRSC->mHal.funcs.allocation.lock1D(mRSC, this);
- decRefs(ptr, mHal.state.type->getSizeBytes() / mHal.state.type->getElementSizeBytes(), 0);
- mRSC->mHal.funcs.allocation.unlock1D(mRSC, this);
-}
-
-bool Allocation::freeChildren() {
- if (mHal.state.hasReferences) {
- incSysRef();
- freeChildrenUnlocked();
- return decSysRef();
- }
- return false;
-}
-
-void Allocation::copyRange1D(Context *rsc, const Allocation *src, int32_t srcOff, int32_t destOff, int32_t len) {
-}
-
-void Allocation::resize1D(Context *rsc, uint32_t dimX) {
- uint32_t oldDimX = mHal.state.dimensionX;
- if (dimX == oldDimX) {
- return;
- }
-
- ObjectBaseRef<Type> t = mHal.state.type->cloneAndResize1D(rsc, dimX);
- if (dimX < oldDimX) {
- decRefs(rsc->mHal.funcs.allocation.lock1D(rsc, this), oldDimX - dimX, dimX);
- rsc->mHal.funcs.allocation.unlock1D(rsc, this);
- }
- rsc->mHal.funcs.allocation.resize(rsc, this, t.get(), mHal.state.hasReferences);
- setType(t.get());
- updateCache();
-}
-
-void Allocation::resize2D(Context *rsc, uint32_t dimX, uint32_t dimY) {
- ALOGE("not implemented");
-}
-
-/////////////////
-//
-
-namespace android {
-namespace renderscript {
-
-void rsi_AllocationSyncAll(Context *rsc, RsAllocation va, RsAllocationUsageType src) {
- Allocation *a = static_cast<Allocation *>(va);
- a->sendDirty(rsc);
- a->syncAll(rsc, src);
-}
-
-void rsi_AllocationGenerateMipmaps(Context *rsc, RsAllocation va) {
- Allocation *alloc = static_cast<Allocation *>(va);
- rsc->mHal.funcs.allocation.generateMipmaps(rsc, alloc);
-}
-
-void rsi_AllocationCopyToBitmap(Context *rsc, RsAllocation va, void *data, size_t sizeBytes) {
- Allocation *a = static_cast<Allocation *>(va);
- const Type * t = a->getType();
- a->read(rsc, 0, 0, 0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X,
- t->getDimX(), t->getDimY(), data, sizeBytes);
-}
-
-void rsi_Allocation1DData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t lod,
- uint32_t count, const void *data, size_t sizeBytes) {
- Allocation *a = static_cast<Allocation *>(va);
- a->data(rsc, xoff, lod, count, data, sizeBytes);
-}
-
-void rsi_Allocation2DElementData(Context *rsc, RsAllocation va, uint32_t x, uint32_t y, uint32_t lod, RsAllocationCubemapFace face,
- const void *data, size_t sizeBytes, size_t eoff) {
- Allocation *a = static_cast<Allocation *>(va);
- a->elementData(rsc, x, y, data, eoff, sizeBytes);
-}
-
-void rsi_Allocation1DElementData(Context *rsc, RsAllocation va, uint32_t x, uint32_t lod,
- const void *data, size_t sizeBytes, size_t eoff) {
- Allocation *a = static_cast<Allocation *>(va);
- a->elementData(rsc, x, data, eoff, sizeBytes);
-}
-
-void rsi_Allocation2DData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, const void *data, size_t sizeBytes) {
- Allocation *a = static_cast<Allocation *>(va);
- a->data(rsc, xoff, yoff, lod, face, w, h, data, sizeBytes);
-}
-
-void rsi_AllocationRead(Context *rsc, RsAllocation va, void *data, size_t sizeBytes) {
- Allocation *a = static_cast<Allocation *>(va);
- const Type * t = a->getType();
- if(t->getDimY()) {
- a->read(rsc, 0, 0, 0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X,
- t->getDimX(), t->getDimY(), data, sizeBytes);
- } else {
- a->read(rsc, 0, 0, t->getDimX(), data, sizeBytes);
- }
-
-}
-
-void rsi_AllocationResize1D(Context *rsc, RsAllocation va, uint32_t dimX) {
- Allocation *a = static_cast<Allocation *>(va);
- a->resize1D(rsc, dimX);
-}
-
-void rsi_AllocationResize2D(Context *rsc, RsAllocation va, uint32_t dimX, uint32_t dimY) {
- Allocation *a = static_cast<Allocation *>(va);
- a->resize2D(rsc, dimX, dimY);
-}
-
-RsAllocation rsi_AllocationCreateTyped(Context *rsc, RsType vtype,
- RsAllocationMipmapControl mips,
- uint32_t usages, uint32_t ptr) {
- Allocation * alloc = Allocation::createAllocation(rsc, static_cast<Type *>(vtype), usages, mips, (void *)ptr);
- if (!alloc) {
- return NULL;
- }
- alloc->incUserRef();
- return alloc;
-}
-
-RsAllocation rsi_AllocationCreateFromBitmap(Context *rsc, RsType vtype,
- RsAllocationMipmapControl mips,
- const void *data, size_t sizeBytes, uint32_t usages) {
- Type *t = static_cast<Type *>(vtype);
-
- RsAllocation vTexAlloc = rsi_AllocationCreateTyped(rsc, vtype, mips, usages, 0);
- Allocation *texAlloc = static_cast<Allocation *>(vTexAlloc);
- if (texAlloc == NULL) {
- ALOGE("Memory allocation failure");
- return NULL;
- }
-
- texAlloc->data(rsc, 0, 0, 0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X,
- t->getDimX(), t->getDimY(), data, sizeBytes);
- if (mips == RS_ALLOCATION_MIPMAP_FULL) {
- rsc->mHal.funcs.allocation.generateMipmaps(rsc, texAlloc);
- }
-
- texAlloc->sendDirty(rsc);
- return texAlloc;
-}
-
-RsAllocation rsi_AllocationCubeCreateFromBitmap(Context *rsc, RsType vtype,
- RsAllocationMipmapControl mips,
- const void *data, size_t sizeBytes, uint32_t usages) {
- Type *t = static_cast<Type *>(vtype);
-
- // Cubemap allocation's faces should be Width by Width each.
- // Source data should have 6 * Width by Width pixels
- // Error checking is done in the java layer
- RsAllocation vTexAlloc = rsi_AllocationCreateTyped(rsc, vtype, mips, usages, 0);
- Allocation *texAlloc = static_cast<Allocation *>(vTexAlloc);
- if (texAlloc == NULL) {
- ALOGE("Memory allocation failure");
- return NULL;
- }
-
- uint32_t faceSize = t->getDimX();
- uint32_t strideBytes = faceSize * 6 * t->getElementSizeBytes();
- uint32_t copySize = faceSize * t->getElementSizeBytes();
-
- uint8_t *sourcePtr = (uint8_t*)data;
- for (uint32_t face = 0; face < 6; face ++) {
- for (uint32_t dI = 0; dI < faceSize; dI ++) {
- texAlloc->data(rsc, 0, dI, 0, (RsAllocationCubemapFace)face,
- t->getDimX(), 1, sourcePtr + strideBytes * dI, copySize);
- }
-
- // Move the data pointer to the next cube face
- sourcePtr += copySize;
- }
-
- if (mips == RS_ALLOCATION_MIPMAP_FULL) {
- rsc->mHal.funcs.allocation.generateMipmaps(rsc, texAlloc);
- }
-
- texAlloc->sendDirty(rsc);
- return texAlloc;
-}
-
-void rsi_AllocationCopy2DRange(Context *rsc,
- RsAllocation dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff,
- uint32_t dstMip, uint32_t dstFace,
- uint32_t width, uint32_t height,
- RsAllocation srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff,
- uint32_t srcMip, uint32_t srcFace) {
- Allocation *dst = static_cast<Allocation *>(dstAlloc);
- Allocation *src= static_cast<Allocation *>(srcAlloc);
- rsc->mHal.funcs.allocation.allocData2D(rsc, dst, dstXoff, dstYoff, dstMip,
- (RsAllocationCubemapFace)dstFace,
- width, height,
- src, srcXoff, srcYoff,srcMip,
- (RsAllocationCubemapFace)srcFace);
-}
-
-}
-}
-
-const void * rsaAllocationGetType(RsContext con, RsAllocation va) {
- Allocation *a = static_cast<Allocation *>(va);
- a->getType()->incUserRef();
-
- return a->getType();
-}
diff --git a/renderscript/v8/rs_support/rsAllocation.h b/renderscript/v8/rs_support/rsAllocation.h
deleted file mode 100644
index 7b842b5..0000000
--- a/renderscript/v8/rs_support/rsAllocation.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (C) 2009-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_STRUCTURED_ALLOCATION_H
-#define ANDROID_STRUCTURED_ALLOCATION_H
-
-#include "rsType.h"
-
-struct ANativeWindow;
-
-// ---------------------------------------------------------------------------
-namespace android {
-
-namespace renderscript {
-
-/*****************************************************************************
- * CAUTION
- *
- * Any layout changes for this class may require a corresponding change to be
- * made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
- * a partial copy of the information below.
- *
- *****************************************************************************/
-class Allocation : public ObjectBase {
- // The graphics equivalent of malloc. The allocation contains a structure of elements.
-
-public:
- const static int MAX_LOD = 16;
-
- struct Hal {
- void * drv;
-
- struct State {
- const Type * type;
-
- uint32_t usageFlags;
- RsAllocationMipmapControl mipmapControl;
-
- // Cached fields from the Type and Element
- // to prevent pointer chasing in critical loops.
- uint32_t dimensionX;
- uint32_t dimensionY;
- uint32_t dimensionZ;
- uint32_t elementSizeBytes;
- bool hasMipmaps;
- bool hasFaces;
- bool hasReferences;
- void * unused_01;
- int32_t surfaceTextureID;
- void *wndSurface;
- void *surfaceTexture;
- RsDataType eType;
- };
- State state;
-
- struct DrvState {
- mutable void * mallocPtrLOD0;
- mutable uint32_t strideLOD0;
- } drvState;
-
- };
- Hal mHal;
-
- static Allocation * createAllocation(Context *rsc, const Type *, uint32_t usages,
- RsAllocationMipmapControl mc = RS_ALLOCATION_MIPMAP_NONE,
- void *ptr = 0);
- virtual ~Allocation();
- void updateCache();
-
- const Type * getType() const {return mHal.state.type;}
-
- void syncAll(Context *rsc, RsAllocationUsageType src);
-
- void copyRange1D(Context *rsc, const Allocation *src, int32_t srcOff, int32_t destOff, int32_t len);
-
- void resize1D(Context *rsc, uint32_t dimX);
- void resize2D(Context *rsc, uint32_t dimX, uint32_t dimY);
-
- void data(Context *rsc, uint32_t xoff, uint32_t lod, uint32_t count, const void *data, size_t sizeBytes);
- void data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, const void *data, size_t sizeBytes);
- void data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, uint32_t d, const void *data, size_t sizeBytes);
-
- void read(Context *rsc, uint32_t xoff, uint32_t lod, uint32_t count, void *data, size_t sizeBytes);
- void read(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, void *data, size_t sizeBytes);
- void read(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, uint32_t d, void *data, size_t sizeBytes);
-
- void elementData(Context *rsc, uint32_t x,
- const void *data, uint32_t elementOff, size_t sizeBytes);
- void elementData(Context *rsc, uint32_t x, uint32_t y,
- const void *data, uint32_t elementOff, size_t sizeBytes);
-
- void addProgramToDirty(const Program *);
- void removeProgramToDirty(const Program *);
-
- virtual void dumpLOGV(const char *prefix) const;
- virtual void serialize(Context *rsc, OStream *stream) const;
- virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_ALLOCATION; }
- static Allocation *createFromStream(Context *rsc, IStream *stream);
-
- bool getIsScript() const {
- return (mHal.state.usageFlags & RS_ALLOCATION_USAGE_SCRIPT) != 0;
- }
- bool getIsTexture() const {
- return (mHal.state.usageFlags & RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE) != 0;
- }
- bool getIsRenderTarget() const {
- return (mHal.state.usageFlags & RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET) != 0;
- }
- bool getIsBufferObject() const {
- return (mHal.state.usageFlags & RS_ALLOCATION_USAGE_GRAPHICS_VERTEX) != 0;
- }
-
- void incRefs(const void *ptr, size_t ct, size_t startOff = 0) const;
- void decRefs(const void *ptr, size_t ct, size_t startOff = 0) const;
- virtual bool freeChildren();
-
- void sendDirty(const Context *rsc) const;
- bool getHasGraphicsMipmaps() const {
- return mHal.state.mipmapControl != RS_ALLOCATION_MIPMAP_NONE;
- }
-
-protected:
- Vector<const Program *> mToDirtyList;
- ObjectBaseRef<const Type> mType;
- void setType(const Type *t) {
- mType.set(t);
- mHal.state.type = t;
- }
-
-private:
- void freeChildrenUnlocked();
- Allocation(Context *rsc, const Type *, uint32_t usages, RsAllocationMipmapControl mc, void *ptr);
-
- uint32_t getPackedSize() const;
- static void writePackedData(Context *rsc, const Type *type, uint8_t *dst,
- const uint8_t *src, bool dstPadded);
- void unpackVec3Allocation(Context *rsc, const void *data, size_t dataSize);
- void packVec3Allocation(Context *rsc, OStream *stream) const;
-};
-
-}
-}
-#endif
-
diff --git a/renderscript/v8/rs_support/rsComponent.cpp b/renderscript/v8/rs_support/rsComponent.cpp
deleted file mode 100644
index d240952..0000000
--- a/renderscript/v8/rs_support/rsComponent.cpp
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Copyright (C) 2009-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsComponent.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-Component::Component() {
- set(RS_TYPE_NONE, RS_KIND_USER, false, 1);
-}
-
-Component::~Component() {
-}
-
-void Component::set(RsDataType dt, RsDataKind dk, bool norm, uint32_t vecSize) {
- mType = dt;
- mKind = dk;
- mNormalized = norm;
- mVectorSize = vecSize;
- rsAssert(vecSize <= 4);
-
- mBits = 0;
- mTypeBits = 0;
- mIsFloat = false;
- mIsSigned = false;
- mIsPixel = false;
-
- switch (mKind) {
- case RS_KIND_PIXEL_L:
- case RS_KIND_PIXEL_A:
- mIsPixel = true;
- rsAssert(mVectorSize == 1);
- rsAssert(mNormalized == true);
- break;
- case RS_KIND_PIXEL_LA:
- mIsPixel = true;
- rsAssert(mVectorSize == 2);
- rsAssert(mNormalized == true);
- break;
- case RS_KIND_PIXEL_RGB:
- mIsPixel = true;
- rsAssert(mVectorSize == 3);
- rsAssert(mNormalized == true);
- break;
- case RS_KIND_PIXEL_RGBA:
- mIsPixel = true;
- rsAssert(mVectorSize == 4);
- rsAssert(mNormalized == true);
- break;
- default:
- rsAssert(mKind != RS_KIND_INVALID);
- break;
- }
-
- switch (mType) {
- case RS_TYPE_NONE:
- return;
- case RS_TYPE_UNSIGNED_5_6_5:
- mVectorSize = 3;
- mBits = 16;
- mNormalized = true;
- rsAssert(mKind == RS_KIND_PIXEL_RGB);
- return;
- case RS_TYPE_UNSIGNED_5_5_5_1:
- mVectorSize = 4;
- mBits = 16;
- mNormalized = true;
- rsAssert(mKind == RS_KIND_PIXEL_RGBA);
- return;
- case RS_TYPE_UNSIGNED_4_4_4_4:
- mVectorSize = 4;
- mBits = 16;
- mNormalized = true;
- rsAssert(mKind == RS_KIND_PIXEL_RGBA);
- return;
-
- case RS_TYPE_MATRIX_4X4:
- mTypeBits = 16 * 32;
- rsAssert(mVectorSize == 1);
- rsAssert(mNormalized == false);
- rsAssert(mKind == RS_KIND_USER);
- break;
- case RS_TYPE_MATRIX_3X3:
- mTypeBits = 9 * 32;
- rsAssert(mVectorSize == 1);
- rsAssert(mNormalized == false);
- rsAssert(mKind == RS_KIND_USER);
- break;
- case RS_TYPE_MATRIX_2X2:
- mTypeBits = 4 * 32;
- rsAssert(mVectorSize == 1);
- rsAssert(mNormalized == false);
- rsAssert(mKind == RS_KIND_USER);
- break;
-
- case RS_TYPE_ELEMENT:
- case RS_TYPE_TYPE:
- case RS_TYPE_ALLOCATION:
- case RS_TYPE_SAMPLER:
- case RS_TYPE_SCRIPT:
- case RS_TYPE_MESH:
- case RS_TYPE_PROGRAM_FRAGMENT:
- case RS_TYPE_PROGRAM_VERTEX:
- case RS_TYPE_PROGRAM_RASTER:
- case RS_TYPE_PROGRAM_STORE:
- case RS_TYPE_FONT:
- rsAssert(mVectorSize == 1);
- rsAssert(mNormalized == false);
- rsAssert(mKind == RS_KIND_USER);
- mBits = 32;
- mTypeBits = 32;
- return;
-
- case RS_TYPE_FLOAT_16:
- mTypeBits = 16;
- mIsFloat = true;
- break;
- case RS_TYPE_FLOAT_32:
- mTypeBits = 32;
- mIsFloat = true;
- break;
- case RS_TYPE_FLOAT_64:
- mTypeBits = 64;
- mIsFloat = true;
- break;
- case RS_TYPE_SIGNED_8:
- mTypeBits = 8;
- mIsSigned = true;
- break;
- case RS_TYPE_SIGNED_16:
- mTypeBits = 16;
- mIsSigned = true;
- break;
- case RS_TYPE_SIGNED_32:
- mTypeBits = 32;
- mIsSigned = true;
- break;
- case RS_TYPE_SIGNED_64:
- mTypeBits = 64;
- mIsSigned = true;
- break;
- case RS_TYPE_UNSIGNED_8:
- mTypeBits = 8;
- break;
- case RS_TYPE_UNSIGNED_16:
- mTypeBits = 16;
- break;
- case RS_TYPE_UNSIGNED_32:
- mTypeBits = 32;
- break;
- case RS_TYPE_UNSIGNED_64:
- mTypeBits = 64;
- break;
-
- case RS_TYPE_BOOLEAN:
- mTypeBits = 8;
- break;
- default:
- rsAssert(mType != RS_TYPE_INVALID);
- rsAssert(0);
- break;
- }
-
- mBitsUnpadded = mTypeBits * mVectorSize;
- mBits = mTypeBits * rsHigherPow2(mVectorSize);
-}
-
-bool Component::isReference() const {
- return (mType >= RS_TYPE_ELEMENT);
-}
-
-static const char * gTypeBasicStrings[] = {
- "NONE",
- "F16",
- "F32",
- "F64",
- "S8",
- "S16",
- "S32",
- "S64",
- "U8",
- "U16",
- "U32",
- "U64",
- "BOOLEAN",
- "UP_565",
- "UP_5551",
- "UP_4444",
- "MATRIX_4X4",
- "MATRIX_3X3",
- "MATRIX_2X2",
-};
-
-static const char * gTypeObjStrings[] = {
- "ELEMENT",
- "TYPE",
- "ALLOCATION",
- "SAMPLER",
- "SCRIPT",
- "MESH",
- "PROGRAM_FRAGMENT",
- "PROGRAM_VERTEX",
- "PROGRAM_RASTER",
- "PROGRAM_STORE",
-};
-
-static const char * gKindStrings[] = {
- "USER",
- "COLOR",
- "POSITION",
- "TEXTURE",
- "NORMAL",
- "INDEX",
- "POINT_SIZE",
- "PIXEL_L",
- "PIXEL_A",
- "PIXEL_LA",
- "PIXEL_RGB",
- "PIXEL_RGBA",
-};
-
-void Component::dumpLOGV(const char *prefix) const {
- if (mType >= RS_TYPE_ELEMENT) {
- ALOGV("%s Component: %s, %s, vectorSize=%i, bits=%i",
- prefix, gTypeObjStrings[mType - RS_TYPE_ELEMENT], gKindStrings[mKind], mVectorSize, mBits);
- } else {
- ALOGV("%s Component: %s, %s, vectorSize=%i, bits=%i",
- prefix, gTypeBasicStrings[mType], gKindStrings[mKind], mVectorSize, mBits);
- }
-}
-
-void Component::serialize(OStream *stream) const {
- stream->addU8((uint8_t)mType);
- stream->addU8((uint8_t)mKind);
- stream->addU8((uint8_t)(mNormalized ? 1 : 0));
- stream->addU32(mVectorSize);
-}
-
-void Component::loadFromStream(IStream *stream) {
- mType = (RsDataType)stream->loadU8();
- mKind = (RsDataKind)stream->loadU8();
- uint8_t temp = stream->loadU8();
- mNormalized = temp != 0;
- mVectorSize = stream->loadU32();
-
- set(mType, mKind, mNormalized, mVectorSize);
-}
-
-
-
-
diff --git a/renderscript/v8/rs_support/rsComponent.h b/renderscript/v8/rs_support/rsComponent.h
deleted file mode 100644
index a2e8c0f..0000000
--- a/renderscript/v8/rs_support/rsComponent.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_COMPONENT_H
-#define ANDROID_COMPONENT_H
-
-#include "rsUtils.h"
-#include "rsDefines.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-
-// An element is a group of Components that occupies one cell in a structure.
-class Component {
-public:
- Component();
- ~Component();
-
- void set(RsDataType dt, RsDataKind dk, bool norm, uint32_t vecSize=1);
-
- void dumpLOGV(const char *prefix) const;
-
- RsDataType getType() const {return mType;}
- RsDataKind getKind() const {return mKind;}
- bool getIsNormalized() const {return mNormalized;}
- uint32_t getVectorSize() const {return mVectorSize;}
- bool getIsFloat() const {return mIsFloat;}
- bool getIsSigned() const {return mIsSigned;}
- uint32_t getBits() const {return mBits;}
- uint32_t getBitsUnpadded() const {return mBitsUnpadded;}
-
- // Helpers for reading / writing this class out
- void serialize(OStream *stream) const;
- void loadFromStream(IStream *stream);
-
- bool isReference() const;
-
-protected:
- RsDataType mType;
- RsDataKind mKind;
- bool mNormalized;
- uint32_t mVectorSize;
-
- // derived
- uint32_t mBits;
- uint32_t mBitsUnpadded;
- uint32_t mTypeBits;
- bool mIsFloat;
- bool mIsSigned;
- bool mIsPixel;
-};
-
-}
-}
-
-#endif
-
diff --git a/renderscript/v8/rs_support/rsContext.cpp b/renderscript/v8/rs_support/rsContext.cpp
deleted file mode 100644
index ec35c06..0000000
--- a/renderscript/v8/rs_support/rsContext.cpp
+++ /dev/null
@@ -1,486 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rs.h"
-#include "rsDevice.h"
-#include "rsContext.h"
-#include "rsThreadIO.h"
-
-#include <sys/types.h>
-#include <sys/resource.h>
-#include <sched.h>
-
-#include <cutils/properties.h>
-
-#include <sys/syscall.h>
-#include <string.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-pthread_mutex_t Context::gInitMutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_mutex_t Context::gLibMutex = PTHREAD_MUTEX_INITIALIZER;
-
-bool Context::initGLThread() {
- pthread_mutex_lock(&gInitMutex);
-
- if (!mHal.funcs.initGraphics(this)) {
- pthread_mutex_unlock(&gInitMutex);
- ALOGE("%p initGraphics failed", this);
- return false;
- }
-
- pthread_mutex_unlock(&gInitMutex);
- return true;
-}
-
-void Context::deinitEGL() {
- //mHal.funcs.shutdownGraphics(this);
-}
-
-Context::PushState::PushState(Context *con) {
- mRsc = con;
-}
-
-Context::PushState::~PushState() {
-}
-
-
-uint32_t Context::runScript(Script *s) {
- PushState ps(this);
-
- uint32_t ret = s->run(this);
- return ret;
-}
-
-uint32_t Context::runRootScript() {
- timerSet(RS_TIMER_SCRIPT);
- watchdog.inRoot = true;
- uint32_t ret = runScript(mRootScript.get());
- watchdog.inRoot = false;
-
- return ret;
-}
-
-uint64_t Context::getTime() const {
-#ifndef ANDROID_RS_SERIALIZE
- struct timespec t;
- clock_gettime(CLOCK_MONOTONIC, &t);
- return t.tv_nsec + ((uint64_t)t.tv_sec * 1000 * 1000 * 1000);
-#else
- return 0;
-#endif //ANDROID_RS_SERIALIZE
-}
-
-void Context::timerReset() {
- for (int ct=0; ct < _RS_TIMER_TOTAL; ct++) {
- mTimers[ct] = 0;
- }
-}
-
-void Context::timerInit() {
- mTimeLast = getTime();
- mTimeFrame = mTimeLast;
- mTimeLastFrame = mTimeLast;
- mTimerActive = RS_TIMER_INTERNAL;
- mAverageFPSFrameCount = 0;
- mAverageFPSStartTime = mTimeLast;
- mAverageFPS = 0;
- timerReset();
-}
-
-void Context::timerFrame() {
- mTimeLastFrame = mTimeFrame;
- mTimeFrame = getTime();
- // Update average fps
- const uint64_t averageFramerateInterval = 1000 * 1000000;
- mAverageFPSFrameCount ++;
- uint64_t inverval = mTimeFrame - mAverageFPSStartTime;
- if (inverval >= averageFramerateInterval) {
- inverval = inverval / 1000000;
- mAverageFPS = (mAverageFPSFrameCount * 1000) / inverval;
- mAverageFPSFrameCount = 0;
- mAverageFPSStartTime = mTimeFrame;
- }
-}
-
-void Context::timerSet(Timers tm) {
- uint64_t last = mTimeLast;
- mTimeLast = getTime();
- mTimers[mTimerActive] += mTimeLast - last;
- mTimerActive = tm;
-}
-
-void Context::timerPrint() {
- double total = 0;
- for (int ct = 0; ct < _RS_TIMER_TOTAL; ct++) {
- total += mTimers[ct];
- }
- uint64_t frame = mTimeFrame - mTimeLastFrame;
- mTimeMSLastFrame = frame / 1000000;
- mTimeMSLastScript = mTimers[RS_TIMER_SCRIPT] / 1000000;
- mTimeMSLastSwap = mTimers[RS_TIMER_CLEAR_SWAP] / 1000000;
-
-
- if (props.mLogTimes) {
- ALOGV("RS: Frame (%i), Script %2.1f%% (%i), Swap %2.1f%% (%i), Idle %2.1f%% (%lli), Internal %2.1f%% (%lli), Avg fps: %u",
- mTimeMSLastFrame,
- 100.0 * mTimers[RS_TIMER_SCRIPT] / total, mTimeMSLastScript,
- 100.0 * mTimers[RS_TIMER_CLEAR_SWAP] / total, mTimeMSLastSwap,
- 100.0 * mTimers[RS_TIMER_IDLE] / total, mTimers[RS_TIMER_IDLE] / 1000000,
- 100.0 * mTimers[RS_TIMER_INTERNAL] / total, mTimers[RS_TIMER_INTERNAL] / 1000000,
- mAverageFPS);
- }
-}
-
-bool Context::setupCheck() {
-
- return true;
-}
-
-static uint32_t getProp(const char *str) {
- char buf[PROPERTY_VALUE_MAX];
- property_get(str, buf, "0");
- return atoi(buf);
-}
-
-void Context::displayDebugStats() {
-}
-
-void * Context::threadProc(void *vrsc) {
- Context *rsc = static_cast<Context *>(vrsc);
-#ifndef ANDROID_RS_SERIALIZE
- rsc->mNativeThreadId = gettid();
- // TODO: Use proper ANDROID_PRIORITY_DISPLAY
- setpriority(PRIO_PROCESS, rsc->mNativeThreadId, /* ANDROID_PRIORITY_DISPLAY */ -4);
- rsc->mThreadPriority = /* ANDROID_PRIORITY_DISPLAY */ -4;
-#endif //ANDROID_RS_SERIALIZE
- rsc->props.mLogTimes = getProp("debug.rs.profile") != 0;
- rsc->props.mLogScripts = getProp("debug.rs.script") != 0;
- rsc->props.mLogObjects = getProp("debug.rs.object") != 0;
- rsc->props.mLogShaders = getProp("debug.rs.shader") != 0;
- rsc->props.mLogShadersAttr = getProp("debug.rs.shader.attributes") != 0;
- rsc->props.mLogShadersUniforms = getProp("debug.rs.shader.uniforms") != 0;
- rsc->props.mLogVisual = getProp("debug.rs.visual") != 0;
- rsc->props.mDebugMaxThreads = getProp("debug.rs.max-threads");
-
- if (!rsdHalInit(rsc, 0, 0)) {
- rsc->setError(RS_ERROR_FATAL_DRIVER, "Failed initializing GL");
- ALOGE("Hal init failed");
- return NULL;
- }
- rsc->mHal.funcs.setPriority(rsc, rsc->mThreadPriority);
-
- rsc->mRunning = true;
- if (!rsc->mIsGraphicsContext) {
- while (!rsc->mExit) {
- rsc->mIO.playCoreCommands(rsc, -1);
- }
- }
- ALOGV("%p RS Thread exiting", rsc);
-
- ALOGV("%p RS Thread exited", rsc);
- return NULL;
-}
-
-void Context::destroyWorkerThreadResources() {
- //ALOGV("destroyWorkerThreadResources 1");
- ObjectBase::zeroAllUserRef(this);
- ObjectBase::freeAllChildren(this);
- mExit = true;
- //ALOGV("destroyWorkerThreadResources 2");
-}
-
-void Context::printWatchdogInfo(void *ctx) {
- Context *rsc = (Context *)ctx;
- if (rsc->watchdog.command && rsc->watchdog.file) {
- ALOGE("RS watchdog timeout: %i %s line %i %s", rsc->watchdog.inRoot,
- rsc->watchdog.command, rsc->watchdog.line, rsc->watchdog.file);
- } else {
- ALOGE("RS watchdog timeout: %i", rsc->watchdog.inRoot);
- }
-}
-
-
-void Context::setPriority(int32_t p) {
- // Note: If we put this in the proper "background" policy
- // the wallpapers can become completly unresponsive at times.
- // This is probably not what we want for something the user is actively
- // looking at.
- mThreadPriority = p;
- setpriority(PRIO_PROCESS, mNativeThreadId, p);
- mHal.funcs.setPriority(this, mThreadPriority);
-}
-
-Context::Context() {
- mDev = NULL;
- mRunning = false;
- mExit = false;
- mPaused = false;
- mObjHead = NULL;
- mError = RS_ERROR_NONE;
- mTargetSdkVersion = 14;
- mDPI = 96;
- mIsContextLite = false;
- memset(&watchdog, 0, sizeof(watchdog));
-}
-
-Context * Context::createContext(Device *dev, const RsSurfaceConfig *sc) {
- Context * rsc = new Context();
-
- if (!rsc->initContext(dev, sc)) {
- delete rsc;
- return NULL;
- }
- return rsc;
-}
-
-Context * Context::createContextLite() {
- Context * rsc = new Context();
- rsc->mIsContextLite = true;
- return rsc;
-}
-
-bool Context::initContext(Device *dev, const RsSurfaceConfig *sc) {
- pthread_mutex_lock(&gInitMutex);
-
- mIO.init();
- mIO.setTimeoutCallback(printWatchdogInfo, this, 2e9);
-
- dev->addContext(this);
- mDev = dev;
- if (sc) {
- mUserSurfaceConfig = *sc;
- } else {
- memset(&mUserSurfaceConfig, 0, sizeof(mUserSurfaceConfig));
- }
-
- mIsGraphicsContext = sc != NULL;
-
- int status;
- pthread_attr_t threadAttr;
-
- pthread_mutex_unlock(&gInitMutex);
-
- // Global init done at this point.
-
- status = pthread_attr_init(&threadAttr);
- if (status) {
- ALOGE("Failed to init thread attribute.");
- return false;
- }
-
- mHasSurface = false;
-
- timerInit();
- timerSet(RS_TIMER_INTERNAL);
-
- status = pthread_create(&mThreadId, &threadAttr, threadProc, this);
- if (status) {
- ALOGE("Failed to start rs context thread.");
- return false;
- }
- while (!mRunning && (mError == RS_ERROR_NONE)) {
- usleep(100);
- }
-
- if (mError != RS_ERROR_NONE) {
- ALOGE("Errors during thread init");
- return false;
- }
-
- pthread_attr_destroy(&threadAttr);
- return true;
-}
-
-Context::~Context() {
- ALOGV("%p Context::~Context", this);
-
- if (!mIsContextLite) {
- mPaused = false;
- void *res;
-
- mIO.shutdown();
- int status = pthread_join(mThreadId, &res);
- rsAssert(mExit);
-
- if (mHal.funcs.shutdownDriver) {
- mHal.funcs.shutdownDriver(this);
- }
-
- // Global structure cleanup.
- pthread_mutex_lock(&gInitMutex);
- if (mDev) {
- mDev->removeContext(this);
- mDev = NULL;
- }
- pthread_mutex_unlock(&gInitMutex);
- }
- ALOGV("%p Context::~Context done", this);
-}
-
-void Context::assignName(ObjectBase *obj, const char *name, uint32_t len) {
- rsAssert(!obj->getName());
- obj->setName(name, len);
- mNames.add(obj);
-}
-
-void Context::removeName(ObjectBase *obj) {
- for (size_t ct=0; ct < mNames.size(); ct++) {
- if (obj == mNames[ct]) {
- mNames.removeAt(ct);
- return;
- }
- }
-}
-
-RsMessageToClientType Context::peekMessageToClient(size_t *receiveLen, uint32_t *subID) {
- return (RsMessageToClientType)mIO.getClientHeader(receiveLen, subID);
-}
-
-RsMessageToClientType Context::getMessageToClient(void *data, size_t *receiveLen, uint32_t *subID, size_t bufferLen) {
- return (RsMessageToClientType)mIO.getClientPayload(data, receiveLen, subID, bufferLen);
-}
-
-bool Context::sendMessageToClient(const void *data, RsMessageToClientType cmdID,
- uint32_t subID, size_t len, bool waitForSpace) const {
-
- return mIO.sendToClient(cmdID, subID, data, len, waitForSpace);
-}
-
-void Context::initToClient() {
- while (!mRunning) {
- usleep(100);
- }
-}
-
-void Context::deinitToClient() {
- mIO.clientShutdown();
-}
-
-void Context::setError(RsError e, const char *msg) const {
- mError = e;
- sendMessageToClient(msg, RS_MESSAGE_TO_CLIENT_ERROR, e, strlen(msg) + 1, true);
-}
-
-
-void Context::dumpDebug() const {
- ALOGE("RS Context debug %p", this);
- ALOGE("RS Context debug");
-
- ALOGE(" RS width %i, height %i", mWidth, mHeight);
- ALOGE(" RS running %i, exit %i, paused %i", mRunning, mExit, mPaused);
- ALOGE(" RS pThreadID %li, nativeThreadID %i", (long int)mThreadId, mNativeThreadId);
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-//
-
-namespace android {
-namespace renderscript {
-
-void rsi_ContextFinish(Context *rsc) {
-}
-
-void rsi_ContextBindRootScript(Context *rsc, RsScript vs) {
- Script *s = static_cast<Script *>(vs);
- //rsc->setRootScript(s);
-}
-
-void rsi_ContextBindSampler(Context *rsc, uint32_t slot, RsSampler vs) {
- Sampler *s = static_cast<Sampler *>(vs);
-
- if (slot > RS_MAX_SAMPLER_SLOT) {
- ALOGE("Invalid sampler slot");
- return;
- }
-
- s->bindToContext(&rsc->mStateSampler, slot);
-}
-
-void rsi_AssignName(Context *rsc, RsObjectBase obj, const char *name, size_t name_length) {
- ObjectBase *ob = static_cast<ObjectBase *>(obj);
- rsc->assignName(ob, name, name_length);
-}
-
-void rsi_ObjDestroy(Context *rsc, void *optr) {
- ObjectBase *ob = static_cast<ObjectBase *>(optr);
- rsc->removeName(ob);
- ob->decUserRef();
-}
-
-void rsi_ContextSetPriority(Context *rsc, int32_t p) {
- rsc->setPriority(p);
-}
-
-void rsi_ContextDump(Context *rsc, int32_t bits) {
- ObjectBase::dumpAll(rsc);
-}
-
-void rsi_ContextDestroyWorker(Context *rsc) {
- rsc->destroyWorkerThreadResources();
-}
-
-void rsi_ContextDestroy(Context *rsc) {
- ALOGV("%p rsContextDestroy", rsc);
- rsContextDestroyWorker(rsc);
- delete rsc;
- ALOGV("%p rsContextDestroy done", rsc);
-}
-
-
-RsMessageToClientType rsi_ContextPeekMessage(Context *rsc,
- size_t * receiveLen, size_t receiveLen_length,
- uint32_t * subID, size_t subID_length) {
- return rsc->peekMessageToClient(receiveLen, subID);
-}
-
-RsMessageToClientType rsi_ContextGetMessage(Context *rsc, void * data, size_t data_length,
- size_t * receiveLen, size_t receiveLen_length,
- uint32_t * subID, size_t subID_length) {
- rsAssert(subID_length == sizeof(uint32_t));
- rsAssert(receiveLen_length == sizeof(size_t));
- return rsc->getMessageToClient(data, receiveLen, subID, data_length);
-}
-
-void rsi_ContextInitToClient(Context *rsc) {
- rsc->initToClient();
-}
-
-void rsi_ContextDeinitToClient(Context *rsc) {
- rsc->deinitToClient();
-}
-
-}
-}
-
-RsContext rsContextCreate(RsDevice vdev, uint32_t version,
- uint32_t sdkVersion) {
- ALOGV("rsContextCreate dev=%p", vdev);
- Device * dev = static_cast<Device *>(vdev);
- Context *rsc = Context::createContext(dev, NULL);
- if (rsc) {
- rsc->setTargetSdkVersion(sdkVersion);
- }
- return rsc;
-}
-
-// Only to be called at a3d load time, before object is visible to user
-// not thread safe
-void rsaGetName(RsContext con, void * obj, const char **name) {
- ObjectBase *ob = static_cast<ObjectBase *>(obj);
- (*name) = ob->getName();
-}
diff --git a/renderscript/v8/rs_support/rsContext.h b/renderscript/v8/rs_support/rsContext.h
deleted file mode 100644
index ab4724d..0000000
--- a/renderscript/v8/rs_support/rsContext.h
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_RS_CONTEXT_H
-#define ANDROID_RS_CONTEXT_H
-
-#include "rsUtils.h"
-#include "rs_hal.h"
-
-#include "rsThreadIO.h"
-#include "rsScriptC.h"
-#include "rsScriptGroup.h"
-#include "rsSampler.h"
-#include <string.h>
-
-// ---------------------------------------------------------------------------
-namespace android {
-
-namespace renderscript {
-
-class Device;
-
-#if 0
-#define CHECK_OBJ(o) { \
- GET_TLS(); \
- if (!ObjectBase::isValid(rsc, (const ObjectBase *)o)) { \
- ALOGE("Bad object %p at %s, %i", o, __FILE__, __LINE__); \
- } \
-}
-#define CHECK_OBJ_OR_NULL(o) { \
- GET_TLS(); \
- if (o && !ObjectBase::isValid(rsc, (const ObjectBase *)o)) { \
- ALOGE("Bad object %p at %s, %i", o, __FILE__, __LINE__); \
- } \
-}
-#else
-#define CHECK_OBJ(o)
-#define CHECK_OBJ_OR_NULL(o)
-#endif
-
-class Context {
-public:
- struct Hal {
- void * drv;
-
- RsdHalFunctions funcs;
- };
- Hal mHal;
-
- static Context * createContext(Device *, const RsSurfaceConfig *sc);
- static Context * createContextLite();
- ~Context();
-
- static pthread_mutex_t gInitMutex;
- // Library mutex (for providing thread-safe calls from the runtime)
- static pthread_mutex_t gLibMutex;
-
- class PushState {
- public:
- PushState(Context *);
- ~PushState();
-
- private:
- Context *mRsc;
- };
-
- RsSurfaceConfig mUserSurfaceConfig;
-
- ElementState mStateElement;
- TypeState mStateType;
- SamplerState mStateSampler;
-
- ScriptCState mScriptC;
-
- bool setupCheck();
-
- void setPriority(int32_t p);
- void destroyWorkerThreadResources();
-
- void assignName(ObjectBase *obj, const char *name, uint32_t len);
- void removeName(ObjectBase *obj);
-
- RsMessageToClientType peekMessageToClient(size_t *receiveLen, uint32_t *subID);
- RsMessageToClientType getMessageToClient(void *data, size_t *receiveLen, uint32_t *subID, size_t bufferLen);
- bool sendMessageToClient(const void *data, RsMessageToClientType cmdID, uint32_t subID, size_t len, bool waitForSpace) const;
- uint32_t runScript(Script *s);
-
- void initToClient();
- void deinitToClient();
-
- mutable ThreadIO mIO;
-
- // Timers
- enum Timers {
- RS_TIMER_IDLE,
- RS_TIMER_INTERNAL,
- RS_TIMER_SCRIPT,
- RS_TIMER_CLEAR_SWAP,
- _RS_TIMER_TOTAL
- };
- uint64_t getTime() const;
- void timerInit();
- void timerReset();
- void timerSet(Timers);
- void timerPrint();
- void timerFrame();
-
- struct {
- bool mLogTimes;
- bool mLogScripts;
- bool mLogObjects;
- bool mLogShaders;
- bool mLogShadersAttr;
- bool mLogShadersUniforms;
- bool mLogVisual;
- uint32_t mDebugMaxThreads;
- } props;
-
- mutable struct {
- bool inRoot;
- const char *command;
- const char *file;
- uint32_t line;
- } watchdog;
- static void printWatchdogInfo(void *ctx);
-
- void dumpDebug() const;
- void setError(RsError e, const char *msg = NULL) const;
-
- mutable const ObjectBase * mObjHead;
-
- uint32_t getDPI() const {return mDPI;}
- void setDPI(uint32_t dpi) {mDPI = dpi;}
-
- uint32_t getTargetSdkVersion() const {return mTargetSdkVersion;}
- void setTargetSdkVersion(uint32_t sdkVer) {mTargetSdkVersion = sdkVer;}
-
- Device *mDev;
-protected:
-
- uint32_t mTargetSdkVersion;
- uint32_t mDPI;
- uint32_t mWidth;
- uint32_t mHeight;
- int32_t mThreadPriority;
- bool mIsGraphicsContext;
-
- bool mRunning;
- bool mExit;
- bool mPaused;
- mutable RsError mError;
-
- pthread_t mThreadId;
- pid_t mNativeThreadId;
-
- ObjectBaseRef<Script> mRootScript;
-
- void displayDebugStats();
-
-private:
- Context();
- bool initContext(Device *, const RsSurfaceConfig *sc);
-
-
- bool initGLThread();
- void deinitEGL();
-
- uint32_t runRootScript();
-
- static void * threadProc(void *);
- static void * helperThreadProc(void *);
-
- bool mHasSurface;
- bool mIsContextLite;
-
- Vector<ObjectBase *> mNames;
-
- uint64_t mTimers[_RS_TIMER_TOTAL];
- Timers mTimerActive;
- uint64_t mTimeLast;
- uint64_t mTimeFrame;
- uint64_t mTimeLastFrame;
- uint32_t mTimeMSLastFrame;
- uint32_t mTimeMSLastScript;
- uint32_t mTimeMSLastSwap;
- uint32_t mAverageFPSFrameCount;
- uint64_t mAverageFPSStartTime;
- uint32_t mAverageFPS;
-};
-
-} // renderscript
-} // android
-#endif
diff --git a/renderscript/v8/rs_support/rsDefines.h b/renderscript/v8/rs_support/rsDefines.h
deleted file mode 100644
index cccff86..0000000
--- a/renderscript/v8/rs_support/rsDefines.h
+++ /dev/null
@@ -1,381 +0,0 @@
-/*
- * Copyright (C) 2007-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef RENDER_SCRIPT_DEFINES_H
-#define RENDER_SCRIPT_DEFINES_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//////////////////////////////////////////////////////
-//
-
-typedef void * RsAsyncVoidPtr;
-
-typedef void * RsAdapter1D;
-typedef void * RsAdapter2D;
-typedef void * RsAllocation;
-typedef void * RsAnimation;
-typedef void * RsContext;
-typedef void * RsDevice;
-typedef void * RsElement;
-typedef void * RsFile;
-typedef void * RsFont;
-typedef void * RsSampler;
-typedef void * RsScript;
-typedef void * RsScriptKernelID;
-typedef void * RsScriptFieldID;
-typedef void * RsScriptMethodID;
-typedef void * RsScriptGroup;
-typedef void * RsMesh;
-typedef void * RsPath;
-typedef void * RsType;
-typedef void * RsObjectBase;
-
-typedef void * RsProgram;
-typedef void * RsProgramVertex;
-typedef void * RsProgramFragment;
-typedef void * RsProgramStore;
-typedef void * RsProgramRaster;
-
-typedef void * RsNativeWindow;
-
-typedef void (* RsBitmapCallback_t)(void *);
-
-typedef struct {
- float m[16];
-} rs_matrix4x4;
-
-typedef struct {
- float m[9];
-} rs_matrix3x3;
-
-typedef struct {
- float m[4];
-} rs_matrix2x2;
-
-enum RsDeviceParam {
- RS_DEVICE_PARAM_FORCE_SOFTWARE_GL,
- RS_DEVICE_PARAM_COUNT
-};
-
-typedef struct {
- uint32_t colorMin;
- uint32_t colorPref;
- uint32_t alphaMin;
- uint32_t alphaPref;
- uint32_t depthMin;
- uint32_t depthPref;
- uint32_t stencilMin;
- uint32_t stencilPref;
- uint32_t samplesMin;
- uint32_t samplesPref;
- float samplesQ;
-} RsSurfaceConfig;
-
-enum RsMessageToClientType {
- RS_MESSAGE_TO_CLIENT_NONE = 0,
- RS_MESSAGE_TO_CLIENT_EXCEPTION = 1,
- RS_MESSAGE_TO_CLIENT_RESIZE = 2,
- RS_MESSAGE_TO_CLIENT_ERROR = 3,
- RS_MESSAGE_TO_CLIENT_USER = 4
-};
-
-enum RsAllocationUsageType {
- RS_ALLOCATION_USAGE_SCRIPT = 0x0001,
- RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE = 0x0002,
- RS_ALLOCATION_USAGE_GRAPHICS_VERTEX = 0x0004,
- RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS = 0x0008,
- RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010,
- RS_ALLOCATION_USAGE_IO_INPUT = 0x0020,
- RS_ALLOCATION_USAGE_IO_OUTPUT = 0x0040,
-
- RS_ALLOCATION_USAGE_ALL = 0x00FF
-};
-
-enum RsAllocationMipmapControl {
- RS_ALLOCATION_MIPMAP_NONE = 0,
- RS_ALLOCATION_MIPMAP_FULL = 1,
- RS_ALLOCATION_MIPMAP_ON_SYNC_TO_TEXTURE = 2
-};
-
-enum RsAllocationCubemapFace {
- RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X = 0,
- RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_X = 1,
- RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Y = 2,
- RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Y = 3,
- RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Z = 4,
- RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Z = 5
-};
-
-enum RsDataType {
- RS_TYPE_NONE,
- RS_TYPE_FLOAT_16,
- RS_TYPE_FLOAT_32,
- RS_TYPE_FLOAT_64,
- RS_TYPE_SIGNED_8,
- RS_TYPE_SIGNED_16,
- RS_TYPE_SIGNED_32,
- RS_TYPE_SIGNED_64,
- RS_TYPE_UNSIGNED_8,
- RS_TYPE_UNSIGNED_16,
- RS_TYPE_UNSIGNED_32,
- RS_TYPE_UNSIGNED_64,
-
- RS_TYPE_BOOLEAN,
-
- RS_TYPE_UNSIGNED_5_6_5,
- RS_TYPE_UNSIGNED_5_5_5_1,
- RS_TYPE_UNSIGNED_4_4_4_4,
-
- RS_TYPE_MATRIX_4X4,
- RS_TYPE_MATRIX_3X3,
- RS_TYPE_MATRIX_2X2,
-
- RS_TYPE_ELEMENT = 1000,
- RS_TYPE_TYPE,
- RS_TYPE_ALLOCATION,
- RS_TYPE_SAMPLER,
- RS_TYPE_SCRIPT,
- RS_TYPE_MESH,
- RS_TYPE_PROGRAM_FRAGMENT,
- RS_TYPE_PROGRAM_VERTEX,
- RS_TYPE_PROGRAM_RASTER,
- RS_TYPE_PROGRAM_STORE,
- RS_TYPE_FONT,
-
- RS_TYPE_INVALID = 10000,
-};
-
-enum RsDataKind {
- RS_KIND_USER,
-
- RS_KIND_PIXEL_L = 7,
- RS_KIND_PIXEL_A,
- RS_KIND_PIXEL_LA,
- RS_KIND_PIXEL_RGB,
- RS_KIND_PIXEL_RGBA,
- RS_KIND_PIXEL_DEPTH,
-
- RS_KIND_INVALID = 100,
-};
-
-enum RsSamplerParam {
- RS_SAMPLER_MIN_FILTER,
- RS_SAMPLER_MAG_FILTER,
- RS_SAMPLER_WRAP_S,
- RS_SAMPLER_WRAP_T,
- RS_SAMPLER_WRAP_R,
- RS_SAMPLER_ANISO
-};
-
-enum RsSamplerValue {
- RS_SAMPLER_NEAREST,
- RS_SAMPLER_LINEAR,
- RS_SAMPLER_LINEAR_MIP_LINEAR,
- RS_SAMPLER_WRAP,
- RS_SAMPLER_CLAMP,
- RS_SAMPLER_LINEAR_MIP_NEAREST,
-
- RS_SAMPLER_INVALID = 100,
-};
-
-enum RsTextureTarget {
- RS_TEXTURE_2D,
- RS_TEXTURE_CUBE
-};
-
-enum RsDimension {
- RS_DIMENSION_X,
- RS_DIMENSION_Y,
- RS_DIMENSION_Z,
- RS_DIMENSION_LOD,
- RS_DIMENSION_FACE,
-
- RS_DIMENSION_ARRAY_0 = 100,
- RS_DIMENSION_ARRAY_1,
- RS_DIMENSION_ARRAY_2,
- RS_DIMENSION_ARRAY_3,
- RS_DIMENSION_MAX = RS_DIMENSION_ARRAY_3
-};
-
-enum RsDepthFunc {
- RS_DEPTH_FUNC_ALWAYS,
- RS_DEPTH_FUNC_LESS,
- RS_DEPTH_FUNC_LEQUAL,
- RS_DEPTH_FUNC_GREATER,
- RS_DEPTH_FUNC_GEQUAL,
- RS_DEPTH_FUNC_EQUAL,
- RS_DEPTH_FUNC_NOTEQUAL
-};
-
-enum RsBlendSrcFunc {
- RS_BLEND_SRC_ZERO, // 0
- RS_BLEND_SRC_ONE, // 1
- RS_BLEND_SRC_DST_COLOR, // 2
- RS_BLEND_SRC_ONE_MINUS_DST_COLOR, // 3
- RS_BLEND_SRC_SRC_ALPHA, // 4
- RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA, // 5
- RS_BLEND_SRC_DST_ALPHA, // 6
- RS_BLEND_SRC_ONE_MINUS_DST_ALPHA, // 7
- RS_BLEND_SRC_SRC_ALPHA_SATURATE, // 8
- RS_BLEND_SRC_INVALID = 100,
-};
-
-enum RsBlendDstFunc {
- RS_BLEND_DST_ZERO, // 0
- RS_BLEND_DST_ONE, // 1
- RS_BLEND_DST_SRC_COLOR, // 2
- RS_BLEND_DST_ONE_MINUS_SRC_COLOR, // 3
- RS_BLEND_DST_SRC_ALPHA, // 4
- RS_BLEND_DST_ONE_MINUS_SRC_ALPHA, // 5
- RS_BLEND_DST_DST_ALPHA, // 6
- RS_BLEND_DST_ONE_MINUS_DST_ALPHA, // 7
-
- RS_BLEND_DST_INVALID = 100,
-};
-
-enum RsTexEnvMode {
- RS_TEX_ENV_MODE_NONE,
- RS_TEX_ENV_MODE_REPLACE,
- RS_TEX_ENV_MODE_MODULATE,
- RS_TEX_ENV_MODE_DECAL
-};
-
-enum RsProgramParam {
- RS_PROGRAM_PARAM_INPUT,
- RS_PROGRAM_PARAM_OUTPUT,
- RS_PROGRAM_PARAM_CONSTANT,
- RS_PROGRAM_PARAM_TEXTURE_TYPE,
-};
-
-enum RsPrimitive {
- RS_PRIMITIVE_POINT,
- RS_PRIMITIVE_LINE,
- RS_PRIMITIVE_LINE_STRIP,
- RS_PRIMITIVE_TRIANGLE,
- RS_PRIMITIVE_TRIANGLE_STRIP,
- RS_PRIMITIVE_TRIANGLE_FAN,
-
- RS_PRIMITIVE_INVALID = 100,
-};
-
-enum RsPathPrimitive {
- RS_PATH_PRIMITIVE_QUADRATIC_BEZIER,
- RS_PATH_PRIMITIVE_CUBIC_BEZIER
-};
-
-enum RsError {
- RS_ERROR_NONE = 0,
- RS_ERROR_BAD_SHADER = 1,
- RS_ERROR_BAD_SCRIPT = 2,
- RS_ERROR_BAD_VALUE = 3,
- RS_ERROR_OUT_OF_MEMORY = 4,
- RS_ERROR_DRIVER = 5,
-
- RS_ERROR_FATAL_UNKNOWN = 0x1000,
- RS_ERROR_FATAL_DRIVER = 0x1001,
- RS_ERROR_FATAL_PROGRAM_LINK = 0x1002
-};
-
-enum RsAnimationInterpolation {
- RS_ANIMATION_INTERPOLATION_STEP,
- RS_ANIMATION_INTERPOLATION_LINEAR,
- RS_ANIMATION_INTERPOLATION_BEZIER,
- RS_ANIMATION_INTERPOLATION_CARDINAL,
- RS_ANIMATION_INTERPOLATION_HERMITE,
- RS_ANIMATION_INTERPOLATION_BSPLINE
-};
-
-enum RsAnimationEdge {
- RS_ANIMATION_EDGE_UNDEFINED,
- RS_ANIMATION_EDGE_CONSTANT,
- RS_ANIMATION_EDGE_GRADIENT,
- RS_ANIMATION_EDGE_CYCLE,
- RS_ANIMATION_EDGE_OSCILLATE,
- RS_ANIMATION_EDGE_CYLE_RELATIVE
-};
-
-enum RsA3DClassID {
- RS_A3D_CLASS_ID_UNKNOWN,
- RS_A3D_CLASS_ID_MESH,
- RS_A3D_CLASS_ID_TYPE,
- RS_A3D_CLASS_ID_ELEMENT,
- RS_A3D_CLASS_ID_ALLOCATION,
- RS_A3D_CLASS_ID_PROGRAM_VERTEX,
- RS_A3D_CLASS_ID_PROGRAM_RASTER,
- RS_A3D_CLASS_ID_PROGRAM_FRAGMENT,
- RS_A3D_CLASS_ID_PROGRAM_STORE,
- RS_A3D_CLASS_ID_SAMPLER,
- RS_A3D_CLASS_ID_ANIMATION,
- RS_A3D_CLASS_ID_ADAPTER_1D,
- RS_A3D_CLASS_ID_ADAPTER_2D,
- RS_A3D_CLASS_ID_SCRIPT_C,
- RS_A3D_CLASS_ID_SCRIPT_KERNEL_ID,
- RS_A3D_CLASS_ID_SCRIPT_FIELD_ID,
- RS_A3D_CLASS_ID_SCRIPT_METHOD_ID,
- RS_A3D_CLASS_ID_SCRIPT_GROUP
-};
-
-enum RsCullMode {
- RS_CULL_BACK,
- RS_CULL_FRONT,
- RS_CULL_NONE,
- RS_CULL_INVALID = 100,
-};
-
-enum RsScriptIntrinsicID {
- RS_SCRIPT_INTRINSIC_ID_UNDEFINED = 0,
- RS_SCRIPT_INTRINSIC_ID_CONVOLVE_3x3 = 1,
- RS_SCRIPT_INTRINSIC_ID_COLOR_MATRIX = 2,
- RS_SCRIPT_INTRINSIC_ID_LUT = 3,
- RS_SCRIPT_INTRINSIC_ID_CONVOLVE_5x5 = 4,
- RS_SCRIPT_INTRINSIC_ID_BLUR = 5,
- RS_SCRIPT_INTRINSIC_ID_YUV_TO_RGB = 6,
- RS_SCRIPT_INTRINSIC_ID_BLEND = 7
-};
-
-typedef struct {
- RsA3DClassID classID;
- const char* objectName;
-} RsFileIndexEntry;
-
-// Script to Script
-typedef struct {
- uint32_t xStart;
- uint32_t xEnd;
- uint32_t yStart;
- uint32_t yEnd;
- uint32_t zStart;
- uint32_t zEnd;
- uint32_t arrayStart;
- uint32_t arrayEnd;
-
-} RsScriptCall;
-
-#ifdef __cplusplus
-};
-#endif
-
-#endif // RENDER_SCRIPT_DEFINES_H
-
-
-
-
diff --git a/renderscript/v8/rs_support/rsDevice.cpp b/renderscript/v8/rs_support/rsDevice.cpp
deleted file mode 100644
index d7d03f6..0000000
--- a/renderscript/v8/rs_support/rsDevice.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsDevice.h"
-#include "rsContext.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-Device::Device() {
- mForceSW = false;
-}
-
-Device::~Device() {
-}
-
-void Device::addContext(Context *rsc) {
- mContexts.push(rsc);
-}
-
-void Device::removeContext(Context *rsc) {
- for (size_t idx=0; idx < mContexts.size(); idx++) {
- if (mContexts[idx] == rsc) {
- mContexts.removeAt(idx);
- break;
- }
- }
-}
-
-RsDevice rsDeviceCreate() {
- Device * d = new Device();
- return d;
-}
-
-void rsDeviceDestroy(RsDevice dev) {
- Device * d = static_cast<Device *>(dev);
- delete d;
-}
-
-void rsDeviceSetConfig(RsDevice dev, RsDeviceParam p, int32_t value) {
- Device * d = static_cast<Device *>(dev);
- if (p == RS_DEVICE_PARAM_FORCE_SOFTWARE_GL) {
- d->mForceSW = value != 0;
- return;
- }
- rsAssert(0);
-}
-
diff --git a/renderscript/v8/rs_support/rsDevice.h b/renderscript/v8/rs_support/rsDevice.h
deleted file mode 100644
index ffb514b..0000000
--- a/renderscript/v8/rs_support/rsDevice.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_RS_DEVICE_H
-#define ANDROID_RS_DEVICE_H
-
-#include "rsUtils.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-class Context;
-
-class Device {
-public:
- Device();
- ~Device();
-
- void addContext(Context *);
- void removeContext(Context *);
-
- bool mForceSW;
-
-protected:
- Vector<Context *> mContexts;
-};
-
-}
-}
-#endif
diff --git a/renderscript/v8/rs_support/rsElement.cpp b/renderscript/v8/rs_support/rsElement.cpp
deleted file mode 100644
index 3126c28..0000000
--- a/renderscript/v8/rs_support/rsElement.cpp
+++ /dev/null
@@ -1,434 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include "rsContext.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-
-Element::Element(Context *rsc) : ObjectBase(rsc) {
- mBits = 0;
- mBitsUnpadded = 0;
- mFields = NULL;
- mFieldCount = 0;
- mHasReference = false;
- memset(&mHal, 0, sizeof(mHal));
-}
-
-Element::~Element() {
- clear();
-}
-
-void Element::preDestroy() const {
- for (uint32_t ct = 0; ct < mRSC->mStateElement.mElements.size(); ct++) {
- if (mRSC->mStateElement.mElements[ct] == this) {
- mRSC->mStateElement.mElements.removeAt(ct);
- break;
- }
- }
-}
-
-void Element::clear() {
- delete [] mFields;
- mFields = NULL;
- mFieldCount = 0;
- mHasReference = false;
-
- delete [] mHal.state.fields;
- delete [] mHal.state.fieldArraySizes;
- delete [] mHal.state.fieldNames;
- delete [] mHal.state.fieldNameLengths;
- delete [] mHal.state.fieldOffsetBytes;
-}
-
-size_t Element::getSizeBits() const {
- if (!mFieldCount) {
- return mBits;
- }
-
- size_t total = 0;
- for (size_t ct=0; ct < mFieldCount; ct++) {
- total += mFields[ct].e->mBits * mFields[ct].arraySize;
- }
- return total;
-}
-
-size_t Element::getSizeBitsUnpadded() const {
- if (!mFieldCount) {
- return mBitsUnpadded;
- }
-
- size_t total = 0;
- for (size_t ct=0; ct < mFieldCount; ct++) {
- total += mFields[ct].e->mBitsUnpadded * mFields[ct].arraySize;
- }
- return total;
-}
-
-void Element::dumpLOGV(const char *prefix) const {
- ObjectBase::dumpLOGV(prefix);
- ALOGV("%s Element: fieldCount: %zu, size bytes: %zu", prefix, mFieldCount, getSizeBytes());
- mComponent.dumpLOGV(prefix);
- for (uint32_t ct = 0; ct < mFieldCount; ct++) {
- ALOGV("%s Element field index: %u ------------------", prefix, ct);
- ALOGV("%s name: %s, offsetBits: %u, arraySize: %u",
- prefix, mFields[ct].name.string(), mFields[ct].offsetBits, mFields[ct].arraySize);
- mFields[ct].e->dumpLOGV(prefix);
- }
-}
-
-void Element::serialize(Context *rsc, OStream *stream) const {
- // Need to identify ourselves
- stream->addU32((uint32_t)getClassId());
-
- String8 name(getName());
- stream->addString(&name);
-
- mComponent.serialize(stream);
-
- // Now serialize all the fields
- stream->addU32(mFieldCount);
- for (uint32_t ct = 0; ct < mFieldCount; ct++) {
- stream->addString(&mFields[ct].name);
- stream->addU32(mFields[ct].arraySize);
- mFields[ct].e->serialize(rsc, stream);
- }
-}
-
-Element *Element::createFromStream(Context *rsc, IStream *stream) {
- // First make sure we are reading the correct object
- RsA3DClassID classID = (RsA3DClassID)stream->loadU32();
- if (classID != RS_A3D_CLASS_ID_ELEMENT) {
- ALOGE("element loading skipped due to invalid class id\n");
- return NULL;
- }
-
- String8 name;
- stream->loadString(&name);
-
- Component component;
- component.loadFromStream(stream);
-
- uint32_t fieldCount = stream->loadU32();
- if (!fieldCount) {
- return (Element *)Element::create(rsc,
- component.getType(),
- component.getKind(),
- component.getIsNormalized(),
- component.getVectorSize());
- }
-
- const Element **subElems = new const Element *[fieldCount];
- const char **subElemNames = new const char *[fieldCount];
- size_t *subElemNamesLengths = new size_t[fieldCount];
- uint32_t *arraySizes = new uint32_t[fieldCount];
-
- String8 elemName;
- for (uint32_t ct = 0; ct < fieldCount; ct ++) {
- stream->loadString(&elemName);
- subElemNamesLengths[ct] = elemName.length();
- char *tmpName = new char[subElemNamesLengths[ct]];
- memcpy(tmpName, elemName.string(), subElemNamesLengths[ct]);
- subElemNames[ct] = tmpName;
- arraySizes[ct] = stream->loadU32();
- subElems[ct] = Element::createFromStream(rsc, stream);
- }
-
- const Element *elem = Element::create(rsc, fieldCount, subElems, subElemNames,
- subElemNamesLengths, arraySizes);
- for (uint32_t ct = 0; ct < fieldCount; ct ++) {
- delete [] subElemNames[ct];
- subElems[ct]->decUserRef();
- }
- delete[] subElems;
- delete[] subElemNames;
- delete[] subElemNamesLengths;
- delete[] arraySizes;
-
- return (Element *)elem;
-}
-
-void Element::compute() {
- mHal.state.dataType = mComponent.getType();
- mHal.state.dataKind = mComponent.getKind();
- mHal.state.vectorSize = mComponent.getVectorSize();
-
- if (mFieldCount == 0) {
- mBits = mComponent.getBits();
- mBitsUnpadded = mComponent.getBitsUnpadded();
- mHasReference = mComponent.isReference();
-
- mHal.state.elementSizeBytes = getSizeBytes();
- return;
- }
-
- uint32_t noPaddingFieldCount = 0;
- for (uint32_t ct = 0; ct < mFieldCount; ct ++) {
- if (mFields[ct].name.string()[0] != '#') {
- noPaddingFieldCount ++;
- }
- }
-
- mHal.state.fields = new const Element*[noPaddingFieldCount];
- mHal.state.fieldArraySizes = new uint32_t[noPaddingFieldCount];
- mHal.state.fieldNames = new const char*[noPaddingFieldCount];
- mHal.state.fieldNameLengths = new uint32_t[noPaddingFieldCount];
- mHal.state.fieldOffsetBytes = new uint32_t[noPaddingFieldCount];
- mHal.state.fieldsCount = noPaddingFieldCount;
-
- size_t bits = 0;
- size_t bitsUnpadded = 0;
- for (size_t ct = 0, ctNoPadding = 0; ct < mFieldCount; ct++) {
- mFields[ct].offsetBits = bits;
- mFields[ct].offsetBitsUnpadded = bitsUnpadded;
- bits += mFields[ct].e->getSizeBits() * mFields[ct].arraySize;
- bitsUnpadded += mFields[ct].e->getSizeBitsUnpadded() * mFields[ct].arraySize;
-
- if (mFields[ct].e->mHasReference) {
- mHasReference = true;
- }
-
- if (mFields[ct].name.string()[0] == '#') {
- continue;
- }
-
- mHal.state.fields[ctNoPadding] = mFields[ct].e.get();
- mHal.state.fieldArraySizes[ctNoPadding] = mFields[ct].arraySize;
- mHal.state.fieldNames[ctNoPadding] = mFields[ct].name.string();
- mHal.state.fieldNameLengths[ctNoPadding] = mFields[ct].name.length() + 1; // to include 0
- mHal.state.fieldOffsetBytes[ctNoPadding] = mFields[ct].offsetBits >> 3;
-
- ctNoPadding ++;
- }
-
- mHal.state.elementSizeBytes = getSizeBytes();
-}
-
-ObjectBaseRef<const Element> Element::createRef(Context *rsc, RsDataType dt, RsDataKind dk,
- bool isNorm, uint32_t vecSize) {
- ObjectBaseRef<const Element> returnRef;
- // Look for an existing match.
- ObjectBase::asyncLock();
- for (uint32_t ct=0; ct < rsc->mStateElement.mElements.size(); ct++) {
- const Element *ee = rsc->mStateElement.mElements[ct];
- if (!ee->getFieldCount() &&
- (ee->getComponent().getType() == dt) &&
- (ee->getComponent().getKind() == dk) &&
- (ee->getComponent().getIsNormalized() == isNorm) &&
- (ee->getComponent().getVectorSize() == vecSize)) {
- // Match
- returnRef.set(ee);
- ObjectBase::asyncUnlock();
- return ee;
- }
- }
- ObjectBase::asyncUnlock();
-
- Element *e = new Element(rsc);
- returnRef.set(e);
- e->mComponent.set(dt, dk, isNorm, vecSize);
- e->compute();
-
- ObjectBase::asyncLock();
- rsc->mStateElement.mElements.push(e);
- ObjectBase::asyncUnlock();
-
- return returnRef;
-}
-
-ObjectBaseRef<const Element> Element::createRef(Context *rsc, size_t count, const Element **ein,
- const char **nin, const size_t * lengths, const uint32_t *asin) {
-
- ObjectBaseRef<const Element> returnRef;
- // Look for an existing match.
- ObjectBase::asyncLock();
- for (uint32_t ct=0; ct < rsc->mStateElement.mElements.size(); ct++) {
- const Element *ee = rsc->mStateElement.mElements[ct];
- if (ee->getFieldCount() == count) {
- bool match = true;
- for (uint32_t i=0; i < count; i++) {
- if ((ee->mFields[i].e.get() != ein[i]) ||
- (ee->mFields[i].name.length() != lengths[i]) ||
- (ee->mFields[i].name != nin[i]) ||
- (ee->mFields[i].arraySize != asin[i])) {
- match = false;
- break;
- }
- }
- if (match) {
- returnRef.set(ee);
- ObjectBase::asyncUnlock();
- return returnRef;
- }
- }
- }
- ObjectBase::asyncUnlock();
-
- Element *e = new Element(rsc);
- returnRef.set(e);
- e->mFields = new ElementField_t [count];
- e->mFieldCount = count;
- for (size_t ct=0; ct < count; ct++) {
- e->mFields[ct].e.set(ein[ct]);
- e->mFields[ct].name.setTo(nin[ct], lengths[ct]);
- e->mFields[ct].arraySize = asin[ct];
- }
- e->compute();
-
- ObjectBase::asyncLock();
- rsc->mStateElement.mElements.push(e);
- ObjectBase::asyncUnlock();
-
- return returnRef;
-}
-
-void Element::incRefs(const void *ptr) const {
- if (!mFieldCount) {
- if (mComponent.isReference()) {
- ObjectBase *const*obp = static_cast<ObjectBase *const*>(ptr);
- ObjectBase *ob = obp[0];
- if (ob) ob->incSysRef();
- }
- return;
- }
-
- const uint8_t *p = static_cast<const uint8_t *>(ptr);
- for (uint32_t i=0; i < mFieldCount; i++) {
- if (mFields[i].e->mHasReference) {
- const uint8_t *p2 = &p[mFields[i].offsetBits >> 3];
- for (uint32_t ct=0; ct < mFields[i].arraySize; ct++) {
- mFields[i].e->incRefs(p2);
- p2 += mFields[i].e->getSizeBytes();
- }
- }
- }
-}
-
-void Element::decRefs(const void *ptr) const {
- if (!mFieldCount) {
- if (mComponent.isReference()) {
- ObjectBase *const*obp = static_cast<ObjectBase *const*>(ptr);
- ObjectBase *ob = obp[0];
- if (ob) ob->decSysRef();
- }
- return;
- }
-
- const uint8_t *p = static_cast<const uint8_t *>(ptr);
- for (uint32_t i=0; i < mFieldCount; i++) {
- if (mFields[i].e->mHasReference) {
- const uint8_t *p2 = &p[mFields[i].offsetBits >> 3];
- for (uint32_t ct=0; ct < mFields[i].arraySize; ct++) {
- mFields[i].e->decRefs(p2);
- p2 += mFields[i].e->getSizeBytes();
- }
- }
- }
-}
-
-Element::Builder::Builder() {
- const uint32_t initialCapacity = 32;
- mBuilderElementRefs.setCapacity(initialCapacity);
- mBuilderElements.setCapacity(initialCapacity);
- mBuilderNameStrings.setCapacity(initialCapacity);
- mBuilderNameLengths.setCapacity(initialCapacity);
- mBuilderArrays.setCapacity(initialCapacity);
-}
-
-void Element::Builder::add(const Element *e, const char *nameStr, uint32_t arraySize) {
- mBuilderElementRefs.push(ObjectBaseRef<const Element>(e));
- mBuilderElements.push(e);
- mBuilderNameStrings.push(nameStr);
- mBuilderNameLengths.push(strlen(nameStr));
- mBuilderArrays.push(arraySize);
-
-}
-
-ObjectBaseRef<const Element> Element::Builder::create(Context *rsc) {
- return Element::createRef(rsc, mBuilderElements.size(),
- &(mBuilderElements.editArray()[0]),
- &(mBuilderNameStrings.editArray()[0]),
- mBuilderNameLengths.editArray(),
- mBuilderArrays.editArray());
-}
-
-
-ElementState::ElementState() {
-}
-
-ElementState::~ElementState() {
- rsAssert(!mElements.size());
-}
-
-/////////////////////////////////////////
-//
-
-namespace android {
-namespace renderscript {
-
-RsElement rsi_ElementCreate(Context *rsc,
- RsDataType dt,
- RsDataKind dk,
- bool norm,
- uint32_t vecSize) {
- return (RsElement)Element::create(rsc, dt, dk, norm, vecSize);
-}
-
-
-RsElement rsi_ElementCreate2(Context *rsc,
- const RsElement * ein,
- size_t ein_length,
-
- const char ** names,
- size_t nameLengths_length,
- const size_t * nameLengths,
-
- const uint32_t * arraySizes,
- size_t arraySizes_length) {
- return (RsElement)Element::create(rsc, ein_length, (const Element **)ein,
- names, nameLengths, arraySizes);
-}
-
-}
-}
-
-void rsaElementGetNativeData(RsContext con, RsElement elem,
- uint32_t *elemData, uint32_t elemDataSize) {
- rsAssert(elemDataSize == 5);
- // we will pack mType; mKind; mNormalized; mVectorSize; NumSubElements
- Element *e = static_cast<Element *>(elem);
-
- (*elemData++) = (uint32_t)e->getType();
- (*elemData++) = (uint32_t)e->getKind();
- (*elemData++) = e->getComponent().getIsNormalized() ? 1 : 0;
- (*elemData++) = e->getComponent().getVectorSize();
- (*elemData++) = e->getFieldCount();
-}
-
-void rsaElementGetSubElements(RsContext con, RsElement elem, uint32_t *ids,
- const char **names, uint32_t *arraySizes, uint32_t dataSize) {
- Element *e = static_cast<Element *>(elem);
- rsAssert(e->getFieldCount() == dataSize);
-
- for (uint32_t i = 0; i < dataSize; i ++) {
- e->getField(i)->incUserRef();
- ids[i] = (uint32_t)e->getField(i);
- names[i] = e->getFieldName(i);
- arraySizes[i] = e->getFieldArraySize(i);
- }
-}
diff --git a/renderscript/v8/rs_support/rsElement.h b/renderscript/v8/rs_support/rsElement.h
deleted file mode 100644
index 57698f4..0000000
--- a/renderscript/v8/rs_support/rsElement.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_STRUCTURED_ELEMENT_H
-#define ANDROID_STRUCTURED_ELEMENT_H
-
-#include "rsComponent.h"
-#include "rsUtils.h"
-#include "rsDefines.h"
-#include "rsObjectBase.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-/*****************************************************************************
- * CAUTION
- *
- * Any layout changes for this class may require a corresponding change to be
- * made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
- * a partial copy of the information below.
- *
- *****************************************************************************/
-// An element is a group of Components that occupies one cell in a structure.
-class Element : public ObjectBase {
-public:
- struct Hal {
- mutable void *drv;
-
- struct State {
- RsDataType dataType;
- RsDataKind dataKind;
- uint32_t vectorSize;
- uint32_t elementSizeBytes;
-
- // Subelements
- const Element **fields;
- uint32_t *fieldArraySizes;
- const char **fieldNames;
- uint32_t *fieldNameLengths;
- uint32_t *fieldOffsetBytes;
- uint32_t fieldsCount;
- };
- State state;
- };
- Hal mHal;
-
- class Builder {
- public:
- Builder();
- void add(const Element *e, const char *nameStr, uint32_t arraySize);
- ObjectBaseRef<const Element> create(Context *rsc);
- private:
- Vector<ObjectBaseRef<const Element> > mBuilderElementRefs;
- Vector<const Element *> mBuilderElements;
- Vector<const char*> mBuilderNameStrings;
- Vector<size_t> mBuilderNameLengths;
- Vector<uint32_t> mBuilderArrays;
- };
- uint32_t getGLType() const;
- uint32_t getGLFormat() const;
-
- size_t getSizeBitsUnpadded() const;
- size_t getSizeBytesUnpadded() const {
- return (getSizeBitsUnpadded() + 7) >> 3;
- }
-
- size_t getSizeBits() const;
- size_t getSizeBytes() const {
- return (getSizeBits() + 7) >> 3;
- }
-
- size_t getFieldOffsetBits(uint32_t componentNumber) const {
- return mFields[componentNumber].offsetBits;
- }
- size_t getFieldOffsetBytes(uint32_t componentNumber) const {
- return mFields[componentNumber].offsetBits >> 3;
- }
-
- size_t getFieldOffsetBytesUnpadded(uint32_t componentNumber) const {
- return mFields[componentNumber].offsetBitsUnpadded >> 3;
- }
-
- uint32_t getFieldCount() const {return mFieldCount;}
- const Element * getField(uint32_t idx) const {return mFields[idx].e.get();}
- const char * getFieldName(uint32_t idx) const {return mFields[idx].name.string();}
- uint32_t getFieldArraySize(uint32_t idx) const {return mFields[idx].arraySize;}
-
- const Component & getComponent() const {return mComponent;}
- RsDataType getType() const {return mComponent.getType();}
- RsDataKind getKind() const {return mComponent.getKind();}
- uint32_t getBits() const {return mBits;}
- uint32_t getBitsUnpadded() const {return mBitsUnpadded;}
-
- void dumpLOGV(const char *prefix) const;
- virtual void serialize(Context *rsc, OStream *stream) const;
- virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_ELEMENT; }
- static Element *createFromStream(Context *rsc, IStream *stream);
-
- static ObjectBaseRef<const Element> createRef(Context *rsc,
- RsDataType dt,
- RsDataKind dk,
- bool isNorm,
- uint32_t vecSize);
- static ObjectBaseRef<const Element> createRef(Context *rsc, size_t count,
- const Element **,
- const char **,
- const size_t * lengths,
- const uint32_t *asin);
-
- static const Element* create(Context *rsc,
- RsDataType dt,
- RsDataKind dk,
- bool isNorm,
- uint32_t vecSize) {
- ObjectBaseRef<const Element> elem = createRef(rsc, dt, dk, isNorm, vecSize);
- elem->incUserRef();
- return elem.get();
- }
- static const Element* create(Context *rsc, size_t count,
- const Element **ein,
- const char **nin,
- const size_t * lengths,
- const uint32_t *asin) {
- ObjectBaseRef<const Element> elem = createRef(rsc, count, ein, nin, lengths, asin);
- elem->incUserRef();
- return elem.get();
- }
-
- void incRefs(const void *) const;
- void decRefs(const void *) const;
- bool getHasReferences() const {return mHasReference;}
-
-protected:
- // deallocate any components that are part of this element.
- void clear();
-
- typedef struct {
- String8 name;
- ObjectBaseRef<const Element> e;
- uint32_t offsetBits;
- uint32_t offsetBitsUnpadded;
- uint32_t arraySize;
- } ElementField_t;
- ElementField_t *mFields;
- size_t mFieldCount;
- bool mHasReference;
-
-
- virtual ~Element();
- Element(Context *);
-
- Component mComponent;
- uint32_t mBitsUnpadded;
- uint32_t mBits;
-
- void compute();
-
- virtual void preDestroy() const;
-};
-
-
-class ElementState {
-public:
- ElementState();
- ~ElementState();
-
- // Cache of all existing elements.
- Vector<Element *> mElements;
-};
-
-
-}
-}
-#endif //ANDROID_STRUCTURED_ELEMENT_H
diff --git a/renderscript/v8/rs_support/rsEnv.h b/renderscript/v8/rs_support/rsEnv.h
deleted file mode 100644
index b82eaf1..0000000
--- a/renderscript/v8/rs_support/rsEnv.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <stdint.h>
-
-
-typedef void * RsAdapter1D;
-typedef void * RsAdapter2D;
-typedef void * RsAllocation;
-typedef void * RsContext;
-typedef void * RsDevice;
-typedef void * RsElement;
-typedef void * RsSampler;
-typedef void * RsScript;
-typedef void * RsMesh;
-typedef void * RsType;
-typedef void * RsProgramFragment;
-typedef void * RsProgramStore;
-
-typedef struct {
- float m[16];
-} rsc_Matrix;
-
-
-typedef struct {
- float v[4];
-} rsc_Vector4;
-
-#define RS_PROGRAM_VERTEX_MODELVIEW_OFFSET 0
-#define RS_PROGRAM_VERTEX_PROJECTION_OFFSET 16
-#define RS_PROGRAM_VERTEX_TEXTURE_OFFSET 32
-#define RS_PROGRAM_VERTEX_MVP_OFFSET 48
diff --git a/renderscript/v8/rs_support/rsFifo.h b/renderscript/v8/rs_support/rsFifo.h
deleted file mode 100644
index 911f446..0000000
--- a/renderscript/v8/rs_support/rsFifo.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_RS_FIFO_H
-#define ANDROID_RS_FIFO_H
-
-
-#include "rsUtils.h"
-
-namespace android {
-namespace renderscript {
-
-
-// A simple FIFO to be used as a producer / consumer between two
-// threads. One is writer and one is reader. The common cases
-// will not require locking. It is not threadsafe for multiple
-// readers or writers by design.
-
-class Fifo {
-protected:
- Fifo();
- virtual ~Fifo();
-
-public:
- bool virtual writeAsync(const void *data, size_t bytes, bool waitForSpace = true) = 0;
- void virtual writeWaitReturn(void *ret, size_t retSize) = 0;
- size_t virtual read(void *data, size_t bytes, bool doWait = true, uint64_t timeToWait = 0) = 0;
- void virtual readReturn(const void *data, size_t bytes) = 0;
-
- void virtual flush() = 0;
-
-};
-
-}
-}
-#endif
diff --git a/renderscript/v8/rs_support/rsFifoSocket.cpp b/renderscript/v8/rs_support/rsFifoSocket.cpp
deleted file mode 100644
index bd511cf..0000000
--- a/renderscript/v8/rs_support/rsFifoSocket.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsFifoSocket.h"
-#include "utils/Timers.h"
-#include "utils/StopWatch.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <unistd.h>
-#include <poll.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-FifoSocket::FifoSocket() {
- mShutdown = false;
-}
-
-FifoSocket::~FifoSocket() {
-
-}
-
-bool FifoSocket::init(bool supportNonBlocking, bool supportReturnValues, size_t maxDataSize) {
- int ret = socketpair(AF_UNIX, SOCK_STREAM, 0, sv);
- return false;
-}
-
-void FifoSocket::shutdown() {
- mShutdown = true;
- uint64_t d = 0;
- ::send(sv[0], &d, sizeof(d), 0);
- ::send(sv[1], &d, sizeof(d), 0);
- close(sv[0]);
- close(sv[1]);
-}
-
-bool FifoSocket::writeAsync(const void *data, size_t bytes, bool waitForSpace) {
- if (bytes == 0) {
- return true;
- }
- //ALOGE("writeAsync %p %i", data, bytes);
- size_t ret = ::send(sv[0], data, bytes, 0);
- //ALOGE("writeAsync ret %i", ret);
- rsAssert(ret == bytes);
- return true;
-}
-
-void FifoSocket::writeWaitReturn(void *retData, size_t retBytes) {
- if (mShutdown) {
- return;
- }
-
- //ALOGE("writeWaitReturn %p %i", retData, retBytes);
- size_t ret = ::recv(sv[0], retData, retBytes, MSG_WAITALL);
- //ALOGE("writeWaitReturn %i", ret);
- rsAssert(ret == retBytes);
-}
-
-size_t FifoSocket::read(void *data, size_t bytes) {
- if (mShutdown) {
- return 0;
- }
-
- //ALOGE("read %p %i", data, bytes);
- size_t ret = ::recv(sv[1], data, bytes, MSG_WAITALL);
- rsAssert(ret == bytes || mShutdown);
- //ALOGE("read ret %i bytes %i", ret, bytes);
- if (mShutdown) {
- ret = 0;
- }
- return ret;
-}
-
-bool FifoSocket::isEmpty() {
- struct pollfd p;
- p.fd = sv[1];
- p.events = POLLIN;
- int r = poll(&p, 1, 0);
- //ALOGE("poll r=%i", r);
- return r == 0;
-}
-
-
-void FifoSocket::readReturn(const void *data, size_t bytes) {
- //ALOGE("readReturn %p %Zu", data, bytes);
- size_t ret = ::send(sv[1], data, bytes, 0);
- //ALOGE("readReturn %Zu", ret);
- //rsAssert(ret == bytes);
-}
-
-
diff --git a/renderscript/v8/rs_support/rsFifoSocket.h b/renderscript/v8/rs_support/rsFifoSocket.h
deleted file mode 100644
index cac0a75..0000000
--- a/renderscript/v8/rs_support/rsFifoSocket.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_RS_FIFO_SOCKET_H
-#define ANDROID_RS_FIFO_SOCKET_H
-
-
-#include "rsFifo.h"
-
-namespace android {
-namespace renderscript {
-
-
-class FifoSocket {
-public:
- FifoSocket();
- virtual ~FifoSocket();
-
- bool init(bool supportNonBlocking = true,
- bool supportReturnValues = true,
- size_t maxDataSize = 0);
- void shutdown();
-
- bool writeAsync(const void *data, size_t bytes, bool waitForSpace = true);
- void writeWaitReturn(void *ret, size_t retSize);
- size_t read(void *data, size_t bytes);
- void readReturn(const void *data, size_t bytes);
- bool isEmpty();
-
- int getWriteFd() {return sv[0];}
- int getReadFd() {return sv[1];}
-
-protected:
- int sv[2];
- bool mShutdown;
-};
-
-}
-}
-
-#endif
diff --git a/renderscript/v8/rs_support/rsMatrix2x2.cpp b/renderscript/v8/rs_support/rsMatrix2x2.cpp
deleted file mode 100644
index 622113c..0000000
--- a/renderscript/v8/rs_support/rsMatrix2x2.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsMatrix2x2.h"
-#include "rsMatrix3x3.h"
-#include "rsMatrix4x4.h"
-
-#include "stdlib.h"
-#include "string.h"
-#include "math.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-
-void Matrix2x2::loadIdentity() {
- m[0] = 1.f;
- m[1] = 0.f;
- m[2] = 0.f;
- m[3] = 1.f;
-}
-
-void Matrix2x2::load(const float *v) {
- memcpy(m, v, sizeof(m));
-}
-
-void Matrix2x2::load(const rs_matrix2x2 *v) {
- memcpy(m, v->m, sizeof(m));
-}
-
-void Matrix2x2::loadMultiply(const rs_matrix2x2 *lhs, const rs_matrix2x2 *rhs) {
- for (int i=0 ; i<2 ; i++) {
- float ri0 = 0;
- float ri1 = 0;
- for (int j=0 ; j<2 ; j++) {
- const float rhs_ij = ((const Matrix2x2 *)rhs)->get(i, j);
- ri0 += ((const Matrix2x2 *)lhs)->get(j, 0) * rhs_ij;
- ri1 += ((const Matrix2x2 *)lhs)->get(j, 1) * rhs_ij;
- }
- set(i, 0, ri0);
- set(i, 1, ri1);
- }
-}
-
-void Matrix2x2::transpose() {
- float temp = m[1];
- m[1] = m[2];
- m[2] = temp;
-}
-
diff --git a/renderscript/v8/rs_support/rsMatrix2x2.h b/renderscript/v8/rs_support/rsMatrix2x2.h
deleted file mode 100644
index 4fbd1c2..0000000
--- a/renderscript/v8/rs_support/rsMatrix2x2.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2011-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_RS_MATRIX_2x2_H
-#define ANDROID_RS_MATRIX_2x2_H
-
-#include "rsType.h"
-
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-struct Matrix2x2 : public rs_matrix2x2 {
- inline float get(uint32_t x, uint32_t y) const {
- return m[x*2 + y];
- }
-
- inline void set(uint32_t x, uint32_t y, float v) {
- m[x*2 + y] = v;
- }
-
- void loadIdentity();
- void load(const float *);
- void load(const rs_matrix2x2 *);
-
- void loadMultiply(const rs_matrix2x2 *lhs, const rs_matrix2x2 *rhs);
-
- void transpose();
-
- void multiply(const rs_matrix2x2 *rhs) {
- Matrix2x2 tmp;
- tmp.loadMultiply(this, rhs);
- load(&tmp);
- }
-};
-
-}
-}
-
-#endif // ANDROID_RS_MATRIX_2x2_H
diff --git a/renderscript/v8/rs_support/rsMatrix3x3.cpp b/renderscript/v8/rs_support/rsMatrix3x3.cpp
deleted file mode 100644
index 3f9a2d1..0000000
--- a/renderscript/v8/rs_support/rsMatrix3x3.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsMatrix2x2.h"
-#include "rsMatrix3x3.h"
-#include "rsMatrix4x4.h"
-
-#include "stdlib.h"
-#include "string.h"
-#include "math.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-void Matrix3x3::loadIdentity() {
- m[0] = 1.f;
- m[1] = 0.f;
- m[2] = 0.f;
- m[3] = 0.f;
- m[4] = 1.f;
- m[5] = 0.f;
- m[6] = 0.f;
- m[7] = 0.f;
- m[8] = 1.f;
-}
-
-void Matrix3x3::load(const float *v) {
- memcpy(m, v, sizeof(m));
-}
-
-void Matrix3x3::load(const rs_matrix3x3 *v) {
- memcpy(m, v->m, sizeof(m));
-}
-
-void Matrix3x3::loadMultiply(const rs_matrix3x3 *lhs, const rs_matrix3x3 *rhs) {
- for (int i=0 ; i<3 ; i++) {
- float ri0 = 0;
- float ri1 = 0;
- float ri2 = 0;
- for (int j=0 ; j<3 ; j++) {
- const float rhs_ij = ((const Matrix3x3 *)rhs)->get(i, j);
- ri0 += ((const Matrix3x3 *)lhs)->get(j, 0) * rhs_ij;
- ri1 += ((const Matrix3x3 *)lhs)->get(j, 1) * rhs_ij;
- ri2 += ((const Matrix3x3 *)lhs)->get(j, 2) * rhs_ij;
- }
- set(i, 0, ri0);
- set(i, 1, ri1);
- set(i, 2, ri2);
- }
-}
-
-void Matrix3x3::transpose() {
- int i, j;
- float temp;
- for (i = 0; i < 2; ++i) {
- for (j = i + 1; j < 3; ++j) {
- temp = get(i, j);
- set(i, j, get(j, i));
- set(j, i, temp);
- }
- }
-}
-
diff --git a/renderscript/v8/rs_support/rsMatrix3x3.h b/renderscript/v8/rs_support/rsMatrix3x3.h
deleted file mode 100644
index 05249b1..0000000
--- a/renderscript/v8/rs_support/rsMatrix3x3.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2011-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_RS_MATRIX_3x3_H
-#define ANDROID_RS_MATRIX_3x3_H
-
-#include "rsType.h"
-
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-struct Matrix3x3 : public rs_matrix3x3 {
- inline float get(uint32_t x, uint32_t y) const {
- return m[x*3 + y];
- }
-
- inline void set(uint32_t x, uint32_t y, float v) {
- m[x*3 + y] = v;
- }
-
- void loadIdentity();
- void load(const float *);
- void load(const rs_matrix3x3 *);
-
- void loadMultiply(const rs_matrix3x3 *lhs, const rs_matrix3x3 *rhs);
-
- void transpose();
-
- void multiply(const rs_matrix3x3 *rhs) {
- Matrix3x3 tmp;
- tmp.loadMultiply(this, rhs);
- load(&tmp);
- }
-};
-
-}
-}
-
-#endif // ANDROID_RS_MATRIX_3x3_H
diff --git a/renderscript/v8/rs_support/rsMatrix4x4.cpp b/renderscript/v8/rs_support/rsMatrix4x4.cpp
deleted file mode 100644
index c6f96d8..0000000
--- a/renderscript/v8/rs_support/rsMatrix4x4.cpp
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsMatrix2x2.h"
-#include "rsMatrix3x3.h"
-#include "rsMatrix4x4.h"
-
-#include "stdlib.h"
-#include "string.h"
-#include "math.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-//////////////////////////////////////////////////////////////////////////////
-// Heavy math functions
-//////////////////////////////////////////////////////////////////////////////
-
-
-
-
-
-// Returns true if the matrix was successfully inversed
-bool Matrix4x4::inverse() {
- rs_matrix4x4 result;
-
- int i, j;
- for (i = 0; i < 4; ++i) {
- for (j = 0; j < 4; ++j) {
- // computeCofactor for int i, int j
- int c0 = (i+1) % 4;
- int c1 = (i+2) % 4;
- int c2 = (i+3) % 4;
- int r0 = (j+1) % 4;
- int r1 = (j+2) % 4;
- int r2 = (j+3) % 4;
-
- float minor =
- (m[c0 + 4*r0] * (m[c1 + 4*r1] * m[c2 + 4*r2] - m[c1 + 4*r2] * m[c2 + 4*r1]))
- - (m[c0 + 4*r1] * (m[c1 + 4*r0] * m[c2 + 4*r2] - m[c1 + 4*r2] * m[c2 + 4*r0]))
- + (m[c0 + 4*r2] * (m[c1 + 4*r0] * m[c2 + 4*r1] - m[c1 + 4*r1] * m[c2 + 4*r0]));
-
- float cofactor = (i+j) & 1 ? -minor : minor;
-
- result.m[4*i + j] = cofactor;
- }
- }
-
- // Dot product of 0th column of source and 0th row of result
- float det = m[0]*result.m[0] + m[4]*result.m[1] +
- m[8]*result.m[2] + m[12]*result.m[3];
-
- if (fabs(det) < 1e-6) {
- return false;
- }
-
- det = 1.0f / det;
- for (i = 0; i < 16; ++i) {
- m[i] = result.m[i] * det;
- }
-
- return true;
-}
-
-// Returns true if the matrix was successfully inversed
-bool Matrix4x4::inverseTranspose() {
- rs_matrix4x4 result;
-
- int i, j;
- for (i = 0; i < 4; ++i) {
- for (j = 0; j < 4; ++j) {
- // computeCofactor for int i, int j
- int c0 = (i+1) % 4;
- int c1 = (i+2) % 4;
- int c2 = (i+3) % 4;
- int r0 = (j+1) % 4;
- int r1 = (j+2) % 4;
- int r2 = (j+3) % 4;
-
- float minor = (m[c0 + 4*r0] * (m[c1 + 4*r1] * m[c2 + 4*r2] - m[c1 + 4*r2] * m[c2 + 4*r1]))
- - (m[c0 + 4*r1] * (m[c1 + 4*r0] * m[c2 + 4*r2] - m[c1 + 4*r2] * m[c2 + 4*r0]))
- + (m[c0 + 4*r2] * (m[c1 + 4*r0] * m[c2 + 4*r1] - m[c1 + 4*r1] * m[c2 + 4*r0]));
-
- float cofactor = (i+j) & 1 ? -minor : minor;
-
- result.m[4*j + i] = cofactor;
- }
- }
-
- // Dot product of 0th column of source and 0th column of result
- float det = m[0]*result.m[0] + m[4]*result.m[4] +
- m[8]*result.m[8] + m[12]*result.m[12];
-
- if (fabs(det) < 1e-6) {
- return false;
- }
-
- det = 1.0f / det;
- for (i = 0; i < 16; ++i) {
- m[i] = result.m[i] * det;
- }
-
- return true;
-}
-
-void Matrix4x4::transpose() {
- int i, j;
- float temp;
- for (i = 0; i < 3; ++i) {
- for (j = i + 1; j < 4; ++j) {
- temp = m[i*4 + j];
- m[i*4 + j] = m[j*4 + i];
- m[j*4 + i] = temp;
- }
- }
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////
-
-void Matrix4x4::loadIdentity() {
- m[0] = 1.f;
- m[1] = 0.f;
- m[2] = 0.f;
- m[3] = 0.f;
- m[4] = 0.f;
- m[5] = 1.f;
- m[6] = 0.f;
- m[7] = 0.f;
- m[8] = 0.f;
- m[9] = 0.f;
- m[10] = 1.f;
- m[11] = 0.f;
- m[12] = 0.f;
- m[13] = 0.f;
- m[14] = 0.f;
- m[15] = 1.f;
-}
-
-void Matrix4x4::load(const float *v) {
- memcpy(m, v, sizeof(m));
-}
-
-void Matrix4x4::load(const rs_matrix4x4 *v) {
- memcpy(m, v->m, sizeof(m));
-}
-
-void Matrix4x4::load(const rs_matrix3x3 *v) {
- m[0] = v->m[0];
- m[1] = v->m[1];
- m[2] = v->m[2];
- m[3] = 0.f;
- m[4] = v->m[3];
- m[5] = v->m[4];
- m[6] = v->m[5];
- m[7] = 0.f;
- m[8] = v->m[6];
- m[9] = v->m[7];
- m[10] = v->m[8];
- m[11] = 0.f;
- m[12] = 0.f;
- m[13] = 0.f;
- m[14] = 0.f;
- m[15] = 1.f;
-}
-
-void Matrix4x4::load(const rs_matrix2x2 *v) {
- m[0] = v->m[0];
- m[1] = v->m[1];
- m[2] = 0.f;
- m[3] = 0.f;
- m[4] = v->m[2];
- m[5] = v->m[3];
- m[6] = 0.f;
- m[7] = 0.f;
- m[8] = 0.f;
- m[9] = 0.f;
- m[10] = 1.f;
- m[11] = 0.f;
- m[12] = 0.f;
- m[13] = 0.f;
- m[14] = 0.f;
- m[15] = 1.f;
-}
-
-
-void Matrix4x4::loadRotate(float rot, float x, float y, float z) {
- float c, s;
- m[3] = 0;
- m[7] = 0;
- m[11]= 0;
- m[12]= 0;
- m[13]= 0;
- m[14]= 0;
- m[15]= 1;
- rot *= float(M_PI / 180.0f);
- c = cosf(rot);
- s = sinf(rot);
-
- const float len = x*x + y*y + z*z;
- if (len != 1) {
- const float recipLen = 1.f / sqrtf(len);
- x *= recipLen;
- y *= recipLen;
- z *= recipLen;
- }
- const float nc = 1.0f - c;
- const float xy = x * y;
- const float yz = y * z;
- const float zx = z * x;
- const float xs = x * s;
- const float ys = y * s;
- const float zs = z * s;
- m[ 0] = x*x*nc + c;
- m[ 4] = xy*nc - zs;
- m[ 8] = zx*nc + ys;
- m[ 1] = xy*nc + zs;
- m[ 5] = y*y*nc + c;
- m[ 9] = yz*nc - xs;
- m[ 2] = zx*nc - ys;
- m[ 6] = yz*nc + xs;
- m[10] = z*z*nc + c;
-}
-
-void Matrix4x4::loadScale(float x, float y, float z) {
- loadIdentity();
- set(0, 0, x);
- set(1, 1, y);
- set(2, 2, z);
-}
-
-void Matrix4x4::loadTranslate(float x, float y, float z) {
- loadIdentity();
- m[12] = x;
- m[13] = y;
- m[14] = z;
-}
-
-void Matrix4x4::loadMultiply(const rs_matrix4x4 *lhs, const rs_matrix4x4 *rhs) {
- for (int i=0 ; i<4 ; i++) {
- float ri0 = 0;
- float ri1 = 0;
- float ri2 = 0;
- float ri3 = 0;
- for (int j=0 ; j<4 ; j++) {
- const float rhs_ij = ((const Matrix4x4 *)rhs)->get(i,j);
- ri0 += ((const Matrix4x4 *)lhs)->get(j,0) * rhs_ij;
- ri1 += ((const Matrix4x4 *)lhs)->get(j,1) * rhs_ij;
- ri2 += ((const Matrix4x4 *)lhs)->get(j,2) * rhs_ij;
- ri3 += ((const Matrix4x4 *)lhs)->get(j,3) * rhs_ij;
- }
- set(i,0, ri0);
- set(i,1, ri1);
- set(i,2, ri2);
- set(i,3, ri3);
- }
-}
-
-void Matrix4x4::loadOrtho(float left, float right, float bottom, float top, float near, float far) {
- loadIdentity();
- m[0] = 2.f / (right - left);
- m[5] = 2.f / (top - bottom);
- m[10]= -2.f / (far - near);
- m[12]= -(right + left) / (right - left);
- m[13]= -(top + bottom) / (top - bottom);
- m[14]= -(far + near) / (far - near);
-}
-
-void Matrix4x4::loadFrustum(float left, float right, float bottom, float top, float near, float far) {
- loadIdentity();
- m[0] = 2.f * near / (right - left);
- m[5] = 2.f * near / (top - bottom);
- m[8] = (right + left) / (right - left);
- m[9] = (top + bottom) / (top - bottom);
- m[10]= -(far + near) / (far - near);
- m[11]= -1.f;
- m[14]= -2.f * far * near / (far - near);
- m[15]= 0.f;
-}
-
-void Matrix4x4::loadPerspective(float fovy, float aspect, float near, float far) {
- float top = near * tan((float) (fovy * M_PI / 360.0f));
- float bottom = -top;
- float left = bottom * aspect;
- float right = top * aspect;
- loadFrustum(left, right, bottom, top, near, far);
-}
-
-void Matrix4x4::vectorMultiply(float *out, const float *in) const {
- out[0] = (m[0] * in[0]) + (m[4] * in[1]) + (m[8] * in[2]) + m[12];
- out[1] = (m[1] * in[0]) + (m[5] * in[1]) + (m[9] * in[2]) + m[13];
- out[2] = (m[2] * in[0]) + (m[6] * in[1]) + (m[10] * in[2]) + m[14];
- out[3] = (m[3] * in[0]) + (m[7] * in[1]) + (m[11] * in[2]) + m[15];
-}
-
-void Matrix4x4::logv(const char *s) const {
- ALOGV("%s {%f, %f, %f, %f", s, m[0], m[4], m[8], m[12]);
- ALOGV("%s %f, %f, %f, %f", s, m[1], m[5], m[9], m[13]);
- ALOGV("%s %f, %f, %f, %f", s, m[2], m[6], m[10], m[14]);
- ALOGV("%s %f, %f, %f, %f}", s, m[3], m[7], m[11], m[15]);
-}
diff --git a/renderscript/v8/rs_support/rsMatrix4x4.h b/renderscript/v8/rs_support/rsMatrix4x4.h
deleted file mode 100644
index 44c33d1..0000000
--- a/renderscript/v8/rs_support/rsMatrix4x4.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2009-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_RS_MATRIX_4x4_H
-#define ANDROID_RS_MATRIX_4x4_H
-
-#include "rsType.h"
-
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-struct Matrix4x4 : public rs_matrix4x4 {
- float get(uint32_t x, uint32_t y) const {
- return m[x*4 + y];
- }
-
- void set(uint32_t x, uint32_t y, float v) {
- m[x*4 + y] = v;
- }
-
- void loadIdentity();
- void load(const float *);
- void load(const rs_matrix4x4 *);
- void load(const rs_matrix3x3 *);
- void load(const rs_matrix2x2 *);
-
- void loadRotate(float rot, float x, float y, float z);
- void loadScale(float x, float y, float z);
- void loadTranslate(float x, float y, float z);
- void loadMultiply(const rs_matrix4x4 *lhs, const rs_matrix4x4 *rhs);
-
- void loadOrtho(float l, float r, float b, float t, float n, float f);
- void loadFrustum(float l, float r, float b, float t, float n, float f);
- void loadPerspective(float fovy, float aspect, float near, float far);
-
- void vectorMultiply(float *v4out, const float *v3in) const;
-
- bool inverse();
- bool inverseTranspose();
- void transpose();
-
- void logv(const char *s) const;
-
-
- void multiply(const rs_matrix4x4 *rhs) {
- Matrix4x4 tmp;
- tmp.loadMultiply(this, rhs);
- load(&tmp);
- }
- void rotate(float rot, float x, float y, float z) {
- Matrix4x4 tmp;
- tmp.loadRotate(rot, x, y, z);
- multiply(&tmp);
- }
- void scale(float x, float y, float z) {
- Matrix4x4 tmp;
- tmp.loadScale(x, y, z);
- multiply(&tmp);
- }
- void translate(float x, float y, float z) {
- Matrix4x4 tmp;
- tmp.loadTranslate(x, y, z);
- multiply(&tmp);
- }
-};
-
-}
-}
-
-#endif // ANDROID_RS_MATRIX_4x4_H
diff --git a/renderscript/v8/rs_support/rsMutex.cpp b/renderscript/v8/rs_support/rsMutex.cpp
deleted file mode 100644
index 6512372..0000000
--- a/renderscript/v8/rs_support/rsMutex.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsMutex.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-
-Mutex::Mutex() {
-}
-
-Mutex::~Mutex() {
- pthread_mutex_destroy(&mMutex);
-}
-
-bool Mutex::init() {
- int status = pthread_mutex_init(&mMutex, NULL);
- if (status) {
- ALOGE("Mutex::Mutex init failure");
- return false;
- }
- return true;
-}
-
-bool Mutex::lock() {
- int status;
- status = pthread_mutex_lock(&mMutex);
- if (status) {
- ALOGE("Mutex: error %i locking.", status);
- return false;
- }
- return true;
-}
-
-bool Mutex::unlock() {
- int status;
- status = pthread_mutex_unlock(&mMutex);
- if (status) {
- ALOGE("Mutex error %i unlocking.", status);
- return false;
- }
- return true;
-}
-
-
diff --git a/renderscript/v8/rs_support/rsMutex.h b/renderscript/v8/rs_support/rsMutex.h
deleted file mode 100644
index 47725d7..0000000
--- a/renderscript/v8/rs_support/rsMutex.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_RS_MUTEX_H
-#define ANDROID_RS_MUTEX_H
-
-
-#include "rsUtils.h"
-
-namespace android {
-namespace renderscript {
-
-class Mutex {
-public:
- Mutex();
- ~Mutex();
-
- bool init();
- bool lock();
- bool unlock();
-
-protected:
- pthread_mutex_t mMutex;
-};
-
-}
-}
-
-#endif
-
diff --git a/renderscript/v8/rs_support/rsObjectBase.cpp b/renderscript/v8/rs_support/rsObjectBase.cpp
deleted file mode 100644
index 6a64582..0000000
--- a/renderscript/v8/rs_support/rsObjectBase.cpp
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsObjectBase.h"
-#include "rsContext.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-pthread_mutex_t ObjectBase::gObjectInitMutex = PTHREAD_MUTEX_INITIALIZER;
-
-ObjectBase::ObjectBase(Context *rsc) {
- mUserRefCount = 0;
- mSysRefCount = 0;
- mRSC = rsc;
- mNext = NULL;
- mPrev = NULL;
-
-#if RS_OBJECT_DEBUG
- mStack.update(2);
-#endif
-
- rsAssert(rsc);
- add();
- //ALOGV("ObjectBase %p con", this);
-}
-
-ObjectBase::~ObjectBase() {
- //ALOGV("~ObjectBase %p ref %i,%i", this, mUserRefCount, mSysRefCount);
-#if RS_OBJECT_DEBUG
- mStack.dump();
-#endif
-
- if (mPrev || mNext) {
- // While the normal practice is to call remove before we call
- // delete. Its possible for objects without a re-use list
- // for avoiding duplication to be created on the stack. In those
- // cases we need to remove ourself here.
- asyncLock();
- remove();
- asyncUnlock();
- }
-
- rsAssert(!mUserRefCount);
- rsAssert(!mSysRefCount);
-}
-
-void ObjectBase::dumpLOGV(const char *op) const {
- if (mName.size()) {
- ALOGV("%s RSobj %p, name %s, refs %i,%i links %p,%p,%p",
- op, this, mName.string(), mUserRefCount, mSysRefCount, mNext, mPrev, mRSC);
- } else {
- ALOGV("%s RSobj %p, no-name, refs %i,%i links %p,%p,%p",
- op, this, mUserRefCount, mSysRefCount, mNext, mPrev, mRSC);
- }
-}
-
-void ObjectBase::incUserRef() const {
- android_atomic_inc(&mUserRefCount);
- //ALOGV("ObjectBase %p incU ref %i, %i", this, mUserRefCount, mSysRefCount);
-}
-
-void ObjectBase::incSysRef() const {
- android_atomic_inc(&mSysRefCount);
- //ALOGV("ObjectBase %p incS ref %i, %i", this, mUserRefCount, mSysRefCount);
-}
-
-void ObjectBase::preDestroy() const {
-}
-
-bool ObjectBase::freeChildren() {
- return false;
-}
-
-bool ObjectBase::checkDelete(const ObjectBase *ref) {
- if (!ref) {
- return false;
- }
-
- asyncLock();
- // This lock protects us against the non-RS threads changing
- // the ref counts. At this point we should be the only thread
- // working on them.
- if (ref->mUserRefCount || ref->mSysRefCount) {
- asyncUnlock();
- return false;
- }
-
- ref->remove();
- // At this point we can unlock because there should be no possible way
- // for another thread to reference this object.
- ref->preDestroy();
- asyncUnlock();
- delete ref;
- return true;
-}
-
-bool ObjectBase::decUserRef() const {
- rsAssert(mUserRefCount > 0);
-#if RS_OBJECT_DEBUG
- ALOGV("ObjectBase %p decU ref %i, %i", this, mUserRefCount, mSysRefCount);
- if (mUserRefCount <= 0) {
- mStack.dump();
- }
-#endif
-
-
- if ((android_atomic_dec(&mUserRefCount) <= 1) &&
- (android_atomic_acquire_load(&mSysRefCount) <= 0)) {
- return checkDelete(this);
- }
- return false;
-}
-
-bool ObjectBase::zeroUserRef() const {
- //ALOGV("ObjectBase %p zeroU ref %i, %i", this, mUserRefCount, mSysRefCount);
- android_atomic_acquire_store(0, &mUserRefCount);
- if (android_atomic_acquire_load(&mSysRefCount) <= 0) {
- return checkDelete(this);
- }
- return false;
-}
-
-bool ObjectBase::decSysRef() const {
- //ALOGV("ObjectBase %p decS ref %i, %i", this, mUserRefCount, mSysRefCount);
- rsAssert(mSysRefCount > 0);
- if ((android_atomic_dec(&mSysRefCount) <= 1) &&
- (android_atomic_acquire_load(&mUserRefCount) <= 0)) {
- return checkDelete(this);
- }
- return false;
-}
-
-void ObjectBase::setName(const char *name) {
- mName.setTo(name);
-}
-
-void ObjectBase::setName(const char *name, uint32_t len) {
- mName.setTo(name, len);
-}
-
-void ObjectBase::asyncLock() {
- pthread_mutex_lock(&gObjectInitMutex);
-}
-
-void ObjectBase::asyncUnlock() {
- pthread_mutex_unlock(&gObjectInitMutex);
-}
-
-void ObjectBase::add() const {
- asyncLock();
-
- rsAssert(!mNext);
- rsAssert(!mPrev);
- //ALOGV("calling add rsc %p", mRSC);
- mNext = mRSC->mObjHead;
- if (mRSC->mObjHead) {
- mRSC->mObjHead->mPrev = this;
- }
- mRSC->mObjHead = this;
-
- asyncUnlock();
-}
-
-void ObjectBase::remove() const {
- //ALOGV("calling remove rsc %p", mRSC);
- if (!mRSC) {
- rsAssert(!mPrev);
- rsAssert(!mNext);
- return;
- }
-
- if (mRSC->mObjHead == this) {
- mRSC->mObjHead = mNext;
- }
- if (mPrev) {
- mPrev->mNext = mNext;
- }
- if (mNext) {
- mNext->mPrev = mPrev;
- }
- mPrev = NULL;
- mNext = NULL;
-}
-
-void ObjectBase::zeroAllUserRef(Context *rsc) {
- if (rsc->props.mLogObjects) {
- ALOGV("Forcing release of all outstanding user refs.");
- }
-
- // This operation can be slow, only to be called during context cleanup.
- const ObjectBase * o = rsc->mObjHead;
- while (o) {
- //ALOGE("o %p", o);
- if (o->zeroUserRef()) {
- // deleted the object and possibly others, restart from head.
- o = rsc->mObjHead;
- //ALOGE("o head %p", o);
- } else {
- o = o->mNext;
- //ALOGE("o next %p", o);
- }
- }
-
- if (rsc->props.mLogObjects) {
- ALOGV("Objects remaining.");
- dumpAll(rsc);
- }
-}
-
-void ObjectBase::freeAllChildren(Context *rsc) {
- if (rsc->props.mLogObjects) {
- ALOGV("Forcing release of all child objects.");
- }
-
- // This operation can be slow, only to be called during context cleanup.
- ObjectBase * o = (ObjectBase *)rsc->mObjHead;
- while (o) {
- if (o->freeChildren()) {
- // deleted ref to self and possibly others, restart from head.
- o = (ObjectBase *)rsc->mObjHead;
- } else {
- o = (ObjectBase *)o->mNext;
- }
- }
-
- if (rsc->props.mLogObjects) {
- ALOGV("Objects remaining.");
- dumpAll(rsc);
- }
-}
-
-void ObjectBase::dumpAll(Context *rsc) {
- asyncLock();
-
- ALOGV("Dumping all objects");
- const ObjectBase * o = rsc->mObjHead;
- while (o) {
- ALOGV(" Object %p", o);
- o->dumpLOGV(" ");
- o = o->mNext;
- }
-
- asyncUnlock();
-}
-
-bool ObjectBase::isValid(const Context *rsc, const ObjectBase *obj) {
- asyncLock();
-
- const ObjectBase * o = rsc->mObjHead;
- while (o) {
- if (o == obj) {
- asyncUnlock();
- return true;
- }
- o = o->mNext;
- }
- asyncUnlock();
- return false;
-}
-
diff --git a/renderscript/v8/rs_support/rsObjectBase.h b/renderscript/v8/rs_support/rsObjectBase.h
deleted file mode 100644
index f16acd9..0000000
--- a/renderscript/v8/rs_support/rsObjectBase.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_RS_OBJECT_BASE_H
-#define ANDROID_RS_OBJECT_BASE_H
-
-#include "rsUtils.h"
-#include "rsDefines.h"
-
-#define RS_OBJECT_DEBUG 0
-
-#include <utils/CallStack.h>
-
-namespace android {
-namespace renderscript {
-
-class Context;
-class OStream;
-
-// An element is a group of Components that occupies one cell in a structure.
-class ObjectBase {
-public:
- ObjectBase(Context *rsc);
-
- void incSysRef() const;
- bool decSysRef() const;
-
- void incUserRef() const;
- bool decUserRef() const;
- bool zeroUserRef() const;
-
- static bool checkDelete(const ObjectBase *);
-
- const char * getName() const {
- return mName.string();
- }
- void setName(const char *);
- void setName(const char *, uint32_t len);
-
- Context * getContext() const {return mRSC;}
- virtual bool freeChildren();
-
- static void zeroAllUserRef(Context *rsc);
- static void freeAllChildren(Context *rsc);
- static void dumpAll(Context *rsc);
-
- virtual void dumpLOGV(const char *prefix) const;
- virtual void serialize(Context *rsc, OStream *stream) const = 0;
- virtual RsA3DClassID getClassId() const = 0;
-
- static bool isValid(const Context *rsc, const ObjectBase *obj);
-
- // The async lock is taken during object creation in non-rs threads
- // and object deletion in the rs thread.
- static void asyncLock();
- static void asyncUnlock();
-
-protected:
- // Called inside the async lock for any object list management that is
- // necessary in derived classes.
- virtual void preDestroy() const;
-
- Context *mRSC;
- virtual ~ObjectBase();
-
-private:
- static pthread_mutex_t gObjectInitMutex;
-
- void add() const;
- void remove() const;
-
- String8 mName;
- mutable int32_t mSysRefCount;
- mutable int32_t mUserRefCount;
-
- mutable const ObjectBase * mPrev;
- mutable const ObjectBase * mNext;
-
-#if RS_OBJECT_DEBUG
- CallStack mStack;
-#endif
-
-};
-
-template<class T>
-class ObjectBaseRef {
-public:
- ObjectBaseRef() {
- mRef = NULL;
- }
-
- ObjectBaseRef(const ObjectBaseRef &ref) {
- mRef = ref.get();
- if (mRef) {
- mRef->incSysRef();
- }
- }
-
- ObjectBaseRef(T *ref) {
- mRef = ref;
- if (mRef) {
- ref->incSysRef();
- }
- }
-
- ObjectBaseRef & operator= (const ObjectBaseRef &ref) {
- if (&ref != this) {
- set(ref);
- }
- return *this;
- }
-
- ~ObjectBaseRef() {
- clear();
- }
-
- void set(T *ref) {
- if (mRef != ref) {
- clear();
- mRef = ref;
- if (mRef) {
- ref->incSysRef();
- }
- }
- }
-
- void set(const ObjectBaseRef &ref) {
- set(ref.mRef);
- }
-
- void clear() {
- if (mRef) {
- mRef->decSysRef();
- }
- mRef = NULL;
- }
-
- inline T * get() const {
- return mRef;
- }
-
- inline T * operator-> () const {
- return mRef;
- }
-
-protected:
- T * mRef;
-};
-
-}
-}
-
-#endif //ANDROID_RS_OBJECT_BASE_H
-
diff --git a/renderscript/v8/rs_support/rsRuntime.h b/renderscript/v8/rs_support/rsRuntime.h
deleted file mode 100644
index c756058..0000000
--- a/renderscript/v8/rs_support/rsRuntime.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsContext.h"
-#include "rsScriptC.h"
-
-#include "utils/Timers.h"
-
-#include <time.h>
-
-namespace android {
-namespace renderscript {
-
-
-//////////////////////////////////////////////////////////////////////////////
-// Context
-//////////////////////////////////////////////////////////////////////////////
-
-void rsrAllocationSyncAll(Context *, Script *, Allocation *);
-
-void rsrAllocationCopy1DRange(Context *, Allocation *dstAlloc,
- uint32_t dstOff,
- uint32_t dstMip,
- uint32_t count,
- Allocation *srcAlloc,
- uint32_t srcOff, uint32_t srcMip);
-void rsrAllocationCopy2DRange(Context *, Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff,
- uint32_t dstMip, uint32_t dstFace,
- uint32_t width, uint32_t height,
- Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff,
- uint32_t srcMip, uint32_t srcFace);
-
-//////////////////////////////////////////////////////////////////////////////
-// Time routines
-//////////////////////////////////////////////////////////////////////////////
-
-float rsrGetDt(Context *, Script *);
-time_t rsrTime(Context *, Script *, time_t *timer);
-tm* rsrLocalTime(Context *, Script *, tm *local, time_t *timer);
-int64_t rsrUptimeMillis(Context *, Script *);
-int64_t rsrUptimeNanos(Context *, Script *);
-
-//////////////////////////////////////////////////////////////////////////////
-// Message routines
-//////////////////////////////////////////////////////////////////////////////
-
-uint32_t rsrToClient(Context *, Script *, int cmdID, void *data, int len);
-uint32_t rsrToClientBlocking(Context *, Script *, int cmdID, void *data, int len);
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-
-void rsrSetObject(const Context *, const Script *, ObjectBase **dst, ObjectBase * src);
-void rsrClearObject(const Context *, const Script *, ObjectBase **dst);
-bool rsrIsObject(const Context *, const Script *, const ObjectBase *src);
-
-void rsrAllocationIncRefs(const Context *, const Allocation *, void *ptr,
- size_t elementCount, size_t startOffset);
-void rsrAllocationDecRefs(const Context *, const Allocation *, void *ptr,
- size_t elementCount, size_t startOffset);
-
-
-uint32_t rsrToClient(Context *, Script *, int cmdID, void *data, int len);
-uint32_t rsrToClientBlocking(Context *, Script *, int cmdID, void *data, int len);
-
-void rsrAllocationMarkDirty(Context *, Script *, RsAllocation a);
-void rsrAllocationSyncAll(Context *, Script *, Allocation *a, RsAllocationUsageType source);
-
-
-void rsrForEach(Context *, Script *, Script *target,
- Allocation *in,
- Allocation *out,
- const void *usr,
- uint32_t usrBytes,
- const RsScriptCall *call);
-
-
-//////////////////////////////////////////////////////////////////////////////
-// Heavy math functions
-//////////////////////////////////////////////////////////////////////////////
-
-
-void rsrMatrixSet(rs_matrix4x4 *m, uint32_t row, uint32_t col, float v);
-float rsrMatrixGet(const rs_matrix4x4 *m, uint32_t row, uint32_t col);
-void rsrMatrixSet(rs_matrix3x3 *m, uint32_t row, uint32_t col, float v);
-float rsrMatrixGet(const rs_matrix3x3 *m, uint32_t row, uint32_t col);
-void rsrMatrixSet(rs_matrix2x2 *m, uint32_t row, uint32_t col, float v);
-float rsrMatrixGet(const rs_matrix2x2 *m, uint32_t row, uint32_t col);
-void rsrMatrixLoadIdentity_4x4(rs_matrix4x4 *m);
-void rsrMatrixLoadIdentity_3x3(rs_matrix3x3 *m);
-void rsrMatrixLoadIdentity_2x2(rs_matrix2x2 *m);
-void rsrMatrixLoad_4x4_f(rs_matrix4x4 *m, const float *v);
-void rsrMatrixLoad_3x3_f(rs_matrix3x3 *m, const float *v);
-void rsrMatrixLoad_2x2_f(rs_matrix2x2 *m, const float *v);
-void rsrMatrixLoad_4x4_4x4(rs_matrix4x4 *m, const rs_matrix4x4 *v);
-void rsrMatrixLoad_4x4_3x3(rs_matrix4x4 *m, const rs_matrix3x3 *v);
-void rsrMatrixLoad_4x4_2x2(rs_matrix4x4 *m, const rs_matrix2x2 *v);
-void rsrMatrixLoad_3x3_3x3(rs_matrix3x3 *m, const rs_matrix3x3 *v);
-void rsrMatrixLoad_2x2_2x2(rs_matrix2x2 *m, const rs_matrix2x2 *v);
-void rsrMatrixLoadRotate(rs_matrix4x4 *m, float rot, float x, float y, float z);
-void rsrMatrixLoadScale(rs_matrix4x4 *m, float x, float y, float z);
-void rsrMatrixLoadTranslate(rs_matrix4x4 *m, float x, float y, float z);
-void rsrMatrixLoadMultiply_4x4_4x4_4x4(rs_matrix4x4 *m, const rs_matrix4x4 *lhs,
- const rs_matrix4x4 *rhs);
-void rsrMatrixMultiply_4x4_4x4(rs_matrix4x4 *m, const rs_matrix4x4 *rhs);
-void rsrMatrixLoadMultiply_3x3_3x3_3x3(rs_matrix3x3 *m, const rs_matrix3x3 *lhs,
- const rs_matrix3x3 *rhs);
-void rsrMatrixMultiply_3x3_3x3(rs_matrix3x3 *m, const rs_matrix3x3 *rhs);
-void rsrMatrixLoadMultiply_2x2_2x2_2x2(rs_matrix2x2 *m, const rs_matrix2x2 *lhs,
- const rs_matrix2x2 *rhs);
-void rsrMatrixMultiply_2x2_2x2(rs_matrix2x2 *m, const rs_matrix2x2 *rhs);
-void rsrMatrixRotate(rs_matrix4x4 *m, float rot, float x, float y, float z);
-void rsrMatrixScale(rs_matrix4x4 *m, float x, float y, float z);
-void rsrMatrixTranslate(rs_matrix4x4 *m, float x, float y, float z);
-void rsrMatrixLoadOrtho(rs_matrix4x4 *m, float left, float right,
- float bottom, float top, float near, float far);
-void rsrMatrixLoadFrustum(rs_matrix4x4 *m, float left, float right,
- float bottom, float top, float near, float far);
-void rsrMatrixLoadPerspective(rs_matrix4x4* m, float fovy, float aspect, float near, float far);
-
-// Returns true if the matrix was successfully inversed
-bool rsrMatrixInverse_4x4(rs_matrix4x4 *m);
-// Returns true if the matrix was successfully inversed
-bool rsrMatrixInverseTranspose_4x4(rs_matrix4x4 *m);
-
-void rsrMatrixTranspose_4x4(rs_matrix4x4 *m);
-void rsrMatrixTranspose_3x3(rs_matrix3x3 *m);
-void rsrMatrixTranspose_2x2(rs_matrix2x2 *m);
-
-}
-}
diff --git a/renderscript/v8/rs_support/rsSampler.cpp b/renderscript/v8/rs_support/rsSampler.cpp
deleted file mode 100644
index fededb1..0000000
--- a/renderscript/v8/rs_support/rsSampler.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsContext.h"
-#include "rsSampler.h"
-#include "rs.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-
-Sampler::Sampler(Context *rsc) : ObjectBase(rsc) {
- // Should not get called.
- rsAssert(0);
-}
-
-Sampler::Sampler(Context *rsc,
- RsSamplerValue magFilter,
- RsSamplerValue minFilter,
- RsSamplerValue wrapS,
- RsSamplerValue wrapT,
- RsSamplerValue wrapR,
- float aniso) : ObjectBase(rsc) {
- mHal.state.magFilter = magFilter;
- mHal.state.minFilter = minFilter;
- mHal.state.wrapS = wrapS;
- mHal.state.wrapT = wrapT;
- mHal.state.wrapR = wrapR;
- mHal.state.aniso = aniso;
-
- mRSC->mHal.funcs.sampler.init(mRSC, this);
-}
-
-Sampler::~Sampler() {
- mRSC->mHal.funcs.sampler.destroy(mRSC, this);
-}
-
-void Sampler::preDestroy() const {
- for (uint32_t ct = 0; ct < mRSC->mStateSampler.mAllSamplers.size(); ct++) {
- if (mRSC->mStateSampler.mAllSamplers[ct] == this) {
- mRSC->mStateSampler.mAllSamplers.removeAt(ct);
- break;
- }
- }
-}
-
-void Sampler::bindToContext(SamplerState *ss, uint32_t slot) {
- ss->mSamplers[slot].set(this);
- mBoundSlot = slot;
-}
-
-void Sampler::unbindFromContext(SamplerState *ss) {
- int32_t slot = mBoundSlot;
- mBoundSlot = -1;
- ss->mSamplers[slot].clear();
-}
-
-void Sampler::serialize(Context *rsc, OStream *stream) const {
-}
-
-Sampler *Sampler::createFromStream(Context *rsc, IStream *stream) {
- return NULL;
-}
-
-ObjectBaseRef<Sampler> Sampler::getSampler(Context *rsc,
- RsSamplerValue magFilter,
- RsSamplerValue minFilter,
- RsSamplerValue wrapS,
- RsSamplerValue wrapT,
- RsSamplerValue wrapR,
- float aniso) {
- ObjectBaseRef<Sampler> returnRef;
- ObjectBase::asyncLock();
- for (uint32_t ct = 0; ct < rsc->mStateSampler.mAllSamplers.size(); ct++) {
- Sampler *existing = rsc->mStateSampler.mAllSamplers[ct];
- if (existing->mHal.state.magFilter != magFilter) continue;
- if (existing->mHal.state.minFilter != minFilter ) continue;
- if (existing->mHal.state.wrapS != wrapS) continue;
- if (existing->mHal.state.wrapT != wrapT) continue;
- if (existing->mHal.state.wrapR != wrapR) continue;
- if (existing->mHal.state.aniso != aniso) continue;
- returnRef.set(existing);
- ObjectBase::asyncUnlock();
- return returnRef;
- }
- ObjectBase::asyncUnlock();
-
- Sampler *s = new Sampler(rsc, magFilter, minFilter, wrapS, wrapT, wrapR, aniso);
- returnRef.set(s);
-
- ObjectBase::asyncLock();
- rsc->mStateSampler.mAllSamplers.push(s);
- ObjectBase::asyncUnlock();
-
- return returnRef;
-}
-
-////////////////////////////////
-
-namespace android {
-namespace renderscript {
-
-RsSampler rsi_SamplerCreate(Context * rsc,
- RsSamplerValue magFilter,
- RsSamplerValue minFilter,
- RsSamplerValue wrapS,
- RsSamplerValue wrapT,
- RsSamplerValue wrapR,
- float aniso) {
- ObjectBaseRef<Sampler> s = Sampler::getSampler(rsc, magFilter, minFilter,
- wrapS, wrapT, wrapR, aniso);
- s->incUserRef();
- return s.get();
-}
-
-}}
diff --git a/renderscript/v8/rs_support/rsSampler.h b/renderscript/v8/rs_support/rsSampler.h
deleted file mode 100644
index 81220a8..0000000
--- a/renderscript/v8/rs_support/rsSampler.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_RS_SAMPLER_H
-#define ANDROID_RS_SAMPLER_H
-
-#include "rsAllocation.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-const static uint32_t RS_MAX_SAMPLER_SLOT = 16;
-
-class SamplerState;
-/*****************************************************************************
- * CAUTION
- *
- * Any layout changes for this class may require a corresponding change to be
- * made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
- * a partial copy of the information below.
- *
- *****************************************************************************/
-class Sampler : public ObjectBase {
-public:
- struct Hal {
- mutable void *drv;
-
- struct State {
- RsSamplerValue magFilter;
- RsSamplerValue minFilter;
- RsSamplerValue wrapS;
- RsSamplerValue wrapT;
- RsSamplerValue wrapR;
- float aniso;
- };
- State state;
- };
- Hal mHal;
-
- static ObjectBaseRef<Sampler> getSampler(Context *,
- RsSamplerValue magFilter,
- RsSamplerValue minFilter,
- RsSamplerValue wrapS,
- RsSamplerValue wrapT,
- RsSamplerValue wrapR,
- float aniso = 1.0f);
- void bindToContext(SamplerState *, uint32_t slot);
- void unbindFromContext(SamplerState *);
-
- virtual void serialize(Context *rsc, OStream *stream) const;
- virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SAMPLER; }
- static Sampler *createFromStream(Context *rsc, IStream *stream);
-
-protected:
- int32_t mBoundSlot;
-
- virtual void preDestroy() const;
- virtual ~Sampler();
-
-private:
- Sampler(Context *);
- Sampler(Context *,
- RsSamplerValue magFilter,
- RsSamplerValue minFilter,
- RsSamplerValue wrapS,
- RsSamplerValue wrapT,
- RsSamplerValue wrapR,
- float aniso = 1.0f);
-};
-
-
-class SamplerState {
-public:
- ObjectBaseRef<Sampler> mSamplers[RS_MAX_SAMPLER_SLOT];
- void init(Context *rsc) {
- }
- void deinit(Context *rsc) {
- for (uint32_t i = 0; i < RS_MAX_SAMPLER_SLOT; i ++) {
- mSamplers[i].clear();
- }
- }
- // Cache of all existing raster programs.
- Vector<Sampler *> mAllSamplers;
-};
-
-}
-}
-#endif //ANDROID_RS_SAMPLER_H
-
-
-
diff --git a/renderscript/v8/rs_support/rsScript.cpp b/renderscript/v8/rs_support/rsScript.cpp
deleted file mode 100644
index 9bbc2ba..0000000
--- a/renderscript/v8/rs_support/rsScript.cpp
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright (C) 2009-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsContext.h"
-#include <time.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-Script::Script(Context *rsc) : ObjectBase(rsc) {
- memset(&mEnviroment, 0, sizeof(mEnviroment));
- memset(&mHal, 0, sizeof(mHal));
-
- mSlots = NULL;
- mTypes = NULL;
- mInitialized = false;
-}
-
-Script::~Script() {
- if (mSlots) {
- delete [] mSlots;
- mSlots = NULL;
- }
- if (mTypes) {
- delete [] mTypes;
- mTypes = NULL;
- }
-}
-
-void Script::setSlot(uint32_t slot, Allocation *a) {
- //ALOGE("setSlot %i %p", slot, a);
- if (slot >= mHal.info.exportedVariableCount) {
- ALOGE("Script::setSlot unable to set allocation, invalid slot index");
- return;
- }
-
- mSlots[slot].set(a);
- mRSC->mHal.funcs.script.setGlobalBind(mRSC, this, slot, a);
-}
-
-void Script::setVar(uint32_t slot, const void *val, size_t len) {
- //ALOGE("setVar %i %p %i", slot, val, len);
- if (slot >= mHal.info.exportedVariableCount) {
- ALOGE("Script::setVar unable to set allocation, invalid slot index");
- return;
- }
- mRSC->mHal.funcs.script.setGlobalVar(mRSC, this, slot, (void *)val, len);
-}
-
-void Script::setVar(uint32_t slot, const void *val, size_t len, Element *e,
- const size_t *dims, size_t dimLen) {
- if (slot >= mHal.info.exportedVariableCount) {
- ALOGE("Script::setVar unable to set allocation, invalid slot index");
- return;
- }
- mRSC->mHal.funcs.script.setGlobalVarWithElemDims(mRSC, this, slot,
- (void *)val, len, e, dims, dimLen);
-}
-
-void Script::setVarObj(uint32_t slot, ObjectBase *val) {
- //ALOGE("setVarObj %i %p", slot, val);
- if (slot >= mHal.info.exportedVariableCount) {
- ALOGE("Script::setVarObj unable to set allocation, invalid slot index");
- return;
- }
- //ALOGE("setvarobj %i %p", slot, val);
- mRSC->mHal.funcs.script.setGlobalObj(mRSC, this, slot, val);
-}
-
-bool Script::freeChildren() {
- incSysRef();
- mRSC->mHal.funcs.script.invokeFreeChildren(mRSC, this);
- return decSysRef();
-}
-
-ScriptKernelID::ScriptKernelID(Context *rsc, Script *s, int slot, int sig)
- : ObjectBase(rsc) {
-
- mScript = s;
- mSlot = slot;
- mHasKernelInput = (sig & 1) != 0;
- mHasKernelOutput = (sig & 2) != 0;
-}
-
-ScriptKernelID::~ScriptKernelID() {
-
-}
-
-void ScriptKernelID::serialize(Context *rsc, OStream *stream) const {
-
-}
-
-RsA3DClassID ScriptKernelID::getClassId() const {
- return RS_A3D_CLASS_ID_SCRIPT_KERNEL_ID;
-}
-
-ScriptFieldID::ScriptFieldID(Context *rsc, Script *s, int slot) : ObjectBase(rsc) {
- mScript = s;
- mSlot = slot;
-}
-
-ScriptFieldID::~ScriptFieldID() {
-
-}
-
-void ScriptFieldID::serialize(Context *rsc, OStream *stream) const {
-
-}
-
-RsA3DClassID ScriptFieldID::getClassId() const {
- return RS_A3D_CLASS_ID_SCRIPT_FIELD_ID;
-}
-
-
-namespace android {
-namespace renderscript {
-
-RsScriptKernelID rsi_ScriptKernelIDCreate(Context *rsc, RsScript vs, int slot, int sig) {
- return new ScriptKernelID(rsc, (Script *)vs, slot, sig);
-}
-
-RsScriptFieldID rsi_ScriptFieldIDCreate(Context *rsc, RsScript vs, int slot) {
- return new ScriptFieldID(rsc, (Script *)vs, slot);
-}
-
-void rsi_ScriptBindAllocation(Context * rsc, RsScript vs, RsAllocation va, uint32_t slot) {
- Script *s = static_cast<Script *>(vs);
- Allocation *a = static_cast<Allocation *>(va);
- s->setSlot(slot, a);
-}
-
-void rsi_ScriptSetTimeZone(Context * rsc, RsScript vs, const char * timeZone, size_t length) {
- // We unfortunately need to make a new copy of the string, since it is
- // not NULL-terminated. We then use setenv(), which properly handles
- // freeing/duplicating the actual string for the environment.
- char *tz = (char *) malloc(length + 1);
- if (!tz) {
- ALOGE("Couldn't allocate memory for timezone buffer");
- return;
- }
- strncpy(tz, timeZone, length);
- tz[length] = '\0';
- if (setenv("TZ", tz, 1) == 0) {
- tzset();
- } else {
- ALOGE("Error setting timezone");
- }
- free(tz);
-}
-
-void rsi_ScriptForEach(Context *rsc, RsScript vs, uint32_t slot,
- RsAllocation vain, RsAllocation vaout,
- const void *params, size_t paramLen) {
- Script *s = static_cast<Script *>(vs);
- s->runForEach(rsc, slot,
- static_cast<const Allocation *>(vain), static_cast<Allocation *>(vaout),
- params, paramLen);
-
-}
-
-void rsi_ScriptInvoke(Context *rsc, RsScript vs, uint32_t slot) {
- Script *s = static_cast<Script *>(vs);
- s->Invoke(rsc, slot, NULL, 0);
-}
-
-
-void rsi_ScriptInvokeData(Context *rsc, RsScript vs, uint32_t slot, void *data) {
- Script *s = static_cast<Script *>(vs);
- s->Invoke(rsc, slot, NULL, 0);
-}
-
-void rsi_ScriptInvokeV(Context *rsc, RsScript vs, uint32_t slot, const void *data, size_t len) {
- Script *s = static_cast<Script *>(vs);
- s->Invoke(rsc, slot, data, len);
-}
-
-void rsi_ScriptSetVarI(Context *rsc, RsScript vs, uint32_t slot, int value) {
- Script *s = static_cast<Script *>(vs);
- s->setVar(slot, &value, sizeof(value));
-}
-
-void rsi_ScriptSetVarObj(Context *rsc, RsScript vs, uint32_t slot, RsObjectBase value) {
- Script *s = static_cast<Script *>(vs);
- ObjectBase *o = static_cast<ObjectBase *>(value);
- s->setVarObj(slot, o);
-}
-
-void rsi_ScriptSetVarJ(Context *rsc, RsScript vs, uint32_t slot, long long value) {
- Script *s = static_cast<Script *>(vs);
- s->setVar(slot, &value, sizeof(value));
-}
-
-void rsi_ScriptSetVarF(Context *rsc, RsScript vs, uint32_t slot, float value) {
- Script *s = static_cast<Script *>(vs);
- s->setVar(slot, &value, sizeof(value));
-}
-
-void rsi_ScriptSetVarD(Context *rsc, RsScript vs, uint32_t slot, double value) {
- Script *s = static_cast<Script *>(vs);
- s->setVar(slot, &value, sizeof(value));
-}
-
-void rsi_ScriptSetVarV(Context *rsc, RsScript vs, uint32_t slot, const void *data, size_t len) {
- Script *s = static_cast<Script *>(vs);
- s->setVar(slot, data, len);
-}
-
-void rsi_ScriptSetVarVE(Context *rsc, RsScript vs, uint32_t slot,
- const void *data, size_t len, RsElement ve,
- const size_t *dims, size_t dimLen) {
- Script *s = static_cast<Script *>(vs);
- Element *e = static_cast<Element *>(ve);
- s->setVar(slot, data, len, e, dims, dimLen);
-}
-
-}
-}
-
diff --git a/renderscript/v8/rs_support/rsScript.h b/renderscript/v8/rs_support/rsScript.h
deleted file mode 100644
index 55388a1..0000000
--- a/renderscript/v8/rs_support/rsScript.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2009-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_RS_SCRIPT_H
-#define ANDROID_RS_SCRIPT_H
-
-#include "rsAllocation.h"
-
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-class ScriptKernelID : public ObjectBase {
-public:
- ScriptKernelID(Context *rsc, Script *s, int slot, int sig);
- virtual ~ScriptKernelID();
-
- virtual void serialize(Context *rsc, OStream *stream) const;
- virtual RsA3DClassID getClassId() const;
-
- Script *mScript;
- int mSlot;
- bool mHasKernelInput;
- bool mHasKernelOutput;
-};
-
-class ScriptFieldID : public ObjectBase {
-public:
- ScriptFieldID(Context *rsc, Script *s, int slot);
- virtual ~ScriptFieldID();
-
- virtual void serialize(Context *rsc, OStream *stream) const;
- virtual RsA3DClassID getClassId() const;
-
- Script *mScript;
- int mSlot;
-};
-
-class Script : public ObjectBase {
-public:
-
- struct Hal {
- void * drv;
-
- struct DriverInfo {
- int mVersionMajor;
- int mVersionMinor;
-
- size_t exportedVariableCount;
- size_t exportedFunctionCount;
- size_t exportedPragmaCount;
- char const **exportedPragmaKeyList;
- char const **exportedPragmaValueList;
-
- int (* root)();
- bool isThreadable;
- };
- DriverInfo info;
- };
- Hal mHal;
-
- typedef void (* InvokeFunc_t)(void);
-
- Script(Context *);
- virtual ~Script();
-
- struct Enviroment_t {
- int64_t mStartTimeMillis;
- int64_t mLastDtTime;
- };
- Enviroment_t mEnviroment;
-
- void setSlot(uint32_t slot, Allocation *a);
- void setVar(uint32_t slot, const void *val, size_t len);
- void setVar(uint32_t slot, const void *val, size_t len, Element *e,
- const size_t *dims, size_t dimLen);
- void setVarObj(uint32_t slot, ObjectBase *val);
-
- virtual bool freeChildren();
-
- virtual void runForEach(Context *rsc,
- uint32_t slot,
- const Allocation * ain,
- Allocation * aout,
- const void * usr,
- size_t usrBytes,
- const RsScriptCall *sc = NULL) = 0;
-
- virtual void Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) = 0;
- virtual void setupScript(Context *rsc) = 0;
- virtual uint32_t run(Context *) = 0;
-protected:
- bool mInitialized;
- ObjectBaseRef<Allocation> *mSlots;
- ObjectBaseRef<const Type> *mTypes;
-
-};
-
-
-}
-}
-#endif
-
diff --git a/renderscript/v8/rs_support/rsScriptC.cpp b/renderscript/v8/rs_support/rsScriptC.cpp
deleted file mode 100644
index 8db345b..0000000
--- a/renderscript/v8/rs_support/rsScriptC.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Copyright (C) 2009-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsContext.h"
-#include "rsScriptC.h"
-#include "utils/Timers.h"
-#include "utils/StopWatch.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-#define GET_TLS() Context::ScriptTLSStruct * tls = \
- (Context::ScriptTLSStruct *)pthread_getspecific(Context::gThreadTLSKey); \
- Context * rsc = tls->mContext; \
- ScriptC * sc = (ScriptC *) tls->mScript
-
-ScriptC::ScriptC(Context *rsc) : Script(rsc) {
-}
-
-ScriptC::~ScriptC() {
- if (mInitialized) {
- mRSC->mHal.funcs.script.invokeFreeChildren(mRSC, this);
- mRSC->mHal.funcs.script.destroy(mRSC, this);
- }
-}
-
-void ScriptC::setupScript(Context *rsc) {
- mEnviroment.mStartTimeMillis
- = nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_MONOTONIC));
-
- for (uint32_t ct=0; ct < mHal.info.exportedVariableCount; ct++) {
- if (mSlots[ct].get() && !mTypes[ct].get()) {
- mTypes[ct].set(mSlots[ct]->getType());
- }
-
- if (!mTypes[ct].get())
- continue;
- rsc->mHal.funcs.script.setGlobalBind(rsc, this, ct, mSlots[ct].get());
- }
-}
-
-void ScriptC::setupGLState(Context *rsc) {
-}
-
-uint32_t ScriptC::run(Context *rsc) {
- if (mHal.info.root == NULL) {
- rsc->setError(RS_ERROR_BAD_SCRIPT, "Attempted to run bad script");
- return 0;
- }
-
- setupGLState(rsc);
- setupScript(rsc);
-
- uint32_t ret = 0;
-
- if (rsc->props.mLogScripts) {
- ALOGV("%p ScriptC::run invoking root, ptr %p", rsc, mHal.info.root);
- }
-
- ret = rsc->mHal.funcs.script.invokeRoot(rsc, this);
-
- if (rsc->props.mLogScripts) {
- ALOGV("%p ScriptC::run invoking complete, ret=%i", rsc, ret);
- }
-
- return ret;
-}
-
-
-void ScriptC::runForEach(Context *rsc,
- uint32_t slot,
- const Allocation * ain,
- Allocation * aout,
- const void * usr,
- size_t usrBytes,
- const RsScriptCall *sc) {
-
- Context::PushState ps(rsc);
-
- setupGLState(rsc);
- setupScript(rsc);
- rsc->mHal.funcs.script.invokeForEach(rsc, this, slot, ain, aout, usr, usrBytes, sc);
-}
-
-void ScriptC::Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) {
- if (slot >= mHal.info.exportedFunctionCount) {
- rsc->setError(RS_ERROR_BAD_SCRIPT, "Calling invoke on bad script");
- return;
- }
- setupScript(rsc);
-
- if (rsc->props.mLogScripts) {
- ALOGV("%p ScriptC::Invoke invoking slot %i, ptr %p", rsc, slot, this);
- }
- rsc->mHal.funcs.script.invokeFunction(rsc, this, slot, data, len);
-}
-
-ScriptCState::ScriptCState() {
-}
-
-ScriptCState::~ScriptCState() {
-}
-
-/*
-static void* symbolLookup(void* pContext, char const* name) {
- const ScriptCState::SymbolTable_t *sym;
- ScriptC *s = (ScriptC *)pContext;
- if (!strcmp(name, "__isThreadable")) {
- return (void*) s->mHal.info.isThreadable;
- } else if (!strcmp(name, "__clearThreadable")) {
- s->mHal.info.isThreadable = false;
- return NULL;
- }
- sym = ScriptCState::lookupSymbol(name);
- if (!sym) {
- sym = ScriptCState::lookupSymbolCL(name);
- }
- if (!sym) {
- sym = ScriptCState::lookupSymbolGL(name);
- }
- if (sym) {
- s->mHal.info.isThreadable &= sym->threadable;
- return sym->mPtr;
- }
- ALOGE("ScriptC sym lookup failed for %s", name);
- return NULL;
-}
-*/
-
-#if 0
-extern const char rs_runtime_lib_bc[];
-extern unsigned rs_runtime_lib_bc_size;
-#endif
-
-bool ScriptC::runCompiler(Context *rsc,
- const char *resName,
- const char *cacheDir,
- const uint8_t *bitcode,
- size_t bitcodeLen) {
-
- //ALOGE("runCompiler %p %p %p %p %p %i", rsc, this, resName, cacheDir, bitcode, bitcodeLen);
-
- if (!rsc->mHal.funcs.script.init(rsc, this, resName, cacheDir, bitcode, bitcodeLen, 0)) {
- return false;
- }
-
- mInitialized = true;
-
- rsc->mHal.funcs.script.invokeInit(rsc, this);
-
- for (size_t i=0; i < mHal.info.exportedPragmaCount; ++i) {
- const char * key = mHal.info.exportedPragmaKeyList[i];
- const char * value = mHal.info.exportedPragmaValueList[i];
- //ALOGE("pragma %s %s", keys[i], values[i]);
- if (!strcmp(key, "version")) {
- if (!strcmp(value, "1")) {
- continue;
- }
- ALOGE("Invalid version pragma value: %s\n", value);
- return false;
- }
- }
-
- mSlots = new ObjectBaseRef<Allocation>[mHal.info.exportedVariableCount];
- mTypes = new ObjectBaseRef<const Type>[mHal.info.exportedVariableCount];
-
- return true;
-}
-
-namespace android {
-namespace renderscript {
-
-RsScript rsi_ScriptCCreate(Context *rsc,
- const char *resName, size_t resName_length,
- const char *cacheDir, size_t cacheDir_length,
- const char *text, size_t text_length)
-{
- ScriptC *s = new ScriptC(rsc);
-
- if (!s->runCompiler(rsc, resName, cacheDir, (uint8_t *)text, text_length)) {
- // Error during compile, destroy s and return null.
- ObjectBase::checkDelete(s);
- return NULL;
- }
-
- s->incUserRef();
- return s;
-}
-
-}
-}
diff --git a/renderscript/v8/rs_support/rsScriptC.h b/renderscript/v8/rs_support/rsScriptC.h
deleted file mode 100644
index eab93c7..0000000
--- a/renderscript/v8/rs_support/rsScriptC.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2009-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_RS_SCRIPT_C_H
-#define ANDROID_RS_SCRIPT_C_H
-
-#include "rsScript.h"
-
-#include "rsEnv.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-
-class ScriptC : public Script {
-public:
- typedef int (*RunScript_t)();
- typedef void (*VoidFunc_t)();
-
- ScriptC(Context *);
- virtual ~ScriptC();
-
- virtual void Invoke(Context *rsc, uint32_t slot, const void *data, size_t len);
-
- virtual uint32_t run(Context *);
-
- virtual void runForEach(Context *rsc,
- uint32_t slot,
- const Allocation * ain,
- Allocation * aout,
- const void * usr,
- size_t usrBytes,
- const RsScriptCall *sc = NULL);
-
- virtual void serialize(Context *rsc, OStream *stream) const { }
- virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SCRIPT_C; }
- static Type *createFromStream(Context *rsc, IStream *stream) { return NULL; }
-
- bool runCompiler(Context *rsc, const char *resName, const char *cacheDir,
- const uint8_t *bitcode, size_t bitcodeLen);
-
-//protected:
- void setupScript(Context *);
- void setupGLState(Context *);
- Script * setTLS(Script *);
-};
-
-class ScriptCState {
-public:
- ScriptCState();
- ~ScriptCState();
-
- char * mScriptText;
- size_t mScriptLen;
-
- struct SymbolTable_t {
- const char * mName;
- void * mPtr;
- bool threadable;
- };
- static const SymbolTable_t * lookupSymbol(const char *);
- static const SymbolTable_t * lookupSymbolCL(const char *);
- static const SymbolTable_t * lookupSymbolGL(const char *);
-};
-
-
-}
-}
-#endif
diff --git a/renderscript/v8/rs_support/rsScriptC_Lib.cpp b/renderscript/v8/rs_support/rsScriptC_Lib.cpp
deleted file mode 100644
index ac3dd12..0000000
--- a/renderscript/v8/rs_support/rsScriptC_Lib.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright (C) 2009-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsContext.h"
-#include "rsScriptC.h"
-#include "rsMatrix4x4.h"
-#include "rsMatrix3x3.h"
-#include "rsMatrix2x2.h"
-#include "rsgApiStructs.h"
-
-#include "utils/Timers.h"
-
-#include <time.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-
-namespace android {
-namespace renderscript {
-
-
-//////////////////////////////////////////////////////////////////////////////
-// Math routines
-//////////////////////////////////////////////////////////////////////////////
-
-#if 0
-static float SC_sinf_fast(float x) {
- const float A = 1.0f / (2.0f * M_PI);
- const float B = -16.0f;
- const float C = 8.0f;
-
- // scale angle for easy argument reduction
- x *= A;
-
- if (fabsf(x) >= 0.5f) {
- // argument reduction
- x = x - ceilf(x + 0.5f) + 1.0f;
- }
-
- const float y = B * x * fabsf(x) + C * x;
- return 0.2215f * (y * fabsf(y) - y) + y;
-}
-
-static float SC_cosf_fast(float x) {
- x += float(M_PI / 2);
-
- const float A = 1.0f / (2.0f * M_PI);
- const float B = -16.0f;
- const float C = 8.0f;
-
- // scale angle for easy argument reduction
- x *= A;
-
- if (fabsf(x) >= 0.5f) {
- // argument reduction
- x = x - ceilf(x + 0.5f) + 1.0f;
- }
-
- const float y = B * x * fabsf(x) + C * x;
- return 0.2215f * (y * fabsf(y) - y) + y;
-}
-#endif
-
-//////////////////////////////////////////////////////////////////////////////
-// Time routines
-//////////////////////////////////////////////////////////////////////////////
-
-time_t rsrTime(Context *rsc, Script *sc, time_t *timer) {
- return time(timer);
-}
-
-tm* rsrLocalTime(Context *rsc, Script *sc, tm *local, time_t *timer) {
- if (!local) {
- return NULL;
- }
-
- // The native localtime function is not thread-safe, so we
- // have to apply locking for proper behavior in RenderScript.
- pthread_mutex_lock(&rsc->gLibMutex);
- tm *tmp = localtime(timer);
- memcpy(local, tmp, sizeof(*tmp));
- pthread_mutex_unlock(&rsc->gLibMutex);
- return local;
-}
-
-int64_t rsrUptimeMillis(Context *rsc, Script *sc) {
- return nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_MONOTONIC));
-}
-
-int64_t rsrUptimeNanos(Context *rsc, Script *sc) {
- return systemTime(SYSTEM_TIME_MONOTONIC);
-}
-
-float rsrGetDt(Context *rsc, Script *sc) {
- int64_t l = sc->mEnviroment.mLastDtTime;
- sc->mEnviroment.mLastDtTime = systemTime(SYSTEM_TIME_MONOTONIC);
- return ((float)(sc->mEnviroment.mLastDtTime - l)) / 1.0e9;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-
-void rsrSetObject(const Context *rsc, const Script *sc, ObjectBase **dst, ObjectBase * src) {
- //ALOGE("rsiSetObject %p,%p %p", vdst, *vdst, vsrc);
- if (src) {
- CHECK_OBJ(src);
- src->incSysRef();
- }
- if (dst[0]) {
- CHECK_OBJ(dst[0]);
- dst[0]->decSysRef();
- }
- *dst = src;
-}
-
-void rsrClearObject(const Context *rsc, const Script *sc, ObjectBase **dst) {
- //ALOGE("rsiClearObject %p,%p", vdst, *vdst);
- if (dst[0]) {
- CHECK_OBJ(dst[0]);
- dst[0]->decSysRef();
- }
- *dst = NULL;
-}
-
-bool rsrIsObject(const Context *rsc, const Script *sc, const ObjectBase *src) {
- return src != NULL;
-}
-
-
-uint32_t rsrToClient(Context *rsc, Script *sc, int cmdID, void *data, int len) {
- //ALOGE("SC_toClient %i %i %i", cmdID, len);
- return rsc->sendMessageToClient(data, RS_MESSAGE_TO_CLIENT_USER, cmdID, len, false);
-}
-
-uint32_t rsrToClientBlocking(Context *rsc, Script *sc, int cmdID, void *data, int len) {
- //ALOGE("SC_toClientBlocking %i %i", cmdID, len);
- return rsc->sendMessageToClient(data, RS_MESSAGE_TO_CLIENT_USER, cmdID, len, true);
-}
-
-
-void rsrForEach(Context *rsc, Script *sc,
- Script *target,
- Allocation *in, Allocation *out,
- const void *usr, uint32_t usrBytes,
- const RsScriptCall *call) {
- target->runForEach(rsc, /* root slot */ 0, in, out, usr, usrBytes, call);
-}
-
-void rsrAllocationSyncAll(Context *rsc, Script *sc, Allocation *a, RsAllocationUsageType usage) {
- a->syncAll(rsc, usage);
-}
-
-void rsrAllocationCopy1DRange(Context *rsc, Allocation *dstAlloc,
- uint32_t dstOff,
- uint32_t dstMip,
- uint32_t count,
- Allocation *srcAlloc,
- uint32_t srcOff, uint32_t srcMip) {
- rsi_AllocationCopy2DRange(rsc, dstAlloc, dstOff, 0,
- dstMip, 0, count, 1,
- srcAlloc, srcOff, 0, srcMip, 0);
-}
-
-void rsrAllocationCopy2DRange(Context *rsc, Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff,
- uint32_t dstMip, uint32_t dstFace,
- uint32_t width, uint32_t height,
- Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff,
- uint32_t srcMip, uint32_t srcFace) {
- rsi_AllocationCopy2DRange(rsc, dstAlloc, dstXoff, dstYoff,
- dstMip, dstFace, width, height,
- srcAlloc, srcXoff, srcYoff, srcMip, srcFace);
-}
-
-
-}
-}
-
diff --git a/renderscript/v8/rs_support/rsScriptGroup.cpp b/renderscript/v8/rs_support/rsScriptGroup.cpp
deleted file mode 100644
index 9230485..0000000
--- a/renderscript/v8/rs_support/rsScriptGroup.cpp
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsContext.h"
-#include <time.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-ScriptGroup::ScriptGroup(Context *rsc) : ObjectBase(rsc) {
-}
-
-ScriptGroup::~ScriptGroup() {
- if (mRSC->mHal.funcs.scriptgroup.destroy) {
- mRSC->mHal.funcs.scriptgroup.destroy(mRSC, this);
- }
-
- for (size_t ct=0; ct < mLinks.size(); ct++) {
- delete mLinks[ct];
- }
-}
-
-ScriptGroup::IO::IO(const ScriptKernelID *kid) {
- mKernel = kid;
-}
-
-ScriptGroup::Node::Node(Script *s) {
- mScript = s;
- mSeen = false;
- mOrder = 0;
-}
-
-ScriptGroup::Node * ScriptGroup::findNode(Script *s) const {
- //ALOGE("find %p %i", s, (int)mNodes.size());
- for (size_t ct=0; ct < mNodes.size(); ct++) {
- Node *n = mNodes[ct];
- for (size_t ct2=0; ct2 < n->mKernels.size(); ct2++) {
- if (n->mKernels[ct2]->mScript == s) {
- return n;
- }
- }
- }
- return NULL;
-}
-
-bool ScriptGroup::calcOrderRecurse(Node *n, int depth) {
- n->mSeen = true;
- if (n->mOrder < depth) {
- n->mOrder = depth;
- }
- bool ret = true;
- for (size_t ct=0; ct < n->mOutputs.size(); ct++) {
- const Link *l = n->mOutputs[ct];
- Node *nt = NULL;
- if (l->mDstField.get()) {
- nt = findNode(l->mDstField->mScript);
- } else {
- nt = findNode(l->mDstKernel->mScript);
- }
- if (nt->mSeen) {
- return false;
- }
- ret &= calcOrderRecurse(nt, n->mOrder + 1);
- }
- return ret;
-}
-
-static int CompareNodeForSort(ScriptGroup::Node *const* lhs,
- ScriptGroup::Node *const* rhs) {
- if (lhs[0]->mOrder > rhs[0]->mOrder) {
- return 1;
- }
- return 0;
-}
-
-
-bool ScriptGroup::calcOrder() {
- // Make nodes
- for (size_t ct=0; ct < mKernels.size(); ct++) {
- const ScriptKernelID *k = mKernels[ct].get();
- //ALOGE(" kernel %i, %p s=%p", (int)ct, k, mKernels[ct]->mScript);
- Node *n = findNode(k->mScript);
- //ALOGE(" n = %p", n);
- if (n == NULL) {
- n = new Node(k->mScript);
- mNodes.add(n);
- }
- n->mKernels.add(k);
- }
-
- // add links
- //ALOGE("link count %i", (int)mLinks.size());
- for (size_t ct=0; ct < mLinks.size(); ct++) {
- Link *l = mLinks[ct];
- //ALOGE("link %i %p", (int)ct, l);
- Node *n = findNode(l->mSource->mScript);
- //ALOGE("link n %p", n);
- n->mOutputs.add(l);
-
- if (l->mDstKernel.get()) {
- //ALOGE("l->mDstKernel.get() %p", l->mDstKernel.get());
- n = findNode(l->mDstKernel->mScript);
- //ALOGE(" n1 %p", n);
- n->mInputs.add(l);
- } else {
- n = findNode(l->mDstField->mScript);
- //ALOGE(" n2 %p", n);
- n->mInputs.add(l);
- }
- }
-
- //ALOGE("node count %i", (int)mNodes.size());
- // Order nodes
- bool ret = true;
- for (size_t ct=0; ct < mNodes.size(); ct++) {
- Node *n = mNodes[ct];
- if (n->mInputs.size() == 0) {
- for (size_t ct2=0; ct2 < mNodes.size(); ct2++) {
- mNodes[ct2]->mSeen = false;
- }
- ret &= calcOrderRecurse(n, 0);
- }
- }
-
- for (size_t ct=0; ct < mKernels.size(); ct++) {
- const ScriptKernelID *k = mKernels[ct].get();
- const Node *n = findNode(k->mScript);
-
- if (k->mHasKernelOutput) {
- bool found = false;
- for (size_t ct2=0; ct2 < n->mOutputs.size(); ct2++) {
- if (n->mOutputs[ct2]->mSource.get() == k) {
- found = true;
- break;
- }
- }
- if (!found) {
- //ALOGE("add io out %p", k);
- mOutputs.add(new IO(k));
- }
- }
-
- if (k->mHasKernelInput) {
- bool found = false;
- for (size_t ct2=0; ct2 < n->mInputs.size(); ct2++) {
- if (n->mInputs[ct2]->mDstKernel.get() == k) {
- found = true;
- break;
- }
- }
- if (!found) {
- //ALOGE("add io in %p", k);
- mInputs.add(new IO(k));
- }
- }
- }
-
- // sort
- mNodes.sort(&CompareNodeForSort);
-
- return ret;
-}
-
-ScriptGroup * ScriptGroup::create(Context *rsc,
- ScriptKernelID ** kernels, size_t kernelsSize,
- ScriptKernelID ** src, size_t srcSize,
- ScriptKernelID ** dstK, size_t dstKSize,
- ScriptFieldID ** dstF, size_t dstFSize,
- const Type ** type, size_t typeSize) {
-
- size_t kernelCount = kernelsSize / sizeof(ScriptKernelID *);
- size_t linkCount = typeSize / sizeof(Type *);
-
- //ALOGE("ScriptGroup::create kernels=%i links=%i", (int)kernelCount, (int)linkCount);
-
-
- // Start by counting unique kernel sources
-
- ScriptGroup *sg = new ScriptGroup(rsc);
-
- sg->mKernels.reserve(kernelCount);
- for (size_t ct=0; ct < kernelCount; ct++) {
- sg->mKernels.add(kernels[ct]);
- }
-
- sg->mLinks.reserve(linkCount);
- for (size_t ct=0; ct < linkCount; ct++) {
- Link *l = new Link();
- l->mType = type[ct];
- l->mSource = src[ct];
- l->mDstField = dstF[ct];
- l->mDstKernel = dstK[ct];
- sg->mLinks.add(l);
- }
-
- sg->calcOrder();
-
- // allocate links
- for (size_t ct=0; ct < sg->mNodes.size(); ct++) {
- const Node *n = sg->mNodes[ct];
- for (size_t ct2=0; ct2 < n->mOutputs.size(); ct2++) {
- Link *l = n->mOutputs[ct2];
- if (l->mAlloc.get()) {
- continue;
- }
- const ScriptKernelID *k = l->mSource.get();
-
- Allocation * alloc = Allocation::createAllocation(rsc,
- l->mType.get(), RS_ALLOCATION_USAGE_SCRIPT);
- l->mAlloc = alloc;
-
- for (size_t ct3=ct2+1; ct3 < n->mOutputs.size(); ct3++) {
- if (n->mOutputs[ct3]->mSource.get() == l->mSource.get()) {
- n->mOutputs[ct3]->mAlloc = alloc;
- }
- }
- }
- }
-
- if (rsc->mHal.funcs.scriptgroup.init) {
- rsc->mHal.funcs.scriptgroup.init(rsc, sg);
- }
- return sg;
-}
-
-void ScriptGroup::setInput(Context *rsc, ScriptKernelID *kid, Allocation *a) {
- for (size_t ct=0; ct < mInputs.size(); ct++) {
- if (mInputs[ct]->mKernel == kid) {
- mInputs[ct]->mAlloc = a;
-
- if (rsc->mHal.funcs.scriptgroup.setInput) {
- rsc->mHal.funcs.scriptgroup.setInput(rsc, this, kid, a);
- }
- return;
- }
- }
- rsAssert(!"ScriptGroup:setInput kid not found");
-}
-
-void ScriptGroup::setOutput(Context *rsc, ScriptKernelID *kid, Allocation *a) {
- for (size_t ct=0; ct < mOutputs.size(); ct++) {
- if (mOutputs[ct]->mKernel == kid) {
- mOutputs[ct]->mAlloc = a;
-
- if (rsc->mHal.funcs.scriptgroup.setOutput) {
- rsc->mHal.funcs.scriptgroup.setOutput(rsc, this, kid, a);
- }
- return;
- }
- }
- rsAssert(!"ScriptGroup:setOutput kid not found");
-}
-
-void ScriptGroup::execute(Context *rsc) {
- //ALOGE("ScriptGroup::execute");
- if (rsc->mHal.funcs.scriptgroup.execute) {
- rsc->mHal.funcs.scriptgroup.execute(rsc, this);
- return;
- }
-
- for (size_t ct=0; ct < mNodes.size(); ct++) {
- Node *n = mNodes[ct];
- //ALOGE("node %i, order %i, in %i out %i", (int)ct, n->mOrder, (int)n->mInputs.size(), (int)n->mOutputs.size());
-
- for (size_t ct2=0; ct2 < n->mKernels.size(); ct2++) {
- const ScriptKernelID *k = n->mKernels[ct2];
- Allocation *ain = NULL;
- Allocation *aout = NULL;
-
- for (size_t ct3=0; ct3 < n->mInputs.size(); ct3++) {
- if (n->mInputs[ct3]->mDstKernel.get() == k) {
- ain = n->mInputs[ct3]->mAlloc.get();
- //ALOGE(" link in %p", ain);
- }
- }
- for (size_t ct3=0; ct3 < mInputs.size(); ct3++) {
- if (mInputs[ct3]->mKernel == k) {
- ain = mInputs[ct3]->mAlloc.get();
- //ALOGE(" io in %p", ain);
- }
- }
-
- for (size_t ct3=0; ct3 < n->mOutputs.size(); ct3++) {
- if (n->mOutputs[ct3]->mSource.get() == k) {
- aout = n->mOutputs[ct3]->mAlloc.get();
- //ALOGE(" link out %p", aout);
- }
- }
- for (size_t ct3=0; ct3 < mOutputs.size(); ct3++) {
- if (mOutputs[ct3]->mKernel == k) {
- aout = mOutputs[ct3]->mAlloc.get();
- //ALOGE(" io out %p", aout);
- }
- }
-
- n->mScript->runForEach(rsc, k->mSlot, ain, aout, NULL, 0);
- }
-
- }
-
-}
-
-void ScriptGroup::serialize(Context *rsc, OStream *stream) const {
-}
-
-RsA3DClassID ScriptGroup::getClassId() const {
- return RS_A3D_CLASS_ID_SCRIPT_GROUP;
-}
-
-ScriptGroup::Link::Link() {
-}
-
-ScriptGroup::Link::~Link() {
-}
-
-namespace android {
-namespace renderscript {
-
-
-RsScriptGroup rsi_ScriptGroupCreate(Context *rsc,
- RsScriptKernelID * kernels, size_t kernelsSize,
- RsScriptKernelID * src, size_t srcSize,
- RsScriptKernelID * dstK, size_t dstKSize,
- RsScriptFieldID * dstF, size_t dstFSize,
- const RsType * type, size_t typeSize) {
-
-
- return ScriptGroup::create(rsc,
- (ScriptKernelID **) kernels, kernelsSize,
- (ScriptKernelID **) src, srcSize,
- (ScriptKernelID **) dstK, dstKSize,
- (ScriptFieldID **) dstF, dstFSize,
- (const Type **) type, typeSize);
-}
-
-
-void rsi_ScriptGroupSetInput(Context *rsc, RsScriptGroup sg, RsScriptKernelID kid,
- RsAllocation alloc) {
- //ALOGE("rsi_ScriptGroupSetInput");
- ScriptGroup *s = (ScriptGroup *)sg;
- s->setInput(rsc, (ScriptKernelID *)kid, (Allocation *)alloc);
-}
-
-void rsi_ScriptGroupSetOutput(Context *rsc, RsScriptGroup sg, RsScriptKernelID kid,
- RsAllocation alloc) {
- //ALOGE("rsi_ScriptGroupSetOutput");
- ScriptGroup *s = (ScriptGroup *)sg;
- s->setOutput(rsc, (ScriptKernelID *)kid, (Allocation *)alloc);
-}
-
-void rsi_ScriptGroupExecute(Context *rsc, RsScriptGroup sg) {
- //ALOGE("rsi_ScriptGroupExecute");
- ScriptGroup *s = (ScriptGroup *)sg;
- s->execute(rsc);
-}
-
-}
-}
-
diff --git a/renderscript/v8/rs_support/rsScriptGroup.h b/renderscript/v8/rs_support/rsScriptGroup.h
deleted file mode 100644
index d51b1db..0000000
--- a/renderscript/v8/rs_support/rsScriptGroup.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_RS_SCRIPT_GROUP_H
-#define ANDROID_RS_SCRIPT_GROUP_H
-
-#include "rsAllocation.h"
-#include "rsScript.h"
-
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-class ProgramVertex;
-class ProgramFragment;
-class ProgramRaster;
-class ProgramStore;
-
-class ScriptGroup : public ObjectBase {
-public:
- Vector<ObjectBaseRef<ScriptKernelID> > mKernels;
-
- class Link {
- public:
- ObjectBaseRef<const ScriptKernelID> mSource;
- ObjectBaseRef<const ScriptKernelID> mDstKernel;
- ObjectBaseRef<const ScriptFieldID> mDstField;
- ObjectBaseRef<const Type> mType;
- ObjectBaseRef<Allocation> mAlloc;
- Link();
- ~Link();
- };
-
- class Node {
- public:
- Node(Script *);
-
- Vector<const ScriptKernelID *> mKernels;
- Vector<Link *> mOutputs;
- Vector<Link *> mInputs;
- bool mSeen;
- int mOrder;
- Script *mScript;
- };
-
- class IO {
- public:
- IO(const ScriptKernelID *);
-
- const ScriptKernelID *mKernel;
- ObjectBaseRef<Allocation> mAlloc;
- };
-
- Vector<Link *> mLinks;
- Vector<Node *> mNodes;
- Vector<IO *> mInputs;
- Vector<IO *> mOutputs;
-
- struct Hal {
- void * drv;
-
- struct DriverInfo {
- };
- DriverInfo info;
- };
- Hal mHal;
-
- static ScriptGroup * create(Context *rsc,
- ScriptKernelID ** kernels, size_t kernelsSize,
- ScriptKernelID ** src, size_t srcSize,
- ScriptKernelID ** dstK, size_t dstKSize,
- ScriptFieldID ** dstF, size_t dstFSize,
- const Type ** type, size_t typeSize);
-
- virtual void serialize(Context *rsc, OStream *stream) const;
- virtual RsA3DClassID getClassId() const;
-
- void execute(Context *rsc);
- void setInput(Context *rsc, ScriptKernelID *kid, Allocation *a);
- void setOutput(Context *rsc, ScriptKernelID *kid, Allocation *a);
-
-
-protected:
- virtual ~ScriptGroup();
- bool mInitialized;
-
-
-private:
- bool calcOrderRecurse(Node *n, int depth);
- bool calcOrder();
- Node * findNode(Script *s) const;
-
- ScriptGroup(Context *);
-};
-
-
-}
-}
-#endif
-
diff --git a/renderscript/v8/rs_support/rsScriptIntrinsic.cpp b/renderscript/v8/rs_support/rsScriptIntrinsic.cpp
deleted file mode 100644
index 51f0a5d..0000000
--- a/renderscript/v8/rs_support/rsScriptIntrinsic.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsContext.h"
-#include "rsScriptIntrinsic.h"
-#include <time.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-ScriptIntrinsic::ScriptIntrinsic(Context *rsc) : Script(rsc) {
-}
-
-ScriptIntrinsic::~ScriptIntrinsic() {
-}
-
-bool ScriptIntrinsic::init(Context *rsc, RsScriptIntrinsicID iid, Element *e) {
- mIntrinsicID = iid;
- mElement.set(e);
- mSlots = new ObjectBaseRef<Allocation>[2];
- mTypes = new ObjectBaseRef<const Type>[2];
-
- rsc->mHal.funcs.script.initIntrinsic(rsc, this, iid, e);
-
-
- return true;
-}
-
-bool ScriptIntrinsic::freeChildren() {
- return false;
-}
-
-void ScriptIntrinsic::setupScript(Context *rsc) {
-}
-
-uint32_t ScriptIntrinsic::run(Context *rsc) {
- rsAssert(!"ScriptIntrinsic::run - should not happen");
- return 0;
-}
-
-
-void ScriptIntrinsic::runForEach(Context *rsc,
- uint32_t slot,
- const Allocation * ain,
- Allocation * aout,
- const void * usr,
- size_t usrBytes,
- const RsScriptCall *sc) {
-
- rsc->mHal.funcs.script.invokeForEach(rsc, this, slot, ain, aout, usr, usrBytes, sc);
-}
-
-void ScriptIntrinsic::Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) {
-}
-
-void ScriptIntrinsic::serialize(Context *rsc, OStream *stream) const {
-}
-
-RsA3DClassID ScriptIntrinsic::getClassId() const {
- return (RsA3DClassID)0;
-}
-
-
-
-namespace android {
-namespace renderscript {
-
-
-RsScript rsi_ScriptIntrinsicCreate(Context *rsc, uint32_t id, RsElement ve) {
- ScriptIntrinsic *si = new ScriptIntrinsic(rsc);
- ALOGE("rsi_ScriptIntrinsicCreate %i", id);
- if (!si->init(rsc, (RsScriptIntrinsicID)id, (Element *)ve)) {
- delete si;
- return NULL;
- }
- return si;
-}
-
-}
-}
-
-
diff --git a/renderscript/v8/rs_support/rsScriptIntrinsic.h b/renderscript/v8/rs_support/rsScriptIntrinsic.h
deleted file mode 100644
index 310cbec..0000000
--- a/renderscript/v8/rs_support/rsScriptIntrinsic.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_RS_SCRIPT_INTRINSIC_H
-#define ANDROID_RS_SCRIPT_INTRINSIC_H
-
-#include "rsScript.h"
-
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-
-class ScriptIntrinsic : public Script {
-public:
-
- ObjectBaseRef<const Element> mElement;
-
- ScriptIntrinsic(Context *);
- virtual ~ScriptIntrinsic();
-
- bool init(Context *rsc, RsScriptIntrinsicID iid, Element *e);
-
-
- virtual void serialize(Context *rsc, OStream *stream) const;
- virtual RsA3DClassID getClassId() const;
- virtual bool freeChildren();
-
- virtual void runForEach(Context *rsc,
- uint32_t slot,
- const Allocation * ain,
- Allocation * aout,
- const void * usr,
- size_t usrBytes,
- const RsScriptCall *sc = NULL);
-
- virtual void Invoke(Context *rsc, uint32_t slot, const void *data, size_t len);
- virtual void setupScript(Context *rsc);
- virtual uint32_t run(Context *);
-protected:
- uint32_t mIntrinsicID;
- float mParams[9];
-
-};
-
-
-}
-}
-#endif
-
-
diff --git a/renderscript/v8/rs_support/rsSignal.cpp b/renderscript/v8/rs_support/rsSignal.cpp
deleted file mode 100644
index 3f6a13c..0000000
--- a/renderscript/v8/rs_support/rsSignal.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsSignal.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-
-Signal::Signal() {
- mSet = true;
-}
-
-Signal::~Signal() {
- pthread_mutex_destroy(&mMutex);
- pthread_cond_destroy(&mCondition);
-}
-
-bool Signal::init() {
- int status = pthread_mutex_init(&mMutex, NULL);
- if (status) {
- ALOGE("LocklessFifo mutex init failure");
- return false;
- }
-
- status = pthread_cond_init(&mCondition, NULL);
- if (status) {
- ALOGE("LocklessFifo condition init failure");
- pthread_mutex_destroy(&mMutex);
- return false;
- }
-
- return true;
-}
-
-void Signal::set() {
- int status;
-
- status = pthread_mutex_lock(&mMutex);
- if (status) {
- ALOGE("LocklessCommandFifo: error %i locking for set condition.", status);
- return;
- }
-
- mSet = true;
-
- status = pthread_cond_signal(&mCondition);
- if (status) {
- ALOGE("LocklessCommandFifo: error %i on set condition.", status);
- }
-
- status = pthread_mutex_unlock(&mMutex);
- if (status) {
- ALOGE("LocklessCommandFifo: error %i unlocking for set condition.", status);
- }
-}
-
-bool Signal::wait(uint64_t timeout) {
- int status;
- bool ret = false;
-
- status = pthread_mutex_lock(&mMutex);
- if (status) {
- ALOGE("LocklessCommandFifo: error %i locking for condition.", status);
- return false;
- }
-
- if (!mSet) {
- if (!timeout) {
- status = pthread_cond_wait(&mCondition, &mMutex);
- } else {
-#if defined(HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE)
- status = pthread_cond_timeout_np(&mCondition, &mMutex, timeout / 1000000);
-#else
- // This is safe it will just make things less reponsive
- status = pthread_cond_wait(&mCondition, &mMutex);
-#endif
- }
- }
-
- if (!status) {
- mSet = false;
- ret = true;
- } else {
- if (status != ETIMEDOUT) {
- ALOGE("LocklessCommandFifo: error %i waiting for condition.", status);
- }
- }
-
- status = pthread_mutex_unlock(&mMutex);
- if (status) {
- ALOGE("LocklessCommandFifo: error %i unlocking for condition.", status);
- }
-
- return ret;
-}
-
diff --git a/renderscript/v8/rs_support/rsSignal.h b/renderscript/v8/rs_support/rsSignal.h
deleted file mode 100644
index fc31883..0000000
--- a/renderscript/v8/rs_support/rsSignal.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_RS_SIGNAL_H
-#define ANDROID_RS_SIGNAL_H
-
-
-#include "rsUtils.h"
-
-namespace android {
-namespace renderscript {
-
-class Signal {
-public:
- Signal();
- ~Signal();
-
- bool init();
-
- void set();
-
- // returns true if the signal occured
- // false for timeout
- bool wait(uint64_t timeout = 0);
-
-protected:
- bool mSet;
- pthread_mutex_t mMutex;
- pthread_cond_t mCondition;
-};
-
-}
-}
-
-#endif
-
diff --git a/renderscript/v8/rs_support/rsStream.cpp b/renderscript/v8/rs_support/rsStream.cpp
deleted file mode 100644
index b9df0cc..0000000
--- a/renderscript/v8/rs_support/rsStream.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsContext.h"
-#include "rsStream.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-IStream::IStream(const uint8_t *buf, bool use64) {
- mData = buf;
- mPos = 0;
- mUse64 = use64;
-}
-
-void IStream::loadByteArray(void *dest, size_t numBytes) {
- memcpy(dest, mData + mPos, numBytes);
- mPos += numBytes;
-}
-
-uint64_t IStream::loadOffset() {
- uint64_t tmp;
- if (mUse64) {
- mPos = (mPos + 7) & (~7);
- tmp = reinterpret_cast<const uint64_t *>(&mData[mPos])[0];
- mPos += sizeof(uint64_t);
- return tmp;
- }
- return loadU32();
-}
-
-void IStream::loadString(String8 *s) {
- uint32_t len = loadU32();
- s->setTo((const char *)&mData[mPos], len);
- mPos += len;
-}
-
-// Output stream implementation
-OStream::OStream(uint64_t len, bool use64) {
- mData = (uint8_t*)malloc(len);
- mLength = len;
- mPos = 0;
- mUse64 = use64;
-}
-
-OStream::~OStream() {
- free(mData);
-}
-
-void OStream::addByteArray(const void *src, size_t numBytes) {
- // We need to potentially grow more than once if the number of byes we write is substantial
- while (mPos + numBytes >= mLength) {
- growSize();
- }
- memcpy(mData + mPos, src, numBytes);
- mPos += numBytes;
-}
-
-void OStream::addOffset(uint64_t v) {
- if (mUse64) {
- mPos = (mPos + 7) & (~7);
- if (mPos + sizeof(v) >= mLength) {
- growSize();
- }
- mData[mPos++] = (uint8_t)(v & 0xff);
- mData[mPos++] = (uint8_t)((v >> 8) & 0xff);
- mData[mPos++] = (uint8_t)((v >> 16) & 0xff);
- mData[mPos++] = (uint8_t)((v >> 24) & 0xff);
- mData[mPos++] = (uint8_t)((v >> 32) & 0xff);
- mData[mPos++] = (uint8_t)((v >> 40) & 0xff);
- mData[mPos++] = (uint8_t)((v >> 48) & 0xff);
- mData[mPos++] = (uint8_t)((v >> 56) & 0xff);
- } else {
- addU32(v);
- }
-}
-
-void OStream::addString(String8 *s) {
- uint32_t len = s->size();
- addU32(len);
- if (mPos + len*sizeof(char) >= mLength) {
- growSize();
- }
- char *stringData = reinterpret_cast<char *>(&mData[mPos]);
- for (uint32_t i = 0; i < len; i ++) {
- stringData[i] = s->string()[i];
- }
- mPos += len*sizeof(char);
-}
-
-void OStream::growSize() {
- uint8_t *newData = (uint8_t*)malloc(mLength*2);
- memcpy(newData, mData, mLength*sizeof(uint8_t));
- mLength = mLength * 2;
- free(mData);
- mData = newData;
-}
-
-
diff --git a/renderscript/v8/rs_support/rsStream.h b/renderscript/v8/rs_support/rsStream.h
deleted file mode 100644
index 62bcf94..0000000
--- a/renderscript/v8/rs_support/rsStream.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_RS_STREAM_H
-#define ANDROID_RS_STREAM_H
-
-#include <utils/String8.h>
-#include <stdio.h>
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-class IStream {
-public:
- IStream(const uint8_t *, bool use64);
-
- float loadF() {
- mPos = (mPos + 3) & (~3);
- float tmp = reinterpret_cast<const float *>(&mData[mPos])[0];
- mPos += sizeof(float);
- return tmp;
- }
- int32_t loadI32() {
- mPos = (mPos + 3) & (~3);
- int32_t tmp = reinterpret_cast<const int32_t *>(&mData[mPos])[0];
- mPos += sizeof(int32_t);
- return tmp;
- }
- uint32_t loadU32() {
- mPos = (mPos + 3) & (~3);
- uint32_t tmp = reinterpret_cast<const uint32_t *>(&mData[mPos])[0];
- mPos += sizeof(uint32_t);
- return tmp;
- }
- uint16_t loadU16() {
- mPos = (mPos + 1) & (~1);
- uint16_t tmp = reinterpret_cast<const uint16_t *>(&mData[mPos])[0];
- mPos += sizeof(uint16_t);
- return tmp;
- }
- inline uint8_t loadU8() {
- uint8_t tmp = reinterpret_cast<const uint8_t *>(&mData[mPos])[0];
- mPos += sizeof(uint8_t);
- return tmp;
- }
- void loadByteArray(void *dest, size_t numBytes);
- uint64_t loadOffset();
- void loadString(String8 *s);
- uint64_t getPos() const {
- return mPos;
- }
- void reset(uint64_t pos) {
- mPos = pos;
- }
- void reset() {
- mPos = 0;
- }
-
- const uint8_t * getPtr() const {
- return mData;
- }
-protected:
- const uint8_t * mData;
- uint64_t mPos;
- bool mUse64;
-};
-
-class OStream {
-public:
- OStream(uint64_t length, bool use64);
- ~OStream();
-
- void align(uint32_t bytes) {
- mPos = (mPos + (bytes - 1)) & (~(bytes - 1));
- if (mPos >= mLength) {
- growSize();
- }
- }
-
- void addF(float v) {
- uint32_t uintV = *reinterpret_cast<uint32_t*> (&v);
- addU32(uintV);
- }
- void addI32(int32_t v) {
- mPos = (mPos + 3) & (~3);
- if (mPos + sizeof(v) >= mLength) {
- growSize();
- }
- mData[mPos++] = (uint8_t)(v & 0xff);
- mData[mPos++] = (uint8_t)((v >> 8) & 0xff);
- mData[mPos++] = (uint8_t)((v >> 16) & 0xff);
- mData[mPos++] = (uint8_t)((v >> 24) & 0xff);
- }
- void addU32(uint32_t v) {
- mPos = (mPos + 3) & (~3);
- if (mPos + sizeof(v) >= mLength) {
- growSize();
- }
- mData[mPos++] = (uint8_t)(v & 0xff);
- mData[mPos++] = (uint8_t)((v >> 8) & 0xff);
- mData[mPos++] = (uint8_t)((v >> 16) & 0xff);
- mData[mPos++] = (uint8_t)((v >> 24) & 0xff);
- }
- void addU16(uint16_t v) {
- mPos = (mPos + 1) & (~1);
- if (mPos + sizeof(v) >= mLength) {
- growSize();
- }
- mData[mPos++] = (uint8_t)(v & 0xff);
- mData[mPos++] = (uint8_t)(v >> 8);
- }
- inline void addU8(uint8_t v) {
- if (mPos + 1 >= mLength) {
- growSize();
- }
- reinterpret_cast<uint8_t *>(&mData[mPos])[0] = v;
- mPos ++;
- }
- void addByteArray(const void *src, size_t numBytes);
- void addOffset(uint64_t v);
- void addString(String8 *s);
- uint64_t getPos() const {
- return mPos;
- }
- void reset(uint64_t pos) {
- mPos = pos;
- }
- void reset() {
- mPos = 0;
- }
- const uint8_t * getPtr() const {
- return mData;
- }
-protected:
- void growSize();
- uint8_t * mData;
- uint64_t mLength;
- uint64_t mPos;
- bool mUse64;
-};
-
-
-} // renderscript
-} // android
-#endif //ANDROID_RS_STREAM_H
-
-
diff --git a/renderscript/v8/rs_support/rsThreadIO.cpp b/renderscript/v8/rs_support/rsThreadIO.cpp
deleted file mode 100644
index 8a0a5dc..0000000
--- a/renderscript/v8/rs_support/rsThreadIO.cpp
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsContext.h"
-#include "rsThreadIO.h"
-#include "rsgApiStructs.h"
-
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <fcntl.h>
-#include <poll.h>
-
-
-using namespace android;
-using namespace android::renderscript;
-
-ThreadIO::ThreadIO() {
- mRunning = true;
- mPureFifo = false;
- mMaxInlineSize = 1024;
-}
-
-ThreadIO::~ThreadIO() {
-}
-
-void ThreadIO::init() {
- mToClient.init();
- mToCore.init();
-}
-
-void ThreadIO::shutdown() {
- mRunning = false;
- mToCore.shutdown();
-}
-
-void * ThreadIO::coreHeader(uint32_t cmdID, size_t dataLen) {
- //ALOGE("coreHeader %i %i", cmdID, dataLen);
- CoreCmdHeader *hdr = (CoreCmdHeader *)&mSendBuffer[0];
- hdr->bytes = dataLen;
- hdr->cmdID = cmdID;
- mSendLen = dataLen + sizeof(CoreCmdHeader);
- //mToCoreSocket.writeAsync(&hdr, sizeof(hdr));
- //ALOGE("coreHeader ret ");
- return &mSendBuffer[sizeof(CoreCmdHeader)];
-}
-
-void ThreadIO::coreCommit() {
- mToCore.writeAsync(&mSendBuffer, mSendLen);
-}
-
-void ThreadIO::clientShutdown() {
- mToClient.shutdown();
-}
-
-void ThreadIO::coreWrite(const void *data, size_t len) {
- //ALOGV("core write %p %i", data, (int)len);
- mToCore.writeAsync(data, len, true);
-}
-
-void ThreadIO::coreRead(void *data, size_t len) {
- //ALOGV("core read %p %i", data, (int)len);
- mToCore.read(data, len);
-}
-
-void ThreadIO::coreSetReturn(const void *data, size_t dataLen) {
- uint32_t buf;
- if (data == NULL) {
- data = &buf;
- dataLen = sizeof(buf);
- }
-
- mToCore.readReturn(data, dataLen);
-}
-
-void ThreadIO::coreGetReturn(void *data, size_t dataLen) {
- uint32_t buf;
- if (data == NULL) {
- data = &buf;
- dataLen = sizeof(buf);
- }
-
- mToCore.writeWaitReturn(data, dataLen);
-}
-
-void ThreadIO::setTimeoutCallback(void (*cb)(void *), void *dat, uint64_t timeout) {
- //mToCore.setTimeoutCallback(cb, dat, timeout);
-}
-
-bool ThreadIO::playCoreCommands(Context *con, int waitFd) {
- bool ret = false;
- const bool isLocal = !isPureFifo();
-
- uint8_t buf[2 * 1024];
- const CoreCmdHeader *cmd = (const CoreCmdHeader *)&buf[0];
- const void * data = (const void *)&buf[sizeof(CoreCmdHeader)];
-
- struct pollfd p[2];
- p[0].fd = mToCore.getReadFd();
- p[0].events = POLLIN;
- p[0].revents = 0;
- p[1].fd = waitFd;
- p[1].events = POLLIN;
- p[1].revents = 0;
- int pollCount = 1;
- if (waitFd >= 0) {
- pollCount = 2;
- }
-
- if (con->props.mLogTimes) {
- con->timerSet(Context::RS_TIMER_IDLE);
- }
-
- int waitTime = -1;
- while (mRunning) {
- int pr = poll(p, pollCount, waitTime);
- if (pr <= 0) {
- break;
- }
-
- if (p[0].revents) {
- size_t r = 0;
- if (isLocal) {
- r = mToCore.read(&buf[0], sizeof(CoreCmdHeader));
- mToCore.read(&buf[sizeof(CoreCmdHeader)], cmd->bytes);
- if (r != sizeof(CoreCmdHeader)) {
- // exception or timeout occurred.
- break;
- }
- } else {
- r = mToCore.read((void *)&cmd->cmdID, sizeof(cmd->cmdID));
- }
-
-
- ret = true;
- if (con->props.mLogTimes) {
- con->timerSet(Context::RS_TIMER_INTERNAL);
- }
- //ALOGV("playCoreCommands 3 %i %i", cmd->cmdID, cmd->bytes);
-
- if (cmd->cmdID >= (sizeof(gPlaybackFuncs) / sizeof(void *))) {
- rsAssert(cmd->cmdID < (sizeof(gPlaybackFuncs) / sizeof(void *)));
- ALOGE("playCoreCommands error con %p, cmd %i", con, cmd->cmdID);
- }
-
- if (isLocal) {
- gPlaybackFuncs[cmd->cmdID](con, data, cmd->bytes);
- } else {
- gPlaybackRemoteFuncs[cmd->cmdID](con, this);
- }
-
- if (con->props.mLogTimes) {
- con->timerSet(Context::RS_TIMER_IDLE);
- }
-
- if (waitFd < 0) {
- // If we don't have a secondary wait object we should stop blocking now
- // that at least one command has been processed.
- waitTime = 0;
- }
- }
-
- if (p[1].revents && !p[0].revents) {
- // We want to finish processing fifo events before processing the vsync.
- // Otherwise we can end up falling behind and having tremendous lag.
- break;
- }
- }
- return ret;
-}
-
-RsMessageToClientType ThreadIO::getClientHeader(size_t *receiveLen, uint32_t *usrID) {
- //ALOGE("getClientHeader");
- mToClient.read(&mLastClientHeader, sizeof(mLastClientHeader));
-
- receiveLen[0] = mLastClientHeader.bytes;
- usrID[0] = mLastClientHeader.userID;
- //ALOGE("getClientHeader %i %i %i", mLastClientHeader.cmdID, usrID[0], receiveLen[0]);
- return (RsMessageToClientType)mLastClientHeader.cmdID;
-}
-
-RsMessageToClientType ThreadIO::getClientPayload(void *data, size_t *receiveLen,
- uint32_t *usrID, size_t bufferLen) {
- //ALOGE("getClientPayload");
- receiveLen[0] = mLastClientHeader.bytes;
- usrID[0] = mLastClientHeader.userID;
- if (bufferLen < mLastClientHeader.bytes) {
- return RS_MESSAGE_TO_CLIENT_RESIZE;
- }
- if (receiveLen[0]) {
- mToClient.read(data, receiveLen[0]);
- }
- //ALOGE("getClientPayload x");
- return (RsMessageToClientType)mLastClientHeader.cmdID;
-}
-
-bool ThreadIO::sendToClient(RsMessageToClientType cmdID, uint32_t usrID, const void *data,
- size_t dataLen, bool waitForSpace) {
-
- //ALOGE("sendToClient %i %i %i", cmdID, usrID, (int)dataLen);
- ClientCmdHeader hdr;
- hdr.bytes = dataLen;
- hdr.cmdID = cmdID;
- hdr.userID = usrID;
-
- mToClient.writeAsync(&hdr, sizeof(hdr));
- if (dataLen) {
- mToClient.writeAsync(data, dataLen);
- }
-
- //ALOGE("sendToClient x");
- return true;
-}
-
diff --git a/renderscript/v8/rs_support/rsThreadIO.h b/renderscript/v8/rs_support/rsThreadIO.h
deleted file mode 100644
index e0a108f..0000000
--- a/renderscript/v8/rs_support/rsThreadIO.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_RS_THREAD_IO_H
-#define ANDROID_RS_THREAD_IO_H
-
-#include "rsUtils.h"
-#include "rsFifoSocket.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-class Context;
-
-class ThreadIO {
-public:
- ThreadIO();
- ~ThreadIO();
-
- void init();
- void shutdown();
-
- size_t getMaxInlineSize() {
- return mMaxInlineSize;
- }
- bool isPureFifo() {
- return mPureFifo;
- }
-
- // Plays back commands from the client.
- // Returns true if any commands were processed.
- bool playCoreCommands(Context *con, int waitFd);
-
- void setTimeoutCallback(void (*)(void *), void *, uint64_t timeout);
-
- void * coreHeader(uint32_t, size_t dataLen);
- void coreCommit();
-
- void coreSetReturn(const void *data, size_t dataLen);
- void coreGetReturn(void *data, size_t dataLen);
- void coreWrite(const void *data, size_t len);
- void coreRead(void *data, size_t len);
-
- void asyncSetReturn(const void *data, size_t dataLen);
- void asyncGetReturn(void *data, size_t dataLen);
- void asyncWrite(const void *data, size_t len);
- void asyncRead(void *data, size_t len);
-
-
- RsMessageToClientType getClientHeader(size_t *receiveLen, uint32_t *usrID);
- RsMessageToClientType getClientPayload(void *data, size_t *receiveLen, uint32_t *subID, size_t bufferLen);
- bool sendToClient(RsMessageToClientType cmdID, uint32_t usrID, const void *data, size_t dataLen, bool waitForSpace);
- void clientShutdown();
-
-
-protected:
- typedef struct CoreCmdHeaderRec {
- uint32_t cmdID;
- uint32_t bytes;
- } CoreCmdHeader;
- typedef struct ClientCmdHeaderRec {
- uint32_t cmdID;
- uint32_t bytes;
- uint32_t userID;
- } ClientCmdHeader;
- ClientCmdHeader mLastClientHeader;
-
- bool mRunning;
- bool mPureFifo;
- size_t mMaxInlineSize;
-
- FifoSocket mToClient;
- FifoSocket mToCore;
-
- intptr_t mToCoreRet;
-
- size_t mSendLen;
- uint8_t mSendBuffer[2 * 1024] __attribute__((aligned(sizeof(double))));
-
-};
-
-
-}
-}
-#endif
-
diff --git a/renderscript/v8/rs_support/rsType.cpp b/renderscript/v8/rs_support/rsType.cpp
deleted file mode 100644
index 7ed8d97..0000000
--- a/renderscript/v8/rs_support/rsType.cpp
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "rsContext.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-Type::Type(Context *rsc) : ObjectBase(rsc) {
- memset(&mHal, 0, sizeof(mHal));
- mDimLOD = false;
-}
-
-void Type::preDestroy() const {
- for (uint32_t ct = 0; ct < mRSC->mStateType.mTypes.size(); ct++) {
- if (mRSC->mStateType.mTypes[ct] == this) {
- mRSC->mStateType.mTypes.removeAt(ct);
- break;
- }
- }
-}
-
-Type::~Type() {
- clear();
-}
-
-void Type::clear() {
- if (mHal.state.lodCount) {
- delete [] mHal.state.lodDimX;
- delete [] mHal.state.lodDimY;
- delete [] mHal.state.lodDimZ;
- delete [] mHal.state.lodOffset;
- }
- mElement.clear();
- memset(&mHal, 0, sizeof(mHal));
-}
-
-TypeState::TypeState() {
-}
-
-TypeState::~TypeState() {
- rsAssert(!mTypes.size());
-}
-
-size_t Type::getOffsetForFace(uint32_t face) const {
- rsAssert(mHal.state.faces);
- return 0;
-}
-
-void Type::compute() {
- uint32_t oldLODCount = mHal.state.lodCount;
- if (mDimLOD) {
- uint32_t l2x = rsFindHighBit(mHal.state.dimX) + 1;
- uint32_t l2y = rsFindHighBit(mHal.state.dimY) + 1;
- uint32_t l2z = rsFindHighBit(mHal.state.dimZ) + 1;
-
- mHal.state.lodCount = rsMax(l2x, l2y);
- mHal.state.lodCount = rsMax(mHal.state.lodCount, l2z);
- } else {
- mHal.state.lodCount = 1;
- }
- if (mHal.state.lodCount != oldLODCount) {
- if (oldLODCount) {
- delete [] mHal.state.lodDimX;
- delete [] mHal.state.lodDimY;
- delete [] mHal.state.lodDimZ;
- delete [] mHal.state.lodOffset;
- }
- mHal.state.lodDimX = new uint32_t[mHal.state.lodCount];
- mHal.state.lodDimY = new uint32_t[mHal.state.lodCount];
- mHal.state.lodDimZ = new uint32_t[mHal.state.lodCount];
- mHal.state.lodOffset = new uint32_t[mHal.state.lodCount];
- }
-
- uint32_t tx = mHal.state.dimX;
- uint32_t ty = mHal.state.dimY;
- uint32_t tz = mHal.state.dimZ;
- size_t offset = 0;
- for (uint32_t lod=0; lod < mHal.state.lodCount; lod++) {
- mHal.state.lodDimX[lod] = tx;
- mHal.state.lodDimY[lod] = ty;
- mHal.state.lodDimZ[lod] = tz;
- mHal.state.lodOffset[lod] = offset;
- offset += tx * rsMax(ty, 1u) * rsMax(tz, 1u) * mElement->getSizeBytes();
- if (tx > 1) tx >>= 1;
- if (ty > 1) ty >>= 1;
- if (tz > 1) tz >>= 1;
- }
-
- // At this point the offset is the size of a mipmap chain;
- mMipChainSizeBytes = offset;
-
- if (mHal.state.faces) {
- offset *= 6;
- }
- mTotalSizeBytes = offset;
- mHal.state.element = mElement.get();
-}
-
-uint32_t Type::getLODOffset(uint32_t lod, uint32_t x) const {
- uint32_t offset = mHal.state.lodOffset[lod];
- offset += x * mElement->getSizeBytes();
- return offset;
-}
-
-uint32_t Type::getLODOffset(uint32_t lod, uint32_t x, uint32_t y) const {
- uint32_t offset = mHal.state.lodOffset[lod];
- offset += (x + y * mHal.state.lodDimX[lod]) * mElement->getSizeBytes();
- return offset;
-}
-
-uint32_t Type::getLODOffset(uint32_t lod, uint32_t x, uint32_t y, uint32_t z) const {
- uint32_t offset = mHal.state.lodOffset[lod];
- offset += (x +
- y * mHal.state.lodDimX[lod] +
- z * mHal.state.lodDimX[lod] * mHal.state.lodDimY[lod]) * mElement->getSizeBytes();
- return offset;
-}
-
-uint32_t Type::getLODFaceOffset(uint32_t lod, RsAllocationCubemapFace face,
- uint32_t x, uint32_t y) const {
- uint32_t offset = mHal.state.lodOffset[lod];
- offset += (x + y * mHal.state.lodDimX[lod]) * mElement->getSizeBytes();
-
- if (face != 0) {
- uint32_t faceOffset = getSizeBytes() / 6;
- offset += faceOffset * face;
- }
- return offset;
-}
-
-void Type::dumpLOGV(const char *prefix) const {
- char buf[1024];
- ObjectBase::dumpLOGV(prefix);
- ALOGV("%s Type: x=%u y=%u z=%u mip=%i face=%i", prefix,
- mHal.state.dimX,
- mHal.state.dimY,
- mHal.state.dimZ,
- mHal.state.lodCount,
- mHal.state.faces);
- snprintf(buf, sizeof(buf), "%s element: ", prefix);
- mElement->dumpLOGV(buf);
-}
-
-void Type::serialize(Context *rsc, OStream *stream) const {
- // Need to identify ourselves
- stream->addU32((uint32_t)getClassId());
-
- String8 name(getName());
- stream->addString(&name);
-
- mElement->serialize(rsc, stream);
-
- stream->addU32(mHal.state.dimX);
- stream->addU32(mHal.state.dimY);
- stream->addU32(mHal.state.dimZ);
-
- stream->addU8((uint8_t)(mHal.state.lodCount ? 1 : 0));
- stream->addU8((uint8_t)(mHal.state.faces ? 1 : 0));
-}
-
-Type *Type::createFromStream(Context *rsc, IStream *stream) {
- // First make sure we are reading the correct object
- RsA3DClassID classID = (RsA3DClassID)stream->loadU32();
- if (classID != RS_A3D_CLASS_ID_TYPE) {
- ALOGE("type loading skipped due to invalid class id\n");
- return NULL;
- }
-
- String8 name;
- stream->loadString(&name);
-
- Element *elem = Element::createFromStream(rsc, stream);
- if (!elem) {
- return NULL;
- }
-
- uint32_t x = stream->loadU32();
- uint32_t y = stream->loadU32();
- uint32_t z = stream->loadU32();
- uint8_t lod = stream->loadU8();
- uint8_t faces = stream->loadU8();
- Type *type = Type::getType(rsc, elem, x, y, z, lod != 0, faces !=0 );
- elem->decUserRef();
- return type;
-}
-
-bool Type::getIsNp2() const {
- uint32_t x = getDimX();
- uint32_t y = getDimY();
- uint32_t z = getDimZ();
-
- if (x && (x & (x-1))) {
- return true;
- }
- if (y && (y & (y-1))) {
- return true;
- }
- if (z && (z & (z-1))) {
- return true;
- }
- return false;
-}
-
-ObjectBaseRef<Type> Type::getTypeRef(Context *rsc, const Element *e,
- uint32_t dimX, uint32_t dimY, uint32_t dimZ,
- bool dimLOD, bool dimFaces) {
- ObjectBaseRef<Type> returnRef;
-
- TypeState * stc = &rsc->mStateType;
-
- ObjectBase::asyncLock();
- for (uint32_t ct=0; ct < stc->mTypes.size(); ct++) {
- Type *t = stc->mTypes[ct];
- if (t->getElement() != e) continue;
- if (t->getDimX() != dimX) continue;
- if (t->getDimY() != dimY) continue;
- if (t->getDimZ() != dimZ) continue;
- if (t->getDimLOD() != dimLOD) continue;
- if (t->getDimFaces() != dimFaces) continue;
- returnRef.set(t);
- ObjectBase::asyncUnlock();
- return returnRef;
- }
- ObjectBase::asyncUnlock();
-
-
- Type *nt = new Type(rsc);
- nt->mDimLOD = dimLOD;
- returnRef.set(nt);
- nt->mElement.set(e);
- nt->mHal.state.dimX = dimX;
- nt->mHal.state.dimY = dimY;
- nt->mHal.state.dimZ = dimZ;
- nt->mHal.state.faces = dimFaces;
- nt->compute();
-
- ObjectBase::asyncLock();
- stc->mTypes.push(nt);
- ObjectBase::asyncUnlock();
-
- return returnRef;
-}
-
-ObjectBaseRef<Type> Type::cloneAndResize1D(Context *rsc, uint32_t dimX) const {
- return getTypeRef(rsc, mElement.get(), dimX,
- getDimY(), getDimZ(), getDimLOD(), getDimFaces());
-}
-
-ObjectBaseRef<Type> Type::cloneAndResize2D(Context *rsc,
- uint32_t dimX,
- uint32_t dimY) const {
- return getTypeRef(rsc, mElement.get(), dimX, dimY,
- getDimZ(), getDimLOD(), getDimFaces());
-}
-
-
-void Type::incRefs(const void *ptr, size_t ct, size_t startOff) const {
- const uint8_t *p = static_cast<const uint8_t *>(ptr);
- const Element *e = mHal.state.element;
- uint32_t stride = e->getSizeBytes();
-
- p += stride * startOff;
- while (ct > 0) {
- e->incRefs(p);
- ct--;
- p += stride;
- }
-}
-
-
-void Type::decRefs(const void *ptr, size_t ct, size_t startOff) const {
- if (!mHal.state.element->getHasReferences()) {
- return;
- }
- const uint8_t *p = static_cast<const uint8_t *>(ptr);
- const Element *e = mHal.state.element;
- uint32_t stride = e->getSizeBytes();
-
- p += stride * startOff;
- while (ct > 0) {
- e->decRefs(p);
- ct--;
- p += stride;
- }
-}
-
-
-//////////////////////////////////////////////////
-//
-namespace android {
-namespace renderscript {
-
-RsType rsi_TypeCreate(Context *rsc, RsElement _e, uint32_t dimX,
- uint32_t dimY, uint32_t dimZ, bool mips, bool faces) {
- Element *e = static_cast<Element *>(_e);
-
- return Type::getType(rsc, e, dimX, dimY, dimZ, mips, faces);
-}
-
-}
-}
-
-void rsaTypeGetNativeData(RsContext con, RsType type, uint32_t *typeData, uint32_t typeDataSize) {
- rsAssert(typeDataSize == 6);
- // Pack the data in the follofing way mHal.state.dimX; mHal.state.dimY; mHal.state.dimZ;
- // mHal.state.lodCount; mHal.state.faces; mElement; into typeData
- Type *t = static_cast<Type *>(type);
-
- (*typeData++) = t->getDimX();
- (*typeData++) = t->getDimY();
- (*typeData++) = t->getDimZ();
- (*typeData++) = t->getDimLOD() ? 1 : 0;
- (*typeData++) = t->getDimFaces() ? 1 : 0;
- (*typeData++) = (uint32_t)t->getElement();
- t->getElement()->incUserRef();
-}
diff --git a/renderscript/v8/rs_support/rsType.h b/renderscript/v8/rs_support/rsType.h
deleted file mode 100644
index 1d136b4..0000000
--- a/renderscript/v8/rs_support/rsType.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_STRUCTURED_TYPE_H
-#define ANDROID_STRUCTURED_TYPE_H
-
-#include "rsElement.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-/*****************************************************************************
- * CAUTION
- *
- * Any layout changes for this class may require a corresponding change to be
- * made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
- * a partial copy of the information below.
- *
- *****************************************************************************/
-
-class Type : public ObjectBase {
-public:
- struct Hal {
- mutable void *drv;
-
- struct State {
- const Element * element;
-
- // Size of the structure in the various dimensions. A missing Dimension is
- // specified as a 0 and not a 1.
- uint32_t dimX;
- uint32_t dimY;
- uint32_t dimZ;
- uint32_t *lodDimX;
- uint32_t *lodDimY;
- uint32_t *lodDimZ;
- uint32_t *lodOffset;
- uint32_t lodCount;
- bool faces;
- };
- State state;
- };
- Hal mHal;
-
- Type * createTex2D(const Element *, size_t w, size_t h, bool mip);
-
- size_t getOffsetForFace(uint32_t face) const;
-
- size_t getSizeBytes() const {return mTotalSizeBytes;}
- size_t getElementSizeBytes() const {return mElement->getSizeBytes();}
- const Element * getElement() const {return mElement.get();}
-
- uint32_t getDimX() const {return mHal.state.dimX;}
- uint32_t getDimY() const {return mHal.state.dimY;}
- uint32_t getDimZ() const {return mHal.state.dimZ;}
- bool getDimLOD() const {return mDimLOD;}
- bool getDimFaces() const {return mHal.state.faces;}
-
- uint32_t getLODDimX(uint32_t lod) const {
- rsAssert(lod < mHal.state.lodCount);
- return mHal.state.lodDimX[lod];
- }
- uint32_t getLODDimY(uint32_t lod) const {
- rsAssert(lod < mHal.state.lodCount);
- return mHal.state.lodDimY[lod];
- }
- uint32_t getLODDimZ(uint32_t lod) const {
- rsAssert(lod < mHal.state.lodCount);
- return mHal.state.lodDimZ[lod];
- }
- uint32_t getLODOffset(uint32_t lod) const {
- rsAssert(lod < mHal.state.lodCount);
- return mHal.state.lodOffset[lod];
- }
- uint32_t getLODOffset(uint32_t lod, uint32_t x) const;
- uint32_t getLODOffset(uint32_t lod, uint32_t x, uint32_t y) const;
- uint32_t getLODOffset(uint32_t lod, uint32_t x, uint32_t y, uint32_t z) const;
-
- uint32_t getLODFaceOffset(uint32_t lod, RsAllocationCubemapFace face,
- uint32_t x, uint32_t y) const;
-
- uint32_t getLODCount() const {return mHal.state.lodCount;}
- bool getIsNp2() const;
-
- void clear();
- void compute();
-
- void dumpLOGV(const char *prefix) const;
- virtual void serialize(Context *rsc, OStream *stream) const;
- virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_TYPE; }
- static Type *createFromStream(Context *rsc, IStream *stream);
-
- ObjectBaseRef<Type> cloneAndResize1D(Context *rsc, uint32_t dimX) const;
- ObjectBaseRef<Type> cloneAndResize2D(Context *rsc, uint32_t dimX, uint32_t dimY) const;
-
- static ObjectBaseRef<Type> getTypeRef(Context *rsc, const Element *e,
- uint32_t dimX, uint32_t dimY, uint32_t dimZ,
- bool dimLOD, bool dimFaces);
-
- static Type* getType(Context *rsc, const Element *e,
- uint32_t dimX, uint32_t dimY, uint32_t dimZ,
- bool dimLOD, bool dimFaces) {
- ObjectBaseRef<Type> type = getTypeRef(rsc, e, dimX, dimY, dimZ, dimLOD, dimFaces);
- type->incUserRef();
- return type.get();
- }
-
- void incRefs(const void *ptr, size_t ct, size_t startOff = 0) const;
- void decRefs(const void *ptr, size_t ct, size_t startOff = 0) const;
-
-protected:
- void makeLODTable();
- bool mDimLOD;
-
- // Internal structure from most to least significant.
- // * Array dimensions
- // * Faces
- // * Mipmaps
- // * xyz
-
- ObjectBaseRef<const Element> mElement;
-
- // count of mipmap levels, 0 indicates no mipmapping
-
- size_t mMipChainSizeBytes;
- size_t mTotalSizeBytes;
-protected:
- virtual void preDestroy() const;
- virtual ~Type();
-
-private:
- Type(Context *);
- Type(const Type &);
-};
-
-
-class TypeState {
-public:
- TypeState();
- ~TypeState();
-
- // Cache of all existing types.
- Vector<Type *> mTypes;
-};
-
-
-}
-}
-#endif //ANDROID_STRUCTURED_TYPE
diff --git a/renderscript/v8/rs_support/rsUtils.h b/renderscript/v8/rs_support/rsUtils.h
deleted file mode 100644
index ebfc679..0000000
--- a/renderscript/v8/rs_support/rsUtils.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_RS_UTILS_H
-#define ANDROID_RS_UTILS_H
-
-#define LOG_NDEBUG 0
-#define LOG_TAG "RenderScript"
-
-#include <utils/Log.h>
-
-#include "rsStream.h"
-
-#include <utils/String8.h>
-#include <utils/Vector.h>
-
-#include <stdlib.h>
-#include <pthread.h>
-#include <time.h>
-#include <cutils/atomic.h>
-
-#include <math.h>
-
-namespace android {
-namespace renderscript {
-
-#if 1
-#define rsAssert(v) do {if(!(v)) ALOGE("rsAssert failed: %s, in %s at %i", #v, __FILE__, __LINE__);} while (0)
-#else
-#define rsAssert(v) while (0)
-#endif
-
-template<typename T>
-T rsMin(T in1, T in2)
-{
- if (in1 > in2) {
- return in2;
- }
- return in1;
-}
-
-template<typename T>
-T rsMax(T in1, T in2) {
- if (in1 < in2) {
- return in2;
- }
- return in1;
-}
-
-template<typename T>
-T rsFindHighBit(T val) {
- uint32_t bit = 0;
- while (val > 1) {
- bit++;
- val>>=1;
- }
- return bit;
-}
-
-template<typename T>
-bool rsIsPow2(T val) {
- return (val & (val-1)) == 0;
-}
-
-template<typename T>
-T rsHigherPow2(T v) {
- if (rsIsPow2(v)) {
- return v;
- }
- return 1 << (rsFindHighBit(v) + 1);
-}
-
-template<typename T>
-T rsLowerPow2(T v) {
- if (rsIsPow2(v)) {
- return v;
- }
- return 1 << rsFindHighBit(v);
-}
-
-static inline uint16_t rs888to565(uint32_t r, uint32_t g, uint32_t b) {
- uint16_t t = 0;
- t |= b >> 3;
- t |= (g >> 2) << 5;
- t |= (r >> 3) << 11;
- return t;
-}
-
-static inline uint16_t rsBoxFilter565(uint16_t i1, uint16_t i2, uint16_t i3, uint16_t i4) {
- uint32_t r = ((i1 & 0x1f) + (i2 & 0x1f) + (i3 & 0x1f) + (i4 & 0x1f));
- uint32_t g = ((i1 >> 5) & 0x3f) + ((i2 >> 5) & 0x3f) + ((i3 >> 5) & 0x3f) + ((i4 >> 5) & 0x3f);
- uint32_t b = ((i1 >> 11) + (i2 >> 11) + (i3 >> 11) + (i4 >> 11));
- return (r >> 2) | ((g >> 2) << 5) | ((b >> 2) << 11);
-}
-
-static inline uint32_t rsBoxFilter8888(uint32_t i1, uint32_t i2, uint32_t i3, uint32_t i4) {
- uint32_t r = (i1 & 0xff) + (i2 & 0xff) + (i3 & 0xff) + (i4 & 0xff);
- uint32_t g = ((i1 >> 8) & 0xff) + ((i2 >> 8) & 0xff) + ((i3 >> 8) & 0xff) + ((i4 >> 8) & 0xff);
- uint32_t b = ((i1 >> 16) & 0xff) + ((i2 >> 16) & 0xff) + ((i3 >> 16) & 0xff) + ((i4 >> 16) & 0xff);
- uint32_t a = ((i1 >> 24) & 0xff) + ((i2 >> 24) & 0xff) + ((i3 >> 24) & 0xff) + ((i4 >> 24) & 0xff);
- return (r >> 2) | ((g >> 2) << 8) | ((b >> 2) << 16) | ((a >> 2) << 24);
-}
-
-}
-}
-
-#endif //ANDROID_RS_OBJECT_BASE_H
-
-
diff --git a/renderscript/v8/rs_support/rs_hal.h b/renderscript/v8/rs_support/rs_hal.h
deleted file mode 100644
index b0e10c9..0000000
--- a/renderscript/v8/rs_support/rs_hal.h
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * Copyright (C) 2011-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef RS_HAL_H
-#define RS_HAL_H
-
-#include <rsDefines.h>
-
-struct ANativeWindow;
-
-namespace android {
-namespace renderscript {
-
-class Context;
-class ObjectBase;
-class Element;
-class Type;
-class Allocation;
-class Script;
-class ScriptKernelID;
-class ScriptFieldID;
-class ScriptMethodID;
-class ScriptC;
-class ScriptGroup;
-class Path;
-class Program;
-class ProgramStore;
-class ProgramRaster;
-class ProgramVertex;
-class ProgramFragment;
-class Mesh;
-class Sampler;
-class FBOCache;
-
-typedef void *(*RsHalSymbolLookupFunc)(void *usrptr, char const *symbolName);
-
-typedef struct {
- const void *in;
- void *out;
- const void *usr;
- size_t usrLen;
- uint32_t x;
- uint32_t y;
- uint32_t z;
- uint32_t lod;
- RsAllocationCubemapFace face;
- uint32_t ar[16];
-
- uint32_t dimX;
- uint32_t dimY;
- uint32_t dimZ;
- uint32_t dimArray;
-
- const uint8_t *ptrIn;
- uint8_t *ptrOut;
- uint32_t eStrideIn;
- uint32_t eStrideOut;
- uint32_t yStrideIn;
- uint32_t yStrideOut;
- uint32_t slot;
-} RsForEachStubParamStruct;
-
-/**
- * Script management functions
- */
-typedef struct {
- bool (*initGraphics)(const Context *);
- void (*shutdownGraphics)(const Context *);
- bool (*setSurface)(const Context *, uint32_t w, uint32_t h, RsNativeWindow);
- void (*swap)(const Context *);
-
- void (*shutdownDriver)(Context *);
- void (*getVersion)(unsigned int *major, unsigned int *minor);
- void (*setPriority)(const Context *, int32_t priority);
-
-
-
- struct {
- bool (*init)(const Context *rsc, ScriptC *s,
- char const *resName,
- char const *cacheDir,
- uint8_t const *bitcode,
- size_t bitcodeSize,
- uint32_t flags);
- bool (*initIntrinsic)(const Context *rsc, Script *s,
- RsScriptIntrinsicID iid,
- Element *e);
-
- void (*invokeFunction)(const Context *rsc, Script *s,
- uint32_t slot,
- const void *params,
- size_t paramLength);
- int (*invokeRoot)(const Context *rsc, Script *s);
- void (*invokeForEach)(const Context *rsc,
- Script *s,
- uint32_t slot,
- const Allocation * ain,
- Allocation * aout,
- const void * usr,
- uint32_t usrLen,
- const RsScriptCall *sc);
- void (*invokeInit)(const Context *rsc, Script *s);
- void (*invokeFreeChildren)(const Context *rsc, Script *s);
-
- void (*setGlobalVar)(const Context *rsc, const Script *s,
- uint32_t slot,
- void *data,
- size_t dataLength);
- void (*setGlobalVarWithElemDims)(const Context *rsc, const Script *s,
- uint32_t slot,
- void *data,
- size_t dataLength,
- const Element *e,
- const size_t *dims,
- size_t dimLength);
- void (*setGlobalBind)(const Context *rsc, const Script *s,
- uint32_t slot,
- Allocation *data);
- void (*setGlobalObj)(const Context *rsc, const Script *s,
- uint32_t slot,
- ObjectBase *data);
-
- void (*destroy)(const Context *rsc, Script *s);
- } script;
-
- struct {
- bool (*init)(const Context *rsc, Allocation *alloc, bool forceZero);
- void (*destroy)(const Context *rsc, Allocation *alloc);
-
- void (*resize)(const Context *rsc, const Allocation *alloc, const Type *newType,
- bool zeroNew);
- void (*syncAll)(const Context *rsc, const Allocation *alloc, RsAllocationUsageType src);
- void (*markDirty)(const Context *rsc, const Allocation *alloc);
-
- int32_t (*initSurfaceTexture)(const Context *rsc, const Allocation *alloc);
- void (*setSurfaceTexture)(const Context *rsc, Allocation *alloc, ANativeWindow *sur);
- void (*ioSend)(const Context *rsc, Allocation *alloc);
- void (*ioReceive)(const Context *rsc, Allocation *alloc);
-
- void (*data1D)(const Context *rsc, const Allocation *alloc,
- uint32_t xoff, uint32_t lod, uint32_t count,
- const void *data, size_t sizeBytes);
- void (*data2D)(const Context *rsc, const Allocation *alloc,
- uint32_t xoff, uint32_t yoff, uint32_t lod,
- RsAllocationCubemapFace face, uint32_t w, uint32_t h,
- const void *data, size_t sizeBytes);
- void (*data3D)(const Context *rsc, const Allocation *alloc,
- uint32_t xoff, uint32_t yoff, uint32_t zoff,
- uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, uint32_t d, const void *data, size_t sizeBytes);
-
- void (*read1D)(const Context *rsc, const Allocation *alloc,
- uint32_t xoff, uint32_t lod, uint32_t count,
- void *data, size_t sizeBytes);
- void (*read2D)(const Context *rsc, const Allocation *alloc,
- uint32_t xoff, uint32_t yoff, uint32_t lod,
- RsAllocationCubemapFace face, uint32_t w, uint32_t h,
- void *data, size_t sizeBytes);
- void (*read3D)(const Context *rsc, const Allocation *alloc,
- uint32_t xoff, uint32_t yoff, uint32_t zoff,
- uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, uint32_t d, void *data, size_t sizeBytes);
-
- // Lock and unlock make a 1D region of memory available to the CPU
- // for direct access by pointer. Once unlock is called control is
- // returned to the SOC driver.
- void * (*lock1D)(const Context *rsc, const Allocation *alloc);
- void (*unlock1D)(const Context *rsc, const Allocation *alloc);
-
- // Allocation to allocation copies
- void (*allocData1D)(const Context *rsc,
- const Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstLod, uint32_t count,
- const Allocation *srcAlloc, uint32_t srcXoff, uint32_t srcLod);
- void (*allocData2D)(const Context *rsc,
- const Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
- RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
- const Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
- RsAllocationCubemapFace srcFace);
- void (*allocData3D)(const Context *rsc,
- const Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
- uint32_t dstLod, RsAllocationCubemapFace dstFace,
- uint32_t w, uint32_t h, uint32_t d,
- const Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
- uint32_t srcLod, RsAllocationCubemapFace srcFace);
-
- void (*elementData1D)(const Context *rsc, const Allocation *alloc, uint32_t x,
- const void *data, uint32_t elementOff, size_t sizeBytes);
- void (*elementData2D)(const Context *rsc, const Allocation *alloc, uint32_t x, uint32_t y,
- const void *data, uint32_t elementOff, size_t sizeBytes);
-
- void (*generateMipmaps)(const Context *rsc, const Allocation *alloc);
- } allocation;
-
- struct {
- bool (*init)(const Context *rsc, const ProgramStore *ps);
- void (*setActive)(const Context *rsc, const ProgramStore *ps);
- void (*destroy)(const Context *rsc, const ProgramStore *ps);
- } store;
-
- struct {
- bool (*init)(const Context *rsc, const ProgramRaster *ps);
- void (*setActive)(const Context *rsc, const ProgramRaster *ps);
- void (*destroy)(const Context *rsc, const ProgramRaster *ps);
- } raster;
-
- struct {
- bool (*init)(const Context *rsc, const ProgramVertex *pv,
- const char* shader, size_t shaderLen,
- const char** textureNames, size_t textureNamesCount,
- const size_t *textureNamesLength);
- void (*setActive)(const Context *rsc, const ProgramVertex *pv);
- void (*destroy)(const Context *rsc, const ProgramVertex *pv);
- } vertex;
-
- struct {
- bool (*init)(const Context *rsc, const ProgramFragment *pf,
- const char* shader, size_t shaderLen,
- const char** textureNames, size_t textureNamesCount,
- const size_t *textureNamesLength);
- void (*setActive)(const Context *rsc, const ProgramFragment *pf);
- void (*destroy)(const Context *rsc, const ProgramFragment *pf);
- } fragment;
-
- struct {
- bool (*init)(const Context *rsc, const Mesh *m);
- void (*draw)(const Context *rsc, const Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len);
- void (*destroy)(const Context *rsc, const Mesh *m);
- } mesh;
-
- struct {
- bool (*initStatic)(const Context *rsc, const Path *m, const Allocation *vtx, const Allocation *loops);
- bool (*initDynamic)(const Context *rsc, const Path *m);
- void (*draw)(const Context *rsc, const Path *m);
- void (*destroy)(const Context *rsc, const Path *m);
- } path;
-
- struct {
- bool (*init)(const Context *rsc, const Sampler *m);
- void (*destroy)(const Context *rsc, const Sampler *m);
- } sampler;
-
- struct {
- bool (*init)(const Context *rsc, const FBOCache *fb);
- void (*setActive)(const Context *rsc, const FBOCache *fb);
- void (*destroy)(const Context *rsc, const FBOCache *fb);
- } framebuffer;
-
- struct {
- bool (*init)(const Context *rsc, const ScriptGroup *sg);
- void (*setInput)(const Context *rsc, const ScriptGroup *sg,
- const ScriptKernelID *kid, Allocation *);
- void (*setOutput)(const Context *rsc, const ScriptGroup *sg,
- const ScriptKernelID *kid, Allocation *);
- void (*execute)(const Context *rsc, const ScriptGroup *sg);
- void (*destroy)(const Context *rsc, const ScriptGroup *sg);
- } scriptgroup;
-
-} RsdHalFunctions;
-
-
-}
-}
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-bool rsdHalInit(RsContext, uint32_t version_major, uint32_t version_minor);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/renderscript/v8/rs_support/rsgApi.cpp.rsg b/renderscript/v8/rs_support/rsgApi.cpp.rsg
deleted file mode 100644
index 0cfbf08..0000000
--- a/renderscript/v8/rs_support/rsgApi.cpp.rsg
+++ /dev/null
@@ -1 +0,0 @@
-2
diff --git a/renderscript/v8/rs_support/rsgApiFuncDecl.h.rsg b/renderscript/v8/rs_support/rsgApiFuncDecl.h.rsg
deleted file mode 100644
index d00491f..0000000
--- a/renderscript/v8/rs_support/rsgApiFuncDecl.h.rsg
+++ /dev/null
@@ -1 +0,0 @@
-1
diff --git a/renderscript/v8/rs_support/rsgApiReplay.cpp.rsg b/renderscript/v8/rs_support/rsgApiReplay.cpp.rsg
deleted file mode 100644
index 00750ed..0000000
--- a/renderscript/v8/rs_support/rsgApiReplay.cpp.rsg
+++ /dev/null
@@ -1 +0,0 @@
-3
diff --git a/renderscript/v8/rs_support/rsgApiStructs.h.rsg b/renderscript/v8/rs_support/rsgApiStructs.h.rsg
deleted file mode 100644
index 573541a..0000000
--- a/renderscript/v8/rs_support/rsgApiStructs.h.rsg
+++ /dev/null
@@ -1 +0,0 @@
-0
diff --git a/renderscript/v8/rs_support/rsg_generator.c b/renderscript/v8/rs_support/rsg_generator.c
deleted file mode 100644
index c404c9c..0000000
--- a/renderscript/v8/rs_support/rsg_generator.c
+++ /dev/null
@@ -1,685 +0,0 @@
-
-#include "spec.h"
-#include <stdio.h>
-#include <string.h>
-
-void printFileHeader(FILE *f) {
- fprintf(f, "/*\n");
- fprintf(f, " * Copyright (C) 2011 The Android Open Source Project\n");
- fprintf(f, " *\n");
- fprintf(f, " * Licensed under the Apache License, Version 2.0 (the \"License\");\n");
- fprintf(f, " * you may not use this file except in compliance with the License.\n");
- fprintf(f, " * You may obtain a copy of the License at\n");
- fprintf(f, " *\n");
- fprintf(f, " * http://www.apache.org/licenses/LICENSE-2.0\n");
- fprintf(f, " *\n");
- fprintf(f, " * Unless required by applicable law or agreed to in writing, software\n");
- fprintf(f, " * distributed under the License is distributed on an \"AS IS\" BASIS,\n");
- fprintf(f, " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n");
- fprintf(f, " * See the License for the specific language governing permissions and\n");
- fprintf(f, " * limitations under the License.\n");
- fprintf(f, " */\n\n");
-}
-
-void printVarType(FILE *f, const VarType *vt) {
- int ct;
- if (vt->isConst) {
- fprintf(f, "const ");
- }
-
- switch (vt->type) {
- case 0:
- fprintf(f, "void");
- break;
- case 1:
- fprintf(f, "int%i_t", vt->bits);
- break;
- case 2:
- fprintf(f, "uint%i_t", vt->bits);
- break;
- case 3:
- if (vt->bits == 32)
- fprintf(f, "float");
- else
- fprintf(f, "double");
- break;
- case 4:
- fprintf(f, "%s", vt->typeName);
- break;
- }
-
- if (vt->ptrLevel) {
- fprintf(f, " ");
- for (ct=0; ct < vt->ptrLevel; ct++) {
- fprintf(f, "*");
- }
- }
-}
-
-void printVarTypeAndName(FILE *f, const VarType *vt) {
- printVarType(f, vt);
-
- if (vt->name[0]) {
- fprintf(f, " %s", vt->name);
- }
-}
-
-void printArgList(FILE *f, const ApiEntry * api, int assumePrevious) {
- int ct;
- for (ct=0; ct < api->paramCount; ct++) {
- if (ct || assumePrevious) {
- fprintf(f, ", ");
- }
- printVarTypeAndName(f, &api->params[ct]);
- }
-}
-
-void printStructures(FILE *f) {
- int ct;
- int ct2;
-
- for (ct=0; ct < apiCount; ct++) {
- fprintf(f, "typedef struct RS_CMD_%s_rec RS_CMD_%s;\n", apis[ct].name, apis[ct].name);
- }
- fprintf(f, "\n");
-
- for (ct=0; ct < apiCount; ct++) {
- const ApiEntry * api = &apis[ct];
- fprintf(f, "#define RS_CMD_ID_%s %i\n", api->name, ct+1);
- fprintf(f, "struct RS_CMD_%s_rec {\n", api->name);
- //fprintf(f, " RsCommandHeader _hdr;\n");
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- fprintf(f, " ");
- printVarTypeAndName(f, &api->params[ct2]);
- fprintf(f, ";\n");
- }
- fprintf(f, "};\n\n");
- }
-}
-
-void printFuncDecl(FILE *f, const ApiEntry *api, const char *prefix, int addContext, int isFnPtr) {
- printVarTypeAndName(f, &api->ret);
- if (isFnPtr) {
- char t[1024];
- strcpy(t, api->name);
- if (strlen(prefix) == 0) {
- if (t[0] > 'A' && t[0] < 'Z') {
- t[0] -= 'A' - 'a';
- }
- }
- fprintf(f, " (* %s%s) (", prefix, api->name);
- } else {
- fprintf(f, " %s%s (", prefix, api->name);
- }
- if (!api->nocontext) {
- if (addContext) {
- fprintf(f, "Context *");
- } else {
- fprintf(f, "RsContext rsc");
- }
- }
- printArgList(f, api, !api->nocontext);
- fprintf(f, ")");
-}
-
-void printFuncDecls(FILE *f, const char *prefix, int addContext) {
- int ct;
- for (ct=0; ct < apiCount; ct++) {
- printFuncDecl(f, &apis[ct], prefix, addContext, 0);
- fprintf(f, ";\n");
- }
- fprintf(f, "\n\n");
-}
-
-void printFuncPointers(FILE *f, int addContext) {
- fprintf(f, "\n");
- fprintf(f, "typedef struct RsApiEntrypoints {\n");
- int ct;
- for (ct=0; ct < apiCount; ct++) {
- fprintf(f, " ");
- printFuncDecl(f, &apis[ct], "", addContext, 1);
- fprintf(f, ";\n");
- }
- fprintf(f, "} RsApiEntrypoints_t;\n\n");
-}
-
-void printPlaybackFuncs(FILE *f, const char *prefix) {
- int ct;
- for (ct=0; ct < apiCount; ct++) {
- if (apis[ct].direct) {
- continue;
- }
-
- fprintf(f, "void %s%s (Context *, const void *);\n", prefix, apis[ct].name);
- }
-}
-
-static int hasInlineDataPointers(const ApiEntry * api) {
- int ret = 0;
- int ct;
- if (api->sync || api->ret.typeName[0]) {
- return 0;
- }
- for (ct=0; ct < api->paramCount; ct++) {
- const VarType *vt = &api->params[ct];
-
- if (!vt->isConst && vt->ptrLevel) {
- // Non-const pointers cannot be inlined.
- return 0;
- }
- if (vt->ptrLevel > 1) {
- // not handled yet.
- return 0;
- }
-
- if (vt->isConst && vt->ptrLevel) {
- // Non-const pointers cannot be inlined.
- ret = 1;
- }
- }
- return ret;
-}
-
-void printApiCpp(FILE *f) {
- int ct;
- int ct2;
-
- fprintf(f, "#include \"rsDevice.h\"\n");
- fprintf(f, "#include \"rsContext.h\"\n");
- fprintf(f, "#include \"rsThreadIO.h\"\n");
- fprintf(f, "#include \"rsgApiStructs.h\"\n");
- fprintf(f, "#include \"rsgApiFuncDecl.h\"\n");
- fprintf(f, "#include \"rsFifo.h\"\n");
- fprintf(f, "\n");
- fprintf(f, "using namespace android;\n");
- fprintf(f, "using namespace android::renderscript;\n");
- fprintf(f, "\n");
-
- printFuncPointers(f, 0);
-
- // Generate RS funcs for local fifo
- for (ct=0; ct < apiCount; ct++) {
- int needFlush = 0;
- const ApiEntry * api = &apis[ct];
-
- fprintf(f, "static ");
- printFuncDecl(f, api, "LF_", 0, 0);
- fprintf(f, "\n{\n");
- if (api->direct) {
- fprintf(f, " ");
- if (api->ret.typeName[0]) {
- fprintf(f, "return ");
- }
- fprintf(f, "rsi_%s(", api->name);
- if (!api->nocontext) {
- fprintf(f, "(Context *)rsc");
- }
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if (ct2 > 0 || !api->nocontext) {
- fprintf(f, ", ");
- }
- fprintf(f, "%s", vt->name);
- }
- fprintf(f, ");\n");
- } else {
- fprintf(f, " ThreadIO *io = &((Context *)rsc)->mIO;\n");
- fprintf(f, " const uint32_t size = sizeof(RS_CMD_%s);\n", api->name);
- if (hasInlineDataPointers(api)) {
- fprintf(f, " uint32_t dataSize = 0;\n");
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if (vt->isConst && vt->ptrLevel) {
- fprintf(f, " dataSize += %s_length;\n", vt->name);
- }
- }
- }
-
- //fprintf(f, " ALOGE(\"add command %s\\n\");\n", api->name);
- if (hasInlineDataPointers(api)) {
- fprintf(f, " RS_CMD_%s *cmd = NULL;\n", api->name);
- fprintf(f, " if (dataSize < io->getMaxInlineSize()) {;\n");
- fprintf(f, " cmd = static_cast<RS_CMD_%s *>(io->coreHeader(RS_CMD_ID_%s, dataSize + size));\n", api->name, api->name);
- fprintf(f, " } else {\n");
- fprintf(f, " cmd = static_cast<RS_CMD_%s *>(io->coreHeader(RS_CMD_ID_%s, size));\n", api->name, api->name);
- fprintf(f, " }\n");
- fprintf(f, " uint8_t *payload = (uint8_t *)&cmd[1];\n");
- } else {
- fprintf(f, " RS_CMD_%s *cmd = static_cast<RS_CMD_%s *>(io->coreHeader(RS_CMD_ID_%s, size));\n", api->name, api->name, api->name);
- }
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- needFlush += vt->ptrLevel;
- if (vt->ptrLevel && hasInlineDataPointers(api)) {
- fprintf(f, " if (dataSize < io->getMaxInlineSize()) {\n");
- fprintf(f, " memcpy(payload, %s, %s_length);\n", vt->name, vt->name);
- fprintf(f, " cmd->%s = (", vt->name);
- printVarType(f, vt);
- fprintf(f, ")(payload - ((uint8_t *)&cmd[1]));\n");
- fprintf(f, " payload += %s_length;\n", vt->name);
- fprintf(f, " } else {\n");
- fprintf(f, " cmd->%s = %s;\n", vt->name, vt->name);
- fprintf(f, " }\n");
-
- } else {
- fprintf(f, " cmd->%s = %s;\n", vt->name, vt->name);
- }
- }
- if (api->ret.typeName[0] || api->sync) {
- needFlush = 1;
- }
-
- fprintf(f, " io->coreCommit();\n");
- if (hasInlineDataPointers(api)) {
- fprintf(f, " if (dataSize >= io->getMaxInlineSize()) {\n");
- fprintf(f, " io->coreGetReturn(NULL, 0);\n");
- fprintf(f, " }\n");
- } else if (api->ret.typeName[0]) {
- fprintf(f, "\n ");
- printVarType(f, &api->ret);
- fprintf(f, " ret;\n");
- fprintf(f, " io->coreGetReturn(&ret, sizeof(ret));\n");
- fprintf(f, " return ret;\n");
- } else if (needFlush) {
- fprintf(f, " io->coreGetReturn(NULL, 0);\n");
- }
- }
- fprintf(f, "};\n\n");
-
-
- // Generate a remote sender function
- const char * str = "core";
- if (api->direct) {
- str = "async";
- }
-
- fprintf(f, "static ");
- printFuncDecl(f, api, "RF_", 0, 0);
- fprintf(f, "\n{\n");
- fprintf(f, " ThreadIO *io = &((Context *)rsc)->mIO;\n");
- fprintf(f, " const uint32_t cmdID = RS_CMD_ID_%s;\n", api->name);
- fprintf(f, " io->%sWrite(&cmdID, sizeof(cmdID));\n\n", str);
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if (vt->ptrLevel == 0) {
- fprintf(f, " io->%sWrite(& %s, sizeof(%s));\n", str, vt->name, vt->name);
- }
- }
- fprintf(f, "\n");
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if ((vt->ptrLevel == 1) && (vt->isConst)) {
- fprintf(f, " io->%sWrite(%s, %s_length);\n", str, vt->name, vt->name);
- }
- }
- fprintf(f, "\n");
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if ((vt->ptrLevel == 2) && (vt->isConst)) {
- fprintf(f, " for (size_t ct = 0; ct < (%s_length_length / sizeof(%s_length)); ct++) {\n", vt->name, vt->name);
- fprintf(f, " io->%sWrite(%s[ct], %s_length[ct]);\n", str, vt->name, vt->name);
- fprintf(f, " }\n");
- }
- }
- fprintf(f, "\n");
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if ((vt->ptrLevel == 1) && (!vt->isConst)) {
- fprintf(f, " io->%sGetReturn(%s, %s_length);\n", str, vt->name, vt->name);
- }
- }
- fprintf(f, "\n");
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if ((vt->ptrLevel == 2) && (!vt->isConst)) {
- fprintf(f, " for (size_t ct = 0; ct < (%s_length_length / sizeof(%s_length)); ct++) {\n", vt->name, vt->name);
- fprintf(f, " io->%sGetReturn(%s[ct], %s_length[ct]);\n", str, vt->name, vt->name);
- fprintf(f, " }\n");
- }
- }
- fprintf(f, "\n");
-
- if (api->ret.typeName[0]) {
- fprintf(f, " ");
- printVarType(f, &api->ret);
- fprintf(f, " retValue;\n");
- fprintf(f, " io->%sGetReturn(&retValue, sizeof(retValue));\n", str);
- fprintf(f, " return retValue;\n");
- } else /*if (api->sync)*/ {
- fprintf(f, " io->%sGetReturn(NULL, 0);\n", str);
- }
- fprintf(f, "}\n\n");
- }
-
- fprintf(f, "\n");
- fprintf(f, "static RsApiEntrypoints_t s_LocalTable = {\n");
- for (ct=0; ct < apiCount; ct++) {
- fprintf(f, " LF_%s,\n", apis[ct].name);
- }
- fprintf(f, "};\n");
-
- fprintf(f, "\n");
- fprintf(f, "static RsApiEntrypoints_t s_RemoteTable = {\n");
- for (ct=0; ct < apiCount; ct++) {
- fprintf(f, " RF_%s,\n", apis[ct].name);
- }
- fprintf(f, "};\n");
-
- fprintf(f, "static RsApiEntrypoints_t *s_CurrentTable = &s_LocalTable;\n\n");
- for (ct=0; ct < apiCount; ct++) {
- int needFlush = 0;
- const ApiEntry * api = &apis[ct];
-
- printFuncDecl(f, api, "rs", 0, 0);
- fprintf(f, "\n{\n");
- fprintf(f, " ");
- if (api->ret.typeName[0]) {
- fprintf(f, "return ");
- }
- fprintf(f, "s_CurrentTable->%s(", api->name);
-
- if (!api->nocontext) {
- fprintf(f, "(Context *)rsc");
- }
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if (ct2 > 0 || !api->nocontext) {
- fprintf(f, ", ");
- }
- fprintf(f, "%s", vt->name);
- }
- fprintf(f, ");\n");
- fprintf(f, "}\n\n");
- }
-
-}
-
-void printPlaybackCpp(FILE *f) {
- int ct;
- int ct2;
-
- fprintf(f, "#include \"rsDevice.h\"\n");
- fprintf(f, "#include \"rsContext.h\"\n");
- fprintf(f, "#include \"rsThreadIO.h\"\n");
- fprintf(f, "#include \"rsgApiStructs.h\"\n");
- fprintf(f, "#include \"rsgApiFuncDecl.h\"\n");
- fprintf(f, "\n");
- fprintf(f, "namespace android {\n");
- fprintf(f, "namespace renderscript {\n");
- fprintf(f, "\n");
-
- for (ct=0; ct < apiCount; ct++) {
- const ApiEntry * api = &apis[ct];
- int needFlush = 0;
-
- if (api->direct) {
- continue;
- }
-
- fprintf(f, "void rsp_%s(Context *con, const void *vp, size_t cmdSizeBytes) {\n", api->name);
- fprintf(f, " const RS_CMD_%s *cmd = static_cast<const RS_CMD_%s *>(vp);\n", api->name, api->name);
-
- if (hasInlineDataPointers(api)) {
- fprintf(f, " const uint8_t *baseData = 0;\n");
- fprintf(f, " if (cmdSizeBytes != sizeof(RS_CMD_%s)) {\n", api->name);
- fprintf(f, " baseData = &((const uint8_t *)vp)[sizeof(*cmd)];\n");
- fprintf(f, " }\n");
- }
-
- fprintf(f, " ");
- if (api->ret.typeName[0]) {
- fprintf(f, "\n ");
- printVarType(f, &api->ret);
- fprintf(f, " ret = ");
- }
- fprintf(f, "rsi_%s(con", api->name);
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- needFlush += vt->ptrLevel;
-
- if (hasInlineDataPointers(api) && vt->ptrLevel) {
- fprintf(f, ",\n (const %s *)&baseData[(intptr_t)cmd->%s]", vt->typeName, vt->name);
- } else {
- fprintf(f, ",\n cmd->%s", vt->name);
- }
- }
- fprintf(f, ");\n");
-
- if (hasInlineDataPointers(api)) {
- fprintf(f, " size_t totalSize = 0;\n");
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- if (api->params[ct2].ptrLevel) {
- fprintf(f, " totalSize += cmd->%s_length;\n", api->params[ct2].name);
- }
- }
-
- fprintf(f, " if ((totalSize != 0) && (cmdSizeBytes == sizeof(RS_CMD_%s))) {\n", api->name);
- fprintf(f, " con->mIO.coreSetReturn(NULL, 0);\n");
- fprintf(f, " }\n");
- } else if (api->ret.typeName[0]) {
- fprintf(f, " con->mIO.coreSetReturn(&ret, sizeof(ret));\n");
- } else if (api->sync || needFlush) {
- fprintf(f, " con->mIO.coreSetReturn(NULL, 0);\n");
- }
-
- fprintf(f, "};\n\n");
- }
-
- for (ct=0; ct < apiCount; ct++) {
- const ApiEntry * api = &apis[ct];
- int needFlush = 0;
-
- fprintf(f, "void rspr_%s(Context *con, ThreadIO *io) {\n", api->name);
- fprintf(f, " RS_CMD_%s cmd;\n", api->name);
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if (vt->ptrLevel == 0) {
- fprintf(f, " io->coreRead(&cmd.%s, sizeof(cmd.%s));\n", vt->name, vt->name);
- }
- }
- fprintf(f, "\n");
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if (vt->ptrLevel == 1) {
- fprintf(f, " cmd.%s = (", vt->name);
- printVarType(f, vt);
- fprintf(f, ")malloc(cmd.%s_length);\n", vt->name);
-
- if (vt->isConst) {
- fprintf(f, " if (cmd.%s_length) io->coreRead((void *)cmd.%s, cmd.%s_length);\n", vt->name, vt->name, vt->name);
- }
- }
- }
- fprintf(f, "\n");
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if (vt->ptrLevel == 2) {
- fprintf(f, " for (size_t ct = 0; ct < (cmd.%s_length_length / sizeof(cmd.%s_length)); ct++) {\n", vt->name, vt->name);
- fprintf(f, " cmd.%s = (", vt->name);
- printVarType(f, vt);
- fprintf(f, ")malloc(cmd.%s_length[ct]);\n", vt->name);
- fprintf(f, " io->coreRead(& cmd.%s, cmd.%s_length[ct]);\n", vt->name, vt->name);
- fprintf(f, " }\n");
- }
- }
- fprintf(f, "\n");
-
- if (api->ret.typeName[0]) {
- fprintf(f, " ");
- printVarType(f, &api->ret);
- fprintf(f, " ret =\n");
- }
-
- fprintf(f, " rsi_%s(", api->name);
- if (!api->nocontext) {
- fprintf(f, "con");
- }
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if (ct2 > 0 || !api->nocontext) {
- fprintf(f, ",\n");
- }
- fprintf(f, " cmd.%s", vt->name);
- }
- fprintf(f, ");\n");
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if ((vt->ptrLevel == 1) && (!vt->isConst)) {
- fprintf(f, " io->coreSetReturn((void *)cmd.%s, cmd.%s_length);\n", vt->name, vt->name);
- }
- }
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if ((vt->ptrLevel == 2) && (!vt->isConst)) {
- fprintf(f, " for (size_t ct = 0; ct < (cmd.%s_length_length / sizeof(cmd.%s_length)); ct++) {\n", vt->name, vt->name);
- fprintf(f, " io->coreSetReturn((void *)cmd.%s[ct], cmd.%s_length[ct]);\n", vt->name, vt->name);
- fprintf(f, " }\n");
- }
- }
- fprintf(f, "\n");
-
- if (api->ret.typeName[0]) {
- fprintf(f, " io->coreSetReturn(&ret, sizeof(ret));\n");
- } else /*if (needFlush)*/ {
- fprintf(f, " io->coreSetReturn(NULL, 0);\n");
- }
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if (vt->ptrLevel == 1) {
- fprintf(f, " free((void *)cmd.%s);\n", vt->name);
- }
- }
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if (vt->ptrLevel == 2) {
- fprintf(f, " for (size_t ct = 0; ct < (cmd.%s_length_length / sizeof(cmd.%s_length)); ct++) {\n", vt->name, vt->name);
- fprintf(f, " free((void *)cmd.%s);\n", vt->name);
- fprintf(f, " }\n");
- }
- }
-
- fprintf(f, "};\n\n");
- }
-
- fprintf(f, "RsPlaybackLocalFunc gPlaybackFuncs[%i] = {\n", apiCount + 1);
- fprintf(f, " NULL,\n");
- for (ct=0; ct < apiCount; ct++) {
- if (apis[ct].direct) {
- fprintf(f, " NULL,\n");
- } else {
- fprintf(f, " %s%s,\n", "rsp_", apis[ct].name);
- }
- }
- fprintf(f, "};\n");
-
- fprintf(f, "RsPlaybackRemoteFunc gPlaybackRemoteFuncs[%i] = {\n", apiCount + 1);
- fprintf(f, " NULL,\n");
- for (ct=0; ct < apiCount; ct++) {
- fprintf(f, " %s%s,\n", "rspr_", apis[ct].name);
- }
- fprintf(f, "};\n");
-
- fprintf(f, "};\n");
- fprintf(f, "};\n");
-}
-
-void yylex();
-
-int main(int argc, char **argv) {
- if (argc != 3) {
- fprintf(stderr, "usage: %s commandFile outFile\n", argv[0]);
- return 1;
- }
- const char* rsgFile = argv[1];
- const char* outFile = argv[2];
- FILE* input = fopen(rsgFile, "r");
-
- char choice = fgetc(input);
- fclose(input);
-
- if (choice < '0' || choice > '3') {
- fprintf(stderr, "Uknown command: \'%c\'\n", choice);
- return -2;
- }
-
- yylex();
- // printf("# of lines = %d\n", num_lines);
-
- FILE *f = fopen(outFile, "w");
-
- printFileHeader(f);
- switch (choice) {
- case '0': // rsgApiStructs.h
- {
- fprintf(f, "\n");
- fprintf(f, "#include \"rsContext.h\"\n");
- fprintf(f, "#include \"rsFifo.h\"\n");
- fprintf(f, "\n");
- fprintf(f, "namespace android {\n");
- fprintf(f, "namespace renderscript {\n");
- printStructures(f);
- printFuncDecls(f, "rsi_", 1);
- printPlaybackFuncs(f, "rsp_");
- fprintf(f, "\n\ntypedef struct RsPlaybackRemoteHeaderRec {\n");
- fprintf(f, " uint32_t command;\n");
- fprintf(f, " uint32_t size;\n");
- fprintf(f, "} RsPlaybackRemoteHeader;\n\n");
- fprintf(f, "typedef void (*RsPlaybackLocalFunc)(Context *, const void *, size_t sizeBytes);\n");
- fprintf(f, "typedef void (*RsPlaybackRemoteFunc)(Context *, ThreadIO *);\n");
- fprintf(f, "extern RsPlaybackLocalFunc gPlaybackFuncs[%i];\n", apiCount + 1);
- fprintf(f, "extern RsPlaybackRemoteFunc gPlaybackRemoteFuncs[%i];\n", apiCount + 1);
-
- fprintf(f, "}\n");
- fprintf(f, "}\n");
- }
- break;
-
- case '1': // rsgApiFuncDecl.h
- {
- printFuncDecls(f, "rs", 0);
- }
- break;
-
- case '2': // rsgApi.cpp
- {
- printApiCpp(f);
- }
- break;
-
- case '3': // rsgApiReplay.cpp
- {
- printFileHeader(f);
- printPlaybackCpp(f);
- }
- break;
-
- case '4': // rsgApiStream.cpp
- {
- printFileHeader(f);
- printPlaybackCpp(f);
- }
-
- case '5': // rsgApiStreamReplay.cpp
- {
- printFileHeader(f);
- printPlaybackCpp(f);
- }
- break;
- }
- fclose(f);
- return 0;
-}
diff --git a/renderscript/v8/rs_support/scriptc/rs_allocation.rsh b/renderscript/v8/rs_support/scriptc/rs_allocation.rsh
deleted file mode 100644
index 42d27bc..0000000
--- a/renderscript/v8/rs_support/scriptc/rs_allocation.rsh
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** @file rs_allocation.rsh
- * \brief Allocation routines
- *
- *
- */
-
-#ifndef __RS_ALLOCATION_RSH__
-#define __RS_ALLOCATION_RSH__
-
-/**
- * Returns the Allocation for a given pointer. The pointer should point within
- * a valid allocation. The results are undefined if the pointer is not from a
- * valid allocation.
- *
- * This function is deprecated and will be removed in the SDK from a future
- * release.
- */
-extern rs_allocation __attribute__((overloadable))
- rsGetAllocation(const void *);
-
-/**
- * Query the dimension of an allocation.
- *
- * @return uint32_t The X dimension of the allocation.
- */
-extern uint32_t __attribute__((overloadable))
- rsAllocationGetDimX(rs_allocation);
-
-/**
- * Query the dimension of an allocation.
- *
- * @return uint32_t The Y dimension of the allocation.
- */
-extern uint32_t __attribute__((overloadable))
- rsAllocationGetDimY(rs_allocation);
-
-/**
- * Query the dimension of an allocation.
- *
- * @return uint32_t The Z dimension of the allocation.
- */
-extern uint32_t __attribute__((overloadable))
- rsAllocationGetDimZ(rs_allocation);
-
-/**
- * Query an allocation for the presence of more than one LOD.
- *
- * @return uint32_t Returns 1 if more than one LOD is present, 0 otherwise.
- */
-extern uint32_t __attribute__((overloadable))
- rsAllocationGetDimLOD(rs_allocation);
-
-/**
- * Query an allocation for the presence of more than one face.
- *
- * @return uint32_t Returns 1 if more than one face is present, 0 otherwise.
- */
-extern uint32_t __attribute__((overloadable))
- rsAllocationGetDimFaces(rs_allocation);
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 14))
-
-/**
- * Copy part of an allocation from another allocation.
- *
- * @param dstAlloc Allocation to copy data into.
- * @param dstOff The offset of the first element to be copied in
- * the destination allocation.
- * @param dstMip Mip level in the destination allocation.
- * @param count The number of elements to be copied.
- * @param srcAlloc The source data allocation.
- * @param srcOff The offset of the first element in data to be
- * copied in the source allocation.
- * @param srcMip Mip level in the source allocation.
- */
-extern void __attribute__((overloadable))
- rsAllocationCopy1DRange(rs_allocation dstAlloc,
- uint32_t dstOff, uint32_t dstMip,
- uint32_t count,
- rs_allocation srcAlloc,
- uint32_t srcOff, uint32_t srcMip);
-
-/**
- * Copy a rectangular region into the allocation from another
- * allocation.
- *
- * @param dstAlloc allocation to copy data into.
- * @param dstXoff X offset of the region to update in the
- * destination allocation.
- * @param dstYoff Y offset of the region to update in the
- * destination allocation.
- * @param dstMip Mip level in the destination allocation.
- * @param dstFace Cubemap face of the destination allocation,
- * ignored for allocations that aren't cubemaps.
- * @param width Width of the incoming region to update.
- * @param height Height of the incoming region to update.
- * @param srcAlloc The source data allocation.
- * @param srcXoff X offset in data of the source allocation.
- * @param srcYoff Y offset in data of the source allocation.
- * @param srcMip Mip level in the source allocation.
- * @param srcFace Cubemap face of the source allocation,
- * ignored for allocations that aren't cubemaps.
- */
-extern void __attribute__((overloadable))
- rsAllocationCopy2DRange(rs_allocation dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff,
- uint32_t dstMip,
- rs_allocation_cubemap_face dstFace,
- uint32_t width, uint32_t height,
- rs_allocation srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff,
- uint32_t srcMip,
- rs_allocation_cubemap_face srcFace);
-
-#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
-
-/**
- * Extract a single element from an allocation.
- */
-extern const void * __attribute__((overloadable))
- rsGetElementAt(rs_allocation, uint32_t x);
-/**
- * \overload
- */
-extern const void * __attribute__((overloadable))
- rsGetElementAt(rs_allocation, uint32_t x, uint32_t y);
-/**
- * \overload
- */
-extern const void * __attribute__((overloadable))
- rsGetElementAt(rs_allocation, uint32_t x, uint32_t y, uint32_t z);
-
-
-#define GET_ELEMENT_AT(T) \
-static inline T __attribute__((overloadable)) \
- rsGetElementAt_##T(rs_allocation a, uint32_t x) { \
- return ((T *)rsGetElementAt(a, x))[0]; \
-} \
-static inline T __attribute__((overloadable)) \
- rsGetElementAt_##T(rs_allocation a, uint32_t x, uint32_t y) { \
- return ((T *)rsGetElementAt(a, x, y))[0]; \
-} \
-static inline T __attribute__((overloadable)) \
- rsGetElementAt_##T(rs_allocation a, uint32_t x, uint32_t y, uint32_t z) { \
- return ((T *)rsGetElementAt(a, x, y, z))[0]; \
-}
-
-GET_ELEMENT_AT(char)
-GET_ELEMENT_AT(char2)
-GET_ELEMENT_AT(char3)
-GET_ELEMENT_AT(char4)
-GET_ELEMENT_AT(uchar)
-GET_ELEMENT_AT(uchar2)
-GET_ELEMENT_AT(uchar3)
-GET_ELEMENT_AT(uchar4)
-GET_ELEMENT_AT(short)
-GET_ELEMENT_AT(short2)
-GET_ELEMENT_AT(short3)
-GET_ELEMENT_AT(short4)
-GET_ELEMENT_AT(ushort)
-GET_ELEMENT_AT(ushort2)
-GET_ELEMENT_AT(ushort3)
-GET_ELEMENT_AT(ushort4)
-GET_ELEMENT_AT(int)
-GET_ELEMENT_AT(int2)
-GET_ELEMENT_AT(int3)
-GET_ELEMENT_AT(int4)
-GET_ELEMENT_AT(uint)
-GET_ELEMENT_AT(uint2)
-GET_ELEMENT_AT(uint3)
-GET_ELEMENT_AT(uint4)
-GET_ELEMENT_AT(long)
-GET_ELEMENT_AT(long2)
-GET_ELEMENT_AT(long3)
-GET_ELEMENT_AT(long4)
-GET_ELEMENT_AT(ulong)
-GET_ELEMENT_AT(ulong2)
-GET_ELEMENT_AT(ulong3)
-GET_ELEMENT_AT(ulong4)
-GET_ELEMENT_AT(float)
-GET_ELEMENT_AT(float2)
-GET_ELEMENT_AT(float3)
-GET_ELEMENT_AT(float4)
-GET_ELEMENT_AT(double)
-GET_ELEMENT_AT(double2)
-GET_ELEMENT_AT(double3)
-GET_ELEMENT_AT(double4)
-
-#undef GET_ELEMENT_AT
-
-// New API's
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-/**
- * Send the contents of the Allocation to the queue.
- * @param a allocation to work on
- */
-extern const void __attribute__((overloadable))
- rsAllocationIoSend(rs_allocation a);
-
-/**
- * Receive a new set of contents from the queue.
- * @param a allocation to work on
- */
-extern const void __attribute__((overloadable))
- rsAllocationIoReceive(rs_allocation a);
-
-
-/**
- * Get the element object describing the allocation's layout
- * @param a allocation to get data from
- * @return element describing allocation layout
- */
-extern rs_element __attribute__((overloadable))
- rsAllocationGetElement(rs_allocation a);
-
-/**
- * Fetch allocation in a way described by the sampler
- * @param a 1D allocation to sample from
- * @param s sampler state
- * @param location to sample from
- */
-extern const float4 __attribute__((overloadable))
- rsSample(rs_allocation a, rs_sampler s, float location);
-/**
- * Fetch allocation in a way described by the sampler
- * @param a 1D allocation to sample from
- * @param s sampler state
- * @param location to sample from
- * @param lod mip level to sample from, for fractional values
- * mip levels will be interpolated if
- * RS_SAMPLER_LINEAR_MIP_LINEAR is used
- */
-extern const float4 __attribute__((overloadable))
- rsSample(rs_allocation a, rs_sampler s, float location, float lod);
-
-/**
- * Fetch allocation in a way described by the sampler
- * @param a 2D allocation to sample from
- * @param s sampler state
- * @param location to sample from
- */
-extern const float4 __attribute__((overloadable))
- rsSample(rs_allocation a, rs_sampler s, float2 location);
-
-/**
- * Fetch allocation in a way described by the sampler
- * @param a 2D allocation to sample from
- * @param s sampler state
- * @param location to sample from
- * @param lod mip level to sample from, for fractional values
- * mip levels will be interpolated if
- * RS_SAMPLER_LINEAR_MIP_LINEAR is used
- */
-extern const float4 __attribute__((overloadable))
- rsSample(rs_allocation a, rs_sampler s, float2 location, float lod);
-
-#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-#endif
-
diff --git a/renderscript/v8/rs_support/scriptc/rs_atomic.rsh b/renderscript/v8/rs_support/scriptc/rs_atomic.rsh
deleted file mode 100644
index a455edd..0000000
--- a/renderscript/v8/rs_support/scriptc/rs_atomic.rsh
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** @file rs_atomic.rsh
- * \brief Atomic routines
- *
- *
- */
-
-#ifndef __RS_ATOMIC_RSH__
-#define __RS_ATOMIC_RSH__
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 14))
-
-/**
- * Atomic add one to the value at addr.
- * Equal to rsAtomicAdd(addr, 1)
- *
- * @param addr Address of value to increment
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
- rsAtomicInc(volatile int32_t* addr);
-/**
- * Atomic add one to the value at addr.
- * Equal to rsAtomicAdd(addr, 1)
- *
- * @param addr Address of value to increment
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
- rsAtomicInc(volatile uint32_t* addr);
-
-/**
- * Atomic subtract one from the value at addr. Equal to rsAtomicSub(addr, 1)
- *
- * @param addr Address of value to decrement
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
- rsAtomicDec(volatile int32_t* addr);
-/**
- * Atomic subtract one from the value at addr. Equal to rsAtomicSub(addr, 1)
- *
- * @param addr Address of value to decrement
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
- rsAtomicDec(volatile uint32_t* addr);
-
-/**
- * Atomic add a value to the value at addr. addr[0] += value
- *
- * @param addr Address of value to modify
- * @param value Amount to add to the value at addr
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
- rsAtomicAdd(volatile int32_t* addr, int32_t value);
-/**
- * Atomic add a value to the value at addr. addr[0] += value
- *
- * @param addr Address of value to modify
- * @param value Amount to add to the value at addr
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
- rsAtomicAdd(volatile uint32_t* addr, uint32_t value);
-
-/**
- * Atomic Subtract a value from the value at addr. addr[0] -= value
- *
- * @param addr Address of value to modify
- * @param value Amount to subtract from the value at addr
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
- rsAtomicSub(volatile int32_t* addr, int32_t value);
-/**
- * Atomic Subtract a value from the value at addr. addr[0] -= value
- *
- * @param addr Address of value to modify
- * @param value Amount to subtract from the value at addr
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
- rsAtomicSub(volatile uint32_t* addr, uint32_t value);
-
-/**
- * Atomic Bitwise and a value from the value at addr. addr[0] &= value
- *
- * @param addr Address of value to modify
- * @param value Amount to and with the value at addr
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
- rsAtomicAnd(volatile int32_t* addr, int32_t value);
-/**
- * Atomic Bitwise and a value from the value at addr. addr[0] &= value
- *
- * @param addr Address of value to modify
- * @param value Amount to and with the value at addr
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
- rsAtomicAnd(volatile uint32_t* addr, uint32_t value);
-
-/**
- * Atomic Bitwise or a value from the value at addr. addr[0] |= value
- *
- * @param addr Address of value to modify
- * @param value Amount to or with the value at addr
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
- rsAtomicOr(volatile int32_t* addr, int32_t value);
-/**
- * Atomic Bitwise or a value from the value at addr. addr[0] |= value
- *
- * @param addr Address of value to modify
- * @param value Amount to or with the value at addr
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
- rsAtomicOr(volatile uint32_t* addr, uint32_t value);
-
-/**
- * Atomic Bitwise xor a value from the value at addr. addr[0] ^= value
- *
- * @param addr Address of value to modify
- * @param value Amount to xor with the value at addr
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
- rsAtomicXor(volatile uint32_t* addr, uint32_t value);
-/**
- * Atomic Bitwise xor a value from the value at addr. addr[0] ^= value
- *
- * @param addr Address of value to modify
- * @param value Amount to xor with the value at addr
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
- rsAtomicXor(volatile int32_t* addr, int32_t value);
-
-/**
- * Atomic Set the value at addr to the min of addr and value
- * addr[0] = rsMin(addr[0], value)
- *
- * @param addr Address of value to modify
- * @param value comparison value
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
- rsAtomicMin(volatile uint32_t* addr, uint32_t value);
-/**
- * Atomic Set the value at addr to the min of addr and value
- * addr[0] = rsMin(addr[0], value)
- *
- * @param addr Address of value to modify
- * @param value comparison value
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
- rsAtomicMin(volatile int32_t* addr, int32_t value);
-
-/**
- * Atomic Set the value at addr to the max of addr and value
- * addr[0] = rsMax(addr[0], value)
- *
- * @param addr Address of value to modify
- * @param value comparison value
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
- rsAtomicMax(volatile uint32_t* addr, uint32_t value);
-/**
- * Atomic Set the value at addr to the max of addr and value
- * addr[0] = rsMin(addr[0], value)
- *
- * @param addr Address of value to modify
- * @param value comparison value
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
- rsAtomicMax(volatile int32_t* addr, int32_t value);
-
-/**
- * Compare-and-set operation with a full memory barrier.
- *
- * If the value at addr matches compareValue then newValue is written.
- *
- * @param addr The address to compare and replace if the compare passes.
- * @param compareValue The value to test addr[0] against.
- * @param newValue The value to write if the test passes.
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
- rsAtomicCas(volatile int32_t* addr, int32_t compareValue, int32_t newValue);
-
-/**
- * Compare-and-set operation with a full memory barrier.
- *
- * If the value at addr matches compareValue then newValue is written.
- *
- * @param addr The address to compare and replace if the compare passes.
- * @param compareValue The value to test addr[0] against.
- * @param newValue The value to write if the test passes.
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
- rsAtomicCas(volatile uint32_t* addr, uint32_t compareValue, uint32_t newValue);
-
-#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
-
-#endif
-
diff --git a/renderscript/v8/rs_support/scriptc/rs_cl.rsh b/renderscript/v8/rs_support/scriptc/rs_cl.rsh
deleted file mode 100644
index 74f0ad9..0000000
--- a/renderscript/v8/rs_support/scriptc/rs_cl.rsh
+++ /dev/null
@@ -1,985 +0,0 @@
-/*
- * Copyright (C) 2011-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** @file rs_cl.rsh
- * \brief Basic math functions
- *
- *
- */
-
-#ifndef __RS_CL_RSH__
-#define __RS_CL_RSH__
-
-// Conversions
-#define CVT_FUNC_2(typeout, typein) \
-_RS_RUNTIME typeout##2 __attribute__((overloadable)) \
- convert_##typeout##2(typein##2 v); \
-_RS_RUNTIME typeout##3 __attribute__((overloadable)) \
- convert_##typeout##3(typein##3 v); \
-_RS_RUNTIME typeout##4 __attribute__((overloadable)) \
- convert_##typeout##4(typein##4 v);
-
-
-#define CVT_FUNC(type) CVT_FUNC_2(type, uchar) \
- CVT_FUNC_2(type, char) \
- CVT_FUNC_2(type, ushort) \
- CVT_FUNC_2(type, short) \
- CVT_FUNC_2(type, uint) \
- CVT_FUNC_2(type, int) \
- CVT_FUNC_2(type, float)
-
-/**
- * Convert to char.
- *
- * Supports 2,3,4 components of uchar, char, ushort, short, uint, int, float.
- */
-CVT_FUNC(char)
-
-/**
- * Convert to unsigned char.
- *
- * Supports 2,3,4 components of uchar, char, ushort, short, uint, int, float.
- */
-CVT_FUNC(uchar)
-
-/**
- * Convert to short.
- *
- * Supports 2,3,4 components of uchar, char, ushort, short, uint, int, float.
- */
-CVT_FUNC(short)
-
-/**
- * Convert to unsigned short.
- *
- * Supports 2,3,4 components of uchar, char, ushort, short, uint, int, float.
- */
-CVT_FUNC(ushort)
-
-/**
- * Convert to int.
- *
- * Supports 2,3,4 components of uchar, char, ushort, short, uint, int, float.
- */
-CVT_FUNC(int)
-
-/**
- * Convert to unsigned int.
- *
- * Supports 2,3,4 components of uchar, char, ushort, short, uint, int, float.
- */
-CVT_FUNC(uint)
-
-/**
- * Convert to float.
- *
- * Supports 2,3,4 components of uchar, char, ushort, short, uint, int, float.
- */
-CVT_FUNC(float)
-
-// Float ops, 6.11.2
-
-#define FN_FUNC_FN(fnc) \
-_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v); \
-_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v); \
-_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v);
-
-#define F_FUNC_FN(fnc) \
-_RS_RUNTIME float __attribute__((overloadable)) fnc(float2 v); \
-_RS_RUNTIME float __attribute__((overloadable)) fnc(float3 v); \
-_RS_RUNTIME float __attribute__((overloadable)) fnc(float4 v);
-
-#define IN_FUNC_FN(fnc) \
-_RS_RUNTIME int2 __attribute__((overloadable)) fnc(float2 v); \
-_RS_RUNTIME int3 __attribute__((overloadable)) fnc(float3 v); \
-_RS_RUNTIME int4 __attribute__((overloadable)) fnc(float4 v);
-
-#define FN_FUNC_FN_FN(fnc) \
-_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, float2 v2); \
-_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, float3 v2); \
-_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, float4 v2);
-
-#define F_FUNC_FN_FN(fnc) \
-_RS_RUNTIME float __attribute__((overloadable)) fnc(float2 v1, float2 v2); \
-_RS_RUNTIME float __attribute__((overloadable)) fnc(float3 v1, float3 v2); \
-_RS_RUNTIME float __attribute__((overloadable)) fnc(float4 v1, float4 v2);
-
-#define FN_FUNC_FN_F(fnc) \
-_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, float v2); \
-_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, float v2); \
-_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, float v2);
-
-#define FN_FUNC_FN_IN(fnc) \
-_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, int2 v2); \
-_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, int3 v2); \
-_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, int4 v2); \
-
-#define FN_FUNC_FN_I(fnc) \
-_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, int v2); \
-_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, int v2); \
-_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, int v2);
-
-#define FN_FUNC_FN_PFN(fnc) \
-_RS_RUNTIME float2 __attribute__((overloadable)) \
- fnc(float2 v1, float2 *v2); \
-_RS_RUNTIME float3 __attribute__((overloadable)) \
- fnc(float3 v1, float3 *v2); \
-_RS_RUNTIME float4 __attribute__((overloadable)) \
- fnc(float4 v1, float4 *v2);
-
-#define FN_FUNC_FN_PIN(fnc) \
-_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, int2 *v2); \
-_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, int3 *v2); \
-_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, int4 *v2);
-
-#define FN_FUNC_FN_FN_FN(fnc) \
-_RS_RUNTIME float2 __attribute__((overloadable)) \
- fnc(float2 v1, float2 v2, float2 v3); \
-_RS_RUNTIME float3 __attribute__((overloadable)) \
- fnc(float3 v1, float3 v2, float3 v3); \
-_RS_RUNTIME float4 __attribute__((overloadable)) \
- fnc(float4 v1, float4 v2, float4 v3);
-
-#define FN_FUNC_FN_FN_F(fnc) \
-_RS_RUNTIME float2 __attribute__((overloadable)) \
- fnc(float2 v1, float2 v2, float v3); \
-_RS_RUNTIME float3 __attribute__((overloadable)) \
- fnc(float3 v1, float3 v2, float v3); \
-_RS_RUNTIME float4 __attribute__((overloadable)) \
- fnc(float4 v1, float4 v2, float v3);
-
-#define FN_FUNC_FN_F_F(fnc) \
-_RS_RUNTIME float2 __attribute__((overloadable)) \
- fnc(float2 v1, float v2, float v3); \
-_RS_RUNTIME float3 __attribute__((overloadable)) \
- fnc(float3 v1, float v2, float v3); \
-_RS_RUNTIME float4 __attribute__((overloadable)) \
- fnc(float4 v1, float v2, float v3);
-
-#define FN_FUNC_FN_FN_PIN(fnc) \
-_RS_RUNTIME float2 __attribute__((overloadable)) \
- fnc(float2 v1, float2 v2, int2 *v3); \
-_RS_RUNTIME float3 __attribute__((overloadable)) \
- fnc(float3 v1, float3 v2, int3 *v3); \
-_RS_RUNTIME float4 __attribute__((overloadable)) \
- fnc(float4 v1, float4 v2, int4 *v3);
-
-
-/**
- * Return the inverse cosine.
- *
- * Supports float, float2, float3, float4
- */
-extern float __attribute__((overloadable)) acos(float);
-FN_FUNC_FN(acos)
-
-/**
- * Return the inverse hyperbolic cosine.
- *
- * Supports float, float2, float3, float4
- */
-extern float __attribute__((overloadable)) acosh(float);
-FN_FUNC_FN(acosh)
-
-/**
- * Return the inverse cosine divided by PI.
- *
- * Supports float, float2, float3, float4
- */
-_RS_RUNTIME float __attribute__((overloadable)) acospi(float v);
-FN_FUNC_FN(acospi)
-
-/**
- * Return the inverse sine.
- *
- * Supports float, float2, float3, float4
- */
-extern float __attribute__((overloadable)) asin(float);
-FN_FUNC_FN(asin)
-
-/**
- * Return the inverse hyperbolic sine.
- *
- * Supports float, float2, float3, float4
- */
-extern float __attribute__((overloadable)) asinh(float);
-FN_FUNC_FN(asinh)
-
-
-/**
- * Return the inverse sine divided by PI.
- *
- * Supports float, float2, float3, float4
- */
-_RS_RUNTIME float __attribute__((overloadable)) asinpi(float v);
-FN_FUNC_FN(asinpi)
-
-/**
- * Return the inverse tangent.
- *
- * Supports float, float2, float3, float4
- */
-extern float __attribute__((overloadable)) atan(float);
-FN_FUNC_FN(atan)
-
-/**
- * Return the inverse tangent of y / x.
- *
- * Supports float, float2, float3, float4. Both arguments must be of the same
- * type.
- *
- * @param y
- * @param x
- */
-extern float __attribute__((overloadable)) atan2(float y, float x);
-FN_FUNC_FN_FN(atan2)
-
-/**
- * Return the inverse hyperbolic tangent.
- *
- * Supports float, float2, float3, float4
- */
-extern float __attribute__((overloadable)) atanh(float);
-FN_FUNC_FN(atanh)
-
-/**
- * Return the inverse tangent divided by PI.
- *
- * Supports float, float2, float3, float4
- */
-_RS_RUNTIME float __attribute__((overloadable)) atanpi(float v);
-FN_FUNC_FN(atanpi)
-
-/**
- * Return the inverse tangent of y / x, divided by PI.
- *
- * Supports float, float2, float3, float4. Both arguments must be of the same
- * type.
- *
- * @param y
- * @param x
- */
-_RS_RUNTIME float __attribute__((overloadable)) atan2pi(float y, float x);
-FN_FUNC_FN_FN(atan2pi)
-
-
-/**
- * Return the cube root.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) cbrt(float);
-FN_FUNC_FN(cbrt)
-
-/**
- * Return the smallest integer not less than a value.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) ceil(float);
-FN_FUNC_FN(ceil)
-
-/**
- * Copy the sign bit from y to x.
- *
- * Supports float, float2, float3, float4. Both arguments must be of the same
- * type.
- *
- * @param x
- * @param y
- */
-extern float __attribute__((overloadable)) copysign(float x, float y);
-FN_FUNC_FN_FN(copysign)
-
-/**
- * Return the cosine.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) cos(float);
-FN_FUNC_FN(cos)
-
-/**
- * Return the hypebolic cosine.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) cosh(float);
-FN_FUNC_FN(cosh)
-
-/**
- * Return the cosine of the value * PI.
- *
- * Supports float, float2, float3, float4.
- */
-_RS_RUNTIME float __attribute__((overloadable)) cospi(float v);
-FN_FUNC_FN(cospi)
-
-/**
- * Return the complementary error function.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) erfc(float);
-FN_FUNC_FN(erfc)
-
-/**
- * Return the error function.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) erf(float);
-FN_FUNC_FN(erf)
-
-/**
- * Return e ^ value.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) exp(float);
-FN_FUNC_FN(exp)
-
-/**
- * Return 2 ^ value.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) exp2(float);
-FN_FUNC_FN(exp2)
-
-/**
- * Return x ^ y.
- *
- * Supports float, float2, float3, float4. Both arguments must be of the same
- * type.
- */
-extern float __attribute__((overloadable)) pow(float x, float y);
-FN_FUNC_FN_FN(pow)
-
-/**
- * Return 10 ^ value.
- *
- * Supports float, float2, float3, float4.
- */
-_RS_RUNTIME float __attribute__((overloadable)) exp10(float v);
-FN_FUNC_FN(exp10)
-
-/**
- * Return (e ^ value) - 1.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) expm1(float);
-FN_FUNC_FN(expm1)
-
-/**
- * Return the absolute value of a value.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) fabs(float);
-FN_FUNC_FN(fabs)
-
-/**
- * Return the positive difference between two values.
- *
- * Supports float, float2, float3, float4. Both arguments must be of the same
- * type.
- */
-extern float __attribute__((overloadable)) fdim(float, float);
-FN_FUNC_FN_FN(fdim)
-
-/**
- * Return the smallest integer not greater than a value.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) floor(float);
-FN_FUNC_FN(floor)
-
-/**
- * Return a*b + c.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) fma(float a, float b, float c);
-FN_FUNC_FN_FN_FN(fma)
-
-/**
- * Return (x < y ? y : x)
- *
- * Supports float, float2, float3, float4.
- * @param x: may be float, float2, float3, float4
- * @param y: may be float or vector. If vector must match type of x.
- */
-extern float __attribute__((overloadable)) fmax(float x, float y);
-FN_FUNC_FN_FN(fmax);
-FN_FUNC_FN_F(fmax);
-
-/**
- * Return (x > y ? y : x)
- *
- * @param x: may be float, float2, float3, float4
- * @param y: may be float or vector. If vector must match type of x.
- */
-extern float __attribute__((overloadable)) fmin(float x, float y);
-FN_FUNC_FN_FN(fmin);
-FN_FUNC_FN_F(fmin);
-
-/**
- * Return the remainder from x / y
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) fmod(float x, float y);
-FN_FUNC_FN_FN(fmod)
-
-
-/**
- * Return fractional part of v
- *
- * @param iptr iptr[0] will be set to the floor of the input value.
- * Supports float, float2, float3, float4.
- */
-_RS_RUNTIME float __attribute__((overloadable)) fract(float v, float *iptr);
-FN_FUNC_FN_PFN(fract)
-
-/**
- * Return the mantissa and place the exponent into iptr[0]
- *
- * @param v Supports float, float2, float3, float4.
- * @param iptr Must have the same vector size as v.
- */
-extern float __attribute__((overloadable)) frexp(float v, int *iptr);
-FN_FUNC_FN_PIN(frexp)
-
-/**
- * Return sqrt(x*x + y*y)
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) hypot(float x, float y);
-FN_FUNC_FN_FN(hypot)
-
-/**
- * Return the integer exponent of a value
- *
- * Supports 1,2,3,4 components
- */
-extern int __attribute__((overloadable)) ilogb(float);
-IN_FUNC_FN(ilogb)
-
-/**
- * Return (x * 2^y)
- *
- * @param x Supports 1,2,3,4 components
- * @param y Supports single component or matching vector.
- */
-extern float __attribute__((overloadable)) ldexp(float x, int y);
-FN_FUNC_FN_IN(ldexp)
-FN_FUNC_FN_I(ldexp)
-
-/**
- * Return the log gamma
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) lgamma(float);
-FN_FUNC_FN(lgamma)
-
-/**
- * Return the log gamma and sign
- *
- * @param x Supports 1,2,3,4 components
- * @param y Supports matching vector.
- */
-extern float __attribute__((overloadable)) lgamma(float x, int* y);
-FN_FUNC_FN_PIN(lgamma)
-
-/**
- * Return the natural logarithm
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) log(float);
-FN_FUNC_FN(log)
-
-/**
- * Return the base 10 logarithm
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) log10(float);
-FN_FUNC_FN(log10)
-
-/**
- * Return the base 2 logarithm
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) log2(float v);
-FN_FUNC_FN(log2)
-
-/**
- * Return the natural logarithm of (v + 1.0f)
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) log1p(float v);
-FN_FUNC_FN(log1p)
-
-/**
- * Compute the exponent of the value.
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) logb(float);
-FN_FUNC_FN(logb)
-
-/**
- * Compute (a * b) + c
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) mad(float a, float b, float c);
-FN_FUNC_FN_FN_FN(mad)
-
-/**
- * Return the integral and fractional components of a number.
- * Supports 1,2,3,4 components
- *
- * @param x Source value
- * @param iret iret[0] will be set to the integral portion of the number.
- * @return The floating point portion of the value.
- */
-extern float __attribute__((overloadable)) modf(float x, float *iret);
-FN_FUNC_FN_PFN(modf);
-
-extern float __attribute__((overloadable)) nan(uint);
-
-/**
- * Return the next floating point number from x towards y.
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) nextafter(float x, float y);
-FN_FUNC_FN_FN(nextafter)
-
-/**
- * Return (v ^ p).
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) pown(float v, int p);
-FN_FUNC_FN_IN(pown)
-
-/**
- * Return (v ^ p).
- * @param v must be greater than 0.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) powr(float v, float p);
-FN_FUNC_FN_FN(powr)
-
-/**
- * Return round x/y to the nearest integer then compute the remander.
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) remainder(float x, float y);
-FN_FUNC_FN_FN(remainder)
-
-// document once we know the precision of bionic
-extern float __attribute__((overloadable)) remquo(float, float, int *);
-FN_FUNC_FN_FN_PIN(remquo)
-
-/**
- * Round to the nearest integral value.
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) rint(float);
-FN_FUNC_FN(rint)
-
-/**
- * Compute the Nth root of a value.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) rootn(float v, int n);
-FN_FUNC_FN_IN(rootn)
-
-/**
- * Round to the nearest integral value. Half values are rounded away from zero.
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) round(float);
-FN_FUNC_FN(round)
-
-/**
- * Return the square root of a value.
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) sqrt(float);
-FN_FUNC_FN(sqrt)
-
-/**
- * Return (1 / sqrt(value)).
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) rsqrt(float v);
-FN_FUNC_FN(rsqrt)
-
-/**
- * Return the sine of a value specified in radians.
- *
- * @param v The incoming value in radians
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) sin(float v);
-FN_FUNC_FN(sin)
-
-/**
- * Return the sine and cosine of a value.
- *
- * @return sine
- * @param v The incoming value in radians
- * @param *cosptr cosptr[0] will be set to the cosine value.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) sincos(float v, float *cosptr);
-FN_FUNC_FN_PFN(sincos);
-
-/**
- * Return the hyperbolic sine of a value specified in radians.
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) sinh(float);
-FN_FUNC_FN(sinh)
-
-/**
- * Return the sin(v * PI).
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) sinpi(float v);
-FN_FUNC_FN(sinpi)
-
-/**
- * Return the tangent of a value.
- *
- * Supports 1,2,3,4 components
- * @param v The incoming value in radians
- */
-extern float __attribute__((overloadable)) tan(float v);
-FN_FUNC_FN(tan)
-
-/**
- * Return the hyperbolic tangent of a value.
- *
- * Supports 1,2,3,4 components
- * @param v The incoming value in radians
- */
-extern float __attribute__((overloadable)) tanh(float);
-FN_FUNC_FN(tanh)
-
-/**
- * Return tan(v * PI)
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) tanpi(float v);
-FN_FUNC_FN(tanpi)
-
-/**
- * Compute the gamma function of a value.
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) tgamma(float);
-FN_FUNC_FN(tgamma)
-
-/**
- * Round to integral using truncation.
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) trunc(float);
-FN_FUNC_FN(trunc)
-
-
-#define XN_FUNC_YN(typeout, fnc, typein) \
-extern typeout __attribute__((overloadable)) fnc(typein); \
-_RS_RUNTIME typeout##2 __attribute__((overloadable)) fnc(typein##2 v); \
-_RS_RUNTIME typeout##3 __attribute__((overloadable)) fnc(typein##3 v); \
-_RS_RUNTIME typeout##4 __attribute__((overloadable)) fnc(typein##4 v);
-
-#define UIN_FUNC_IN(fnc) \
-XN_FUNC_YN(uchar, fnc, char) \
-XN_FUNC_YN(ushort, fnc, short) \
-XN_FUNC_YN(uint, fnc, int)
-
-#define IN_FUNC_IN(fnc) \
-XN_FUNC_YN(uchar, fnc, uchar) \
-XN_FUNC_YN(char, fnc, char) \
-XN_FUNC_YN(ushort, fnc, ushort) \
-XN_FUNC_YN(short, fnc, short) \
-XN_FUNC_YN(uint, fnc, uint) \
-XN_FUNC_YN(int, fnc, int)
-
-
-#define XN_FUNC_XN_XN_BODY(type, fnc, body) \
-_RS_RUNTIME type __attribute__((overloadable)) \
- fnc(type v1, type v2); \
-_RS_RUNTIME type##2 __attribute__((overloadable)) \
- fnc(type##2 v1, type##2 v2); \
-_RS_RUNTIME type##3 __attribute__((overloadable)) \
- fnc(type##3 v1, type##3 v2); \
-_RS_RUNTIME type##4 __attribute__((overloadable)) \
- fnc(type##4 v1, type##4 v2);
-
-#define IN_FUNC_IN_IN_BODY(fnc, body) \
-XN_FUNC_XN_XN_BODY(uchar, fnc, body) \
-XN_FUNC_XN_XN_BODY(char, fnc, body) \
-XN_FUNC_XN_XN_BODY(ushort, fnc, body) \
-XN_FUNC_XN_XN_BODY(short, fnc, body) \
-XN_FUNC_XN_XN_BODY(uint, fnc, body) \
-XN_FUNC_XN_XN_BODY(int, fnc, body) \
-XN_FUNC_XN_XN_BODY(float, fnc, body)
-
-/**
- * Return the absolute value of a value.
- *
- * Supports 1,2,3,4 components of char, short, int.
- */
-UIN_FUNC_IN(abs)
-
-/**
- * Return the number of leading 0-bits in a value.
- *
- * Supports 1,2,3,4 components of uchar, char, ushort, short, uint, int.
- */
-IN_FUNC_IN(clz)
-
-/**
- * Return the minimum of two values.
- *
- * Supports 1,2,3,4 components of uchar, char, ushort, short, uint, int, float.
- */
-IN_FUNC_IN_IN_BODY(min, (v1 < v2 ? v1 : v2))
-FN_FUNC_FN_F(min)
-
-/**
- * Return the maximum of two values.
- *
- * Supports 1,2,3,4 components of uchar, char, ushort, short, uint, int, float.
- */
-IN_FUNC_IN_IN_BODY(max, (v1 > v2 ? v1 : v2))
-FN_FUNC_FN_F(max)
-
-/**
- * Clamp a value to a specified high and low bound.
- *
- * @param amount value to be clamped. Supports 1,2,3,4 components
- * @param low Lower bound, must be scalar or matching vector.
- * @param high High bound, must match type of low
- */
-_RS_RUNTIME float __attribute__((overloadable)) clamp(float amount, float low, float high);
-FN_FUNC_FN_FN_FN(clamp)
-FN_FUNC_FN_F_F(clamp)
-
-/**
- * Convert from radians to degrees.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) degrees(float radians);
-FN_FUNC_FN(degrees)
-
-/**
- * return start + ((stop - start) * amount);
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) mix(float start, float stop, float amount);
-FN_FUNC_FN_FN_FN(mix)
-FN_FUNC_FN_FN_F(mix)
-
-/**
- * Convert from degrees to radians.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) radians(float degrees);
-FN_FUNC_FN(radians)
-
-/**
- * if (v < edge)
- * return 0.f;
- * else
- * return 1.f;
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) step(float edge, float v);
-FN_FUNC_FN_FN(step)
-FN_FUNC_FN_F(step)
-
-// not implemented
-extern float __attribute__((overloadable)) smoothstep(float, float, float);
-extern float2 __attribute__((overloadable)) smoothstep(float2, float2, float2);
-extern float3 __attribute__((overloadable)) smoothstep(float3, float3, float3);
-extern float4 __attribute__((overloadable)) smoothstep(float4, float4, float4);
-extern float2 __attribute__((overloadable)) smoothstep(float, float, float2);
-extern float3 __attribute__((overloadable)) smoothstep(float, float, float3);
-extern float4 __attribute__((overloadable)) smoothstep(float, float, float4);
-
-/**
- * Return the sign of a value.
- *
- * if (v < 0) return -1.f;
- * else if (v > 0) return 1.f;
- * else return 0.f;
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) sign(float v);
-FN_FUNC_FN(sign)
-
-/**
- * Compute the cross product of two vectors.
- *
- * Supports 3,4 components
- */
-_RS_RUNTIME float3 __attribute__((overloadable)) cross(float3 lhs, float3 rhs);
-_RS_RUNTIME float4 __attribute__((overloadable)) cross(float4 lhs, float4 rhs);
-
-/**
- * Compute the dot product of two vectors.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) dot(float lhs, float rhs);
-F_FUNC_FN_FN(dot)
-
-/**
- * Compute the length of a vector.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) length(float v);
-F_FUNC_FN(length)
-
-/**
- * Compute the distance between two points.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) distance(float lhs, float rhs);
-F_FUNC_FN_FN(distance)
-
-/**
- * Normalize a vector.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) normalize(float v);
-FN_FUNC_FN(normalize)
-
-
-// New approx API functions
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-
-/**
- * Return the approximate reciprocal of a value.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) half_recip(float);
-FN_FUNC_FN(half_recip)
-
-/**
- * Return the approximate square root of a value.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) half_sqrt(float);
-FN_FUNC_FN(half_sqrt)
-
-/**
- * Return the approximate value of (1 / sqrt(value)).
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) half_rsqrt(float v);
-FN_FUNC_FN(half_rsqrt)
-
-/**
- * Compute the approximate length of a vector.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) fast_length(float v);
-F_FUNC_FN(fast_length)
-
-/**
- * Compute the approximate distance between two points.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) fast_distance(float lhs, float rhs);
-F_FUNC_FN_FN(fast_distance)
-
-/**
- * Approximately normalize a vector.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) fast_normalize(float v);
-F_FUNC_FN(fast_normalize)
-
-#endif // (defined(RS_VERSION) && (RS_VERSION >= 17))
-
-
-#undef CVT_FUNC
-#undef CVT_FUNC_2
-#undef FN_FUNC_FN
-#undef F_FUNC_FN
-#undef IN_FUNC_FN
-#undef FN_FUNC_FN_FN
-#undef F_FUNC_FN_FN
-#undef FN_FUNC_FN_F
-#undef FN_FUNC_FN_IN
-#undef FN_FUNC_FN_I
-#undef FN_FUNC_FN_PFN
-#undef FN_FUNC_FN_PIN
-#undef FN_FUNC_FN_FN_FN
-#undef FN_FUNC_FN_FN_F
-#undef FN_FUNC_FN_F_F
-#undef FN_FUNC_FN_FN_PIN
-#undef XN_FUNC_YN
-#undef UIN_FUNC_IN
-#undef IN_FUNC_IN
-#undef XN_FUNC_XN_XN_BODY
-#undef IN_FUNC_IN_IN_BODY
-
-#endif
diff --git a/renderscript/v8/rs_support/scriptc/rs_core.rsh b/renderscript/v8/rs_support/scriptc/rs_core.rsh
deleted file mode 100644
index 1b0f9db..0000000
--- a/renderscript/v8/rs_support/scriptc/rs_core.rsh
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (C) 2011-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
- /*! \mainpage notitle
- *
- * Renderscript is a high-performance runtime that provides graphics rendering and
- * compute operations at the native level. Renderscript code is compiled on devices
- * at runtime to allow platform-independence as well.
- * This reference documentation describes the Renderscript runtime APIs, which you
- * can utilize to write Renderscript code in C99. The Renderscript header
- * files are automatically included for you, except for the rs_graphics.rsh header. If
- * you are doing graphics rendering, include the graphics header file like this:
- *
- * <code>#include "rs_graphics.rsh"</code>
- *
- * To use Renderscript, you need to utilize the Renderscript runtime APIs documented here
- * as well as the Android framework APIs for Renderscript.
- * For documentation on the Android framework APIs, see the <a target="_parent" href=
- * "http://developer.android.com/reference/android/renderscript/package-summary.html">
- * android.renderscript</a> package reference.
- * For more information on how to develop with Renderscript and how the runtime and
- * Android framework APIs interact, see the <a target="_parent" href=
- * "http://developer.android.com/guide/topics/renderscript/index.html">Renderscript
- * developer guide</a> and the <a target="_parent" href=
- * "http://developer.android.com/resources/samples/RenderScript/index.html">
- * Renderscript samples</a>.
- */
-
-/** @file rs_core.rsh
- * \brief todo-jsams
- *
- * todo-jsams
- *
- */
-
-#ifndef __RS_CORE_RSH__
-#define __RS_CORE_RSH__
-
-#define _RS_RUNTIME extern
-
-#include "rs_types.rsh"
-#include "rs_allocation.rsh"
-#include "rs_atomic.rsh"
-#include "rs_cl.rsh"
-#include "rs_debug.rsh"
-#include "rs_element.rsh"
-#include "rs_math.rsh"
-#include "rs_matrix.rsh"
-#include "rs_object.rsh"
-#include "rs_quaternion.rsh"
-#include "rs_sampler.rsh"
-#include "rs_time.rsh"
-
-/**
- * Send a message back to the client. Will not block and returns true
- * if the message was sendable and false if the fifo was full.
- * A message ID is required. Data payload is optional.
- */
-extern bool __attribute__((overloadable))
- rsSendToClient(int cmdID);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsSendToClient(int cmdID, const void *data, uint len);
-/**
- * Send a message back to the client, blocking until the message is queued.
- * A message ID is required. Data payload is optional.
- */
-extern void __attribute__((overloadable))
- rsSendToClientBlocking(int cmdID);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSendToClientBlocking(int cmdID, const void *data, uint len);
-
-
-/**
- * Launch order hint for rsForEach calls. This provides a hint to the system to
- * determine in which order the root function of the target is called with each
- * cell of the allocation.
- *
- * This is a hint and implementations may not obey the order.
- */
-enum rs_for_each_strategy {
- RS_FOR_EACH_STRATEGY_SERIAL,
- RS_FOR_EACH_STRATEGY_DONT_CARE,
- RS_FOR_EACH_STRATEGY_DST_LINEAR,
- RS_FOR_EACH_STRATEGY_TILE_SMALL,
- RS_FOR_EACH_STRATEGY_TILE_MEDIUM,
- RS_FOR_EACH_STRATEGY_TILE_LARGE
-};
-
-
-/**
- * Structure to provide extra information to a rsForEach call. Primarly used to
- * restrict the call to a subset of cells in the allocation.
- */
-typedef struct rs_script_call {
- enum rs_for_each_strategy strategy;
- uint32_t xStart;
- uint32_t xEnd;
- uint32_t yStart;
- uint32_t yEnd;
- uint32_t zStart;
- uint32_t zEnd;
- uint32_t arrayStart;
- uint32_t arrayEnd;
-} rs_script_call_t;
-
-/**
- * Make a script to script call to launch work. One of the input or output is
- * required to be a valid object. The input and output must be of the same
- * dimensions.
- * API 10-13
- *
- * @param script The target script to call
- * @param input The allocation to source data from
- * @param output the allocation to write date into
- * @param usrData The user definied params to pass to the root script. May be
- * NULL.
- * @param sc Extra control infomation used to select a sub-region of the
- * allocation to be processed or suggest a walking strategy. May be
- * NULL.
- *
- * */
-#if !defined(RS_VERSION) || (RS_VERSION < 14)
-extern void __attribute__((overloadable))
- rsForEach(rs_script script, rs_allocation input,
- rs_allocation output, const void * usrData,
- const rs_script_call_t *sc);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsForEach(rs_script script, rs_allocation input,
- rs_allocation output, const void * usrData);
-#else
-
-/**
- * Make a script to script call to launch work. One of the input or output is
- * required to be a valid object. The input and output must be of the same
- * dimensions.
- * API 14+
- *
- * @param script The target script to call
- * @param input The allocation to source data from
- * @param output the allocation to write date into
- * @param usrData The user definied params to pass to the root script. May be
- * NULL.
- * @param usrDataLen The size of the userData structure. This will be used to
- * perform a shallow copy of the data if necessary.
- * @param sc Extra control infomation used to select a sub-region of the
- * allocation to be processed or suggest a walking strategy. May be
- * NULL.
- *
- */
-extern void __attribute__((overloadable))
- rsForEach(rs_script script, rs_allocation input, rs_allocation output,
- const void * usrData, size_t usrDataLen, const rs_script_call_t *);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsForEach(rs_script script, rs_allocation input, rs_allocation output,
- const void * usrData, size_t usrDataLen);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsForEach(rs_script script, rs_allocation input, rs_allocation output);
-#endif
-
-
-
-#undef _RS_RUNTIME
-
-#endif
diff --git a/renderscript/v8/rs_support/scriptc/rs_debug.rsh b/renderscript/v8/rs_support/scriptc/rs_debug.rsh
deleted file mode 100644
index 7a13c9d..0000000
--- a/renderscript/v8/rs_support/scriptc/rs_debug.rsh
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** @file rs_debug.rsh
- * \brief Utility debugging routines
- *
- * Routines intended to be used during application developement. These should
- * not be used in shipping applications. All print a string and value pair to
- * the standard log.
- *
- */
-
-#ifndef __RS_DEBUG_RSH__
-#define __RS_DEBUG_RSH__
-
-
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, float);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, float, float);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, float, float, float);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, float, float, float, float);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, float2);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, float3);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, float4);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, double);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, const rs_matrix4x4 *);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, const rs_matrix3x3 *);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, const rs_matrix2x2 *);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, int);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, uint);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, long);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, unsigned long);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, long long);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, unsigned long long);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, const void *);
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 17))
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, char);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, char2);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, char3);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, char4);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, unsigned char);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, uchar2);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, uchar3);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, uchar4);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, short);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, short2);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, short3);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, short4);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, unsigned short);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, ushort2);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, ushort3);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, ushort4);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, int2);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, int3);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, int4);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, uint2);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, uint3);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, uint4);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, long2);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, long3);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, long4);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, ulong2);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, ulong3);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, ulong4);
-#endif // (defined(RS_VERSION) && (RS_VERSION >= 17))
-
-#define RS_DEBUG(a) rsDebug(#a, a)
-#define RS_DEBUG_MARKER rsDebug(__FILE__, __LINE__)
-
-#endif
diff --git a/renderscript/v8/rs_support/scriptc/rs_element.rsh b/renderscript/v8/rs_support/scriptc/rs_element.rsh
deleted file mode 100644
index 0230f10..0000000
--- a/renderscript/v8/rs_support/scriptc/rs_element.rsh
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** @file rs_element.rsh
- * \brief Element routines
- *
- *
- */
-
-#ifndef __RS_ELEMENT_RSH__
-#define __RS_ELEMENT_RSH__
-
-// New API's
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-/**
- * Elements could be simple, such as an int or a float, or a
- * structure with multiple sub elements, such as a collection of
- * floats, float2, float4. This function returns zero for simple
- * elements or the number of sub-elements otherwise.
- *
- * @param e element to get data from
- * @return number of sub-elements in this element
- */
-extern uint32_t __attribute__((overloadable))
- rsElementGetSubElementCount(rs_element e);
-
-/**
- * For complex elements, this function will return the
- * sub-element at index
- *
- * @param e element to get data from
- * @param index index of the sub-element to return
- * @return sub-element in this element at given index
- */
-extern rs_element __attribute__((overloadable))
- rsElementGetSubElement(rs_element, uint32_t index);
-
-/**
- * For complex elements, this function will return the length of
- * sub-element name at index
- *
- * @param e element to get data from
- * @param index index of the sub-element to return
- * @return length of the sub-element name including the null
- * terminator (size of buffer needed to write the name)
- */
-extern uint32_t __attribute__((overloadable))
- rsElementGetSubElementNameLength(rs_element e, uint32_t index);
-
-/**
- * For complex elements, this function will return the
- * sub-element name at index
- *
- * @param e element to get data from
- * @param index index of the sub-element
- * @param name array to store the name into
- * @param nameLength length of the provided name array
- * @return number of characters actually written, excluding the
- * null terminator
- */
-extern uint32_t __attribute__((overloadable))
- rsElementGetSubElementName(rs_element e, uint32_t index, char *name, uint32_t nameLength);
-
-/**
- * For complex elements, some sub-elements could be statically
- * sized arrays. This function will return the array size for
- * sub-element at index
- *
- * @param e element to get data from
- * @param index index of the sub-element
- * @return array size of sub-element in this element at given
- * index
- */
-extern uint32_t __attribute__((overloadable))
- rsElementGetSubElementArraySize(rs_element e, uint32_t index);
-
-/**
- * This function specifies the location of a sub-element within
- * the element
- *
- * @param e element to get data from
- * @param index index of the sub-element
- * @return offset in bytes of sub-element in this element at
- * given index
- */
-extern uint32_t __attribute__((overloadable))
- rsElementGetSubElementOffsetBytes(rs_element e, uint32_t index);
-
-/**
- * Returns the size of element in bytes
- *
- * @param e element to get data from
- * @return total size of the element in bytes
- */
-extern uint32_t __attribute__((overloadable))
- rsElementGetBytesSize(rs_element e);
-
-/**
- * Returns the element's data type
- *
- * @param e element to get data from
- * @return element's data type
- */
-extern rs_data_type __attribute__((overloadable))
- rsElementGetDataType(rs_element e);
-
-/**
- * Returns the element's data kind
- *
- * @param e element to get data from
- * @return element's data size
- */
-extern rs_data_kind __attribute__((overloadable))
- rsElementGetDataKind(rs_element e);
-
-/**
- * Returns the element's vector size
- *
- * @param e element to get data from
- * @return length of the element vector (for float2, float3,
- * etc.)
- */
-extern uint32_t __attribute__((overloadable))
- rsElementGetVectorSize(rs_element e);
-
-#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-#endif // __RS_ELEMENT_RSH__
-
diff --git a/renderscript/v8/rs_support/scriptc/rs_graphics.rsh b/renderscript/v8/rs_support/scriptc/rs_graphics.rsh
deleted file mode 100644
index 44ee99f..0000000
--- a/renderscript/v8/rs_support/scriptc/rs_graphics.rsh
+++ /dev/null
@@ -1,421 +0,0 @@
-/*
- * Copyright (C) 2011-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** @file rs_graphics.rsh
- * \brief Renderscript graphics API
- *
- * A set of graphics functions used by Renderscript.
- *
- */
-#ifndef __RS_GRAPHICS_RSH__
-#define __RS_GRAPHICS_RSH__
-
-#include "rs_mesh.rsh"
-#include "rs_program.rsh"
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 14))
-/**
- * Set the color target used for all subsequent rendering calls
- * @param colorTarget
- * @param slot
- */
-extern void __attribute__((overloadable))
- rsgBindColorTarget(rs_allocation colorTarget, uint slot);
-
-/**
- * Clear the previously set color target
- * @param slot
- */
-extern void __attribute__((overloadable))
- rsgClearColorTarget(uint slot);
-
-/**
- * Set the depth target used for all subsequent rendering calls
- * @param depthTarget
- */
-extern void __attribute__((overloadable))
- rsgBindDepthTarget(rs_allocation depthTarget);
-
-/**
- * Clear the previously set depth target
- */
-extern void __attribute__((overloadable))
- rsgClearDepthTarget(void);
-
-/**
- * Clear all color and depth targets and resume rendering into
- * the framebuffer
- */
-extern void __attribute__((overloadable))
- rsgClearAllRenderTargets(void);
-
-/**
- * Force Renderscript to finish all rendering commands
- */
-extern uint __attribute__((overloadable))
- rsgFinish(void);
-
-#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
-
-/**
- * Bind a new ProgramFragment to the rendering context.
- *
- * @param pf
- */
-extern void __attribute__((overloadable))
- rsgBindProgramFragment(rs_program_fragment pf);
-
-/**
- * Bind a new ProgramStore to the rendering context.
- *
- * @param ps
- */
-extern void __attribute__((overloadable))
- rsgBindProgramStore(rs_program_store ps);
-
-/**
- * Bind a new ProgramVertex to the rendering context.
- *
- * @param pv
- */
-extern void __attribute__((overloadable))
- rsgBindProgramVertex(rs_program_vertex pv);
-
-/**
- * Bind a new ProgramRaster to the rendering context.
- *
- * @param pr
- */
-extern void __attribute__((overloadable))
- rsgBindProgramRaster(rs_program_raster pr);
-
-/**
- * Bind a new Sampler object to a ProgramFragment. The sampler will
- * operate on the texture bound at the matching slot.
- *
- * @param slot
- */
-extern void __attribute__((overloadable))
- rsgBindSampler(rs_program_fragment, uint slot, rs_sampler);
-
-/**
- * Bind a new Allocation object to a ProgramFragment. The
- * Allocation must be a valid texture for the Program. The sampling
- * of the texture will be controled by the Sampler bound at the
- * matching slot.
- *
- * @param slot
- */
-extern void __attribute__((overloadable))
- rsgBindTexture(rs_program_fragment, uint slot, rs_allocation);
-
-/**
- * Load the projection matrix for a currently bound fixed function
- * vertex program. Calling this function with a custom vertex shader
- * would result in an error.
- * @param proj projection matrix
- */
-extern void __attribute__((overloadable))
- rsgProgramVertexLoadProjectionMatrix(const rs_matrix4x4 *proj);
-/**
- * Load the model matrix for a currently bound fixed function
- * vertex program. Calling this function with a custom vertex shader
- * would result in an error.
- * @param model model matrix
- */
-extern void __attribute__((overloadable))
- rsgProgramVertexLoadModelMatrix(const rs_matrix4x4 *model);
-/**
- * Load the texture matrix for a currently bound fixed function
- * vertex program. Calling this function with a custom vertex shader
- * would result in an error.
- * @param tex texture matrix
- */
-extern void __attribute__((overloadable))
- rsgProgramVertexLoadTextureMatrix(const rs_matrix4x4 *tex);
-/**
- * Get the projection matrix for a currently bound fixed function
- * vertex program. Calling this function with a custom vertex shader
- * would result in an error.
- * @param proj matrix to store the current projection matrix into
- */
-extern void __attribute__((overloadable))
- rsgProgramVertexGetProjectionMatrix(rs_matrix4x4 *proj);
-
-/**
- * Set the constant color for a fixed function emulation program.
- *
- * @param pf
- * @param r
- * @param g
- * @param b
- * @param a
- */
-extern void __attribute__((overloadable))
- rsgProgramFragmentConstantColor(rs_program_fragment pf, float r, float g, float b, float a);
-
-/**
- * Bind a new Allocation object to a ProgramFragment. The
- * Allocation must be a valid constant input for the Program.
- *
- * @param ps program object
- * @param slot index of the constant buffer on the program
- * @param c constants to bind
- */
-extern void __attribute__((overloadable))
- rsgBindConstant(rs_program_fragment ps, uint slot, rs_allocation c);
-
-/**
- * Bind a new Allocation object to a ProgramVertex. The
- * Allocation must be a valid constant input for the Program.
- *
- * @param pv program object
- * @param slot index of the constant buffer on the program
- * @param c constants to bind
- */
-extern void __attribute__((overloadable))
- rsgBindConstant(rs_program_vertex pv, uint slot, rs_allocation c);
-
-/**
- * Get the width of the current rendering surface.
- *
- * @return uint
- */
-extern uint __attribute__((overloadable))
- rsgGetWidth(void);
-
-/**
- * Get the height of the current rendering surface.
- *
- * @return uint
- */
-extern uint __attribute__((overloadable))
- rsgGetHeight(void);
-
-
-/**
- * Sync the contents of an allocation from its SCRIPT memory space to its HW
- * memory spaces.
- *
- * @param alloc
- */
-extern void __attribute__((overloadable))
- rsgAllocationSyncAll(rs_allocation alloc);
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 14))
-
-/**
- * Sync the contents of an allocation from memory space
- * specified by source.
- *
- * @param alloc
- * @param source
- */
-extern void __attribute__((overloadable))
- rsgAllocationSyncAll(rs_allocation alloc,
- rs_allocation_usage_type source);
-
-#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
-
-/**
- * Low performance utility function for drawing a simple rectangle. Not
- * intended for drawing large quantities of geometry.
- *
- * @param x1
- * @param y1
- * @param x2
- * @param y2
- * @param z
- */
-extern void __attribute__((overloadable))
- rsgDrawRect(float x1, float y1, float x2, float y2, float z);
-
-/**
- * Low performance utility function for drawing a simple quad. Not intended for
- * drawing large quantities of geometry.
- *
- * @param x1
- * @param y1
- * @param z1
- * @param x2
- * @param y2
- * @param z2
- * @param x3
- * @param y3
- * @param z3
- * @param x4
- * @param y4
- * @param z4
- */
-extern void __attribute__((overloadable))
- rsgDrawQuad(float x1, float y1, float z1,
- float x2, float y2, float z2,
- float x3, float y3, float z3,
- float x4, float y4, float z4);
-
-
-/**
- * Low performance utility function for drawing a textured quad. Not intended
- * for drawing large quantities of geometry.
- *
- * @param x1
- * @param y1
- * @param z1
- * @param u1
- * @param v1
- * @param x2
- * @param y2
- * @param z2
- * @param u2
- * @param v2
- * @param x3
- * @param y3
- * @param z3
- * @param u3
- * @param v3
- * @param x4
- * @param y4
- * @param z4
- * @param u4
- * @param v4
- */
-extern void __attribute__((overloadable))
- rsgDrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1,
- float x2, float y2, float z2, float u2, float v2,
- float x3, float y3, float z3, float u3, float v3,
- float x4, float y4, float z4, float u4, float v4);
-
-
-/**
- * Low performance function for drawing rectangles in screenspace. This
- * function uses the default passthough ProgramVertex. Any bound ProgramVertex
- * is ignored. This function has considerable overhead and should not be used
- * for drawing in shipping applications.
- *
- * @param x
- * @param y
- * @param z
- * @param w
- * @param h
- */
-extern void __attribute__((overloadable))
- rsgDrawSpriteScreenspace(float x, float y, float z, float w, float h);
-
-extern void __attribute__((overloadable))
- rsgDrawPath(rs_path p);
-
-/**
- * Draw a mesh using the current context state. The whole mesh is
- * rendered.
- *
- * @param ism
- */
-extern void __attribute__((overloadable))
- rsgDrawMesh(rs_mesh ism);
-/**
- * Draw part of a mesh using the current context state.
- * @param ism mesh object to render
- * @param primitiveIndex for meshes that contain multiple primitive groups
- * this parameter specifies the index of the group to draw.
- */
-extern void __attribute__((overloadable))
- rsgDrawMesh(rs_mesh ism, uint primitiveIndex);
-/**
- * Draw specified index range of part of a mesh using the current context state.
- * @param ism mesh object to render
- * @param primitiveIndex for meshes that contain multiple primitive groups
- * this parameter specifies the index of the group to draw.
- * @param start starting index in the range
- * @param len number of indices to draw
- */
-extern void __attribute__((overloadable))
- rsgDrawMesh(rs_mesh ism, uint primitiveIndex, uint start, uint len);
-
-/**
- * Clears the rendering surface to the specified color.
- *
- * @param r
- * @param g
- * @param b
- * @param a
- */
-extern void __attribute__((overloadable))
- rsgClearColor(float r, float g, float b, float a);
-
-/**
- * Clears the depth suface to the specified value.
- */
-extern void __attribute__((overloadable))
- rsgClearDepth(float value);
-/**
- * Draws text given a string and location
- */
-extern void __attribute__((overloadable))
- rsgDrawText(const char *, int x, int y);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsgDrawText(rs_allocation, int x, int y);
-/**
- * Binds the font object to be used for all subsequent font rendering calls
- * @param font object to bind
- */
-extern void __attribute__((overloadable))
- rsgBindFont(rs_font font);
-/**
- * Sets the font color for all subsequent rendering calls
- * @param r red component
- * @param g green component
- * @param b blue component
- * @param a alpha component
- */
-extern void __attribute__((overloadable))
- rsgFontColor(float r, float g, float b, float a);
-/**
- * Returns the bounding box of the text relative to (0, 0)
- * Any of left, right, top, bottom could be NULL
- */
-extern void __attribute__((overloadable))
- rsgMeasureText(const char *, int *left, int *right, int *top, int *bottom);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsgMeasureText(rs_allocation, int *left, int *right, int *top, int *bottom);
-/**
- * Computes an axis aligned bounding box of a mesh object
- */
-extern void __attribute__((overloadable))
- rsgMeshComputeBoundingBox(rs_mesh mesh, float *minX, float *minY, float *minZ,
- float *maxX, float *maxY, float *maxZ);
-/**
- * \overload
- */
-__inline__ static void __attribute__((overloadable, always_inline))
-rsgMeshComputeBoundingBox(rs_mesh mesh, float3 *bBoxMin, float3 *bBoxMax) {
- float x1, y1, z1, x2, y2, z2;
- rsgMeshComputeBoundingBox(mesh, &x1, &y1, &z1, &x2, &y2, &z2);
- bBoxMin->x = x1;
- bBoxMin->y = y1;
- bBoxMin->z = z1;
- bBoxMax->x = x2;
- bBoxMax->y = y2;
- bBoxMax->z = z2;
-}
-
-#endif
-
diff --git a/renderscript/v8/rs_support/scriptc/rs_math.rsh b/renderscript/v8/rs_support/scriptc/rs_math.rsh
deleted file mode 100644
index 73040b3..0000000
--- a/renderscript/v8/rs_support/scriptc/rs_math.rsh
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** @file rs_math.rsh
- * \brief todo-jsams
- *
- * todo-jsams
- *
- */
-
-#ifndef __RS_MATH_RSH__
-#define __RS_MATH_RSH__
-
-
-/**
- * Return a random value between 0 (or min_value) and max_malue.
- */
-extern int __attribute__((overloadable))
- rsRand(int max_value);
-/**
- * \overload
- */
-extern int __attribute__((overloadable))
- rsRand(int min_value, int max_value);
-/**
- * \overload
- */
-extern float __attribute__((overloadable))
- rsRand(float max_value);
-/**
- * \overload
- */
-extern float __attribute__((overloadable))
- rsRand(float min_value, float max_value);
-
-/**
- * Returns the fractional part of a float
- */
-extern float __attribute__((overloadable))
- rsFrac(float);
-
-
-/////////////////////////////////////////////////////
-// int ops
-/////////////////////////////////////////////////////
-
-/**
- * Clamp the value amount between low and high.
- *
- * @param amount The value to clamp
- * @param low
- * @param high
- */
-_RS_RUNTIME uint __attribute__((overloadable, always_inline)) rsClamp(uint amount, uint low, uint high);
-
-/**
- * \overload
- */
-_RS_RUNTIME int __attribute__((overloadable, always_inline)) rsClamp(int amount, int low, int high);
-/**
- * \overload
- */
-_RS_RUNTIME ushort __attribute__((overloadable, always_inline)) rsClamp(ushort amount, ushort low, ushort high);
-/**
- * \overload
- */
-_RS_RUNTIME short __attribute__((overloadable, always_inline)) rsClamp(short amount, short low, short high);
-/**
- * \overload
- */
-_RS_RUNTIME uchar __attribute__((overloadable, always_inline)) rsClamp(uchar amount, uchar low, uchar high);
-/**
- * \overload
- */
-_RS_RUNTIME char __attribute__((overloadable, always_inline)) rsClamp(char amount, char low, char high);
-
-
-/**
- * Computes 6 frustum planes from the view projection matrix
- * @param viewProj matrix to extract planes from
- * @param left plane
- * @param right plane
- * @param top plane
- * @param bottom plane
- * @param near plane
- * @param far plane
- */
-__inline__ static void __attribute__((overloadable, always_inline))
-rsExtractFrustumPlanes(const rs_matrix4x4 *viewProj,
- float4 *left, float4 *right,
- float4 *top, float4 *bottom,
- float4 *near, float4 *far) {
- // x y z w = a b c d in the plane equation
- left->x = viewProj->m[3] + viewProj->m[0];
- left->y = viewProj->m[7] + viewProj->m[4];
- left->z = viewProj->m[11] + viewProj->m[8];
- left->w = viewProj->m[15] + viewProj->m[12];
-
- right->x = viewProj->m[3] - viewProj->m[0];
- right->y = viewProj->m[7] - viewProj->m[4];
- right->z = viewProj->m[11] - viewProj->m[8];
- right->w = viewProj->m[15] - viewProj->m[12];
-
- top->x = viewProj->m[3] - viewProj->m[1];
- top->y = viewProj->m[7] - viewProj->m[5];
- top->z = viewProj->m[11] - viewProj->m[9];
- top->w = viewProj->m[15] - viewProj->m[13];
-
- bottom->x = viewProj->m[3] + viewProj->m[1];
- bottom->y = viewProj->m[7] + viewProj->m[5];
- bottom->z = viewProj->m[11] + viewProj->m[9];
- bottom->w = viewProj->m[15] + viewProj->m[13];
-
- near->x = viewProj->m[3] + viewProj->m[2];
- near->y = viewProj->m[7] + viewProj->m[6];
- near->z = viewProj->m[11] + viewProj->m[10];
- near->w = viewProj->m[15] + viewProj->m[14];
-
- far->x = viewProj->m[3] - viewProj->m[2];
- far->y = viewProj->m[7] - viewProj->m[6];
- far->z = viewProj->m[11] - viewProj->m[10];
- far->w = viewProj->m[15] - viewProj->m[14];
-
- float len = length(left->xyz);
- *left /= len;
- len = length(right->xyz);
- *right /= len;
- len = length(top->xyz);
- *top /= len;
- len = length(bottom->xyz);
- *bottom /= len;
- len = length(near->xyz);
- *near /= len;
- len = length(far->xyz);
- *far /= len;
-}
-
-/**
- * Checks if a sphere is withing the 6 frustum planes
- * @param sphere float4 representing the sphere
- * @param left plane
- * @param right plane
- * @param top plane
- * @param bottom plane
- * @param near plane
- * @param far plane
- */
-__inline__ static bool __attribute__((overloadable, always_inline))
-rsIsSphereInFrustum(float4 *sphere,
- float4 *left, float4 *right,
- float4 *top, float4 *bottom,
- float4 *near, float4 *far) {
-
- float distToCenter = dot(left->xyz, sphere->xyz) + left->w;
- if (distToCenter < -sphere->w) {
- return false;
- }
- distToCenter = dot(right->xyz, sphere->xyz) + right->w;
- if (distToCenter < -sphere->w) {
- return false;
- }
- distToCenter = dot(top->xyz, sphere->xyz) + top->w;
- if (distToCenter < -sphere->w) {
- return false;
- }
- distToCenter = dot(bottom->xyz, sphere->xyz) + bottom->w;
- if (distToCenter < -sphere->w) {
- return false;
- }
- distToCenter = dot(near->xyz, sphere->xyz) + near->w;
- if (distToCenter < -sphere->w) {
- return false;
- }
- distToCenter = dot(far->xyz, sphere->xyz) + far->w;
- if (distToCenter < -sphere->w) {
- return false;
- }
- return true;
-}
-
-
-/**
- * Pack floating point (0-1) RGB values into a uchar4. The alpha component is
- * set to 255 (1.0).
- *
- * @param r
- * @param g
- * @param b
- *
- * @return uchar4
- */
-_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b);
-
-/**
- * Pack floating point (0-1) RGBA values into a uchar4.
- *
- * @param r
- * @param g
- * @param b
- * @param a
- *
- * @return uchar4
- */
-_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b, float a);
-
-/**
- * Pack floating point (0-1) RGB values into a uchar4. The alpha component is
- * set to 255 (1.0).
- *
- * @param color
- *
- * @return uchar4
- */
-_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float3 color);
-
-/**
- * Pack floating point (0-1) RGBA values into a uchar4.
- *
- * @param color
- *
- * @return uchar4
- */
-_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float4 color);
-
-/**
- * Unpack a uchar4 color to float4. The resulting float range will be (0-1).
- *
- * @param c
- *
- * @return float4
- */
-_RS_RUNTIME float4 rsUnpackColor8888(uchar4 c);
-
-_RS_RUNTIME uchar4 __attribute__((overloadable)) rsYuvToRGBA_uchar4(uchar y, uchar u, uchar v);
-_RS_RUNTIME float4 __attribute__((overloadable)) rsYuvToRGBA_float4(uchar y, uchar u, uchar v);
-
-
-#endif
diff --git a/renderscript/v8/rs_support/scriptc/rs_matrix.rsh b/renderscript/v8/rs_support/scriptc/rs_matrix.rsh
deleted file mode 100644
index ebff7f4..0000000
--- a/renderscript/v8/rs_support/scriptc/rs_matrix.rsh
+++ /dev/null
@@ -1,378 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** @file rs_matrix.rsh
- * \brief Matrix routines
- *
- *
- */
-
-#ifndef __RS_MATRIX_RSH__
-#define __RS_MATRIX_RSH__
-
-/**
- * Set one element of a matrix.
- *
- * @param m The matrix to be set
- * @param row
- * @param col
- * @param v
- *
- * @return void
- */
-_RS_RUNTIME void __attribute__((overloadable))
-rsMatrixSet(rs_matrix4x4 *m, uint32_t row, uint32_t col, float v);
-/**
- * \overload
- */
-_RS_RUNTIME void __attribute__((overloadable))
-rsMatrixSet(rs_matrix3x3 *m, uint32_t row, uint32_t col, float v);
-/**
- * \overload
- */
-_RS_RUNTIME void __attribute__((overloadable))
-rsMatrixSet(rs_matrix2x2 *m, uint32_t row, uint32_t col, float v);
-
-/**
- * Get one element of a matrix.
- *
- * @param m The matrix to read from
- * @param row
- * @param col
- *
- * @return float
- */
-_RS_RUNTIME float __attribute__((overloadable))
-rsMatrixGet(const rs_matrix4x4 *m, uint32_t row, uint32_t col);
-/**
- * \overload
- */
-_RS_RUNTIME float __attribute__((overloadable))
-rsMatrixGet(const rs_matrix3x3 *m, uint32_t row, uint32_t col);
-/**
- * \overload
- */
-_RS_RUNTIME float __attribute__((overloadable))
-rsMatrixGet(const rs_matrix2x2 *m, uint32_t row, uint32_t col);
-
-/**
- * Set the elements of a matrix to the identity matrix.
- *
- * @param m
- */
-extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix4x4 *m);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix3x3 *m);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix2x2 *m);
-
-/**
- * Set the elements of a matrix from an array of floats.
- *
- * @param m
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const float *v);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix3x3 *m, const float *v);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix2x2 *m, const float *v);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix4x4 *v);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix3x3 *v);
-
-/**
- * Set the elements of a matrix from another matrix.
- *
- * @param m
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix2x2 *v);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix3x3 *m, const rs_matrix3x3 *v);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix2x2 *m, const rs_matrix2x2 *v);
-
-/**
- * Load a rotation matrix.
- *
- * @param m
- * @param rot
- * @param x
- * @param y
- * @param z
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadRotate(rs_matrix4x4 *m, float rot, float x, float y, float z);
-
-/**
- * Load a scale matrix.
- *
- * @param m
- * @param x
- * @param y
- * @param z
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadScale(rs_matrix4x4 *m, float x, float y, float z);
-
-/**
- * Load a translation matrix.
- *
- * @param m
- * @param x
- * @param y
- * @param z
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadTranslate(rs_matrix4x4 *m, float x, float y, float z);
-
-/**
- * Multiply two matrix (lhs, rhs) and place the result in m.
- *
- * @param m
- * @param lhs
- * @param rhs
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadMultiply(rs_matrix4x4 *m, const rs_matrix4x4 *lhs, const rs_matrix4x4 *rhs);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadMultiply(rs_matrix3x3 *m, const rs_matrix3x3 *lhs, const rs_matrix3x3 *rhs);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadMultiply(rs_matrix2x2 *m, const rs_matrix2x2 *lhs, const rs_matrix2x2 *rhs);
-
-/**
- * Multiply the matrix m by rhs and place the result back into m.
- *
- * @param m (lhs)
- * @param rhs
- */
-extern void __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix4x4 *m, const rs_matrix4x4 *rhs);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix3x3 *m, const rs_matrix3x3 *rhs);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix2x2 *m, const rs_matrix2x2 *rhs);
-
-/**
- * Multiple matrix m with a rotation matrix
- *
- * @param m
- * @param rot
- * @param x
- * @param y
- * @param z
- */
-extern void __attribute__((overloadable))
-rsMatrixRotate(rs_matrix4x4 *m, float rot, float x, float y, float z);
-
-/**
- * Multiple matrix m with a scale matrix
- *
- * @param m
- * @param x
- * @param y
- * @param z
- */
-extern void __attribute__((overloadable))
-rsMatrixScale(rs_matrix4x4 *m, float x, float y, float z);
-
-/**
- * Multiple matrix m with a translation matrix
- *
- * @param m
- * @param x
- * @param y
- * @param z
- */
-extern void __attribute__((overloadable))
-rsMatrixTranslate(rs_matrix4x4 *m, float x, float y, float z);
-
-/**
- * Load an Ortho projection matrix constructed from the 6 planes
- *
- * @param m
- * @param left
- * @param right
- * @param bottom
- * @param top
- * @param near
- * @param far
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadOrtho(rs_matrix4x4 *m, float left, float right, float bottom, float top, float near, float far);
-
-/**
- * Load an Frustum projection matrix constructed from the 6 planes
- *
- * @param m
- * @param left
- * @param right
- * @param bottom
- * @param top
- * @param near
- * @param far
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadFrustum(rs_matrix4x4 *m, float left, float right, float bottom, float top, float near, float far);
-
-/**
- * Load an perspective projection matrix constructed from the 6 planes
- *
- * @param m
- * @param fovy Field of view, in degrees along the Y axis.
- * @param aspect Ratio of x / y.
- * @param near
- * @param far
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadPerspective(rs_matrix4x4* m, float fovy, float aspect, float near, float far);
-
-#if !defined(RS_VERSION) || (RS_VERSION < 14)
-/**
- * Multiply a vector by a matrix and return the result vector.
- * API version 10-13
- */
-_RS_RUNTIME float4 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix4x4 *m, float4 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float4 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix4x4 *m, float3 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float4 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix4x4 *m, float2 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float3 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix3x3 *m, float3 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float3 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix3x3 *m, float2 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float2 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix2x2 *m, float2 in);
-#else
-/**
- * Multiply a vector by a matrix and return the result vector.
- * API version 14+
- */
-_RS_RUNTIME float4 __attribute__((overloadable))
-rsMatrixMultiply(const rs_matrix4x4 *m, float4 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float4 __attribute__((overloadable))
-rsMatrixMultiply(const rs_matrix4x4 *m, float3 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float4 __attribute__((overloadable))
-rsMatrixMultiply(const rs_matrix4x4 *m, float2 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float3 __attribute__((overloadable))
-rsMatrixMultiply(const rs_matrix3x3 *m, float3 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float3 __attribute__((overloadable))
-rsMatrixMultiply(const rs_matrix3x3 *m, float2 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float2 __attribute__((overloadable))
-rsMatrixMultiply(const rs_matrix2x2 *m, float2 in);
-#endif
-
-
-/**
- * Returns true if the matrix was successfully inversed
- *
- * @param m
- */
-extern bool __attribute__((overloadable)) rsMatrixInverse(rs_matrix4x4 *m);
-
-/**
- * Returns true if the matrix was successfully inversed and transposed.
- *
- * @param m
- */
-extern bool __attribute__((overloadable)) rsMatrixInverseTranspose(rs_matrix4x4 *m);
-
-/**
- * Transpose the matrix m.
- *
- * @param m
- */
-extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix4x4 *m);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix3x3 *m);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix2x2 *m);
-
-
-#endif
diff --git a/renderscript/v8/rs_support/scriptc/rs_mesh.rsh b/renderscript/v8/rs_support/scriptc/rs_mesh.rsh
deleted file mode 100644
index 0ecd786..0000000
--- a/renderscript/v8/rs_support/scriptc/rs_mesh.rsh
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** @file rs_mesh.rsh
- * \brief Mesh routines
- *
- *
- */
-
-#ifndef __RS_MESH_RSH__
-#define __RS_MESH_RSH__
-
-// New API's
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-/**
- * Returns the number of allocations in the mesh that contain
- * vertex data
- *
- * @param m mesh to get data from
- * @return number of allocations in the mesh that contain vertex
- * data
- */
-extern uint32_t __attribute__((overloadable))
- rsgMeshGetVertexAllocationCount(rs_mesh m);
-
-/**
- * Meshes could have multiple index sets, this function returns
- * the number.
- *
- * @param m mesh to get data from
- * @return number of primitive groups in the mesh. This would
- * include simple primitives as well as allocations
- * containing index data
- */
-extern uint32_t __attribute__((overloadable))
- rsgMeshGetPrimitiveCount(rs_mesh m);
-
-/**
- * Returns an allocation that is part of the mesh and contains
- * vertex data, e.g. positions, normals, texcoords
- *
- * @param m mesh to get data from
- * @param index index of the vertex allocation
- * @return allocation containing vertex data
- */
-extern rs_allocation __attribute__((overloadable))
- rsgMeshGetVertexAllocation(rs_mesh m, uint32_t index);
-
-/**
- * Returns an allocation containing index data or a null
- * allocation if only the primitive is specified
- *
- * @param m mesh to get data from
- * @param index index of the index allocation
- * @return allocation containing index data
- */
-extern rs_allocation __attribute__((overloadable))
- rsgMeshGetIndexAllocation(rs_mesh m, uint32_t index);
-
-/**
- * Returns the primitive describing how a part of the mesh is
- * rendered
- *
- * @param m mesh to get data from
- * @param index index of the primitive
- * @return primitive describing how the mesh is rendered
- */
-extern rs_primitive __attribute__((overloadable))
- rsgMeshGetPrimitive(rs_mesh m, uint32_t index);
-
-#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-#endif // __RS_MESH_RSH__
-
diff --git a/renderscript/v8/rs_support/scriptc/rs_object.rsh b/renderscript/v8/rs_support/scriptc/rs_object.rsh
deleted file mode 100644
index 1fc3f83..0000000
--- a/renderscript/v8/rs_support/scriptc/rs_object.rsh
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** @file rs_object.rsh
- * \brief Object routines
- *
- *
- */
-
-#ifndef __RS_OBJECT_RSH__
-#define __RS_OBJECT_RSH__
-
-
-/**
- * Copy reference to the specified object.
- *
- * @param dst
- * @param src
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_element *dst, rs_element src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_type *dst, rs_type src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_allocation *dst, rs_allocation src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_sampler *dst, rs_sampler src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_script *dst, rs_script src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_path *dst, rs_path src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_mesh *dst, rs_mesh src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_program_fragment *dst, rs_program_fragment src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_program_vertex *dst, rs_program_vertex src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_program_raster *dst, rs_program_raster src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_program_store *dst, rs_program_store src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_font *dst, rs_font src);
-
-/**
- * Sets the object to NULL.
- *
- * @return bool
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_element *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_type *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_allocation *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_sampler *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_script *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_path *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_mesh *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_program_fragment *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_program_vertex *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_program_raster *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_program_store *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_font *dst);
-
-
-
-/**
- * Tests if the object is valid. Returns true if the object is valid, false if
- * it is NULL.
- *
- * @return bool
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_element);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_type);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_allocation);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_sampler);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_script);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_path);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_mesh);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_program_fragment);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_program_vertex);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_program_raster);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_program_store);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_font);
-
-#endif
diff --git a/renderscript/v8/rs_support/scriptc/rs_program.rsh b/renderscript/v8/rs_support/scriptc/rs_program.rsh
deleted file mode 100644
index 299aae6..0000000
--- a/renderscript/v8/rs_support/scriptc/rs_program.rsh
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** @file rs_program.rsh
- * \brief Program object routines
- *
- *
- */
-
-#ifndef __RS_PROGRAM_RSH__
-#define __RS_PROGRAM_RSH__
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-/**
- * Get program store depth function
- *
- * @param ps program store to query
- */
-extern rs_depth_func __attribute__((overloadable))
- rsgProgramStoreGetDepthFunc(rs_program_store ps);
-
-/**
- * Get program store depth mask
- *
- * @param ps program store to query
- */
-extern bool __attribute__((overloadable))
- rsgProgramStoreIsDepthMaskEnabled(rs_program_store ps);
-/**
- * Get program store red component color mask
- *
- * @param ps program store to query
- */
-extern bool __attribute__((overloadable))
- rsgProgramStoreIsColorMaskRedEnabled(rs_program_store ps);
-
-/**
- * Get program store green component color mask
- *
- * @param ps program store to query
- */
-extern bool __attribute__((overloadable))
- rsgProgramStoreIsColorMaskGreenEnabled(rs_program_store ps);
-
-/**
- * Get program store blur component color mask
- *
- * @param ps program store to query
- */
-extern bool __attribute__((overloadable))
- rsgProgramStoreIsColorMaskBlueEnabled(rs_program_store ps);
-
-/**
- * Get program store alpha component color mask
- *
- * @param ps program store to query
- */
-extern bool __attribute__((overloadable))
- rsgProgramStoreIsColorMaskAlphaEnabled(rs_program_store ps);
-
-/**
- * Get program store blend source function
- *
- * @param ps program store to query
- */
-extern rs_blend_src_func __attribute__((overloadable))
- rsgProgramStoreGetBlendSrcFunc(rs_program_store ps);
-
-/**
- * Get program store blend destination function
- *
- * @param ps program store to query
- */
-extern rs_blend_dst_func __attribute__((overloadable))
- rsgProgramStoreGetBlendDstFunc(rs_program_store ps);
-
-/**
- * Get program store dither state
- *
- * @param ps program store to query
- */
-extern bool __attribute__((overloadable))
- rsgProgramStoreIsDitherEnabled(rs_program_store ps);
-
-/**
- * Get program raster point sprite state
- *
- * @param pr program raster to query
- */
-extern bool __attribute__((overloadable))
- rsgProgramRasterIsPointSpriteEnabled(rs_program_raster pr);
-
-/**
- * Get program raster cull mode
- *
- * @param pr program raster to query
- */
-extern rs_cull_mode __attribute__((overloadable))
- rsgProgramRasterGetCullMode(rs_program_raster pr);
-
-#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-#endif // __RS_PROGRAM_RSH__
-
diff --git a/renderscript/v8/rs_support/scriptc/rs_quaternion.rsh b/renderscript/v8/rs_support/scriptc/rs_quaternion.rsh
deleted file mode 100644
index 4e08d2f..0000000
--- a/renderscript/v8/rs_support/scriptc/rs_quaternion.rsh
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** @file rs_quaternion.rsh
- * \brief Quaternion routines
- *
- *
- */
-
-#ifndef __RS_QUATERNION_RSH__
-#define __RS_QUATERNION_RSH__
-
-
-/**
- * Set the quaternion components
- * @param w component
- * @param x component
- * @param y component
- * @param z component
- */
-static void __attribute__((overloadable))
-rsQuaternionSet(rs_quaternion *q, float w, float x, float y, float z) {
- q->w = w;
- q->x = x;
- q->y = y;
- q->z = z;
-}
-
-/**
- * Set the quaternion from another quaternion
- * @param q destination quaternion
- * @param rhs source quaternion
- */
-static void __attribute__((overloadable))
-rsQuaternionSet(rs_quaternion *q, const rs_quaternion *rhs) {
- q->w = rhs->w;
- q->x = rhs->x;
- q->y = rhs->y;
- q->z = rhs->z;
-}
-
-/**
- * Multiply quaternion by a scalar
- * @param q quaternion to multiply
- * @param s scalar
- */
-static void __attribute__((overloadable))
-rsQuaternionMultiply(rs_quaternion *q, float s) {
- q->w *= s;
- q->x *= s;
- q->y *= s;
- q->z *= s;
-}
-
-/**
- * Add two quaternions
- * @param q destination quaternion to add to
- * @param rsh right hand side quaternion to add
- */
-static void
-rsQuaternionAdd(rs_quaternion *q, const rs_quaternion *rhs) {
- q->w *= rhs->w;
- q->x *= rhs->x;
- q->y *= rhs->y;
- q->z *= rhs->z;
-}
-
-/**
- * Loads a quaternion that represents a rotation about an arbitrary unit vector
- * @param q quaternion to set
- * @param rot angle to rotate by
- * @param x component of a vector
- * @param y component of a vector
- * @param x component of a vector
- */
-static void
-rsQuaternionLoadRotateUnit(rs_quaternion *q, float rot, float x, float y, float z) {
- rot *= (float)(M_PI / 180.0f) * 0.5f;
- float c = cos(rot);
- float s = sin(rot);
-
- q->w = c;
- q->x = x * s;
- q->y = y * s;
- q->z = z * s;
-}
-
-/**
- * Loads a quaternion that represents a rotation about an arbitrary vector
- * (doesn't have to be unit)
- * @param q quaternion to set
- * @param rot angle to rotate by
- * @param x component of a vector
- * @param y component of a vector
- * @param x component of a vector
- */
-static void
-rsQuaternionLoadRotate(rs_quaternion *q, float rot, float x, float y, float z) {
- const float len = x*x + y*y + z*z;
- if (len != 1) {
- const float recipLen = 1.f / sqrt(len);
- x *= recipLen;
- y *= recipLen;
- z *= recipLen;
- }
- rsQuaternionLoadRotateUnit(q, rot, x, y, z);
-}
-
-/**
- * Conjugates the quaternion
- * @param q quaternion to conjugate
- */
-static void
-rsQuaternionConjugate(rs_quaternion *q) {
- q->x = -q->x;
- q->y = -q->y;
- q->z = -q->z;
-}
-
-/**
- * Dot product of two quaternions
- * @param q0 first quaternion
- * @param q1 second quaternion
- * @return dot product between q0 and q1
- */
-static float
-rsQuaternionDot(const rs_quaternion *q0, const rs_quaternion *q1) {
- return q0->w*q1->w + q0->x*q1->x + q0->y*q1->y + q0->z*q1->z;
-}
-
-/**
- * Normalizes the quaternion
- * @param q quaternion to normalize
- */
-static void
-rsQuaternionNormalize(rs_quaternion *q) {
- const float len = rsQuaternionDot(q, q);
- if (len != 1) {
- const float recipLen = 1.f / sqrt(len);
- rsQuaternionMultiply(q, recipLen);
- }
-}
-
-/**
- * Multiply quaternion by another quaternion
- * @param q destination quaternion
- * @param rhs right hand side quaternion to multiply by
- */
-static void __attribute__((overloadable))
-rsQuaternionMultiply(rs_quaternion *q, const rs_quaternion *rhs) {
- rs_quaternion qtmp;
- rsQuaternionSet(&qtmp, q);
-
- q->w = qtmp.w*rhs->w - qtmp.x*rhs->x - qtmp.y*rhs->y - qtmp.z*rhs->z;
- q->x = qtmp.w*rhs->x + qtmp.x*rhs->w + qtmp.y*rhs->z - qtmp.z*rhs->y;
- q->y = qtmp.w*rhs->y + qtmp.y*rhs->w + qtmp.z*rhs->x - qtmp.x*rhs->z;
- q->z = qtmp.w*rhs->z + qtmp.z*rhs->w + qtmp.x*rhs->y - qtmp.y*rhs->x;
- rsQuaternionNormalize(q);
-}
-
-/**
- * Performs spherical linear interpolation between two quaternions
- * @param q result quaternion from interpolation
- * @param q0 first param
- * @param q1 second param
- * @param t how much to interpolate by
- */
-static void
-rsQuaternionSlerp(rs_quaternion *q, const rs_quaternion *q0, const rs_quaternion *q1, float t) {
- if (t <= 0.0f) {
- rsQuaternionSet(q, q0);
- return;
- }
- if (t >= 1.0f) {
- rsQuaternionSet(q, q1);
- return;
- }
-
- rs_quaternion tempq0, tempq1;
- rsQuaternionSet(&tempq0, q0);
- rsQuaternionSet(&tempq1, q1);
-
- float angle = rsQuaternionDot(q0, q1);
- if (angle < 0) {
- rsQuaternionMultiply(&tempq0, -1.0f);
- angle *= -1.0f;
- }
-
- float scale, invScale;
- if (angle + 1.0f > 0.05f) {
- if (1.0f - angle >= 0.05f) {
- float theta = acos(angle);
- float invSinTheta = 1.0f / sin(theta);
- scale = sin(theta * (1.0f - t)) * invSinTheta;
- invScale = sin(theta * t) * invSinTheta;
- } else {
- scale = 1.0f - t;
- invScale = t;
- }
- } else {
- rsQuaternionSet(&tempq1, tempq0.z, -tempq0.y, tempq0.x, -tempq0.w);
- scale = sin(M_PI * (0.5f - t));
- invScale = sin(M_PI * t);
- }
-
- rsQuaternionSet(q, tempq0.w*scale + tempq1.w*invScale, tempq0.x*scale + tempq1.x*invScale,
- tempq0.y*scale + tempq1.y*invScale, tempq0.z*scale + tempq1.z*invScale);
-}
-
-/**
- * Computes rotation matrix from the normalized quaternion
- * @param m resulting matrix
- * @param p normalized quaternion
- */
-static void rsQuaternionGetMatrixUnit(rs_matrix4x4 *m, const rs_quaternion *q) {
- float xx = q->x * q->x;
- float xy = q->x * q->y;
- float xz = q->x * q->z;
- float xw = q->x * q->w;
- float yy = q->y * q->y;
- float yz = q->y * q->z;
- float yw = q->y * q->w;
- float zz = q->z * q->z;
- float zw = q->z * q->w;
-
- m->m[0] = 1.0f - 2.0f * ( yy + zz );
- m->m[4] = 2.0f * ( xy - zw );
- m->m[8] = 2.0f * ( xz + yw );
- m->m[1] = 2.0f * ( xy + zw );
- m->m[5] = 1.0f - 2.0f * ( xx + zz );
- m->m[9] = 2.0f * ( yz - xw );
- m->m[2] = 2.0f * ( xz - yw );
- m->m[6] = 2.0f * ( yz + xw );
- m->m[10] = 1.0f - 2.0f * ( xx + yy );
- m->m[3] = m->m[7] = m->m[11] = m->m[12] = m->m[13] = m->m[14] = 0.0f;
- m->m[15] = 1.0f;
-}
-
-#endif
-
diff --git a/renderscript/v8/rs_support/scriptc/rs_sampler.rsh b/renderscript/v8/rs_support/scriptc/rs_sampler.rsh
deleted file mode 100644
index 2ff426c..0000000
--- a/renderscript/v8/rs_support/scriptc/rs_sampler.rsh
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** @file rs_sampler.rsh
- * \brief Sampler routines
- *
- *
- */
-
-#ifndef __RS_SAMPLER_RSH__
-#define __RS_SAMPLER_RSH__
-
-// New API's
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-/**
- * Get sampler minification value
- *
- * @param s sampler to query
- * @return minification value
- */
-extern rs_sampler_value __attribute__((overloadable))
- rsSamplerGetMinification(rs_sampler s);
-
-/**
- * Get sampler magnification value
- *
- * @param s sampler to query
- * @return magnification value
- */
-extern rs_sampler_value __attribute__((overloadable))
- rsSamplerGetMagnification(rs_sampler s);
-
-/**
- * Get sampler wrap S value
- *
- * @param s sampler to query
- * @return wrap S value
- */
-extern rs_sampler_value __attribute__((overloadable))
- rsSamplerGetWrapS(rs_sampler s);
-
-/**
- * Get sampler wrap T value
- *
- * @param s sampler to query
- * @return wrap T value
- */
-extern rs_sampler_value __attribute__((overloadable))
- rsSamplerGetWrapT(rs_sampler s);
-
-/**
- Get sampler anisotropy
- *
- * @param s sampler to query
- * @return anisotropy
- */
-extern float __attribute__((overloadable))
- rsSamplerGetAnisotropy(rs_sampler s);
-
-#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-#endif // __RS_SAMPLER_RSH__
-
diff --git a/renderscript/v8/rs_support/scriptc/rs_time.rsh b/renderscript/v8/rs_support/scriptc/rs_time.rsh
deleted file mode 100644
index 60e3dee..0000000
--- a/renderscript/v8/rs_support/scriptc/rs_time.rsh
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** @file rs_time.rsh
- * \brief Renderscript time routines
- *
- * This file contains Renderscript functions relating to time and date
- * manipulation.
- */
-
-#ifndef __RS_TIME_RSH__
-#define __RS_TIME_RSH__
-
-/**
- * Calendar time interpreted as seconds elapsed since the Epoch (00:00:00 on
- * January 1, 1970, Coordinated Universal Time (UTC)).
- */
-typedef int rs_time_t;
-
-/**
- * Data structure for broken-down time components.
- *
- * tm_sec - Seconds after the minute. This ranges from 0 to 59, but possibly
- * up to 60 for leap seconds.
- * tm_min - Minutes after the hour. This ranges from 0 to 59.
- * tm_hour - Hours past midnight. This ranges from 0 to 23.
- * tm_mday - Day of the month. This ranges from 1 to 31.
- * tm_mon - Months since January. This ranges from 0 to 11.
- * tm_year - Years since 1900.
- * tm_wday - Days since Sunday. This ranges from 0 to 6.
- * tm_yday - Days since January 1. This ranges from 0 to 365.
- * tm_isdst - Flag to indicate whether daylight saving time is in effect. The
- * value is positive if it is in effect, zero if it is not, and
- * negative if the information is not available.
- */
-typedef struct {
- int tm_sec; ///< seconds
- int tm_min; ///< minutes
- int tm_hour; ///< hours
- int tm_mday; ///< day of the month
- int tm_mon; ///< month
- int tm_year; ///< year
- int tm_wday; ///< day of the week
- int tm_yday; ///< day of the year
- int tm_isdst; ///< daylight savings time
-} rs_tm;
-
-/**
- * Returns the number of seconds since the Epoch (00:00:00 UTC, January 1,
- * 1970). If @p timer is non-NULL, the result is also stored in the memory
- * pointed to by this variable. If an error occurs, a value of -1 is returned.
- *
- * @param timer Location to also store the returned calendar time.
- *
- * @return Seconds since the Epoch.
- */
-extern rs_time_t __attribute__((overloadable))
- rsTime(rs_time_t *timer);
-
-/**
- * Converts the time specified by @p timer into broken-down time and stores it
- * in @p local. This function also returns a pointer to @p local. If @p local
- * is NULL, this function does nothing and returns NULL.
- *
- * @param local Broken-down time.
- * @param timer Input time as calendar time.
- *
- * @return Pointer to broken-down time (same as input @p local).
- */
-extern rs_tm * __attribute__((overloadable))
- rsLocaltime(rs_tm *local, const rs_time_t *timer);
-
-/**
- * Returns the current system clock (uptime) in milliseconds.
- *
- * @return Uptime in milliseconds.
- */
-extern int64_t __attribute__((overloadable))
- rsUptimeMillis(void);
-
-/**
- * Returns the current system clock (uptime) in nanoseconds.
- *
- * @return Uptime in nanoseconds.
- */
-extern int64_t __attribute__((overloadable))
- rsUptimeNanos(void);
-
-/**
- * Returns the time in seconds since this function was last called in this
- * script.
- *
- * @return Time in seconds.
- */
-extern float __attribute__((overloadable))
- rsGetDt(void);
-
-#endif
diff --git a/renderscript/v8/rs_support/scriptc/rs_types.rsh b/renderscript/v8/rs_support/scriptc/rs_types.rsh
deleted file mode 100644
index 5c99313..0000000
--- a/renderscript/v8/rs_support/scriptc/rs_types.rsh
+++ /dev/null
@@ -1,626 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** @file rs_types.rsh
- *
- * Define the standard Renderscript types
- *
- * Integers
- * 8 bit: char, int8_t
- * 16 bit: short, int16_t
- * 32 bit: int, in32_t
- * 64 bit: long, long long, int64_t
- *
- * Unsigned Integers
- * 8 bit: uchar, uint8_t
- * 16 bit: ushort, uint16_t
- * 32 bit: uint, uint32_t
- * 64 bit: ulong, uint64_t
- *
- * Floating point
- * 32 bit: float
- * 64 bit: double
- *
- * Vectors of length 2, 3, and 4 are supported for all the types above.
- *
- */
-
-#ifndef __RS_TYPES_RSH__
-#define __RS_TYPES_RSH__
-
-/* Constants */
-#define M_E 2.718281828459045235360287471352662498f /* e */
-#define M_LOG2E 1.442695040888963407359924681001892137f /* log_2 e */
-#define M_LOG10E 0.434294481903251827651128918916605082f /* log_10 e */
-#define M_LN2 0.693147180559945309417232121458176568f /* log_e 2 */
-#define M_LN10 2.302585092994045684017991454684364208f /* log_e 10 */
-#define M_PI 3.141592653589793238462643383279502884f /* pi */
-#define M_PI_2 1.570796326794896619231321691639751442f /* pi/2 */
-#define M_PI_4 0.785398163397448309615660845819875721f /* pi/4 */
-#define M_1_PI 0.318309886183790671537767526745028724f /* 1/pi */
-#define M_2_PIl 0.636619772367581343075535053490057448f /* 2/pi */
-#define M_2_SQRTPI 1.128379167095512573896158903121545172f /* 2/sqrt(pi) */
-#define M_SQRT2 1.414213562373095048801688724209698079f /* sqrt(2) */
-#define M_SQRT1_2 0.707106781186547524400844362104849039f /* 1/sqrt(2) */
-
-#include "stdbool.h"
-/**
- * 8 bit integer type
- */
-typedef char int8_t;
-/**
- * 16 bit integer type
- */
-typedef short int16_t;
-/**
- * 32 bit integer type
- */
-typedef int int32_t;
-/**
- * 64 bit integer type
- */
-typedef long long int64_t;
-/**
- * 8 bit unsigned integer type
- */
-typedef unsigned char uint8_t;
-/**
- * 16 bit unsigned integer type
- */
-typedef unsigned short uint16_t;
-/**
- * 32 bit unsigned integer type
- */
-typedef unsigned int uint32_t;
-/**
- * 64 bit unsigned integer type
- */
-typedef unsigned long long uint64_t;
-/**
- * 8 bit unsigned integer type
- */
-typedef uint8_t uchar;
-/**
- * 16 bit unsigned integer type
- */
-typedef uint16_t ushort;
-/**
- * 32 bit unsigned integer type
- */
-typedef uint32_t uint;
-/**
- * Typedef for unsigned long (use for 64-bit unsigned integers)
- */
-typedef uint64_t ulong;
-/**
- * Typedef for unsigned int
- */
-typedef uint32_t size_t;
-/**
- * Typedef for int (use for 32-bit integers)
- */
-typedef int32_t ssize_t;
-
-/**
- * \brief Opaque handle to a Renderscript element.
- *
- * See: android.renderscript.Element
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_element;
-/**
- * \brief Opaque handle to a Renderscript type.
- *
- * See: android.renderscript.Type
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_type;
-/**
- * \brief Opaque handle to a Renderscript allocation.
- *
- * See: android.renderscript.Allocation
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_allocation;
-/**
- * \brief Opaque handle to a Renderscript sampler object.
- *
- * See: android.renderscript.Sampler
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_sampler;
-/**
- * \brief Opaque handle to a Renderscript script object.
- *
- * See: android.renderscript.ScriptC
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_script;
-/**
- * \brief Opaque handle to a Renderscript mesh object.
- *
- * See: android.renderscript.Mesh
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_mesh;
-/**
- * \brief Opaque handle to a Renderscript Path object.
- *
- * See: android.renderscript.Path
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_path;
-/**
- * \brief Opaque handle to a Renderscript ProgramFragment object.
- *
- * See: android.renderscript.ProgramFragment
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_fragment;
-/**
- * \brief Opaque handle to a Renderscript ProgramVertex object.
- *
- * See: android.renderscript.ProgramVertex
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_vertex;
-/**
- * \brief Opaque handle to a Renderscript ProgramRaster object.
- *
- * See: android.renderscript.ProgramRaster
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_raster;
-/**
- * \brief Opaque handle to a Renderscript ProgramStore object.
- *
- * See: android.renderscript.ProgramStore
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_store;
-/**
- * \brief Opaque handle to a Renderscript font object.
- *
- * See: android.renderscript.Font
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_font;
-
-/**
- * Vector version of the basic float type.
- * Provides two float fields packed into a single 64 bit field with 64 bit
- * alignment.
- */
-typedef float float2 __attribute__((ext_vector_type(2)));
-/**
- * Vector version of the basic float type. Provides three float fields packed
- * into a single 128 bit field with 128 bit alignment.
- */
-typedef float float3 __attribute__((ext_vector_type(3)));
-/**
- * Vector version of the basic float type.
- * Provides four float fields packed into a single 128 bit field with 128 bit
- * alignment.
- */
-typedef float float4 __attribute__((ext_vector_type(4)));
-
-/**
- * Vector version of the basic double type. Provides two double fields packed
- * into a single 128 bit field with 128 bit alignment.
- */
-typedef double double2 __attribute__((ext_vector_type(2)));
-/**
- * Vector version of the basic double type. Provides three double fields packed
- * into a single 256 bit field with 256 bit alignment.
- */
-typedef double double3 __attribute__((ext_vector_type(3)));
-/**
- * Vector version of the basic double type. Provides four double fields packed
- * into a single 256 bit field with 256 bit alignment.
- */
-typedef double double4 __attribute__((ext_vector_type(4)));
-
-/**
- * Vector version of the basic uchar type. Provides two uchar fields packed
- * into a single 16 bit field with 16 bit alignment.
- */
-typedef uchar uchar2 __attribute__((ext_vector_type(2)));
-/**
- * Vector version of the basic uchar type. Provides three uchar fields packed
- * into a single 32 bit field with 32 bit alignment.
- */
-typedef uchar uchar3 __attribute__((ext_vector_type(3)));
-/**
- * Vector version of the basic uchar type. Provides four uchar fields packed
- * into a single 32 bit field with 32 bit alignment.
- */
-typedef uchar uchar4 __attribute__((ext_vector_type(4)));
-
-/**
- * Vector version of the basic ushort type. Provides two ushort fields packed
- * into a single 32 bit field with 32 bit alignment.
- */
-typedef ushort ushort2 __attribute__((ext_vector_type(2)));
-/**
- * Vector version of the basic ushort type. Provides three ushort fields packed
- * into a single 64 bit field with 64 bit alignment.
- */
-typedef ushort ushort3 __attribute__((ext_vector_type(3)));
-/**
- * Vector version of the basic ushort type. Provides four ushort fields packed
- * into a single 64 bit field with 64 bit alignment.
- */
-typedef ushort ushort4 __attribute__((ext_vector_type(4)));
-
-/**
- * Vector version of the basic uint type. Provides two uint fields packed into a
- * single 64 bit field with 64 bit alignment.
- */
-typedef uint uint2 __attribute__((ext_vector_type(2)));
-/**
- * Vector version of the basic uint type. Provides three uint fields packed into
- * a single 128 bit field with 128 bit alignment.
- */
-typedef uint uint3 __attribute__((ext_vector_type(3)));
-/**
- * Vector version of the basic uint type. Provides four uint fields packed into
- * a single 128 bit field with 128 bit alignment.
- */
-typedef uint uint4 __attribute__((ext_vector_type(4)));
-
-/**
- * Vector version of the basic ulong type. Provides two ulong fields packed into
- * a single 128 bit field with 128 bit alignment.
- */
-typedef ulong ulong2 __attribute__((ext_vector_type(2)));
-/**
- * Vector version of the basic ulong type. Provides three ulong fields packed
- * into a single 256 bit field with 256 bit alignment.
- */
-typedef ulong ulong3 __attribute__((ext_vector_type(3)));
-/**
- * Vector version of the basic ulong type. Provides four ulong fields packed
- * into a single 256 bit field with 256 bit alignment.
- */
-typedef ulong ulong4 __attribute__((ext_vector_type(4)));
-
-/**
- * Vector version of the basic char type. Provides two char fields packed into a
- * single 16 bit field with 16 bit alignment.
- */
-typedef char char2 __attribute__((ext_vector_type(2)));
-/**
- * Vector version of the basic char type. Provides three char fields packed into
- * a single 32 bit field with 32 bit alignment.
- */
-typedef char char3 __attribute__((ext_vector_type(3)));
-/**
- * Vector version of the basic char type. Provides four char fields packed into
- * a single 32 bit field with 32 bit alignment.
- */
-typedef char char4 __attribute__((ext_vector_type(4)));
-
-/**
- * Vector version of the basic short type. Provides two short fields packed into
- * a single 32 bit field with 32 bit alignment.
- */
-typedef short short2 __attribute__((ext_vector_type(2)));
-/**
- * Vector version of the basic short type. Provides three short fields packed
- * into a single 64 bit field with 64 bit alignment.
- */
-typedef short short3 __attribute__((ext_vector_type(3)));
-/**
- * Vector version of the basic short type. Provides four short fields packed
- * into a single 64 bit field with 64 bit alignment.
- */
-typedef short short4 __attribute__((ext_vector_type(4)));
-
-/**
- * Vector version of the basic int type. Provides two int fields packed into a
- * single 64 bit field with 64 bit alignment.
- */
-typedef int int2 __attribute__((ext_vector_type(2)));
-/**
- * Vector version of the basic int type. Provides three int fields packed into a
- * single 128 bit field with 128 bit alignment.
- */
-typedef int int3 __attribute__((ext_vector_type(3)));
-/**
- * Vector version of the basic int type. Provides two four fields packed into a
- * single 128 bit field with 128 bit alignment.
- */
-typedef int int4 __attribute__((ext_vector_type(4)));
-
-/**
- * Vector version of the basic long type. Provides two long fields packed into a
- * single 128 bit field with 128 bit alignment.
- */
-typedef long long2 __attribute__((ext_vector_type(2)));
-/**
- * Vector version of the basic long type. Provides three long fields packed into
- * a single 256 bit field with 256 bit alignment.
- */
-typedef long long3 __attribute__((ext_vector_type(3)));
-/**
- * Vector version of the basic long type. Provides four long fields packed into
- * a single 256 bit field with 256 bit alignment.
- */
-typedef long long4 __attribute__((ext_vector_type(4)));
-
-/**
- * \brief 4x4 float matrix
- *
- * Native holder for RS matrix. Elements are stored in the array at the
- * location [row*4 + col]
- */
-typedef struct {
- float m[16];
-} rs_matrix4x4;
-/**
- * \brief 3x3 float matrix
- *
- * Native holder for RS matrix. Elements are stored in the array at the
- * location [row*3 + col]
- */
-typedef struct {
- float m[9];
-} rs_matrix3x3;
-/**
- * \brief 2x2 float matrix
- *
- * Native holder for RS matrix. Elements are stored in the array at the
- * location [row*2 + col]
- */
-typedef struct {
- float m[4];
-} rs_matrix2x2;
-
-/**
- * quaternion type for use with the quaternion functions
- */
-typedef float4 rs_quaternion;
-
-#define RS_PACKED __attribute__((packed, aligned(4)))
-#define NULL ((void *)0)
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 14))
-
-/**
- * \brief Enum for selecting cube map faces
- */
-typedef enum {
- RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X = 0,
- RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_X = 1,
- RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Y = 2,
- RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Y = 3,
- RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Z = 4,
- RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Z = 5
-} rs_allocation_cubemap_face;
-
-/**
- * \brief Bitfield to specify the usage types for an allocation.
- *
- * These values are ORed together to specify which usages or memory spaces are
- * relevant to an allocation or an operation on an allocation.
- */
-typedef enum {
- RS_ALLOCATION_USAGE_SCRIPT = 0x0001,
- RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE = 0x0002,
- RS_ALLOCATION_USAGE_GRAPHICS_VERTEX = 0x0004,
- RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS = 0x0008,
- RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010
-} rs_allocation_usage_type;
-
-#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
-
-// New API's
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-/**
- * Describes the way mesh vertex data is interpreted when rendering
- *
- **/
-typedef enum {
- /**
- * Vertex data will be rendered as a series of points
- */
- RS_PRIMITIVE_POINT = 0,
- /**
- * Vertex pairs will be rendered as lines
- */
- RS_PRIMITIVE_LINE = 1,
- /**
- * Vertex data will be rendered as a connected line strip
- */
- RS_PRIMITIVE_LINE_STRIP = 2,
- /**
- * Vertices will be rendered as individual triangles
- */
- RS_PRIMITIVE_TRIANGLE = 3,
- /**
- * Vertices will be rendered as a connected triangle strip
- * defined by the first three vertices with each additional
- * triangle defined by a new vertex
- */
- RS_PRIMITIVE_TRIANGLE_STRIP = 4,
- /**
- * Vertices will be rendered as a sequence of triangles that all
- * share first vertex as the origin
- */
- RS_PRIMITIVE_TRIANGLE_FAN = 5,
-
- /**
- * Invalid primitive
- */
- RS_PRIMITIVE_INVALID = 100,
-} rs_primitive;
-
-/**
- * \brief Enumeration for possible element data types
- *
- * DataType represents the basic type information for a basic element. The
- * naming convention follows. For numeric types it is FLOAT,
- * SIGNED, or UNSIGNED followed by the _BITS where BITS is the
- * size of the data. BOOLEAN is a true / false (1,0)
- * represented in an 8 bit container. The UNSIGNED variants
- * with multiple bit definitions are for packed graphical data
- * formats and represent vectors with per vector member sizes
- * which are treated as a single unit for packing and alignment
- * purposes.
- *
- * MATRIX the three matrix types contain FLOAT_32 elements and are treated
- * as 32 bits for alignment purposes.
- *
- * RS_* objects. 32 bit opaque handles.
- */
-typedef enum {
- RS_TYPE_NONE = 0,
- RS_TYPE_FLOAT_32 = 2,
- RS_TYPE_FLOAT_64 = 3,
- RS_TYPE_SIGNED_8 = 4,
- RS_TYPE_SIGNED_16 = 5,
- RS_TYPE_SIGNED_32 = 6,
- RS_TYPE_SIGNED_64 = 7,
- RS_TYPE_UNSIGNED_8 = 8,
- RS_TYPE_UNSIGNED_16 = 9,
- RS_TYPE_UNSIGNED_32 = 10,
- RS_TYPE_UNSIGNED_64 = 11,
-
- RS_TYPE_BOOLEAN = 12,
-
- RS_TYPE_UNSIGNED_5_6_5 = 13,
- RS_TYPE_UNSIGNED_5_5_5_1 = 14,
- RS_TYPE_UNSIGNED_4_4_4_4 = 15,
-
- RS_TYPE_MATRIX_4X4 = 16,
- RS_TYPE_MATRIX_3X3 = 17,
- RS_TYPE_MATRIX_2X2 = 18,
-
- RS_TYPE_ELEMENT = 1000,
- RS_TYPE_TYPE = 1001,
- RS_TYPE_ALLOCATION = 1002,
- RS_TYPE_SAMPLER = 1003,
- RS_TYPE_SCRIPT = 1004,
- RS_TYPE_MESH = 1005,
- RS_TYPE_PROGRAM_FRAGMENT = 1006,
- RS_TYPE_PROGRAM_VERTEX = 1007,
- RS_TYPE_PROGRAM_RASTER = 1008,
- RS_TYPE_PROGRAM_STORE = 1009,
- RS_TYPE_FONT = 1010,
-
- RS_TYPE_INVALID = 10000,
-} rs_data_type;
-
-/**
- * \brief Enumeration for possible element data kind
- *
- * The special interpretation of the data if required. This is primarly
- * useful for graphical data. USER indicates no special interpretation is
- * expected. PIXEL is used in conjunction with the standard data types for
- * representing texture formats.
- */
-typedef enum {
- RS_KIND_USER = 0,
-
- RS_KIND_PIXEL_L = 7,
- RS_KIND_PIXEL_A = 8,
- RS_KIND_PIXEL_LA = 9,
- RS_KIND_PIXEL_RGB = 10,
- RS_KIND_PIXEL_RGBA = 11,
- RS_KIND_PIXEL_DEPTH = 12,
-
- RS_KIND_INVALID = 100,
-} rs_data_kind;
-
-typedef enum {
- /**
- * Always drawn
- */
- RS_DEPTH_FUNC_ALWAYS = 0,
- /**
- * Drawn if the incoming depth value is less than that in the
- * depth buffer
- */
- RS_DEPTH_FUNC_LESS = 1,
- /**
- * Drawn if the incoming depth value is less or equal to that in
- * the depth buffer
- */
- RS_DEPTH_FUNC_LEQUAL = 2,
- /**
- * Drawn if the incoming depth value is greater than that in the
- * depth buffer
- */
- RS_DEPTH_FUNC_GREATER = 3,
- /**
- * Drawn if the incoming depth value is greater or equal to that
- * in the depth buffer
- */
- RS_DEPTH_FUNC_GEQUAL = 4,
- /**
- * Drawn if the incoming depth value is equal to that in the
- * depth buffer
- */
- RS_DEPTH_FUNC_EQUAL = 5,
- /**
- * Drawn if the incoming depth value is not equal to that in the
- * depth buffer
- */
- RS_DEPTH_FUNC_NOTEQUAL = 6,
- /**
- * Invalid depth function
- */
- RS_DEPTH_FUNC_INVALID = 100,
-} rs_depth_func;
-
-typedef enum {
- RS_BLEND_SRC_ZERO = 0,
- RS_BLEND_SRC_ONE = 1,
- RS_BLEND_SRC_DST_COLOR = 2,
- RS_BLEND_SRC_ONE_MINUS_DST_COLOR = 3,
- RS_BLEND_SRC_SRC_ALPHA = 4,
- RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA = 5,
- RS_BLEND_SRC_DST_ALPHA = 6,
- RS_BLEND_SRC_ONE_MINUS_DST_ALPHA = 7,
- RS_BLEND_SRC_SRC_ALPHA_SATURATE = 8,
-
- RS_BLEND_SRC_INVALID = 100,
-} rs_blend_src_func;
-
-typedef enum {
- RS_BLEND_DST_ZERO = 0,
- RS_BLEND_DST_ONE = 1,
- RS_BLEND_DST_SRC_COLOR = 2,
- RS_BLEND_DST_ONE_MINUS_SRC_COLOR = 3,
- RS_BLEND_DST_SRC_ALPHA = 4,
- RS_BLEND_DST_ONE_MINUS_SRC_ALPHA = 5,
- RS_BLEND_DST_DST_ALPHA = 6,
- RS_BLEND_DST_ONE_MINUS_DST_ALPHA = 7,
-
- RS_BLEND_DST_INVALID = 100,
-} rs_blend_dst_func;
-
-typedef enum {
- RS_CULL_BACK = 0,
- RS_CULL_FRONT = 1,
- RS_CULL_NONE = 2,
-
- RS_CULL_INVALID = 100,
-} rs_cull_mode;
-
-typedef enum {
- RS_SAMPLER_NEAREST = 0,
- RS_SAMPLER_LINEAR = 1,
- RS_SAMPLER_LINEAR_MIP_LINEAR = 2,
- RS_SAMPLER_WRAP = 3,
- RS_SAMPLER_CLAMP = 4,
- RS_SAMPLER_LINEAR_MIP_NEAREST = 5,
-
- RS_SAMPLER_INVALID = 100,
-} rs_sampler_value;
-
-#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-#endif // __RS_TYPES_RSH__
diff --git a/renderscript/v8/rs_support/spec.h b/renderscript/v8/rs_support/spec.h
deleted file mode 100644
index ecc5cc7..0000000
--- a/renderscript/v8/rs_support/spec.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef SPEC_H
-#define SPEC_H
-
-#include <string.h>
-#include <stdlib.h>
-
-#if __cplusplus
-extern "C" {
-#endif
-
-extern int num_lines;
-
-typedef struct {
- int isConst;
- int type;
- int bits;
- int ptrLevel;
- char name[256];
- char typeName[256];
-} VarType;
-
-extern VarType *currType;
-
-typedef struct {
- char name[256];
- int sync;
- int handcodeApi;
- int direct;
- int nocontext;
- int paramCount;
- VarType ret;
- VarType params[16];
-} ApiEntry;
-
-extern ApiEntry apis[128];
-extern int apiCount;
-
-extern int typeNextState;
-
-#if __cplusplus
-} // extern "C"
-#endif
-
-#endif // SPEC_H
diff --git a/renderscript/v8/rs_support/spec.l b/renderscript/v8/rs_support/spec.l
deleted file mode 100644
index a24bfd3..0000000
--- a/renderscript/v8/rs_support/spec.l
+++ /dev/null
@@ -1,198 +0,0 @@
-%option stack
-
-%x comment
-%x api_entry
-%x api_entry2
-%x api_entry_param
-%x var_type
-
-DIGIT [0-9]
-ID [a-zA-Z_][a-zA-Z0-9_]*
-
- #include "spec.h"
-
- int num_lines = 0;
-
- VarType *currType = 0;
-
- ApiEntry apis[128];
- int apiCount = 0;
-
- int typeNextState;
-
- void checkPointerType() {
- VarType *baseType = currType;
- int curPtrLevel = 0;
- while (curPtrLevel < baseType->ptrLevel) {
- currType = &apis[apiCount].params[apis[apiCount].paramCount];
- currType->type = 4;
- currType->ptrLevel = curPtrLevel;
- if (currType->ptrLevel > 0) {
- currType->isConst = 1;
- }
- sprintf(currType->typeName, "%s", "size_t");
- switch(baseType->ptrLevel - curPtrLevel) {
- case 1:
- sprintf(currType->name, "%s_length", baseType->name);
- break;
- case 2:
- sprintf(currType->name, "%s_length_length", baseType->name);
- break;
- }
- apis[apiCount].paramCount++;
- curPtrLevel ++;
- }
- }
-
- extern "C" int yylex();
-
-%%
-
-"/*" BEGIN(comment);
-<comment>[^*\n]* /* eat anything that's not a '*' */
-<comment>"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */
-<comment>\n ++num_lines;
-<comment>"*"+"/" BEGIN(INITIAL);
-
-<*>" " //printf("found ' '\n");
-<*>"\t" //printf("found ' '\n");
-<*>"\n" ++num_lines; //printf("found lf \n");
-
-{ID} {
- memset(&apis[apiCount], 0, sizeof(ApiEntry));
- memcpy(apis[apiCount].name, yytext, yyleng);
- BEGIN(api_entry);
- }
-
-<api_entry>"{" {
- BEGIN(api_entry2);
- }
-
-<api_entry2>"sync" {
- apis[apiCount].sync = 1;
- }
-
-<api_entry2>"handcodeApi" {
- apis[apiCount].handcodeApi = 1;
- }
-
-<api_entry2>"direct" {
- apis[apiCount].direct = 1;
- }
-
-<api_entry2>"nocontext" {
- apis[apiCount].nocontext = 1;
- }
-
-<api_entry2>"ret" {
- currType = &apis[apiCount].ret;
- typeNextState = api_entry2;
- BEGIN(var_type);
- }
-
-<api_entry2>"param" {
- currType = &apis[apiCount].params[apis[apiCount].paramCount];
- apis[apiCount].paramCount++;
- typeNextState = api_entry_param;
- BEGIN(var_type);
- }
-
-<var_type>"const" {
- currType->isConst = 1;
- }
-
-<var_type>"i8" {
- currType->type = 1;
- currType->bits = 8;
- BEGIN(typeNextState);
- }
-
-<var_type>"i16" {
- currType->type = 1;
- currType->bits = 16;
- BEGIN(typeNextState);
- }
-
-<var_type>"i32" {
- currType->type = 1;
- currType->bits = 32;
- BEGIN(typeNextState);
- }
-
-<var_type>"i64" {
- currType->type = 1;
- currType->bits = 64;
- BEGIN(typeNextState);
- }
-
-<var_type>"u8" {
- currType->type = 2;
- currType->bits = 8;
- BEGIN(typeNextState);
- }
-
-<var_type>"u16" {
- currType->type = 2;
- currType->bits = 16;
- BEGIN(typeNextState);
- }
-
-<var_type>"u32" {
- currType->type = 2;
- currType->bits = 32;
- BEGIN(typeNextState);
- }
-
-<var_type>"u64" {
- currType->type = 2;
- currType->bits = 64;
- BEGIN(typeNextState);
- }
-
-<var_type>"f" {
- currType->type = 3;
- currType->bits = 32;
- BEGIN(typeNextState);
- }
-
-<var_type>"d" {
- currType->type = 3;
- currType->bits = 64;
- BEGIN(typeNextState);
- }
-
-<var_type>{ID} {
- currType->type = 4;
- currType->bits = 32;
- memcpy(currType->typeName, yytext, yyleng);
- BEGIN(typeNextState);
- }
-
-<api_entry_param>"*" {
- currType->ptrLevel ++;
- }
-
-<api_entry_param>{ID} {
- memcpy(currType->name, yytext, yyleng);
- checkPointerType();
- BEGIN(api_entry2);
- }
-
-<api_entry2>"*" {
- currType->ptrLevel ++;
- }
-
-<api_entry2>"}" {
- apiCount++;
- BEGIN(INITIAL);
- }
-
-
-%%
-
-
-int yywrap()
-{
- return 1;
-}
-
diff --git a/v13/Android.mk b/v13/Android.mk
index 2ba726f..7101fed 100644
--- a/v13/Android.mk
+++ b/v13/Android.mk
@@ -19,16 +19,25 @@
# A helper sub-library that makes direct use of Ice Cream Sandwich APIs.
include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-v13-ics-mr1
-LOCAL_SDK_VERSION := 15
-LOCAL_SRC_FILES := $(call all-java-files-under, ics-mr1)
+LOCAL_MODULE := android-support-v13-ics
+LOCAL_SDK_VERSION := 14
+LOCAL_SRC_FILES := $(call all-java-files-under, ics)
include $(BUILD_STATIC_JAVA_LIBRARY)
# A helper sub-library that makes direct use of Ice Cream Sandwich APIs.
include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-v13-ics
-LOCAL_SDK_VERSION := 14
-LOCAL_SRC_FILES := $(call all-java-files-under, ics)
+LOCAL_MODULE := android-support-v13-ics-mr1
+LOCAL_SDK_VERSION := 15
+LOCAL_SRC_FILES := $(call all-java-files-under, ics-mr1)
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-v13-ics
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+# A helper sub-library that makes direct use of K APIs.
+include $(CLEAR_VARS)
+LOCAL_MODULE := android-support-v13-k
+LOCAL_SDK_VERSION := current
+LOCAL_SRC_FILES := $(call all-java-files-under, k)
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-v13-ics-mr1
include $(BUILD_STATIC_JAVA_LIBRARY)
# -----------------------------------------------------------------------
@@ -38,8 +47,7 @@
LOCAL_SDK_VERSION := 13
LOCAL_SRC_FILES := $(call all-java-files-under, java)
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4 \
- android-support-v13-ics \
- android-support-v13-ics-mr1
+ android-support-v13-k
include $(BUILD_STATIC_JAVA_LIBRARY)
# Include this library in the build server's output directory
diff --git a/v4/Android.mk b/v4/Android.mk
index f05aee4..e82b94e 100644
--- a/v4/Android.mk
+++ b/v4/Android.mk
@@ -14,9 +14,6 @@
LOCAL_PATH := $(call my-dir)
-# Note: the source code is in java/, not src/, because this code is also part of
-# the framework library, and build/core/pathmap.mk expects a java/ subdirectory.
-
# A helper sub-library that makes direct use of Eclair APIs.
include $(CLEAR_VARS)
LOCAL_MODULE := android-support-v4-eclair
@@ -31,6 +28,7 @@
LOCAL_MODULE := android-support-v4-froyo
LOCAL_SDK_VERSION := 8
LOCAL_SRC_FILES := $(call all-java-files-under, froyo)
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4-eclair
include $(BUILD_STATIC_JAVA_LIBRARY)
# -----------------------------------------------------------------------
@@ -40,6 +38,7 @@
LOCAL_MODULE := android-support-v4-gingerbread
LOCAL_SDK_VERSION := 9
LOCAL_SRC_FILES := $(call all-java-files-under, gingerbread)
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4-froyo
include $(BUILD_STATIC_JAVA_LIBRARY)
# -----------------------------------------------------------------------
@@ -49,6 +48,7 @@
LOCAL_MODULE := android-support-v4-honeycomb
LOCAL_SDK_VERSION := 11
LOCAL_SRC_FILES := $(call all-java-files-under, honeycomb)
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4-gingerbread
include $(BUILD_STATIC_JAVA_LIBRARY)
# -----------------------------------------------------------------------
@@ -58,6 +58,7 @@
LOCAL_MODULE := android-support-v4-honeycomb-mr2
LOCAL_SDK_VERSION := 13
LOCAL_SRC_FILES := $(call all-java-files-under, honeycomb_mr2)
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4-honeycomb
include $(BUILD_STATIC_JAVA_LIBRARY)
# -----------------------------------------------------------------------
@@ -67,6 +68,7 @@
LOCAL_MODULE := android-support-v4-ics
LOCAL_SDK_VERSION := 14
LOCAL_SRC_FILES := $(call all-java-files-under, ics)
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4-honeycomb-mr2
include $(BUILD_STATIC_JAVA_LIBRARY)
# -----------------------------------------------------------------------
@@ -76,6 +78,7 @@
LOCAL_MODULE := android-support-v4-ics-mr1
LOCAL_SDK_VERSION := 15
LOCAL_SRC_FILES := $(call all-java-files-under, ics-mr1)
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4-ics
include $(BUILD_STATIC_JAVA_LIBRARY)
# -----------------------------------------------------------------------
@@ -85,6 +88,7 @@
LOCAL_MODULE := android-support-v4-jellybean
LOCAL_SDK_VERSION := 16
LOCAL_SRC_FILES := $(call all-java-files-under, jellybean)
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4-ics-mr1
include $(BUILD_STATIC_JAVA_LIBRARY)
# -----------------------------------------------------------------------
@@ -94,6 +98,17 @@
LOCAL_MODULE := android-support-v4-jellybean-mr1
LOCAL_SDK_VERSION := 17
LOCAL_SRC_FILES := $(call all-java-files-under, jellybean-mr1)
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4-jellybean
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+# -----------------------------------------------------------------------
+
+# A helper sub-library that makes direct use of JellyBean MR2 APIs.
+include $(CLEAR_VARS)
+LOCAL_MODULE := android-support-v4-jellybean-mr2
+LOCAL_SDK_VERSION := current
+LOCAL_SRC_FILES := $(call all-java-files-under, jellybean-mr2)
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4-jellybean-mr1
include $(BUILD_STATIC_JAVA_LIBRARY)
# -----------------------------------------------------------------------
@@ -103,16 +118,7 @@
LOCAL_MODULE := android-support-v4
LOCAL_SDK_VERSION := 4
LOCAL_SRC_FILES := $(call all-java-files-under, java)
-LOCAL_STATIC_JAVA_LIBRARIES += \
- android-support-v4-eclair \
- android-support-v4-froyo \
- android-support-v4-gingerbread \
- android-support-v4-honeycomb \
- android-support-v4-honeycomb-mr2 \
- android-support-v4-ics \
- android-support-v4-ics-mr1 \
- android-support-v4-jellybean \
- android-support-v4-jellybean-mr1
+LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4-jellybean-mr2
include $(BUILD_STATIC_JAVA_LIBRARY)
# Include this library in the build server's output directory
diff --git a/v4/eclair/android/support/v4/view/KeyEventCompatEclair.java b/v4/eclair/android/support/v4/view/KeyEventCompatEclair.java
index aa60edb..b3b0d11 100644
--- a/v4/eclair/android/support/v4/view/KeyEventCompatEclair.java
+++ b/v4/eclair/android/support/v4/view/KeyEventCompatEclair.java
@@ -18,8 +18,18 @@
package android.support.v4.view;
import android.view.KeyEvent;
+import android.view.View;
class KeyEventCompatEclair {
+ public static Object getKeyDispatcherState(View view) {
+ return view.getKeyDispatcherState();
+ }
+
+ public static boolean dispatch(KeyEvent event, KeyEvent.Callback receiver, Object state,
+ Object target) {
+ return event.dispatch(receiver, (KeyEvent.DispatcherState)state, target);
+ }
+
public static void startTracking(KeyEvent event) {
event.startTracking();
}
diff --git a/v4/ics/android/support/v4/text/ICUCompatIcs.java b/v4/ics/android/support/v4/text/ICUCompatIcs.java
new file mode 100644
index 0000000..7dc5d3c
--- /dev/null
+++ b/v4/ics/android/support/v4/text/ICUCompatIcs.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.text;
+
+import android.util.Log;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+class ICUCompatIcs {
+
+ private static final String TAG = "ICUCompatIcs";
+
+ private static Method sGetScriptMethod;
+ private static Method sAddLikelySubtagsMethod;
+
+ static {
+ try {
+ final Class<?> clazz = Class.forName("libcore.icu.ICU");
+ if (clazz != null) {
+ sGetScriptMethod = clazz.getMethod("getScript",
+ new Class[]{ String.class });
+ sAddLikelySubtagsMethod = clazz.getMethod("addLikelySubtags",
+ new Class[]{ String.class });
+ }
+ } catch (Exception e) {
+ // Nothing we can do here, we just log the exception
+ Log.w(TAG, e);
+ }
+ }
+
+ public static String getScript(String locale) {
+ try {
+ if (sGetScriptMethod != null) {
+ final Object[] args = new Object[] { locale };
+ return (String) sGetScriptMethod.invoke(null, args);
+ }
+ } catch (IllegalAccessException e) {
+ // Nothing we can do here, we just log the exception
+ Log.w(TAG, e);
+ }
+ catch (InvocationTargetException e) {
+ // Nothing we can do here, we just log the exception
+ Log.w(TAG, e);
+ }
+ return null;
+ }
+
+ public static String addLikelySubtags(String locale) {
+ try {
+ if (sAddLikelySubtagsMethod != null) {
+ final Object[] args = new Object[] { locale };
+ return (String) sAddLikelySubtagsMethod.invoke(null, args);
+ }
+ } catch (IllegalAccessException e) {
+ // Nothing we can do here, we just log the exception
+ Log.w(TAG, e);
+ }
+ catch (InvocationTargetException e) {
+ // Nothing we can do here, we just log the exception
+ Log.w(TAG, e);
+ }
+ return locale;
+ }
+}
diff --git a/v4/java/android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat.java b/v4/java/android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat.java
index 4a2fff6..cb1f24c 100644
--- a/v4/java/android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat.java
+++ b/v4/java/android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat.java
@@ -20,6 +20,7 @@
import android.accessibilityservice.AccessibilityServiceInfo;
import android.content.pm.ResolveInfo;
import android.os.Build;
+import android.view.View;
/**
* Helper for accessing features in {@link android.accessibilityservice.AccessibilityService}
@@ -33,6 +34,7 @@
public boolean getCanRetrieveWindowContent(AccessibilityServiceInfo info);
public String getDescription(AccessibilityServiceInfo info);
public String getSettingsActivityName(AccessibilityServiceInfo info);
+ public int getCapabilities(AccessibilityServiceInfo info);
}
static class AccessibilityServiceInfoStubImpl implements AccessibilityServiceInfoVersionImpl {
@@ -56,6 +58,10 @@
public String getSettingsActivityName(AccessibilityServiceInfo info) {
return null;
}
+
+ public int getCapabilities(AccessibilityServiceInfo info) {
+ return 0;
+ }
}
static class AccessibilityServiceInfoIcsImpl extends AccessibilityServiceInfoStubImpl {
@@ -84,19 +90,68 @@
public String getSettingsActivityName(AccessibilityServiceInfo info) {
return AccessibilityServiceInfoCompatIcs.getSettingsActivityName(info);
}
+
+ @Override
+ public int getCapabilities(AccessibilityServiceInfo info) {
+ if (getCanRetrieveWindowContent(info)) {
+ return CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT;
+ }
+ return 0;
+ }
+ }
+
+ static class AccessibilityServiceInfoJellyBeanMr2 extends AccessibilityServiceInfoIcsImpl {
+ @Override
+ public int getCapabilities(AccessibilityServiceInfo info) {
+ return AccessibilityServiceInfoCompatJellyBeanMr2.getCapabilities(info);
+ }
}
static {
- if (Build.VERSION.SDK_INT >= 14) { // ICS
+ // TODO: Update this as soon as the APIs are final (bug:8644149)
+ if ("JellyBeanMR2".equals(Build.VERSION.CODENAME)) {
+ IMPL = new AccessibilityServiceInfoJellyBeanMr2();
+ } else if (Build.VERSION.SDK_INT >= 14) { // ICS
IMPL = new AccessibilityServiceInfoIcsImpl();
} else {
IMPL = new AccessibilityServiceInfoStubImpl();
}
}
+ // Capabilities
+
private static final AccessibilityServiceInfoVersionImpl IMPL;
/**
+ * Capability: This accessibility service can retrieve the active window content.
+ */
+ public static final int CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT = 0x00000001;
+
+ /**
+ * Capability: This accessibility service can request touch exploration mode in which
+ * touched items are spoken aloud and the UI can be explored via gestures.
+ */
+ public static final int CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION = 0x00000002;
+
+ /**
+ * Capability: This accessibility service can request enhanced web accessibility
+ * enhancements. For example, installing scripts to make app content more accessible.
+ */
+ public static final int CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY = 0x00000004;
+
+ /**
+ * Capability: This accessibility service can filter the key event stream.
+ */
+ public static final int CAPABILITY_CAN_FILTER_KEY_EVENTS = 0x00000008;
+
+ // Feedback types
+
+ /**
+ * Denotes braille feedback.
+ */
+ public static final int FEEDBACK_BRAILLE = 0x0000020;
+
+ /**
* Mask for all feedback types.
*
* @see AccessibilityServiceInfo#FEEDBACK_SPOKEN
@@ -104,9 +159,121 @@
* @see AccessibilityServiceInfo#FEEDBACK_AUDIBLE
* @see AccessibilityServiceInfo#FEEDBACK_VISUAL
* @see AccessibilityServiceInfo#FEEDBACK_GENERIC
+ * @see FEEDBACK_BRAILLE
*/
public static final int FEEDBACK_ALL_MASK = 0xFFFFFFFF;
+ // Flags
+
+ /**
+ * If an {@link AccessibilityService} is the default for a given type.
+ * Default service is invoked only if no package specific one exists. In case of
+ * more than one package specific service only the earlier registered is notified.
+ */
+ public static final int DEFAULT = 0x0000001;
+
+ /**
+ * If this flag is set the system will regard views that are not important
+ * for accessibility in addition to the ones that are important for accessibility.
+ * That is, views that are marked as not important for accessibility via
+ * {@link View#IMPORTANT_FOR_ACCESSIBILITY_NO} and views that are marked as
+ * potentially important for accessibility via
+ * {@link View#IMPORTANT_FOR_ACCESSIBILITY_AUTO} for which the system has determined
+ * that are not important for accessibility, are both reported while querying the
+ * window content and also the accessibility service will receive accessibility events
+ * from them.
+ * <p>
+ * <strong>Note:</strong> For accessibility services targeting API version
+ * {@link Build.VERSION_CODES#JELLY_BEAN} or higher this flag has to be explicitly
+ * set for the system to regard views that are not important for accessibility. For
+ * accessibility services targeting API version lower than
+ * {@link Build.VERSION_CODES#JELLY_BEAN} this flag is ignored and all views are
+ * regarded for accessibility purposes.
+ * </p>
+ * <p>
+ * Usually views not important for accessibility are layout managers that do not
+ * react to user actions, do not draw any content, and do not have any special
+ * semantics in the context of the screen content. For example, a three by three
+ * grid can be implemented as three horizontal linear layouts and one vertical,
+ * or three vertical linear layouts and one horizontal, or one grid layout, etc.
+ * In this context the actual layout mangers used to achieve the grid configuration
+ * are not important, rather it is important that there are nine evenly distributed
+ * elements.
+ * </p>
+ */
+ public static final int FLAG_INCLUDE_NOT_IMPORTANT_VIEWS = 0x0000002;
+
+ /**
+ * This flag requests that the system gets into touch exploration mode.
+ * In this mode a single finger moving on the screen behaves as a mouse
+ * pointer hovering over the user interface. The system will also detect
+ * certain gestures performed on the touch screen and notify this service.
+ * The system will enable touch exploration mode if there is at least one
+ * accessibility service that has this flag set. Hence, clearing this
+ * flag does not guarantee that the device will not be in touch exploration
+ * mode since there may be another enabled service that requested it.
+ * <p>
+ * For accessibility services targeting API version higher than
+ * {@link Build.VERSION_CODES#JELLY_BEAN_MR1} that want to set
+ * this flag have to declare this capability in their meta-data by setting
+ * the attribute canRequestTouchExplorationMode to true, otherwise this flag
+ * will be ignored. For how to declare the meta-data of a service refer to
+ * {@value AccessibilityService#SERVICE_META_DATA}.
+ * </p>
+ * <p>
+ * Services targeting API version equal to or lower than
+ * {@link Build.VERSION_CODES#JELLY_BEAN_MR1} will work normally, i.e.
+ * the first time they are run, if this flag is specified, a dialog is
+ * shown to the user to confirm enabling explore by touch.
+ * </p>
+ */
+ public static final int FLAG_REQUEST_TOUCH_EXPLORATION_MODE = 0x0000004;
+
+ /**
+ * This flag requests from the system to enable web accessibility enhancing
+ * extensions. Such extensions aim to provide improved accessibility support
+ * for content presented in a {@link android.webkit.WebView}. An example of such
+ * an extension is injecting JavaScript from a secure source. The system will enable
+ * enhanced web accessibility if there is at least one accessibility service
+ * that has this flag set. Hence, clearing this flag does not guarantee that the
+ * device will not have enhanced web accessibility enabled since there may be
+ * another enabled service that requested it.
+ * <p>
+ * Services that want to set this flag have to declare this capability
+ * in their meta-data by setting the attribute canRequestEnhancedWebAccessibility
+ * to true, otherwise this flag will be ignored. For how to declare the meta-data
+ * of a service refer to {@value AccessibilityService#SERVICE_META_DATA}.
+ * </p>
+ */
+ public static final int FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY = 0x00000008;
+
+ /**
+ * This flag requests that the AccessibilityNodeInfos obtained
+ * by an {@link AccessibilityService} contain the id of the source view.
+ * The source view id will be a fully qualified resource name of the
+ * form "package:id/name", for example "foo.bar:id/my_list", and it is
+ * useful for UI test automation. This flag is not set by default.
+ */
+ public static final int FLAG_REPORT_VIEW_IDS = 0x00000010;
+
+ /**
+ * This flag requests from the system to filter key events. If this flag
+ * is set the accessibility service will receive the key events before
+ * applications allowing it implement global shortcuts. Setting this flag
+ * does not guarantee that this service will filter key events since only
+ * one service can do so at any given time. This avoids user confusion due
+ * to behavior change in case different key filtering services are enabled.
+ * If there is already another key filtering service enabled, this one will
+ * not receive key events.
+ * <p>
+ * Services that want to set this flag have to declare this capability
+ * in their meta-data by setting the attribute canRequestFilterKeyEvents
+ * to true, otherwise this flag will be ignored. For how to declare the meta
+ * -data of a service refer to {@value AccessibilityService#SERVICE_META_DATA}.
+ * </p>
+ */
+ public static final int FLAG_REQUEST_FILTER_KEY_EVENTS = 0x00000020;
+
/*
* Hide constructor
*/
@@ -226,10 +393,59 @@
*/
public static String flagToString(int flag) {
switch (flag) {
- case AccessibilityServiceInfo.DEFAULT:
+ case DEFAULT:
return "DEFAULT";
+ case FLAG_INCLUDE_NOT_IMPORTANT_VIEWS:
+ return "FLAG_INCLUDE_NOT_IMPORTANT_VIEWS";
+ case FLAG_REQUEST_TOUCH_EXPLORATION_MODE:
+ return "FLAG_REQUEST_TOUCH_EXPLORATION_MODE";
+ case FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY:
+ return "FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY";
+ case FLAG_REPORT_VIEW_IDS:
+ return "FLAG_REPORT_VIEW_IDS";
+ case FLAG_REQUEST_FILTER_KEY_EVENTS:
+ return "FLAG_REQUEST_FILTER_KEY_EVENTS";
default:
return null;
}
}
+
+ /**
+ * Returns the bit mask of capabilities this accessibility service has such as
+ * being able to retrieve the active window content, etc.
+ *
+ * @param info The service info whose capabilities to get.
+ * @return The capability bit mask.
+ *
+ * @see #CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT
+ * @see #CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION
+ * @see #CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY
+ * @see #CAPABILITY_CAN_FILTER_KEY_EVENTS
+ */
+ public static int getCapabilities(AccessibilityServiceInfo info) {
+ return IMPL.getCapabilities(info);
+ }
+
+ /**
+ * Returns the string representation of a capability. For example,
+ * {@link #CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT} is represented
+ * by the string CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT.
+ *
+ * @param capability The capability.
+ * @return The string representation.
+ */
+ public static String capabilityToString(int capability) {
+ switch (capability) {
+ case CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT:
+ return "CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT";
+ case CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION:
+ return "CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION";
+ case CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY:
+ return "CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY";
+ case CAPABILITY_CAN_FILTER_KEY_EVENTS:
+ return "CAPABILITY_CAN_FILTER_KEY_EVENTS";
+ default:
+ return "UNKNOWN";
+ }
+ }
}
diff --git a/v4/java/android/support/v4/app/ActivityCompat.java b/v4/java/android/support/v4/app/ActivityCompat.java
index 4bdfd90..a30eff2 100644
--- a/v4/java/android/support/v4/app/ActivityCompat.java
+++ b/v4/java/android/support/v4/app/ActivityCompat.java
@@ -119,4 +119,20 @@
activity.startActivityForResult(intent, requestCode);
}
}
+
+ /**
+ * Finish this activity, and tries to finish all activities immediately below it
+ * in the current task that have the same affinity.
+ *
+ * <p>On Android 4.1+ calling this method will call through to the native version of this
+ * method. For other platforms {@link Activity#finish()} will be called instead.</p>
+ */
+ public static void finishAffinity(Activity activity) {
+ if (Build.VERSION.SDK_INT >= 16) {
+ ActivityCompatJB.finishAffinity(activity);
+ } else {
+ activity.finish();
+ }
+ }
+
}
diff --git a/v4/java/android/support/v4/app/Fragment.java b/v4/java/android/support/v4/app/Fragment.java
index 3d27050..12022d6 100644
--- a/v4/java/android/support/v4/app/Fragment.java
+++ b/v4/java/android/support/v4/app/Fragment.java
@@ -1319,7 +1319,7 @@
public boolean onContextItemSelected(MenuItem item) {
return false;
}
-
+
/**
* Print the Fragments's state into the given stream.
*
diff --git a/v4/java/android/support/v4/app/FragmentActivity.java b/v4/java/android/support/v4/app/FragmentActivity.java
index 00b124a..acb8181 100644
--- a/v4/java/android/support/v4/app/FragmentActivity.java
+++ b/v4/java/android/support/v4/app/FragmentActivity.java
@@ -117,7 +117,7 @@
boolean mLoadersStarted;
HashMap<String, LoaderManagerImpl> mAllLoaderManagers;
LoaderManagerImpl mLoaderManager;
-
+
static final class NonConfigurationInstances {
Object activity;
Object custom;
@@ -615,7 +615,9 @@
}
/**
- * Invalidate the activity's options menu. This will cause relevant presentations
+ * Support library version of {@link Activity#invalidateOptionsMenu}.
+ *
+ * <p>Invalidate the activity's options menu. This will cause relevant presentations
* of the menu to fully update via calls to onCreateOptionsMenu and
* onPrepareOptionsMenu the next time the menu is requested.
*/
@@ -631,7 +633,7 @@
// the options menu the next time it is prepared.
mOptionsMenuInvalidated = true;
}
-
+
/**
* Print the Activity's state into the given stream. This gets invoked if
* you run "adb shell dumpsys activity <activity_component_name>".
diff --git a/v4/java/android/support/v4/app/FragmentManager.java b/v4/java/android/support/v4/app/FragmentManager.java
index e1510c2..278bfc3 100644
--- a/v4/java/android/support/v4/app/FragmentManager.java
+++ b/v4/java/android/support/v4/app/FragmentManager.java
@@ -2008,7 +2008,7 @@
}
}
}
-
+
public static int reverseTransit(int transit) {
int rev = 0;
switch (transit) {
diff --git a/v4/java/android/support/v4/content/AsyncTaskLoader.java b/v4/java/android/support/v4/content/AsyncTaskLoader.java
index 74e74ce..22fe3a2 100644
--- a/v4/java/android/support/v4/content/AsyncTaskLoader.java
+++ b/v4/java/android/support/v4/content/AsyncTaskLoader.java
@@ -200,6 +200,7 @@
onCanceled(data);
if (mCancellingTask == task) {
if (DEBUG) Log.v(TAG, "Cancelled task is now canceled!");
+ rollbackContentChanged();
mLastLoadCompleteTime = SystemClock.uptimeMillis();
mCancellingTask = null;
executePendingTask();
@@ -215,6 +216,7 @@
// This cursor has been abandoned; just cancel the new data.
onCanceled(data);
} else {
+ commitContentChanged();
mLastLoadCompleteTime = SystemClock.uptimeMillis();
mTask = null;
if (DEBUG) Log.v(TAG, "Delivering result");
diff --git a/v4/java/android/support/v4/content/CursorLoader.java b/v4/java/android/support/v4/content/CursorLoader.java
index 01e386e..980e7d9 100644
--- a/v4/java/android/support/v4/content/CursorLoader.java
+++ b/v4/java/android/support/v4/content/CursorLoader.java
@@ -51,19 +51,11 @@
if (cursor != null) {
// Ensure the cursor window is filled
cursor.getCount();
- registerContentObserver(cursor, mObserver);
+ cursor.registerContentObserver(mObserver);
}
return cursor;
}
- /**
- * Registers an observer to get notifications from the content provider
- * when the cursor needs to be refreshed.
- */
- void registerContentObserver(Cursor cursor, ContentObserver observer) {
- cursor.registerContentObserver(mObserver);
- }
-
/* Runs on the UI thread */
@Override
public void deliverResult(Cursor cursor) {
diff --git a/v4/java/android/support/v4/content/FileProvider.java b/v4/java/android/support/v4/content/FileProvider.java
new file mode 100644
index 0000000..b97b45a
--- /dev/null
+++ b/v4/java/android/support/v4/content/FileProvider.java
@@ -0,0 +1,456 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.content;
+
+import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT;
+import static org.xmlpull.v1.XmlPullParser.START_TAG;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ProviderInfo;
+import android.content.res.XmlResourceParser;
+import android.database.Cursor;
+import android.database.MatrixCursor;
+import android.net.Uri;
+import android.os.Environment;
+import android.os.ParcelFileDescriptor;
+import android.provider.OpenableColumns;
+import android.text.TextUtils;
+import android.webkit.MimeTypeMap;
+
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Provider to support easy sharing of private files between apps. When paired
+ * with features like {@link Context#grantUriPermission(String, Uri, int)} or
+ * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION}, this provider ensures that
+ * receiving apps can always open the underlying file.
+ * <p>
+ * Apps should generally avoid sending raw filesystem paths across process
+ * boundaries, since the receiving app may not have the same access as the
+ * sender. Instead, apps should send {@link Uri} backed by a provider like
+ * {@link FileProvider}.
+ * <p>
+ * To use this provider, add it to your manifest:
+ * <p>
+ * {@sample development/samples/Support4Demos/AndroidManifest.xml
+ * file_provider_declaration}
+ * <p>
+ * And define one or more filesystem paths your provider should support in an
+ * XML resource. This provider will only support files which exist under these
+ * defined paths.
+ * <p>
+ * {@sample development/samples/Support4Demos/res/xml/my_paths.xml
+ * file_provider_paths_declaration}
+ * <p>
+ * Then use {@link #getUriForFile(Context, String, File)} at runtime to generate
+ * a {@link Uri} backed by the provider. Since the provider is not exported,
+ * these {@link Uri} can only be accessed by other apps when you explicitly
+ * grant access.
+ */
+public class FileProvider extends ContentProvider {
+ private static final String[] COLUMNS = {
+ OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE };
+
+ private static final String
+ META_DATA_FILE_PROVIDER_PATHS = "android.support.FILE_PROVIDER_PATHS";
+
+ private static final String TAG_ROOT_PATH = "root-path";
+ private static final String TAG_FILES_PATH = "files-path";
+ private static final String TAG_CACHE_PATH = "cache-path";
+ private static final String TAG_EXTERNAL = "external-path";
+
+ private static final String ATTR_NAME = "name";
+ private static final String ATTR_PATH = "path";
+
+ private static final File DEVICE_ROOT = new File("/");
+
+ // @GuardedBy("sCache")
+ private static HashMap<String, PathStrategy> sCache = new HashMap<String, PathStrategy>();
+
+ private PathStrategy mStrategy;
+
+ @Override
+ public boolean onCreate() {
+ return true;
+ }
+
+ @Override
+ public void attachInfo(Context context, ProviderInfo info) {
+ super.attachInfo(context, info);
+
+ // Sanity check our security
+ if (info.exported) {
+ throw new SecurityException("Provider must not be exported");
+ }
+ if (!info.grantUriPermissions) {
+ throw new SecurityException("Provider must grant uri permissions");
+ }
+
+ mStrategy = getPathStrategy(context, info.authority);
+ }
+
+ /**
+ * Return a {@link Uri} that provides access to the given {@link File}. The
+ * returned {@link Uri} can be used with features like
+ * {@link Context#grantUriPermission(String, Uri, int)} or
+ * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION} to allow other apps to
+ * access private files. Providers only support files which exist under
+ * filesystem paths defined in their {@code <meta-data>}.
+ *
+ * @param authority The authority of a {@link FileProvider} defined as a
+ * {@code <provider>} in your manifest.
+ * @throws IllegalArgumentException When the given {@link File} is outside
+ * the paths supported by the provider.
+ */
+ public static Uri getUriForFile(Context context, String authority, File file) {
+ final PathStrategy strategy = getPathStrategy(context, authority);
+ return strategy.getUriForFile(file);
+ }
+
+ @Override
+ public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
+ String sortOrder) {
+ // ContentProvider has already checked granted permissions
+ final File file = mStrategy.getFileForUri(uri);
+
+ if (projection == null) {
+ projection = COLUMNS;
+ }
+
+ String[] cols = new String[projection.length];
+ Object[] values = new Object[projection.length];
+ int i = 0;
+ for (String col : projection) {
+ if (OpenableColumns.DISPLAY_NAME.equals(col)) {
+ cols[i] = OpenableColumns.DISPLAY_NAME;
+ values[i++] = file.getName();
+ } else if (OpenableColumns.SIZE.equals(col)) {
+ cols[i] = OpenableColumns.SIZE;
+ values[i++] = file.length();
+ }
+ }
+
+ cols = copyOf(cols, i);
+ values = copyOf(values, i);
+
+ final MatrixCursor cursor = new MatrixCursor(cols, 1);
+ cursor.addRow(values);
+ return cursor;
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ // ContentProvider has already checked granted permissions
+ final File file = mStrategy.getFileForUri(uri);
+
+ final int lastDot = file.getName().lastIndexOf('.');
+ if (lastDot >= 0) {
+ final String extension = file.getName().substring(lastDot + 1);
+ final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
+ if (mime != null) {
+ return mime;
+ }
+ }
+
+ return "application/octet-stream";
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues values) {
+ throw new UnsupportedOperationException("No external inserts");
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+ throw new UnsupportedOperationException("No external updates");
+ }
+
+ @Override
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
+ // ContentProvider has already checked granted permissions
+ final File file = mStrategy.getFileForUri(uri);
+ return file.delete() ? 1 : 0;
+ }
+
+ @Override
+ public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
+ // ContentProvider has already checked granted permissions
+ final File file = mStrategy.getFileForUri(uri);
+ final int fileMode = modeToMode(mode);
+ return ParcelFileDescriptor.open(file, fileMode);
+ }
+
+ /**
+ * Return {@link PathStrategy} for given authority, either by parsing or
+ * returning from cache.
+ */
+ private static PathStrategy getPathStrategy(Context context, String authority) {
+ PathStrategy strat;
+ synchronized (sCache) {
+ strat = sCache.get(authority);
+ if (strat == null) {
+ try {
+ strat = parsePathStrategy(context, authority);
+ } catch (IOException e) {
+ throw new IllegalArgumentException(
+ "Failed to parse " + META_DATA_FILE_PROVIDER_PATHS + " meta-data", e);
+ } catch (XmlPullParserException e) {
+ throw new IllegalArgumentException(
+ "Failed to parse " + META_DATA_FILE_PROVIDER_PATHS + " meta-data", e);
+ }
+ sCache.put(authority, strat);
+ }
+ }
+ return strat;
+ }
+
+ /**
+ * Parse and return {@link PathStrategy} for given authority as defined in
+ * {@link #META_DATA_FILE_PROVIDER_PATHS} {@code <meta-data>}.
+ *
+ * @see #getPathStrategy(Context, String)
+ */
+ private static PathStrategy parsePathStrategy(Context context, String authority)
+ throws IOException, XmlPullParserException {
+ final SimplePathStrategy strat = new SimplePathStrategy(authority);
+
+ final ProviderInfo info = context.getPackageManager()
+ .resolveContentProvider(authority, PackageManager.GET_META_DATA);
+ final XmlResourceParser in = info.loadXmlMetaData(
+ context.getPackageManager(), META_DATA_FILE_PROVIDER_PATHS);
+ if (in == null) {
+ throw new IllegalArgumentException(
+ "Missing " + META_DATA_FILE_PROVIDER_PATHS + " meta-data");
+ }
+
+ int type;
+ while ((type = in.next()) != END_DOCUMENT) {
+ if (type == START_TAG) {
+ final String tag = in.getName();
+
+ final String name = in.getAttributeValue(null, ATTR_NAME);
+ String path = in.getAttributeValue(null, ATTR_PATH);
+
+ File target = null;
+ if (TAG_ROOT_PATH.equals(tag)) {
+ target = buildPath(DEVICE_ROOT, path);
+ } else if (TAG_FILES_PATH.equals(tag)) {
+ target = buildPath(context.getFilesDir(), path);
+ } else if (TAG_CACHE_PATH.equals(tag)) {
+ target = buildPath(context.getCacheDir(), path);
+ } else if (TAG_EXTERNAL.equals(tag)) {
+ target = buildPath(Environment.getExternalStorageDirectory(), path);
+ }
+
+ if (target != null) {
+ strat.addRoot(name, target);
+ }
+ }
+ }
+
+ return strat;
+ }
+
+ /**
+ * Strategy for mapping between {@link File} and {@link Uri}.
+ * <p>
+ * Strategies must be symmetric so that mapping a {@link File} to a
+ * {@link Uri} and then back to a {@link File} points at the original
+ * target.
+ * <p>
+ * Strategies must remain consistent across app launches, and not rely on
+ * dynamic state. This ensures that any generated {@link Uri} can still be
+ * resolved if your process is killed and later restarted.
+ *
+ * @see SimplePathStrategy
+ */
+ interface PathStrategy {
+ /**
+ * Return a {@link Uri} that represents the given {@link File}.
+ */
+ public Uri getUriForFile(File file);
+
+ /**
+ * Return a {@link File} that represents the given {@link Uri}.
+ */
+ public File getFileForUri(Uri uri);
+ }
+
+ /**
+ * Strategy that provides access to files living under a narrow whitelist of
+ * filesystem roots. It will throw {@link SecurityException} if callers try
+ * accessing files outside the configured roots.
+ * <p>
+ * For example, if configured with
+ * {@code addRoot("myfiles", context.getFilesDir())}, then
+ * {@code context.getFileStreamPath("foo.txt")} would map to
+ * {@code content://myauthority/myfiles/foo.txt}.
+ */
+ static class SimplePathStrategy implements PathStrategy {
+ private final String mAuthority;
+ private final HashMap<String, File> mRoots = new HashMap<String, File>();
+
+ public SimplePathStrategy(String authority) {
+ mAuthority = authority;
+ }
+
+ /**
+ * Add a mapping from a name to a filesystem root. The provider only offers
+ * access to files that live under configured roots.
+ */
+ public void addRoot(String name, File root) {
+ if (TextUtils.isEmpty(name)) {
+ throw new IllegalArgumentException("Name must not be empty");
+ }
+
+ try {
+ // Resolve to canonical path to keep path checking fast
+ root = root.getCanonicalFile();
+ } catch (IOException e) {
+ throw new IllegalArgumentException(
+ "Failed to resolve canonical path for " + root, e);
+ }
+
+ mRoots.put(name, root);
+ }
+
+ @Override
+ public Uri getUriForFile(File file) {
+ String path;
+ try {
+ path = file.getCanonicalPath();
+ } catch (IOException e) {
+ throw new IllegalArgumentException("Failed to resolve canonical path for " + file);
+ }
+
+ // Find the most-specific root path
+ Map.Entry<String, File> mostSpecific = null;
+ for (Map.Entry<String, File> root : mRoots.entrySet()) {
+ final String rootPath = root.getValue().getPath();
+ if (path.startsWith(rootPath) && (mostSpecific == null
+ || rootPath.length() > mostSpecific.getValue().getPath().length())) {
+ mostSpecific = root;
+ }
+ }
+
+ if (mostSpecific == null) {
+ throw new IllegalArgumentException(
+ "Failed to find configured root that contains " + path);
+ }
+
+ // Start at first char of path under root
+ final String rootPath = mostSpecific.getValue().getPath();
+ if (rootPath.endsWith("/")) {
+ path = path.substring(rootPath.length());
+ } else {
+ path = path.substring(rootPath.length() + 1);
+ }
+
+ // Encode the tag and path separately
+ path = Uri.encode(mostSpecific.getKey()) + '/' + Uri.encode(path, "/");
+ return new Uri.Builder().scheme("content")
+ .authority(mAuthority).encodedPath(path).build();
+ }
+
+ @Override
+ public File getFileForUri(Uri uri) {
+ String path = uri.getEncodedPath();
+
+ final int splitIndex = path.indexOf('/', 1);
+ final String tag = Uri.decode(path.substring(1, splitIndex));
+ path = Uri.decode(path.substring(splitIndex + 1));
+
+ final File root = mRoots.get(tag);
+ if (root == null) {
+ throw new IllegalArgumentException("Unable to find configured root for " + uri);
+ }
+
+ File file = new File(root, path);
+ try {
+ file = file.getCanonicalFile();
+ } catch (IOException e) {
+ throw new IllegalArgumentException("Failed to resolve canonical path for " + file);
+ }
+
+ if (!file.getPath().startsWith(root.getPath())) {
+ throw new SecurityException("Resolved path jumped beyond configured root");
+ }
+
+ return file;
+ }
+ }
+
+ /**
+ * Copied from ContentResolver.java
+ */
+ private static int modeToMode(String mode) {
+ int modeBits;
+ if ("r".equals(mode)) {
+ modeBits = ParcelFileDescriptor.MODE_READ_ONLY;
+ } else if ("w".equals(mode) || "wt".equals(mode)) {
+ modeBits = ParcelFileDescriptor.MODE_WRITE_ONLY
+ | ParcelFileDescriptor.MODE_CREATE
+ | ParcelFileDescriptor.MODE_TRUNCATE;
+ } else if ("wa".equals(mode)) {
+ modeBits = ParcelFileDescriptor.MODE_WRITE_ONLY
+ | ParcelFileDescriptor.MODE_CREATE
+ | ParcelFileDescriptor.MODE_APPEND;
+ } else if ("rw".equals(mode)) {
+ modeBits = ParcelFileDescriptor.MODE_READ_WRITE
+ | ParcelFileDescriptor.MODE_CREATE;
+ } else if ("rwt".equals(mode)) {
+ modeBits = ParcelFileDescriptor.MODE_READ_WRITE
+ | ParcelFileDescriptor.MODE_CREATE
+ | ParcelFileDescriptor.MODE_TRUNCATE;
+ } else {
+ throw new IllegalArgumentException("Invalid mode: " + mode);
+ }
+ return modeBits;
+ }
+
+ private static File buildPath(File base, String... segments) {
+ File cur = base;
+ for (String segment : segments) {
+ if (segment != null) {
+ cur = new File(cur, segment);
+ }
+ }
+ return cur;
+ }
+
+ private static String[] copyOf(String[] original, int newLength) {
+ final String[] result = new String[newLength];
+ System.arraycopy(original, 0, result, 0, newLength);
+ return result;
+ }
+
+ private static Object[] copyOf(Object[] original, int newLength) {
+ final Object[] result = new Object[newLength];
+ System.arraycopy(original, 0, result, 0, newLength);
+ return result;
+ }
+}
diff --git a/v4/java/android/support/v4/content/Loader.java b/v4/java/android/support/v4/content/Loader.java
index c79aad9..bd01b0a 100644
--- a/v4/java/android/support/v4/content/Loader.java
+++ b/v4/java/android/support/v4/content/Loader.java
@@ -39,6 +39,7 @@
boolean mAbandoned = false;
boolean mReset = true;
boolean mContentChanged = false;
+ boolean mProcessingChange = false;
/**
* An implementation of a ContentObserver that takes care of connecting
@@ -292,6 +293,7 @@
mStarted = false;
mAbandoned = false;
mContentChanged = false;
+ mProcessingChange = false;
}
/**
@@ -311,9 +313,34 @@
public boolean takeContentChanged() {
boolean res = mContentChanged;
mContentChanged = false;
+ mProcessingChange |= res;
return res;
}
-
+
+ /**
+ * Commit that you have actually fully processed a content change that
+ * was returned by {@link #takeContentChanged}. This is for use with
+ * {@link #rollbackContentChanged()} to handle situations where a load
+ * is cancelled. Call this when you have completely processed a load
+ * without it being cancelled.
+ */
+ public void commitContentChanged() {
+ mProcessingChange = false;
+ }
+
+ /**
+ * Report that you have abandoned the processing of a content change that
+ * was returned by {@link #takeContentChanged()} and would like to rollback
+ * to the state where there is again a pending content change. This is
+ * to handle the case where a data load due to a content change has been
+ * canceled before its data was delivered back to the loader.
+ */
+ public void rollbackContentChanged() {
+ if (mProcessingChange) {
+ mContentChanged = true;
+ }
+ }
+
/**
* Called when {@link ForceLoadContentObserver} detects a change. The
* default implementation checks to see if the loader is currently started;
@@ -365,9 +392,14 @@
public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
writer.print(prefix); writer.print("mId="); writer.print(mId);
writer.print(" mListener="); writer.println(mListener);
- writer.print(prefix); writer.print("mStarted="); writer.print(mStarted);
- writer.print(" mContentChanged="); writer.print(mContentChanged);
- writer.print(" mAbandoned="); writer.print(mAbandoned);
- writer.print(" mReset="); writer.println(mReset);
+ if (mStarted || mContentChanged || mProcessingChange) {
+ writer.print(prefix); writer.print("mStarted="); writer.print(mStarted);
+ writer.print(" mContentChanged="); writer.print(mContentChanged);
+ writer.print(" mProcessingChange="); writer.println(mProcessingChange);
+ }
+ if (mAbandoned || mReset) {
+ writer.print(prefix); writer.print("mAbandoned="); writer.print(mAbandoned);
+ writer.print(" mReset="); writer.println(mReset);
+ }
}
}
\ No newline at end of file
diff --git a/v4/java/android/support/v4/content/WakefulBroadcastReceiver.java b/v4/java/android/support/v4/content/WakefulBroadcastReceiver.java
new file mode 100644
index 0000000..017da1a
--- /dev/null
+++ b/v4/java/android/support/v4/content/WakefulBroadcastReceiver.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.content;
+
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.os.PowerManager;
+import android.util.Log;
+import android.util.SparseArray;
+
+/**
+ * Helper for the common pattern of implementing a {@link BroadcastReceiver}
+ * that will receiver a device wakeup event, and wants to pass that work
+ * off to a {@link android.app.Service} while ensuring the device does not
+ * go back to sleep during the transition.
+ *
+ * <p>This class takes care of creating and managing a partial wake lock
+ * for you; you must request the {@link android.Manifest.permission#WAKE_LOCK}
+ * permission to use it.</p>
+ */
+public abstract class WakefulBroadcastReceiver extends BroadcastReceiver {
+ private static final String EXTRA_WAKE_LOCK_ID = "android.support.content.wakelockid";
+
+ private static final SparseArray<PowerManager.WakeLock> mActiveWakeLocks
+ = new SparseArray<PowerManager.WakeLock>();
+ private static int mNextId = 1;
+
+ /**
+ * Do a {@link android.content.Context#startService(android.content.Intent)
+ * Context.startService}, but holding a wake lock while the service starts.
+ * This will modify the Intent to hold an extra identifying the wake lock;
+ * when the service receives it in {@link android.app.Service#onStartCommand
+ * Service.onStartCommand}, it should the Intent it receives there back to
+ * {@link #completeWakefulIntent(android.content.Intent)} in order to release
+ * the wake lock.
+ *
+ * @param context The Context in which it operate.
+ * @param intent The Intent with which to start the service, as per
+ * {@link android.content.Context#startService(android.content.Intent)
+ * Context.startService}.
+ */
+ public static ComponentName startWakefulService(Context context, Intent intent) {
+ synchronized (mActiveWakeLocks) {
+ int id = mNextId;
+ mNextId++;
+ if (mNextId <= 0) {
+ mNextId = 1;
+ }
+
+ intent.putExtra(EXTRA_WAKE_LOCK_ID, id);
+ ComponentName comp = context.startService(intent);
+ if (comp == null) {
+ return null;
+ }
+
+ PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
+ PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
+ "wake:" + comp.flattenToShortString());
+ wl.setReferenceCounted(false);
+ wl.acquire(60*1000);
+ mActiveWakeLocks.put(id, wl);
+ return comp;
+ }
+ }
+
+ /**
+ * Finish the execution from a previous {@link #startWakefulService}. Any wake lock
+ * that was being held will now be released.
+ *
+ * @param intent The Intent as originally generated by {@link #startWakefulService}.
+ * @return Returns true if the intent is associated with a wake lock that is
+ * now released; returns false if there was no wake lock specified for it.
+ */
+ public static boolean completeWakefulIntent(Intent intent) {
+ final int id = intent.getIntExtra(EXTRA_WAKE_LOCK_ID, 0);
+ if (id == 0) {
+ return false;
+ }
+ synchronized (mActiveWakeLocks) {
+ PowerManager.WakeLock wl = mActiveWakeLocks.get(id);
+ if (wl != null) {
+ wl.release();
+ mActiveWakeLocks.remove(id);
+ return true;
+ }
+ // We return true whether or not we actually found the wake lock
+ // the return code is defined to indicate whether the Intent contained
+ // an identifier for a wake lock that it was supposed to match.
+ // We just log a warning here if there is no wake lock found, which could
+ // happen for example if this function is called twice on the same
+ // intent or the process is killed and restarted before processing the intent.
+ Log.w("WakefulBroadcastReceiver", "No active wake lock id #" + id);
+ return true;
+ }
+ }
+}
diff --git a/v4/java/android/support/v4/hardware/display/DisplayManagerCompat.java b/v4/java/android/support/v4/hardware/display/DisplayManagerCompat.java
new file mode 100644
index 0000000..177c40a
--- /dev/null
+++ b/v4/java/android/support/v4/hardware/display/DisplayManagerCompat.java
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.hardware.display;
+
+import android.content.Context;
+import android.view.Display;
+import android.view.WindowManager;
+
+import java.util.WeakHashMap;
+
+/**
+ * Helper for accessing features in {@link android.hardware.display.DisplayManager}
+ * introduced after API level 4 in a backwards compatible fashion.
+ */
+public abstract class DisplayManagerCompat {
+ private static final WeakHashMap<Context, DisplayManagerCompat> sInstances =
+ new WeakHashMap<Context, DisplayManagerCompat>();
+
+ /**
+ * Display category: Presentation displays.
+ * <p>
+ * This category can be used to identify secondary displays that are suitable for
+ * use as presentation displays.
+ * </p>
+ *
+ * @see android.app.Presentation for information about presenting content
+ * on secondary displays.
+ * @see #getDisplays(String)
+ */
+ public static final String DISPLAY_CATEGORY_PRESENTATION =
+ "android.hardware.display.category.PRESENTATION";
+
+ DisplayManagerCompat() {
+ }
+
+ /**
+ * Gets an instance of the display manager given the context.
+ */
+ public static DisplayManagerCompat getInstance(Context context) {
+ synchronized (sInstances) {
+ DisplayManagerCompat instance = sInstances.get(context);
+ if (instance == null) {
+ final int version = android.os.Build.VERSION.SDK_INT;
+ if (version >= 17) {
+ instance = new JellybeanMr1Impl(context);
+ } else {
+ instance = new LegacyImpl(context);
+ }
+ sInstances.put(context, instance);
+ }
+ return instance;
+ }
+ }
+
+ /**
+ * Gets information about a logical display.
+ *
+ * The display metrics may be adjusted to provide compatibility
+ * for legacy applications.
+ *
+ * @param displayId The logical display id.
+ * @return The display object, or null if there is no valid display with the given id.
+ */
+ public abstract Display getDisplay(int displayId);
+
+ /**
+ * Gets all currently valid logical displays.
+ *
+ * @return An array containing all displays.
+ */
+ public abstract Display[] getDisplays();
+
+ /**
+ * Gets all currently valid logical displays of the specified category.
+ * <p>
+ * When there are multiple displays in a category the returned displays are sorted
+ * of preference. For example, if the requested category is
+ * {@link #DISPLAY_CATEGORY_PRESENTATION} and there are multiple presentation displays
+ * then the displays are sorted so that the first display in the returned array
+ * is the most preferred presentation display. The application may simply
+ * use the first display or allow the user to choose.
+ * </p>
+ *
+ * @param category The requested display category or null to return all displays.
+ * @return An array containing all displays sorted by order of preference.
+ *
+ * @see #DISPLAY_CATEGORY_PRESENTATION
+ */
+ public abstract Display[] getDisplays(String category);
+
+ private static class LegacyImpl extends DisplayManagerCompat {
+ private final WindowManager mWindowManager;
+
+ public LegacyImpl(Context context) {
+ mWindowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
+ }
+
+ @Override
+ public Display getDisplay(int displayId) {
+ Display display = mWindowManager.getDefaultDisplay();
+ if (display.getDisplayId() == displayId) {
+ return display;
+ }
+ return null;
+ }
+
+ @Override
+ public Display[] getDisplays() {
+ return new Display[] { mWindowManager.getDefaultDisplay() };
+ }
+
+ @Override
+ public Display[] getDisplays(String category) {
+ return category == null ? getDisplays() : new Display[0];
+ }
+ }
+
+ private static class JellybeanMr1Impl extends DisplayManagerCompat {
+ private final Object mDisplayManagerObj;
+
+ public JellybeanMr1Impl(Context context) {
+ mDisplayManagerObj = DisplayManagerJellybeanMr1.getDisplayManager(context);
+ }
+
+ @Override
+ public Display getDisplay(int displayId) {
+ return DisplayManagerJellybeanMr1.getDisplay(mDisplayManagerObj, displayId);
+ }
+
+ @Override
+ public Display[] getDisplays() {
+ return DisplayManagerJellybeanMr1.getDisplays(mDisplayManagerObj);
+ }
+
+ @Override
+ public Display[] getDisplays(String category) {
+ return DisplayManagerJellybeanMr1.getDisplays(mDisplayManagerObj, category);
+ }
+ }
+}
diff --git a/v4/java/android/support/v4/media/TransportController.java b/v4/java/android/support/v4/media/TransportController.java
new file mode 100644
index 0000000..fdbb3f8
--- /dev/null
+++ b/v4/java/android/support/v4/media/TransportController.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.media;
+
+/**
+ * Base interface to controlling a media transport. This is the
+ * interface for implementing things like on-screen controls: it
+ * allows them to request changes in playback, retrieve the current
+ * playback state, and monitor for changes to the playback state.
+ */
+public abstract class TransportController {
+ /**
+ * Start listening to changes in playback state.
+ */
+ public abstract void registerStateListener(TransportStateListener listener);
+
+ /**
+ * Stop listening to changes in playback state.
+ */
+ public abstract void unregisterStateListener(TransportStateListener listener);
+
+ /**
+ * Request that the player start its playback at its current position.
+ */
+ public abstract void startPlaying();
+
+ /**
+ * Request that the player pause its playback and stay at its current position.
+ */
+ public abstract void pausePlaying();
+
+ /**
+ * Request that the player stop its playback; it may clear its state in whatever
+ * way is appropriate.
+ */
+ public abstract void stopPlaying();
+
+ /**
+ * Retrieve the total duration of the media stream, in milliseconds.
+ */
+ public abstract int getDuration();
+
+ /**
+ * Retrieve the current playback location in the media stream, in milliseconds.
+ */
+ public abstract int getCurrentPosition();
+
+ /**
+ * Move to a new location in the media stream.
+ * @param pos Position to move to, in milliseconds.
+ */
+ public abstract void seekTo(int pos);
+
+ /**
+ * Return whether the player is currently playing its stream.
+ */
+ public abstract boolean isPlaying();
+
+ /**
+ * Retrieve amount, in percentage (0-100), that the media stream has been buffered
+ * on to the local device. Return 100 if the stream is always local.
+ */
+ public abstract int getBufferPercentage();
+
+ /**
+ * Retrieve the flags for the media transport control buttons that this transport supports.
+ * Result is a combination of the following flags:
+ * {@link TransportMediator#FLAG_KEY_MEDIA_PREVIOUS},
+ * {@link TransportMediator#FLAG_KEY_MEDIA_REWIND},
+ * {@link TransportMediator#FLAG_KEY_MEDIA_PLAY},
+ * {@link TransportMediator#FLAG_KEY_MEDIA_PLAY_PAUSE},
+ * {@link TransportMediator#FLAG_KEY_MEDIA_PAUSE},
+ * {@link TransportMediator#FLAG_KEY_MEDIA_STOP},
+ * {@link TransportMediator#FLAG_KEY_MEDIA_FAST_FORWARD},
+ * {@link TransportMediator#FLAG_KEY_MEDIA_NEXT}
+ */
+ public abstract int getTransportControlFlags();
+}
diff --git a/v4/java/android/support/v4/media/TransportMediator.java b/v4/java/android/support/v4/media/TransportMediator.java
new file mode 100644
index 0000000..8ea16a9
--- /dev/null
+++ b/v4/java/android/support/v4/media/TransportMediator.java
@@ -0,0 +1,325 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.media;
+
+import android.app.Activity;
+import android.content.Context;
+import android.media.AudioManager;
+import android.os.Build;
+import android.support.v4.view.KeyEventCompat;
+import android.view.KeyEvent;
+import android.view.View;
+
+import java.util.ArrayList;
+
+/**
+ * Helper for implementing a media transport control (with play, pause, skip, and
+ * other media actions). Takes care of both key events and advanced features
+ * like {@link android.media.RemoteControlClient}. This class is intended to
+ * serve as an intermediary between transport controls (whether they be on-screen
+ * controls, hardware buttons, remote controls) and the actual player. The player
+ * is represented by a single {@link TransportPerformer} that must be supplied to
+ * this class. On-screen controls that want to control and show the state of the
+ * player should do this through calls to the {@link TransportController} interface.
+ *
+ * <p>Here is a simple but fairly complete sample of a video player that is built
+ * around this class. Note that the MediaController class used here is not the one
+ * included in the standard Android framework, but a custom implementation. Real
+ * applications often implement their own transport controls, or you can copy the
+ * implementation here out of Support4Demos.</p>
+ *
+ * {@sample development/samples/Support4Demos/src/com/example/android/supportv4/media/TransportControllerActivity.java
+ * complete}
+ */
+public class TransportMediator extends TransportController {
+ final Context mContext;
+ final TransportPerformer mCallbacks;
+ final AudioManager mAudioManager;
+ final View mView;
+ final Object mDispatcherState;
+ final TransportControllerJellybeanMR2 mController;
+ final ArrayList<TransportStateListener> mListeners
+ = new ArrayList<TransportStateListener>();
+ final TransportControllerJellybeanMR2.TransportCallback mTransportKeyCallback
+ = new TransportControllerJellybeanMR2.TransportCallback() {
+ @Override
+ public void handleKey(KeyEvent key) {
+ key.dispatch(mKeyEventCallback);
+ }
+ @Override
+ public void handleAudioFocusChange(int focusChange) {
+ mCallbacks.onAudioFocusChange(focusChange);
+ }
+ };
+
+ /** Synonym for {@link KeyEvent#KEYCODE_MEDIA_PLAY KeyEvent.KEYCODE_MEDIA_PLAY} */
+ public static final int KEYCODE_MEDIA_PLAY = 126;
+ /** Synonym for {@link KeyEvent#KEYCODE_MEDIA_PAUSE KeyEvent.KEYCODE_MEDIA_PAUSE} */
+ public static final int KEYCODE_MEDIA_PAUSE = 127;
+ /** Synonym for {@link KeyEvent#KEYCODE_MEDIA_RECORD KeyEvent.KEYCODE_MEDIA_RECORD} */
+ public static final int KEYCODE_MEDIA_RECORD = 130;
+
+ /** Synonym for {@link android.media.RemoteControlClient#FLAG_KEY_MEDIA_PREVIOUS
+ * RemoveControlClient.FLAG_KEY_MEDIA_PREVIOUS */
+ public final static int FLAG_KEY_MEDIA_PREVIOUS = 1 << 0;
+ /** Synonym for {@link android.media.RemoteControlClient#FLAG_KEY_MEDIA_REWIND
+ * RemoveControlClient.FLAG_KEY_MEDIA_REWIND */
+ public final static int FLAG_KEY_MEDIA_REWIND = 1 << 1;
+ /** Synonym for {@link android.media.RemoteControlClient#FLAG_KEY_MEDIA_PLAY
+ * RemoveControlClient.FLAG_KEY_MEDIA_PLAY */
+ public final static int FLAG_KEY_MEDIA_PLAY = 1 << 2;
+ /** Synonym for {@link android.media.RemoteControlClient#FLAG_KEY_MEDIA_PLAY_PAUSE
+ * RemoveControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE */
+ public final static int FLAG_KEY_MEDIA_PLAY_PAUSE = 1 << 3;
+ /** Synonym for {@link android.media.RemoteControlClient#FLAG_KEY_MEDIA_PAUSE
+ * RemoveControlClient.FLAG_KEY_MEDIA_PAUSE */
+ public final static int FLAG_KEY_MEDIA_PAUSE = 1 << 4;
+ /** Synonym for {@link android.media.RemoteControlClient#FLAG_KEY_MEDIA_STOP
+ * RemoveControlClient.FLAG_KEY_MEDIA_STOP */
+ public final static int FLAG_KEY_MEDIA_STOP = 1 << 5;
+ /** Synonym for {@link android.media.RemoteControlClient#FLAG_KEY_MEDIA_FAST_FORWARD
+ * RemoveControlClient.FLAG_KEY_MEDIA_FAST_FORWARD */
+ public final static int FLAG_KEY_MEDIA_FAST_FORWARD = 1 << 6;
+ /** Synonym for {@link android.media.RemoteControlClient#FLAG_KEY_MEDIA_NEXT
+ * RemoveControlClient.FLAG_KEY_MEDIA_NEXT */
+ public final static int FLAG_KEY_MEDIA_NEXT = 1 << 7;
+
+ static boolean isMediaKey(int keyCode) {
+ switch (keyCode) {
+ case KEYCODE_MEDIA_PLAY:
+ case KEYCODE_MEDIA_PAUSE:
+ case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
+ case KeyEvent.KEYCODE_MUTE:
+ case KeyEvent.KEYCODE_HEADSETHOOK:
+ case KeyEvent.KEYCODE_MEDIA_STOP:
+ case KeyEvent.KEYCODE_MEDIA_NEXT:
+ case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
+ case KeyEvent.KEYCODE_MEDIA_REWIND:
+ case KEYCODE_MEDIA_RECORD:
+ case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ final KeyEvent.Callback mKeyEventCallback = new KeyEvent.Callback() {
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ return isMediaKey(keyCode) ? mCallbacks.onMediaButtonDown(keyCode, event) : false;
+ }
+
+ public boolean onKeyLongPress(int keyCode, KeyEvent event) {
+ return false;
+ }
+
+ @Override
+ public boolean onKeyUp(int keyCode, KeyEvent event) {
+ return isMediaKey(keyCode) ? mCallbacks.onMediaButtonUp(keyCode, event) : false;
+ }
+
+ @Override
+ public boolean onKeyMultiple(int keyCode, int count, KeyEvent event) {
+ return false;
+ }
+ };
+
+ public TransportMediator(Activity activity, TransportPerformer callbacks) {
+ this(activity, null, callbacks);
+ }
+
+ public TransportMediator(View view, TransportPerformer callbacks) {
+ this(null, view, callbacks);
+ }
+
+ private TransportMediator(Activity activity, View view, TransportPerformer callbacks) {
+ mContext = activity != null ? activity : view.getContext();
+ mCallbacks = callbacks;
+ mAudioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
+ mView = activity != null ? activity.getWindow().getDecorView() : view;
+ mDispatcherState = KeyEventCompat.getKeyDispatcherState(mView);
+ if (Build.VERSION.SDK_INT >= 18 || Build.VERSION.CODENAME.equals("JellyBeanMR2")) {
+ mController = new TransportControllerJellybeanMR2(mContext, mAudioManager,
+ mView, mTransportKeyCallback);
+ } else {
+ mController = null;
+ }
+ }
+
+ /**
+ * Return the {@link android.media.RemoteControlClient} associated with this transport.
+ * This returns a generic Object since the RemoteControlClient is not availble before
+ * {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}. Further, this class
+ * will not use RemoteControlClient in its implementation until
+ * {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}. You should always check for
+ * null here and not do anything with the RemoteControlClient if none is given; this
+ * way you don't need to worry about the current platform API version.
+ */
+ public Object getRemoteControlClient() {
+ return mController != null ? mController.getRemoteControlClient() : null;
+ }
+
+ /**
+ * Must call from {@link Activity#dispatchKeyEvent Activity.dispatchKeyEvent} to give
+ * the transport an opportunity to intercept media keys. Any such keys will show up
+ * in {@link TransportPerformer}.
+ * @param event
+ */
+ public boolean dispatchKeyEvent(KeyEvent event) {
+ return KeyEventCompat.dispatch(event, mKeyEventCallback, mDispatcherState, this);
+ }
+
+ public void registerStateListener(TransportStateListener listener) {
+ mListeners.add(listener);
+ }
+
+ public void unregisterStateListener(TransportStateListener listener) {
+ mListeners.remove(listener);
+ }
+
+ private TransportStateListener[] getListeners() {
+ if (mListeners.size() <= 0) {
+ return null;
+ }
+ TransportStateListener listeners[] = new TransportStateListener[mListeners.size()];
+ mListeners.toArray(listeners);
+ return listeners;
+ }
+
+ private void reportPlayingChanged() {
+ TransportStateListener[] listeners = getListeners();
+ if (listeners != null) {
+ for (TransportStateListener listener : listeners) {
+ listener.onPlayingChanged(this);
+ }
+ }
+ }
+
+ private void reportTransportControlsChanged() {
+ TransportStateListener[] listeners = getListeners();
+ if (listeners != null) {
+ for (TransportStateListener listener : listeners) {
+ listener.onTransportControlsChanged(this);
+ }
+ }
+ }
+
+ private void pushControllerState() {
+ if (mController != null) {
+ mController.refreshState(mCallbacks.onIsPlaying(),
+ mCallbacks.onGetTransportControlFlags());
+ }
+ }
+
+ public void refreshState() {
+ pushControllerState();
+ reportPlayingChanged();
+ reportTransportControlsChanged();
+ }
+
+ /**
+ * Move the controller into the playing state. This updates the remote control
+ * client to indicate it is playing, and takes audio focus for the app.
+ */
+ @Override
+ public void startPlaying() {
+ if (mController != null) {
+ mController.startPlaying();
+ }
+ mCallbacks.onStart();
+ pushControllerState();
+ reportPlayingChanged();
+ }
+
+ /**
+ * Move the controller into the paused state. This updates the remote control
+ * client to indicate it is paused, but keeps audio focus.
+ */
+ @Override
+ public void pausePlaying() {
+ if (mController != null) {
+ mController.pausePlaying();
+ }
+ mCallbacks.onPause();
+ pushControllerState();
+ reportPlayingChanged();
+ }
+
+ /**
+ * Move the controller into the stopped state. This updates the remote control
+ * client to indicate it is stopped, and removes audio focus from the app.
+ */
+ @Override
+ public void stopPlaying() {
+ if (mController != null) {
+ mController.stopPlaying();
+ }
+ mCallbacks.onStop();
+ pushControllerState();
+ reportPlayingChanged();
+ }
+
+ @Override
+ public int getDuration() {
+ return mCallbacks.onGetDuration();
+ }
+
+ @Override
+ public int getCurrentPosition() {
+ return mCallbacks.onGetCurrentPosition();
+ }
+
+ @Override
+ public void seekTo(int pos) {
+ mCallbacks.onSeekTo(pos);
+ }
+
+ @Override
+ public boolean isPlaying() {
+ return mCallbacks.onIsPlaying();
+ }
+
+ @Override
+ public int getBufferPercentage() {
+ return mCallbacks.onGetBufferPercentage();
+ }
+
+ /**
+ * Retrieves the flags for the media transport control buttons that this transport supports.
+ * Result is a combination of the following flags:
+ * {@link #FLAG_KEY_MEDIA_PREVIOUS},
+ * {@link #FLAG_KEY_MEDIA_REWIND},
+ * {@link #FLAG_KEY_MEDIA_PLAY},
+ * {@link #FLAG_KEY_MEDIA_PLAY_PAUSE},
+ * {@link #FLAG_KEY_MEDIA_PAUSE},
+ * {@link #FLAG_KEY_MEDIA_STOP},
+ * {@link #FLAG_KEY_MEDIA_FAST_FORWARD},
+ * {@link #FLAG_KEY_MEDIA_NEXT}
+ */
+ public int getTransportControlFlags() {
+ return mCallbacks.onGetTransportControlFlags();
+ }
+
+ /**
+ * Optionally call when no longer using the TransportController. Its resources
+ * will also be automatically cleaned up when your activity/view is detached from
+ * its window, so you don't normally need to call this explicitly.
+ */
+ public void destroy() {
+ mController.destroy();
+ }
+}
diff --git a/v4/java/android/support/v4/media/TransportPerformer.java b/v4/java/android/support/v4/media/TransportPerformer.java
new file mode 100644
index 0000000..98bbbaa
--- /dev/null
+++ b/v4/java/android/support/v4/media/TransportPerformer.java
@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.media;
+
+import android.os.SystemClock;
+import android.view.KeyEvent;
+
+/**
+ * Implemented by the playback side of the media system, to respond to
+ * requests to perform actions and to retrieve its current state. These
+ * requests may either come from key events dispatched directly to your UI, or
+ * events sent over a media button event receiver that this class keeps active
+ * while your window is in focus.
+ */
+public abstract class TransportPerformer {
+ /**
+ * Request to start playback on the media, resuming from whatever current state
+ * (position etc) it is in.
+ */
+ public abstract void onStart();
+
+ /**
+ * Request to pause playback of the media, staying at the current playback position
+ * and other state so a later call to {@link #onStart()} will resume at the same place.
+ */
+ public abstract void onPause();
+
+ /**
+ * Request to completely stop playback of the media, clearing whatever state the
+ * player thinks is appropriate.
+ */
+ public abstract void onStop();
+
+ /**
+ * Request to return the duration of the current media, in milliseconds.
+ */
+ public abstract int onGetDuration();
+
+ /**
+ * Request to return the current playback position, in milliseconds.
+ */
+ public abstract int onGetCurrentPosition();
+
+ /**
+ * Request to move the current playback position.
+ * @param pos New position to move to, in milliseconds.
+ */
+ public abstract void onSeekTo(int pos);
+
+ /**
+ * Request to find out whether the player is currently playing its media.
+ */
+ public abstract boolean onIsPlaying();
+
+ /**
+ * Request to find out how much of the media has been buffered on the local device.
+ * @return Return a percentage (0-100) indicating how much of the total data
+ * has been buffered. The default implementation returns 100, meaning the content
+ * is always on the local device.
+ */
+ public int onGetBufferPercentage() {
+ return 100;
+ }
+
+ /**
+ * Retrieves the flags for the media transport control buttons that this transport supports.
+ * Result is a combination of the following flags:
+ * {@link TransportMediator#FLAG_KEY_MEDIA_PREVIOUS},
+ * {@link TransportMediator#FLAG_KEY_MEDIA_REWIND},
+ * {@link TransportMediator#FLAG_KEY_MEDIA_PLAY},
+ * {@link TransportMediator#FLAG_KEY_MEDIA_PLAY_PAUSE},
+ * {@link TransportMediator#FLAG_KEY_MEDIA_PAUSE},
+ * {@link TransportMediator#FLAG_KEY_MEDIA_STOP},
+ * {@link TransportMediator#FLAG_KEY_MEDIA_FAST_FORWARD},
+ * {@link TransportMediator#FLAG_KEY_MEDIA_NEXT}
+ *
+ * <p>The default implementation returns:
+ * {@link TransportMediator#FLAG_KEY_MEDIA_PLAY},
+ * {@link TransportMediator#FLAG_KEY_MEDIA_PLAY_PAUSE},
+ * {@link TransportMediator#FLAG_KEY_MEDIA_PAUSE}, and
+ * {@link TransportMediator#FLAG_KEY_MEDIA_STOP}</p>
+ */
+ public int onGetTransportControlFlags() {
+ return TransportMediator.FLAG_KEY_MEDIA_PLAY
+ | TransportMediator.FLAG_KEY_MEDIA_PLAY_PAUSE
+ | TransportMediator.FLAG_KEY_MEDIA_PAUSE
+ | TransportMediator.FLAG_KEY_MEDIA_STOP;
+ }
+
+ /**
+ * Report that a media button has been pressed. This is like
+ * {@link android.view.KeyEvent.Callback#onKeyDown(int, android.view.KeyEvent)} but
+ * will only deliver media keys. The default implementation handles these keys:
+ * <ul>
+ * <li>KEYCODE_MEDIA_PLAY: call {@link #onStart}</li>
+ * <li>KEYCODE_MEDIA_PAUSE: call {@link #onPause}</li>
+ * <li>KEYCODE_MEDIA_STOP: call {@link #onStop}</li>
+ * <li>KEYCODE_MEDIA_PLAY_PAUSE and KEYCODE_HEADSETHOOK: call {@link #onPause}
+ * if {@link #onIsPlaying()} returns true, otherwise call {@link #onStart}</li>
+ * </ul>
+ * @param keyCode The code of the media key.
+ * @param event The full key event.
+ * @return Indicate whether the key has been consumed. The default
+ * implementation always returns true. This only matters for keys
+ * being dispatched here from
+ * {@link TransportMediator#dispatchKeyEvent(android.view.KeyEvent)
+ * TransportController.dispatchKeyEvent}, and determines whether the key
+ * continues on to its default key handling (which for media keys means
+ * being delivered to the current media remote control, which should
+ * be us).
+ */
+ public boolean onMediaButtonDown(int keyCode, KeyEvent event) {
+ switch (keyCode) {
+ case TransportMediator.KEYCODE_MEDIA_PLAY:
+ onStart();
+ return true;
+ case TransportMediator.KEYCODE_MEDIA_PAUSE:
+ onPause();
+ return true;
+ case KeyEvent.KEYCODE_MEDIA_STOP:
+ onStop();
+ return true;
+ case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
+ case KeyEvent.KEYCODE_HEADSETHOOK:
+ if (onIsPlaying()) {
+ onPause();
+ } else {
+ onStart();
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Report that a media button has been released. This is like
+ * {@link KeyEvent.Callback#onKeyUp(int, android.view.KeyEvent)} but
+ * will only deliver media keys. The default implementation does nothing.
+ * @param keyCode The code of the media key.
+ * @param event The full key event.
+ * @return Indicate whether the key has been consumed. The default
+ * implementation always returns true. This only matters for keys
+ * being dispatched here from
+ * {@link TransportMediator#dispatchKeyEvent(android.view.KeyEvent)
+ * TransportController.dispatchKeyEvent}, and determines whether the key
+ * continues on to its default key handling (which for media keys means
+ * being delivered to the current media remote control, which should
+ * be us).
+ */
+ public boolean onMediaButtonUp(int keyCode, KeyEvent event) {
+ return true;
+ }
+
+ // Copy constants from framework since we can't link to them.
+ static final int AUDIOFOCUS_GAIN = 1;
+ static final int AUDIOFOCUS_GAIN_TRANSIENT = 2;
+ static final int AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK = 3;
+ static final int AUDIOFOCUS_LOSS = -1 * AUDIOFOCUS_GAIN;
+ static final int AUDIOFOCUS_LOSS_TRANSIENT = -1 * AUDIOFOCUS_GAIN_TRANSIENT;
+ static final int AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK =
+ -1 * AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK;
+
+ /**
+ * Report that audio focus has changed on the app. This only happens if
+ * you have indicated you have started playing with
+ * {@link TransportMediator#startPlaying TransportController.startPlaying},
+ * which takes audio focus for you.
+ * @param focusChange The type of focus change, as per
+ * {@link android.media.AudioManager.OnAudioFocusChangeListener#onAudioFocusChange(int)
+ * OnAudioFocusChangeListener.onAudioFocusChange}. The default implementation will
+ * deliver a {@link KeyEvent#KEYCODE_MEDIA_STOP}
+ * when receiving {@link android.media.AudioManager#AUDIOFOCUS_LOSS}.
+ */
+ public void onAudioFocusChange(int focusChange) {
+ int keyCode = 0;
+ switch (focusChange) {
+ case AUDIOFOCUS_LOSS:
+ // This will cause us to stop playback, which means we drop audio focus
+ // so we will not get any further audio focus gain.
+ keyCode = TransportMediator.KEYCODE_MEDIA_PAUSE;
+ break;
+ }
+ if (keyCode != 0) {
+ final long now = SystemClock.uptimeMillis();
+ onMediaButtonDown(keyCode, new KeyEvent(now, now, KeyEvent.ACTION_DOWN, keyCode, 0));
+ onMediaButtonUp(keyCode, new KeyEvent(now, now, KeyEvent.ACTION_UP, keyCode, 0));
+ }
+ }
+}
diff --git a/v4/java/android/support/v4/media/TransportStateListener.java b/v4/java/android/support/v4/media/TransportStateListener.java
new file mode 100644
index 0000000..384cca2
--- /dev/null
+++ b/v4/java/android/support/v4/media/TransportStateListener.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.media;
+
+/**
+ * A listener for playback changes that can be registered with
+ * {@link TransportController}.
+ */
+public class TransportStateListener {
+ /**
+ * The play state of the transport changed. Use
+ * {@link android.support.v4.media.TransportController#isPlaying()
+ * TransportController.isPlaying()} to determine the new state.
+ */
+ public void onPlayingChanged(TransportController controller) {
+ }
+
+ /**
+ * The available controls of the transport changed. Use
+ * {@link TransportController#getTransportControlFlags()}
+ * TransportController.getTransportControlFlags()} to determine the new state.
+ */
+ public void onTransportControlsChanged(TransportController controller) {
+ }
+}
diff --git a/v4/java/android/support/v4/text/ICUCompat.java b/v4/java/android/support/v4/text/ICUCompat.java
new file mode 100644
index 0000000..6df35ff
--- /dev/null
+++ b/v4/java/android/support/v4/text/ICUCompat.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.text;
+
+import android.os.Build;
+
+public class ICUCompat {
+
+ interface ICUCompatImpl {
+ public String getScript(String locale);
+ public String addLikelySubtags(String locale);
+ }
+
+ static class ICUCompatImplBase implements ICUCompatImpl {
+ @Override
+ public String getScript(String locale) {
+ return null;
+ }
+
+ @Override
+ public String addLikelySubtags(String locale) {
+ return locale;
+ }
+ }
+
+ static class ICUCompatImplIcs implements ICUCompatImpl {
+ @Override
+ public String getScript(String locale) {
+ return ICUCompatIcs.getScript(locale);
+ }
+
+ @Override
+ public String addLikelySubtags(String locale) {
+ return ICUCompatIcs.addLikelySubtags(locale);
+ }
+ }
+
+ private static final ICUCompatImpl IMPL;
+
+ static {
+ final int version = Build.VERSION.SDK_INT;
+ if (version >= 14) {
+ IMPL = new ICUCompatImplIcs();
+ } else {
+ IMPL = new ICUCompatImplBase();
+ }
+ }
+
+ /**
+ * Returns the script (language code) of a script.
+ *
+ * @param locale The locale.
+ * @return a String representing the script (language code) of the locale.
+ */
+ public static String getScript(String locale) {
+ return IMPL.getScript(locale);
+ }
+
+ /**
+ * Add the likely subtags for a provided locale ID, per the algorithm described in the following
+ * CLDR technical report:
+ *
+ * http://www.unicode.org/reports/tr35/#Likely_Subtags
+ *
+ * If locale is already in the maximal form, or there is no data available for maximization,
+ * it will be just returned. For example, "und-Zzzz" cannot be maximized, since there is no
+ * reasonable maximization.
+ *
+ * Examples:
+ *
+ * "en" maximizes to "en_Latn_US"
+ * "de" maximizes to "de_Latn_US"
+ * "sr" maximizes to "sr_Cyrl_RS"
+ * "sh" maximizes to "sr_Latn_RS" (Note this will not reverse.)
+ * "zh_Hani" maximizes to "zh_Hans_CN" (Note this will not reverse.)
+
+ * @param locale The locale to maximize
+ *
+ * @return the maximized locale
+ */
+ public static String addLikelySubtags(String locale) {
+ return IMPL.addLikelySubtags(locale);
+ }
+}
diff --git a/v4/java/android/support/v4/text/TextDirectionHeuristicCompat.java b/v4/java/android/support/v4/text/TextDirectionHeuristicCompat.java
new file mode 100644
index 0000000..ab9b2f7
--- /dev/null
+++ b/v4/java/android/support/v4/text/TextDirectionHeuristicCompat.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.text;
+
+/**
+ * Interface for objects that use a heuristic for guessing at the paragraph direction by examining text.
+ */
+public interface TextDirectionHeuristicCompat {
+ /**
+ * Guess if a chars array is in the RTL direction or not.
+ *
+ * @param array the char array.
+ * @param start start index, inclusive.
+ * @param count the length to check, must not be negative and not greater than
+ * {@code array.length - start}.
+ * @return true if all chars in the range are to be considered in a RTL direction,
+ * false otherwise.
+ */
+ boolean isRtl(char[] array, int start, int count);
+
+ /**
+ * Guess if a {@code CharSequence} is in the RTL direction or not.
+ *
+ * @param cs the CharSequence.
+ * @param start start index, inclusive.
+ * @param count the length to check, must not be negative and not greater than
+ * {@code CharSequence.length() - start}.
+ * @return true if all chars in the range are to be considered in a RTL direction,
+ * false otherwise.
+ */
+ boolean isRtl(CharSequence cs, int start, int count);
+}
diff --git a/v4/java/android/support/v4/text/TextDirectionHeuristicsCompat.java b/v4/java/android/support/v4/text/TextDirectionHeuristicsCompat.java
new file mode 100644
index 0000000..1fddfd1
--- /dev/null
+++ b/v4/java/android/support/v4/text/TextDirectionHeuristicsCompat.java
@@ -0,0 +1,257 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.text;
+
+
+import android.support.v4.view.ViewCompat;
+
+import java.nio.CharBuffer;
+
+/**
+ * Some objects that implement TextDirectionHeuristic.
+ *
+ */
+public class TextDirectionHeuristicsCompat {
+
+ /**
+ * Always decides that the direction is left to right.
+ */
+ public static final android.support.v4.text.TextDirectionHeuristicCompat LTR =
+ new TextDirectionHeuristicInternal(null /* no algorithm */, false);
+
+ /**
+ * Always decides that the direction is right to left.
+ */
+ public static final android.support.v4.text.TextDirectionHeuristicCompat RTL =
+ new TextDirectionHeuristicInternal(null /* no algorithm */, true);
+
+ /**
+ * Determines the direction based on the first strong directional character, including bidi
+ * format chars, falling back to left to right if it finds none. This is the default behavior
+ * of the Unicode Bidirectional Algorithm.
+ */
+ public static final android.support.v4.text.TextDirectionHeuristicCompat FIRSTSTRONG_LTR =
+ new TextDirectionHeuristicInternal(FirstStrong.INSTANCE, false);
+
+ /**
+ * Determines the direction based on the first strong directional character, including bidi
+ * format chars, falling back to right to left if it finds none. This is similar to the default
+ * behavior of the Unicode Bidirectional Algorithm, just with different fallback behavior.
+ */
+ public static final android.support.v4.text.TextDirectionHeuristicCompat FIRSTSTRONG_RTL =
+ new TextDirectionHeuristicInternal(FirstStrong.INSTANCE, true);
+
+ /**
+ * If the text contains any strong right to left non-format character, determines that the
+ * direction is right to left, falling back to left to right if it finds none.
+ */
+ public static final android.support.v4.text.TextDirectionHeuristicCompat ANYRTL_LTR =
+ new TextDirectionHeuristicInternal(AnyStrong.INSTANCE_RTL, false);
+
+ /**
+ * Force the paragraph direction to the Locale direction. Falls back to left to right.
+ */
+ public static final android.support.v4.text.TextDirectionHeuristicCompat LOCALE =
+ TextDirectionHeuristicLocale.INSTANCE;
+
+ /**
+ * State constants for taking care about true / false / unknown
+ */
+ private static final int STATE_TRUE = 0;
+ private static final int STATE_FALSE = 1;
+ private static final int STATE_UNKNOWN = 2;
+
+ private static int isRtlText(int directionality) {
+ switch (directionality) {
+ case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
+ return STATE_FALSE;
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
+ return STATE_TRUE;
+ default:
+ return STATE_UNKNOWN;
+ }
+ }
+
+ private static int isRtlTextOrFormat(int directionality) {
+ switch (directionality) {
+ case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
+ case Character.DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING:
+ case Character.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE:
+ return STATE_FALSE;
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING:
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE:
+ return STATE_TRUE;
+ default:
+ return STATE_UNKNOWN;
+ }
+ }
+
+ /**
+ * Computes the text direction based on an algorithm. Subclasses implement
+ * {@link #defaultIsRtl} to handle cases where the algorithm cannot determine the
+ * direction from the text alone.
+ */
+ private static abstract class TextDirectionHeuristicImpl implements TextDirectionHeuristicCompat {
+ private final TextDirectionAlgorithm mAlgorithm;
+
+ public TextDirectionHeuristicImpl(TextDirectionAlgorithm algorithm) {
+ mAlgorithm = algorithm;
+ }
+
+ /**
+ * Return true if the default text direction is rtl.
+ */
+ abstract protected boolean defaultIsRtl();
+
+ @Override
+ public boolean isRtl(char[] array, int start, int count) {
+ return isRtl(CharBuffer.wrap(array), start, count);
+ }
+
+ @Override
+ public boolean isRtl(CharSequence cs, int start, int count) {
+ if (cs == null || start < 0 || count < 0 || cs.length() - count < start) {
+ throw new IllegalArgumentException();
+ }
+ if (mAlgorithm == null) {
+ return defaultIsRtl();
+ }
+ return doCheck(cs, start, count);
+ }
+
+ private boolean doCheck(CharSequence cs, int start, int count) {
+ switch(mAlgorithm.checkRtl(cs, start, count)) {
+ case STATE_TRUE:
+ return true;
+ case STATE_FALSE:
+ return false;
+ default:
+ return defaultIsRtl();
+ }
+ }
+ }
+
+ private static class TextDirectionHeuristicInternal extends TextDirectionHeuristicImpl {
+ private final boolean mDefaultIsRtl;
+
+ private TextDirectionHeuristicInternal(TextDirectionAlgorithm algorithm,
+ boolean defaultIsRtl) {
+ super(algorithm);
+ mDefaultIsRtl = defaultIsRtl;
+ }
+
+ @Override
+ protected boolean defaultIsRtl() {
+ return mDefaultIsRtl;
+ }
+ }
+
+ /**
+ * Interface for an algorithm to guess the direction of a paragraph of text.
+ */
+ private static interface TextDirectionAlgorithm {
+ /**
+ * Returns whether the range of text is RTL according to the algorithm.
+ */
+ int checkRtl(CharSequence cs, int start, int count);
+ }
+
+ /**
+ * Algorithm that uses the first strong directional character to determine the paragraph
+ * direction. This is the standard Unicode Bidirectional algorithm.
+ */
+ private static class FirstStrong implements TextDirectionAlgorithm {
+ @Override
+ public int checkRtl(CharSequence cs, int start, int count) {
+ int result = STATE_UNKNOWN;
+ for (int i = start, e = start + count; i < e && result == STATE_UNKNOWN; ++i) {
+ result = isRtlTextOrFormat(Character.getDirectionality(cs.charAt(i)));
+ }
+ return result;
+ }
+
+ private FirstStrong() {
+ }
+
+ public static final FirstStrong INSTANCE = new FirstStrong();
+ }
+
+ /**
+ * Algorithm that uses the presence of any strong directional non-format
+ * character (e.g. excludes LRE, LRO, RLE, RLO) to determine the
+ * direction of text.
+ */
+ private static class AnyStrong implements TextDirectionAlgorithm {
+ private final boolean mLookForRtl;
+
+ @Override
+ public int checkRtl(CharSequence cs, int start, int count) {
+ boolean haveUnlookedFor = false;
+ for (int i = start, e = start + count; i < e; ++i) {
+ switch (isRtlText(Character.getDirectionality(cs.charAt(i)))) {
+ case STATE_TRUE:
+ if (mLookForRtl) {
+ return STATE_TRUE;
+ }
+ haveUnlookedFor = true;
+ break;
+ case STATE_FALSE:
+ if (!mLookForRtl) {
+ return STATE_FALSE;
+ }
+ haveUnlookedFor = true;
+ break;
+ default:
+ break;
+ }
+ }
+ if (haveUnlookedFor) {
+ return mLookForRtl ? STATE_FALSE : STATE_TRUE;
+ }
+ return STATE_UNKNOWN;
+ }
+
+ private AnyStrong(boolean lookForRtl) {
+ this.mLookForRtl = lookForRtl;
+ }
+
+ public static final AnyStrong INSTANCE_RTL = new AnyStrong(true);
+ public static final AnyStrong INSTANCE_LTR = new AnyStrong(false);
+ }
+
+ /**
+ * Algorithm that uses the Locale direction to force the direction of a paragraph.
+ */
+ private static class TextDirectionHeuristicLocale extends TextDirectionHeuristicImpl {
+
+ public TextDirectionHeuristicLocale() {
+ super(null);
+ }
+
+ @Override
+ protected boolean defaultIsRtl() {
+ final int dir = TextUtilsCompat.getLayoutDirectionFromLocale(java.util.Locale.getDefault());
+ return (dir == ViewCompat.LAYOUT_DIRECTION_RTL);
+ }
+
+ public static final TextDirectionHeuristicLocale INSTANCE =
+ new TextDirectionHeuristicLocale();
+ }
+}
diff --git a/v4/java/android/support/v4/text/TextUtilsCompat.java b/v4/java/android/support/v4/text/TextUtilsCompat.java
new file mode 100644
index 0000000..3400866
--- /dev/null
+++ b/v4/java/android/support/v4/text/TextUtilsCompat.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.text;
+
+import android.support.v4.view.ViewCompat;
+
+import java.util.Locale;
+
+public class TextUtilsCompat {
+
+ /**
+ * Html-encode the string.
+ * @param s the string to be encoded
+ * @return the encoded string
+ */
+ public static String htmlEncode(String s) {
+ StringBuilder sb = new StringBuilder();
+ char c;
+ for (int i = 0; i < s.length(); i++) {
+ c = s.charAt(i);
+ switch (c) {
+ case '<':
+ sb.append("<"); //$NON-NLS-1$
+ break;
+ case '>':
+ sb.append(">"); //$NON-NLS-1$
+ break;
+ case '&':
+ sb.append("&"); //$NON-NLS-1$
+ break;
+ case '\'':
+ //http://www.w3.org/TR/xhtml1
+ // The named character reference ' (the apostrophe, U+0027) was introduced in
+ // XML 1.0 but does not appear in HTML. Authors should therefore use ' instead
+ // of ' to work as expected in HTML 4 user agents.
+ sb.append("'"); //$NON-NLS-1$
+ break;
+ case '"':
+ sb.append("""); //$NON-NLS-1$
+ break;
+ default:
+ sb.append(c);
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Return the layout direction for a given Locale
+ *
+ * @param locale the Locale for which we want the layout direction. Can be null.
+ * @return the layout direction. This may be one of:
+ * {@link ViewCompat#LAYOUT_DIRECTION_LTR} or
+ * {@link ViewCompat#LAYOUT_DIRECTION_RTL}.
+ *
+ * Be careful: this code will need to be updated when vertical scripts will be supported
+ */
+ public static int getLayoutDirectionFromLocale(Locale locale) {
+ if (locale != null && !locale.equals(ROOT)) {
+ final String scriptSubtag = ICUCompat.getScript(
+ ICUCompat.addLikelySubtags(locale.toString()));
+ if (scriptSubtag == null) return getLayoutDirectionFromFirstChar(locale);
+
+ if (scriptSubtag.equalsIgnoreCase(ARAB_SCRIPT_SUBTAG) ||
+ scriptSubtag.equalsIgnoreCase(HEBR_SCRIPT_SUBTAG)) {
+ return ViewCompat.LAYOUT_DIRECTION_RTL;
+ }
+ }
+
+ return ViewCompat.LAYOUT_DIRECTION_LTR;
+ }
+
+ /**
+ * Fallback algorithm to detect the locale direction. Rely on the fist char of the
+ * localized locale name. This will not work if the localized locale name is in English
+ * (this is the case for ICU 4.4 and "Urdu" script)
+ *
+ * @param locale
+ * @return the layout direction. This may be one of:
+ * {@link ViewCompat#LAYOUT_DIRECTION_LTR} or
+ * {@link ViewCompat#LAYOUT_DIRECTION_RTL}.
+ *
+ * Be careful: this code will need to be updated when vertical scripts will be supported
+ */
+ private static int getLayoutDirectionFromFirstChar(Locale locale) {
+ switch(Character.getDirectionality(locale.getDisplayName(locale).charAt(0))) {
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
+ return ViewCompat.LAYOUT_DIRECTION_RTL;
+
+ case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
+ default:
+ return ViewCompat.LAYOUT_DIRECTION_LTR;
+ }
+ }
+
+ public static final Locale ROOT = new Locale("", "");
+
+ private static String ARAB_SCRIPT_SUBTAG = "Arab";
+ private static String HEBR_SCRIPT_SUBTAG = "Hebr";
+}
diff --git a/v4/java/android/support/v4/text/bidi/BidiFormatter.java b/v4/java/android/support/v4/text/bidi/BidiFormatter.java
new file mode 100644
index 0000000..277dd62
--- /dev/null
+++ b/v4/java/android/support/v4/text/bidi/BidiFormatter.java
@@ -0,0 +1,1130 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.text.bidi;
+
+import android.support.v4.text.TextDirectionHeuristicCompat;
+import android.support.v4.text.TextDirectionHeuristicsCompat;
+import android.support.v4.text.TextUtilsCompat;
+import android.support.v4.view.ViewCompat;
+
+import java.util.Locale;
+
+import static android.support.v4.text.TextDirectionHeuristicsCompat.FIRSTSTRONG_LTR;
+
+/**
+ * Utility class for formatting text for display in a potentially opposite-directionality context
+ * without garbling. The directionality of the context is set at formatter creation and the
+ * directionality of the text can be either estimated or passed in when known. Provides the
+ * following functionality:
+ * <p>
+ * 1. Bidi Wrapping
+ * When text in one language is mixed into a document in another, opposite-directionality language,
+ * e.g. when an English business name is embedded in a Hebrew web page, both the inserted string
+ * and the text surrounding it may be displayed incorrectly unless the inserted string is explicitly
+ * separated from the surrounding text in a "wrapper" that:
+ * <p>
+ * - Declares its directionality so that the string is displayed correctly. This can be done in HTML
+ * markup (e.g. a 'span dir="rtl"' element) by {@link #spanWrap} and similar methods, or - only in
+ * contexts where markup can't be used - in Unicode bidi formatting codes by {@link #unicodeWrap}
+ * and similar methods.
+ * <p>
+ * - Isolates the string's directionality, so it does not unduly affect the surrounding content.
+ * Currently, this can only be done using invisible Unicode characters of the same direction as
+ * the context (LRM or RLM) in addition to the directionality declaration above, thus "resetting"
+ * the directionality to that of the context. The "reset" may need to be done at both ends of the
+ * string. Without "reset" after the string, the string will "stick" to a number or logically
+ * separate opposite-direction text that happens to follow it in-line (even if separated by
+ * neutral content like spaces and punctuation). Without "reset" before the string, the same can
+ * happen there, but only with more opposite-direction text, not a number. One approach is to
+ * "reset" the direction only after each string, on the theory that if the preceding opposite-
+ * direction text is itself bidi-wrapped, the "reset" after it will prevent the sticking. (Doing
+ * the "reset" only before each string definitely does not work because we do not want to require
+ * bidi-wrapping numbers, and a bidi-wrapped opposite-direction string could be followed by a
+ * number.) Still, the safest policy is to do the "reset" on both ends of each string, since RTL
+ * message translations often contain untranslated Latin-script brand names and technical terms,
+ * and one of these can be followed by a bidi-wrapped inserted value. On the other hand, when one
+ * has such a message, it is best to do the "reset" manually in the message translation itself,
+ * since the message's opposite-direction text could be followed by an inserted number, which we
+ * would not bidi-wrap anyway. Thus, "reset" only after the string is the current default. In an
+ * alternative to "reset", recent additions to the HTML, CSS, and Unicode standards allow the
+ * isolation to be part of the directionality declaration. This form of isolation is better than
+ * "reset" because it takes less space, does not require knowing the context directionality, has a
+ * gentler effect than "reset", and protects both ends of the string. However, we do not yet allow
+ * using it because required platforms do not yet support it.
+ * <p>
+ * Providing these wrapping services is the basic purpose of the bidi formatter.
+ * <p>
+ * 2. Directionality estimation
+ * How does one know whether a string about to be inserted into surrounding text has the same
+ * directionality? Well, in many cases, one knows that this must be the case when writing the code
+ * doing the insertion, e.g. when a localized message is inserted into a localized page. In such
+ * cases there is no need to involve the bidi formatter at all. In some other cases, it need not be
+ * the same as the context, but is either constant (e.g. urls are always LTR) or otherwise known.
+ * In the remaining cases, e.g. when the string is user-entered or comes from a database, the
+ * language of the string (and thus its directionality) is not known a priori, and must be
+ * estimated at run-time. The bidi formatter can do this automatically using the default
+ * first-strong estimation algorithm. It can also be configured to use a custom directionality
+ * estimation object.
+ * <p>
+ * 3. Escaping
+ * When wrapping plain text - i.e. text that is not already HTML or HTML-escaped - in HTML markup,
+ * the text must first be HTML-escaped to prevent XSS attacks and other nasty business. This of
+ * course is always true, but the escaping can not be done after the string has already been wrapped
+ * in markup, so the bidi formatter also serves as a last chance and includes escaping services.
+ * <p>
+ * Thus, in a single call, the formatter will escape the input string as specified, determine its
+ * directionality, and wrap it as necessary. It is then up to the caller to insert the return value
+ * in the output.
+ */
+public final class BidiFormatter {
+
+ /**
+ * The default text direction heuristic.
+ */
+ private static TextDirectionHeuristicCompat DEFAULT_TEXT_DIRECTION_HEURISTIC = FIRSTSTRONG_LTR;
+
+ /**
+ * Unicode "Left-To-Right Embedding" (LRE) character.
+ */
+ private static final char LRE = '\u202A';
+
+ /**
+ * Unicode "Right-To-Left Embedding" (RLE) character.
+ */
+ private static final char RLE = '\u202B';
+
+ /**
+ * Unicode "Pop Directional Formatting" (PDF) character.
+ */
+ private static final char PDF = '\u202C';
+
+ /**
+ * Unicode "Left-To-Right Mark" (LRM) character.
+ */
+ private static final char LRM = '\u200E';
+
+ /*
+ * Unicode "Right-To-Left Mark" (RLM) character.
+ */
+ private static final char RLM = '\u200F';
+
+ /*
+ * String representation of LRM
+ */
+ private static final String LRM_STRING = Character.toString(LRM);
+
+ /*
+ * String representation of RLM
+ */
+ private static final String RLM_STRING = Character.toString(RLM);
+
+ /**
+ * "ltr" string constant.
+ */
+ private static final String LTR_STRING = "ltr";
+
+ /**
+ * "rtl" string constant.
+ */
+ private static final String RTL_STRING = "rtl";
+
+ /**
+ * "dir=\"ltr\"" string constant.
+ */
+ private static final String DIR_LTR_STRING = "dir=\"ltr\"";
+
+ /**
+ * "dir=\"rtl\"" string constant.
+ */
+ private static final String DIR_RTL_STRING = "dir=\"rtl\"";
+
+ /**
+ * "right" string constant.
+ */
+ private static final String RIGHT = "right";
+
+ /**
+ * "left" string constant.
+ */
+ private static final String LEFT = "left";
+
+ /**
+ * Empty string constant.
+ */
+ private static final String EMPTY_STRING = "";
+
+ /**
+ * A class for building a BidiFormatter with non-default options.
+ */
+ public static final class Builder {
+ private boolean mIsRtlContext;
+ private int mFlags;
+ private TextDirectionHeuristicCompat mTextDirectionHeuristicCompat;
+
+ /**
+ * Constructor.
+ *
+ */
+ public Builder() {
+ initialize(isRtlLocale(Locale.getDefault()));
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param rtlContext Whether the context directionality is RTL.
+ */
+ public Builder(boolean rtlContext) {
+ initialize(rtlContext);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param locale The context locale.
+ */
+ public Builder(Locale locale) {
+ initialize(isRtlLocale(locale));
+ }
+
+ /**
+ * Initializes the builder with the given context directionality and default options.
+ *
+ * @param isRtlContext Whether the context is RTL or not.
+ */
+ private void initialize(boolean isRtlContext) {
+ mIsRtlContext = isRtlContext;
+ mTextDirectionHeuristicCompat = DEFAULT_TEXT_DIRECTION_HEURISTIC;
+ mFlags = DEFAULT_FLAGS;
+ }
+
+ /**
+ * Specifies whether the BidiFormatter to be built should also "reset" directionality before
+ * a string being bidi-wrapped, not just after it. The default is false.
+ */
+ public Builder stereoReset(boolean stereoReset) {
+ if (stereoReset) {
+ mFlags |= FLAG_STEREO_RESET;
+ } else {
+ mFlags &= ~FLAG_STEREO_RESET;
+ }
+ return this;
+ }
+
+ /**
+ * Specifies the default directionality estimation algorithm to be used by the BidiFormatter.
+ * By default, uses the first-strong heuristic.
+ *
+ * @param heuristic the {@code TextDirectionHeuristic} to use.
+ * @return the builder itself.
+ */
+ public Builder setTextDirectionHeuristic(TextDirectionHeuristicCompat heuristic) {
+ mTextDirectionHeuristicCompat = heuristic;
+ return this;
+ }
+
+ private static BidiFormatter getDefaultInstanceFromContext(boolean isRtlContext) {
+ return isRtlContext ? DEFAULT_RTL_INSTANCE : DEFAULT_LTR_INSTANCE;
+ }
+
+ /**
+ * @return A BidiFormatter with the specified options.
+ */
+ public BidiFormatter build() {
+ if (mFlags == DEFAULT_FLAGS &&
+ mTextDirectionHeuristicCompat == DEFAULT_TEXT_DIRECTION_HEURISTIC) {
+ return getDefaultInstanceFromContext(mIsRtlContext);
+ }
+ return new BidiFormatter(mIsRtlContext, mFlags, mTextDirectionHeuristicCompat);
+ }
+ }
+
+ //
+ private static final int FLAG_STEREO_RESET = 2;
+ private static final int DEFAULT_FLAGS = FLAG_STEREO_RESET;
+
+ private static final BidiFormatter DEFAULT_LTR_INSTANCE = new BidiFormatter(
+ false /* LTR context */,
+ DEFAULT_FLAGS,
+ DEFAULT_TEXT_DIRECTION_HEURISTIC);
+
+ private static final BidiFormatter DEFAULT_RTL_INSTANCE = new BidiFormatter(
+ true /* RTL context */,
+ DEFAULT_FLAGS,
+ DEFAULT_TEXT_DIRECTION_HEURISTIC);
+
+ private final boolean mIsRtlContext;
+ private final int mFlags;
+ private final TextDirectionHeuristicCompat mDefaultTextDirectionHeuristicCompat;
+
+ /**
+ * Factory for creating an instance of BidiFormatter for the default locale directionality.
+ *
+ */
+ public static BidiFormatter getInstance() {
+ return new Builder().build();
+ }
+
+ /**
+ * Factory for creating an instance of BidiFormatter given the context directionality.
+ *
+ * @param rtlContext Whether the context directionality is RTL.
+ */
+ public static BidiFormatter getInstance(boolean rtlContext) {
+ return new Builder(rtlContext).build();
+ }
+
+ /**
+ * Factory for creating an instance of BidiFormatter given the context locale.
+ *
+ * @param locale The context locale.
+ */
+ public static BidiFormatter getInstance(Locale locale) {
+ return new Builder(locale).build();
+ }
+
+ /**
+ * @param isRtlContext Whether the context directionality is RTL or not.
+ * @param flags The option flags.
+ * @param heuristic The default text direction heuristic.
+ */
+ private BidiFormatter(boolean isRtlContext, int flags, TextDirectionHeuristicCompat heuristic) {
+ mIsRtlContext = isRtlContext;
+ mFlags = flags;
+ mDefaultTextDirectionHeuristicCompat = heuristic;
+ }
+
+ /**
+ * @return Whether the context directionality is RTL
+ */
+ public boolean isRtlContext() {
+ return mIsRtlContext;
+ }
+
+ /**
+ * @return Whether directionality "reset" should also be done before a string being
+ * bidi-wrapped, not just after it.
+ */
+ public boolean getStereoReset() {
+ return (mFlags & FLAG_STEREO_RESET) != 0;
+ }
+
+ /**
+ * Returns "rtl" if {@code str}'s estimated directionality is RTL, and "ltr" if it is LTR.
+ *
+ * @param str String whose directionality is to be estimated.
+ * @return "rtl" if {@code str}'s estimated directionality is RTL, and "ltr" otherwise.
+ */
+ public String dirAttrValue(String str) {
+ return dirAttrValue(isRtl(str));
+ }
+
+ /**
+ * Operates like {@link #dirAttrValue(String)}, but uses a given heuristic to estimate the
+ * {@code str}'s directionality.
+ *
+ * @param str String whose directionality is to be estimated.
+ * @param heuristic The text direction heuristic that will be used to estimate the {@code str}'s
+ * directionality.
+ * @return "rtl" if {@code str}'s estimated directionality is RTL, and "ltr" otherwise.
+ */
+ public String dirAttrValue(String str, TextDirectionHeuristicCompat heuristic) {
+ return dirAttrValue(heuristic.isRtl(str, 0, str.length()));
+ }
+
+ /**
+ * Returns "rtl" if the given directionality is RTL, and "ltr" if it is LTR.
+ *
+ * @param isRtl Whether the directionality is RTL or not.
+ * @return "rtl" if the given directionality is RTL, and "ltr" otherwise.
+ */
+ public String dirAttrValue(boolean isRtl) {
+ return isRtl ? RTL_STRING : LTR_STRING;
+ }
+
+ /**
+ * Returns "dir=\"ltr\"" or "dir=\"rtl\"", depending on {@code str}'s estimated directionality,
+ * if it is not the same as the context directionality. Otherwise, returns the empty string.
+ *
+ * @param str String whose directionality is to be estimated.
+ * @return "dir=\"rtl\"" for RTL text in non-RTL context; "dir=\"ltr\"" for LTR text in non-LTR
+ * context; else, the empty string.
+ */
+ public String dirAttr(String str) {
+ return dirAttr(isRtl(str));
+ }
+
+ /**
+ * Operates like {@link #dirAttr(String)}, but uses a given heuristic to estimate the
+ * {@code str}'s directionality.
+ *
+ * @param str String whose directionality is to be estimated.
+ * @param heuristic The text direction heuristic that will be used to estimate the {@code str}'s
+ * directionality.
+ * @return "dir=\"rtl\"" for RTL text in non-RTL context; "dir=\"ltr\"" for LTR text in non-LTR
+ * context; else, the empty string.
+ */
+ public String dirAttr(String str, TextDirectionHeuristicCompat heuristic) {
+ return dirAttr(heuristic.isRtl(str, 0, str.length()));
+ }
+
+ /**
+ * Returns "dir=\"ltr\"" or "dir=\"rtl\"", depending on the given directionality, if it is not
+ * the same as the context directionality. Otherwise, returns the empty string.
+ *
+ * @param isRtl Whether the directionality is RTL or not
+ * @return "dir=\"rtl\"" for RTL text in non-RTL context; "dir=\"ltr\"" for LTR text in non-LTR
+ * context; else, the empty string.
+ */
+ public String dirAttr(boolean isRtl) {
+ return (isRtl != mIsRtlContext) ? (isRtl ? DIR_RTL_STRING : DIR_LTR_STRING) : EMPTY_STRING;
+ }
+
+ /**
+ * Returns a Unicode bidi mark matching the context directionality (LRM or RLM) if either the
+ * overall or the exit directionality of a given string is opposite to the context directionality.
+ * Putting this after the string (including its directionality declaration wrapping) prevents it
+ * from "sticking" to other opposite-directionality text or a number appearing after it inline
+ * with only neutral content in between. Otherwise returns the empty string. While the exit
+ * directionality is determined by scanning the end of the string, the overall directionality is
+ * given explicitly in {@code dir}.
+ *
+ * @param str String after which the mark may need to appear.
+ * @return LRM for RTL text in LTR context; RLM for LTR text in RTL context;
+ * else, the empty string.
+ */
+ public String markAfter(String str) {
+ return markAfter(str, mDefaultTextDirectionHeuristicCompat);
+ }
+
+ /**
+ * Operates like {@link #markAfter(String)}, but uses a given heuristic to estimate the
+ * {@code str}'s directionality.
+ *
+ * @param str String after which the mark may need to appear.
+ * @param heuristic The text direction heuristic that will be used to estimate the {@code str}'s
+ * directionality.
+ * @return LRM for RTL text in LTR context; RLM for LTR text in RTL context;
+ * else, the empty string.
+ */
+ public String markAfter(String str, TextDirectionHeuristicCompat heuristic) {
+ final boolean isRtl = heuristic.isRtl(str, 0, str.length());
+ // getExitDir() is called only if needed (short-circuit).
+ if (!mIsRtlContext && (isRtl || getExitDir(str) == DIR_RTL)) {
+ return LRM_STRING;
+ }
+ if (mIsRtlContext && (!isRtl || getExitDir(str) == DIR_LTR)) {
+ return RLM_STRING;
+ }
+ return EMPTY_STRING;
+ }
+
+ /**
+ * Returns a Unicode bidi mark matching the context directionality (LRM or RLM) if either the
+ * overall or the entry directionality of a given string is opposite to the context
+ * directionality. Putting this before the string (including its directionality declaration
+ * wrapping) prevents it from "sticking" to other opposite-directionality text appearing before it
+ * inline with only neutral content in between. Otherwise returns the empty string. While the
+ * entry directionality is determined by scanning the beginning of the string, the overall
+ * directionality is given explicitly in {@code dir}.
+ *
+ * @param str String before which the mark may need to appear.
+ * @return LRM for RTL text in LTR context; RLM for LTR text in RTL context;
+ * else, the empty string.
+ */
+ public String markBefore(String str) {
+ return markBefore(str, mDefaultTextDirectionHeuristicCompat);
+ }
+
+ /**
+ * Operates like {@link #markBefore(String)}, but uses a given heuristic to estimate the
+ * {@code str}'s directionality.
+ *
+ * @param str String before which the mark may need to appear.
+ * @param heuristic The text direction heuristic that will be used to estimate the {@code str}'s
+ * directionality.
+ * @return LRM for RTL text in LTR context; RLM for LTR text in RTL context;
+ * else, the empty string.
+ */
+ public String markBefore(String str, TextDirectionHeuristicCompat heuristic) {
+ final boolean isRtl = heuristic.isRtl(str, 0, str.length());
+ // getEntryDir() is called only if needed (short-circuit).
+ if (!mIsRtlContext && (isRtl || getEntryDir(str) == DIR_RTL)) {
+ return LRM_STRING;
+ }
+ if (mIsRtlContext && (!isRtl || getEntryDir(str) == DIR_LTR)) {
+ return RLM_STRING;
+ }
+ return EMPTY_STRING;
+ }
+
+ /**
+ * Returns the Unicode bidi mark matching the context directionality (LRM for LTR context
+ * directionality, RLM for RTL context directionality).
+ */
+ public String mark() {
+ return mIsRtlContext ? RLM_STRING : LRM_STRING;
+ }
+
+ /**
+ * Returns "right" for RTL context directionality. Otherwise for LTR context directionality
+ * returns "left".
+ */
+ public String startEdge() {
+ return mIsRtlContext ? RIGHT : LEFT;
+ }
+
+ /**
+ * Returns "left" for RTL context directionality. Otherwise for LTR context directionality
+ * returns "right".
+ */
+ public String endEdge() {
+ return mIsRtlContext ? LEFT : RIGHT;
+ }
+
+ /**
+ * Estimates the directionality of a string using the default text direction heuristic.
+ *
+ * @param str String whose directionality is to be estimated.
+ * @return true if {@code str}'s estimated overall directionality is RTL. Otherwise returns
+ * false.
+ */
+ public boolean isRtl(String str) {
+ return mDefaultTextDirectionHeuristicCompat.isRtl(str, 0, str.length());
+ }
+
+ /**
+ * Formats a given string of unknown directionality for use in HTML output of the context
+ * directionality, so an opposite-directionality string is neither garbled nor garbles its
+ * surroundings.
+ * <p>
+ * The algorithm: estimates the directionality of the given string using the given heuristic.
+ * If the directionality is known, pass TextDirectionHeuristics.LTR or RTL for heuristic.
+ * In case its directionality doesn't match the context directionality, wraps it with a 'span'
+ * element and adds a "dir" attribute (either 'dir=\"rtl\"' or 'dir=\"ltr\"').
+ * <p>
+ * If {@code isolate}, directionally isolates the string so that it does not garble its
+ * surroundings. Currently, this is done by "resetting" the directionality after the string by
+ * appending a trailing Unicode bidi mark matching the context directionality (LRM or RLM) when
+ * either the overall directionality or the exit directionality of the string is opposite to that
+ * of the context. If the formatter was built using {@link Builder#stereoReset(boolean)} and
+ * passing "true" as an argument, also prepends a Unicode bidi mark matching the context
+ * directionality when either the overall directionality or the entry directionality of the
+ * string is opposite to that of the context.
+ * <p>
+ *
+ * @param str The input string.
+ * @param heuristic The algorithm to be used to estimate the string's overall direction.
+ * @param isolate Whether to directionally isolate the string to prevent it from garbling the
+ * content around it.
+ * @return Input string after applying the above processing.
+ */
+ public String spanWrap(String str, TextDirectionHeuristicCompat heuristic, boolean isolate) {
+ final boolean isRtl = heuristic.isRtl(str, 0, str.length());
+ String origStr = str;
+ str = TextUtilsCompat.htmlEncode(str);
+
+ StringBuilder result = new StringBuilder();
+ if (getStereoReset() && isolate) {
+ result.append(markBefore(origStr,
+ isRtl ? TextDirectionHeuristicsCompat.RTL : TextDirectionHeuristicsCompat.LTR));
+ }
+ if (isRtl != mIsRtlContext) {
+ result.append("<span ").append(dirAttr(isRtl)).append('>').append(str).append("</span>");
+ } else {
+ result.append(str);
+ }
+ if (isolate) {
+ result.append(markAfter(origStr,
+ isRtl ? TextDirectionHeuristicsCompat.RTL : TextDirectionHeuristicsCompat.LTR));
+ }
+ return result.toString();
+ }
+
+ /**
+ * Operates like {@link #spanWrap(String, android.support.v4.text.TextDirectionHeuristicCompat, boolean)}, but assumes
+ * {@code isolate} is true.
+ *
+ * @param str The input string.
+ * @param heuristic The algorithm to be used to estimate the string's overall direction.
+ * @return Input string after applying the above processing.
+ */
+ public String spanWrap(String str, TextDirectionHeuristicCompat heuristic) {
+ return spanWrap(str, heuristic, true /* isolate */);
+ }
+
+ /**
+ * Operates like {@link #spanWrap(String, android.support.v4.text.TextDirectionHeuristicCompat, boolean)}, but uses the
+ * formatter's default direction estimation algorithm.
+ *
+ * @param str The input string.
+ * @param isolate Whether to directionally isolate the string to prevent it from garbling the
+ * content around it
+ * @return Input string after applying the above processing.
+ */
+ public String spanWrap(String str, boolean isolate) {
+ return spanWrap(str, mDefaultTextDirectionHeuristicCompat, isolate);
+ }
+
+ /**
+ * Operates like {@link #spanWrap(String, android.support.v4.text.TextDirectionHeuristicCompat, boolean)}, but uses the
+ * formatter's default direction estimation algorithm and assumes {@code isolate} is true.
+ *
+ * @param str The input string.
+ * @return Input string after applying the above processing.
+ */
+ public String spanWrap(String str) {
+ return spanWrap(str, mDefaultTextDirectionHeuristicCompat, true /* isolate */);
+ }
+
+ /**
+ * Formats a string of given directionality for use in plain-text output of the context
+ * directionality, so an opposite-directionality string is neither garbled nor garbles its
+ * surroundings. As opposed to {@link #spanWrap}, this makes use of Unicode bidi
+ * formatting characters. In HTML, its *only* valid use is inside of elements that do not allow
+ * markup, e.g. the 'option' and 'title' elements.
+ * <p>
+ * The algorithm: In case the given directionality doesn't match the context directionality, wraps
+ * the string with Unicode bidi formatting characters: RLE+{@code str}+PDF for RTL text, or
+ * LRE+{@code str}+PDF for LTR text.
+ * <p>
+ * If {@code isolate}, directionally isolates the string so that it does not garble its
+ * surroundings. Currently, this is done by "resetting" the directionality after the string by
+ * appending a trailing Unicode bidi mark matching the context directionality (LRM or RLM) when
+ * either the overall directionality or the exit directionality of the string is opposite to that
+ * of the context. If the formatter was built using {@link Builder#stereoReset(boolean)} and
+ * passing "true" as an argument, also prepends a Unicode bidi mark matching the context
+ * directionality when either the overall directionality or the entry directionality of the
+ * string is opposite to that of the context. Note that as opposed to the overall
+ * directionality, the entry and exit directionalities are determined from the string itself.
+ * <p>
+ * Does *not* do HTML-escaping.
+ *
+ * @param str The input string.
+ * @param heuristic The algorithm to be used to estimate the string's overall direction.
+ * @param isolate Whether to directionally isolate the string to prevent it from garbling the
+ * content around it
+ * @return Input string after applying the above processing.
+ */
+ public String unicodeWrap(String str, TextDirectionHeuristicCompat heuristic, boolean isolate) {
+ final boolean isRtl = heuristic.isRtl(str, 0, str.length());
+ StringBuilder result = new StringBuilder();
+ if (getStereoReset() && isolate) {
+ result.append(markBefore(str,
+ isRtl ? TextDirectionHeuristicsCompat.RTL : TextDirectionHeuristicsCompat.LTR));
+ }
+ if (isRtl != mIsRtlContext) {
+ result.append(isRtl ? RLE : LRE);
+ result.append(str);
+ result.append(PDF);
+ } else {
+ result.append(str);
+ }
+ if (isolate) {
+ result.append(markAfter(str,
+ isRtl ? TextDirectionHeuristicsCompat.RTL : TextDirectionHeuristicsCompat.LTR));
+ }
+ return result.toString();
+ }
+
+ /**
+ * Operates like {@link #unicodeWrap(String, android.support.v4.text.TextDirectionHeuristicCompat, boolean)}, but assumes
+ * {@code isolate} is true.
+ *
+ * @param str The input string.
+ * @param heuristic The algorithm to be used to estimate the string's overall direction.
+ * @return Input string after applying the above processing.
+ */
+ public String unicodeWrap(String str, TextDirectionHeuristicCompat heuristic) {
+ return unicodeWrap(str, heuristic, true /* isolate */);
+ }
+
+ /**
+ * Operates like {@link #unicodeWrap(String, android.support.v4.text.TextDirectionHeuristicCompat, boolean)}, but uses the
+ * formatter's default direction estimation algorithm.
+ *
+ * @param str The input string.
+ * @param isolate Whether to directionally isolate the string to prevent it from garbling the
+ * content around it
+ * @return Input string after applying the above processing.
+ */
+ public String unicodeWrap(String str, boolean isolate) {
+ return unicodeWrap(str, mDefaultTextDirectionHeuristicCompat, isolate);
+ }
+
+ /**
+ * Operates like {@link #unicodeWrap(String, android.support.v4.text.TextDirectionHeuristicCompat, boolean)}, but uses the
+ * formatter's default direction estimation algorithm and assumes {@code isolate} is true.
+ *
+ * @param str The input string.
+ * @return Input string after applying the above processing.
+ */
+ public String unicodeWrap(String str) {
+ return unicodeWrap(str, mDefaultTextDirectionHeuristicCompat, true /* isolate */);
+ }
+
+ /**
+ * Helper method to return true if the Locale directionality is RTL.
+ *
+ * @param locale The Locale whose directionality will be checked to be RTL or LTR
+ * @return true if the {@code locale} directionality is RTL. False otherwise.
+ */
+ private static boolean isRtlLocale(Locale locale) {
+ return (TextUtilsCompat.getLayoutDirectionFromLocale(locale) == ViewCompat.LAYOUT_DIRECTION_RTL);
+ }
+
+ /**
+ * Enum for directionality type.
+ */
+ private static final int DIR_LTR = -1;
+ private static final int DIR_UNKNOWN = 0;
+ private static final int DIR_RTL = +1;
+
+ /**
+ * Returns the directionality of the last character with strong directionality in the string, or
+ * DIR_UNKNOWN if none was encountered. For efficiency, actually scans backwards from the end of
+ * the string. Treats a non-BN character between an LRE/RLE/LRO/RLO and its matching PDF as a
+ * strong character, LTR after LRE/LRO, and RTL after RLE/RLO. The results are undefined for a
+ * string containing unbalanced LRE/RLE/LRO/RLO/PDF characters. The intended use is to check
+ * whether a logically separate item that starts with a number or a character of the string's
+ * exit directionality and follows this string inline (not counting any neutral characters in
+ * between) would "stick" to it in an opposite-directionality context, thus being displayed in
+ * an incorrect position. An LRM or RLM character (the one of the context's directionality)
+ * between the two will prevent such sticking.
+ *
+ * @param str the string to check.
+ */
+ private static int getExitDir(String str) {
+ return new DirectionalityEstimator(str, false /* isHtml */).getExitDir();
+ }
+
+ /**
+ * Returns the directionality of the first character with strong directionality in the string,
+ * or DIR_UNKNOWN if none was encountered. Treats a non-BN character between an
+ * LRE/RLE/LRO/RLO and its matching PDF as a strong character, LTR after LRE/LRO, and RTL after
+ * RLE/RLO. The results are undefined for a string containing unbalanced LRE/RLE/LRO/RLO/PDF
+ * characters. The intended use is to check whether a logically separate item that ends with a
+ * character of the string's entry directionality and precedes the string inline (not counting
+ * any neutral characters in between) would "stick" to it in an opposite-directionality context,
+ * thus being displayed in an incorrect position. An LRM or RLM character (the one of the
+ * context's directionality) between the two will prevent such sticking.
+ *
+ * @param str the string to check.
+ */
+ private static int getEntryDir(String str) {
+ return new DirectionalityEstimator(str, false /* isHtml */).getEntryDir();
+ }
+
+ /**
+ * An object that estimates the directionality of a given string by various methods.
+ *
+ */
+ private static class DirectionalityEstimator {
+
+ // Internal static variables and constants.
+
+ /**
+ * Size of the bidi character class cache. The results of the Character.getDirectionality()
+ * calls on the lowest DIR_TYPE_CACHE_SIZE codepoints are kept in an array for speed.
+ * The 0x700 value is designed to leave all the European and Near Eastern languages in the
+ * cache. It can be reduced to 0x180, restricting the cache to the Western European
+ * languages.
+ */
+ private static final int DIR_TYPE_CACHE_SIZE = 0x700;
+
+ /**
+ * The bidi character class cache.
+ */
+ private static final byte DIR_TYPE_CACHE[];
+
+ static {
+ DIR_TYPE_CACHE = new byte[DIR_TYPE_CACHE_SIZE];
+ for (int i = 0; i < DIR_TYPE_CACHE_SIZE; i++) {
+ DIR_TYPE_CACHE[i] = Character.getDirectionality(i);
+ }
+ }
+
+ // Internal instance variables.
+
+ /**
+ * The text to be scanned.
+ */
+ private final String text;
+
+ /**
+ * Whether the text to be scanned is to be treated as HTML, i.e. skipping over tags and
+ * entities when looking for the next / preceding dir type.
+ */
+ private final boolean isHtml;
+
+ /**
+ * The length of the text in chars.
+ */
+ private final int length;
+
+ /**
+ * The current position in the text.
+ */
+ private int charIndex;
+
+ /**
+ * The char encountered by the last dirTypeForward or dirTypeBackward call. If it
+ * encountered a supplementary codepoint, this contains a char that is not a valid
+ * codepoint. This is ok, because this member is only used to detect some well-known ASCII
+ * syntax, e.g. "http://" and the beginning of an HTML tag or entity.
+ */
+ private char lastChar;
+
+ /**
+ * Constructor.
+ *
+ * @param text The string to scan.
+ * @param isHtml Whether the text to be scanned is to be treated as HTML, i.e. skipping over
+ * tags and entities.
+ */
+ DirectionalityEstimator(String text, boolean isHtml) {
+ this.text = text;
+ this.isHtml = isHtml;
+ length = text.length();
+ }
+
+ /**
+ * Returns the directionality of the first character with strong directionality in the
+ * string, or DIR_UNKNOWN if none was encountered. Treats a non-BN character between an
+ * LRE/RLE/LRO/RLO and its matching PDF as a strong character, LTR after LRE/LRO, and RTL
+ * after RLE/RLO. The results are undefined for a string containing unbalanced
+ * LRE/RLE/LRO/RLO/PDF characters.
+ */
+ int getEntryDir() {
+ // The reason for this method name, as opposed to getFirstStrongDir(), is that
+ // "first strong" is a commonly used description of Unicode's estimation algorithm,
+ // but the two must treat formatting characters quite differently. Thus, we are staying
+ // away from both "first" and "last" in these method names to avoid confusion.
+ charIndex = 0;
+ int embeddingLevel = 0;
+ int embeddingLevelDir = DIR_UNKNOWN;
+ int firstNonEmptyEmbeddingLevel = 0;
+ while (charIndex < length && firstNonEmptyEmbeddingLevel == 0) {
+ switch (dirTypeForward()) {
+ case Character.DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING:
+ case Character.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE:
+ ++embeddingLevel;
+ embeddingLevelDir = DIR_LTR;
+ break;
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING:
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE:
+ ++embeddingLevel;
+ embeddingLevelDir = DIR_RTL;
+ break;
+ case Character.DIRECTIONALITY_POP_DIRECTIONAL_FORMAT:
+ --embeddingLevel;
+ // To restore embeddingLevelDir to its previous value, we would need a
+ // stack, which we want to avoid. Thus, at this point we do not know the
+ // current embedding's directionality.
+ embeddingLevelDir = DIR_UNKNOWN;
+ break;
+ case Character.DIRECTIONALITY_BOUNDARY_NEUTRAL:
+ break;
+ case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
+ if (embeddingLevel == 0) {
+ return DIR_LTR;
+ }
+ firstNonEmptyEmbeddingLevel = embeddingLevel;
+ break;
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
+ if (embeddingLevel == 0) {
+ return DIR_RTL;
+ }
+ firstNonEmptyEmbeddingLevel = embeddingLevel;
+ break;
+ default:
+ firstNonEmptyEmbeddingLevel = embeddingLevel;
+ break;
+ }
+ }
+
+ // We have either found a non-empty embedding or scanned the entire string finding
+ // neither a non-empty embedding nor a strong character outside of an embedding.
+ if (firstNonEmptyEmbeddingLevel == 0) {
+ // We have not found a non-empty embedding. Thus, the string contains neither a
+ // non-empty embedding nor a strong character outside of an embedding.
+ return DIR_UNKNOWN;
+ }
+
+ // We have found a non-empty embedding.
+ if (embeddingLevelDir != DIR_UNKNOWN) {
+ // We know the directionality of the non-empty embedding.
+ return embeddingLevelDir;
+ }
+
+ // We do not remember the directionality of the non-empty embedding we found. So, we go
+ // backwards to find the start of the non-empty embedding and get its directionality.
+ while (charIndex > 0) {
+ switch (dirTypeBackward()) {
+ case Character.DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING:
+ case Character.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE:
+ if (firstNonEmptyEmbeddingLevel == embeddingLevel) {
+ return DIR_LTR;
+ }
+ --embeddingLevel;
+ break;
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING:
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE:
+ if (firstNonEmptyEmbeddingLevel == embeddingLevel) {
+ return DIR_RTL;
+ }
+ --embeddingLevel;
+ break;
+ case Character.DIRECTIONALITY_POP_DIRECTIONAL_FORMAT:
+ ++embeddingLevel;
+ break;
+ }
+ }
+ // We should never get here.
+ return DIR_UNKNOWN;
+ }
+
+ /**
+ * Returns the directionality of the last character with strong directionality in the
+ * string, or DIR_UNKNOWN if none was encountered. For efficiency, actually scans backwards
+ * from the end of the string. Treats a non-BN character between an LRE/RLE/LRO/RLO and its
+ * matching PDF as a strong character, LTR after LRE/LRO, and RTL after RLE/RLO. The results
+ * are undefined for a string containing unbalanced LRE/RLE/LRO/RLO/PDF characters.
+ */
+ int getExitDir() {
+ // The reason for this method name, as opposed to getLastStrongDir(), is that "last
+ // strong" sounds like the exact opposite of "first strong", which is a commonly used
+ // description of Unicode's estimation algorithm (getUnicodeDir() above), but the two
+ // must treat formatting characters quite differently. Thus, we are staying away from
+ // both "first" and "last" in these method names to avoid confusion.
+ charIndex = length;
+ int embeddingLevel = 0;
+ int lastNonEmptyEmbeddingLevel = 0;
+ while (charIndex > 0) {
+ switch (dirTypeBackward()) {
+ case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
+ if (embeddingLevel == 0) {
+ return DIR_LTR;
+ }
+ if (lastNonEmptyEmbeddingLevel == 0) {
+ lastNonEmptyEmbeddingLevel = embeddingLevel;
+ }
+ break;
+ case Character.DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING:
+ case Character.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE:
+ if (lastNonEmptyEmbeddingLevel == embeddingLevel) {
+ return DIR_LTR;
+ }
+ --embeddingLevel;
+ break;
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
+ if (embeddingLevel == 0) {
+ return DIR_RTL;
+ }
+ if (lastNonEmptyEmbeddingLevel == 0) {
+ lastNonEmptyEmbeddingLevel = embeddingLevel;
+ }
+ break;
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING:
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE:
+ if (lastNonEmptyEmbeddingLevel == embeddingLevel) {
+ return DIR_RTL;
+ }
+ --embeddingLevel;
+ break;
+ case Character.DIRECTIONALITY_POP_DIRECTIONAL_FORMAT:
+ ++embeddingLevel;
+ break;
+ case Character.DIRECTIONALITY_BOUNDARY_NEUTRAL:
+ break;
+ default:
+ if (lastNonEmptyEmbeddingLevel == 0) {
+ lastNonEmptyEmbeddingLevel = embeddingLevel;
+ }
+ break;
+ }
+ }
+ return DIR_UNKNOWN;
+ }
+
+ // Internal methods
+
+ /**
+ * Gets the bidi character class, i.e. Character.getDirectionality(), of a given char, using
+ * a cache for speed. Not designed for supplementary codepoints, whose results we do not
+ * cache.
+ */
+ private static byte getCachedDirectionality(char c) {
+ return c < DIR_TYPE_CACHE_SIZE ? DIR_TYPE_CACHE[c] : Character.getDirectionality(c);
+ }
+
+ /**
+ * Returns the Character.DIRECTIONALITY_... value of the next codepoint and advances
+ * charIndex. If isHtml, and the codepoint is '<' or '&', advances through the tag/entity,
+ * and returns Character.DIRECTIONALITY_WHITESPACE. For an entity, it would be best to
+ * figure out the actual character, and return its dirtype, but treating it as whitespace is
+ * good enough for our purposes.
+ *
+ * @throws java.lang.IndexOutOfBoundsException if called when charIndex >= length or < 0.
+ */
+ byte dirTypeForward() {
+ lastChar = text.charAt(charIndex);
+ if (Character.isHighSurrogate(lastChar)) {
+ int codePoint = Character.codePointAt(text, charIndex);
+ charIndex += Character.charCount(codePoint);
+ return Character.getDirectionality(codePoint);
+ }
+ charIndex++;
+ byte dirType = getCachedDirectionality(lastChar);
+ if (isHtml) {
+ // Process tags and entities.
+ if (lastChar == '<') {
+ dirType = skipTagForward();
+ } else if (lastChar == '&') {
+ dirType = skipEntityForward();
+ }
+ }
+ return dirType;
+ }
+
+ /**
+ * Returns the Character.DIRECTIONALITY_... value of the preceding codepoint and advances
+ * charIndex backwards. If isHtml, and the codepoint is the end of a complete HTML tag or
+ * entity, advances over the whole tag/entity and returns
+ * Character.DIRECTIONALITY_WHITESPACE. For an entity, it would be best to figure out the
+ * actual character, and return its dirtype, but treating it as whitespace is good enough
+ * for our purposes.
+ *
+ * @throws java.lang.IndexOutOfBoundsException if called when charIndex > length or <= 0.
+ */
+ byte dirTypeBackward() {
+ lastChar = text.charAt(charIndex - 1);
+ if (Character.isLowSurrogate(lastChar)) {
+ int codePoint = Character.codePointBefore(text, charIndex);
+ charIndex -= Character.charCount(codePoint);
+ return Character.getDirectionality(codePoint);
+ }
+ charIndex--;
+ byte dirType = getCachedDirectionality(lastChar);
+ if (isHtml) {
+ // Process tags and entities.
+ if (lastChar == '>') {
+ dirType = skipTagBackward();
+ } else if (lastChar == ';') {
+ dirType = skipEntityBackward();
+ }
+ }
+ return dirType;
+ }
+
+ /**
+ * Advances charIndex forward through an HTML tag (after the opening < has already been
+ * read) and returns Character.DIRECTIONALITY_WHITESPACE. If there is no matching >,
+ * does not change charIndex and returns Character.DIRECTIONALITY_OTHER_NEUTRALS (for the
+ * < that hadn't been part of a tag after all).
+ */
+ private byte skipTagForward() {
+ int initialCharIndex = charIndex;
+ while (charIndex < length) {
+ lastChar = text.charAt(charIndex++);
+ if (lastChar == '>') {
+ // The end of the tag.
+ return Character.DIRECTIONALITY_WHITESPACE;
+ }
+ if (lastChar == '"' || lastChar == '\'') {
+ // Skip over a quoted attribute value inside the tag.
+ char quote = lastChar;
+ while (charIndex < length && (lastChar = text.charAt(charIndex++)) != quote) {}
+ }
+ }
+ // The original '<' wasn't the start of a tag after all.
+ charIndex = initialCharIndex;
+ lastChar = '<';
+ return Character.DIRECTIONALITY_OTHER_NEUTRALS;
+ }
+
+ /**
+ * Advances charIndex backward through an HTML tag (after the closing > has already been
+ * read) and returns Character.DIRECTIONALITY_WHITESPACE. If there is no matching <, does
+ * not change charIndex and returns Character.DIRECTIONALITY_OTHER_NEUTRALS (for the >
+ * that hadn't been part of a tag after all). Nevertheless, the running time for calling
+ * skipTagBackward() in a loop remains linear in the size of the text, even for a text like
+ * ">>>>", because skipTagBackward() also stops looking for a matching <
+ * when it encounters another >.
+ */
+ private byte skipTagBackward() {
+ int initialCharIndex = charIndex;
+ while (charIndex > 0) {
+ lastChar = text.charAt(--charIndex);
+ if (lastChar == '<') {
+ // The start of the tag.
+ return Character.DIRECTIONALITY_WHITESPACE;
+ }
+ if (lastChar == '>') {
+ break;
+ }
+ if (lastChar == '"' || lastChar == '\'') {
+ // Skip over a quoted attribute value inside the tag.
+ char quote = lastChar;
+ while (charIndex > 0 && (lastChar = text.charAt(--charIndex)) != quote) {}
+ }
+ }
+ // The original '>' wasn't the end of a tag after all.
+ charIndex = initialCharIndex;
+ lastChar = '>';
+ return Character.DIRECTIONALITY_OTHER_NEUTRALS;
+ }
+
+ /**
+ * Advances charIndex forward through an HTML character entity tag (after the opening
+ * & has already been read) and returns Character.DIRECTIONALITY_WHITESPACE. It would be
+ * best to figure out the actual character and return its dirtype, but this is good enough.
+ */
+ private byte skipEntityForward() {
+ while (charIndex < length && (lastChar = text.charAt(charIndex++)) != ';') {}
+ return Character.DIRECTIONALITY_WHITESPACE;
+ }
+
+ /**
+ * Advances charIndex backward through an HTML character entity tag (after the closing ;
+ * has already been read) and returns Character.DIRECTIONALITY_WHITESPACE. It would be best
+ * to figure out the actual character and return its dirtype, but this is good enough.
+ * If there is no matching &, does not change charIndex and returns
+ * Character.DIRECTIONALITY_OTHER_NEUTRALS (for the ';' that did not start an entity after
+ * all). Nevertheless, the running time for calling skipEntityBackward() in a loop remains
+ * linear in the size of the text, even for a text like ";;;;;;;", because skipTagBackward()
+ * also stops looking for a matching & when it encounters another ;.
+ */
+ private byte skipEntityBackward() {
+ int initialCharIndex = charIndex;
+ while (charIndex > 0) {
+ lastChar = text.charAt(--charIndex);
+ if (lastChar == '&') {
+ return Character.DIRECTIONALITY_WHITESPACE;
+ }
+ if (lastChar == ';') {
+ break;
+ }
+ }
+ charIndex = initialCharIndex;
+ lastChar = ';';
+ return Character.DIRECTIONALITY_OTHER_NEUTRALS;
+ }
+ }
+}
\ No newline at end of file
diff --git a/v4/java/android/support/v4/view/KeyEventCompat.java b/v4/java/android/support/v4/view/KeyEventCompat.java
index c278080..fc0ee2e 100644
--- a/v4/java/android/support/v4/view/KeyEventCompat.java
+++ b/v4/java/android/support/v4/view/KeyEventCompat.java
@@ -17,6 +17,7 @@
package android.support.v4.view;
import android.view.KeyEvent;
+import android.view.View;
/**
* Helper for accessing features in {@link KeyEvent} introduced after
@@ -32,6 +33,9 @@
public boolean metaStateHasNoModifiers(int metaState);
public void startTracking(KeyEvent event);
public boolean isTracking(KeyEvent event);
+ public Object getKeyDispatcherState(View view);
+ public boolean dispatch(KeyEvent event, KeyEvent.Callback receiver, Object state,
+ Object target);
}
/**
@@ -98,6 +102,17 @@
public boolean isTracking(KeyEvent event) {
return false;
}
+
+ @Override
+ public Object getKeyDispatcherState(View view) {
+ return null;
+ }
+
+ @Override
+ public boolean dispatch(KeyEvent event, KeyEvent.Callback receiver, Object state,
+ Object target) {
+ return event.dispatch(receiver);
+ }
}
static class EclairKeyEventVersionImpl extends BaseKeyEventVersionImpl {
@@ -110,6 +125,17 @@
public boolean isTracking(KeyEvent event) {
return KeyEventCompatEclair.isTracking(event);
}
+
+ @Override
+ public Object getKeyDispatcherState(View view) {
+ return KeyEventCompatEclair.getKeyDispatcherState(view);
+ }
+
+ @Override
+ public boolean dispatch(KeyEvent event, KeyEvent.Callback receiver, Object state,
+ Object target) {
+ return KeyEventCompatEclair.dispatch(event, receiver, state, target);
+ }
}
/**
@@ -173,4 +199,13 @@
public static boolean isTracking(KeyEvent event) {
return IMPL.isTracking(event);
}
+
+ public static Object getKeyDispatcherState(View view) {
+ return IMPL.getKeyDispatcherState(view);
+ }
+
+ public static boolean dispatch(KeyEvent event, KeyEvent.Callback receiver, Object state,
+ Object target) {
+ return IMPL.dispatch(event, receiver, state, target);
+ }
}
diff --git a/v4/java/android/support/v4/view/ViewPager.java b/v4/java/android/support/v4/view/ViewPager.java
index c736fbe..8874096 100644
--- a/v4/java/android/support/v4/view/ViewPager.java
+++ b/v4/java/android/support/v4/view/ViewPager.java
@@ -30,7 +30,9 @@
import android.os.SystemClock;
import android.support.v4.os.ParcelableCompat;
import android.support.v4.os.ParcelableCompatCreatorCallbacks;
+import android.support.v4.view.accessibility.AccessibilityEventCompat;
import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
+import android.support.v4.view.accessibility.AccessibilityRecordCompat;
import android.support.v4.widget.EdgeEffectCompat;
import android.util.AttributeSet;
import android.util.Log;
@@ -2682,11 +2684,12 @@
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
- // ViewPagers should only report accessibility info for the current page,
- // otherwise things get very confusing.
+ // Dispatch scroll events from this ViewPager.
+ if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
+ return super.dispatchPopulateAccessibilityEvent(event);
+ }
- // TODO: Should this note something about the paging container?
-
+ // Dispatch all other accessibility events from the current page.
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = getChildAt(i);
@@ -2728,17 +2731,24 @@
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
super.onInitializeAccessibilityEvent(host, event);
event.setClassName(ViewPager.class.getName());
+ final AccessibilityRecordCompat recordCompat = AccessibilityRecordCompat.obtain();
+ recordCompat.setScrollable(canScroll());
+ if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
+ recordCompat.setItemCount(mAdapter.getCount());
+ recordCompat.setFromIndex(mCurItem);
+ recordCompat.setToIndex(mCurItem);
+ }
}
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
super.onInitializeAccessibilityNodeInfo(host, info);
info.setClassName(ViewPager.class.getName());
- info.setScrollable(mAdapter != null && mAdapter.getCount() > 1);
- if (mAdapter != null && mCurItem >= 0 && mCurItem < mAdapter.getCount() - 1) {
+ info.setScrollable(canScroll());
+ if (canScrollForward()) {
info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD);
}
- if (mAdapter != null && mCurItem > 0 && mCurItem < mAdapter.getCount()) {
+ if (canScrollBackward()) {
info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
}
}
@@ -2750,13 +2760,13 @@
}
switch (action) {
case AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD: {
- if (mAdapter != null && mCurItem >= 0 && mCurItem < mAdapter.getCount() - 1) {
+ if (canScrollForward()) {
setCurrentItem(mCurItem + 1);
return true;
}
} return false;
case AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD: {
- if (mAdapter != null && mCurItem > 0 && mCurItem < mAdapter.getCount()) {
+ if (canScrollBackward()) {
setCurrentItem(mCurItem - 1);
return true;
}
@@ -2764,6 +2774,18 @@
}
return false;
}
+
+ private boolean canScroll() {
+ return (mAdapter != null) && (mAdapter.getCount() > 1);
+ }
+
+ private boolean canScrollForward() {
+ return (mAdapter != null) && (mCurItem >= 0) && (mCurItem < (mAdapter.getCount() - 1));
+ }
+
+ private boolean canScrollBackward() {
+ return (mAdapter != null) && (mCurItem > 0) && (mCurItem < mAdapter.getCount());
+ }
}
private class PagerObserver extends DataSetObserver {
diff --git a/v4/java/android/support/v4/view/WindowCompat.java b/v4/java/android/support/v4/view/WindowCompat.java
new file mode 100644
index 0000000..15fe715
--- /dev/null
+++ b/v4/java/android/support/v4/view/WindowCompat.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.view;
+
+import android.view.View;
+import android.view.Window;
+
+/**
+ * Helper for accessing features in {@link Window} introduced after API
+ * level 4 in a backwards compatible fashion.
+ */
+public class WindowCompat {
+ /**
+ * Flag for enabling the Action Bar.
+ * This is enabled by default for some devices. The Action Bar
+ * replaces the title bar and provides an alternate location
+ * for an on-screen menu button on some devices.
+ */
+ public static final int FEATURE_ACTION_BAR = 8;
+
+ /**
+ * Flag for requesting an Action Bar that overlays window content.
+ * Normally an Action Bar will sit in the space above window content, but if this
+ * feature is requested along with {@link #FEATURE_ACTION_BAR} it will be layered over
+ * the window content itself. This is useful if you would like your app to have more control
+ * over how the Action Bar is displayed, such as letting application content scroll beneath
+ * an Action Bar with a transparent background or otherwise displaying a transparent/translucent
+ * Action Bar over application content.
+ *
+ * <p>This mode is especially useful with {@link View#SYSTEM_UI_FLAG_FULLSCREEN
+ * View.SYSTEM_UI_FLAG_FULLSCREEN}, which allows you to seamlessly hide the
+ * action bar in conjunction with other screen decorations.
+ *
+ * <p>As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, when an
+ * ActionBar is in this mode it will adjust the insets provided to
+ * {@link View#fitSystemWindows(android.graphics.Rect) View.fitSystemWindows(Rect)}
+ * to include the content covered by the action bar, so you can do layout within
+ * that space.
+ */
+ public static final int FEATURE_ACTION_BAR_OVERLAY = 9;
+
+ /**
+ * Flag for specifying the behavior of action modes when an Action Bar is not present.
+ * If overlay is enabled, the action mode UI will be allowed to cover existing window content.
+ */
+ public static final int FEATURE_ACTION_MODE_OVERLAY = 10;
+}
diff --git a/v4/java/android/support/v4/view/accessibility/AccessibilityNodeInfoCompat.java b/v4/java/android/support/v4/view/accessibility/AccessibilityNodeInfoCompat.java
index bb0bb49..144d2a1 100644
--- a/v4/java/android/support/v4/view/accessibility/AccessibilityNodeInfoCompat.java
+++ b/v4/java/android/support/v4/view/accessibility/AccessibilityNodeInfoCompat.java
@@ -19,6 +19,7 @@
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
+import android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat;
import android.view.View;
import java.util.ArrayList;
@@ -92,6 +93,8 @@
public CharSequence getContentDescription(Object info);
public void setContentDescription(Object info, CharSequence contentDescription);
public void recycle(Object info);
+ public CharSequence getViewIdResourceName(Object info);
+ public void setViewIdResourceName(Object info, CharSequence viewId);
}
static class AccessibilityNodeInfoStubImpl implements AccessibilityNodeInfoImpl {
@@ -394,6 +397,16 @@
public void setParent(Object info, View root, int virtualDescendantId) {
}
+
+ @Override
+ public CharSequence getViewIdResourceName(Object info) {
+ return null;
+ }
+
+ @Override
+ public void setViewIdResourceName(Object info, CharSequence viewId) {
+
+ }
}
static class AccessibilityNodeInfoIcsImpl extends AccessibilityNodeInfoStubImpl {
@@ -700,8 +713,24 @@
}
}
+ static class AccessibilityNodeInfoJellybeanMr2Impl extends AccessibilityNodeInfoJellybeanImpl {
+
+ @Override
+ public CharSequence getViewIdResourceName(Object info) {
+ return AccessibilityNodeInfoCompatJellybeanMr2.getViewIdResourceName(info);
+ }
+
+ @Override
+ public void setViewIdResourceName(Object info, CharSequence viewId) {
+ AccessibilityNodeInfoCompatJellybeanMr2.setViewIdResourceName(info, viewId);
+ }
+ }
+
static {
- if (Build.VERSION.SDK_INT >= 16) { // JellyBean
+ // TODO: Use SDK_INT when it is finalized, tracked by bug:8133596
+ if ("JellyBeanMR2".equals(Build.VERSION.CODENAME)) { // JellyBean MR2
+ IMPL = new AccessibilityNodeInfoJellybeanMr2Impl();
+ } else if (Build.VERSION.SDK_INT >= 16) { // JellyBean
IMPL = new AccessibilityNodeInfoJellybeanImpl();
} else if (Build.VERSION.SDK_INT >= 14) { // ICS
IMPL = new AccessibilityNodeInfoIcsImpl();
@@ -714,7 +743,7 @@
private final Object mInfo;
- // Actions.
+ // Actions introduced in IceCreamSandwich
/**
* Action that focuses the node.
@@ -746,6 +775,8 @@
*/
public static final int ACTION_LONG_CLICK = 0x00000020;
+ // Actions introduced in JellyBean
+
/**
* Action that gives accessibility focus to the node.
*/
@@ -761,16 +792,22 @@
* at a given movement granularity. For example, move to the next character,
* word, etc.
* <p>
- * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT}<br>
- * <strong>Example:</strong>
+ * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT}<,
+ * {@link #ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN}<br>
+ * <strong>Example:</strong> Move to the previous character and do not extend selection.
* <code><pre><p>
* Bundle arguments = new Bundle();
* arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT,
* AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER);
+ * arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN,
+ * false);
* info.performAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
* </code></pre></p>
* </p>
*
+ * @see #ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
+ * @see #ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
+ *
* @see #setMovementGranularities(int)
* @see #getMovementGranularities()
*
@@ -787,17 +824,23 @@
* at a given movement granularity. For example, move to the next character,
* word, etc.
* <p>
- * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT}<br>
- * <strong>Example:</strong>
+ * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT}<,
+ * {@link #ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN}<br>
+ * <strong>Example:</strong> Move to the next character and do not extend selection.
* <code><pre><p>
* Bundle arguments = new Bundle();
* arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT,
* AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER);
+ * arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN,
+ * false);
* info.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY,
* arguments);
* </code></pre></p>
* </p>
*
+ * @see #ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
+ * @see #ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
+ *
* @see #setMovementGranularities(int)
* @see #getMovementGranularities()
*
@@ -849,6 +892,45 @@
*/
public static final int ACTION_SCROLL_BACKWARD = 0x00002000;
+ // Actions introduced in JellyBeanMr2
+
+ /**
+ * Action to copy the current selection to the clipboard.
+ */
+ public static final int ACTION_COPY = 0x00004000;
+
+ /**
+ * Action to paste the current clipboard content.
+ */
+ public static final int ACTION_PASTE = 0x00008000;
+
+ /**
+ * Action to cut the current selection and place it to the clipboard.
+ */
+ public static final int ACTION_CUT = 0x00010000;
+
+ /**
+ * Action to set the selection. Performing this action with no arguments
+ * clears the selection.
+ * <p>
+ * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_SELECTION_START_INT},
+ * {@link #ACTION_ARGUMENT_SELECTION_END_INT}<br>
+ * <strong>Example:</strong>
+ * <code><pre><p>
+ * Bundle arguments = new Bundle();
+ * arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 1);
+ * arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 2);
+ * info.performAction(AccessibilityNodeInfo.ACTION_SET_SELECTION, arguments);
+ * </code></pre></p>
+ * </p>
+ *
+ * @see #ACTION_ARGUMENT_SELECTION_START_INT
+ * @see #ACTION_ARGUMENT_SELECTION_END_INT
+ */
+ public static final int ACTION_SET_SELECTION = 0x00020000;
+
+ // Action arguments
+
/**
* Argument for which movement granularity to be used when traversing the node text.
* <p>
@@ -872,6 +954,47 @@
"ACTION_ARGUMENT_HTML_ELEMENT_STRING";
/**
+ * Argument for whether when moving at granularity to extend the selection
+ * or to move it otherwise.
+ * <p>
+ * <strong>Type:</strong> boolean<br>
+ * <strong>Actions:</strong> {@link #ACTION_NEXT_AT_MOVEMENT_GRANULARITY},
+ * {@link #ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY}
+ * </p>
+ *
+ * @see #ACTION_NEXT_AT_MOVEMENT_GRANULARITY
+ * @see #ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY
+ */
+ public static final String ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN =
+ "ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN";
+
+ /**
+ * Argument for specifying the selection start.
+ * <p>
+ * <strong>Type:</strong> int<br>
+ * <strong>Actions:</strong> {@link #ACTION_SET_SELECTION}
+ * </p>
+ *
+ * @see #ACTION_SET_SELECTION
+ */
+ public static final String ACTION_ARGUMENT_SELECTION_START_INT =
+ "ACTION_ARGUMENT_SELECTION_START_INT";
+
+ /**
+ * Argument for specifying the selection end.
+ * <p>
+ * <strong>Type:</strong> int<br>
+ * <strong>Actions:</strong> {@link #ACTION_SET_SELECTION}
+ * </p>
+ *
+ * @see #ACTION_SET_SELECTION
+ */
+ public static final String ACTION_ARGUMENT_SELECTION_END_INT =
+ "ACTION_ARGUMENT_SELECTION_END_INT";
+
+ // Focus types
+
+ /**
* The input focus.
*/
public static final int FOCUS_INPUT = 1;
@@ -1724,6 +1847,37 @@
IMPL.recycle(mInfo);
}
+ /**
+ * Sets the fully qualified resource name of the source view's id.
+ *
+ * <p>
+ * <strong>Note:</strong> Cannot be called from an
+ * {@link android.accessibilityservice.AccessibilityService}.
+ * This class is made immutable before being delivered to an AccessibilityService.
+ * </p>
+ *
+ * @param viewId The id resource name.
+ */
+ public void setViewIdResourceName(CharSequence viewId) {
+ IMPL.setViewIdResourceName(mInfo, viewId);
+ }
+
+ /**
+ * Gets the fully qualified resource name of the source view's id.
+ *
+ * <p>
+ * <strong>Note:</strong> The primary usage of this API is for UI test automation
+ * and in order to report the source view id of an {@link AccessibilityNodeInfoCompat}
+ * the client has to set the {@link AccessibilityServiceInfoCompat#FLAG_REPORT_VIEW_IDS}
+ * flag when configuring his {@link android.accessibilityservice.AccessibilityService}.
+ * </p>
+ *
+ * @return The id resource name.
+ */
+ public CharSequence getViewIdResourceName() {
+ return IMPL.getViewIdResourceName(mInfo);
+ }
+
@Override
public int hashCode() {
return (mInfo == null) ? 0 : mInfo.hashCode();
@@ -1750,4 +1904,91 @@
}
return true;
}
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append(super.toString());
+
+ Rect bounds = new Rect();
+
+ getBoundsInParent(bounds);
+ builder.append("; boundsInParent: " + bounds);
+
+ getBoundsInScreen(bounds);
+ builder.append("; boundsInScreen: " + bounds);
+
+ builder.append("; packageName: ").append(getPackageName());
+ builder.append("; className: ").append(getClassName());
+ builder.append("; text: ").append(getText());
+ builder.append("; contentDescription: ").append(getContentDescription());
+ builder.append("; viewId: ").append(getViewIdResourceName());
+
+ builder.append("; checkable: ").append(isCheckable());
+ builder.append("; checked: ").append(isChecked());
+ builder.append("; focusable: ").append(isFocusable());
+ builder.append("; focused: ").append(isFocused());
+ builder.append("; selected: ").append(isSelected());
+ builder.append("; clickable: ").append(isClickable());
+ builder.append("; longClickable: ").append(isLongClickable());
+ builder.append("; enabled: ").append(isEnabled());
+ builder.append("; password: ").append(isPassword());
+ builder.append("; scrollable: " + isScrollable());
+
+ builder.append("; [");
+ for (int actionBits = getActions(); actionBits != 0;) {
+ final int action = 1 << Integer.numberOfTrailingZeros(actionBits);
+ actionBits &= ~action;
+ builder.append(getActionSymbolicName(action));
+ if (actionBits != 0) {
+ builder.append(", ");
+ }
+ }
+ builder.append("]");
+
+ return builder.toString();
+ }
+
+ private static String getActionSymbolicName(int action) {
+ switch (action) {
+ case ACTION_FOCUS:
+ return "ACTION_FOCUS";
+ case ACTION_CLEAR_FOCUS:
+ return "ACTION_CLEAR_FOCUS";
+ case ACTION_SELECT:
+ return "ACTION_SELECT";
+ case ACTION_CLEAR_SELECTION:
+ return "ACTION_CLEAR_SELECTION";
+ case ACTION_CLICK:
+ return "ACTION_CLICK";
+ case ACTION_LONG_CLICK:
+ return "ACTION_LONG_CLICK";
+ case ACTION_ACCESSIBILITY_FOCUS:
+ return "ACTION_ACCESSIBILITY_FOCUS";
+ case ACTION_CLEAR_ACCESSIBILITY_FOCUS:
+ return "ACTION_CLEAR_ACCESSIBILITY_FOCUS";
+ case ACTION_NEXT_AT_MOVEMENT_GRANULARITY:
+ return "ACTION_NEXT_AT_MOVEMENT_GRANULARITY";
+ case ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY:
+ return "ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY";
+ case ACTION_NEXT_HTML_ELEMENT:
+ return "ACTION_NEXT_HTML_ELEMENT";
+ case ACTION_PREVIOUS_HTML_ELEMENT:
+ return "ACTION_PREVIOUS_HTML_ELEMENT";
+ case ACTION_SCROLL_FORWARD:
+ return "ACTION_SCROLL_FORWARD";
+ case ACTION_SCROLL_BACKWARD:
+ return "ACTION_SCROLL_BACKWARD";
+ case ACTION_CUT:
+ return "ACTION_CUT";
+ case ACTION_COPY:
+ return "ACTION_COPY";
+ case ACTION_PASTE:
+ return "ACTION_PASTE";
+ case ACTION_SET_SELECTION:
+ return "ACTION_SET_SELECTION";
+ default:
+ return"ACTION_UNKNOWN";
+ }
+ }
}
diff --git a/v4/java/android/support/v4/widget/SlidingPaneLayout.java b/v4/java/android/support/v4/widget/SlidingPaneLayout.java
index 3880bd4..2dd8950 100644
--- a/v4/java/android/support/v4/widget/SlidingPaneLayout.java
+++ b/v4/java/android/support/v4/widget/SlidingPaneLayout.java
@@ -507,6 +507,10 @@
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
+ if (child.getVisibility() == GONE) {
+ continue;
+ }
+
final boolean skippedFirstPass = lp.width == 0 && lp.weight > 0;
final int measuredWidth = skippedFirstPass ? 0 : child.getMeasuredWidth();
if (canSlide && child != mSlideableView) {
@@ -585,6 +589,7 @@
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
+
final int width = r - l;
final int paddingLeft = getPaddingLeft();
final int paddingRight = getPaddingRight();
diff --git a/v4/jellybean-mr1/android/support/v4/hardware/display/DisplayManagerJellybeanMr1.java b/v4/jellybean-mr1/android/support/v4/hardware/display/DisplayManagerJellybeanMr1.java
new file mode 100644
index 0000000..b44a2e8
--- /dev/null
+++ b/v4/jellybean-mr1/android/support/v4/hardware/display/DisplayManagerJellybeanMr1.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.hardware.display;
+
+import android.content.Context;
+import android.view.Display;
+
+final class DisplayManagerJellybeanMr1 {
+ public static Object getDisplayManager(Context context) {
+ return context.getSystemService(Context.DISPLAY_SERVICE);
+ }
+
+ public static Display getDisplay(Object displayManagerObj, int displayId) {
+ return ((android.hardware.display.DisplayManager)displayManagerObj).getDisplay(displayId);
+ }
+
+ public static Display[] getDisplays(Object displayManagerObj) {
+ return ((android.hardware.display.DisplayManager)displayManagerObj).getDisplays();
+ }
+
+ public static Display[] getDisplays(Object displayManagerObj, String category) {
+ return ((android.hardware.display.DisplayManager)displayManagerObj).getDisplays(category);
+ }
+}
diff --git a/v4/jellybean-mr2/android/support/v4/accessibilityservice/AccessibilityServiceInfoCompatJellyBeanMr2.java b/v4/jellybean-mr2/android/support/v4/accessibilityservice/AccessibilityServiceInfoCompatJellyBeanMr2.java
new file mode 100644
index 0000000..3a41b7a
--- /dev/null
+++ b/v4/jellybean-mr2/android/support/v4/accessibilityservice/AccessibilityServiceInfoCompatJellyBeanMr2.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.accessibilityservice;
+
+import android.accessibilityservice.AccessibilityServiceInfo;
+import android.content.pm.ResolveInfo;
+
+/**
+ * ICS implementation of the new APIs in AccessibilityServiceInfo.
+ */
+class AccessibilityServiceInfoCompatJellyBeanMr2 {
+
+ public static int getCapabilities(AccessibilityServiceInfo info) {
+ return info.getCapabilities();
+ }
+}
diff --git a/v4/jellybean-mr2/android/support/v4/media/TransportControllerJellybeanMR2.java b/v4/jellybean-mr2/android/support/v4/media/TransportControllerJellybeanMR2.java
new file mode 100644
index 0000000..fa63005
--- /dev/null
+++ b/v4/jellybean-mr2/android/support/v4/media/TransportControllerJellybeanMR2.java
@@ -0,0 +1,201 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.media;
+
+import android.app.PendingIntent;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.media.AudioManager;
+import android.media.RemoteControlClient;
+import android.os.SystemClock;
+import android.util.Log;
+import android.view.InputDevice;
+import android.view.KeyCharacterMap;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.ViewTreeObserver;
+
+public class TransportControllerJellybeanMR2 {
+ final Context mContext;
+ final AudioManager mAudioManager;
+ final View mTargetView;
+ final TransportCallback mTransportCallback;
+ final String mReceiverAction;
+ final IntentFilter mReceiverFilter;
+ final Intent mIntent;
+ final ViewTreeObserver.OnWindowAttachListener mWindowAttachListener =
+ new ViewTreeObserver.OnWindowAttachListener() {
+ @Override
+ public void onWindowAttached() {
+ windowAttached();
+ }
+ @Override
+ public void onWindowDetached() {
+ windowDetached();
+ }
+ };
+ final ViewTreeObserver.OnWindowFocusChangeListener mWindowFocusListener =
+ new ViewTreeObserver.OnWindowFocusChangeListener() {
+ @Override
+ public void onWindowFocusChanged(boolean hasFocus) {
+ if (hasFocus) gainFocus();
+ else loseFocus();
+ }
+ };
+ final BroadcastReceiver mMediaButtonReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ try {
+ KeyEvent event = (KeyEvent)intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
+ mTransportCallback.handleKey(event);
+ } catch (ClassCastException e) {
+ Log.w("TransportController", e);
+ }
+ }
+ };
+ AudioManager.OnAudioFocusChangeListener mAudioFocusChangeListener
+ = new AudioManager.OnAudioFocusChangeListener() {
+ @Override
+ public void onAudioFocusChange(int focusChange) {
+ mTransportCallback.handleAudioFocusChange(focusChange);
+ }
+ };
+
+ PendingIntent mPendingIntent;
+ RemoteControlClient mRemoteControl;
+ boolean mFocused;
+ int mPlayState = 0;
+ boolean mAudioFocused;
+
+ public interface TransportCallback {
+ public void handleKey(KeyEvent key);
+ public void handleAudioFocusChange(int focusChange);
+ }
+
+ public TransportControllerJellybeanMR2(Context context, AudioManager audioManager,
+ View view, TransportCallback transportCallback) {
+ mContext = context;
+ mAudioManager = audioManager;
+ mTargetView = view;
+ mTransportCallback = transportCallback;
+ mReceiverAction = context.getPackageName() + ":transport:" + System.identityHashCode(this);
+ mIntent = new Intent(mReceiverAction);
+ mIntent.setPackage(context.getPackageName());
+ mReceiverFilter = new IntentFilter();
+ mReceiverFilter.addAction(mReceiverAction);
+ mTargetView.getViewTreeObserver().addOnWindowAttachListener(mWindowAttachListener);
+ mTargetView.getViewTreeObserver().addOnWindowFocusChangeListener(mWindowFocusListener);
+ }
+
+ public Object getRemoteControlClient() {
+ return mRemoteControl;
+ }
+
+ public void destroy() {
+ windowDetached();
+ mTargetView.getViewTreeObserver().removeOnWindowAttachListener(mWindowAttachListener);
+ mTargetView.getViewTreeObserver().removeOnWindowFocusChangeListener(mWindowFocusListener);
+ }
+
+ void windowAttached() {
+ mContext.registerReceiver(mMediaButtonReceiver, mReceiverFilter);
+ mPendingIntent = PendingIntent.getBroadcast(mContext, 0, mIntent,
+ PendingIntent.FLAG_CANCEL_CURRENT);
+ mRemoteControl = new RemoteControlClient(mPendingIntent);
+ }
+
+ void gainFocus() {
+ if (!mFocused) {
+ mFocused = true;
+ mAudioManager.registerMediaButtonEventReceiver(mPendingIntent);
+ mAudioManager.registerRemoteControlClient(mRemoteControl);
+ if (mPlayState == RemoteControlClient.PLAYSTATE_PLAYING) {
+ takeAudioFocus();
+ }
+ }
+ }
+
+ void takeAudioFocus() {
+ if (!mAudioFocused) {
+ mAudioFocused = true;
+ mAudioManager.requestAudioFocus(mAudioFocusChangeListener,
+ AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
+ }
+ }
+
+ public void startPlaying() {
+ if (mPlayState != RemoteControlClient.PLAYSTATE_PLAYING) {
+ mPlayState = RemoteControlClient.PLAYSTATE_PLAYING;
+ mRemoteControl.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
+ }
+ if (mFocused) {
+ takeAudioFocus();
+ }
+ }
+
+ public void refreshState(boolean playing, int transportControls) {
+ if (mRemoteControl != null) {
+ mRemoteControl.setPlaybackState(playing ? RemoteControlClient.PLAYSTATE_PLAYING
+ : RemoteControlClient.PLAYSTATE_STOPPED);
+ mRemoteControl.setTransportControlFlags(transportControls);
+ }
+ }
+
+ public void pausePlaying() {
+ if (mPlayState == RemoteControlClient.PLAYSTATE_PLAYING) {
+ mPlayState = RemoteControlClient.PLAYSTATE_PAUSED;
+ mRemoteControl.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
+ }
+ dropAudioFocus();
+ }
+
+ public void stopPlaying() {
+ if (mPlayState != RemoteControlClient.PLAYSTATE_STOPPED) {
+ mPlayState = RemoteControlClient.PLAYSTATE_STOPPED;
+ mRemoteControl.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
+ }
+ dropAudioFocus();
+ }
+
+ void dropAudioFocus() {
+ if (mAudioFocused) {
+ mAudioFocused = false;
+ mAudioManager.abandonAudioFocus(mAudioFocusChangeListener);
+ }
+ }
+
+ void loseFocus() {
+ dropAudioFocus();
+ if (mFocused) {
+ mFocused = false;
+ mAudioManager.unregisterRemoteControlClient(mRemoteControl);
+ mAudioManager.unregisterMediaButtonEventReceiver(mPendingIntent);
+ }
+ }
+
+ void windowDetached() {
+ loseFocus();
+ if (mPendingIntent != null) {
+ mContext.unregisterReceiver(mMediaButtonReceiver);
+ mPendingIntent.cancel();
+ mPendingIntent = null;
+ mRemoteControl = null;
+ }
+ }
+}
diff --git a/v4/jellybean-mr2/android/support/v4/view/accessibility/AccessibilityNodeInfoCompatJellybeanMr2.java b/v4/jellybean-mr2/android/support/v4/view/accessibility/AccessibilityNodeInfoCompatJellybeanMr2.java
new file mode 100644
index 0000000..13ed002
--- /dev/null
+++ b/v4/jellybean-mr2/android/support/v4/view/accessibility/AccessibilityNodeInfoCompatJellybeanMr2.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.view.accessibility;
+
+import android.view.accessibility.AccessibilityNodeInfo;
+
+public class AccessibilityNodeInfoCompatJellybeanMr2 {
+
+ public static void setViewIdResourceName(Object info, CharSequence viewId) {
+ ((AccessibilityNodeInfo) info).setViewIdResourceName(viewId);
+ }
+
+ public static CharSequence getViewIdResourceName(Object info) {
+ return ((AccessibilityNodeInfo) info).getViewIdResourceName();
+ }
+}
diff --git a/v4/jellybean/android/support/v4/app/ActivityCompatJB.java b/v4/jellybean/android/support/v4/app/ActivityCompatJB.java
index a4b527f..0c7318f 100644
--- a/v4/jellybean/android/support/v4/app/ActivityCompatJB.java
+++ b/v4/jellybean/android/support/v4/app/ActivityCompatJB.java
@@ -29,4 +29,8 @@
public static void startActivityForResult(Activity activity, Intent intent, int requestCode, Bundle options) {
activity.startActivityForResult(intent, requestCode, options);
}
+
+ public static void finishAffinity(Activity activity) {
+ activity.finishAffinity();
+ }
}
diff --git a/v4/tests/Android.mk b/v4/tests/Android.mk
new file mode 100644
index 0000000..f94db83
--- /dev/null
+++ b/v4/tests/Android.mk
@@ -0,0 +1,12 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, java)
+
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4
+LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_PACKAGE_NAME := AndroidSupport4Tests
+
+include $(BUILD_PACKAGE)
diff --git a/v4/tests/AndroidManifest.xml b/v4/tests/AndroidManifest.xml
new file mode 100644
index 0000000..f91afc5
--- /dev/null
+++ b/v4/tests/AndroidManifest.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android.support.v4.content.tests">
+
+ <application>
+ <uses-library android:name="android.test.runner" />
+
+ <provider
+ android:name="android.support.v4.content.FileProvider"
+ android:authorities="moocow"
+ android:grantUriPermissions="true">
+ <meta-data
+ android:name="android.support.FILE_PROVIDER_PATHS"
+ android:resource="@xml/paths" />
+ </provider>
+
+ </application>
+
+ <instrumentation
+ android:name="android.test.InstrumentationTestRunner"
+ android:targetPackage="android.support.v4.content.tests" />
+
+</manifest>
diff --git a/v4/tests/java/android/support/v4/content/FileProviderTest.java b/v4/tests/java/android/support/v4/content/FileProviderTest.java
new file mode 100644
index 0000000..b7bd01c
--- /dev/null
+++ b/v4/tests/java/android/support/v4/content/FileProviderTest.java
@@ -0,0 +1,351 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.content;
+
+import static android.provider.OpenableColumns.DISPLAY_NAME;
+import static android.provider.OpenableColumns.SIZE;
+
+import android.content.ContentResolver;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Environment;
+import android.support.v4.content.FileProvider.SimplePathStrategy;
+import android.test.AndroidTestCase;
+import android.test.MoreAsserts;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import libcore.io.IoUtils;
+import libcore.io.Streams;
+
+/**
+ * Tests for {@link FileProvider}
+ */
+public class FileProviderTest extends AndroidTestCase {
+ private static final String TEST_AUTHORITY = "moocow";
+
+ private static final String TEST_FILE = "file.test";
+ private static final byte[] TEST_DATA = new byte[] { (byte) 0xf0, 0x00, 0x0d };
+ private static final byte[] TEST_DATA_ALT = new byte[] { (byte) 0x33, 0x66 };
+
+ private ContentResolver mResolver;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ mResolver = getContext().getContentResolver();
+ }
+
+ public void testStrategyUriSimple() throws Exception {
+ final SimplePathStrategy strat = new SimplePathStrategy("authority");
+ strat.addRoot("tag", mContext.getFilesDir());
+
+ File file = buildPath(mContext.getFilesDir(), "file.test");
+ assertEquals("content://authority/tag/file.test",
+ strat.getUriForFile(file).toString());
+
+ file = buildPath(mContext.getFilesDir(), "subdir", "file.test");
+ assertEquals("content://authority/tag/subdir/file.test",
+ strat.getUriForFile(file).toString());
+
+ file = buildPath(Environment.getExternalStorageDirectory(), "file.test");
+ try {
+ strat.getUriForFile(file);
+ fail("somehow got uri for file outside roots?");
+ } catch (IllegalArgumentException e) {
+ }
+ }
+
+ public void testStrategyUriJumpOutside() throws Exception {
+ final SimplePathStrategy strat = new SimplePathStrategy("authority");
+ strat.addRoot("tag", mContext.getFilesDir());
+
+ File file = buildPath(mContext.getFilesDir(), "..", "file.test");
+ try {
+ strat.getUriForFile(file);
+ fail("file escaped!");
+ } catch (IllegalArgumentException e) {
+ }
+ }
+
+ public void testStrategyUriShortestRoot() throws Exception {
+ SimplePathStrategy strat = new SimplePathStrategy("authority");
+ strat.addRoot("tag1", mContext.getFilesDir());
+ strat.addRoot("tag2", new File("/"));
+
+ File file = buildPath(mContext.getFilesDir(), "file.test");
+ assertEquals("content://authority/tag1/file.test",
+ strat.getUriForFile(file).toString());
+
+ strat = new SimplePathStrategy("authority");
+ strat.addRoot("tag1", new File("/"));
+ strat.addRoot("tag2", mContext.getFilesDir());
+
+ file = buildPath(mContext.getFilesDir(), "file.test");
+ assertEquals("content://authority/tag2/file.test",
+ strat.getUriForFile(file).toString());
+ }
+
+ public void testStrategyFileSimple() throws Exception {
+ final SimplePathStrategy strat = new SimplePathStrategy("authority");
+ strat.addRoot("tag", mContext.getFilesDir());
+
+ File file = buildPath(mContext.getFilesDir(), "file.test");
+ assertEquals(file.getPath(),
+ strat.getFileForUri(Uri.parse("content://authority/tag/file.test")).getPath());
+
+ file = buildPath(mContext.getFilesDir(), "subdir", "file.test");
+ assertEquals(file.getPath(), strat.getFileForUri(
+ Uri.parse("content://authority/tag/subdir/file.test")).getPath());
+ }
+
+ public void testStrategyFileJumpOutside() throws Exception {
+ final SimplePathStrategy strat = new SimplePathStrategy("authority");
+ strat.addRoot("tag", mContext.getFilesDir());
+
+ try {
+ strat.getFileForUri(Uri.parse("content://authority/tag/../file.test"));
+ fail("file escaped!");
+ } catch (SecurityException e) {
+ }
+ }
+
+ public void testStrategyEscaping() throws Exception {
+ final SimplePathStrategy strat = new SimplePathStrategy("authority");
+ strat.addRoot("t/g", mContext.getFilesDir());
+
+ File file = buildPath(mContext.getFilesDir(), "lol\"wat?foo&bar", "wat.txt");
+ final String expected = "content://authority/t%2Fg/lol%22wat%3Ffoo%26bar/wat.txt";
+
+ assertEquals(expected,
+ strat.getUriForFile(file).toString());
+ assertEquals(file.getPath(),
+ strat.getFileForUri(Uri.parse(expected)).getPath());
+ }
+
+ public void testStrategyExtraParams() throws Exception {
+ final SimplePathStrategy strat = new SimplePathStrategy("authority");
+ strat.addRoot("tag", mContext.getFilesDir());
+
+ File file = buildPath(mContext.getFilesDir(), "file.txt");
+ assertEquals(file.getPath(), strat.getFileForUri(
+ Uri.parse("content://authority/tag/file.txt?extra=foo")).getPath());
+ }
+
+ public void testStrategyExtraSeparators() throws Exception {
+ final SimplePathStrategy strat = new SimplePathStrategy("authority");
+ strat.addRoot("tag", mContext.getFilesDir());
+
+ // When canonicalized, the path separators are trimmed
+ File inFile = new File(mContext.getFilesDir(), "//foo//bar//");
+ File outFile = new File(mContext.getFilesDir(), "/foo/bar");
+ final String expected = "content://authority/tag/foo/bar";
+
+ assertEquals(expected,
+ strat.getUriForFile(inFile).toString());
+ assertEquals(outFile.getPath(),
+ strat.getFileForUri(Uri.parse(expected)).getPath());
+ }
+
+ public void testQueryProjectionNull() throws Exception {
+ final File file = new File(mContext.getFilesDir(), TEST_FILE);
+ final Uri uri = stageFileAndGetUri(file, TEST_DATA);
+
+ // Verify that null brings out default columns
+ Cursor cursor = mResolver.query(uri, null, null, null, null);
+ try {
+ assertEquals(1, cursor.getCount());
+ cursor.moveToFirst();
+ assertEquals(TEST_FILE, cursor.getString(cursor.getColumnIndex(DISPLAY_NAME)));
+ assertEquals(TEST_DATA.length, cursor.getLong(cursor.getColumnIndex(SIZE)));
+ } finally {
+ cursor.close();
+ }
+ }
+
+ public void testQueryProjectionOrder() throws Exception {
+ final File file = new File(mContext.getFilesDir(), TEST_FILE);
+ final Uri uri = stageFileAndGetUri(file, TEST_DATA);
+
+ // Verify that swapped order works
+ Cursor cursor = mResolver.query(uri, new String[] {
+ SIZE, DISPLAY_NAME }, null, null, null);
+ try {
+ assertEquals(1, cursor.getCount());
+ cursor.moveToFirst();
+ assertEquals(TEST_DATA.length, cursor.getLong(0));
+ assertEquals(TEST_FILE, cursor.getString(1));
+ } finally {
+ cursor.close();
+ }
+
+ cursor = mResolver.query(uri, new String[] {
+ DISPLAY_NAME, SIZE }, null, null, null);
+ try {
+ assertEquals(1, cursor.getCount());
+ cursor.moveToFirst();
+ assertEquals(TEST_FILE, cursor.getString(0));
+ assertEquals(TEST_DATA.length, cursor.getLong(1));
+ } finally {
+ cursor.close();
+ }
+ }
+
+ public void testQueryExtraColumn() throws Exception {
+ final File file = new File(mContext.getFilesDir(), TEST_FILE);
+ final Uri uri = stageFileAndGetUri(file, TEST_DATA);
+
+ // Verify that extra column doesn't gook things up
+ Cursor cursor = mResolver.query(uri, new String[] {
+ SIZE, "foobar", DISPLAY_NAME }, null, null, null);
+ try {
+ assertEquals(1, cursor.getCount());
+ cursor.moveToFirst();
+ assertEquals(TEST_DATA.length, cursor.getLong(0));
+ assertEquals(TEST_FILE, cursor.getString(1));
+ } finally {
+ cursor.close();
+ }
+ }
+
+ public void testReadFile() throws Exception {
+ final File file = new File(mContext.getFilesDir(), TEST_FILE);
+ final Uri uri = stageFileAndGetUri(file, TEST_DATA);
+
+ assertContentsEquals(TEST_DATA, uri);
+ }
+
+ public void testWriteFile() throws Exception {
+ final File file = new File(mContext.getFilesDir(), TEST_FILE);
+ final Uri uri = stageFileAndGetUri(file, TEST_DATA);
+
+ assertContentsEquals(TEST_DATA, uri);
+
+ final OutputStream out = mResolver.openOutputStream(uri);
+ try {
+ out.write(TEST_DATA_ALT);
+ } finally {
+ IoUtils.closeQuietly(out);
+ }
+
+ assertContentsEquals(TEST_DATA_ALT, uri);
+ }
+
+ public void testWriteMissingFile() throws Exception {
+ final File file = new File(mContext.getFilesDir(), TEST_FILE);
+ final Uri uri = stageFileAndGetUri(file, null);
+
+ try {
+ assertContentsEquals(new byte[0], uri);
+ fail("Somehow read missing file?");
+ } catch(FileNotFoundException e) {
+ }
+
+ final OutputStream out = mResolver.openOutputStream(uri);
+ try {
+ out.write(TEST_DATA_ALT);
+ } finally {
+ IoUtils.closeQuietly(out);
+ }
+
+ assertContentsEquals(TEST_DATA_ALT, uri);
+ }
+
+ public void testDelete() throws Exception {
+ final File file = new File(mContext.getFilesDir(), TEST_FILE);
+ final Uri uri = stageFileAndGetUri(file, TEST_DATA);
+
+ assertContentsEquals(TEST_DATA, uri);
+
+ assertEquals(1, mResolver.delete(uri, null, null));
+ assertEquals(0, mResolver.delete(uri, null, null));
+
+ try {
+ assertContentsEquals(new byte[0], uri);
+ fail("Somehow read missing file?");
+ } catch(FileNotFoundException e) {
+ }
+ }
+
+ public void testMetaDataTargets() {
+ Uri actual;
+
+ actual = FileProvider.getUriForFile(mContext, TEST_AUTHORITY,
+ new File("/proc/version"));
+ assertEquals("content://moocow/test_root/proc/version", actual.toString());
+
+ actual = FileProvider.getUriForFile(mContext, TEST_AUTHORITY,
+ new File("/proc/1/mountinfo"));
+ assertEquals("content://moocow/test_init/mountinfo", actual.toString());
+
+ actual = FileProvider.getUriForFile(mContext, TEST_AUTHORITY,
+ buildPath(mContext.getFilesDir(), "meow"));
+ assertEquals("content://moocow/test_files/meow", actual.toString());
+
+ actual = FileProvider.getUriForFile(mContext, TEST_AUTHORITY,
+ buildPath(mContext.getFilesDir(), "thumbs", "rawr"));
+ assertEquals("content://moocow/test_thumbs/rawr", actual.toString());
+
+ actual = FileProvider.getUriForFile(mContext, TEST_AUTHORITY,
+ buildPath(mContext.getCacheDir(), "up", "down"));
+ assertEquals("content://moocow/test_cache/up/down", actual.toString());
+
+ actual = FileProvider.getUriForFile(mContext, TEST_AUTHORITY,
+ buildPath(Environment.getExternalStorageDirectory(), "Android", "obb", "foobar"));
+ assertEquals("content://moocow/test_external/Android/obb/foobar", actual.toString());
+ }
+
+ private void assertContentsEquals(byte[] expected, Uri actual) throws Exception {
+ final InputStream in = mResolver.openInputStream(actual);
+ try {
+ MoreAsserts.assertEquals(expected, Streams.readFully(in));
+ } finally {
+ IoUtils.closeQuietly(in);
+ }
+ }
+
+ private Uri stageFileAndGetUri(File file, byte[] data) throws Exception {
+ if (data != null) {
+ final FileOutputStream out = new FileOutputStream(file);
+ try {
+ out.write(data);
+ } finally {
+ out.close();
+ }
+ } else {
+ file.delete();
+ }
+ return FileProvider.getUriForFile(mContext, TEST_AUTHORITY, file);
+ }
+
+ private static File buildPath(File base, String... segments) {
+ File cur = base;
+ for (String segment : segments) {
+ if (cur == null) {
+ cur = new File(segment);
+ } else {
+ cur = new File(cur, segment);
+ }
+ }
+ return cur;
+ }
+}
diff --git a/v4/tests/java/android/support/v4/text/bidi/BidiFormatterTest.java b/v4/tests/java/android/support/v4/text/bidi/BidiFormatterTest.java
new file mode 100644
index 0000000..28980a5
--- /dev/null
+++ b/v4/tests/java/android/support/v4/text/bidi/BidiFormatterTest.java
@@ -0,0 +1,421 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.text.bidi;
+
+import android.test.AndroidTestCase;
+import android.support.v4.text.TextDirectionHeuristicsCompat;
+
+import java.util.Locale;
+
+public class BidiFormatterTest extends AndroidTestCase {
+
+ private static final BidiFormatter LTR_FMT = BidiFormatter.getInstance(false /* LTR context */);
+ private static final BidiFormatter RTL_FMT = BidiFormatter.getInstance(true /* RTL context */);
+
+ private static final BidiFormatter LTR_FMT_EXIT_RESET =
+ new BidiFormatter.Builder(false /* LTR context */).stereoReset(false).build();
+ private static final BidiFormatter RTL_FMT_EXIT_RESET =
+ new BidiFormatter.Builder(true /* RTL context */).stereoReset(false).build();
+
+ private static final String EN = "abba";
+ private static final String HE = "\u05e0\u05e1";
+
+ private static final String LRM = "\u200E";
+ private static final String RLM = "\u200F";
+ private static final String LRE = "\u202A";
+ private static final String RLE = "\u202B";
+ private static final String PDF = "\u202C";
+
+ private static final String LEFT = "left";
+ private static final String RIGHT = "right";
+
+
+ public void testIsRtlContext() {
+ assertEquals(false, LTR_FMT.isRtlContext());
+ assertEquals(true, RTL_FMT.isRtlContext());
+
+ assertEquals(false, BidiFormatter.getInstance(Locale.ENGLISH).isRtlContext());
+ assertEquals(true, BidiFormatter.getInstance(true).isRtlContext());
+ }
+
+ public void testBuilderIsRtlContext() {
+ assertEquals(false, new BidiFormatter.Builder(false).build().isRtlContext());
+ assertEquals(true, new BidiFormatter.Builder(true).build().isRtlContext());
+ }
+
+ public void testIsRtl() {
+ assertEquals(true, BidiFormatter.getInstance(true).isRtl(HE));
+ assertEquals(true, BidiFormatter.getInstance(false).isRtl(HE));
+
+ assertEquals(false, BidiFormatter.getInstance(true).isRtl(EN));
+ assertEquals(false, BidiFormatter.getInstance(false).isRtl(EN));
+ }
+
+ public void testDirAttrValue() {
+ assertEquals("ltr", LTR_FMT.dirAttrValue(EN));
+ assertEquals("ltr", RTL_FMT.dirAttrValue(EN));
+
+ assertEquals("rtl", LTR_FMT.dirAttrValue(HE));
+ assertEquals("rtl", RTL_FMT.dirAttrValue(HE));
+
+ assertEquals("ltr", LTR_FMT.dirAttrValue(EN, TextDirectionHeuristicsCompat.LTR));
+ assertEquals("rtl", LTR_FMT.dirAttrValue(EN, TextDirectionHeuristicsCompat.RTL));
+
+ assertEquals("ltr", RTL_FMT.dirAttrValue(EN, TextDirectionHeuristicsCompat.LTR));
+ assertEquals("rtl", RTL_FMT.dirAttrValue(EN, TextDirectionHeuristicsCompat.RTL));
+
+ assertEquals("ltr", LTR_FMT.dirAttrValue(HE, TextDirectionHeuristicsCompat.LTR));
+ assertEquals("rtl", LTR_FMT.dirAttrValue(HE, TextDirectionHeuristicsCompat.RTL));
+
+ assertEquals("ltr", RTL_FMT.dirAttrValue(HE, TextDirectionHeuristicsCompat.LTR));
+ assertEquals("rtl", RTL_FMT.dirAttrValue(HE, TextDirectionHeuristicsCompat.RTL));
+
+ assertEquals("ltr", LTR_FMT.dirAttrValue("", TextDirectionHeuristicsCompat.LTR));
+ assertEquals("rtl", LTR_FMT.dirAttrValue("", TextDirectionHeuristicsCompat.RTL));
+
+ assertEquals("ltr", RTL_FMT.dirAttrValue("", TextDirectionHeuristicsCompat.LTR));
+ assertEquals("rtl", RTL_FMT.dirAttrValue("", TextDirectionHeuristicsCompat.RTL));
+ }
+
+ public void testDirAttr() {
+ assertEquals("", LTR_FMT.dirAttr(EN));
+ assertEquals("dir=\"ltr\"", RTL_FMT.dirAttr(EN));
+
+ assertEquals("dir=\"rtl\"", LTR_FMT.dirAttr(HE));
+ assertEquals("", RTL_FMT.dirAttr(HE));
+
+ assertEquals("", LTR_FMT.dirAttr(".", TextDirectionHeuristicsCompat.LTR));
+ assertEquals("dir=\"ltr\"", RTL_FMT.dirAttr(".", TextDirectionHeuristicsCompat.LTR));
+
+ assertEquals("dir=\"rtl\"", LTR_FMT.dirAttr(".", TextDirectionHeuristicsCompat.RTL));
+ assertEquals("", RTL_FMT.dirAttr(".", TextDirectionHeuristicsCompat.RTL));
+ }
+
+ public void testMarkAfter() {
+ assertEquals("uniform dir matches LTR context",
+ "", LTR_FMT.markAfter(EN));
+ assertEquals("uniform dir matches RTL context",
+ "", RTL_FMT.markAfter(HE));
+
+ assertEquals("exit dir opposite to LTR context",
+ LRM, LTR_FMT.markAfter(EN + HE, TextDirectionHeuristicsCompat.LTR));
+ assertEquals("exit dir opposite to RTL context",
+ RLM, RTL_FMT.markAfter(HE + EN, TextDirectionHeuristicsCompat.RTL));
+
+ assertEquals("overall dir (but not exit dir) opposite to LTR context",
+ LRM, LTR_FMT.markAfter(HE + EN, TextDirectionHeuristicsCompat.RTL));
+ assertEquals("overall dir (but not exit dir) opposite to RTL context",
+ RLM, RTL_FMT.markAfter(EN + HE, TextDirectionHeuristicsCompat.LTR));
+
+ assertEquals("exit dir neutral, overall dir matches LTR context",
+ "", LTR_FMT.markAfter(".", TextDirectionHeuristicsCompat.LTR));
+ assertEquals("exit dir neutral, overall dir matches RTL context",
+ "", RTL_FMT.markAfter(".", TextDirectionHeuristicsCompat.RTL));
+ }
+
+ public void testMarkBefore() {
+ assertEquals("uniform dir matches LTR context",
+ "", LTR_FMT.markBefore(EN));
+ assertEquals("uniform dir matches RTL context",
+ "", RTL_FMT.markBefore(HE));
+
+ assertEquals("entry dir opposite to LTR context",
+ LRM, LTR_FMT.markBefore(HE + EN, TextDirectionHeuristicsCompat.LTR));
+ assertEquals("entry dir opposite to RTL context",
+ RLM, RTL_FMT.markBefore(EN + HE, TextDirectionHeuristicsCompat.RTL));
+
+ assertEquals("overall dir (but not entry dir) opposite to LTR context",
+ LRM, LTR_FMT.markBefore(EN + HE, TextDirectionHeuristicsCompat.RTL));
+ assertEquals("overall dir (but not entry dir) opposite to RTL context",
+ RLM, RTL_FMT.markBefore(HE + EN, TextDirectionHeuristicsCompat.LTR));
+
+ assertEquals("exit dir neutral, overall dir matches LTR context",
+ "", LTR_FMT.markBefore(".", TextDirectionHeuristicsCompat.LTR));
+ assertEquals("exit dir neutral, overall dir matches RTL context",
+ "", RTL_FMT.markBefore(".", TextDirectionHeuristicsCompat.RTL));
+ }
+
+
+ public void testMark() {
+ assertEquals(LRM, LTR_FMT.mark());
+ assertEquals(RLM, RTL_FMT.mark());
+ }
+
+ public void testStartEdge() {
+ assertEquals(LEFT, LTR_FMT.startEdge());
+ assertEquals(RIGHT, RTL_FMT.startEdge());
+ }
+
+ public void testEndEdge() {
+ assertEquals(RIGHT, LTR_FMT.endEdge());
+ assertEquals(LEFT, RTL_FMT.endEdge());
+ }
+
+ public void testUnicodeWrap() {
+ // Uniform directionality in opposite context.
+ assertEquals("uniform dir opposite to LTR context",
+ RLE + "." + HE + "." + PDF + LRM,
+ LTR_FMT_EXIT_RESET.unicodeWrap("." + HE + "."));
+ assertEquals("uniform dir opposite to LTR context, stereo reset",
+ LRM + RLE + "." + HE + "." + PDF + LRM,
+ LTR_FMT.unicodeWrap("." + HE + "."));
+ assertEquals("uniform dir opposite to LTR context, stereo reset, no isolation",
+ RLE + "." + HE + "." + PDF,
+ LTR_FMT.unicodeWrap("." + HE + ".", false));
+ assertEquals("neutral treated as opposite to LTR context",
+ RLE + "." + PDF + LRM,
+ LTR_FMT_EXIT_RESET.unicodeWrap(".", TextDirectionHeuristicsCompat.RTL));
+ assertEquals("uniform dir opposite to RTL context",
+ LRE + "." + EN + "." + PDF + RLM,
+ RTL_FMT_EXIT_RESET.unicodeWrap("." + EN + "."));
+ assertEquals("uniform dir opposite to RTL context, stereo reset",
+ RLM + LRE + "." + EN + "." + PDF + RLM,
+ RTL_FMT.unicodeWrap("." + EN + "."));
+ assertEquals("uniform dir opposite to RTL context, stereo reset, no isolation",
+ LRE + "." + EN + "." + PDF,
+ RTL_FMT.unicodeWrap("." + EN + ".", false));
+ assertEquals("neutral treated as opposite to RTL context",
+ LRE + "." + PDF + RLM,
+ RTL_FMT_EXIT_RESET.unicodeWrap(".", TextDirectionHeuristicsCompat.LTR));
+
+ // We test mixed-directionality cases only with an explicit overall directionality parameter
+ // because the estimation logic is outside the sphere of BidiFormatter, and different
+ // estimators will treat them differently.
+
+ // Overall directionality matching context, but with opposite exit directionality.
+ assertEquals("exit dir opposite to LTR context",
+ EN + HE + LRM,
+ LTR_FMT_EXIT_RESET.unicodeWrap(EN + HE, TextDirectionHeuristicsCompat.LTR));
+ assertEquals("exit dir opposite to LTR context, stereo reset",
+ EN + HE + LRM,
+ LTR_FMT.unicodeWrap(EN + HE, TextDirectionHeuristicsCompat.LTR));
+ assertEquals("exit dir opposite to LTR context, stereo reset, no isolation",
+ EN + HE,
+ LTR_FMT.unicodeWrap(EN + HE, TextDirectionHeuristicsCompat.LTR, false));
+
+ assertEquals("exit dir opposite to RTL context",
+ HE + EN + RLM,
+ RTL_FMT_EXIT_RESET.unicodeWrap(HE + EN, TextDirectionHeuristicsCompat.RTL));
+ assertEquals("exit dir opposite to RTL context, stereo reset",
+ HE + EN + RLM,
+ RTL_FMT.unicodeWrap(HE + EN, TextDirectionHeuristicsCompat.RTL));
+ assertEquals("exit dir opposite to RTL context, stereo reset, no isolation",
+ HE + EN,
+ RTL_FMT.unicodeWrap(HE + EN, TextDirectionHeuristicsCompat.RTL, false));
+
+ // Overall directionality matching context, but with opposite entry directionality.
+ assertEquals("entry dir opposite to LTR context",
+ HE + EN,
+ LTR_FMT_EXIT_RESET.unicodeWrap(HE + EN, TextDirectionHeuristicsCompat.LTR));
+ assertEquals("entry dir opposite to LTR context, stereo reset",
+ LRM + HE + EN,
+ LTR_FMT.unicodeWrap(HE + EN, TextDirectionHeuristicsCompat.LTR));
+ assertEquals("entry dir opposite to LTR context, stereo reset, no isolation",
+ HE + EN,
+ LTR_FMT.unicodeWrap(HE + EN, TextDirectionHeuristicsCompat.LTR, false));
+
+ assertEquals("entry dir opposite to RTL context",
+ EN + HE,
+ RTL_FMT_EXIT_RESET.unicodeWrap(EN + HE, TextDirectionHeuristicsCompat.RTL));
+ assertEquals("entry dir opposite to RTL context, stereo reset",
+ RLM + EN + HE,
+ RTL_FMT.unicodeWrap(EN + HE, TextDirectionHeuristicsCompat.RTL));
+ assertEquals("entry dir opposite to RTL context, stereo reset, no isolation",
+ EN + HE,
+ RTL_FMT.unicodeWrap(EN + HE, TextDirectionHeuristicsCompat.RTL, false));
+
+ // Overall directionality matching context, but with opposite entry and exit directionality.
+ assertEquals("entry and exit dir opposite to LTR context",
+ HE + EN + HE + LRM,
+ LTR_FMT_EXIT_RESET.unicodeWrap(HE + EN + HE, TextDirectionHeuristicsCompat.LTR));
+ assertEquals("entry and exit dir opposite to LTR context, stereo reset",
+ LRM + HE + EN + HE + LRM,
+ LTR_FMT.unicodeWrap(HE + EN + HE, TextDirectionHeuristicsCompat.LTR));
+ assertEquals("entry and exit dir opposite to LTR context, no isolation",
+ HE + EN + HE,
+ LTR_FMT_EXIT_RESET.unicodeWrap(HE + EN + HE, TextDirectionHeuristicsCompat.LTR, false));
+
+ assertEquals("entry and exit dir opposite to RTL context",
+ EN + HE + EN + RLM,
+ RTL_FMT_EXIT_RESET.unicodeWrap(EN + HE + EN, TextDirectionHeuristicsCompat.RTL));
+ assertEquals("entry and exit dir opposite to RTL context, no isolation",
+ EN + HE + EN,
+ RTL_FMT_EXIT_RESET.unicodeWrap(EN + HE + EN, TextDirectionHeuristicsCompat.RTL, false));
+
+ // Entry and exit directionality matching context, but with opposite overall directionality.
+ assertEquals("overall dir (but not entry or exit dir) opposite to LTR context",
+ RLE + EN + HE + EN + PDF + LRM,
+ LTR_FMT_EXIT_RESET.unicodeWrap(EN + HE + EN, TextDirectionHeuristicsCompat.RTL));
+ assertEquals("overall dir (but not entry or exit dir) opposite to LTR context, stereo reset",
+ LRM + RLE + EN + HE + EN + PDF + LRM,
+ LTR_FMT.unicodeWrap(EN + HE + EN, TextDirectionHeuristicsCompat.RTL));
+ assertEquals("overall dir (but not entry or exit dir) opposite to LTR context, no isolation",
+ RLE + EN + HE + EN + PDF,
+ LTR_FMT_EXIT_RESET.unicodeWrap(EN + HE + EN, TextDirectionHeuristicsCompat.RTL, false));
+
+ assertEquals("overall dir (but not entry or exit dir) opposite to RTL context",
+ LRE + HE + EN + HE + PDF + RLM,
+ RTL_FMT_EXIT_RESET.unicodeWrap(HE + EN + HE, TextDirectionHeuristicsCompat.LTR));
+ assertEquals("overall dir (but not entry or exit dir) opposite to RTL context, stereo reset",
+ RLM + LRE + HE + EN + HE + PDF + RLM,
+ RTL_FMT.unicodeWrap(HE + EN + HE, TextDirectionHeuristicsCompat.LTR));
+ assertEquals("overall dir (but not entry or exit dir) opposite to RTL context, no isolation",
+ LRE + HE + EN + HE + PDF,
+ RTL_FMT_EXIT_RESET.unicodeWrap(HE + EN + HE, TextDirectionHeuristicsCompat.LTR, false));
+ }
+
+
+ public void testSpanWrap() {
+ // Uniform directionality in matching context.
+ assertEquals("uniform dir matches LTR context",
+ "& " + EN + "<", LTR_FMT.spanWrap("& " + EN + "<"));
+ assertEquals("neutral treated as matching LTR context",
+ ".", LTR_FMT.spanWrap(".", TextDirectionHeuristicsCompat.LTR));
+ assertEquals("uniform dir matches RTL context",
+ "& " + HE + "<", RTL_FMT.spanWrap("& " + HE + "<"));
+ assertEquals("neutral treated as matching RTL context",
+ ".", RTL_FMT.spanWrap(".", TextDirectionHeuristicsCompat.RTL));
+
+ // Uniform directionality in opposite context.
+ assertEquals("uniform dir opposite to LTR context",
+ "<span dir=\"rtl\">." + HE + ".</span>" + LRM,
+ LTR_FMT_EXIT_RESET.spanWrap("." + HE + "."));
+ assertEquals("uniform dir opposite to LTR context, stereo reset",
+ LRM + "<span dir=\"rtl\">." + HE + ".</span>" + LRM,
+ LTR_FMT.spanWrap("." + HE + "."));
+ assertEquals("uniform dir opposite to LTR context, no isolation",
+ "<span dir=\"rtl\">." + HE + ".</span>",
+ LTR_FMT_EXIT_RESET.spanWrap("." + HE + ".", false));
+ assertEquals("uniform dir opposite to LTR context, stereo reset, no isolation",
+ "<span dir=\"rtl\">." + HE + ".</span>",
+ LTR_FMT.spanWrap("." + HE + ".", false));
+ assertEquals("neutral treated as opposite to LTR context",
+ "<span dir=\"rtl\">" + "." + "</span>" + LRM,
+ LTR_FMT_EXIT_RESET.spanWrap(".", TextDirectionHeuristicsCompat.RTL));
+ assertEquals("uniform dir opposite to RTL context",
+ "<span dir=\"ltr\">." + EN + ".</span>" + RLM,
+ RTL_FMT_EXIT_RESET.spanWrap("." + EN + "."));
+ assertEquals("uniform dir opposite to RTL context, stereo reset",
+ RLM + "<span dir=\"ltr\">." + EN + ".</span>" + RLM,
+ RTL_FMT.spanWrap("." + EN + "."));
+ assertEquals("uniform dir opposite to RTL context, no isolation",
+ "<span dir=\"ltr\">." + EN + ".</span>",
+ RTL_FMT_EXIT_RESET.spanWrap("." + EN + ".", false));
+ assertEquals("uniform dir opposite to RTL context, stereo reset, no isolation",
+ "<span dir=\"ltr\">." + EN + ".</span>",
+ RTL_FMT.spanWrap("." + EN + ".", false));
+ assertEquals("neutral treated as opposite to RTL context",
+ "<span dir=\"ltr\">" + "." + "</span>" + RLM,
+ RTL_FMT_EXIT_RESET.spanWrap(".", TextDirectionHeuristicsCompat.LTR));
+
+ // We test mixed-directionality cases only with an explicit overall directionality parameter
+ // because the estimation logic is outside the sphere of BidiFormatter, and different
+ // estimators will treat them differently.
+
+ // Overall directionality matching context, but with opposite exit directionality.
+ assertEquals("exit dir opposite to LTR context",
+ EN + HE + LRM,
+ LTR_FMT_EXIT_RESET.spanWrap(EN + HE, TextDirectionHeuristicsCompat.LTR));
+ assertEquals("exit dir opposite to LTR context, stereo reset",
+ EN + HE + LRM,
+ LTR_FMT.spanWrap(EN + HE, TextDirectionHeuristicsCompat.LTR));
+ assertEquals("exit dir opposite to LTR context, no isolation",
+ EN + HE,
+ LTR_FMT_EXIT_RESET.spanWrap(EN + HE, TextDirectionHeuristicsCompat.LTR, false));
+ assertEquals("exit dir opposite to LTR context, stereo reset, no isolation",
+ EN + HE,
+ LTR_FMT.spanWrap(EN + HE, TextDirectionHeuristicsCompat.LTR, false));
+ assertEquals("exit dir opposite to RTL context",
+ HE + EN + RLM,
+ RTL_FMT_EXIT_RESET.spanWrap(HE + EN, TextDirectionHeuristicsCompat.RTL));
+ assertEquals("exit dir opposite to RTL context, stereo reset",
+ HE + EN + RLM,
+ RTL_FMT.spanWrap(HE + EN, TextDirectionHeuristicsCompat.RTL));
+ assertEquals("exit dir opposite to RTL context, no isolation",
+ HE + EN,
+ RTL_FMT_EXIT_RESET.spanWrap(HE + EN, TextDirectionHeuristicsCompat.RTL, false));
+ assertEquals("exit dir opposite to RTL context, stereo reset, no isolation",
+ HE + EN,
+ RTL_FMT.spanWrap( HE + EN, TextDirectionHeuristicsCompat.RTL, false));
+
+ // Overall directionality matching context, but with opposite entry directionality.
+ assertEquals("entry dir opposite to LTR context",
+ HE + EN,
+ LTR_FMT_EXIT_RESET.spanWrap(HE + EN, TextDirectionHeuristicsCompat.LTR));
+ assertEquals("entry dir opposite to LTR context, stereo reset",
+ LRM + HE + EN,
+ LTR_FMT.spanWrap(HE + EN, TextDirectionHeuristicsCompat.LTR));
+ assertEquals("entry dir opposite to LTR context, no isolation",
+ HE + EN,
+ LTR_FMT_EXIT_RESET.spanWrap(HE + EN, TextDirectionHeuristicsCompat.LTR, false));
+ assertEquals("entry dir opposite to LTR context, stereo reset, no isolation",
+ HE + EN,
+ LTR_FMT.spanWrap(HE + EN, TextDirectionHeuristicsCompat.LTR, false));
+ assertEquals("entry dir opposite to RTL context",
+ EN + HE,
+ RTL_FMT_EXIT_RESET.spanWrap(EN + HE, TextDirectionHeuristicsCompat.RTL));
+ assertEquals("entry dir opposite to RTL context, stereo reset",
+ RLM + EN + HE,
+ RTL_FMT.spanWrap(EN + HE, TextDirectionHeuristicsCompat.RTL));
+ assertEquals("entry dir opposite to RTL context, no isolation",
+ EN + HE,
+ RTL_FMT_EXIT_RESET.spanWrap(EN + HE, TextDirectionHeuristicsCompat.RTL, false));
+ assertEquals("entry dir opposite to RTL context, stereo reset, no isolation",
+ EN + HE,
+ RTL_FMT.spanWrap(EN + HE, TextDirectionHeuristicsCompat.RTL, false));
+
+ // Overall directionality matching context, but with opposite entry and exit directionality.
+ assertEquals("entry and exit dir opposite to LTR context",
+ HE + EN + HE + LRM,
+ LTR_FMT_EXIT_RESET.spanWrap(HE + EN + HE, TextDirectionHeuristicsCompat.LTR));
+ assertEquals("entry and exit dir opposite to LTR context, stereo reset",
+ LRM + HE + EN + HE + LRM,
+ LTR_FMT.spanWrap(HE + EN + HE, TextDirectionHeuristicsCompat.LTR));
+ assertEquals("entry and exit dir opposite to LTR context, no isolation",
+ HE + EN + HE,
+ LTR_FMT_EXIT_RESET.spanWrap(HE + EN + HE, TextDirectionHeuristicsCompat.LTR, false));
+ assertEquals("entry and exit dir opposite to RTL context",
+ EN + HE + EN + RLM,
+ RTL_FMT_EXIT_RESET.spanWrap(EN + HE + EN, TextDirectionHeuristicsCompat.RTL));
+ assertEquals("entry and exit dir opposite to RTL context, stereo reset",
+ RLM + EN + HE + EN + RLM,
+ RTL_FMT.spanWrap(EN + HE + EN, TextDirectionHeuristicsCompat.RTL));
+ assertEquals("entry and exit dir opposite to RTL context, no isolation",
+ EN + HE + EN,
+ RTL_FMT_EXIT_RESET.spanWrap(EN + HE + EN, TextDirectionHeuristicsCompat.RTL, false));
+
+ // Entry and exit directionality matching context, but with opposite overall directionality.
+ assertEquals("overall dir (but not entry or exit dir) opposite to LTR context",
+ "<span dir=\"rtl\">" + EN + HE + EN + "</span>" + LRM,
+ LTR_FMT_EXIT_RESET.spanWrap(EN + HE + EN, TextDirectionHeuristicsCompat.RTL));
+ assertEquals("overall dir (but not entry or exit dir) opposite to LTR context, stereo reset",
+ LRM + "<span dir=\"rtl\">" + EN + HE + EN + "</span>" + LRM,
+ LTR_FMT.spanWrap(EN + HE + EN, TextDirectionHeuristicsCompat.RTL));
+ assertEquals("overall dir (but not entry or exit dir) opposite to LTR context, no isolation",
+ "<span dir=\"rtl\">" + EN + HE + EN + "</span>",
+ LTR_FMT_EXIT_RESET.spanWrap(EN + HE + EN, TextDirectionHeuristicsCompat.RTL, false));
+ assertEquals("overall dir (but not entry or exit dir) opposite to RTL context",
+ "<span dir=\"ltr\">" + HE + EN + HE + "</span>" + RLM,
+ RTL_FMT_EXIT_RESET.spanWrap(HE + EN + HE, TextDirectionHeuristicsCompat.LTR));
+ assertEquals("overall dir (but not entry or exit dir) opposite to RTL context, stereo reset",
+ RLM + "<span dir=\"ltr\">" + HE + EN + HE + "</span>" + RLM,
+ RTL_FMT.spanWrap(HE + EN + HE, TextDirectionHeuristicsCompat.LTR));
+ assertEquals("overall dir (but not entry or exit dir) opposite to RTL context, no isolation",
+ "<span dir=\"ltr\">" + HE + EN + HE + "</span>",
+ RTL_FMT_EXIT_RESET.spanWrap(HE + EN + HE, TextDirectionHeuristicsCompat.LTR, false));
+ }
+}
diff --git a/v4/tests/res/xml/paths.xml b/v4/tests/res/xml/paths.xml
new file mode 100644
index 0000000..baa2908
--- /dev/null
+++ b/v4/tests/res/xml/paths.xml
@@ -0,0 +1,14 @@
+<paths xmlns:android="http://schemas.android.com/apk/res/android">
+ <!-- / -->
+ <root-path name="test_root" />
+ <!-- /proc/1 -->
+ <root-path name="test_init" path="proc/1/" />
+ <!-- /data/data/com.example/files -->
+ <files-path name="test_files" />
+ <!-- /data/data/com.example/files/thumbs -->
+ <files-path name="test_thumbs" path="thumbs/" />
+ <!-- /data/data/com.example/cache -->
+ <cache-path name="test_cache" />
+ <!-- /storage/emulated/0/Android/com.example/files -->
+ <external-path name="test_external" />
+</paths>
diff --git a/v7/Android.mk b/v7/Android.mk
deleted file mode 100644
index 52e7fd3..0000000
--- a/v7/Android.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-
-# Note: the source code is in java/, not src/, because this code is also part of
-# the framework library, and build/core/pathmap.mk expects a java/ subdirectory.
-
-# A helper sub-library that contains the R class only. Used to compiled the final library
-# without being included in it.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-v7-gridlayout-r
-LOCAL_SRC_FILES := $(call all-java-files-under, gridlayout/gen)
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# Here is the final static library that apps can link against.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-v7-gridlayout
-#LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := $(call all-java-files-under, gridlayout/src)
-LOCAL_JAVA_LIBRARIES += \
- android-support-v7-gridlayout-r
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# Include this library in the build server's output directory
-$(call dist-for-goals, droidcore sdk, $(LOCAL_BUILT_MODULE):android-support-v7-gridlayout.jar)
diff --git a/appcompat/.classpath b/v7/appcompat/.classpath
similarity index 67%
rename from appcompat/.classpath
rename to v7/appcompat/.classpath
index 0962016..a4763d1 100644
--- a/appcompat/.classpath
+++ b/v7/appcompat/.classpath
@@ -1,12 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="eclair"/>
- <classpathentry kind="src" path="honeycomb"/>
- <classpathentry kind="src" path="ics"/>
- <classpathentry kind="src" path="java"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
diff --git a/appcompat/.gitignore b/v7/appcompat/.gitignore
similarity index 100%
rename from appcompat/.gitignore
rename to v7/appcompat/.gitignore
diff --git a/appcompat/.project b/v7/appcompat/.project
similarity index 94%
copy from appcompat/.project
copy to v7/appcompat/.project
index bac1446..957d33d 100644
--- a/appcompat/.project
+++ b/v7/appcompat/.project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>android-support-appcompat</name>
+ <name>android-support-v7-appcompat</name>
<comment></comment>
<projects>
</projects>
diff --git a/appcompat/Android.mk b/v7/appcompat/Android.mk
similarity index 64%
copy from appcompat/Android.mk
copy to v7/appcompat/Android.mk
index 3724ff4..ae73678 100644
--- a/appcompat/Android.mk
+++ b/v7/appcompat/Android.mk
@@ -14,16 +14,18 @@
LOCAL_PATH := $(call my-dir)
-# Note: the source code is in java/, not src/, because this code is also part of
-# the framework library, and build/core/pathmap.mk expects a java/ subdirectory.
-
+# Here is the final static library that apps can link against.
+# The R class is automatically excluded from the generated library.
+# Applications that use this library must specify LOCAL_RESOURCE_DIR
+# in their makefiles to include the resources in their package.
include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-appcompat
-LOCAL_SDK_VERSION := 14
-LOCAL_SRC_FILES := $(call all-java-files-under,eclair honeycomb ics java)
-LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
+LOCAL_MODULE := android-support-v7-appcompat
+LOCAL_SDK_VERSION := current
+LOCAL_SRC_FILES := $(call all-java-files-under,src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+LOCAL_JAVA_LIBRARIES += android-support-v4
include $(BUILD_STATIC_JAVA_LIBRARY)
# Include this library in the build server's output directory
-$(call dist-for-goals, droidcore sdk, $(LOCAL_BUILT_MODULE):android-support-appcompat.jar)
+$(call dist-for-goals, droidcore sdk, $(LOCAL_BUILT_MODULE):android-support-v7-appcompat.jar)
+
diff --git a/appcompat/AndroidManifest.xml b/v7/appcompat/AndroidManifest.xml
similarity index 88%
rename from appcompat/AndroidManifest.xml
rename to v7/appcompat/AndroidManifest.xml
index 4f60d8d..a77e640 100644
--- a/appcompat/AndroidManifest.xml
+++ b/v7/appcompat/AndroidManifest.xml
@@ -14,6 +14,6 @@
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.support.appcompat">
- <uses-sdk android:minSdkVersion="9"/>
+ package="android.support.v7.appcompat">
+ <uses-sdk android:minSdkVersion="7"/>
</manifest>
diff --git a/v7/appcompat/README.txt b/v7/appcompat/README.txt
new file mode 100644
index 0000000..8e8de05
--- /dev/null
+++ b/v7/appcompat/README.txt
@@ -0,0 +1,10 @@
+Library Project including compatibility ActionBar.
+
+This can be used by an Android project to provide
+access to ActionBar on applications running on API 7+.
+
+There is technically no source, but the src folder is necessary
+to ensure that the build system works. The content is actually
+located in libs/android-support-v7-appcompat.jar.
+The accompanying resources must also be included in the application.
+
diff --git a/appcompat/project.properties b/v7/appcompat/project.properties
similarity index 100%
rename from appcompat/project.properties
rename to v7/appcompat/project.properties
diff --git a/appcompat/res/drawable/action_bar_background.xml b/v7/appcompat/res/anim/abc_fade_in.xml
similarity index 65%
copy from appcompat/res/drawable/action_bar_background.xml
copy to v7/appcompat/res/anim/abc_fade_in.xml
index 42f1bac..da7ee29 100644
--- a/appcompat/res/drawable/action_bar_background.xml
+++ b/v7/appcompat/res/anim/abc_fade_in.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,9 +14,7 @@
limitations under the License.
-->
-<shape xmlns:android="http://schemas.android.com/apk/res/android">
- <gradient
- android:startColor="#ffd1d2d4"
- android:endColor="#ff85878a"
- android:angle="270"/>
-</shape>
\ No newline at end of file
+<alpha xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@android:anim/decelerate_interpolator"
+ android:fromAlpha="0.0" android:toAlpha="1.0"
+ android:duration="@android:integer/config_mediumAnimTime" />
\ No newline at end of file
diff --git a/appcompat/res/drawable/action_bar_background.xml b/v7/appcompat/res/anim/abc_fade_out.xml
similarity index 65%
copy from appcompat/res/drawable/action_bar_background.xml
copy to v7/appcompat/res/anim/abc_fade_out.xml
index 42f1bac..c81b39a 100644
--- a/appcompat/res/drawable/action_bar_background.xml
+++ b/v7/appcompat/res/anim/abc_fade_out.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,9 +14,7 @@
limitations under the License.
-->
-<shape xmlns:android="http://schemas.android.com/apk/res/android">
- <gradient
- android:startColor="#ffd1d2d4"
- android:endColor="#ff85878a"
- android:angle="270"/>
-</shape>
\ No newline at end of file
+<alpha xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@android:anim/decelerate_interpolator"
+ android:fromAlpha="1.0" android:toAlpha="0.0"
+ android:duration="@android:integer/config_mediumAnimTime" />
\ No newline at end of file
diff --git a/appcompat/res/drawable/action_bar_background.xml b/v7/appcompat/res/anim/abc_slide_in_bottom.xml
similarity index 64%
copy from appcompat/res/drawable/action_bar_background.xml
copy to v7/appcompat/res/anim/abc_slide_in_bottom.xml
index 42f1bac..1afa8fe 100644
--- a/appcompat/res/drawable/action_bar_background.xml
+++ b/v7/appcompat/res/anim/abc_slide_in_bottom.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -13,10 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
-<shape xmlns:android="http://schemas.android.com/apk/res/android">
- <gradient
- android:startColor="#ffd1d2d4"
- android:endColor="#ff85878a"
- android:angle="270"/>
-</shape>
\ No newline at end of file
+<translate xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@android:anim/decelerate_interpolator"
+ android:fromYDelta="50%p" android:toYDelta="0"
+ android:duration="@android:integer/config_mediumAnimTime"/>
diff --git a/appcompat/res/drawable/action_bar_background.xml b/v7/appcompat/res/anim/abc_slide_in_top.xml
similarity index 64%
copy from appcompat/res/drawable/action_bar_background.xml
copy to v7/appcompat/res/anim/abc_slide_in_top.xml
index 42f1bac..ab824f2 100644
--- a/appcompat/res/drawable/action_bar_background.xml
+++ b/v7/appcompat/res/anim/abc_slide_in_top.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -13,10 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
-<shape xmlns:android="http://schemas.android.com/apk/res/android">
- <gradient
- android:startColor="#ffd1d2d4"
- android:endColor="#ff85878a"
- android:angle="270"/>
-</shape>
\ No newline at end of file
+<translate xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@android:anim/decelerate_interpolator"
+ android:fromYDelta="-50%p" android:toYDelta="0"
+ android:duration="@android:integer/config_mediumAnimTime"/>
\ No newline at end of file
diff --git a/appcompat/res/drawable/action_bar_background.xml b/v7/appcompat/res/anim/abc_slide_out_bottom.xml
similarity index 64%
copy from appcompat/res/drawable/action_bar_background.xml
copy to v7/appcompat/res/anim/abc_slide_out_bottom.xml
index 42f1bac..b309fe8 100644
--- a/appcompat/res/drawable/action_bar_background.xml
+++ b/v7/appcompat/res/anim/abc_slide_out_bottom.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -13,10 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
-<shape xmlns:android="http://schemas.android.com/apk/res/android">
- <gradient
- android:startColor="#ffd1d2d4"
- android:endColor="#ff85878a"
- android:angle="270"/>
-</shape>
\ No newline at end of file
+<translate xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@android:anim/accelerate_interpolator"
+ android:fromYDelta="0" android:toYDelta="50%p"
+ android:duration="@android:integer/config_mediumAnimTime"/>
\ No newline at end of file
diff --git a/appcompat/res/drawable/action_bar_background.xml b/v7/appcompat/res/anim/abc_slide_out_top.xml
similarity index 64%
copy from appcompat/res/drawable/action_bar_background.xml
copy to v7/appcompat/res/anim/abc_slide_out_top.xml
index 42f1bac..e84d1c7 100644
--- a/appcompat/res/drawable/action_bar_background.xml
+++ b/v7/appcompat/res/anim/abc_slide_out_top.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -13,10 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
-<shape xmlns:android="http://schemas.android.com/apk/res/android">
- <gradient
- android:startColor="#ffd1d2d4"
- android:endColor="#ff85878a"
- android:angle="270"/>
-</shape>
\ No newline at end of file
+<translate xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@android:anim/accelerate_interpolator"
+ android:fromYDelta="0" android:toYDelta="-50%p"
+ android:duration="@android:integer/config_mediumAnimTime"/>
\ No newline at end of file
diff --git a/v7/appcompat/res/drawable-hdpi/abc_ab_bottom_solid_dark_holo.9.png b/v7/appcompat/res/drawable-hdpi/abc_ab_bottom_solid_dark_holo.9.png
new file mode 100644
index 0000000..769463b
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_ab_bottom_solid_dark_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/ab_bottom_solid_light_holo.9.png b/v7/appcompat/res/drawable-hdpi/abc_ab_bottom_solid_light_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-hdpi/ab_bottom_solid_light_holo.9.png
rename to v7/appcompat/res/drawable-hdpi/abc_ab_bottom_solid_light_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_ab_bottom_transparent_dark_holo.9.png b/v7/appcompat/res/drawable-hdpi/abc_ab_bottom_transparent_dark_holo.9.png
new file mode 100644
index 0000000..712a551
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_ab_bottom_transparent_dark_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/ab_bottom_transparent_light_holo.9.png b/v7/appcompat/res/drawable-hdpi/abc_ab_bottom_transparent_light_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-hdpi/ab_bottom_transparent_light_holo.9.png
rename to v7/appcompat/res/drawable-hdpi/abc_ab_bottom_transparent_light_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/ab_solid_dark_holo.9.png b/v7/appcompat/res/drawable-hdpi/abc_ab_solid_dark_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-hdpi/ab_solid_dark_holo.9.png
rename to v7/appcompat/res/drawable-hdpi/abc_ab_solid_dark_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/ab_solid_light_holo.9.png b/v7/appcompat/res/drawable-hdpi/abc_ab_solid_light_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-hdpi/ab_solid_light_holo.9.png
rename to v7/appcompat/res/drawable-hdpi/abc_ab_solid_light_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/ab_stacked_solid_dark_holo.9.png b/v7/appcompat/res/drawable-hdpi/abc_ab_stacked_solid_dark_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-hdpi/ab_stacked_solid_dark_holo.9.png
rename to v7/appcompat/res/drawable-hdpi/abc_ab_stacked_solid_dark_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/ab_stacked_solid_light_holo.9.png b/v7/appcompat/res/drawable-hdpi/abc_ab_stacked_solid_light_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-hdpi/ab_stacked_solid_light_holo.9.png
rename to v7/appcompat/res/drawable-hdpi/abc_ab_stacked_solid_light_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_ab_stacked_transparent_dark_holo.9.png b/v7/appcompat/res/drawable-hdpi/abc_ab_stacked_transparent_dark_holo.9.png
new file mode 100644
index 0000000..1e39572
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_ab_stacked_transparent_dark_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/ab_stacked_transparent_light_holo.9.png b/v7/appcompat/res/drawable-hdpi/abc_ab_stacked_transparent_light_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-hdpi/ab_stacked_transparent_light_holo.9.png
rename to v7/appcompat/res/drawable-hdpi/abc_ab_stacked_transparent_light_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_ab_transparent_dark_holo.9.png b/v7/appcompat/res/drawable-hdpi/abc_ab_transparent_dark_holo.9.png
new file mode 100644
index 0000000..0eff695
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_ab_transparent_dark_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/ab_transparent_light_holo.9.png b/v7/appcompat/res/drawable-hdpi/abc_ab_transparent_light_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-hdpi/ab_transparent_light_holo.9.png
rename to v7/appcompat/res/drawable-hdpi/abc_ab_transparent_light_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_cab_background_bottom_holo_dark.9.png b/v7/appcompat/res/drawable-hdpi/abc_cab_background_bottom_holo_dark.9.png
new file mode 100644
index 0000000..1d836f6
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_cab_background_bottom_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_cab_background_bottom_holo_light.9.png b/v7/appcompat/res/drawable-hdpi/abc_cab_background_bottom_holo_light.9.png
new file mode 100644
index 0000000..5818666
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_cab_background_bottom_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_cab_background_top_holo_dark.9.png b/v7/appcompat/res/drawable-hdpi/abc_cab_background_top_holo_dark.9.png
new file mode 100644
index 0000000..564fb34
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_cab_background_top_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_cab_background_top_holo_light.9.png b/v7/appcompat/res/drawable-hdpi/abc_cab_background_top_holo_light.9.png
new file mode 100644
index 0000000..ae21b76
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_cab_background_top_holo_light.9.png
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/ic_ab_back_holo_dark.png b/v7/appcompat/res/drawable-hdpi/abc_ic_ab_back_holo_dark.png
similarity index 100%
rename from appcompat/res/drawable-hdpi/ic_ab_back_holo_dark.png
rename to v7/appcompat/res/drawable-hdpi/abc_ic_ab_back_holo_dark.png
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/ic_ab_back_holo_light.png b/v7/appcompat/res/drawable-hdpi/abc_ic_ab_back_holo_light.png
similarity index 100%
rename from appcompat/res/drawable-hdpi/ic_ab_back_holo_light.png
rename to v7/appcompat/res/drawable-hdpi/abc_ic_ab_back_holo_light.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_ic_cab_done_holo_dark.png b/v7/appcompat/res/drawable-hdpi/abc_ic_cab_done_holo_dark.png
new file mode 100644
index 0000000..d8662e3
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_ic_cab_done_holo_dark.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_ic_cab_done_holo_light.png b/v7/appcompat/res/drawable-hdpi/abc_ic_cab_done_holo_light.png
new file mode 100644
index 0000000..ed03f62
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_ic_cab_done_holo_light.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_ic_menu_moreoverflow_normal_holo_dark.png b/v7/appcompat/res/drawable-hdpi/abc_ic_menu_moreoverflow_normal_holo_dark.png
new file mode 100644
index 0000000..2abc458
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_ic_menu_moreoverflow_normal_holo_dark.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_ic_menu_moreoverflow_normal_holo_light.png b/v7/appcompat/res/drawable-hdpi/abc_ic_menu_moreoverflow_normal_holo_light.png
new file mode 100644
index 0000000..bb6aef1
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_ic_menu_moreoverflow_normal_holo_light.png
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/appcompat_divider_dark.9.png b/v7/appcompat/res/drawable-hdpi/abc_list_divider_holo_dark.9.png
similarity index 100%
rename from appcompat/res/drawable-hdpi/appcompat_divider_dark.9.png
rename to v7/appcompat/res/drawable-hdpi/abc_list_divider_holo_dark.9.png
Binary files differ
diff --git a/appcompat/res/drawable-hdpi/appcompat_divider_light.9.png b/v7/appcompat/res/drawable-hdpi/abc_list_divider_holo_light.9.png
similarity index 100%
rename from appcompat/res/drawable-hdpi/appcompat_divider_light.9.png
rename to v7/appcompat/res/drawable-hdpi/abc_list_divider_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_list_focused_holo.9.png b/v7/appcompat/res/drawable-hdpi/abc_list_focused_holo.9.png
new file mode 100644
index 0000000..5552708
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_list_focused_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_list_longpressed_holo.9.png b/v7/appcompat/res/drawable-hdpi/abc_list_longpressed_holo.9.png
new file mode 100644
index 0000000..4ea7afa
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_list_longpressed_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_list_pressed_holo_dark.9.png b/v7/appcompat/res/drawable-hdpi/abc_list_pressed_holo_dark.9.png
new file mode 100644
index 0000000..5654cd6
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_list_pressed_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_list_pressed_holo_light.9.png b/v7/appcompat/res/drawable-hdpi/abc_list_pressed_holo_light.9.png
new file mode 100644
index 0000000..5654cd6
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_list_pressed_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_list_selector_disabled_holo_dark.9.png b/v7/appcompat/res/drawable-hdpi/abc_list_selector_disabled_holo_dark.9.png
new file mode 100644
index 0000000..f6fd30d
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_list_selector_disabled_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_list_selector_disabled_holo_light.9.png b/v7/appcompat/res/drawable-hdpi/abc_list_selector_disabled_holo_light.9.png
new file mode 100644
index 0000000..ca8e9a2
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_list_selector_disabled_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_menu_dropdown_panel_holo_dark.9.png b/v7/appcompat/res/drawable-hdpi/abc_menu_dropdown_panel_holo_dark.9.png
new file mode 100644
index 0000000..72ee35f
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_menu_dropdown_panel_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_menu_dropdown_panel_holo_light.9.png b/v7/appcompat/res/drawable-hdpi/abc_menu_dropdown_panel_holo_light.9.png
new file mode 100644
index 0000000..0d1f9bf
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_menu_dropdown_panel_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_menu_hardkey_panel_holo_dark.9.png b/v7/appcompat/res/drawable-hdpi/abc_menu_hardkey_panel_holo_dark.9.png
new file mode 100644
index 0000000..465ee6d
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_menu_hardkey_panel_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_menu_hardkey_panel_holo_light.9.png b/v7/appcompat/res/drawable-hdpi/abc_menu_hardkey_panel_holo_light.9.png
new file mode 100644
index 0000000..76a5c53
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_menu_hardkey_panel_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_default_holo_dark.9.png b/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_default_holo_dark.9.png
new file mode 100644
index 0000000..88f8765
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_default_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_default_holo_light.9.png b/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_default_holo_light.9.png
new file mode 100644
index 0000000..fa68a13
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_default_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_disabled_holo_dark.9.png b/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_disabled_holo_dark.9.png
new file mode 100644
index 0000000..78c63cb
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_disabled_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_disabled_holo_light.9.png b/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_disabled_holo_light.9.png
new file mode 100644
index 0000000..e13a9f8
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_disabled_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_focused_holo_dark.9.png b/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_focused_holo_dark.9.png
new file mode 100644
index 0000000..26d2e16
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_focused_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_focused_holo_light.9.png b/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_focused_holo_light.9.png
new file mode 100644
index 0000000..00ae92a
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_focused_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_pressed_holo_dark.9.png b/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_pressed_holo_dark.9.png
new file mode 100644
index 0000000..dc20a8d
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_pressed_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_pressed_holo_light.9.png b/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_pressed_holo_light.9.png
new file mode 100644
index 0000000..272a2a1
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_spinner_ab_pressed_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_tab_selected_focused_holo.9.png b/v7/appcompat/res/drawable-hdpi/abc_tab_selected_focused_holo.9.png
new file mode 100644
index 0000000..673e3bf
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_tab_selected_focused_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_tab_selected_holo.9.png b/v7/appcompat/res/drawable-hdpi/abc_tab_selected_holo.9.png
new file mode 100644
index 0000000..d57df98
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_tab_selected_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_tab_selected_pressed_holo.9.png b/v7/appcompat/res/drawable-hdpi/abc_tab_selected_pressed_holo.9.png
new file mode 100644
index 0000000..6278eef
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_tab_selected_pressed_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-hdpi/abc_tab_unselected_pressed_holo.9.png b/v7/appcompat/res/drawable-hdpi/abc_tab_unselected_pressed_holo.9.png
new file mode 100644
index 0000000..aadc6f8
--- /dev/null
+++ b/v7/appcompat/res/drawable-hdpi/abc_tab_unselected_pressed_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_ab_bottom_solid_dark_holo.9.png b/v7/appcompat/res/drawable-mdpi/abc_ab_bottom_solid_dark_holo.9.png
new file mode 100644
index 0000000..b229367
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_ab_bottom_solid_dark_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/ab_bottom_solid_light_holo.9.png b/v7/appcompat/res/drawable-mdpi/abc_ab_bottom_solid_light_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-mdpi/ab_bottom_solid_light_holo.9.png
rename to v7/appcompat/res/drawable-mdpi/abc_ab_bottom_solid_light_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_ab_bottom_transparent_dark_holo.9.png b/v7/appcompat/res/drawable-mdpi/abc_ab_bottom_transparent_dark_holo.9.png
new file mode 100644
index 0000000..d814d02
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_ab_bottom_transparent_dark_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/ab_bottom_transparent_light_holo.9.png b/v7/appcompat/res/drawable-mdpi/abc_ab_bottom_transparent_light_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-mdpi/ab_bottom_transparent_light_holo.9.png
rename to v7/appcompat/res/drawable-mdpi/abc_ab_bottom_transparent_light_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/ab_solid_dark_holo.9.png b/v7/appcompat/res/drawable-mdpi/abc_ab_solid_dark_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-mdpi/ab_solid_dark_holo.9.png
rename to v7/appcompat/res/drawable-mdpi/abc_ab_solid_dark_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/ab_solid_light_holo.9.png b/v7/appcompat/res/drawable-mdpi/abc_ab_solid_light_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-mdpi/ab_solid_light_holo.9.png
rename to v7/appcompat/res/drawable-mdpi/abc_ab_solid_light_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/ab_stacked_solid_dark_holo.9.png b/v7/appcompat/res/drawable-mdpi/abc_ab_stacked_solid_dark_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-mdpi/ab_stacked_solid_dark_holo.9.png
rename to v7/appcompat/res/drawable-mdpi/abc_ab_stacked_solid_dark_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/ab_stacked_solid_light_holo.9.png b/v7/appcompat/res/drawable-mdpi/abc_ab_stacked_solid_light_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-mdpi/ab_stacked_solid_light_holo.9.png
rename to v7/appcompat/res/drawable-mdpi/abc_ab_stacked_solid_light_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_ab_stacked_transparent_dark_holo.9.png b/v7/appcompat/res/drawable-mdpi/abc_ab_stacked_transparent_dark_holo.9.png
new file mode 100644
index 0000000..0ad6c88
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_ab_stacked_transparent_dark_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/ab_stacked_transparent_light_holo.9.png b/v7/appcompat/res/drawable-mdpi/abc_ab_stacked_transparent_light_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-mdpi/ab_stacked_transparent_light_holo.9.png
rename to v7/appcompat/res/drawable-mdpi/abc_ab_stacked_transparent_light_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_ab_transparent_dark_holo.9.png b/v7/appcompat/res/drawable-mdpi/abc_ab_transparent_dark_holo.9.png
new file mode 100644
index 0000000..ad980b1
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_ab_transparent_dark_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/ab_transparent_light_holo.9.png b/v7/appcompat/res/drawable-mdpi/abc_ab_transparent_light_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-mdpi/ab_transparent_light_holo.9.png
rename to v7/appcompat/res/drawable-mdpi/abc_ab_transparent_light_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_cab_background_bottom_holo_dark.9.png b/v7/appcompat/res/drawable-mdpi/abc_cab_background_bottom_holo_dark.9.png
new file mode 100644
index 0000000..d8f1c8b
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_cab_background_bottom_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_cab_background_bottom_holo_light.9.png b/v7/appcompat/res/drawable-mdpi/abc_cab_background_bottom_holo_light.9.png
new file mode 100644
index 0000000..31e4989
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_cab_background_bottom_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_cab_background_top_holo_dark.9.png b/v7/appcompat/res/drawable-mdpi/abc_cab_background_top_holo_dark.9.png
new file mode 100644
index 0000000..7c2cbe5
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_cab_background_top_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_cab_background_top_holo_light.9.png b/v7/appcompat/res/drawable-mdpi/abc_cab_background_top_holo_light.9.png
new file mode 100644
index 0000000..30cbdc1
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_cab_background_top_holo_light.9.png
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/ic_ab_back_holo_dark.png b/v7/appcompat/res/drawable-mdpi/abc_ic_ab_back_holo_dark.png
similarity index 100%
rename from appcompat/res/drawable-mdpi/ic_ab_back_holo_dark.png
rename to v7/appcompat/res/drawable-mdpi/abc_ic_ab_back_holo_dark.png
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/ic_ab_back_holo_light.png b/v7/appcompat/res/drawable-mdpi/abc_ic_ab_back_holo_light.png
similarity index 100%
rename from appcompat/res/drawable-mdpi/ic_ab_back_holo_light.png
rename to v7/appcompat/res/drawable-mdpi/abc_ic_ab_back_holo_light.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_ic_cab_done_holo_dark.png b/v7/appcompat/res/drawable-mdpi/abc_ic_cab_done_holo_dark.png
new file mode 100644
index 0000000..a17b6a7
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_ic_cab_done_holo_dark.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_ic_cab_done_holo_light.png b/v7/appcompat/res/drawable-mdpi/abc_ic_cab_done_holo_light.png
new file mode 100644
index 0000000..b28b3b5
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_ic_cab_done_holo_light.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_ic_menu_moreoverflow_normal_holo_dark.png b/v7/appcompat/res/drawable-mdpi/abc_ic_menu_moreoverflow_normal_holo_dark.png
new file mode 100644
index 0000000..ba704b6
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_ic_menu_moreoverflow_normal_holo_dark.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_ic_menu_moreoverflow_normal_holo_light.png b/v7/appcompat/res/drawable-mdpi/abc_ic_menu_moreoverflow_normal_holo_light.png
new file mode 100644
index 0000000..01d6816
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_ic_menu_moreoverflow_normal_holo_light.png
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/appcompat_divider_dark.9.png b/v7/appcompat/res/drawable-mdpi/abc_list_divider_holo_dark.9.png
similarity index 100%
rename from appcompat/res/drawable-mdpi/appcompat_divider_dark.9.png
rename to v7/appcompat/res/drawable-mdpi/abc_list_divider_holo_dark.9.png
Binary files differ
diff --git a/appcompat/res/drawable-mdpi/appcompat_divider_light.9.png b/v7/appcompat/res/drawable-mdpi/abc_list_divider_holo_light.9.png
similarity index 100%
rename from appcompat/res/drawable-mdpi/appcompat_divider_light.9.png
rename to v7/appcompat/res/drawable-mdpi/abc_list_divider_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_list_focused_holo.9.png b/v7/appcompat/res/drawable-mdpi/abc_list_focused_holo.9.png
new file mode 100644
index 0000000..00f05d8
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_list_focused_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_list_longpressed_holo.9.png b/v7/appcompat/res/drawable-mdpi/abc_list_longpressed_holo.9.png
new file mode 100644
index 0000000..3bf8e03
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_list_longpressed_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_list_pressed_holo_dark.9.png b/v7/appcompat/res/drawable-mdpi/abc_list_pressed_holo_dark.9.png
new file mode 100644
index 0000000..6e77525
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_list_pressed_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_list_pressed_holo_light.9.png b/v7/appcompat/res/drawable-mdpi/abc_list_pressed_holo_light.9.png
new file mode 100644
index 0000000..6e77525
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_list_pressed_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_list_selector_disabled_holo_dark.9.png b/v7/appcompat/res/drawable-mdpi/abc_list_selector_disabled_holo_dark.9.png
new file mode 100644
index 0000000..92da2f0
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_list_selector_disabled_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_list_selector_disabled_holo_light.9.png b/v7/appcompat/res/drawable-mdpi/abc_list_selector_disabled_holo_light.9.png
new file mode 100644
index 0000000..42cb646
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_list_selector_disabled_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_menu_dropdown_panel_holo_dark.9.png b/v7/appcompat/res/drawable-mdpi/abc_menu_dropdown_panel_holo_dark.9.png
new file mode 100644
index 0000000..31dc342
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_menu_dropdown_panel_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_menu_dropdown_panel_holo_light.9.png b/v7/appcompat/res/drawable-mdpi/abc_menu_dropdown_panel_holo_light.9.png
new file mode 100644
index 0000000..755c145
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_menu_dropdown_panel_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_menu_hardkey_panel_holo_dark.9.png b/v7/appcompat/res/drawable-mdpi/abc_menu_hardkey_panel_holo_dark.9.png
new file mode 100644
index 0000000..3677994
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_menu_hardkey_panel_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_menu_hardkey_panel_holo_light.9.png b/v7/appcompat/res/drawable-mdpi/abc_menu_hardkey_panel_holo_light.9.png
new file mode 100644
index 0000000..02b25f0
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_menu_hardkey_panel_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_default_holo_dark.9.png b/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_default_holo_dark.9.png
new file mode 100644
index 0000000..8d75946
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_default_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_default_holo_light.9.png b/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_default_holo_light.9.png
new file mode 100644
index 0000000..716560b
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_default_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_disabled_holo_dark.9.png b/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_disabled_holo_dark.9.png
new file mode 100644
index 0000000..c3ba89c
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_disabled_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_disabled_holo_light.9.png b/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_disabled_holo_light.9.png
new file mode 100644
index 0000000..67c5358
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_disabled_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_focused_holo_dark.9.png b/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_focused_holo_dark.9.png
new file mode 100644
index 0000000..c015f43
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_focused_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_focused_holo_light.9.png b/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_focused_holo_light.9.png
new file mode 100644
index 0000000..487edc2
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_focused_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_pressed_holo_dark.9.png b/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_pressed_holo_dark.9.png
new file mode 100644
index 0000000..2fa15e7
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_pressed_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_pressed_holo_light.9.png b/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_pressed_holo_light.9.png
new file mode 100644
index 0000000..a964b22
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_spinner_ab_pressed_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_tab_selected_focused_holo.9.png b/v7/appcompat/res/drawable-mdpi/abc_tab_selected_focused_holo.9.png
new file mode 100644
index 0000000..c9972e7
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_tab_selected_focused_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_tab_selected_holo.9.png b/v7/appcompat/res/drawable-mdpi/abc_tab_selected_holo.9.png
new file mode 100644
index 0000000..587337c
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_tab_selected_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_tab_selected_pressed_holo.9.png b/v7/appcompat/res/drawable-mdpi/abc_tab_selected_pressed_holo.9.png
new file mode 100644
index 0000000..155c4fc
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_tab_selected_pressed_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-mdpi/abc_tab_unselected_pressed_holo.9.png b/v7/appcompat/res/drawable-mdpi/abc_tab_unselected_pressed_holo.9.png
new file mode 100644
index 0000000..b1223fe
--- /dev/null
+++ b/v7/appcompat/res/drawable-mdpi/abc_tab_unselected_pressed_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_ab_bottom_solid_dark_holo.9.png b/v7/appcompat/res/drawable-xhdpi/abc_ab_bottom_solid_dark_holo.9.png
new file mode 100644
index 0000000..5753346
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_ab_bottom_solid_dark_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/ab_bottom_solid_light_holo.9.png b/v7/appcompat/res/drawable-xhdpi/abc_ab_bottom_solid_light_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-xhdpi/ab_bottom_solid_light_holo.9.png
rename to v7/appcompat/res/drawable-xhdpi/abc_ab_bottom_solid_light_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_ab_bottom_transparent_dark_holo.9.png b/v7/appcompat/res/drawable-xhdpi/abc_ab_bottom_transparent_dark_holo.9.png
new file mode 100644
index 0000000..6cee9a1
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_ab_bottom_transparent_dark_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/ab_bottom_transparent_light_holo.9.png b/v7/appcompat/res/drawable-xhdpi/abc_ab_bottom_transparent_light_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-xhdpi/ab_bottom_transparent_light_holo.9.png
rename to v7/appcompat/res/drawable-xhdpi/abc_ab_bottom_transparent_light_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/ab_solid_dark_holo.9.png b/v7/appcompat/res/drawable-xhdpi/abc_ab_solid_dark_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-xhdpi/ab_solid_dark_holo.9.png
rename to v7/appcompat/res/drawable-xhdpi/abc_ab_solid_dark_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/ab_solid_light_holo.9.png b/v7/appcompat/res/drawable-xhdpi/abc_ab_solid_light_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-xhdpi/ab_solid_light_holo.9.png
rename to v7/appcompat/res/drawable-xhdpi/abc_ab_solid_light_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/ab_stacked_solid_dark_holo.9.png b/v7/appcompat/res/drawable-xhdpi/abc_ab_stacked_solid_dark_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-xhdpi/ab_stacked_solid_dark_holo.9.png
rename to v7/appcompat/res/drawable-xhdpi/abc_ab_stacked_solid_dark_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/ab_stacked_solid_light_holo.9.png b/v7/appcompat/res/drawable-xhdpi/abc_ab_stacked_solid_light_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-xhdpi/ab_stacked_solid_light_holo.9.png
rename to v7/appcompat/res/drawable-xhdpi/abc_ab_stacked_solid_light_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_ab_stacked_transparent_dark_holo.9.png b/v7/appcompat/res/drawable-xhdpi/abc_ab_stacked_transparent_dark_holo.9.png
new file mode 100644
index 0000000..5ad475d
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_ab_stacked_transparent_dark_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/ab_stacked_transparent_light_holo.9.png b/v7/appcompat/res/drawable-xhdpi/abc_ab_stacked_transparent_light_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-xhdpi/ab_stacked_transparent_light_holo.9.png
rename to v7/appcompat/res/drawable-xhdpi/abc_ab_stacked_transparent_light_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_ab_transparent_dark_holo.9.png b/v7/appcompat/res/drawable-xhdpi/abc_ab_transparent_dark_holo.9.png
new file mode 100644
index 0000000..719b923
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_ab_transparent_dark_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/ab_transparent_light_holo.9.png b/v7/appcompat/res/drawable-xhdpi/abc_ab_transparent_light_holo.9.png
similarity index 100%
rename from appcompat/res/drawable-xhdpi/ab_transparent_light_holo.9.png
rename to v7/appcompat/res/drawable-xhdpi/abc_ab_transparent_light_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_cab_background_bottom_holo_dark.9.png b/v7/appcompat/res/drawable-xhdpi/abc_cab_background_bottom_holo_dark.9.png
new file mode 100644
index 0000000..0bd0980
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_cab_background_bottom_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_cab_background_bottom_holo_light.9.png b/v7/appcompat/res/drawable-xhdpi/abc_cab_background_bottom_holo_light.9.png
new file mode 100644
index 0000000..43ed26d
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_cab_background_bottom_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_cab_background_top_holo_dark.9.png b/v7/appcompat/res/drawable-xhdpi/abc_cab_background_top_holo_dark.9.png
new file mode 100644
index 0000000..6b31579
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_cab_background_top_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_cab_background_top_holo_light.9.png b/v7/appcompat/res/drawable-xhdpi/abc_cab_background_top_holo_light.9.png
new file mode 100644
index 0000000..df0121b
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_cab_background_top_holo_light.9.png
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/ic_ab_back_holo_dark.png b/v7/appcompat/res/drawable-xhdpi/abc_ic_ab_back_holo_dark.png
similarity index 100%
rename from appcompat/res/drawable-xhdpi/ic_ab_back_holo_dark.png
rename to v7/appcompat/res/drawable-xhdpi/abc_ic_ab_back_holo_dark.png
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/ic_ab_back_holo_light.png b/v7/appcompat/res/drawable-xhdpi/abc_ic_ab_back_holo_light.png
similarity index 100%
rename from appcompat/res/drawable-xhdpi/ic_ab_back_holo_light.png
rename to v7/appcompat/res/drawable-xhdpi/abc_ic_ab_back_holo_light.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_ic_cab_done_holo_dark.png b/v7/appcompat/res/drawable-xhdpi/abc_ic_cab_done_holo_dark.png
new file mode 100644
index 0000000..2e06dd0
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_ic_cab_done_holo_dark.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_ic_cab_done_holo_light.png b/v7/appcompat/res/drawable-xhdpi/abc_ic_cab_done_holo_light.png
new file mode 100644
index 0000000..bb19810
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_ic_cab_done_holo_light.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_ic_menu_moreoverflow_normal_holo_dark.png b/v7/appcompat/res/drawable-xhdpi/abc_ic_menu_moreoverflow_normal_holo_dark.png
new file mode 100644
index 0000000..a92fb1d
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_ic_menu_moreoverflow_normal_holo_dark.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_ic_menu_moreoverflow_normal_holo_light.png b/v7/appcompat/res/drawable-xhdpi/abc_ic_menu_moreoverflow_normal_holo_light.png
new file mode 100644
index 0000000..930ca8d
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_ic_menu_moreoverflow_normal_holo_light.png
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/appcompat_divider_dark.9.png b/v7/appcompat/res/drawable-xhdpi/abc_list_divider_holo_dark.9.png
similarity index 100%
rename from appcompat/res/drawable-xhdpi/appcompat_divider_dark.9.png
rename to v7/appcompat/res/drawable-xhdpi/abc_list_divider_holo_dark.9.png
Binary files differ
diff --git a/appcompat/res/drawable-xhdpi/appcompat_divider_light.9.png b/v7/appcompat/res/drawable-xhdpi/abc_list_divider_holo_light.9.png
similarity index 100%
rename from appcompat/res/drawable-xhdpi/appcompat_divider_light.9.png
rename to v7/appcompat/res/drawable-xhdpi/abc_list_divider_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_list_focused_holo.9.png b/v7/appcompat/res/drawable-xhdpi/abc_list_focused_holo.9.png
new file mode 100644
index 0000000..b545f8e
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_list_focused_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_list_longpressed_holo.9.png b/v7/appcompat/res/drawable-xhdpi/abc_list_longpressed_holo.9.png
new file mode 100644
index 0000000..eda10e6
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_list_longpressed_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_list_pressed_holo_dark.9.png b/v7/appcompat/res/drawable-xhdpi/abc_list_pressed_holo_dark.9.png
new file mode 100644
index 0000000..e4b3393
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_list_pressed_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_list_pressed_holo_light.9.png b/v7/appcompat/res/drawable-xhdpi/abc_list_pressed_holo_light.9.png
new file mode 100644
index 0000000..e4b3393
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_list_pressed_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_list_selector_disabled_holo_dark.9.png b/v7/appcompat/res/drawable-xhdpi/abc_list_selector_disabled_holo_dark.9.png
new file mode 100644
index 0000000..88726b6
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_list_selector_disabled_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_list_selector_disabled_holo_light.9.png b/v7/appcompat/res/drawable-xhdpi/abc_list_selector_disabled_holo_light.9.png
new file mode 100644
index 0000000..c6a7d4d
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_list_selector_disabled_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_menu_dropdown_panel_holo_dark.9.png b/v7/appcompat/res/drawable-xhdpi/abc_menu_dropdown_panel_holo_dark.9.png
new file mode 100644
index 0000000..abc48f8
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_menu_dropdown_panel_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_menu_dropdown_panel_holo_light.9.png b/v7/appcompat/res/drawable-xhdpi/abc_menu_dropdown_panel_holo_light.9.png
new file mode 100644
index 0000000..48905ed
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_menu_dropdown_panel_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_menu_hardkey_panel_holo_dark.9.png b/v7/appcompat/res/drawable-xhdpi/abc_menu_hardkey_panel_holo_dark.9.png
new file mode 100644
index 0000000..c1ad023
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_menu_hardkey_panel_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_menu_hardkey_panel_holo_light.9.png b/v7/appcompat/res/drawable-xhdpi/abc_menu_hardkey_panel_holo_light.9.png
new file mode 100644
index 0000000..a1e33d6
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_menu_hardkey_panel_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_default_holo_dark.9.png b/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_default_holo_dark.9.png
new file mode 100644
index 0000000..c43293d
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_default_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_default_holo_light.9.png b/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_default_holo_light.9.png
new file mode 100644
index 0000000..3dc481e
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_default_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_disabled_holo_dark.9.png b/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_disabled_holo_dark.9.png
new file mode 100644
index 0000000..9a7b173
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_disabled_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_disabled_holo_light.9.png b/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_disabled_holo_light.9.png
new file mode 100644
index 0000000..6888fdc
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_disabled_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_focused_holo_dark.9.png b/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_focused_holo_dark.9.png
new file mode 100644
index 0000000..9408b47
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_focused_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_focused_holo_light.9.png b/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_focused_holo_light.9.png
new file mode 100644
index 0000000..1cb95d1
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_focused_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_pressed_holo_dark.9.png b/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_pressed_holo_dark.9.png
new file mode 100644
index 0000000..a3c7711
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_pressed_holo_dark.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_pressed_holo_light.9.png b/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_pressed_holo_light.9.png
new file mode 100644
index 0000000..2a21210
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_spinner_ab_pressed_holo_light.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_tab_selected_focused_holo.9.png b/v7/appcompat/res/drawable-xhdpi/abc_tab_selected_focused_holo.9.png
new file mode 100644
index 0000000..03cfb09
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_tab_selected_focused_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_tab_selected_holo.9.png b/v7/appcompat/res/drawable-xhdpi/abc_tab_selected_holo.9.png
new file mode 100644
index 0000000..e4229f2
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_tab_selected_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_tab_selected_pressed_holo.9.png b/v7/appcompat/res/drawable-xhdpi/abc_tab_selected_pressed_holo.9.png
new file mode 100644
index 0000000..e862cb1
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_tab_selected_pressed_holo.9.png
Binary files differ
diff --git a/v7/appcompat/res/drawable-xhdpi/abc_tab_unselected_pressed_holo.9.png b/v7/appcompat/res/drawable-xhdpi/abc_tab_unselected_pressed_holo.9.png
new file mode 100644
index 0000000..f1eb673
--- /dev/null
+++ b/v7/appcompat/res/drawable-xhdpi/abc_tab_unselected_pressed_holo.9.png
Binary files differ
diff --git a/appcompat/res/drawable/item_background.xml b/v7/appcompat/res/drawable/abc_item_background_holo_dark.xml
similarity index 64%
copy from appcompat/res/drawable/item_background.xml
copy to v7/appcompat/res/drawable/abc_item_background_holo_dark.xml
index a4f826d..12ccc02 100644
--- a/appcompat/res/drawable/item_background.xml
+++ b/v7/appcompat/res/drawable/abc_item_background_holo_dark.xml
@@ -4,9 +4,9 @@
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,14 +16,11 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_window_focused="false" android:drawable="@color/transparent"/>
-
<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
- <item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/list_selector_background_disabled" />
- <item android:state_focused="true" android:state_enabled="false" android:drawable="@drawable/list_selector_background_disabled" />
- <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition" />
- <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition" />
- <item android:state_focused="true" android:drawable="@drawable/list_selector_background_focused" />
- <item android:drawable="@color/transparent"/>
-
+ <item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/abc_list_selector_disabled_holo_dark" />
+ <item android:state_focused="true" android:state_enabled="false" android:drawable="@drawable/abc_list_selector_disabled_holo_dark" />
+ <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/abc_list_selector_background_transition_holo_dark" />
+ <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/abc_list_selector_background_transition_holo_dark" />
+ <item android:state_focused="true" android:drawable="@drawable/abc_list_focused_holo" />
+ <item android:drawable="@color/transparent" />
</selector>
diff --git a/appcompat/res/drawable/item_background.xml b/v7/appcompat/res/drawable/abc_item_background_holo_light.xml
similarity index 64%
copy from appcompat/res/drawable/item_background.xml
copy to v7/appcompat/res/drawable/abc_item_background_holo_light.xml
index a4f826d..77dfc8f 100644
--- a/appcompat/res/drawable/item_background.xml
+++ b/v7/appcompat/res/drawable/abc_item_background_holo_light.xml
@@ -4,9 +4,9 @@
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,14 +16,11 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_window_focused="false" android:drawable="@color/transparent"/>
-
<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
- <item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/list_selector_background_disabled" />
- <item android:state_focused="true" android:state_enabled="false" android:drawable="@drawable/list_selector_background_disabled" />
- <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition" />
- <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition" />
- <item android:state_focused="true" android:drawable="@drawable/list_selector_background_focused" />
- <item android:drawable="@color/transparent"/>
-
+ <item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/abc_list_selector_disabled_holo_light" />
+ <item android:state_focused="true" android:state_enabled="false" android:drawable="@drawable/abc_list_selector_disabled_holo_light" />
+ <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/abc_list_selector_background_transition_holo_light" />
+ <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/abc_list_selector_background_transition_holo_light" />
+ <item android:state_focused="true" android:drawable="@drawable/abc_list_focused_holo" />
+ <item android:drawable="@color/transparent" />
</selector>
diff --git a/appcompat/res/drawable/list_selector_background_transition.xml b/v7/appcompat/res/drawable/abc_list_selector_background_transition_holo_dark.xml
similarity index 76%
rename from appcompat/res/drawable/list_selector_background_transition.xml
rename to v7/appcompat/res/drawable/abc_list_selector_background_transition_holo_dark.xml
index 2e8b4d6..0add58c 100644
--- a/appcompat/res/drawable/list_selector_background_transition.xml
+++ b/v7/appcompat/res/drawable/abc_list_selector_background_transition_holo_dark.xml
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 The Android Open Source Project
+<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,6 +15,6 @@
-->
<transition xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:drawable="@drawable/list_selector_background_pressed"/>
- <item android:drawable="@drawable/list_selector_background_longpress"/>
+ <item android:drawable="@drawable/abc_list_pressed_holo_dark" />
+ <item android:drawable="@drawable/abc_list_longpressed_holo" />
</transition>
diff --git a/appcompat/res/drawable/list_selector_background_transition.xml b/v7/appcompat/res/drawable/abc_list_selector_background_transition_holo_light.xml
similarity index 76%
copy from appcompat/res/drawable/list_selector_background_transition.xml
copy to v7/appcompat/res/drawable/abc_list_selector_background_transition_holo_light.xml
index 2e8b4d6..0c1d3e6 100644
--- a/appcompat/res/drawable/list_selector_background_transition.xml
+++ b/v7/appcompat/res/drawable/abc_list_selector_background_transition_holo_light.xml
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 The Android Open Source Project
+<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,6 +15,6 @@
-->
<transition xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:drawable="@drawable/list_selector_background_pressed"/>
- <item android:drawable="@drawable/list_selector_background_longpress"/>
+ <item android:drawable="@drawable/abc_list_pressed_holo_light" />
+ <item android:drawable="@drawable/abc_list_longpressed_holo" />
</transition>
diff --git a/appcompat/res/drawable/item_background.xml b/v7/appcompat/res/drawable/abc_list_selector_holo_dark.xml
similarity index 68%
copy from appcompat/res/drawable/item_background.xml
copy to v7/appcompat/res/drawable/abc_list_selector_holo_dark.xml
index a4f826d..b5f8b75 100644
--- a/appcompat/res/drawable/item_background.xml
+++ b/v7/appcompat/res/drawable/abc_list_selector_holo_dark.xml
@@ -4,9 +4,9 @@
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,14 +16,12 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_window_focused="false" android:drawable="@color/transparent"/>
+ <item android:state_window_focused="false" android:drawable="@color/transparent" />
<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
- <item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/list_selector_background_disabled" />
- <item android:state_focused="true" android:state_enabled="false" android:drawable="@drawable/list_selector_background_disabled" />
- <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition" />
- <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition" />
- <item android:state_focused="true" android:drawable="@drawable/list_selector_background_focused" />
- <item android:drawable="@color/transparent"/>
-
+ <item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/abc_list_selector_disabled_holo_dark" />
+ <item android:state_focused="true" android:state_enabled="false" android:drawable="@drawable/abc_list_selector_disabled_holo_dark" />
+ <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/abc_list_selector_background_transition_holo_dark" />
+ <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/abc_list_selector_background_transition_holo_dark" />
+ <item android:state_focused="true" android:drawable="@drawable/abc_list_focused_holo" />
</selector>
diff --git a/appcompat/res/drawable/item_background.xml b/v7/appcompat/res/drawable/abc_list_selector_holo_light.xml
similarity index 68%
rename from appcompat/res/drawable/item_background.xml
rename to v7/appcompat/res/drawable/abc_list_selector_holo_light.xml
index a4f826d..dc5d506 100644
--- a/appcompat/res/drawable/item_background.xml
+++ b/v7/appcompat/res/drawable/abc_list_selector_holo_light.xml
@@ -4,9 +4,9 @@
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,14 +16,13 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_window_focused="false" android:drawable="@color/transparent"/>
+ <item android:state_window_focused="false" android:drawable="@color/transparent" />
<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
- <item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/list_selector_background_disabled" />
- <item android:state_focused="true" android:state_enabled="false" android:drawable="@drawable/list_selector_background_disabled" />
- <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition" />
- <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition" />
- <item android:state_focused="true" android:drawable="@drawable/list_selector_background_focused" />
- <item android:drawable="@color/transparent"/>
+ <item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/abc_list_selector_disabled_holo_light" />
+ <item android:state_focused="true" android:state_enabled="false" android:drawable="@drawable/abc_list_selector_disabled_holo_light" />
+ <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/abc_list_selector_background_transition_holo_light" />
+ <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/abc_list_selector_background_transition_holo_light" />
+ <item android:state_focused="true" android:drawable="@drawable/abc_list_focused_holo" />
</selector>
diff --git a/appcompat/res/drawable/minitab_lt.xml b/v7/appcompat/res/drawable/abc_spinner_ab_holo_dark.xml
similarity index 61%
copy from appcompat/res/drawable/minitab_lt.xml
copy to v7/appcompat/res/drawable/abc_spinner_ab_holo_dark.xml
index 383daf6..934b374 100644
--- a/appcompat/res/drawable/minitab_lt.xml
+++ b/v7/appcompat/res/drawable/abc_spinner_ab_holo_dark.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
+<!-- Copyright (C) 2011 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,11 +15,11 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_pressed="true" android:state_selected="true"
- android:drawable="@drawable/minitab_lt_press"/>
- <item android:state_selected="true"
- android:drawable="@drawable/minitab_lt_selected"/>
+ <item android:state_enabled="false"
+ android:drawable="@drawable/abc_spinner_ab_disabled_holo_dark" />
<item android:state_pressed="true"
- android:drawable="@drawable/minitab_lt_unselected_press"/>
- <item android:drawable="@drawable/minitab_lt_unselected"/>
+ android:drawable="@drawable/abc_spinner_ab_pressed_holo_dark" />
+ <item android:state_pressed="false" android:state_focused="true"
+ android:drawable="@drawable/abc_spinner_ab_focused_holo_dark" />
+ <item android:drawable="@drawable/abc_spinner_ab_default_holo_dark" />
</selector>
diff --git a/appcompat/res/drawable/minitab_lt.xml b/v7/appcompat/res/drawable/abc_spinner_ab_holo_light.xml
similarity index 65%
rename from appcompat/res/drawable/minitab_lt.xml
rename to v7/appcompat/res/drawable/abc_spinner_ab_holo_light.xml
index 383daf6..dd0245e 100644
--- a/appcompat/res/drawable/minitab_lt.xml
+++ b/v7/appcompat/res/drawable/abc_spinner_ab_holo_light.xml
@@ -15,11 +15,11 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_pressed="true" android:state_selected="true"
- android:drawable="@drawable/minitab_lt_press"/>
- <item android:state_selected="true"
- android:drawable="@drawable/minitab_lt_selected"/>
+ <item android:state_enabled="false"
+ android:drawable="@drawable/abc_spinner_ab_disabled_holo_light" />
<item android:state_pressed="true"
- android:drawable="@drawable/minitab_lt_unselected_press"/>
- <item android:drawable="@drawable/minitab_lt_unselected"/>
+ android:drawable="@drawable/abc_spinner_ab_pressed_holo_light" />
+ <item android:state_pressed="false" android:state_focused="true"
+ android:drawable="@drawable/abc_spinner_ab_focused_holo_light" />
+ <item android:drawable="@drawable/abc_spinner_ab_default_holo_light" />
</selector>
diff --git a/v7/appcompat/res/drawable/abc_tab_indicator_ab_holo.xml b/v7/appcompat/res/drawable/abc_tab_indicator_ab_holo.xml
new file mode 100644
index 0000000..55140f9
--- /dev/null
+++ b/v7/appcompat/res/drawable/abc_tab_indicator_ab_holo.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <!-- Non focused states -->
+ <item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@color/transparent" />
+ <item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/abc_tab_selected_holo" />
+
+ <!-- Focused states -->
+ <item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/abc_list_focused_holo" />
+ <item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/abc_tab_selected_focused_holo" />
+
+ <!-- Pressed -->
+ <!-- Non focused states -->
+ <item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/abc_list_pressed_holo_dark" />
+ <item android:state_focused="false" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/abc_tab_selected_pressed_holo" />
+
+ <!-- Focused states -->
+ <item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/abc_tab_unselected_pressed_holo" />
+ <item android:state_focused="true" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/abc_tab_selected_pressed_holo" />
+</selector>
diff --git a/appcompat/res/layout/action_bar_decor.xml b/v7/appcompat/res/layout/abc_action_bar_decor.xml
similarity index 86%
rename from appcompat/res/layout/action_bar_decor.xml
rename to v7/appcompat/res/layout/abc_action_bar_decor.xml
index 5642f73..076a408 100644
--- a/appcompat/res/layout/action_bar_decor.xml
+++ b/v7/appcompat/res/layout/abc_action_bar_decor.xml
@@ -19,29 +19,29 @@
android:layout_height="fill_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">
- <android.support.appcompat.widget.ActionBarContainer android:id="@+id/action_bar_container"
+ <android.support.v7.internal.widget.ActionBarContainer android:id="@+id/action_bar_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?attr/actionBarStyle">
- <android.support.appcompat.widget.ActionBarView
+ <android.support.v7.internal.widget.ActionBarView
android:id="@+id/action_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?attr/actionBarStyle"/>
- <android.support.appcompat.widget.ActionBarContextView
+ <android.support.v7.internal.widget.ActionBarContextView
android:id="@+id/action_context_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone"
style="?attr/actionModeStyle"/>
- </android.support.appcompat.widget.ActionBarContainer>
+ </android.support.v7.internal.widget.ActionBarContainer>
<FrameLayout android:id="@id/action_bar_activity_content"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:foregroundGravity="fill_horizontal|top"
android:foreground="?android:attr/windowContentOverlay"/>
- <android.support.appcompat.widget.ActionBarContainer android:id="@+id/split_action_bar"
+ <android.support.v7.internal.widget.ActionBarContainer android:id="@+id/split_action_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?attr/actionBarSplitStyle"
diff --git a/appcompat/res/layout/action_bar_decor_overlay.xml b/v7/appcompat/res/layout/abc_action_bar_decor_overlay.xml
similarity index 85%
rename from appcompat/res/layout/action_bar_decor_overlay.xml
rename to v7/appcompat/res/layout/abc_action_bar_decor_overlay.xml
index d7afa66..5ea8fc1 100644
--- a/appcompat/res/layout/action_bar_decor_overlay.xml
+++ b/v7/appcompat/res/layout/abc_action_bar_decor_overlay.xml
@@ -14,7 +14,7 @@
limitations under the License.
-->
-<android.support.appcompat.widget.ActionBarOverlayLayout
+<android.support.v7.internal.widget.ActionBarOverlayLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/action_bar_overlay_layout"
android:layout_width="fill_parent"
@@ -26,34 +26,34 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top">
- <android.support.appcompat.widget.ActionBarContainer android:id="@+id/action_bar_container"
+ <android.support.v7.internal.widget.ActionBarContainer android:id="@+id/action_bar_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
style="?attr/actionBarStyle"
android:gravity="top">
- <android.support.appcompat.widget.ActionBarView
+ <android.support.v7.internal.widget.ActionBarView
android:id="@+id/action_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?attr/actionBarStyle"/>
- <android.support.appcompat.widget.ActionBarContextView
+ <android.support.v7.internal.widget.ActionBarContextView
android:id="@+id/action_context_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone"
style="?attr/actionModeStyle"/>
- </android.support.appcompat.widget.ActionBarContainer>
+ </android.support.v7.internal.widget.ActionBarContainer>
<ImageView android:src="?android:attr/windowContentOverlay"
android:scaleType="fitXY"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
- <android.support.appcompat.widget.ActionBarContainer android:id="@+id/split_action_bar"
+ <android.support.v7.internal.widget.ActionBarContainer android:id="@+id/split_action_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
style="?attr/actionBarSplitStyle"
android:visibility="gone"
android:gravity="center"/>
-</android.support.appcompat.widget.ActionBarOverlayLayout>
+</android.support.v7.internal.widget.ActionBarOverlayLayout>
diff --git a/appcompat/res/layout/action_bar_home.xml b/v7/appcompat/res/layout/abc_action_bar_home.xml
similarity index 95%
rename from appcompat/res/layout/action_bar_home.xml
rename to v7/appcompat/res/layout/abc_action_bar_home.xml
index 84c2bfa..d6c26e5 100644
--- a/appcompat/res/layout/action_bar_home.xml
+++ b/v7/appcompat/res/layout/abc_action_bar_home.xml
@@ -15,7 +15,7 @@
-->
<view xmlns:android="http://schemas.android.com/apk/res/android"
- class="android.support.appcompat.widget.ActionBarView$HomeView"
+ class="android.support.v7.internal.widget.ActionBarView$HomeView"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="?attr/actionBarItemBackground">
diff --git a/v7/appcompat/res/layout/abc_action_bar_tab.xml b/v7/appcompat/res/layout/abc_action_bar_tab.xml
new file mode 100644
index 0000000..85eda96
--- /dev/null
+++ b/v7/appcompat/res/layout/abc_action_bar_tab.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<view xmlns:android="http://schemas.android.com/apk/res/android"
+ class="android.support.v7.internal.widget.ScrollingTabContainerView$TabView"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ style="?attr/actionBarTabStyle"/>
diff --git a/v7/appcompat/res/layout/abc_action_bar_tabbar.xml b/v7/appcompat/res/layout/abc_action_bar_tabbar.xml
new file mode 100644
index 0000000..08f9c89
--- /dev/null
+++ b/v7/appcompat/res/layout/abc_action_bar_tabbar.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<android.support.v7.internal.widget.LinearLayoutICS
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ style="?attr/actionBarTabBarStyle"/>
diff --git a/appcompat/res/layout/action_bar_title_item.xml b/v7/appcompat/res/layout/abc_action_bar_title_item.xml
similarity index 100%
rename from appcompat/res/layout/action_bar_title_item.xml
rename to v7/appcompat/res/layout/abc_action_bar_title_item.xml
diff --git a/appcompat/res/layout/action_bar_view_list_nav_layout.xml b/v7/appcompat/res/layout/abc_action_bar_view_list_nav_layout.xml
similarity index 100%
rename from appcompat/res/layout/action_bar_view_list_nav_layout.xml
rename to v7/appcompat/res/layout/abc_action_bar_view_list_nav_layout.xml
diff --git a/appcompat/res/layout/action_menu_item_layout.xml b/v7/appcompat/res/layout/abc_action_menu_item_layout.xml
similarity index 95%
rename from appcompat/res/layout/action_menu_item_layout.xml
rename to v7/appcompat/res/layout/abc_action_menu_item_layout.xml
index adbd83d..150ea50 100644
--- a/appcompat/res/layout/action_menu_item_layout.xml
+++ b/v7/appcompat/res/layout/abc_action_menu_item_layout.xml
@@ -14,7 +14,7 @@
limitations under the License.
-->
-<com.android.internal.view.menu.ActionMenuItemView
+<android.support.v7.internal.view.menu.ActionMenuItemView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/appcompat/res/layout/action_menu_layout.xml b/v7/appcompat/res/layout/abc_action_menu_layout.xml
similarity index 90%
rename from appcompat/res/layout/action_menu_layout.xml
rename to v7/appcompat/res/layout/abc_action_menu_layout.xml
index d307b66..37a02e6 100644
--- a/appcompat/res/layout/action_menu_layout.xml
+++ b/v7/appcompat/res/layout/abc_action_menu_layout.xml
@@ -14,11 +14,11 @@
limitations under the License.
-->
-<android.support.appcompat.view.menu.ActionMenuView
+<android.support.v7.internal.view.menu.ActionMenuView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:divider="?attr/actionBarDivider"
+ app:divider="?attr/actionBarDivider"
app:dividerPadding="12dip"
android:gravity="center_vertical"/>
diff --git a/appcompat/res/layout/action_mode_bar.xml b/v7/appcompat/res/layout/abc_action_mode_bar.xml
similarity index 93%
rename from appcompat/res/layout/action_mode_bar.xml
rename to v7/appcompat/res/layout/abc_action_mode_bar.xml
index f6d6850..b81cd85 100644
--- a/appcompat/res/layout/action_mode_bar.xml
+++ b/v7/appcompat/res/layout/abc_action_mode_bar.xml
@@ -16,7 +16,7 @@
** limitations under the License.
*/
-->
-<com.android.internal.widget.ActionBarContextView
+<android.support.v7.internal.widget.ActionBarContextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
diff --git a/appcompat/res/layout/action_mode_close_item.xml b/v7/appcompat/res/layout/abc_action_mode_close_item.xml
similarity index 100%
rename from appcompat/res/layout/action_mode_close_item.xml
rename to v7/appcompat/res/layout/abc_action_mode_close_item.xml
diff --git a/appcompat/res/drawable/action_bar_background.xml b/v7/appcompat/res/layout/abc_expanded_menu_layout.xml
similarity index 65%
rename from appcompat/res/drawable/action_bar_background.xml
rename to v7/appcompat/res/layout/abc_expanded_menu_layout.xml
index 42f1bac..f4af882 100644
--- a/appcompat/res/drawable/action_bar_background.xml
+++ b/v7/appcompat/res/layout/abc_expanded_menu_layout.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,9 +14,8 @@
limitations under the License.
-->
-<shape xmlns:android="http://schemas.android.com/apk/res/android">
- <gradient
- android:startColor="#ffd1d2d4"
- android:endColor="#ff85878a"
- android:angle="270"/>
-</shape>
\ No newline at end of file
+<android.support.v7.internal.view.menu.ExpandedMenuView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/expanded_menu"
+ android:layout_width="?attr/panelMenuListWidth"
+ android:layout_height="wrap_content"/>
diff --git a/appcompat/res/layout/list_menu_item_checkbox.xml b/v7/appcompat/res/layout/abc_list_menu_item_checkbox.xml
similarity index 100%
rename from appcompat/res/layout/list_menu_item_checkbox.xml
rename to v7/appcompat/res/layout/abc_list_menu_item_checkbox.xml
diff --git a/appcompat/res/layout/list_menu_item_icon.xml b/v7/appcompat/res/layout/abc_list_menu_item_icon.xml
similarity index 100%
rename from appcompat/res/layout/list_menu_item_icon.xml
rename to v7/appcompat/res/layout/abc_list_menu_item_icon.xml
diff --git a/appcompat/res/layout/popup_menu_item_layout.xml b/v7/appcompat/res/layout/abc_list_menu_item_layout.xml
similarity index 65%
copy from appcompat/res/layout/popup_menu_item_layout.xml
copy to v7/appcompat/res/layout/abc_list_menu_item_layout.xml
index 0f2b67b..d3be782 100644
--- a/appcompat/res/layout/popup_menu_item_layout.xml
+++ b/v7/appcompat/res/layout/abc_list_menu_item_layout.xml
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
+<!-- Copyright (C) 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -14,13 +14,10 @@
limitations under the License.
-->
-<!-- TODO(trevorjohns): This will need to be renamed once ListMenuItemView is copied over. -->
-<com.android.internal.view.menu.ListMenuItemView
+<android.support.v7.internal.view.menu.ListMenuItemView
xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="?attr/dropdownListPreferredItemHeight"
- android:minWidth="196dip"
- android:paddingRight="16dip">
+ android:layout_width="match_parent"
+ android:layout_height="?attr/listPreferredItemHeightSmall">
<!-- Icon will be inserted here. -->
@@ -28,35 +25,34 @@
<RelativeLayout
android:layout_width="0dip"
android:layout_weight="1"
+ android:layout_marginLeft="?attr/listPreferredItemPaddingLeft"
+ android:layout_marginRight="?attr/listPreferredItemPaddingRight"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
- android:layout_marginLeft="16dip"
android:duplicateParentState="true">
<TextView
android:id="@+id/title"
- android:layout_width="fill_parent"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
- android:layout_alignParentLeft="true"
- android:textAppearance="?attr/textAppearanceLargePopupMenu"
+ android:textAppearance="?attr/textAppearanceListItemSmall"
android:singleLine="true"
android:duplicateParentState="true"
android:ellipsize="marquee"
- android:fadingEdge="horizontal"/>
+ android:fadingEdge="horizontal" />
<TextView
android:id="@+id/shortcut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/title"
- android:layout_alignParentLeft="true"
- android:textAppearance="?attr/textAppearanceSmallPopupMenu"
+ android:textAppearance="?android:attr/textAppearanceSmall"
android:singleLine="true"
- android:duplicateParentState="true"/>
+ android:duplicateParentState="true" />
</RelativeLayout>
<!-- Checkbox, and/or radio button will be inserted here. -->
-</com.android.internal.view.menu.ListMenuItemView>
+</android.support.v7.internal.view.menu.ListMenuItemView>
diff --git a/appcompat/res/layout/list_menu_item_radio.xml b/v7/appcompat/res/layout/abc_list_menu_item_radio.xml
similarity index 100%
rename from appcompat/res/layout/list_menu_item_radio.xml
rename to v7/appcompat/res/layout/abc_list_menu_item_radio.xml
diff --git a/appcompat/res/layout/popup_menu_item_layout.xml b/v7/appcompat/res/layout/abc_popup_menu_item_layout.xml
similarity index 92%
rename from appcompat/res/layout/popup_menu_item_layout.xml
rename to v7/appcompat/res/layout/abc_popup_menu_item_layout.xml
index 0f2b67b..1e4e27d 100644
--- a/appcompat/res/layout/popup_menu_item_layout.xml
+++ b/v7/appcompat/res/layout/abc_popup_menu_item_layout.xml
@@ -14,8 +14,7 @@
limitations under the License.
-->
-<!-- TODO(trevorjohns): This will need to be renamed once ListMenuItemView is copied over. -->
-<com.android.internal.view.menu.ListMenuItemView
+<android.support.v7.internal.view.menu.ListMenuItemView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?attr/dropdownListPreferredItemHeight"
@@ -59,4 +58,4 @@
<!-- Checkbox, and/or radio button will be inserted here. -->
-</com.android.internal.view.menu.ListMenuItemView>
+</android.support.v7.internal.view.menu.ListMenuItemView>
diff --git a/appcompat/res/layout/screen.xml b/v7/appcompat/res/layout/abc_screen.xml
similarity index 98%
rename from appcompat/res/layout/screen.xml
rename to v7/appcompat/res/layout/abc_screen.xml
index 2072b57..bcb6132 100644
--- a/appcompat/res/layout/screen.xml
+++ b/v7/appcompat/res/layout/abc_screen.xml
@@ -28,7 +28,7 @@
<!-- Popout bar for action modes -->
<ViewStub android:id="@+id/action_mode_bar_stub"
android:inflatedId="@+id/action_mode_bar"
- android:layout="@layout/action_mode_bar"
+ android:layout="@layout/abc_action_mode_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
diff --git a/appcompat/res/drawable/progress_small_white.xml b/v7/appcompat/res/layout/support_simple_spinner_dropdown_item.xml
similarity index 60%
rename from appcompat/res/drawable/progress_small_white.xml
rename to v7/appcompat/res/layout/support_simple_spinner_dropdown_item.xml
index 0caa953..d2f177a 100644
--- a/appcompat/res/drawable/progress_small_white.xml
+++ b/v7/appcompat/res/layout/support_simple_spinner_dropdown_item.xml
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
-/*
**
-** Copyright 2012, The Android Open Source Project
+** Copyright 2008, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
@@ -17,7 +16,10 @@
** limitations under the License.
*/
-->
-<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
- android:drawable="@drawable/spinner_white_16"
- android:pivotX="50%"
- android:pivotY="50%"/>
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@android:id/text1"
+ style="?attr/spinnerDropDownItemStyle"
+ android:singleLine="true"
+ android:layout_width="match_parent"
+ android:layout_height="?attr/dropdownListPreferredItemHeight"
+ android:ellipsize="marquee"/>
\ No newline at end of file
diff --git a/appcompat/AndroidManifest.xml b/v7/appcompat/res/values-land/bools.xml
similarity index 79%
copy from appcompat/AndroidManifest.xml
copy to v7/appcompat/res/values-land/bools.xml
index 4f60d8d..2622516 100644
--- a/appcompat/AndroidManifest.xml
+++ b/v7/appcompat/res/values-land/bools.xml
@@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.support.appcompat">
- <uses-sdk android:minSdkVersion="9"/>
-</manifest>
+
+<resources>
+ <bool name="split_action_bar_is_narrow">false</bool>
+</resources>
diff --git a/appcompat/AndroidManifest.xml b/v7/appcompat/res/values-land/config.xml
similarity index 72%
copy from appcompat/AndroidManifest.xml
copy to v7/appcompat/res/values-land/config.xml
index 4f60d8d..f27725f 100644
--- a/appcompat/AndroidManifest.xml
+++ b/v7/appcompat/res/values-land/config.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -13,7 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.support.appcompat">
- <uses-sdk android:minSdkVersion="9"/>
-</manifest>
+<resources>
+ <bool name="config_allowActionMenuItemTextWithIcon">true</bool>
+</resources>
diff --git a/appcompat/res/values-land/dimens.xml b/v7/appcompat/res/values-land/dimens.xml
similarity index 100%
rename from appcompat/res/values-land/dimens.xml
rename to v7/appcompat/res/values-land/dimens.xml
diff --git a/appcompat/AndroidManifest.xml b/v7/appcompat/res/values-large/bools.xml
similarity index 79%
copy from appcompat/AndroidManifest.xml
copy to v7/appcompat/res/values-large/bools.xml
index 4f60d8d..2622516 100644
--- a/appcompat/AndroidManifest.xml
+++ b/v7/appcompat/res/values-large/bools.xml
@@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.support.appcompat">
- <uses-sdk android:minSdkVersion="9"/>
-</manifest>
+
+<resources>
+ <bool name="split_action_bar_is_narrow">false</bool>
+</resources>
diff --git a/appcompat/res/values-large/config.xml b/v7/appcompat/res/values-large/config.xml
similarity index 79%
rename from appcompat/res/values-large/config.xml
rename to v7/appcompat/res/values-large/config.xml
index 211b782..b3da075 100644
--- a/appcompat/res/values-large/config.xml
+++ b/v7/appcompat/res/values-large/config.xml
@@ -20,6 +20,11 @@
<!-- These resources are around just to allow their values to be customized
for different hardware and product builds. -->
<resources>
+ <!-- Whether action menu items should obey the "withText" showAsAction.
+ This may be set to false for situations where space is
+ extremely limited. -->
+ <bool name="config_allowActionMenuItemTextWithIcon">true</bool>
+
<!-- see comment in values/config.xml -->
<dimen name="config_prefDialogWidth">440dp</dimen>
</resources>
\ No newline at end of file
diff --git a/appcompat/res/values-port/bools.xml b/v7/appcompat/res/values-port/bools.xml
similarity index 100%
rename from appcompat/res/values-port/bools.xml
rename to v7/appcompat/res/values-port/bools.xml
diff --git a/appcompat/res/values-sw600dp/config.xml b/v7/appcompat/res/values-sw600dp/config.xml
similarity index 100%
rename from appcompat/res/values-sw600dp/config.xml
rename to v7/appcompat/res/values-sw600dp/config.xml
diff --git a/appcompat/res/values-sw600dp/dimens.xml b/v7/appcompat/res/values-sw600dp/dimens.xml
similarity index 100%
rename from appcompat/res/values-sw600dp/dimens.xml
rename to v7/appcompat/res/values-sw600dp/dimens.xml
diff --git a/v7/appcompat/res/values-v11/styles_base.xml b/v7/appcompat/res/values-v11/styles_base.xml
new file mode 100644
index 0000000..e0089cf
--- /dev/null
+++ b/v7/appcompat/res/values-v11/styles_base.xml
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+
+ <!-- Like in themes_base.xml, the namespace "*.AppCompat.Base" is used to
+ define base styles for the platform version. The "*.AppCompat"
+ variants are for direct use or use as parent styles by the app. -->
+ <eat-comment/>
+
+ <!-- Action Bar Spinner Widgets -->
+
+ <style name="Widget.AppCompat.Base.ListView.DropDown"
+ parent="android:Widget.Holo.ListView.DropDown"/>
+
+ <style name="Widget.AppCompat.Light.Base.ListView.DropDown"
+ parent="android:Widget.Holo.ListView.DropDown"/>
+
+ <style name="Widget.AppCompat.Base.DropDownItem.Spinner"
+ parent="android:Widget.Holo.DropDownItem.Spinner"/>
+
+ <style name="Widget.AppCompat.Light.Base.DropDownItem.Spinner"
+ parent="android:Widget.Holo.Light.DropDownItem.Spinner"/>
+
+ <style name="Widget.AppCompat.Base.Spinner"
+ parent="android:Widget.Holo.Spinner"/>
+
+ <style name="Widget.AppCompat.Light.Base.Spinner"
+ parent="android:Widget.Holo.Light.Spinner"/>
+
+ <style name="Widget.AppCompat.Base.DropDownItem.Spinner"
+ parent="android:Widget.Holo.DropDownItem.Spinner"/>
+
+ <style name="Widget.AppCompat.Light.Base.DropDownItem.Spinner"
+ parent="android:Widget.Holo.Light.DropDownItem.Spinner">
+ </style>
+
+ <!-- ActionBar -->
+ <style name="Widget.AppCompat.Base.ActionBar" parent="android:Widget.Holo.ActionBar">
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionBar"
+ parent="android:Widget.Holo.Light.ActionBar">
+ </style>
+
+ <!-- Patterned after style name="Widget.Holo.ActionBar.Solid" -->
+ <style name="Widget.AppCompat.Base.ActionBar.Solid" parent="android:Widget.Holo.ActionBar">
+ <item name="android:background">@drawable/abc_ab_solid_dark_holo</item>
+ </style>
+
+ <!-- Patterned after style name="Widget.Holo.Light.ActionBar.Solid" -->
+ <style name="Widget.AppCompat.Light.Base.ActionBar.Solid"
+ parent="android:Widget.Holo.Light.ActionBar">
+ <item name="android:background">@drawable/abc_ab_solid_light_holo</item>
+ </style>
+
+ <style name="Widget.AppCompat.Base.ActionButton" parent="android:Widget.Holo.ActionButton">
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionButton"
+ parent="android:Widget.Holo.Light.ActionButton">
+ </style>
+
+ <style name="Widget.AppCompat.Base.ActionButton.CloseMode"
+ parent="android:Widget.Holo.ActionButton.CloseMode">
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionButton.CloseMode"
+ parent="android:Widget.Holo.Light.ActionButton.CloseMode">
+ </style>
+
+ <style name="Widget.AppCompat.Base.ActionButton.Overflow"
+ parent="android:Widget.Holo.ActionButton.Overflow">
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionButton.Overflow"
+ parent="android:Widget.Holo.Light.ActionButton.Overflow">
+ </style>
+
+ <style name="Widget.AppCompat.Base.ActionMode" parent="android:Widget.Holo.ActionMode">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.ActionBar.Title"
+ parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.ActionBar.Subtitle"
+ parent="android:TextAppearance.Holo.Widget.ActionBar.Subtitle">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.ActionMode.Title"
+ parent="android:TextAppearance.Holo.Widget.ActionMode.Title">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.ActionMode.Subtitle"
+ parent="android:TextAppearance.Holo.Widget.ActionMode.Subtitle">
+ </style>
+
+ <style name="Widget.AppCompat.Base.ProgressBar.Horizontal"
+ parent="android:Widget.Holo.ProgressBar.Horizontal">
+ </style>
+
+ <style name="Widget.AppCompat.Base.ProgressBar"
+ parent="android:Widget.Holo.ProgressBar">
+ </style>
+
+ <style name="Widget.AppCompat.Base.ListView.Menu" parent="android:Widget.ListView.Menu">
+ </style>
+
+ <!--
+ Inverse styles. As we don't have a DarkActionBar theme on v11, these extend
+ from the respective Light styles
+ -->
+ <style name="Widget.AppCompat.Light.Base.ActionBar.Solid.Inverse"
+ parent="Widget.AppCompat.Light.Base.ActionBar.Solid">
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionMode.Inverse"
+ parent="Widget.AppCompat.Base.ActionMode">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.ActionMode.Title.Inverse"
+ parent="TextAppearance.AppCompat.Widget.Base.ActionMode.Title">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.ActionMode.Subtitle.Inverse"
+ parent="TextAppearance.AppCompat.Widget.Base.ActionMode.Subtitle">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.ActionBar.Title.Inverse"
+ parent="TextAppearance.AppCompat.Widget.Base.ActionBar.Title">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.ActionBar.Subtitle.Inverse"
+ parent="TextAppearance.AppCompat.Widget.Base.ActionBar.Subtitle">
+ </style>
+
+</resources>
diff --git a/v7/appcompat/res/values-v11/themes_base.xml b/v7/appcompat/res/values-v11/themes_base.xml
new file mode 100644
index 0000000..9fa1099
--- /dev/null
+++ b/v7/appcompat/res/values-v11/themes_base.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+
+ <!-- Themes in the "Theme.Base" family vary based on the current platform
+ version to provide the correct basis on each device. You probably don't
+ want to use them directly in your apps.
+
+ Themes in the "Theme.AppCompat" family are meant to be extended or used
+ directly by apps.
+
+ This is the values-v11/ file that only declares the Base themes for
+ Honeycomb+. You probably want to edit values/themes.xml instead. -->
+ <eat-comment/>
+
+ <!-- Base platform-dependent theme providing an action bar in a dark-themed activity. -->
+ <style name="Theme.Base.AppCompat" parent="android:Theme.Holo">
+ <!-- Copy system flag values for our use -->
+ <item name="windowActionBar">?android:attr/windowActionBar</item>
+ <item name="actionBarSize">?android:attr/actionBarSize</item>
+
+ <!-- Required for use of support_simple_spinner_dropdown_item.xml -->
+ <item name="listPreferredItemHeight">?android:attr/listPreferredItemHeight</item>
+ <item name="listPreferredItemHeightSmall">48dp</item>
+ <item name="listPreferredItemHeightLarge">80dp</item>
+ <item name="listPreferredItemPaddingLeft">8dip</item>
+ <item name="listPreferredItemPaddingRight">8dip</item>
+ </style>
+
+ <!-- Base platform-dependent theme providing an action bar in a light-themed activity. -->
+ <style name="Theme.Base.AppCompat.Light" parent="android:Theme.Holo.Light">
+ <!-- Copy system flag values for our use -->
+ <item name="windowActionBar">?android:attr/windowActionBar</item>
+ <item name="actionBarSize">?android:attr/actionBarSize</item>
+
+ <!-- Required for use of support_simple_spinner_dropdown_item.xml -->
+ <item name="listPreferredItemHeight">?android:attr/listPreferredItemHeight</item>
+ <item name="listPreferredItemHeightSmall">48dp</item>
+ <item name="listPreferredItemHeightLarge">80dp</item>
+ <item name="listPreferredItemPaddingLeft">8dip</item>
+ <item name="listPreferredItemPaddingRight">8dip</item>
+ </style>
+
+ <!-- Base platform-dependent theme. There is no DarkActionBar theme in v11, so we use Light -->
+ <style name="Theme.Base.AppCompat.Light.DarkActionBar"
+ parent="Theme.Base.AppCompat.Light">
+ </style>
+
+</resources>
diff --git a/v7/appcompat/res/values-v14/styles_base.xml b/v7/appcompat/res/values-v14/styles_base.xml
new file mode 100644
index 0000000..d806f14
--- /dev/null
+++ b/v7/appcompat/res/values-v14/styles_base.xml
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+
+ <!-- Like in themes_base.xml, the namespace "*.AppCompat.Base" is used to
+ define base styles for the platform version. The "*.AppCompat"
+ variants are for direct use or use as parent styles by the app. -->
+ <eat-comment/>
+
+
+ <style name="Widget.AppCompat.Base.ActionBar.Solid"
+ parent="android:Widget.Holo.ActionBar.Solid">
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionBar.Solid"
+ parent="android:Widget.Holo.Light.ActionBar.Solid">
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionBar.Solid.Inverse"
+ parent="android:Widget.Holo.Light.ActionBar.Solid.Inverse">
+ </style>
+
+ <style name="Widget.AppCompat.Base.ActionBar.TabBar"
+ parent="android:Widget.Holo.ActionBar.TabBar">
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionBar.TabBar"
+ parent="android:Widget.Holo.Light.ActionBar.TabBar">
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionBar.TabBar.Inverse"
+ parent="android:Widget.Holo.Light.ActionBar.TabBar.Inverse">
+ </style>
+
+ <style name="Widget.AppCompat.Base.ActionBar.TabView"
+ parent="android:Widget.Holo.ActionBar.TabView">
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionBar.TabView"
+ parent="android:Widget.Holo.Light.ActionBar.TabView">
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionBar.TabView.Inverse"
+ parent="android:Widget.Holo.Light.ActionBar.TabView.Inverse">
+ </style>
+
+ <style name="Widget.AppCompat.Base.ActionBar.TabText"
+ parent="android:Widget.Holo.ActionBar.TabText">
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionBar.TabText"
+ parent="android:Widget.Holo.Light.ActionBar.TabText">
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionBar.TabText.Inverse"
+ parent="android:Widget.Holo.Light.ActionBar.TabText.Inverse">
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionMode.Inverse"
+ parent="android:Widget.Holo.Light.ActionMode.Inverse">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.ActionBar.Menu"
+ parent="android:TextAppearance.Holo.Widget.ActionBar.Menu">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.ActionBar.Title.Inverse"
+ parent="android:TextAppearance.Holo.Widget.ActionBar.Title.Inverse">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.ActionBar.Subtitle.Inverse"
+ parent="android:TextAppearance.Holo.Widget.ActionBar.Subtitle.Inverse">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.ActionMode.Title.Inverse"
+ parent="android:TextAppearance.Holo.Widget.ActionMode.Title.Inverse">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.ActionMode.Subtitle.Inverse"
+ parent="android:TextAppearance.Holo.Widget.ActionMode.Subtitle.Inverse">
+ </style>
+
+ <style name="Widget.AppCompat.Base.PopupMenu" parent="android:Widget.Holo.PopupMenu">
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.PopupMenu"
+ parent="android:Widget.Holo.Light.PopupMenu">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Base.Widget.PopupMenu.Large"
+ parent="android:TextAppearance.Holo.Widget.PopupMenu.Large">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Base.Widget.PopupMenu.Small"
+ parent="android:TextAppearance.Holo.Widget.PopupMenu.Small">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Light.Base.Widget.PopupMenu.Large"
+ parent="android:TextAppearance.Holo.Widget.PopupMenu.Large">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Light.Base.Widget.PopupMenu.Small"
+ parent="android:TextAppearance.Holo.Widget.PopupMenu.Small">
+ </style>
+
+</resources>
diff --git a/v7/appcompat/res/values-v14/themes_base.xml b/v7/appcompat/res/values-v14/themes_base.xml
new file mode 100644
index 0000000..a386621
--- /dev/null
+++ b/v7/appcompat/res/values-v14/themes_base.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+
+ <!-- Themes in the "Theme.Base" family vary based on the current platform
+ version to provide the correct basis on each device. You probably don't
+ want to use them directly in your apps.
+
+ Themes in the "Theme.AppCompat" family are meant to be extended or used
+ directly by apps.
+
+ This is the values-v14/ file that only declares the Base themes for
+ Ice Cream Sandwich+. You probably want to edit values/themes.xml instead. -->
+ <eat-comment/>
+
+ <!-- Base platform-dependent theme providing an action bar in a dark-themed activity. -->
+ <style name="Theme.Base.AppCompat" parent="android:Theme.Holo">
+ <!-- Copy system flag values for our use -->
+ <item name="windowActionBar">?android:attr/windowActionBar</item>
+ <item name="actionBarSize">?android:attr/actionBarSize</item>
+
+ <!-- Required for use of support_simple_spinner_dropdown_item.xml -->
+ <item name="listPreferredItemHeight">?android:attr/listPreferredItemHeight</item>
+ <item name="listPreferredItemHeightSmall">?android:attr/listPreferredItemHeightSmall</item>
+ <item name="listPreferredItemHeightLarge">?android:attr/listPreferredItemHeightLarge</item>
+ <item name="listPreferredItemPaddingLeft">?android:attr/listPreferredItemPaddingLeft</item>
+ <item name="listPreferredItemPaddingRight">?android:attr/listPreferredItemPaddingRight
+ </item>
+ </style>
+
+ <!-- Base platform-dependent theme providing an action bar in a light-themed activity. -->
+ <style name="Theme.Base.AppCompat.Light" parent="android:Theme.Holo.Light">
+ <!-- Copy system flag values for our use -->
+ <item name="windowActionBar">?android:attr/windowActionBar</item>
+ <item name="actionBarSize">?android:attr/actionBarSize</item>
+
+ <!-- Required for use of support_simple_spinner_dropdown_item.xml -->
+ <item name="listPreferredItemHeight">?android:attr/listPreferredItemHeight</item>
+ <item name="listPreferredItemHeightSmall">?android:attr/listPreferredItemHeightSmall</item>
+ <item name="listPreferredItemHeightLarge">?android:attr/listPreferredItemHeightLarge</item>
+ <item name="listPreferredItemPaddingLeft">?android:attr/listPreferredItemPaddingLeft</item>
+ <item name="listPreferredItemPaddingRight">?android:attr/listPreferredItemPaddingRight
+ </item>
+ </style>
+
+ <!-- Base platform-dependent theme providing a dark action bar in a light-themed activity. -->
+ <style name="Theme.Base.AppCompat.Light.DarkActionBar"
+ parent="android:Theme.Holo.Light.DarkActionBar">
+ <!-- Copy system flag values for our use -->
+ <item name="windowActionBar">?android:attr/windowActionBar</item>
+ <item name="actionBarSize">?android:attr/actionBarSize</item>
+
+ <!-- Required for use of support_simple_spinner_dropdown_item.xml -->
+ <item name="listPreferredItemHeight">?android:attr/listPreferredItemHeight</item>
+ <item name="listPreferredItemHeightSmall">?android:attr/listPreferredItemHeightSmall</item>
+ <item name="listPreferredItemHeightLarge">?android:attr/listPreferredItemHeightLarge</item>
+ <item name="listPreferredItemPaddingLeft">?android:attr/listPreferredItemPaddingLeft</item>
+ <item name="listPreferredItemPaddingRight">?android:attr/listPreferredItemPaddingRight
+ </item>
+ </style>
+
+</resources>
diff --git a/appcompat/res/values-w360dp/dimens.xml b/v7/appcompat/res/values-w360dp/dimens.xml
similarity index 100%
rename from appcompat/res/values-w360dp/dimens.xml
rename to v7/appcompat/res/values-w360dp/dimens.xml
diff --git a/appcompat/res/values-w480dp/bools.xml b/v7/appcompat/res/values-w480dp/bools.xml
similarity index 100%
rename from appcompat/res/values-w480dp/bools.xml
rename to v7/appcompat/res/values-w480dp/bools.xml
diff --git a/appcompat/res/values-w480dp/config.xml b/v7/appcompat/res/values-w480dp/config.xml
similarity index 100%
rename from appcompat/res/values-w480dp/config.xml
rename to v7/appcompat/res/values-w480dp/config.xml
diff --git a/appcompat/res/values-w500dp/dimens.xml b/v7/appcompat/res/values-w500dp/dimens.xml
similarity index 100%
rename from appcompat/res/values-w500dp/dimens.xml
rename to v7/appcompat/res/values-w500dp/dimens.xml
diff --git a/appcompat/res/values-w600dp/dimens.xml b/v7/appcompat/res/values-w600dp/dimens.xml
similarity index 100%
rename from appcompat/res/values-w600dp/dimens.xml
rename to v7/appcompat/res/values-w600dp/dimens.xml
diff --git a/appcompat/res/values-w720dp/bools.xml b/v7/appcompat/res/values-w720dp/bools.xml
similarity index 100%
rename from appcompat/res/values-w720dp/bools.xml
rename to v7/appcompat/res/values-w720dp/bools.xml
diff --git a/appcompat/res/values/attrs.xml b/v7/appcompat/res/values/attrs.xml
similarity index 62%
rename from appcompat/res/values/attrs.xml
rename to v7/appcompat/res/values/attrs.xml
index baeba89..8f99769 100644
--- a/appcompat/res/values/attrs.xml
+++ b/v7/appcompat/res/values/attrs.xml
@@ -31,6 +31,7 @@
<declare-styleable name="ActionBarWindow">
<attr name="windowActionBar" format="boolean"/>
<attr name="windowActionBarOverlay" format="boolean"/>
+ <attr name="windowSplitActionBar" format="boolean" />
</declare-styleable>
<!-- ============================================ -->
@@ -201,7 +202,6 @@
<attr name="android:layout_gravity"/>
</declare-styleable>
- <!-- TODO(trevorjohns): Write docs for this. -->
<declare-styleable name="ActionMenuItemView">
<attr name="android:minWidth"/>
</declare-styleable>
@@ -259,39 +259,220 @@
<!-- These are the standard attributes that make up a complete theme. -->
<declare-styleable name="Theme">
- <!-- TODO(trevorjohns): Add other attributes! -->
<!-- Default ActionBar dropdown style. -->
- <attr name="actionDropDownStylFe" format="reference"/>
+ <attr name="actionDropDownStyle" format="reference"/>
<!-- The preferred item height for dropdown lists. -->
<attr name="dropdownListPreferredItemHeight" format="dimension"/>
<!-- Default PopupMenu style. -->
<attr name="popupMenuStyle" format="reference"/>
- <!-- Default ActionBar dropdown style. -->
- <attr name="actionDropDownStyle" format="reference"/>
+
+ <!-- ============ -->
+ <!-- Panel styles -->
+ <!-- ============ -->
+ <eat-comment />
+
+ <!-- Default Panel Menu width. -->
+ <attr name="panelMenuListWidth" format="dimension" />
+
+ <!-- Default Panel Menu style. -->
+ <attr name="panelMenuListTheme" format="reference" />
+
+ <!-- Drawable used as a background for selected list items. -->
+ <attr name="listChoiceBackgroundIndicator" format="reference" />
+
</declare-styleable>
<declare-styleable name="MenuView">
<!-- Default appearance of menu item text. -->
- <attr name="itemTextAppearance" format="reference"/>
+ <attr name="android:itemTextAppearance"/>
<!-- Default horizontal divider between rows of menu items. -->
- <attr name="horizontalDivider" format="reference"/>
+ <attr name="android:horizontalDivider"/>
<!-- Default vertical divider between menu items. -->
- <attr name="verticalDivider" format="reference"/>
+ <attr name="android:verticalDivider"/>
<!-- Default background for the menu header. -->
- <attr name="headerBackground" format="color|reference"/>
+ <attr name="android:headerBackground"/>
<!-- Default background for each menu item. -->
- <attr name="itemBackground" format="color|reference"/>
+ <attr name="android:itemBackground"/>
<!-- Default animations for the menu. -->
- <attr name="windowAnimationStyle" format="reference"/>
+ <attr name="android:windowAnimationStyle"/>
<!-- Default disabled icon alpha for each menu item that shows an icon. -->
- <attr name="itemIconDisabledAlpha" format="float"/>
+ <attr name="android:itemIconDisabledAlpha"/>
<!-- Whether space should be reserved in layout when an icon is missing. -->
- <attr name="preserveIconSpacing" format="boolean"/>
+ <attr name="android:preserveIconSpacing"/>
</declare-styleable>
<declare-styleable name="ActionMenuView">
<!-- Size of padding on either end of a divider. -->
</declare-styleable>
- <attr name="dividerPadding" format="dimension"/>
+ <!-- Base attributes that are available to all groups. -->
+ <declare-styleable name="MenuGroup">
+
+ <!-- The ID of the group. -->
+ <attr name="android:id" />
+
+ <!-- The category applied to all items within this group.
+ (This will be or'ed with the orderInCategory attribute.) -->
+ <attr name="android:menuCategory" />
+
+ <!-- The order within the category applied to all items within this group.
+ (This will be or'ed with the category attribute.) -->
+ <attr name="android:orderInCategory" />
+
+ <!-- Whether the items are capable of displaying a check mark. -->
+ <attr name="android:checkableBehavior" />
+
+ <!-- Whether the items are shown/visible. -->
+ <attr name="android:visible" />
+
+ <!-- Whether the items are enabled. -->
+ <attr name="android:enabled" />
+
+ </declare-styleable>
+
+ <!-- Base attributes that are available to all Item objects. -->
+ <declare-styleable name="MenuItem">
+
+ <!-- The ID of the item. -->
+ <attr name="android:id" />
+
+ <!-- The category applied to the item.
+ (This will be or'ed with the orderInCategory attribute.) -->
+ <attr name="android:menuCategory" />
+
+ <!-- The order within the category applied to the item.
+ (This will be or'ed with the category attribute.) -->
+ <attr name="android:orderInCategory" />
+
+ <!-- The title associated with the item. -->
+ <attr name="android:title" />
+
+ <!-- The condensed title associated with the item. This is used in situations where the
+ normal title may be too long to be displayed. -->
+ <attr name="android:titleCondensed" />
+
+ <!-- The icon associated with this item. This icon will not always be shown, so
+ the title should be sufficient in describing this item. -->
+ <attr name="android:icon" />
+
+ <!-- The alphabetic shortcut key. This is the shortcut when using a keyboard
+ with alphabetic keys. -->
+ <attr name="android:alphabeticShortcut" />
+
+ <!-- The numeric shortcut key. This is the shortcut when using a numeric (e.g., 12-key)
+ keyboard. -->
+ <attr name="android:numericShortcut" />
+
+ <!-- Whether the item is capable of displaying a check mark. -->
+ <attr name="android:checkable" />
+
+ <!-- Whether the item is checked. Note that you must first have enabled checking with
+ the checkable attribute or else the check mark will not appear. -->
+ <attr name="android:checked" />
+
+ <!-- Whether the item is shown/visible. -->
+ <attr name="android:visible" />
+
+ <!-- Whether the item is enabled. -->
+ <attr name="android:enabled" />
+
+ <!-- Name of a method on the Context used to inflate the menu that will be
+ called when the item is clicked. -->
+ <attr name="android:onClick" />
+
+ <!-- How this item should display in the Action Bar, if present. -->
+ <attr name="showAsAction">
+ <!-- Never show this item in an action bar, show it in the overflow menu instead.
+ Mutually exclusive with "ifRoom" and "always". -->
+ <flag name="never" value="0" />
+ <!-- Show this item in an action bar if there is room for it as determined
+ by the system. Favor this option over "always" where possible.
+ Mutually exclusive with "never" and "always". -->
+ <flag name="ifRoom" value="1" />
+ <!-- Always show this item in an actionbar, even if it would override
+ the system's limits of how much stuff to put there. This may make
+ your action bar look bad on some screens. In most cases you should
+ use "ifRoom" instead. Mutually exclusive with "ifRoom" and "never". -->
+ <flag name="always" value="2" />
+ <!-- When this item is shown as an action in the action bar, show a text
+ label with it even if it has an icon representation. -->
+ <flag name="withText" value="4" />
+ <!-- This item's action view collapses to a normal menu
+ item. When expanded, the action view takes over a
+ larger segment of its container. -->
+ <flag name="collapseActionView" value="8" />
+ </attr>
+
+ <!-- An optional layout to be used as an action view.
+ See {@link android.view.MenuItem#setActionView(android.view.View)}
+ for more info. -->
+ <attr name="actionLayout" format="reference" />
+
+ <!-- The name of an optional View class to instantiate and use as an
+ action view. See {@link android.view.MenuItem#setActionView(android.view.View)}
+ for more info. -->
+ <attr name="actionViewClass" format="string" />
+
+ <!-- The name of an optional ActionProvider class to instantiate an action view
+ and perform operations such as default action for that menu item.
+ See {@link android.view.MenuItem#setActionProvider(android.view.ActionProvider)}
+ for more info. -->
+ <attr name="actionProviderClass" format="string" />
+
+ </declare-styleable>
+
+ <declare-styleable name="Spinner">
+ <!-- The prompt to display when the spinner's dialog is shown. -->
+ <attr name="prompt" format="reference" />
+ <!-- Display mode for spinner options. -->
+ <attr name="spinnerMode" format="enum">
+ <!-- Spinner options will be presented to the user as a dialog window. -->
+ <enum name="dialog" value="0" />
+ <!-- Spinner options will be presented to the user as an inline dropdown
+ anchored to the spinner widget itself. -->
+ <enum name="dropdown" value="1" />
+ </attr>
+ <!-- List selector to use for spinnerMode="dropdown" display. -->
+ <attr name="android:dropDownSelector" />
+ <!-- Background drawable to use for the dropdown in spinnerMode="dropdown". -->
+ <attr name="android:popupBackground" />
+ <!-- Vertical offset from the spinner widget for positioning the dropdown in
+ spinnerMode="dropdown". -->
+ <attr name="android:dropDownVerticalOffset" />
+ <!-- Horizontal offset from the spinner widget for positioning the dropdown
+ in spinnerMode="dropdown". -->
+ <attr name="android:dropDownHorizontalOffset" />
+ <!-- Width of the dropdown in spinnerMode="dropdown". -->
+ <attr name="android:dropDownWidth" />
+ <!-- Reference to a layout to use for displaying a prompt in the dropdown for
+ spinnerMode="dropdown". This layout must contain a TextView with the id
+ @android:id/text1 to be populated with the prompt text. -->
+ <attr name="popupPromptView" format="reference" />
+ <!-- Gravity setting for positioning the currently selected item. -->
+ <attr name="android:gravity" />
+ <!-- Whether this spinner should mark child views as enabled/disabled when
+ the spinner itself is enabled/disabled. -->
+ <attr name="disableChildrenWhenDisabled" format="boolean" />
+ </declare-styleable>
+
+ <declare-styleable name="LinearLayoutICS">
+ <!-- Drawable to use as a vertical divider between buttons. -->
+ <attr name="divider" />
+ <!-- Setting for which dividers to show. -->
+ <attr name="showDividers">
+ <flag name="none" value="0" />
+ <flag name="beginning" value="1" />
+ <flag name="middle" value="2" />
+ <flag name="end" value="4" />
+ </attr>
+ <!-- Size of padding on either end of a divider. -->
+ <attr name="dividerPadding" format="dimension" />
+ </declare-styleable>
+
+ <!-- Default Spinner style. -->
+ <attr name="spinnerStyle" format="reference" />
+
+ <!-- Default Spinner style. -->
+ <attr name="spinnerDropDownItemStyle" format="reference" />
+
</resources>
diff --git a/appcompat/res/values/bools.xml b/v7/appcompat/res/values/bools.xml
similarity index 87%
rename from appcompat/res/values/bools.xml
rename to v7/appcompat/res/values/bools.xml
index 55798f7..c1d205f 100644
--- a/appcompat/res/values/bools.xml
+++ b/v7/appcompat/res/values/bools.xml
@@ -20,8 +20,5 @@
<bool name="action_bar_expanded_action_views_exclusive">true</bool>
<bool name="split_action_bar_is_narrow">true</bool>
- <!-- TODO(anirudhd) ported from symbols.xml. framework uses symbols.xml
- and sed script to generate internal values.
- -->
<bool name="config_showMenuShortcutsWhenKeyboardPresent">false</bool>
</resources>
diff --git a/appcompat/res/values/colors.xml b/v7/appcompat/res/values/colors.xml
similarity index 100%
rename from appcompat/res/values/colors.xml
rename to v7/appcompat/res/values/colors.xml
diff --git a/appcompat/res/values/config.xml b/v7/appcompat/res/values/config.xml
similarity index 100%
rename from appcompat/res/values/config.xml
rename to v7/appcompat/res/values/config.xml
diff --git a/appcompat/res/values/dimens.xml b/v7/appcompat/res/values/dimens.xml
similarity index 91%
rename from appcompat/res/values/dimens.xml
rename to v7/appcompat/res/values/dimens.xml
index 066f0c7..7f7da19 100644
--- a/appcompat/res/values/dimens.xml
+++ b/v7/appcompat/res/values/dimens.xml
@@ -42,5 +42,10 @@
<dimen name="action_bar_subtitle_top_margin">-3dp</dimen>
<!-- Bottom margin for action bar subtitles -->
<dimen name="action_bar_subtitle_bottom_margin">5dip</dimen>
+ <!-- Minimum width for an action button in the menu area of an action bar -->
+ <dimen name="action_button_min_width">56dip</dimen>
+
+
+ <dimen name="panel_menu_list_width">296dp</dimen>
</resources>
diff --git a/appcompat/res/values/ids.xml b/v7/appcompat/res/values/ids.xml
similarity index 100%
rename from appcompat/res/values/ids.xml
rename to v7/appcompat/res/values/ids.xml
diff --git a/appcompat/res/values/strings.xml b/v7/appcompat/res/values/strings.xml
similarity index 100%
rename from appcompat/res/values/strings.xml
rename to v7/appcompat/res/values/strings.xml
diff --git a/v7/appcompat/res/values/styles.xml b/v7/appcompat/res/values/styles.xml
new file mode 100644
index 0000000..191e95a
--- /dev/null
+++ b/v7/appcompat/res/values/styles.xml
@@ -0,0 +1,206 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+
+ <!-- Styles in here can be extended for customisation in your application. Each utilises
+ one of the Base styles. If Holo themes are available on the current platform version
+ they will be used instead of the compat styles. -->
+
+ <style name="Widget.AppCompat.ActionBar" parent="Widget.AppCompat.Base.ActionBar">
+ </style>
+
+ <style name="Widget.AppCompat.Light.ActionBar" parent="Widget.AppCompat.Light.Base.ActionBar">
+ </style>
+
+ <style name="Widget.AppCompat.ActionBar.Solid"
+ parent="Widget.AppCompat.Base.ActionBar.Solid">
+ </style>
+
+ <style name="Widget.AppCompat.Light.ActionBar.Solid"
+ parent="Widget.AppCompat.Light.Base.ActionBar.Solid">
+ </style>
+
+ <style name="Widget.AppCompat.Light.ActionBar.Solid.Inverse"
+ parent="Widget.AppCompat.Light.Base.ActionBar.Solid.Inverse">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.ActionBar.Title"
+ parent="TextAppearance.AppCompat.Widget.Base.ActionBar.Title">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.ActionBar.Subtitle"
+ parent="TextAppearance.AppCompat.Widget.Base.ActionBar.Subtitle">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse"
+ parent="TextAppearance.AppCompat.Widget.Base.ActionBar.Title.Inverse">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.ActionBar.Subtitle.Inverse"
+ parent="TextAppearance.AppCompat.Widget.Base.ActionBar.Subtitle.Inverse">
+ </style>
+
+ <style name="Widget.AppCompat.ProgressBar.Horizontal"
+ parent="Widget.AppCompat.Base.ProgressBar.Horizontal">
+ </style>
+
+ <style name="Widget.AppCompat.ProgressBar"
+ parent="Widget.AppCompat.Base.ProgressBar">
+ </style>
+
+ <style name="Widget.AppCompat.ActionButton" parent="Widget.AppCompat.Base.ActionButton">
+ </style>
+
+ <style name="Widget.AppCompat.Light.ActionButton"
+ parent="Widget.AppCompat.Light.Base.ActionButton">
+ </style>
+
+ <style name="Widget.AppCompat.ActionButton.CloseMode"
+ parent="Widget.AppCompat.Base.ActionButton.CloseMode">
+ </style>
+
+ <style name="Widget.AppCompat.Light.ActionButton.CloseMode"
+ parent="Widget.AppCompat.Light.Base.ActionButton.CloseMode">
+ </style>
+
+ <style name="Widget.AppCompat.ActionButton.Overflow"
+ parent="Widget.AppCompat.Base.ActionButton.Overflow">
+ </style>
+
+ <style name="Widget.AppCompat.Light.ActionButton.Overflow"
+ parent="Widget.AppCompat.Light.Base.ActionButton.Overflow">
+ </style>
+
+ <style name="Widget.AppCompat.ActionBar.TabBar" parent="Widget.AppCompat.Base.ActionBar.TabBar">
+ </style>
+
+ <style name="Widget.AppCompat.Light.ActionBar.TabBar"
+ parent="Widget.AppCompat.Light.Base.ActionBar.TabBar">
+ </style>
+
+ <style name="Widget.AppCompat.Light.ActionBar.TabBar.Inverse"
+ parent="Widget.AppCompat.Light.Base.ActionBar.TabBar.Inverse"></style>
+
+ <style name="Widget.AppCompat.ActionBar.TabView"
+ parent="Widget.AppCompat.Base.ActionBar.TabView">
+ </style>
+
+ <style name="Widget.AppCompat.Light.ActionBar.TabView"
+ parent="Widget.AppCompat.Light.Base.ActionBar.TabView">
+ </style>
+
+ <style name="Widget.AppCompat.Light.ActionBar.TabView.Inverse"
+ parent="Widget.AppCompat.Light.Base.ActionBar.TabView.Inverse">
+ </style>
+
+ <style name="Widget.AppCompat.ActionBar.TabText"
+ parent="Widget.AppCompat.Base.ActionBar.TabText">
+ </style>
+
+ <style name="Widget.AppCompat.Light.ActionBar.TabText"
+ parent="Widget.AppCompat.Light.Base.ActionBar.TabText">
+ </style>
+
+ <style name="Widget.AppCompat.Light.ActionBar.TabText.Inverse"
+ parent="Widget.AppCompat.Light.Base.ActionBar.TabText.Inverse">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.ActionBar.Menu"
+ parent="TextAppearance.AppCompat.Widget.Base.ActionBar.Menu">
+ </style>
+
+ <style name="Widget.AppCompat.ActionMode" parent="Widget.AppCompat.Base.ActionMode">
+ </style>
+
+ <style name="Widget.AppCompat.Light.ActionMode.Inverse"
+ parent="Widget.AppCompat.Light.Base.ActionMode.Inverse">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.ActionMode.Title"
+ parent="TextAppearance.AppCompat.Widget.Base.ActionMode.Title">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.ActionMode.Subtitle"
+ parent="TextAppearance.AppCompat.Widget.Base.ActionMode.Subtitle">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.ActionMode.Title.Inverse"
+ parent="TextAppearance.AppCompat.Widget.Base.ActionMode.Title.Inverse">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.ActionMode.Subtitle.Inverse"
+ parent="TextAppearance.AppCompat.Widget.Base.ActionMode.Subtitle.Inverse">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.DropDownItem"
+ parent="TextAppearance.AppCompat.Widget.Base.DropDownItem">
+ </style>
+
+ <style name="Widget.AppCompat.Spinner.DropDown.ActionBar"
+ parent="Widget.AppCompat.Base.Spinner">
+ </style>
+
+ <style name="Widget.AppCompat.Light.Spinner.DropDown.ActionBar"
+ parent="Widget.AppCompat.Light.Base.Spinner">
+ </style>
+
+ <style name="Widget.AppCompat.DropDownItem.Spinner"
+ parent="Widget.AppCompat.Base.DropDownItem.Spinner">
+ </style>
+ <style name="Widget.AppCompat.Light.DropDownItem.Spinner"
+ parent="Widget.AppCompat.Light.Base.DropDownItem.Spinner">
+ </style>
+
+ <style name="Widget.AppCompat.ListView.DropDown"
+ parent="Widget.AppCompat.Base.ListView.DropDown">
+ </style>
+
+ <style name="Widget.AppCompat.Light.ListView.DropDown"
+ parent="Widget.AppCompat.Light.Base.ListView.DropDown">
+ </style>
+
+ <style name="TextAppearance.Widget.AppCompat.ExpandedMenu.Item"
+ parent="TextAppearance.Widget.AppCompat.Base.ExpandedMenu.Item">
+ </style>
+
+ <style name="Widget.AppCompat.PopupMenu" parent="Widget.AppCompat.Base.PopupMenu">
+ </style>
+
+ <style name="Widget.AppCompat.Light.PopupMenu"
+ parent="Widget.AppCompat.Light.Base.PopupMenu">
+ </style>
+
+ <style name="Widget.AppCompat.ListView.Menu" parent="Widget.AppCompat.Base.ListView.Menu">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.PopupMenu.Large"
+ parent="TextAppearance.AppCompat.Base.Widget.PopupMenu.Large">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.PopupMenu.Small"
+ parent="TextAppearance.AppCompat.Base.Widget.PopupMenu.Small">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Light.Widget.PopupMenu.Large"
+ parent="TextAppearance.AppCompat.Light.Base.Widget.PopupMenu.Large">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Light.Widget.PopupMenu.Small"
+ parent="TextAppearance.AppCompat.Light.Base.Widget.PopupMenu.Small">
+ </style>
+
+</resources>
diff --git a/v7/appcompat/res/values/styles_base.xml b/v7/appcompat/res/values/styles_base.xml
new file mode 100644
index 0000000..2158c65
--- /dev/null
+++ b/v7/appcompat/res/values/styles_base.xml
@@ -0,0 +1,328 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+
+ <!-- Like in themes_base.xml, the namespace "*.AppCompat.Base" is used to
+ define base styles for the platform version. The "*.AppCompat"
+ variants are for direct use or use as parent styles by the app. -->
+ <eat-comment/>
+
+ <style name="Widget.AppCompat.Base.ActionBar" parent="">
+ <item name="displayOptions">useLogo|showHome|showTitle</item>
+ <item name="divider">?attr/dividerVertical</item>
+ <item name="height">?attr/actionBarSize</item>
+ <item name="homeLayout">@layout/abc_action_bar_home</item>
+
+ <item name="titleTextStyle">@style/TextAppearance.AppCompat.Widget.ActionBar.Title</item>
+ <item name="subtitleTextStyle">@style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle
+ </item>
+
+ <item name="background">@drawable/abc_ab_transparent_dark_holo</item>
+ <item name="backgroundStacked">@drawable/abc_ab_stacked_transparent_dark_holo</item>
+ <item name="backgroundSplit">@drawable/abc_ab_bottom_transparent_dark_holo</item>
+
+ <item name="actionButtonStyle">@style/Widget.AppCompat.ActionButton</item>
+ <item name="actionOverflowButtonStyle">@style/Widget.AppCompat.ActionButton.Overflow</item>
+
+ <item name="progressBarStyle">@style/Widget.AppCompat.ProgressBar.Horizontal</item>
+ <item name="indeterminateProgressStyle">@style/Widget.AppCompat.ProgressBar</item>
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionBar" parent="Widget.AppCompat.Base.ActionBar">
+ <item name="background">@drawable/abc_ab_transparent_light_holo</item>
+ <item name="backgroundStacked">@drawable/abc_ab_stacked_transparent_light_holo</item>
+ <item name="backgroundSplit">@drawable/abc_ab_bottom_transparent_light_holo</item>
+
+ <item name="actionButtonStyle">@style/Widget.AppCompat.Light.ActionButton</item>
+ <item name="actionOverflowButtonStyle">@style/Widget.AppCompat.Light.ActionButton.Overflow
+ </item>
+
+ <item name="progressBarStyle">@style/Widget.AppCompat.ProgressBar.Horizontal</item>
+ <item name="indeterminateProgressStyle">@style/Widget.AppCompat.ProgressBar</item>
+ </style>
+
+ <style name="Widget.AppCompat.Base.ActionBar.Solid" parent="Widget.AppCompat.Base.ActionBar">
+ <item name="background">@drawable/abc_ab_solid_dark_holo</item>
+ <item name="backgroundStacked">@drawable/abc_ab_stacked_solid_dark_holo</item>
+ <item name="backgroundSplit">@drawable/abc_ab_bottom_solid_dark_holo</item>
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionBar.Solid"
+ parent="Widget.AppCompat.Light.Base.ActionBar">
+ <item name="background">@drawable/abc_ab_solid_light_holo</item>
+ <item name="backgroundStacked">@drawable/abc_ab_stacked_solid_light_holo</item>
+ <item name="backgroundSplit">@drawable/abc_ab_bottom_solid_light_holo</item>
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionBar.Solid.Inverse"
+ parent="Widget.AppCompat.Base.ActionBar.Solid">
+ <item name="titleTextStyle">
+ @style/TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse
+ </item>
+ <item name="subtitleTextStyle">
+ @style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle.Inverse
+ </item>
+ <item name="actionButtonStyle">@style/Widget.AppCompat.ActionButton</item>
+ <item name="actionOverflowButtonStyle">@style/Widget.AppCompat.ActionButton.Overflow
+ </item>
+ </style>
+
+ <style name="Widget.AppCompat.Base.ActionButton" parent="">
+ <item name="android:background">?attr/actionBarItemBackground</item>
+ <item name="android:paddingLeft">12dip</item>
+ <item name="android:paddingRight">12dip</item>
+ <item name="android:minWidth">@dimen/action_button_min_width</item>
+ <item name="android:minHeight">?attr/actionBarSize</item>
+ <item name="android:gravity">center</item>
+ <item name="android:maxLines">2</item>
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionButton"
+ parent="Widget.AppCompat.Base.ActionButton">
+ </style>
+
+ <style name="Widget.AppCompat.Base.ActionButton.CloseMode"
+ parent="Widget.AppCompat.Base.ActionButton">
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionButton.CloseMode"
+ parent="Widget.AppCompat.Light.Base.ActionButton">
+ </style>
+
+ <style name="Widget.AppCompat.Base.ActionButton.Overflow"
+ parent="Widget.AppCompat.Base.ActionButton">
+ <item name="android:src">@drawable/abc_ic_menu_moreoverflow_normal_holo_dark</item>
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionButton.Overflow"
+ parent="Widget.AppCompat.Light.Base.ActionButton">
+ <item name="android:src">@drawable/abc_ic_menu_moreoverflow_normal_holo_light</item>
+ </style>
+
+ <style name="Widget.AppCompat.Base.ActionBar.TabBar" parent="">
+ <item name="divider">?attr/actionBarDivider</item>
+ <item name="showDividers">middle</item>
+ <item name="dividerPadding">12dip</item>
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionBar.TabBar"
+ parent="Widget.AppCompat.Base.ActionBar.TabBar">
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionBar.TabBar.Inverse"
+ parent="Widget.AppCompat.Light.Base.ActionBar.TabBar">
+ </style>
+
+ <style name="Widget.AppCompat.Base.ActionBar.TabView" parent="">
+ <item name="android:background">@drawable/abc_tab_indicator_ab_holo</item>
+ <item name="android:gravity">center_horizontal</item>
+ <item name="android:paddingLeft">16dip</item>
+ <item name="android:paddingRight">16dip</item>
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionBar.TabView"
+ parent="Widget.AppCompat.Base.ActionBar.TabView">
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionBar.TabView.Inverse"
+ parent="Widget.AppCompat.Light.Base.ActionBar.TabView">
+ </style>
+
+ <style name="Widget.AppCompat.Base.ActionBar.TabText" parent="">
+ <item name="android:textAppearance">@null</item>
+ <item name="android:textColor">?android:attr/textColorPrimaryDisableOnly</item>
+ <item name="android:textSize">12sp</item>
+ <item name="android:textStyle">bold</item>
+ <item name="android:ellipsize">marquee</item>
+ <item name="android:maxLines">2</item>
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionBar.TabText"
+ parent="Widget.AppCompat.Base.ActionBar.TabText">
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionBar.TabText.Inverse"
+ parent="Widget.AppCompat.Light.Base.ActionBar.TabText">
+ <item name="android:textColor">?android:attr/textColorPrimaryInverseDisableOnly</item>
+ </style>
+
+ <style name="Widget.AppCompat.Base.ActionMode" parent="">
+ <item name="background">?attr/actionModeBackground</item>
+ <item name="backgroundSplit">?attr/actionModeSplitBackground</item>
+ <item name="height">?attr/actionBarSize</item>
+ <item name="titleTextStyle">@style/TextAppearance.AppCompat.Widget.ActionMode.Title</item>
+ <item name="subtitleTextStyle">@style/TextAppearance.AppCompat.Widget.ActionMode.Subtitle
+ </item>
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ActionMode.Inverse"
+ parent="Widget.AppCompat.Base.ActionMode">
+ <item name="titleTextStyle">
+ @style/TextAppearance.AppCompat.Widget.ActionMode.Title.Inverse
+ </item>
+ <item name="subtitleTextStyle">
+ @style/TextAppearance.AppCompat.Widget.ActionMode.Subtitle.Inverse
+ </item>
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.ActionMode.Title"
+ parent="android:TextAppearance.Medium">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.ActionMode.Subtitle"
+ parent="android:TextAppearance.Small">
+ <item name="android:textColor">?android:attr/textColorSecondary</item>
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.ActionMode.Title.Inverse"
+ parent="android:TextAppearance.Medium.Inverse">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.ActionMode.Subtitle.Inverse"
+ parent="android:TextAppearance.Small.Inverse">
+ <item name="android:textColor">?android:attr/textColorSecondaryInverse</item>
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.ActionBar.Menu"
+ parent="android:TextAppearance.Small">
+ <item name="android:textSize">12sp</item>
+ <item name="android:textStyle">bold</item>
+ <item name="android:textColor">?attr/actionMenuTextColor</item>
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.ActionBar.Title"
+ parent="android:TextAppearance.Medium">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.ActionBar.Subtitle"
+ parent="android:TextAppearance.Small">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.ActionBar.Title.Inverse"
+ parent="android:TextAppearance.Medium.Inverse">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.ActionBar.Subtitle.Inverse"
+ parent="android:TextAppearance.Small.Inverse">
+ </style>
+
+ <style name="Widget.AppCompat.Base.ProgressBar.Horizontal"
+ parent="android:Widget.ProgressBar.Horizontal">
+ </style>
+
+ <style name="Widget.AppCompat.Base.ProgressBar" parent="android:Widget.ProgressBar">
+ </style>
+
+ <!-- Action Bar Spinner Widgets -->
+
+ <style name="Widget.AppCompat.Base.Spinner" parent="">
+ <item name="spinnerMode">dropdown</item>
+ <item name="android:popupBackground">@drawable/abc_menu_dropdown_panel_holo_dark</item>
+ <item name="android:dropDownSelector">@drawable/abc_list_selector_holo_dark</item>
+ <item name="android:dropDownVerticalOffset">0dip</item>
+ <item name="android:dropDownHorizontalOffset">0dip</item>
+ <item name="android:dropDownWidth">wrap_content</item>
+ <item name="android:gravity">left|center_vertical</item>
+ <item name="android:clickable">true</item>
+ <item name="android:background">@drawable/abc_spinner_ab_holo_dark</item>
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.Spinner" parent="Widget.AppCompat.Base.Spinner">
+ <item name="android:dropDownSelector">@drawable/abc_list_selector_holo_light</item>
+ <item name="android:popupBackground">@drawable/abc_menu_dropdown_panel_holo_light</item>
+ <item name="android:background">@drawable/abc_spinner_ab_holo_light</item>
+ </style>
+
+ <style name="Widget.AppCompat.Base.DropDownItem.Spinner" parent="">
+ <item name="android:textAppearance">@style/TextAppearance.AppCompat.Widget.DropDownItem
+ </item>
+ <item name="android:paddingLeft">8dp</item>
+ <item name="android:paddingRight">8dp</item>
+ <item name="android:gravity">center_vertical</item>
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.DropDownItem.Spinner"
+ parent="Widget.AppCompat.Base.DropDownItem.Spinner">
+ </style>
+
+ <style name="Widget.AppCompat.Base.ListView.DropDown" parent="android:Widget.ListView">
+ <item name="android:listSelector">@drawable/abc_list_selector_holo_dark</item>
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.ListView.DropDown"
+ parent="android:Widget.ListView">
+ <item name="android:listSelector">@drawable/abc_list_selector_holo_light</item>
+ </style>
+
+ <style name="TextAppearance.AppCompat.Widget.Base.DropDownItem"
+ parent="android:TextAppearance.Small">
+ <item name="android:textColor">?android:attr/textColorPrimaryDisableOnly</item>
+ </style>
+
+ <style name="TextAppearance.Widget.AppCompat.Base.ExpandedMenu.Item"
+ parent="android:TextAppearance.Medium">
+ <item name="android:textColor">?android:attr/textColorPrimaryDisableOnly</item>
+ </style>
+
+ <!-- Mimic text appearance in select_dialog_item.xml -->
+ <style name="TextAppearance.AppCompat.Base.CompactMenu.Dialog"
+ parent="android:TextAppearance.Medium">
+ <item name="android:textColor">@android:color/primary_text_light</item>
+ </style>
+
+ <style name="Widget.AppCompat.Base.ListView.Menu" parent="android:Widget.ListView.Menu">
+ <item name="android:listSelector">?attr/listChoiceBackgroundIndicator</item>
+ <item name="android:divider">?attr/dividerHorizontal</item>
+ </style>
+
+ <style name="Widget.AppCompat.Base.PopupMenu" parent="">
+ <item name="android:dropDownSelector">@drawable/abc_list_selector_holo_dark</item>
+ <item name="android:popupBackground">@drawable/abc_menu_dropdown_panel_holo_dark</item>
+ <item name="android:dropDownVerticalOffset">0dip</item>
+ <item name="android:dropDownHorizontalOffset">0dip</item>
+ <item name="android:dropDownWidth">wrap_content</item>
+ </style>
+
+ <style name="Widget.AppCompat.Light.Base.PopupMenu" parent="">
+ <item name="android:dropDownSelector">@drawable/abc_list_selector_holo_light</item>
+ <item name="android:popupBackground">@drawable/abc_menu_dropdown_panel_holo_light</item>
+ <item name="android:dropDownVerticalOffset">0dip</item>
+ <item name="android:dropDownHorizontalOffset">0dip</item>
+ <item name="android:dropDownWidth">wrap_content</item>
+ </style>
+
+ <style name="TextAppearance.AppCompat.Base.Widget.PopupMenu.Large"
+ parent="android:TextAppearance.Widget">
+ <item name="android:textColor">?android:attr/textColorPrimaryDisableOnly</item>
+ <item name="android:textSize">18sp</item>
+ </style>
+
+ <style name="TextAppearance.AppCompat.Base.Widget.PopupMenu.Small"
+ parent="android:TextAppearance.Widget">
+ <item name="android:textColor">?android:attr/textColorPrimaryDisableOnly</item>
+ <item name="android:textSize">14sp</item>
+ </style>
+
+ <style name="TextAppearance.AppCompat.Light.Base.Widget.PopupMenu.Large"
+ parent="TextAppearance.AppCompat.Base.Widget.PopupMenu.Large">
+ </style>
+
+ <style name="TextAppearance.AppCompat.Light.Base.Widget.PopupMenu.Small"
+ parent="TextAppearance.AppCompat.Base.Widget.PopupMenu.Small">
+ </style>
+
+</resources>
diff --git a/v7/appcompat/res/values/themes.xml b/v7/appcompat/res/values/themes.xml
new file mode 100644
index 0000000..9e4ee54
--- /dev/null
+++ b/v7/appcompat/res/values/themes.xml
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+
+ <!-- Themes in the "Theme.AppCompat" family will contain an action bar by default.
+ If Holo themes are available on the current platform version they will be used.
+ A limited Holo-styled action bar will be provided on platform versions older
+ than 3.0. (API 11)
+
+ These theme declarations contain any version-independent specification. Items
+ that need to vary based on platform version should be defined in the corresponding
+ "Theme.Base" theme. -->
+
+ <!-- Platform-independent theme providing an action bar in a dark-themed activity. -->
+ <style name="Theme.AppCompat" parent="Theme.Base.AppCompat">
+
+ <!-- Required for use of support_simple_spinner_dropdown_item.xml -->
+ <item name="spinnerDropDownItemStyle">
+ @style/Widget.AppCompat.DropDownItem.Spinner
+ </item>
+ <item name="dropdownListPreferredItemHeight">?attr/listPreferredItemHeightSmall</item>
+
+ <!-- Popup Menu styles -->
+ <item name="popupMenuStyle">@style/Widget.AppCompat.PopupMenu</item>
+ <item name="textAppearanceLargePopupMenu">
+ @style/TextAppearance.AppCompat.Widget.PopupMenu.Large
+ </item>
+ <item name="textAppearanceSmallPopupMenu">
+ @style/TextAppearance.AppCompat.Widget.PopupMenu.Small
+ </item>
+ </style>
+
+ <!-- Platform-independent theme providing an action bar in a light-themed activity. -->
+ <style name="Theme.AppCompat.Light" parent="Theme.Base.AppCompat.Light">
+
+ <!-- Required for use of support_simple_spinner_dropdown_item.xml -->
+ <item name="spinnerDropDownItemStyle">
+ @style/Widget.AppCompat.Light.DropDownItem.Spinner
+ </item>
+ <item name="dropdownListPreferredItemHeight">?attr/listPreferredItemHeightSmall</item>
+
+ <!-- Popup Menu styles -->
+ <item name="popupMenuStyle">@style/Widget.AppCompat.Light.PopupMenu</item>
+ <item name="textAppearanceLargePopupMenu">
+ @style/TextAppearance.AppCompat.Light.Widget.PopupMenu.Large
+ </item>
+ <item name="textAppearanceSmallPopupMenu">
+ @style/TextAppearance.AppCompat.Light.Widget.PopupMenu.Small
+ </item>
+ </style>
+
+ <!-- Platform-independent theme providing an action bar in a dark-themed activity. -->
+ <style name="Theme.AppCompat.Light.DarkActionBar"
+ parent="Theme.Base.AppCompat.Light.DarkActionBar">
+
+ <!-- Required for use of support_simple_spinner_dropdown_item.xml -->
+ <item name="spinnerDropDownItemStyle">
+ @style/Widget.AppCompat.Light.DropDownItem.Spinner
+ </item>
+ <item name="dropdownListPreferredItemHeight">?attr/listPreferredItemHeightSmall</item>
+
+ <!-- Popup Menu styles -->
+ <item name="popupMenuStyle">@style/Widget.AppCompat.Light.PopupMenu</item>
+ <item name="textAppearanceLargePopupMenu">
+ @style/TextAppearance.AppCompat.Light.Widget.PopupMenu.Large
+ </item>
+ <item name="textAppearanceSmallPopupMenu">
+ @style/TextAppearance.AppCompat.Light.Widget.PopupMenu.Small
+ </item>
+ </style>
+
+
+ <!-- Menu/item attributes -->
+ <style name="Theme.AppCompat.CompactMenu" parent="Theme.AppCompat.Base.CompactMenu">
+ </style>
+
+ <style name="Theme.AppCompat.CompactMenu.Dialog"
+ parent="Theme.AppCompat.Base.CompactMenu.Dialog">
+ </style>
+
+</resources>
diff --git a/v7/appcompat/res/values/themes_base.xml b/v7/appcompat/res/values/themes_base.xml
new file mode 100644
index 0000000..e56cef3
--- /dev/null
+++ b/v7/appcompat/res/values/themes_base.xml
@@ -0,0 +1,198 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+
+ <!-- Themes in the "Theme.Base" family vary based on the current platform
+ version to provide the correct basis on each device. You probably don't
+ want to use them directly in your apps.
+
+ Themes in the "Theme.AppCompat" family are meant to be extended or used
+ directly by apps. -->
+ <eat-comment/>
+
+ <!-- Base platform-dependent theme providing an action bar in a dark-themed activity. -->
+ <style name="Theme.Base.AppCompat" parent="android:Theme">
+ <item name="windowActionBar">true</item>
+ <!-- Remove system title bars; we will add the action bar ourselves. -->
+ <item name="android:windowNoTitle">true</item>
+
+ <item name="buttonBarStyle">@android:style/ButtonBar</item>
+ <item name="buttonBarButtonStyle">@android:style/Widget.Button</item>
+ <item name="selectableItemBackground">@drawable/abc_item_background_holo_dark</item>
+ <item name="homeAsUpIndicator">@drawable/abc_ic_ab_back_holo_dark</item>
+
+ <item name="dividerVertical">@drawable/abc_list_divider_holo_dark</item>
+ <item name="dividerHorizontal">@drawable/abc_list_divider_holo_dark</item>
+
+ <item name="listPreferredItemHeight">?android:attr/listPreferredItemHeight</item>
+ <item name="listPreferredItemHeightSmall">48dp</item>
+ <item name="listPreferredItemHeightLarge">80dp</item>
+ <item name="listPreferredItemPaddingLeft">8dip</item>
+ <item name="listPreferredItemPaddingRight">8dip</item>
+
+ <item name="textAppearanceListItem">?android:attr/textAppearanceMedium</item>
+ <item name="textAppearanceListItemSmall">?android:attr/textAppearanceMedium</item>
+
+ <item name="actionBarTabStyle">@style/Widget.AppCompat.ActionBar.TabView</item>
+ <item name="actionBarTabBarStyle">@style/Widget.AppCompat.ActionBar.TabBar</item>
+ <item name="actionBarTabTextStyle">@style/Widget.AppCompat.ActionBar.TabText</item>
+ <item name="actionButtonStyle">@style/Widget.AppCompat.ActionButton</item>
+ <item name="actionOverflowButtonStyle">@style/Widget.AppCompat.ActionButton.Overflow</item>
+ <item name="actionBarStyle">@style/Widget.AppCompat.ActionBar</item>
+ <item name="actionBarSplitStyle">?attr/actionBarStyle</item>
+ <item name="actionBarWidgetTheme">@null</item>
+ <item name="actionBarSize">@dimen/action_bar_size</item>
+ <item name="actionBarDivider">?attr/dividerVertical</item>
+ <item name="actionBarItemBackground">?attr/selectableItemBackground</item>
+ <item name="actionMenuTextAppearance">
+ @style/TextAppearance.AppCompat.Widget.ActionBar.Menu
+ </item>
+ <item name="actionMenuTextColor">?android:attr/textColorPrimaryDisableOnly</item>
+
+ <!-- Dropdown Spinner Attributes -->
+ <item name="actionDropDownStyle">@style/Widget.AppCompat.Spinner.DropDown.ActionBar</item>
+ <item name="dropDownListViewStyle">@style/Widget.AppCompat.ListView.DropDown</item>
+
+ <!-- Action Mode -->
+ <item name="actionModeStyle">@style/Widget.AppCompat.ActionMode</item>
+ <item name="actionModeBackground">@drawable/abc_cab_background_top_holo_dark</item>
+ <item name="actionModeSplitBackground">@drawable/abc_cab_background_bottom_holo_dark</item>
+ <item name="actionModeCloseDrawable">@drawable/abc_ic_cab_done_holo_dark</item>
+ <item name="actionModeCloseButtonStyle">@style/Widget.AppCompat.ActionButton.CloseMode
+ </item>
+
+ <!-- Panel attributes -->
+ <item name="panelMenuListWidth">@dimen/panel_menu_list_width</item>
+ <item name="panelMenuListTheme">@style/Theme.AppCompat.CompactMenu</item>
+ <item name="android:panelBackground">@drawable/abc_menu_hardkey_panel_holo_dark</item>
+ <item name="listChoiceBackgroundIndicator">@drawable/abc_list_selector_holo_dark</item>
+
+ </style>
+
+ <!-- Base platform-dependent theme providing an action bar in a light-themed activity. -->
+ <style name="Theme.Base.AppCompat.Light" parent="android:Theme.Light">
+ <item name="windowActionBar">true</item>
+ <!-- Remove system title bars; we will add the action bar ourselves. -->
+ <item name="android:windowNoTitle">true</item>
+
+ <item name="buttonBarStyle">@android:style/ButtonBar</item>
+ <item name="buttonBarButtonStyle">@android:style/Widget.Button</item>
+ <item name="selectableItemBackground">@drawable/abc_item_background_holo_light</item>
+ <item name="homeAsUpIndicator">@drawable/abc_ic_ab_back_holo_light</item>
+
+ <item name="dividerVertical">@drawable/abc_list_divider_holo_light</item>
+ <item name="dividerHorizontal">@drawable/abc_list_divider_holo_light</item>
+
+ <item name="listPreferredItemHeight">?android:attr/listPreferredItemHeight</item>
+ <item name="listPreferredItemHeightSmall">48dp</item>
+ <item name="listPreferredItemHeightLarge">80dp</item>
+ <item name="listPreferredItemPaddingLeft">8dip</item>
+ <item name="listPreferredItemPaddingRight">8dip</item>
+
+ <item name="textAppearanceListItem">?android:attr/textAppearanceMedium</item>
+ <item name="textAppearanceListItemSmall">?android:attr/textAppearanceMedium</item>
+
+ <!-- Action Bar Styles -->
+ <item name="actionBarTabStyle">@style/Widget.AppCompat.Light.ActionBar.TabView</item>
+ <item name="actionBarTabBarStyle">@style/Widget.AppCompat.Light.ActionBar.TabBar</item>
+ <item name="actionBarTabTextStyle">@style/Widget.AppCompat.Light.ActionBar.TabText</item>
+ <item name="actionButtonStyle">@style/Widget.AppCompat.Light.ActionButton</item>
+ <item name="actionOverflowButtonStyle">
+ @style/Widget.AppCompat.Light.ActionButton.Overflow
+ </item>
+ <item name="actionBarStyle">@style/Widget.AppCompat.Light.ActionBar</item>
+ <item name="actionBarSplitStyle">?attr/actionBarStyle</item>
+ <item name="actionBarWidgetTheme">@null</item>
+ <item name="actionBarSize">@dimen/action_bar_size</item>
+ <item name="actionBarDivider">?attr/dividerVertical</item>
+ <item name="actionBarItemBackground">?attr/selectableItemBackground</item>
+ <item name="actionMenuTextAppearance">
+ @style/TextAppearance.AppCompat.Widget.ActionBar.Menu
+ </item>
+ <item name="actionMenuTextColor">?android:attr/textColorPrimaryDisableOnly</item>
+
+ <!-- Action Mode -->
+ <item name="actionModeStyle">@style/Widget.AppCompat.ActionMode</item>
+ <item name="actionModeBackground">@drawable/abc_cab_background_top_holo_light</item>
+ <item name="actionModeSplitBackground">@drawable/abc_cab_background_bottom_holo_light</item>
+ <item name="actionModeCloseDrawable">@drawable/abc_ic_cab_done_holo_light</item>
+ <item name="actionModeCloseButtonStyle">@style/Widget.AppCompat.Light.ActionButton.CloseMode
+ </item>
+
+ <!-- Dropdown Spinner Attributes -->
+ <item name="actionDropDownStyle">
+ @style/Widget.AppCompat.Light.Spinner.DropDown.ActionBar
+ </item>
+ <item name="dropDownListViewStyle">
+ @style/Widget.AppCompat.Light.ListView.DropDown
+ </item>
+
+ <!-- Panel attributes -->
+ <item name="panelMenuListWidth">@dimen/panel_menu_list_width</item>
+ <item name="panelMenuListTheme">@style/Theme.AppCompat.CompactMenu</item>
+ <item name="android:panelBackground">@drawable/abc_menu_hardkey_panel_holo_light</item>
+ <item name="listChoiceBackgroundIndicator">@drawable/abc_list_selector_holo_light</item>
+
+ </style>
+
+ <!-- Base platform-dependent theme providing a dark action bar in a light-themed activity. -->
+ <style name="Theme.Base.AppCompat.Light.DarkActionBar" parent="Theme.Base.AppCompat.Light">
+ <item name="homeAsUpIndicator">@drawable/abc_ic_ab_back_holo_dark</item>
+
+ <item name="actionBarStyle">@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse</item>
+ <item name="actionBarWidgetTheme">@style/Theme.AppCompat</item>
+ <item name="actionBarDivider">@drawable/abc_list_divider_holo_dark</item>
+ <item name="actionBarItemBackground">@drawable/abc_item_background_holo_dark</item>
+ <item name="actionBarTabStyle">@style/Widget.AppCompat.Light.ActionBar.TabView.Inverse
+ </item>
+ <item name="actionBarTabBarStyle">@style/Widget.AppCompat.Light.ActionBar.TabBar.Inverse
+ </item>
+ <item name="actionBarTabTextStyle">@style/Widget.AppCompat.Light.ActionBar.TabText.Inverse
+ </item>
+ <item name="actionMenuTextColor">?android:attr/textColorPrimaryInverseDisableOnly</item>
+
+ <!-- Action Mode -->
+ <item name="actionModeStyle">@style/Widget.AppCompat.Light.ActionMode.Inverse</item>
+ <item name="actionModeBackground">@drawable/abc_cab_background_top_holo_dark</item>
+ <item name="actionModeSplitBackground">@drawable/abc_cab_background_bottom_holo_dark</item>
+ <item name="actionModeCloseDrawable">@drawable/abc_ic_cab_done_holo_dark</item>
+ <item name="actionModeCloseButtonStyle">@style/Widget.AppCompat.ActionButton.CloseMode
+ </item>
+
+ <!-- Dropdown Spinner Attributes -->
+ <item name="actionDropDownStyle">@style/Widget.AppCompat.Spinner.DropDown.ActionBar</item>
+
+ <!-- Panel attributes -->
+ <item name="android:panelBackground">@drawable/abc_menu_hardkey_panel_holo_dark</item>
+ <item name="listChoiceBackgroundIndicator">@drawable/abc_list_selector_holo_dark</item>
+
+ </style>
+
+ <!-- Menu/item attributes -->
+ <style name="Theme.AppCompat.Base.CompactMenu" parent="">
+ <item name="android:itemTextAppearance">
+ @style/TextAppearance.Widget.AppCompat.ExpandedMenu.Item</item>
+ <item name="android:listViewStyle">@style/Widget.AppCompat.ListView.Menu</item>
+ </style>
+
+ <style name="Theme.AppCompat.Base.CompactMenu.Dialog" parent="">
+ <item name="android:itemTextAppearance">
+ @style/TextAppearance.AppCompat.Base.CompactMenu.Dialog</item>
+ <item name="android:listViewStyle">@android:style/Widget.ListView.Menu</item>
+ </style>
+
+</resources>
diff --git a/v7/gridlayout/readme b/v7/appcompat/src/.readme
similarity index 100%
copy from v7/gridlayout/readme
copy to v7/appcompat/src/.readme
diff --git a/appcompat/eclair/android/support/appcompat/app/ActionBar.java b/v7/appcompat/src/android/support/v7/app/ActionBar.java
similarity index 98%
rename from appcompat/eclair/android/support/appcompat/app/ActionBar.java
rename to v7/appcompat/src/android/support/v7/app/ActionBar.java
index 686cb90..ee7ed46 100644
--- a/appcompat/eclair/android/support/appcompat/app/ActionBar.java
+++ b/v7/appcompat/src/android/support/v7/app/ActionBar.java
@@ -14,15 +14,14 @@
* limitations under the License.
*/
-package android.support.appcompat.app;
+package android.support.v7.app;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
-import android.support.appcompat.R;
-import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
+import android.support.v7.appcompat.R;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
@@ -40,7 +39,7 @@
* android.R.style#Theme_Holo Holo} theme (or one of its descendant themes), which is the default.
* You may otherwise add the action bar by calling {@link
* android.view.Window#requestFeature requestFeature(FEATURE_ACTION_BAR)} or by declaring it in a
- * custom theme with the {@link android.R.styleable#Theme_windowActionBar windowActionBar} property.
+ * custom theme with the {@link R.styleable#ActionBarWindow_windowActionBar windowActionBar} property.
*
* <p>By default, the action bar shows the application icon on
* the left, followed by the activity title. If your activity has an options menu, you can make
@@ -929,6 +928,10 @@
public LayoutParams(ViewGroup.LayoutParams source) {
super(source);
}
+
+ public android.app.ActionBar.LayoutParams toNative() {
+ return new android.app.ActionBar.LayoutParams(width, height, gravity);
+ }
}
/**
diff --git a/v7/appcompat/src/android/support/v7/app/ActionBarActivity.java b/v7/appcompat/src/android/support/v7/app/ActionBarActivity.java
new file mode 100644
index 0000000..7a6e356
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/app/ActionBarActivity.java
@@ -0,0 +1,499 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.app;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.v4.app.ActivityCompat;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.NavUtils;
+import android.support.v4.app.TaskStackBuilder;
+import android.support.v4.view.WindowCompat;
+import android.support.v7.view.ActionMode;
+import android.support.v7.view.MenuInflater;
+import android.support.v7.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+
+/**
+ * Base class for activities that use the support library action bar features.
+ */
+public class ActionBarActivity extends FragmentActivity implements ActionBar.Callback {
+ ActionBarActivityDelegate mImpl;
+
+ /**
+ * Support library version of {@link Activity#getActionBar}.
+ *
+ * <p>Retrieve a reference to this activity's ActionBar.
+ *
+ * @return The Activity's ActionBar, or null if it does not have one.
+ */
+ public ActionBar getSupportActionBar() {
+ return mImpl.getSupportActionBar();
+ }
+
+ /**
+ * Support library version of {@link Activity#getMenuInflater}.
+ *
+ * <p>Returns a {@link MenuInflater} with this context.
+ *
+ * @return The Activity's menu inflater.
+ */
+ public MenuInflater getSupportMenuInflater() {
+ return mImpl.getSupportMenuInflater();
+ }
+
+ @Override
+ public void setContentView(int layoutResID) {
+ mImpl.setContentView(layoutResID);
+ }
+
+ @Override
+ public void setContentView(View view) {
+ mImpl.setContentView(view);
+ }
+
+ @Override
+ public void setContentView(View view, ViewGroup.LayoutParams params) {
+ mImpl.setContentView(view, params);
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ mImpl = ActionBarActivityDelegate.createDelegate(this);
+ super.onCreate(savedInstanceState);
+ mImpl.onCreate(savedInstanceState);
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ mImpl.onConfigurationChanged(newConfig);
+ }
+
+ @Override
+ public void onStop() {
+ super.onStop();
+ mImpl.onStop();
+ }
+
+ @Override
+ public void onPostResume() {
+ super.onPostResume();
+ mImpl.onPostResume();
+ }
+
+ @Override
+ public boolean onCreatePanelMenu(int featureId, android.view.Menu frameworkMenu) {
+ return mImpl.onCreatePanelMenu(featureId, frameworkMenu);
+ }
+
+ @Override
+ public boolean onPreparePanel(int featureId, View view, android.view.Menu menu) {
+ return mImpl.onPreparePanel(featureId, view, menu);
+ }
+
+ @Override
+ public View onCreatePanelView(int featureId) {
+ if (featureId == Window.FEATURE_OPTIONS_PANEL) {
+ return mImpl.onCreatePanelView(featureId);
+ } else {
+ return super.onCreatePanelView(featureId);
+ }
+ }
+
+ /**
+ * You should override {@link #onCreateSupportOptionsMenu(android.support.v7.view.Menu)} when
+ * using the support Action Bar.
+ */
+ @Override
+ public final boolean onCreateOptionsMenu(android.view.Menu menu) {
+ return false;
+ }
+
+ /**
+ * You should override {@link #onPrepareSupportOptionsMenu(android.support.v7.view.Menu)} when
+ * using the support Action Bar.
+ */
+ @Override
+ public final boolean onPrepareOptionsMenu(android.view.Menu menu) {
+ return false;
+ }
+
+ /**
+ * You should override {@link #onSupportOptionsItemSelected(android.support.v7.view.MenuItem)}
+ * when using the support Action Bar.
+ */
+ @Override
+ public final boolean onOptionsItemSelected(android.view.MenuItem item) {
+ return false;
+ }
+
+ @Override
+ public final boolean onMenuItemSelected(int featureId, android.view.MenuItem item) {
+ if (mImpl.onMenuItemSelected(featureId, item)) {
+ return true;
+ }
+ return super.onMenuItemSelected(featureId, item);
+ }
+
+ @Override
+ protected void onTitleChanged(CharSequence title, int color) {
+ super.onTitleChanged(title, color);
+ mImpl.setTitle(title);
+ }
+
+ /**
+ * Enable extended support library window features.
+ * <p>
+ * This is a convenience for calling
+ * {@link android.view.Window#requestFeature getWindow().requestFeature()}.
+ * </p>
+ *
+ * @param featureId The desired feature as defined in
+ * {@link android.view.Window} or {@link WindowCompat}.
+ * @return Returns true if the requested feature is supported and now enabled.
+ *
+ * @see android.app.Activity#requestWindowFeature
+ * @see android.view.Window#requestFeature
+ */
+ public boolean supportRequestWindowFeature(int featureId) {
+ return mImpl.supportRequestWindowFeature(featureId);
+ }
+
+ @Override
+ public void supportInvalidateOptionsMenu() {
+ // Only call up to super on HC+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
+ super.supportInvalidateOptionsMenu();
+ }
+ mImpl.supportInvalidateOptionsMenu();
+ }
+
+ @Override
+ public final void onActionModeFinished(android.view.ActionMode mode) {
+ mImpl.onActionModeFinished(mode);
+ }
+
+ @Override
+ public final void onActionModeStarted(android.view.ActionMode mode) {
+ mImpl.onActionModeStarted(mode);
+ }
+
+ /**
+ * Notifies the Activity that a support action mode has been started.
+ * Activity subclasses overriding this method should call the superclass implementation.
+ *
+ * @param mode The new action mode.
+ */
+ public void onSupportActionModeStarted(ActionMode mode) {
+ }
+
+ /**
+ * Notifies the activity that a support action mode has finished.
+ * Activity subclasses overriding this method should call the superclass implementation.
+ *
+ * @param mode The action mode that just finished.
+ */
+ public void onSupportActionModeFinished(ActionMode mode) {
+ }
+
+ /**
+ * Support library version of {@link Activity#onPrepareOptionsMenu}.
+ *
+ * <p>Prepare the Screen's standard options menu to be displayed. This is
+ * called right before the menu is shown, every time it is shown. You can
+ * use this method to efficiently enable/disable items or otherwise
+ * dynamically modify the contents.
+ *
+ * <p>The default implementation updates the system menu items based on the
+ * activity's state. Deriving classes should always call through to the
+ * base class implementation.
+ *
+ * @param menu The options menu as last shown or first initialized by
+ * onCreateSupportOptionsMenu().
+ *
+ * @return You must return true for the menu to be displayed;
+ * if you return false it will not be shown.
+ *
+ * @see #onCreateSupportOptionsMenu
+ */
+ public boolean onPrepareSupportOptionsMenu(android.support.v7.view.Menu menu) {
+ return true;
+ }
+
+ /**
+ * Support library version of {@link Activity#onCreateOptionsMenu}.
+ *
+ * <p>Initialize the contents of the Activity's standard options menu. You
+ * should place your menu items in to <var>menu</var>.
+ *
+ * <p>This is only called once, the first time the options menu is
+ * displayed. To update the menu every time it is displayed, see
+ * {@link #onPrepareSupportOptionsMenu}.
+ *
+ * <p>The default implementation populates the menu with standard system
+ * menu items. These are placed in the {@link android.support.v7.view.Menu#CATEGORY_SYSTEM}
+ * group so that they will be correctly ordered with application-defined menu items.
+ * Deriving classes should always call through to the base implementation.
+ *
+ * <p>You can safely hold on to <var>menu</var> (and any items created
+ * from it), making modifications to it as desired, until the next
+ * time onCreateSupportOptionsMenu() is called.
+ *
+ * <p>When you add items to the menu, you can implement the Activity's
+ * {@link #onSupportOptionsItemSelected} method to handle them there.
+ *
+ * @param menu The options menu in which you place your items.
+ *
+ * @return You must return true for the menu to be displayed;
+ * if you return false it will not be shown.
+ *
+ * @see #onPrepareSupportOptionsMenu
+ * @see #onSupportOptionsItemSelected
+ */
+ public boolean onCreateSupportOptionsMenu(android.support.v7.view.Menu menu) {
+ return true;
+ }
+
+ /**
+ * Support library version of {@link Activity#onOptionsItemSelected}.
+ *
+ * <p>This hook is called whenever an item in your options menu is selected.
+ * The default implementation simply returns false to have the normal
+ * processing happen (calling the item's Runnable or sending a message to
+ * its Handler as appropriate). You can use this method for any items
+ * for which you would like to do processing without those other
+ * facilities.
+ *
+ * <p>Derived classes should call through to the base class for it to
+ * perform the default menu handling.</p>
+ *
+ * @param item The menu item that was selected.
+ *
+ * @return boolean Return false to allow normal menu processing to
+ * proceed, true to consume it here.
+ *
+ * @see #onPrepareSupportOptionsMenu
+ * @see #onCreateSupportOptionsMenu
+ */
+ public boolean onSupportOptionsItemSelected(android.support.v7.view.MenuItem item) {
+ return false;
+ }
+
+ /**
+ * Support library version of {@link Activity#onMenuItemSelected}.
+ *
+ * <p>This calls through to the {@link #onSupportOptionsItemSelected}
+ * method for the {@link android.view.Window#FEATURE_OPTIONS_PANEL}
+ * panel, so that subclasses of Activity don't need to deal with feature codes.
+ */
+ public boolean onSupportMenuItemSelected(int featureId, MenuItem item) {
+ switch (featureId) {
+ case Window.FEATURE_OPTIONS_PANEL:
+ if (onSupportOptionsItemSelected(item)) {
+ return true;
+ }
+
+ // FIXME Fix Fragments Menu
+ //if (mFragments.dispatchOptionsItemSelected(item)) {
+ // return true;
+ //}
+
+ ActionBar ab = getSupportActionBar();
+ if (item.getItemId() == android.R.id.home && ab != null &&
+ (ab.getDisplayOptions() & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
+ return onSupportNavigateUp();
+ }
+ return false;
+
+ default:
+ return false;
+ }
+ }
+
+ public ActionMode startSupportActionMode(ActionMode.Callback callback) {
+ return mImpl.startSupportActionMode(callback);
+ }
+
+ void superSetContentView(int resId) {
+ super.setContentView(resId);
+ }
+
+ void superSetContentView(View v) {
+ super.setContentView(v);
+ }
+
+ void superSetContentView(View v, ViewGroup.LayoutParams lp) {
+ super.setContentView(v, lp);
+ }
+
+ void superAddContentView(View v, ViewGroup.LayoutParams lp) {
+ super.addContentView(v, lp);
+ }
+
+ boolean superOnCreatePanelMenu(int featureId, android.view.Menu frameworkMenu) {
+ return super.onCreatePanelMenu(featureId, frameworkMenu);
+ }
+
+ boolean superOnPreparePanelMenu(int featureId, View view, android.view.Menu menu) {
+ return super.onPreparePanel(featureId, view, menu);
+ }
+
+ @Override
+ public void onBackPressed() {
+ if (!mImpl.onBackPressed()) {
+ super.onBackPressed();
+ }
+ }
+
+ /**
+ * Support library version of {@link Activity#setProgressBarVisibility(boolean)}
+ * <p>
+ * Sets the visibility of the progress bar in the title.
+ * <p>
+ * In order for the progress bar to be shown, the feature must be requested
+ * via {@link #supportRequestWindowFeature(int)}.
+ *
+ * @param visible Whether to show the progress bars in the title.
+ */
+ public void setSupportProgressBarVisibility(boolean visible) {
+ mImpl.setSupportProgressBarVisibility(visible);
+ }
+
+ /**
+ * Support library version of {@link Activity#setProgressBarIndeterminateVisibility(boolean)}
+ * <p>
+ * Sets the visibility of the indeterminate progress bar in the title.
+ * <p>
+ * In order for the progress bar to be shown, the feature must be requested
+ * via {@link #supportRequestWindowFeature(int)}.
+ *
+ * @param visible Whether to show the progress bars in the title.
+ */
+ public void setSupportProgressBarIndeterminateVisibility(boolean visible) {
+ mImpl.setSupportProgressBarIndeterminateVisibility(visible);
+ }
+
+ /**
+ * Support library version of {@link Activity#setProgressBarIndeterminate(boolean)}
+ * <p>
+ * Sets whether the horizontal progress bar in the title should be indeterminate (the
+ * circular is always indeterminate).
+ * <p>
+ * In order for the progress bar to be shown, the feature must be requested
+ * via {@link #supportRequestWindowFeature(int)}.
+ *
+ * @param indeterminate Whether the horizontal progress bar should be indeterminate.
+ */
+ public void setSupportProgressBarIndeterminate(boolean indeterminate) {
+ mImpl.setSupportProgressBarIndeterminate(indeterminate);
+ }
+
+ /**
+ * Support library version of {@link Activity#setProgress(int)}.
+ * <p>
+ * Sets the progress for the progress bars in the title.
+ * <p>
+ * In order for the progress bar to be shown, the feature must be requested
+ * via {@link #supportRequestWindowFeature(int)}.
+ *
+ * @param progress The progress for the progress bar. Valid ranges are from
+ * 0 to 10000 (both inclusive). If 10000 is given, the progress
+ * bar will be completely filled and will fade out.
+ */
+ public void setSupportProgress(int progress) {
+ mImpl.setSupportProgress(progress);
+ }
+
+ /**
+ * Support version of {@link #onCreateNavigateUpTaskStack(android.app.TaskStackBuilder)}.
+ * This method will be called on all platform versions.
+ *
+ * Define the synthetic task stack that will be generated during Up navigation from
+ * a different task.
+ *
+ * <p>The default implementation of this method adds the parent chain of this activity
+ * as specified in the manifest to the supplied {@link TaskStackBuilder}. Applications
+ * may choose to override this method to construct the desired task stack in a different
+ * way.</p>
+ *
+ * <p>This method will be invoked by the default implementation of {@link #onNavigateUp()}
+ * if {@link #shouldUpRecreateTask(Intent)} returns true when supplied with the intent
+ * returned by {@link #getParentActivityIntent()}.</p>
+ *
+ * <p>Applications that wish to supply extra Intent parameters to the parent stack defined
+ * by the manifest should override
+ * {@link #onPrepareSupportNavigateUpTaskStack(TaskStackBuilder)}.</p>
+ *
+ * @param builder An empty TaskStackBuilder - the application should add intents representing
+ * the desired task stack
+ */
+ public void onCreateSupportNavigateUpTaskStack(TaskStackBuilder builder) {
+ builder.addParentStack(this);
+ }
+
+ /**
+ * Support version of {@link #onPrepareNavigateUpTaskStack(android.app.TaskStackBuilder)}.
+ * This method will be called on all platform versions.
+ *
+ * Prepare the synthetic task stack that will be generated during Up navigation
+ * from a different task.
+ *
+ * <p>This method receives the {@link TaskStackBuilder} with the constructed series of
+ * Intents as generated by {@link #onCreateSupportNavigateUpTaskStack(TaskStackBuilder)}.
+ * If any extra data should be added to these intents before launching the new task,
+ * the application should override this method and add that data here.</p>
+ *
+ * @param builder A TaskStackBuilder that has been populated with Intents by
+ * onCreateNavigateUpTaskStack.
+ */
+ public void onPrepareSupportNavigateUpTaskStack(TaskStackBuilder builder) {
+ }
+
+ public boolean onSupportNavigateUp() {
+ Intent upIntent = NavUtils.getParentActivityIntent(this);
+
+ if (upIntent != null) {
+ if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
+ TaskStackBuilder b = TaskStackBuilder.create(this);
+ onCreateSupportNavigateUpTaskStack(b);
+ onPrepareSupportNavigateUpTaskStack(b);
+ b.startActivities();
+
+ try {
+ ActivityCompat.finishAffinity(this);
+ } catch (IllegalStateException e) {
+ // This can only happen on 4.1+, when we don't have a parent or a result set.
+ // In that case we should just finish().
+ finish();
+ }
+ } else {
+ // This activity is part of the application's task, so simply
+ // navigate up to the hierarchical parent activity.
+ NavUtils.navigateUpTo(this, upIntent);
+ }
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/v7/appcompat/src/android/support/v7/app/ActionBarActivityDelegate.java b/v7/appcompat/src/android/support/v7/app/ActionBarActivityDelegate.java
new file mode 100644
index 0000000..b86993f
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/app/ActionBarActivityDelegate.java
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.app;
+
+import android.content.Context;
+import android.content.pm.ActivityInfo;
+import android.content.pm.PackageManager;
+import android.content.res.Configuration;
+import android.content.res.TypedArray;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.v7.appcompat.R;
+import android.support.v7.internal.view.SupportMenuInflater;
+import android.support.v7.view.ActionMode;
+import android.support.v7.view.MenuInflater;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+
+abstract class ActionBarActivityDelegate {
+
+ static final String METADATA_UI_OPTIONS = "android.support.UI_OPTIONS";
+ static final String UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW = "splitActionBarWhenNarrow";
+
+ private static final String TAG = "ActionBarActivityDelegate";
+
+ static ActionBarActivityDelegate createDelegate(ActionBarActivity activity) {
+ final int version = Build.VERSION.SDK_INT;
+ if (version >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ return new ActionBarActivityDelegateICS(activity);
+ } else if (version >= Build.VERSION_CODES.HONEYCOMB) {
+ return new ActionBarActivityDelegateHC(activity);
+ } else {
+ return new ActionBarActivityDelegateCompat(activity);
+ }
+ }
+
+ final ActionBarActivity mActivity;
+
+ private ActionBar mActionBar;
+ private MenuInflater mMenuInflater;
+
+ // true if this activity has an action bar.
+ boolean mHasActionBar;
+ // true if this activity's action bar overlays other activity content.
+ boolean mOverlayActionBar;
+
+ ActionBarActivityDelegate(ActionBarActivity activity) {
+ mActivity = activity;
+ }
+
+ abstract ActionBar createSupportActionBar();
+
+ final ActionBar getSupportActionBar() {
+ // The Action Bar should be lazily created as mHasActionBar or mOverlayActionBar
+ // could change after onCreate
+ if (mHasActionBar || mOverlayActionBar) {
+ if (mActionBar == null) {
+ mActionBar = createSupportActionBar();
+ }
+ } else {
+ // If we're not set to have a Action Bar, null it just in case it's been set
+ mActionBar = null;
+ }
+ return mActionBar;
+ }
+
+ MenuInflater getSupportMenuInflater() {
+ if (mMenuInflater == null) {
+ mMenuInflater = new SupportMenuInflater(mActivity);
+ }
+ return mMenuInflater;
+ }
+
+ void onCreate(Bundle savedInstanceState) {
+ TypedArray a = mActivity.obtainStyledAttributes(R.styleable.ActionBarWindow);
+
+ if (!a.hasValue(R.styleable.ActionBarWindow_windowActionBar)) {
+ a.recycle();
+ throw new IllegalStateException(
+ "You need to use a Theme.AppCompat theme (or descendant) with this activity.");
+ }
+
+ mHasActionBar = a.getBoolean(R.styleable.ActionBarWindow_windowActionBar, false);
+ mOverlayActionBar = a.getBoolean(R.styleable.ActionBarWindow_windowActionBarOverlay, false);
+ a.recycle();
+ }
+
+ abstract void onConfigurationChanged(Configuration newConfig);
+
+ abstract void onStop();
+
+ abstract void onPostResume();
+
+ abstract void setContentView(View v);
+
+ abstract void setContentView(int resId);
+
+ abstract void setContentView(View v, ViewGroup.LayoutParams lp);
+
+ abstract void addContentView(View v, ViewGroup.LayoutParams lp);
+
+ abstract void setTitle(CharSequence title);
+
+ abstract void supportInvalidateOptionsMenu();
+
+ abstract boolean supportRequestWindowFeature(int featureId);
+
+ // Methods used to create and respond to options menu
+ abstract View onCreatePanelView(int featureId);
+
+ abstract boolean onCreatePanelMenu(int featureId, android.view.Menu frameworkMenu);
+
+ abstract boolean onMenuItemSelected(int featureId, android.view.MenuItem frameworkItem);
+
+ abstract boolean onPreparePanel(int featureId, View view, android.view.Menu frameworkMenu);
+
+ abstract boolean onBackPressed();
+
+ abstract ActionMode startSupportActionMode(ActionMode.Callback callback);
+
+ abstract void onActionModeFinished(android.view.ActionMode mode);
+
+ abstract void onActionModeStarted(android.view.ActionMode mode);
+
+ abstract void setSupportProgressBarVisibility(boolean visible) ;
+
+ abstract void setSupportProgressBarIndeterminateVisibility(boolean visible);
+
+ abstract void setSupportProgressBarIndeterminate(boolean indeterminate);
+
+ abstract void setSupportProgress(int progress);
+
+ protected final String getUiOptionsFromMetadata() {
+ try {
+ PackageManager pm = mActivity.getPackageManager();
+ ActivityInfo info = pm.getActivityInfo(mActivity.getComponentName(),
+ PackageManager.GET_META_DATA);
+
+ String uiOptions = null;
+ if (info.metaData != null) {
+ uiOptions = info.metaData.getString(METADATA_UI_OPTIONS);
+ }
+ return uiOptions;
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.e(TAG, "getUiOptionsFromMetadata: Activity '" + mActivity.getClass()
+ .getSimpleName() + "' not in manifest");
+ return null;
+ }
+ }
+
+ protected final Context getActionBarThemedContext() {
+ Context context = mActivity;
+
+ // If we have an action bar, initialize the menu with a context themed from it.
+ ActionBar ab = getSupportActionBar();
+ if (ab != null) {
+ context = ab.getThemedContext();
+ }
+ return context;
+ }
+
+}
diff --git a/v7/appcompat/src/android/support/v7/app/ActionBarActivityDelegateCompat.java b/v7/appcompat/src/android/support/v7/app/ActionBarActivityDelegateCompat.java
new file mode 100644
index 0000000..7b0ef75
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/app/ActionBarActivityDelegateCompat.java
@@ -0,0 +1,615 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.app;
+
+import android.content.Context;
+import android.content.res.Configuration;
+import android.content.res.TypedArray;
+import android.support.v4.view.WindowCompat;
+import android.support.v7.appcompat.R;
+import android.support.v7.internal.view.menu.ListMenuPresenter;
+import android.support.v7.internal.view.menu.MenuBuilder;
+import android.support.v7.internal.view.menu.MenuPresenter;
+import android.support.v7.internal.view.menu.MenuView;
+import android.support.v7.internal.widget.ActionBarContainer;
+import android.support.v7.internal.widget.ActionBarContextView;
+import android.support.v7.internal.widget.ActionBarView;
+import android.support.v7.internal.widget.ProgressBarICS;
+import android.support.v7.view.ActionMode;
+import android.support.v7.view.Menu;
+import android.support.v7.view.MenuItem;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+
+class ActionBarActivityDelegateCompat extends ActionBarActivityDelegate implements
+ MenuPresenter.Callback, MenuBuilder.Callback, ActionBarView.Callback {
+
+ private ActionBarView mActionBarView;
+ private ListMenuPresenter mListMenuPresenter;
+ private MenuBuilder mMenu;
+
+ private ActionMode mActionMode;
+
+ // true if we have installed a window sub-decor layout.
+ private boolean mSubDecorInstalled;
+
+ // Used to keep track of Progress Bar Window features
+ private boolean mFeatureProgress, mFeatureIndeterminateProgress;
+
+ private boolean mInvalidateMenuPosted;
+ private final Runnable mInvalidateMenuRunnable = new Runnable() {
+ @Override
+ public void run() {
+ final MenuBuilder menu = createMenu();
+ if (dispatchCreateSupportOptionsMenu(menu) &&
+ dispatchPrepareSupportOptionsMenu(menu)) {
+ setMenu(menu);
+ } else {
+ setMenu(null);
+ }
+
+ mInvalidateMenuPosted = false;
+ }
+ };
+
+ ActionBarActivityDelegateCompat(ActionBarActivity activity) {
+ super(activity);
+ }
+
+ @Override
+ public ActionBar createSupportActionBar() {
+ return new ActionBarImplCompat(mActivity, mActivity);
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ // If this is called before sub-decor is installed, ActionBar will not
+ // be properly initialized.
+ if (mHasActionBar && mSubDecorInstalled) {
+ // Note: The action bar will need to access
+ // view changes from superclass.
+ ActionBarImplCompat actionBar = (ActionBarImplCompat) getSupportActionBar();
+ actionBar.onConfigurationChanged(newConfig);
+ }
+ }
+
+ @Override
+ public void onStop() {
+ ActionBarImplCompat ab = (ActionBarImplCompat) getSupportActionBar();
+ if (ab != null) {
+ ab.setShowHideAnimationEnabled(false);
+ }
+ }
+
+ @Override
+ public void onPostResume() {
+ ActionBarImplCompat ab = (ActionBarImplCompat) getSupportActionBar();
+ if (ab != null) {
+ ab.setShowHideAnimationEnabled(true);
+ }
+ }
+
+ @Override
+ public void setContentView(View v) {
+ ensureSubDecor();
+ if (mHasActionBar) {
+ final ViewGroup contentParent =
+ (ViewGroup) mActivity.findViewById(R.id.action_bar_activity_content);
+ contentParent.removeAllViews();
+ contentParent.addView(v);
+ } else {
+ mActivity.superSetContentView(v);
+ }
+ }
+
+ @Override
+ public void setContentView(int resId) {
+ ensureSubDecor();
+ if (mHasActionBar) {
+ final ViewGroup contentParent =
+ (ViewGroup) mActivity.findViewById(R.id.action_bar_activity_content);
+ contentParent.removeAllViews();
+ final LayoutInflater inflater = mActivity.getLayoutInflater();
+ inflater.inflate(resId, contentParent);
+ } else {
+ mActivity.superSetContentView(resId);
+ }
+ }
+
+ @Override
+ public void setContentView(View v, ViewGroup.LayoutParams lp) {
+ ensureSubDecor();
+ if (mHasActionBar) {
+ final ViewGroup contentParent =
+ (ViewGroup) mActivity.findViewById(R.id.action_bar_activity_content);
+ contentParent.removeAllViews();
+ contentParent.addView(v, lp);
+ } else {
+ mActivity.superSetContentView(v, lp);
+ }
+ }
+
+ @Override
+ public void addContentView(View v, ViewGroup.LayoutParams lp) {
+ ensureSubDecor();
+ if (mHasActionBar) {
+ final ViewGroup contentParent =
+ (ViewGroup) mActivity.findViewById(R.id.action_bar_activity_content);
+ contentParent.addView(v, lp);
+ } else {
+ mActivity.superSetContentView(v, lp);
+ }
+ }
+
+ private void ensureSubDecor() {
+ if (mHasActionBar && !mSubDecorInstalled) {
+ if (mOverlayActionBar) {
+ mActivity.superSetContentView(R.layout.abc_action_bar_decor_overlay);
+ } else {
+ mActivity.superSetContentView(R.layout.abc_action_bar_decor);
+ }
+ mActionBarView = (ActionBarView) mActivity.findViewById(R.id.action_bar);
+ mActionBarView.setViewCallback(this);
+
+ /**
+ * Progress Bars
+ */
+ if (mFeatureProgress) {
+ mActionBarView.initProgress();
+ }
+ if (mFeatureIndeterminateProgress) {
+ mActionBarView.initIndeterminateProgress();
+ }
+
+ /**
+ * Split Action Bar
+ */
+ boolean splitWhenNarrow = UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW
+ .equals(getUiOptionsFromMetadata());
+ boolean splitActionBar;
+
+ if (splitWhenNarrow) {
+ splitActionBar = mActivity.getResources()
+ .getBoolean(R.bool.split_action_bar_is_narrow);
+ } else {
+ TypedArray a = mActivity.obtainStyledAttributes(R.styleable.ActionBarWindow);
+ splitActionBar = a
+ .getBoolean(R.styleable.ActionBarWindow_windowSplitActionBar, false);
+ a.recycle();
+ }
+
+ final ActionBarContainer splitView = (ActionBarContainer) mActivity.findViewById(
+ R.id.split_action_bar);
+ if (splitView != null) {
+ mActionBarView.setSplitView(splitView);
+ mActionBarView.setSplitActionBar(splitActionBar);
+ mActionBarView.setSplitWhenNarrow(splitWhenNarrow);
+
+ final ActionBarContextView cab = (ActionBarContextView) mActivity.findViewById(
+ R.id.action_context_bar);
+ cab.setSplitView(splitView);
+ cab.setSplitActionBar(splitActionBar);
+ cab.setSplitWhenNarrow(splitWhenNarrow);
+ }
+
+ mSubDecorInstalled = true;
+
+ supportInvalidateOptionsMenu();
+ }
+ }
+
+ @Override
+ public boolean supportRequestWindowFeature(int featureId) {
+ switch (featureId) {
+ case WindowCompat.FEATURE_ACTION_BAR:
+ mHasActionBar = true;
+ return true;
+ case WindowCompat.FEATURE_ACTION_BAR_OVERLAY:
+ mOverlayActionBar = true;
+ return true;
+ case Window.FEATURE_PROGRESS:
+ mFeatureProgress = true;
+ return true;
+ case Window.FEATURE_INDETERMINATE_PROGRESS:
+ mFeatureIndeterminateProgress = true;
+ return true;
+ default:
+ return mActivity.requestWindowFeature(featureId);
+ }
+ }
+
+ @Override
+ public void setTitle(CharSequence title) {
+ ActionBar ab = getSupportActionBar();
+ if (ab != null) {
+ ab.setTitle(title);
+ }
+ }
+
+ @Override
+ public View onCreatePanelView(int featureId) {
+ View createdPanelView = null;
+
+ if (featureId == Window.FEATURE_OPTIONS_PANEL) {
+ boolean show = true;
+ MenuBuilder menu = mMenu;
+
+ if (mActionMode == null) {
+ // We only want to dispatch Activity/Fragment menu calls if there isn't
+ // currently an action mode
+
+ if (menu == null) {
+ // We don't have a menu created, so create one
+ menu = createMenu();
+ setMenu(menu);
+
+ // Make sure we're not dispatching item changes to presenters
+ menu.stopDispatchingItemsChanged();
+ // Dispatch onCreateSupportOptionsMenu
+ show = dispatchCreateSupportOptionsMenu(menu);
+ }
+
+ if (show) {
+ // Make sure we're not dispatching item changes to presenters
+ menu.stopDispatchingItemsChanged();
+ // Dispatch onPrepareSupportOptionsMenu
+ show = dispatchPrepareSupportOptionsMenu(menu);
+ }
+ }
+
+ if (show) {
+ createdPanelView = (View) getListMenuView(mActivity, this);
+
+ // Allow menu to start dispatching changes to presenters
+ menu.startDispatchingItemsChanged();
+ } else {
+ // If the menu isn't being shown, we no longer need it
+ setMenu(null);
+ }
+ }
+
+ return createdPanelView;
+ }
+
+ @Override
+ public boolean onCreatePanelMenu(int featureId, android.view.Menu frameworkMenu) {
+ if (Window.FEATURE_OPTIONS_PANEL != featureId) {
+ return mActivity.superOnCreatePanelMenu(featureId, frameworkMenu);
+ }
+
+ // Should never get here as FEATURE_OPTIONS_PANEL is handled by onCreatePanelView
+ return false;
+ }
+
+ @Override
+ public boolean onPreparePanel(int featureId, View view, android.view.Menu menu) {
+ if (Window.FEATURE_OPTIONS_PANEL != featureId) {
+ return mActivity.superOnPreparePanelMenu(featureId, view, menu);
+ }
+
+ // Should never get here as FEATURE_OPTIONS_PANEL is handled by onCreatePanelView
+ return false;
+ }
+
+ @Override
+ public boolean onMenuItemSelected(int featureId, android.view.MenuItem frameworkItem) {
+ // We don't want to handle framework items here
+ return false;
+ }
+
+ @Override
+ public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) {
+ return mActivity.onSupportMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item);
+ }
+
+ @Override
+ public void onMenuModeChange(MenuBuilder menu) {
+ reopenMenu(menu, true);
+ }
+
+ @Override
+ public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
+ mActivity.closeOptionsMenu();
+ }
+
+ @Override
+ public boolean onOpenSubMenu(MenuBuilder subMenu) {
+ return false;
+ }
+
+ @Override
+ public ActionMode startSupportActionMode(ActionMode.Callback callback) {
+ if (callback == null) {
+ throw new IllegalArgumentException("ActionMode callback can not be null.");
+ }
+
+ if (mActionMode != null) {
+ mActionMode.finish();
+ }
+
+ final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapper(callback);
+
+ ActionBarImplCompat ab = (ActionBarImplCompat) getSupportActionBar();
+ if (ab != null) {
+ mActionMode = ab.startActionMode(wrappedCallback);
+ }
+
+ if (mActionMode != null) {
+ mActivity.onSupportActionModeStarted(mActionMode);
+ }
+ return mActionMode;
+ }
+
+ @Override
+ public void supportInvalidateOptionsMenu() {
+ if (!mInvalidateMenuPosted) {
+ mInvalidateMenuPosted = true;
+ mActivity.getWindow().getDecorView().post(mInvalidateMenuRunnable);
+ }
+ }
+
+ private MenuBuilder createMenu() {
+ MenuBuilder menu = new MenuBuilder(getActionBarThemedContext());
+ menu.setCallback(this);
+ return menu;
+ }
+
+ private void reopenMenu(MenuBuilder menu, boolean toggleMenuMode) {
+ if (mActionBarView != null && mActionBarView.isOverflowReserved()) {
+ if (!mActionBarView.isOverflowMenuShowing() || !toggleMenuMode) {
+ if (mActionBarView.getVisibility() == View.VISIBLE) {
+ mActionBarView.showOverflowMenu();
+ }
+ } else {
+ mActionBarView.hideOverflowMenu();
+ }
+ return;
+ }
+
+ menu.close();
+ }
+
+ private MenuView getListMenuView(Context context, MenuPresenter.Callback cb) {
+ if (mMenu == null) {
+ return null;
+ }
+
+ if (mListMenuPresenter == null) {
+ TypedArray a = context.obtainStyledAttributes(R.styleable.Theme);
+ final int listPresenterTheme = a.getResourceId(
+ R.styleable.Theme_panelMenuListTheme,
+ R.style.Theme_AppCompat_CompactMenu);
+ a.recycle();
+
+ mListMenuPresenter = new ListMenuPresenter(
+ R.layout.abc_list_menu_item_layout, listPresenterTheme);
+ mListMenuPresenter.setCallback(cb);
+ mMenu.addMenuPresenter(mListMenuPresenter);
+ } else {
+ // Make sure we update the ListView
+ mListMenuPresenter.updateMenuView(false);
+ }
+
+ return mListMenuPresenter.getMenuView(null);
+ }
+
+ private void setMenu(MenuBuilder menu) {
+ if (menu == mMenu) {
+ return;
+ }
+
+ if (mMenu != null) {
+ mMenu.removeMenuPresenter(mListMenuPresenter);
+ }
+ mMenu = menu;
+
+ if (menu != null && mListMenuPresenter != null) {
+ // Only update list menu if there isn't an action mode menu
+ menu.addMenuPresenter(mListMenuPresenter);
+ }
+ if (mActionBarView != null) {
+ mActionBarView.setMenu(menu, this);
+ }
+ }
+
+ @Override
+ public boolean onBackPressed() {
+ // Back cancels action modes first.
+ if (mActionMode != null) {
+ mActionMode.finish();
+ return true;
+ }
+
+ // Next collapse any expanded action views.
+ if (mActionBarView != null && mActionBarView.hasExpandedActionView()) {
+ mActionBarView.collapseActionView();
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ public void onActionModeStarted(android.view.ActionMode mode) {
+ // Will never be called
+ }
+
+ @Override
+ void setSupportProgressBarVisibility(boolean visible) {
+ updateProgressBars(visible ? Window.PROGRESS_VISIBILITY_ON :
+ Window.PROGRESS_VISIBILITY_OFF);
+ }
+
+ @Override
+ void setSupportProgressBarIndeterminateVisibility(boolean visible) {
+ updateProgressBars(visible ? Window.PROGRESS_VISIBILITY_ON :
+ Window.PROGRESS_VISIBILITY_OFF);
+ }
+
+ @Override
+ void setSupportProgressBarIndeterminate(boolean indeterminate) {
+ updateProgressBars(indeterminate ? Window.PROGRESS_INDETERMINATE_ON
+ : Window.PROGRESS_INDETERMINATE_OFF);
+ }
+
+ @Override
+ void setSupportProgress(int progress) {
+ updateProgressBars(Window.PROGRESS_START + progress);
+ }
+
+ @Override
+ public void onActionModeFinished(android.view.ActionMode mode) {
+ // Will never be called
+ }
+
+ private boolean dispatchCreateSupportOptionsMenu(MenuBuilder menu) {
+ // Allow activity to inflate menu contents
+ boolean show = mActivity.onCreateSupportOptionsMenu(menu);
+
+ // FIXME: Reintroduce support options menu dispatch through facade.
+ //show |= mActivity.mFragments.dispatchCreateSupportOptionsMenu(menu,
+ // mActivity.getCompatMenuInflater());
+
+ return show;
+ }
+
+ private boolean dispatchPrepareSupportOptionsMenu(MenuBuilder menu) {
+ boolean goforit = mActivity.onPrepareSupportOptionsMenu(menu);
+ // FIXME: Reintroduce support options menu dispatch through facade.
+ //goforit |= mActivity.mFragments.dispatchPrepareSupportOptionsMenu(menu);
+ return goforit;
+ }
+
+ /**
+ * Progress Bar function. Mostly extracted from PhoneWindow.java
+ */
+ private void updateProgressBars(int value) {
+ ProgressBarICS circularProgressBar = getCircularProgressBar();
+ ProgressBarICS horizontalProgressBar = getHorizontalProgressBar();
+
+ if (value == Window.PROGRESS_VISIBILITY_ON) {
+ if (mFeatureProgress) {
+ int level = horizontalProgressBar.getProgress();
+ int visibility = (horizontalProgressBar.isIndeterminate() || level < 10000) ?
+ View.VISIBLE : View.INVISIBLE;
+ horizontalProgressBar.setVisibility(visibility);
+ }
+ if (mFeatureIndeterminateProgress) {
+ circularProgressBar.setVisibility(View.VISIBLE);
+ }
+ } else if (value == Window.PROGRESS_VISIBILITY_OFF) {
+ if (mFeatureProgress) {
+ horizontalProgressBar.setVisibility(View.GONE);
+ }
+ if (mFeatureIndeterminateProgress) {
+ circularProgressBar.setVisibility(View.GONE);
+ }
+ } else if (value == Window.PROGRESS_INDETERMINATE_ON) {
+ horizontalProgressBar.setIndeterminate(true);
+ } else if (value == Window.PROGRESS_INDETERMINATE_OFF) {
+ horizontalProgressBar.setIndeterminate(false);
+ } else if (Window.PROGRESS_START <= value && value <= Window.PROGRESS_END) {
+ // We want to set the progress value before testing for visibility
+ // so that when the progress bar becomes visible again, it has the
+ // correct level.
+ horizontalProgressBar.setProgress(value - Window.PROGRESS_START);
+
+ if (value < Window.PROGRESS_END) {
+ showProgressBars(horizontalProgressBar, circularProgressBar);
+ } else {
+ hideProgressBars(horizontalProgressBar, circularProgressBar);
+ }
+ }
+ }
+
+ private void showProgressBars(ProgressBarICS horizontalProgressBar,
+ ProgressBarICS spinnyProgressBar) {
+ if (mFeatureIndeterminateProgress && spinnyProgressBar.getVisibility() == View.INVISIBLE) {
+ spinnyProgressBar.setVisibility(View.VISIBLE);
+ }
+ // Only show the progress bars if the primary progress is not complete
+ if (mFeatureProgress && horizontalProgressBar.getProgress() < 10000) {
+ horizontalProgressBar.setVisibility(View.VISIBLE);
+ }
+ }
+
+ private void hideProgressBars(ProgressBarICS horizontalProgressBar,
+ ProgressBarICS spinnyProgressBar) {
+ if (mFeatureIndeterminateProgress && spinnyProgressBar.getVisibility() == View.VISIBLE) {
+ spinnyProgressBar.setVisibility(View.INVISIBLE);
+ }
+ if (mFeatureProgress && horizontalProgressBar.getVisibility() == View.VISIBLE) {
+ horizontalProgressBar.setVisibility(View.INVISIBLE);
+ }
+ }
+
+ private ProgressBarICS getCircularProgressBar() {
+ ProgressBarICS pb = (ProgressBarICS) mActionBarView.findViewById(R.id.progress_circular);
+ if (pb != null) {
+ pb.setVisibility(View.INVISIBLE);
+ }
+ return pb;
+ }
+
+ private ProgressBarICS getHorizontalProgressBar() {
+ ProgressBarICS pb = (ProgressBarICS) mActionBarView.findViewById(R.id.progress_horizontal);
+ if (pb != null) {
+ pb.setVisibility(View.INVISIBLE);
+ }
+ return pb;
+ }
+
+ /**
+ * From ActionBarView.Callback
+ */
+ @Override
+ public boolean onMenuItemSelected(int featureId, android.support.v7.view.MenuItem item) {
+ return mActivity.onSupportMenuItemSelected(featureId, item);
+ }
+
+ /**
+ * Clears out internal reference when the action mode is destroyed.
+ */
+ private class ActionModeCallbackWrapper implements ActionMode.Callback {
+ private ActionMode.Callback mWrapped;
+
+ public ActionModeCallbackWrapper(ActionMode.Callback wrapped) {
+ mWrapped = wrapped;
+ }
+
+ public boolean onCreateActionMode(ActionMode mode, Menu menu) {
+ return mWrapped.onCreateActionMode(mode, menu);
+ }
+
+ public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
+ return mWrapped.onPrepareActionMode(mode, menu);
+ }
+
+ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
+ return mWrapped.onActionItemClicked(mode, item);
+ }
+
+ public void onDestroyActionMode(ActionMode mode) {
+ mWrapped.onDestroyActionMode(mode);
+ mActivity.onSupportActionModeFinished(mode);
+ mActionMode = null;
+ }
+ }
+
+}
diff --git a/v7/appcompat/src/android/support/v7/app/ActionBarActivityDelegateHC.java b/v7/appcompat/src/android/support/v7/app/ActionBarActivityDelegateHC.java
new file mode 100644
index 0000000..3a9bd1a
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/app/ActionBarActivityDelegateHC.java
@@ -0,0 +1,206 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.app;
+
+import android.content.Context;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.support.v4.view.WindowCompat;
+import android.support.v7.internal.view.ActionModeWrapper;
+import android.support.v7.internal.view.menu.MenuWrapper;
+import android.support.v7.view.ActionMode;
+import android.support.v7.view.Menu;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+
+class ActionBarActivityDelegateHC extends ActionBarActivityDelegate {
+
+ Menu mMenu;
+
+ ActionBarActivityDelegateHC(ActionBarActivity activity) {
+ super(activity);
+ }
+
+ @Override
+ public ActionBar createSupportActionBar() {
+ return new ActionBarImplHC(mActivity, mActivity);
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ if (mHasActionBar) {
+ // If action bar is requested by inheriting from the appcompat theme,
+ // the system will not know about that. So explicitly request for an action bar.
+ mActivity.requestWindowFeature(WindowCompat.FEATURE_ACTION_BAR);
+ }
+ if (mOverlayActionBar) {
+ mActivity.requestWindowFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY);
+ }
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ }
+
+ @Override
+ public void onStop() {
+ }
+
+ @Override
+ public void onPostResume() {
+ }
+
+ @Override
+ public void setContentView(View v) {
+ mActivity.superSetContentView(v);
+ }
+
+ @Override
+ public void setContentView(int resId) {
+ mActivity.superSetContentView(resId);
+ }
+
+ @Override
+ public void setContentView(View v, ViewGroup.LayoutParams lp) {
+ mActivity.superSetContentView(v, lp);
+ }
+
+ @Override
+ public void addContentView(View v, ViewGroup.LayoutParams lp) {
+ mActivity.superAddContentView(v, lp);
+ }
+
+ @Override
+ public boolean supportRequestWindowFeature(int featureId) {
+ return mActivity.requestWindowFeature(featureId);
+ }
+
+ @Override
+ public View onCreatePanelView(int featureId) {
+ // Do not create custom options menu on HC+
+ return null;
+ }
+
+ @Override
+ public boolean onCreatePanelMenu(int featureId, android.view.Menu frameworkMenu) {
+ if (featureId == Window.FEATURE_OPTIONS_PANEL) {
+ // This is a boundary where we transition from framework Menu objects to support
+ // library Menu objects.
+ if (mMenu == null) {
+ mMenu = MenuWrapper.createMenuWrapper(frameworkMenu);
+ }
+ boolean show = mActivity.onCreateSupportOptionsMenu(mMenu);
+ // FIXME: Reintroduce support options menu dispatch through facade.
+ //show |= mActivity.mFragments.dispatchCreateSupportOptionsMenu(mMenu,
+ // mActivity.getCompatMenuInflater());
+ return show;
+ } else {
+ return mActivity.superOnCreatePanelMenu(featureId, frameworkMenu);
+ }
+ }
+
+ @Override
+ public boolean onMenuItemSelected(int featureId, android.view.MenuItem frameworkItem) {
+ return mActivity.onSupportMenuItemSelected(featureId,
+ MenuWrapper.createMenuItemWrapper(frameworkItem));
+ }
+
+ @Override
+ public boolean onPreparePanel(int featureId, View view, android.view.Menu menu) {
+ if (featureId == Window.FEATURE_OPTIONS_PANEL && mMenu != null) {
+ boolean goforit = mActivity.onPrepareSupportOptionsMenu(mMenu);
+ // FIXME: Reintroduce support options menu dispatch through facade.
+ //goforit |= mActivity.mFragments.dispatchPrepareSupportOptionsMenu(mMenu);
+ return goforit;
+ } else {
+ return mActivity.superOnPreparePanelMenu(featureId, view, menu);
+ }
+ }
+
+ @Override
+ public void setTitle(CharSequence title) {
+ // Handled by framework
+ }
+
+ @Override
+ public ActionMode startSupportActionMode(ActionMode.Callback callback) {
+ if (callback == null) {
+ throw new IllegalArgumentException("ActionMode callback can not be null.");
+ }
+
+ Context context = getActionBarThemedContext();
+
+ ActionModeWrapper.CallbackWrapper wrappedCallback = new ActionModeWrapper.CallbackWrapper(
+ context, callback);
+ ActionModeWrapper wrappedMode = null;
+
+ android.view.ActionMode frameworkMode = mActivity.startActionMode(wrappedCallback);
+
+ if (frameworkMode != null) {
+ wrappedMode = new ActionModeWrapper(context,
+ mActivity.startActionMode(wrappedCallback));
+ wrappedCallback.setLastStartedActionMode(wrappedMode);
+ }
+
+ return wrappedMode;
+ }
+
+ @Override
+ public void onActionModeStarted(android.view.ActionMode mode) {
+ mActivity.onSupportActionModeStarted(
+ new ActionModeWrapper(getActionBarThemedContext(), mode));
+ }
+
+ @Override
+ void setSupportProgressBarVisibility(boolean visible) {
+ mActivity.setProgressBarVisibility(visible);
+ }
+
+ @Override
+ void setSupportProgressBarIndeterminateVisibility(boolean visible) {
+ mActivity.setProgressBarIndeterminateVisibility(visible);
+ }
+
+ @Override
+ void setSupportProgressBarIndeterminate(boolean indeterminate) {
+ mActivity.setProgressBarIndeterminate(indeterminate);
+ }
+
+ @Override
+ void setSupportProgress(int progress) {
+ mActivity.setProgress(progress);
+ }
+
+ @Override
+ public void onActionModeFinished(android.view.ActionMode mode) {
+ mActivity.onSupportActionModeFinished(
+ new ActionModeWrapper(getActionBarThemedContext(), mode));
+ }
+
+ @Override
+ public void supportInvalidateOptionsMenu() {
+ }
+
+ @Override
+ public boolean onBackPressed() {
+ return false;
+ }
+
+}
diff --git a/v7/appcompat/src/android/support/v7/app/ActionBarActivityDelegateICS.java b/v7/appcompat/src/android/support/v7/app/ActionBarActivityDelegateICS.java
new file mode 100644
index 0000000..efb3745
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/app/ActionBarActivityDelegateICS.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.app;
+
+import android.content.pm.ActivityInfo;
+import android.os.Bundle;
+
+class ActionBarActivityDelegateICS extends ActionBarActivityDelegateHC {
+
+ ActionBarActivityDelegateICS(ActionBarActivity activity) {
+ super(activity);
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ // Set framework uiOptions from the support metadata value
+ if (UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW.equals(getUiOptionsFromMetadata())) {
+ mActivity.getWindow().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW,
+ ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);
+ }
+
+ super.onCreate(savedInstanceState);
+ }
+
+ @Override
+ public ActionBar createSupportActionBar() {
+ return new ActionBarImplICS(mActivity, mActivity);
+ }
+
+}
diff --git a/appcompat/eclair/android/support/appcompat/app/ActionBarImplCompat.java b/v7/appcompat/src/android/support/v7/app/ActionBarImplCompat.java
similarity index 72%
rename from appcompat/eclair/android/support/appcompat/app/ActionBarImplCompat.java
rename to v7/appcompat/src/android/support/v7/app/ActionBarImplCompat.java
index 72e6fae..1d79334 100644
--- a/appcompat/eclair/android/support/appcompat/app/ActionBarImplCompat.java
+++ b/v7/appcompat/src/android/support/v7/app/ActionBarImplCompat.java
@@ -14,39 +14,46 @@
* limitations under the License.
*/
-package android.support.appcompat.app;
+package android.support.v7.app;
import android.app.Dialog;
import android.content.Context;
+import android.content.res.Configuration;
+import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Handler;
-import android.support.appcompat.view.ActionMode;
-import android.support.appcompat.view.Menu;
-import android.support.appcompat.view.MenuItem;
-import android.support.appcompat.view.menu.MenuBuilder;
-import android.support.appcompat.view.menu.SubMenuBuilder;
-import android.support.appcompat.widget.ActionBarContainer;
-import android.support.appcompat.widget.ActionBarContextView;
-import android.support.appcompat.widget.ActionBarOverlayLayout;
-import android.support.appcompat.widget.ActionBarView;
-import android.support.appcompat.widget.ScrollingTabContainerView;
-import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
+import android.support.v7.appcompat.R;
+import android.support.v7.internal.view.ActionBarPolicy;
+import android.support.v7.view.ActionMode;
+import android.support.v7.internal.view.SupportMenuInflater;
+import android.support.v7.internal.view.menu.MenuBuilder;
+import android.support.v7.internal.view.menu.SubMenuBuilder;
+import android.support.v7.internal.widget.ActionBarContainer;
+import android.support.v7.internal.widget.ActionBarContextView;
+import android.support.v7.internal.widget.ActionBarOverlayLayout;
+import android.support.v7.internal.widget.ActionBarView;
+import android.support.v7.internal.widget.ScrollingTabContainerView;
+import android.support.v7.view.Menu;
+import android.support.v7.view.MenuInflater;
+import android.support.v7.view.MenuItem;
+import android.util.TypedValue;
+import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
-import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
import android.widget.SpinnerAdapter;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
-public class ActionBarImplCompat extends ActionBar {
-
+class ActionBarImplCompat extends ActionBar {
private Context mContext;
private Context mThemedContext;
- private FragmentActivity mActivity;
+ private ActionBarActivity mActivity;
private Dialog mDialog;
private ActionBarOverlayLayout mOverlayLayout;
@@ -91,16 +98,81 @@
private boolean mShowingForMode;
private boolean mNowShowing = true;
-
- // TODO: What to do about animations?
- // private Animator mCurrentShowAnim;
private boolean mShowHideAnimationEnabled;
private Callback mCallback;
- public ActionBarImplCompat(FragmentActivity activity, Callback callback) {
+ public ActionBarImplCompat(ActionBarActivity activity, Callback callback) {
mActivity = activity;
+ mContext = activity;
mCallback = callback;
+ init(mActivity);
+ }
+
+ private void init(ActionBarActivity activity) {
+ mOverlayLayout = (ActionBarOverlayLayout) activity.findViewById(
+ R.id.action_bar_overlay_layout);
+ if (mOverlayLayout != null) {
+ mOverlayLayout.setActionBar(this);
+ }
+ mActionView = (ActionBarView) activity.findViewById(R.id.action_bar);
+ mContextView = (ActionBarContextView) activity.findViewById(R.id.action_context_bar);
+ mContainerView = (ActionBarContainer) activity.findViewById(R.id.action_bar_container);
+ mTopVisibilityView = (ViewGroup) activity.findViewById(R.id.top_action_bar);
+ if (mTopVisibilityView == null) {
+ mTopVisibilityView = mContainerView;
+ }
+ mSplitView = (ActionBarContainer) activity.findViewById(R.id.split_action_bar);
+
+ if (mActionView == null || mContextView == null || mContainerView == null) {
+ throw new IllegalStateException(getClass().getSimpleName() + " can only be used " +
+ "with a compatible window decor layout");
+ }
+
+ mActionView.setContextView(mContextView);
+ mContextDisplayMode = mActionView.isSplitActionBar() ?
+ CONTEXT_DISPLAY_SPLIT : CONTEXT_DISPLAY_NORMAL;
+
+ // This was initially read from the action bar style
+ final int current = mActionView.getDisplayOptions();
+ final boolean homeAsUp = (current & DISPLAY_HOME_AS_UP) != 0;
+ if (homeAsUp) {
+ mDisplayHomeAsUpSet = true;
+ }
+
+ ActionBarPolicy abp = ActionBarPolicy.get(mContext);
+ setHomeButtonEnabled(abp.enableHomeButtonByDefault() || homeAsUp);
+ setHasEmbeddedTabs(abp.hasEmbeddedTabs());
+ setTitle(mActivity.getTitle());
+ }
+
+ public void onConfigurationChanged(Configuration newConfig) {
+ setHasEmbeddedTabs(ActionBarPolicy.get(mContext).hasEmbeddedTabs());
+ }
+
+ private void setHasEmbeddedTabs(boolean hasEmbeddedTabs) {
+ mHasEmbeddedTabs = hasEmbeddedTabs;
+ // Switch tab layout configuration if needed
+ if (!mHasEmbeddedTabs) {
+ mActionView.setEmbeddedTabView(null);
+ mContainerView.setTabContainer(mTabScrollView);
+ } else {
+ mContainerView.setTabContainer(null);
+ mActionView.setEmbeddedTabView(mTabScrollView);
+ }
+ final boolean isInTabMode = getNavigationMode() == NAVIGATION_MODE_TABS;
+ if (mTabScrollView != null) {
+ if (isInTabMode) {
+ mTabScrollView.setVisibility(View.VISIBLE);
+ } else {
+ mTabScrollView.setVisibility(View.GONE);
+ }
+ }
+ mActionView.setCollapsable(!mHasEmbeddedTabs && isInTabMode);
+ }
+
+ public boolean hasNonEmbeddedTabs() {
+ return !mHasEmbeddedTabs && getNavigationMode() == NAVIGATION_MODE_TABS;
}
@Override
@@ -427,6 +499,23 @@
}
@Override
+ public Context getThemedContext() {
+ if (mThemedContext == null) {
+ TypedValue outValue = new TypedValue();
+ Resources.Theme currentTheme = mContext.getTheme();
+ currentTheme.resolveAttribute(R.attr.actionBarWidgetTheme, outValue, true);
+ final int targetThemeRes = outValue.resourceId;
+
+ if (targetThemeRes != 0) {
+ mThemedContext = new ContextThemeWrapper(mContext, targetThemeRes);
+ } else {
+ mThemedContext = mContext;
+ }
+ }
+ return mThemedContext;
+ }
+
+ @Override
public int getHeight() {
return mContainerView.getHeight();
}
@@ -439,6 +528,13 @@
}
}
+ private void showForActionMode() {
+ if (!mShowingForMode) {
+ mShowingForMode = true;
+ updateVisibility(false);
+ }
+ }
+
@Override
public void hide() {
if (!mHiddenByApp) {
@@ -447,6 +543,13 @@
}
}
+ private void hideForActionMode() {
+ if (mShowingForMode) {
+ mShowingForMode = false;
+ updateVisibility(false);
+ }
+ }
+
@Override
public boolean isShowing() {
return mNowShowing;
@@ -462,6 +565,46 @@
mMenuVisibilityListeners.remove(listener);
}
+ public ActionMode startActionMode(ActionMode.Callback callback) {
+ if (mActionMode != null) {
+ mActionMode.finish();
+ }
+
+ mContextView.killMode();
+ ActionModeImpl mode = new ActionModeImpl(callback);
+ if (mode.dispatchOnCreate()) {
+ mode.invalidate();
+ mContextView.initForMode(mode);
+ animateToMode(true);
+ if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) {
+ if (mSplitView.getVisibility() != View.VISIBLE) {
+ mSplitView.setVisibility(View.VISIBLE);
+ if (mOverlayLayout != null) {
+ mOverlayLayout.requestFitSystemWindows();
+ }
+ }
+ }
+ mContextView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
+ mActionMode = mode;
+ return mode;
+ }
+ return null;
+ }
+
+ void animateToMode(boolean toActionMode) {
+ if (toActionMode) {
+ showForActionMode();
+ } else {
+ hideForActionMode();
+ }
+
+ mActionView.animateToVisibility(toActionMode ? View.INVISIBLE : View.VISIBLE);
+ mContextView.animateToVisibility(toActionMode ? View.VISIBLE : View.GONE);
+ if (mTabScrollView != null && !mActionView.hasEmbeddedTabs() && mActionView.isCollapsed()) {
+ mTabScrollView.setVisibility(toActionMode ? View.GONE : View.VISIBLE);
+ }
+ }
+
/**
* @hide
*/
@@ -588,11 +731,7 @@
}
}
- /**
- * @hide
- */
- //public class ActionModeImpl extends ActionMode implements MenuBuilder.Callback {
- public class ActionModeImpl extends ActionMode implements MenuBuilder.Callback {
+ class ActionModeImpl extends ActionMode implements MenuBuilder.Callback {
private ActionMode.Callback mCallback;
private MenuBuilder mMenu;
@@ -607,7 +746,7 @@
@Override
public MenuInflater getMenuInflater() {
- return new MenuInflater(getThemedContext());
+ return new SupportMenuInflater(getThemedContext());
}
@Override
@@ -635,7 +774,7 @@
mCallback.onDestroyActionMode(this);
}
mCallback = null;
- //animateToMode(false);
+ animateToMode(false);
// Clear out the context mode views after the animation finishes
mContextView.closeMode();
@@ -646,7 +785,7 @@
@Override
public void invalidate() {
- //mMenu.stopDispatchingItemsChanged();
+ mMenu.stopDispatchingItemsChanged();
try {
mCallback.onPrepareActionMode(this, mMenu);
} finally {
@@ -659,7 +798,7 @@
try {
return mCallback.onCreateActionMode(this, mMenu);
} finally {
- //mMenu.startDispatchingItemsChanged();
+ mMenu.startDispatchingItemsChanged();
}
}
@@ -760,10 +899,6 @@
}
}
- /**
- * TODO(trevorjohns): Methods below this line were missing! **********************************
- */
-
private void ensureTabsExist() {
if (mTabScrollView != null) {
return;
@@ -846,13 +981,57 @@
}
}
+ public void setShowHideAnimationEnabled(boolean enabled) {
+ mShowHideAnimationEnabled = enabled;
+ if (!enabled) {
+ mTopVisibilityView.clearAnimation();
+ if (mSplitView != null) {
+ mSplitView.clearAnimation();
+ }
+ }
+ }
+
public void doShow(boolean fromSystem) {
- // TODO(trevorjohns): Animation removed from doShow/doHide. Verify that this is correct.
+ mTopVisibilityView.clearAnimation();
+ if (mTopVisibilityView.getVisibility() == View.VISIBLE) {
+ return;
+ }
+
+ if (mShowHideAnimationEnabled) {
+ Animation anim = AnimationUtils.loadAnimation(mContext, R.anim.abc_slide_in_top);
+ mTopVisibilityView.startAnimation(anim);
+ }
mTopVisibilityView.setVisibility(View.VISIBLE);
+
+ if (mSplitView != null && mSplitView.getVisibility() != View.VISIBLE) {
+ if (mShowHideAnimationEnabled) {
+ Animation anim = AnimationUtils.loadAnimation(mContext, R.anim.abc_slide_in_bottom);
+ mSplitView.startAnimation(anim);
+ }
+ mSplitView.setVisibility(View.VISIBLE);
+ }
}
public void doHide(boolean fromSystem) {
- mTopVisibilityView.setVisibility(View.INVISIBLE);
+ mTopVisibilityView.clearAnimation();
+ if (mTopVisibilityView.getVisibility() == View.GONE) {
+ return;
+ }
+
+ if (mShowHideAnimationEnabled) {
+ Animation anim = AnimationUtils.loadAnimation(mContext, R.anim.abc_slide_out_top);
+ mTopVisibilityView.startAnimation(anim);
+ }
+ mTopVisibilityView.setVisibility(View.GONE);
+
+ if (mSplitView != null && mSplitView.getVisibility() != View.GONE) {
+ if (mShowHideAnimationEnabled) {
+ Animation anim = AnimationUtils
+ .loadAnimation(mContext, R.anim.abc_slide_out_bottom);
+ mSplitView.startAnimation(anim);
+ }
+ mSplitView.setVisibility(View.GONE);
+ }
}
}
diff --git a/appcompat/honeycomb/android/support/appcompat/app/ActionBarImplHC.java b/v7/appcompat/src/android/support/v7/app/ActionBarImplHC.java
similarity index 82%
rename from appcompat/honeycomb/android/support/appcompat/app/ActionBarImplHC.java
rename to v7/appcompat/src/android/support/v7/app/ActionBarImplHC.java
index a525987..cf74f29 100644
--- a/appcompat/honeycomb/android/support/appcompat/app/ActionBarImplHC.java
+++ b/v7/appcompat/src/android/support/v7/app/ActionBarImplHC.java
@@ -14,11 +14,13 @@
* limitations under the License.
*/
-package android.support.appcompat.app;
+package android.support.v7.app;
import android.app.Activity;
+import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v4.app.FragmentTransaction;
+import android.util.Log;
import android.view.View;
import android.widget.SpinnerAdapter;
@@ -27,9 +29,9 @@
class ActionBarImplHC extends ActionBar {
- Activity mActivity;
- Callback mCallback;
- android.app.ActionBar mActionBar;
+ final Activity mActivity;
+ final Callback mCallback;
+ final android.app.ActionBar mActionBar;
private ArrayList<WeakReference<OnMenuVisibilityListenerWrapper>> mAddedMenuVisWrappers =
new ArrayList<WeakReference<OnMenuVisibilityListenerWrapper>>();
@@ -70,37 +72,33 @@
@Override
public void setCustomView(int resId) {
- // TODO: do layoutparams translation
mActionBar.setCustomView(resId);
}
@Override
public void setIcon(int resId) {
- // TODO compatibility impl?
- //mActionBar.setIcon(resId);
+ Log.i("ActionBarCompat", "setIcon() is not available when running on Honeycomb devices.");
}
@Override
public void setIcon(Drawable icon) {
- // TODO compatibility impl?
- //mActionBar.setIcon(icon);
+ Log.i("ActionBarCompat", "setIcon() is not available when running on Honeycomb devices.");
}
@Override
public void setLogo(int resId) {
- // TODO compatibility impl?
- //mActionBar.setLogo(resId);
+ Log.i("ActionBarCompat", "setLogo() is not available when running on Honeycomb devices.");
}
@Override
public void setLogo(Drawable logo) {
- // TODO compatibility impl?
- //mActionBar.setLogo(logo);
+ Log.i("ActionBarCompat", "setLogo() is not available when running on Honeycomb devices.");
}
@Override
public void setListNavigationCallbacks(SpinnerAdapter adapter, OnNavigationListener callback) {
- mActionBar.setListNavigationCallbacks(adapter, new OnNavigationListenerWrapper(callback));
+ mActionBar.setListNavigationCallbacks(adapter,
+ callback != null ? new OnNavigationListenerWrapper(callback) : null);
}
@Override
@@ -223,7 +221,7 @@
@Override
public void addTab(Tab tab, boolean setSelected) {
- mActionBar.addTab(((TabWrapper) tab).mWrappedTab);
+ mActionBar.addTab(((TabWrapper) tab).mWrappedTab, setSelected);
}
@Override
@@ -272,6 +270,12 @@
}
@Override
+ public Context getThemedContext() {
+ // v11 doesn't have the actionBarWidgetTheme attr, so just use the Activity
+ return mActivity;
+ }
+
+ @Override
public int getHeight() {
return mActionBar.getHeight();
}
@@ -293,9 +297,11 @@
@Override
public void addOnMenuVisibilityListener(OnMenuVisibilityListener listener) {
- OnMenuVisibilityListenerWrapper w = new OnMenuVisibilityListenerWrapper(listener);
- mAddedMenuVisWrappers.add(new WeakReference<OnMenuVisibilityListenerWrapper>(w));
- mActionBar.addOnMenuVisibilityListener(w);
+ if (listener != null) {
+ OnMenuVisibilityListenerWrapper w = new OnMenuVisibilityListenerWrapper(listener);
+ mAddedMenuVisWrappers.add(new WeakReference<OnMenuVisibilityListenerWrapper>(w));
+ mActionBar.addOnMenuVisibilityListener(w);
+ }
}
@Override
@@ -335,12 +341,13 @@
}
- class TabWrapper extends ActionBar.Tab {
+ class TabWrapper extends ActionBar.Tab implements android.app.ActionBar.TabListener {
final android.app.ActionBar.Tab mWrappedTab;
private Object mTag;
private FragmentTransaction mActiveTransaction;
private CharSequence mContentDescription;
+ private TabListener mTabListener;
public TabWrapper(android.app.ActionBar.Tab tab) {
mWrappedTab = tab;
@@ -415,16 +422,14 @@
@Override
public Tab setTabListener(TabListener listener) {
- mWrappedTab.setTabListener(new TabListenerWrapper(listener));
+ mTabListener = listener;
+ mWrappedTab.setTabListener(listener != null ? this : null);
return this;
}
@Override
public void select() {
- mActiveTransaction = mCallback.getSupportFragmentManager().beginTransaction();
mWrappedTab.select();
- mActiveTransaction.commit();
- mActiveTransaction = null;
}
@Override
@@ -444,36 +449,39 @@
return mContentDescription;
}
- }
-
- class TabListenerWrapper implements android.app.ActionBar.TabListener {
-
- private final TabListener mWrappedListener;
-
- public TabListenerWrapper(TabListener l) {
- mWrappedListener = l;
- }
-
@Override
public void onTabSelected(android.app.ActionBar.Tab tab,
android.app.FragmentTransaction ft) {
- final TabWrapper wrappedTab = (TabWrapper) tab.getTag();
- mWrappedListener.onTabSelected(wrappedTab, wrappedTab.mActiveTransaction);
+ mTabListener.onTabSelected(this, ft != null ? getActiveTransaction() : null);
+ commitActiveTransaction();
}
@Override
public void onTabUnselected(android.app.ActionBar.Tab tab,
android.app.FragmentTransaction ft) {
- final TabWrapper wrappedTab = (TabWrapper) tab.getTag();
- mWrappedListener.onTabUnselected(wrappedTab, wrappedTab.mActiveTransaction);
+ mTabListener.onTabUnselected(this, ft != null ? getActiveTransaction() : null);
}
@Override
public void onTabReselected(android.app.ActionBar.Tab tab,
android.app.FragmentTransaction ft) {
- final TabWrapper wrappedTab = (TabWrapper) tab.getTag();
- mWrappedListener.onTabReselected(wrappedTab, wrappedTab.mActiveTransaction);
+ mTabListener.onTabReselected(this, ft != null ? getActiveTransaction() : null);
+ commitActiveTransaction();
}
+ private FragmentTransaction getActiveTransaction() {
+ if (mActiveTransaction == null) {
+ mActiveTransaction = mCallback.getSupportFragmentManager().beginTransaction()
+ .disallowAddToBackStack();
+ }
+ return mActiveTransaction;
+ }
+
+ private void commitActiveTransaction() {
+ if (mActiveTransaction != null && !mActiveTransaction.isEmpty()) {
+ mActiveTransaction.commit();
+ }
+ mActiveTransaction = null;
+ }
}
}
diff --git a/v7/appcompat/src/android/support/v7/app/ActionBarImplICS.java b/v7/appcompat/src/android/support/v7/app/ActionBarImplICS.java
new file mode 100644
index 0000000..d2e3f6f
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/app/ActionBarImplICS.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.app;
+
+import android.app.Activity;
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+
+class ActionBarImplICS extends ActionBarImplHC {
+
+ public ActionBarImplICS(Activity activity, Callback callback) {
+ super(activity, callback);
+ }
+
+ @Override
+ public Context getThemedContext() {
+ return mActionBar.getThemedContext();
+ }
+
+ @Override
+ public void setIcon(int resId) {
+ mActionBar.setIcon(resId);
+ }
+
+ @Override
+ public void setIcon(Drawable icon) {
+ mActionBar.setIcon(icon);
+ }
+
+ @Override
+ public void setLogo(int resId) {
+ mActionBar.setLogo(resId);
+ }
+
+ @Override
+ public void setLogo(Drawable logo) {
+ mActionBar.setLogo(logo);
+ }
+
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/ActionBarPolicy.java b/v7/appcompat/src/android/support/v7/internal/view/ActionBarPolicy.java
similarity index 97%
rename from appcompat/eclair/android/support/appcompat/view/ActionBarPolicy.java
rename to v7/appcompat/src/android/support/v7/internal/view/ActionBarPolicy.java
index df1176f..3b5e593 100644
--- a/appcompat/eclair/android/support/appcompat/view/ActionBarPolicy.java
+++ b/v7/appcompat/src/android/support/v7/internal/view/ActionBarPolicy.java
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-package android.support.appcompat.view;
+package android.support.v7.internal.view;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
-import android.support.appcompat.R;
+import android.support.v7.appcompat.R;
/**
* Allows components to query for various configuration policy decisions about how the action bar
diff --git a/v7/appcompat/src/android/support/v7/internal/view/ActionModeWrapper.java b/v7/appcompat/src/android/support/v7/internal/view/ActionModeWrapper.java
new file mode 100644
index 0000000..620ef93
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/internal/view/ActionModeWrapper.java
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.internal.view;
+
+import android.content.Context;
+import android.support.v7.internal.view.menu.MenuWrapper;
+import android.support.v7.view.ActionMode;
+import android.support.v7.view.Menu;
+import android.support.v7.view.MenuInflater;
+import android.view.View;
+
+/**
+ * @hide
+ */
+public class ActionModeWrapper extends ActionMode {
+
+ final MenuInflater mInflater;
+ final android.view.ActionMode mWrappedObject;
+
+ public ActionModeWrapper(Context context, android.view.ActionMode frameworkActionMode) {
+ mWrappedObject = frameworkActionMode;
+ mInflater = new SupportMenuInflater(context);
+ }
+
+ @Override
+ public Object getTag() {
+ return mWrappedObject.getTag();
+ }
+
+ @Override
+ public void setTag(Object tag) {
+ mWrappedObject.setTag(tag);
+ }
+
+ @Override
+ public boolean getTitleOptionalHint() {
+ return mWrappedObject.getTitleOptionalHint();
+ }
+
+ @Override
+ public void setTitleOptionalHint(boolean titleOptional) {
+ mWrappedObject.setTitleOptionalHint(titleOptional);
+ }
+
+ @Override
+ public boolean isTitleOptional() {
+ return mWrappedObject.isTitleOptional();
+ }
+
+ @Override
+ public void setTitle(CharSequence title) {
+ mWrappedObject.setTitle(title);
+ }
+
+ @Override
+ public void setSubtitle(CharSequence subtitle) {
+ mWrappedObject.setSubtitle(subtitle);
+ }
+
+ @Override
+ public void invalidate() {
+ mWrappedObject.invalidate();
+ }
+
+ @Override
+ public void finish() {
+ mWrappedObject.finish();
+ }
+
+ @Override
+ public Menu getMenu() {
+ return MenuWrapper.createMenuWrapper(mWrappedObject.getMenu());
+ }
+
+ @Override
+ public CharSequence getTitle() {
+ return mWrappedObject.getTitle();
+ }
+
+ @Override
+ public void setTitle(int resId) {
+ mWrappedObject.setTitle(resId);
+ }
+
+ @Override
+ public CharSequence getSubtitle() {
+ return mWrappedObject.getSubtitle();
+ }
+
+ @Override
+ public void setSubtitle(int resId) {
+ mWrappedObject.setSubtitle(resId);
+ }
+
+ @Override
+ public View getCustomView() {
+ return mWrappedObject.getCustomView();
+ }
+
+ @Override
+ public void setCustomView(View view) {
+ mWrappedObject.setCustomView(view);
+ }
+
+ @Override
+ public MenuInflater getMenuInflater() {
+ return mInflater;
+ }
+
+ /**
+ * @hide
+ */
+ public static class CallbackWrapper implements android.view.ActionMode.Callback {
+ final Callback mWrappedCallback;
+ final Context mContext;
+
+ private ActionModeWrapper mLastStartedActionMode;
+
+ public CallbackWrapper(Context context, Callback supportCallback) {
+ mContext = context;
+ mWrappedCallback = supportCallback;
+ }
+
+ @Override
+ public boolean onCreateActionMode(android.view.ActionMode mode, android.view.Menu menu) {
+ return mWrappedCallback.onCreateActionMode(getActionModeWrapper(mode),
+ MenuWrapper.createMenuWrapper(menu));
+ }
+
+ @Override
+ public boolean onPrepareActionMode(android.view.ActionMode mode, android.view.Menu menu) {
+ return mWrappedCallback.onPrepareActionMode(getActionModeWrapper(mode),
+ MenuWrapper.createMenuWrapper(menu));
+ }
+
+ @Override
+ public boolean onActionItemClicked(android.view.ActionMode mode,
+ android.view.MenuItem item) {
+ return mWrappedCallback.onActionItemClicked(getActionModeWrapper(mode),
+ MenuWrapper.createMenuItemWrapper(item));
+ }
+
+ @Override
+ public void onDestroyActionMode(android.view.ActionMode mode) {
+ mWrappedCallback.onDestroyActionMode(getActionModeWrapper(mode));
+ }
+
+ public void setLastStartedActionMode(ActionModeWrapper modeWrapper) {
+ mLastStartedActionMode = modeWrapper;
+ }
+
+ private ActionMode getActionModeWrapper(android.view.ActionMode mode) {
+ if (mLastStartedActionMode != null && mLastStartedActionMode.mWrappedObject == mode) {
+ // If the given mode equals our wrapped mode, just return it
+ return mLastStartedActionMode;
+ } else {
+ return new ActionModeWrapper(mContext, mode);
+ }
+ }
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/CollapsibleActionView.java b/v7/appcompat/src/android/support/v7/internal/view/CollapsibleActionView.java
similarity index 78%
rename from appcompat/eclair/android/support/appcompat/view/CollapsibleActionView.java
rename to v7/appcompat/src/android/support/v7/internal/view/CollapsibleActionView.java
index d924e69..410b123 100644
--- a/appcompat/eclair/android/support/appcompat/view/CollapsibleActionView.java
+++ b/v7/appcompat/src/android/support/v7/internal/view/CollapsibleActionView.java
@@ -14,29 +14,29 @@
* limitations under the License.
*/
-package android.support.appcompat.view;
+package android.support.v7.internal.view;
-import android.support.appcompat.view.MenuItem.OnActionExpandListener;
+import android.support.v7.view.MenuItem.OnActionExpandListener;
/**
* When a {@link View} implements this interface it will receive callbacks when expanded or
* collapsed as an action view alongside the optional, app-specified callbacks to {@link
* OnActionExpandListener}.
*
- * <p>See {@link MenuItem} for more information about action views. See {@link
+ * <p>See {@link android.support.v4.view.MenuItem} for more information about action views. See {@link
* android.app.ActionBar} for more information about the action bar.
*/
public interface CollapsibleActionView {
/**
* Called when this view is expanded as an action view. See {@link
- * MenuItem#expandActionView()}.
+ * android.support.v4.view.MenuItem#expandActionView()}.
*/
public void onActionViewExpanded();
/**
* Called when this view is collapsed as an action view. See {@link
- * MenuItem#collapseActionView()}.
+ * android.support.v4.view.MenuItem#collapseActionView()}.
*/
public void onActionViewCollapsed();
}
diff --git a/v7/appcompat/src/android/support/v7/internal/view/SupportMenuInflater.java b/v7/appcompat/src/android/support/v7/internal/view/SupportMenuInflater.java
new file mode 100644
index 0000000..b93b547
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/internal/view/SupportMenuInflater.java
@@ -0,0 +1,488 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.internal.view;
+
+import android.support.v7.appcompat.R;
+import android.support.v7.internal.view.menu.MenuItemImpl;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.content.res.XmlResourceParser;
+import android.support.v7.view.Menu;
+import android.support.v7.view.MenuInflater;
+import android.support.v7.view.MenuItem;
+import android.support.v7.view.SubMenu;
+import android.support.v7.view.ActionProvider;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.util.Xml;
+import android.view.InflateException;
+import android.view.View;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
+/**
+ * This class is used to instantiate menu XML files into Menu objects.
+ * <p>
+ * For performance reasons, menu inflation relies heavily on pre-processing of
+ * XML files that is done at build time. Therefore, it is not currently possible
+ * to use SupportMenuInflater with an XmlPullParser over a plain XML file at runtime;
+ * it only works with an XmlPullParser returned from a compiled resource (R.
+ * <em>something</em> file.)
+ */
+public class SupportMenuInflater implements MenuInflater {
+ private static final String LOG_TAG = "SupportMenuInflater";
+
+ /** Menu tag name in XML. */
+ private static final String XML_MENU = "menu";
+
+ /** Group tag name in XML. */
+ private static final String XML_GROUP = "group";
+
+ /** Item tag name in XML. */
+ private static final String XML_ITEM = "item";
+
+ private static final int NO_ID = 0;
+
+ private static final Class<?>[] ACTION_VIEW_CONSTRUCTOR_SIGNATURE = new Class[] {Context.class};
+
+ private static final Class<?>[] ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE =
+ ACTION_VIEW_CONSTRUCTOR_SIGNATURE;
+
+ private final Object[] mActionViewConstructorArguments;
+
+ private final Object[] mActionProviderConstructorArguments;
+
+ private Context mContext;
+ private Object mRealOwner;
+
+ /**
+ * Constructs a menu inflater.
+ *
+ * @see Activity#getMenuInflater()
+ */
+ public SupportMenuInflater(Context context) {
+ mContext = context;
+ mRealOwner = context;
+ mActionViewConstructorArguments = new Object[] {context};
+ mActionProviderConstructorArguments = mActionViewConstructorArguments;
+ }
+
+ /**
+ * Constructs a menu inflater.
+ *
+ * @see Activity#getMenuInflater()
+ * @hide
+ */
+ public SupportMenuInflater(Context context, Object realOwner) {
+ mContext = context;
+ mRealOwner = realOwner;
+ mActionViewConstructorArguments = new Object[] {context};
+ mActionProviderConstructorArguments = mActionViewConstructorArguments;
+ }
+
+ /**
+ * Inflate a menu hierarchy from the specified XML resource. Throws
+ * {@link InflateException} if there is an error.
+ *
+ * @param menuRes Resource ID for an XML layout resource to load (e.g.,
+ * <code>R.menu.main_activity</code>)
+ * @param menu The Menu to inflate into. The items and submenus will be
+ * added to this Menu.
+ */
+ @Override
+ public void inflate(int menuRes, Menu menu) {
+ XmlResourceParser parser = null;
+ try {
+ parser = mContext.getResources().getLayout(menuRes);
+ AttributeSet attrs = Xml.asAttributeSet(parser);
+
+ parseMenu(parser, attrs, menu);
+ } catch (XmlPullParserException e) {
+ throw new InflateException("Error inflating menu XML", e);
+ } catch (IOException e) {
+ throw new InflateException("Error inflating menu XML", e);
+ } finally {
+ if (parser != null) parser.close();
+ }
+ }
+
+ /**
+ * Called internally to fill the given menu. If a sub menu is seen, it will
+ * call this recursively.
+ */
+ private void parseMenu(XmlPullParser parser, AttributeSet attrs, Menu menu)
+ throws XmlPullParserException, IOException {
+ MenuState menuState = new MenuState(menu);
+
+ int eventType = parser.getEventType();
+ String tagName;
+ boolean lookingForEndOfUnknownTag = false;
+ String unknownTagName = null;
+
+ // This loop will skip to the menu start tag
+ do {
+ if (eventType == XmlPullParser.START_TAG) {
+ tagName = parser.getName();
+ if (tagName.equals(XML_MENU)) {
+ // Go to next tag
+ eventType = parser.next();
+ break;
+ }
+
+ throw new RuntimeException("Expecting menu, got " + tagName);
+ }
+ eventType = parser.next();
+ } while (eventType != XmlPullParser.END_DOCUMENT);
+
+ boolean reachedEndOfMenu = false;
+ while (!reachedEndOfMenu) {
+ switch (eventType) {
+ case XmlPullParser.START_TAG:
+ if (lookingForEndOfUnknownTag) {
+ break;
+ }
+
+ tagName = parser.getName();
+ if (tagName.equals(XML_GROUP)) {
+ menuState.readGroup(attrs);
+ } else if (tagName.equals(XML_ITEM)) {
+ menuState.readItem(attrs);
+ } else if (tagName.equals(XML_MENU)) {
+ // A menu start tag denotes a submenu for an item
+ SubMenu subMenu = menuState.addSubMenuItem();
+
+ // Parse the submenu into returned SubMenu
+ parseMenu(parser, attrs, subMenu);
+ } else {
+ lookingForEndOfUnknownTag = true;
+ unknownTagName = tagName;
+ }
+ break;
+
+ case XmlPullParser.END_TAG:
+ tagName = parser.getName();
+ if (lookingForEndOfUnknownTag && tagName.equals(unknownTagName)) {
+ lookingForEndOfUnknownTag = false;
+ unknownTagName = null;
+ } else if (tagName.equals(XML_GROUP)) {
+ menuState.resetGroup();
+ } else if (tagName.equals(XML_ITEM)) {
+ // Add the item if it hasn't been added (if the item was
+ // a submenu, it would have been added already)
+ if (!menuState.hasAddedItem()) {
+ if (menuState.itemActionProvider != null &&
+ menuState.itemActionProvider.hasSubMenu()) {
+ menuState.addSubMenuItem();
+ } else {
+ menuState.addItem();
+ }
+ }
+ } else if (tagName.equals(XML_MENU)) {
+ reachedEndOfMenu = true;
+ }
+ break;
+
+ case XmlPullParser.END_DOCUMENT:
+ throw new RuntimeException("Unexpected end of document");
+ }
+
+ eventType = parser.next();
+ }
+ }
+
+ private static class InflatedOnMenuItemClickListener
+ implements MenuItem.OnMenuItemClickListener {
+ private static final Class<?>[] PARAM_TYPES = new Class[] { MenuItem.class };
+
+ private Object mRealOwner;
+ private Method mMethod;
+
+ public InflatedOnMenuItemClickListener(Object realOwner, String methodName) {
+ mRealOwner = realOwner;
+ Class<?> c = realOwner.getClass();
+ try {
+ mMethod = c.getMethod(methodName, PARAM_TYPES);
+ } catch (Exception e) {
+ InflateException ex = new InflateException(
+ "Couldn't resolve menu item onClick handler " + methodName +
+ " in class " + c.getName());
+ ex.initCause(e);
+ throw ex;
+ }
+ }
+
+ public boolean onMenuItemClick(MenuItem item) {
+ try {
+ if (mMethod.getReturnType() == Boolean.TYPE) {
+ return (Boolean) mMethod.invoke(mRealOwner, item);
+ } else {
+ mMethod.invoke(mRealOwner, item);
+ return true;
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ /**
+ * State for the current menu.
+ * <p>
+ * Groups can not be nested unless there is another menu (which will have
+ * its state class).
+ */
+ private class MenuState {
+ private Menu menu;
+
+ /*
+ * Group state is set on items as they are added, allowing an item to
+ * override its group state. (As opposed to set on items at the group end tag.)
+ */
+ private int groupId;
+ private int groupCategory;
+ private int groupOrder;
+ private int groupCheckable;
+ private boolean groupVisible;
+ private boolean groupEnabled;
+
+ private boolean itemAdded;
+ private int itemId;
+ private int itemCategoryOrder;
+ private CharSequence itemTitle;
+ private CharSequence itemTitleCondensed;
+ private int itemIconResId;
+ private char itemAlphabeticShortcut;
+ private char itemNumericShortcut;
+ /**
+ * Sync to attrs.xml enum:
+ * - 0: none
+ * - 1: all
+ * - 2: exclusive
+ */
+ private int itemCheckable;
+ private boolean itemChecked;
+ private boolean itemVisible;
+ private boolean itemEnabled;
+
+ /**
+ * Sync to attrs.xml enum, values in MenuItem:
+ * - 0: never
+ * - 1: ifRoom
+ * - 2: always
+ * - -1: Safe sentinel for "no value".
+ */
+ private int itemShowAsAction;
+
+ private int itemActionViewLayout;
+ private String itemActionViewClassName;
+ private String itemActionProviderClassName;
+
+ private String itemListenerMethodName;
+
+ private ActionProvider itemActionProvider;
+
+ private static final int defaultGroupId = NO_ID;
+ private static final int defaultItemId = NO_ID;
+ private static final int defaultItemCategory = 0;
+ private static final int defaultItemOrder = 0;
+ private static final int defaultItemCheckable = 0;
+ private static final boolean defaultItemChecked = false;
+ private static final boolean defaultItemVisible = true;
+ private static final boolean defaultItemEnabled = true;
+
+ public MenuState(final Menu menu) {
+ this.menu = menu;
+
+ resetGroup();
+ }
+
+ public void resetGroup() {
+ groupId = defaultGroupId;
+ groupCategory = defaultItemCategory;
+ groupOrder = defaultItemOrder;
+ groupCheckable = defaultItemCheckable;
+ groupVisible = defaultItemVisible;
+ groupEnabled = defaultItemEnabled;
+ }
+
+ /**
+ * Called when the parser is pointing to a group tag.
+ */
+ public void readGroup(AttributeSet attrs) {
+ TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.MenuGroup);
+
+ groupId = a.getResourceId(R.styleable.MenuGroup_android_id, defaultGroupId);
+ groupCategory = a.getInt(
+ R.styleable.MenuGroup_android_menuCategory, defaultItemCategory);
+ groupOrder = a.getInt(R.styleable.MenuGroup_android_orderInCategory, defaultItemOrder);
+ groupCheckable = a.getInt(
+ R.styleable.MenuGroup_android_checkableBehavior, defaultItemCheckable);
+ groupVisible = a.getBoolean(R.styleable.MenuGroup_android_visible, defaultItemVisible);
+ groupEnabled = a.getBoolean(R.styleable.MenuGroup_android_enabled, defaultItemEnabled);
+
+ a.recycle();
+ }
+
+ /**
+ * Called when the parser is pointing to an item tag.
+ */
+ public void readItem(AttributeSet attrs) {
+ TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.MenuItem);
+
+ // Inherit attributes from the group as default value
+ itemId = a.getResourceId(R.styleable.MenuItem_android_id, defaultItemId);
+ final int category = a.getInt(R.styleable.MenuItem_android_menuCategory, groupCategory);
+ final int order = a.getInt(R.styleable.MenuItem_android_orderInCategory, groupOrder);
+ itemCategoryOrder = (category & Menu.CATEGORY_MASK) | (order & Menu.USER_MASK);
+ itemTitle = a.getText(R.styleable.MenuItem_android_title);
+ itemTitleCondensed = a.getText(R.styleable.MenuItem_android_titleCondensed);
+ itemIconResId = a.getResourceId(R.styleable.MenuItem_android_icon, 0);
+ itemAlphabeticShortcut =
+ getShortcut(a.getString(R.styleable.MenuItem_android_alphabeticShortcut));
+ itemNumericShortcut =
+ getShortcut(a.getString(R.styleable.MenuItem_android_numericShortcut));
+ if (a.hasValue(R.styleable.MenuItem_android_checkable)) {
+ // Item has attribute checkable, use it
+ itemCheckable = a.getBoolean(R.styleable.MenuItem_android_checkable, false) ? 1 : 0;
+ } else {
+ // Item does not have attribute, use the group's (group can have one more state
+ // for checkable that represents the exclusive checkable)
+ itemCheckable = groupCheckable;
+ }
+ itemChecked = a.getBoolean(R.styleable.MenuItem_android_checked, defaultItemChecked);
+ itemVisible = a.getBoolean(R.styleable.MenuItem_android_visible, groupVisible);
+ itemEnabled = a.getBoolean(R.styleable.MenuItem_android_enabled, groupEnabled);
+ itemShowAsAction = a.getInt(R.styleable.MenuItem_showAsAction, -1);
+ itemListenerMethodName = a.getString(R.styleable.MenuItem_android_onClick);
+ itemActionViewLayout = a.getResourceId(R.styleable.MenuItem_actionLayout, 0);
+ itemActionViewClassName = a.getString(R.styleable.MenuItem_actionViewClass);
+ itemActionProviderClassName = a.getString(R.styleable.MenuItem_actionProviderClass);
+
+ final boolean hasActionProvider = itemActionProviderClassName != null;
+ if (hasActionProvider && itemActionViewLayout == 0 && itemActionViewClassName == null) {
+ itemActionProvider = newInstance(itemActionProviderClassName,
+ ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE,
+ mActionProviderConstructorArguments);
+ } else {
+ if (hasActionProvider) {
+ Log.w(LOG_TAG, "Ignoring attribute 'actionProviderClass'."
+ + " Action view already specified.");
+ }
+ itemActionProvider = null;
+ }
+
+ a.recycle();
+
+ itemAdded = false;
+ }
+
+ private char getShortcut(String shortcutString) {
+ if (shortcutString == null) {
+ return 0;
+ } else {
+ return shortcutString.charAt(0);
+ }
+ }
+
+ private void setItem(MenuItem item) {
+ item.setChecked(itemChecked)
+ .setVisible(itemVisible)
+ .setEnabled(itemEnabled)
+ .setCheckable(itemCheckable >= 1)
+ .setTitleCondensed(itemTitleCondensed)
+ .setIcon(itemIconResId)
+ .setAlphabeticShortcut(itemAlphabeticShortcut)
+ .setNumericShortcut(itemNumericShortcut);
+
+ if (itemShowAsAction >= 0) {
+ item.setShowAsAction(itemShowAsAction);
+ }
+
+ if (itemListenerMethodName != null) {
+ if (mContext.isRestricted()) {
+ throw new IllegalStateException("The android:onClick attribute cannot "
+ + "be used within a restricted context");
+ }
+ item.setOnMenuItemClickListener(
+ new InflatedOnMenuItemClickListener(mRealOwner, itemListenerMethodName));
+ }
+
+ if (item instanceof MenuItemImpl) {
+ MenuItemImpl impl = (MenuItemImpl) item;
+ if (itemCheckable >= 2) {
+ impl.setExclusiveCheckable(true);
+ }
+ }
+
+ boolean actionViewSpecified = false;
+ if (itemActionViewClassName != null) {
+ View actionView = (View) newInstance(itemActionViewClassName,
+ ACTION_VIEW_CONSTRUCTOR_SIGNATURE, mActionViewConstructorArguments);
+ item.setActionView(actionView);
+ actionViewSpecified = true;
+ }
+ if (itemActionViewLayout > 0) {
+ if (!actionViewSpecified) {
+ item.setActionView(itemActionViewLayout);
+ actionViewSpecified = true;
+ } else {
+ Log.w(LOG_TAG, "Ignoring attribute 'itemActionViewLayout'."
+ + " Action view already specified.");
+ }
+ }
+ if (itemActionProvider != null) {
+ item.setActionProvider(itemActionProvider);
+ }
+ }
+
+ public void addItem() {
+ itemAdded = true;
+ setItem(menu.add(groupId, itemId, itemCategoryOrder, itemTitle));
+ }
+
+ public SubMenu addSubMenuItem() {
+ itemAdded = true;
+ SubMenu subMenu = menu.addSubMenu(groupId, itemId, itemCategoryOrder, itemTitle);
+ setItem(subMenu.getItem());
+ return subMenu;
+ }
+
+ public boolean hasAddedItem() {
+ return itemAdded;
+ }
+
+ @SuppressWarnings("unchecked")
+ private <T> T newInstance(String className, Class<?>[] constructorSignature,
+ Object[] arguments) {
+ try {
+ Class<?> clazz = mContext.getClassLoader().loadClass(className);
+ Constructor<?> constructor = clazz.getConstructor(constructorSignature);
+ return (T) constructor.newInstance(arguments);
+ } catch (Exception e) {
+ Log.w(LOG_TAG, "Cannot instantiate class: " + className, e);
+ }
+ return null;
+ }
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/ActionMenuItem.java b/v7/appcompat/src/android/support/v7/internal/view/menu/ActionMenuItem.java
similarity index 96%
rename from appcompat/eclair/android/support/appcompat/view/menu/ActionMenuItem.java
rename to v7/appcompat/src/android/support/v7/internal/view/menu/ActionMenuItem.java
index 1cdbe04..1617c06 100644
--- a/appcompat/eclair/android/support/appcompat/view/menu/ActionMenuItem.java
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/ActionMenuItem.java
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-package android.support.appcompat.view.menu;
+package android.support.v7.internal.view.menu;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
-import android.support.appcompat.view.ActionProvider;
-import android.support.appcompat.view.MenuItem;
-import android.support.appcompat.view.SubMenu;
+import android.support.v7.view.ActionProvider;
+import android.support.v7.view.MenuItem;
+import android.support.v7.view.SubMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.View;
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/ActionMenuItemView.java b/v7/appcompat/src/android/support/v7/internal/view/menu/ActionMenuItemView.java
similarity index 95%
rename from appcompat/eclair/android/support/appcompat/view/menu/ActionMenuItemView.java
rename to v7/appcompat/src/android/support/v7/internal/view/menu/ActionMenuItemView.java
index a7568e3..77862a3 100644
--- a/appcompat/eclair/android/support/appcompat/view/menu/ActionMenuItemView.java
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/ActionMenuItemView.java
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-package android.support.appcompat.view.menu;
+package android.support.v7.internal.view.menu;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
-import android.support.appcompat.R;
+import android.support.v7.appcompat.R;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.Gravity;
@@ -29,8 +29,6 @@
import android.widget.TextView;
import android.widget.Toast;
-// TODO(trevorjohns): Lots of things here have been commented out. This needs to be addressed.
-
/**
* @hide
*/
@@ -62,9 +60,9 @@
super(context, attrs, defStyle);
final Resources res = context.getResources();
mAllowTextWithIcon = res.getBoolean(
- android.support.appcompat.R.bool.config_allowActionMenuItemTextWithIcon);
+ android.support.v7.appcompat.R.bool.config_allowActionMenuItemTextWithIcon);
TypedArray a = context.obtainStyledAttributes(attrs,
- android.support.appcompat.R.styleable.ActionMenuItemView, 0, 0);
+ android.support.v7.appcompat.R.styleable.ActionMenuItemView, 0, 0);
mMinWidth = a.getDimensionPixelSize(
R.styleable.ActionMenuItemView_android_minWidth, 0);
a.recycle();
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/ActionMenuPresenter.java b/v7/appcompat/src/android/support/v7/internal/view/menu/ActionMenuPresenter.java
similarity index 91%
rename from appcompat/eclair/android/support/appcompat/view/menu/ActionMenuPresenter.java
rename to v7/appcompat/src/android/support/v7/internal/view/menu/ActionMenuPresenter.java
index e77a4eb..7639042 100644
--- a/appcompat/eclair/android/support/appcompat/view/menu/ActionMenuPresenter.java
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/ActionMenuPresenter.java
@@ -14,18 +14,19 @@
* limitations under the License.
*/
-package android.support.appcompat.view.menu;
+package android.support.v7.internal.view.menu;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Parcel;
import android.os.Parcelable;
-import android.support.appcompat.R;
-import android.support.appcompat.view.ActionBarPolicy;
-import android.support.appcompat.view.ActionProvider;
-import android.support.appcompat.view.MenuItem;
-import android.support.appcompat.view.menu.ActionMenuView.ActionMenuChildView;
+import android.support.v7.appcompat.R;
+import android.support.v7.internal.view.ActionBarPolicy;
+import android.support.v7.view.ActionProvider;
+import android.support.v7.view.MenuItem;
+import android.support.v7.internal.view.menu.ActionMenuView.ActionMenuChildView;
import android.util.SparseBooleanArray;
import android.view.SoundEffectConstants;
import android.view.View;
@@ -70,8 +71,7 @@
int mOpenSubMenuId;
public ActionMenuPresenter(Context context) {
- super(context, android.support.appcompat.R.layout.action_menu_layout,
- android.support.appcompat.R.layout.action_menu_item_layout);
+ super(context, R.layout.abc_action_menu_layout, R.layout.abc_action_menu_item_layout);
}
@Override
@@ -120,8 +120,7 @@
R.integer.max_action_buttons);
}
if (mMenu != null) {
- // TODO(trevorjohns): Figure out what to do about mMenu.onItemsChanged()
- //mMenu.onItemsChanged(true);
+ mMenu.onItemsChanged(true);
}
}
@@ -177,8 +176,7 @@
final ActionMenuView menuView = (ActionMenuView) mMenuView;
ActionMenuItemView actionItemView = (ActionMenuItemView) itemView;
- // TODO(trevorjohns): setItemInvoker was commented out, what to do with this?
- //actionItemView.setItemInvoker(menuView);
+ actionItemView.setItemInvoker(menuView);
}
@Override
@@ -190,6 +188,10 @@
public void updateMenuView(boolean cleared) {
super.updateMenuView(cleared);
+ if (mMenuView == null) {
+ return;
+ }
+
if (mMenu != null) {
final ArrayList<MenuItemImpl> actionItems = mMenu.getActionItems();
final int count = actionItems.size();
@@ -259,9 +261,8 @@
}
mOpenSubMenuId = subMenu.getItem().getItemId();
- mActionButtonPopup = new ActionButtonSubmenu(mContext, subMenu);
- mActionButtonPopup.setAnchorView(anchor);
- mActionButtonPopup.show();
+ mActionButtonPopup = new ActionButtonSubmenu(subMenu);
+ mActionButtonPopup.show(null);
super.onSubMenuSelected(subMenu);
return true;
}
@@ -613,37 +614,16 @@
}
}
- private class ActionButtonSubmenu extends MenuPopupHelper {
+ private class ActionButtonSubmenu extends MenuDialogHelper {
- private SubMenuBuilder mSubMenu;
-
- public ActionButtonSubmenu(Context context, SubMenuBuilder subMenu) {
- super(context, subMenu);
- mSubMenu = subMenu;
-
- MenuItemImpl item = (MenuItemImpl) subMenu.getItem();
- if (!item.isActionButton()) {
- // Give a reasonable anchor to nested submenus.
- setAnchorView(mOverflowButton == null ? (View) mMenuView : mOverflowButton);
- }
-
+ public ActionButtonSubmenu(SubMenuBuilder subMenu) {
+ super(subMenu);
setCallback(mPopupPresenterCallback);
-
- boolean preserveIconSpacing = false;
- final int count = subMenu.size();
- for (int i = 0; i < count; i++) {
- MenuItem childItem = subMenu.getItem(i);
- if (childItem.isVisible() && childItem.getIcon() != null) {
- preserveIconSpacing = true;
- break;
- }
- }
- setForceShowIcon(preserveIconSpacing);
}
@Override
- public void onDismiss() {
- super.onDismiss();
+ public void onDismiss(DialogInterface dialog) {
+ super.onDismiss(dialog);
mActionButtonPopup = null;
mOpenSubMenuId = 0;
}
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/ActionMenuView.java b/v7/appcompat/src/android/support/v7/internal/view/menu/ActionMenuView.java
similarity index 98%
rename from appcompat/eclair/android/support/appcompat/view/menu/ActionMenuView.java
rename to v7/appcompat/src/android/support/v7/internal/view/menu/ActionMenuView.java
index 96fa380..4f86aa2 100644
--- a/appcompat/eclair/android/support/appcompat/view/menu/ActionMenuView.java
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/ActionMenuView.java
@@ -13,13 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package android.support.appcompat.view.menu;
+package android.support.v7.internal.view.menu;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.os.Build;
-import android.support.appcompat.R;
+import android.support.v7.appcompat.R;
+import android.support.v7.internal.widget.LinearLayoutICS;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
@@ -31,7 +32,7 @@
/**
* @hide
*/
-public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvoker, MenuView {
+public class ActionMenuView extends LinearLayoutICS implements MenuBuilder.ItemInvoker, MenuView {
private static final String TAG = "ActionMenuView";
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/BaseMenuPresenter.java b/v7/appcompat/src/android/support/v7/internal/view/menu/BaseMenuPresenter.java
similarity index 98%
rename from appcompat/eclair/android/support/appcompat/view/menu/BaseMenuPresenter.java
rename to v7/appcompat/src/android/support/v7/internal/view/menu/BaseMenuPresenter.java
index 8a3fc38..fde68bc 100644
--- a/appcompat/eclair/android/support/appcompat/view/menu/BaseMenuPresenter.java
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/BaseMenuPresenter.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package android.support.appcompat.view.menu;
+package android.support.v7.internal.view.menu;
import android.content.Context;
import android.view.LayoutInflater;
diff --git a/v7/appcompat/src/android/support/v7/internal/view/menu/BaseMenuWrapper.java b/v7/appcompat/src/android/support/v7/internal/view/menu/BaseMenuWrapper.java
new file mode 100644
index 0000000..bb6d684
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/BaseMenuWrapper.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.internal.view.menu;
+
+import android.support.v7.view.MenuItem;
+import android.support.v7.view.SubMenu;
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+abstract class BaseMenuWrapper<T> extends BaseWrapper<T> {
+
+ private HashMap<android.view.MenuItem, MenuItem> mMenuItems;
+
+ private HashMap<android.view.SubMenu, SubMenu> mSubMenus;
+
+ BaseMenuWrapper(T object) {
+ super(object);
+ }
+
+ final MenuItem getMenuItemWrapper(android.view.MenuItem frameworkItem) {
+ if (frameworkItem != null) {
+ // Instantiate HashMap if null
+ if (mMenuItems == null) {
+ mMenuItems = new HashMap<android.view.MenuItem, MenuItem>();
+ }
+
+ MenuItem compatItem = mMenuItems.get(frameworkItem);
+
+ if (null == compatItem) {
+ compatItem = createMenuItemWrapper(frameworkItem);
+ mMenuItems.put(frameworkItem, compatItem);
+ }
+
+ return compatItem;
+ }
+ return null;
+ }
+
+ final SubMenu getSubMenuWrapper(android.view.SubMenu frameworkSubMenu) {
+ if (frameworkSubMenu != null) {
+ // Instantiate HashMap if null
+ if (mSubMenus == null) {
+ mSubMenus = new HashMap<android.view.SubMenu, SubMenu>();
+ }
+
+ SubMenu compatSubMenu = mSubMenus.get(frameworkSubMenu);
+
+ if (null == compatSubMenu) {
+ compatSubMenu = createSubMenuWrapper(frameworkSubMenu);
+ mSubMenus.put(frameworkSubMenu, compatSubMenu);
+ }
+ return compatSubMenu;
+ }
+ return null;
+ }
+
+
+ final void internalClear() {
+ if (mMenuItems != null) {
+ mMenuItems.clear();
+ }
+ if (mSubMenus != null) {
+ mSubMenus.clear();
+ }
+ }
+
+ final void internalRemoveGroup(final int groupId) {
+ if (mMenuItems == null) {
+ return;
+ }
+
+ Iterator<android.view.MenuItem> iterator = mMenuItems.keySet().iterator();
+ android.view.MenuItem menuItem;
+
+ while (iterator.hasNext()) {
+ menuItem = iterator.next();
+ if (groupId == menuItem.getGroupId()) {
+ iterator.remove();
+ }
+ }
+ }
+
+ final void internalRemoveItem(final int id) {
+ if (mMenuItems == null) {
+ return;
+ }
+
+ Iterator<android.view.MenuItem> iterator = mMenuItems.keySet().iterator();
+ android.view.MenuItem menuItem;
+
+ while (iterator.hasNext()) {
+ menuItem = iterator.next();
+ if (id == menuItem.getItemId()) {
+ iterator.remove();
+ break;
+ }
+ }
+ }
+
+ abstract MenuItem createMenuItemWrapper(android.view.MenuItem menuItem);
+
+ abstract SubMenu createSubMenuWrapper(android.view.SubMenu subMenu);
+
+}
diff --git a/appcompat/ics/android/support/appcompat/app/ActionBarImplICS.java b/v7/appcompat/src/android/support/v7/internal/view/menu/BaseWrapper.java
similarity index 63%
rename from appcompat/ics/android/support/appcompat/app/ActionBarImplICS.java
rename to v7/appcompat/src/android/support/v7/internal/view/menu/BaseWrapper.java
index cb94431..116bc23 100644
--- a/appcompat/ics/android/support/appcompat/app/ActionBarImplICS.java
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/BaseWrapper.java
@@ -14,16 +14,21 @@
* limitations under the License.
*/
-package android.support.appcompat.app;
+package android.support.v7.internal.view.menu;
-import android.app.Activity;
-import android.support.appcompat.app.ActionBarImplHC;
+class BaseWrapper<T> {
-class ActionBarImplICS extends ActionBarImplHC {
+ final T mWrappedObject;
- public ActionBarImplICS(Activity activity, Callback callback) {
- super(activity, callback);
- // TODO Auto-generated constructor stub
+ BaseWrapper(T object) {
+ if (null == object) {
+ throw new IllegalArgumentException("Wrapped Object can not be null.");
+ }
+ mWrappedObject = object;
+ }
+
+ public T getWrappedObject() {
+ return mWrappedObject;
}
}
diff --git a/v7/appcompat/src/android/support/v7/internal/view/menu/ExpandedMenuView.java b/v7/appcompat/src/android/support/v7/internal/view/menu/ExpandedMenuView.java
new file mode 100644
index 0000000..67c6241
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/ExpandedMenuView.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.internal.view.menu;
+
+import android.content.Context;
+import android.support.v7.internal.view.menu.MenuBuilder;
+import android.support.v7.internal.view.menu.MenuBuilder.ItemInvoker;
+import android.support.v7.internal.view.menu.MenuView;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ListView;
+
+/**
+ * The expanded menu view is a list-like menu with all of the available menu items. It is opened
+ * by the user clicking no the 'More' button on the icon menu view.
+ */
+public final class ExpandedMenuView extends ListView implements ItemInvoker, MenuView, OnItemClickListener {
+ private MenuBuilder mMenu;
+
+ /** Default animations for this menu */
+ private int mAnimations;
+
+ /**
+ * Instantiates the ExpandedMenuView that is linked with the provided MenuBuilder.
+ * @param menu The model for the menu which this MenuView will display
+ */
+ public ExpandedMenuView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setOnItemClickListener(this);
+ }
+
+ public void initialize(MenuBuilder menu) {
+ mMenu = menu;
+ }
+
+ @Override
+ protected void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+
+ // Clear the cached bitmaps of children
+ setChildrenDrawingCacheEnabled(false);
+ }
+
+ public boolean invokeItem(MenuItemImpl item) {
+ return mMenu.performItemAction(item, 0);
+ }
+
+ public void onItemClick(AdapterView parent, View v, int position, long id) {
+ invokeItem((MenuItemImpl) getAdapter().getItem(position));
+ }
+
+ public int getWindowAnimations() {
+ return mAnimations;
+ }
+
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/ListMenuItemView.java b/v7/appcompat/src/android/support/v7/internal/view/menu/ListMenuItemView.java
similarity index 93%
rename from appcompat/eclair/android/support/appcompat/view/menu/ListMenuItemView.java
rename to v7/appcompat/src/android/support/v7/internal/view/menu/ListMenuItemView.java
index 370897d..e77f1f2 100644
--- a/appcompat/eclair/android/support/appcompat/view/menu/ListMenuItemView.java
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/ListMenuItemView.java
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-package android.support.appcompat.view.menu;
+package android.support.v7.internal.view.menu;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
-import android.support.appcompat.R;
+import android.support.v7.appcompat.R;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
@@ -65,11 +65,11 @@
context.obtainStyledAttributes(
attrs, R.styleable.MenuView, defStyle, 0);
- mBackground = a.getDrawable(R.styleable.MenuView_itemBackground);
+ mBackground = a.getDrawable(R.styleable.MenuView_android_itemBackground);
mTextAppearance = a.getResourceId(R.styleable.
- MenuView_itemTextAppearance, -1);
+ MenuView_android_itemTextAppearance, -1);
mPreserveIconSpacing = a.getBoolean(
- R.styleable.MenuView_preserveIconSpacing, false);
+ R.styleable.MenuView_android_preserveIconSpacing, false);
mTextAppearanceContext = context;
a.recycle();
@@ -246,7 +246,7 @@
private void insertIconView() {
LayoutInflater inflater = getInflater();
- mIconView = (ImageView) inflater.inflate(R.layout.list_menu_item_icon,
+ mIconView = (ImageView) inflater.inflate(R.layout.abc_list_menu_item_icon,
this, false);
addView(mIconView, 0);
}
@@ -254,7 +254,7 @@
private void insertRadioButton() {
LayoutInflater inflater = getInflater();
mRadioButton =
- (RadioButton) inflater.inflate(R.layout.list_menu_item_radio,
+ (RadioButton) inflater.inflate(R.layout.abc_list_menu_item_radio,
this, false);
addView(mRadioButton);
}
@@ -262,7 +262,7 @@
private void insertCheckBox() {
LayoutInflater inflater = getInflater();
mCheckBox =
- (CheckBox) inflater.inflate(R.layout.list_menu_item_checkbox,
+ (CheckBox) inflater.inflate(R.layout.abc_list_menu_item_checkbox,
this, false);
addView(mCheckBox);
}
diff --git a/v7/appcompat/src/android/support/v7/internal/view/menu/ListMenuPresenter.java b/v7/appcompat/src/android/support/v7/internal/view/menu/ListMenuPresenter.java
new file mode 100644
index 0000000..2a6ef94
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/ListMenuPresenter.java
@@ -0,0 +1,292 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.internal.view.menu;
+
+import android.content.Context;
+import android.database.DataSetObserver;
+import android.os.Bundle;
+import android.os.Parcelable;
+import android.support.v7.appcompat.R;
+import android.util.SparseArray;
+import android.view.ContextThemeWrapper;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.BaseAdapter;
+import android.widget.ListAdapter;
+
+import java.util.ArrayList;
+
+/**
+ * MenuPresenter for list-style menus.
+ */
+public class ListMenuPresenter implements MenuPresenter, AdapterView.OnItemClickListener {
+ private static final String TAG = "ListMenuPresenter";
+
+ Context mContext;
+ LayoutInflater mInflater;
+ MenuBuilder mMenu;
+
+ ExpandedMenuView mMenuView;
+
+ private int mItemIndexOffset;
+ int mThemeRes;
+ int mItemLayoutRes;
+
+ private Callback mCallback;
+ MenuAdapter mAdapter;
+
+ private int mId;
+
+ public static final String VIEWS_TAG = "android:menu:list";
+
+ /**
+ * Construct a new ListMenuPresenter.
+ * @param context Context to use for theming. This will supersede the context provided
+ * to initForMenu when this presenter is added.
+ * @param itemLayoutRes Layout resource for individual item views.
+ */
+ public ListMenuPresenter(Context context, int itemLayoutRes) {
+ this(itemLayoutRes, 0);
+ mContext = context;
+ mInflater = LayoutInflater.from(mContext);
+ }
+
+ /**
+ * Construct a new ListMenuPresenter.
+ * @param itemLayoutRes Layout resource for individual item views.
+ * @param themeRes Resource ID of a theme to use for views.
+ */
+ public ListMenuPresenter(int itemLayoutRes, int themeRes) {
+ mItemLayoutRes = itemLayoutRes;
+ mThemeRes = themeRes;
+ }
+
+ @Override
+ public void initForMenu(Context context, MenuBuilder menu) {
+ if (mThemeRes != 0) {
+ mContext = new ContextThemeWrapper(context, mThemeRes);
+ mInflater = LayoutInflater.from(mContext);
+ } else if (mContext != null) {
+ mContext = context;
+ if (mInflater == null) {
+ mInflater = LayoutInflater.from(mContext);
+ }
+ }
+ mMenu = menu;
+ if (mAdapter != null) {
+ mAdapter.notifyDataSetChanged();
+ }
+ }
+
+ @Override
+ public MenuView getMenuView(ViewGroup root) {
+ if (mAdapter == null) {
+ mAdapter = new MenuAdapter();
+ }
+
+ if (!mAdapter.isEmpty()) {
+ if (mMenuView == null) {
+ mMenuView = (ExpandedMenuView) mInflater.inflate(
+ R.layout.abc_expanded_menu_layout, root, false);
+ mMenuView.setAdapter(mAdapter);
+ mMenuView.setOnItemClickListener(this);
+ }
+ return mMenuView;
+ }
+
+ // If we reach here, the Menu is empty so we have nothing to display
+ return null;
+ }
+
+ /**
+ * Call this instead of getMenuView if you want to manage your own ListView.
+ * For proper operation, the ListView hosting this adapter should add
+ * this presenter as an OnItemClickListener.
+ *
+ * @return A ListAdapter containing the items in the menu.
+ */
+ public ListAdapter getAdapter() {
+ if (mAdapter == null) {
+ mAdapter = new MenuAdapter();
+ }
+ return mAdapter;
+ }
+
+ @Override
+ public void updateMenuView(boolean cleared) {
+ if (mAdapter != null) mAdapter.notifyDataSetChanged();
+ }
+
+ @Override
+ public void setCallback(Callback cb) {
+ mCallback = cb;
+ }
+
+ @Override
+ public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
+ if (!subMenu.hasVisibleItems()) return false;
+
+ // The window manager will give us a token.
+ new MenuDialogHelper(subMenu).show(null);
+ if (mCallback != null) {
+ mCallback.onOpenSubMenu(subMenu);
+ }
+ return true;
+ }
+
+ @Override
+ public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
+ if (mCallback != null) {
+ mCallback.onCloseMenu(menu, allMenusAreClosing);
+ }
+ }
+
+ int getItemIndexOffset() {
+ return mItemIndexOffset;
+ }
+
+ public void setItemIndexOffset(int offset) {
+ mItemIndexOffset = offset;
+ if (mMenuView != null) {
+ updateMenuView(false);
+ }
+ }
+
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ mMenu.performItemAction(mAdapter.getItem(position), 0);
+ }
+
+ @Override
+ public boolean flagActionItems() {
+ return false;
+ }
+
+ public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) {
+ return false;
+ }
+
+ public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) {
+ return false;
+ }
+
+ public void saveHierarchyState(Bundle outState) {
+ SparseArray<Parcelable> viewStates = new SparseArray<Parcelable>();
+ if (mMenuView != null) {
+ ((View) mMenuView).saveHierarchyState(viewStates);
+ }
+ outState.putSparseParcelableArray(VIEWS_TAG, viewStates);
+ }
+
+ public void restoreHierarchyState(Bundle inState) {
+ SparseArray<Parcelable> viewStates = inState.getSparseParcelableArray(VIEWS_TAG);
+ if (viewStates != null) {
+ ((View) mMenuView).restoreHierarchyState(viewStates);
+ }
+ }
+
+ public void setId(int id) {
+ mId = id;
+ }
+
+ @Override
+ public int getId() {
+ return mId;
+ }
+
+ @Override
+ public Parcelable onSaveInstanceState() {
+ if (mMenuView == null) {
+ return null;
+ }
+
+ Bundle state = new Bundle();
+ saveHierarchyState(state);
+ return state;
+ }
+
+ @Override
+ public void onRestoreInstanceState(Parcelable state) {
+ restoreHierarchyState((Bundle) state);
+ }
+
+ private class MenuAdapter extends BaseAdapter {
+ private int mExpandedIndex = -1;
+
+ public MenuAdapter() {
+ findExpandedIndex();
+ }
+
+ public int getCount() {
+ ArrayList<MenuItemImpl> items = mMenu.getNonActionItems();
+ int count = items.size() - mItemIndexOffset;
+ if (mExpandedIndex < 0) {
+ return count;
+ }
+ return count - 1;
+ }
+
+ public MenuItemImpl getItem(int position) {
+ ArrayList<MenuItemImpl> items = mMenu.getNonActionItems();
+ position += mItemIndexOffset;
+ if (mExpandedIndex >= 0 && position >= mExpandedIndex) {
+ position++;
+ }
+ return items.get(position);
+ }
+
+ public long getItemId(int position) {
+ // Since a menu item's ID is optional, we'll use the position as an
+ // ID for the item in the AdapterView
+ return position;
+ }
+
+ public View getView(int position, View convertView, ViewGroup parent) {
+ if (convertView == null) {
+ convertView = mInflater.inflate(mItemLayoutRes, parent, false);
+ }
+
+ MenuView.ItemView itemView = (MenuView.ItemView) convertView;
+ itemView.initialize(getItem(position), 0);
+ return convertView;
+ }
+
+ void findExpandedIndex() {
+ final MenuItemImpl expandedItem = mMenu.getExpandedItem();
+ if (expandedItem != null) {
+ final ArrayList<MenuItemImpl> items = mMenu.getNonActionItems();
+ final int count = items.size();
+ for (int i = 0; i < count; i++) {
+ final MenuItemImpl item = items.get(i);
+ if (item == expandedItem) {
+ mExpandedIndex = i;
+ return;
+ }
+ }
+ }
+ mExpandedIndex = -1;
+ }
+
+ @Override
+ public void notifyDataSetChanged() {
+ findExpandedIndex();
+ super.notifyDataSetChanged();
+ }
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/MenuBuilder.java b/v7/appcompat/src/android/support/v7/internal/view/menu/MenuBuilder.java
similarity index 98%
rename from appcompat/eclair/android/support/appcompat/view/menu/MenuBuilder.java
rename to v7/appcompat/src/android/support/v7/internal/view/menu/MenuBuilder.java
index 5abab46..6d99899 100644
--- a/appcompat/eclair/android/support/appcompat/view/menu/MenuBuilder.java
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/MenuBuilder.java
@@ -1,6 +1,6 @@
// Copyright 2012 Google Inc. All Rights Reserved.
-package android.support.appcompat.view.menu;
+package android.support.v7.internal.view.menu;
import android.content.ComponentName;
import android.content.Context;
@@ -12,11 +12,11 @@
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Parcelable;
-import android.support.appcompat.R;
-import android.support.appcompat.view.ActionProvider;
-import android.support.appcompat.view.Menu;
-import android.support.appcompat.view.MenuItem;
-import android.support.appcompat.view.SubMenu;
+import android.support.v7.appcompat.R;
+import android.support.v7.view.ActionProvider;
+import android.support.v7.view.Menu;
+import android.support.v7.view.MenuItem;
+import android.support.v7.view.SubMenu;
import android.util.SparseArray;
import android.view.ContextMenu;
import android.view.KeyCharacterMap;
@@ -29,7 +29,7 @@
import java.util.concurrent.CopyOnWriteArrayList;
/**
- * Implementation of the {@link android.support.appcompat.view.Menu} interface for creating a
+ * Implementation of the {@link android.support.v4.view.Menu} interface for creating a
* standard menu UI.
*/
public class MenuBuilder implements Menu {
diff --git a/v7/appcompat/src/android/support/v7/internal/view/menu/MenuDialogHelper.java b/v7/appcompat/src/android/support/v7/internal/view/menu/MenuDialogHelper.java
new file mode 100644
index 0000000..716dfd2
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/MenuDialogHelper.java
@@ -0,0 +1,172 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.internal.view.menu;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.os.IBinder;
+import android.support.v7.appcompat.R;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+
+/**
+ * Helper for menus that appear as Dialogs (context and submenus).
+ *
+ * @hide
+ */
+public class MenuDialogHelper implements DialogInterface.OnKeyListener,
+ DialogInterface.OnClickListener,
+ DialogInterface.OnDismissListener,
+ MenuPresenter.Callback {
+ private MenuBuilder mMenu;
+ private AlertDialog mDialog;
+ ListMenuPresenter mPresenter;
+ private MenuPresenter.Callback mPresenterCallback;
+
+ public MenuDialogHelper(MenuBuilder menu) {
+ mMenu = menu;
+ }
+
+ /**
+ * Shows menu as a dialog.
+ *
+ * @param windowToken Optional token to assign to the window.
+ */
+ public void show(IBinder windowToken) {
+ // Many references to mMenu, create local reference
+ final MenuBuilder menu = mMenu;
+
+ // Get the builder for the dialog
+ final AlertDialog.Builder builder = new AlertDialog.Builder(menu.getContext());
+
+ // Need to force Light Menu theme as list_menu_item_layout is usually against a dark bg and
+ // AlertDialog's bg is white
+ mPresenter = new ListMenuPresenter(R.layout.abc_list_menu_item_layout,
+ R.style.Theme_AppCompat_CompactMenu_Dialog);
+
+ mPresenter.setCallback(this);
+ mMenu.addMenuPresenter(mPresenter);
+ builder.setAdapter(mPresenter.getAdapter(), this);
+
+ // Set the title
+ final View headerView = menu.getHeaderView();
+ if (headerView != null) {
+ // Menu's client has given a custom header view, use it
+ builder.setCustomTitle(headerView);
+ } else {
+ // Otherwise use the (text) title and icon
+ builder.setIcon(menu.getHeaderIcon()).setTitle(menu.getHeaderTitle());
+ }
+
+ // Set the key listener
+ builder.setOnKeyListener(this);
+
+ // Show the menu
+ mDialog = builder.create();
+ mDialog.setOnDismissListener(this);
+
+ WindowManager.LayoutParams lp = mDialog.getWindow().getAttributes();
+ lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
+ if (windowToken != null) {
+ lp.token = windowToken;
+ }
+ lp.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
+
+ mDialog.show();
+ }
+
+ public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
+ if (keyCode == KeyEvent.KEYCODE_MENU || keyCode == KeyEvent.KEYCODE_BACK) {
+ if (event.getAction() == KeyEvent.ACTION_DOWN
+ && event.getRepeatCount() == 0) {
+ Window win = mDialog.getWindow();
+ if (win != null) {
+ View decor = win.getDecorView();
+ if (decor != null) {
+ KeyEvent.DispatcherState ds = decor.getKeyDispatcherState();
+ if (ds != null) {
+ ds.startTracking(event, this);
+ return true;
+ }
+ }
+ }
+ } else if (event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()) {
+ Window win = mDialog.getWindow();
+ if (win != null) {
+ View decor = win.getDecorView();
+ if (decor != null) {
+ KeyEvent.DispatcherState ds = decor.getKeyDispatcherState();
+ if (ds != null && ds.isTracking(event)) {
+ mMenu.close(true);
+ dialog.dismiss();
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ // Menu shortcut matching
+ return mMenu.performShortcut(keyCode, event, 0);
+
+ }
+
+ public void setPresenterCallback(MenuPresenter.Callback cb) {
+ mPresenterCallback = cb;
+ }
+
+ /**
+ * Dismisses the menu's dialog.
+ *
+ * @see Dialog#dismiss()
+ */
+ public void dismiss() {
+ if (mDialog != null) {
+ mDialog.dismiss();
+ }
+ }
+
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ mPresenter.onCloseMenu(mMenu, true);
+ }
+
+ @Override
+ public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
+ if (allMenusAreClosing || menu == mMenu) {
+ dismiss();
+ }
+ if (mPresenterCallback != null) {
+ mPresenterCallback.onCloseMenu(menu, allMenusAreClosing);
+ }
+ }
+
+ @Override
+ public boolean onOpenSubMenu(MenuBuilder subMenu) {
+ if (mPresenterCallback != null) {
+ return mPresenterCallback.onOpenSubMenu(subMenu);
+ }
+ return false;
+ }
+
+ public void onClick(DialogInterface dialog, int which) {
+ mMenu.performItemAction((MenuItemImpl) mPresenter.getAdapter().getItem(which), 0);
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/MenuItemImpl.java b/v7/appcompat/src/android/support/v7/internal/view/menu/MenuItemImpl.java
similarity index 91%
rename from appcompat/eclair/android/support/appcompat/view/menu/MenuItemImpl.java
rename to v7/appcompat/src/android/support/v7/internal/view/menu/MenuItemImpl.java
index a2b9fec..77fb098 100644
--- a/appcompat/eclair/android/support/appcompat/view/menu/MenuItemImpl.java
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/MenuItemImpl.java
@@ -14,19 +14,22 @@
* limitations under the License.
*/
-package android.support.appcompat.view.menu;
+package android.support.v7.internal.view.menu;
-import android.support.appcompat.view.ActionProvider;
-import android.support.appcompat.view.MenuItem;
-import android.support.appcompat.view.SubMenu;
+import android.content.Context;
+import android.support.v7.view.ActionProvider;
+import android.support.v7.view.MenuItem;
+import android.support.v7.view.SubMenu;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.ContextMenu.ContextMenuInfo;
+import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewDebug;
+import android.widget.LinearLayout;
/**
* @hide
@@ -151,9 +154,9 @@
return true;
}
- //if (mMenu.dispatchMenuItemSelected(mMenu.getRootMenu(), this)) {
- // return true;
- //}
+ if (mMenu.dispatchMenuItemSelected(mMenu.getRootMenu(), this)) {
+ return true;
+ }
if (mItemCallback != null) {
mItemCallback.run();
@@ -162,7 +165,7 @@
if (mIntent != null) {
try {
- //mMenu.getContext().startActivity(mIntent);
+ mMenu.getContext().startActivity(mIntent);
return true;
} catch (ActivityNotFoundException e) {
Log.e(TAG, "Can't find activity to handle intent; ignoring", e);
@@ -187,7 +190,7 @@
mFlags &= ~ENABLED;
}
- //mMenu.onItemsChanged(false);
+ mMenu.onItemsChanged(false);
return this;
}
@@ -238,7 +241,7 @@
mShortcutAlphabeticChar = Character.toLowerCase(alphaChar);
- //mMenu.onItemsChanged(false);
+ mMenu.onItemsChanged(false);
return this;
}
@@ -254,7 +257,7 @@
mShortcutNumericChar = numericChar;
- //mMenu.onItemsChanged(false);
+ mMenu.onItemsChanged(false);
return this;
}
@@ -263,7 +266,7 @@
mShortcutNumericChar = numericChar;
mShortcutAlphabeticChar = Character.toLowerCase(alphaChar);
- //mMenu.onItemsChanged(false);
+ mMenu.onItemsChanged(false);
return this;
}
@@ -354,7 +357,7 @@
public MenuItem setTitle(CharSequence title) {
mTitle = title;
- //mMenu.onItemsChanged(false);
+ mMenu.onItemsChanged(false);
if (mSubMenu != null) {
mSubMenu.setHeaderTitle(title);
@@ -379,7 +382,7 @@
title = mTitle;
}
- //mMenu.onItemsChanged(false);
+ mMenu.onItemsChanged(false);
return this;
}
@@ -390,10 +393,10 @@
}
if (mIconResId != NO_ICON) {
- //Drawable icon = mMenu.getResources().getDrawable(mIconResId);
- // mIconResId = NO_ICON;
- //mIconDrawable = icon;
- //return icon;
+ Drawable icon = mMenu.getResources().getDrawable(mIconResId);
+ mIconResId = NO_ICON;
+ mIconDrawable = icon;
+ return icon;
}
return null;
@@ -402,7 +405,7 @@
public MenuItem setIcon(Drawable icon) {
mIconResId = NO_ICON;
mIconDrawable = icon;
- //mMenu.onItemsChanged(false);
+ mMenu.onItemsChanged(false);
return this;
}
@@ -412,7 +415,7 @@
mIconResId = iconResId;
// If we have a view, we need to push the Drawable to them
- //mMenu.onItemsChanged(false);
+ mMenu.onItemsChanged(false);
return this;
}
@@ -425,7 +428,7 @@
final int oldFlags = mFlags;
mFlags = (mFlags & ~CHECKABLE) | (checkable ? CHECKABLE : 0);
if (oldFlags != mFlags) {
- //mMenu.onItemsChanged(false);
+ mMenu.onItemsChanged(false);
}
return this;
@@ -447,7 +450,7 @@
if ((mFlags & EXCLUSIVE) != 0) {
// Call the method on the Menu since it knows about the others in this
// exclusive checkable group
- //mMenu.setExclusiveItemChecked(this);
+ mMenu.setExclusiveItemChecked(this);
} else {
setCheckedInt(checked);
}
@@ -459,7 +462,7 @@
final int oldFlags = mFlags;
mFlags = (mFlags & ~CHECKED) | (checked ? CHECKED : 0);
if (oldFlags != mFlags) {
- //mMenu.onItemsChanged(false);
+ mMenu.onItemsChanged(false);
}
}
@@ -485,7 +488,7 @@
// Try to set the shown state to the given state. If the shown state was changed
// (i.e. the previous state isn't the same as given state), notify the parent menu that
// the shown state has changed for this item
- //if (setVisibleInt(shown)) mMenu.onItemVisibleChanged(this);
+ if (setVisibleInt(shown)) mMenu.onItemVisibleChanged(this);
return this;
}
@@ -509,7 +512,7 @@
}
public void actionFormatChanged() {
- //mMenu.onItemActionRequestChanged(this);
+ mMenu.onItemActionRequestChanged(this);
}
/**
@@ -557,7 +560,7 @@
+ " and SHOW_AS_ACTION_NEVER are mutually exclusive.");
}
mShowAsAction = actionEnum;
- //mMenu.onItemActionRequestChanged(this);
+ mMenu.onItemActionRequestChanged(this);
}
public MenuItem setActionView(View view) {
@@ -566,14 +569,14 @@
if (view != null && view.getId() == View.NO_ID && mId > 0) {
view.setId(mId);
}
- //mMenu.onItemActionRequestChanged(this);
+ mMenu.onItemActionRequestChanged(this);
return this;
}
public MenuItem setActionView(int resId) {
- //final Context context = mMenu.getContext();
- //final LayoutInflater inflater = LayoutInflater.from(context);
- //setActionView(inflater.inflate(resId, new LinearLayout(context), false));
+ final Context context = mMenu.getContext();
+ final LayoutInflater inflater = LayoutInflater.from(context);
+ setActionView(inflater.inflate(resId, new LinearLayout(context), false));
return this;
}
@@ -595,7 +598,7 @@
public MenuItem setActionProvider(ActionProvider actionProvider) {
mActionView = null;
mActionProvider = actionProvider;
- //mMenu.onItemsChanged(true); // Measurement can be changed
+ mMenu.onItemsChanged(true); // Measurement can be changed
return this;
}
@@ -613,7 +616,7 @@
if (mOnActionExpandListener == null ||
mOnActionExpandListener.onMenuItemActionExpand(this)) {
- //return mMenu.expandItemActionView(this);
+ return mMenu.expandItemActionView(this);
}
return false;
@@ -649,7 +652,7 @@
public void setActionViewExpanded(boolean isExpanded) {
mIsActionViewExpanded = isExpanded;
- //mMenu.onItemsChanged(false);
+ mMenu.onItemsChanged(false);
}
public boolean isActionViewExpanded() {
diff --git a/v7/appcompat/src/android/support/v7/internal/view/menu/MenuItemWrapperHC.java b/v7/appcompat/src/android/support/v7/internal/view/menu/MenuItemWrapperHC.java
new file mode 100644
index 0000000..6e95fd8
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/MenuItemWrapperHC.java
@@ -0,0 +1,325 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.internal.view.menu;
+
+import android.content.Intent;
+import android.graphics.drawable.Drawable;
+import android.support.v7.view.ActionProvider;
+import android.support.v7.view.MenuItem;
+import android.support.v7.view.SubMenu;
+import android.view.ContextMenu;
+import android.view.View;
+
+class MenuItemWrapperHC extends BaseMenuWrapper<android.view.MenuItem> implements MenuItem {
+ private ActionProvider mActionProvider;
+
+ MenuItemWrapperHC(android.view.MenuItem object) {
+ super(object);
+ }
+
+ @Override
+ public int getItemId() {
+ return mWrappedObject.getItemId();
+ }
+
+ @Override
+ public int getGroupId() {
+ return mWrappedObject.getGroupId();
+ }
+
+ @Override
+ public int getOrder() {
+ return mWrappedObject.getOrder();
+ }
+
+ @Override
+ public MenuItem setTitle(CharSequence title) {
+ mWrappedObject.setTitle(title);
+ return this;
+ }
+
+ @Override
+ public MenuItem setTitle(int title) {
+ mWrappedObject.setTitle(title);
+ return this;
+ }
+
+ @Override
+ public CharSequence getTitle() {
+ return mWrappedObject.getTitle();
+ }
+
+ @Override
+ public MenuItem setTitleCondensed(CharSequence title) {
+ mWrappedObject.setTitleCondensed(title);
+ return this;
+ }
+
+ @Override
+ public CharSequence getTitleCondensed() {
+ return mWrappedObject.getTitleCondensed();
+ }
+
+ @Override
+ public MenuItem setIcon(Drawable icon) {
+ mWrappedObject.setIcon(icon);
+ return this;
+ }
+
+ @Override
+ public MenuItem setIcon(int iconRes) {
+ mWrappedObject.setIcon(iconRes);
+ return this;
+ }
+
+ @Override
+ public Drawable getIcon() {
+ return mWrappedObject.getIcon();
+ }
+
+ @Override
+ public MenuItem setIntent(Intent intent) {
+ mWrappedObject.setIntent(intent);
+ return this;
+ }
+
+ @Override
+ public Intent getIntent() {
+ return mWrappedObject.getIntent();
+ }
+
+ @Override
+ public MenuItem setShortcut(char numericChar, char alphaChar) {
+ mWrappedObject.setShortcut(numericChar, alphaChar);
+ return this;
+ }
+
+ @Override
+ public MenuItem setNumericShortcut(char numericChar) {
+ mWrappedObject.setNumericShortcut(numericChar);
+ return this;
+ }
+
+ @Override
+ public char getNumericShortcut() {
+ return mWrappedObject.getNumericShortcut();
+ }
+
+ @Override
+ public MenuItem setAlphabeticShortcut(char alphaChar) {
+ mWrappedObject.setAlphabeticShortcut(alphaChar);
+ return this;
+ }
+
+ @Override
+ public char getAlphabeticShortcut() {
+ return mWrappedObject.getAlphabeticShortcut();
+ }
+
+ @Override
+ public MenuItem setCheckable(boolean checkable) {
+ mWrappedObject.setCheckable(checkable);
+ return this;
+ }
+
+ @Override
+ public boolean isCheckable() {
+ return mWrappedObject.isCheckable();
+ }
+
+ @Override
+ public MenuItem setChecked(boolean checked) {
+ mWrappedObject.setChecked(checked);
+ return this;
+ }
+
+ @Override
+ public boolean isChecked() {
+ return mWrappedObject.isChecked();
+ }
+
+ @Override
+ public MenuItem setVisible(boolean visible) {
+ mWrappedObject.setVisible(visible);
+ return this;
+ }
+
+ @Override
+ public boolean isVisible() {
+ return mWrappedObject.isVisible();
+ }
+
+ @Override
+ public MenuItem setEnabled(boolean enabled) {
+ mWrappedObject.setEnabled(enabled);
+ return this;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return mWrappedObject.isEnabled();
+ }
+
+ @Override
+ public boolean hasSubMenu() {
+ return mWrappedObject.hasSubMenu();
+ }
+
+ @Override
+ public SubMenu getSubMenu() {
+ return getSubMenuWrapper(mWrappedObject.getSubMenu());
+ }
+
+ @Override
+ public MenuItem setOnMenuItemClickListener(OnMenuItemClickListener menuItemClickListener) {
+ mWrappedObject.setOnMenuItemClickListener(
+ new OnMenuItemClickListenerWrapper(menuItemClickListener));
+ return this;
+ }
+
+ @Override
+ public ContextMenu.ContextMenuInfo getMenuInfo() {
+ return mWrappedObject.getMenuInfo();
+ }
+
+ @Override
+ public void setShowAsAction(int actionEnum) {
+ mWrappedObject.setShowAsAction(actionEnum);
+ }
+
+ @Override
+ public MenuItem setShowAsActionFlags(int actionEnum) {
+ mWrappedObject.setShowAsActionFlags(actionEnum);
+ return this;
+ }
+
+ @Override
+ public MenuItem setActionView(View view) {
+ mWrappedObject.setActionView(view);
+ return this;
+ }
+
+ @Override
+ public MenuItem setActionView(int resId) {
+ mWrappedObject.setActionView(resId);
+ return this;
+ }
+
+ @Override
+ public View getActionView() {
+ return mWrappedObject.getActionView();
+ }
+
+ @Override
+ public MenuItem setActionProvider(ActionProvider actionProvider) {
+ mActionProvider = actionProvider;
+ mWrappedObject.setActionProvider(actionProvider != null ?
+ new ActionProviderWrapper(actionProvider) : null);
+ return this;
+ }
+
+ @Override
+ public ActionProvider getActionProvider() {
+ return mActionProvider;
+ }
+
+ @Override
+ public boolean expandActionView() {
+ // APIv14+ API
+ return false;
+ }
+
+ @Override
+ public boolean collapseActionView() {
+ // APIv14+ API
+ return false;
+ }
+
+ @Override
+ public boolean isActionViewExpanded() {
+ // APIv14+ API
+ return false;
+ }
+
+ @Override
+ public MenuItem setOnActionExpandListener(OnActionExpandListener listener) {
+ // APIv14+ API
+ return null;
+ }
+
+ @Override
+ MenuItem createMenuItemWrapper(android.view.MenuItem menuItem) {
+ return new MenuItemWrapperHC(menuItem);
+ }
+
+ @Override
+ SubMenu createSubMenuWrapper(android.view.SubMenu subMenu) {
+ return new SubMenuWrapperHC(subMenu);
+ }
+
+ private class OnMenuItemClickListenerWrapper extends BaseWrapper<OnMenuItemClickListener>
+ implements android.view.MenuItem.OnMenuItemClickListener {
+
+ OnMenuItemClickListenerWrapper(OnMenuItemClickListener object) {
+ super(object);
+ }
+
+ @Override
+ public boolean onMenuItemClick(android.view.MenuItem item) {
+ return mWrappedObject.onMenuItemClick(getMenuItemWrapper(item));
+ }
+ }
+
+ private final class ActionProviderWrapper extends android.view.ActionProvider {
+ private final ActionProvider mInner;
+
+ public ActionProviderWrapper(ActionProvider inner) {
+ super(inner.getContext());
+ mInner = inner;
+ }
+
+ @Override
+ @SuppressWarnings("deprecation")
+ public View onCreateActionView() {
+ return mInner.onCreateActionView();
+ }
+
+ @Override
+ public boolean isVisible() {
+ return true;
+ }
+
+ @Override
+ public void refreshVisibility() {
+ }
+
+ @Override
+ public boolean onPerformDefaultAction() {
+ return mInner.onPerformDefaultAction();
+ }
+
+ @Override
+ public boolean hasSubMenu() {
+ return mInner.hasSubMenu();
+ }
+
+ @Override
+ public void onPrepareSubMenu(android.view.SubMenu subMenu) {
+ mInner.onPrepareSubMenu(new SubMenuWrapperHC(subMenu));
+ }
+ }
+}
diff --git a/v7/appcompat/src/android/support/v7/internal/view/menu/MenuItemWrapperICS.java b/v7/appcompat/src/android/support/v7/internal/view/menu/MenuItemWrapperICS.java
new file mode 100644
index 0000000..de5a284
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/MenuItemWrapperICS.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.internal.view.menu;
+
+import android.support.v7.view.ActionProvider;
+import android.support.v7.view.MenuItem;
+import android.support.v7.view.SubMenu;
+import android.view.View;
+
+class MenuItemWrapperICS extends MenuItemWrapperHC {
+
+ MenuItemWrapperICS(android.view.MenuItem object) {
+ super(object);
+ }
+
+ @Override
+ public MenuItem setActionProvider(ActionProvider actionProvider) {
+ mWrappedObject.setActionProvider(new ActionProviderWrapper(actionProvider));
+ return this;
+ }
+
+ @Override
+ public ActionProvider getActionProvider() {
+ return ((ActionProviderWrapper) mWrappedObject.getActionProvider()).getWrappedObject();
+ }
+
+ @Override
+ public boolean expandActionView() {
+ return mWrappedObject.expandActionView();
+ }
+
+ @Override
+ public boolean collapseActionView() {
+ return mWrappedObject.collapseActionView();
+ }
+
+ @Override
+ public boolean isActionViewExpanded() {
+ return mWrappedObject.isActionViewExpanded();
+ }
+
+ @Override
+ public MenuItem setOnActionExpandListener(MenuItem.OnActionExpandListener listener) {
+ mWrappedObject.setOnActionExpandListener(new OnActionExpandListenerWrapper(listener));
+ return this;
+ }
+
+ @Override
+ MenuItem createMenuItemWrapper(android.view.MenuItem menuItem) {
+ return new MenuItemWrapperICS(menuItem);
+ }
+
+ @Override
+ SubMenu createSubMenuWrapper(android.view.SubMenu subMenu) {
+ return new SubMenuWrapperICS(subMenu);
+ }
+
+ private class OnActionExpandListenerWrapper extends BaseWrapper<MenuItem.OnActionExpandListener>
+ implements android.view.MenuItem.OnActionExpandListener {
+
+ OnActionExpandListenerWrapper(MenuItem.OnActionExpandListener object) {
+ super(object);
+ }
+
+ @Override
+ public boolean onMenuItemActionExpand(android.view.MenuItem item) {
+ return mWrappedObject.onMenuItemActionExpand(getMenuItemWrapper(item));
+ }
+
+ @Override
+ public boolean onMenuItemActionCollapse(android.view.MenuItem item) {
+ return mWrappedObject.onMenuItemActionCollapse(getMenuItemWrapper(item));
+ }
+ }
+
+ private class ActionProviderWrapper extends android.view.ActionProvider {
+
+ private final ActionProvider mWrappedObject;
+
+ public ActionProviderWrapper(ActionProvider object) {
+ super(null);
+ mWrappedObject = object;
+ }
+
+ @Override
+ public View onCreateActionView() {
+ return mWrappedObject.onCreateActionView();
+ }
+
+ @Override
+ public boolean onPerformDefaultAction() {
+ return mWrappedObject.onPerformDefaultAction();
+ }
+
+ @Override
+ public boolean hasSubMenu() {
+ return mWrappedObject.hasSubMenu();
+ }
+
+ @Override
+ public void onPrepareSubMenu(android.view.SubMenu subMenu) {
+ mWrappedObject.onPrepareSubMenu(getSubMenuWrapper(subMenu));
+ }
+
+ ActionProvider getWrappedObject() {
+ return mWrappedObject;
+ }
+ }
+
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/MenuPopupHelper.java b/v7/appcompat/src/android/support/v7/internal/view/menu/MenuPopupHelper.java
similarity index 97%
rename from appcompat/eclair/android/support/appcompat/view/menu/MenuPopupHelper.java
rename to v7/appcompat/src/android/support/v7/internal/view/menu/MenuPopupHelper.java
index 84dfcf7..802f457 100644
--- a/appcompat/eclair/android/support/appcompat/view/menu/MenuPopupHelper.java
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/MenuPopupHelper.java
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-package android.support.appcompat.view.menu;
+package android.support.v7.internal.view.menu;
import android.content.Context;
import android.content.res.Resources;
import android.os.Parcelable;
-import android.support.appcompat.R;
-import android.support.appcompat.view.MenuItem;
-import android.support.appcompat.widget.ListPopupWindow;
+import android.support.v7.appcompat.R;
+import android.support.v7.internal.widget.ListPopupWindow;
+import android.support.v7.view.MenuItem;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
@@ -47,7 +47,7 @@
private static final String TAG = "MenuPopupHelper";
- static final int ITEM_LAYOUT = R.layout.popup_menu_item_layout;
+ static final int ITEM_LAYOUT = R.layout.abc_popup_menu_item_layout;
private Context mContext;
private LayoutInflater mInflater;
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/MenuPresenter.java b/v7/appcompat/src/android/support/v7/internal/view/menu/MenuPresenter.java
similarity index 97%
rename from appcompat/eclair/android/support/appcompat/view/menu/MenuPresenter.java
rename to v7/appcompat/src/android/support/v7/internal/view/menu/MenuPresenter.java
index 0c5a2be..62a22a9 100644
--- a/appcompat/eclair/android/support/appcompat/view/menu/MenuPresenter.java
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/MenuPresenter.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package android.support.appcompat.view.menu;
+package android.support.v7.internal.view.menu;
-import android.support.appcompat.view.Menu;
+import android.support.v7.view.Menu;
import android.content.Context;
import android.os.Parcelable;
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/MenuView.java b/v7/appcompat/src/android/support/v7/internal/view/menu/MenuView.java
similarity index 95%
rename from appcompat/eclair/android/support/appcompat/view/menu/MenuView.java
rename to v7/appcompat/src/android/support/v7/internal/view/menu/MenuView.java
index 614c95e..43068a5 100644
--- a/appcompat/eclair/android/support/appcompat/view/menu/MenuView.java
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/MenuView.java
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-package android.support.appcompat.view.menu;
+package android.support.v7.internal.view.menu;
-import android.support.appcompat.view.menu.MenuBuilder;
-import android.support.appcompat.view.menu.MenuItemImpl;
+import android.support.v7.internal.view.menu.MenuBuilder;
+import android.support.v7.internal.view.menu.MenuItemImpl;
import android.graphics.drawable.Drawable;
diff --git a/v7/appcompat/src/android/support/v7/internal/view/menu/MenuWrapper.java b/v7/appcompat/src/android/support/v7/internal/view/menu/MenuWrapper.java
new file mode 100644
index 0000000..82a9ad6
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/MenuWrapper.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.internal.view.menu;
+
+import android.os.Build;
+import android.support.v7.view.Menu;
+import android.support.v7.view.MenuItem;
+
+public class MenuWrapper {
+
+ public static Menu createMenuWrapper(android.view.Menu frameworkMenu) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
+ return new MenuWrapperHC(frameworkMenu);
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ return new MenuWrapperICS(frameworkMenu);
+ }
+
+ return null;
+ }
+
+ public static MenuItem createMenuItemWrapper(android.view.MenuItem frameworkMenuItem) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
+ return new MenuItemWrapperHC(frameworkMenuItem);
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ return new MenuItemWrapperICS(frameworkMenuItem);
+ }
+
+ return null;
+ }
+
+}
diff --git a/v7/appcompat/src/android/support/v7/internal/view/menu/MenuWrapperHC.java b/v7/appcompat/src/android/support/v7/internal/view/menu/MenuWrapperHC.java
new file mode 100644
index 0000000..ed1f5ad
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/MenuWrapperHC.java
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.internal.view.menu;
+
+import android.content.ComponentName;
+import android.content.Intent;
+import android.support.v7.view.Menu;
+import android.support.v7.view.MenuItem;
+import android.support.v7.view.SubMenu;
+import android.view.KeyEvent;
+
+class MenuWrapperHC extends BaseMenuWrapper<android.view.Menu> implements Menu {
+
+ MenuWrapperHC(android.view.Menu object) {
+ super(object);
+ }
+
+ @Override
+ public MenuItem add(CharSequence title) {
+ return getMenuItemWrapper(mWrappedObject.add(title));
+ }
+
+ @Override
+ public MenuItem add(int titleRes) {
+ return getMenuItemWrapper(mWrappedObject.add(titleRes));
+ }
+
+ @Override
+ public MenuItem add(int groupId, int itemId, int order, CharSequence title) {
+ return getMenuItemWrapper(mWrappedObject.add(groupId, itemId, order, title));
+ }
+
+ @Override
+ public MenuItem add(int groupId, int itemId, int order, int titleRes) {
+ return getMenuItemWrapper(mWrappedObject.add(groupId, itemId, order, titleRes));
+ }
+
+ @Override
+ public SubMenu addSubMenu(CharSequence title) {
+ return getSubMenuWrapper(mWrappedObject.addSubMenu(title));
+ }
+
+ @Override
+ public SubMenu addSubMenu(int titleRes) {
+ return getSubMenuWrapper(mWrappedObject.addSubMenu(titleRes));
+ }
+
+ @Override
+ public SubMenu addSubMenu(int groupId, int itemId, int order, CharSequence title) {
+ return getSubMenuWrapper(mWrappedObject.addSubMenu(groupId, itemId, order, title));
+ }
+
+ @Override
+ public SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes) {
+ return getSubMenuWrapper(
+ mWrappedObject.addSubMenu(groupId, itemId, order, titleRes));
+ }
+
+ @Override
+ public int addIntentOptions(int groupId, int itemId, int order, ComponentName caller,
+ Intent[] specifics, Intent intent, int flags, MenuItem[] outSpecificItems) {
+ android.view.MenuItem[] items = null;
+ if (outSpecificItems != null) {
+ items = new android.view.MenuItem[outSpecificItems.length];
+ }
+
+ int result = mWrappedObject
+ .addIntentOptions(groupId, itemId, order, caller, specifics, intent, flags, items);
+
+ if (items != null) {
+ for (int i = 0, z = items.length; i < z; i++) {
+ outSpecificItems[i] = getMenuItemWrapper(items[i]);
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public void removeItem(int id) {
+ internalRemoveItem(id);
+ mWrappedObject.removeItem(id);
+ }
+
+ @Override
+ public void removeGroup(int groupId) {
+ internalRemoveGroup(groupId);
+ mWrappedObject.removeGroup(groupId);
+ }
+
+ @Override
+ public void clear() {
+ internalClear();
+ mWrappedObject.clear();
+ }
+
+ @Override
+ public void setGroupCheckable(int group, boolean checkable, boolean exclusive) {
+ mWrappedObject.setGroupCheckable(group, checkable, exclusive);
+ }
+
+ @Override
+ public void setGroupVisible(int group, boolean visible) {
+ mWrappedObject.setGroupVisible(group, visible);
+ }
+
+ @Override
+ public void setGroupEnabled(int group, boolean enabled) {
+ mWrappedObject.setGroupEnabled(group, enabled);
+ }
+
+ @Override
+ public boolean hasVisibleItems() {
+ return mWrappedObject.hasVisibleItems();
+ }
+
+ @Override
+ public MenuItem findItem(int id) {
+ return getMenuItemWrapper(mWrappedObject.findItem(id));
+ }
+
+ @Override
+ public int size() {
+ return mWrappedObject.size();
+ }
+
+ @Override
+ public MenuItem getItem(int index) {
+ return getMenuItemWrapper(mWrappedObject.getItem(index));
+ }
+
+ @Override
+ public void close() {
+ mWrappedObject.close();
+ }
+
+ @Override
+ public boolean performShortcut(int keyCode, KeyEvent event, int flags) {
+ return mWrappedObject.performShortcut(keyCode, event, flags);
+ }
+
+ @Override
+ public boolean isShortcutKey(int keyCode, KeyEvent event) {
+ return mWrappedObject.isShortcutKey(keyCode, event);
+ }
+
+ @Override
+ public boolean performIdentifierAction(int id, int flags) {
+ return mWrappedObject.performIdentifierAction(id, flags);
+ }
+
+ @Override
+ public void setQwertyMode(boolean isQwerty) {
+ mWrappedObject.setQwertyMode(isQwerty);
+ }
+
+ @Override
+ MenuItem createMenuItemWrapper(android.view.MenuItem menuItem) {
+ return new MenuItemWrapperHC(menuItem);
+ }
+
+ @Override
+ SubMenu createSubMenuWrapper(android.view.SubMenu subMenu) {
+ return new SubMenuWrapperHC(subMenu);
+ }
+
+}
diff --git a/v7/appcompat/src/android/support/v7/internal/view/menu/MenuWrapperICS.java b/v7/appcompat/src/android/support/v7/internal/view/menu/MenuWrapperICS.java
new file mode 100644
index 0000000..f6ecdf1
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/MenuWrapperICS.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.internal.view.menu;
+
+import android.support.v7.view.MenuItem;
+import android.support.v7.view.SubMenu;
+
+class MenuWrapperICS extends MenuWrapperHC {
+
+ MenuWrapperICS(android.view.Menu object) {
+ super(object);
+ }
+
+ @Override
+ MenuItem createMenuItemWrapper(android.view.MenuItem menuItem) {
+ return new MenuItemWrapperICS(menuItem);
+ }
+
+ @Override
+ SubMenu createSubMenuWrapper(android.view.SubMenu subMenu) {
+ return new SubMenuWrapperICS(subMenu);
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/menu/SubMenuBuilder.java b/v7/appcompat/src/android/support/v7/internal/view/menu/SubMenuBuilder.java
similarity index 94%
rename from appcompat/eclair/android/support/appcompat/view/menu/SubMenuBuilder.java
rename to v7/appcompat/src/android/support/v7/internal/view/menu/SubMenuBuilder.java
index ff4cdb9..a8a5266 100644
--- a/appcompat/eclair/android/support/appcompat/view/menu/SubMenuBuilder.java
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/SubMenuBuilder.java
@@ -14,14 +14,13 @@
* limitations under the License.
*/
-package android.support.appcompat.view.menu;
-
-import android.support.appcompat.view.Menu;
+package android.support.v7.internal.view.menu;
import android.content.Context;
import android.graphics.drawable.Drawable;
-import android.support.appcompat.view.MenuItem;
-import android.support.appcompat.view.SubMenu;
+import android.support.v7.view.Menu;
+import android.support.v7.view.MenuItem;
+import android.support.v7.view.SubMenu;
import android.view.View;
/**
diff --git a/v7/appcompat/src/android/support/v7/internal/view/menu/SubMenuWrapperHC.java b/v7/appcompat/src/android/support/v7/internal/view/menu/SubMenuWrapperHC.java
new file mode 100644
index 0000000..e56e90c
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/SubMenuWrapperHC.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.internal.view.menu;
+
+import android.graphics.drawable.Drawable;
+import android.support.v7.view.MenuItem;
+import android.support.v7.view.SubMenu;
+import android.view.View;
+
+class SubMenuWrapperHC extends MenuWrapperHC implements SubMenu {
+
+ SubMenuWrapperHC(android.view.SubMenu subMenu) {
+ super(subMenu);
+ }
+
+ @Override
+ public android.view.SubMenu getWrappedObject() {
+ return (android.view.SubMenu) mWrappedObject;
+ }
+
+ @Override
+ public SubMenu setHeaderTitle(int titleRes) {
+ ((android.view.SubMenu) mWrappedObject).setHeaderTitle(titleRes);
+ return this;
+ }
+
+ @Override
+ public SubMenu setHeaderTitle(CharSequence title) {
+ ((android.view.SubMenu) mWrappedObject).setHeaderTitle(title);
+ return this;
+ }
+
+ @Override
+ public SubMenu setHeaderIcon(int iconRes) {
+ ((android.view.SubMenu) mWrappedObject).setHeaderIcon(iconRes);
+ return this;
+ }
+
+ @Override
+ public SubMenu setHeaderIcon(Drawable icon) {
+ ((android.view.SubMenu) mWrappedObject).setHeaderIcon(icon);
+ return this;
+ }
+
+ @Override
+ public SubMenu setHeaderView(View view) {
+ ((android.view.SubMenu) mWrappedObject).setHeaderView(view);
+ return this;
+ }
+
+ @Override
+ public void clearHeader() {
+ ((android.view.SubMenu) mWrappedObject).clearHeader();
+ }
+
+ @Override
+ public SubMenu setIcon(int iconRes) {
+ ((android.view.SubMenu) mWrappedObject).setIcon(iconRes);
+ return this;
+ }
+
+ @Override
+ public SubMenu setIcon(Drawable icon) {
+ ((android.view.SubMenu) mWrappedObject).setIcon(icon);
+ return this;
+ }
+
+ @Override
+ public MenuItem getItem() {
+ return getMenuItemWrapper(((android.view.SubMenu) mWrappedObject).getItem());
+ }
+}
diff --git a/v7/appcompat/src/android/support/v7/internal/view/menu/SubMenuWrapperICS.java b/v7/appcompat/src/android/support/v7/internal/view/menu/SubMenuWrapperICS.java
new file mode 100644
index 0000000..7a36d98
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/internal/view/menu/SubMenuWrapperICS.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.internal.view.menu;
+
+import android.support.v7.view.MenuItem;
+import android.support.v7.view.SubMenu;
+
+class SubMenuWrapperICS extends SubMenuWrapperHC implements SubMenu {
+
+ SubMenuWrapperICS(android.view.SubMenu subMenu) {
+ super(subMenu);
+ }
+
+ @Override
+ MenuItem createMenuItemWrapper(android.view.MenuItem menuItem) {
+ return new MenuItemWrapperICS(menuItem);
+ }
+
+ @Override
+ SubMenu createSubMenuWrapper(android.view.SubMenu subMenu) {
+ return new SubMenuWrapperICS(subMenu);
+ }
+
+}
diff --git a/appcompat/eclair/android/support/appcompat/widget/AbsActionBarView.java b/v7/appcompat/src/android/support/v7/internal/widget/AbsActionBarView.java
similarity index 84%
rename from appcompat/eclair/android/support/appcompat/widget/AbsActionBarView.java
rename to v7/appcompat/src/android/support/v7/internal/widget/AbsActionBarView.java
index 2c4392a..9130f88 100644
--- a/appcompat/eclair/android/support/appcompat/widget/AbsActionBarView.java
+++ b/v7/appcompat/src/android/support/v7/internal/widget/AbsActionBarView.java
@@ -13,20 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package android.support.appcompat.widget;
+package android.support.v7.internal.widget;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.os.Build;
-import android.support.appcompat.R;
-import android.support.appcompat.view.menu.ActionMenuPresenter;
-import android.support.appcompat.view.menu.ActionMenuView;
+import android.support.v7.appcompat.R;
+import android.support.v7.internal.view.menu.ActionMenuPresenter;
+import android.support.v7.internal.view.menu.ActionMenuView;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
-public abstract class AbsActionBarView extends ViewGroup {
+abstract class AbsActionBarView extends ViewGroup {
protected ActionMenuView mMenuView;
@@ -42,15 +44,15 @@
private static final int FADE_DURATION = 200;
- public AbsActionBarView(Context context) {
+ AbsActionBarView(Context context) {
super(context);
}
- public AbsActionBarView(Context context, AttributeSet attrs) {
+ AbsActionBarView(Context context, AttributeSet attrs) {
super(context, attrs);
}
- public AbsActionBarView(Context context, AttributeSet attrs, int defStyle) {
+ AbsActionBarView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@@ -114,7 +116,20 @@
}
public void animateToVisibility(int visibility) {
- setVisibility(visibility);
+ clearAnimation();
+
+ if (visibility != getVisibility()) {
+ Animation anim = AnimationUtils.loadAnimation(getContext(),
+ visibility == View.VISIBLE ? R.anim.abc_fade_in : R.anim.abc_fade_out);
+
+ startAnimation(anim);
+ setVisibility(visibility);
+
+ if (mSplitView != null && mMenuView != null) {
+ mMenuView.startAnimation(anim);
+ mMenuView.setVisibility(visibility);
+ }
+ }
}
@Override
diff --git a/v7/appcompat/src/android/support/v7/internal/widget/AbsSpinnerICS.java b/v7/appcompat/src/android/support/v7/internal/widget/AbsSpinnerICS.java
new file mode 100644
index 0000000..4bb4c0f
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/internal/widget/AbsSpinnerICS.java
@@ -0,0 +1,453 @@
+/*
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.internal.widget;
+
+import android.content.Context;
+import android.database.DataSetObserver;
+import android.graphics.Rect;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.AttributeSet;
+import android.util.SparseArray;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.SpinnerAdapter;
+
+/**
+ * An abstract base class for spinner widgets. SDK users will probably not
+ * need to use this class.
+ */
+abstract class AbsSpinnerICS extends AdapterViewICS<SpinnerAdapter> {
+ SpinnerAdapter mAdapter;
+
+ int mHeightMeasureSpec;
+ int mWidthMeasureSpec;
+ boolean mBlockLayoutRequests;
+
+ int mSelectionLeftPadding = 0;
+ int mSelectionTopPadding = 0;
+ int mSelectionRightPadding = 0;
+ int mSelectionBottomPadding = 0;
+ final Rect mSpinnerPadding = new Rect();
+
+ final RecycleBin mRecycler = new RecycleBin();
+ private DataSetObserver mDataSetObserver;
+
+ /** Temporary frame to hold a child View's frame rectangle */
+ private Rect mTouchFrame;
+
+ AbsSpinnerICS(Context context) {
+ super(context);
+ initAbsSpinner();
+ }
+
+ AbsSpinnerICS(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ AbsSpinnerICS(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ initAbsSpinner();
+ }
+
+ /**
+ * Common code for different constructor flavors
+ */
+ private void initAbsSpinner() {
+ setFocusable(true);
+ setWillNotDraw(false);
+ }
+
+ /**
+ * The Adapter is used to provide the data which backs this Spinner.
+ * It also provides methods to transform spinner items based on their position
+ * relative to the selected item.
+ * @param adapter The SpinnerAdapter to use for this Spinner
+ */
+ @Override
+ public void setAdapter(SpinnerAdapter adapter) {
+ if (null != mAdapter) {
+ mAdapter.unregisterDataSetObserver(mDataSetObserver);
+ resetList();
+ }
+
+ mAdapter = adapter;
+
+ mOldSelectedPosition = INVALID_POSITION;
+ mOldSelectedRowId = INVALID_ROW_ID;
+
+ if (mAdapter != null) {
+ mOldItemCount = mItemCount;
+ mItemCount = mAdapter.getCount();
+ checkFocus();
+
+ mDataSetObserver = new AdapterDataSetObserver();
+ mAdapter.registerDataSetObserver(mDataSetObserver);
+
+ int position = mItemCount > 0 ? 0 : INVALID_POSITION;
+
+ setSelectedPositionInt(position);
+ setNextSelectedPositionInt(position);
+
+ if (mItemCount == 0) {
+ // Nothing selected
+ checkSelectionChanged();
+ }
+
+ } else {
+ checkFocus();
+ resetList();
+ // Nothing selected
+ checkSelectionChanged();
+ }
+
+ requestLayout();
+ }
+
+ /**
+ * Clear out all children from the list
+ */
+ void resetList() {
+ mDataChanged = false;
+ mNeedSync = false;
+
+ removeAllViewsInLayout();
+ mOldSelectedPosition = INVALID_POSITION;
+ mOldSelectedRowId = INVALID_ROW_ID;
+
+ setSelectedPositionInt(INVALID_POSITION);
+ setNextSelectedPositionInt(INVALID_POSITION);
+ invalidate();
+ }
+
+ /**
+ * @see android.view.View#measure(int, int)
+ *
+ * Figure out the dimensions of this Spinner. The width comes from
+ * the widthMeasureSpec as Spinnners can't have their width set to
+ * UNSPECIFIED. The height is based on the height of the selected item
+ * plus padding.
+ */
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ int widthMode = MeasureSpec.getMode(widthMeasureSpec);
+ int widthSize;
+ int heightSize;
+
+ final int paddingLeft = getPaddingLeft();
+ final int paddingTop = getPaddingTop();
+ final int paddingRight = getPaddingRight();
+ final int paddingBottom = getPaddingBottom();
+
+ mSpinnerPadding.left = paddingLeft > mSelectionLeftPadding ? paddingLeft
+ : mSelectionLeftPadding;
+ mSpinnerPadding.top = paddingTop > mSelectionTopPadding ? paddingTop
+ : mSelectionTopPadding;
+ mSpinnerPadding.right = paddingRight > mSelectionRightPadding ? paddingRight
+ : mSelectionRightPadding;
+ mSpinnerPadding.bottom = paddingBottom > mSelectionBottomPadding ? paddingBottom
+ : mSelectionBottomPadding;
+
+ if (mDataChanged) {
+ handleDataChanged();
+ }
+
+ int preferredHeight = 0;
+ int preferredWidth = 0;
+ boolean needsMeasuring = true;
+
+ int selectedPosition = getSelectedItemPosition();
+ if (selectedPosition >= 0 && mAdapter != null && selectedPosition < mAdapter.getCount()) {
+ // Try looking in the recycler. (Maybe we were measured once already)
+ View view = mRecycler.get(selectedPosition);
+ if (view == null) {
+ // Make a new one
+ view = mAdapter.getView(selectedPosition, null, this);
+ }
+
+ if (view != null) {
+ // Put in recycler for re-measuring and/or layout
+ mRecycler.put(selectedPosition, view);
+ }
+
+ if (view != null) {
+ if (view.getLayoutParams() == null) {
+ mBlockLayoutRequests = true;
+ view.setLayoutParams(generateDefaultLayoutParams());
+ mBlockLayoutRequests = false;
+ }
+ measureChild(view, widthMeasureSpec, heightMeasureSpec);
+
+ preferredHeight = getChildHeight(view) + mSpinnerPadding.top + mSpinnerPadding.bottom;
+ preferredWidth = getChildWidth(view) + mSpinnerPadding.left + mSpinnerPadding.right;
+
+ needsMeasuring = false;
+ }
+ }
+
+ if (needsMeasuring) {
+ // No views -- just use padding
+ preferredHeight = mSpinnerPadding.top + mSpinnerPadding.bottom;
+ if (widthMode == MeasureSpec.UNSPECIFIED) {
+ preferredWidth = mSpinnerPadding.left + mSpinnerPadding.right;
+ }
+ }
+
+ preferredHeight = Math.max(preferredHeight, getSuggestedMinimumHeight());
+ preferredWidth = Math.max(preferredWidth, getSuggestedMinimumWidth());
+
+ heightSize = resolveSize(preferredHeight, heightMeasureSpec);
+ widthSize = resolveSize(preferredWidth, widthMeasureSpec);
+
+ setMeasuredDimension(widthSize, heightSize);
+ mHeightMeasureSpec = heightMeasureSpec;
+ mWidthMeasureSpec = widthMeasureSpec;
+ }
+
+ int getChildHeight(View child) {
+ return child.getMeasuredHeight();
+ }
+
+ int getChildWidth(View child) {
+ return child.getMeasuredWidth();
+ }
+
+ @Override
+ protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
+ return new ViewGroup.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT);
+ }
+
+ void recycleAllViews() {
+ final int childCount = getChildCount();
+ final AbsSpinnerICS.RecycleBin recycleBin = mRecycler;
+ final int position = mFirstPosition;
+
+ // All views go in recycler
+ for (int i = 0; i < childCount; i++) {
+ View v = getChildAt(i);
+ int index = position + i;
+ recycleBin.put(index, v);
+ }
+ }
+
+ /**
+ * Jump directly to a specific item in the adapter data.
+ */
+ public void setSelection(int position, boolean animate) {
+ // Animate only if requested position is already on screen somewhere
+ boolean shouldAnimate = animate && mFirstPosition <= position &&
+ position <= mFirstPosition + getChildCount() - 1;
+ setSelectionInt(position, shouldAnimate);
+ }
+
+ @Override
+ public void setSelection(int position) {
+ setNextSelectedPositionInt(position);
+ requestLayout();
+ invalidate();
+ }
+
+
+ /**
+ * Makes the item at the supplied position selected.
+ *
+ * @param position Position to select
+ * @param animate Should the transition be animated
+ *
+ */
+ void setSelectionInt(int position, boolean animate) {
+ if (position != mOldSelectedPosition) {
+ mBlockLayoutRequests = true;
+ int delta = position - mSelectedPosition;
+ setNextSelectedPositionInt(position);
+ layout(delta, animate);
+ mBlockLayoutRequests = false;
+ }
+ }
+
+ abstract void layout(int delta, boolean animate);
+
+ @Override
+ public View getSelectedView() {
+ if (mItemCount > 0 && mSelectedPosition >= 0) {
+ return getChildAt(mSelectedPosition - mFirstPosition);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Override to prevent spamming ourselves with layout requests
+ * as we place views
+ *
+ * @see android.view.View#requestLayout()
+ */
+ @Override
+ public void requestLayout() {
+ if (!mBlockLayoutRequests) {
+ super.requestLayout();
+ }
+ }
+
+ @Override
+ public SpinnerAdapter getAdapter() {
+ return mAdapter;
+ }
+
+ @Override
+ public int getCount() {
+ return mItemCount;
+ }
+
+ /**
+ * Maps a point to a position in the list.
+ *
+ * @param x X in local coordinate
+ * @param y Y in local coordinate
+ * @return The position of the item which contains the specified point, or
+ * {@link #INVALID_POSITION} if the point does not intersect an item.
+ */
+ public int pointToPosition(int x, int y) {
+ Rect frame = mTouchFrame;
+ if (frame == null) {
+ mTouchFrame = new Rect();
+ frame = mTouchFrame;
+ }
+
+ final int count = getChildCount();
+ for (int i = count - 1; i >= 0; i--) {
+ View child = getChildAt(i);
+ if (child.getVisibility() == View.VISIBLE) {
+ child.getHitRect(frame);
+ if (frame.contains(x, y)) {
+ return mFirstPosition + i;
+ }
+ }
+ }
+ return INVALID_POSITION;
+ }
+
+ static class SavedState extends BaseSavedState {
+ long selectedId;
+ int position;
+
+ /**
+ * Constructor called from {@link AbsSpinnerICS#onSaveInstanceState()}
+ */
+ SavedState(Parcelable superState) {
+ super(superState);
+ }
+
+ /**
+ * Constructor called from {@link #CREATOR}
+ */
+ private SavedState(Parcel in) {
+ super(in);
+ selectedId = in.readLong();
+ position = in.readInt();
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ super.writeToParcel(out, flags);
+ out.writeLong(selectedId);
+ out.writeInt(position);
+ }
+
+ @Override
+ public String toString() {
+ return "AbsSpinner.SavedState{"
+ + Integer.toHexString(System.identityHashCode(this))
+ + " selectedId=" + selectedId
+ + " position=" + position + "}";
+ }
+
+ public static final Parcelable.Creator<SavedState> CREATOR
+ = new Parcelable.Creator<SavedState>() {
+ public SavedState createFromParcel(Parcel in) {
+ return new SavedState(in);
+ }
+
+ public SavedState[] newArray(int size) {
+ return new SavedState[size];
+ }
+ };
+ }
+
+ @Override
+ public Parcelable onSaveInstanceState() {
+ Parcelable superState = super.onSaveInstanceState();
+ SavedState ss = new SavedState(superState);
+ ss.selectedId = getSelectedItemId();
+ if (ss.selectedId >= 0) {
+ ss.position = getSelectedItemPosition();
+ } else {
+ ss.position = INVALID_POSITION;
+ }
+ return ss;
+ }
+
+ @Override
+ public void onRestoreInstanceState(Parcelable state) {
+ SavedState ss = (SavedState) state;
+
+ super.onRestoreInstanceState(ss.getSuperState());
+
+ if (ss.selectedId >= 0) {
+ mDataChanged = true;
+ mNeedSync = true;
+ mSyncRowId = ss.selectedId;
+ mSyncPosition = ss.position;
+ mSyncMode = SYNC_SELECTED_POSITION;
+ requestLayout();
+ }
+ }
+
+ class RecycleBin {
+ private final SparseArray<View> mScrapHeap = new SparseArray<View>();
+
+ public void put(int position, View v) {
+ mScrapHeap.put(position, v);
+ }
+
+ View get(int position) {
+ // System.out.print("Looking for " + position);
+ View result = mScrapHeap.get(position);
+ if (result != null) {
+ // System.out.println(" HIT");
+ mScrapHeap.delete(position);
+ } else {
+ // System.out.println(" MISS");
+ }
+ return result;
+ }
+
+ void clear() {
+ final SparseArray<View> scrapHeap = mScrapHeap;
+ final int count = scrapHeap.size();
+ for (int i = 0; i < count; i++) {
+ final View view = scrapHeap.valueAt(i);
+ if (view != null) {
+ removeDetachedView(view, true);
+ }
+ }
+ scrapHeap.clear();
+ }
+ }
+}
\ No newline at end of file
diff --git a/appcompat/eclair/android/support/appcompat/widget/ActionBarContainer.java b/v7/appcompat/src/android/support/v7/internal/widget/ActionBarContainer.java
similarity index 97%
rename from appcompat/eclair/android/support/appcompat/widget/ActionBarContainer.java
rename to v7/appcompat/src/android/support/v7/internal/widget/ActionBarContainer.java
index 1446e4f..25776d7 100644
--- a/appcompat/eclair/android/support/appcompat/widget/ActionBarContainer.java
+++ b/v7/appcompat/src/android/support/v7/internal/widget/ActionBarContainer.java
@@ -14,15 +14,15 @@
* limitations under the License.
*/
-package android.support.appcompat.widget;
+package android.support.v7.internal.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
-import android.support.appcompat.R;
-import android.support.appcompat.app.ActionBar;
-import android.support.appcompat.view.ActionMode;
+import android.support.v7.app.ActionBar;
+import android.support.v7.appcompat.R;
+import android.support.v7.view.ActionMode;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
diff --git a/appcompat/eclair/android/support/appcompat/widget/ActionBarContextView.java b/v7/appcompat/src/android/support/v7/internal/widget/ActionBarContextView.java
similarity index 96%
rename from appcompat/eclair/android/support/appcompat/widget/ActionBarContextView.java
rename to v7/appcompat/src/android/support/v7/internal/widget/ActionBarContextView.java
index bc1c8ab..07df4de 100644
--- a/appcompat/eclair/android/support/appcompat/widget/ActionBarContextView.java
+++ b/v7/appcompat/src/android/support/v7/internal/widget/ActionBarContextView.java
@@ -13,16 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package android.support.appcompat.widget;
+package android.support.v7.internal.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
-import android.support.appcompat.R;
-import android.support.appcompat.view.ActionMode;
-import android.support.appcompat.view.menu.ActionMenuPresenter;
-import android.support.appcompat.view.menu.ActionMenuView;
-import android.support.appcompat.view.menu.MenuBuilder;
+import android.support.v7.appcompat.R;
+import android.support.v7.view.ActionMode;
+import android.support.v7.internal.view.menu.ActionMenuPresenter;
+import android.support.v7.internal.view.menu.ActionMenuView;
+import android.support.v7.internal.view.menu.MenuBuilder;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
@@ -166,7 +166,7 @@
private void initTitle() {
if (mTitleLayout == null) {
LayoutInflater inflater = LayoutInflater.from(getContext());
- inflater.inflate(R.layout.action_bar_title_item, this);
+ inflater.inflate(R.layout.abc_action_bar_title_item, this);
mTitleLayout = (LinearLayout) getChildAt(getChildCount() - 1);
mTitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_title);
mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_subtitle);
@@ -193,7 +193,7 @@
public void initForMode(final ActionMode mode) {
if (mClose == null) {
LayoutInflater inflater = LayoutInflater.from(getContext());
- mClose = inflater.inflate(R.layout.action_mode_close_item, this, false);
+ mClose = inflater.inflate(R.layout.abc_action_mode_close_item, this, false);
addView(mClose);
} else if (mClose.getParent() == null) {
addView(mClose);
diff --git a/v7/appcompat/src/android/support/v7/internal/widget/ActionBarOverlayLayout.java b/v7/appcompat/src/android/support/v7/internal/widget/ActionBarOverlayLayout.java
new file mode 100644
index 0000000..e6bcc99
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/internal/widget/ActionBarOverlayLayout.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.internal.widget;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Rect;
+import android.support.v7.app.ActionBar;
+import android.support.v7.appcompat.R;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.FrameLayout;
+
+/**
+ * Special layout for the containing of an overlay action bar (and its content) to correctly handle
+ * fitting system windows when the content has request that its layout ignore them.
+ */
+public class ActionBarOverlayLayout extends FrameLayout {
+
+ private int mActionBarHeight;
+ private ActionBar mActionBar;
+ private View mContent;
+ private View mActionBarTop;
+ private ActionBarContainer mContainerView;
+ private ActionBarView mActionView;
+ private View mActionBarBottom;
+ private final Rect mZeroRect = new Rect(0, 0, 0, 0);
+
+ static final int[] mActionBarSizeAttr = new int[]{
+ R.attr.actionBarSize
+ };
+
+ public ActionBarOverlayLayout(Context context) {
+ super(context);
+ init(context);
+ }
+
+ public ActionBarOverlayLayout(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init(context);
+ }
+
+ private void init(Context context) {
+ TypedArray ta = getContext().getTheme().obtainStyledAttributes(mActionBarSizeAttr);
+ mActionBarHeight = ta.getDimensionPixelSize(0, 0);
+ ta.recycle();
+ }
+
+ public void setActionBar(ActionBar impl) {
+ mActionBar = impl;
+ }
+
+ private boolean applyInsets(View view, Rect insets, boolean left, boolean top,
+ boolean bottom, boolean right) {
+ boolean changed = false;
+ FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) view.getLayoutParams();
+ if (left && lp.leftMargin != insets.left) {
+ changed = true;
+ lp.leftMargin = insets.left;
+ }
+ if (top && lp.topMargin != insets.top) {
+ changed = true;
+ lp.topMargin = insets.top;
+ }
+ if (right && lp.rightMargin != insets.right) {
+ changed = true;
+ lp.rightMargin = insets.right;
+ }
+ if (bottom && lp.bottomMargin != insets.bottom) {
+ changed = true;
+ lp.bottomMargin = insets.bottom;
+ }
+ return changed;
+ }
+
+ void pullChildren() {
+ if (mContent == null) {
+ mContent = findViewById(R.id.action_bar_activity_content);
+ mActionBarTop = findViewById(R.id.top_action_bar);
+ mContainerView = (ActionBarContainer) findViewById(
+ R.id.action_bar_container);
+ mActionView = (ActionBarView) findViewById(R.id.action_bar);
+ mActionBarBottom = findViewById(R.id.split_action_bar);
+ }
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/widget/ActionBarView.java b/v7/appcompat/src/android/support/v7/internal/widget/ActionBarView.java
similarity index 95%
rename from appcompat/eclair/android/support/appcompat/widget/ActionBarView.java
rename to v7/appcompat/src/android/support/v7/internal/widget/ActionBarView.java
index 12f6f06..3523e22 100644
--- a/appcompat/eclair/android/support/appcompat/widget/ActionBarView.java
+++ b/v7/appcompat/src/android/support/v7/internal/widget/ActionBarView.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package android.support.appcompat.widget;
+package android.support.v7.internal.widget;
import android.app.Activity;
import android.content.Context;
@@ -27,37 +27,33 @@
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
-import android.support.appcompat.R;
-import android.support.appcompat.app.ActionBar;
-import android.support.appcompat.app.ActionBar.OnNavigationListener;
-import android.support.appcompat.view.CollapsibleActionView;
-import android.support.appcompat.view.MenuItem;
-import android.support.appcompat.view.menu.ActionMenuItem;
-import android.support.appcompat.view.menu.ActionMenuPresenter;
-import android.support.appcompat.view.menu.ActionMenuView;
-import android.support.appcompat.view.menu.MenuBuilder;
-import android.support.appcompat.view.menu.MenuItemImpl;
-import android.support.appcompat.view.menu.MenuPresenter;
-import android.support.appcompat.view.menu.MenuView;
-import android.support.appcompat.view.menu.SubMenuBuilder;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.ActionBar.OnNavigationListener;
+import android.support.v7.appcompat.R;
+import android.support.v7.internal.view.CollapsibleActionView;
+import android.support.v7.internal.view.menu.ActionMenuItem;
+import android.support.v7.internal.view.menu.ActionMenuPresenter;
+import android.support.v7.internal.view.menu.ActionMenuView;
+import android.support.v7.internal.view.menu.MenuBuilder;
+import android.support.v7.internal.view.menu.MenuItemImpl;
+import android.support.v7.internal.view.menu.MenuPresenter;
+import android.support.v7.internal.view.menu.MenuView;
+import android.support.v7.internal.view.menu.SubMenuBuilder;
+import android.support.v7.view.Menu;
+import android.support.v7.view.MenuItem;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.Window;
import android.view.accessibility.AccessibilityEvent;
-import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
-import android.widget.ProgressBar;
-import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
@@ -100,12 +96,12 @@
private TextView mSubtitleView;
private View mTitleUpView;
- private Spinner mSpinner;
+ private SpinnerICS mSpinner;
private LinearLayout mListNavLayout;
private ScrollingTabContainerView mTabScrollView;
private View mCustomNavView;
- private ProgressBar mProgressView;
- private ProgressBar mIndeterminateProgressView;
+ private ProgressBarICS mProgressView;
+ private ProgressBarICS mIndeterminateProgressView;
private int mProgressBarPadding;
private int mItemPadding;
@@ -134,17 +130,18 @@
private ExpandedActionViewMenuPresenter mExpandedMenuPresenter;
View mExpandedActionView;
- Window.Callback mWindowCallback;
+ Callback mViewCallback;
- private final AdapterView.OnItemSelectedListener mNavItemSelectedListener =
- new AdapterView.OnItemSelectedListener() {
- public void onItemSelected(AdapterView parent, View view, int position, long id) {
+ private final AdapterViewICS.OnItemSelectedListener mNavItemSelectedListener =
+ new AdapterViewICS.OnItemSelectedListener() {
+ public void onItemSelected(AdapterViewICS<?> parent, View view, int position,
+ long id) {
if (mCallback != null) {
mCallback.onNavigationItemSelected(position, id);
}
}
- public void onNothingSelected(AdapterView parent) {
+ public void onNothingSelected(AdapterViewICS<?> parent) {
// Do nothing
}
};
@@ -161,8 +158,7 @@
private final OnClickListener mUpClickListener = new OnClickListener() {
public void onClick(View v) {
- //TODO(anirudhd): Window callback is not implemented yet.
- //mWindowCallback.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mLogoNavItem);
+ mViewCallback.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mLogoNavItem);
}
};
@@ -217,7 +213,7 @@
final int homeResId = a.getResourceId(
R.styleable.ActionBar_homeLayout,
- R.layout.action_bar_home);
+ R.layout.abc_action_bar_home);
mHomeLayout = (HomeView) inflater.inflate(homeResId, this, false);
@@ -248,7 +244,7 @@
mContentHeight = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
a.recycle();
- mLogoNavItem = new ActionMenuItem(context, 0, R.id.home, 0, 0, mTitle);
+ mLogoNavItem = new ActionMenuItem(context, 0, android.R.id.home, 0, 0, mTitle);
mHomeLayout.setOnClickListener(mUpClickListener);
mHomeLayout.setClickable(true);
mHomeLayout.setFocusable(true);
@@ -281,12 +277,12 @@
}
/**
- * Set the window callback used to invoke menu items; used for dispatching home button presses.
+ * Set the view callback used to invoke menu items; used for dispatching home button presses.
*
- * @param cb Window callback to dispatch to
+ * @param cb View callback to dispatch to
*/
- public void setWindowCallback(Window.Callback cb) {
- mWindowCallback = cb;
+ public void setViewCallback(Callback cb) {
+ mViewCallback = cb;
}
@Override
@@ -304,7 +300,7 @@
}
public void initProgress() {
- mProgressView = new ProgressBar(mContext, null, mProgressStyle);
+ mProgressView = new ProgressBarICS(mContext, null, 0, mProgressStyle);
mProgressView.setId(R.id.progress_horizontal);
mProgressView.setMax(10000);
mProgressView.setVisibility(GONE);
@@ -312,7 +308,8 @@
}
public void initIndeterminateProgress() {
- mIndeterminateProgressView = new ProgressBar(mContext, null, mIndeterminateProgressStyle);
+ mIndeterminateProgressView = new ProgressBarICS(mContext, null, 0,
+ mIndeterminateProgressStyle);
mIndeterminateProgressView.setId(R.id.progress_circular);
mIndeterminateProgressView.setVisibility(GONE);
addView(mIndeterminateProgressView);
@@ -458,9 +455,11 @@
} else {
mActionMenuPresenter.initForMenu(mContext, null);
mExpandedMenuPresenter.initForMenu(mContext, null);
- mActionMenuPresenter.updateMenuView(true);
- mExpandedMenuPresenter.updateMenuView(true);
}
+
+ // Make sure the Presenter's View is updated
+ mActionMenuPresenter.updateMenuView(true);
+ mExpandedMenuPresenter.updateMenuView(true);
}
public boolean hasExpandedActionView() {
@@ -671,10 +670,10 @@
switch (mode) {
case ActionBar.NAVIGATION_MODE_LIST:
if (mSpinner == null) {
- mSpinner = new Spinner(mContext, null,
+ mSpinner = new SpinnerICS(mContext, null,
R.attr.actionDropDownStyle);
mListNavLayout = (LinearLayout) LayoutInflater.from(mContext).inflate(
- R.layout.action_bar_view_list_nav_layout, null);
+ R.layout.abc_action_bar_view_list_nav_layout, null);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
params.gravity = Gravity.CENTER;
@@ -755,7 +754,7 @@
private void initTitle() {
if (mTitleLayout == null) {
LayoutInflater inflater = LayoutInflater.from(getContext());
- mTitleLayout = (LinearLayout) inflater.inflate(R.layout.action_bar_title_item,
+ mTitleLayout = (LinearLayout) inflater.inflate(R.layout.abc_action_bar_title_item,
this, false);
mTitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_title);
mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_subtitle);
@@ -1483,5 +1482,14 @@
public void onRestoreInstanceState(Parcelable state) {
}
}
+
+ /**
+ * Emulates the necessary methods from {@link android.view.Window.Callback}
+ */
+ public interface Callback {
+
+ boolean onMenuItemSelected (int featureId, android.support.v7.view.MenuItem item);
+
+ }
}
diff --git a/v7/appcompat/src/android/support/v7/internal/widget/AdapterViewICS.java b/v7/appcompat/src/android/support/v7/internal/widget/AdapterViewICS.java
new file mode 100644
index 0000000..b586e69
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/internal/widget/AdapterViewICS.java
@@ -0,0 +1,1148 @@
+package android.support.v7.internal.widget;
+
+/*
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import android.content.Context;
+import android.database.DataSetObserver;
+import android.os.Parcelable;
+import android.os.SystemClock;
+import android.util.AttributeSet;
+import android.util.SparseArray;
+import android.view.ContextMenu;
+import android.view.ContextMenu.ContextMenuInfo;
+import android.view.SoundEffectConstants;
+import android.view.View;
+import android.view.ViewDebug;
+import android.view.ViewGroup;
+import android.view.accessibility.AccessibilityEvent;
+import android.widget.Adapter;
+import android.widget.AdapterView;
+import android.widget.ListView;
+
+
+/**
+ * An AdapterView is a view whose children are determined by an {@link android.widget.Adapter}.
+ *
+ * <p>
+ * See {@link ListView}, {@link android.widget.GridView}, {@link android.widget.Spinner} and
+ * {@link android.widget.Gallery} for commonly used subclasses of AdapterView.
+ *
+ * <div class="special reference">
+ * <h3>Developer Guides</h3>
+ * <p>For more information about using AdapterView, read the
+ * <a href="{@docRoot}guide/topics/ui/binding.html">Binding to Data with AdapterView</a>
+ * developer guide.</p></div>
+ */
+abstract class AdapterViewICS<T extends Adapter> extends ViewGroup {
+
+ /**
+ * The item view type returned by {@link Adapter#getItemViewType(int)} when
+ * the adapter does not want the item's view recycled.
+ */
+ static final int ITEM_VIEW_TYPE_IGNORE = -1;
+
+ /**
+ * The item view type returned by {@link Adapter#getItemViewType(int)} when
+ * the item is a header or footer.
+ */
+ static final int ITEM_VIEW_TYPE_HEADER_OR_FOOTER = -2;
+
+ /**
+ * The position of the first child displayed
+ */
+ @ViewDebug.ExportedProperty(category = "scrolling")
+ int mFirstPosition = 0;
+
+ /**
+ * The offset in pixels from the top of the AdapterView to the top
+ * of the view to select during the next layout.
+ */
+ int mSpecificTop;
+
+ /**
+ * Position from which to start looking for mSyncRowId
+ */
+ int mSyncPosition;
+
+ /**
+ * Row id to look for when data has changed
+ */
+ long mSyncRowId = INVALID_ROW_ID;
+
+ /**
+ * Height of the view when mSyncPosition and mSyncRowId where set
+ */
+ long mSyncHeight;
+
+ /**
+ * True if we need to sync to mSyncRowId
+ */
+ boolean mNeedSync = false;
+
+ /**
+ * Indicates whether to sync based on the selection or position. Possible
+ * values are {@link #SYNC_SELECTED_POSITION} or
+ * {@link #SYNC_FIRST_POSITION}.
+ */
+ int mSyncMode;
+
+ /**
+ * Our height after the last layout
+ */
+ private int mLayoutHeight;
+
+ /**
+ * Sync based on the selected child
+ */
+ static final int SYNC_SELECTED_POSITION = 0;
+
+ /**
+ * Sync based on the first child displayed
+ */
+ static final int SYNC_FIRST_POSITION = 1;
+
+ /**
+ * Maximum amount of time to spend in {@link #findSyncPosition()}
+ */
+ static final int SYNC_MAX_DURATION_MILLIS = 100;
+
+ /**
+ * Indicates that this view is currently being laid out.
+ */
+ boolean mInLayout = false;
+
+ /**
+ * The listener that receives notifications when an item is selected.
+ */
+ OnItemSelectedListener mOnItemSelectedListener;
+
+ /**
+ * The listener that receives notifications when an item is clicked.
+ */
+ OnItemClickListener mOnItemClickListener;
+
+ /**
+ * The listener that receives notifications when an item is long clicked.
+ */
+ OnItemLongClickListener mOnItemLongClickListener;
+
+ /**
+ * True if the data has changed since the last layout
+ */
+ boolean mDataChanged;
+
+ /**
+ * The position within the adapter's data set of the item to select
+ * during the next layout.
+ */
+ @ViewDebug.ExportedProperty(category = "list")
+ int mNextSelectedPosition = INVALID_POSITION;
+
+ /**
+ * The item id of the item to select during the next layout.
+ */
+ long mNextSelectedRowId = INVALID_ROW_ID;
+
+ /**
+ * The position within the adapter's data set of the currently selected item.
+ */
+ @ViewDebug.ExportedProperty(category = "list")
+ int mSelectedPosition = INVALID_POSITION;
+
+ /**
+ * The item id of the currently selected item.
+ */
+ long mSelectedRowId = INVALID_ROW_ID;
+
+ /**
+ * View to show if there are no items to show.
+ */
+ private View mEmptyView;
+
+ /**
+ * The number of items in the current adapter.
+ */
+ @ViewDebug.ExportedProperty(category = "list")
+ int mItemCount;
+
+ /**
+ * The number of items in the adapter before a data changed event occurred.
+ */
+ int mOldItemCount;
+
+ /**
+ * Represents an invalid position. All valid positions are in the range 0 to 1 less than the
+ * number of items in the current adapter.
+ */
+ public static final int INVALID_POSITION = -1;
+
+ /**
+ * Represents an empty or invalid row id
+ */
+ public static final long INVALID_ROW_ID = Long.MIN_VALUE;
+
+ /**
+ * The last selected position we used when notifying
+ */
+ int mOldSelectedPosition = INVALID_POSITION;
+
+ /**
+ * The id of the last selected position we used when notifying
+ */
+ long mOldSelectedRowId = INVALID_ROW_ID;
+
+ /**
+ * Indicates what focusable state is requested when calling setFocusable().
+ * In addition to this, this view has other criteria for actually
+ * determining the focusable state (such as whether its empty or the text
+ * filter is shown).
+ *
+ * @see #setFocusable(boolean)
+ * @see #checkFocus()
+ */
+ private boolean mDesiredFocusableState;
+ private boolean mDesiredFocusableInTouchModeState;
+
+ private SelectionNotifier mSelectionNotifier;
+ /**
+ * When set to true, calls to requestLayout() will not propagate up the parent hierarchy.
+ * This is used to layout the children during a layout pass.
+ */
+ boolean mBlockLayoutRequests = false;
+
+ AdapterViewICS(Context context) {
+ super(context);
+ }
+
+ AdapterViewICS(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ AdapterViewICS(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ /**
+ * Interface definition for a callback to be invoked when an item in this
+ * AdapterView has been clicked.
+ */
+ public interface OnItemClickListener {
+
+ /**
+ * Callback method to be invoked when an item in this AdapterView has
+ * been clicked.
+ * <p>
+ * Implementers can call getItemAtPosition(position) if they need
+ * to access the data associated with the selected item.
+ *
+ * @param parent The AdapterView where the click happened.
+ * @param view The view within the AdapterView that was clicked (this
+ * will be a view provided by the adapter)
+ * @param position The position of the view in the adapter.
+ * @param id The row id of the item that was clicked.
+ */
+ void onItemClick(AdapterViewICS<?> parent, View view, int position, long id);
+ }
+
+ class OnItemClickListenerWrapper implements AdapterView.OnItemClickListener {
+
+ private final OnItemClickListener mWrappedListener;
+
+ public OnItemClickListenerWrapper(OnItemClickListener listener) {
+ mWrappedListener = listener;
+ }
+
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ mWrappedListener.onItemClick(AdapterViewICS.this, view, position, id);
+ }
+ }
+
+ /**
+ * Register a callback to be invoked when an item in this AdapterView has
+ * been clicked.
+ *
+ * @param listener The callback that will be invoked.
+ */
+ public void setOnItemClickListener(OnItemClickListener listener) {
+ mOnItemClickListener = listener;
+ }
+
+ /**
+ * @return The callback to be invoked with an item in this AdapterView has
+ * been clicked, or null id no callback has been set.
+ */
+ public final OnItemClickListener getOnItemClickListener() {
+ return mOnItemClickListener;
+ }
+
+ /**
+ * Call the OnItemClickListener, if it is defined.
+ *
+ * @param view The view within the AdapterView that was clicked.
+ * @param position The position of the view in the adapter.
+ * @param id The row id of the item that was clicked.
+ * @return True if there was an assigned OnItemClickListener that was
+ * called, false otherwise is returned.
+ */
+ public boolean performItemClick(View view, int position, long id) {
+ if (mOnItemClickListener != null) {
+ playSoundEffect(SoundEffectConstants.CLICK);
+ if (view != null) {
+ view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
+ }
+ mOnItemClickListener.onItemClick(this, view, position, id);
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Interface definition for a callback to be invoked when an item in this
+ * view has been clicked and held.
+ */
+ public interface OnItemLongClickListener {
+ /**
+ * Callback method to be invoked when an item in this view has been
+ * clicked and held.
+ *
+ * Implementers can call getItemAtPosition(position) if they need to access
+ * the data associated with the selected item.
+ *
+ * @param parent The AbsListView where the click happened
+ * @param view The view within the AbsListView that was clicked
+ * @param position The position of the view in the list
+ * @param id The row id of the item that was clicked
+ *
+ * @return true if the callback consumed the long click, false otherwise
+ */
+ boolean onItemLongClick(AdapterViewICS<?> parent, View view, int position, long id);
+ }
+
+
+ /**
+ * Register a callback to be invoked when an item in this AdapterView has
+ * been clicked and held
+ *
+ * @param listener The callback that will run
+ */
+ public void setOnItemLongClickListener(OnItemLongClickListener listener) {
+ if (!isLongClickable()) {
+ setLongClickable(true);
+ }
+ mOnItemLongClickListener = listener;
+ }
+
+ /**
+ * @return The callback to be invoked with an item in this AdapterView has
+ * been clicked and held, or null id no callback as been set.
+ */
+ public final OnItemLongClickListener getOnItemLongClickListener() {
+ return mOnItemLongClickListener;
+ }
+
+ /**
+ * Interface definition for a callback to be invoked when
+ * an item in this view has been selected.
+ */
+ public interface OnItemSelectedListener {
+ /**
+ * <p>Callback method to be invoked when an item in this view has been
+ * selected. This callback is invoked only when the newly selected
+ * position is different from the previously selected position or if
+ * there was no selected item.</p>
+ *
+ * Impelmenters can call getItemAtPosition(position) if they need to access the
+ * data associated with the selected item.
+ *
+ * @param parent The AdapterView where the selection happened
+ * @param view The view within the AdapterView that was clicked
+ * @param position The position of the view in the adapter
+ * @param id The row id of the item that is selected
+ */
+ void onItemSelected(AdapterViewICS<?> parent, View view, int position, long id);
+
+ /**
+ * Callback method to be invoked when the selection disappears from this
+ * view. The selection can disappear for instance when touch is activated
+ * or when the adapter becomes empty.
+ *
+ * @param parent The AdapterView that now contains no selected item.
+ */
+ void onNothingSelected(AdapterViewICS<?> parent);
+ }
+
+
+ /**
+ * Register a callback to be invoked when an item in this AdapterView has
+ * been selected.
+ *
+ * @param listener The callback that will run
+ */
+ public void setOnItemSelectedListener(OnItemSelectedListener listener) {
+ mOnItemSelectedListener = listener;
+ }
+
+ public final OnItemSelectedListener getOnItemSelectedListener() {
+ return mOnItemSelectedListener;
+ }
+
+ /**
+ * Extra menu information provided to the
+ * {@link android.view.View.OnCreateContextMenuListener#onCreateContextMenu(ContextMenu, View, ContextMenuInfo) }
+ * callback when a context menu is brought up for this AdapterView.
+ *
+ */
+ public static class AdapterContextMenuInfo implements ContextMenu.ContextMenuInfo {
+
+ public AdapterContextMenuInfo(View targetView, int position, long id) {
+ this.targetView = targetView;
+ this.position = position;
+ this.id = id;
+ }
+
+ /**
+ * The child view for which the context menu is being displayed. This
+ * will be one of the children of this AdapterView.
+ */
+ public View targetView;
+
+ /**
+ * The position in the adapter for which the context menu is being
+ * displayed.
+ */
+ public int position;
+
+ /**
+ * The row id of the item for which the context menu is being displayed.
+ */
+ public long id;
+ }
+
+ /**
+ * Returns the adapter currently associated with this widget.
+ *
+ * @return The adapter used to provide this view's content.
+ */
+ public abstract T getAdapter();
+
+ /**
+ * Sets the adapter that provides the data and the views to represent the data
+ * in this widget.
+ *
+ * @param adapter The adapter to use to create this view's content.
+ */
+ public abstract void setAdapter(T adapter);
+
+ /**
+ * This method is not supported and throws an UnsupportedOperationException when called.
+ *
+ * @param child Ignored.
+ *
+ * @throws UnsupportedOperationException Every time this method is invoked.
+ */
+ @Override
+ public void addView(View child) {
+ throw new UnsupportedOperationException("addView(View) is not supported in AdapterView");
+ }
+
+ /**
+ * This method is not supported and throws an UnsupportedOperationException when called.
+ *
+ * @param child Ignored.
+ * @param index Ignored.
+ *
+ * @throws UnsupportedOperationException Every time this method is invoked.
+ */
+ @Override
+ public void addView(View child, int index) {
+ throw new UnsupportedOperationException("addView(View, int) is not supported in AdapterView");
+ }
+
+ /**
+ * This method is not supported and throws an UnsupportedOperationException when called.
+ *
+ * @param child Ignored.
+ * @param params Ignored.
+ *
+ * @throws UnsupportedOperationException Every time this method is invoked.
+ */
+ @Override
+ public void addView(View child, LayoutParams params) {
+ throw new UnsupportedOperationException("addView(View, LayoutParams) "
+ + "is not supported in AdapterView");
+ }
+
+ /**
+ * This method is not supported and throws an UnsupportedOperationException when called.
+ *
+ * @param child Ignored.
+ * @param index Ignored.
+ * @param params Ignored.
+ *
+ * @throws UnsupportedOperationException Every time this method is invoked.
+ */
+ @Override
+ public void addView(View child, int index, LayoutParams params) {
+ throw new UnsupportedOperationException("addView(View, int, LayoutParams) "
+ + "is not supported in AdapterView");
+ }
+
+ /**
+ * This method is not supported and throws an UnsupportedOperationException when called.
+ *
+ * @param child Ignored.
+ *
+ * @throws UnsupportedOperationException Every time this method is invoked.
+ */
+ @Override
+ public void removeView(View child) {
+ throw new UnsupportedOperationException("removeView(View) is not supported in AdapterView");
+ }
+
+ /**
+ * This method is not supported and throws an UnsupportedOperationException when called.
+ *
+ * @param index Ignored.
+ *
+ * @throws UnsupportedOperationException Every time this method is invoked.
+ */
+ @Override
+ public void removeViewAt(int index) {
+ throw new UnsupportedOperationException("removeViewAt(int) is not supported in AdapterView");
+ }
+
+ /**
+ * This method is not supported and throws an UnsupportedOperationException when called.
+ *
+ * @throws UnsupportedOperationException Every time this method is invoked.
+ */
+ @Override
+ public void removeAllViews() {
+ throw new UnsupportedOperationException("removeAllViews() is not supported in AdapterView");
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ mLayoutHeight = getHeight();
+ }
+
+ /**
+ * Return the position of the currently selected item within the adapter's data set
+ *
+ * @return int Position (starting at 0), or {@link #INVALID_POSITION} if there is nothing selected.
+ */
+ @ViewDebug.CapturedViewProperty
+ public int getSelectedItemPosition() {
+ return mNextSelectedPosition;
+ }
+
+ /**
+ * @return The id corresponding to the currently selected item, or {@link #INVALID_ROW_ID}
+ * if nothing is selected.
+ */
+ @ViewDebug.CapturedViewProperty
+ public long getSelectedItemId() {
+ return mNextSelectedRowId;
+ }
+
+ /**
+ * @return The view corresponding to the currently selected item, or null
+ * if nothing is selected
+ */
+ public abstract View getSelectedView();
+
+ /**
+ * @return The data corresponding to the currently selected item, or
+ * null if there is nothing selected.
+ */
+ public Object getSelectedItem() {
+ T adapter = getAdapter();
+ int selection = getSelectedItemPosition();
+ if (adapter != null && adapter.getCount() > 0 && selection >= 0) {
+ return adapter.getItem(selection);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @return The number of items owned by the Adapter associated with this
+ * AdapterView. (This is the number of data items, which may be
+ * larger than the number of visible views.)
+ */
+ @ViewDebug.CapturedViewProperty
+ public int getCount() {
+ return mItemCount;
+ }
+
+ /**
+ * Get the position within the adapter's data set for the view, where view is a an adapter item
+ * or a descendant of an adapter item.
+ *
+ * @param view an adapter item, or a descendant of an adapter item. This must be visible in this
+ * AdapterView at the time of the call.
+ * @return the position within the adapter's data set of the view, or {@link #INVALID_POSITION}
+ * if the view does not correspond to a list item (or it is not currently visible).
+ */
+ public int getPositionForView(View view) {
+ View listItem = view;
+ try {
+ View v;
+ while (!(v = (View) listItem.getParent()).equals(this)) {
+ listItem = v;
+ }
+ } catch (ClassCastException e) {
+ // We made it up to the window without find this list view
+ return INVALID_POSITION;
+ }
+
+ // Search the children for the list item
+ final int childCount = getChildCount();
+ for (int i = 0; i < childCount; i++) {
+ if (getChildAt(i).equals(listItem)) {
+ return mFirstPosition + i;
+ }
+ }
+
+ // Child not found!
+ return INVALID_POSITION;
+ }
+
+ /**
+ * Returns the position within the adapter's data set for the first item
+ * displayed on screen.
+ *
+ * @return The position within the adapter's data set
+ */
+ public int getFirstVisiblePosition() {
+ return mFirstPosition;
+ }
+
+ /**
+ * Returns the position within the adapter's data set for the last item
+ * displayed on screen.
+ *
+ * @return The position within the adapter's data set
+ */
+ public int getLastVisiblePosition() {
+ return mFirstPosition + getChildCount() - 1;
+ }
+
+ /**
+ * Sets the currently selected item. To support accessibility subclasses that
+ * override this method must invoke the overriden super method first.
+ *
+ * @param position Index (starting at 0) of the data item to be selected.
+ */
+ public abstract void setSelection(int position);
+
+ /**
+ * Sets the view to show if the adapter is empty
+ */
+ public void setEmptyView(View emptyView) {
+ mEmptyView = emptyView;
+
+ final T adapter = getAdapter();
+ final boolean empty = ((adapter == null) || adapter.isEmpty());
+ updateEmptyStatus(empty);
+ }
+
+ /**
+ * When the current adapter is empty, the AdapterView can display a special view
+ * call the empty view. The empty view is used to provide feedback to the user
+ * that no data is available in this AdapterView.
+ *
+ * @return The view to show if the adapter is empty.
+ */
+ public View getEmptyView() {
+ return mEmptyView;
+ }
+
+ /**
+ * Indicates whether this view is in filter mode. Filter mode can for instance
+ * be enabled by a user when typing on the keyboard.
+ *
+ * @return True if the view is in filter mode, false otherwise.
+ */
+ boolean isInFilterMode() {
+ return false;
+ }
+
+ @Override
+ public void setFocusable(boolean focusable) {
+ final T adapter = getAdapter();
+ final boolean empty = adapter == null || adapter.getCount() == 0;
+
+ mDesiredFocusableState = focusable;
+ if (!focusable) {
+ mDesiredFocusableInTouchModeState = false;
+ }
+
+ super.setFocusable(focusable && (!empty || isInFilterMode()));
+ }
+
+ @Override
+ public void setFocusableInTouchMode(boolean focusable) {
+ final T adapter = getAdapter();
+ final boolean empty = adapter == null || adapter.getCount() == 0;
+
+ mDesiredFocusableInTouchModeState = focusable;
+ if (focusable) {
+ mDesiredFocusableState = true;
+ }
+
+ super.setFocusableInTouchMode(focusable && (!empty || isInFilterMode()));
+ }
+
+ void checkFocus() {
+ final T adapter = getAdapter();
+ final boolean empty = adapter == null || adapter.getCount() == 0;
+ final boolean focusable = !empty || isInFilterMode();
+ // The order in which we set focusable in touch mode/focusable may matter
+ // for the client, see View.setFocusableInTouchMode() comments for more
+ // details
+ super.setFocusableInTouchMode(focusable && mDesiredFocusableInTouchModeState);
+ super.setFocusable(focusable && mDesiredFocusableState);
+ if (mEmptyView != null) {
+ updateEmptyStatus((adapter == null) || adapter.isEmpty());
+ }
+ }
+
+ /**
+ * Update the status of the list based on the empty parameter. If empty is true and
+ * we have an empty view, display it. In all the other cases, make sure that the listview
+ * is VISIBLE and that the empty view is GONE (if it's not null).
+ */
+ private void updateEmptyStatus(boolean empty) {
+ if (isInFilterMode()) {
+ empty = false;
+ }
+
+ if (empty) {
+ if (mEmptyView != null) {
+ mEmptyView.setVisibility(View.VISIBLE);
+ setVisibility(View.GONE);
+ } else {
+ // If the caller just removed our empty view, make sure the list view is visible
+ setVisibility(View.VISIBLE);
+ }
+
+ // We are now GONE, so pending layouts will not be dispatched.
+ // Force one here to make sure that the state of the list matches
+ // the state of the adapter.
+ if (mDataChanged) {
+ this.onLayout(false, getLeft(), getTop(), getRight(), getBottom());
+ }
+ } else {
+ if (mEmptyView != null) mEmptyView.setVisibility(View.GONE);
+ setVisibility(View.VISIBLE);
+ }
+ }
+
+ /**
+ * Gets the data associated with the specified position in the list.
+ *
+ * @param position Which data to get
+ * @return The data associated with the specified position in the list
+ */
+ public Object getItemAtPosition(int position) {
+ T adapter = getAdapter();
+ return (adapter == null || position < 0) ? null : adapter.getItem(position);
+ }
+
+ public long getItemIdAtPosition(int position) {
+ T adapter = getAdapter();
+ return (adapter == null || position < 0) ? INVALID_ROW_ID : adapter.getItemId(position);
+ }
+
+ @Override
+ public void setOnClickListener(OnClickListener l) {
+ throw new RuntimeException("Don't call setOnClickListener for an AdapterView. "
+ + "You probably want setOnItemClickListener instead");
+ }
+
+ /**
+ * Override to prevent freezing of any views created by the adapter.
+ */
+ @Override
+ protected void dispatchSaveInstanceState(SparseArray<Parcelable> container) {
+ dispatchFreezeSelfOnly(container);
+ }
+
+ /**
+ * Override to prevent thawing of any views created by the adapter.
+ */
+ @Override
+ protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container) {
+ dispatchThawSelfOnly(container);
+ }
+
+ class AdapterDataSetObserver extends DataSetObserver {
+
+ private Parcelable mInstanceState = null;
+
+ @Override
+ public void onChanged() {
+ mDataChanged = true;
+ mOldItemCount = mItemCount;
+ mItemCount = getAdapter().getCount();
+
+ // Detect the case where a cursor that was previously invalidated has
+ // been repopulated with new data.
+ if (AdapterViewICS.this.getAdapter().hasStableIds() && mInstanceState != null
+ && mOldItemCount == 0 && mItemCount > 0) {
+ AdapterViewICS.this.onRestoreInstanceState(mInstanceState);
+ mInstanceState = null;
+ } else {
+ rememberSyncState();
+ }
+ checkFocus();
+ requestLayout();
+ }
+
+ @Override
+ public void onInvalidated() {
+ mDataChanged = true;
+
+ if (AdapterViewICS.this.getAdapter().hasStableIds()) {
+ // Remember the current state for the case where our hosting activity is being
+ // stopped and later restarted
+ mInstanceState = AdapterViewICS.this.onSaveInstanceState();
+ }
+
+ // Data is invalid so we should reset our state
+ mOldItemCount = mItemCount;
+ mItemCount = 0;
+ mSelectedPosition = INVALID_POSITION;
+ mSelectedRowId = INVALID_ROW_ID;
+ mNextSelectedPosition = INVALID_POSITION;
+ mNextSelectedRowId = INVALID_ROW_ID;
+ mNeedSync = false;
+
+ checkFocus();
+ requestLayout();
+ }
+
+ public void clearSavedState() {
+ mInstanceState = null;
+ }
+ }
+
+ @Override
+ protected void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+ removeCallbacks(mSelectionNotifier);
+ }
+
+ private class SelectionNotifier implements Runnable {
+ public void run() {
+ if (mDataChanged) {
+ // Data has changed between when this SelectionNotifier
+ // was posted and now. We need to wait until the AdapterView
+ // has been synched to the new data.
+ if (getAdapter() != null) {
+ post(this);
+ }
+ } else {
+ fireOnSelected();
+ }
+ }
+ }
+
+ void selectionChanged() {
+ if (mOnItemSelectedListener != null) {
+ if (mInLayout || mBlockLayoutRequests) {
+ // If we are in a layout traversal, defer notification
+ // by posting. This ensures that the view tree is
+ // in a consistent state and is able to accomodate
+ // new layout or invalidate requests.
+ if (mSelectionNotifier == null) {
+ mSelectionNotifier = new SelectionNotifier();
+ }
+ post(mSelectionNotifier);
+ } else {
+ fireOnSelected();
+ }
+ }
+
+ // we fire selection events here not in View
+ if (mSelectedPosition != ListView.INVALID_POSITION && isShown() && !isInTouchMode()) {
+ sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
+ }
+ }
+
+ private void fireOnSelected() {
+ if (mOnItemSelectedListener == null)
+ return;
+
+ int selection = this.getSelectedItemPosition();
+ if (selection >= 0) {
+ View v = getSelectedView();
+ mOnItemSelectedListener.onItemSelected(this, v, selection,
+ getAdapter().getItemId(selection));
+ } else {
+ mOnItemSelectedListener.onNothingSelected(this);
+ }
+ }
+
+ @Override
+ public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
+ View selectedView = getSelectedView();
+ if (selectedView != null && selectedView.getVisibility() == VISIBLE
+ && selectedView.dispatchPopulateAccessibilityEvent(event)) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected boolean canAnimate() {
+ return super.canAnimate() && mItemCount > 0;
+ }
+
+ void handleDataChanged() {
+ final int count = mItemCount;
+ boolean found = false;
+
+ if (count > 0) {
+
+ int newPos;
+
+ // Find the row we are supposed to sync to
+ if (mNeedSync) {
+ // Update this first, since setNextSelectedPositionInt inspects
+ // it
+ mNeedSync = false;
+
+ // See if we can find a position in the new data with the same
+ // id as the old selection
+ newPos = findSyncPosition();
+ if (newPos >= 0) {
+ // Verify that new selection is selectable
+ int selectablePos = lookForSelectablePosition(newPos, true);
+ if (selectablePos == newPos) {
+ // Same row id is selected
+ setNextSelectedPositionInt(newPos);
+ found = true;
+ }
+ }
+ }
+ if (!found) {
+ // Try to use the same position if we can't find matching data
+ newPos = getSelectedItemPosition();
+
+ // Pin position to the available range
+ if (newPos >= count) {
+ newPos = count - 1;
+ }
+ if (newPos < 0) {
+ newPos = 0;
+ }
+
+ // Make sure we select something selectable -- first look down
+ int selectablePos = lookForSelectablePosition(newPos, true);
+ if (selectablePos < 0) {
+ // Looking down didn't work -- try looking up
+ selectablePos = lookForSelectablePosition(newPos, false);
+ }
+ if (selectablePos >= 0) {
+ setNextSelectedPositionInt(selectablePos);
+ checkSelectionChanged();
+ found = true;
+ }
+ }
+ }
+ if (!found) {
+ // Nothing is selected
+ mSelectedPosition = INVALID_POSITION;
+ mSelectedRowId = INVALID_ROW_ID;
+ mNextSelectedPosition = INVALID_POSITION;
+ mNextSelectedRowId = INVALID_ROW_ID;
+ mNeedSync = false;
+ checkSelectionChanged();
+ }
+ }
+
+ void checkSelectionChanged() {
+ if ((mSelectedPosition != mOldSelectedPosition) || (mSelectedRowId != mOldSelectedRowId)) {
+ selectionChanged();
+ mOldSelectedPosition = mSelectedPosition;
+ mOldSelectedRowId = mSelectedRowId;
+ }
+ }
+
+ /**
+ * Searches the adapter for a position matching mSyncRowId. The search starts at mSyncPosition
+ * and then alternates between moving up and moving down until 1) we find the right position, or
+ * 2) we run out of time, or 3) we have looked at every position
+ *
+ * @return Position of the row that matches mSyncRowId, or {@link #INVALID_POSITION} if it can't
+ * be found
+ */
+ int findSyncPosition() {
+ int count = mItemCount;
+
+ if (count == 0) {
+ return INVALID_POSITION;
+ }
+
+ long idToMatch = mSyncRowId;
+ int seed = mSyncPosition;
+
+ // If there isn't a selection don't hunt for it
+ if (idToMatch == INVALID_ROW_ID) {
+ return INVALID_POSITION;
+ }
+
+ // Pin seed to reasonable values
+ seed = Math.max(0, seed);
+ seed = Math.min(count - 1, seed);
+
+ long endTime = SystemClock.uptimeMillis() + SYNC_MAX_DURATION_MILLIS;
+
+ long rowId;
+
+ // first position scanned so far
+ int first = seed;
+
+ // last position scanned so far
+ int last = seed;
+
+ // True if we should move down on the next iteration
+ boolean next = false;
+
+ // True when we have looked at the first item in the data
+ boolean hitFirst;
+
+ // True when we have looked at the last item in the data
+ boolean hitLast;
+
+ // Get the item ID locally (instead of getItemIdAtPosition), so
+ // we need the adapter
+ T adapter = getAdapter();
+ if (adapter == null) {
+ return INVALID_POSITION;
+ }
+
+ while (SystemClock.uptimeMillis() <= endTime) {
+ rowId = adapter.getItemId(seed);
+ if (rowId == idToMatch) {
+ // Found it!
+ return seed;
+ }
+
+ hitLast = last == count - 1;
+ hitFirst = first == 0;
+
+ if (hitLast && hitFirst) {
+ // Looked at everything
+ break;
+ }
+
+ if (hitFirst || (next && !hitLast)) {
+ // Either we hit the top, or we are trying to move down
+ last++;
+ seed = last;
+ // Try going up next time
+ next = false;
+ } else if (hitLast || (!next && !hitFirst)) {
+ // Either we hit the bottom, or we are trying to move up
+ first--;
+ seed = first;
+ // Try going down next time
+ next = true;
+ }
+
+ }
+
+ return INVALID_POSITION;
+ }
+
+ /**
+ * Find a position that can be selected (i.e., is not a separator).
+ *
+ * @param position The starting position to look at.
+ * @param lookDown Whether to look down for other positions.
+ * @return The next selectable position starting at position and then searching either up or
+ * down. Returns {@link #INVALID_POSITION} if nothing can be found.
+ */
+ int lookForSelectablePosition(int position, boolean lookDown) {
+ return position;
+ }
+
+ /**
+ * Utility to keep mSelectedPosition and mSelectedRowId in sync
+ * @param position Our current position
+ */
+ void setSelectedPositionInt(int position) {
+ mSelectedPosition = position;
+ mSelectedRowId = getItemIdAtPosition(position);
+ }
+
+ /**
+ * Utility to keep mNextSelectedPosition and mNextSelectedRowId in sync
+ * @param position Intended value for mSelectedPosition the next time we go
+ * through layout
+ */
+ void setNextSelectedPositionInt(int position) {
+ mNextSelectedPosition = position;
+ mNextSelectedRowId = getItemIdAtPosition(position);
+ // If we are trying to sync to the selection, update that too
+ if (mNeedSync && mSyncMode == SYNC_SELECTED_POSITION && position >= 0) {
+ mSyncPosition = position;
+ mSyncRowId = mNextSelectedRowId;
+ }
+ }
+
+ /**
+ * Remember enough information to restore the screen state when the data has
+ * changed.
+ *
+ */
+ void rememberSyncState() {
+ if (getChildCount() > 0) {
+ mNeedSync = true;
+ mSyncHeight = mLayoutHeight;
+ if (mSelectedPosition >= 0) {
+ // Sync the selection state
+ View v = getChildAt(mSelectedPosition - mFirstPosition);
+ mSyncRowId = mNextSelectedRowId;
+ mSyncPosition = mNextSelectedPosition;
+ if (v != null) {
+ mSpecificTop = v.getTop();
+ }
+ mSyncMode = SYNC_SELECTED_POSITION;
+ } else {
+ // Sync the based on the offset of the first view
+ View v = getChildAt(0);
+ T adapter = getAdapter();
+ if (mFirstPosition >= 0 && mFirstPosition < adapter.getCount()) {
+ mSyncRowId = adapter.getItemId(mFirstPosition);
+ } else {
+ mSyncRowId = NO_ID;
+ }
+ mSyncPosition = mFirstPosition;
+ if (v != null) {
+ mSpecificTop = v.getTop();
+ }
+ mSyncMode = SYNC_FIRST_POSITION;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/v7/appcompat/src/android/support/v7/internal/widget/LinearLayoutICS.java b/v7/appcompat/src/android/support/v7/internal/widget/LinearLayoutICS.java
new file mode 100644
index 0000000..9e2070e
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/internal/widget/LinearLayoutICS.java
@@ -0,0 +1,184 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.internal.widget;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.graphics.drawable.Drawable;
+import android.support.v7.appcompat.R;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.LinearLayout;
+
+/**
+ * @hide
+ */
+public class LinearLayoutICS extends LinearLayout {
+
+ private static final int SHOW_DIVIDER_NONE = 0;
+ private static final int SHOW_DIVIDER_BEGINNING = 1;
+ private static final int SHOW_DIVIDER_MIDDLE = 2;
+ private static final int SHOW_DIVIDER_END = 4;
+
+ private final Drawable mDivider;
+ private final int mDividerWidth, mDividerHeight;
+ private final int mShowDividers;
+ private final int mDividerPadding;
+
+ public LinearLayoutICS(Context context, AttributeSet attrs) {
+ super(context, attrs);
+
+ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LinearLayoutICS);
+
+ mDivider = a.getDrawable(R.styleable.LinearLayoutICS_divider);
+ if (mDivider != null) {
+ mDividerWidth = mDivider.getIntrinsicWidth();
+ mDividerHeight = mDivider.getIntrinsicHeight();
+ } else {
+ mDividerHeight = mDividerWidth = 0;
+ }
+
+ mShowDividers = a.getInt(R.styleable.LinearLayoutICS_showDividers, SHOW_DIVIDER_NONE);
+ mDividerPadding = a.getDimensionPixelSize(R.styleable.LinearLayoutICS_dividerPadding, 0);
+
+ a.recycle();
+
+ setWillNotDraw(mDivider == null);
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ if (getOrientation() == VERTICAL) {
+ drawDividersVertical(canvas);
+ } else {
+ drawDividersHorizontal(canvas);
+ }
+ }
+
+ @Override
+ protected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed,
+ int parentHeightMeasureSpec, int heightUsed) {
+
+ if (mDivider != null) {
+ final int childIndex = indexOfChild(child);
+ final int count = getChildCount();
+ final LayoutParams params = (LayoutParams) child.getLayoutParams();
+
+ // To display the dividers in-between the child views, we modify their margins
+ // to create space.
+ if (getOrientation() == VERTICAL) {
+ if (hasDividerBeforeChildAt(childIndex)) {
+ params.topMargin = mDividerHeight;
+ } else if (childIndex == count - 1 && hasDividerBeforeChildAt(count)) {
+ params.bottomMargin = mDividerHeight;
+ }
+ } else {
+ if (hasDividerBeforeChildAt(childIndex)) {
+ params.leftMargin = mDividerWidth;
+ } else if (childIndex == count - 1 && hasDividerBeforeChildAt(count)) {
+ params.rightMargin = mDividerWidth;
+ }
+ }
+ }
+
+ super.measureChildWithMargins(child, parentWidthMeasureSpec, widthUsed,
+ parentHeightMeasureSpec, heightUsed);
+ }
+
+ void drawDividersVertical(Canvas canvas) {
+ final int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ final View child = getChildAt(i);
+ if (child != null && child.getVisibility() != GONE && hasDividerBeforeChildAt(i)) {
+ final LayoutParams lp = (LayoutParams) child.getLayoutParams();
+ drawHorizontalDivider(canvas, child.getTop() - lp.topMargin);
+ }
+ }
+
+ if (hasDividerBeforeChildAt(count)) {
+ final View child = getChildAt(count - 1);
+ int bottom = 0;
+ if (child == null) {
+ bottom = getHeight() - getPaddingBottom() - mDividerHeight;
+ } else {
+ bottom = child.getBottom();
+ }
+ drawHorizontalDivider(canvas, bottom);
+ }
+ }
+
+ void drawDividersHorizontal(Canvas canvas) {
+ final int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ final View child = getChildAt(i);
+ if (child != null && child.getVisibility() != GONE && hasDividerBeforeChildAt(i)) {
+ final LayoutParams lp = (LayoutParams) child.getLayoutParams();
+ drawVerticalDivider(canvas, child.getLeft() - lp.leftMargin);
+ }
+ }
+
+ if (hasDividerBeforeChildAt(count)) {
+ final View child = getChildAt(count - 1);
+ int right = 0;
+ if (child == null) {
+ right = getWidth() - getPaddingRight() - mDividerWidth;
+ } else {
+ right = child.getRight();
+ }
+ drawVerticalDivider(canvas, right);
+ }
+ }
+
+ void drawHorizontalDivider(Canvas canvas, int top) {
+ mDivider.setBounds(getPaddingLeft() + mDividerPadding, top,
+ getWidth() - getPaddingRight() - mDividerPadding, top + mDividerHeight);
+ mDivider.draw(canvas);
+ }
+
+ void drawVerticalDivider(Canvas canvas, int left) {
+ mDivider.setBounds(left, getPaddingTop() + mDividerPadding,
+ left + mDividerWidth, getHeight() - getPaddingBottom() - mDividerPadding);
+ mDivider.draw(canvas);
+ }
+
+ /**
+ * Determines where to position dividers between children.
+ *
+ * @param childIndex Index of child to check for preceding divider
+ * @return true if there should be a divider before the child at childIndex
+ * @hide Pending API consideration. Currently only used internally by the system.
+ */
+ protected boolean hasDividerBeforeChildAt(int childIndex) {
+ if (childIndex == 0) {
+ return (mShowDividers & SHOW_DIVIDER_BEGINNING) != 0;
+ } else if (childIndex == getChildCount()) {
+ return (mShowDividers & SHOW_DIVIDER_END) != 0;
+ } else if ((mShowDividers & SHOW_DIVIDER_MIDDLE) != 0) {
+ boolean hasVisibleViewBefore = false;
+ for (int i = childIndex - 1; i >= 0; i--) {
+ if (getChildAt(i).getVisibility() != GONE) {
+ hasVisibleViewBefore = true;
+ break;
+ }
+ }
+ return hasVisibleViewBefore;
+ }
+ return false;
+ }
+
+}
diff --git a/appcompat/eclair/android/support/appcompat/widget/ListPopupWindow.java b/v7/appcompat/src/android/support/v7/internal/widget/ListPopupWindow.java
similarity index 95%
rename from appcompat/eclair/android/support/appcompat/widget/ListPopupWindow.java
rename to v7/appcompat/src/android/support/v7/internal/widget/ListPopupWindow.java
index 6be2bec..800fa46 100644
--- a/appcompat/eclair/android/support/appcompat/widget/ListPopupWindow.java
+++ b/v7/appcompat/src/android/support/v7/internal/widget/ListPopupWindow.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package android.support.appcompat.widget;
+package android.support.v7.internal.widget;
import android.content.Context;
import android.content.res.Resources;
@@ -22,7 +22,7 @@
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Handler;
-import android.support.appcompat.R;
+import android.support.v7.appcompat.R;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
@@ -515,8 +515,6 @@
int heightSpec = 0;
boolean noInputMethod = isInputMethodNotNeeded();
- // TODO(anirudhd) : Test and replicate this behaviour
- // mPopup.setAllowScrollingAnchorParent(!noInputMethod);
if (mPopup.isShowing()) {
if (mDropDownWidth == ViewGroup.LayoutParams.FILL_PARENT) {
@@ -575,7 +573,6 @@
}
mPopup.setWindowLayoutMode(widthSpec, heightSpec);
- setClipToScreenEnabled(mPopup, true);
// use outside touchable to dismiss drop down when touching outside of it, so
// only set this if the dropdown is not always visible
@@ -594,20 +591,6 @@
}
}
- public static void setClipToScreenEnabled(PopupWindow mPopup, boolean enabled) {
- // mClipToScreen = enabled;
- try {
- Field f = mPopup.getClass().getDeclaredField("mClipToScreen");
- f.setAccessible(true);
- f.setBoolean(mPopup, enabled);
- } catch (NoSuchFieldException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
- mPopup.setClippingEnabled(!enabled);
- }
-
/**
* Dismiss the popup window.
*/
@@ -916,25 +899,6 @@
}
/**
- * Filter pre-IME key events. By forwarding {@link View#onKeyPreIme(int, KeyEvent)} events to
- * this function, views using ListPopupWindow can have it dismiss the popup when the back key is
- * pressed.
- *
- * @param keyCode keyCode param passed to the host view's onKeyPreIme
- * @param event event param passed to the host view's onKeyPreIme
- * @return true if the event was handled, false if it was ignored.
- * @see #setModal(boolean)
- */
- public boolean onKeyPreIme(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK && isShowing()) {
- // special case for the back key, we do not even try to send it
- // to the drop down list but instead, consume it immediately
- //TODO(anirudhd): No dispatcher APIs in eclair
- }
- return false;
- }
-
- /**
* <p>Builds the popup window's content and returns the height the popup should have. Returns -1
* when the content already exists.</p>
*
@@ -1093,7 +1057,7 @@
break;
}
- final int listContent = mDropDownList.measureHeightOfChildren(childWidthSpec,
+ final int listContent = mDropDownList.measureHeightOfChildrenCompat(childWidthSpec,
0, DropDownListView.NO_POSITION, maxHeight - otherHeights, -1);
// add padding only if the list has items in it, that way we don't show
// the popup if it is not needed
@@ -1146,21 +1110,6 @@
}
/**
- * Set the layout direction for this popup. Should be a resolved direction as the popup as no
- * capacity to do the resolution on his own.
- *
- * @param layoutDirection One of {@link View#LAYOUT_DIRECTION_LTR}, {@link
- * View#LAYOUT_DIRECTION_RTL},
- */
- public void setLayoutDirection(int layoutDirection) {
- mLayoutDirection = layoutDirection;
- if (mDropDownList != null) {
- // BiDi support
- // mDropDownList.setLayoutDirection(mLayoutDirection);
- }
- }
-
- /**
* <p>Wrapper class for a ListView. This wrapper can hijack the focus to make sure the list uses
* the appropriate drawables and states when displayed on screen within a drop down. The focus
* is never actually passed to the drop down in this mode; the list only looks focused.</p>
@@ -1218,7 +1167,6 @@
public DropDownListView(Context context, boolean hijackFocus) {
super(context, null, R.attr.dropDownListViewStyle);
mHijackFocus = hijackFocus;
- // TODO: Add an API to control this
setCacheColorHint(0); // Transparent, since the background drawable could be anything.
}
@@ -1230,7 +1178,7 @@
* @return The next selectable position starting at position and then searching either up or
* down. Returns {@link #INVALID_POSITION} if nothing can be found.
*/
- int lookForSelectablePosition(int position, boolean lookDown) {
+ private int lookForSelectablePosition(int position, boolean lookDown) {
final ListAdapter adapter = getAdapter();
if (adapter == null || isInTouchMode()) {
return INVALID_POSITION;
@@ -1324,7 +1272,7 @@
* startPosition is 0).
* @return The height of this ListView with the given children.
*/
- final int measureHeightOfChildren(int widthMeasureSpec, int startPosition,
+ final int measureHeightOfChildrenCompat(int widthMeasureSpec, int startPosition,
int endPosition, final int maxHeight,
int disallowPartialChildPosition) {
diff --git a/v7/appcompat/src/android/support/v7/internal/widget/ProgressBarICS.java b/v7/appcompat/src/android/support/v7/internal/widget/ProgressBarICS.java
new file mode 100644
index 0000000..d272b5a
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/internal/widget/ProgressBarICS.java
@@ -0,0 +1,920 @@
+package android.support.v7.internal.widget;
+
+/*
+ * Copyright (C) 2013 Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Bitmap;
+import android.graphics.BitmapShader;
+import android.graphics.Canvas;
+import android.graphics.Rect;
+import android.graphics.Shader;
+import android.graphics.drawable.Animatable;
+import android.graphics.drawable.AnimationDrawable;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.ClipDrawable;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.LayerDrawable;
+import android.graphics.drawable.ShapeDrawable;
+import android.graphics.drawable.shapes.RoundRectShape;
+import android.graphics.drawable.shapes.Shape;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.os.SystemClock;
+import android.util.AttributeSet;
+import android.view.Gravity;
+import android.view.View;
+import android.view.animation.AlphaAnimation;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.view.animation.Interpolator;
+import android.view.animation.LinearInterpolator;
+import android.view.animation.Transformation;
+
+/**
+ * @hide
+ */
+public class ProgressBarICS extends View {
+
+ private static final int MAX_LEVEL = 10000;
+ private static final int ANIMATION_RESOLUTION = 200;
+
+ /**
+ * android.R.styleable.ProgressBar is internalised, so we need to create it ourselves.
+ */
+ private static final int[] android_R_styleable_ProgressBar = new int[]{
+ android.R.attr.max,
+ android.R.attr.progress,
+ android.R.attr.secondaryProgress,
+ android.R.attr.indeterminate,
+ android.R.attr.indeterminateOnly,
+ android.R.attr.indeterminateDrawable,
+ android.R.attr.progressDrawable,
+ android.R.attr.indeterminateDuration,
+ android.R.attr.indeterminateBehavior,
+ android.R.attr.minWidth,
+ android.R.attr.maxWidth,
+ android.R.attr.minHeight,
+ android.R.attr.maxHeight,
+ android.R.attr.interpolator,
+ };
+
+ int mMinWidth;
+ int mMaxWidth;
+ int mMinHeight;
+ int mMaxHeight;
+
+ private int mProgress;
+ private int mSecondaryProgress;
+ private int mMax;
+
+ private int mBehavior;
+ private int mDuration;
+ private boolean mIndeterminate;
+ private boolean mOnlyIndeterminate;
+ private Transformation mTransformation;
+ private AlphaAnimation mAnimation;
+ private Drawable mIndeterminateDrawable;
+ private Drawable mProgressDrawable;
+ private Drawable mCurrentDrawable;
+ Bitmap mSampleTile;
+ private boolean mNoInvalidate;
+ private Interpolator mInterpolator;
+ private RefreshProgressRunnable mRefreshProgressRunnable;
+ private long mUiThreadId;
+ private boolean mShouldStartAnimationDrawable;
+ private long mLastDrawTime;
+
+ private boolean mInDrawing;
+
+ /**
+ * @hide
+ */
+ public ProgressBarICS(Context context, AttributeSet attrs, int defStyle, int styleRes) {
+ super(context, attrs, defStyle);
+ mUiThreadId = Thread.currentThread().getId();
+ initProgressBar();
+
+ TypedArray a = context.obtainStyledAttributes(attrs, android_R_styleable_ProgressBar,
+ defStyle, styleRes);
+
+ mNoInvalidate = true;
+
+ setMax(a.getInt(0, mMax));
+ setProgress(a.getInt(1, mProgress));
+ setSecondaryProgress(a.getInt(2, mSecondaryProgress));
+
+ final boolean indeterminate = a.getBoolean(3, mIndeterminate);
+ mOnlyIndeterminate = a.getBoolean(4, mOnlyIndeterminate);
+
+ Drawable drawable = a.getDrawable(5);
+ if (drawable != null) {
+ drawable = tileifyIndeterminate(drawable);
+ setIndeterminateDrawable(drawable);
+ }
+
+ drawable = a.getDrawable(6);
+ if (drawable != null) {
+ drawable = tileify(drawable, false);
+ // Calling this method can set mMaxHeight, make sure the corresponding
+ // XML attribute for mMaxHeight is read after calling this method
+ setProgressDrawable(drawable);
+ }
+
+ mDuration = a.getInt(7, mDuration);
+ mBehavior = a.getInt(8, mBehavior);
+ mMinWidth = a.getDimensionPixelSize(9, mMinWidth);
+ mMaxWidth = a.getDimensionPixelSize(10, mMaxWidth);
+ mMinHeight = a.getDimensionPixelSize(11, mMinHeight);
+ mMaxHeight = a.getDimensionPixelSize(12, mMaxHeight);
+
+ final int resID = a.getResourceId(13, android.R.anim.linear_interpolator);
+ if (resID > 0) {
+ setInterpolator(context, resID);
+ }
+
+ a.recycle();
+
+ mNoInvalidate = false;
+ setIndeterminate(mOnlyIndeterminate || indeterminate);
+ }
+
+ /**
+ * Converts a drawable to a tiled version of itself. It will recursively
+ * traverse layer and state list drawables.
+ */
+ private Drawable tileify(Drawable drawable, boolean clip) {
+
+ if (drawable instanceof LayerDrawable) {
+ LayerDrawable background = (LayerDrawable) drawable;
+ final int N = background.getNumberOfLayers();
+ Drawable[] outDrawables = new Drawable[N];
+
+ for (int i = 0; i < N; i++) {
+ int id = background.getId(i);
+ outDrawables[i] = tileify(background.getDrawable(i),
+ (id == android.R.id.progress || id == android.R.id.secondaryProgress));
+ }
+
+ LayerDrawable newBg = new LayerDrawable(outDrawables);
+
+ for (int i = 0; i < N; i++) {
+ newBg.setId(i, background.getId(i));
+ }
+
+ return newBg;
+
+ } else if (drawable instanceof BitmapDrawable) {
+ final Bitmap tileBitmap = ((BitmapDrawable) drawable).getBitmap();
+ if (mSampleTile == null) {
+ mSampleTile = tileBitmap;
+ }
+
+ final ShapeDrawable shapeDrawable = new ShapeDrawable(getDrawableShape());
+
+ final BitmapShader bitmapShader = new BitmapShader(tileBitmap,
+ Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
+ shapeDrawable.getPaint().setShader(bitmapShader);
+
+ return (clip) ? new ClipDrawable(shapeDrawable, Gravity.LEFT,
+ ClipDrawable.HORIZONTAL) : shapeDrawable;
+ }
+
+ return drawable;
+ }
+
+ Shape getDrawableShape() {
+ final float[] roundedCorners = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 };
+ return new RoundRectShape(roundedCorners, null, null);
+ }
+
+ /**
+ * Convert a AnimationDrawable for use as a barberpole animation.
+ * Each frame of the animation is wrapped in a ClipDrawable and
+ * given a tiling BitmapShader.
+ */
+ private Drawable tileifyIndeterminate(Drawable drawable) {
+ if (drawable instanceof AnimationDrawable) {
+ AnimationDrawable background = (AnimationDrawable) drawable;
+ final int N = background.getNumberOfFrames();
+ AnimationDrawable newBg = new AnimationDrawable();
+ newBg.setOneShot(background.isOneShot());
+
+ for (int i = 0; i < N; i++) {
+ Drawable frame = tileify(background.getFrame(i), true);
+ frame.setLevel(10000);
+ newBg.addFrame(frame, background.getDuration(i));
+ }
+ newBg.setLevel(10000);
+ drawable = newBg;
+ }
+ return drawable;
+ }
+
+ /**
+ * <p>
+ * Initialize the progress bar's default values:
+ * </p>
+ * <ul>
+ * <li>progress = 0</li>
+ * <li>max = 100</li>
+ * <li>animation duration = 4000 ms</li>
+ * <li>indeterminate = false</li>
+ * <li>behavior = repeat</li>
+ * </ul>
+ */
+ private void initProgressBar() {
+ mMax = 100;
+ mProgress = 0;
+ mSecondaryProgress = 0;
+ mIndeterminate = false;
+ mOnlyIndeterminate = false;
+ mDuration = 4000;
+ mBehavior = AlphaAnimation.RESTART;
+ mMinWidth = 24;
+ mMaxWidth = 48;
+ mMinHeight = 24;
+ mMaxHeight = 48;
+ }
+
+ /**
+ * <p>Indicate whether this progress bar is in indeterminate mode.</p>
+ *
+ * @return true if the progress bar is in indeterminate mode
+ */
+ public synchronized boolean isIndeterminate() {
+ return mIndeterminate;
+ }
+
+ /**
+ * <p>Change the indeterminate mode for this progress bar. In indeterminate
+ * mode, the progress is ignored and the progress bar shows an infinite
+ * animation instead.</p>
+ *
+ * If this progress bar's style only supports indeterminate mode (such as the circular
+ * progress bars), then this will be ignored.
+ *
+ * @param indeterminate true to enable the indeterminate mode
+ */
+ public synchronized void setIndeterminate(boolean indeterminate) {
+ if ((!mOnlyIndeterminate || !mIndeterminate) && indeterminate != mIndeterminate) {
+ mIndeterminate = indeterminate;
+
+ if (indeterminate) {
+ // swap between indeterminate and regular backgrounds
+ mCurrentDrawable = mIndeterminateDrawable;
+ startAnimation();
+ } else {
+ mCurrentDrawable = mProgressDrawable;
+ stopAnimation();
+ }
+ }
+ }
+
+ /**
+ * <p>Get the drawable used to draw the progress bar in
+ * indeterminate mode.</p>
+ *
+ * @return a {@link android.graphics.drawable.Drawable} instance
+ *
+ * @see #setIndeterminateDrawable(android.graphics.drawable.Drawable)
+ * @see #setIndeterminate(boolean)
+ */
+ public Drawable getIndeterminateDrawable() {
+ return mIndeterminateDrawable;
+ }
+
+ /**
+ * <p>Define the drawable used to draw the progress bar in
+ * indeterminate mode.</p>
+ *
+ * @param d the new drawable
+ *
+ * @see #getIndeterminateDrawable()
+ * @see #setIndeterminate(boolean)
+ */
+ public void setIndeterminateDrawable(Drawable d) {
+ if (d != null) {
+ d.setCallback(this);
+ }
+ mIndeterminateDrawable = d;
+ if (mIndeterminate) {
+ mCurrentDrawable = d;
+ postInvalidate();
+ }
+ }
+
+ /**
+ * <p>Get the drawable used to draw the progress bar in
+ * progress mode.</p>
+ *
+ * @return a {@link android.graphics.drawable.Drawable} instance
+ *
+ * @see #setProgressDrawable(android.graphics.drawable.Drawable)
+ * @see #setIndeterminate(boolean)
+ */
+ public Drawable getProgressDrawable() {
+ return mProgressDrawable;
+ }
+
+ /**
+ * <p>Define the drawable used to draw the progress bar in
+ * progress mode.</p>
+ *
+ * @param d the new drawable
+ *
+ * @see #getProgressDrawable()
+ * @see #setIndeterminate(boolean)
+ */
+ public void setProgressDrawable(Drawable d) {
+ boolean needUpdate;
+ if (mProgressDrawable != null && d != mProgressDrawable) {
+ mProgressDrawable.setCallback(null);
+ needUpdate = true;
+ } else {
+ needUpdate = false;
+ }
+
+ if (d != null) {
+ d.setCallback(this);
+
+ // Make sure the android_R_styleable_ProgressBar is always tall enough
+ int drawableHeight = d.getMinimumHeight();
+ if (mMaxHeight < drawableHeight) {
+ mMaxHeight = drawableHeight;
+ requestLayout();
+ }
+ }
+ mProgressDrawable = d;
+ if (!mIndeterminate) {
+ mCurrentDrawable = d;
+ postInvalidate();
+ }
+
+ if (needUpdate) {
+ updateDrawableBounds(getWidth(), getHeight());
+ updateDrawableState();
+ doRefreshProgress(android.R.id.progress, mProgress, false, false);
+ doRefreshProgress(android.R.id.secondaryProgress, mSecondaryProgress, false, false);
+ }
+ }
+
+ @Override
+ protected boolean verifyDrawable(Drawable who) {
+ return who == mProgressDrawable || who == mIndeterminateDrawable
+ || super.verifyDrawable(who);
+ }
+
+ @Override
+ public void postInvalidate() {
+ if (!mNoInvalidate) {
+ super.postInvalidate();
+ }
+ }
+
+ private class RefreshProgressRunnable implements Runnable {
+
+ private int mId;
+ private int mProgress;
+ private boolean mFromUser;
+
+ RefreshProgressRunnable(int id, int progress, boolean fromUser) {
+ mId = id;
+ mProgress = progress;
+ mFromUser = fromUser;
+ }
+
+ public void run() {
+ doRefreshProgress(mId, mProgress, mFromUser, true);
+ // Put ourselves back in the cache when we are done
+ mRefreshProgressRunnable = this;
+ }
+
+ public void setup(int id, int progress, boolean fromUser) {
+ mId = id;
+ mProgress = progress;
+ mFromUser = fromUser;
+ }
+
+ }
+
+ private synchronized void doRefreshProgress(int id, int progress, boolean fromUser,
+ boolean callBackToApp) {
+ float scale = mMax > 0 ? (float) progress / (float) mMax : 0;
+ final Drawable d = mCurrentDrawable;
+ if (d != null) {
+ Drawable progressDrawable = null;
+
+ if (d instanceof LayerDrawable) {
+ progressDrawable = ((LayerDrawable) d).findDrawableByLayerId(id);
+ }
+
+ final int level = (int) (scale * MAX_LEVEL);
+ (progressDrawable != null ? progressDrawable : d).setLevel(level);
+ } else {
+ invalidate();
+ }
+ }
+
+ private synchronized void refreshProgress(int id, int progress, boolean fromUser) {
+ if (mUiThreadId == Thread.currentThread().getId()) {
+ doRefreshProgress(id, progress, fromUser, true);
+ } else {
+ RefreshProgressRunnable r;
+ if (mRefreshProgressRunnable != null) {
+ // Use cached RefreshProgressRunnable if available
+ r = mRefreshProgressRunnable;
+ // Uncache it
+ mRefreshProgressRunnable = null;
+ r.setup(id, progress, fromUser);
+ } else {
+ // Make a new one
+ r = new RefreshProgressRunnable(id, progress, fromUser);
+ }
+ post(r);
+ }
+ }
+
+ /**
+ * <p>Set the current progress to the specified value. Does not do anything
+ * if the progress bar is in indeterminate mode.</p>
+ *
+ * @param progress the new progress, between 0 and {@link #getMax()}
+ *
+ * @see #setIndeterminate(boolean)
+ * @see #isIndeterminate()
+ * @see #getProgress()
+ * @see #incrementProgressBy(int)
+ */
+ public synchronized void setProgress(int progress) {
+ setProgress(progress, false);
+ }
+
+ synchronized void setProgress(int progress, boolean fromUser) {
+ if (mIndeterminate) {
+ return;
+ }
+
+ if (progress < 0) {
+ progress = 0;
+ }
+
+ if (progress > mMax) {
+ progress = mMax;
+ }
+
+ if (progress != mProgress) {
+ mProgress = progress;
+ refreshProgress(android.R.id.progress, mProgress, fromUser);
+ }
+ }
+
+ /**
+ * <p>
+ * Set the current secondary progress to the specified value. Does not do
+ * anything if the progress bar is in indeterminate mode.
+ * </p>
+ *
+ * @param secondaryProgress the new secondary progress, between 0 and {@link #getMax()}
+ * @see #setIndeterminate(boolean)
+ * @see #isIndeterminate()
+ * @see #getSecondaryProgress()
+ * @see #incrementSecondaryProgressBy(int)
+ */
+ public synchronized void setSecondaryProgress(int secondaryProgress) {
+ if (mIndeterminate) {
+ return;
+ }
+
+ if (secondaryProgress < 0) {
+ secondaryProgress = 0;
+ }
+
+ if (secondaryProgress > mMax) {
+ secondaryProgress = mMax;
+ }
+
+ if (secondaryProgress != mSecondaryProgress) {
+ mSecondaryProgress = secondaryProgress;
+ refreshProgress(android.R.id.secondaryProgress, mSecondaryProgress, false);
+ }
+ }
+
+ /**
+ * <p>Get the progress bar's current level of progress. Return 0 when the
+ * progress bar is in indeterminate mode.</p>
+ *
+ * @return the current progress, between 0 and {@link #getMax()}
+ *
+ * @see #setIndeterminate(boolean)
+ * @see #isIndeterminate()
+ * @see #setProgress(int)
+ * @see #setMax(int)
+ * @see #getMax()
+ */
+ public synchronized int getProgress() {
+ return mIndeterminate ? 0 : mProgress;
+ }
+
+ /**
+ * <p>Get the progress bar's current level of secondary progress. Return 0 when the
+ * progress bar is in indeterminate mode.</p>
+ *
+ * @return the current secondary progress, between 0 and {@link #getMax()}
+ *
+ * @see #setIndeterminate(boolean)
+ * @see #isIndeterminate()
+ * @see #setSecondaryProgress(int)
+ * @see #setMax(int)
+ * @see #getMax()
+ */
+ public synchronized int getSecondaryProgress() {
+ return mIndeterminate ? 0 : mSecondaryProgress;
+ }
+
+ /**
+ * <p>Return the upper limit of this progress bar's range.</p>
+ *
+ * @return a positive integer
+ *
+ * @see #setMax(int)
+ * @see #getProgress()
+ * @see #getSecondaryProgress()
+ */
+ public synchronized int getMax() {
+ return mMax;
+ }
+
+ /**
+ * <p>Set the range of the progress bar to 0...<tt>max</tt>.</p>
+ *
+ * @param max the upper range of this progress bar
+ *
+ * @see #getMax()
+ * @see #setProgress(int)
+ * @see #setSecondaryProgress(int)
+ */
+ public synchronized void setMax(int max) {
+ if (max < 0) {
+ max = 0;
+ }
+ if (max != mMax) {
+ mMax = max;
+ postInvalidate();
+
+ if (mProgress > max) {
+ mProgress = max;
+ }
+ refreshProgress(android.R.id.progress, mProgress, false);
+ }
+ }
+
+ /**
+ * <p>Increase the progress bar's progress by the specified amount.</p>
+ *
+ * @param diff the amount by which the progress must be increased
+ *
+ * @see #setProgress(int)
+ */
+ public synchronized final void incrementProgressBy(int diff) {
+ setProgress(mProgress + diff);
+ }
+
+ /**
+ * <p>Increase the progress bar's secondary progress by the specified amount.</p>
+ *
+ * @param diff the amount by which the secondary progress must be increased
+ *
+ * @see #setSecondaryProgress(int)
+ */
+ public synchronized final void incrementSecondaryProgressBy(int diff) {
+ setSecondaryProgress(mSecondaryProgress + diff);
+ }
+
+ /**
+ * <p>Start the indeterminate progress animation.</p>
+ */
+ void startAnimation() {
+ if (getVisibility() != VISIBLE) {
+ return;
+ }
+
+ if (mIndeterminateDrawable instanceof Animatable) {
+ mShouldStartAnimationDrawable = true;
+ mAnimation = null;
+ } else {
+ if (mInterpolator == null) {
+ mInterpolator = new LinearInterpolator();
+ }
+
+ mTransformation = new Transformation();
+ mAnimation = new AlphaAnimation(0.0f, 1.0f);
+ mAnimation.setRepeatMode(mBehavior);
+ mAnimation.setRepeatCount(Animation.INFINITE);
+ mAnimation.setDuration(mDuration);
+ mAnimation.setInterpolator(mInterpolator);
+ mAnimation.setStartTime(Animation.START_ON_FIRST_FRAME);
+ }
+ postInvalidate();
+ }
+
+ /**
+ * <p>Stop the indeterminate progress animation.</p>
+ */
+ void stopAnimation() {
+ mAnimation = null;
+ mTransformation = null;
+ if (mIndeterminateDrawable instanceof Animatable) {
+ ((Animatable) mIndeterminateDrawable).stop();
+ mShouldStartAnimationDrawable = false;
+ }
+ postInvalidate();
+ }
+
+ /**
+ * Sets the acceleration curve for the indeterminate animation.
+ * The interpolator is loaded as a resource from the specified context.
+ *
+ * @param context The application environment
+ * @param resID The resource identifier of the interpolator to load
+ */
+ public void setInterpolator(Context context, int resID) {
+ setInterpolator(AnimationUtils.loadInterpolator(context, resID));
+ }
+
+ /**
+ * Sets the acceleration curve for the indeterminate animation.
+ * Defaults to a linear interpolation.
+ *
+ * @param interpolator The interpolator which defines the acceleration curve
+ */
+ public void setInterpolator(Interpolator interpolator) {
+ mInterpolator = interpolator;
+ }
+
+ /**
+ * Gets the acceleration curve type for the indeterminate animation.
+ *
+ * @return the {@link Interpolator} associated to this animation
+ */
+ public Interpolator getInterpolator() {
+ return mInterpolator;
+ }
+
+ @Override
+ public void setVisibility(int v) {
+ if (getVisibility() != v) {
+ super.setVisibility(v);
+
+ if (mIndeterminate) {
+ // let's be nice with the UI thread
+ if (v == GONE || v == INVISIBLE) {
+ stopAnimation();
+ } else {
+ startAnimation();
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void onVisibilityChanged(View changedView, int visibility) {
+ super.onVisibilityChanged(changedView, visibility);
+
+ if (mIndeterminate) {
+ // let's be nice with the UI thread
+ if (visibility == GONE || visibility == INVISIBLE) {
+ stopAnimation();
+ } else {
+ startAnimation();
+ }
+ }
+ }
+
+ @Override
+ public void invalidateDrawable(Drawable dr) {
+ if (!mInDrawing) {
+ if (verifyDrawable(dr)) {
+ final Rect dirty = dr.getBounds();
+ final int scrollX = getScrollX() + getPaddingLeft();
+ final int scrollY = getScrollY() + getPaddingTop();
+
+ invalidate(dirty.left + scrollX, dirty.top + scrollY,
+ dirty.right + scrollX, dirty.bottom + scrollY);
+ } else {
+ super.invalidateDrawable(dr);
+ }
+ }
+ }
+
+ @Override
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ updateDrawableBounds(w, h);
+ }
+
+ private void updateDrawableBounds(int w, int h) {
+ // onDraw will translate the canvas so we draw starting at 0,0
+ int right = w - getPaddingRight() - getPaddingLeft();
+ int bottom = h - getPaddingBottom() - getPaddingTop();
+ int top = 0;
+ int left = 0;
+
+ if (mIndeterminateDrawable != null) {
+ // Aspect ratio logic does not apply to AnimationDrawables
+ if (mOnlyIndeterminate && !(mIndeterminateDrawable instanceof AnimationDrawable)) {
+ // Maintain aspect ratio. Certain kinds of animated drawables
+ // get very confused otherwise.
+ final int intrinsicWidth = mIndeterminateDrawable.getIntrinsicWidth();
+ final int intrinsicHeight = mIndeterminateDrawable.getIntrinsicHeight();
+ final float intrinsicAspect = (float) intrinsicWidth / intrinsicHeight;
+ final float boundAspect = (float) w / h;
+ if (intrinsicAspect != boundAspect) {
+ if (boundAspect > intrinsicAspect) {
+ // New width is larger. Make it smaller to match height.
+ final int width = (int) (h * intrinsicAspect);
+ left = (w - width) / 2;
+ right = left + width;
+ } else {
+ // New height is larger. Make it smaller to match width.
+ final int height = (int) (w * (1 / intrinsicAspect));
+ top = (h - height) / 2;
+ bottom = top + height;
+ }
+ }
+ }
+ mIndeterminateDrawable.setBounds(left, top, right, bottom);
+ }
+
+ if (mProgressDrawable != null) {
+ mProgressDrawable.setBounds(0, 0, right, bottom);
+ }
+ }
+
+ @Override
+ protected synchronized void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+
+ Drawable d = mCurrentDrawable;
+ if (d != null) {
+ // Translate canvas so a indeterminate circular progress bar with padding
+ // rotates properly in its animation
+ canvas.save();
+ canvas.translate(getPaddingLeft(), getPaddingTop());
+ long time = getDrawingTime();
+ if (mAnimation != null) {
+ mAnimation.getTransformation(time, mTransformation);
+ float scale = mTransformation.getAlpha();
+ try {
+ mInDrawing = true;
+ d.setLevel((int) (scale * MAX_LEVEL));
+ } finally {
+ mInDrawing = false;
+ }
+ if (SystemClock.uptimeMillis() - mLastDrawTime >= ANIMATION_RESOLUTION) {
+ mLastDrawTime = SystemClock.uptimeMillis();
+ postInvalidateDelayed(ANIMATION_RESOLUTION);
+ }
+ }
+ d.draw(canvas);
+ canvas.restore();
+ if (mShouldStartAnimationDrawable && d instanceof Animatable) {
+ ((Animatable) d).start();
+ mShouldStartAnimationDrawable = false;
+ }
+ }
+ }
+
+ @Override
+ protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ Drawable d = mCurrentDrawable;
+
+ int dw = 0;
+ int dh = 0;
+ if (d != null) {
+ dw = Math.max(mMinWidth, Math.min(mMaxWidth, d.getIntrinsicWidth()));
+ dh = Math.max(mMinHeight, Math.min(mMaxHeight, d.getIntrinsicHeight()));
+ }
+ updateDrawableState();
+ dw += getPaddingLeft() + getPaddingRight();
+ dh += getPaddingTop() + getPaddingBottom();
+
+ setMeasuredDimension(resolveSize(dw, widthMeasureSpec),
+ resolveSize(dh, heightMeasureSpec));
+ }
+
+ @Override
+ protected void drawableStateChanged() {
+ super.drawableStateChanged();
+ updateDrawableState();
+ }
+
+ private void updateDrawableState() {
+ int[] state = getDrawableState();
+
+ if (mProgressDrawable != null && mProgressDrawable.isStateful()) {
+ mProgressDrawable.setState(state);
+ }
+
+ if (mIndeterminateDrawable != null && mIndeterminateDrawable.isStateful()) {
+ mIndeterminateDrawable.setState(state);
+ }
+ }
+
+ static class SavedState extends BaseSavedState {
+ int progress;
+ int secondaryProgress;
+
+ /**
+ * Constructor called from {@link ProgressBarICS#onSaveInstanceState()}
+ */
+ SavedState(Parcelable superState) {
+ super(superState);
+ }
+
+ /**
+ * Constructor called from {@link #CREATOR}
+ */
+ private SavedState(Parcel in) {
+ super(in);
+ progress = in.readInt();
+ secondaryProgress = in.readInt();
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ super.writeToParcel(out, flags);
+ out.writeInt(progress);
+ out.writeInt(secondaryProgress);
+ }
+
+ public static final Parcelable.Creator<SavedState> CREATOR
+ = new Parcelable.Creator<SavedState>() {
+ public SavedState createFromParcel(Parcel in) {
+ return new SavedState(in);
+ }
+
+ public SavedState[] newArray(int size) {
+ return new SavedState[size];
+ }
+ };
+ }
+
+ @Override
+ public Parcelable onSaveInstanceState() {
+ // Force our ancestor class to save its state
+ Parcelable superState = super.onSaveInstanceState();
+ SavedState ss = new SavedState(superState);
+
+ ss.progress = mProgress;
+ ss.secondaryProgress = mSecondaryProgress;
+
+ return ss;
+ }
+
+ @Override
+ public void onRestoreInstanceState(Parcelable state) {
+ SavedState ss = (SavedState) state;
+ super.onRestoreInstanceState(ss.getSuperState());
+
+ setProgress(ss.progress);
+ setSecondaryProgress(ss.secondaryProgress);
+ }
+
+ @Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ if (mIndeterminate) {
+ startAnimation();
+ }
+ }
+
+ @Override
+ protected void onDetachedFromWindow() {
+ if (mIndeterminate) {
+ stopAnimation();
+ }
+ if(mRefreshProgressRunnable != null) {
+ removeCallbacks(mRefreshProgressRunnable);
+ }
+
+ // This should come after stopAnimation(), otherwise an invalidate message remains in the
+ // queue, which can prevent the entire view hierarchy from being GC'ed during a rotation
+ super.onDetachedFromWindow();
+ }
+
+}
\ No newline at end of file
diff --git a/appcompat/eclair/android/support/appcompat/widget/ScrollingTabContainerView.java b/v7/appcompat/src/android/support/v7/internal/widget/ScrollingTabContainerView.java
similarity index 92%
rename from appcompat/eclair/android/support/appcompat/widget/ScrollingTabContainerView.java
rename to v7/appcompat/src/android/support/v7/internal/widget/ScrollingTabContainerView.java
index 370a0de..e5ccbf7 100644
--- a/appcompat/eclair/android/support/appcompat/widget/ScrollingTabContainerView.java
+++ b/v7/appcompat/src/android/support/v7/internal/widget/ScrollingTabContainerView.java
@@ -13,16 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package android.support.appcompat.widget;
+package android.support.v7.internal.widget;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
-import android.support.appcompat.R;
-import android.support.appcompat.app.ActionBar;
-import android.support.appcompat.view.ActionBarPolicy;
+import android.support.v7.app.ActionBar;
+import android.support.v7.appcompat.R;
+import android.support.v7.internal.view.ActionBarPolicy;
import android.text.TextUtils.TruncateAt;
+import android.util.AttributeSet;
import android.view.Gravity;
+import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
@@ -50,6 +52,8 @@
private Spinner mTabSpinner;
private boolean mAllowCollapse;
+ private final LayoutInflater mInflater;
+
int mMaxTabWidth;
int mStackedTabMaxWidth;
private int mContentHeight;
@@ -57,13 +61,15 @@
public ScrollingTabContainerView(Context context) {
super(context);
+ mInflater = LayoutInflater.from(context);
+
setHorizontalScrollBarEnabled(false);
ActionBarPolicy abp = ActionBarPolicy.get(context);
setContentHeight(abp.getTabContainerHeight());
mStackedTabMaxWidth = abp.getStackedTabMaxWidth();
- mTabLayout = createTabLayout();
+ mTabLayout = (LinearLayout) mInflater.inflate(R.layout.abc_action_bar_tabbar, this, false);
addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.FILL_PARENT));
}
@@ -177,17 +183,6 @@
requestLayout();
}
- private LinearLayout createTabLayout() {
- //final LinearLayout tabLayout = new LinearLayout( getContext(), null, R.attr.actionBarTabBarStyle);
- final LinearLayout tabLayout = new LinearLayout(getContext(), null);
-
- //tabLayout.setMeasureWithLargestChildEnabled(true);
- tabLayout.setGravity(Gravity.CENTER);
- tabLayout.setLayoutParams(new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.FILL_PARENT));
- return tabLayout;
- }
-
private Spinner createSpinner() {
final Spinner spinner = new Spinner(getContext(), null,
R.attr.actionDropDownStyle);
@@ -238,7 +233,10 @@
}
private TabView createTabView(ActionBar.Tab tab, boolean forAdapter) {
- final TabView tabView = new TabView(getContext(), tab, forAdapter);
+ final TabView tabView = (TabView) mInflater.inflate(R.layout.abc_action_bar_tab, mTabLayout,
+ false);
+ tabView.attach(this, tab, forAdapter);
+
if (forAdapter) {
tabView.setBackgroundDrawable(null);
tabView.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.FILL_PARENT,
@@ -320,17 +318,20 @@
tabView.getTab().select();
}
- private class TabView extends LinearLayout {
+ public static class TabView extends LinearLayout {
private ActionBar.Tab mTab;
private TextView mTextView;
private ImageView mIconView;
private View mCustomView;
+ private ScrollingTabContainerView mParent;
- public TabView(Context context, ActionBar.Tab tab, boolean forList) {
- //super(context, null, R.attr.actionBarTabStyle);
- super(context, null);
+ public TabView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+ void attach(ScrollingTabContainerView parent, ActionBar.Tab tab, boolean forList) {
+ mParent = parent;
mTab = tab;
if (forList) {
@@ -349,9 +350,11 @@
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ int maxTabWidth = mParent != null ? mParent.mMaxTabWidth : 0;
+
// Re-measure if we went beyond our maximum size.
- if (mMaxTabWidth > 0 && getMeasuredWidth() > mMaxTabWidth) {
- super.onMeasure(MeasureSpec.makeMeasureSpec(mMaxTabWidth, MeasureSpec.EXACTLY),
+ if (maxTabWidth > 0 && getMeasuredWidth() > maxTabWidth) {
+ super.onMeasure(MeasureSpec.makeMeasureSpec(maxTabWidth, MeasureSpec.EXACTLY),
heightMeasureSpec);
}
}
diff --git a/v7/appcompat/src/android/support/v7/internal/widget/SpinnerICS.java b/v7/appcompat/src/android/support/v7/internal/widget/SpinnerICS.java
new file mode 100644
index 0000000..9d829de
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/internal/widget/SpinnerICS.java
@@ -0,0 +1,754 @@
+package android.support.v7.internal.widget;
+
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
+import android.content.res.TypedArray;
+import android.database.DataSetObserver;
+import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
+import android.support.v7.appcompat.R;
+import android.util.AttributeSet;
+import android.view.Gravity;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ListAdapter;
+import android.widget.ListView;
+import android.widget.Spinner;
+import android.widget.SpinnerAdapter;
+
+
+/**
+ * A view that displays one child at a time and lets the user pick among them.
+ * The items in the Spinner come from the {@link android.widget.Adapter} associated with
+ * this view.
+ *
+ * <p>See the <a href="{@docRoot}resources/tutorials/views/hello-spinner.html">Spinner
+ * tutorial</a>.</p>
+ *
+ * @attr ref R.styleable#Spinner_prompt
+ */
+class SpinnerICS extends AbsSpinnerICS implements OnClickListener {
+ private static final String TAG = "Spinner";
+
+ // Only measure this many items to get a decent max width.
+ private static final int MAX_ITEMS_MEASURED = 15;
+
+ /**
+ * Use a dialog window for selecting spinner options.
+ */
+ static final int MODE_DIALOG = 0;
+
+ /**
+ * Use a dropdown anchored to the Spinner for selecting spinner options.
+ */
+ static final int MODE_DROPDOWN = 1;
+
+ /**
+ * Use the theme-supplied value to select the dropdown mode.
+ */
+ private static final int MODE_THEME = -1;
+
+ private SpinnerPopup mPopup;
+ private DropDownAdapter mTempAdapter;
+ int mDropDownWidth;
+
+ private int mGravity;
+
+ private Rect mTempRect = new Rect();
+
+ /**
+ * Construct a new spinner with the given context's theme.
+ *
+ * @param context The Context the view is running in, through which it can
+ * access the current theme, resources, etc.
+ */
+ SpinnerICS(Context context) {
+ this(context, null);
+ }
+
+ /**
+ * Construct a new spinner with the given context's theme and the supplied
+ * mode of displaying choices. <code>mode</code> may be one of
+ * {@link #MODE_DIALOG} or {@link #MODE_DROPDOWN}.
+ *
+ * @param context The Context the view is running in, through which it can
+ * access the current theme, resources, etc.
+ * @param mode Constant describing how the user will select choices from the spinner.
+ *
+ * @see #MODE_DIALOG
+ * @see #MODE_DROPDOWN
+ */
+ SpinnerICS(Context context, int mode) {
+ this(context, null, R.attr.spinnerStyle, mode);
+ }
+
+ /**
+ * Construct a new spinner with the given context's theme and the supplied attribute set.
+ *
+ * @param context The Context the view is running in, through which it can
+ * access the current theme, resources, etc.
+ * @param attrs The attributes of the XML tag that is inflating the view.
+ */
+ SpinnerICS(Context context, AttributeSet attrs) {
+ this(context, attrs, R.attr.spinnerStyle);
+ }
+
+ /**
+ * Construct a new spinner with the given context's theme, the supplied attribute set,
+ * and default style.
+ *
+ * @param context The Context the view is running in, through which it can
+ * access the current theme, resources, etc.
+ * @param attrs The attributes of the XML tag that is inflating the view.
+ * @param defStyle The default style to apply to this view. If 0, no style
+ * will be applied (beyond what is included in the theme). This may
+ * either be an attribute resource, whose value will be retrieved
+ * from the current theme, or an explicit style resource.
+ */
+ SpinnerICS(Context context, AttributeSet attrs, int defStyle) {
+ this(context, attrs, defStyle, MODE_THEME);
+ }
+
+ /**
+ * Construct a new spinner with the given context's theme, the supplied attribute set,
+ * and default style. <code>mode</code> may be one of {@link #MODE_DIALOG} or
+ * {@link #MODE_DROPDOWN} and determines how the user will select choices from the spinner.
+ *
+ * @param context The Context the view is running in, through which it can
+ * access the current theme, resources, etc.
+ * @param attrs The attributes of the XML tag that is inflating the view.
+ * @param defStyle The default style to apply to this view. If 0, no style
+ * will be applied (beyond what is included in the theme). This may
+ * either be an attribute resource, whose value will be retrieved
+ * from the current theme, or an explicit style resource.
+ * @param mode Constant describing how the user will select choices from the spinner.
+ *
+ * @see #MODE_DIALOG
+ * @see #MODE_DROPDOWN
+ */
+ SpinnerICS(Context context, AttributeSet attrs, int defStyle, int mode) {
+ super(context, attrs, defStyle);
+
+ TypedArray a = context.obtainStyledAttributes(attrs,
+ R.styleable.Spinner, defStyle, 0);
+
+ if (mode == MODE_THEME) {
+ mode = a.getInt(R.styleable.Spinner_spinnerMode, MODE_DIALOG);
+ }
+
+ switch (mode) {
+ case MODE_DIALOG: {
+ mPopup = new DialogPopup();
+ break;
+ }
+
+ case MODE_DROPDOWN: {
+ DropdownPopup popup = new DropdownPopup(context, attrs, defStyle);
+
+ mDropDownWidth = a.getLayoutDimension(R.styleable.Spinner_android_dropDownWidth,
+ ViewGroup.LayoutParams.WRAP_CONTENT);
+
+ popup.setBackgroundDrawable(
+ a.getDrawable(R.styleable.Spinner_android_popupBackground));
+
+ final int verticalOffset = a.getDimensionPixelOffset(
+ R.styleable.Spinner_android_dropDownVerticalOffset, 0);
+ if (verticalOffset != 0) {
+ popup.setVerticalOffset(verticalOffset);
+ }
+
+ final int horizontalOffset = a.getDimensionPixelOffset(
+ R.styleable.Spinner_android_dropDownHorizontalOffset, 0);
+ if (horizontalOffset != 0) {
+ popup.setHorizontalOffset(horizontalOffset);
+ }
+
+ mPopup = popup;
+ break;
+ }
+ }
+
+ mGravity = a.getInt(R.styleable.Spinner_android_gravity, Gravity.CENTER);
+
+ mPopup.setPromptText(a.getString(R.styleable.Spinner_prompt));
+
+ a.recycle();
+
+ // Base constructor can call setAdapter before we initialize mPopup.
+ // Finish setting things up if this happened.
+ if (mTempAdapter != null) {
+ mPopup.setAdapter(mTempAdapter);
+ mTempAdapter = null;
+ }
+ }
+
+ /**
+ * Describes how the selected item view is positioned. Currently only the horizontal component
+ * is used. The default is determined by the current theme.
+ *
+ * @param gravity See {@link android.view.Gravity}
+ *
+ * @attr ref android.R.styleable#Spinner_gravity
+ */
+ public void setGravity(int gravity) {
+ if (mGravity != gravity) {
+ if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == 0) {
+ gravity |= Gravity.LEFT;
+ }
+ mGravity = gravity;
+ requestLayout();
+ }
+ }
+
+ @Override
+ public void setAdapter(SpinnerAdapter adapter) {
+ super.setAdapter(adapter);
+
+ if (mPopup != null) {
+ mPopup.setAdapter(new DropDownAdapter(adapter));
+ } else {
+ mTempAdapter = new DropDownAdapter(adapter);
+ }
+ }
+
+ @Override
+ public int getBaseline() {
+ View child = null;
+
+ if (getChildCount() > 0) {
+ child = getChildAt(0);
+ } else if (mAdapter != null && mAdapter.getCount() > 0) {
+ child = makeAndAddView(0);
+ mRecycler.put(0, child);
+ removeAllViewsInLayout();
+ }
+
+ if (child != null) {
+ final int childBaseline = child.getBaseline();
+ return childBaseline >= 0 ? child.getTop() + childBaseline : -1;
+ } else {
+ return -1;
+ }
+ }
+
+ @Override
+ protected void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+
+ if (mPopup != null && mPopup.isShowing()) {
+ mPopup.dismiss();
+ }
+ }
+
+ /**
+ * <p>A spinner does not support item click events. Calling this method
+ * will raise an exception.</p>
+ *
+ * @param l this listener will be ignored
+ */
+ @Override
+ public void setOnItemClickListener(OnItemClickListener l) {
+ throw new RuntimeException("setOnItemClickListener cannot be used with a spinner.");
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ if (mPopup != null && MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.AT_MOST) {
+ final int measuredWidth = getMeasuredWidth();
+ setMeasuredDimension(Math.min(Math.max(measuredWidth,
+ measureContentWidth(getAdapter(), getBackground())),
+ MeasureSpec.getSize(widthMeasureSpec)),
+ getMeasuredHeight());
+ }
+ }
+
+ /**
+ * @see android.view.View#onLayout(boolean,int,int,int,int)
+ *
+ * Creates and positions all views
+ *
+ */
+ @Override
+ protected void onLayout(boolean changed, int l, int t, int r, int b) {
+ super.onLayout(changed, l, t, r, b);
+ mInLayout = true;
+ layout(0, false);
+ mInLayout = false;
+ }
+
+ /**
+ * Creates and positions all views for this Spinner.
+ *
+ * @param delta Change in the selected position. +1 moves selection is moving to the right,
+ * so views are scrolling to the left. -1 means selection is moving to the left.
+ */
+ @Override
+ void layout(int delta, boolean animate) {
+ int childrenLeft = mSpinnerPadding.left;
+ int childrenWidth = getRight() - getLeft() - mSpinnerPadding.left - mSpinnerPadding.right;
+
+ if (mDataChanged) {
+ handleDataChanged();
+ }
+
+ // Handle the empty set by removing all views
+ if (mItemCount == 0) {
+ resetList();
+ return;
+ }
+
+ if (mNextSelectedPosition >= 0) {
+ setSelectedPositionInt(mNextSelectedPosition);
+ }
+
+ recycleAllViews();
+
+ // Clear out old views
+ removeAllViewsInLayout();
+
+ // Make selected view and position it
+ mFirstPosition = mSelectedPosition;
+ View sel = makeAndAddView(mSelectedPosition);
+ int width = sel.getMeasuredWidth();
+ int selectedOffset = childrenLeft;
+ switch (mGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
+ case Gravity.CENTER_HORIZONTAL:
+ selectedOffset = childrenLeft + (childrenWidth / 2) - (width / 2);
+ break;
+ case Gravity.RIGHT:
+ selectedOffset = childrenLeft + childrenWidth - width;
+ break;
+ }
+ sel.offsetLeftAndRight(selectedOffset);
+
+ // Flush any cached views that did not get reused above
+ mRecycler.clear();
+
+ invalidate();
+
+ checkSelectionChanged();
+
+ mDataChanged = false;
+ mNeedSync = false;
+ setNextSelectedPositionInt(mSelectedPosition);
+ }
+
+ /**
+ * Obtain a view, either by pulling an existing view from the recycler or
+ * by getting a new one from the adapter. If we are animating, make sure
+ * there is enough information in the view's layout parameters to animate
+ * from the old to new positions.
+ *
+ * @param position Position in the spinner for the view to obtain
+ * @return A view that has been added to the spinner
+ */
+ private View makeAndAddView(int position) {
+
+ View child;
+
+ if (!mDataChanged) {
+ child = mRecycler.get(position);
+ if (child != null) {
+ // Position the view
+ setUpChild(child);
+
+ return child;
+ }
+ }
+
+ // Nothing found in the recycler -- ask the adapter for a view
+ child = mAdapter.getView(position, null, this);
+
+ // Position the view
+ setUpChild(child);
+
+ return child;
+ }
+
+ /**
+ * Helper for makeAndAddView to set the position of a view
+ * and fill out its layout paramters.
+ *
+ * @param child The view to position
+ */
+ private void setUpChild(View child) {
+
+ // Respect layout params that are already in the view. Otherwise
+ // make some up...
+ ViewGroup.LayoutParams lp = child.getLayoutParams();
+ if (lp == null) {
+ lp = generateDefaultLayoutParams();
+ }
+
+ addViewInLayout(child, 0, lp);
+
+ child.setSelected(hasFocus());
+
+ // Get measure specs
+ int childHeightSpec = ViewGroup.getChildMeasureSpec(mHeightMeasureSpec,
+ mSpinnerPadding.top + mSpinnerPadding.bottom, lp.height);
+ int childWidthSpec = ViewGroup.getChildMeasureSpec(mWidthMeasureSpec,
+ mSpinnerPadding.left + mSpinnerPadding.right, lp.width);
+
+ // Measure child
+ child.measure(childWidthSpec, childHeightSpec);
+
+ int childLeft;
+ int childRight;
+
+ // Position vertically based on gravity setting
+ int childTop = mSpinnerPadding.top
+ + ((getMeasuredHeight() - mSpinnerPadding.bottom -
+ mSpinnerPadding.top - child.getMeasuredHeight()) / 2);
+ int childBottom = childTop + child.getMeasuredHeight();
+
+ int width = child.getMeasuredWidth();
+ childLeft = 0;
+ childRight = childLeft + width;
+
+ child.layout(childLeft, childTop, childRight, childBottom);
+ }
+
+ @Override
+ public boolean performClick() {
+ boolean handled = super.performClick();
+
+ if (!handled) {
+ handled = true;
+
+ if (!mPopup.isShowing()) {
+ mPopup.show();
+ }
+ }
+
+ return handled;
+ }
+
+ public void onClick(DialogInterface dialog, int which) {
+ setSelection(which);
+ dialog.dismiss();
+ }
+
+ /**
+ * Sets the prompt to display when the dialog is shown.
+ * @param prompt the prompt to set
+ */
+ public void setPrompt(CharSequence prompt) {
+ mPopup.setPromptText(prompt);
+ }
+
+ /**
+ * Sets the prompt to display when the dialog is shown.
+ * @param promptId the resource ID of the prompt to display when the dialog is shown
+ */
+ public void setPromptId(int promptId) {
+ setPrompt(getContext().getText(promptId));
+ }
+
+ /**
+ * @return The prompt to display when the dialog is shown
+ */
+ public CharSequence getPrompt() {
+ return mPopup.getHintText();
+ }
+
+ int measureContentWidth(SpinnerAdapter adapter, Drawable background) {
+ if (adapter == null) {
+ return 0;
+ }
+
+ int width = 0;
+ View itemView = null;
+ int itemType = 0;
+ final int widthMeasureSpec =
+ MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
+ final int heightMeasureSpec =
+ MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
+
+ // Make sure the number of items we'll measure is capped. If it's a huge data set
+ // with wildly varying sizes, oh well.
+ int start = Math.max(0, getSelectedItemPosition());
+ final int end = Math.min(adapter.getCount(), start + MAX_ITEMS_MEASURED);
+ final int count = end - start;
+ start = Math.max(0, start - (MAX_ITEMS_MEASURED - count));
+ for (int i = start; i < end; i++) {
+ final int positionType = adapter.getItemViewType(i);
+ if (positionType != itemType) {
+ itemType = positionType;
+ itemView = null;
+ }
+ itemView = adapter.getView(i, itemView, this);
+ if (itemView.getLayoutParams() == null) {
+ itemView.setLayoutParams(new ViewGroup.LayoutParams(
+ ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT));
+ }
+ itemView.measure(widthMeasureSpec, heightMeasureSpec);
+ width = Math.max(width, itemView.getMeasuredWidth());
+ }
+
+ // Add background padding to measured width
+ if (background != null) {
+ background.getPadding(mTempRect);
+ width += mTempRect.left + mTempRect.right;
+ }
+
+ return width;
+ }
+
+ /**
+ * <p>Wrapper class for an Adapter. Transforms the embedded Adapter instance
+ * into a ListAdapter.</p>
+ */
+ private static class DropDownAdapter implements ListAdapter, SpinnerAdapter {
+ private SpinnerAdapter mAdapter;
+ private ListAdapter mListAdapter;
+
+ /**
+ * <p>Creates a new ListAdapter wrapper for the specified adapter.</p>
+ *
+ * @param adapter the Adapter to transform into a ListAdapter
+ */
+ public DropDownAdapter(SpinnerAdapter adapter) {
+ this.mAdapter = adapter;
+ if (adapter instanceof ListAdapter) {
+ this.mListAdapter = (ListAdapter) adapter;
+ }
+ }
+
+ public int getCount() {
+ return mAdapter == null ? 0 : mAdapter.getCount();
+ }
+
+ public Object getItem(int position) {
+ return mAdapter == null ? null : mAdapter.getItem(position);
+ }
+
+ public long getItemId(int position) {
+ return mAdapter == null ? -1 : mAdapter.getItemId(position);
+ }
+
+ public View getView(int position, View convertView, ViewGroup parent) {
+ return getDropDownView(position, convertView, parent);
+ }
+
+ public View getDropDownView(int position, View convertView, ViewGroup parent) {
+ return mAdapter == null ? null :
+ mAdapter.getDropDownView(position, convertView, parent);
+ }
+
+ public boolean hasStableIds() {
+ return mAdapter != null && mAdapter.hasStableIds();
+ }
+
+ public void registerDataSetObserver(DataSetObserver observer) {
+ if (mAdapter != null) {
+ mAdapter.registerDataSetObserver(observer);
+ }
+ }
+
+ public void unregisterDataSetObserver(DataSetObserver observer) {
+ if (mAdapter != null) {
+ mAdapter.unregisterDataSetObserver(observer);
+ }
+ }
+
+ /**
+ * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call.
+ * Otherwise, return true.
+ */
+ public boolean areAllItemsEnabled() {
+ final ListAdapter adapter = mListAdapter;
+ if (adapter != null) {
+ return adapter.areAllItemsEnabled();
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call.
+ * Otherwise, return true.
+ */
+ public boolean isEnabled(int position) {
+ final ListAdapter adapter = mListAdapter;
+ if (adapter != null) {
+ return adapter.isEnabled(position);
+ } else {
+ return true;
+ }
+ }
+
+ public int getItemViewType(int position) {
+ return 0;
+ }
+
+ public int getViewTypeCount() {
+ return 1;
+ }
+
+ public boolean isEmpty() {
+ return getCount() == 0;
+ }
+ }
+
+ /**
+ * Implements some sort of popup selection interface for selecting a spinner option.
+ * Allows for different spinner modes.
+ */
+ private interface SpinnerPopup {
+ public void setAdapter(ListAdapter adapter);
+
+ /**
+ * Show the popup
+ */
+ public void show();
+
+ /**
+ * Dismiss the popup
+ */
+ public void dismiss();
+
+ /**
+ * @return true if the popup is showing, false otherwise.
+ */
+ public boolean isShowing();
+
+ /**
+ * Set hint text to be displayed to the user. This should provide
+ * a description of the choice being made.
+ * @param hintText Hint text to set.
+ */
+ public void setPromptText(CharSequence hintText);
+ public CharSequence getHintText();
+ }
+
+ private class DialogPopup implements SpinnerPopup, DialogInterface.OnClickListener {
+ private AlertDialog mPopup;
+ private ListAdapter mListAdapter;
+ private CharSequence mPrompt;
+
+ public void dismiss() {
+ mPopup.dismiss();
+ mPopup = null;
+ }
+
+ public boolean isShowing() {
+ return mPopup != null ? mPopup.isShowing() : false;
+ }
+
+ public void setAdapter(ListAdapter adapter) {
+ mListAdapter = adapter;
+ }
+
+ public void setPromptText(CharSequence hintText) {
+ mPrompt = hintText;
+ }
+
+ public CharSequence getHintText() {
+ return mPrompt;
+ }
+
+ public void show() {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
+ if (mPrompt != null) {
+ builder.setTitle(mPrompt);
+ }
+ mPopup = builder.setSingleChoiceItems(mListAdapter,
+ getSelectedItemPosition(), this).show();
+ }
+
+ public void onClick(DialogInterface dialog, int which) {
+ setSelection(which);
+ dismiss();
+ }
+ }
+
+ private class DropdownPopup extends android.support.v7.internal.widget.ListPopupWindow
+ implements SpinnerPopup {
+ private CharSequence mHintText;
+ private ListAdapter mAdapter;
+
+ public DropdownPopup(Context context, AttributeSet attrs, int defStyleRes) {
+ super(context, attrs, defStyleRes);
+
+ setAnchorView(SpinnerICS.this);
+ setModal(true);
+ setPromptPosition(POSITION_PROMPT_ABOVE);
+
+ AdapterView.OnItemClickListener listener = new OnItemClickListenerWrapper(
+ new OnItemClickListener() {
+ public void onItemClick(AdapterViewICS parent, View v, int position, long id) {
+ SpinnerICS.this.setSelection(position);
+ dismiss();
+ }
+ });
+
+ setOnItemClickListener(listener);
+ }
+
+ @Override
+ public void setAdapter(ListAdapter adapter) {
+ super.setAdapter(adapter);
+ mAdapter = adapter;
+ }
+
+ public CharSequence getHintText() {
+ return mHintText;
+ }
+
+ public void setPromptText(CharSequence hintText) {
+ // Hint text is ignored for dropdowns, but maintain it here.
+ mHintText = hintText;
+ }
+
+ @Override
+ public void show() {
+ final int spinnerPaddingLeft = SpinnerICS.this.getPaddingLeft();
+ if (mDropDownWidth == WRAP_CONTENT) {
+ final int spinnerWidth = SpinnerICS.this.getWidth();
+ final int spinnerPaddingRight = SpinnerICS.this.getPaddingRight();
+ setContentWidth(Math.max(
+ measureContentWidth((SpinnerAdapter) mAdapter, getBackground()),
+ spinnerWidth - spinnerPaddingLeft - spinnerPaddingRight));
+ } else if (mDropDownWidth == FILL_PARENT) {
+ final int spinnerWidth = SpinnerICS.this.getWidth();
+ final int spinnerPaddingRight = SpinnerICS.this.getPaddingRight();
+ setContentWidth(spinnerWidth - spinnerPaddingLeft - spinnerPaddingRight);
+ } else {
+ setContentWidth(mDropDownWidth);
+ }
+ final Drawable background = getBackground();
+ int bgOffset = 0;
+ if (background != null) {
+ background.getPadding(mTempRect);
+ bgOffset = -mTempRect.left;
+ }
+ setHorizontalOffset(bgOffset + spinnerPaddingLeft);
+ setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED);
+ super.show();
+ getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
+ setSelection(SpinnerICS.this.getSelectedItemPosition());
+ }
+ }
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/ActionMode.java b/v7/appcompat/src/android/support/v7/view/ActionMode.java
similarity index 98%
rename from appcompat/eclair/android/support/appcompat/view/ActionMode.java
rename to v7/appcompat/src/android/support/v7/view/ActionMode.java
index 94f7e6e..1243326 100644
--- a/appcompat/eclair/android/support/appcompat/view/ActionMode.java
+++ b/v7/appcompat/src/android/support/v7/view/ActionMode.java
@@ -14,10 +14,8 @@
* limitations under the License.
*/
-package android.support.appcompat.view;
+package android.support.v7.view;
-
-import android.view.MenuInflater;
import android.view.View;
/**
diff --git a/appcompat/eclair/android/support/appcompat/view/ActionProvider.java b/v7/appcompat/src/android/support/v7/view/ActionProvider.java
similarity index 78%
rename from appcompat/eclair/android/support/appcompat/view/ActionProvider.java
rename to v7/appcompat/src/android/support/v7/view/ActionProvider.java
index 2e0f87e..d604ecb 100644
--- a/appcompat/eclair/android/support/appcompat/view/ActionProvider.java
+++ b/v7/appcompat/src/android/support/v7/view/ActionProvider.java
@@ -14,10 +14,9 @@
* limitations under the License.
*/
-package android.support.appcompat.view;
+package android.support.v7.view;
import android.content.Context;
-import android.support.appcompat.view.SubMenu;
import android.view.View;
/**
@@ -26,7 +25,8 @@
* also implements other functions such a performing a default action.
*
* <p>An ActionProvider can be
- * optionally specified for a {@link MenuItem} and in such a case it will be responsible for
+ * optionally specified for a {@link android.support.v7.view.MenuItem} and in such a case it will be
+ * responsible for
* creating the action view that appears in the {@link android.app.ActionBar} as a substitute for
* the menu item when the item is displayed as an action item. Also the provider is responsible for
* performing a default action if a menu item placed on the overflow menu of the ActionBar is
@@ -35,8 +35,8 @@
*
* <p>There are two ways for using an action provider for creating and handling of action views:
*
- * <ul><li> Setting the action provider on a {@link MenuItem} directly by calling {@link
- * MenuItem#setActionProvider(ActionProvider)}. </li>
+ * <ul><li> Setting the action provider on a {@link android.support.v7.view.MenuItem} directly by
+ * calling {@link android.support.v7.view.MenuItem#setActionProvider(ActionProvider)}. </li>
*
* <li>Declaring the action provider in the menu XML resource. For example:
*
@@ -51,10 +51,11 @@
* </pre>
* </li></ul></p>
*
- * @see MenuItem#setActionProvider(ActionProvider)
- * @see MenuItem#getActionProvider()
+ * @see android.support.v7.view.MenuItem#setActionProvider(ActionProvider)
+ * @see android.support.v7.view.MenuItem#getActionProvider()
*/
public abstract class ActionProvider {
+ private final Context mContext;
private SubUiVisibilityListener mSubUiVisibilityListener;
@@ -64,6 +65,14 @@
* @param context Context for accessing resources.
*/
public ActionProvider(Context context) {
+ mContext = context;
+ }
+
+ /**
+ * Gets the context associated with this action provider.
+ */
+ public Context getContext() {
+ return mContext;
}
/**
@@ -82,18 +91,22 @@
*
* <p> A menu item selection is processed in the following order:
*
- * <ul><li>Receiving a call to {@link MenuItem.OnMenuItemClickListener#onMenuItemClick
+ * <ul><li>Receiving a call to
+ * {@link android.support.v7.view.MenuItem.OnMenuItemClickListener#onMenuItemClick
* MenuItem.OnMenuItemClickListener.onMenuItemClick}.</li>
*
- * <li>Receiving a call to {@link android.app.Activity#onOptionsItemSelected(MenuItem)
- * Activity.onOptionsItemSelected(MenuItem)}
+ * <li>Receiving a call to
+ * {@link android.support.v4.app.FragmentActivity#onSupportOptionsItemSelected(MenuItem)}
+ * FragmentActivity.onSupportOptionsItemSelected(MenuItem)}
* </li>
*
- * <li>Receiving a call to {@link android.app.Fragment#onOptionsItemSelected(MenuItem)
- * Fragment.onOptionsItemSelected(MenuItem)}</li>
+ * <li>Receiving a call to
+ * {@link android.support.v4.app.Fragment#onSupportOptionsItemSelected(MenuItem)}
+ * Fragment.onSupportOptionsItemSelected(MenuItem)}</li>
*
* <li>Launching the {@link android.content.Intent} set via
- * {@link MenuItem#setIntent(android.content.Intent) MenuItem.setIntent(android.content.Intent)}
+ * {@link android.support.v7.view.MenuItem#setIntent(android.content.Intent)
+ * MenuItem.setIntent(android.content.Intent)}
* </li>
*
* <li>Invoking this method.</li></ul>
diff --git a/appcompat/eclair/android/support/appcompat/view/Menu.java b/v7/appcompat/src/android/support/v7/view/Menu.java
similarity index 98%
rename from appcompat/eclair/android/support/appcompat/view/Menu.java
rename to v7/appcompat/src/android/support/v7/view/Menu.java
index d0efebe..1a5be9d 100644
--- a/appcompat/eclair/android/support/appcompat/view/Menu.java
+++ b/v7/appcompat/src/android/support/v7/view/Menu.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package android.support.appcompat.view;
+package android.support.v7.view;
import android.app.Activity;
import android.content.ComponentName;
@@ -28,8 +28,8 @@
* You can add items to this menu and handle clicks on your additions. The
* easiest way of adding menu items is inflating an XML file into the
* {@link Menu} via {@link MenuInflater}. The easiest way of attaching code to
- * clicks is via {@link Activity#onOptionsItemSelected(MenuItem)} and
- * {@link Activity#onContextItemSelected(MenuItem)}.
+ * clicks is via
+ * {@link android.support.v4.app.FragmentActivity#onSupportOptionsItemSelected(MenuItem)}.
*
* <p>Different menu types support different features:
*
diff --git a/v7/appcompat/src/android/support/v7/view/MenuInflater.java b/v7/appcompat/src/android/support/v7/view/MenuInflater.java
new file mode 100644
index 0000000..132c066
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/view/MenuInflater.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.view;
+
+/**
+ * This class is used to instantiate menu XML files into Menu objects.
+ * <p>
+ * For performance reasons, menu inflation relies heavily on pre-processing of
+ * XML files that is done at build time. Therefore, it is not currently possible
+ * to use MenuInflater with an XmlPullParser over a plain XML file at runtime;
+ * it only works with an XmlPullParser returned from a compiled resource (R.
+ * <em>something</em> file.)
+ */
+public interface MenuInflater {
+
+ /**
+ * Inflate a menu hierarchy from the specified XML resource. Throws
+ * {@link android.view.InflateException} if there is an error.
+ *
+ * @param menuRes Resource ID for an XML layout resource to load (e.g.,
+ * <code>R.menu.main_activity</code>)
+ * @param menu The Menu to inflate into. The items and submenus will be
+ * added to this Menu.
+ */
+ void inflate(int menuRes, Menu menu);
+
+}
diff --git a/appcompat/eclair/android/support/appcompat/view/MenuItem.java b/v7/appcompat/src/android/support/v7/view/MenuItem.java
similarity index 91%
rename from appcompat/eclair/android/support/appcompat/view/MenuItem.java
rename to v7/appcompat/src/android/support/v7/view/MenuItem.java
index 46af984..70032be 100644
--- a/appcompat/eclair/android/support/appcompat/view/MenuItem.java
+++ b/v7/appcompat/src/android/support/v7/view/MenuItem.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package android.support.appcompat.view;
+package android.support.v7.view;
import android.app.Activity;
import android.content.Intent;
@@ -29,7 +29,7 @@
* <p>An Item is returned by calling one of the {@link android.view.Menu#add}
* methods.
*
- * <p>For a feature set of specific menu types, see {@link android.support.appcompat.view.Menu}.
+ * <p>For a feature set of specific menu types, see {@link Menu}.
*
* <div class="special reference">
* <h3>Developer Guides</h3>
@@ -73,8 +73,7 @@
/**
* Interface definition for a callback to be invoked when a menu item is clicked.
*
- * @see Activity#onContextItemSelected(MenuItem)
- * @see Activity#onOptionsItemSelected(MenuItem)
+ * @see android.support.v7.app.ActionBarActivity#onSupportOptionsItemSelected(MenuItem)
*/
public interface OnMenuItemClickListener {
@@ -142,11 +141,11 @@
* integer; set by or/add the category with the order within the
* category) and the ordering of the item within that category (the
* lower bits). Example categories are
- * {@link android.support.appcompat.view.Menu#CATEGORY_SYSTEM},
- * {@link android.support.appcompat.view.Menu#CATEGORY_SECONDARY}, {@link
- * android.support.appcompat.view.Menu#CATEGORY_ALTERNATIVE}, {@link
- * android.support.appcompat.view.Menu#CATEGORY_CONTAINER}. See {@link
- * android.support.appcompat.view.Menu} for a full list.
+ * {@link Menu#CATEGORY_SYSTEM},
+ * {@link Menu#CATEGORY_SECONDARY}, {@link
+ * Menu#CATEGORY_ALTERNATIVE}, {@link
+ * Menu#CATEGORY_CONTAINER}. See {@link
+ * Menu} for a full list.
*
* @return The order of this item.
*/
@@ -163,7 +162,7 @@
/**
* Change the title associated with this item. <p/> Some menu types do not sufficient space to
* show the full title, and instead a condensed title is preferred. See {@link
- * android.support.appcompat.view.Menu} for more information.
+ * Menu} for more information.
*
* @param title The resource id of the new text to be displayed.
* @return This Item so additional setters can be called.
@@ -198,7 +197,7 @@
/**
* Change the icon associated with this item. This icon will not always be shown, so the title
- * should be sufficient in describing this item. See {@link android.support.appcompat.view.Menu}
+ * should be sufficient in describing this item. See {@link Menu}
* for the menu types that support icons.
*
* @param icon The new icon (as a Drawable) to be displayed.
@@ -208,7 +207,7 @@
/**
* Change the icon associated with this item. This icon will not always be shown, so the title
- * should be sufficient in describing this item. See {@link android.support.appcompat.view.Menu}
+ * should be sufficient in describing this item. See {@link Menu}
* for the menu types that support icons. <p/> This method will set the resource ID of the icon
* which will be used to lazily get the Drawable when this item is being shown.
*
@@ -232,7 +231,7 @@
* {@link android.content.Context#startActivity} with the given Intent.
*
* <p>Note that setIntent() can not be used with the versions of
- * {@link android.support.appcompat.view.Menu#add} that take a Runnable, because
+ * {@link Menu#add} that take a Runnable, because
* {@link Runnable#run} does not return a value so there is no way to tell if it handled the
* item. In this case it is assumed that the Runnable always handles
* the item, and the intent will never be started.
@@ -261,7 +260,7 @@
* shortcut characters will be displayed in lower case.
*
* <p>See {@link
- * android.support.appcompat.view.Menu} for the menu types that support shortcuts.
+ * Menu} for the menu types that support shortcuts.
*
* @param numericChar The numeric shortcut key. This is the shortcut when using a numeric (e.g.,
* 12-key) keyboard.
@@ -273,7 +272,7 @@
/**
* Change the numeric shortcut associated with this item. <p/> See {@link
- * android.support.appcompat.view.Menu} for the menu types that support shortcuts.
+ * Menu} for the menu types that support shortcuts.
*
* @param numericChar The numeric shortcut key. This is the shortcut when using a 12-key
* (numeric) keyboard.
@@ -296,7 +295,7 @@
* with the characters '\b' or '\n' as shortcuts will get triggered by the
* Delete key or Carriage Return key, respectively.
*
- * <p></p>See {@link android.support.appcompat.view.Menu} for the menu types that support
+ * <p></p>See {@link Menu} for the menu types that support
* shortcuts.
*
* @param alphaChar The alphabetic shortcut key. This is the shortcut when using a keyboard with
@@ -315,14 +314,14 @@
/**
* Control whether this item can display a check mark. Setting this does not actually display a
* check mark (see {@link #setChecked} for that); rather, it ensures there is room in the item
- * in which to display a check mark. <p/> See {@link android.support.appcompat.view.Menu} for
+ * in which to display a check mark. <p/> See {@link Menu} for
* the menu types that support check marks.
*
* @param checkable Set to true to allow a check mark, false to disallow. The default is false.
* @return This Item so additional setters can be called.
* @see #setChecked
* @see #isCheckable
- * @see android.support.appcompat.view.Menu#setGroupCheckable
+ * @see Menu#setGroupCheckable
*/
public MenuItem setCheckable(boolean checkable);
@@ -338,10 +337,10 @@
* Control whether this item is shown with a check mark. Note that you
* must first have enabled checking with {@link #setCheckable} or else
* the check mark will not appear. If this item is a member of a group that contains
- * mutually-exclusive items (set via {@link android.support.appcompat.view.Menu#setGroupCheckable(int, boolean, boolean)},
+ * mutually-exclusive items (set via {@link Menu#setGroupCheckable(int, boolean, boolean)},
* the other items in the group will be unchecked.
*
- * <p>See {@link android.support.appcompat.view.Menu} for the menu types that support check
+ * <p>See {@link Menu} for the menu types that support check
* marks.
*
* @param checked Set to true to display a check mark, false to hide it. The default value is
@@ -349,7 +348,7 @@
* @return This Item so additional setters can be called.
* @see #setCheckable
* @see #isChecked
- * @see android.support.appcompat.view.Menu#setGroupCheckable
+ * @see Menu#setGroupCheckable
*/
public MenuItem setChecked(boolean checked);
@@ -411,13 +410,12 @@
/**
* Set a custom listener for invocation of this menu item. In most situations, it is more
- * efficient and easier to use {@link Activity#onOptionsItemSelected(MenuItem)} or {@link
- * Activity#onContextItemSelected(MenuItem)}.
+ * efficient and easier to use
+ * {@link android.support.v4.app.FragmentActivity#onSupportOptionsItemSelected(MenuItem)}.
*
* @param menuItemClickListener The object to receive invokations.
* @return This Item so additional setters can be called.
- * @see Activity#onOptionsItemSelected(MenuItem)
- * @see Activity#onContextItemSelected(MenuItem)
+ * @see android.support.v4.app.FragmentActivity#onSupportOptionsItemSelected(MenuItem)
*/
public MenuItem setOnMenuItemClickListener(
MenuItem.OnMenuItemClickListener menuItemClickListener);
diff --git a/appcompat/eclair/android/support/appcompat/view/SubMenu.java b/v7/appcompat/src/android/support/v7/view/SubMenu.java
similarity index 98%
rename from appcompat/eclair/android/support/appcompat/view/SubMenu.java
rename to v7/appcompat/src/android/support/v7/view/SubMenu.java
index dcfba65..0ce91b9 100644
--- a/appcompat/eclair/android/support/appcompat/view/SubMenu.java
+++ b/v7/appcompat/src/android/support/v7/view/SubMenu.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package android.support.appcompat.view;
+package android.support.v7.view;
import android.graphics.drawable.Drawable;
import android.view.View;
diff --git a/v7/appcompat/src/android/support/v7/widget/PopupMenu.java b/v7/appcompat/src/android/support/v7/widget/PopupMenu.java
new file mode 100644
index 0000000..9e0351f
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/widget/PopupMenu.java
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.support.v7.widget;
+
+
+import android.content.Context;
+import android.support.v7.internal.view.SupportMenuInflater;
+import android.support.v7.internal.view.menu.MenuBuilder;
+import android.support.v7.internal.view.menu.MenuPopupHelper;
+import android.support.v7.internal.view.menu.MenuPresenter;
+import android.support.v7.internal.view.menu.SubMenuBuilder;
+import android.support.v7.view.Menu;
+import android.support.v7.view.MenuInflater;
+import android.support.v7.view.MenuItem;
+import android.view.View;
+
+/**
+ * Static library support version of the framework's {@link android.widget.PopupMenu}.
+ * Used to write apps that run on platforms prior to Android 3.0. When running
+ * on Android 3.0 or above, this implementation is still used; it does not try
+ * to switch to the framework's implementation. See the framework SDK
+ * documentation for a class overview.
+ */
+public class PopupMenu implements MenuBuilder.Callback, MenuPresenter.Callback {
+ private Context mContext;
+ private MenuBuilder mMenu;
+ private View mAnchor;
+ private MenuPopupHelper mPopup;
+ private OnMenuItemClickListener mMenuItemClickListener;
+ private OnDismissListener mDismissListener;
+
+ /**
+ * Callback interface used to notify the application that the menu has closed.
+ */
+ public interface OnDismissListener {
+ /**
+ * Called when the associated menu has been dismissed.
+ *
+ * @param menu The PopupMenu that was dismissed.
+ */
+ public void onDismiss(PopupMenu menu);
+ }
+
+ /**
+ * Construct a new PopupMenu.
+ *
+ * @param context Context for the PopupMenu.
+ * @param anchor Anchor view for this popup. The popup will appear below the anchor if there
+ * is room, or above it if there is not.
+ */
+ public PopupMenu(Context context, View anchor) {
+ mContext = context;
+ mMenu = new MenuBuilder(context);
+ mMenu.setCallback(this);
+ mAnchor = anchor;
+ mPopup = new MenuPopupHelper(context, mMenu, anchor);
+ mPopup.setCallback(this);
+ }
+
+ /**
+ * @return the {@link Menu} associated with this popup. Populate the returned Menu with
+ * items before calling {@link #show()}.
+ *
+ * @see #show()
+ * @see #getMenuInflater()
+ */
+ public Menu getMenu() {
+ return mMenu;
+ }
+
+ /**
+ * @return a {@link MenuInflater} that can be used to inflate menu items from XML into the
+ * menu returned by {@link #getMenu()}.
+ *
+ * @see #getMenu()
+ */
+ public MenuInflater getMenuInflater() {
+ return new SupportMenuInflater(mContext);
+ }
+
+ /**
+ * Inflate a menu resource into this PopupMenu. This is equivalent to calling
+ * popupMenu.getMenuInflater().inflate(menuRes, popupMenu.getMenu()).
+ * @param menuRes Menu resource to inflate
+ */
+ public void inflate(int menuRes) {
+ getMenuInflater().inflate(menuRes, mMenu);
+ }
+
+ /**
+ * Show the menu popup anchored to the view specified during construction.
+ * @see #dismiss()
+ */
+ public void show() {
+ mPopup.show();
+ }
+
+ /**
+ * Dismiss the menu popup.
+ * @see #show()
+ */
+ public void dismiss() {
+ mPopup.dismiss();
+ }
+
+ /**
+ * Set a listener that will be notified when the user selects an item from the menu.
+ *
+ * @param listener Listener to notify
+ */
+ public void setOnMenuItemClickListener(OnMenuItemClickListener listener) {
+ mMenuItemClickListener = listener;
+ }
+
+ /**
+ * Set a listener that will be notified when this menu is dismissed.
+ *
+ * @param listener Listener to notify
+ */
+ public void setOnDismissListener(OnDismissListener listener) {
+ mDismissListener = listener;
+ }
+
+ /**
+ * @hide
+ */
+ public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) {
+ if (mMenuItemClickListener != null) {
+ return mMenuItemClickListener.onMenuItemClick(item);
+ }
+ return false;
+ }
+
+ /**
+ * @hide
+ */
+ public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
+ if (mDismissListener != null) {
+ mDismissListener.onDismiss(this);
+ }
+ }
+
+ /**
+ * @hide
+ */
+ public boolean onOpenSubMenu(MenuBuilder subMenu) {
+ if (subMenu == null) return false;
+
+ if (!subMenu.hasVisibleItems()) {
+ return true;
+ }
+
+ // Current menu will be dismissed by the normal helper, submenu will be shown in its place.
+ new MenuPopupHelper(mContext, subMenu, mAnchor).show();
+ return true;
+ }
+
+ /**
+ * @hide
+ */
+ public void onCloseSubMenu(SubMenuBuilder menu) {
+ }
+
+ /**
+ * @hide
+ */
+ public void onMenuModeChange(MenuBuilder menu) {
+ }
+
+ /**
+ * Interface responsible for receiving menu item click events if the items themselves
+ * do not have individual item click listeners.
+ */
+ public interface OnMenuItemClickListener {
+ /**
+ * This method will be invoked when a menu item is clicked if the item itself did
+ * not already handle the event.
+ *
+ * @param item {@link MenuItem} that was clicked
+ * @return <code>true</code> if the event was handled, <code>false</code> otherwise.
+ */
+ public boolean onMenuItemClick(MenuItem item);
+ }
+}
\ No newline at end of file
diff --git a/v7/appcompat/src/android/support/v7/widget/SearchActionProvider.java b/v7/appcompat/src/android/support/v7/widget/SearchActionProvider.java
new file mode 100644
index 0000000..7ecf8e9
--- /dev/null
+++ b/v7/appcompat/src/android/support/v7/widget/SearchActionProvider.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.widget;
+
+import android.content.Context;
+import android.support.v4.widget.SearchViewCompat;
+import android.support.v7.view.ActionProvider;
+import android.view.View;
+
+/**
+ * An {@link ActionProvider} that provides a search action using
+ * {@link android.support.v4.widget.SearchViewCompat}.
+ */
+public class SearchActionProvider extends ActionProvider {
+ public SearchActionProvider(Context context) {
+ super(context);
+ }
+
+ @Override
+ public View onCreateActionView() {
+ return SearchViewCompat.newSearchView(getContext());
+ }
+}
diff --git a/v7/gridlayout/.gitignore b/v7/gridlayout/.gitignore
index c5e82d7..c3c25e0 100644
--- a/v7/gridlayout/.gitignore
+++ b/v7/gridlayout/.gitignore
@@ -1 +1,4 @@
-bin
\ No newline at end of file
+.settings
+bin
+libs
+gen
diff --git a/appcompat/Android.mk b/v7/gridlayout/Android.mk
similarity index 64%
rename from appcompat/Android.mk
rename to v7/gridlayout/Android.mk
index 3724ff4..74eac10 100644
--- a/appcompat/Android.mk
+++ b/v7/gridlayout/Android.mk
@@ -1,4 +1,4 @@
-# Copyright (C) 2012 The Android Open Source Project
+# Copyright (C) 2011 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -14,16 +14,16 @@
LOCAL_PATH := $(call my-dir)
-# Note: the source code is in java/, not src/, because this code is also part of
-# the framework library, and build/core/pathmap.mk expects a java/ subdirectory.
-
+# Here is the final static library that apps can link against.
+# The R class is automatically excluded from the generated library.
+# Applications that use this library must specify LOCAL_RESOURCE_DIR
+# in their makefiles to include the resources in their package.
include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-appcompat
-LOCAL_SDK_VERSION := 14
-LOCAL_SRC_FILES := $(call all-java-files-under,eclair honeycomb ics java)
-LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
+LOCAL_MODULE := android-support-v7-gridlayout
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
include $(BUILD_STATIC_JAVA_LIBRARY)
# Include this library in the build server's output directory
-$(call dist-for-goals, droidcore sdk, $(LOCAL_BUILT_MODULE):android-support-appcompat.jar)
+$(call dist-for-goals, droidcore sdk, $(LOCAL_BUILT_MODULE):android-support-v7-gridlayout.jar)
+
diff --git a/v7/gridlayout/AndroidManifest.xml b/v7/gridlayout/AndroidManifest.xml
index c3ed113..f07d1a8 100644
--- a/v7/gridlayout/AndroidManifest.xml
+++ b/v7/gridlayout/AndroidManifest.xml
@@ -1,9 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.support.v7.gridlayout"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="7" />
-
-</manifest>
\ No newline at end of file
+ package="android.support.v7.gridlayout">
+ <uses-sdk android:minSdkVersion="7"/>
+</manifest>
diff --git a/v7/gridlayout/README.txt b/v7/gridlayout/README.txt
index 16cff14..a67bf2a 100644
--- a/v7/gridlayout/README.txt
+++ b/v7/gridlayout/README.txt
@@ -1,11 +1,12 @@
-Library Project including GridLayout.
+Library Project including compatibility GridLayout.
This can be used by an Android project to provide
-access to GridLayout on applications running on API 7+
+access to GridLayout on applications running on API 7+.
There is technically no source, but the src folder is necessary
-to ensure that the build system works. The content is actually
-located in libs/android-support-v7-gridlayout.jar
+to ensure that the build system works. The content is actually
+located in libs/android-support-v7-gridlayout.jar.
+The accompanying resources must also be included in the application.
USAGE:
diff --git a/v7/gridlayout/gen/android/support/v7/gridlayout/BuildConfig.java b/v7/gridlayout/gen/android/support/v7/gridlayout/BuildConfig.java
deleted file mode 100644
index 0b07e25..0000000
--- a/v7/gridlayout/gen/android/support/v7/gridlayout/BuildConfig.java
+++ /dev/null
@@ -1,6 +0,0 @@
-/** Automatically generated file. DO NOT MODIFY */
-package android.support.v7.gridlayout;
-
-public final class BuildConfig {
- public final static boolean DEBUG = true;
-}
\ No newline at end of file
diff --git a/v7/gridlayout/gen/android/support/v7/gridlayout/R.java b/v7/gridlayout/gen/android/support/v7/gridlayout/R.java
deleted file mode 100644
index 687ac68..0000000
--- a/v7/gridlayout/gen/android/support/v7/gridlayout/R.java
+++ /dev/null
@@ -1,686 +0,0 @@
-/* AUTO-GENERATED FILE. DO NOT MODIFY.
- *
- * This class was automatically generated by the
- * aapt tool from the resource data it found. It
- * should not be modified by hand.
- */
-
-package android.support.v7.gridlayout;
-
-public final class R {
- public static final class attr {
- /**
- When set to alignMargins, causes alignment to take place between the outer
- boundary of a view, as defined by its margins. When set to alignBounds,
- causes alignment to take place between the edges of the view.
- The default is alignMargins.
- See {@link android.widget.GridLayout#setAlignmentMode(int)}.
-
- <p>Must be one of the following constant values.</p>
-<table>
-<colgroup align="left" />
-<colgroup align="left" />
-<colgroup align="left" />
-<tr><th>Constant</th><th>Value</th><th>Description</th></tr>
-<tr><td><code>alignBounds</code></td><td>0</td><td>
- Align the bounds of the children.
- See {@link android.widget.GridLayout#ALIGN_BOUNDS}.
- </td></tr>
-<tr><td><code>alignMargins</code></td><td>1</td><td>
- Align the margins of the children.
- See {@link android.widget.GridLayout#ALIGN_MARGINS}.
- </td></tr>
-</table>
- */
- public static int alignmentMode=0x7f010004;
- /** The maximum number of columns to create when automatically positioning children.
- <p>Must be an integer value, such as "<code>100</code>".
-<p>This may also be a reference to a resource (in the form
-"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
-theme attribute (in the form
-"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
-containing a value of this type.
- */
- public static int columnCount=0x7f010002;
- /**
- When set to true, forces column boundaries to appear in the same order
- as column indices.
- The default is true.
- See {@link android.widget.GridLayout#setColumnOrderPreserved(boolean)}.
-
- <p>Must be a boolean value, either "<code>true</code>" or "<code>false</code>".
-<p>This may also be a reference to a resource (in the form
-"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
-theme attribute (in the form
-"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
-containing a value of this type.
- */
- public static int columnOrderPreserved=0x7f010006;
- /**
- The column boundary delimiting the left of the group of cells
- occupied by this view.
-
- <p>Must be an integer value, such as "<code>100</code>".
-<p>This may also be a reference to a resource (in the form
-"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
-theme attribute (in the form
-"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
-containing a value of this type.
- */
- public static int layout_column=0x7f010009;
- /**
- The column span: the difference between the right and left
- boundaries delimiting the group of cells occupied by this view.
- The default is one.
- See {@link android.widget.GridLayout.Spec}.
-
- <p>Must be an integer value, such as "<code>100</code>".
-<p>This may also be a reference to a resource (in the form
-"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
-theme attribute (in the form
-"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
-containing a value of this type.
- */
- public static int layout_columnSpan=0x7f01000a;
- /**
- Gravity specifies how a component should be placed in its group of cells.
- The default is LEFT | BASELINE.
- See {@link android.widget.GridLayout.LayoutParams#setGravity(int)}.
-
- <p>Must be one or more (separated by '|') of the following constant values.</p>
-<table>
-<colgroup align="left" />
-<colgroup align="left" />
-<colgroup align="left" />
-<tr><th>Constant</th><th>Value</th><th>Description</th></tr>
-<tr><td><code>top</code></td><td>0x30</td><td> Push object to the top of its container, not changing its size. </td></tr>
-<tr><td><code>bottom</code></td><td>0x50</td><td> Push object to the bottom of its container, not changing its size. </td></tr>
-<tr><td><code>left</code></td><td>0x03</td><td> Push object to the left of its container, not changing its size. </td></tr>
-<tr><td><code>right</code></td><td>0x05</td><td> Push object to the right of its container, not changing its size. </td></tr>
-<tr><td><code>center_vertical</code></td><td>0x10</td><td> Place object in the vertical center of its container, not changing its size. </td></tr>
-<tr><td><code>fill_vertical</code></td><td>0x70</td><td> Grow the vertical size of the object if needed so it completely fills its container. </td></tr>
-<tr><td><code>center_horizontal</code></td><td>0x01</td><td> Place object in the horizontal center of its container, not changing its size. </td></tr>
-<tr><td><code>fill_horizontal</code></td><td>0x07</td><td> Grow the horizontal size of the object if needed so it completely fills its container. </td></tr>
-<tr><td><code>center</code></td><td>0x11</td><td> Place the object in the center of its container in both the vertical and horizontal axis, not changing its size. </td></tr>
-<tr><td><code>fill</code></td><td>0x77</td><td> Grow the horizontal and vertical size of the object if needed so it completely fills its container. </td></tr>
-<tr><td><code>clip_vertical</code></td><td>0x80</td><td>
- Additional option that can be set to have the top and/or bottom edges of
- the child clipped to its container's bounds.
- The clip will be based on the vertical gravity: a top gravity will clip the bottom
- edge, a bottom gravity will clip the top edge, and neither will clip both edges.
- </td></tr>
-<tr><td><code>clip_horizontal</code></td><td>0x08</td><td>
- Additional option that can be set to have the left and/or right edges of
- the child clipped to its container's bounds.
- The clip will be based on the horizontal gravity: a left gravity will clip the right
- edge, a right gravity will clip the left edge, and neither will clip both edges.
- </td></tr>
-<tr><td><code>start</code></td><td>0x00800003</td><td> Push object to the beginning of its container, not changing its size. </td></tr>
-<tr><td><code>end</code></td><td>0x00800005</td><td> Push object to the end of its container, not changing its size. </td></tr>
-</table>
- */
- public static int layout_gravity=0x7f01000b;
- /** END MarginLayout layoutparams
-
- The row boundary delimiting the top of the group of cells
- occupied by this view.
-
- <p>Must be an integer value, such as "<code>100</code>".
-<p>This may also be a reference to a resource (in the form
-"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
-theme attribute (in the form
-"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
-containing a value of this type.
- */
- public static int layout_row=0x7f010007;
- /**
- The row span: the difference between the bottom and top
- boundaries delimiting the group of cells occupied by this view.
- The default is one.
- See {@link android.widget.GridLayout.Spec}.
-
- <p>Must be an integer value, such as "<code>100</code>".
-<p>This may also be a reference to a resource (in the form
-"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
-theme attribute (in the form
-"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
-containing a value of this type.
- */
- public static int layout_rowSpan=0x7f010008;
- /**
- support versions. All attributes not present in ViewGroup/View are
- redefined in the support library namespace.
-
-
- The orientation property is not used during layout. It is only used to
- allocate row and column parameters when they are not specified by its children's
- layout parameters. GridLayout works like LinearLayout in this case;
- putting all the components either in a single row or in a single column -
- depending on the value of this flag. In the horizontal case, a columnCount
- property may be additionally supplied to force new rows to be created when a
- row is full. The rowCount attribute may be used similarly in the vertical case.
- The default is horizontal.
-
- <p>Must be one of the following constant values.</p>
-<table>
-<colgroup align="left" />
-<colgroup align="left" />
-<colgroup align="left" />
-<tr><th>Constant</th><th>Value</th><th>Description</th></tr>
-<tr><td><code>horizontal</code></td><td>0</td><td> Defines an horizontal widget. </td></tr>
-<tr><td><code>vertical</code></td><td>1</td><td> Defines a vertical widget. </td></tr>
-</table>
- */
- public static int orientation=0x7f010000;
- /** The maximum number of rows to create when automatically positioning children.
- <p>Must be an integer value, such as "<code>100</code>".
-<p>This may also be a reference to a resource (in the form
-"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
-theme attribute (in the form
-"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
-containing a value of this type.
- */
- public static int rowCount=0x7f010001;
- /**
- When set to true, forces row boundaries to appear in the same order
- as row indices.
- The default is true.
- See {@link android.widget.GridLayout#setRowOrderPreserved(boolean)}.
-
- <p>Must be a boolean value, either "<code>true</code>" or "<code>false</code>".
-<p>This may also be a reference to a resource (in the form
-"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
-theme attribute (in the form
-"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
-containing a value of this type.
- */
- public static int rowOrderPreserved=0x7f010005;
- /**
- When set to true, tells GridLayout to use default margins when none are specified
- in a view's layout parameters.
- The default value is false.
- See {@link android.widget.GridLayout#setUseDefaultMargins(boolean)}.
-
- <p>Must be a boolean value, either "<code>true</code>" or "<code>false</code>".
-<p>This may also be a reference to a resource (in the form
-"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
-theme attribute (in the form
-"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
-containing a value of this type.
- */
- public static int useDefaultMargins=0x7f010003;
- }
- public static final class dimen {
- /** The default gap between components in a layout.
- */
- public static int default_gap=0x7f030000;
- }
- public static final class id {
- public static int alignBounds=0x7f020002;
- public static int alignMargins=0x7f020003;
- public static int bottom=0x7f020005;
- public static int center=0x7f02000c;
- public static int center_horizontal=0x7f02000a;
- public static int center_vertical=0x7f020008;
- public static int clip_horizontal=0x7f02000f;
- public static int clip_vertical=0x7f02000e;
- public static int end=0x7f020011;
- public static int fill=0x7f02000d;
- public static int fill_horizontal=0x7f02000b;
- public static int fill_vertical=0x7f020009;
- public static int horizontal=0x7f020000;
- public static int left=0x7f020006;
- public static int right=0x7f020007;
- public static int start=0x7f020010;
- public static int top=0x7f020004;
- public static int vertical=0x7f020001;
- }
- public static final class styleable {
- /** Attributes that can be used with a GridLayout.
- <p>Includes the following attributes:</p>
- <table>
- <colgroup align="left" />
- <colgroup align="left" />
- <tr><th>Attribute</th><th>Description</th></tr>
- <tr><td><code>{@link #GridLayout_alignmentMode android.support.v7.gridlayout:alignmentMode}</code></td><td>
- When set to alignMargins, causes alignment to take place between the outer
- boundary of a view, as defined by its margins.</td></tr>
- <tr><td><code>{@link #GridLayout_columnCount android.support.v7.gridlayout:columnCount}</code></td><td> The maximum number of columns to create when automatically positioning children.</td></tr>
- <tr><td><code>{@link #GridLayout_columnOrderPreserved android.support.v7.gridlayout:columnOrderPreserved}</code></td><td>
- When set to true, forces column boundaries to appear in the same order
- as column indices.</td></tr>
- <tr><td><code>{@link #GridLayout_orientation android.support.v7.gridlayout:orientation}</code></td><td>
- support versions.</td></tr>
- <tr><td><code>{@link #GridLayout_rowCount android.support.v7.gridlayout:rowCount}</code></td><td> The maximum number of rows to create when automatically positioning children.</td></tr>
- <tr><td><code>{@link #GridLayout_rowOrderPreserved android.support.v7.gridlayout:rowOrderPreserved}</code></td><td>
- When set to true, forces row boundaries to appear in the same order
- as row indices.</td></tr>
- <tr><td><code>{@link #GridLayout_useDefaultMargins android.support.v7.gridlayout:useDefaultMargins}</code></td><td>
- When set to true, tells GridLayout to use default margins when none are specified
- in a view's layout parameters.</td></tr>
- </table>
- @see #GridLayout_alignmentMode
- @see #GridLayout_columnCount
- @see #GridLayout_columnOrderPreserved
- @see #GridLayout_orientation
- @see #GridLayout_rowCount
- @see #GridLayout_rowOrderPreserved
- @see #GridLayout_useDefaultMargins
- */
- public static final int[] GridLayout = {
- 0x7f010000, 0x7f010001, 0x7f010002, 0x7f010003,
- 0x7f010004, 0x7f010005, 0x7f010006
- };
- /**
- <p>
- @attr description
-
- When set to alignMargins, causes alignment to take place between the outer
- boundary of a view, as defined by its margins. When set to alignBounds,
- causes alignment to take place between the edges of the view.
- The default is alignMargins.
- See {@link android.widget.GridLayout#setAlignmentMode(int)}.
-
-
-
- <p>Must be one of the following constant values.</p>
-<table>
-<colgroup align="left" />
-<colgroup align="left" />
-<colgroup align="left" />
-<tr><th>Constant</th><th>Value</th><th>Description</th></tr>
-<tr><td><code>alignBounds</code></td><td>0</td><td>
- Align the bounds of the children.
- See {@link android.widget.GridLayout#ALIGN_BOUNDS}.
- </td></tr>
-<tr><td><code>alignMargins</code></td><td>1</td><td>
- Align the margins of the children.
- See {@link android.widget.GridLayout#ALIGN_MARGINS}.
- </td></tr>
-</table>
- <p>This is a private symbol.
- @attr name android:alignmentMode
- */
- public static final int GridLayout_alignmentMode = 4;
- /**
- <p>
- @attr description
- The maximum number of columns to create when automatically positioning children.
-
-
- <p>Must be an integer value, such as "<code>100</code>".
-<p>This may also be a reference to a resource (in the form
-"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
-theme attribute (in the form
-"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
-containing a value of this type.
- <p>This is a private symbol.
- @attr name android:columnCount
- */
- public static final int GridLayout_columnCount = 2;
- /**
- <p>
- @attr description
-
- When set to true, forces column boundaries to appear in the same order
- as column indices.
- The default is true.
- See {@link android.widget.GridLayout#setColumnOrderPreserved(boolean)}.
-
-
-
- <p>Must be a boolean value, either "<code>true</code>" or "<code>false</code>".
-<p>This may also be a reference to a resource (in the form
-"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
-theme attribute (in the form
-"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
-containing a value of this type.
- <p>This is a private symbol.
- @attr name android:columnOrderPreserved
- */
- public static final int GridLayout_columnOrderPreserved = 6;
- /**
- <p>
- @attr description
-
- support versions. All attributes not present in ViewGroup/View are
- redefined in the support library namespace.
-
-
- The orientation property is not used during layout. It is only used to
- allocate row and column parameters when they are not specified by its children's
- layout parameters. GridLayout works like LinearLayout in this case;
- putting all the components either in a single row or in a single column -
- depending on the value of this flag. In the horizontal case, a columnCount
- property may be additionally supplied to force new rows to be created when a
- row is full. The rowCount attribute may be used similarly in the vertical case.
- The default is horizontal.
-
-
-
- <p>Must be one of the following constant values.</p>
-<table>
-<colgroup align="left" />
-<colgroup align="left" />
-<colgroup align="left" />
-<tr><th>Constant</th><th>Value</th><th>Description</th></tr>
-<tr><td><code>horizontal</code></td><td>0</td><td> Defines an horizontal widget. </td></tr>
-<tr><td><code>vertical</code></td><td>1</td><td> Defines a vertical widget. </td></tr>
-</table>
- <p>This is a private symbol.
- @attr name android:orientation
- */
- public static final int GridLayout_orientation = 0;
- /**
- <p>
- @attr description
- The maximum number of rows to create when automatically positioning children.
-
-
- <p>Must be an integer value, such as "<code>100</code>".
-<p>This may also be a reference to a resource (in the form
-"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
-theme attribute (in the form
-"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
-containing a value of this type.
- <p>This is a private symbol.
- @attr name android:rowCount
- */
- public static final int GridLayout_rowCount = 1;
- /**
- <p>
- @attr description
-
- When set to true, forces row boundaries to appear in the same order
- as row indices.
- The default is true.
- See {@link android.widget.GridLayout#setRowOrderPreserved(boolean)}.
-
-
-
- <p>Must be a boolean value, either "<code>true</code>" or "<code>false</code>".
-<p>This may also be a reference to a resource (in the form
-"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
-theme attribute (in the form
-"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
-containing a value of this type.
- <p>This is a private symbol.
- @attr name android:rowOrderPreserved
- */
- public static final int GridLayout_rowOrderPreserved = 5;
- /**
- <p>
- @attr description
-
- When set to true, tells GridLayout to use default margins when none are specified
- in a view's layout parameters.
- The default value is false.
- See {@link android.widget.GridLayout#setUseDefaultMargins(boolean)}.
-
-
-
- <p>Must be a boolean value, either "<code>true</code>" or "<code>false</code>".
-<p>This may also be a reference to a resource (in the form
-"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
-theme attribute (in the form
-"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
-containing a value of this type.
- <p>This is a private symbol.
- @attr name android:useDefaultMargins
- */
- public static final int GridLayout_useDefaultMargins = 3;
- /** Attributes that can be used with a GridLayout_Layout.
- <p>Includes the following attributes:</p>
- <table>
- <colgroup align="left" />
- <colgroup align="left" />
- <tr><th>Attribute</th><th>Description</th></tr>
- <tr><td><code>{@link #GridLayout_Layout_android_layout_height android.support.v7.gridlayout:android_layout_height}</code></td><td></td></tr>
- <tr><td><code>{@link #GridLayout_Layout_android_layout_margin android.support.v7.gridlayout:android_layout_margin}</code></td><td>
- Specifies extra space on the left, top, right and bottom
- sides of this view.</td></tr>
- <tr><td><code>{@link #GridLayout_Layout_android_layout_marginBottom android.support.v7.gridlayout:android_layout_marginBottom}</code></td><td>
- Specifies extra space on the bottom side of this view.</td></tr>
- <tr><td><code>{@link #GridLayout_Layout_android_layout_marginLeft android.support.v7.gridlayout:android_layout_marginLeft}</code></td><td>
- Specifies extra space on the left side of this view.</td></tr>
- <tr><td><code>{@link #GridLayout_Layout_android_layout_marginRight android.support.v7.gridlayout:android_layout_marginRight}</code></td><td>
- Specifies extra space on the right side of this view.</td></tr>
- <tr><td><code>{@link #GridLayout_Layout_android_layout_marginTop android.support.v7.gridlayout:android_layout_marginTop}</code></td><td>
- Specifies extra space on the top side of this view.</td></tr>
- <tr><td><code>{@link #GridLayout_Layout_android_layout_width android.support.v7.gridlayout:android_layout_width}</code></td><td>
- support versions.</td></tr>
- <tr><td><code>{@link #GridLayout_Layout_layout_column android.support.v7.gridlayout:layout_column}</code></td><td>
- The column boundary delimiting the left of the group of cells
- occupied by this view.</td></tr>
- <tr><td><code>{@link #GridLayout_Layout_layout_columnSpan android.support.v7.gridlayout:layout_columnSpan}</code></td><td>
- The column span: the difference between the right and left
- boundaries delimiting the group of cells occupied by this view.</td></tr>
- <tr><td><code>{@link #GridLayout_Layout_layout_gravity android.support.v7.gridlayout:layout_gravity}</code></td><td>
- Gravity specifies how a component should be placed in its group of cells.</td></tr>
- <tr><td><code>{@link #GridLayout_Layout_layout_row android.support.v7.gridlayout:layout_row}</code></td><td> END MarginLayout layoutparams
-
- The row boundary delimiting the top of the group of cells
- occupied by this view.</td></tr>
- <tr><td><code>{@link #GridLayout_Layout_layout_rowSpan android.support.v7.gridlayout:layout_rowSpan}</code></td><td>
- The row span: the difference between the bottom and top
- boundaries delimiting the group of cells occupied by this view.</td></tr>
- </table>
- @see #GridLayout_Layout_android_layout_height
- @see #GridLayout_Layout_android_layout_margin
- @see #GridLayout_Layout_android_layout_marginBottom
- @see #GridLayout_Layout_android_layout_marginLeft
- @see #GridLayout_Layout_android_layout_marginRight
- @see #GridLayout_Layout_android_layout_marginTop
- @see #GridLayout_Layout_android_layout_width
- @see #GridLayout_Layout_layout_column
- @see #GridLayout_Layout_layout_columnSpan
- @see #GridLayout_Layout_layout_gravity
- @see #GridLayout_Layout_layout_row
- @see #GridLayout_Layout_layout_rowSpan
- */
- public static final int[] GridLayout_Layout = {
- 0x010100f4, 0x010100f5, 0x010100f6, 0x010100f7,
- 0x010100f8, 0x010100f9, 0x010100fa, 0x7f010007,
- 0x7f010008, 0x7f010009, 0x7f01000a, 0x7f01000b
- };
- /**
- <p>This symbol is the offset where the {@link android.support.v7.gridlayout.R.attr#android_layout_height}
- attribute's value can be found in the {@link #GridLayout_Layout} array.
- @attr name android:android_layout_height
- */
- public static final int GridLayout_Layout_android_layout_height = 1;
- /**
- <p>
- @attr description
-
- Specifies extra space on the left, top, right and bottom
- sides of this view. This space is outside this view's bounds.
-
- <p>This corresponds to the global attribute resource symbol {@link android.support.v7.gridlayout.R.attr#android_layout_margin}.
- @attr name android:android_layout_margin
- */
- public static final int GridLayout_Layout_android_layout_margin = 2;
- /**
- <p>
- @attr description
-
- Specifies extra space on the bottom side of this view.
- This space is outside this view's bounds.
-
- <p>This corresponds to the global attribute resource symbol {@link android.support.v7.gridlayout.R.attr#android_layout_marginBottom}.
- @attr name android:android_layout_marginBottom
- */
- public static final int GridLayout_Layout_android_layout_marginBottom = 6;
- /**
- <p>
- @attr description
-
- Specifies extra space on the left side of this view.
- This space is outside this view's bounds.
-
- <p>This corresponds to the global attribute resource symbol {@link android.support.v7.gridlayout.R.attr#android_layout_marginLeft}.
- @attr name android:android_layout_marginLeft
- */
- public static final int GridLayout_Layout_android_layout_marginLeft = 3;
- /**
- <p>
- @attr description
-
- Specifies extra space on the right side of this view.
- This space is outside this view's bounds.
-
- <p>This corresponds to the global attribute resource symbol {@link android.support.v7.gridlayout.R.attr#android_layout_marginRight}.
- @attr name android:android_layout_marginRight
- */
- public static final int GridLayout_Layout_android_layout_marginRight = 5;
- /**
- <p>
- @attr description
-
- Specifies extra space on the top side of this view.
- This space is outside this view's bounds.
-
- <p>This corresponds to the global attribute resource symbol {@link android.support.v7.gridlayout.R.attr#android_layout_marginTop}.
- @attr name android:android_layout_marginTop
- */
- public static final int GridLayout_Layout_android_layout_marginTop = 4;
- /**
- <p>
- @attr description
-
- support versions. All attributes not present in MarginLayout are
- redefined in the support library name space.
-
- START MarginLayout layoutparams
- <p>This corresponds to the global attribute resource symbol {@link android.support.v7.gridlayout.R.attr#android_layout_width}.
- @attr name android:android_layout_width
- */
- public static final int GridLayout_Layout_android_layout_width = 0;
- /**
- <p>
- @attr description
-
- The column boundary delimiting the left of the group of cells
- occupied by this view.
-
-
-
- <p>Must be an integer value, such as "<code>100</code>".
-<p>This may also be a reference to a resource (in the form
-"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
-theme attribute (in the form
-"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
-containing a value of this type.
- <p>This is a private symbol.
- @attr name android:layout_column
- */
- public static final int GridLayout_Layout_layout_column = 9;
- /**
- <p>
- @attr description
-
- The column span: the difference between the right and left
- boundaries delimiting the group of cells occupied by this view.
- The default is one.
- See {@link android.widget.GridLayout.Spec}.
-
-
-
- <p>Must be an integer value, such as "<code>100</code>".
-<p>This may also be a reference to a resource (in the form
-"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
-theme attribute (in the form
-"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
-containing a value of this type.
- <p>This is a private symbol.
- @attr name android:layout_columnSpan
- */
- public static final int GridLayout_Layout_layout_columnSpan = 10;
- /**
- <p>
- @attr description
-
- Gravity specifies how a component should be placed in its group of cells.
- The default is LEFT | BASELINE.
- See {@link android.widget.GridLayout.LayoutParams#setGravity(int)}.
-
-
-
- <p>Must be one or more (separated by '|') of the following constant values.</p>
-<table>
-<colgroup align="left" />
-<colgroup align="left" />
-<colgroup align="left" />
-<tr><th>Constant</th><th>Value</th><th>Description</th></tr>
-<tr><td><code>top</code></td><td>0x30</td><td> Push object to the top of its container, not changing its size. </td></tr>
-<tr><td><code>bottom</code></td><td>0x50</td><td> Push object to the bottom of its container, not changing its size. </td></tr>
-<tr><td><code>left</code></td><td>0x03</td><td> Push object to the left of its container, not changing its size. </td></tr>
-<tr><td><code>right</code></td><td>0x05</td><td> Push object to the right of its container, not changing its size. </td></tr>
-<tr><td><code>center_vertical</code></td><td>0x10</td><td> Place object in the vertical center of its container, not changing its size. </td></tr>
-<tr><td><code>fill_vertical</code></td><td>0x70</td><td> Grow the vertical size of the object if needed so it completely fills its container. </td></tr>
-<tr><td><code>center_horizontal</code></td><td>0x01</td><td> Place object in the horizontal center of its container, not changing its size. </td></tr>
-<tr><td><code>fill_horizontal</code></td><td>0x07</td><td> Grow the horizontal size of the object if needed so it completely fills its container. </td></tr>
-<tr><td><code>center</code></td><td>0x11</td><td> Place the object in the center of its container in both the vertical and horizontal axis, not changing its size. </td></tr>
-<tr><td><code>fill</code></td><td>0x77</td><td> Grow the horizontal and vertical size of the object if needed so it completely fills its container. </td></tr>
-<tr><td><code>clip_vertical</code></td><td>0x80</td><td>
- Additional option that can be set to have the top and/or bottom edges of
- the child clipped to its container's bounds.
- The clip will be based on the vertical gravity: a top gravity will clip the bottom
- edge, a bottom gravity will clip the top edge, and neither will clip both edges.
- </td></tr>
-<tr><td><code>clip_horizontal</code></td><td>0x08</td><td>
- Additional option that can be set to have the left and/or right edges of
- the child clipped to its container's bounds.
- The clip will be based on the horizontal gravity: a left gravity will clip the right
- edge, a right gravity will clip the left edge, and neither will clip both edges.
- </td></tr>
-<tr><td><code>start</code></td><td>0x00800003</td><td> Push object to the beginning of its container, not changing its size. </td></tr>
-<tr><td><code>end</code></td><td>0x00800005</td><td> Push object to the end of its container, not changing its size. </td></tr>
-</table>
- <p>This is a private symbol.
- @attr name android:layout_gravity
- */
- public static final int GridLayout_Layout_layout_gravity = 11;
- /**
- <p>
- @attr description
- END MarginLayout layoutparams
-
- The row boundary delimiting the top of the group of cells
- occupied by this view.
-
-
-
- <p>Must be an integer value, such as "<code>100</code>".
-<p>This may also be a reference to a resource (in the form
-"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
-theme attribute (in the form
-"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
-containing a value of this type.
- <p>This is a private symbol.
- @attr name android:layout_row
- */
- public static final int GridLayout_Layout_layout_row = 7;
- /**
- <p>
- @attr description
-
- The row span: the difference between the bottom and top
- boundaries delimiting the group of cells occupied by this view.
- The default is one.
- See {@link android.widget.GridLayout.Spec}.
-
-
-
- <p>Must be an integer value, such as "<code>100</code>".
-<p>This may also be a reference to a resource (in the form
-"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
-theme attribute (in the form
-"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
-containing a value of this type.
- <p>This is a private symbol.
- @attr name android:layout_rowSpan
- */
- public static final int GridLayout_Layout_layout_rowSpan = 8;
- };
-}
diff --git a/v7/gridlayout/readme b/v7/gridlayout/src/.readme
similarity index 100%
rename from v7/gridlayout/readme
rename to v7/gridlayout/src/.readme
diff --git a/appcompat/.classpath b/v7/mediarouter/.classpath
similarity index 66%
copy from appcompat/.classpath
copy to v7/mediarouter/.classpath
index 0962016..a4763d1 100644
--- a/appcompat/.classpath
+++ b/v7/mediarouter/.classpath
@@ -1,12 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="eclair"/>
- <classpathentry kind="src" path="honeycomb"/>
- <classpathentry kind="src" path="ics"/>
- <classpathentry kind="src" path="java"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
diff --git a/appcompat/.gitignore b/v7/mediarouter/.gitignore
similarity index 100%
copy from appcompat/.gitignore
copy to v7/mediarouter/.gitignore
diff --git a/appcompat/.project b/v7/mediarouter/.project
similarity index 94%
rename from appcompat/.project
rename to v7/mediarouter/.project
index bac1446..2eca48b 100644
--- a/appcompat/.project
+++ b/v7/mediarouter/.project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>android-support-appcompat</name>
+ <name>android-support-v7-mediarouter</name>
<comment></comment>
<projects>
</projects>
diff --git a/v7/mediarouter/Android.mk b/v7/mediarouter/Android.mk
new file mode 100644
index 0000000..b3153a2
--- /dev/null
+++ b/v7/mediarouter/Android.mk
@@ -0,0 +1,58 @@
+# Copyright (C) 2013 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+
+# A helper sub-library that makes direct use of JellyBean APIs.
+include $(CLEAR_VARS)
+LOCAL_MODULE := android-support-v7-mediarouter-jellybean
+LOCAL_SDK_VERSION := 16
+LOCAL_SRC_FILES := $(call all-java-files-under, jellybean)
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+# A helper sub-library that makes direct use of JellyBean MR1 APIs.
+include $(CLEAR_VARS)
+LOCAL_MODULE := android-support-v7-mediarouter-jellybean-mr1
+LOCAL_SDK_VERSION := 17
+LOCAL_SRC_FILES := $(call all-java-files-under, jellybean-mr1)
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-v7-mediarouter-jellybean
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+# A helper sub-library that makes direct use of JellyBean MR2 APIs.
+include $(CLEAR_VARS)
+LOCAL_MODULE := android-support-v7-mediarouter-jellybean-mr2
+LOCAL_SDK_VERSION := current
+LOCAL_SRC_FILES := $(call all-java-files-under, jellybean-mr2)
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-v7-mediarouter-jellybean-mr1
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+# Here is the final static library that apps can link against.
+# The R class is automatically excluded from the generated library.
+# Applications that use this library must specify LOCAL_RESOURCE_DIR
+# in their makefiles to include the resources in their package.
+include $(CLEAR_VARS)
+LOCAL_MODULE := android-support-v7-mediarouter
+LOCAL_SDK_VERSION := 4
+LOCAL_SRC_FILES := $(call all-java-files-under,src)
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-v7-mediarouter-jellybean-mr2
+LOCAL_JAVA_LIBRARIES := android-support-v4
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+# Include this library in the build server's output directory
+$(call dist-for-goals, droidcore sdk, $(LOCAL_BUILT_MODULE):android-support-v7-mediarouter.jar)
+
diff --git a/appcompat/AndroidManifest.xml b/v7/mediarouter/AndroidManifest.xml
similarity index 81%
copy from appcompat/AndroidManifest.xml
copy to v7/mediarouter/AndroidManifest.xml
index 4f60d8d..f22f80f 100644
--- a/appcompat/AndroidManifest.xml
+++ b/v7/mediarouter/AndroidManifest.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,6 +14,6 @@
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.support.appcompat">
- <uses-sdk android:minSdkVersion="9"/>
+ package="android.support.v7.mediarouter">
+ <uses-sdk android:minSdkVersion="7"/>
</manifest>
diff --git a/v7/mediarouter/README.txt b/v7/mediarouter/README.txt
new file mode 100644
index 0000000..5d99185
--- /dev/null
+++ b/v7/mediarouter/README.txt
@@ -0,0 +1,10 @@
+Library Project including compatibility MediaRouter.
+
+This can be used by an Android project to provide
+access to MediaRouter on applications running on API 7+.
+
+There is technically no source, but the src folder is necessary
+to ensure that the build system works. The content is actually
+located in libs/android-support-v7-mediarouter.jar.
+The accompanying resources must also be included in the application.
+
diff --git a/v7/mediarouter/jellybean-mr1/android/support/v7/media/MediaRouterJellybeanMr1.java b/v7/mediarouter/jellybean-mr1/android/support/v7/media/MediaRouterJellybeanMr1.java
new file mode 100644
index 0000000..a6b2afd
--- /dev/null
+++ b/v7/mediarouter/jellybean-mr1/android/support/v7/media/MediaRouterJellybeanMr1.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.media;
+
+import android.view.Display;
+
+final class MediaRouterJellybeanMr1 {
+ public static Object createCallback(Callback callback) {
+ return new CallbackProxy<Callback>(callback);
+ }
+
+ public static final class RouteInfo {
+ public static boolean isEnabled(Object routeObj) {
+ return ((android.media.MediaRouter.RouteInfo)routeObj).isEnabled();
+ }
+
+ public static Display getPresentationDisplay(Object routeObj) {
+ return ((android.media.MediaRouter.RouteInfo)routeObj).getPresentationDisplay();
+ }
+ }
+
+ public static interface Callback extends MediaRouterJellybean.Callback {
+ public void onRoutePresentationDisplayChanged(Object routeObj);
+ }
+
+ static class CallbackProxy<T extends Callback>
+ extends MediaRouterJellybean.CallbackProxy<T> {
+ public CallbackProxy(T callback) {
+ super(callback);
+ }
+
+ @Override
+ public void onRoutePresentationDisplayChanged(android.media.MediaRouter router,
+ android.media.MediaRouter.RouteInfo route) {
+ mCallback.onRoutePresentationDisplayChanged(route);
+ }
+ }
+}
diff --git a/appcompat/res-stub/android/support/appcompat/dummy/Dummy.java b/v7/mediarouter/jellybean-mr2/android/support/v7/media/MediaRouterJellybeanMr2.java
similarity index 67%
rename from appcompat/res-stub/android/support/appcompat/dummy/Dummy.java
rename to v7/mediarouter/jellybean-mr2/android/support/v7/media/MediaRouterJellybeanMr2.java
index 5c6f91e..a78b9eb 100644
--- a/appcompat/res-stub/android/support/appcompat/dummy/Dummy.java
+++ b/v7/mediarouter/jellybean-mr2/android/support/v7/media/MediaRouterJellybeanMr2.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,12 +14,10 @@
* limitations under the License.
*/
-package android.support.appcompat.dummy;
+package android.support.v7.media;
-/**
- * TODO Find out why the build system is rejecting the res-only sublibrary without any source
- * files.
- */
-class Dummy {
-
+final class MediaRouterJellybeanMr2 {
+ public static Object getDefaultRoute(Object routerObj) {
+ return ((android.media.MediaRouter)routerObj).getDefaultRoute();
+ }
}
diff --git a/v7/mediarouter/jellybean/android/support/v7/media/MediaRouterJellybean.java b/v7/mediarouter/jellybean/android/support/v7/media/MediaRouterJellybean.java
new file mode 100644
index 0000000..9b8cc72
--- /dev/null
+++ b/v7/mediarouter/jellybean/android/support/v7/media/MediaRouterJellybean.java
@@ -0,0 +1,340 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.media;
+
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+final class MediaRouterJellybean {
+ public static final int ROUTE_TYPE_LIVE_AUDIO = 0x1;
+ public static final int ROUTE_TYPE_LIVE_VIDEO = 0x2;
+ public static final int ROUTE_TYPE_USER = 0x00800000;
+
+ public static Object getMediaRouter(Context context) {
+ return context.getSystemService(Context.MEDIA_ROUTER_SERVICE);
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public static List getRoutes(Object routerObj) {
+ final android.media.MediaRouter router = (android.media.MediaRouter)routerObj;
+ final int count = router.getRouteCount();
+ List out = new ArrayList(count);
+ for (int i = 0; i < count; i++) {
+ out.add(router.getRouteAt(i));
+ }
+ return out;
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public static List getCategories(Object routerObj) {
+ final android.media.MediaRouter router = (android.media.MediaRouter)routerObj;
+ final int count = router.getCategoryCount();
+ List out = new ArrayList(count);
+ for (int i = 0; i < count; i++) {
+ out.add(router.getCategoryAt(i));
+ }
+ return out;
+ }
+
+ public static Object getSelectedRoute(Object routerObj, int type) {
+ return ((android.media.MediaRouter)routerObj).getSelectedRoute(type);
+ }
+
+ public static void selectRoute(Object routerObj, int types, Object routeObj) {
+ ((android.media.MediaRouter)routerObj).selectRoute(types,
+ (android.media.MediaRouter.RouteInfo)routeObj);
+ }
+
+ public static void addCallback(Object routerObj, int types, Object callbackObj) {
+ ((android.media.MediaRouter)routerObj).addCallback(types,
+ (android.media.MediaRouter.Callback)callbackObj);
+ }
+
+ public static void removeCallback(Object routerObj, Object callbackObj) {
+ ((android.media.MediaRouter)routerObj).removeCallback(
+ (android.media.MediaRouter.Callback)callbackObj);
+ }
+
+ public static Object createRouteCategory(Object routerObj,
+ String name, boolean isGroupable) {
+ return ((android.media.MediaRouter)routerObj).createRouteCategory(name, isGroupable);
+ }
+
+ public static Object createUserRoute(Object routerObj, Object categoryObj) {
+ return ((android.media.MediaRouter)routerObj).createUserRoute(
+ (android.media.MediaRouter.RouteCategory)categoryObj);
+ }
+
+ public static void addUserRoute(Object routerObj, Object routeObj) {
+ ((android.media.MediaRouter)routerObj).addUserRoute(
+ (android.media.MediaRouter.UserRouteInfo)routeObj);
+ }
+
+ public static void removeUserRoute(Object routerObj, Object routeObj) {
+ ((android.media.MediaRouter)routerObj).removeUserRoute(
+ (android.media.MediaRouter.UserRouteInfo)routeObj);
+ }
+
+ public static Object createCallback(Callback callback) {
+ return new CallbackProxy<Callback>(callback);
+ }
+
+ public static Object createVolumeCallback(VolumeCallback callback) {
+ return new VolumeCallbackProxy<VolumeCallback>(callback);
+ }
+
+ public static final class RouteInfo {
+ public static final Class<?> clazz = android.media.MediaRouter.RouteInfo.class;
+
+ public static CharSequence getName(Object routeObj, Context context) {
+ return ((android.media.MediaRouter.RouteInfo)routeObj).getName(context);
+ }
+
+ public static CharSequence getStatus(Object routeObj) {
+ return ((android.media.MediaRouter.RouteInfo)routeObj).getStatus();
+ }
+
+ public static int getSupportedTypes(Object routeObj) {
+ return ((android.media.MediaRouter.RouteInfo)routeObj).getSupportedTypes();
+ }
+
+ public static Object getCategory(Object routeObj) {
+ return ((android.media.MediaRouter.RouteInfo)routeObj).getCategory();
+ }
+
+ public static Drawable getIconDrawable(Object routeObj) {
+ return ((android.media.MediaRouter.RouteInfo)routeObj).getIconDrawable();
+ }
+
+ public static int getPlaybackType(Object routeObj) {
+ return ((android.media.MediaRouter.RouteInfo)routeObj).getPlaybackType();
+ }
+
+ public static int getPlaybackStream(Object routeObj) {
+ return ((android.media.MediaRouter.RouteInfo)routeObj).getPlaybackStream();
+ }
+
+ public static int getVolume(Object routeObj) {
+ return ((android.media.MediaRouter.RouteInfo)routeObj).getVolume();
+ }
+
+ public static int getVolumeMax(Object routeObj) {
+ return ((android.media.MediaRouter.RouteInfo)routeObj).getVolumeMax();
+ }
+
+ public static int getVolumeHandling(Object routeObj) {
+ return ((android.media.MediaRouter.RouteInfo)routeObj).getVolumeHandling();
+ }
+
+ public static Object getTag(Object routeObj) {
+ return ((android.media.MediaRouter.RouteInfo)routeObj).getTag();
+ }
+
+ public static void setTag(Object routeObj, Object tag) {
+ ((android.media.MediaRouter.RouteInfo)routeObj).setTag(tag);
+ }
+
+ public static void requestSetVolume(Object routeObj, int volume) {
+ ((android.media.MediaRouter.RouteInfo)routeObj).requestSetVolume(volume);
+ }
+
+ public static void requestUpdateVolume(Object routeObj, int direction) {
+ ((android.media.MediaRouter.RouteInfo)routeObj).requestUpdateVolume(direction);
+ }
+
+ public static Object getGroup(Object routeObj) {
+ return ((android.media.MediaRouter.RouteInfo)routeObj).getGroup();
+ }
+
+ public static boolean isGroup(Object routeObj) {
+ return routeObj instanceof android.media.MediaRouter.RouteGroup;
+ }
+ }
+
+ public static final class RouteGroup {
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public static List getGroupedRoutes(Object groupObj) {
+ final android.media.MediaRouter.RouteGroup group =
+ (android.media.MediaRouter.RouteGroup)groupObj;
+ final int count = group.getRouteCount();
+ List out = new ArrayList(count);
+ for (int i = 0; i < count; i++) {
+ out.add(group.getRouteAt(i));
+ }
+ return out;
+ }
+ }
+
+ public static final class UserRouteInfo {
+ public static void setName(Object routeObj, CharSequence name) {
+ ((android.media.MediaRouter.UserRouteInfo)routeObj).setName(name);
+ }
+
+ public static void setStatus(Object routeObj, CharSequence status) {
+ ((android.media.MediaRouter.UserRouteInfo)routeObj).setStatus(status);
+ }
+
+ public static void setIconDrawable(Object routeObj, Drawable icon) {
+ ((android.media.MediaRouter.UserRouteInfo)routeObj).setIconDrawable(icon);
+ }
+
+ public static void setPlaybackType(Object routeObj, int type) {
+ ((android.media.MediaRouter.UserRouteInfo)routeObj).setPlaybackType(type);
+ }
+
+ public static void setPlaybackStream(Object routeObj, int stream) {
+ ((android.media.MediaRouter.UserRouteInfo)routeObj).setPlaybackStream(stream);
+ }
+
+ public static void setVolume(Object routeObj, int volume) {
+ ((android.media.MediaRouter.UserRouteInfo)routeObj).setVolume(volume);
+ }
+
+ public static void setVolumeMax(Object routeObj, int volumeMax) {
+ ((android.media.MediaRouter.UserRouteInfo)routeObj).setVolumeMax(volumeMax);
+ }
+
+ public static void setVolumeHandling(Object routeObj, int volumeHandling) {
+ ((android.media.MediaRouter.UserRouteInfo)routeObj).setVolumeHandling(volumeHandling);
+ }
+
+ public static void setVolumeCallback(Object routeObj, Object volumeCallbackObj) {
+ ((android.media.MediaRouter.UserRouteInfo)routeObj).setVolumeCallback(
+ ((android.media.MediaRouter.VolumeCallback)volumeCallbackObj));
+ }
+ }
+
+ public static final class RouteCategory {
+ public static CharSequence getName(Object categoryObj, Context context) {
+ return ((android.media.MediaRouter.RouteCategory)categoryObj).getName(context);
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public static List getRoutes(Object categoryObj) {
+ ArrayList out = new ArrayList();
+ ((android.media.MediaRouter.RouteCategory)categoryObj).getRoutes(out);
+ return out;
+ }
+
+ public static int getSupportedTypes(Object categoryObj) {
+ return ((android.media.MediaRouter.RouteCategory)categoryObj).getSupportedTypes();
+ }
+
+ public static boolean isGroupable(Object categoryObj) {
+ return ((android.media.MediaRouter.RouteCategory)categoryObj).isGroupable();
+ }
+ }
+
+ public static interface Callback {
+ public void onRouteSelected(int type, Object routeObj);
+ public void onRouteUnselected(int type, Object routeObj);
+ public void onRouteAdded(Object routeObj);
+ public void onRouteRemoved(Object routeObj);
+ public void onRouteChanged(Object routeObj);
+ public void onRouteGrouped(Object routeObj, Object groupObj, int index);
+ public void onRouteUngrouped(Object routeObj, Object groupObj);
+ public void onRouteVolumeChanged(Object routeObj);
+ }
+
+ public static interface VolumeCallback {
+ public void onVolumeSetRequest(Object routeObj, int volume);
+ public void onVolumeUpdateRequest(Object routeObj, int direction);
+ }
+
+ static class CallbackProxy<T extends Callback>
+ extends android.media.MediaRouter.Callback {
+ protected final T mCallback;
+
+ public CallbackProxy(T callback) {
+ mCallback = callback;
+ }
+
+ @Override
+ public void onRouteSelected(android.media.MediaRouter router,
+ int type, android.media.MediaRouter.RouteInfo route) {
+ mCallback.onRouteSelected(type, route);
+ }
+
+ @Override
+ public void onRouteUnselected(android.media.MediaRouter router,
+ int type, android.media.MediaRouter.RouteInfo route) {
+ mCallback.onRouteUnselected(type, route);
+ }
+
+ @Override
+ public void onRouteAdded(android.media.MediaRouter router,
+ android.media.MediaRouter.RouteInfo route) {
+ mCallback.onRouteAdded(route);
+ }
+
+ @Override
+ public void onRouteRemoved(android.media.MediaRouter router,
+ android.media.MediaRouter.RouteInfo route) {
+ mCallback.onRouteRemoved(route);
+ }
+
+ @Override
+ public void onRouteChanged(android.media.MediaRouter router,
+ android.media.MediaRouter.RouteInfo route) {
+ mCallback.onRouteChanged(route);
+ }
+
+ @Override
+ public void onRouteGrouped(android.media.MediaRouter router,
+ android.media.MediaRouter.RouteInfo route,
+ android.media.MediaRouter.RouteGroup group, int index) {
+ mCallback.onRouteGrouped(route, group, index);
+ }
+
+ @Override
+ public void onRouteUngrouped(android.media.MediaRouter router,
+ android.media.MediaRouter.RouteInfo route,
+ android.media.MediaRouter.RouteGroup group) {
+ mCallback.onRouteUngrouped(route, group);
+ }
+
+ @Override
+ public void onRouteVolumeChanged(android.media.MediaRouter router,
+ android.media.MediaRouter.RouteInfo route) {
+ mCallback.onRouteVolumeChanged(route);
+ }
+ }
+
+ static class VolumeCallbackProxy<T extends VolumeCallback>
+ extends android.media.MediaRouter.VolumeCallback {
+ protected final T mCallback;
+
+ public VolumeCallbackProxy(T callback) {
+ mCallback = callback;
+ }
+
+ @Override
+ public void onVolumeSetRequest(android.media.MediaRouter.RouteInfo route,
+ int volume) {
+ mCallback.onVolumeSetRequest(route, volume);
+ }
+
+ @Override
+ public void onVolumeUpdateRequest(android.media.MediaRouter.RouteInfo route,
+ int direction) {
+ mCallback.onVolumeUpdateRequest(route, direction);
+ }
+ }
+}
diff --git a/appcompat/project.properties b/v7/mediarouter/project.properties
similarity index 100%
copy from appcompat/project.properties
copy to v7/mediarouter/project.properties
diff --git a/v7/mediarouter/res/values/strings.xml b/v7/mediarouter/res/values/strings.xml
new file mode 100644
index 0000000..a2caff3
--- /dev/null
+++ b/v7/mediarouter/res/values/strings.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <!-- Name for the default system route prior to Jellybean. [CHAR LIMIT=30] -->
+ <string name="system_route_name">System</string>
+
+ <!-- Name for the user route category created when publishing routes to the system in Jellybean and above. [CHAR LIMIT=30] -->
+ <string name="user_route_category_name">Devices</string>
+</resources>
diff --git a/v7/gridlayout/readme b/v7/mediarouter/src/.readme
similarity index 100%
copy from v7/gridlayout/readme
copy to v7/mediarouter/src/.readme
diff --git a/v7/mediarouter/src/android/support/v7/media/MediaControlIntent.java b/v7/mediarouter/src/android/support/v7/media/MediaControlIntent.java
new file mode 100644
index 0000000..5d2711c
--- /dev/null
+++ b/v7/mediarouter/src/android/support/v7/media/MediaControlIntent.java
@@ -0,0 +1,609 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.media;
+
+import android.app.PendingIntent;
+import android.content.Intent;
+import android.net.Uri;
+
+/**
+ * Constants for identifying media route capabilities and controlling media routes
+ * by sending an {@link Intent}.
+ * <p>
+ * The basic capabilities of a media route may be determined by looking at the
+ * media control intent categories and actions supported by the route.
+ * </p><ul>
+ * <li>A media control intent category specifies the type of the route
+ * and the manner in which applications send media to its destination.
+ * <li>A media control intent action specifies a command to be delivered to
+ * the media route's destination to control media playback. Media control
+ * actions may only apply to routes that support certain media control categories.
+ * </ul>
+ *
+ * <h3>Route Categories</h3>
+ * <p>
+ * Routes are classified by the categories of actions that they support. The following
+ * standard categories are defined.
+ * </p><ul>
+ * <li>{@link #CATEGORY_LIVE_AUDIO Live audio}: The route supports streaming live audio
+ * from the device to the destination. Live audio routes include local speakers
+ * and Bluetooth headsets.
+ * <li>{@link #CATEGORY_LIVE_VIDEO Live video}: The route supports streaming live video
+ * from the device to the destination. Live video routes include local displays
+ * and wireless displays that support mirroring and
+ * {@link android.app.Presentation presentations}.
+ * <li>{@link #CATEGORY_REMOTE_PLAYBACK Remote playback}: The route supports sending
+ * remote playback requests for media content to the destination. The content to be
+ * played is identified by a Uri and mime-type.
+ * </ul>
+ *
+ * <h3>Remote Playback</h3>
+ * <p>
+ * Media control intents are frequently used to start remote playback of media
+ * on a destination using remote playback actions from the
+ * {@link #CATEGORY_REMOTE_PLAYBACK remote playback category}.
+ * </p><p>
+ * The {@link #ACTION_PLAY} action enqueues the Uri of content to be played and obtains
+ * a media item id that can be used to control playback.
+ * </p>
+ *
+ * <h4>Media Items</h4>
+ * <p>
+ * A media item id is an opaque token that represents the playback request.
+ * The application must supply the media item id when sending control requests to
+ * {@link #ACTION_PAUSE pause}, {@link #ACTION_RESUME resume}, {@link #ACTION_SEEK seek},
+ * {@link #ACTION_GET_STATUS get status}, {@link #ACTION_GET_PROGRESS get progress},
+ * or perform other actions to affect playback.
+ * </p><p>
+ * Each remote playback action is bound to a specific media item. If a
+ * media item has finished, been canceled or encountered an error, then most
+ * actions other than status requests will fail. In particular, actions such as
+ * {@link #ACTION_PAUSE} always control playback of a specific media item rather
+ * than acting globally upon whatever happens to be playing at the moment.
+ * </p>
+ *
+ * <h4>Queue Behavior</h4>
+ * <p>
+ * To provide a seamless media experience, the application can enqueue a limited number
+ * of items to play in succession. The destination can take advantage of its
+ * queue to optimize continuous playback, starting the next media item automatically
+ * as soon as the previous one finishes.
+ * </p><p>
+ * By default, the {@link #ACTION_PLAY play action} causes the destination to stop
+ * whatever is currently playing, clear the queue of pending items, then begin playing
+ * the newly requested content. By supplying a
+ * {@link #EXTRA_ITEM_QUEUE_BEHAVIOR queue behavior} parameter as part of the playback
+ * request, the application can specify whether the media item should
+ * {@link #ITEM_QUEUE_BEHAVIOR_PLAY_NOW play now},
+ * {@link #ITEM_QUEUE_BEHAVIOR_PLAY_NOW play next},
+ * or {@link #ITEM_QUEUE_BEHAVIOR_PLAY_NOW play later},
+ * </p><p>
+ * Typically the application will start by queuing two media items at once: one item to
+ * play now and one item to play later. When the first item finishes, the next item
+ * will begin playing immediately. The application can then enqueue another media item to
+ * play next (without interrupting current playback), and so on.
+ * </p><p>
+ * The application can also enqueue additional items to play later although queuing
+ * just two items at a time is usually sufficient for continuous playback.
+ * </p>
+ */
+public final class MediaControlIntent {
+ /**
+ * Media control category: Live audio.
+ * <p>
+ * A route that supports live audio routing will allow the media audio stream
+ * to be sent to supported destinations. This can include internal speakers or
+ * audio jacks on the device itself, A2DP devices, and more.
+ * </p><p>
+ * When a live audio route is selected, audio routing is transparent to the application.
+ * All audio played on the media stream will be routed to the selected destination.
+ * </p>
+ */
+ public static final String CATEGORY_LIVE_AUDIO = "android.media.intent.category.LIVE_AUDIO";
+
+ /**
+ * Media control category: Live video.
+ * <p>
+ * A route that supports live video routing will allow a mirrored version
+ * of the device's primary display or a customized
+ * {@link android.app.Presentation Presentation} to be sent to supported
+ * destinations.
+ * </p><p>
+ * When a live video route is selected, audio and video routing is transparent
+ * to the application. By default, audio and video is routed to the selected
+ * destination. For certain live video routes, the application may also use a
+ * {@link android.app.Presentation Presentation} to replace the mirrored view
+ * on the external display with different content.
+ * </p>
+ *
+ * @see MediaRouter.RouteInfo#getPresentationDisplay()
+ * @see android.app.Presentation
+ */
+ public static final String CATEGORY_LIVE_VIDEO = "android.media.intent.category.LIVE_VIDEO";
+
+ /**
+ * Media control category: Remote playback.
+ * <p>
+ * A route that supports remote playback routing will allow an application to send
+ * requests to play content remotely to supported destinations.
+ * </p><p>
+ * Remote playback routes destinations operate independently of the local device.
+ * When a remote playback route is selected, the application can control the content
+ * playing on the destination by sending media control actions to the route.
+ * The application may also receive status updates from the route regarding
+ * remote playback.
+ * </p>
+ *
+ * @see MediaRouter.RouteInfo#sendControlRequest
+ */
+ public static final String CATEGORY_REMOTE_PLAYBACK =
+ "android.media.intent.category.REMOTE_PLAYBACK";
+
+ /**
+ * Media control action: Play media item.
+ * <p>
+ * Used with routes that support {@link #CATEGORY_REMOTE_PLAYBACK remote playback}
+ * media control.
+ * </p><p>
+ * This action causes a remote playback route to start playing content with
+ * the {@link Uri} specified in the {@link Intent}'s {@link Intent#getData() data uri}.
+ * The action returns a media item id which can be used to control playback
+ * using other remote playback actions.
+ * </p><p>
+ * Once initiated, playback of the specified content will be queued and managed
+ * independently by the destination. The application will receive status
+ * and progress updates as the content is played.
+ * </p><p>
+ * If the data uri specifies an HTTP or HTTPS scheme, then the destination is
+ * responsible for following HTTP redirects to a reasonable depth of at least 3
+ * levels as might typically be handled by a web browser. If an HTTP error
+ * occurs, then the destination should send a status update back to the client
+ * indicating the {@link MediaItemStatus#PLAYBACK_STATE_ERROR error}
+ * {@link MediaItemStatus#KEY_PLAYBACK_STATE state}
+ * and include the {@link MediaItemStatus#KEY_HTTP_STATUS_CODE HTTP status code}.
+ * </p>
+ *
+ * <h3>Request parameters</h3>
+ * <ul>
+ * <li>{@link #EXTRA_ITEM_QUEUE_BEHAVIOR}: specifies when the content should be played.
+ * <li>{@link #EXTRA_ITEM_POSITION}: specifies the initial start position of the content.
+ * <li>{@link #EXTRA_ITEM_METADATA}: specifies metadata associated with the
+ * content such as the title of a song.
+ * <li>{@link #EXTRA_ITEM_STATUS_UPDATE_RECEIVER}: specifies a {@link PendingIntent}
+ * for a broadcast receiver that will receive status updates about the media item.
+ * <li>{@link #EXTRA_ITEM_HTTP_HEADERS}: specifies HTTP headers to supply to the
+ * server when fetching the content.
+ * </ul>
+ *
+ * <h3>Result data</h3>
+ * <ul>
+ * <li>{@link #EXTRA_ITEM_ID}: specifies an opaque string identifier to use to refer
+ * to the media item in subsequent requests such as {@link #ACTION_PAUSE}.
+ * </ul>
+ *
+ * <h3>Status updates</h3>
+ * <p>
+ * If the client supplies a {@link #EXTRA_ITEM_STATUS_UPDATE_RECEIVER status update receiver}
+ * then the media route provider is responsible for sending status updates to the receiver
+ * when significant media item state changes occur.
+ * </p>
+ *
+ * <h3>Example</h3>
+ * <pre>
+ * MediaRouter mediaRouter = MediaRouter.getInstance(context);
+ * MediaRouter.RouteInfo route = mediaRouter.getSelectedRoute();
+ * Intent intent = new Intent(MediaControlIntent.ACTION_PLAY);
+ * intent.addCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK);
+ * intent.setDataAndType("http://example.com/videos/movie.mp4", "video/mp4");
+ * intent.putExtra(MediaControlIntent.EXTRA_ITEM_QUEUE_BEHAVIOR,
+ * MediaControlIntent.ITEM_QUEUE_BEHAVIOR_PLAY_NEXT);
+ * if (route.supportsControlRequest(intent)) {
+ * MediaRouter.ControlRequestCallback callback = new MediaRouter.ControlRequestCallback() {
+ * public void onResult(int result, Bundle data) {
+ * if (result == REQUEST_SUCCEEDED) {
+ * // The request succeeded.
+ * // Playback may be controlled using the returned item id...
+ * String id = data.getStringExtra(MediaControlIntent.EXTRA_ITEM_ID);
+ * }
+ * }
+ * };
+ * route.sendControlRequest(intent, callback);
+ * }</pre>
+ *
+ * @see MediaRouter.RouteInfo#sendControlRequest
+ * @see #CATEGORY_REMOTE_PLAYBACK
+ * @see #ACTION_SEEK
+ * @see #ACTION_STOP
+ * @see #ACTION_PAUSE
+ * @see #ACTION_RESUME
+ * @see #ACTION_GET_PROGRESS
+ * @see #ACTION_GET_STATUS
+ */
+ public static final String ACTION_PLAY = "android.media.intent.action.PLAY";
+
+ /**
+ * Media control action: Seek media item to a new playback position.
+ * <p>
+ * Used with routes that support {@link #CATEGORY_REMOTE_PLAYBACK remote playback}
+ * media control.
+ * </p><p>
+ * This action causes a remote playback route to modify the current playback
+ * position of the specified media item.
+ * </p><p>
+ * This action should generally not affect the current playback state of the media item.
+ * If the item is paused, then seeking should set the position but leave
+ * the item paused. Likewise if the item is playing, then seeking should
+ * continue playing from the new position. If the item has not yet started
+ * playing, then the new playback position should be remembered and used as the
+ * initial position for the item.
+ * </p>
+ *
+ * <h3>Request parameters</h3>
+ * <ul>
+ * <li>{@link #EXTRA_ITEM_ID}: specifies the media item id of the playback to be
+ * controlled. This value was returned as a result from the
+ * {@link #ACTION_PLAY play} action.
+ * <li>{@link #EXTRA_ITEM_POSITION}: specifies the new position of the content.
+ * </ul>
+ *
+ * <h3>Result data</h3>
+ * <ul>
+ * <li>(none)
+ * </ul>
+ *
+ * @see MediaRouter.RouteInfo#sendControlRequest
+ * @see #CATEGORY_REMOTE_PLAYBACK
+ */
+ public static final String ACTION_SEEK = "android.media.intent.action.SEEK";
+
+ /**
+ * Media control action: Stop media item playback.
+ * <p>
+ * Used with routes that support {@link #CATEGORY_REMOTE_PLAYBACK remote playback}
+ * media control.
+ * </p><p>
+ * This action causes a remote playback route to stop playback of the
+ * specified media item.
+ * </p><p>
+ * If the media item has not started playing yet, then the media item should
+ * be stopped and removed from the queue.
+ * </p>
+ *
+ * <h3>Request parameters</h3>
+ * <ul>
+ * <li>{@link #EXTRA_ITEM_ID}: specifies the media item id of the playback to be
+ * controlled. This value was returned as a result from the
+ * {@link #ACTION_PLAY play} action.
+ * </ul>
+ *
+ * <h3>Result data</h3>
+ * <ul>
+ * <li>(none)
+ * </ul>
+ *
+ * @see MediaRouter.RouteInfo#sendControlRequest
+ * @see #CATEGORY_REMOTE_PLAYBACK
+ */
+ public static final String ACTION_STOP = "android.media.intent.action.STOP";
+
+
+ /**
+ * Media control action: Pause media item playback.
+ * <p>
+ * Used with routes that support {@link #CATEGORY_REMOTE_PLAYBACK remote playback}
+ * media control.
+ * </p><p>
+ * This action causes a remote playback route to pause playback of the
+ * specified media item.
+ * </p><p>
+ * If the media item has not started playing yet, then the request to pause should
+ * be remembered such that the item will initially start in a paused state.
+ * </p>
+ *
+ * <h3>Request parameters</h3>
+ * <ul>
+ * <li>{@link #EXTRA_ITEM_ID}: specifies the media item id of the playback to be
+ * controlled. This value was returned as a result from the
+ * {@link #ACTION_PLAY play} action.
+ * </ul>
+ *
+ * <h3>Result data</h3>
+ * <ul>
+ * <li>(none)
+ * </ul>
+ *
+ * @see MediaRouter.RouteInfo#sendControlRequest
+ * @see #CATEGORY_REMOTE_PLAYBACK
+ * @see #ACTION_RESUME
+ */
+ public static final String ACTION_PAUSE = "android.media.intent.action.PAUSE";
+
+ /**
+ * Media control action: Resume media item playback (unpause).
+ * <p>
+ * Used with routes that support {@link #CATEGORY_REMOTE_PLAYBACK remote playback}
+ * media control.
+ * </p><p>
+ * This action causes a remote playback route to resume playback of the
+ * specified media item. Reverses the effects of {@link #ACTION_PAUSE}.
+ * </p>
+ *
+ * <h3>Request parameters</h3>
+ * <ul>
+ * <li>{@link #EXTRA_ITEM_ID}: specifies the media item id of the playback to be
+ * controlled. This value was returned as a result from the
+ * {@link #ACTION_PLAY play} action.
+ * </ul>
+ *
+ * <h3>Result data</h3>
+ * <ul>
+ * <li>(none)
+ * </ul>
+ *
+ * @see MediaRouter.RouteInfo#sendControlRequest
+ * @see #CATEGORY_REMOTE_PLAYBACK
+ * @see #ACTION_PAUSE
+ */
+ public static final String ACTION_RESUME = "android.media.intent.action.RESUME";
+
+ /**
+ * Media control action: Get media item status.
+ * <p>
+ * Used with routes that support {@link #CATEGORY_REMOTE_PLAYBACK remote playback}
+ * media control.
+ * </p><p>
+ * This action asks a remote playback route to provide updated status information
+ * about playback of the specified media item.
+ * </p>
+ *
+ * <h3>Request parameters</h3>
+ * <ul>
+ * <li>{@link #EXTRA_ITEM_ID}: specifies the media item id of the playback to be
+ * controlled. This value was returned as a result from the
+ * {@link #ACTION_PLAY play} action.
+ * </ul>
+ *
+ * <h3>Result data</h3>
+ * <ul>
+ * <li>{@link #EXTRA_ITEM_STATUS}: specifies the status of the stream.
+ * </ul>
+ *
+ * @see MediaRouter.RouteInfo#sendControlRequest
+ * @see #CATEGORY_REMOTE_PLAYBACK
+ * @see #EXTRA_ITEM_STATUS_UPDATE_RECEIVER
+ */
+ public static final String ACTION_GET_STATUS = "android.media.intent.action.GET_STATUS";
+
+ /**
+ * Media control action: Get media item progress.
+ * <p>
+ * Used with routes that support {@link #CATEGORY_REMOTE_PLAYBACK remote playback}
+ * media control.
+ * </p><p>
+ * This action asks a remote playback route to provide media item playback
+ * progress information. The client may use this information to provide feedback
+ * to the user about the current playback position and overall duration.
+ * </p>
+ *
+ * <h3>Request parameters</h3>
+ * <ul>
+ * <li>{@link #EXTRA_ITEM_ID}: specifies the media item id of the playback to be
+ * controlled. This value was returned as a result from the
+ * {@link #ACTION_PLAY play} action.
+ * </ul>
+ *
+ * <h3>Result data</h3>
+ * <ul>
+ * <li>{@link #EXTRA_ITEM_POSITION}: specifies the content playback position.
+ * <li>{@link #EXTRA_ITEM_DURATION}: specifies the overall duration of the content.
+ * </ul>
+ *
+ * @see MediaRouter.RouteInfo#sendControlRequest
+ * @see #CATEGORY_REMOTE_PLAYBACK
+ */
+ public static final String ACTION_GET_PROGRESS = "android.media.intent.action.GET_PROGRESS";
+
+ /**
+ * Integer extra: Media item queue behavior.
+ * <p>
+ * Used with {@link #ACTION_PLAY} to specify when the requested should be
+ * played. The default is to play the content immediately.
+ * </p><p>
+ * The value must be one of {@link #ITEM_QUEUE_BEHAVIOR_PLAY_NOW},
+ * {@link #ITEM_QUEUE_BEHAVIOR_PLAY_NEXT}, or {@link #ITEM_QUEUE_BEHAVIOR_PLAY_LATER}.
+ * </p>
+ *
+ * @see #ACTION_PLAY
+ */
+ public static final String EXTRA_ITEM_QUEUE_BEHAVIOR =
+ "android.media.intent.extra.QUEUE_BEHAVIOR";
+
+ /**
+ * Value for {@link #EXTRA_ITEM_QUEUE_BEHAVIOR}: Play now.
+ * <p>
+ * This is the default queue behavior.
+ * </p><p>
+ * Requests that the new content be played immediately, canceling the currently playing
+ * media item and all subsequent items in the queue. When this control request returns,
+ * the queue will contain exactly one item consisting of the newly requested content.
+ * </p>
+ *
+ * @see #EXTRA_ITEM_QUEUE_BEHAVIOR
+ */
+ public static final int ITEM_QUEUE_BEHAVIOR_PLAY_NOW = 0;
+
+ /**
+ * Value for {@link #EXTRA_ITEM_QUEUE_BEHAVIOR}: Play next.
+ * <p>
+ * Requests that the new content be enqueued to play next after the currently playing
+ * media item, canceling all subsequent items in the queue. When this control request
+ * returns, the queue will contain either one or two items consisting of the currently
+ * playing content, if any, followed by the newly requested content.
+ * </p>
+ *
+ * @see #EXTRA_ITEM_QUEUE_BEHAVIOR
+ */
+ public static final int ITEM_QUEUE_BEHAVIOR_PLAY_NEXT = 1;
+
+ /**
+ * Value for {@link #EXTRA_ITEM_QUEUE_BEHAVIOR}: Play later.
+ * <p>
+ * Requests that the new content be enqueued to play later after all other media items
+ * currently in the queue. When this control request returns, the queue will contain at
+ * least one item consisting of the currently playing content and all previously
+ * enqueued items followed by the newly requested content.
+ * </p>
+ *
+ * @see #EXTRA_ITEM_QUEUE_BEHAVIOR
+ */
+ public static final int ITEM_QUEUE_BEHAVIOR_PLAY_LATER = 2;
+
+ /**
+ * Integer extra: Media item content position.
+ * <p>
+ * Used with {@link #ACTION_PLAY} to specify the starting playback position.
+ * </p><p>
+ * Used with {@link #ACTION_SEEK} to set a new playback position.
+ * </p><p>
+ * Used with {@link #ACTION_GET_PROGRESS} to report the current playback position.
+ * </p><p>
+ * The value is an integer number of seconds from the beginning of the content.
+ * <p>
+ *
+ * @see #ACTION_PLAY
+ * @see #ACTION_SEEK
+ * @see #ACTION_GET_PROGRESS
+ */
+ public static final String EXTRA_ITEM_POSITION =
+ "android.media.intent.extra.ITEM_POSITION";
+
+ /**
+ * Integer extra: Media item content duration.
+ * <p>
+ * Used with {@link #ACTION_GET_PROGRESS} to report the overall duration of the
+ * media item content.
+ * </p><p>
+ * The value is an integer number of seconds from the beginning of the content.
+ * <p>
+ *
+ * @see #ACTION_GET_PROGRESS
+ */
+ public static final String EXTRA_ITEM_DURATION =
+ "android.media.intent.extra.ITEM_DURATION";
+
+ /**
+ * Bundle extra: Media item metadata.
+ * <p>
+ * Used with {@link #ACTION_PLAY} to specify metadata associated with the content
+ * of a media item.
+ * </p><p>
+ * The value is a {@link android.os.Bundle} of metadata keys and values as defined
+ * in {@link MediaItemMetadata}.
+ * </p>
+ *
+ * @see #ACTION_PLAY
+ */
+ public static final String EXTRA_ITEM_METADATA =
+ "android.media.intent.extra.ITEM_METADATA";
+
+ /**
+ * Bundle extra: Media item id.
+ * <p>
+ * Returned as a result from {@link #ACTION_PLAY} to provide an opaque unique id
+ * for the requested media item which may then be used to issue subsequent
+ * requests to control the content.
+ * </p><p>
+ * Used with various actions to specify the id of the media item to be controlled.
+ * </p><p>
+ * The value is a unique string value generated by the media route provider
+ * to represent one particular media item.
+ * </p>
+ *
+ * @see #ACTION_PLAY
+ * @see #ACTION_STOP
+ * @see #ACTION_SEEK
+ * @see #ACTION_PAUSE
+ * @see #ACTION_RESUME
+ * @see #ACTION_GET_STATUS
+ */
+ public static final String EXTRA_ITEM_ID =
+ "android.media.intent.extra.ITEM_ID";
+
+ /**
+ * Bundle extra: Media item status.
+ * <p>
+ * Returned as a result from {@link #ACTION_GET_STATUS} and in broadcasts
+ * sent to a {@link #EXTRA_ITEM_STATUS_UPDATE_RECEIVER status update receiver}
+ * to describe the status of the media item.
+ * </p><p>
+ * The value is a {@link android.os.Bundle} of status keys and values as defined
+ * in {@link MediaItemStatus}.
+ * </p>
+ *
+ * @see #ACTION_PLAY
+ * @see #ACTION_GET_STATUS
+ */
+ public static final String EXTRA_ITEM_STATUS =
+ "android.media.intent.extra.ITEM_STATUS";
+
+ /**
+ * Bundle extra: Media item status update receiver.
+ * <p>
+ * Used with {@link #ACTION_PLAY} to specify a {@link PendingIntent} for a
+ * broadcast receiver that will receive status updates about a media item.
+ * </p><p>
+ * Whenever the status of the media item changes, the media route provider will
+ * send a broadcast to the pending intent with extras that describe
+ * the status of the media item.
+ * </p><p>
+ * The value is a {@link PendingIntent}.
+ * </p>
+ *
+ * <h3>Broadcast extras</h3>
+ * <ul>
+ * <li>{@link #EXTRA_ITEM_ID}: specifies the media item id of the playback to be
+ * controlled. This value was returned as a result from the
+ * {@link #ACTION_PLAY play} action.
+ * <li>{@link #EXTRA_ITEM_STATUS}: specifies the status of the stream.
+ * </ul>
+ *
+ * @see #ACTION_PLAY
+ */
+ public static final String EXTRA_ITEM_STATUS_UPDATE_RECEIVER =
+ "android.media.intent.extra.ITEM_STATUS_UPDATE_RECEIVER";
+
+ /**
+ * Bundle extra: HTTP headers.
+ * <p>
+ * Used with {@link #ACTION_PLAY} to specify HTTP headers to be included when
+ * fetching to the content indicated by the media item's data Uri.
+ * </p><p>
+ * This extra may be used to provide authentication tokens and other
+ * parameters to the server separately from the media item's data Uri.
+ * </p><p>
+ * The value is a {@link android.os.Bundle} of string based key value pairs
+ * that describe the HTTP headers.
+ * </p>
+ *
+ * @see #ACTION_PLAY
+ */
+ public static final String EXTRA_ITEM_HTTP_HEADERS =
+ "android.media.intent.extra.HTTP_HEADERS";
+
+ private MediaControlIntent() {
+ }
+}
diff --git a/v7/mediarouter/src/android/support/v7/media/MediaItemMetadata.java b/v7/mediarouter/src/android/support/v7/media/MediaItemMetadata.java
new file mode 100644
index 0000000..1836f91
--- /dev/null
+++ b/v7/mediarouter/src/android/support/v7/media/MediaItemMetadata.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.media;
+
+import android.os.Bundle;
+
+/**
+ * Constants for specifying metadata about a media item as a {@link Bundle}.
+ */
+public final class MediaItemMetadata {
+ /*
+ * Note: MediaMetadataRetriever also defines a collection of metadata keys that can be
+ * retrieved from a content stream although the representation is somewhat different here
+ * since we are sending the data to a remote endpoint.
+ */
+
+ private MediaItemMetadata() {
+ }
+
+ /**
+ * Metadata key: Album artist name.
+ * <p>
+ * The value is a string suitable for display.
+ * </p>
+ */
+ public static final String KEY_ALBUM_ARTIST = "ALBUM_ARTIST";
+
+ /**
+ * Metadata key: Album title.
+ * <p>
+ * The value is a string suitable for display.
+ * </p>
+ */
+ public static final String KEY_ALBUM_TITLE = "ALBUM_TITLE";
+
+ /**
+ * Metadata key: Artwork Uri.
+ * <p>
+ * The value is a string URI for an image file associated with the media item,
+ * such as album or cover art.
+ * </p>
+ *
+ * @see #KEY_ARTWORK_BITMAP
+ */
+ public static final String KEY_ARTWORK_URI = "ARTWORK_URI";
+
+ /**
+ * Metadata key: Artwork Bitmap.
+ * <p>
+ * The value is a {@link Bitmap} for an image file associated with the media item,
+ * such as album or cover art.
+ * </p><p>
+ * Because bitmaps can be large, use {@link #KEY_ARTWORK_URI} instead if the artwork can
+ * be downloaded from the network.
+ * </p>
+ *
+ * @see #KEY_ARTWORK_URI
+ */
+ public static final String KEY_ARTWORK_BITMAP = "ARTWORK_BITMAP";
+
+ /**
+ * Metadata key: Artist name.
+ * <p>
+ * The value is a string suitable for display.
+ * </p>
+ */
+ public static final String KEY_ARTIST = "ARTIST";
+
+ /**
+ * Metadata key: Author name.
+ * <p>
+ * The value is a string suitable for display.
+ * </p>
+ */
+ public static final String KEY_AUTHOR = "AUTHOR";
+
+ /**
+ * Metadata key: Composer name.
+ * <p>
+ * The value is a string suitable for display.
+ * </p>
+ */
+ public static final String KEY_COMPOSER = "COMPOSER";
+
+ /**
+ * Metadata key: Track title.
+ * <p>
+ * The value is a string suitable for display.
+ * </p>
+ */
+ public static final String KEY_TITLE = "TITLE";
+
+ /**
+ * Metadata key: Year of publication.
+ * <p>
+ * The value is an integer year number.
+ * </p>
+ */
+ public static final String KEY_YEAR = "YEAR";
+
+ /**
+ * Metadata key: Track number (such as a track on a CD).
+ * <p>
+ * The value is a one-based integer track number.
+ * </p>
+ */
+ public static final String KEY_TRACK_NUMBER = "TRACK_NUMBER";
+
+ /**
+ * Metadata key: Disc number within a collection.
+ * <p>
+ * The value is a one-based integer disc number.
+ * </p>
+ */
+ public static final String KEY_DISC_NUMBER = "DISC_NUMBER";
+}
diff --git a/v7/mediarouter/src/android/support/v7/media/MediaItemStatus.java b/v7/mediarouter/src/android/support/v7/media/MediaItemStatus.java
new file mode 100644
index 0000000..4a53113
--- /dev/null
+++ b/v7/mediarouter/src/android/support/v7/media/MediaItemStatus.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.media;
+
+import android.os.Bundle;
+
+/**
+ * Constants for specifying status about a media item as a {@link Bundle}.
+ */
+public final class MediaItemStatus {
+ private MediaItemStatus() {
+ }
+
+ /**
+ * Status key: Playback state.
+ * <p>
+ * Specifies the playback state of a media item.
+ * </p><p>
+ * Value is one of {@link #PLAYBACK_STATE_QUEUED}, {@link #PLAYBACK_STATE_PLAYING},
+ * {@link #PLAYBACK_STATE_PAUSED}, {@link #PLAYBACK_STATE_BUFFERING},
+ * {@link #PLAYBACK_STATE_CANCELED}, or {@link #PLAYBACK_STATE_ERROR}.
+ * </p>
+ */
+ public static final String KEY_PLAYBACK_STATE = "PLAYBACK_STATE";
+
+ /**
+ * Playback state: Queued.
+ * <p>
+ * Indicates that the media item is in the queue to be played eventually.
+ * </p>
+ */
+ public static final int PLAYBACK_STATE_QUEUED = 0;
+
+ /**
+ * Playback state: Playing.
+ * <p>
+ * Indicates that the media item is currently playing.
+ * </p>
+ */
+ public static final int PLAYBACK_STATE_PLAYING = 1;
+
+ /**
+ * Playback state: Paused.
+ * <p>
+ * Indicates that the media item has been paused. Playback can be
+ * resumed playback by sending {@link MediaControlIntent#ACTION_RESUME}.
+ * </p>
+ */
+ public static final int PLAYBACK_STATE_PAUSED = 2;
+
+ /**
+ * Playback state: Buffering or seeking to a new position.
+ * <p>
+ * Indicates that the media item has been temporarily interrupted
+ * to fetch more content. Playback will resume automatically
+ * when enough content has been buffered.
+ * </p>
+ */
+ public static final int PLAYBACK_STATE_BUFFERING = 3;
+
+ /**
+ * Playback state: Stopped.
+ * <p>
+ * Indicates that the media item has been stopped permanently either because
+ * it reached the end of the content or because the user ended playback.
+ * </p><p>
+ * A stopped media item cannot be resumed. To play the content again, the application
+ * must send a new {@link MediaControlIntent#ACTION_PLAY} action to enqueue
+ * a new playback request and obtain a new media item id from that request.
+ * </p>
+ */
+ public static final int PLAYBACK_STATE_STOPPED = 4;
+
+ /**
+ * Playback state: Canceled.
+ * <p>
+ * Indicates that the media item was canceled permanently. This may
+ * happen because a new media item was queued which caused this media item
+ * to be stopped and removed from the queue.
+ * </p><p>
+ * A canceled media item cannot be resumed. To play the content again, the application
+ * must send a new {@link MediaControlIntent#ACTION_PLAY} action to enqueue
+ * a new playback request and obtain a new media item id from that request.
+ * </p>
+ */
+ public static final int PLAYBACK_STATE_CANCELED = 5;
+
+ /**
+ * Playback state: Playback halted or aborted due to an error.
+ * <p>
+ * Examples of errors are no network connectivity when attempting to retrieve content
+ * from a server, or expired user credentials when trying to play subscription-based
+ * content.
+ * </p><p>
+ * A media item in the error state cannot be resumed. To play the content again,
+ * the application must send a new {@link MediaControlIntent#ACTION_PLAY} action to enqueue
+ * a new playback request and obtain a new media item id from that request.
+ * </p>
+ */
+ public static final int PLAYBACK_STATE_ERROR = 6;
+
+ /**
+ * Status key: HTTP status code.
+ * <p>
+ * Specifies the HTTP status code that was encountered when the content
+ * was requested after all redirects were followed. This key only needs to
+ * specified when the content uri uses the HTTP or HTTPS scheme and an error
+ * occurred. This key may be omitted if the content was able to be played
+ * successfully; there is no need to report a 200 (OK) status code.
+ * </p><p>
+ * Value is an integer HTTP status code such as 401 (Unauthorized), 404 (Not Found),
+ * or 500 (Server Error).
+ * </p>
+ */
+ public static final String KEY_HTTP_STATUS_CODE = "HTTP_STATUS_CODE";
+}
diff --git a/v7/mediarouter/src/android/support/v7/media/MediaRouteProvider.java b/v7/mediarouter/src/android/support/v7/media/MediaRouteProvider.java
new file mode 100644
index 0000000..2901419
--- /dev/null
+++ b/v7/mediarouter/src/android/support/v7/media/MediaRouteProvider.java
@@ -0,0 +1,718 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.media;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.os.Parcelable;
+import android.support.v7.media.MediaRouter.ControlRequestCallback;
+import android.text.TextUtils;
+
+import java.util.concurrent.CopyOnWriteArrayList;
+
+/**
+ * Media route providers are used to publish additional media routes for
+ * use within an application. Media route providers may also be declared
+ * as a service to publish additional media routes to all applications
+ * in the system.
+ * <p>
+ * Applications and services should extend this class to publish additional media routes
+ * to the {@link MediaRouter}. To make additional media routes available within
+ * your application, call {@link MediaRouter#addProvider} to add your provider to
+ * the media router. To make additional media routes available to all applications
+ * in the system, register a media route provider service in your manifest.
+ * </p><p>
+ * This object must only be accessed on the main thread.
+ * </p>
+ */
+public abstract class MediaRouteProvider {
+ private static final int MSG_DELIVER_DESCRIPTOR_CHANGED = 1;
+
+ private final Context mContext;
+ private final ProviderMetadata mMetadata;
+ private final ProviderHandler mHandler = new ProviderHandler();
+ private final CopyOnWriteArrayList<Callback> mCallbacks =
+ new CopyOnWriteArrayList<Callback>();
+
+ private ProviderDescriptor mDescriptor;
+ private boolean mPendingDescriptorChange;
+
+ /**
+ * Creates a media route provider.
+ *
+ * @param context The context.
+ */
+ public MediaRouteProvider(Context context) {
+ this(context, null);
+ }
+
+ MediaRouteProvider(Context context, ProviderMetadata metadata) {
+ if (context == null) {
+ throw new IllegalArgumentException("context must not be null");
+ }
+
+ mContext = context;
+ if (metadata == null) {
+ mMetadata = new ProviderMetadata(context.getPackageName());
+ } else {
+ mMetadata = metadata;
+ }
+ }
+
+ /**
+ * Gets the context of the media route provider.
+ */
+ public final Context getContext() {
+ return mContext;
+ }
+
+ final ProviderMetadata getMetadata() {
+ return mMetadata;
+ }
+
+ /**
+ * Gets the provider's descriptor.
+ * <p>
+ * The descriptor describes the state of the media route provider and
+ * the routes that it publishes. Watch for changes to the descriptor
+ * by registering a {@link Callback callback} with {@link #addCallback}.
+ * </p>
+ *
+ * @return The media route provider descriptor, or null if none. This object
+ * and all of its contents should be treated as if it were immutable so that it is
+ * safe for clients to cache it.
+ */
+ public final ProviderDescriptor getDescriptor() {
+ return mDescriptor;
+ }
+
+ /**
+ * Sets the provider's descriptor.
+ * <p>
+ * Asynchronously notifies all registered {@link Callback callbacks} about the change.
+ * </p>
+ *
+ * @param descriptor The updated route provider descriptor, or null if none.
+ * This object and all of its contents should be treated as if it were immutable
+ * so that it is safe for clients to cache it.
+ */
+ public final void setDescriptor(ProviderDescriptor descriptor) {
+ MediaRouter.checkCallingThread();
+
+ if (mDescriptor != descriptor) {
+ mDescriptor = descriptor;
+ if (!mPendingDescriptorChange) {
+ mPendingDescriptorChange = true;
+ mHandler.sendEmptyMessage(MSG_DELIVER_DESCRIPTOR_CHANGED);
+ }
+ }
+ }
+
+ private void deliverDescriptorChanged() {
+ mPendingDescriptorChange = false;
+
+ if (!mCallbacks.isEmpty()) {
+ final ProviderDescriptor currentDescriptor = mDescriptor;
+ for (Callback callback : mCallbacks) {
+ callback.onDescriptorChanged(this, currentDescriptor);
+ }
+ }
+ }
+
+ /**
+ * Adds a callback to be invoked on the main thread when information about a route
+ * provider and its routes changes.
+ *
+ * @param callback The callback to add.
+ */
+ public final void addCallback(Callback callback) {
+ if (callback == null) {
+ throw new IllegalArgumentException("callback");
+ }
+
+ if (!mCallbacks.contains(callback)) {
+ mCallbacks.add(callback);
+ }
+ }
+
+ /**
+ * Removes a callback.
+ *
+ * @param callback The callback to remove.
+ */
+ public final void removeCallback(Callback callback) {
+ if (callback == null) {
+ throw new IllegalArgumentException("callback");
+ }
+
+ mCallbacks.remove(callback);
+ }
+
+ /**
+ * Called by the media router to obtain a route controller for a particular route.
+ * <p>
+ * The media router will invoke the {@link RouteController#onRelease} method of the route
+ * controller when it is no longer needed to allow it to free its resources.
+ * </p>
+ *
+ * @param routeId The unique id of the route.
+ * @return The route controller. Returns null if there is no such route or if the route
+ * cannot be controlled using the route controller interface.
+ */
+ public RouteController onCreateRouteController(String routeId) {
+ return null;
+ }
+
+ /**
+ * Describes immutable properties of the route provider itself.
+ */
+ static final class ProviderMetadata {
+ private final String mPackageName;
+
+ public ProviderMetadata(String packageName) {
+ if (TextUtils.isEmpty(packageName)) {
+ throw new IllegalArgumentException("packageName must not be null or empty");
+ }
+ mPackageName = packageName;
+ }
+
+ public String getPackageName() {
+ return mPackageName;
+ }
+ }
+
+ /**
+ * Describes the state of a media route provider and the routes that it publishes.
+ */
+ public static final class ProviderDescriptor {
+ private static final String KEY_ROUTES = "routes";
+
+ private final Bundle mBundle;
+ private RouteDescriptor[] mRoutes;
+
+ /**
+ * Creates a route provider descriptor.
+ */
+ public ProviderDescriptor() {
+ mBundle = new Bundle();
+ }
+
+ /**
+ * Creates a copy of another route provider descriptor.
+ */
+ public ProviderDescriptor(ProviderDescriptor other) {
+ mBundle = new Bundle(other.mBundle);
+ }
+
+ ProviderDescriptor(Bundle bundle) {
+ mBundle = bundle;
+ }
+
+ /**
+ * Gets the list of all routes that this provider has published.
+ */
+ public RouteDescriptor[] getRoutes() {
+ if (mRoutes == null) {
+ mRoutes = RouteDescriptor.fromParcelableArray(
+ mBundle.getParcelableArray(KEY_ROUTES));
+ }
+ return mRoutes;
+ }
+
+ /**
+ * Sets the list of all routes that this provider has published.
+ */
+ public void setRoutes(RouteDescriptor[] routes) {
+ if (routes == null) {
+ throw new IllegalArgumentException("routes must not be null");
+ }
+ mRoutes = routes;
+ mBundle.putParcelableArray(KEY_ROUTES, RouteDescriptor.toParcelableArray(routes));
+ }
+
+ /**
+ * Returns true if the route provider descriptor and all of the routes that
+ * it contains have all of the required fields.
+ * <p>
+ * This verification is deep. If the provider descriptor is known to be
+ * valid then it is not necessary to call {@link #isValid} on each of its routes.
+ * </p>
+ */
+ public boolean isValid() {
+ for (RouteDescriptor route : getRoutes()) {
+ if (route == null || !route.isValid()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "RouteProviderDescriptor{" + mBundle.toString() + "}";
+ }
+
+ Bundle asBundle() {
+ return mBundle;
+ }
+
+ static ProviderDescriptor fromBundle(Bundle bundle) {
+ return bundle != null ? new ProviderDescriptor(bundle) : null;
+ }
+ }
+
+ /**
+ * Describes the properties of a route.
+ * <p>
+ * Each route is uniquely identified by an opaque id string. This token
+ * may take any form as long as it is unique within the media route provider.
+ * </p>
+ */
+ public static final class RouteDescriptor {
+ static final RouteDescriptor[] EMPTY_ROUTE_ARRAY = new RouteDescriptor[0];
+ static final IntentFilter[] EMTPY_FILTER_ARRAY = new IntentFilter[0];
+
+ private static final String KEY_ID = "id";
+ private static final String KEY_NAME = "name";
+ private static final String KEY_STATUS = "status";
+ private static final String KEY_ICON_RESOURCE = "iconId";
+ private static final String KEY_ENABLED = "enabled";
+ private static final String KEY_CONTROL_FILTERS = "controlFilters";
+ private static final String KEY_PLAYBACK_TYPE = "playbackType";
+ private static final String KEY_PLAYBACK_STREAM = "playbackStream";
+ private static final String KEY_VOLUME = "volume";
+ private static final String KEY_VOLUME_MAX = "volumeMax";
+ private static final String KEY_VOLUME_HANDLING = "volumeHandling";
+ private static final String KEY_PRESENTATION_DISPLAY_ID = "presentationDisplayId";
+ private static final String KEY_EXTRAS = "extras";
+
+ private final Bundle mBundle;
+ private IntentFilter[] mControlFilters;
+ private Drawable mIconDrawable;
+
+ /**
+ * Creates a route descriptor.
+ *
+ * @param id The unique id of the route.
+ * @param name The user-friendly name of the route.
+ */
+ public RouteDescriptor(String id, String name) {
+ mBundle = new Bundle();
+ setId(id);
+ setName(name);
+ }
+
+ /**
+ * Creates a copy of another route descriptor.
+ */
+ public RouteDescriptor(RouteDescriptor other) {
+ mBundle = new Bundle(other.mBundle);
+ }
+
+ RouteDescriptor(Bundle bundle) {
+ mBundle = bundle;
+ }
+
+ /**
+ * Gets the unique id of the route.
+ */
+ public String getId() {
+ return mBundle.getString(KEY_ID);
+ }
+
+ /**
+ * Sets the unique id of the route.
+ */
+ public void setId(String id) {
+ mBundle.putString(KEY_ID, id);
+ }
+
+ /**
+ * Gets the user-friendly name of the route.
+ */
+ public String getName() {
+ return mBundle.getString(KEY_NAME);
+ }
+
+ /**
+ * Sets the user-friendly name of the route.
+ */
+ public void setName(String name) {
+ mBundle.putString(KEY_NAME, name);
+ }
+
+ /**
+ * Gets the user-friendly status of the route.
+ */
+ public String getStatus() {
+ return mBundle.getString(KEY_STATUS);
+ }
+
+ /**
+ * Sets the user-friendly status of the route.
+ */
+ public void setStatus(String status) {
+ mBundle.putString(KEY_STATUS, status);
+ }
+
+ /**
+ * Gets a drawable to display as the route's icon.
+ * <p>
+ * Because drawables cannot be transferred to other processes, this method may
+ * only be used by media route providers that reside in the same process
+ * as the application. When implementing a media route provider service, use
+ * {@link #getIconResource} instead.
+ * </p>
+ */
+ public Drawable getIconDrawable() {
+ return mIconDrawable;
+ }
+
+ /**
+ * Sets a drawable to display as the route's icon.
+ * <p>
+ * Because drawables cannot be transferred to other processes, this method may
+ * only be used by media route providers that reside in the same process
+ * as the application. When implementing a media route provider service, use
+ * {@link #setIconResource} instead.
+ * </p>
+ */
+ public void setIconDrawable(Drawable drawable) {
+ mIconDrawable = drawable;
+ }
+
+ /**
+ * Gets the id of a drawable resource to display as the route's icon.
+ * <p>
+ * The specified drawable resource id will be loaded from the media route
+ * provider's package.
+ * </p>
+ */
+ public int getIconResource() {
+ return mBundle.getInt(KEY_ICON_RESOURCE);
+ }
+
+ /**
+ * Sets the id of a drawable resource to display as the route's icon.
+ * <p>
+ * The specified drawable resource id will be loaded from the media route
+ * provider's package.
+ * </p>
+ */
+ public void setIconResource(int id) {
+ mBundle.putInt(KEY_ICON_RESOURCE, id);
+ }
+
+ /**
+ * Gets whether the route is enabled.
+ */
+ public boolean isEnabled() {
+ return mBundle.getBoolean(KEY_ENABLED, true);
+ }
+
+ /**
+ * Sets whether the route is enabled.
+ */
+ public void setEnabled(boolean enabled) {
+ mBundle.putBoolean(KEY_ENABLED, enabled);
+ }
+
+ /**
+ * Gets the route's {@link MediaControlIntent media control intent} filters.
+ */
+ public IntentFilter[] getControlFilters() {
+ if (mControlFilters == null) {
+ Parcelable[] filters = mBundle.getParcelableArray(KEY_CONTROL_FILTERS);
+ if (filters instanceof IntentFilter[]) {
+ mControlFilters = (IntentFilter[])filters;
+ } else if (filters != null && filters.length > 0) {
+ mControlFilters = new IntentFilter[filters.length];
+ System.arraycopy(filters, 0, mControlFilters, 0, filters.length);
+ } else {
+ mControlFilters = EMTPY_FILTER_ARRAY;
+ }
+ }
+ return mControlFilters;
+ }
+
+ /**
+ * Sets the route's {@link MediaControlIntent media control intent} filters.
+ */
+ public void setControlFilters(IntentFilter[] controlFilters) {
+ if (controlFilters == null) {
+ throw new IllegalArgumentException("controlFilters must not be null");
+ }
+ mControlFilters = controlFilters;
+ mBundle.putParcelableArray(KEY_CONTROL_FILTERS, controlFilters);
+ }
+
+ /**
+ * Gets the route's playback type.
+ */
+ public int getPlaybackType() {
+ return mBundle.getInt(KEY_PLAYBACK_TYPE, MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE);
+ }
+
+ /**
+ * Sets the route's playback type.
+ */
+ public void setPlaybackType(int playbackType) {
+ mBundle.putInt(KEY_PLAYBACK_TYPE, playbackType);
+ }
+
+ /**
+ * Gets the route's playback stream.
+ */
+ public int getPlaybackStream() {
+ return mBundle.getInt(KEY_PLAYBACK_STREAM, -1);
+ }
+
+ /**
+ * Sets the route's playback stream.
+ */
+ public void setPlaybackStream(int playbackStream) {
+ mBundle.putInt(KEY_PLAYBACK_STREAM, playbackStream);
+ }
+
+ /**
+ * Gets the route's current volume, or 0 if unknown.
+ */
+ public int getVolume() {
+ return mBundle.getInt(KEY_VOLUME);
+ }
+
+ /**
+ * Sets the route's current volume, or 0 if unknown.
+ */
+ public void setVolume(int volume) {
+ mBundle.putInt(KEY_VOLUME, volume);
+ }
+
+ /**
+ * Gets the route's maximum volume, or 0 if unknown.
+ */
+ public int getVolumeMax() {
+ return mBundle.getInt(KEY_VOLUME_MAX);
+ }
+
+ /**
+ * Sets the route's maximum volume, or 0 if unknown.
+ */
+ public void setVolumeMax(int volumeMax) {
+ mBundle.putInt(KEY_VOLUME_MAX, volumeMax);
+ }
+
+ /**
+ * Gets the route's volume handling.
+ */
+ public int getVolumeHandling() {
+ return mBundle.getInt(KEY_VOLUME_HANDLING,
+ MediaRouter.RouteInfo.PLAYBACK_VOLUME_FIXED);
+ }
+
+ /**
+ * Sets the route's volume handling.
+ */
+ public void setVolumeHandling(int volumeHandling) {
+ mBundle.putInt(KEY_VOLUME_HANDLING, volumeHandling);
+ }
+
+ /**
+ * Gets the route's presentation display id, or -1 if none.
+ */
+ public int getPresentationDisplayId() {
+ return mBundle.getInt(KEY_PRESENTATION_DISPLAY_ID, -1);
+ }
+
+ /**
+ * Sets the route's presentation display id, or -1 if none.
+ */
+ public void setPresentationDisplayId(int presentationDisplayId) {
+ mBundle.putInt(KEY_PRESENTATION_DISPLAY_ID, presentationDisplayId);
+ }
+
+ /**
+ * Gets a bundle of extras for this route descriptor.
+ * The extras will be ignored by the media router but they may be used
+ * by applications.
+ */
+ public Bundle getExtras() {
+ return mBundle.getBundle(KEY_EXTRAS);
+ }
+
+ /**
+ * Sets a bundle of extras for this route descriptor.
+ * The extras will be ignored by the media router but they may be used
+ * by applications.
+ */
+ public void setExtras(Bundle extras) {
+ mBundle.putBundle(KEY_EXTRAS, extras);
+ }
+
+ /**
+ * Returns true if the route descriptor has all of the required fields.
+ */
+ public boolean isValid() {
+ if (TextUtils.isEmpty(getId())
+ || TextUtils.isEmpty(getName())) {
+ return false;
+ }
+ for (IntentFilter filter : getControlFilters()) {
+ if (filter == null) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "RouteDescriptor{" + mBundle.toString() + "}";
+ }
+
+ Bundle asBundle() {
+ return mBundle;
+ }
+
+ static Parcelable[] toParcelableArray(RouteDescriptor[] descriptors) {
+ if (descriptors != null && descriptors.length > 0) {
+ Parcelable[] bundles = new Parcelable[descriptors.length];
+ for (int i = 0; i < descriptors.length; i++) {
+ bundles[i] = descriptors[i].asBundle();
+ }
+ return bundles;
+ }
+ return null;
+ }
+
+ static RouteDescriptor[] fromParcelableArray(Parcelable[] bundles) {
+ if (bundles != null && bundles.length > 0) {
+ RouteDescriptor[] descriptors = new RouteDescriptor[bundles.length];
+ for (int i = 0; i < bundles.length; i++) {
+ descriptors[i] = new RouteDescriptor((Bundle)bundles[i]);
+ }
+ return descriptors;
+ }
+ return EMPTY_ROUTE_ARRAY;
+ }
+ }
+
+ /**
+ * Provides control over a particular route.
+ * <p>
+ * The media router obtains a route controller for a route whenever it needs
+ * to control a route. When a route is selected, the media router invokes
+ * the {@link #onSelect} method of its route controller. While selected,
+ * the media router may call other methods of the route controller to
+ * request that it perform certain actions to the route. When a route is
+ * unselected, the media router invokes the {@link #onUnselect} method of its
+ * route controller. When the media route no longer needs the route controller
+ * it will invoke the {@link #onRelease} method to allow the route controller
+ * to free its resources.
+ * </p><p>
+ * There may be multiple route controllers simultaneously active for the
+ * same route. Each route controller will be released separately.
+ * </p><p>
+ * All operations on the route controller are asynchronous and
+ * results are communicated via callbacks.
+ * </p>
+ */
+ public static abstract class RouteController {
+ /**
+ * Releases the route controller, allowing it to free its resources.
+ */
+ public void onRelease() {
+ }
+
+ /**
+ * Selects the route.
+ */
+ public void onSelect() {
+ }
+
+ /**
+ * Unselects the route.
+ */
+ public void onUnselect() {
+ }
+
+ /**
+ * Requests to set the volume of the route.
+ *
+ * @param volume The new volume value between 0 and {@link RouteDescriptor#getVolumeMax}.
+ */
+ public void onSetVolume(int volume) {
+ }
+
+ /**
+ * Requests an incremental volume update for the route.
+ *
+ * @param delta The delta to add to the current volume.
+ */
+ public void onUpdateVolume(int delta) {
+ }
+
+ /**
+ * Performs a {@link MediaControlIntent media control} request
+ * asynchronously on behalf of the route.
+ *
+ * @param intent A {@link MediaControlIntent media control intent}.
+ * @param callback A {@link ControlRequestCallback} to invoke with the result
+ * of the request, or null if no result is required.
+ * @return True if the controller intends to handle the request and will
+ * invoke the callback when finished. False if the contorller will not
+ * handle the request and will not invoke the callback.
+ *
+ * @see MediaControlIntent
+ */
+ public boolean onControlRequest(Intent intent, ControlRequestCallback callback) {
+ return false;
+ }
+ }
+
+ /**
+ * Callback which is invoked when route information becomes available or changes.
+ */
+ public static abstract class Callback {
+ /**
+ * Called when information about a route provider and its routes changes.
+ *
+ * @param provider The media route provider that changed.
+ * and all of its contents should be treated as if it were immutable so that it is
+ * safe for clients to cache it.
+ */
+ public void onDescriptorChanged(MediaRouteProvider provider,
+ ProviderDescriptor descriptor) {
+ }
+ }
+
+ private final class ProviderHandler extends Handler {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case MSG_DELIVER_DESCRIPTOR_CHANGED:
+ deliverDescriptorChanged();
+ break;
+ }
+ }
+ }
+}
diff --git a/v7/mediarouter/src/android/support/v7/media/MediaRouteProviderService.java b/v7/mediarouter/src/android/support/v7/media/MediaRouteProviderService.java
new file mode 100644
index 0000000..8f1da51
--- /dev/null
+++ b/v7/mediarouter/src/android/support/v7/media/MediaRouteProviderService.java
@@ -0,0 +1,739 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.media;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.IBinder.DeathRecipient;
+import android.os.Bundle;
+import android.os.DeadObjectException;
+import android.os.Message;
+import android.os.Messenger;
+import android.os.RemoteException;
+import android.support.v7.media.MediaRouteProvider.ProviderDescriptor;
+import android.util.Log;
+import android.util.SparseArray;
+
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+
+/**
+ * Base class for media route provider services.
+ * <p>
+ * To implement your own media route provider service, extend this class and
+ * override the {@link #onCreateMediaRouteProvider} method to return an
+ * instance of your {@link MediaRouteProvider}.
+ * </p><p>
+ * Declare your media route provider service in your application manifest
+ * like this:
+ * </p>
+ * <pre>
+ * <service android:name=".MyMediaRouteProviderService"
+ * android:label="@string/my_media_route_provider_service">
+ * <intent-filter>
+ * <action android:name="android.media.MediaRouteProviderService" />
+ * </intent-filter>
+ * </service>
+ * </pre>
+ */
+public abstract class MediaRouteProviderService extends Service {
+ private static final String TAG = "MediaRouteProviderService";
+ private static final boolean DEBUG = true;
+
+ private final ArrayList<ClientRecord> mClients = new ArrayList<ClientRecord>();
+ private final ReceiveHandler mReceiveHandler;
+ private final Messenger mReceiveMessenger;
+ private final PrivateHandler mPrivateHandler;
+ private final ProviderCallback mProviderCallback;
+
+ private MediaRouteProvider mProvider;
+
+ /**
+ * The {@link Intent} that must be declared as handled by the service.
+ * Put this in your manifest.
+ */
+ public static final String SERVICE_INTERFACE =
+ "android.media.MediaRouteProviderService";
+
+ /*
+ * Messages sent from the client to the service.
+ * DO NOT RENUMBER THESE!
+ */
+
+ /** (client v1)
+ * Register client.
+ * - replyTo : client messenger
+ * - arg1 : request id
+ * - arg2 : client version
+ */
+ static final int CLIENT_MSG_REGISTER = 1;
+
+ /** (client v1)
+ * Unregister client.
+ * - replyTo : client messenger
+ * - arg1 : request id
+ */
+ static final int CLIENT_MSG_UNREGISTER = 2;
+
+ /** (client v1)
+ * Create route controller.
+ * - replyTo : client messenger
+ * - arg1 : request id
+ * - arg2 : route controller id
+ * - CLIENT_DATA_ROUTE_ID : route id string
+ */
+ static final int CLIENT_MSG_CREATE_ROUTE_CONTROLLER = 3;
+
+ /** (client v1)
+ * Release route controller.
+ * - replyTo : client messenger
+ * - arg1 : request id
+ * - arg2 : route controller id
+ */
+ static final int CLIENT_MSG_RELEASE_ROUTE_CONTROLLER = 4;
+
+ /** (client v1)
+ * Select route.
+ * - replyTo : client messenger
+ * - arg1 : request id
+ * - arg2 : route controller id
+ */
+ static final int CLIENT_MSG_SELECT_ROUTE = 5;
+
+ /** (client v1)
+ * Unselect route.
+ * - replyTo : client messenger
+ * - arg1 : request id
+ * - arg2 : route controller id
+ */
+ static final int CLIENT_MSG_UNSELECT_ROUTE = 6;
+
+ /** (client v1)
+ * Set route volume.
+ * - replyTo : client messenger
+ * - arg1 : request id
+ * - arg2 : route controller id
+ * - CLIENT_DATA_VOLUME : volume integer
+ */
+ static final int CLIENT_MSG_SET_ROUTE_VOLUME = 7;
+
+ /** (client v1)
+ * Update route volume.
+ * - replyTo : client messenger
+ * - arg1 : request id
+ * - arg2 : route controller id
+ * - CLIENT_DATA_VOLUME : volume delta integer
+ */
+ static final int CLIENT_MSG_UPDATE_ROUTE_VOLUME = 8;
+
+ /** (client v1)
+ * Route control request.
+ * - replyTo : client messenger
+ * - arg1 : request id
+ * - arg2 : route controller id
+ * - obj : media control intent
+ */
+ static final int CLIENT_MSG_ROUTE_CONTROL_REQUEST = 9;
+
+ static final String CLIENT_DATA_ROUTE_ID = "routeId";
+ static final String CLIENT_DATA_VOLUME = "volume";
+
+ /*
+ * Messages sent from the service to the client.
+ * DO NOT RENUMBER THESE!
+ */
+
+ /** (service v1)
+ * Generic failure sent in response to any unrecognized or malformed request.
+ * - arg1 : request id
+ */
+ static final int SERVICE_MSG_GENERIC_FAILURE = 0;
+
+ /** (service v1)
+ * Generic failure sent in response to a successful message.
+ * - arg1 : request id
+ */
+ static final int SERVICE_MSG_GENERIC_SUCCESS = 1;
+
+ /** (service v1)
+ * Registration succeeded.
+ * - arg1 : request id
+ * - arg2 : server version
+ * - obj : route provider descriptor bundle, or null
+ */
+ static final int SERVICE_MSG_REGISTERED = 2;
+
+ /** (service v1)
+ * Route control request result.
+ * - arg1 : request id
+ * - arg2 : result code
+ * - obj : result data bundle, or null
+ */
+ static final int SERVICE_MSG_CONTROL_RESULT = 3;
+
+ /** (service v1)
+ * Route provider descriptor changed. (unsolicited event)
+ * - arg1 : reserved (0)
+ * - obj : route provider descriptor bundle, or null
+ */
+ static final int SERVICE_MSG_DESCRIPTOR_CHANGED = 4;
+
+ /*
+ * Recognized client version numbers. (Reserved for future use.)
+ * DO NOT RENUMBER THESE!
+ */
+
+ static final int CLIENT_VERSION_1 = 1;
+ static final int CLIENT_VERSION_CURRENT = CLIENT_VERSION_1;
+
+ /*
+ * Recognized server version numbers. (Reserved for future use.)
+ * DO NOT RENUMBER THESE!
+ */
+
+ static final int SERVICE_VERSION_1 = 1;
+ static final int SERVICE_VERSION_CURRENT = SERVICE_VERSION_1;
+
+ /*
+ * Private messages used internally. (Yes, you can renumber these.)
+ */
+
+ private static final int PRIVATE_MSG_CLIENT_DIED = 1;
+
+ /**
+ * Creates a media route provider service.
+ */
+ public MediaRouteProviderService() {
+ mReceiveHandler = new ReceiveHandler(this);
+ mReceiveMessenger = new Messenger(mReceiveHandler);
+ mPrivateHandler = new PrivateHandler();
+ mProviderCallback = new ProviderCallback();
+ }
+
+ /**
+ * Called by the system when it is time to create the media route provider.
+ *
+ * @return The media route provider offered by this service, or null if
+ * this service has decided not to offer a media route provider.
+ */
+ public abstract MediaRouteProvider onCreateMediaRouteProvider();
+
+ /**
+ * Gets the media route provider offered by this service.
+ *
+ * @return The media route provider offered by this service, or null if
+ * it has not yet been created.
+ *
+ * @see #onCreateMediaRouteProvider()
+ */
+ public MediaRouteProvider getMediaRouteProvider() {
+ return mProvider;
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ if (intent.getAction().equals(SERVICE_INTERFACE)) {
+ if (mProvider == null) {
+ MediaRouteProvider provider = onCreateMediaRouteProvider();
+ if (provider != null) {
+ String providerPackage = provider.getMetadata().getPackageName();
+ if (!providerPackage.equals(getPackageName())) {
+ throw new IllegalStateException("onCreateMediaRouteProvider() returned "
+ + "a provider whose package name does not match the package "
+ + "name of the service. A media route provider service can "
+ + "only export its own media route providers. "
+ + "Provider package name: " + providerPackage
+ + ". Service package name: " + getPackageName() + ".");
+ }
+ mProvider = provider;
+ mProvider.addCallback(mProviderCallback);
+ }
+ }
+ if (mProvider != null) {
+ return mReceiveMessenger.getBinder();
+ }
+ }
+ return null;
+ }
+
+ private boolean onRegisterClient(Messenger messenger, int requestId, int version) {
+ if (version >= CLIENT_VERSION_1) {
+ int index = findClient(messenger);
+ if (index < 0) {
+ ClientRecord client = new ClientRecord(messenger, version);
+ if (client.register()) {
+ mClients.add(client);
+ if (DEBUG) {
+ Log.d(TAG, client + ": Registered, version=" + version);
+ }
+ if (requestId != 0) {
+ ProviderDescriptor descriptor = mProvider.getDescriptor();
+ sendReply(messenger, SERVICE_MSG_REGISTERED,
+ requestId, SERVICE_VERSION_CURRENT,
+ descriptor != null ? descriptor.asBundle() : null, null);
+ }
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean onUnregisterClient(Messenger messenger, int requestId) {
+ int index = findClient(messenger);
+ if (index >= 0) {
+ ClientRecord client = mClients.remove(index);
+ if (DEBUG) {
+ Log.d(TAG, client + ": Unregistered");
+ }
+ client.dispose();
+ sendGenericSuccess(messenger, requestId);
+ return true;
+ }
+ return false;
+ }
+
+ private void onBinderDied(Messenger messenger) {
+ int index = findClient(messenger);
+ if (index >= 0) {
+ ClientRecord client = mClients.remove(index);
+ if (DEBUG) {
+ Log.d(TAG, client + ": Binder died");
+ }
+ client.dispose();
+ }
+ }
+
+ private boolean onCreateRouteController(Messenger messenger, int requestId,
+ int controllerId, String routeId) {
+ ClientRecord client = getClient(messenger);
+ if (client != null) {
+ if (client.createRouteController(routeId, controllerId)) {
+ if (DEBUG) {
+ Log.d(TAG, client + ": Route controller created"
+ + ", controllerId=" + controllerId + ", routeId=" + routeId);
+ }
+ sendGenericSuccess(messenger, requestId);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean onReleaseRouteController(Messenger messenger, int requestId,
+ int controllerId) {
+ ClientRecord client = getClient(messenger);
+ if (client != null) {
+ if (client.releaseRouteController(controllerId)) {
+ if (DEBUG) {
+ Log.d(TAG, client + ": Route controller released"
+ + ", controllerId=" + controllerId);
+ }
+ sendGenericSuccess(messenger, requestId);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean onSelectRoute(Messenger messenger, int requestId,
+ int controllerId) {
+ ClientRecord client = getClient(messenger);
+ if (client != null) {
+ MediaRouteProvider.RouteController controller =
+ client.getRouteController(controllerId);
+ if (controller != null) {
+ controller.onSelect();
+ if (DEBUG) {
+ Log.d(TAG, client + ": Route selected"
+ + ", controllerId=" + controllerId);
+ }
+ sendGenericSuccess(messenger, requestId);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean onUnselectRoute(Messenger messenger, int requestId,
+ int controllerId) {
+ ClientRecord client = getClient(messenger);
+ if (client != null) {
+ MediaRouteProvider.RouteController controller =
+ client.getRouteController(controllerId);
+ if (controller != null) {
+ controller.onUnselect();
+ if (DEBUG) {
+ Log.d(TAG, client + ": Route unselected"
+ + ", controllerId=" + controllerId);
+ }
+ sendGenericSuccess(messenger, requestId);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean onSetRouteVolume(Messenger messenger, int requestId,
+ int controllerId, int volume) {
+ ClientRecord client = getClient(messenger);
+ if (client != null) {
+ MediaRouteProvider.RouteController controller =
+ client.getRouteController(controllerId);
+ if (controller != null) {
+ controller.onSetVolume(volume);
+ if (DEBUG) {
+ Log.d(TAG, client + ": Route volume changed"
+ + ", controllerId=" + controllerId + ", volume=" + volume);
+ }
+ sendGenericSuccess(messenger, requestId);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean onUpdateRouteVolume(Messenger messenger, int requestId,
+ int controllerId, int delta) {
+ ClientRecord client = getClient(messenger);
+ if (client != null) {
+ MediaRouteProvider.RouteController controller =
+ client.getRouteController(controllerId);
+ if (controller != null) {
+ controller.onUpdateVolume(delta);
+ if (DEBUG) {
+ Log.d(TAG, client + ": Route volume updated"
+ + ", controllerId=" + controllerId + ", delta=" + delta);
+ }
+ sendGenericSuccess(messenger, requestId);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean onRouteControlRequest(final Messenger messenger, final int requestId,
+ final int controllerId, final Intent intent) {
+ final ClientRecord client = getClient(messenger);
+ if (client != null) {
+ MediaRouteProvider.RouteController controller =
+ client.getRouteController(controllerId);
+ if (controller != null) {
+ MediaRouter.ControlRequestCallback callback = null;
+ if (requestId != 0) {
+ callback = new MediaRouter.ControlRequestCallback() {
+ @Override
+ public void onResult(int result, Bundle data) {
+ if (DEBUG) {
+ Log.d(TAG, client + ": Route control request finished"
+ + ", controllerId=" + controllerId
+ + ", intent=" + intent
+ + ", result=" + result + ", data=" + data);
+ }
+ if (findClient(messenger) >= 0) {
+ sendReply(messenger, SERVICE_MSG_CONTROL_RESULT,
+ requestId, result, data, null);
+ }
+ }
+ };
+ }
+ if (controller.onControlRequest(intent, callback)) {
+ if (DEBUG) {
+ Log.d(TAG, client + ": Route control request delivered"
+ + ", controllerId=" + controllerId + ", intent=" + intent);
+ }
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private void sendDescriptorChanged(MediaRouteProvider.ProviderDescriptor descriptor) {
+ Bundle descriptorBundle = descriptor != null ? descriptor.asBundle() : null;
+ final int count = mClients.size();
+ for (int i = 0; i < count; i++) {
+ ClientRecord client = mClients.get(i);
+ sendReply(client.mMessenger, SERVICE_MSG_DESCRIPTOR_CHANGED, 0, 0,
+ descriptorBundle, null);
+ if (DEBUG) {
+ Log.d(TAG, client + ": Sent descriptor change event, descriptor=" + descriptor);
+ }
+ }
+ }
+
+ private ClientRecord getClient(Messenger messenger) {
+ int index = findClient(messenger);
+ return index >= 0 ? mClients.get(index) : null;
+ }
+
+ private int findClient(Messenger messenger) {
+ final int count = mClients.size();
+ for (int i = 0; i < count; i++) {
+ ClientRecord client = mClients.get(i);
+ if (client.hasMessenger(messenger)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ private static void sendGenericFailure(Messenger messenger, int requestId) {
+ if (requestId != 0) {
+ sendReply(messenger, SERVICE_MSG_GENERIC_FAILURE, requestId, 0, null, null);
+ }
+ }
+
+ private static void sendGenericSuccess(Messenger messenger, int requestId) {
+ if (requestId != 0) {
+ sendReply(messenger, SERVICE_MSG_GENERIC_SUCCESS, requestId, 0, null, null);
+ }
+ }
+
+ private static void sendReply(Messenger messenger, int what,
+ int requestId, int arg, Object obj, Bundle data) {
+ Message msg = Message.obtain();
+ msg.what = what;
+ msg.arg1 = requestId;
+ msg.arg2 = arg;
+ msg.obj = obj;
+ msg.setData(data);
+ try {
+ messenger.send(msg);
+ } catch (DeadObjectException ex) {
+ // The client died.
+ } catch (RemoteException ex) {
+ Log.e(TAG, "Could not send message to " + getClientId(messenger), ex);
+ }
+ }
+
+ private static String getClientId(Messenger messenger) {
+ return "Client connection " + messenger.getBinder().toString();
+ }
+
+ /**
+ * Returns true if the messenger object is valid.
+ * <p>
+ * The messenger contructor and unparceling code does not check whether the
+ * provided IBinder is a valid IMessenger object. As a result, it's possible
+ * for a peer to send an invalid IBinder that will result in crashes downstream.
+ * This method checks that the messenger is in a valid state.
+ * </p>
+ */
+ static boolean isValidRemoteMessenger(Messenger messenger) {
+ try {
+ return messenger != null && messenger.getBinder() != null;
+ } catch (NullPointerException ex) {
+ // If the messenger was constructed with a binder interface other than
+ // IMessenger then the call to getBinder() will crash with an NPE.
+ return false;
+ }
+ }
+
+ private final class PrivateHandler extends Handler {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case PRIVATE_MSG_CLIENT_DIED:
+ onBinderDied((Messenger)msg.obj);
+ break;
+ }
+ }
+ }
+
+ private final class ProviderCallback extends MediaRouteProvider.Callback {
+ @Override
+ public void onDescriptorChanged(MediaRouteProvider provider,
+ ProviderDescriptor descriptor) {
+ sendDescriptorChanged(descriptor);
+ }
+ }
+
+ private final class ClientRecord implements DeathRecipient {
+ public final Messenger mMessenger;
+ public final int mVersion;
+
+ private final SparseArray<MediaRouteProvider.RouteController> mControllers =
+ new SparseArray<MediaRouteProvider.RouteController>();
+
+ public ClientRecord(Messenger messenger, int version) {
+ mMessenger = messenger;
+ mVersion = version;
+ }
+
+ public boolean register() {
+ try {
+ mMessenger.getBinder().linkToDeath(this, 0);
+ return true;
+ } catch (RemoteException ex) {
+ binderDied();
+ }
+ return false;
+ }
+
+ public void dispose() {
+ int count = mControllers.size();
+ for (int i = 0; i < count; i++) {
+ mControllers.valueAt(i).onRelease();
+ }
+ mControllers.clear();
+
+ mMessenger.getBinder().unlinkToDeath(this, 0);
+ }
+
+ public boolean hasMessenger(Messenger other) {
+ return mMessenger.getBinder() == other.getBinder();
+ }
+
+ public boolean createRouteController(String routeId, int controllerId) {
+ if (mControllers.indexOfKey(controllerId) < 0) {
+ MediaRouteProvider.RouteController controller =
+ mProvider.onCreateRouteController(routeId);
+ mControllers.put(controllerId, controller);
+ return true;
+ }
+ return false;
+ }
+
+ public boolean releaseRouteController(int controllerId) {
+ MediaRouteProvider.RouteController controller = mControllers.get(controllerId);
+ if (controller != null) {
+ mControllers.remove(controllerId);
+ controller.onRelease();
+ return true;
+ }
+ return false;
+ }
+
+ public MediaRouteProvider.RouteController getRouteController(int controllerId) {
+ return mControllers.get(controllerId);
+ }
+
+ @Override
+ public void binderDied() {
+ mPrivateHandler.obtainMessage(PRIVATE_MSG_CLIENT_DIED, mMessenger).sendToTarget();
+ }
+
+ @Override
+ public String toString() {
+ return getClientId(mMessenger);
+ }
+ }
+
+ /**
+ * Handler that receives messages from clients.
+ * <p>
+ * This inner class is static and only retains a weak reference to the service
+ * to prevent the service from being leaked in case one of the clients is holding an
+ * active reference to the server's messenger.
+ * </p><p>
+ * This handler should not be used to handle any messages other than those
+ * that come from the client.
+ * </p>
+ */
+ private static final class ReceiveHandler extends Handler {
+ private final WeakReference<MediaRouteProviderService> mServiceRef;
+
+ public ReceiveHandler(MediaRouteProviderService service) {
+ mServiceRef = new WeakReference<MediaRouteProviderService>(service);
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ final Messenger messenger = msg.replyTo;
+ if (isValidRemoteMessenger(messenger)) {
+ final int what = msg.what;
+ final int requestId = msg.arg1;
+ final int arg = msg.arg2;
+ final Object obj = msg.obj;
+ final Bundle data = msg.peekData();
+ if (!processMessage(what, messenger, requestId, arg, obj, data)) {
+ if (DEBUG) {
+ Log.d(TAG, getClientId(messenger) + ": Message failed, what=" + what
+ + ", requestId=" + requestId + ", arg=" + arg
+ + ", obj=" + obj + ", data=" + data);
+ }
+ sendGenericFailure(messenger, requestId);
+ }
+ } else {
+ if (DEBUG) {
+ Log.d(TAG, "Ignoring message without valid reply messenger.");
+ }
+ }
+ }
+
+ private boolean processMessage(int what,
+ Messenger messenger, int requestId, int arg, Object obj, Bundle data) {
+ MediaRouteProviderService service = mServiceRef.get();
+ if (service != null) {
+ switch (what) {
+ case CLIENT_MSG_REGISTER:
+ return service.onRegisterClient(messenger, requestId, arg);
+
+ case CLIENT_MSG_UNREGISTER:
+ return service.onUnregisterClient(messenger, requestId);
+
+ case CLIENT_MSG_CREATE_ROUTE_CONTROLLER: {
+ String routeId = data.getString(CLIENT_DATA_ROUTE_ID);
+ if (routeId != null) {
+ return service.onCreateRouteController(
+ messenger, requestId, arg, routeId);
+ }
+ break;
+ }
+
+ case CLIENT_MSG_RELEASE_ROUTE_CONTROLLER:
+ return service.onReleaseRouteController(messenger, requestId, arg);
+
+ case CLIENT_MSG_SELECT_ROUTE:
+ return service.onSelectRoute(messenger, requestId, arg);
+
+ case CLIENT_MSG_UNSELECT_ROUTE:
+ return service.onUnselectRoute(messenger, requestId, arg);
+
+ case CLIENT_MSG_SET_ROUTE_VOLUME: {
+ int volume = data.getInt(CLIENT_DATA_VOLUME, -1);
+ if (volume >= 0) {
+ return service.onSetRouteVolume(
+ messenger, requestId, arg, volume);
+ }
+ break;
+ }
+
+ case CLIENT_MSG_UPDATE_ROUTE_VOLUME: {
+ int delta = data.getInt(CLIENT_DATA_VOLUME, 0);
+ if (delta != 0) {
+ return service.onUpdateRouteVolume(
+ messenger, requestId, arg, delta);
+ }
+ break;
+ }
+
+ case CLIENT_MSG_ROUTE_CONTROL_REQUEST:
+ if (obj instanceof Intent) {
+ return service.onRouteControlRequest(
+ messenger, requestId, arg, (Intent)obj);
+ }
+ break;
+ }
+ }
+ return false;
+ }
+ }
+}
diff --git a/v7/mediarouter/src/android/support/v7/media/MediaRouter.java b/v7/mediarouter/src/android/support/v7/media/MediaRouter.java
new file mode 100644
index 0000000..09122e1
--- /dev/null
+++ b/v7/mediarouter/src/android/support/v7/media/MediaRouter.java
@@ -0,0 +1,1415 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.media;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.Resources;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
+import android.support.v4.hardware.display.DisplayManagerCompat;
+import android.support.v7.media.MediaRouteProvider.RouteDescriptor;
+import android.support.v7.media.MediaRouteProvider.ProviderDescriptor;
+import android.support.v7.media.MediaRouteProvider.ProviderMetadata;
+import android.util.Log;
+import android.view.Display;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.WeakHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+/**
+ * MediaRouter allows applications to control the routing of media channels
+ * and streams from the current device to external speakers and destination devices.
+ * <p>
+ * A MediaRouter instance is retrieved through {@link #getInstance}. Applications
+ * can query the media router about the currently selected route and its capabilities
+ * to determine how to send content to the route's destination. Applications can
+ * also {@link RouteInfo#sendControlRequest send control requests} to the route
+ * to ask the route's destination to perform certain remote control functions
+ * such as playing media.
+ * </p><p>
+ * See also {@link MediaRouteProvider} for information on how an application
+ * can publish new media routes to the media router.
+ * </p><p>
+ * The media router API is not thread-safe; all interactions with it must be
+ * done from the main thread of the process.
+ * </p>
+ */
+public final class MediaRouter {
+ private static final String TAG = "MediaRouter";
+
+ // Maintains global media router state for the process.
+ // This field is initialized in MediaRouter.getInstance() before any
+ // MediaRouter objects are instantiated so it is guaranteed to be
+ // valid whenever any instance method is invoked.
+ static GlobalMediaRouter sGlobal;
+
+ // Context-bound state of the media router.
+ final Context mContext;
+ final CopyOnWriteArrayList<Callback> mCallbacks = new CopyOnWriteArrayList<Callback>();
+
+ MediaRouter(Context context) {
+ mContext = context;
+ }
+
+ /**
+ * Gets an instance of the media router service from the context.
+ */
+ public static MediaRouter getInstance(Context context) {
+ if (context == null) {
+ throw new IllegalArgumentException("context must not be null");
+ }
+ checkCallingThread();
+
+ if (sGlobal == null) {
+ sGlobal = new GlobalMediaRouter(context.getApplicationContext());
+ sGlobal.start();
+ }
+ return sGlobal.getRouter(context);
+ }
+
+ /**
+ * Gets information about the {@link MediaRouter.RouteInfo routes} currently known to
+ * this media router.
+ */
+ public List<RouteInfo> getRoutes() {
+ checkCallingThread();
+ return sGlobal.getRoutes();
+ }
+
+ /**
+ * Gets information about the {@link MediaRouter.ProviderInfo route providers}
+ * currently known to this media router.
+ */
+ public List<ProviderInfo> getProviders() {
+ checkCallingThread();
+ return sGlobal.getProviders();
+ }
+
+ /**
+ * Gets the default route for playing media content on the system.
+ * <p>
+ * The system always provides a default route.
+ * </p>
+ *
+ * @return The default route, which is guaranteed to never be null.
+ */
+ public RouteInfo getDefaultRoute() {
+ checkCallingThread();
+ return sGlobal.getDefaultRoute();
+ }
+
+ /**
+ * Gets the currently selected route.
+ * <p>
+ * The application should examine the route's
+ * {@link RouteInfo#getControlFilters media control intent filters} to assess the
+ * capabilities of the route before attempting to use it.
+ * </p>
+ *
+ * <h3>Example</h3>
+ * <pre>
+ * public boolean playMovie() {
+ * MediaRouter mediaRouter = MediaRouter.getInstance(context);
+ * MediaRouter.RouteInfo route = mediaRouter.getSelectedRoute();
+ *
+ * // First try using the remote playback interface, if supported.
+ * if (route.supportsControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)) {
+ * // The route supports remote playback.
+ * // Try to send it the Uri of the movie to play.
+ * Intent intent = new Intent(MediaControlIntent.ACTION_PLAY);
+ * intent.addCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK);
+ * intent.setDataAndType("http://example.com/videos/movie.mp4", "video/mp4");
+ * if (route.supportsControlRequest(intent)) {
+ * route.sendControlRequest(intent, null);
+ * return true; // sent the request to play the movie
+ * }
+ * }
+ *
+ * // If remote playback was not possible, then play locally.
+ * if (route.supportsControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO)) {
+ * // The route supports live video streaming.
+ * // Prepare to play content locally in a window or in a presentation.
+ * return playMovieInWindow();
+ * }
+ *
+ * // Neither interface is supported, so we can't play the movie to this route.
+ * return false;
+ * }
+ * </pre>
+ *
+ * @return The selected route, which is guaranteed to never be null.
+ *
+ * @see RouteInfo#getControlFilters
+ * @see RouteInfo#supportsControlCategory
+ * @see RouteInfo#supportsControlRequest
+ */
+ public RouteInfo getSelectedRoute() {
+ checkCallingThread();
+ return sGlobal.getSelectedRoute();
+ }
+
+ /**
+ * Selects the specified route.
+ *
+ * @param route The route to select.
+ */
+ public void selectRoute(RouteInfo route) {
+ if (route == null) {
+ throw new IllegalArgumentException("route must not be null");
+ }
+ checkCallingThread();
+
+ sGlobal.selectRoute(route);
+ }
+
+ /**
+ * Adds a callback to listen to changes to media routes.
+ *
+ * @param callback The callback to add.
+ */
+ public void addCallback(Callback callback) {
+ if (callback == null) {
+ throw new IllegalArgumentException("callback must not be null");
+ }
+ checkCallingThread();
+
+ if (!mCallbacks.contains(callback)) {
+ mCallbacks.add(callback);
+ }
+ }
+
+ /**
+ * Removes the specified callback. It will no longer receive information about
+ * changes to media routes.
+ *
+ * @param callback The callback to remove.
+ */
+ public void removeCallback(Callback callback) {
+ if (callback == null) {
+ throw new IllegalArgumentException("callback must not be null");
+ }
+ checkCallingThread();
+
+ mCallbacks.remove(callback);
+ }
+
+ /**
+ * Registers a media route provider globally for this application process.
+ *
+ * @param providerInstance The media route provider instance to add.
+ *
+ * @see MediaRouteProvider
+ */
+ public void addProvider(MediaRouteProvider providerInstance) {
+ if (providerInstance == null) {
+ throw new IllegalArgumentException("providerInstance must not be null");
+ }
+ checkCallingThread();
+
+ sGlobal.addProvider(providerInstance);
+ }
+
+ /**
+ * Unregisters a media route provider globally for this application process.
+ *
+ * @param providerInstance The media route provider instance to remove.
+ *
+ * @see MediaRouteProvider
+ */
+ public void removeProvider(MediaRouteProvider providerInstance) {
+ if (providerInstance == null) {
+ throw new IllegalArgumentException("providerInstance must not be null");
+ }
+ checkCallingThread();
+
+ sGlobal.removeProvider(providerInstance);
+ }
+
+ /**
+ * Ensures that calls into the media router are on the correct thread.
+ * It pays to be a little paranoid when global state invariants are at risk.
+ */
+ static void checkCallingThread() {
+ if (Looper.myLooper() != Looper.getMainLooper()) {
+ throw new IllegalStateException("The media router service must only be "
+ + "accessed on the application's main thread.");
+ }
+ }
+
+ static <T> boolean equal(T a, T b) {
+ return a == b || (a != null && b != null && a.equals(b));
+ }
+
+ /**
+ * Provides information about a media route.
+ * <p>
+ * Each media route has a list of {@link MediaControlIntent media control}
+ * {@link #getControlFilters intent filters} that describe the capabilities of the
+ * route and the manner in which it is used and controlled.
+ * </p>
+ */
+ public static final class RouteInfo {
+ private final ProviderInfo mProvider;
+ private final String mDescriptorId;
+ private String mName;
+ private String mStatus;
+ private Drawable mIconDrawable;
+ private int mIconResource;
+ private boolean mEnabled;
+ private final ArrayList<IntentFilter> mControlFilters = new ArrayList<IntentFilter>();
+ private int mPlaybackType;
+ private int mPlaybackStream;
+ private int mVolumeHandling;
+ private int mVolume;
+ private int mVolumeMax;
+ private Display mPresentationDisplay;
+ private int mPresentationDisplayId = -1;
+ private Bundle mExtras;
+ private RouteDescriptor mDescriptor;
+
+ /**
+ * The default playback type, "local", indicating the presentation of the media
+ * is happening on the same device (e.g. a phone, a tablet) as where it is
+ * controlled from.
+ *
+ * @see #getPlaybackType
+ */
+ public static final int PLAYBACK_TYPE_LOCAL = 0;
+
+ /**
+ * A playback type indicating the presentation of the media is happening on
+ * a different device (i.e. the remote device) than where it is controlled from.
+ *
+ * @see #getPlaybackType
+ */
+ public static final int PLAYBACK_TYPE_REMOTE = 1;
+
+ /**
+ * Playback information indicating the playback volume is fixed, i.e. it cannot be
+ * controlled from this object. An example of fixed playback volume is a remote player,
+ * playing over HDMI where the user prefers to control the volume on the HDMI sink, rather
+ * than attenuate at the source.
+ *
+ * @see #getVolumeHandling
+ */
+ public static final int PLAYBACK_VOLUME_FIXED = 0;
+
+ /**
+ * Playback information indicating the playback volume is variable and can be controlled
+ * from this object.
+ *
+ * @see #getVolumeHandling
+ */
+ public static final int PLAYBACK_VOLUME_VARIABLE = 1;
+
+ static final int CHANGE_GENERAL = 1 << 0;
+ static final int CHANGE_VOLUME = 1 << 1;
+ static final int CHANGE_PRESENTATION_DISPLAY = 1 << 2;
+
+ RouteInfo(ProviderInfo provider, String descriptorId) {
+ mProvider = provider;
+ mDescriptorId = descriptorId;
+ }
+
+ /**
+ * Gets information about the provider of this media route.
+ */
+ public ProviderInfo getProvider() {
+ return mProvider;
+ }
+
+ /**
+ * Gets the name of this route.
+ *
+ * @return The user-friendly name of a media route. This is the string presented
+ * to users who may select this as the active route.
+ */
+ public String getName() {
+ return mName;
+ }
+
+ /**
+ * Gets the status of this route.
+ *
+ * @return The user-friendly status for a media route. This may include a description
+ * of the currently playing media, if available.
+ */
+ public String getStatus() {
+ return mStatus;
+ }
+
+ /**
+ * Get the icon representing this route.
+ * This icon will be used in picker UIs if available.
+ *
+ * @return The icon representing this route or null if no icon is available.
+ */
+ public Drawable getIconDrawable() {
+ checkCallingThread();
+ if (mIconDrawable == null) {
+ if (mIconResource != 0) {
+ Resources resources = mProvider.getResources();
+ if (resources != null) {
+ try {
+ mIconDrawable = resources.getDrawable(mIconResource);
+ } catch (Resources.NotFoundException ex) {
+ Log.w(TAG, "Unable to load media route icon drawable resource "
+ + "from provider.", ex);
+ }
+ }
+ }
+ }
+ return mIconDrawable;
+ }
+
+ /**
+ * Returns true if this route is enabled and may be selected.
+ *
+ * @return true if this route is enabled and may be selected.
+ */
+ public boolean isEnabled() {
+ return mEnabled;
+ }
+
+ /**
+ * Returns true if this route is currently selected.
+ *
+ * @return true if this route is currently selected.
+ *
+ * @see MediaRouter#getSelectedRoute
+ */
+ public boolean isSelected() {
+ checkCallingThread();
+ return sGlobal.getSelectedRoute() == this;
+ }
+
+ /**
+ * Returns true if this route is the default route.
+ *
+ * @return true if this route is the default route.
+ *
+ * @see MediaRouter#getDefaultRoute
+ */
+ public boolean isDefault() {
+ checkCallingThread();
+ return sGlobal.getDefaultRoute() == this;
+ }
+
+ /**
+ * Gets a list of {@link MediaControlIntent media control intent} filters that
+ * describe the capabilities of this route and the media control actions that
+ * it supports.
+ *
+ * @return A list of intent filters that specifies the media control intents that
+ * this route supports.
+ *
+ * @see MediaControlIntent
+ * @see #supportsControlCategory
+ * @see #supportsControlRequest
+ */
+ public List<IntentFilter> getControlFilters() {
+ return mControlFilters;
+ }
+
+ /**
+ * Returns true if the route supports the specified
+ * {@link MediaControlIntent media control} category.
+ * <p>
+ * Media control categories describe the capabilities of this route
+ * such as whether it supports live audio streaming or remote playback.
+ * </p>
+ *
+ * @param category A {@link MediaControlIntent media control} category
+ * such as {@link MediaControlIntent#CATEGORY_LIVE_AUDIO},
+ * {@link MediaControlIntent#CATEGORY_LIVE_VIDEO},
+ * {@link MediaControlIntent#CATEGORY_REMOTE_PLAYBACK}, or a provider-defined
+ * media control category.
+ *
+ * @see MediaControlIntent
+ * @see #getControlFilters
+ */
+ public boolean supportsControlCategory(String category) {
+ if (category == null) {
+ throw new IllegalArgumentException("category must not be null");
+ }
+ checkCallingThread();
+
+ int count = mControlFilters.size();
+ for (int i = 0; i < count; i++) {
+ if (mControlFilters.get(i).hasCategory(category)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns true if the route supports the specified
+ * {@link MediaControlIntent media control} request.
+ * <p>
+ * Media control requests are used to request the route to perform
+ * actions such as starting remote playback of a media item.
+ * </p>
+ *
+ * @param intent A {@link MediaControlIntent media control intent}.
+ * @return True if the route can handle the specified intent.
+ *
+ * @see MediaControlIntent
+ * @see #getControlFilters
+ */
+ public boolean supportsControlRequest(Intent intent) {
+ if (intent == null) {
+ throw new IllegalArgumentException("intent must not be null");
+ }
+ checkCallingThread();
+
+ ContentResolver contentResolver = sGlobal.getContentResolver();
+ int count = mControlFilters.size();
+ for (int i = 0; i < count; i++) {
+ if (mControlFilters.get(i).match(contentResolver, intent, true, TAG) >= 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Sends a {@link MediaControlIntent media control} request to be performed
+ * asynchronously by the route's destination.
+ * <p>
+ * Media control requests are used to request the route to perform
+ * actions such as starting remote playback of a media item.
+ * </p><p>
+ * This function may only be called on a selected route. Control requests
+ * sent to unselected routes will fail.
+ * </p>
+ *
+ * @param intent A {@link MediaControlIntent media control intent}.
+ * @param callback A {@link ControlRequestCallback} to invoke with the result
+ * of the request, or null if no result is required.
+ *
+ * @see MediaControlIntent
+ */
+ public void sendControlRequest(Intent intent, ControlRequestCallback callback) {
+ if (intent == null) {
+ throw new IllegalArgumentException("intent must not be null");
+ }
+ checkCallingThread();
+
+ sGlobal.sendControlRequest(this, intent, callback);
+ }
+
+ /**
+ * Gets the type of playback associated with this route.
+ *
+ * @return The type of playback associated with this route: {@link #PLAYBACK_TYPE_LOCAL}
+ * or {@link #PLAYBACK_TYPE_REMOTE}.
+ */
+ public int getPlaybackType() {
+ return mPlaybackType;
+ }
+
+ /**
+ * Gets the audio stream over which the playback associated with this route is performed.
+ *
+ * @return The stream over which the playback associated with this route is performed.
+ */
+ public int getPlaybackStream() {
+ return mPlaybackStream;
+ }
+
+ /**
+ * Gets information about how volume is handled on the route.
+ *
+ * @return How volume is handled on the route: {@link #PLAYBACK_VOLUME_FIXED}
+ * or {@link #PLAYBACK_VOLUME_VARIABLE}.
+ */
+ public int getVolumeHandling() {
+ return mVolumeHandling;
+ }
+
+ /**
+ * Gets the current volume for this route. Depending on the route, this may only
+ * be valid if the route is currently selected.
+ *
+ * @return The volume at which the playback associated with this route is performed.
+ */
+ public int getVolume() {
+ return mVolume;
+ }
+
+ /**
+ * Gets the maximum volume at which the playback associated with this route is performed.
+ *
+ * @return The maximum volume at which the playback associated with
+ * this route is performed.
+ */
+ public int getVolumeMax() {
+ return mVolumeMax;
+ }
+
+ /**
+ * Requests a volume change for this route asynchronously.
+ * <p>
+ * This function may only be called on a selected route. It will have
+ * no effect if the route is currently unselected.
+ * </p>
+ *
+ * @param volume The new volume value between 0 and {@link #getVolumeMax}.
+ */
+ public void requestSetVolume(int volume) {
+ checkCallingThread();
+ sGlobal.requestSetVolume(this, Math.min(mVolumeMax, Math.max(0, volume)));
+ }
+
+ /**
+ * Requests an incremental volume update for this route asynchronously.
+ * <p>
+ * This function may only be called on a selected route. It will have
+ * no effect if the route is currently unselected.
+ * </p>
+ *
+ * @param delta The delta to add to the current volume.
+ */
+ public void requestUpdateVolume(int delta) {
+ checkCallingThread();
+ if (delta != 0) {
+ sGlobal.requestUpdateVolume(this, delta);
+ }
+ }
+
+ /**
+ * Gets the {@link Display} that should be used by the application to show
+ * a {@link android.app.Presentation} on an external display when this route is selected.
+ * Depending on the route, this may only be valid if the route is currently
+ * selected.
+ * <p>
+ * The preferred presentation display may change independently of the route
+ * being selected or unselected. For example, the presentation display
+ * of the default system route may change when an external HDMI display is connected
+ * or disconnected even though the route itself has not changed.
+ * </p><p>
+ * This method may return null if there is no external display associated with
+ * the route or if the display is not ready to show UI yet.
+ * </p><p>
+ * The application should listen for changes to the presentation display
+ * using the {@link Callback#onRoutePresentationDisplayChanged} callback and
+ * show or dismiss its {@link android.app.Presentation} accordingly when the display
+ * becomes available or is removed.
+ * </p><p>
+ * This method only makes sense for
+ * {@link MediaControlIntent#CATEGORY_LIVE_VIDEO live video} routes.
+ * </p>
+ *
+ * @return The preferred presentation display to use when this route is
+ * selected or null if none.
+ *
+ * @see MediaControlIntent#CATEGORY_LIVE_VIDEO
+ * @see android.app.Presentation
+ */
+ public Display getPresentationDisplay() {
+ checkCallingThread();
+ if (mPresentationDisplayId >= 0 && mPresentationDisplay == null) {
+ mPresentationDisplay = sGlobal.getDisplay(mPresentationDisplayId);
+ }
+ return mPresentationDisplay;
+ }
+
+ /**
+ * Gets a collection of extra properties about this route that were supplied
+ * by its media route provider, or null if none.
+ */
+ public Bundle getExtras() {
+ return mExtras;
+ }
+
+ /**
+ * Selects this media route.
+ */
+ public void select() {
+ checkCallingThread();
+ sGlobal.selectRoute(this);
+ }
+
+ @Override
+ public String toString() {
+ return "MediaRouter.RouteInfo{ name=" + mName
+ + ", status=" + mStatus
+ + ", enabled=" + mEnabled
+ + ", playbackType=" + mPlaybackType
+ + ", playbackStream=" + mPlaybackStream
+ + ", volumeHandling=" + mVolumeHandling
+ + ", volume=" + mVolume
+ + ", volumeMax=" + mVolumeMax
+ + ", presentationDisplayId=" + mPresentationDisplayId
+ + ", extras=" + mExtras
+ + ", providerPackageName=" + mProvider.getPackageName()
+ + " }";
+ }
+
+ int updateDescriptor(RouteDescriptor descriptor) {
+ int changes = 0;
+ if (mDescriptor != descriptor) {
+ mDescriptor = descriptor;
+ if (descriptor != null) {
+ if (!equal(mName, descriptor.getName())) {
+ mName = descriptor.getName();
+ changes |= CHANGE_GENERAL;
+ }
+ if (!equal(mStatus, descriptor.getStatus())) {
+ mStatus = descriptor.getStatus();
+ changes |= CHANGE_GENERAL;
+ }
+ if (mIconResource != descriptor.getIconResource()) {
+ mIconResource = descriptor.getIconResource();
+ mIconDrawable = null;
+ changes |= CHANGE_GENERAL;
+ }
+ if (mIconResource == 0
+ && mIconDrawable != descriptor.getIconDrawable()) {
+ mIconDrawable = descriptor.getIconDrawable();
+ changes |= CHANGE_GENERAL;
+ }
+ if (mEnabled != descriptor.isEnabled()) {
+ mEnabled = descriptor.isEnabled();
+ changes |= CHANGE_GENERAL;
+ }
+ IntentFilter[] descriptorControlFilters = descriptor.getControlFilters();
+ if (!hasSameControlFilters(descriptorControlFilters)) {
+ mControlFilters.clear();
+ for (IntentFilter f : descriptorControlFilters) {
+ mControlFilters.add(f);
+ }
+ changes |= CHANGE_GENERAL;
+ }
+ if (mPlaybackType != descriptor.getPlaybackType()) {
+ mPlaybackType = descriptor.getPlaybackType();
+ changes |= CHANGE_GENERAL;
+ }
+ if (mPlaybackStream != descriptor.getPlaybackStream()) {
+ mPlaybackStream = descriptor.getPlaybackStream();
+ changes |= CHANGE_GENERAL;
+ }
+ if (mVolumeHandling != descriptor.getVolumeHandling()) {
+ mVolumeHandling = descriptor.getVolumeHandling();
+ changes |= CHANGE_GENERAL | CHANGE_VOLUME;
+ }
+ if (mVolume != descriptor.getVolume()) {
+ mVolume = descriptor.getVolume();
+ changes |= CHANGE_GENERAL | CHANGE_VOLUME;
+ }
+ if (mVolumeMax != descriptor.getVolumeMax()) {
+ mVolumeMax = descriptor.getVolumeMax();
+ changes |= CHANGE_GENERAL | CHANGE_VOLUME;
+ }
+ if (mPresentationDisplayId != descriptor.getPresentationDisplayId()) {
+ mPresentationDisplayId = descriptor.getPresentationDisplayId();
+ mPresentationDisplay = null;
+ changes |= CHANGE_GENERAL | CHANGE_PRESENTATION_DISPLAY;
+ }
+ if (!equal(mExtras, descriptor.getExtras())) {
+ mExtras = descriptor.getExtras();
+ changes |= CHANGE_GENERAL;
+ }
+ }
+ }
+ return changes;
+ }
+
+ boolean hasSameControlFilters(IntentFilter[] controlFilters) {
+ final int count = mControlFilters.size();
+ if (count != controlFilters.length) {
+ return false;
+ }
+ for (int i = 0; i < count; i++) {
+ if (!mControlFilters.get(i).equals(controlFilters[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ String getDescriptorId() {
+ return mDescriptorId;
+ }
+
+ MediaRouteProvider getProviderInstance() {
+ return mProvider.getProviderInstance();
+ }
+ }
+
+ /**
+ * Provides information about a media route provider.
+ * <p>
+ * This object may be used to determine which media route provider has
+ * published a particular route.
+ * </p>
+ */
+ public static final class ProviderInfo {
+ private final MediaRouteProvider mProviderInstance;
+ private final ArrayList<RouteInfo> mRoutes = new ArrayList<RouteInfo>();
+
+ private final ProviderMetadata mMetadata;
+ private ProviderDescriptor mDescriptor;
+ private Resources mResources;
+ private boolean mResourcesNotAvailable;
+
+ ProviderInfo(MediaRouteProvider provider) {
+ mProviderInstance = provider;
+ mMetadata = provider.getMetadata();
+ }
+
+ /**
+ * Gets the provider's underlying {@link MediaRouteProvider} instance.
+ */
+ public MediaRouteProvider getProviderInstance() {
+ checkCallingThread();
+ return mProviderInstance;
+ }
+
+ /**
+ * Gets the package name of the media route provider service.
+ */
+ public String getPackageName() {
+ return mMetadata.getPackageName();
+ }
+
+ /**
+ * Gets the {@link MediaRouter.RouteInfo routes} published by this route provider.
+ */
+ public List<RouteInfo> getRoutes() {
+ checkCallingThread();
+ return mRoutes;
+ }
+
+ Resources getResources() {
+ if (mResources == null && !mResourcesNotAvailable) {
+ String packageName = getPackageName();
+ Context context = sGlobal.getProviderContext(packageName);
+ if (context != null) {
+ mResources = context.getResources();
+ } else {
+ Log.w(TAG, "Unable to obtain resources for route provider package: "
+ + packageName);
+ mResourcesNotAvailable = true;
+ }
+ }
+ return mResources;
+ }
+
+ boolean updateDescriptor(ProviderDescriptor descriptor) {
+ if (mDescriptor != descriptor) {
+ mDescriptor = descriptor;
+ return true;
+ }
+ return false;
+ }
+
+ int findRouteByDescriptorId(String id) {
+ final int count = mRoutes.size();
+ for (int i = 0; i < count; i++) {
+ if (mRoutes.get(i).mDescriptorId.equals(id)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ @Override
+ public String toString() {
+ return "MediaRouter.RouteProviderInfo{ packageName=" + getPackageName()
+ + " }";
+ }
+ }
+
+ /**
+ * Interface for receiving events about media routing changes.
+ * All methods of this interface will be called from the application's main thread.
+ * <p>
+ * A Callback will only receive events relevant to routes that the callback
+ * was registered for.
+ * </p>
+ *
+ * @see MediaRouter#addCallback(Callback)
+ * @see MediaRouter#removeCallback(Callback)
+ */
+ public static abstract class Callback {
+ /**
+ * Called when the supplied media route becomes selected as the active route.
+ *
+ * @param router The media router reporting the event.
+ * @param route The route that has been selected.
+ */
+ public void onRouteSelected(MediaRouter router, RouteInfo route) {
+ }
+
+ /**
+ * Called when the supplied media route becomes unselected as the active route.
+ *
+ * @param router The media router reporting the event.
+ * @param route The route that has been unselected.
+ */
+ public void onRouteUnselected(MediaRouter router, RouteInfo route) {
+ }
+
+ /**
+ * Called when a media route has been added.
+ *
+ * @param router The media router reporting the event.
+ * @param route The route that has become available for use.
+ */
+ public void onRouteAdded(MediaRouter router, RouteInfo route) {
+ }
+
+ /**
+ * Called when a media route has been removed.
+ *
+ * @param router The media router reporting the event.
+ * @param route The route that has been removed from availability.
+ */
+ public void onRouteRemoved(MediaRouter router, RouteInfo route) {
+ }
+
+ /**
+ * Called when a property of the indicated media route has changed.
+ *
+ * @param router The media router reporting the event.
+ * @param route The route that was changed.
+ */
+ public void onRouteChanged(MediaRouter router, RouteInfo route) {
+ }
+
+ /**
+ * Called when a media route's volume changes.
+ *
+ * @param router The media router reporting the event.
+ * @param route The route whose volume changed.
+ */
+ public void onRouteVolumeChanged(MediaRouter router, RouteInfo route) {
+ }
+
+ /**
+ * Called when a media route's presentation display changes.
+ * <p>
+ * This method is called whenever the route's presentation display becomes
+ * available, is removed or has changes to some of its properties (such as its size).
+ * </p>
+ *
+ * @param router The media router reporting the event.
+ * @param route The route whose presentation display changed.
+ *
+ * @see RouteInfo#getPresentationDisplay()
+ */
+ public void onRoutePresentationDisplayChanged(MediaRouter router, RouteInfo route) {
+ }
+
+ /**
+ * Called when a media route provider has been added.
+ *
+ * @param router The media router reporting the event.
+ * @param provider The provider that has become available for use.
+ */
+ public void onProviderAdded(MediaRouter router, ProviderInfo provider) {
+ }
+
+ /**
+ * Called when a media route provider has been removed.
+ *
+ * @param router The media router reporting the event.
+ * @param provider The provider that has been removed from availability.
+ */
+ public void onProviderRemoved(MediaRouter router, ProviderInfo provider) {
+ }
+ }
+
+ /**
+ * Callback which is invoked with the result of a media control request.
+ *
+ * @see RouteInfo#sendControlRequest
+ */
+ public static abstract class ControlRequestCallback {
+ /**
+ * Result code: The media control action succeeded.
+ */
+ public static final int REQUEST_SUCCEEDED = 0;
+
+ /**
+ * Result code: The media control action failed.
+ */
+ public static final int REQUEST_FAILED = -1;
+
+ /**
+ * Called with the result of the media control request.
+ *
+ * @param result The result code: {@link #REQUEST_SUCCEEDED}, or {@link #REQUEST_FAILED}.
+ * @param data Additional result data. Contents depend on the media control action.
+ */
+ public void onResult(int result, Bundle data) {
+ }
+ }
+
+ /**
+ * Global state for the media router.
+ * <p>
+ * Media routes and media route providers are global to the process; their
+ * state and the bulk of the media router implementation lives here.
+ * </p>
+ */
+ private static final class GlobalMediaRouter implements SystemMediaRouteProvider.SyncCallback {
+ private final Context mApplicationContext;
+ private final MediaRouter mApplicationRouter;
+ private final WeakHashMap<Context, MediaRouter> mRouters =
+ new WeakHashMap<Context, MediaRouter>();
+ private final ArrayList<RouteInfo> mRoutes = new ArrayList<RouteInfo>();
+ private final ArrayList<ProviderInfo> mProviders =
+ new ArrayList<ProviderInfo>();
+ private final ProviderCallback mProviderCallback = new ProviderCallback();
+ private final CallbackHandler mCallbackHandler = new CallbackHandler();
+ private final DisplayManagerCompat mDisplayManager;
+ private final SystemMediaRouteProvider mSystemProvider;
+
+ private RegisteredMediaRouteProviderWatcher mRegisteredProviderWatcher;
+ private RouteInfo mDefaultRoute;
+ private RouteInfo mSelectedRoute;
+ private MediaRouteProvider.RouteController mSelectedRouteController;
+
+ GlobalMediaRouter(Context applicationContext) {
+ mApplicationContext = applicationContext;
+ mDisplayManager = DisplayManagerCompat.getInstance(applicationContext);
+ mApplicationRouter = getRouter(applicationContext);
+
+ // Add the system media route provider for interoperating with
+ // the framework media router. This one is special and receives
+ // synchronization messages from the media router.
+ mSystemProvider = SystemMediaRouteProvider.obtain(applicationContext, this);
+ addProvider(mSystemProvider);
+ }
+
+ public void start() {
+ // Start watching for routes published by registered media route
+ // provider services.
+ mRegisteredProviderWatcher = new RegisteredMediaRouteProviderWatcher(
+ mApplicationContext, mApplicationRouter);
+ mRegisteredProviderWatcher.start();
+ }
+
+ public MediaRouter getRouter(Context context) {
+ MediaRouter router = mRouters.get(context);
+ if (router == null) {
+ router = new MediaRouter(context);
+ mRouters.put(context, router);
+ }
+ return router;
+ }
+
+ public ContentResolver getContentResolver() {
+ return mApplicationContext.getContentResolver();
+ }
+
+ public Context getProviderContext(String packageName) {
+ if (packageName.equals(SystemMediaRouteProvider.PACKAGE_NAME)) {
+ return mApplicationContext;
+ }
+ try {
+ return mApplicationContext.createPackageContext(
+ packageName, Context.CONTEXT_RESTRICTED);
+ } catch (NameNotFoundException ex) {
+ return null;
+ }
+ }
+
+ public Display getDisplay(int displayId) {
+ return mDisplayManager.getDisplay(displayId);
+ }
+
+ public void sendControlRequest(RouteInfo route,
+ Intent intent, ControlRequestCallback callback) {
+ if (route == mSelectedRoute && mSelectedRouteController != null) {
+ if (mSelectedRouteController.onControlRequest(intent, callback)) {
+ return;
+ }
+ }
+ if (callback != null) {
+ callback.onResult(ControlRequestCallback.REQUEST_FAILED, null);
+ }
+ }
+
+ public void requestSetVolume(RouteInfo route, int volume) {
+ if (route == mSelectedRoute && mSelectedRouteController != null) {
+ mSelectedRouteController.onSetVolume(volume);
+ }
+ }
+
+ public void requestUpdateVolume(RouteInfo route, int delta) {
+ if (route == mSelectedRoute && mSelectedRouteController != null) {
+ mSelectedRouteController.onUpdateVolume(delta);
+ }
+ }
+
+ public List<RouteInfo> getRoutes() {
+ return mRoutes;
+ }
+
+ public List<ProviderInfo> getProviders() {
+ return mProviders;
+ }
+
+ public RouteInfo getDefaultRoute() {
+ if (mDefaultRoute == null) {
+ // This should never happen once the media router has been fully
+ // initialized but it is good to check for the error in case there
+ // is a bug in provider initialization.
+ throw new IllegalStateException("There is no default route. "
+ + "The media router has not yet been fully initialized.");
+ }
+ return mDefaultRoute;
+ }
+
+ public RouteInfo getSelectedRoute() {
+ if (mSelectedRoute == null) {
+ // This should never happen once the media router has been fully
+ // initialized but it is good to check for the error in case there
+ // is a bug in provider initialization.
+ throw new IllegalStateException("There is no currently selected route. "
+ + "The media router has not yet been fully initialized.");
+ }
+ return mSelectedRoute;
+ }
+
+ public void selectRoute(RouteInfo route) {
+ if (!mRoutes.contains(route)) {
+ Log.w(TAG, "Ignoring attempt to select removed route: " + route);
+ return;
+ }
+ if (!route.mEnabled) {
+ Log.w(TAG, "Ignoring attempt to select disabled route: " + route);
+ return;
+ }
+
+ setSelectedRouteInternal(route);
+ }
+
+ public void addProvider(MediaRouteProvider providerInstance) {
+ int index = findProviderInfo(providerInstance);
+ if (index < 0) {
+ // 1. Add the provider to the list.
+ ProviderInfo provider = new ProviderInfo(providerInstance);
+ mProviders.add(provider);
+ mCallbackHandler.post(CallbackHandler.MSG_PROVIDER_ADDED, provider);
+ // 2. Create the provider's contents.
+ updateProviderContents(provider, providerInstance.getDescriptor());
+ // 3. Register the provider callback.
+ providerInstance.addCallback(mProviderCallback);
+ }
+ }
+
+ public void removeProvider(MediaRouteProvider providerInstance) {
+ int index = findProviderInfo(providerInstance);
+ if (index >= 0) {
+ // 1. Unregister the provider callback.
+ providerInstance.removeCallback(mProviderCallback);
+ // 2. Delete the provider's contents.
+ ProviderInfo provider = mProviders.get(index);
+ updateProviderContents(provider, null);
+ // 3. Remove the provider from the list.
+ mCallbackHandler.post(CallbackHandler.MSG_PROVIDER_REMOVED, provider);
+ mProviders.remove(index);
+ }
+ }
+
+ private void updateProviderDescriptor(MediaRouteProvider providerInstance,
+ ProviderDescriptor descriptor) {
+ int index = findProviderInfo(providerInstance);
+ if (index >= 0) {
+ // Update the provider's contents.
+ ProviderInfo provider = mProviders.get(index);
+ updateProviderContents(provider, descriptor);
+ }
+ }
+
+ private int findProviderInfo(MediaRouteProvider providerInstance) {
+ final int count = mProviders.size();
+ for (int i = 0; i < count; i++) {
+ if (mProviders.get(i).mProviderInstance == providerInstance) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ private void updateProviderContents(ProviderInfo provider,
+ ProviderDescriptor providerDescriptor) {
+ if (provider.updateDescriptor(providerDescriptor)) {
+ // Update all existing routes and reorder them to match
+ // the order of their descriptors.
+ int targetIndex = 0;
+ if (providerDescriptor != null) {
+ if (providerDescriptor.isValid()) {
+ final RouteDescriptor[] routeDescriptors = providerDescriptor.getRoutes();
+ for (int i = 0; i < routeDescriptors.length; i++) {
+ final RouteDescriptor routeDescriptor = routeDescriptors[i];
+ final String id = routeDescriptor.getId();
+ final int sourceIndex = provider.findRouteByDescriptorId(id);
+ if (sourceIndex < 0) {
+ // 1. Add the route to the list.
+ RouteInfo route = new RouteInfo(provider, id);
+ provider.mRoutes.add(targetIndex++, route);
+ mRoutes.add(route);
+ // 2. Create the route's contents.
+ route.updateDescriptor(routeDescriptor);
+ // 3. Notify clients about addition.
+ mCallbackHandler.post(CallbackHandler.MSG_ROUTE_ADDED, route);
+ } else if (sourceIndex < targetIndex) {
+ Log.w(TAG, "Ignoring route descriptor with duplicate id: "
+ + routeDescriptor);
+ } else {
+ // 1. Reorder the route within the list.
+ RouteInfo route = provider.mRoutes.get(sourceIndex);
+ Collections.swap(provider.mRoutes,
+ sourceIndex, targetIndex++);
+ // 2. Update the route's contents.
+ int changes = route.updateDescriptor(routeDescriptor);
+ // 3. Unselect route if needed before notifying about changes.
+ unselectRouteIfNeeded(route);
+ // 4. Notify clients about changes.
+ if ((changes & RouteInfo.CHANGE_GENERAL) != 0) {
+ mCallbackHandler.post(
+ CallbackHandler.MSG_ROUTE_CHANGED, route);
+ }
+ if ((changes & RouteInfo.CHANGE_VOLUME) != 0) {
+ mCallbackHandler.post(
+ CallbackHandler.MSG_ROUTE_VOLUME_CHANGED, route);
+ }
+ if ((changes & RouteInfo.CHANGE_PRESENTATION_DISPLAY) != 0) {
+ mCallbackHandler.post(CallbackHandler.
+ MSG_ROUTE_PRESENTATION_DISPLAY_CHANGED, route);
+ }
+ }
+ }
+ } else {
+ Log.w(TAG, "Ignoring invalid provider descriptor: " + providerDescriptor);
+ }
+ }
+
+ // Dispose all remaining routes that do not have matching descriptors.
+ for (int i = provider.mRoutes.size() - 1; i >= targetIndex; i--) {
+ // 1. Delete the route's contents.
+ RouteInfo route = provider.mRoutes.get(i);
+ route.updateDescriptor(null);
+ // 2. Remove the route from the list.
+ mRoutes.remove(provider);
+ provider.mRoutes.remove(i);
+ // 3. Unselect route if needed before notifying about removal.
+ unselectRouteIfNeeded(route);
+ // 4. Notify clients about removal.
+ mCallbackHandler.post(CallbackHandler.MSG_ROUTE_REMOVED, route);
+ }
+
+ // Choose a new selected route if needed.
+ selectRouteIfNeeded();
+ }
+ }
+
+ private void unselectRouteIfNeeded(RouteInfo route) {
+ if (mDefaultRoute == route && !isRouteSelectable(route)) {
+ Log.i(TAG, "Choosing a new default route because the current one "
+ + "is no longer selectable: " + route);
+ mDefaultRoute = null;
+ }
+ if (mSelectedRoute == route && !isRouteSelectable(route)) {
+ Log.i(TAG, "Choosing a new selected route because the current one "
+ + "is no longer selectable: " + route);
+ setSelectedRouteInternal(null);
+ }
+ }
+
+ private void selectRouteIfNeeded() {
+ if (mDefaultRoute == null && !mRoutes.isEmpty()) {
+ for (RouteInfo route : mRoutes) {
+ if (isSystemDefaultRoute(route) && isRouteSelectable(route)) {
+ mDefaultRoute = route;
+ break;
+ }
+ }
+ }
+ if (mSelectedRoute == null) {
+ setSelectedRouteInternal(mDefaultRoute);
+ }
+ }
+
+ private boolean isRouteSelectable(RouteInfo route) {
+ // This tests whether the route is still valid and enabled.
+ // The route descriptor field is set to null when the route is removed.
+ return route.mDescriptor != null && route.mEnabled;
+ }
+
+ private boolean isSystemDefaultRoute(RouteInfo route) {
+ return route.getProviderInstance() == mSystemProvider
+ && route.mDescriptorId.equals(
+ SystemMediaRouteProvider.DEFAULT_ROUTE_ID);
+ }
+
+ private void setSelectedRouteInternal(RouteInfo route) {
+ if (mSelectedRoute != route) {
+ if (mSelectedRoute != null) {
+ mCallbackHandler.post(CallbackHandler.MSG_ROUTE_UNSELECTED, mSelectedRoute);
+ if (mSelectedRouteController != null) {
+ mSelectedRouteController.onUnselect();
+ mSelectedRouteController.onRelease();
+ mSelectedRouteController = null;
+ }
+ }
+
+ mSelectedRoute = route;
+
+ if (mSelectedRoute != null) {
+ mSelectedRouteController = route.getProviderInstance().onCreateRouteController(
+ route.mDescriptorId);
+ if (mSelectedRouteController != null) {
+ mSelectedRouteController.onSelect();
+ }
+ mCallbackHandler.post(CallbackHandler.MSG_ROUTE_SELECTED, mSelectedRoute);
+ }
+ }
+ }
+
+ @Override
+ public RouteInfo getSystemRouteByDescriptorId(String id) {
+ int providerIndex = findProviderInfo(mSystemProvider);
+ if (providerIndex >= 0) {
+ ProviderInfo provider = mProviders.get(providerIndex);
+ int routeIndex = provider.findRouteByDescriptorId(id);
+ if (routeIndex >= 0) {
+ return provider.mRoutes.get(routeIndex);
+ }
+ }
+ return null;
+ }
+
+ private final class ProviderCallback extends MediaRouteProvider.Callback {
+ @Override
+ public void onDescriptorChanged(MediaRouteProvider provider,
+ ProviderDescriptor descriptor) {
+ updateProviderDescriptor(provider, descriptor);
+ }
+ }
+
+ private final class CallbackHandler extends Handler {
+ private final ArrayList<MediaRouter> mTempMediaRouters =
+ new ArrayList<MediaRouter>();
+
+ public static final int MSG_ROUTE_ADDED = 1;
+ public static final int MSG_ROUTE_REMOVED = 2;
+ public static final int MSG_ROUTE_CHANGED = 3;
+ public static final int MSG_ROUTE_VOLUME_CHANGED = 4;
+ public static final int MSG_ROUTE_PRESENTATION_DISPLAY_CHANGED = 5;
+ public static final int MSG_ROUTE_SELECTED = 6;
+ public static final int MSG_ROUTE_UNSELECTED = 7;
+ public static final int MSG_PROVIDER_ADDED = 8;
+ public static final int MSG_PROVIDER_REMOVED = 9;
+
+ public void post(int msg, Object obj) {
+ obtainMessage(msg, obj).sendToTarget();
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ final int what = msg.what;
+ final Object obj = msg.obj;
+
+ // Synchronize state with the system media router.
+ syncWithSystemProvider(what, obj);
+
+ // Invoke all registered callbacks.
+ mTempMediaRouters.addAll(mRouters.values());
+ try {
+ final int routerCount = mTempMediaRouters.size();
+ for (int i = 0; i < routerCount; i++) {
+ final MediaRouter router = mTempMediaRouters.get(i);
+ if (!router.mCallbacks.isEmpty()) {
+ for (MediaRouter.Callback callback : router.mCallbacks) {
+ invokeCallback(router, callback, what, obj);
+ }
+ }
+ }
+ } finally {
+ mTempMediaRouters.clear();
+ }
+ }
+
+ private void syncWithSystemProvider(int what, Object obj) {
+ switch (what) {
+ case MSG_ROUTE_ADDED:
+ mSystemProvider.onSyncRouteAdded((RouteInfo)obj);
+ break;
+ case MSG_ROUTE_REMOVED:
+ mSystemProvider.onSyncRouteRemoved((RouteInfo)obj);
+ break;
+ case MSG_ROUTE_CHANGED:
+ mSystemProvider.onSyncRouteChanged((RouteInfo)obj);
+ break;
+ case MSG_ROUTE_SELECTED:
+ mSystemProvider.onSyncRouteSelected((RouteInfo)obj);
+ break;
+ }
+ }
+
+ private void invokeCallback(MediaRouter router, MediaRouter.Callback callback,
+ int what, Object obj) {
+ switch (what) {
+ case MSG_ROUTE_ADDED:
+ callback.onRouteAdded(router, (RouteInfo)obj);
+ break;
+ case MSG_ROUTE_REMOVED:
+ callback.onRouteRemoved(router, (RouteInfo)obj);
+ break;
+ case MSG_ROUTE_CHANGED:
+ callback.onRouteChanged(router, (RouteInfo)obj);
+ break;
+ case MSG_ROUTE_VOLUME_CHANGED:
+ callback.onRouteVolumeChanged(router, (RouteInfo)obj);
+ break;
+ case MSG_ROUTE_PRESENTATION_DISPLAY_CHANGED:
+ callback.onRoutePresentationDisplayChanged(router, (RouteInfo)obj);
+ break;
+ case MSG_ROUTE_SELECTED:
+ callback.onRouteSelected(router, (RouteInfo)obj);
+ break;
+ case MSG_ROUTE_UNSELECTED:
+ callback.onRouteUnselected(router, (RouteInfo)obj);
+ break;
+ case MSG_PROVIDER_ADDED:
+ callback.onProviderAdded(router, (ProviderInfo)obj);
+ break;
+ case MSG_PROVIDER_REMOVED:
+ callback.onProviderRemoved(router, (ProviderInfo)obj);
+ break;
+ }
+ }
+ }
+ }
+}
diff --git a/v7/mediarouter/src/android/support/v7/media/RegisteredMediaRouteProvider.java b/v7/mediarouter/src/android/support/v7/media/RegisteredMediaRouteProvider.java
new file mode 100644
index 0000000..cab2d15
--- /dev/null
+++ b/v7/mediarouter/src/android/support/v7/media/RegisteredMediaRouteProvider.java
@@ -0,0 +1,577 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.media;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.Bundle;
+import android.os.DeadObjectException;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.os.IBinder.DeathRecipient;
+import android.os.Message;
+import android.os.Messenger;
+import android.support.v7.media.MediaRouter.ControlRequestCallback;
+import android.util.Log;
+import android.util.SparseArray;
+
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+
+/**
+ * Maintains a connection to a particular media route provider service.
+ */
+final class RegisteredMediaRouteProvider extends MediaRouteProvider
+ implements ServiceConnection {
+ private static final String TAG = "RegisteredMediaRouteProvider";
+ private static final boolean DEBUG = true;
+
+ private final ComponentName mComponentName;
+ private final PrivateHandler mPrivateHandler;
+ private final ArrayList<Controller> mControllers = new ArrayList<Controller>();
+
+ private boolean mBound;
+ private Connection mActiveConnection;
+ private boolean mConnectionReady;
+
+ public RegisteredMediaRouteProvider(Context context, ComponentName componentName) {
+ super(context, new ProviderMetadata(componentName.getPackageName()));
+
+ mComponentName = componentName;
+ mPrivateHandler = new PrivateHandler();
+ }
+
+ @Override
+ public RouteController onCreateRouteController(String routeId) {
+ ProviderDescriptor descriptor = getDescriptor();
+ if (descriptor != null) {
+ RouteDescriptor[] routes = descriptor.getRoutes();
+ for (int i = 0; i < routes.length; i++) {
+ if (routes[i].getId().equals(routeId)) {
+ Controller controller = new Controller(routeId);
+ mControllers.add(controller);
+ if (mConnectionReady) {
+ controller.attachConnection(mActiveConnection);
+ }
+ return controller;
+ }
+ }
+ }
+ return null;
+ }
+
+ public boolean hasComponentName(String packageName, String className) {
+ return mComponentName.getPackageName().equals(packageName)
+ && mComponentName.getClassName().equals(className);
+ }
+
+ public void bind() {
+ if (DEBUG) {
+ Log.d(TAG, this + ": Binding");
+ }
+
+ Intent service = new Intent(MediaRouteProviderService.SERVICE_INTERFACE);
+ service.setComponent(mComponentName);
+ try {
+ mBound = getContext().bindService(service, this, Context.BIND_AUTO_CREATE);
+ if (!mBound && DEBUG) {
+ Log.d(TAG, this + ": Bind failed");
+ }
+ } catch (SecurityException ex) {
+ if (DEBUG) {
+ Log.d(TAG, this + ": Bind failed", ex);
+ }
+ }
+ }
+
+ public void unbind() {
+ if (DEBUG) {
+ Log.d(TAG, this + ": Unbinding");
+ }
+
+ disconnect();
+ if (mBound) {
+ mBound = false;
+ getContext().unbindService(this);
+ }
+ }
+
+ public void rebindIfDisconnected() {
+ if (mActiveConnection == null) {
+ unbind();
+ bind();
+ }
+ }
+
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ if (DEBUG) {
+ Log.d(TAG, this + ": Connected");
+ }
+
+ if (mBound) {
+ disconnect();
+
+ Messenger messenger = (service != null ? new Messenger(service) : null);
+ if (MediaRouteProviderService.isValidRemoteMessenger(messenger)) {
+ Connection connection = new Connection(messenger);
+ if (connection.register()) {
+ mActiveConnection = connection;
+ } else {
+ if (DEBUG) {
+ Log.d(TAG, this + ": Registration failed");
+ }
+ }
+ } else {
+ Log.e(TAG, this + ": Service returned invalid messenger binder");
+ }
+ }
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ if (DEBUG) {
+ Log.d(TAG, this + ": Service disconnected");
+ }
+ disconnect();
+ }
+
+ private void onConnectionReady(Connection connection) {
+ if (mActiveConnection == connection) {
+ mConnectionReady = true;
+ attachControllersToConnection();
+ }
+ }
+
+ private void onConnectionDied(Connection connection) {
+ if (mActiveConnection == connection) {
+ if (DEBUG) {
+ Log.d(TAG, this + ": Service connection died");
+ }
+ disconnect();
+ }
+ }
+
+ private void onConnectionError(Connection connection, String error) {
+ if (mActiveConnection == connection) {
+ if (DEBUG) {
+ Log.d(TAG, this + ": Service connection error - " + error);
+ }
+ unbind();
+ }
+ }
+
+ private void onConnectionDescriptorChanged(Connection connection,
+ ProviderDescriptor descriptor) {
+ if (mActiveConnection == connection) {
+ if (DEBUG) {
+ Log.d(TAG, this + ": Descriptor changed, descriptor=" + descriptor);
+ }
+ setDescriptor(descriptor);
+ }
+ }
+
+ private void disconnect() {
+ if (mActiveConnection != null) {
+ setDescriptor(null);
+ mConnectionReady = false;
+ detachControllersFromConnection();
+ mActiveConnection.dispose();
+ mActiveConnection = null;
+ }
+ }
+
+ private void onControllerReleased(Controller controller) {
+ mControllers.remove(controller);
+ controller.detachConnection();
+ }
+
+ private void attachControllersToConnection() {
+ int count = mControllers.size();
+ for (int i = 0; i < count; i++) {
+ mControllers.get(i).attachConnection(mActiveConnection);
+ }
+ }
+
+ private void detachControllersFromConnection() {
+ int count = mControllers.size();
+ for (int i = 0; i < count; i++) {
+ mControllers.get(i).detachConnection();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "Service connection " + mComponentName.flattenToShortString();
+ }
+
+ private final class Controller extends RouteController {
+ private final String mRouteId;
+
+ private boolean mSelected;
+ private int mPendingSetVolume = -1;
+ private int mPendingUpdateVolumeDelta;
+
+ private Connection mConnection;
+ private int mControllerId;
+
+ public Controller(String routeId) {
+ mRouteId = routeId;
+ }
+
+ public void attachConnection(Connection connection) {
+ mConnection = connection;
+ mControllerId = connection.createRouteController(mRouteId);
+ if (mSelected) {
+ connection.selectRoute(mControllerId);
+ if (mPendingSetVolume >= 0) {
+ connection.setVolume(mControllerId, mPendingSetVolume);
+ mPendingSetVolume = -1;
+ }
+ if (mPendingUpdateVolumeDelta != 0) {
+ connection.updateVolume(mControllerId, mPendingUpdateVolumeDelta);
+ mPendingUpdateVolumeDelta = 0;
+ }
+ }
+ }
+
+ public void detachConnection() {
+ if (mConnection != null) {
+ mConnection.releaseRouteController(mControllerId);
+ mConnection = null;
+ mControllerId = 0;
+ }
+ }
+
+ @Override
+ public void onRelease() {
+ onControllerReleased(this);
+ }
+
+ @Override
+ public void onSelect() {
+ mSelected = true;
+ if (mConnection != null) {
+ mConnection.selectRoute(mControllerId);
+ }
+ }
+
+ @Override
+ public void onUnselect() {
+ mSelected = false;
+ if (mConnection != null) {
+ mConnection.unselectRoute(mControllerId);
+ }
+ }
+
+ @Override
+ public void onSetVolume(int volume) {
+ if (mConnection != null) {
+ mConnection.setVolume(mControllerId, volume);
+ } else {
+ mPendingSetVolume = volume;
+ mPendingUpdateVolumeDelta = 0;
+ }
+ }
+
+ @Override
+ public void onUpdateVolume(int delta) {
+ if (mConnection != null) {
+ mConnection.updateVolume(mControllerId, delta);
+ } else {
+ mPendingUpdateVolumeDelta += delta;
+ }
+ }
+
+ @Override
+ public boolean onControlRequest(Intent intent, ControlRequestCallback callback) {
+ if (mConnection != null) {
+ return mConnection.sendControlRequest(mControllerId, intent, callback);
+ }
+ return false;
+ }
+ }
+
+ private final class Connection implements DeathRecipient {
+ private final Messenger mServiceMessenger;
+ private final ReceiveHandler mReceiveHandler;
+ private final Messenger mReceiveMessenger;
+
+ private int mNextRequestId = 1;
+ private int mNextControllerId = 1;
+ private int mServiceVersion; // non-zero when registration complete
+
+ private int mPendingRegisterRequestId;
+ private final SparseArray<ControlRequestCallback> mPendingCallbacks =
+ new SparseArray<ControlRequestCallback>();
+
+ public Connection(Messenger serviceMessenger) {
+ mServiceMessenger = serviceMessenger;
+ mReceiveHandler = new ReceiveHandler(this);
+ mReceiveMessenger = new Messenger(mReceiveHandler);
+ }
+
+ public boolean register() {
+ mPendingRegisterRequestId = mNextRequestId++;
+ if (!sendRequest(MediaRouteProviderService.CLIENT_MSG_REGISTER,
+ mPendingRegisterRequestId,
+ MediaRouteProviderService.CLIENT_VERSION_CURRENT, null, null)) {
+ return false;
+ }
+
+ try {
+ mServiceMessenger.getBinder().linkToDeath(this, 0);
+ return true;
+ } catch (RemoteException ex) {
+ binderDied();
+ }
+ return false;
+ }
+
+ public void dispose() {
+ sendRequest(MediaRouteProviderService.CLIENT_MSG_UNREGISTER, 0, 0, null, null);
+ mReceiveHandler.dispose();
+ mServiceMessenger.getBinder().unlinkToDeath(this, 0);
+
+ mPrivateHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ failPendingCallbacks();
+ }
+ });
+ }
+
+ private void failPendingCallbacks() {
+ int count = 0;
+ for (int i = 0; i < mPendingCallbacks.size(); i++) {
+ mPendingCallbacks.get(i).onResult(ControlRequestCallback.REQUEST_FAILED, null);
+ }
+ mPendingCallbacks.clear();
+ }
+
+ public boolean onGenericFailure(int requestId) {
+ if (requestId == mPendingRegisterRequestId) {
+ mPendingRegisterRequestId = 0;
+ onConnectionError(this, "Registation failed");
+ }
+ ControlRequestCallback callback = mPendingCallbacks.get(requestId);
+ if (callback != null) {
+ mPendingCallbacks.remove(requestId);
+ callback.onResult(ControlRequestCallback.REQUEST_FAILED, null);
+ }
+ return true;
+ }
+
+ public boolean onGenericSuccess(int requestId) {
+ return true;
+ }
+
+ public boolean onRegistered(int requestId, int serviceVersion,
+ Bundle descriptorBundle) {
+ if (mServiceVersion == 0
+ && requestId == mPendingRegisterRequestId
+ && serviceVersion >= MediaRouteProviderService.SERVICE_VERSION_1) {
+ mPendingRegisterRequestId = 0;
+ mServiceVersion = serviceVersion;
+ onConnectionDescriptorChanged(this,
+ ProviderDescriptor.fromBundle(descriptorBundle));
+ onConnectionReady(this);
+ return true;
+ }
+ return false;
+ }
+
+ public boolean onDescriptorChanged(Bundle descriptorBundle) {
+ if (mServiceVersion != 0) {
+ onConnectionDescriptorChanged(this,
+ ProviderDescriptor.fromBundle(descriptorBundle));
+ return true;
+ }
+ return false;
+ }
+
+ public boolean onControlRequestResult(int requestId, int resultCode,
+ Bundle resultData) {
+ ControlRequestCallback callback = mPendingCallbacks.get(requestId);
+ if (callback != null) {
+ mPendingCallbacks.remove(requestId);
+ callback.onResult(resultCode, resultData);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void binderDied() {
+ mPrivateHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ onConnectionDied(Connection.this);
+ }
+ });
+ }
+
+ public int createRouteController(String routeId) {
+ int controllerId = mNextControllerId++;
+ Bundle data = new Bundle();
+ data.putString(MediaRouteProviderService.CLIENT_DATA_ROUTE_ID, routeId);
+ sendRequest(MediaRouteProviderService.CLIENT_MSG_CREATE_ROUTE_CONTROLLER,
+ mNextRequestId++, controllerId, null, data);
+ return controllerId;
+ }
+
+ public void releaseRouteController(int controllerId) {
+ sendRequest(MediaRouteProviderService.CLIENT_MSG_RELEASE_ROUTE_CONTROLLER,
+ mNextRequestId++, controllerId, null, null);
+ }
+
+ public void selectRoute(int controllerId) {
+ sendRequest(MediaRouteProviderService.CLIENT_MSG_SELECT_ROUTE,
+ mNextRequestId++, controllerId, null, null);
+ }
+
+ public void unselectRoute(int controllerId) {
+ sendRequest(MediaRouteProviderService.CLIENT_MSG_UNSELECT_ROUTE,
+ mNextRequestId++, controllerId, null, null);
+ }
+
+ public void setVolume(int controllerId, int volume) {
+ Bundle data = new Bundle();
+ data.putInt(MediaRouteProviderService.CLIENT_DATA_VOLUME, volume);
+ sendRequest(MediaRouteProviderService.CLIENT_MSG_SET_ROUTE_VOLUME,
+ mNextRequestId++, controllerId, null, data);
+ }
+
+ public void updateVolume(int controllerId, int delta) {
+ Bundle data = new Bundle();
+ data.putInt(MediaRouteProviderService.CLIENT_DATA_VOLUME, delta);
+ sendRequest(MediaRouteProviderService.CLIENT_MSG_UPDATE_ROUTE_VOLUME,
+ mNextRequestId++, controllerId, null, data);
+ }
+
+ public boolean sendControlRequest(int controllerId, Intent intent,
+ ControlRequestCallback callback) {
+ int requestId = mNextRequestId++;
+ if (sendRequest(MediaRouteProviderService.CLIENT_MSG_ROUTE_CONTROL_REQUEST,
+ requestId, controllerId, intent, null)) {
+ if (callback != null) {
+ mPendingCallbacks.put(requestId, callback);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ private boolean sendRequest(int what, int requestId, int arg, Object obj, Bundle data) {
+ Message msg = Message.obtain();
+ msg.what = what;
+ msg.arg1 = requestId;
+ msg.arg2 = arg;
+ msg.obj = obj;
+ msg.setData(data);
+ msg.replyTo = mReceiveMessenger;
+ try {
+ mServiceMessenger.send(msg);
+ return true;
+ } catch (DeadObjectException ex) {
+ // The service died.
+ } catch (RemoteException ex) {
+ if (what != MediaRouteProviderService.CLIENT_MSG_UNREGISTER) {
+ Log.e(TAG, "Could not send message to service.", ex);
+ }
+ }
+ return false;
+ }
+ }
+
+ private final class PrivateHandler extends Handler {
+ }
+
+ /**
+ * Handler that receives messages from the server.
+ * <p>
+ * This inner class is static and only retains a weak reference to the connection
+ * to prevent the client from being leaked in case the service is holding an
+ * active reference to the client's messenger.
+ * </p><p>
+ * This handler should not be used to handle any messages other than those
+ * that come from the service.
+ * </p>
+ */
+ private static final class ReceiveHandler extends Handler {
+ private final WeakReference<Connection> mConnectionRef;
+
+ public ReceiveHandler(Connection connection) {
+ mConnectionRef = new WeakReference<Connection>(connection);
+ }
+
+ public void dispose() {
+ mConnectionRef.clear();
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ final int what = msg.what;
+ final int requestId = msg.arg1;
+ final int arg = msg.arg2;
+ final Object obj = msg.obj;
+ if (!processMessage(what, requestId, arg, obj)) {
+ if (DEBUG) {
+ Log.d(TAG, "Unhandled message from server: " + msg);
+ }
+ }
+ }
+
+ private boolean processMessage(int what, int requestId, int arg, Object obj) {
+ Connection connection = mConnectionRef.get();
+ if (connection != null) {
+ switch (what) {
+ case MediaRouteProviderService.SERVICE_MSG_GENERIC_FAILURE:
+ connection.onGenericFailure(requestId);
+ return true;
+
+ case MediaRouteProviderService.SERVICE_MSG_GENERIC_SUCCESS:
+ connection.onGenericSuccess(requestId);
+ return true;
+
+ case MediaRouteProviderService.SERVICE_MSG_REGISTERED:
+ if (obj == null || obj instanceof Bundle) {
+ return connection.onRegistered(requestId, arg, (Bundle)obj);
+ }
+ break;
+
+ case MediaRouteProviderService.SERVICE_MSG_DESCRIPTOR_CHANGED:
+ if (obj == null || obj instanceof Bundle) {
+ return connection.onDescriptorChanged((Bundle)obj);
+ }
+ break;
+
+ case MediaRouteProviderService.SERVICE_MSG_CONTROL_RESULT:
+ if (obj == null || obj instanceof Bundle) {
+ return connection.onControlRequestResult(
+ requestId, arg, (Bundle)obj);
+ }
+ break;
+ }
+ }
+ return false;
+ }
+ }
+}
diff --git a/v7/mediarouter/src/android/support/v7/media/RegisteredMediaRouteProviderWatcher.java b/v7/mediarouter/src/android/support/v7/media/RegisteredMediaRouteProviderWatcher.java
new file mode 100644
index 0000000..f67eeff
--- /dev/null
+++ b/v7/mediarouter/src/android/support/v7/media/RegisteredMediaRouteProviderWatcher.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.media;
+
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.content.pm.ServiceInfo;
+
+import java.util.ArrayList;
+import java.util.Collections;
+
+/**
+ * Watches for media route provider services to be installed.
+ * Adds a provider to the media router for each registered service.
+ *
+ * @see RegisteredMediaRouteProvider
+ */
+final class RegisteredMediaRouteProviderWatcher {
+ private final Context mContext;
+ private final MediaRouter mRouter;
+ private final ArrayList<RegisteredMediaRouteProvider> mProviders =
+ new ArrayList<RegisteredMediaRouteProvider>();
+ private final PackageManager mPackageManager;
+
+ public RegisteredMediaRouteProviderWatcher(Context context, MediaRouter router) {
+ mContext = context;
+ mRouter = router;
+ mPackageManager = context.getPackageManager();
+ }
+
+ public void start() {
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(Intent.ACTION_PACKAGE_ADDED);
+ filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
+ filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
+ mContext.registerReceiver(new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ scanPackages();
+ }
+ }, filter);
+
+ scanPackages();
+ }
+
+ private void scanPackages() {
+ // Add providers for all new services.
+ // Reorder the list so that providers left at the end will be the ones to remove.
+ int targetIndex = 0;
+ Intent intent = new Intent(MediaRouteProviderService.SERVICE_INTERFACE);
+ for (ResolveInfo resolveInfo : mPackageManager.queryIntentServices(intent, 0)) {
+ ServiceInfo serviceInfo = resolveInfo.serviceInfo;
+ if (serviceInfo != null) {
+ int sourceIndex = findProvider(serviceInfo.packageName, serviceInfo.name);
+ if (sourceIndex < 0) {
+ RegisteredMediaRouteProvider provider =
+ new RegisteredMediaRouteProvider(mContext,
+ new ComponentName(serviceInfo.packageName, serviceInfo.name));
+ provider.bind();
+ mProviders.add(targetIndex++, provider);
+ mRouter.addProvider(provider);
+ } else if (sourceIndex >= targetIndex) {
+ RegisteredMediaRouteProvider provider = mProviders.get(sourceIndex);
+ provider.rebindIfDisconnected();
+ Collections.swap(mProviders, sourceIndex, targetIndex++);
+ }
+ }
+ }
+
+ // Remove providers for missing services.
+ if (targetIndex < mProviders.size()) {
+ for (int i = mProviders.size() - 1; i >= targetIndex; i--) {
+ RegisteredMediaRouteProvider provider = mProviders.get(i);
+ mRouter.removeProvider(provider);
+ mProviders.remove(provider);
+ provider.unbind();
+ }
+ }
+ }
+
+ private int findProvider(String packageName, String className) {
+ int count = mProviders.size();
+ for (int i = 0; i < count; i++) {
+ RegisteredMediaRouteProvider provider = mProviders.get(i);
+ if (provider.hasComponentName(packageName, className)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+}
diff --git a/v7/mediarouter/src/android/support/v7/media/SystemMediaRouteProvider.java b/v7/mediarouter/src/android/support/v7/media/SystemMediaRouteProvider.java
new file mode 100644
index 0000000..1246e96
--- /dev/null
+++ b/v7/mediarouter/src/android/support/v7/media/SystemMediaRouteProvider.java
@@ -0,0 +1,741 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v7.media;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.res.Resources;
+import android.media.AudioManager;
+import android.os.Build;
+import android.support.v7.mediarouter.R;
+import android.util.Log;
+import android.view.Display;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+
+/**
+ * Provides routes for built-in system destinations such as the local display
+ * and speaker. On Jellybean and newer platform releases, queries the framework
+ * MediaRouter for framework-provided routes and registers non-framework-provided
+ * routes as user routes.
+ */
+abstract class SystemMediaRouteProvider extends MediaRouteProvider {
+ private static final String TAG = "SystemMediaRouteProvider";
+
+ public static final String PACKAGE_NAME = "android";
+ public static final String DEFAULT_ROUTE_ID = "DEFAULT_ROUTE";
+
+ protected SystemMediaRouteProvider(Context context) {
+ super(context, new ProviderMetadata(PACKAGE_NAME));
+ }
+
+ public static SystemMediaRouteProvider obtain(Context context, SyncCallback syncCallback) {
+ if (Build.VERSION.SDK_INT >= 18) {
+ return new JellybeanMr2Impl(context, syncCallback);
+ }
+ if (Build.VERSION.SDK_INT >= 17) {
+ return new JellybeanMr1Impl(context, syncCallback);
+ }
+ if (Build.VERSION.SDK_INT >= 16) {
+ return new JellybeanImpl(context, syncCallback);
+ }
+ return new LegacyImpl(context);
+ }
+
+ /**
+ * Called by the media router when a route is added to synchronize state with
+ * the framework media router.
+ */
+ public void onSyncRouteAdded(MediaRouter.RouteInfo route) {
+ }
+
+ /**
+ * Called by the media router when a route is removed to synchronize state with
+ * the framework media router.
+ */
+ public void onSyncRouteRemoved(MediaRouter.RouteInfo route) {
+ }
+
+ /**
+ * Called by the media router when a route is changed to synchronize state with
+ * the framework media router.
+ */
+ public void onSyncRouteChanged(MediaRouter.RouteInfo route) {
+ }
+
+ /**
+ * Called by the media router when a route is selected to synchronize state with
+ * the framework media router.
+ */
+ public void onSyncRouteSelected(MediaRouter.RouteInfo route) {
+ }
+
+ /**
+ * Callbacks into the media router to synchronize state with the framework media router.
+ */
+ public interface SyncCallback {
+ public MediaRouter.RouteInfo getSystemRouteByDescriptorId(String id);
+ }
+
+ /**
+ * Legacy implementation for platform versions prior to Jellybean.
+ */
+ static class LegacyImpl extends SystemMediaRouteProvider {
+ private static final int PLAYBACK_STREAM = AudioManager.STREAM_MUSIC;
+
+ private static final IntentFilter[] CONTROL_FILTERS;
+ static {
+ CONTROL_FILTERS = new IntentFilter[1];
+ CONTROL_FILTERS[0] = new IntentFilter();
+ CONTROL_FILTERS[0].addCategory(MediaControlIntent.CATEGORY_LIVE_AUDIO);
+ CONTROL_FILTERS[0].addCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO);
+ }
+
+ private final AudioManager mAudioManager;
+ private final VolumeChangeReceiver mVolumeChangeReceiver;
+ private int mLastReportedVolume = -1;
+
+ public LegacyImpl(Context context) {
+ super(context);
+ mAudioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
+ mVolumeChangeReceiver = new VolumeChangeReceiver();
+
+ context.registerReceiver(mVolumeChangeReceiver,
+ new IntentFilter(VolumeChangeReceiver.VOLUME_CHANGED_ACTION));
+ publishRoutes();
+ }
+
+ private void publishRoutes() {
+ Resources r = getContext().getResources();
+ RouteDescriptor defaultRoute = new RouteDescriptor(
+ DEFAULT_ROUTE_ID, r.getString(R.string.system_route_name));
+ defaultRoute.setControlFilters(CONTROL_FILTERS);
+ defaultRoute.setPlaybackStream(PLAYBACK_STREAM);
+ defaultRoute.setPlaybackType(MediaRouter.RouteInfo.PLAYBACK_TYPE_LOCAL);
+ defaultRoute.setVolumeHandling(MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE);
+ defaultRoute.setVolumeMax(mAudioManager.getStreamMaxVolume(PLAYBACK_STREAM));
+ mLastReportedVolume = mAudioManager.getStreamVolume(PLAYBACK_STREAM);
+ defaultRoute.setVolume(mLastReportedVolume);
+
+ ProviderDescriptor providerDescriptor = new ProviderDescriptor();
+ providerDescriptor.setRoutes(new RouteDescriptor[] { defaultRoute });
+ setDescriptor(providerDescriptor);
+ }
+
+ @Override
+ public RouteController onCreateRouteController(String routeId) {
+ if (routeId.equals(DEFAULT_ROUTE_ID)) {
+ return new DefaultRouteController();
+ }
+ return null;
+ }
+
+ final class DefaultRouteController extends RouteController {
+ @Override
+ public void onSetVolume(int volume) {
+ mAudioManager.setStreamVolume(PLAYBACK_STREAM, volume, 0);
+ publishRoutes();
+ }
+
+ @Override
+ public void onUpdateVolume(int delta) {
+ int volume = mAudioManager.getStreamVolume(PLAYBACK_STREAM);
+ int maxVolume = mAudioManager.getStreamMaxVolume(PLAYBACK_STREAM);
+ int newVolume = Math.min(maxVolume, Math.max(0, volume + delta));
+ if (newVolume != volume) {
+ mAudioManager.setStreamVolume(PLAYBACK_STREAM, volume, 0);
+ }
+ publishRoutes();
+ }
+ }
+
+ final class VolumeChangeReceiver extends BroadcastReceiver {
+ // These constants come from AudioManager.
+ public static final String VOLUME_CHANGED_ACTION =
+ "android.media.VOLUME_CHANGED_ACTION";
+ public static final String EXTRA_VOLUME_STREAM_TYPE =
+ "android.media.EXTRA_VOLUME_STREAM_TYPE";
+ public static final String EXTRA_VOLUME_STREAM_VALUE =
+ "android.media.EXTRA_VOLUME_STREAM_VALUE";
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(VOLUME_CHANGED_ACTION)) {
+ final int streamType = intent.getIntExtra(EXTRA_VOLUME_STREAM_TYPE, -1);
+ if (streamType == PLAYBACK_STREAM) {
+ final int volume = intent.getIntExtra(EXTRA_VOLUME_STREAM_VALUE, -1);
+ if (volume >= 0 && volume != mLastReportedVolume) {
+ publishRoutes();
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Jellybean implementation.
+ */
+ static class JellybeanImpl extends SystemMediaRouteProvider
+ implements MediaRouterJellybean.Callback, MediaRouterJellybean.VolumeCallback {
+ protected static final int ALL_ROUTE_TYPES =
+ MediaRouterJellybean.ROUTE_TYPE_LIVE_AUDIO
+ | MediaRouterJellybean.ROUTE_TYPE_LIVE_VIDEO
+ | MediaRouterJellybean.ROUTE_TYPE_USER;
+
+ private static final IntentFilter[] LIVE_AUDIO_CONTROL_FILTERS;
+ static {
+ LIVE_AUDIO_CONTROL_FILTERS = new IntentFilter[1];
+ LIVE_AUDIO_CONTROL_FILTERS[0] = new IntentFilter();
+ LIVE_AUDIO_CONTROL_FILTERS[0].addCategory(MediaControlIntent.CATEGORY_LIVE_AUDIO);
+ }
+
+ private static final IntentFilter[] LIVE_VIDEO_CONTROL_FILTERS;
+ static {
+ LIVE_VIDEO_CONTROL_FILTERS = new IntentFilter[1];
+ LIVE_VIDEO_CONTROL_FILTERS[0] = new IntentFilter();
+ LIVE_VIDEO_CONTROL_FILTERS[0].addCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO);
+ }
+
+ private static final IntentFilter[] ALL_CONTROL_FILTERS;
+ static {
+ ALL_CONTROL_FILTERS = new IntentFilter[1];
+ ALL_CONTROL_FILTERS[0] = new IntentFilter();
+ ALL_CONTROL_FILTERS[0].addCategory(MediaControlIntent.CATEGORY_LIVE_AUDIO);
+ ALL_CONTROL_FILTERS[0].addCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO);
+ }
+
+ private final SyncCallback mSyncCallback;
+ private Method mSelectRouteIntMethod;
+ private Method mGetSystemAudioRouteMethod;
+
+ protected final Object mRouterObj;
+ protected final Object mCallbackObj;
+ protected final Object mVolumeCallbackObj;
+ protected final Object mUserRouteCategoryObj;
+
+ // Maintains an association from framework routes to support library routes.
+ // Note that we cannot use the tag field for this because an application may
+ // have published its own user routes to the framework media router and already
+ // used the tag for its own purposes.
+ protected final ArrayList<SystemRouteRecord> mSystemRouteRecords =
+ new ArrayList<SystemRouteRecord>();
+
+ // Maintains an association from support library routes to framework routes.
+ protected final ArrayList<UserRouteRecord> mUserRouteRecords =
+ new ArrayList<UserRouteRecord>();
+
+ public JellybeanImpl(Context context, SyncCallback syncCallback) {
+ super(context);
+ mSyncCallback = syncCallback;
+ mRouterObj = MediaRouterJellybean.getMediaRouter(context);
+ mCallbackObj = createCallbackObj();
+ mVolumeCallbackObj = createVolumeCallbackObj();
+
+ Resources r = context.getResources();
+ mUserRouteCategoryObj = MediaRouterJellybean.createRouteCategory(
+ mRouterObj, r.getString(R.string.user_route_category_name), false);
+
+ addInitialSystemRoutes();
+ MediaRouterJellybean.addCallback(mRouterObj, ALL_ROUTE_TYPES, mCallbackObj);
+ }
+
+ @Override
+ public void onRouteAdded(Object routeObj) {
+ if (getUserRouteRecord(routeObj) == null) {
+ int index = findSystemRouteRecord(routeObj);
+ if (index < 0) {
+ addSystemRouteNoPublish(routeObj);
+ publishRoutes();
+ }
+ }
+ }
+
+ private void addInitialSystemRoutes() {
+ for (Object routeObj : MediaRouterJellybean.getRoutes(mRouterObj)) {
+ addSystemRouteNoPublish(routeObj);
+ }
+ publishRoutes();
+ }
+
+ private void addSystemRouteNoPublish(Object routeObj) {
+ if (getUserRouteRecord(routeObj) == null) {
+ boolean isDefault = (getDefaultRoute() == routeObj);
+ SystemRouteRecord record = new SystemRouteRecord(routeObj, isDefault);
+ updateSystemRouteDescriptor(record);
+ mSystemRouteRecords.add(record);
+ }
+ }
+
+ @Override
+ public void onRouteRemoved(Object routeObj) {
+ if (getUserRouteRecord(routeObj) == null) {
+ int index = findSystemRouteRecord(routeObj);
+ if (index >= 0) {
+ mSystemRouteRecords.remove(index);
+ publishRoutes();
+ }
+ }
+ }
+
+ @Override
+ public void onRouteChanged(Object routeObj) {
+ if (getUserRouteRecord(routeObj) == null) {
+ int index = findSystemRouteRecord(routeObj);
+ if (index >= 0) {
+ SystemRouteRecord record = mSystemRouteRecords.get(index);
+ updateSystemRouteDescriptor(record);
+ publishRoutes();
+ }
+ }
+ }
+
+ @Override
+ public void onRouteVolumeChanged(Object routeObj) {
+ if (getUserRouteRecord(routeObj) == null) {
+ int index = findSystemRouteRecord(routeObj);
+ if (index >= 0) {
+ SystemRouteRecord record = mSystemRouteRecords.get(index);
+ int newVolume = MediaRouterJellybean.RouteInfo.getVolume(routeObj);
+ if (newVolume != record.mRouteDescriptor.getVolume()) {
+ record.mRouteDescriptor = new RouteDescriptor(record.mRouteDescriptor);
+ record.mRouteDescriptor.setVolume(newVolume);
+ publishRoutes();
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onRouteSelected(int type, Object routeObj) {
+ if (routeObj != MediaRouterJellybean.getSelectedRoute(mRouterObj, ALL_ROUTE_TYPES)) {
+ // The currently selected route has already changed so this callback
+ // is stale. Drop it to prevent getting into sync loops.
+ return;
+ }
+
+ UserRouteRecord userRouteRecord = getUserRouteRecord(routeObj);
+ if (userRouteRecord != null) {
+ userRouteRecord.mRoute.select();
+ } else {
+ // Select the route if it already exists in the compat media router.
+ // If not, we will select it instead when the route is added.
+ int index = findSystemRouteRecord(routeObj);
+ if (index >= 0) {
+ SystemRouteRecord record = mSystemRouteRecords.get(index);
+ MediaRouter.RouteInfo route = mSyncCallback.getSystemRouteByDescriptorId(
+ record.mRouteDescriptorId);
+ if (route != null) {
+ route.select();
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onRouteUnselected(int type, Object routeObj) {
+ // Nothing to do when a route is unselected.
+ // We only need to handle when a route is selected.
+ }
+
+ @Override
+ public void onRouteGrouped(Object routeObj, Object groupObj, int index) {
+ // Route grouping is deprecated and no longer supported.
+ }
+
+ @Override
+ public void onRouteUngrouped(Object routeObj, Object groupObj) {
+ // Route grouping is deprecated and no longer supported.
+ }
+
+ @Override
+ public void onVolumeSetRequest(Object routeObj, int volume) {
+ UserRouteRecord record = getUserRouteRecord(routeObj);
+ if (record != null) {
+ record.mRoute.requestSetVolume(volume);
+ }
+ }
+
+ @Override
+ public void onVolumeUpdateRequest(Object routeObj, int direction) {
+ UserRouteRecord record = getUserRouteRecord(routeObj);
+ if (record != null) {
+ record.mRoute.requestUpdateVolume(direction);
+ }
+ }
+
+ @Override
+ public void onSyncRouteAdded(MediaRouter.RouteInfo route) {
+ if (route.getProviderInstance() != this) {
+ Object routeObj = MediaRouterJellybean.createUserRoute(
+ mRouterObj, mUserRouteCategoryObj);
+ UserRouteRecord record = new UserRouteRecord(route, routeObj);
+ MediaRouterJellybean.RouteInfo.setTag(routeObj, record);
+ MediaRouterJellybean.UserRouteInfo.setVolumeCallback(routeObj, mVolumeCallbackObj);
+ updateUserRouteProperties(record);
+ mUserRouteRecords.add(record);
+ MediaRouterJellybean.addUserRoute(mRouterObj, routeObj);
+ } else {
+ // If the newly added route is the counterpart of the currently selected
+ // route in the framework media router then ensure it is selected in
+ // the compat media router.
+ Object routeObj = MediaRouterJellybean.getSelectedRoute(
+ mRouterObj, ALL_ROUTE_TYPES);
+ int index = findSystemRouteRecord(routeObj);
+ if (index >= 0) {
+ SystemRouteRecord record = mSystemRouteRecords.get(index);
+ if (record.mRouteDescriptorId.equals(route.getDescriptorId())) {
+ route.select();
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onSyncRouteRemoved(MediaRouter.RouteInfo route) {
+ if (route.getProviderInstance() != this) {
+ int index = findUserRouteRecord(route);
+ if (index >= 0) {
+ UserRouteRecord record = mUserRouteRecords.remove(index);
+ MediaRouterJellybean.RouteInfo.setTag(record.mRouteObj, null);
+ MediaRouterJellybean.UserRouteInfo.setVolumeCallback(record.mRouteObj, null);
+ MediaRouterJellybean.removeUserRoute(mRouterObj, record.mRouteObj);
+ }
+ }
+ }
+
+ @Override
+ public void onSyncRouteChanged(MediaRouter.RouteInfo route) {
+ if (route.getProviderInstance() != this) {
+ int index = findUserRouteRecord(route);
+ if (index >= 0) {
+ UserRouteRecord record = mUserRouteRecords.get(index);
+ updateUserRouteProperties(record);
+ }
+ }
+ }
+
+ @Override
+ public void onSyncRouteSelected(MediaRouter.RouteInfo route) {
+ if (!route.isSelected()) {
+ // The currently selected route has already changed so this callback
+ // is stale. Drop it to prevent getting into sync loops.
+ return;
+ }
+
+ if (route.getProviderInstance() != this) {
+ int index = findUserRouteRecord(route);
+ if (index >= 0) {
+ UserRouteRecord record = mUserRouteRecords.get(index);
+ selectRoute(record.mRouteObj);
+ }
+ } else {
+ int index = findSystemRouteRecordByDescriptorId(route.getDescriptorId());
+ if (index >= 0) {
+ SystemRouteRecord record = mSystemRouteRecords.get(index);
+ selectRoute(record.mRouteObj);
+ }
+ }
+ }
+
+ protected void publishRoutes() {
+ int count = mSystemRouteRecords.size();
+ RouteDescriptor[] routeDescriptors = new RouteDescriptor[count];
+ for (int i = 0; i < count; i++) {
+ routeDescriptors[i] = mSystemRouteRecords.get(i).mRouteDescriptor;
+ }
+
+ ProviderDescriptor providerDescriptor = new ProviderDescriptor();
+ providerDescriptor.setRoutes(routeDescriptors);
+ setDescriptor(providerDescriptor);
+ }
+
+ protected int findSystemRouteRecord(Object routeObj) {
+ final int count = mSystemRouteRecords.size();
+ for (int i = 0; i < count; i++) {
+ if (mSystemRouteRecords.get(i).mRouteObj == routeObj) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ protected int findSystemRouteRecordByDescriptorId(String id) {
+ final int count = mSystemRouteRecords.size();
+ for (int i = 0; i < count; i++) {
+ if (mSystemRouteRecords.get(i).mRouteDescriptorId.equals(id)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ protected int findUserRouteRecord(MediaRouter.RouteInfo route) {
+ final int count = mUserRouteRecords.size();
+ for (int i = 0; i < count; i++) {
+ if (mUserRouteRecords.get(i).mRoute == route) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ protected UserRouteRecord getUserRouteRecord(Object routeObj) {
+ Object tag = MediaRouterJellybean.RouteInfo.getTag(routeObj);
+ return tag instanceof UserRouteRecord ? (UserRouteRecord)tag : null;
+ }
+
+ protected void updateSystemRouteDescriptor(SystemRouteRecord record) {
+ // We must always recreate the route descriptor when making any changes
+ // because they are intended to be immutable once published.
+
+ // Routes should not have null names but it may happen for badly configured
+ // user routes. We tolerate this by using an empty name string here but
+ // such unnamed routes will be discarded by the media router upstream
+ // (with a log message so we can track down the problem).
+ CharSequence name = MediaRouterJellybean.RouteInfo.getName(
+ record.mRouteObj, getContext());
+ record.mRouteDescriptor = new RouteDescriptor(
+ record.mRouteDescriptorId, name != null ? name.toString() : "");
+
+ int supportedTypes = MediaRouterJellybean.RouteInfo.getSupportedTypes(
+ record.mRouteObj);
+ if ((supportedTypes & MediaRouterJellybean.ROUTE_TYPE_LIVE_AUDIO) != 0) {
+ if ((supportedTypes & MediaRouterJellybean.ROUTE_TYPE_LIVE_VIDEO) != 0) {
+ record.mRouteDescriptor.setControlFilters(ALL_CONTROL_FILTERS);
+ } else {
+ record.mRouteDescriptor.setControlFilters(LIVE_AUDIO_CONTROL_FILTERS);
+ }
+ } else if ((supportedTypes & MediaRouterJellybean.ROUTE_TYPE_LIVE_VIDEO) != 0) {
+ record.mRouteDescriptor.setControlFilters(LIVE_VIDEO_CONTROL_FILTERS);
+ }
+
+ CharSequence status = MediaRouterJellybean.RouteInfo.getStatus(record.mRouteObj);
+ if (status != null) {
+ record.mRouteDescriptor.setStatus(status.toString());
+ }
+ record.mRouteDescriptor.setIconDrawable(
+ MediaRouterJellybean.RouteInfo.getIconDrawable(record.mRouteObj));
+ record.mRouteDescriptor.setPlaybackType(
+ MediaRouterJellybean.RouteInfo.getPlaybackType(record.mRouteObj));
+ record.mRouteDescriptor.setPlaybackStream(
+ MediaRouterJellybean.RouteInfo.getPlaybackStream(record.mRouteObj));
+ record.mRouteDescriptor.setVolume(
+ MediaRouterJellybean.RouteInfo.getVolume(record.mRouteObj));
+ record.mRouteDescriptor.setVolumeMax(
+ MediaRouterJellybean.RouteInfo.getVolumeMax(record.mRouteObj));
+ record.mRouteDescriptor.setVolumeHandling(
+ MediaRouterJellybean.RouteInfo.getVolumeHandling(record.mRouteObj));
+ }
+
+ protected void updateUserRouteProperties(UserRouteRecord record) {
+ MediaRouterJellybean.UserRouteInfo.setName(
+ record.mRouteObj, record.mRoute.getName());
+ MediaRouterJellybean.UserRouteInfo.setStatus(
+ record.mRouteObj, normalizeStatus(record.mRoute.getStatus()));
+ MediaRouterJellybean.UserRouteInfo.setIconDrawable(
+ record.mRouteObj, record.mRoute.getIconDrawable());
+ MediaRouterJellybean.UserRouteInfo.setPlaybackType(
+ record.mRouteObj, record.mRoute.getPlaybackType());
+ MediaRouterJellybean.UserRouteInfo.setPlaybackStream(
+ record.mRouteObj, record.mRoute.getPlaybackStream());
+ MediaRouterJellybean.UserRouteInfo.setVolume(
+ record.mRouteObj, record.mRoute.getVolume());
+ MediaRouterJellybean.UserRouteInfo.setVolumeMax(
+ record.mRouteObj, record.mRoute.getVolumeMax());
+ MediaRouterJellybean.UserRouteInfo.setVolumeHandling(
+ record.mRouteObj, record.mRoute.getVolumeHandling());
+ }
+
+ // The framework MediaRouter crashes if we set a null status even though
+ // RouteInfo.getStatus() may return null. So we need to use a different
+ // value instead.
+ private static String normalizeStatus(String status) {
+ return status != null ? status : "";
+ }
+
+ protected Object createCallbackObj() {
+ return MediaRouterJellybean.createCallback(this);
+ }
+
+ protected Object createVolumeCallbackObj() {
+ return MediaRouterJellybean.createVolumeCallback(this);
+ }
+
+ protected void selectRoute(Object routeObj) {
+ int types = MediaRouterJellybean.RouteInfo.getSupportedTypes(routeObj);
+ if ((types & MediaRouterJellybean.ROUTE_TYPE_USER) == 0) {
+ // Handle non-user routes.
+ // On JB and JB MR1, the selectRoute() API only supports programmatically
+ // selecting user routes. So instead we rely on the hidden selectRouteInt()
+ // method on these versions of the platform. This limitation was removed
+ // in JB MR2. See also the JellybeanMr2Impl implementation of this method.
+ if (mSelectRouteIntMethod == null) {
+ try {
+ mSelectRouteIntMethod = mRouterObj.getClass().getMethod(
+ "selectRouteInt", int.class, MediaRouterJellybean.RouteInfo.clazz);
+ } catch (NoSuchMethodException ex) {
+ Log.w(TAG, "Cannot programmatically select non-user route "
+ + "because the platform is missing the selectRouteInt() "
+ + "method. Media routing may not work.", ex);
+ return;
+ }
+ }
+ try {
+ mSelectRouteIntMethod.invoke(mRouterObj, ALL_ROUTE_TYPES, routeObj);
+ } catch (IllegalAccessException ex) {
+ Log.w(TAG, "Cannot programmatically select non-user route. "
+ + "Media routing may not work.", ex);
+ } catch (InvocationTargetException ex) {
+ Log.w(TAG, "Cannot programmatically select non-user route. "
+ + "Media routing may not work.", ex);
+ }
+ } else {
+ // Handle user routes.
+ MediaRouterJellybean.selectRoute(mRouterObj, ALL_ROUTE_TYPES, routeObj);
+ }
+ }
+
+ protected Object getDefaultRoute() {
+ // On JB and JB MR1, the getDefaultRoute() API does not exist.
+ // Instead there is a hidden getSystemAudioRoute() that does the same thing.
+ // See also the JellybeanMr2Impl implementation of this method.
+ if (mGetSystemAudioRouteMethod == null) {
+ try {
+ mGetSystemAudioRouteMethod = mRouterObj.getClass().getMethod(
+ "getSystemAudioRoute");
+ } catch (NoSuchMethodException ex) {
+ // Fall through.
+ }
+ }
+ if (mGetSystemAudioRouteMethod != null) {
+ try {
+ return mGetSystemAudioRouteMethod.invoke(mRouterObj);
+ } catch (IllegalAccessException ex) {
+ // Fall through.
+ } catch (InvocationTargetException ex) {
+ // Fall through.
+ }
+ }
+ // Could not find the method or it does not work.
+ // Return the first route and hope for the best.
+ return MediaRouterJellybean.getRoutes(mRouterObj).get(0);
+ }
+
+ /**
+ * Represents a route that is provided by the framework media router
+ * and published by this route provider to the support library media router.
+ */
+ protected static final class SystemRouteRecord {
+ private static int sNextId;
+
+ public final Object mRouteObj;
+ public final String mRouteDescriptorId;
+ public RouteDescriptor mRouteDescriptor; // assigned immediately after creation
+
+ public SystemRouteRecord(Object routeObj, boolean isDefault) {
+ mRouteObj = routeObj;
+ mRouteDescriptorId = isDefault ? DEFAULT_ROUTE_ID : "ROUTE_" + (sNextId++);
+ }
+ }
+
+ /**
+ * Represents a route that is provided by the support library media router
+ * and published by this route provider to the framework media router.
+ */
+ protected static final class UserRouteRecord {
+ public final MediaRouter.RouteInfo mRoute;
+ public final Object mRouteObj;
+
+ public UserRouteRecord(MediaRouter.RouteInfo route, Object routeObj) {
+ mRoute = route;
+ mRouteObj = routeObj;
+ }
+ }
+ }
+
+ /**
+ * Jellybean MR1 implementation.
+ */
+ private static class JellybeanMr1Impl extends JellybeanImpl
+ implements MediaRouterJellybeanMr1.Callback {
+ public JellybeanMr1Impl(Context context, SyncCallback syncCallback) {
+ super(context, syncCallback);
+ }
+
+ @Override
+ public void onRoutePresentationDisplayChanged(Object routeObj) {
+ int index = findSystemRouteRecord(routeObj);
+ if (index >= 0) {
+ SystemRouteRecord record = mSystemRouteRecords.get(index);
+ Display newPresentationDisplay =
+ MediaRouterJellybeanMr1.RouteInfo.getPresentationDisplay(routeObj);
+ int newPresentationDisplayId = (newPresentationDisplay != null
+ ? newPresentationDisplay.getDisplayId() : -1);
+ if (newPresentationDisplayId
+ != record.mRouteDescriptor.getPresentationDisplayId()) {
+ record.mRouteDescriptor = new RouteDescriptor(record.mRouteDescriptor);
+ record.mRouteDescriptor.setPresentationDisplayId(newPresentationDisplayId);
+ publishRoutes();
+ }
+ }
+ }
+
+ @Override
+ protected void updateSystemRouteDescriptor(SystemRouteRecord record) {
+ super.updateSystemRouteDescriptor(record);
+
+ if (!MediaRouterJellybeanMr1.RouteInfo.isEnabled(record.mRouteObj)) {
+ record.mRouteDescriptor.setEnabled(false);
+ }
+ Display presentationDisplay =
+ MediaRouterJellybeanMr1.RouteInfo.getPresentationDisplay(record.mRouteObj);
+ if (presentationDisplay != null) {
+ record.mRouteDescriptor.setPresentationDisplayId(
+ presentationDisplay.getDisplayId());
+ }
+ }
+
+ @Override
+ protected Object createCallbackObj() {
+ return MediaRouterJellybeanMr1.createCallback(this);
+ }
+ }
+
+ /**
+ * Jellybean MR2 implementation.
+ */
+ private static class JellybeanMr2Impl extends JellybeanMr1Impl {
+ public JellybeanMr2Impl(Context context, SyncCallback syncCallback) {
+ super(context, syncCallback);
+ }
+
+ @Override
+ protected void selectRoute(Object routeObj) {
+ MediaRouterJellybean.selectRoute(mRouterObj, ALL_ROUTE_TYPES, routeObj);
+ }
+
+ @Override
+ protected Object getDefaultRoute() {
+ return MediaRouterJellybeanMr2.getDefaultRoute(mRouterObj);
+ }
+ }
+}