From 6621c917a09d5e20208d9e9a0065a77362df522e Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Thu, 24 Oct 2013 13:07:24 -0700 Subject: [PATCH 01/10] Add new phone type (public API) DO NOT MERGE This CL adds a new public API to allow services to implement calls. Change-Id: Ic57f39dfce070cce43c2b4e0f023b0e50ee60718 --- Android.mk | 3 + api/current.txt | 43 +++++++++ .../android/telephony/TelephonyManager.java | 16 ++++ .../telephony/ThirdPartyCallListener.java | 89 +++++++++++++++++ .../telephony/ThirdPartyCallProvider.java | 87 +++++++++++++++++ .../telephony/ThirdPartyCallService.java | 96 +++++++++++++++++++ .../internal/telephony/ITelephony.aidl | 13 ++- .../telephony/IThirdPartyCallListener.aidl | 46 +++++++++ .../telephony/IThirdPartyCallProvider.aidl | 41 ++++++++ .../telephony/IThirdPartyCallService.aidl | 35 +++++++ .../internal/telephony/PhoneConstants.java | 1 + .../internal/telephony/RILConstants.java | 1 + 12 files changed, 469 insertions(+), 2 deletions(-) create mode 100644 telephony/java/android/telephony/ThirdPartyCallListener.java create mode 100644 telephony/java/android/telephony/ThirdPartyCallProvider.java create mode 100644 telephony/java/android/telephony/ThirdPartyCallService.java create mode 100644 telephony/java/com/android/internal/telephony/IThirdPartyCallListener.aidl create mode 100644 telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl create mode 100644 telephony/java/com/android/internal/telephony/IThirdPartyCallService.aidl diff --git a/Android.mk b/Android.mk index bcab2761dea1c..45639aba3776e 100644 --- a/Android.mk +++ b/Android.mk @@ -264,6 +264,9 @@ LOCAL_SRC_FILES += \ telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \ telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ + telephony/java/com/android/internal/telephony/IThirdPartyCallListener.aidl \ + telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl \ + telephony/java/com/android/internal/telephony/IThirdPartyCallService.aidl \ telephony/java/com/android/internal/telephony/ISms.aidl \ telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl \ telephony/java/com/android/internal/telephony/IWapPushManager.aidl \ diff --git a/api/current.txt b/api/current.txt index 9f80ef62a140c..d3fd7d43e4ed5 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24085,6 +24085,7 @@ package android.telephony { method public boolean hasIccCard(); method public boolean isNetworkRoaming(); method public void listen(android.telephony.PhoneStateListener, int); + method public void newIncomingThirdPartyCall(android.content.ComponentName, java.lang.String); field public static final java.lang.String ACTION_PHONE_STATE_CHANGED = "android.intent.action.PHONE_STATE"; field public static final java.lang.String ACTION_RESPOND_VIA_MESSAGE = "android.intent.action.RESPOND_VIA_MESSAGE"; field public static final int CALL_STATE_IDLE = 0; // 0x0 @@ -24132,6 +24133,31 @@ package android.telephony { field public static final int SIM_STATE_UNKNOWN = 0; // 0x0 } + public class ThirdPartyCallListener { + ctor public ThirdPartyCallListener(com.android.internal.telephony.IThirdPartyCallListener); + method public void onCallEnded(int); + method public void onCallEstablished(); + method public void onCallProviderAttached(android.telephony.ThirdPartyCallProvider); + method public void onRingingStarted(); + field public static final int CALL_END_INCOMING_MISSED = 2; // 0x2 + field public static final int CALL_END_NORMAL = 1; // 0x1 + field public static final int CALL_END_OTHER = 3; // 0x3 + } + + public class ThirdPartyCallProvider { + ctor public ThirdPartyCallProvider(); + method public void hangup(); + method public void incomingCallAccept(); + method public void mute(boolean); + } + + public class ThirdPartyCallService { + ctor public ThirdPartyCallService(); + method public android.os.IBinder getBinder(); + method public void incomingCallAttach(android.telephony.ThirdPartyCallListener, java.lang.String); + method public void outgoingCallInitiate(android.telephony.ThirdPartyCallListener, java.lang.String); + } + } package android.telephony.cdma { @@ -33527,6 +33553,23 @@ package android.widget { } +package com.android.internal.telephony { + + public abstract interface IThirdPartyCallListener implements android.os.IInterface { + method public abstract void onCallEnded(int) throws android.os.RemoteException; + method public abstract void onCallEstablished() throws android.os.RemoteException; + method public abstract void onCallProviderAttached(com.android.internal.telephony.IThirdPartyCallProvider) throws android.os.RemoteException; + method public abstract void onRingingStarted() throws android.os.RemoteException; + } + + public abstract interface IThirdPartyCallProvider implements android.os.IInterface { + method public abstract void hangup() throws android.os.RemoteException; + method public abstract void incomingCallAccept() throws android.os.RemoteException; + method public abstract void mute(boolean) throws android.os.RemoteException; + } + +} + package com.android.internal.util { public abstract interface Predicate { diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 8f17e72799245..b0f7dcfc90227 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -18,6 +18,7 @@ package android.telephony; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; +import android.content.ComponentName; import android.content.Context; import android.os.Bundle; import android.os.RemoteException; @@ -1422,6 +1423,21 @@ public class TelephonyManager { } } + /** + * Inform the phone about a new incoming third party call. The phone will bind to the service + * identified by component to handle the call. + * @param component the component that should handle the intent. + * @param callId the unique id of the call. This id is passed to the service via {@link + * ThirdPartyCallService#incomingCallAttach incomingCallAttach}. + */ + public void newIncomingThirdPartyCall(ComponentName component, String callId) { + try { + getITelephony().newIncomingThirdPartyCall(component, callId); + } catch (RemoteException ex) { + } catch (NullPointerException ex) { + } + } + /** * Returns the MMS user agent. */ diff --git a/telephony/java/android/telephony/ThirdPartyCallListener.java b/telephony/java/android/telephony/ThirdPartyCallListener.java new file mode 100644 index 0000000000000..08f8d3aa13f4f --- /dev/null +++ b/telephony/java/android/telephony/ThirdPartyCallListener.java @@ -0,0 +1,89 @@ +/* + * 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.telephony; + +import android.os.Handler; +import android.os.Message; +import android.os.RemoteException; + +import com.android.internal.telephony.IThirdPartyCallListener; + +/** + * Interface provided to {@link android.telephony.ThirdPartyCallService}. The service can use this + * to notify the listener of changes to the call state. + */ +public class ThirdPartyCallListener { + private final IThirdPartyCallListener mListener; + + // Call end reason. + public static final int CALL_END_NORMAL = 1; + public static final int CALL_END_INCOMING_MISSED = 2; + public static final int CALL_END_OTHER = 3; + + public ThirdPartyCallListener(IThirdPartyCallListener listener) { + mListener = listener; + } + + /** + * Called by the service when a call provider is available to perform the outgoing or incoming + * call. + */ + public void onCallProviderAttached(ThirdPartyCallProvider callProvider) { + try { + if (mListener != null) { + mListener.onCallProviderAttached(callProvider.callback); + } + } catch (RemoteException e) { + } + } + + /** + * Notifies the listener that ringing has started for this call. + */ + public void onRingingStarted() { + try { + if (mListener != null) { + mListener.onRingingStarted(); + } + } catch (RemoteException e) { + } + } + + /** + * Notifies the listener that the call has been successfully established. + */ + public void onCallEstablished() { + try { + if (mListener != null) { + mListener.onCallEstablished(); + } + } catch (RemoteException e) { + } + } + + /** + * Notifies the listener that the call has ended. + */ + public void onCallEnded(int reason) { + try { + if (mListener != null) { + mListener.onCallEnded(reason); + } + } catch (RemoteException e) { + } + } +} diff --git a/telephony/java/android/telephony/ThirdPartyCallProvider.java b/telephony/java/android/telephony/ThirdPartyCallProvider.java new file mode 100644 index 0000000000000..9d3f929a22bc7 --- /dev/null +++ b/telephony/java/android/telephony/ThirdPartyCallProvider.java @@ -0,0 +1,87 @@ +/* + * 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.telephony; + +import android.os.Handler; +import android.os.Message; + +import com.android.internal.telephony.IThirdPartyCallProvider; + +/** + * Interface sent to {@link android.telephony.ThirdPartyCallListener#onCallProviderAttached + * onCallProviderAttached}. This is used to control an outgoing or an incoming call. + */ +public class ThirdPartyCallProvider { + private static final int MSG_MUTE = 1; + private static final int MSG_HANGUP = 2; + private static final int MSG_INCOMING_CALL_ACCEPT = 3; + + /** + * Mutes or unmutes the call. + */ + public void mute(boolean shouldMute) { + // default implementation empty + } + + /** + * Ends the current call. If this is an unanswered incoming call then the call is rejected. + */ + public void hangup() { + // default implementation empty + } + + /** + * Accepts the incoming call. + */ + public void incomingCallAccept() { + // default implementation empty + } + + final IThirdPartyCallProvider callback = new IThirdPartyCallProvider.Stub() { + @Override + public void mute(boolean shouldMute) { + Message.obtain(mHandler, MSG_MUTE, shouldMute ? 1 : 0, 0).sendToTarget(); + } + + @Override + public void hangup() { + Message.obtain(mHandler, MSG_HANGUP).sendToTarget(); + } + + @Override + public void incomingCallAccept() { + Message.obtain(mHandler, MSG_INCOMING_CALL_ACCEPT).sendToTarget(); + } + }; + + private final Handler mHandler = new Handler() { + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case MSG_MUTE: + mute(msg.arg1 != 0); + break; + case MSG_HANGUP: + hangup(); + break; + case MSG_INCOMING_CALL_ACCEPT: + incomingCallAccept(); + break; + } + } + }; +} diff --git a/telephony/java/android/telephony/ThirdPartyCallService.java b/telephony/java/android/telephony/ThirdPartyCallService.java new file mode 100644 index 0000000000000..de6c2903dcd6c --- /dev/null +++ b/telephony/java/android/telephony/ThirdPartyCallService.java @@ -0,0 +1,96 @@ +/* + * 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.telephony; + +import android.os.Handler; +import android.os.IBinder; +import android.os.Message; +import android.os.RemoteException; +import android.util.Pair; + +import com.android.internal.telephony.IThirdPartyCallListener; +import com.android.internal.telephony.IThirdPartyCallService; + +/** + * Interface provided by a service to start outgoing calls and attach to incoming calls. + */ +public class ThirdPartyCallService { + private static final int MSG_OUTGOING_CALL_INITIATE = 1; + private static final int MSG_INCOMING_CALL_ATTACH = 2; + + /** + * Call to start a new outgoing call. + */ + public void outgoingCallInitiate(ThirdPartyCallListener listener, String number) { + // default implementation empty + } + + /** + * Call to attach to an incoming call. This is in response to a call to {@link + * android.telephony.TelephonyManager#newIncomingThirdPartyCall newIncomingThirdPartyCall}. + */ + public void incomingCallAttach(ThirdPartyCallListener listener, String callId) { + // default implementation empty + } + + /** + * Returns an IBinder instance that can returned from the service's onBind function. + */ + public IBinder getBinder() { + return callback; + } + + private final IThirdPartyCallService.Stub callback = new IThirdPartyCallService.Stub() { + @Override + public void outgoingCallInitiate(IThirdPartyCallListener listener, String number) { + Rlog.w("ThirdPartyPhone", "ThirdPartyCallService.IThirdPartyCallService.out"); + Message.obtain(mHandler, MSG_OUTGOING_CALL_INITIATE, + Pair.create(listener, number)).sendToTarget(); + } + + @Override + public void incomingCallAttach(IThirdPartyCallListener listener, String callId) { + Rlog.w("ThirdPartyPhone", "ThirdPartyCallService.IThirdPartyCallService.in"); + Message.obtain(mHandler, MSG_INCOMING_CALL_ATTACH, + Pair.create(listener, callId)).sendToTarget(); + } + }; + + private final Handler mHandler = new Handler() { + public void handleMessage(Message msg) { + Rlog.w("ThirdPartyPhone", "ThirdPartyCallService.handleMessage: " + msg.what); + switch (msg.what) { + case MSG_OUTGOING_CALL_INITIATE: { + Rlog.w("ThirdPartyPhone", "ThirdPartyCallService.handleMessage out"); + Pair pair = + (Pair) msg.obj; + ThirdPartyCallListener listener = new ThirdPartyCallListener(pair.first); + outgoingCallInitiate(listener, pair.second); + break; + } + case MSG_INCOMING_CALL_ATTACH: { + Rlog.w("ThirdPartyPhone", "ThirdPartyCallService.handleMessage in"); + Pair pair = + (Pair) msg.obj; + ThirdPartyCallListener listener = new ThirdPartyCallListener(pair.first); + incomingCallAttach(listener, pair.second); + break; + } + } + } + }; +} diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 7bd2c8412e979..69a44289f6cf7 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -17,10 +17,12 @@ package com.android.internal.telephony; import android.os.Bundle; -import java.util.List; +import android.content.ComponentName; import android.telephony.NeighboringCellInfo; import android.telephony.CellInfo; +import java.util.List; + /** * Interface used to interact with the phone. Mostly this is used by the * TelephonyManager class. A few places are still using this directly. @@ -324,5 +326,12 @@ interface ITelephony { * Sets minimum time in milli-seconds between onCellInfoChanged */ void setCellInfoListRate(int rateInMillis); -} + /** + * Inform the phone about a new incoming third party call. The phone will bind to the service + * identified by component to handle the call. + * @param component the component that should handle the intent. + * @param callId the unique id of the call. + */ + void newIncomingThirdPartyCall(in ComponentName component, String callId); +} diff --git a/telephony/java/com/android/internal/telephony/IThirdPartyCallListener.aidl b/telephony/java/com/android/internal/telephony/IThirdPartyCallListener.aidl new file mode 100644 index 0000000000000..bcf2d81d9b636 --- /dev/null +++ b/telephony/java/com/android/internal/telephony/IThirdPartyCallListener.aidl @@ -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 com.android.internal.telephony; + +import com.android.internal.telephony.IThirdPartyCallProvider; + +/** + * Interface provided to ThirdPartyCallService. The service can use this to notify the listener of + * changes to the call state. + */ +oneway interface IThirdPartyCallListener { + /** + * Called by the service when a call provider is available to perform the outgoing or incoming + * call. + */ + void onCallProviderAttached(IThirdPartyCallProvider callProvider); + + /** + * Notifies the listener that ringing has started for this call. + */ + void onRingingStarted(); + + /** + * Notifies the listener that the call has been successfully established. + */ + void onCallEstablished(); + + /** + * Notifies the listener that the call has ended. + */ + void onCallEnded(int reason); +} diff --git a/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl b/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl new file mode 100644 index 0000000000000..dcbf877a587ac --- /dev/null +++ b/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl @@ -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 com.android.internal.telephony; + +import com.android.internal.telephony.IThirdPartyCallListener; + +/** + * Interface sent to ThirdPartyCallListener.onCallProviderAttached. This is used to control an + * outgoing or incoming call. + */ +oneway interface IThirdPartyCallProvider { + /** + * Mutes or unmutes the call. + */ + void mute(boolean shouldMute); + + /** + * Ends the current call. If this is an unanswered incoming call then the call is rejected (for + * example, a notification is sent to a server that the user declined the call). + */ + void hangup(); + + /** + * Accepts the incoming call. + */ + void incomingCallAccept(); +} diff --git a/telephony/java/com/android/internal/telephony/IThirdPartyCallService.aidl b/telephony/java/com/android/internal/telephony/IThirdPartyCallService.aidl new file mode 100644 index 0000000000000..597567af02eae --- /dev/null +++ b/telephony/java/com/android/internal/telephony/IThirdPartyCallService.aidl @@ -0,0 +1,35 @@ +/* + * 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 com.android.internal.telephony; + +import com.android.internal.telephony.IThirdPartyCallListener; + +/** + * Interface provided by a service to start outgoing calls and attach to incoming calls. + */ +oneway interface IThirdPartyCallService { + /** + * Call to start a new outgoing call. + */ + void outgoingCallInitiate(IThirdPartyCallListener listener, String number); + + /** + * Call to attach to an incoming call. This is in response to a call to + * TelephonyManager.newIncomingThirdPartyCall. + */ + void incomingCallAttach(IThirdPartyCallListener listener, String callId); +} diff --git a/telephony/java/com/android/internal/telephony/PhoneConstants.java b/telephony/java/com/android/internal/telephony/PhoneConstants.java index 416325591352b..fe8f03181a112 100644 --- a/telephony/java/com/android/internal/telephony/PhoneConstants.java +++ b/telephony/java/com/android/internal/telephony/PhoneConstants.java @@ -57,6 +57,7 @@ public class PhoneConstants { public static final int PHONE_TYPE_GSM = RILConstants.GSM_PHONE; public static final int PHONE_TYPE_CDMA = RILConstants.CDMA_PHONE; public static final int PHONE_TYPE_SIP = RILConstants.SIP_PHONE; + public static final int PHONE_TYPE_THIRD_PARTY = RILConstants.THIRD_PARTY_PHONE; // Modes for LTE_ON_CDMA public static final int LTE_ON_CDMA_UNKNOWN = RILConstants.LTE_ON_CDMA_UNKNOWN; diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java index 821a11cb3b0bf..71c3bec071112 100644 --- a/telephony/java/com/android/internal/telephony/RILConstants.java +++ b/telephony/java/com/android/internal/telephony/RILConstants.java @@ -82,6 +82,7 @@ public interface RILConstants { int GSM_PHONE = 1; int CDMA_PHONE = 2; int SIP_PHONE = 3; + int THIRD_PARTY_PHONE = 4; int LTE_ON_CDMA_UNKNOWN = -1; int LTE_ON_CDMA_FALSE = 0; From 1dc5b4e87bdb7b9d9767aadd15ad25326fb28071 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Wed, 13 Nov 2013 09:14:49 -0800 Subject: [PATCH 02/10] ThirdPartyPhone: DTMF & callerDisplayName API DO NOT MERGE This CL extends the ThirdPartyCall API to support DTMF and callerDisplayname. Change-Id: I4bb43273243af6b41d63dde69c982891f160c035 --- api/current.txt | 4 +++- .../java/android/telephony/TelephonyManager.java | 7 +++++-- .../telephony/ThirdPartyCallProvider.java | 16 ++++++++++++++++ .../android/internal/telephony/ITelephony.aidl | 5 ++++- .../telephony/IThirdPartyCallProvider.aidl | 5 +++++ 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/api/current.txt b/api/current.txt index 964f1e8d68b00..88eec1af17a14 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24088,7 +24088,7 @@ package android.telephony { method public boolean hasIccCard(); method public boolean isNetworkRoaming(); method public void listen(android.telephony.PhoneStateListener, int); - method public void newIncomingThirdPartyCall(android.content.ComponentName, java.lang.String); + method public void newIncomingThirdPartyCall(android.content.ComponentName, java.lang.String, java.lang.String); field public static final java.lang.String ACTION_PHONE_STATE_CHANGED = "android.intent.action.PHONE_STATE"; field public static final java.lang.String ACTION_RESPOND_VIA_MESSAGE = "android.intent.action.RESPOND_VIA_MESSAGE"; field public static final int CALL_STATE_IDLE = 0; // 0x0 @@ -24152,6 +24152,7 @@ package android.telephony { method public void hangup(); method public void incomingCallAccept(); method public void mute(boolean); + method public void sendDtmf(char); } public class ThirdPartyCallService { @@ -33574,6 +33575,7 @@ package com.android.internal.telephony { method public abstract void hangup() throws android.os.RemoteException; method public abstract void incomingCallAccept() throws android.os.RemoteException; method public abstract void mute(boolean) throws android.os.RemoteException; + method public abstract void sendDtmf(char) throws android.os.RemoteException; } } diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index b0f7dcfc90227..42b2b8ccc4415 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -1429,10 +1429,13 @@ public class TelephonyManager { * @param component the component that should handle the intent. * @param callId the unique id of the call. This id is passed to the service via {@link * ThirdPartyCallService#incomingCallAttach incomingCallAttach}. + * @param callerDisplayName the name shown to the user. Normally this will be the caller's phone + * number. */ - public void newIncomingThirdPartyCall(ComponentName component, String callId) { + public void newIncomingThirdPartyCall(ComponentName component, String callId, + String callerDisplayName) { try { - getITelephony().newIncomingThirdPartyCall(component, callId); + getITelephony().newIncomingThirdPartyCall(component, callId, callerDisplayName); } catch (RemoteException ex) { } catch (NullPointerException ex) { } diff --git a/telephony/java/android/telephony/ThirdPartyCallProvider.java b/telephony/java/android/telephony/ThirdPartyCallProvider.java index 9d3f929a22bc7..74b9ae373485f 100644 --- a/telephony/java/android/telephony/ThirdPartyCallProvider.java +++ b/telephony/java/android/telephony/ThirdPartyCallProvider.java @@ -29,6 +29,7 @@ public class ThirdPartyCallProvider { private static final int MSG_MUTE = 1; private static final int MSG_HANGUP = 2; private static final int MSG_INCOMING_CALL_ACCEPT = 3; + private static final int MSG_SEND_DTMF = 4; /** * Mutes or unmutes the call. @@ -51,6 +52,13 @@ public class ThirdPartyCallProvider { // default implementation empty } + /** + * Sends the given DTMF code. The code can be '0'-'9', 'A'-'D', '#', or '*'. + */ + public void sendDtmf(char c) { + // default implementation empty + } + final IThirdPartyCallProvider callback = new IThirdPartyCallProvider.Stub() { @Override public void mute(boolean shouldMute) { @@ -66,6 +74,11 @@ public class ThirdPartyCallProvider { public void incomingCallAccept() { Message.obtain(mHandler, MSG_INCOMING_CALL_ACCEPT).sendToTarget(); } + + @Override + public void sendDtmf(char c) { + Message.obtain(mHandler, MSG_SEND_DTMF, (int) c, 0).sendToTarget(); + } }; private final Handler mHandler = new Handler() { @@ -81,6 +94,9 @@ public class ThirdPartyCallProvider { case MSG_INCOMING_CALL_ACCEPT: incomingCallAccept(); break; + case MSG_SEND_DTMF: + sendDtmf((char) msg.arg1); + break; } } }; diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 69a44289f6cf7..d81cab3069694 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -332,6 +332,9 @@ interface ITelephony { * identified by component to handle the call. * @param component the component that should handle the intent. * @param callId the unique id of the call. + * @param callerDisplayName the name shown to the user. Normally this will be the caller's phone + * number. */ - void newIncomingThirdPartyCall(in ComponentName component, String callId); + void newIncomingThirdPartyCall(in ComponentName component, String callId, + String callerDisplayName); } diff --git a/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl b/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl index dcbf877a587ac..a9d67a4e91f7d 100644 --- a/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl +++ b/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl @@ -38,4 +38,9 @@ oneway interface IThirdPartyCallProvider { * Accepts the incoming call. */ void incomingCallAccept(); + + /** + * Sends the given DTMF code. The code can be '0'-'9', 'A'-'D', '#', or '*'. + */ + void sendDtmf(char c); } From fc2a0a34d64baa9a9c793c68a06d75d8ca0e8e41 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Fri, 15 Nov 2013 13:23:45 -0800 Subject: [PATCH 03/10] DO NOT MERGE ThirdPartyCallSendDtmfCallBack API This API is needed to implement post dial. Change-Id: I013382a910948b3934ae128288f47bcf73c68f8c --- Android.mk | 1 + api/current.txt | 13 +++++- .../telephony/ThirdPartyCallProvider.java | 11 +++-- .../ThirdPartyCallSendDtmfCallback.java | 46 +++++++++++++++++++ .../telephony/IThirdPartyCallProvider.aidl | 3 +- .../IThirdPartyCallSendDtmfCallback.aidl | 27 +++++++++++ 6 files changed, 94 insertions(+), 7 deletions(-) create mode 100644 telephony/java/android/telephony/ThirdPartyCallSendDtmfCallback.java create mode 100644 telephony/java/com/android/internal/telephony/IThirdPartyCallSendDtmfCallback.aidl diff --git a/Android.mk b/Android.mk index 8b137eaeb7ff2..8c4d5242f8bc0 100644 --- a/Android.mk +++ b/Android.mk @@ -270,6 +270,7 @@ LOCAL_SRC_FILES += \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ telephony/java/com/android/internal/telephony/IThirdPartyCallListener.aidl \ telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl \ + telephony/java/com/android/internal/telephony/IThirdPartyCallSendDtmfCallback.aidl \ telephony/java/com/android/internal/telephony/IThirdPartyCallService.aidl \ telephony/java/com/android/internal/telephony/ISms.aidl \ telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl \ diff --git a/api/current.txt b/api/current.txt index 88eec1af17a14..e2a847d189a07 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24152,7 +24152,12 @@ package android.telephony { method public void hangup(); method public void incomingCallAccept(); method public void mute(boolean); - method public void sendDtmf(char); + method public void sendDtmf(char, android.telephony.ThirdPartyCallSendDtmfCallback); + } + + public class ThirdPartyCallSendDtmfCallback { + ctor public ThirdPartyCallSendDtmfCallback(com.android.internal.telephony.IThirdPartyCallSendDtmfCallback); + method public void onSendDtmfCompleted(); } public class ThirdPartyCallService { @@ -33575,7 +33580,11 @@ package com.android.internal.telephony { method public abstract void hangup() throws android.os.RemoteException; method public abstract void incomingCallAccept() throws android.os.RemoteException; method public abstract void mute(boolean) throws android.os.RemoteException; - method public abstract void sendDtmf(char) throws android.os.RemoteException; + method public abstract void sendDtmf(char, com.android.internal.telephony.IThirdPartyCallSendDtmfCallback) throws android.os.RemoteException; + } + + public abstract interface IThirdPartyCallSendDtmfCallback implements android.os.IInterface { + method public abstract void onSendDtmfCompleted() throws android.os.RemoteException; } } diff --git a/telephony/java/android/telephony/ThirdPartyCallProvider.java b/telephony/java/android/telephony/ThirdPartyCallProvider.java index 74b9ae373485f..5054380f51343 100644 --- a/telephony/java/android/telephony/ThirdPartyCallProvider.java +++ b/telephony/java/android/telephony/ThirdPartyCallProvider.java @@ -20,6 +20,7 @@ import android.os.Handler; import android.os.Message; import com.android.internal.telephony.IThirdPartyCallProvider; +import com.android.internal.telephony.IThirdPartyCallSendDtmfCallback; /** * Interface sent to {@link android.telephony.ThirdPartyCallListener#onCallProviderAttached @@ -55,7 +56,7 @@ public class ThirdPartyCallProvider { /** * Sends the given DTMF code. The code can be '0'-'9', 'A'-'D', '#', or '*'. */ - public void sendDtmf(char c) { + public void sendDtmf(char c, ThirdPartyCallSendDtmfCallback callback) { // default implementation empty } @@ -76,8 +77,8 @@ public class ThirdPartyCallProvider { } @Override - public void sendDtmf(char c) { - Message.obtain(mHandler, MSG_SEND_DTMF, (int) c, 0).sendToTarget(); + public void sendDtmf(char c, IThirdPartyCallSendDtmfCallback callback) { + Message.obtain(mHandler, MSG_SEND_DTMF, (int) c, 0, callback).sendToTarget(); } }; @@ -95,7 +96,9 @@ public class ThirdPartyCallProvider { incomingCallAccept(); break; case MSG_SEND_DTMF: - sendDtmf((char) msg.arg1); + ThirdPartyCallSendDtmfCallback callback = new ThirdPartyCallSendDtmfCallback( + (IThirdPartyCallSendDtmfCallback) msg.obj); + sendDtmf((char) msg.arg1, callback); break; } } diff --git a/telephony/java/android/telephony/ThirdPartyCallSendDtmfCallback.java b/telephony/java/android/telephony/ThirdPartyCallSendDtmfCallback.java new file mode 100644 index 0000000000000..5a67cf76bf98d --- /dev/null +++ b/telephony/java/android/telephony/ThirdPartyCallSendDtmfCallback.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.telephony; + +import android.os.RemoteException; + +import com.android.internal.telephony.IThirdPartyCallSendDtmfCallback; + +/** + * Callback interface for when DTMF has been sent. + */ +public class ThirdPartyCallSendDtmfCallback { + private final IThirdPartyCallSendDtmfCallback mCallback; + + public ThirdPartyCallSendDtmfCallback(IThirdPartyCallSendDtmfCallback callback) { + if (callback == null) { + throw new IllegalArgumentException("Invalid callback"); + } + mCallback = callback; + } + + /** + * Called by the service when a call provider is available to perform the outgoing or incoming + * call. + */ + public void onSendDtmfCompleted() { + try { + mCallback.onSendDtmfCompleted(); + } catch (RemoteException e) { + } + } +} diff --git a/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl b/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl index a9d67a4e91f7d..9d595b0b1b5a1 100644 --- a/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl +++ b/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl @@ -17,6 +17,7 @@ package com.android.internal.telephony; import com.android.internal.telephony.IThirdPartyCallListener; +import com.android.internal.telephony.IThirdPartyCallSendDtmfCallback; /** * Interface sent to ThirdPartyCallListener.onCallProviderAttached. This is used to control an @@ -42,5 +43,5 @@ oneway interface IThirdPartyCallProvider { /** * Sends the given DTMF code. The code can be '0'-'9', 'A'-'D', '#', or '*'. */ - void sendDtmf(char c); + void sendDtmf(char c, IThirdPartyCallSendDtmfCallback callback); } diff --git a/telephony/java/com/android/internal/telephony/IThirdPartyCallSendDtmfCallback.aidl b/telephony/java/com/android/internal/telephony/IThirdPartyCallSendDtmfCallback.aidl new file mode 100644 index 0000000000000..3a02b06055d06 --- /dev/null +++ b/telephony/java/com/android/internal/telephony/IThirdPartyCallSendDtmfCallback.aidl @@ -0,0 +1,27 @@ +/* + * 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 com.android.internal.telephony; + +/** + * Callback interface for when DTMF has been sent. + */ +oneway interface IThirdPartyCallSendDtmfCallback { + /** + * Called when the DTMF code has been sent. + */ + void onSendDtmfCompleted(); +} From c62180949f3b1a39b2625b3381f998ff60537e46 Mon Sep 17 00:00:00 2001 From: Ihab Awad Date: Mon, 25 Nov 2013 11:31:46 -0800 Subject: [PATCH 04/10] Add Wi-Fi calling state setting to telephony interfaces Change-Id: I73e643c00c7c00182cc4650053d098b6e40a8a5f --- core/java/android/provider/Settings.java | 8 ++++ .../android/telephony/TelephonyManager.java | 42 ++++++++++++++++++- .../internal/telephony/ITelephony.aidl | 14 +++++++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 0dffc17bda128..69ab166caef4b 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -2483,6 +2483,14 @@ public final class Settings { NOTIFICATION_SOUND }; + /** + * When to use Wi-Fi calling + * + * @see android.telephony.TelephonyManager.WifiCallingChoices + * @hide + */ + public static final String WHEN_TO_MAKE_WIFI_CALLS = "when_to_make_wifi_calls"; + // Settings moved to Settings.Secure /** diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 42b2b8ccc4415..37cd4f8d3640c 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -24,7 +24,6 @@ import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemProperties; -import android.telephony.Rlog; import com.android.internal.telephony.IPhoneSubInfo; import com.android.internal.telephony.ITelephony; @@ -63,6 +62,20 @@ public class TelephonyManager { private static ITelephonyRegistry sRegistry; private final Context mContext; + /** + * The allowed states of Wi-Fi calling. + * + * @hide + */ + public interface WifiCallingChoices { + /** Always use Wi-Fi calling */ + static final int ALWAYS_USE = 0; + /** Never use Wi-Fi calling */ + static final int NEVER_USE = 1; + /** Ask the user whether to use Wi-Fi on every call */ + static final int ASK_EVERY_TIME = 2; + } + /** @hide */ public TelephonyManager(Context context) { Context appContext = context.getApplicationContext(); @@ -1458,4 +1471,31 @@ public class TelephonyManager { return mContext.getResources().getString( com.android.internal.R.string.config_mms_user_agent_profile_url); } + + /** + * Obtain the current state of Wi-Fi calling. + * + * @hide + * @see android.telephony.TelephonyManager.WifiCallingChoices + */ + public int getWhenToMakeWifiCalls() { + try { + return getITelephony().getWhenToMakeWifiCalls(); + } catch (RemoteException ex) { + return WifiCallingChoices.NEVER_USE; + } + } + + /** + * Set the current state of Wi-Fi calling. + * + * @hide + * @see android.telephony.TelephonyManager.WifiCallingChoices + */ + public void setWhenToMakeWifiCalls(int state) { + try { + getITelephony().setWhenToMakeWifiCalls(state); + } catch (RemoteException ex) { + } + } } diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index d81cab3069694..caa7ff40d448e 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -337,4 +337,18 @@ interface ITelephony { */ void newIncomingThirdPartyCall(in ComponentName component, String callId, String callerDisplayName); + + /** + * Obtain the current state of Wi-Fi calling. + * + * @see android.telephony.TelephonyManager.WifiCallingChoices + */ + int getWhenToMakeWifiCalls(); + + /** + * Set the current state of Wi-Fi calling. + * + * @see android.telephony.TelephonyManager.WifiCallingChoices + */ + void setWhenToMakeWifiCalls(int state); } From 7647f361b35f11e5a7a071b89f8cbf62fd793cf7 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Wed, 20 Nov 2013 13:22:28 -0800 Subject: [PATCH 05/10] Add interface definitions for CallService/PhoneService Interfaces are meant to replace ThirdParty*.aidl/java files in same directory long term. The differences in methods are on purpose and reflect more recent design directions. Change-Id: Ia5ece7149b228a44758e659a4cabfc0676d1c499 --- Android.mk | 2 + .../android/internal/telephony/CallInfo.aidl | 19 +++++ .../android/internal/telephony/CallInfo.java | 77 +++++++++++++++++++ .../internal/telephony/ICallService.aidl | 61 +++++++++++++++ .../telephony/ICallServiceAdapter.aidl | 61 +++++++++++++++ 5 files changed, 220 insertions(+) create mode 100644 telephony/java/com/android/internal/telephony/CallInfo.aidl create mode 100644 telephony/java/com/android/internal/telephony/CallInfo.java create mode 100644 telephony/java/com/android/internal/telephony/ICallService.aidl create mode 100644 telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl diff --git a/Android.mk b/Android.mk index 8b137eaeb7ff2..216fcbf52fd94 100644 --- a/Android.mk +++ b/Android.mk @@ -265,6 +265,8 @@ LOCAL_SRC_FILES += \ media/java/android/media/IRemoteDisplayProvider.aidl \ media/java/android/media/IRemoteVolumeObserver.aidl \ media/java/android/media/IRingtonePlayer.aidl \ + telephony/java/com/android/internal/telephony/ICallService.aidl \ + telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl \ telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \ telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ diff --git a/telephony/java/com/android/internal/telephony/CallInfo.aidl b/telephony/java/com/android/internal/telephony/CallInfo.aidl new file mode 100644 index 0000000000000..9140388587845 --- /dev/null +++ b/telephony/java/com/android/internal/telephony/CallInfo.aidl @@ -0,0 +1,19 @@ +/* +** Copyright 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 com.android.internal.telephony; + +parcelable CallInfo; diff --git a/telephony/java/com/android/internal/telephony/CallInfo.java b/telephony/java/com/android/internal/telephony/CallInfo.java new file mode 100644 index 0000000000000..6bfc9d73e8c5c --- /dev/null +++ b/telephony/java/com/android/internal/telephony/CallInfo.java @@ -0,0 +1,77 @@ +/* +** Copyright 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 com.android.internal.telephony; + +import android.os.Parcel; +import android.os.Parcelable; + +/** + * A parcelable holder class of Call information data. + */ +public class CallInfo implements Parcelable { + + /** + * Endpoint to which the call is connected. + * This could be the dialed value for outgoing calls or the caller id of incoming calls. + */ + private String handle; + + public CallInfo(String handle) { + this.handle = handle; + } + + public String getHandle() { + return handle; + } + + // + // Parcelling related code below here. + // + + /** + * Responsible for creating CallInfo objects for deserialized Parcels. + */ + public static final Parcelable.Creator CREATOR + = new Parcelable.Creator () { + + @Override + public CallInfo createFromParcel(Parcel source) { + return new CallInfo(source.readString()); + } + + @Override + public CallInfo[] newArray(int size) { + return new CallInfo[size]; + } + }; + + /** + * {@inheritDoc} + */ + @Override + public int describeContents() { + return 0; + } + + /** + * Writes CallInfo object into a serializeable Parcel. + */ + @Override + public void writeToParcel(Parcel destination, int flags) { + destination.writeString(handle); + } +} diff --git a/telephony/java/com/android/internal/telephony/ICallService.aidl b/telephony/java/com/android/internal/telephony/ICallService.aidl new file mode 100644 index 0000000000000..a24c860d08cd6 --- /dev/null +++ b/telephony/java/com/android/internal/telephony/ICallService.aidl @@ -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 com.android.internal.telephony; + +import com.android.internal.telephony.ICallServiceAdapter; + +/** + * Service interface for services which would like to provide calls to be + * managed by the system in-call UI. + * + * This interface provides methods that the android framework can use to deliver commands + * for calls provided by this call service including making new calls and disconnecting + * existing ones. A binding to ICallService implementations exists for two conditions: + * 1) There exists one or more live calls for that call service, + * 2) Prior to an outbound call to test if this call service is compatible with the outgoing call. + */ +oneway interface ICallService { + + /** + * Determines if the CallService can make calls to the handle. + * TODO(santoscordon): Move this method into its own service interface long term. + * TODO(santoscordon): Add response callback parameter. + */ + void isCompatibleWith(String handle); + + /** + * Attempts to call the relevant party using the specified handle, be it a phone number, + * SIP address, or some other kind of user ID. Note that the set of handle types is + * dynamically extensible since call providers should be able to implement arbitrary + * handle-calling systems. See {@link #isCompatibleWith}. + * TODO(santoscordon): Should this have a response attached to it to ensure that the call + * service actually plans to make the call? + */ + void call(String handle); + + /** + * Disconnects the call identified by callId. + */ + void disconnect(String callId); + + /** + * Sets an implementation of ICallServiceAdapter which the call service can use to add new calls + * and communicate state changes of existing calls. This is the first method that is called + * after a the framework binds to the call service. + */ + void setCallServiceAdapter(ICallServiceAdapter CallServiceAdapter); +} diff --git a/telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl b/telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl new file mode 100644 index 0000000000000..bc900f00d71ae --- /dev/null +++ b/telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl @@ -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 com.android.internal.telephony; + +import com.android.internal.telephony.CallInfo; + +/** + * Provides methods for ICallService implementations to interact with the system phone app. + */ +oneway interface ICallServiceAdapter { + + /** + * Retrieves a new unique call id for use with newOutgoingCall and newIncomingCall. + */ + void getNextCallId(/* TODO(santoscordon): Needs response object */); + + /** + * Tells CallsManager of a new incoming call. + */ + void newIncomingCall(String callId, in CallInfo info); + + /** + * Tells CallsManager of a new outgoing call. + */ + void newOutgoingCall(String callId, in CallInfo info); + + /** + * Sets a call's state to active (e.g., an ongoing call where two parties can actively + * communicate). + */ + void setActive(String callId); + + /** + * Sets a call's state to ringing (e.g., an inbound ringing call). + */ + void setRinging(String callId); + + /** + * Sets a call's state to dialing (e.g., dialing an outbound call). + */ + void setDialing(String callId); + + /** + * Sets a call's state to disconnected. + */ + void setDisconnected(String callId); +} From d16654f80e5ed5d71fb512ccaf6709e5247805f7 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Tue, 26 Nov 2013 11:50:49 -0800 Subject: [PATCH 06/10] Add abstract base implementation of CallService. Base implementation takes care of a lot of boilerplate code. Change-Id: Ic7ee3325f694f7df06d23501d77172b4770551bc --- .../java/android/telephony/CallService.java | 165 ++++++++++++++++++ .../internal/telephony/ICallService.aidl | 2 +- 2 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 telephony/java/android/telephony/CallService.java diff --git a/telephony/java/android/telephony/CallService.java b/telephony/java/android/telephony/CallService.java new file mode 100644 index 0000000000000..0ea55b283e7c3 --- /dev/null +++ b/telephony/java/android/telephony/CallService.java @@ -0,0 +1,165 @@ +/* + * 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.telephony; + +import android.app.Service; +import android.content.Intent; +import android.os.Handler; +import android.os.IBinder; +import android.os.Message; + +import com.android.internal.telephony.ICallService; +import com.android.internal.telephony.ICallServiceAdapter; + +/** + * Base implementation of CallService which can be used to provide calls for the system + * in-call UI. CallService is a one-way service from the framework's CallsManager to any app + * that would like to provide calls managed by the default system in-call user interface. + * When the service is bound by the framework, CallsManager will call setCallServiceAdapter + * which will provide CallService with an instance of {@link CallServiceAdapter} to be used + * for communicating back to CallsManager. Subsequently, more specific methods of the service + * will be called to perform various call actions including making an outgoing call and + * disconnected existing calls. + * TODO(santoscordon): Needs more about AndroidManifest.xml service registrations before + * we can unhide this API. + * + * Most public methods of this function are backed by a one-way AIDL interface which precludes + * syncronous responses. As a result, most responses are handled by (or have TODOs to handle) + * response objects instead of return values. + * TODO(santoscordon): Improve paragraph above once the final design is in place. + * @hide + */ +public abstract class CallService extends Service { + + /** + * Default Handler used to consolidate binder method calls onto a single thread. + */ + private final class CallServiceMessageHandler extends Handler { + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case MSG_SET_CALL_SERVICE_ADAPTER: + setCallServiceAdapter((ICallServiceAdapter) msg.obj); + break; + case MSG_IS_COMPATIBLE_WITH: + isCompatibleWith((String) msg.obj); + break; + case MSG_CALL: + call((String) msg.obj); + break; + case MSG_DISCONNECT: + disconnect((String) msg.obj); + break; + default: + break; + } + } + } + + /** + * Default ICallService implementation provided to CallsManager via {@link #onBind}. + */ + private final class CallServiceWrapper extends ICallService.Stub { + @Override + public void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter) { + mMessageHandler.obtainMessage(MSG_SET_CALL_SERVICE_ADAPTER, callServiceAdapter) + .sendToTarget(); + } + + @Override + public void isCompatibleWith(String handle) { + mMessageHandler.obtainMessage(MSG_IS_COMPATIBLE_WITH, handle).sendToTarget(); + } + + @Override + public void call(String handle) { + mMessageHandler.obtainMessage(MSG_CALL, handle).sendToTarget(); + } + + @Override + public void disconnect(String callId) { + mMessageHandler.obtainMessage(MSG_DISCONNECT, callId).sendToTarget(); + } + } + + // Only used internally by this class. + // Binder method calls on this service can occur on multiple threads. These messages are used + // in conjunction with {@link #mMessageHandler} to ensure that all callbacks are handled on a + // single thread. Keeping it on a single thread allows CallService implementations to avoid + // needing multi-threaded code in their own callback routines. + private static final int + MSG_SET_CALL_SERVICE_ADAPTER = 1, + MSG_IS_COMPATIBLE_WITH = 2, + MSG_CALL = 3, + MSG_DISCONNECT = 4; + + /** + * Message handler for consolidating binder callbacks onto a single thread. + * See {@link #CallServiceMessageHandler}. + */ + private final CallServiceMessageHandler mMessageHandler; + + /** + * Default binder implementation of {@link ICallService} interface. + */ + private final CallServiceWrapper mBinder; + + /** + * Protected constructor called only by subclasses creates the binder interface and + * single-threaded message handler. + */ + protected CallService() { + mMessageHandler = new CallServiceMessageHandler(); + mBinder = new CallServiceWrapper(); + } + + /** {@inheritDoc} */ + public IBinder onBind(Intent intent) { + return mBinder; + } + + /** + * Sets an implementation of ICallServiceAdapter for adding new calls and communicating state + * changes of existing calls. + * @param callServiceAdapter Adapter object for communicating call to CallsManager + * TODO(santoscordon): Should we not reference ICallServiceAdapter directly from here? Should we + * wrap that in a wrapper like we do for CallService/ICallService? + * TODO(santoscordon): Consider rename of CallServiceAdapter to CallsManager. + */ + public abstract void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter); + + /** + * Determines if the CallService can make calls to the handle. + * @param handle The handle to test for compatibility. + * TODO(santoscordon): Need response parameter. + */ + public abstract void isCompatibleWith(String handle); + + /** + * Calls the specified handle. Handle type is dynamically extensible and can be a phone number, + * a SIP address, or other types. Only called if {@link #isCompatibleWith} returns true for the + * same handle and this service is selected by the switchboard to handle the call. + * @param handle The handle to call. + */ + public abstract void call(String handle); + + /** + * Disconnects the specified call. + * @param callId The ID of the call to disconnect. + */ + public abstract void disconnect(String callId); +} diff --git a/telephony/java/com/android/internal/telephony/ICallService.aidl b/telephony/java/com/android/internal/telephony/ICallService.aidl index a24c860d08cd6..cb9b2e838ddf9 100644 --- a/telephony/java/com/android/internal/telephony/ICallService.aidl +++ b/telephony/java/com/android/internal/telephony/ICallService.aidl @@ -57,5 +57,5 @@ oneway interface ICallService { * and communicate state changes of existing calls. This is the first method that is called * after a the framework binds to the call service. */ - void setCallServiceAdapter(ICallServiceAdapter CallServiceAdapter); + void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter); } From c8712b6e2297f8b86045b885d3f8cdf28d7ec462 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Mon, 16 Dec 2013 16:27:43 -0800 Subject: [PATCH 07/10] Update TelephonyManager.WifiCallingChoices API This CL updates the order of the WifiCallingChoices values to match the wifi_calling_choice_values resource. Change-Id: Ib314bc44073fdc416b15926cec2aca91aedba08f --- telephony/java/android/telephony/TelephonyManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 37cd4f8d3640c..f1ed0a211c3b9 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -70,10 +70,10 @@ public class TelephonyManager { public interface WifiCallingChoices { /** Always use Wi-Fi calling */ static final int ALWAYS_USE = 0; - /** Never use Wi-Fi calling */ - static final int NEVER_USE = 1; /** Ask the user whether to use Wi-Fi on every call */ - static final int ASK_EVERY_TIME = 2; + static final int ASK_EVERY_TIME = 1; + /** Never use Wi-Fi calling */ + static final int NEVER_USE = 2; } /** @hide */ From 588f34a92d0b5c0313d7d455fd12624965b05c12 Mon Sep 17 00:00:00 2001 From: Qiwen Zhao Date: Mon, 10 Feb 2014 17:33:32 -0800 Subject: [PATCH 08/10] reset to master for rs/java/android/renderscript --- rs/java/android/renderscript/BaseObj.java | 2 +- rs/java/android/renderscript/Byte2.java | 356 +++++++++++- rs/java/android/renderscript/Byte3.java | 388 ++++++++++++- rs/java/android/renderscript/Byte4.java | 420 ++++++++++++++- rs/java/android/renderscript/Double2.java | 375 ++++++++++++- rs/java/android/renderscript/Double3.java | 413 +++++++++++++- rs/java/android/renderscript/Double4.java | 445 ++++++++++++++- rs/java/android/renderscript/FileA3D.java | 4 +- rs/java/android/renderscript/Float2.java | 381 ++++++++++++- rs/java/android/renderscript/Float3.java | 411 +++++++++++++- rs/java/android/renderscript/Float4.java | 444 ++++++++++++++- rs/java/android/renderscript/Font.java | 10 +- rs/java/android/renderscript/Int2.java | 429 ++++++++++++++- rs/java/android/renderscript/Int3.java | 472 +++++++++++++++- rs/java/android/renderscript/Int4.java | 508 +++++++++++++++++- rs/java/android/renderscript/Long2.java | 428 ++++++++++++++- rs/java/android/renderscript/Long3.java | 471 +++++++++++++++- rs/java/android/renderscript/Long4.java | 507 ++++++++++++++++- .../android/renderscript/ProgramStore.java | 4 +- .../android/renderscript/RenderScript.java | 36 +- rs/java/android/renderscript/Sampler.java | 4 +- rs/java/android/renderscript/ScriptC.java | 16 +- rs/java/android/renderscript/Short2.java | 426 ++++++++++++++- rs/java/android/renderscript/Short3.java | 472 +++++++++++++++- rs/java/android/renderscript/Short4.java | 508 +++++++++++++++++- 25 files changed, 7638 insertions(+), 292 deletions(-) diff --git a/rs/java/android/renderscript/BaseObj.java b/rs/java/android/renderscript/BaseObj.java index eee4936a96e33..842aa2337c45d 100644 --- a/rs/java/android/renderscript/BaseObj.java +++ b/rs/java/android/renderscript/BaseObj.java @@ -32,7 +32,7 @@ public class BaseObj { mDestroyed = false; } - void setID(int id) { + void setID(long id) { if (mID != 0) { throw new RSRuntimeException("Internal Error, reset of object ID."); } diff --git a/rs/java/android/renderscript/Byte2.java b/rs/java/android/renderscript/Byte2.java index ef7c770fbba08..3ad79e400c917 100644 --- a/rs/java/android/renderscript/Byte2.java +++ b/rs/java/android/renderscript/Byte2.java @@ -22,6 +22,9 @@ package android.renderscript; * **/ public class Byte2 { + public byte x; + public byte y; + public Byte2() { } @@ -30,8 +33,357 @@ public class Byte2 { y = initY; } - public byte x; - public byte y; + /** @hide */ + public Byte2(Byte2 source) { + this.x = source.x; + this.y = source.y; + } + + /** @hide + * Vector add + * + * @param a + */ + public void add(Byte2 a) { + this.x += a.x; + this.y += a.y; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Byte2 add(Byte2 a, Byte2 b) { + Byte2 result = new Byte2(); + result.x = (byte)(a.x + b.x); + result.y = (byte)(a.y + b.y); + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(byte value) { + x += value; + y += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Byte2 add(Byte2 a, byte b) { + Byte2 result = new Byte2(); + result.x = (byte)(a.x + b); + result.y = (byte)(a.y + b); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Byte2 a) { + this.x -= a.x; + this.y -= a.y; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Byte2 sub(Byte2 a, Byte2 b) { + Byte2 result = new Byte2(); + result.x = (byte)(a.x - b.x); + result.y = (byte)(a.y - b.y); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(byte value) { + x -= value; + y -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Byte2 sub(Byte2 a, byte b) { + Byte2 result = new Byte2(); + result.x = (byte)(a.x - b); + result.y = (byte)(a.y - b); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Byte2 a) { + this.x *= a.x; + this.y *= a.y; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Byte2 mul(Byte2 a, Byte2 b) { + Byte2 result = new Byte2(); + result.x = (byte)(a.x * b.x); + result.y = (byte)(a.y * b.y); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(byte value) { + x *= value; + y *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Byte2 mul(Byte2 a, byte b) { + Byte2 result = new Byte2(); + result.x = (byte)(a.x * b); + result.y = (byte)(a.y * b); + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Byte2 a) { + this.x /= a.x; + this.y /= a.y; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Byte2 div(Byte2 a, Byte2 b) { + Byte2 result = new Byte2(); + result.x = (byte)(a.x / b.x); + result.y = (byte)(a.y / b.y); + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(byte value) { + x /= value; + y /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Byte2 div(Byte2 a, byte b) { + Byte2 result = new Byte2(); + result.x = (byte)(a.x / b); + result.y = (byte)(a.y / b); + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public byte length() { + return 2; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = (byte)(-x); + this.y = (byte)(-y); + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public byte dotProduct(Byte2 a) { + return (byte)((x * a.x) + (y * a.y)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static byte dotProduct(Byte2 a, Byte2 b) { + return (byte)((b.x * a.x) + (b.y * a.y)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Byte2 a, byte factor) { + x += a.x * factor; + y += a.y * factor; + } + + /** @hide + * set vector value by Byte2 + * + * @param a + */ + public void set(Byte2 a) { + this.x = a.x; + this.y = a.y; + } + + /** @hide + * set the vector field value by Char + * + * @param a + * @param b + */ + public void setValues(byte a, byte b) { + this.x = a; + this.y = b; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public byte elementSum() { + return (byte)(x + y); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public byte get(int i) { + switch (i) { + case 0: + return x; + case 1: + return y; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, byte value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, byte value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to Char array + * + * @param data + * @param offset + */ + public void copyTo(byte[] data, int offset) { + data[offset] = x; + data[offset + 1] = y; + } + } diff --git a/rs/java/android/renderscript/Byte3.java b/rs/java/android/renderscript/Byte3.java index 025e8de80f753..a138313321d04 100644 --- a/rs/java/android/renderscript/Byte3.java +++ b/rs/java/android/renderscript/Byte3.java @@ -22,6 +22,10 @@ package android.renderscript; * **/ public class Byte3 { + public byte x; + public byte y; + public byte z; + public Byte3() { } @@ -31,9 +35,387 @@ public class Byte3 { z = initZ; } - public byte x; - public byte y; - public byte z; + /** @hide */ + public Byte3(Byte3 source) { + this.x = source.x; + this.y = source.y; + this.z = source.z; + } + + /** @hide + * Vector add + * + * @param a + */ + public void add(Byte3 a) { + this.x += a.x; + this.y += a.y; + this.z += a.z; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Byte3 add(Byte3 a, Byte3 b) { + Byte3 result = new Byte3(); + result.x = (byte)(a.x + b.x); + result.y = (byte)(a.y + b.y); + result.z = (byte)(a.z + b.z); + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(byte value) { + x += value; + y += value; + z += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Byte3 add(Byte3 a, byte b) { + Byte3 result = new Byte3(); + result.x = (byte)(a.x + b); + result.y = (byte)(a.y + b); + result.z = (byte)(a.z + b); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Byte3 a) { + this.x -= a.x; + this.y -= a.y; + this.z -= a.z; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Byte3 sub(Byte3 a, Byte3 b) { + Byte3 result = new Byte3(); + result.x = (byte)(a.x - b.x); + result.y = (byte)(a.y - b.y); + result.z = (byte)(a.z - b.z); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(byte value) { + x -= value; + y -= value; + z -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Byte3 sub(Byte3 a, byte b) { + Byte3 result = new Byte3(); + result.x = (byte)(a.x - b); + result.y = (byte)(a.y - b); + result.z = (byte)(a.z - b); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Byte3 a) { + this.x *= a.x; + this.y *= a.y; + this.z *= a.z; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Byte3 mul(Byte3 a, Byte3 b) { + Byte3 result = new Byte3(); + result.x = (byte)(a.x * b.x); + result.y = (byte)(a.y * b.y); + result.z = (byte)(a.z * b.z); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(byte value) { + x *= value; + y *= value; + z *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Byte3 mul(Byte3 a, byte b) { + Byte3 result = new Byte3(); + result.x = (byte)(a.x * b); + result.y = (byte)(a.y * b); + result.z = (byte)(a.z * b); + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Byte3 a) { + this.x /= a.x; + this.y /= a.y; + this.z /= a.z; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Byte3 div(Byte3 a, Byte3 b) { + Byte3 result = new Byte3(); + result.x = (byte)(a.x / b.x); + result.y = (byte)(a.y / b.y); + result.z = (byte)(a.z / b.z); + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(byte value) { + x /= value; + y /= value; + z /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Byte3 div(Byte3 a, byte b) { + Byte3 result = new Byte3(); + result.x = (byte)(a.x / b); + result.y = (byte)(a.y / b); + result.z = (byte)(a.z / b); + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public byte length() { + return 3; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = (byte)(-x); + this.y = (byte)(-y); + this.z = (byte)(-z); + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public byte dotProduct(Byte3 a) { + return (byte)((byte)((byte)(x * a.x) + (byte)(y * a.y)) + (byte)(z * a.z)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static byte dotProduct(Byte3 a, Byte3 b) { + return (byte)((byte)((byte)(b.x * a.x) + (byte)(b.y * a.y)) + (byte)(b.z * a.z)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Byte3 a, byte factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + } + + /** @hide + * set vector value by Byte3 + * + * @param a + */ + public void set(Byte3 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + } + + /** @hide + * set the vector field value by Char + * + * @param a + * @param b + * @param c + */ + public void setValues(byte a, byte b, byte c) { + this.x = a; + this.y = b; + this.z = c; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public byte elementSum() { + return (byte)(x + y + z); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public byte get(int i) { + switch (i) { + case 0: + return x; + case 1: + return y; + case 2: + return z; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, byte value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, byte value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to Char array + * + * @param data + * @param offset + */ + public void copyTo(byte[] data, int offset) { + data[offset] = x; + data[offset + 1] = y; + data[offset + 2] = z; + } } diff --git a/rs/java/android/renderscript/Byte4.java b/rs/java/android/renderscript/Byte4.java index 7df21049cdfd6..fa4c13d797140 100644 --- a/rs/java/android/renderscript/Byte4.java +++ b/rs/java/android/renderscript/Byte4.java @@ -22,6 +22,11 @@ package android.renderscript; * **/ public class Byte4 { + public byte x; + public byte y; + public byte z; + public byte w; + public Byte4() { } @@ -31,11 +36,418 @@ public class Byte4 { z = initZ; w = initW; } + /** @hide */ + public Byte4(Byte4 source) { + this.x = source.x; + this.y = source.y; + this.z = source.z; + this.w = source.w; + } - public byte x; - public byte y; - public byte z; - public byte w; + /** @hide + * Vector add + * + * @param a + */ + public void add(Byte4 a) { + this.x += a.x; + this.y += a.y; + this.z += a.z; + this.w += a.w; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Byte4 add(Byte4 a, Byte4 b) { + Byte4 result = new Byte4(); + result.x = (byte)(a.x + b.x); + result.y = (byte)(a.y + b.y); + result.z = (byte)(a.z + b.z); + result.w = (byte)(a.w + b.w); + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(byte value) { + x += value; + y += value; + z += value; + w += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Byte4 add(Byte4 a, byte b) { + Byte4 result = new Byte4(); + result.x = (byte)(a.x + b); + result.y = (byte)(a.y + b); + result.z = (byte)(a.z + b); + result.w = (byte)(a.w + b); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Byte4 a) { + this.x -= a.x; + this.y -= a.y; + this.z -= a.z; + this.w -= a.w; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Byte4 sub(Byte4 a, Byte4 b) { + Byte4 result = new Byte4(); + result.x = (byte)(a.x - b.x); + result.y = (byte)(a.y - b.y); + result.z = (byte)(a.z - b.z); + result.w = (byte)(a.w - b.w); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(byte value) { + x -= value; + y -= value; + z -= value; + w -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Byte4 sub(Byte4 a, byte b) { + Byte4 result = new Byte4(); + result.x = (byte)(a.x - b); + result.y = (byte)(a.y - b); + result.z = (byte)(a.z - b); + result.w = (byte)(a.w - b); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Byte4 a) { + this.x *= a.x; + this.y *= a.y; + this.z *= a.z; + this.w *= a.w; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Byte4 mul(Byte4 a, Byte4 b) { + Byte4 result = new Byte4(); + result.x = (byte)(a.x * b.x); + result.y = (byte)(a.y * b.y); + result.z = (byte)(a.z * b.z); + result.w = (byte)(a.w * b.w); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(byte value) { + x *= value; + y *= value; + z *= value; + w *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Byte4 mul(Byte4 a, byte b) { + Byte4 result = new Byte4(); + result.x = (byte)(a.x * b); + result.y = (byte)(a.y * b); + result.z = (byte)(a.z * b); + result.w = (byte)(a.w * b); + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Byte4 a) { + this.x /= a.x; + this.y /= a.y; + this.z /= a.z; + this.w /= a.w; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Byte4 div(Byte4 a, Byte4 b) { + Byte4 result = new Byte4(); + result.x = (byte)(a.x / b.x); + result.y = (byte)(a.y / b.y); + result.z = (byte)(a.z / b.z); + result.w = (byte)(a.w / b.w); + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(byte value) { + x /= value; + y /= value; + z /= value; + w /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Byte4 div(Byte4 a, byte b) { + Byte4 result = new Byte4(); + result.x = (byte)(a.x / b); + result.y = (byte)(a.y / b); + result.z = (byte)(a.z / b); + result.w = (byte)(a.w / b); + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public byte length() { + return 4; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = (byte)(-x); + this.y = (byte)(-y); + this.z = (byte)(-z); + this.w = (byte)(-w); + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public byte dotProduct(Byte4 a) { + return (byte)((x * a.x) + (y * a.y) + (z * a.z) + (w * a.w)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static byte dotProduct(Byte4 a, Byte4 b) { + return (byte)((b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Byte4 a, byte factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + w += a.w * factor; + } + + /** @hide + * set vector value by Byte4 + * + * @param a + */ + public void set(Byte4 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + this.w = a.w; + } + + /** @hide + * set the vector field values + * + * @param a + * @param b + * @param c + * @param d + */ + public void setValues(byte a, byte b, byte c, byte d) { + this.x = a; + this.y = b; + this.z = c; + this.w = d; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public byte elementSum() { + return (byte)(x + y + z + w); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public byte get(int i) { + switch (i) { + case 0: + return x; + case 1: + return y; + case 2: + return z; + case 3: + return w; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, byte value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + case 3: + w = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, byte value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + case 3: + w += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to Char array + * + * @param data + * @param offset + */ + public void copyTo(byte[] data, int offset) { + data[offset] = x; + data[offset + 1] = y; + data[offset + 2] = z; + data[offset + 3] = w; + } } diff --git a/rs/java/android/renderscript/Double2.java b/rs/java/android/renderscript/Double2.java index 6e1afe6090116..4c7319d5a4b0f 100644 --- a/rs/java/android/renderscript/Double2.java +++ b/rs/java/android/renderscript/Double2.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 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. @@ -16,25 +16,370 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript double2 type back - * to the Android system. - * - **/ + * Vector version of the basic double type. + * Provides two double fields packed. + */ public class Double2 { + public double x; + public double y; + public Double2() { } - public Double2(double initX, double initY) { - x = initX; - y = initY; + /** @hide */ + public Double2(Double2 data) { + this.x = data.x; + this.y = data.y; } - public double x; - public double y; + public Double2(double x, double y) { + this.x = x; + this.y = y; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Double2 add(Double2 a, Double2 b) { + Double2 res = new Double2(); + res.x = a.x + b.x; + res.y = a.y + b.y; + + return res; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(Double2 value) { + x += value.x; + y += value.y; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(double value) { + x += value; + y += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Double2 add(Double2 a, double b) { + Double2 res = new Double2(); + res.x = a.x + b; + res.y = a.y + b; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(Double2 value) { + x -= value.x; + y -= value.y; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Double2 sub(Double2 a, Double2 b) { + Double2 res = new Double2(); + res.x = a.x - b.x; + res.y = a.y - b.y; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(double value) { + x -= value; + y -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Double2 sub(Double2 a, double b) { + Double2 res = new Double2(); + res.x = a.x - b; + res.y = a.y - b; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(Double2 value) { + x *= value.x; + y *= value.y; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Double2 mul(Double2 a, Double2 b) { + Double2 res = new Double2(); + res.x = a.x * b.x; + res.y = a.y * b.y; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(double value) { + x *= value; + y *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Double2 mul(Double2 a, double b) { + Double2 res = new Double2(); + res.x = a.x * b; + res.y = a.y * b; + + return res; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(Double2 value) { + x /= value.x; + y /= value.y; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Double2 div(Double2 a, Double2 b) { + Double2 res = new Double2(); + res.x = a.x / b.x; + res.y = a.y / b.y; + + return res; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(double value) { + x /= value; + y /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Double2 div(Double2 a, double b) { + Double2 res = new Double2(); + res.x = a.x / b; + res.y = a.y / b; + + return res; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public double dotProduct(Double2 a) { + return (x * a.x) + (y * a.y); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static Double dotProduct(Double2 a, Double2 b) { + return (b.x * a.x) + (b.y * a.y); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Double2 a, double factor) { + x += a.x * factor; + y += a.y * factor; + } + + /** @hide + * Set vector value by double2 + * + * @param a + */ + public void set(Double2 a) { + this.x = a.x; + this.y = a.y; + } + + /** @hide + * Set vector negate + */ + public void negate() { + x = -x; + y = -y; + } + + /** @hide + * Get vector length + * + * @return + */ + public int length() { + return 2; + } + + /** @hide + * Return the element sum of vector + * + * @return + */ + public double elementSum() { + return x + y; + } + + /** @hide + * Get the vector field value by index + * + * @param i + * @return + */ + public double get(int i) { + switch (i) { + case 0: + return x; + case 1: + return y; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * Set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, double value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * Add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, double value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * Set the vector field value + * + * @param x + * @param y + */ + public void setValues(double x, double y) { + this.x = x; + this.y = y; + } + + /** @hide + * Copy the vector to double array + * + * @param data + * @param offset + */ + public void copyTo(double[] data, int offset) { + data[offset] = x; + data[offset + 1] = y; + } } - - - - diff --git a/rs/java/android/renderscript/Double3.java b/rs/java/android/renderscript/Double3.java index 7c0979d32d16d..b819716017e9c 100644 --- a/rs/java/android/renderscript/Double3.java +++ b/rs/java/android/renderscript/Double3.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 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. @@ -16,27 +16,402 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript double3 type back - * to the Android system. - * - **/ + * Vector version of the basic double type. + * Provides three double fields packed. + */ public class Double3 { - public Double3() { - } - - public Double3(double initX, double initY, double initZ) { - x = initX; - y = initY; - z = initZ; - } - public double x; public double y; public double z; + + public Double3() { + } + /** @hide */ + public Double3(Double3 data) { + this.x = data.x; + this.y = data.y; + this.z = data.z; + } + + public Double3(double x, double y, double z) { + this.x = x; + this.y = y; + this.z = z; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Double3 add(Double3 a, Double3 b) { + Double3 res = new Double3(); + res.x = a.x + b.x; + res.y = a.y + b.y; + res.z = a.z + b.z; + + return res; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(Double3 value) { + x += value.x; + y += value.y; + z += value.z; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(double value) { + x += value; + y += value; + z += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Double3 add(Double3 a, double b) { + Double3 res = new Double3(); + res.x = a.x + b; + res.y = a.y + b; + res.z = a.z + b; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(Double3 value) { + x -= value.x; + y -= value.y; + z -= value.z; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Double3 sub(Double3 a, Double3 b) { + Double3 res = new Double3(); + res.x = a.x - b.x; + res.y = a.y - b.y; + res.z = a.z - b.z; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(double value) { + x -= value; + y -= value; + z -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Double3 sub(Double3 a, double b) { + Double3 res = new Double3(); + res.x = a.x - b; + res.y = a.y - b; + res.z = a.z - b; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(Double3 value) { + x *= value.x; + y *= value.y; + z *= value.z; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Double3 mul(Double3 a, Double3 b) { + Double3 res = new Double3(); + res.x = a.x * b.x; + res.y = a.y * b.y; + res.z = a.z * b.z; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(double value) { + x *= value; + y *= value; + z *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Double3 mul(Double3 a, double b) { + Double3 res = new Double3(); + res.x = a.x * b; + res.y = a.y * b; + res.z = a.z * b; + + return res; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(Double3 value) { + x /= value.x; + y /= value.y; + z /= value.z; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Double3 div(Double3 a, Double3 b) { + Double3 res = new Double3(); + res.x = a.x / b.x; + res.y = a.y / b.y; + res.z = a.z / b.z; + + return res; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(double value) { + x /= value; + y /= value; + z /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Double3 div(Double3 a, double b) { + Double3 res = new Double3(); + res.x = a.x / b; + res.y = a.y / b; + res.z = a.z / b; + + return res; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public double dotProduct(Double3 a) { + return (x * a.x) + (y * a.y) + (z * a.z); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static double dotProduct(Double3 a, Double3 b) { + return (b.x * a.x) + (b.y * a.y) + (b.z * a.z); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Double3 a, double factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + } + + /** @hide + * Set vector value by double3 + * + * @param a + */ + public void set(Double3 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + } + + /** @hide + * Set vector negate + */ + public void negate() { + x = -x; + y = -y; + z = -z; + } + + /** @hide + * Get vector length + * + * @return + */ + public int length() { + return 3; + } + + /** @hide + * Return the element sum of vector + * + * @return + */ + public double elementSum() { + return x + y + z; + } + + /** @hide + * Get the vector field value by index + * + * @param i + * @return + */ + public double get(int i) { + switch (i) { + case 0: + return x; + case 1: + return y; + case 2: + return z; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * Set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, double value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * Add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, double value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * Set the vector field value + * + * @param x + * @param y + * @param z + */ + public void setValues(double x, double y, double z) { + this.x = x; + this.y = y; + this.z = z; + } + + /** @hide + * Copy the vector to double array + * + * @param data + * @param offset + */ + public void copyTo(double[] data, int offset) { + data[offset] = x; + data[offset + 1] = y; + data[offset + 2] = z; + } } - - - - diff --git a/rs/java/android/renderscript/Double4.java b/rs/java/android/renderscript/Double4.java index 9e8261199d71d..e4829f7426aeb 100644 --- a/rs/java/android/renderscript/Double4.java +++ b/rs/java/android/renderscript/Double4.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 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. @@ -16,28 +16,435 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript double4 type back - * to the Android system. - * - **/ + * Vector version of the basic double type. + * Provides four double fields packed. + */ public class Double4 { - public Double4() { - } - - public Double4(double initX, double initY, double initZ, double initW) { - x = initX; - y = initY; - z = initZ; - w = initW; - } - public double x; public double y; public double z; public double w; + + public Double4() { + } + /** @hide */ + public Double4(Double4 data) { + this.x = data.x; + this.y = data.y; + this.z = data.z; + this.w = data.w; + } + + public Double4(double x, double y, double z, double w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Double4 add(Double4 a, Double4 b) { + Double4 res = new Double4(); + res.x = a.x + b.x; + res.y = a.y + b.y; + res.z = a.z + b.z; + res.w = a.w + b.w; + + return res; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(Double4 value) { + x += value.x; + y += value.y; + z += value.z; + w += value.w; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(double value) { + x += value; + y += value; + z += value; + w += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Double4 add(Double4 a, double b) { + Double4 res = new Double4(); + res.x = a.x + b; + res.y = a.y + b; + res.z = a.z + b; + res.w = a.w + b; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(Double4 value) { + x -= value.x; + y -= value.y; + z -= value.z; + w -= value.w; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(double value) { + x -= value; + y -= value; + z -= value; + w -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Double4 sub(Double4 a, double b) { + Double4 res = new Double4(); + res.x = a.x - b; + res.y = a.y - b; + res.z = a.z - b; + res.w = a.w - b; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Double4 sub(Double4 a, Double4 b) { + Double4 res = new Double4(); + res.x = a.x - b.x; + res.y = a.y - b.y; + res.z = a.z - b.z; + res.w = a.w - b.w; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(Double4 value) { + x *= value.x; + y *= value.y; + z *= value.z; + w *= value.w; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(double value) { + x *= value; + y *= value; + z *= value; + w *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Double4 mul(Double4 a, Double4 b) { + Double4 res = new Double4(); + res.x = a.x * b.x; + res.y = a.y * b.y; + res.z = a.z * b.z; + res.w = a.w * b.w; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Double4 mul(Double4 a, double b) { + Double4 res = new Double4(); + res.x = a.x * b; + res.y = a.y * b; + res.z = a.z * b; + res.w = a.w * b; + + return res; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(Double4 value) { + x /= value.x; + y /= value.y; + z /= value.z; + w /= value.w; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(double value) { + x /= value; + y /= value; + z /= value; + w /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Double4 div(Double4 a, double b) { + Double4 res = new Double4(); + res.x = a.x / b; + res.y = a.y / b; + res.z = a.z / b; + res.w = a.w / b; + + return res; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Double4 div(Double4 a, Double4 b) { + Double4 res = new Double4(); + res.x = a.x / b.x; + res.y = a.y / b.y; + res.z = a.z / b.z; + res.w = a.w / b.w; + + return res; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public double dotProduct(Double4 a) { + return (x * a.x) + (y * a.y) + (z * a.z) + (w * a.w); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static double dotProduct(Double4 a, Double4 b) { + return (b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Double4 a, double factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + w += a.w * factor; + } + + /** @hide + * Set vector value by double4 + * + * @param a + */ + public void set(Double4 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + this.w = a.w; + } + + /** @hide + * Set vector negate + */ + public void negate() { + x = -x; + y = -y; + z = -z; + w = -w; + } + + /** @hide + * Get vector length + * + * @return + */ + public int length() { + return 4; + } + + /** @hide + * Return the element sum of vector + * + * @return + */ + public double elementSum() { + return x + y + z + w; + } + + /** @hide + * Get the vector field value by index + * + * @param i + * @return + */ + public double get(int i) { + switch (i) { + case 0: + return x; + case 1: + return y; + case 2: + return z; + case 3: + return w; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * Set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, double value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + case 3: + w = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * Add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, double value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + case 3: + w += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * Set the vector field value + * + * @param x + * @param y + * @param z + * @param w + */ + public void setValues(double x, double y, double z, double w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + /** @hide + * Copy the vector to double array + * + * @param data + * @param offset + */ + public void copyTo(double[] data, int offset) { + data[offset] = x; + data[offset + 1] = y; + data[offset + 2] = z; + data[offset + 3] = w; + } } - - - diff --git a/rs/java/android/renderscript/FileA3D.java b/rs/java/android/renderscript/FileA3D.java index f0acb56b84adb..41648101cc885 100644 --- a/rs/java/android/renderscript/FileA3D.java +++ b/rs/java/android/renderscript/FileA3D.java @@ -136,7 +136,7 @@ public class FileA3D extends BaseObj { return null; } - int objectID = rs.nFileA3DGetEntryByIndex(entry.mID, entry.mIndex); + long objectID = rs.nFileA3DGetEntryByIndex(entry.mID, entry.mIndex); if(objectID == 0) { return null; } @@ -292,7 +292,7 @@ public class FileA3D extends BaseObj { long fileId = 0; if (is instanceof AssetManager.AssetInputStream) { - int asset = ((AssetManager.AssetInputStream) is).getAssetInt(); + long asset = ((AssetManager.AssetInputStream) is).getNativeAsset(); fileId = rs.nFileA3DCreateFromAssetStream(asset); } else { throw new RSRuntimeException("Unsupported asset stream"); diff --git a/rs/java/android/renderscript/Float2.java b/rs/java/android/renderscript/Float2.java index 427f038f8312a..e9f8ca7737ce1 100644 --- a/rs/java/android/renderscript/Float2.java +++ b/rs/java/android/renderscript/Float2.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 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. @@ -16,24 +16,369 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript float2 type back to the Android system. - * - **/ -public class Float2 { - public Float2() { - } - - public Float2(float initX, float initY) { - x = initX; - y = initY; - } - + * Vector version of the basic float type. + * Provides two float fields packed. + */ +public class Float2 { public float x; public float y; + + public Float2() { + } + /** @hide */ + public Float2(Float2 data) { + this.x = data.x; + this.y = data.y; + } + + public Float2(float x, float y) { + this.x = x; + this.y = y; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Float2 add(Float2 a, Float2 b) { + Float2 res = new Float2(); + res.x = a.x + b.x; + res.y = a.y + b.y; + + return res; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(Float2 value) { + x += value.x; + y += value.y; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(float value) { + x += value; + y += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Float2 add(Float2 a, float b) { + Float2 res = new Float2(); + res.x = a.x + b; + res.y = a.y + b; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(Float2 value) { + x -= value.x; + y -= value.y; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Float2 sub(Float2 a, Float2 b) { + Float2 res = new Float2(); + res.x = a.x - b.x; + res.y = a.y - b.y; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(float value) { + x -= value; + y -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Float2 sub(Float2 a, float b) { + Float2 res = new Float2(); + res.x = a.x - b; + res.y = a.y - b; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(Float2 value) { + x *= value.x; + y *= value.y; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Float2 mul(Float2 a, Float2 b) { + Float2 res = new Float2(); + res.x = a.x * b.x; + res.y = a.y * b.y; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(float value) { + x *= value; + y *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Float2 mul(Float2 a, float b) { + Float2 res = new Float2(); + res.x = a.x * b; + res.y = a.y * b; + + return res; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(Float2 value) { + x /= value.x; + y /= value.y; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Float2 div(Float2 a, Float2 b) { + Float2 res = new Float2(); + res.x = a.x / b.x; + res.y = a.y / b.y; + + return res; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(float value) { + x /= value; + y /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Float2 div(Float2 a, float b) { + Float2 res = new Float2(); + res.x = a.x / b; + res.y = a.y / b; + + return res; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public float dotProduct(Float2 a) { + return (x * a.x) + (y * a.y); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static float dotProduct(Float2 a, Float2 b) { + return (b.x * a.x) + (b.y * a.y); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Float2 a, float factor) { + x += a.x * factor; + y += a.y * factor; + } + + /** @hide + * set vector value by float2 + * + * @param a + */ + public void set(Float2 a) { + this.x = a.x; + this.y = a.y; + } + + /** @hide + * set vector negate + */ + public void negate() { + x = -x; + y = -y; + } + + /** @hide + * get vector length + * + * @return + */ + public int length() { + return 2; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public float elementSum() { + return x + y; + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public float get(int i) { + switch (i) { + case 0: + return x; + case 1: + return y; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, float value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, float value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value + * + * @param x + * @param y + */ + public void setValues(float x, float y) { + this.x = x; + this.y = y; + } + + /** @hide + * copy the vector to float array + * + * @param data + * @param offset + */ + public void copyTo(float[] data, int offset) { + data[offset] = x; + data[offset + 1] = y; + } } - - - - diff --git a/rs/java/android/renderscript/Float3.java b/rs/java/android/renderscript/Float3.java index bfe143af60748..555bdf6d6e4eb 100644 --- a/rs/java/android/renderscript/Float3.java +++ b/rs/java/android/renderscript/Float3.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 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. @@ -16,25 +16,402 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript float2 type back to the Android system. - * - **/ + * Vector version of the basic float type. + * Provides three float fields packed. + */ public class Float3 { - public Float3() { - } - public Float3(float initX, float initY, float initZ) { - x = initX; - y = initY; - z = initZ; - } - public float x; public float y; public float z; + + public Float3() { + } + /** @hide */ + public Float3(Float3 data) { + this.x = data.x; + this.y = data.y; + this.z = data.z; + } + + public Float3(float x, float y, float z) { + this.x = x; + this.y = y; + this.z = z; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Float3 add(Float3 a, Float3 b) { + Float3 res = new Float3(); + res.x = a.x + b.x; + res.y = a.y + b.y; + res.z = a.z + b.z; + + return res; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(Float3 value) { + x += value.x; + y += value.y; + z += value.z; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(float value) { + x += value; + y += value; + z += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Float3 add(Float3 a, float b) { + Float3 res = new Float3(); + res.x = a.x + b; + res.y = a.y + b; + res.z = a.z + b; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(Float3 value) { + x -= value.x; + y -= value.y; + z -= value.z; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Float3 sub(Float3 a, Float3 b) { + Float3 res = new Float3(); + res.x = a.x - b.x; + res.y = a.y - b.y; + res.z = a.z - b.z; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(float value) { + x -= value; + y -= value; + z -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Float3 sub(Float3 a, float b) { + Float3 res = new Float3(); + res.x = a.x - b; + res.y = a.y - b; + res.z = a.z - b; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(Float3 value) { + x *= value.x; + y *= value.y; + z *= value.z; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Float3 mul(Float3 a, Float3 b) { + Float3 res = new Float3(); + res.x = a.x * b.x; + res.y = a.y * b.y; + res.z = a.z * b.z; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(float value) { + x *= value; + y *= value; + z *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Float3 mul(Float3 a, float b) { + Float3 res = new Float3(); + res.x = a.x * b; + res.y = a.y * b; + res.z = a.z * b; + + return res; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(Float3 value) { + x /= value.x; + y /= value.y; + z /= value.z; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Float3 div(Float3 a, Float3 b) { + Float3 res = new Float3(); + res.x = a.x / b.x; + res.y = a.y / b.y; + res.z = a.z / b.z; + + return res; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(float value) { + x /= value; + y /= value; + z /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Float3 div(Float3 a, float b) { + Float3 res = new Float3(); + res.x = a.x / b; + res.y = a.y / b; + res.z = a.z / b; + + return res; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public Float dotProduct(Float3 a) { + return new Float((x * a.x) + (y * a.y) + (z * a.z)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static Float dotProduct(Float3 a, Float3 b) { + return new Float((b.x * a.x) + (b.y * a.y) + (b.z * a.z)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Float3 a, float factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + } + + /** @hide + * set vector value by float3 + * + * @param a + */ + public void set(Float3 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + } + + /** @hide + * set vector negate + */ + public void negate() { + x = -x; + y = -y; + z = -z; + } + + /** @hide + * get vector length + * + * @return + */ + public int length() { + return 3; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public Float elementSum() { + return new Float(x + y + z); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public float get(int i) { + switch (i) { + case 0: + return x; + case 1: + return y; + case 2: + return z; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, float value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, float value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value + * + * @param x + * @param y + * @param z + */ + public void setValues(float x, float y, float z) { + this.x = x; + this.y = y; + this.z = z; + } + + /** @hide + * copy the vector to float array + * + * @param data + * @param offset + */ + public void copyTo(float[] data, int offset) { + data[offset] = x; + data[offset + 1] = y; + data[offset + 2] = z; + } } - - - - diff --git a/rs/java/android/renderscript/Float4.java b/rs/java/android/renderscript/Float4.java index 67c7afc2f743d..6541b2ec7264a 100644 --- a/rs/java/android/renderscript/Float4.java +++ b/rs/java/android/renderscript/Float4.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 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. @@ -16,27 +16,435 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript float2 type back to the Android system. - * - **/ + * Vector version of the basic float type. + * Provides four float fields packed. + */ public class Float4 { - public Float4() { - } - - public Float4(float initX, float initY, float initZ, float initW) { - x = initX; - y = initY; - z = initZ; - w = initW; - } - public float x; public float y; public float z; public float w; + + public Float4() { + } + /** @hide */ + public Float4(Float4 data) { + this.x = data.x; + this.y = data.y; + this.z = data.z; + this.w = data.w; + } + + public Float4(float x, float y, float z, float w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Float4 add(Float4 a, Float4 b) { + Float4 res = new Float4(); + res.x = a.x + b.x; + res.y = a.y + b.y; + res.z = a.z + b.z; + res.w = a.w + b.w; + + return res; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(Float4 value) { + x += value.x; + y += value.y; + z += value.z; + w += value.w; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(float value) { + x += value; + y += value; + z += value; + w += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Float4 add(Float4 a, float b) { + Float4 res = new Float4(); + res.x = a.x + b; + res.y = a.y + b; + res.z = a.z + b; + res.w = a.w + b; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(Float4 value) { + x -= value.x; + y -= value.y; + z -= value.z; + w -= value.w; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(float value) { + x -= value; + y -= value; + z -= value; + w -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Float4 sub(Float4 a, float b) { + Float4 res = new Float4(); + res.x = a.x - b; + res.y = a.y - b; + res.z = a.z - b; + res.w = a.w - b; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Float4 sub(Float4 a, Float4 b) { + Float4 res = new Float4(); + res.x = a.x - b.x; + res.y = a.y - b.y; + res.z = a.z - b.z; + res.w = a.w - b.w; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(Float4 value) { + x *= value.x; + y *= value.y; + z *= value.z; + w *= value.w; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(float value) { + x *= value; + y *= value; + z *= value; + w *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Float4 mul(Float4 a, Float4 b) { + Float4 res = new Float4(); + res.x = a.x * b.x; + res.y = a.y * b.y; + res.z = a.z * b.z; + res.w = a.w * b.w; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Float4 mul(Float4 a, float b) { + Float4 res = new Float4(); + res.x = a.x * b; + res.y = a.y * b; + res.z = a.z * b; + res.w = a.w * b; + + return res; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(Float4 value) { + x /= value.x; + y /= value.y; + z /= value.z; + w /= value.w; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(float value) { + x /= value; + y /= value; + z /= value; + w /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Float4 div(Float4 a, float b) { + Float4 res = new Float4(); + res.x = a.x / b; + res.y = a.y / b; + res.z = a.z / b; + res.w = a.w / b; + + return res; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Float4 div(Float4 a, Float4 b) { + Float4 res = new Float4(); + res.x = a.x / b.x; + res.y = a.y / b.y; + res.z = a.z / b.z; + res.w = a.w / b.w; + + return res; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public float dotProduct(Float4 a) { + return (x * a.x) + (y * a.y) + (z * a.z) + (w * a.w); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static float dotProduct(Float4 a, Float4 b) { + return (b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Float4 a, float factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + w += a.w * factor; + } + + /** @hide + * set vector value by float4 + * + * @param a + */ + public void set(Float4 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + this.w = a.w; + } + + /** @hide + * set vector negate + */ + public void negate() { + x = -x; + y = -y; + z = -z; + w = -w; + } + + /** @hide + * get vector length + * + * @return + */ + public int length() { + return 4; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public float elementSum() { + return x + y + z + w; + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public float get(int i) { + switch (i) { + case 0: + return x; + case 1: + return y; + case 2: + return z; + case 3: + return w; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, float value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + case 3: + w = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, float value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + case 3: + w += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value + * + * @param x + * @param y + * @param z + * @param w + */ + public void setValues(float x, float y, float z, float w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + /** @hide + * copy the vector to float array + * + * @param data + * @param offset + */ + public void copyTo(float[] data, int offset) { + data[offset] = x; + data[offset + 1] = y; + data[offset + 2] = z; + data[offset + 3] = w; + } } - - - diff --git a/rs/java/android/renderscript/Font.java b/rs/java/android/renderscript/Font.java index 4cd89db28e932..b22aeb7c04b71 100644 --- a/rs/java/android/renderscript/Font.java +++ b/rs/java/android/renderscript/Font.java @@ -148,7 +148,7 @@ public class Font extends BaseObj { return "DroidSans.ttf"; } - Font(int id, RenderScript rs) { + Font(long id, RenderScript rs) { super(id, rs); } @@ -159,7 +159,7 @@ public class Font extends BaseObj { static public Font createFromFile(RenderScript rs, Resources res, String path, float pointSize) { rs.validate(); int dpi = res.getDisplayMetrics().densityDpi; - int fontId = rs.nFontCreateFromFile(path, pointSize, dpi); + long fontId = rs.nFontCreateFromFile(path, pointSize, dpi); if(fontId == 0) { throw new RSRuntimeException("Unable to create font from file " + path); @@ -184,7 +184,7 @@ public class Font extends BaseObj { AssetManager mgr = res.getAssets(); int dpi = res.getDisplayMetrics().densityDpi; - int fontId = rs.nFontCreateFromAsset(mgr, path, pointSize, dpi); + long fontId = rs.nFontCreateFromAsset(mgr, path, pointSize, dpi); if(fontId == 0) { throw new RSRuntimeException("Unable to create font from asset " + path); } @@ -208,9 +208,9 @@ public class Font extends BaseObj { int dpi = res.getDisplayMetrics().densityDpi; - int fontId = 0; + long fontId = 0; if (is instanceof AssetManager.AssetInputStream) { - int asset = ((AssetManager.AssetInputStream) is).getAssetInt(); + long asset = ((AssetManager.AssetInputStream) is).getNativeAsset(); fontId = rs.nFontCreateFromAssetStream(name, pointSize, dpi, asset); } else { throw new RSRuntimeException("Unsupported asset stream created"); diff --git a/rs/java/android/renderscript/Int2.java b/rs/java/android/renderscript/Int2.java index 524e36185ffec..120957bcd726d 100644 --- a/rs/java/android/renderscript/Int2.java +++ b/rs/java/android/renderscript/Int2.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 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. @@ -16,24 +16,425 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript int2 type back to the Android system. - * - **/ + * Vector version of the basic int type. + * Provides two int fields packed. + */ public class Int2 { + public int x; + public int y; + public Int2() { } - public Int2(int initX, int initY) { - x = initX; - y = initY; + /** @hide */ + public Int2(int i) { + this.x = this.y = i; } - public int x; - public int y; + public Int2(int x, int y) { + this.x = x; + this.y = y; + } + + /** @hide */ + public Int2(Int2 source) { + this.x = source.x; + this.y = source.y; + } + + /** @hide + * Vector add + * + * @param a + */ + public void add(Int2 a) { + this.x += a.x; + this.y += a.y; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Int2 add(Int2 a, Int2 b) { + Int2 result = new Int2(); + result.x = a.x + b.x; + result.y = a.y + b.y; + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(int value) { + x += value; + y += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Int2 add(Int2 a, int b) { + Int2 result = new Int2(); + result.x = a.x + b; + result.y = a.y + b; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Int2 a) { + this.x -= a.x; + this.y -= a.y; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Int2 sub(Int2 a, Int2 b) { + Int2 result = new Int2(); + result.x = a.x - b.x; + result.y = a.y - b.y; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(int value) { + x -= value; + y -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Int2 sub(Int2 a, int b) { + Int2 result = new Int2(); + result.x = a.x - b; + result.y = a.y - b; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Int2 a) { + this.x *= a.x; + this.y *= a.y; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Int2 mul(Int2 a, Int2 b) { + Int2 result = new Int2(); + result.x = a.x * b.x; + result.y = a.y * b.y; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(int value) { + x *= value; + y *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Int2 mul(Int2 a, int b) { + Int2 result = new Int2(); + result.x = a.x * b; + result.y = a.y * b; + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Int2 a) { + this.x /= a.x; + this.y /= a.y; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Int2 div(Int2 a, Int2 b) { + Int2 result = new Int2(); + result.x = a.x / b.x; + result.y = a.y / b.y; + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(int value) { + x /= value; + y /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Int2 div(Int2 a, int b) { + Int2 result = new Int2(); + result.x = a.x / b; + result.y = a.y / b; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param a + */ + public void mod(Int2 a) { + this.x %= a.x; + this.y %= a.y; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Int2 mod(Int2 a, Int2 b) { + Int2 result = new Int2(); + result.x = a.x % b.x; + result.y = a.y % b.y; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param value + */ + public void mod(int value) { + x %= value; + y %= value; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Int2 mod(Int2 a, int b) { + Int2 result = new Int2(); + result.x = a.x % b; + result.y = a.y % b; + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public int length() { + return 2; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = -x; + this.y = -y; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public int dotProduct(Int2 a) { + return (int)((x * a.x) + (y * a.y)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static int dotProduct(Int2 a, Int2 b) { + return (int)((b.x * a.x) + (b.y * a.y)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Int2 a, int factor) { + x += a.x * factor; + y += a.y * factor; + } + + /** @hide + * set vector value by Int2 + * + * @param a + */ + public void set(Int2 a) { + this.x = a.x; + this.y = a.y; + } + + /** @hide + * set the vector field value by Int + * + * @param a + * @param b + */ + public void setValues(int a, int b) { + this.x = a; + this.y = b; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public int elementSum() { + return (int)(x + y); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public int get(int i) { + switch (i) { + case 0: + return (int)(x); + case 1: + return (int)(y); + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, int value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, int value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to int array + * + * @param data + * @param offset + */ + public void copyTo(int[] data, int offset) { + data[offset] = (int)(x); + data[offset + 1] = (int)(y); + } } - - - - diff --git a/rs/java/android/renderscript/Int3.java b/rs/java/android/renderscript/Int3.java index df42e28e52ca7..5431b9a75ba75 100644 --- a/rs/java/android/renderscript/Int3.java +++ b/rs/java/android/renderscript/Int3.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 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. @@ -16,26 +16,462 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript int3 type back to the Android system. - * - **/ + * Vector version of the basic int type. + * Provides three int fields packed. + */ public class Int3 { - public Int3() { - } - - public Int3(int initX, int initY, int initZ) { - x = initX; - y = initY; - z = initZ; - } - public int x; public int y; public int z; + + public Int3() { + } + + /** @hide */ + public Int3(int i) { + this.x = this.y = this.z = i; + } + + public Int3(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + } + + /** @hide */ + public Int3(Int3 source) { + this.x = source.x; + this.y = source.y; + this.z = source.z; + } + + /** @hide + * Vector add + * + * @param a + */ + public void add(Int3 a) { + this.x += a.x; + this.y += a.y; + this.z += a.z; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Int3 add(Int3 a, Int3 b) { + Int3 result = new Int3(); + result.x = a.x + b.x; + result.y = a.y + b.y; + result.z = a.z + b.z; + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(int value) { + x += value; + y += value; + z += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Int3 add(Int3 a, int b) { + Int3 result = new Int3(); + result.x = a.x + b; + result.y = a.y + b; + result.z = a.z + b; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Int3 a) { + this.x -= a.x; + this.y -= a.y; + this.z -= a.z; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Int3 sub(Int3 a, Int3 b) { + Int3 result = new Int3(); + result.x = a.x - b.x; + result.y = a.y - b.y; + result.z = a.z - b.z; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(int value) { + x -= value; + y -= value; + z -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Int3 sub(Int3 a, int b) { + Int3 result = new Int3(); + result.x = a.x - b; + result.y = a.y - b; + result.z = a.z - b; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Int3 a) { + this.x *= a.x; + this.y *= a.y; + this.z *= a.z; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Int3 mul(Int3 a, Int3 b) { + Int3 result = new Int3(); + result.x = a.x * b.x; + result.y = a.y * b.y; + result.z = a.z * b.z; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(int value) { + x *= value; + y *= value; + z *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Int3 mul(Int3 a, int b) { + Int3 result = new Int3(); + result.x = a.x * b; + result.y = a.y * b; + result.z = a.z * b; + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Int3 a) { + this.x /= a.x; + this.y /= a.y; + this.z /= a.z; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Int3 div(Int3 a, Int3 b) { + Int3 result = new Int3(); + result.x = a.x / b.x; + result.y = a.y / b.y; + result.z = a.z / b.z; + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(int value) { + x /= value; + y /= value; + z /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Int3 div(Int3 a, int b) { + Int3 result = new Int3(); + result.x = a.x / b; + result.y = a.y / b; + result.z = a.z / b; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param a + */ + public void mod(Int3 a) { + this.x %= a.x; + this.y %= a.y; + this.z %= a.z; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Int3 mod(Int3 a, Int3 b) { + Int3 result = new Int3(); + result.x = a.x % b.x; + result.y = a.y % b.y; + result.z = a.z % b.z; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param value + */ + public void mod(int value) { + x %= value; + y %= value; + z %= value; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Int3 mod(Int3 a, int b) { + Int3 result = new Int3(); + result.x = a.x % b; + result.y = a.y % b; + result.z = a.z % b; + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public int length() { + return 3; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = -x; + this.y = -y; + this.z = -z; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public int dotProduct(Int3 a) { + return (int)((x * a.x) + (y * a.y) + (z * a.z)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static int dotProduct(Int3 a, Int3 b) { + return (int)((b.x * a.x) + (b.y * a.y) + (b.z * a.z)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Int3 a, int factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + } + + /** @hide + * set vector value by Int3 + * + * @param a + */ + public void set(Int3 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + } + + /** @hide + * set the vector field value by Int + * + * @param a + * @param b + * @param c + */ + public void setValues(int a, int b, int c) { + this.x = a; + this.y = b; + this.z = c; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public int elementSum() { + return (int)(x + y + z); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public int get(int i) { + switch (i) { + case 0: + return (int)(x); + case 1: + return (int)(y); + case 2: + return (int)(z); + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, int value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, int value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to int array + * + * @param data + * @param offset + */ + public void copyTo(int[] data, int offset) { + data[offset] = (int)(x); + data[offset + 1] = (int)(y); + data[offset + 2] = (int)(z); + } } - - - - diff --git a/rs/java/android/renderscript/Int4.java b/rs/java/android/renderscript/Int4.java index 408fb0ddd6fdb..1c0e2e2621aa9 100644 --- a/rs/java/android/renderscript/Int4.java +++ b/rs/java/android/renderscript/Int4.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 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. @@ -16,27 +16,499 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript int4 type back to the Android system. - * - **/ + * Vector version of the basic int type. + * Provides four int fields packed. + */ public class Int4 { - public Int4() { - } - - public Int4(int initX, int initY, int initZ, int initW) { - x = initX; - y = initY; - z = initZ; - w = initW; - } - public int x; public int y; public int z; public int w; + + public Int4() { + } + + /** @hide */ + public Int4(int i) { + this.x = this.y = this.z = this.w = i; + } + + public Int4(int x, int y, int z, int w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + /** @hide */ + public Int4(Int4 source) { + this.x = source.x; + this.y = source.y; + this.z = source.z; + this.w = source.w; + } + + /** @hide + * Vector add + * + * @param a + */ + public void add(Int4 a) { + this.x += a.x; + this.y += a.y; + this.z += a.z; + this.w += a.w; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Int4 add(Int4 a, Int4 b) { + Int4 result = new Int4(); + result.x = a.x + b.x; + result.y = a.y + b.y; + result.z = a.z + b.z; + result.w = a.w + b.w; + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(int value) { + x += value; + y += value; + z += value; + w += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Int4 add(Int4 a, int b) { + Int4 result = new Int4(); + result.x = a.x + b; + result.y = a.y + b; + result.z = a.z + b; + result.w = a.w + b; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Int4 a) { + this.x -= a.x; + this.y -= a.y; + this.z -= a.z; + this.w -= a.w; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Int4 sub(Int4 a, Int4 b) { + Int4 result = new Int4(); + result.x = a.x - b.x; + result.y = a.y - b.y; + result.z = a.z - b.z; + result.w = a.w - b.w; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(int value) { + x -= value; + y -= value; + z -= value; + w -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Int4 sub(Int4 a, int b) { + Int4 result = new Int4(); + result.x = a.x - b; + result.y = a.y - b; + result.z = a.z - b; + result.w = a.w - b; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Int4 a) { + this.x *= a.x; + this.y *= a.y; + this.z *= a.z; + this.w *= a.w; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Int4 mul(Int4 a, Int4 b) { + Int4 result = new Int4(); + result.x = a.x * b.x; + result.y = a.y * b.y; + result.z = a.z * b.z; + result.w = a.w * b.w; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(int value) { + x *= value; + y *= value; + z *= value; + w *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Int4 mul(Int4 a, int b) { + Int4 result = new Int4(); + result.x = a.x * b; + result.y = a.y * b; + result.z = a.z * b; + result.w = a.w * b; + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Int4 a) { + this.x /= a.x; + this.y /= a.y; + this.z /= a.z; + this.w /= a.w; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Int4 div(Int4 a, Int4 b) { + Int4 result = new Int4(); + result.x = a.x / b.x; + result.y = a.y / b.y; + result.z = a.z / b.z; + result.w = a.w / b.w; + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(int value) { + x /= value; + y /= value; + z /= value; + w /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Int4 div(Int4 a, int b) { + Int4 result = new Int4(); + result.x = a.x / b; + result.y = a.y / b; + result.z = a.z / b; + result.w = a.w / b; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param a + */ + public void mod(Int4 a) { + this.x %= a.x; + this.y %= a.y; + this.z %= a.z; + this.w %= a.w; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Int4 mod(Int4 a, Int4 b) { + Int4 result = new Int4(); + result.x = a.x % b.x; + result.y = a.y % b.y; + result.z = a.z % b.z; + result.w = a.w % b.w; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param value + */ + public void mod(int value) { + x %= value; + y %= value; + z %= value; + w %= value; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Int4 mod(Int4 a, int b) { + Int4 result = new Int4(); + result.x = a.x % b; + result.y = a.y % b; + result.z = a.z % b; + result.w = a.w % b; + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public int length() { + return 4; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = -x; + this.y = -y; + this.z = -z; + this.w = -w; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public int dotProduct(Int4 a) { + return (int)((x * a.x) + (y * a.y) + (z * a.z) + (w * a.w)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static int dotProduct(Int4 a, Int4 b) { + return (int)((b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Int4 a, int factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + w += a.w * factor; + } + + /** @hide + * set vector value by Int4 + * + * @param a + */ + public void set(Int4 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + this.w = a.w; + } + + /** @hide + * set the vector field value by Int + * + * @param a + * @param b + * @param c + * @param d + */ + public void setValues(int a, int b, int c, int d) { + this.x = a; + this.y = b; + this.z = c; + this.w = d; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public int elementSum() { + return (int)(x + y + z + w); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public int get(int i) { + switch (i) { + case 0: + return (int)(x); + case 1: + return (int)(y); + case 2: + return (int)(z); + case 3: + return (int)(w); + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, int value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + case 3: + w = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, int value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + case 3: + w += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to int array + * + * @param data + * @param offset + */ + public void copyTo(int[] data, int offset) { + data[offset] = (int)(x); + data[offset + 1] = (int)(y); + data[offset + 2] = (int)(z); + data[offset + 3] = (int)(w); + } } - - - diff --git a/rs/java/android/renderscript/Long2.java b/rs/java/android/renderscript/Long2.java index 70fc374b57ea8..fabf2046a48ce 100644 --- a/rs/java/android/renderscript/Long2.java +++ b/rs/java/android/renderscript/Long2.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 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. @@ -16,23 +16,425 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript long2 type back to the Android system. - **/ + * Vector version of the basic long type. + * Provides two long fields packed. + */ public class Long2 { + public long x; + public long y; + public Long2() { } - public Long2(long initX, long initY) { - x = initX; - y = initY; + /** @hide */ + public Long2(long i) { + this.x = this.y = i; } - public long x; - public long y; + public Long2(long x, long y) { + this.x = x; + this.y = y; + } + + /** @hide */ + public Long2(Long2 source) { + this.x = source.x; + this.y = source.y; + } + + /** @hide + * Vector add + * + * @param a + */ + public void add(Long2 a) { + this.x += a.x; + this.y += a.y; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Long2 add(Long2 a, Long2 b) { + Long2 result = new Long2(); + result.x = a.x + b.x; + result.y = a.y + b.y; + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(long value) { + x += value; + y += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Long2 add(Long2 a, long b) { + Long2 result = new Long2(); + result.x = a.x + b; + result.y = a.y + b; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Long2 a) { + this.x -= a.x; + this.y -= a.y; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Long2 sub(Long2 a, Long2 b) { + Long2 result = new Long2(); + result.x = a.x - b.x; + result.y = a.y - b.y; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(long value) { + x -= value; + y -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Long2 sub(Long2 a, long b) { + Long2 result = new Long2(); + result.x = a.x - b; + result.y = a.y - b; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Long2 a) { + this.x *= a.x; + this.y *= a.y; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Long2 mul(Long2 a, Long2 b) { + Long2 result = new Long2(); + result.x = a.x * b.x; + result.y = a.y * b.y; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(long value) { + x *= value; + y *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Long2 mul(Long2 a, long b) { + Long2 result = new Long2(); + result.x = a.x * b; + result.y = a.y * b; + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Long2 a) { + this.x /= a.x; + this.y /= a.y; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Long2 div(Long2 a, Long2 b) { + Long2 result = new Long2(); + result.x = a.x / b.x; + result.y = a.y / b.y; + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(long value) { + x /= value; + y /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Long2 div(Long2 a, long b) { + Long2 result = new Long2(); + result.x = a.x / b; + result.y = a.y / b; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param a + */ + public void mod(Long2 a) { + this.x %= a.x; + this.y %= a.y; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Long2 mod(Long2 a, Long2 b) { + Long2 result = new Long2(); + result.x = a.x % b.x; + result.y = a.y % b.y; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param value + */ + public void mod(long value) { + x %= value; + y %= value; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Long2 mod(Long2 a, long b) { + Long2 result = new Long2(); + result.x = a.x % b; + result.y = a.y % b; + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public long length() { + return 2; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = -x; + this.y = -y; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public long dotProduct(Long2 a) { + return (long)((x * a.x) + (y * a.y)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static long dotProduct(Long2 a, Long2 b) { + return (long)((b.x * a.x) + (b.y * a.y)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Long2 a, long factor) { + x += a.x * factor; + y += a.y * factor; + } + + /** @hide + * set vector value by Long2 + * + * @param a + */ + public void set(Long2 a) { + this.x = a.x; + this.y = a.y; + } + + /** @hide + * set the vector field value by Long + * + * @param a + * @param b + */ + public void setValues(long a, long b) { + this.x = a; + this.y = b; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public long elementSum() { + return (long)(x + y); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public long get(int i) { + switch (i) { + case 0: + return (long)(x); + case 1: + return (long)(y); + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, long value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, long value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to long array + * + * @param data + * @param offset + */ + public void copyTo(long[] data, int offset) { + data[offset] = (long)(x); + data[offset + 1] = (long)(y); + } } - - - - diff --git a/rs/java/android/renderscript/Long3.java b/rs/java/android/renderscript/Long3.java index d81826b0529a9..8e243cce647f5 100644 --- a/rs/java/android/renderscript/Long3.java +++ b/rs/java/android/renderscript/Long3.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 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. @@ -16,25 +16,462 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript long3 type back to the Android system. - **/ + * Vector version of the basic long type. + * Provides three long fields packed. + */ public class Long3 { - public Long3() { - } - - public Long3(long initX, long initY, long initZ) { - x = initX; - y = initY; - z = initZ; - } - public long x; public long y; public long z; + + public Long3() { + } + + /** @hide */ + public Long3(long i) { + this.x = this.y = this.z = i; + } + + public Long3(long x, long y, long z) { + this.x = x; + this.y = y; + this.z = z; + } + + /** @hide */ + public Long3(Long3 source) { + this.x = source.x; + this.y = source.y; + this.z = source.z; + } + + /** @hide + * Vector add + * + * @param a + */ + public void add(Long3 a) { + this.x += a.x; + this.y += a.y; + this.z += a.z; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Long3 add(Long3 a, Long3 b) { + Long3 result = new Long3(); + result.x = a.x + b.x; + result.y = a.y + b.y; + result.z = a.z + b.z; + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(long value) { + x += value; + y += value; + z += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Long3 add(Long3 a, long b) { + Long3 result = new Long3(); + result.x = a.x + b; + result.y = a.y + b; + result.z = a.z + b; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Long3 a) { + this.x -= a.x; + this.y -= a.y; + this.z -= a.z; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Long3 sub(Long3 a, Long3 b) { + Long3 result = new Long3(); + result.x = a.x - b.x; + result.y = a.y - b.y; + result.z = a.z - b.z; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(long value) { + x -= value; + y -= value; + z -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Long3 sub(Long3 a, long b) { + Long3 result = new Long3(); + result.x = a.x - b; + result.y = a.y - b; + result.z = a.z - b; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Long3 a) { + this.x *= a.x; + this.y *= a.y; + this.z *= a.z; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Long3 mul(Long3 a, Long3 b) { + Long3 result = new Long3(); + result.x = a.x * b.x; + result.y = a.y * b.y; + result.z = a.z * b.z; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(long value) { + x *= value; + y *= value; + z *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Long3 mul(Long3 a, long b) { + Long3 result = new Long3(); + result.x = a.x * b; + result.y = a.y * b; + result.z = a.z * b; + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Long3 a) { + this.x /= a.x; + this.y /= a.y; + this.z /= a.z; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Long3 div(Long3 a, Long3 b) { + Long3 result = new Long3(); + result.x = a.x / b.x; + result.y = a.y / b.y; + result.z = a.z / b.z; + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(long value) { + x /= value; + y /= value; + z /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Long3 div(Long3 a, long b) { + Long3 result = new Long3(); + result.x = a.x / b; + result.y = a.y / b; + result.z = a.z / b; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param a + */ + public void mod(Long3 a) { + this.x %= a.x; + this.y %= a.y; + this.z %= a.z; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Long3 mod(Long3 a, Long3 b) { + Long3 result = new Long3(); + result.x = a.x % b.x; + result.y = a.y % b.y; + result.z = a.z % b.z; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param value + */ + public void mod(long value) { + x %= value; + y %= value; + z %= value; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Long3 mod(Long3 a, long b) { + Long3 result = new Long3(); + result.x = a.x % b; + result.y = a.y % b; + result.z = a.z % b; + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public long length() { + return 3; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = -x; + this.y = -y; + this.z = -z; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public long dotProduct(Long3 a) { + return (long)((x * a.x) + (y * a.y) + (z * a.z)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static long dotProduct(Long3 a, Long3 b) { + return (long)((b.x * a.x) + (b.y * a.y) + (b.z * a.z)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Long3 a, long factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + } + + /** @hide + * set vector value by Long3 + * + * @param a + */ + public void set(Long3 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + } + + /** @hide + * set the vector field value by Long + * + * @param a + * @param b + * @param c + */ + public void setValues(long a, long b, long c) { + this.x = a; + this.y = b; + this.z = c; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public long elementSum() { + return (long)(x + y + z); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public long get(int i) { + switch (i) { + case 0: + return (long)(x); + case 1: + return (long)(y); + case 2: + return (long)(z); + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, long value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, long value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to long array + * + * @param data + * @param offset + */ + public void copyTo(long[] data, int offset) { + data[offset] = (long)(x); + data[offset + 1] = (long)(y); + data[offset + 2] = (long)(z); + } } - - - - diff --git a/rs/java/android/renderscript/Long4.java b/rs/java/android/renderscript/Long4.java index 47ef43726c782..1a1ad748e462e 100644 --- a/rs/java/android/renderscript/Long4.java +++ b/rs/java/android/renderscript/Long4.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 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. @@ -16,26 +16,499 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript long4 type back to the Android system. - **/ + * Vector version of the basic long type. + * Provides four long fields packed. + */ public class Long4 { - public Long4() { - } - - public Long4(long initX, long initY, long initZ, long initW) { - x = initX; - y = initY; - z = initZ; - w = initW; - } - public long x; public long y; public long z; public long w; + + public Long4() { + } + + /** @hide */ + public Long4(long i) { + this.x = this.y = this.z = this.w = i; + } + + public Long4(long x, long y, long z, long w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + /** @hide */ + public Long4(Long4 source) { + this.x = source.x; + this.y = source.y; + this.z = source.z; + this.w = source.w; + } + + /** @hide + * Vector add + * + * @param a + */ + public void add(Long4 a) { + this.x += a.x; + this.y += a.y; + this.z += a.z; + this.w += a.w; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Long4 add(Long4 a, Long4 b) { + Long4 result = new Long4(); + result.x = a.x + b.x; + result.y = a.y + b.y; + result.z = a.z + b.z; + result.w = a.w + b.w; + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(long value) { + x += value; + y += value; + z += value; + w += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Long4 add(Long4 a, long b) { + Long4 result = new Long4(); + result.x = a.x + b; + result.y = a.y + b; + result.z = a.z + b; + result.w = a.w + b; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Long4 a) { + this.x -= a.x; + this.y -= a.y; + this.z -= a.z; + this.w -= a.w; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Long4 sub(Long4 a, Long4 b) { + Long4 result = new Long4(); + result.x = a.x - b.x; + result.y = a.y - b.y; + result.z = a.z - b.z; + result.w = a.w - b.w; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(long value) { + x -= value; + y -= value; + z -= value; + w -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Long4 sub(Long4 a, long b) { + Long4 result = new Long4(); + result.x = a.x - b; + result.y = a.y - b; + result.z = a.z - b; + result.w = a.w - b; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Long4 a) { + this.x *= a.x; + this.y *= a.y; + this.z *= a.z; + this.w *= a.w; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Long4 mul(Long4 a, Long4 b) { + Long4 result = new Long4(); + result.x = a.x * b.x; + result.y = a.y * b.y; + result.z = a.z * b.z; + result.w = a.w * b.w; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(long value) { + x *= value; + y *= value; + z *= value; + w *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Long4 mul(Long4 a, long b) { + Long4 result = new Long4(); + result.x = a.x * b; + result.y = a.y * b; + result.z = a.z * b; + result.w = a.w * b; + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Long4 a) { + this.x /= a.x; + this.y /= a.y; + this.z /= a.z; + this.w /= a.w; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Long4 div(Long4 a, Long4 b) { + Long4 result = new Long4(); + result.x = a.x / b.x; + result.y = a.y / b.y; + result.z = a.z / b.z; + result.w = a.w / b.w; + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(long value) { + x /= value; + y /= value; + z /= value; + w /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Long4 div(Long4 a, long b) { + Long4 result = new Long4(); + result.x = a.x / b; + result.y = a.y / b; + result.z = a.z / b; + result.w = a.w / b; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param a + */ + public void mod(Long4 a) { + this.x %= a.x; + this.y %= a.y; + this.z %= a.z; + this.w %= a.w; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Long4 mod(Long4 a, Long4 b) { + Long4 result = new Long4(); + result.x = a.x % b.x; + result.y = a.y % b.y; + result.z = a.z % b.z; + result.w = a.w % b.w; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param value + */ + public void mod(long value) { + x %= value; + y %= value; + z %= value; + w %= value; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Long4 mod(Long4 a, long b) { + Long4 result = new Long4(); + result.x = a.x % b; + result.y = a.y % b; + result.z = a.z % b; + result.w = a.w % b; + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public long length() { + return 4; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = -x; + this.y = -y; + this.z = -z; + this.w = -w; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public long dotProduct(Long4 a) { + return (long)((x * a.x) + (y * a.y) + (z * a.z) + (w * a.w)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static long dotProduct(Long4 a, Long4 b) { + return (long)((b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Long4 a, long factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + w += a.w * factor; + } + + /** @hide + * set vector value by Long4 + * + * @param a + */ + public void set(Long4 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + this.w = a.w; + } + + /** @hide + * set the vector field value by Long + * + * @param a + * @param b + * @param c + * @param d + */ + public void setValues(long a, long b, long c, long d) { + this.x = a; + this.y = b; + this.z = c; + this.w = d; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public long elementSum() { + return (long)(x + y + z + w); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public long get(int i) { + switch (i) { + case 0: + return (long)(x); + case 1: + return (long)(y); + case 2: + return (long)(z); + case 3: + return (long)(w); + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, long value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + case 3: + w = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, long value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + case 3: + w += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to long array + * + * @param data + * @param offset + */ + public void copyTo(long[] data, int offset) { + data[offset] = (long)(x); + data[offset + 1] = (long)(y); + data[offset + 2] = (long)(z); + data[offset + 3] = (long)(w); + } } - - - diff --git a/rs/java/android/renderscript/ProgramStore.java b/rs/java/android/renderscript/ProgramStore.java index 730c51bc2d15e..c0fa9c45fb53f 100644 --- a/rs/java/android/renderscript/ProgramStore.java +++ b/rs/java/android/renderscript/ProgramStore.java @@ -143,7 +143,7 @@ public class ProgramStore extends BaseObj { BlendDstFunc mBlendDst; boolean mDither; - ProgramStore(int id, RenderScript rs) { + ProgramStore(long id, RenderScript rs) { super(id, rs); } @@ -418,7 +418,7 @@ public class ProgramStore extends BaseObj { */ public ProgramStore create() { mRS.validate(); - int id = mRS.nProgramStoreCreate(mColorMaskR, mColorMaskG, mColorMaskB, mColorMaskA, + long id = mRS.nProgramStoreCreate(mColorMaskR, mColorMaskG, mColorMaskB, mColorMaskA, mDepthMask, mDither, mBlendSrc.mID, mBlendDst.mID, mDepthFunc.mID); ProgramStore programStore = new ProgramStore(id, mRS); diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java index b0ef156e0934f..a4a9070a800d1 100644 --- a/rs/java/android/renderscript/RenderScript.java +++ b/rs/java/android/renderscript/RenderScript.java @@ -502,8 +502,8 @@ public class RenderScript { rsnAllocationResize1D(mContext, id, dimX); } - native long rsnFileA3DCreateFromAssetStream(long con, int assetStream); - synchronized long nFileA3DCreateFromAssetStream(int assetStream) { + native long rsnFileA3DCreateFromAssetStream(long con, long assetStream); + synchronized long nFileA3DCreateFromAssetStream(long assetStream) { validate(); return rsnFileA3DCreateFromAssetStream(mContext, assetStream); } @@ -527,24 +527,24 @@ public class RenderScript { validate(); rsnFileA3DGetIndexEntries(mContext, fileA3D, numEntries, IDs, names); } - native int rsnFileA3DGetEntryByIndex(long con, long fileA3D, int index); - synchronized int nFileA3DGetEntryByIndex(long fileA3D, int index) { + native long rsnFileA3DGetEntryByIndex(long con, long fileA3D, int index); + synchronized long nFileA3DGetEntryByIndex(long fileA3D, int index) { validate(); return rsnFileA3DGetEntryByIndex(mContext, fileA3D, index); } - native int rsnFontCreateFromFile(long con, String fileName, float size, int dpi); - synchronized int nFontCreateFromFile(String fileName, float size, int dpi) { + native long rsnFontCreateFromFile(long con, String fileName, float size, int dpi); + synchronized long nFontCreateFromFile(String fileName, float size, int dpi) { validate(); return rsnFontCreateFromFile(mContext, fileName, size, dpi); } - native int rsnFontCreateFromAssetStream(long con, String name, float size, int dpi, int assetStream); - synchronized int nFontCreateFromAssetStream(String name, float size, int dpi, int assetStream) { + native long rsnFontCreateFromAssetStream(long con, String name, float size, int dpi, long assetStream); + synchronized long nFontCreateFromAssetStream(String name, float size, int dpi, long assetStream) { validate(); return rsnFontCreateFromAssetStream(mContext, name, size, dpi, assetStream); } - native int rsnFontCreateFromAsset(long con, AssetManager mgr, String path, float size, int dpi); - synchronized int nFontCreateFromAsset(AssetManager mgr, String path, float size, int dpi) { + native long rsnFontCreateFromAsset(long con, AssetManager mgr, String path, float size, int dpi); + synchronized long nFontCreateFromAsset(AssetManager mgr, String path, float size, int dpi) { validate(); return rsnFontCreateFromAsset(mContext, mgr, path, size, dpi); } @@ -661,9 +661,9 @@ public class RenderScript { rsnScriptSetVarObj(mContext, id, slot, val); } - native int rsnScriptCCreate(long con, String resName, String cacheDir, + native long rsnScriptCCreate(long con, String resName, String cacheDir, byte[] script, int length); - synchronized int nScriptCCreate(String resName, String cacheDir, byte[] script, int length) { + synchronized long nScriptCCreate(String resName, String cacheDir, byte[] script, int length) { validate(); return rsnScriptCCreate(mContext, resName, cacheDir, script, length); } @@ -710,18 +710,18 @@ public class RenderScript { rsnScriptGroupExecute(mContext, group); } - native int rsnSamplerCreate(long con, int magFilter, int minFilter, + native long rsnSamplerCreate(long con, int magFilter, int minFilter, int wrapS, int wrapT, int wrapR, float aniso); - synchronized int nSamplerCreate(int magFilter, int minFilter, + synchronized long nSamplerCreate(int magFilter, int minFilter, int wrapS, int wrapT, int wrapR, float aniso) { validate(); return rsnSamplerCreate(mContext, magFilter, minFilter, wrapS, wrapT, wrapR, aniso); } - native int rsnProgramStoreCreate(long con, boolean r, boolean g, boolean b, boolean a, + native long rsnProgramStoreCreate(long con, boolean r, boolean g, boolean b, boolean a, boolean depthMask, boolean dither, int srcMode, int dstMode, int depthFunc); - synchronized int nProgramStoreCreate(boolean r, boolean g, boolean b, boolean a, + synchronized long nProgramStoreCreate(boolean r, boolean g, boolean b, boolean a, boolean depthMask, boolean dither, int srcMode, int dstMode, int depthFunc) { validate(); @@ -787,8 +787,8 @@ public class RenderScript { rsnMeshGetIndices(mContext, id, idxIds, primitives, vtxIdCount); } - native long rsnPathCreate(long con, int prim, boolean isStatic, long vtx, int loop, float q); - synchronized long nPathCreate(int prim, boolean isStatic, long vtx, int loop, float q) { + native long rsnPathCreate(long con, int prim, boolean isStatic, long vtx, long loop, float q); + synchronized long nPathCreate(int prim, boolean isStatic, long vtx, long loop, float q) { validate(); return rsnPathCreate(mContext, prim, isStatic, vtx, loop, q); } diff --git a/rs/java/android/renderscript/Sampler.java b/rs/java/android/renderscript/Sampler.java index 39b867b7b039e..a4edbb50ac109 100644 --- a/rs/java/android/renderscript/Sampler.java +++ b/rs/java/android/renderscript/Sampler.java @@ -49,7 +49,7 @@ public class Sampler extends BaseObj { Value mWrapR; float mAniso; - Sampler(int id, RenderScript rs) { + Sampler(long id, RenderScript rs) { super(id, rs); } @@ -336,7 +336,7 @@ public class Sampler extends BaseObj { public Sampler create() { mRS.validate(); - int id = mRS.nSamplerCreate(mMag.mID, mMin.mID, + long id = mRS.nSamplerCreate(mMag.mID, mMin.mID, mWrapS.mID, mWrapT.mID, mWrapR.mID, mAniso); Sampler sampler = new Sampler(id, mRS); sampler.mMin = mMin; diff --git a/rs/java/android/renderscript/ScriptC.java b/rs/java/android/renderscript/ScriptC.java index c7979f6fa2bc1..9e76f5293bd06 100644 --- a/rs/java/android/renderscript/ScriptC.java +++ b/rs/java/android/renderscript/ScriptC.java @@ -38,7 +38,17 @@ public class ScriptC extends Script { protected ScriptC(int id, RenderScript rs) { super(id, rs); } - + /** + * Only intended for use by the generated derived classes. + * + * @param id + * @param rs + * + * @hide + */ + protected ScriptC(long id, RenderScript rs) { + super(id, rs); + } /** * Only intended for use by the generated derived classes. * @@ -49,7 +59,7 @@ public class ScriptC extends Script { */ protected ScriptC(RenderScript rs, Resources resources, int resourceID) { super(0, rs); - int id = internalCreate(rs, resources, resourceID); + long id = internalCreate(rs, resources, resourceID); if (id == 0) { throw new RSRuntimeException("Loading of ScriptC script failed."); } @@ -63,7 +73,7 @@ public class ScriptC extends Script { static String mCachePath; - private static synchronized int internalCreate(RenderScript rs, Resources resources, int resourceID) { + private static synchronized long internalCreate(RenderScript rs, Resources resources, int resourceID) { byte[] pgm; int pgmLength; InputStream is = resources.openRawResource(resourceID); diff --git a/rs/java/android/renderscript/Short2.java b/rs/java/android/renderscript/Short2.java index 2c6c334a53b24..24809f7391598 100644 --- a/rs/java/android/renderscript/Short2.java +++ b/rs/java/android/renderscript/Short2.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 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. @@ -20,20 +20,424 @@ package android.renderscript; /** * Class for exposing the native RenderScript Short2 type back to the Android system. * - **/ + * Vector version of the basic short type. + * Provides two short fields packed. + */ public class Short2 { + public short x; + public short y; + public Short2() { } - public Short2(short initX, short initY) { - x = initX; - y = initY; + /** @hide */ + public Short2(short i) { + this.x = this.y = i; } - public short x; - public short y; + public Short2(short x, short y) { + this.x = x; + this.y = y; + } + + /** @hide */ + public Short2(Short2 source) { + this.x = source.x; + this.y = source.y; + } + + /** @hide + * Vector add + * + * @param a + */ + public void add(Short2 a) { + this.x += a.x; + this.y += a.y; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Short2 add(Short2 a, Short2 b) { + Short2 result = new Short2(); + result.x = (short)(a.x + b.x); + result.y = (short)(a.y + b.y); + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(short value) { + x += value; + y += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Short2 add(Short2 a, short b) { + Short2 result = new Short2(); + result.x = (short)(a.x + b); + result.y = (short)(a.y + b); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Short2 a) { + this.x -= a.x; + this.y -= a.y; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Short2 sub(Short2 a, Short2 b) { + Short2 result = new Short2(); + result.x = (short)(a.x - b.x); + result.y = (short)(a.y - b.y); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(short value) { + x -= value; + y -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Short2 sub(Short2 a, short b) { + Short2 result = new Short2(); + result.x = (short)(a.x - b); + result.y = (short)(a.y - b); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Short2 a) { + this.x *= a.x; + this.y *= a.y; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Short2 mul(Short2 a, Short2 b) { + Short2 result = new Short2(); + result.x = (short)(a.x * b.x); + result.y = (short)(a.y * b.y); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(short value) { + x *= value; + y *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Short2 mul(Short2 a, short b) { + Short2 result = new Short2(); + result.x = (short)(a.x * b); + result.y = (short)(a.y * b); + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Short2 a) { + this.x /= a.x; + this.y /= a.y; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Short2 div(Short2 a, Short2 b) { + Short2 result = new Short2(); + result.x = (short)(a.x / b.x); + result.y = (short)(a.y / b.y); + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(short value) { + x /= value; + y /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Short2 div(Short2 a, short b) { + Short2 result = new Short2(); + result.x = (short)(a.x / b); + result.y = (short)(a.y / b); + + return result; + } + + /** @hide + * Vector Modulo + * + * @param a + */ + public void mod(Short2 a) { + this.x %= a.x; + this.y %= a.y; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Short2 mod(Short2 a, Short2 b) { + Short2 result = new Short2(); + result.x = (short)(a.x % b.x); + result.y = (short)(a.y % b.y); + + return result; + } + + /** @hide + * Vector Modulo + * + * @param value + */ + public void mod(short value) { + x %= value; + y %= value; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Short2 mod(Short2 a, short b) { + Short2 result = new Short2(); + result.x = (short)(a.x % b); + result.y = (short)(a.y % b); + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public short length() { + return 2; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = (short)(-x); + this.y = (short)(-y); + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public short dotProduct(Short2 a) { + return (short)((x * a.x) + (y * a.y)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static short dotProduct(Short2 a, Short2 b) { + return (short)((b.x * a.x) + (b.y * a.y)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Short2 a, short factor) { + x += a.x * factor; + y += a.y * factor; + } + + /** @hide + * set vector value by Short2 + * + * @param a + */ + public void set(Short2 a) { + this.x = a.x; + this.y = a.y; + } + + /** @hide + * set the vector field value by Short + * + * @param a + * @param b + */ + public void setValues(short a, short b) { + this.x = a; + this.y = b; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public short elementSum() { + return (short)(x + y); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public short get(int i) { + switch (i) { + case 0: + return (short)(x); + case 1: + return (short)(y); + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, short value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, short value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to short array + * + * @param data + * @param offset + */ + public void copyTo(short[] data, int offset) { + data[offset] = (short)(x); + data[offset + 1] = (short)(y); + } } - - - - diff --git a/rs/java/android/renderscript/Short3.java b/rs/java/android/renderscript/Short3.java index aafd27b15326e..661db0a89f3d8 100644 --- a/rs/java/android/renderscript/Short3.java +++ b/rs/java/android/renderscript/Short3.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 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. @@ -16,26 +16,462 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript short3 type back to the Android system. - * - **/ + * Vector version of the basic short type. + * Provides three short fields packed. + */ public class Short3 { - public Short3() { - } - - public Short3(short initX, short initY, short initZ) { - x = initX; - y = initY; - z = initZ; - } - public short x; public short y; public short z; + + public Short3() { + } + + /** @hide */ + public Short3(short i) { + this.x = this.y = this.z = i; + } + + public Short3(short x, short y, short z) { + this.x = x; + this.y = y; + this.z = z; + } + + /** @hide */ + public Short3(Short3 source) { + this.x = source.x; + this.y = source.y; + this.z = source.z; + } + + /** @hide + * Vector add + * + * @param a + */ + public void add(Short3 a) { + this.x += a.x; + this.y += a.y; + this.z += a.z; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Short3 add(Short3 a, Short3 b) { + Short3 result = new Short3(); + result.x = (short)(a.x + b.x); + result.y = (short)(a.y + b.y); + result.z = (short)(a.z + b.z); + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(short value) { + x += value; + y += value; + z += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Short3 add(Short3 a, short b) { + Short3 result = new Short3(); + result.x = (short)(a.x + b); + result.y = (short)(a.y + b); + result.z = (short)(a.z + b); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Short3 a) { + this.x -= a.x; + this.y -= a.y; + this.z -= a.z; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Short3 sub(Short3 a, Short3 b) { + Short3 result = new Short3(); + result.x = (short)(a.x - b.x); + result.y = (short)(a.y - b.y); + result.z = (short)(a.z - b.z); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(short value) { + x -= value; + y -= value; + z -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Short3 sub(Short3 a, short b) { + Short3 result = new Short3(); + result.x = (short)(a.x - b); + result.y = (short)(a.y - b); + result.z = (short)(a.z - b); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Short3 a) { + this.x *= a.x; + this.y *= a.y; + this.z *= a.z; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Short3 mul(Short3 a, Short3 b) { + Short3 result = new Short3(); + result.x = (short)(a.x * b.x); + result.y = (short)(a.y * b.y); + result.z = (short)(a.z * b.z); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(short value) { + x *= value; + y *= value; + z *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Short3 mul(Short3 a, short b) { + Short3 result = new Short3(); + result.x = (short)(a.x * b); + result.y = (short)(a.y * b); + result.z = (short)(a.z * b); + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Short3 a) { + this.x /= a.x; + this.y /= a.y; + this.z /= a.z; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Short3 div(Short3 a, Short3 b) { + Short3 result = new Short3(); + result.x = (short)(a.x / b.x); + result.y = (short)(a.y / b.y); + result.z = (short)(a.z / b.z); + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(short value) { + x /= value; + y /= value; + z /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Short3 div(Short3 a, short b) { + Short3 result = new Short3(); + result.x = (short)(a.x / b); + result.y = (short)(a.y / b); + result.z = (short)(a.z / b); + + return result; + } + + /** @hide + * Vector Modulo + * + * @param a + */ + public void mod(Short3 a) { + this.x %= a.x; + this.y %= a.y; + this.z %= a.z; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Short3 mod(Short3 a, Short3 b) { + Short3 result = new Short3(); + result.x = (short)(a.x % b.x); + result.y = (short)(a.y % b.y); + result.z = (short)(a.z % b.z); + + return result; + } + + /** @hide + * Vector Modulo + * + * @param value + */ + public void mod(short value) { + x %= value; + y %= value; + z %= value; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Short3 mod(Short3 a, short b) { + Short3 result = new Short3(); + result.x = (short)(a.x % b); + result.y = (short)(a.y % b); + result.z = (short)(a.z % b); + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public short length() { + return 3; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = (short)(-x); + this.y = (short)(-y); + this.z = (short)(-z); + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public short dotProduct(Short3 a) { + return (short)((x * a.x) + (y * a.y) + (z * a.z)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static short dotProduct(Short3 a, Short3 b) { + return (short)((b.x * a.x) + (b.y * a.y) + (b.z * a.z)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Short3 a, short factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + } + + /** @hide + * set vector value by Short3 + * + * @param a + */ + public void set(Short3 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + } + + /** @hide + * set the vector field value by Short + * + * @param a + * @param b + * @param c + */ + public void setValues(short a, short b, short c) { + this.x = a; + this.y = b; + this.z = c; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public short elementSum() { + return (short)(x + y + z); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public short get(int i) { + switch (i) { + case 0: + return (short)(x); + case 1: + return (short)(y); + case 2: + return (short)(z); + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, short value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, short value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to short array + * + * @param data + * @param offset + */ + public void copyTo(short[] data, int offset) { + data[offset] = (short)(x); + data[offset + 1] = (short)(y); + data[offset + 2] = (short)(z); + } } - - - - diff --git a/rs/java/android/renderscript/Short4.java b/rs/java/android/renderscript/Short4.java index 176bde91c9262..a2d74f2ccf94b 100644 --- a/rs/java/android/renderscript/Short4.java +++ b/rs/java/android/renderscript/Short4.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 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. @@ -16,27 +16,499 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript short4 type back to the Android system. - * - **/ + * Vector version of the basic short type. + * Provides four short fields packed. + */ public class Short4 { - public Short4() { - } - - public Short4(short initX, short initY, short initZ, short initW) { - x = initX; - y = initY; - z = initZ; - w = initW; - } - public short x; public short y; public short z; public short w; + + public Short4() { + } + + /** @hide */ + public Short4(short i) { + this.x = this.y = this.z = this.w = i; + } + + public Short4(short x, short y, short z, short w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + /** @hide */ + public Short4(Short4 source) { + this.x = source.x; + this.y = source.y; + this.z = source.z; + this.w = source.w; + } + + /** @hide + * Vector add + * + * @param a + */ + public void add(Short4 a) { + this.x += a.x; + this.y += a.y; + this.z += a.z; + this.w += a.w; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Short4 add(Short4 a, Short4 b) { + Short4 result = new Short4(); + result.x = (short)(a.x + b.x); + result.y = (short)(a.y + b.y); + result.z = (short)(a.z + b.z); + result.w = (short)(a.w + b.w); + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(short value) { + x += value; + y += value; + z += value; + w += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Short4 add(Short4 a, short b) { + Short4 result = new Short4(); + result.x = (short)(a.x + b); + result.y = (short)(a.y + b); + result.z = (short)(a.z + b); + result.w = (short)(a.w + b); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Short4 a) { + this.x -= a.x; + this.y -= a.y; + this.z -= a.z; + this.w -= a.w; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Short4 sub(Short4 a, Short4 b) { + Short4 result = new Short4(); + result.x = (short)(a.x - b.x); + result.y = (short)(a.y - b.y); + result.z = (short)(a.z - b.z); + result.w = (short)(a.w - b.w); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(short value) { + x -= value; + y -= value; + z -= value; + w -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Short4 sub(Short4 a, short b) { + Short4 result = new Short4(); + result.x = (short)(a.x - b); + result.y = (short)(a.y - b); + result.z = (short)(a.z - b); + result.w = (short)(a.w - b); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Short4 a) { + this.x *= a.x; + this.y *= a.y; + this.z *= a.z; + this.w *= a.w; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Short4 mul(Short4 a, Short4 b) { + Short4 result = new Short4(); + result.x = (short)(a.x * b.x); + result.y = (short)(a.y * b.y); + result.z = (short)(a.z * b.z); + result.w = (short)(a.w * b.w); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(short value) { + x *= value; + y *= value; + z *= value; + w *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Short4 mul(Short4 a, short b) { + Short4 result = new Short4(); + result.x = (short)(a.x * b); + result.y = (short)(a.y * b); + result.z = (short)(a.z * b); + result.w = (short)(a.w * b); + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Short4 a) { + this.x /= a.x; + this.y /= a.y; + this.z /= a.z; + this.w /= a.w; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Short4 div(Short4 a, Short4 b) { + Short4 result = new Short4(); + result.x = (short)(a.x / b.x); + result.y = (short)(a.y / b.y); + result.z = (short)(a.z / b.z); + result.w = (short)(a.w / b.w); + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(short value) { + x /= value; + y /= value; + z /= value; + w /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Short4 div(Short4 a, short b) { + Short4 result = new Short4(); + result.x = (short)(a.x / b); + result.y = (short)(a.y / b); + result.z = (short)(a.z / b); + result.w = (short)(a.w / b); + + return result; + } + + /** @hide + * Vector Modulo + * + * @param a + */ + public void mod(Short4 a) { + this.x %= a.x; + this.y %= a.y; + this.z %= a.z; + this.w %= a.w; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Short4 mod(Short4 a, Short4 b) { + Short4 result = new Short4(); + result.x = (short)(a.x % b.x); + result.y = (short)(a.y % b.y); + result.z = (short)(a.z % b.z); + result.w = (short)(a.w % b.w); + + return result; + } + + /** @hide + * Vector Modulo + * + * @param value + */ + public void mod(short value) { + x %= value; + y %= value; + z %= value; + w %= value; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Short4 mod(Short4 a, short b) { + Short4 result = new Short4(); + result.x = (short)(a.x % b); + result.y = (short)(a.y % b); + result.z = (short)(a.z % b); + result.w = (short)(a.w % b); + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public short length() { + return 4; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = (short)(-x); + this.y = (short)(-y); + this.z = (short)(-z); + this.w = (short)(-w); + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public short dotProduct(Short4 a) { + return (short)((x * a.x) + (y * a.y) + (z * a.z) + (w * a.w)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static short dotProduct(Short4 a, Short4 b) { + return (short)((b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Short4 a, short factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + w += a.w * factor; + } + + /** @hide + * set vector value by Short4 + * + * @param a + */ + public void set(Short4 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + this.w = a.w; + } + + /** @hide + * set the vector field value by Short + * + * @param a + * @param b + * @param c + * @param d + */ + public void setValues(short a, short b, short c, short d) { + this.x = a; + this.y = b; + this.z = c; + this.w = d; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public short elementSum() { + return (short)(x + y + z + w); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public short get(int i) { + switch (i) { + case 0: + return (short)(x); + case 1: + return (short)(y); + case 2: + return (short)(z); + case 3: + return (short)(w); + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, short value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + case 3: + w = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, short value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + case 3: + w += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to short array + * + * @param data + * @param offset + */ + public void copyTo(short[] data, int offset) { + data[offset] = (short)(x); + data[offset + 1] = (short)(y); + data[offset + 2] = (short)(z); + data[offset + 3] = (short)(w); + } } - - - From cc69d4c778738500b1ddbc0e08ac55bb322e3889 Mon Sep 17 00:00:00 2001 From: Craig Mautner Date: Fri, 7 Feb 2014 13:11:47 -0800 Subject: [PATCH 09/10] Don't remove Activities and Tasks until animation done Just like stacks and displays, activities and tasks need to stick around until animations have completed. Change-Id: I54fe8f6855d60cbc3a25cbc6e762defd5ac50bf5 --- .../server/am/ActivityStackSupervisor.java | 10 ++-- .../com/android/server/wm/AppWindowToken.java | 2 + .../core/java/com/android/server/wm/Task.java | 1 + .../java/com/android/server/wm/TaskStack.java | 17 ++++++- .../server/wm/WindowManagerService.java | 48 +++++++++++++++---- .../server/wm/WindowStateAnimator.java | 2 +- 6 files changed, 63 insertions(+), 17 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java index a33b0e5078ea4..8f8b2a27ad6ac 100644 --- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java @@ -1151,7 +1151,11 @@ public final class ActivityStackSupervisor implements DisplayListener { if (err == ActivityManager.START_SUCCESS) { final int userId = aInfo != null ? UserHandle.getUserId(aInfo.applicationInfo.uid) : 0; Slog.i(TAG, "START u" + userId + " {" + intent.toShortString(true, true, true, false) - + "} from pid " + (callerApp != null ? callerApp.pid : callingPid)); + + "} from pid " + (callerApp != null ? callerApp.pid : callingPid) + + " on display " + (container == null ? (mFocusedStack == null ? + Display.DEFAULT_DISPLAY : mFocusedStack.mDisplayId) : + (container.mActivityDisplay == null ? Display.DEFAULT_DISPLAY : + container.mActivityDisplay.mDisplayId))); } ActivityRecord sourceRecord = null; @@ -3069,10 +3073,6 @@ public final class ActivityStackSupervisor implements DisplayListener { init(mDisplayManager.getDisplay(displayId)); } - ActivityDisplay(Display display) { - init(display); - } - ActivityDisplay(Surface surface, int width, int height, int density) { DisplayManagerGlobal dm = DisplayManagerGlobal.getInstance(); long ident = Binder.clearCallingIdentity(); diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java index e98014bdea3e9..ca4ad8a32e0d8 100644 --- a/services/core/java/com/android/server/wm/AppWindowToken.java +++ b/services/core/java/com/android/server/wm/AppWindowToken.java @@ -105,6 +105,8 @@ class AppWindowToken extends WindowToken { // Input application handle used by the input dispatcher. final InputApplicationHandle mInputApplicationHandle; + boolean mDeferRemoval; + AppWindowToken(WindowManagerService _service, IApplicationToken _token) { super(_service, _token.asBinder(), WindowManager.LayoutParams.TYPE_APPLICATION, true); diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 44f2596eb92be..c301ffed1a4b1 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -24,6 +24,7 @@ class Task { final AppTokenList mAppTokens = new AppTokenList(); final int taskId; final int mUserId; + boolean mDeferRemoval = false; Task(AppWindowToken wtoken, TaskStack stack, int userId) { taskId = wtoken.groupId; diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java index 0941c76855021..7d8cff4a8040c 100644 --- a/services/core/java/com/android/server/wm/TaskStack.java +++ b/services/core/java/com/android/server/wm/TaskStack.java @@ -366,7 +366,7 @@ public class TaskStack { mAnimationBackgroundSurface.mDimSurface.destroy(); } - void checkForDeferredDetach() { + void checkForDeferredActions() { if (mDisplayContent != null && (mDisplayContent.mDeferredActions & DisplayContent.DEFER_DETACH) != 0 && !isAnimating()) { @@ -377,6 +377,21 @@ public class TaskStack { mService.onDisplayRemoved(mDisplayContent.getDisplayId()); } } + for (int taskNdx = mTasks.size() - 1; taskNdx >= 0; --taskNdx) { + final Task task = mTasks.get(taskNdx); + AppTokenList tokens = task.mAppTokens; + for (int tokenNdx = tokens.size() - 1; tokenNdx >= 0; --tokenNdx) { + AppWindowToken wtoken = tokens.get(tokenNdx); + if (wtoken.mDeferRemoval) { + wtoken.mDeferRemoval = false; + mService.removeAppFromTaskLocked(wtoken); + } + } + if (task.mDeferRemoval) { + task.mDeferRemoval = false; + mService.removeTaskLocked(task); + } + } } public void dump(String prefix, PrintWriter pw) { diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index b76ec4bb67263..7293d6f1c0e95 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -21,6 +21,7 @@ import static android.view.WindowManager.LayoutParams.*; import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; import android.app.AppOpsManager; +import android.util.ArraySet; import android.util.TimeUtils; import android.view.IWindowId; @@ -362,6 +363,11 @@ public class WindowManagerService extends IWindowManager.Stub */ final ArrayList mPendingRemove = new ArrayList(); + /** + * Stacks whose animations have ended and whose tasks, apps, selves may now be removed. + */ + final ArraySet mPendingStacksRemove = new ArraySet(); + /** * Used when processing mPendingRemove to avoid working on the original array. */ @@ -3425,6 +3431,8 @@ public class WindowManagerService extends IWindowManager.Stub } private Task createTask(int taskId, int stackId, int userId, AppWindowToken atoken) { + if (DEBUG_STACK) Slog.i(TAG, "createTask: taskId=" + taskId + " stackId=" + stackId + + " atoken=" + atoken); final TaskStack stack = mStackIdToStack.get(stackId); if (stack == null) { throw new IllegalArgumentException("addAppToken: invalid stackId=" + stackId); @@ -3507,7 +3515,7 @@ public class WindowManagerService extends IWindowManager.Stub return; } final Task oldTask = mTaskIdToTask.get(atoken.groupId); - removeAppFromTask(atoken); + removeAppFromTaskLocked(atoken); atoken.groupId = groupId; Task newTask = mTaskIdToTask.get(groupId); @@ -4525,11 +4533,10 @@ public class WindowManagerService extends IWindowManager.Stub } } - void removeAppFromTask(AppWindowToken wtoken) { + void removeAppFromTaskLocked(AppWindowToken wtoken) { final Task task = mTaskIdToTask.get(wtoken.groupId); - if (task != null && task.removeAppToken(wtoken)) { - task.mStack.removeTask(task); - mTaskIdToTask.delete(wtoken.groupId); + if (!wtoken.mDeferRemoval && task != null && task.removeAppToken(wtoken)) { + removeTaskLocked(task); } } @@ -4571,17 +4578,18 @@ public class WindowManagerService extends IWindowManager.Stub if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, "removeAppToken make exiting: " + wtoken); stack.mExitingAppTokens.add(wtoken); + wtoken.mDeferRemoval = true; } else { // Make sure there is no animation running on this token, // so any windows associated with it will be removed as // soon as their animations are complete wtoken.mAppAnimator.clearAnimation(); wtoken.mAppAnimator.animating = false; + removeAppFromTaskLocked(wtoken); } if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, "removeAppToken: " + wtoken); - removeAppFromTask(wtoken); wtoken.removed = true; if (wtoken.startingData != null) { @@ -4926,6 +4934,21 @@ public class WindowManagerService extends IWindowManager.Stub } } + void removeTaskLocked(Task task) { + final int taskId = task.taskId; + final TaskStack stack = task.mStack; + if (stack.isAnimating()) { + if (DEBUG_STACK) Slog.i(TAG, "removeTask: deferring removing taskId=" + taskId); + task.mDeferRemoval = true; + return; + } + if (DEBUG_STACK) Slog.i(TAG, "removeTask: removing taskId=" + taskId); + EventLog.writeEvent(EventLogTags.WM_TASK_REMOVED, taskId, "removeTask"); + task.mDeferRemoval = false; + task.mStack.removeTask(task); + mTaskIdToTask.delete(task.taskId); + } + public void removeTask(int taskId) { synchronized (mWindowMap) { Task task = mTaskIdToTask.get(taskId); @@ -4933,14 +4956,14 @@ public class WindowManagerService extends IWindowManager.Stub if (DEBUG_STACK) Slog.i(TAG, "removeTask: could not find taskId=" + taskId); return; } - final TaskStack stack = task.mStack; - EventLog.writeEvent(EventLogTags.WM_TASK_REMOVED, taskId, "removeTask"); - stack.removeTask(task); + removeTaskLocked(task); } } public void addTask(int taskId, int stackId, boolean toTop) { synchronized (mWindowMap) { + if (DEBUG_STACK) Slog.i(TAG, "addTask: adding taskId=" + taskId + + " to " + (toTop ? "top" : "bottom")); Task task = mTaskIdToTask.get(taskId); if (task == null) { return; @@ -9365,7 +9388,7 @@ public class WindowManagerService extends IWindowManager.Stub token.mAppAnimator.animating = false; if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, "performLayout: App token exiting now removed" + token); - removeAppFromTask(token); + removeAppFromTaskLocked(token); exitingAppTokens.remove(i); } } @@ -9458,6 +9481,11 @@ public class WindowManagerService extends IWindowManager.Stub } } + // Remove all deferred Stacks, tasks, and activities. + for (int stackNdx = mPendingStacksRemove.size() - 1; stackNdx >= 0; --stackNdx) { + mPendingStacksRemove.removeAt(stackNdx).checkForDeferredActions(); + } + setFocusedStackFrame(); // Check to see if we are now in a state where the screen should diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index 5cff3197a336b..ffb17f1fb3745 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -416,7 +416,7 @@ class WindowStateAnimator { mService.mPendingRemove.add(mWin); mWin.mRemoveOnExit = false; } - mWin.getStack().checkForDeferredDetach(); + mService.mPendingStacksRemove.add(mWin.getStack()); mAnimator.hideWallpapersLocked(mWin); } From 13f0a3a43dcebcd949932782a86f57bad8b03956 Mon Sep 17 00:00:00 2001 From: Qiwen Zhao Date: Tue, 11 Feb 2014 10:56:43 -0800 Subject: [PATCH 10/10] reset to master for this file since it is missing an older change. --- core/jni/android_view_GLES20Canvas.cpp | 152 ------------------------- 1 file changed, 152 deletions(-) diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp index 3e140efc61f53..dd089f2eeea08 100644 --- a/core/jni/android_view_GLES20Canvas.cpp +++ b/core/jni/android_view_GLES20Canvas.cpp @@ -47,7 +47,6 @@ #include #include #include -#include #include #include @@ -81,7 +80,6 @@ using namespace uirenderer; #define MODIFIER_SHADOW 1 #define MODIFIER_SHADER 2 -#define MODIFIER_COLOR_FILTER 4 // ---------------------------------------------------------------------------- @@ -638,7 +636,6 @@ static void android_view_GLES20Canvas_resetModifiers(JNIEnv* env, jobject clazz, OpenGLRenderer* renderer = reinterpret_cast(rendererPtr); if (modifiers & MODIFIER_SHADOW) renderer->resetShadow(); if (modifiers & MODIFIER_SHADER) renderer->resetShader(); - if (modifiers & MODIFIER_COLOR_FILTER) renderer->resetColorFilter(); } static void android_view_GLES20Canvas_setupShader(JNIEnv* env, jobject clazz, @@ -648,12 +645,6 @@ static void android_view_GLES20Canvas_setupShader(JNIEnv* env, jobject clazz, renderer->setupShader(shader); } -static void android_view_GLES20Canvas_setupColorFilter(JNIEnv* env, jobject clazz, - jlong rendererPtr, jlong colorFilterPtr) { - OpenGLRenderer* renderer = reinterpret_cast(rendererPtr); - SkiaColorFilter* colorFilter = reinterpret_cast(colorFilterPtr); - renderer->setupColorFilter(colorFilter); -} static void android_view_GLES20Canvas_setupShadow(JNIEnv* env, jobject clazz, jlong rendererPtr, jfloat radius, jfloat dx, jfloat dy, jint color) { @@ -923,148 +914,6 @@ static void android_view_GLES20Canvas_resume(JNIEnv* env, jobject clazz, renderer->resume(); } -<<<<<<< HEAD -static jint android_view_GLES20Canvas_createLayerRenderer(JNIEnv* env, - jobject clazz, jlong layerPtr) { - Layer* layer = reinterpret_cast(layerPtr); - if (layer) { - OpenGLRenderer* renderer = new LayerRenderer(layer); - renderer->initProperties(); - return reinterpret_cast(renderer); - } - return NULL; -} - -static jlong android_view_GLES20Canvas_createTextureLayer(JNIEnv* env, jobject clazz, - jboolean isOpaque, jintArray layerInfo) { - Layer* layer = LayerRenderer::createTextureLayer(isOpaque); - - if (layer) { - jint* storage = env->GetIntArrayElements(layerInfo, NULL); - storage[0] = layer->getTexture(); - env->ReleaseIntArrayElements(layerInfo, storage, 0); - } - - return reinterpret_cast(layer); -} - -static jlong android_view_GLES20Canvas_createLayer(JNIEnv* env, jobject clazz, - jint width, jint height, jboolean isOpaque, jintArray layerInfo) { - Layer* layer = LayerRenderer::createLayer(width, height, isOpaque); - - if (layer) { - jint* storage = env->GetIntArrayElements(layerInfo, NULL); - storage[0] = layer->getWidth(); - storage[1] = layer->getHeight(); - env->ReleaseIntArrayElements(layerInfo, storage, 0); - } - - return reinterpret_cast(layer); -} - -static jboolean android_view_GLES20Canvas_resizeLayer(JNIEnv* env, jobject clazz, - jlong layerPtr, jint width, jint height, jintArray layerInfo) { - Layer* layer = reinterpret_cast(layerPtr); - if (LayerRenderer::resizeLayer(layer, width, height)) { - jint* storage = env->GetIntArrayElements(layerInfo, NULL); - storage[0] = layer->getWidth(); - storage[1] = layer->getHeight(); - env->ReleaseIntArrayElements(layerInfo, storage, 0); - return JNI_TRUE; - } - return JNI_FALSE; -} - -static void android_view_GLES20Canvas_setLayerPaint(JNIEnv* env, jobject clazz, - jlong layerPtr, jlong paintPtr) { - Layer* layer = reinterpret_cast(layerPtr); - if (layer) { - SkPaint* paint = reinterpret_cast(paintPtr); - layer->setPaint(paint); - } -} - -static void android_view_GLES20Canvas_setLayerColorFilter(JNIEnv* env, jobject clazz, - jlong layerPtr, jlong colorFilterPtr) { - Layer* layer = reinterpret_cast(layerPtr); - if (layer) { - SkiaColorFilter* colorFilter = reinterpret_cast(colorFilterPtr); - layer->setColorFilter(colorFilter); - } -} - -static void android_view_GLES20Canvas_setOpaqueLayer(JNIEnv* env, jobject clazz, - jlong layerPtr, jboolean isOpaque) { - Layer* layer = reinterpret_cast(layerPtr); - if (layer) { - layer->setBlend(!isOpaque); - } -} - -static void android_view_GLES20Canvas_updateTextureLayer(JNIEnv* env, jobject clazz, - jlong layerPtr, jint width, jint height, jboolean isOpaque, jobject surface) { - float transform[16]; - sp surfaceTexture(SurfaceTexture_getSurfaceTexture(env, surface)); - - if (surfaceTexture->updateTexImage() == NO_ERROR) { - int64_t frameNumber = surfaceTexture->getFrameNumber(); - // If the GLConsumer queue is in synchronous mode, need to discard all - // but latest frame, using the frame number to tell when we no longer - // have newer frames to target. Since we can't tell which mode it is in, - // do this unconditionally. - int dropCounter = 0; - while (surfaceTexture->updateTexImage() == NO_ERROR) { - int64_t newFrameNumber = surfaceTexture->getFrameNumber(); - if (newFrameNumber == frameNumber) break; - frameNumber = newFrameNumber; - dropCounter++; - } - #if DEBUG_RENDERER - if (dropCounter > 0) { - RENDERER_LOGD("Dropped %d frames on texture layer update", dropCounter); - } - #endif - surfaceTexture->getTransformMatrix(transform); - GLenum renderTarget = surfaceTexture->getCurrentTextureTarget(); - - Layer* layer = reinterpret_cast(layerPtr); - LayerRenderer::updateTextureLayer(layer, width, height, isOpaque, renderTarget, transform); - } -} - -static void android_view_GLES20Canvas_updateRenderLayer(JNIEnv* env, jobject clazz, - jlong layerPtr, jlong rendererPtr, jlong displayListPtr, - jint left, jint top, jint right, jint bottom) { - Layer* layer = reinterpret_cast(layerPtr); - OpenGLRenderer* renderer = reinterpret_cast(rendererPtr); - DisplayList* displayList = reinterpret_cast(displayListPtr); - layer->updateDeferred(renderer, displayList, left, top, right, bottom); -} - -static void android_view_GLES20Canvas_clearLayerTexture(JNIEnv* env, jobject clazz, - jlong layerPtr) { - Layer* layer = reinterpret_cast(layerPtr); - layer->clearTexture(); -} - -static void android_view_GLES20Canvas_setTextureLayerTransform(JNIEnv* env, jobject clazz, - jlong layerPtr, jlong matrixPtr) { - Layer* layer = reinterpret_cast(layerPtr); - SkMatrix* matrix = reinterpret_cast(matrixPtr); - layer->getTransform().load(*matrix); -} - -static void android_view_GLES20Canvas_destroyLayer(JNIEnv* env, jobject clazz, jlong layerPtr) { - Layer* layer = reinterpret_cast(layerPtr); - LayerRenderer::destroyLayer(layer); -} - -static void android_view_GLES20Canvas_destroyLayerDeferred(JNIEnv* env, - jobject clazz, jlong layerPtr) { - Layer* layer = reinterpret_cast(layerPtr); - LayerRenderer::destroyLayerDeferred(layer); -} - static void android_view_GLES20Canvas_drawLayer(JNIEnv* env, jobject clazz, jlong rendererPtr, jlong layerPtr, jfloat x, jfloat y) { OpenGLRenderer* renderer = reinterpret_cast(rendererPtr); @@ -1223,7 +1072,6 @@ static JNINativeMethod gMethods[] = { { "nResetModifiers", "(JI)V", (void*) android_view_GLES20Canvas_resetModifiers }, { "nSetupShader", "(JJ)V", (void*) android_view_GLES20Canvas_setupShader }, - { "nSetupColorFilter", "(JJ)V", (void*) android_view_GLES20Canvas_setupColorFilter }, { "nSetupShadow", "(JFFFI)V", (void*) android_view_GLES20Canvas_setupShadow }, { "nSetupPaintFilter", "(JII)V", (void*) android_view_GLES20Canvas_setupPaintFilter },