summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/app/ActivityManager.java29
-rw-r--r--core/java/com/android/internal/widget/ActionBarView.java21
-rw-r--r--data/fonts/DroidSansThai.ttfbin36028 -> 35584 bytes
-rw-r--r--libs/hwui/GradientCache.h43
-rw-r--r--libs/hwui/LayerCache.h4
-rw-r--r--libs/hwui/PatchCache.h7
-rw-r--r--libs/hwui/PathCache.h4
-rw-r--r--libs/hwui/ShapeCache.h40
-rw-r--r--libs/rs/rsContext.cpp26
-rw-r--r--libs/rs/rsLocklessFifo.cpp14
-rw-r--r--libs/rs/rsLocklessFifo.h4
-rw-r--r--libs/rs/rsSignal.cpp29
-rw-r--r--libs/rs/rsSignal.h5
-rw-r--r--libs/rs/rsThreadIO.cpp16
-rw-r--r--libs/rs/rsThreadIO.h2
-rw-r--r--policy/src/com/android/internal/policy/impl/KeyguardViewManager.java8
16 files changed, 130 insertions, 122 deletions
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index f7e5cf1..93e30af 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -18,6 +18,7 @@ package android.app;
import com.android.internal.app.IUsageStats;
import com.android.internal.os.PkgUsageStats;
+import com.android.internal.util.MemInfoReader;
import android.content.ComponentName;
import android.content.Context;
@@ -28,6 +29,7 @@ import android.content.pm.IPackageDataObserver;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
+import android.graphics.Point;
import android.os.Debug;
import android.os.Handler;
import android.os.Parcel;
@@ -38,6 +40,8 @@ import android.os.SystemProperties;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
+import android.util.Slog;
+import android.view.Display;
import java.util.ArrayList;
import java.util.HashMap;
@@ -206,6 +210,31 @@ public class ActivityManager {
}
/**
+ * Used by persistent processes to determine if they are running on a
+ * higher-end device so should be okay using hardware drawing acceleration
+ * (which tends to consume a lot more RAM).
+ * @hide
+ */
+ static public boolean isHighEndGfx(Display display) {
+ MemInfoReader reader = new MemInfoReader();
+ reader.readMemInfo();
+ if (reader.getTotalSize() >= (512*1024*1024)) {
+ // If the device has at least 512MB RAM available to the kernel,
+ // we can afford the overhead of graphics acceleration.
+ return true;
+ }
+ Point p = new Point();
+ display.getRealSize(p);
+ int pixels = p.x * p.y;
+ if (pixels >= (1024*600)) {
+ // If this is a sufficiently large screen, then there are enough
+ // pixels on it that we'd really like to use hw drawing.
+ return true;
+ }
+ return false;
+ }
+
+ /**
* Information you can retrieve about tasks that the user has most recently
* started or visited.
*/
diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java
index a3d0fe4..83f3294 100644
--- a/core/java/com/android/internal/widget/ActionBarView.java
+++ b/core/java/com/android/internal/widget/ActionBarView.java
@@ -579,7 +579,7 @@ public class ActionBarView extends AbsActionBarView {
}
public void setIcon(int resId) {
- setIcon(mContext.getResources().getDrawableForDensity(resId, getPreferredIconDensity()));
+ setIcon(mContext.getResources().getDrawable(resId));
}
public void setLogo(Drawable logo) {
@@ -593,25 +593,6 @@ public class ActionBarView extends AbsActionBarView {
setLogo(mContext.getResources().getDrawable(resId));
}
- /**
- * @return Drawable density to load that will best fit the available height.
- */
- private int getPreferredIconDensity() {
- final Resources res = mContext.getResources();
- final int availableHeight = getLayoutParams().height -
- mHomeLayout.getVerticalIconPadding();
- int iconSize = res.getDimensionPixelSize(android.R.dimen.app_icon_size);
-
- if (iconSize * DisplayMetrics.DENSITY_LOW >= availableHeight) {
- return DisplayMetrics.DENSITY_LOW;
- } else if (iconSize * DisplayMetrics.DENSITY_MEDIUM >= availableHeight) {
- return DisplayMetrics.DENSITY_MEDIUM;
- } else if (iconSize * DisplayMetrics.DENSITY_HIGH >= availableHeight) {
- return DisplayMetrics.DENSITY_HIGH;
- }
- return DisplayMetrics.DENSITY_XHIGH;
- }
-
public void setNavigationMode(int mode) {
final int oldMode = mNavigationMode;
if (mode != oldMode) {
diff --git a/data/fonts/DroidSansThai.ttf b/data/fonts/DroidSansThai.ttf
index f849bae..c078be0 100644
--- a/data/fonts/DroidSansThai.ttf
+++ b/data/fonts/DroidSansThai.ttf
Binary files differ
diff --git a/libs/hwui/GradientCache.h b/libs/hwui/GradientCache.h
index 45c1005..7339853 100644
--- a/libs/hwui/GradientCache.h
+++ b/libs/hwui/GradientCache.h
@@ -38,28 +38,27 @@ struct GradientCacheEntry {
GradientCacheEntry(uint32_t* colors, float* positions, int count,
SkShader::TileMode tileMode) {
- this->count = count;
- this->colors = new uint32_t[count];
- this->positions = new float[count];
- this->tileMode = tileMode;
-
- memcpy(this->colors, colors, count * sizeof(uint32_t));
- memcpy(this->positions, positions, count * sizeof(float));
+ copy(colors, positions, count, tileMode);
}
GradientCacheEntry(const GradientCacheEntry& entry) {
- this->count = entry.count;
- this->colors = new uint32_t[count];
- this->positions = new float[count];
- this->tileMode = entry.tileMode;
-
- memcpy(this->colors, entry.colors, count * sizeof(uint32_t));
- memcpy(this->positions, entry.positions, count * sizeof(float));
+ copy(entry.colors, entry.positions, entry.count, entry.tileMode);
}
~GradientCacheEntry() {
- if (colors) delete[] colors;
- if (positions) delete[] positions;
+ delete[] colors;
+ delete[] positions;
+ }
+
+ GradientCacheEntry& operator=(const GradientCacheEntry& entry) {
+ if (this != &entry) {
+ delete[] colors;
+ delete[] positions;
+
+ copy(entry.colors, entry.positions, entry.count, entry.tileMode);
+ }
+
+ return *this;
}
bool operator<(const GradientCacheEntry& r) const {
@@ -82,6 +81,18 @@ struct GradientCacheEntry {
int count;
SkShader::TileMode tileMode;
+private:
+
+ void copy(uint32_t* colors, float* positions, int count, SkShader::TileMode tileMode) {
+ this->count = count;
+ this->colors = new uint32_t[count];
+ this->positions = new float[count];
+ this->tileMode = tileMode;
+
+ memcpy(this->colors, colors, count * sizeof(uint32_t));
+ memcpy(this->positions, positions, count * sizeof(float));
+ }
+
}; // GradientCacheEntry
/**
diff --git a/libs/hwui/LayerCache.h b/libs/hwui/LayerCache.h
index a0eae59..63bb824 100644
--- a/libs/hwui/LayerCache.h
+++ b/libs/hwui/LayerCache.h
@@ -119,10 +119,6 @@ private:
mHeight = uint32_t(ceilf(layerHeight / float(LAYER_SIZE)) * LAYER_SIZE);
}
- LayerEntry(const LayerEntry& entry):
- mLayer(entry.mLayer), mWidth(entry.mWidth), mHeight(entry.mHeight) {
- }
-
LayerEntry(Layer* layer):
mLayer(layer), mWidth(layer->getWidth()), mHeight(layer->getHeight()) {
}
diff --git a/libs/hwui/PatchCache.h b/libs/hwui/PatchCache.h
index 62d0ce1..91b603f 100644
--- a/libs/hwui/PatchCache.h
+++ b/libs/hwui/PatchCache.h
@@ -80,13 +80,6 @@ private:
emptyCount(emptyCount), colorKey(colorKey) {
}
- PatchDescription(const PatchDescription& description):
- bitmapWidth(description.bitmapWidth), bitmapHeight(description.bitmapHeight),
- pixelWidth(description.pixelWidth), pixelHeight(description.pixelHeight),
- xCount(description.xCount), yCount(description.yCount),
- emptyCount(description.emptyCount), colorKey(description.colorKey) {
- }
-
bool operator<(const PatchDescription& rhs) const {
LTE_FLOAT(bitmapWidth) {
LTE_FLOAT(bitmapHeight) {
diff --git a/libs/hwui/PathCache.h b/libs/hwui/PathCache.h
index 7ff8b74..4904a58 100644
--- a/libs/hwui/PathCache.h
+++ b/libs/hwui/PathCache.h
@@ -41,10 +41,6 @@ struct PathCacheEntry: public ShapeCacheEntry {
path = NULL;
}
- PathCacheEntry(const PathCacheEntry& entry): ShapeCacheEntry(entry) {
- path = entry.path;
- }
-
bool lessThan(const ShapeCacheEntry& r) const {
const PathCacheEntry& rhs = (const PathCacheEntry&) r;
LTE_INT(path) {
diff --git a/libs/hwui/ShapeCache.h b/libs/hwui/ShapeCache.h
index 33953be..0660b69 100644
--- a/libs/hwui/ShapeCache.h
+++ b/libs/hwui/ShapeCache.h
@@ -96,12 +96,6 @@ struct ShapeCacheEntry {
pathEffect = NULL;
}
- ShapeCacheEntry(const ShapeCacheEntry& entry):
- shapeType(entry.shapeType), join(entry.join), cap(entry.cap),
- style(entry.style), miter(entry.miter),
- strokeWidth(entry.strokeWidth), pathEffect(entry.pathEffect) {
- }
-
ShapeCacheEntry(ShapeType type, SkPaint* paint) {
shapeType = type;
join = paint->getStrokeJoin();
@@ -167,14 +161,6 @@ struct RoundRectShapeCacheEntry: public ShapeCacheEntry {
mRy = 0;
}
- RoundRectShapeCacheEntry(const RoundRectShapeCacheEntry& entry):
- ShapeCacheEntry(entry) {
- mWidth = entry.mWidth;
- mHeight = entry.mHeight;
- mRx = entry.mRx;
- mRy = entry.mRy;
- }
-
bool lessThan(const ShapeCacheEntry& r) const {
const RoundRectShapeCacheEntry& rhs = (const RoundRectShapeCacheEntry&) r;
LTE_INT(mWidth) {
@@ -206,11 +192,6 @@ struct CircleShapeCacheEntry: public ShapeCacheEntry {
mRadius = 0;
}
- CircleShapeCacheEntry(const CircleShapeCacheEntry& entry):
- ShapeCacheEntry(entry) {
- mRadius = entry.mRadius;
- }
-
bool lessThan(const ShapeCacheEntry& r) const {
const CircleShapeCacheEntry& rhs = (const CircleShapeCacheEntry&) r;
LTE_INT(mRadius) {
@@ -234,12 +215,6 @@ struct OvalShapeCacheEntry: public ShapeCacheEntry {
mWidth = mHeight = 0;
}
- OvalShapeCacheEntry(const OvalShapeCacheEntry& entry):
- ShapeCacheEntry(entry) {
- mWidth = entry.mWidth;
- mHeight = entry.mHeight;
- }
-
bool lessThan(const ShapeCacheEntry& r) const {
const OvalShapeCacheEntry& rhs = (const OvalShapeCacheEntry&) r;
LTE_INT(mWidth) {
@@ -266,12 +241,6 @@ struct RectShapeCacheEntry: public ShapeCacheEntry {
mWidth = mHeight = 0;
}
- RectShapeCacheEntry(const RectShapeCacheEntry& entry):
- ShapeCacheEntry(entry) {
- mWidth = entry.mWidth;
- mHeight = entry.mHeight;
- }
-
bool lessThan(const ShapeCacheEntry& r) const {
const RectShapeCacheEntry& rhs = (const RectShapeCacheEntry&) r;
LTE_INT(mWidth) {
@@ -306,15 +275,6 @@ struct ArcShapeCacheEntry: public ShapeCacheEntry {
mUseCenter = 0;
}
- ArcShapeCacheEntry(const ArcShapeCacheEntry& entry):
- ShapeCacheEntry(entry) {
- mWidth = entry.mWidth;
- mHeight = entry.mHeight;
- mStartAngle = entry.mStartAngle;
- mSweepAngle = entry.mSweepAngle;
- mUseCenter = entry.mUseCenter;
- }
-
bool lessThan(const ShapeCacheEntry& r) const {
const ArcShapeCacheEntry& rhs = (const ArcShapeCacheEntry&) r;
LTE_INT(mWidth) {
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index 6a30b17..bffe3c0 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -245,20 +245,32 @@ void * Context::threadProc(void *vrsc) {
rsc->mRunning = true;
bool mDraw = true;
+ bool doWait = true;
+
+ uint64_t targetTime = rsc->getTime();
while (!rsc->mExit) {
- mDraw |= rsc->mIO.playCoreCommands(rsc, !mDraw);
+ uint64_t waitTime = 0;
+ uint64_t now = rsc->getTime();
+ if (now < targetTime) {
+ waitTime = targetTime - now;
+ } else {
+ doWait = false;
+ }
+
+ mDraw |= rsc->mIO.playCoreCommands(rsc, doWait, waitTime);
mDraw &= (rsc->mRootScript.get() != NULL);
mDraw &= rsc->mHasSurface;
- uint32_t targetTime = 0;
if (mDraw && rsc->mIsGraphicsContext) {
- targetTime = rsc->runRootScript();
+ uint64_t delay = rsc->runRootScript() * 1000000;
+ targetTime = rsc->getTime() + delay;
+ doWait = delay != 0;
if (rsc->props.mLogVisual) {
rsc->displayDebugStats();
}
- mDraw = targetTime && !rsc->mPaused;
+ mDraw = !rsc->mPaused;
rsc->timerSet(RS_TIMER_CLEAR_SWAP);
rsc->mHal.funcs.swap(rsc);
rsc->timerFrame();
@@ -266,12 +278,6 @@ void * Context::threadProc(void *vrsc) {
rsc->timerPrint();
rsc->timerReset();
}
- if (targetTime > 1) {
- int32_t t = (targetTime - (int32_t)(rsc->mTimeMSLastScript + rsc->mTimeMSLastSwap)) * 1000;
- if (t > 0) {
- usleep(t);
- }
- }
}
LOGV("%p, RS Thread exiting", rsc);
diff --git a/libs/rs/rsLocklessFifo.cpp b/libs/rs/rsLocklessFifo.cpp
index 7023a1f..02a76ab 100644
--- a/libs/rs/rsLocklessFifo.cpp
+++ b/libs/rs/rsLocklessFifo.cpp
@@ -129,21 +129,23 @@ void LocklessCommandFifo::flush() {
//dumpState("flush 2");
}
-void LocklessCommandFifo::wait() {
+bool LocklessCommandFifo::wait(uint64_t timeout) {
while (isEmpty() && !mInShutdown) {
mSignalToControl.set();
- mSignalToWorker.wait();
+ return mSignalToWorker.wait(timeout);
}
+ return true;
}
-const void * LocklessCommandFifo::get(uint32_t *command, uint32_t *bytesData) {
+const void * LocklessCommandFifo::get(uint32_t *command, uint32_t *bytesData, uint64_t timeout) {
while (1) {
//dumpState("get");
- wait();
- if (mInShutdown) {
+ wait(timeout);
+
+ if (isEmpty() || mInShutdown) {
*command = 0;
*bytesData = 0;
- return 0;
+ return NULL;
}
*command = reinterpret_cast<const uint16_t *>(mGet)[0];
diff --git a/libs/rs/rsLocklessFifo.h b/libs/rs/rsLocklessFifo.h
index eabdc3e..4962ef6 100644
--- a/libs/rs/rsLocklessFifo.h
+++ b/libs/rs/rsLocklessFifo.h
@@ -57,9 +57,9 @@ public:
void commitSync(uint32_t command, uint32_t bytes);
void flush();
- void wait();
+ bool wait(uint64_t timeout = 0);
- const void * get(uint32_t *command, uint32_t *bytesData);
+ const void * get(uint32_t *command, uint32_t *bytesData, uint64_t timeout = 0);
void next();
void makeSpace(uint32_t bytes);
diff --git a/libs/rs/rsSignal.cpp b/libs/rs/rsSignal.cpp
index ccd20b9..413ac2b 100644
--- a/libs/rs/rsSignal.cpp
+++ b/libs/rs/rsSignal.cpp
@@ -68,26 +68,43 @@ void Signal::set() {
}
}
-void Signal::wait() {
+bool Signal::wait(uint64_t timeout) {
int status;
+ bool ret = false;
status = pthread_mutex_lock(&mMutex);
if (status) {
LOGE("LocklessCommandFifo: error %i locking for condition.", status);
- return;
+ return false;
}
if (!mSet) {
- status = pthread_cond_wait(&mCondition, &mMutex);
- if (status) {
- LOGE("LocklessCommandFifo: error %i waiting on condition.", status);
+ if (!timeout) {
+ status = pthread_cond_wait(&mCondition, &mMutex);
+ } else {
+#if defined(HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE)
+ status = pthread_cond_timeout_np(&mCondition, &mMutex, timeout / 1000000);
+#else
+ // This is safe it will just make things less reponsive
+ status = pthread_cond_wait(&mCondition, &mMutex);
+#endif
+ }
+ }
+
+ if (!status) {
+ mSet = false;
+ ret = true;
+ } else {
+ if (status != ETIMEDOUT) {
+ LOGE("LocklessCommandFifo: error %i waiting for condition.", status);
}
}
- mSet = false;
status = pthread_mutex_unlock(&mMutex);
if (status) {
LOGE("LocklessCommandFifo: error %i unlocking for condition.", status);
}
+
+ return ret;
}
diff --git a/libs/rs/rsSignal.h b/libs/rs/rsSignal.h
index 2e760f1..fc31883 100644
--- a/libs/rs/rsSignal.h
+++ b/libs/rs/rsSignal.h
@@ -31,7 +31,10 @@ public:
bool init();
void set();
- void wait();
+
+ // returns true if the signal occured
+ // false for timeout
+ bool wait(uint64_t timeout = 0);
protected:
bool mSet;
diff --git a/libs/rs/rsThreadIO.cpp b/libs/rs/rsThreadIO.cpp
index 1c8b89c..fe2c52e 100644
--- a/libs/rs/rsThreadIO.cpp
+++ b/libs/rs/rsThreadIO.cpp
@@ -113,8 +113,10 @@ void ThreadIO::coreGetReturn(void *data, size_t dataLen) {
}
-bool ThreadIO::playCoreCommands(Context *con, bool waitForCommand) {
+bool ThreadIO::playCoreCommands(Context *con, bool waitForCommand, uint64_t timeToWait) {
bool ret = false;
+ uint64_t startTime = con->getTime();
+
while (!mToCore.isEmpty() || waitForCommand) {
uint32_t cmdID = 0;
uint32_t cmdSize = 0;
@@ -122,9 +124,17 @@ bool ThreadIO::playCoreCommands(Context *con, bool waitForCommand) {
if (con->props.mLogTimes) {
con->timerSet(Context::RS_TIMER_IDLE);
}
- const void * data = mToCore.get(&cmdID, &cmdSize);
+
+ uint64_t delay = 0;
+ if (waitForCommand) {
+ delay = timeToWait - (con->getTime() - startTime);
+ if (delay > timeToWait) {
+ delay = 0;
+ }
+ }
+ const void * data = mToCore.get(&cmdID, &cmdSize, delay);
if (!cmdSize) {
- // exception occured, probably shutdown.
+ // exception or timeout occurred.
return false;
}
if (con->props.mLogTimes) {
diff --git a/libs/rs/rsThreadIO.h b/libs/rs/rsThreadIO.h
index cad7318..9036118 100644
--- a/libs/rs/rsThreadIO.h
+++ b/libs/rs/rsThreadIO.h
@@ -37,7 +37,7 @@ public:
// Plays back commands from the client.
// Returns true if any commands were processed.
- bool playCoreCommands(Context *con, bool waitForCommand);
+ bool playCoreCommands(Context *con, bool waitForCommand, uint64_t timeToWait);
//LocklessCommandFifo mToCore;
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java b/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java
index 6ee5861..f52bb26 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java
@@ -18,6 +18,7 @@ package com.android.internal.policy.impl;
import com.android.internal.R;
+import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.res.Resources;
@@ -107,13 +108,16 @@ public class KeyguardViewManager implements KeyguardWindowController {
int flags = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN
| WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER
| WindowManager.LayoutParams.FLAG_KEEP_SURFACE_WHILE_ANIMATING
- | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
- | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED_SYSTEM
/*| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR*/ ;
if (!mNeedsInput) {
flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
}
+ if (ActivityManager.isHighEndGfx(((WindowManager)mContext.getSystemService(
+ Context.WINDOW_SERVICE)).getDefaultDisplay())) {
+ flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
+ | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED_SYSTEM;
+ }
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
stretch, stretch, WindowManager.LayoutParams.TYPE_KEYGUARD,
flags, PixelFormat.TRANSLUCENT);