Merge "Update comments"
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 5042258..056be7f 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -10951,20 +10951,70 @@
}
/**
+ * Utility function, called by draw(canvas, parent, drawingTime) to handle the less common
+ * case of an active Animation being run on the view.
+ */
+ private boolean drawAnimation(ViewGroup parent, long drawingTime,
+ Animation a, boolean scalingRequired) {
+ Transformation invalidationTransform;
+ final int flags = parent.mGroupFlags;
+ final boolean initialized = a.isInitialized();
+ if (!initialized) {
+ a.initialize(mRight - mLeft, mBottom - mTop, getWidth(), getHeight());
+ a.initializeInvalidateRegion(0, 0, mRight - mLeft, mBottom - mTop);
+ onAnimationStart();
+ }
+
+ boolean more = a.getTransformation(drawingTime, parent.mChildTransformation, 1f);
+ if (scalingRequired && mAttachInfo.mApplicationScale != 1f) {
+ if (parent.mInvalidationTransformation == null) {
+ parent.mInvalidationTransformation = new Transformation();
+ }
+ invalidationTransform = parent.mInvalidationTransformation;
+ a.getTransformation(drawingTime, invalidationTransform, 1f);
+ } else {
+ invalidationTransform = parent.mChildTransformation;
+ }
+ if (more) {
+ if (!a.willChangeBounds()) {
+ if ((flags & (parent.FLAG_OPTIMIZE_INVALIDATE | parent.FLAG_ANIMATION_DONE)) ==
+ parent.FLAG_OPTIMIZE_INVALIDATE) {
+ parent.mGroupFlags |= parent.FLAG_INVALIDATE_REQUIRED;
+ } else if ((flags & parent.FLAG_INVALIDATE_REQUIRED) == 0) {
+ // The child need to draw an animation, potentially offscreen, so
+ // make sure we do not cancel invalidate requests
+ parent.mPrivateFlags |= DRAW_ANIMATION;
+ parent.invalidate(mLeft, mTop, mRight, mBottom);
+ }
+ } else {
+ if (parent.mInvalidateRegion == null) {
+ parent.mInvalidateRegion = new RectF();
+ }
+ final RectF region = parent.mInvalidateRegion;
+ a.getInvalidateRegion(0, 0, mRight - mLeft, mBottom - mTop, region,
+ invalidationTransform);
+
+ // The child need to draw an animation, potentially offscreen, so
+ // make sure we do not cancel invalidate requests
+ parent.mPrivateFlags |= DRAW_ANIMATION;
+
+ final int left = mLeft + (int) region.left;
+ final int top = mTop + (int) region.top;
+ parent.invalidate(left, top, left + (int) (region.width() + .5f),
+ top + (int) (region.height() + .5f));
+ }
+ }
+ return more;
+ }
+
+ /**
* This method is called by ViewGroup.drawChild() to have each child view draw itself.
* This draw() method is an implementation detail and is not intended to be overridden or
* to be called from anywhere else other than ViewGroup.drawChild().
*/
boolean draw(Canvas canvas, ViewGroup parent, long drawingTime) {
boolean more = false;
-
- final int cl = mLeft;
- final int ct = mTop;
- final int cr = mRight;
- final int cb = mBottom;
-
final boolean childHasIdentityMatrix = hasIdentityMatrix();
-
final int flags = parent.mGroupFlags;
if ((flags & parent.FLAG_CLEAR_TRANSFORMATION) == parent.FLAG_CLEAR_TRANSFORMATION) {
@@ -10973,8 +11023,6 @@
}
Transformation transformToApply = null;
- Transformation invalidationTransform;
- final Animation a = getAnimation();
boolean concatMatrix = false;
boolean scalingRequired = false;
@@ -10990,59 +11038,15 @@
caching = (layerType != LAYER_TYPE_NONE) || hardwareAccelerated;
}
+ final Animation a = getAnimation();
if (a != null) {
- final boolean initialized = a.isInitialized();
- if (!initialized) {
- a.initialize(cr - cl, cb - ct, getWidth(), getHeight());
- a.initializeInvalidateRegion(0, 0, cr - cl, cb - ct);
- onAnimationStart();
- }
-
- more = a.getTransformation(drawingTime, parent.mChildTransformation, 1f);
- if (scalingRequired && mAttachInfo.mApplicationScale != 1f) {
- if (parent.mInvalidationTransformation == null) {
- parent.mInvalidationTransformation = new Transformation();
- }
- invalidationTransform = parent.mInvalidationTransformation;
- a.getTransformation(drawingTime, invalidationTransform, 1f);
- } else {
- invalidationTransform = parent.mChildTransformation;
- }
- transformToApply = parent.mChildTransformation;
-
+ more = drawAnimation(parent, drawingTime, a, scalingRequired);
concatMatrix = a.willChangeTransformationMatrix();
-
- if (more) {
- if (!a.willChangeBounds()) {
- if ((flags & (parent.FLAG_OPTIMIZE_INVALIDATE | parent.FLAG_ANIMATION_DONE)) ==
- parent.FLAG_OPTIMIZE_INVALIDATE) {
- parent.mGroupFlags |= parent.FLAG_INVALIDATE_REQUIRED;
- } else if ((flags & parent.FLAG_INVALIDATE_REQUIRED) == 0) {
- // The child need to draw an animation, potentially offscreen, so
- // make sure we do not cancel invalidate requests
- parent.mPrivateFlags |= DRAW_ANIMATION;
- invalidate(cl, ct, cr, cb);
- }
- } else {
- if (parent.mInvalidateRegion == null) {
- parent.mInvalidateRegion = new RectF();
- }
- final RectF region = parent.mInvalidateRegion;
- a.getInvalidateRegion(0, 0, cr - cl, cb - ct, region, invalidationTransform);
-
- // The child need to draw an animation, potentially offscreen, so
- // make sure we do not cancel invalidate requests
- parent.mPrivateFlags |= DRAW_ANIMATION;
-
- final int left = cl + (int) region.left;
- final int top = ct + (int) region.top;
- invalidate(left, top, left + (int) (region.width() + .5f),
- top + (int) (region.height() + .5f));
- }
- }
+ transformToApply = parent.mChildTransformation;
} else if ((flags & parent.FLAG_SUPPORT_STATIC_TRANSFORMATIONS) ==
parent.FLAG_SUPPORT_STATIC_TRANSFORMATIONS) {
- final boolean hasTransform = parent.getChildStaticTransformation(this, parent.mChildTransformation);
+ final boolean hasTransform =
+ parent.getChildStaticTransformation(this, parent.mChildTransformation);
if (hasTransform) {
final int transformType = parent.mChildTransformation.getTransformationType();
transformToApply = transformType != Transformation.TYPE_IDENTITY ?
@@ -11057,7 +11061,7 @@
// to call invalidate() successfully when doing animations
mPrivateFlags |= DRAWN;
- if (!concatMatrix && canvas.quickReject(cl, ct, cr, cb, Canvas.EdgeType.BW) &&
+ if (!concatMatrix && canvas.quickReject(mLeft, mTop, mRight, mBottom, Canvas.EdgeType.BW) &&
(mPrivateFlags & DRAW_ANIMATION) == 0) {
return more;
}
@@ -11105,9 +11109,9 @@
final int restoreTo = canvas.save();
if (offsetForScroll) {
- canvas.translate(cl - sx, ct - sy);
+ canvas.translate(mLeft - sx, mTop - sy);
} else {
- canvas.translate(cl, ct);
+ canvas.translate(mLeft, mTop);
if (scalingRequired) {
// mAttachInfo cannot be null, otherwise scalingRequired == false
final float scale = 1.0f / mAttachInfo.mApplicationScale;
@@ -11163,8 +11167,8 @@
if (layerType == LAYER_TYPE_NONE) {
final int scrollX = hasDisplayList ? 0 : sx;
final int scrollY = hasDisplayList ? 0 : sy;
- canvas.saveLayerAlpha(scrollX, scrollY, scrollX + cr - cl,
- scrollY + cb - ct, multipliedAlpha, layerFlags);
+ canvas.saveLayerAlpha(scrollX, scrollY, scrollX + mRight - mLeft,
+ scrollY + mBottom - mTop, multipliedAlpha, layerFlags);
}
} else {
// Alpha is handled by the child directly, clobber the layer's alpha
@@ -11179,10 +11183,10 @@
if ((flags & parent.FLAG_CLIP_CHILDREN) == parent.FLAG_CLIP_CHILDREN) {
if (offsetForScroll) {
- canvas.clipRect(sx, sy, sx + (cr - cl), sy + (cb - ct));
+ canvas.clipRect(sx, sy, sx + (mRight - mLeft), sy + (mBottom - mTop));
} else {
if (!scalingRequired || cache == null) {
- canvas.clipRect(0, 0, cr - cl, cb - ct);
+ canvas.clipRect(0, 0, mRight - mLeft, mBottom - mTop);
} else {
canvas.clipRect(0, 0, cache.getWidth(), cache.getHeight());
}
@@ -11212,7 +11216,7 @@
final int scrollX = hasDisplayList ? 0 : sx;
final int scrollY = hasDisplayList ? 0 : sy;
canvas.saveLayer(scrollX, scrollY,
- scrollX + cr - cl, scrollY + cb - ct, mLayerPaint,
+ scrollX + mRight - mLeft, scrollY + mBottom - mTop, mLayerPaint,
Canvas.HAS_ALPHA_LAYER_SAVE_FLAG | Canvas.CLIP_TO_LAYER_SAVE_FLAG);
}
}
@@ -11231,7 +11235,8 @@
}
} else {
mPrivateFlags &= ~DIRTY_MASK;
- ((HardwareCanvas) canvas).drawDisplayList(displayList, cr - cl, cb - ct, null);
+ ((HardwareCanvas) canvas).drawDisplayList(displayList,
+ mRight - mLeft, mBottom - mTop, null);
}
}
} else if (cache != null) {
@@ -11248,7 +11253,8 @@
if (alpha < 1.0f) {
cachePaint.setAlpha((int) (alpha * 255));
parent.mGroupFlags |= parent.FLAG_ALPHA_LOWER_THAN_ONE;
- } else if ((flags & parent.FLAG_ALPHA_LOWER_THAN_ONE) == parent.FLAG_ALPHA_LOWER_THAN_ONE) {
+ } else if ((flags & parent.FLAG_ALPHA_LOWER_THAN_ONE) ==
+ parent.FLAG_ALPHA_LOWER_THAN_ONE) {
cachePaint.setAlpha(255);
parent.mGroupFlags &= ~parent.FLAG_ALPHA_LOWER_THAN_ONE;
}
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index b27eef0..a2e85a3 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -2620,7 +2620,7 @@
*
* @param canvas The canvas on which to draw the child
* @param child Who to draw
- * @param drawingTime The time at which draw is occuring
+ * @param drawingTime The time at which draw is occurring
* @return True if an invalidate() was issued
*/
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h
index 0f2c323..ac7f6cf 100644
--- a/include/media/AudioTrack.h
+++ b/include/media/AudioTrack.h
@@ -303,7 +303,6 @@
* (loopEnd-loopStart) <= framecount()
*/
status_t setLoop(uint32_t loopStart, uint32_t loopEnd, int loopCount);
- status_t getLoop(uint32_t *loopStart, uint32_t *loopEnd, int *loopCount) const;
/* Sets marker position. When playback reaches the number of frames specified, a callback with
* event type EVENT_MARKER is called. Calling setMarkerPosition with marker == 0 cancels marker
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index db18b36..aead9a1 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -599,26 +599,6 @@
return NO_ERROR;
}
-status_t AudioTrack::getLoop(uint32_t *loopStart, uint32_t *loopEnd, int *loopCount) const
-{
- AutoMutex lock(mLock);
- if (loopStart != NULL) {
- *loopStart = mCblk->loopStart;
- }
- if (loopEnd != NULL) {
- *loopEnd = mCblk->loopEnd;
- }
- if (loopCount != NULL) {
- if (mCblk->loopCount < 0) {
- *loopCount = -1;
- } else {
- *loopCount = mCblk->loopCount;
- }
- }
-
- return NO_ERROR;
-}
-
status_t AudioTrack::setMarkerPosition(uint32_t marker)
{
if (mCbf == NULL) return INVALID_OPERATION;
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 131371e..c8807fa 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -540,7 +540,7 @@
Mutex::Autolock _l(mLock);
mMasterVolume = value;
- for (uint32_t i = 0; i < mPlaybackThreads.size(); i++)
+ for (size_t i = 0; i < mPlaybackThreads.size(); i++)
mPlaybackThreads.valueAt(i)->setMasterVolume(value);
return NO_ERROR;
@@ -572,7 +572,7 @@
if (NO_ERROR == ret) {
Mutex::Autolock _l(mLock);
mMode = mode;
- for (uint32_t i = 0; i < mPlaybackThreads.size(); i++)
+ for (size_t i = 0; i < mPlaybackThreads.size(); i++)
mPlaybackThreads.valueAt(i)->setMode(mode);
}
@@ -623,7 +623,7 @@
Mutex::Autolock _l(mLock);
// This is an optimization, so PlaybackThread doesn't have to look at the one from AudioFlinger
mMasterMute = muted;
- for (uint32_t i = 0; i < mPlaybackThreads.size(); i++)
+ for (size_t i = 0; i < mPlaybackThreads.size(); i++)
mPlaybackThreads.valueAt(i)->setMasterMute(muted);
return NO_ERROR;
@@ -666,7 +666,7 @@
mStreamTypes[stream].volume = value;
if (thread == NULL) {
- for (uint32_t i = 0; i < mPlaybackThreads.size(); i++) {
+ for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
mPlaybackThreads.valueAt(i)->setStreamVolume(stream, value);
}
} else {
@@ -929,7 +929,7 @@
{
Mutex::Autolock _l(mLock);
- int index = mNotificationClients.indexOfKey(pid);
+ ssize_t index = mNotificationClients.indexOfKey(pid);
if (index >= 0) {
sp <NotificationClient> client = mNotificationClients.valueFor(pid);
ALOGV("removeNotificationClient() %p, pid %d", client.get(), pid);
@@ -937,9 +937,9 @@
}
ALOGV("%d died, releasing its sessions", pid);
- int num = mAudioSessionRefs.size();
+ size_t num = mAudioSessionRefs.size();
bool removed = false;
- for (int i = 0; i< num; i++) {
+ for (size_t i = 0; i< num; ) {
AudioSessionRef *ref = mAudioSessionRefs.itemAt(i);
ALOGV(" pid %d @ %d", ref->pid, i);
if (ref->pid == pid) {
@@ -947,8 +947,9 @@
mAudioSessionRefs.removeAt(i);
delete ref;
removed = true;
- i--;
num--;
+ } else {
+ i++;
}
}
if (removed) {
@@ -1239,7 +1240,7 @@
void AudioFlinger::ThreadBase::checkSuspendOnAddEffectChain_l(const sp<EffectChain>& chain)
{
- int index = mSuspendedSessions.indexOfKey(chain->sessionId());
+ ssize_t index = mSuspendedSessions.indexOfKey(chain->sessionId());
if (index < 0) {
return;
}
@@ -1265,7 +1266,7 @@
bool suspend,
int sessionId)
{
- int index = mSuspendedSessions.indexOfKey(sessionId);
+ ssize_t index = mSuspendedSessions.indexOfKey(sessionId);
KeyedVector <int, sp<SuspendedSessionDesc> > sessionEffects;
@@ -5179,8 +5180,8 @@
Mutex::Autolock _l(mLock);
pid_t caller = IPCThreadState::self()->getCallingPid();
ALOGV("acquiring %d from %d", audioSession, caller);
- int num = mAudioSessionRefs.size();
- for (int i = 0; i< num; i++) {
+ size_t num = mAudioSessionRefs.size();
+ for (size_t i = 0; i< num; i++) {
AudioSessionRef *ref = mAudioSessionRefs.editItemAt(i);
if (ref->sessionid == audioSession && ref->pid == caller) {
ref->cnt++;
@@ -5197,8 +5198,8 @@
Mutex::Autolock _l(mLock);
pid_t caller = IPCThreadState::self()->getCallingPid();
ALOGV("releasing %d from %d", audioSession, caller);
- int num = mAudioSessionRefs.size();
- for (int i = 0; i< num; i++) {
+ size_t num = mAudioSessionRefs.size();
+ for (size_t i = 0; i< num; i++) {
AudioSessionRef *ref = mAudioSessionRefs.itemAt(i);
if (ref->sessionid == audioSession && ref->pid == caller) {
ref->cnt--;
@@ -7179,12 +7180,12 @@
// Reject insertion if an effect with EFFECT_FLAG_INSERT_EXCLUSIVE is
// already present
- int size = (int)mEffects.size();
- int idx_insert = size;
- int idx_insert_first = -1;
- int idx_insert_last = -1;
+ size_t size = mEffects.size();
+ size_t idx_insert = size;
+ ssize_t idx_insert_first = -1;
+ ssize_t idx_insert_last = -1;
- for (int i = 0; i < size; i++) {
+ for (size_t i = 0; i < size; i++) {
effect_descriptor_t d = mEffects[i]->desc();
uint32_t iMode = d.flags & EFFECT_FLAG_TYPE_MASK;
uint32_t iPref = d.flags & EFFECT_FLAG_INSERT_MASK;
@@ -7253,11 +7254,10 @@
size_t AudioFlinger::EffectChain::removeEffect_l(const sp<EffectModule>& effect)
{
Mutex::Autolock _l(mLock);
- int size = (int)mEffects.size();
- int i;
+ size_t size = mEffects.size();
uint32_t type = effect->desc().flags & EFFECT_FLAG_TYPE_MASK;
- for (i = 0; i < size; i++) {
+ for (size_t i = 0; i < size; i++) {
if (effect == mEffects[i]) {
// calling stop here will remove pre-processing effect from the audio HAL.
// This is safe as we hold the EffectChain mutex which guarantees that we are not in
@@ -7404,7 +7404,7 @@
sp<SuspendedEffectDesc> desc;
// use effect type UUID timelow as key as there is no real risk of identical
// timeLow fields among effect type UUIDs.
- int index = mSuspendedEffects.indexOfKey(type->timeLow);
+ ssize_t index = mSuspendedEffects.indexOfKey(type->timeLow);
if (suspend) {
if (index >= 0) {
desc = mSuspendedEffects.valueAt(index);
@@ -7454,7 +7454,7 @@
{
sp<SuspendedEffectDesc> desc;
- int index = mSuspendedEffects.indexOfKey((int)kKeyForSuspendAll);
+ ssize_t index = mSuspendedEffects.indexOfKey((int)kKeyForSuspendAll);
if (suspend) {
if (index >= 0) {
desc = mSuspendedEffects.valueAt(index);
@@ -7536,7 +7536,7 @@
void AudioFlinger::EffectChain::checkSuspendOnEffectEnabled(const sp<EffectModule>& effect,
bool enabled)
{
- int index = mSuspendedEffects.indexOfKey(effect->desc().type.timeLow);
+ ssize_t index = mSuspendedEffects.indexOfKey(effect->desc().type.timeLow);
if (enabled) {
if (index < 0) {
// if the effect is not suspend check if all effects are suspended
diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp
index 21b5811..041b5a8 100644
--- a/services/audioflinger/AudioPolicyService.cpp
+++ b/services/audioflinger/AudioPolicyService.cpp
@@ -768,7 +768,7 @@
snprintf(buffer, SIZE, "- Commands:\n");
result = String8(buffer);
result.append(" Command Time Wait pParam\n");
- for (int i = 0; i < (int)mAudioCommands.size(); i++) {
+ for (size_t i = 0; i < mAudioCommands.size(); i++) {
mAudioCommands[i]->dump(buffer, SIZE);
result.append(buffer);
}
@@ -902,7 +902,7 @@
// insertCommand_l() must be called with mLock held
void AudioPolicyService::AudioCommandThread::insertCommand_l(AudioCommand *command, int delayMs)
{
- ssize_t i;
+ ssize_t i; // not size_t because i will count down to -1
Vector <AudioCommand *> removedCommands;
command->mTime = systemTime() + milliseconds(delayMs);