summaryrefslogtreecommitdiff
path: root/libs/rs
diff options
context:
space:
mode:
author Shih-wei Liao <sliao@google.com> 2010-12-20 20:45:56 +0800
committer Shih-wei Liao <sliao@google.com> 2010-12-20 21:02:32 +0800
commiteeca435dc6134a285b9bbb832cd6a1a88f34e85f (patch)
tree0c7650ef80ade830a7892e867afe777a64187780 /libs/rs
parentb70c82dc45f62a1c257a80e7aa9e0ecfe063c1be (diff)
Stale cache management to address a P1 bug # 3296131.
Change-Id: I593f35a91c4a14c055828f8989fe01b9e7790039
Diffstat (limited to 'libs/rs')
-rw-r--r--libs/rs/Android.mk6
-rw-r--r--libs/rs/rs.spec1
-rw-r--r--libs/rs/rsScriptC.cpp49
-rw-r--r--libs/rs/rsScriptC.h2
4 files changed, 51 insertions, 7 deletions
diff --git a/libs/rs/Android.mk b/libs/rs/Android.mk
index 2ec003f989ea..c2e58b663ae2 100644
--- a/libs/rs/Android.mk
+++ b/libs/rs/Android.mk
@@ -113,11 +113,11 @@ LOCAL_SRC_FILES:= \
rsVertexArray.cpp
-LOCAL_SHARED_LIBRARIES += libcutils libutils libEGL libGLESv1_CM libGLESv2 libui libbcc
+LOCAL_SHARED_LIBRARIES += libz libcutils libutils libEGL libGLESv1_CM libGLESv2 libui libbcc
-LOCAL_STATIC_LIBRARIES := libft2 librslib_rt
+LOCAL_STATIC_LIBRARIES := libdex libft2 librslib_rt
-LOCAL_C_INCLUDES += external/freetype/include
+LOCAL_C_INCLUDES += external/freetype/include external/zlib dalvik
LOCAL_LDLIBS := -lpthread -ldl
LOCAL_MODULE:= libRS
diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec
index cf94060e42fb..021ff92cf7fd 100644
--- a/libs/rs/rs.spec
+++ b/libs/rs/rs.spec
@@ -321,6 +321,7 @@ ScriptCSetText {
}
ScriptCCreate {
+ param const char * packageName
param const char * resName
param const char * cacheDir
ret RsScript
diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp
index 0ae85cba6100..5197eeb2216f 100644
--- a/libs/rs/rsScriptC.cpp
+++ b/libs/rs/rsScriptC.cpp
@@ -20,6 +20,9 @@
#include "../../compile/libbcc/include/bcc/bcc.h"
#include "utils/Timers.h"
#include "utils/StopWatch.h"
+extern "C" {
+#include "libdex/ZipArchive.h"
+}
#include <GLES/gl.h>
#include <GLES/glext.h>
@@ -402,7 +405,12 @@ static BCCvoid* symbolLookup(BCCvoid* pContext, const BCCchar* name) {
extern const char rs_runtime_lib_bc[];
extern unsigned rs_runtime_lib_bc_size;
-void ScriptCState::runCompiler(Context *rsc, ScriptC *s, const char *resName, const char *cacheDir) {
+void ScriptCState::runCompiler(Context *rsc,
+ ScriptC *s,
+ long modWhen,
+ long crc32,
+ const char *resName,
+ const char *cacheDir) {
{
s->mBccScript = bccCreateScript();
s->mEnviroment.mIsThreadable = true;
@@ -413,6 +421,8 @@ void ScriptCState::runCompiler(Context *rsc, ScriptC *s, const char *resName, co
if (bccReadBC(s->mBccScript,
s->mEnviroment.mScriptText,
s->mEnviroment.mScriptTextLength,
+ modWhen,
+ crc32,
resName,
cacheDir) >= 0) {
//bccLinkBC(s->mBccScript, rs_runtime_lib_bc, rs_runtime_lib_bc_size);
@@ -424,6 +434,8 @@ void ScriptCState::runCompiler(Context *rsc, ScriptC *s, const char *resName, co
bccReadBC(s->mBccScript,
s->mEnviroment.mScriptText,
s->mEnviroment.mScriptTextLength,
+ modWhen,
+ crc32,
NULL,
cacheDir);
bccCompileBC(s->mBccScript);
@@ -542,7 +554,11 @@ void rsi_ScriptCSetText(Context *rsc, const char *text, uint32_t len) {
ss->mScript->mEnviroment.mScriptTextLength = len;
}
-RsScript rsi_ScriptCCreate(Context * rsc, const char *resName, const char *cacheDir)
+
+RsScript rsi_ScriptCCreate(Context *rsc,
+ const char *packageName,
+ const char *resName,
+ const char *cacheDir)
{
ScriptCState *ss = &rsc->mScriptC;
@@ -550,7 +566,34 @@ RsScript rsi_ScriptCCreate(Context * rsc, const char *resName, const char *cache
ss->mScript.clear();
s->incUserRef();
- ss->runCompiler(rsc, s.get(), resName, cacheDir);
+ // Open the apk and return the ZipArchive:
+ // int dexZipOpenArchive(const char* fileName, ZipArchive* pArchive)
+ ZipArchive archive;
+ long modWhen;
+ long crc32;
+ if (!dexZipOpenArchive(packageName, &archive)) { // Success
+ ZipEntry entry = dexZipFindEntry(&archive, resName);
+
+ int method;
+ size_t uncompLen;
+ size_t compLen;
+ off_t offset;
+ if (!dexZipGetEntryInfo(&archive,
+ entry,
+ &method,
+ &uncompLen,
+ &compLen,
+ &offset,
+ &modWhen,
+ &crc32)) {
+ } else {
+ LOGI("Coudn't get entry info for the bitcode in an apk");
+ }
+ } else {
+ LOGI("Couldn't open the archive and read the bitcode");
+ }
+
+ ss->runCompiler(rsc, s.get(), modWhen, crc32, resName, cacheDir);
ss->clear(rsc);
return s.get();
}
diff --git a/libs/rs/rsScriptC.h b/libs/rs/rsScriptC.h
index a71413294394..4cb5ade98c28 100644
--- a/libs/rs/rsScriptC.h
+++ b/libs/rs/rsScriptC.h
@@ -83,7 +83,7 @@ public:
void init(Context *rsc);
void clear(Context *rsc);
- void runCompiler(Context *rsc, ScriptC *s, const char *resName, const char *cacheDir);
+ void runCompiler(Context *rsc, ScriptC *s, long modWhen, long crc32, const char *resName, const char *cacheDir);
struct SymbolTable_t {
const char * mName;