diff options
author | Pirama Arumuga Nainar <pirama@google.com> | 2015-04-28 14:40:45 -0700 |
---|---|---|
committer | The Android Automerger <android-build@google.com> | 2015-04-29 12:43:58 -0700 |
commit | abb535bc6978fbc735dcfc45215cef5aaffc654a (patch) | |
tree | 7af48900284efbdf2a1dfd54fa324a4593804548 | |
parent | d57865a769071ccde7acc5287fb25a0f31bd0a4d (diff) | |
download | android_frameworks_rs-abb535bc6978fbc735dcfc45215cef5aaffc654a.tar.gz android_frameworks_rs-abb535bc6978fbc735dcfc45215cef5aaffc654a.tar.bz2 android_frameworks_rs-abb535bc6978fbc735dcfc45215cef5aaffc654a.zip |
Handle older structure sizes by zeroing new fields
Bug 19734267
Bug 19866850
Prior fix handled only rsForEach calls from a script. It is not
sufficient, as launch options in support library also will also use old
structures. Apps compiled for support library still run in native mode
when available, thus necessitating this fix.
This fix copies and extends the input in ScriptC::runForEach instead of
rsrForEach.
Change-Id: I3bb2527eadcbcdb85a76a1f5568269bbfdee972b
(cherry-pick of 9479e5bf0152ecff022cd374e2e80905f88b1a5d from AOSP)
-rw-r--r-- | driver/rsdRuntimeStubs.cpp | 15 | ||||
-rw-r--r-- | rsRuntime.h | 3 | ||||
-rw-r--r-- | rsScriptC.cpp | 9 | ||||
-rw-r--r-- | rsScriptC_Lib.cpp | 19 |
4 files changed, 18 insertions, 28 deletions
diff --git a/driver/rsdRuntimeStubs.cpp b/driver/rsdRuntimeStubs.cpp index bc5c8922..c728ca71 100644 --- a/driver/rsdRuntimeStubs.cpp +++ b/driver/rsdRuntimeStubs.cpp @@ -439,9 +439,8 @@ void __attribute__((overloadable)) rsForEach(::rs_script script, const void *usr, const rs_script_call *call) { Context *rsc = RsdCpuReference::getTlsContext(); - const Script *sc = RsdCpuReference::getTlsScript(); rsrForEach(rsc, (Script *)script.p, (Allocation *)in.p, - (Allocation *)out.p, usr, 0, (RsScriptCall *)call, sc); + (Allocation *)out.p, usr, 0, (RsScriptCall *)call); } void __attribute__((overloadable)) rsForEach(::rs_script script, @@ -449,18 +448,16 @@ void __attribute__((overloadable)) rsForEach(::rs_script script, ::rs_allocation out, const void *usr) { Context *rsc = RsdCpuReference::getTlsContext(); - const Script *sc = RsdCpuReference::getTlsScript(); rsrForEach(rsc, (Script *)script.p, (Allocation *)in.p, (Allocation *)out.p, - usr, 0, nullptr, sc); + usr, 0, nullptr); } void __attribute__((overloadable)) rsForEach(::rs_script script, ::rs_allocation in, ::rs_allocation out) { Context *rsc = RsdCpuReference::getTlsContext(); - const Script *sc = RsdCpuReference::getTlsScript(); rsrForEach(rsc, (Script *)script.p, (Allocation *)in.p, (Allocation *)out.p, - nullptr, 0, nullptr, sc); + nullptr, 0, nullptr); } // These functions are only supported in 32-bit. @@ -471,9 +468,8 @@ void __attribute__((overloadable)) rsForEach(::rs_script script, const void *usr, uint32_t usrLen) { Context *rsc = RsdCpuReference::getTlsContext(); - const Script *sc = RsdCpuReference::getTlsScript(); rsrForEach(rsc, (Script *)script.p, (Allocation *)in.p, (Allocation *)out.p, - usr, usrLen, nullptr, sc); + usr, usrLen, nullptr); } void __attribute__((overloadable)) rsForEach(::rs_script script, @@ -483,9 +479,8 @@ void __attribute__((overloadable)) rsForEach(::rs_script script, uint32_t usrLen, const rs_script_call *call) { Context *rsc = RsdCpuReference::getTlsContext(); - const Script *sc = RsdCpuReference::getTlsScript(); rsrForEach(rsc, (Script *)script.p, (Allocation *)in.p, (Allocation *)out.p, - usr, usrLen, (RsScriptCall *)call, sc); + usr, usrLen, (RsScriptCall *)call); } #endif diff --git a/rsRuntime.h b/rsRuntime.h index de6ede36..5a058830 100644 --- a/rsRuntime.h +++ b/rsRuntime.h @@ -159,8 +159,7 @@ void rsrForEach(Context *, Script *target, Allocation *out, const void *usr, uint32_t usrBytes, - const RsScriptCall *call, - const Script *callingScript); + const RsScriptCall *call); ////////////////////////////////////////////////////////////////////////////// diff --git a/rsScriptC.cpp b/rsScriptC.cpp index e1685b91..a24334e3 100644 --- a/rsScriptC.cpp +++ b/rsScriptC.cpp @@ -192,6 +192,15 @@ void ScriptC::runForEach(Context *rsc, const void * usr, size_t usrBytes, const RsScriptCall *sc) { + // Make a copy of RsScriptCall and zero out extra fields that are absent + // in API levels below 23. + RsScriptCall sc_copy; + if (sc != nullptr && getApiLevel() < 23) { + memset(&sc_copy, 0, sizeof(sc_copy)); + memcpy(&sc_copy, sc, 7*4); + sc = &sc_copy; + } + // Trace this function call. // To avoid overhead we only build the string if tracing is actually // enabled. diff --git a/rsScriptC_Lib.cpp b/rsScriptC_Lib.cpp index cc930211..c404bde9 100644 --- a/rsScriptC_Lib.cpp +++ b/rsScriptC_Lib.cpp @@ -238,30 +238,17 @@ void rsrForEach(Context *rsc, Script *target, Allocation *in, Allocation *out, const void *usr, uint32_t usrBytes, - const RsScriptCall *call, - const Script *callingScript) { - - RsScriptCall c, *cptr = nullptr; - memset(&c, 0, sizeof(c)); - if (call != nullptr) { - cptr = &c; - if (callingScript->getApiLevel() < 23) { - // Up to API 23, the structure was smaller and we need to zero extend - memcpy(&c, call, 7*4); - } else { - c = *call; - } - } + const RsScriptCall *call) { if (in == nullptr) { target->runForEach(rsc, /* root slot */ 0, nullptr, 0, out, usr, - usrBytes, cptr); + usrBytes, call); } else { const Allocation *ins[1] = {in}; target->runForEach(rsc, /* root slot */ 0, ins, sizeof(ins) / sizeof(RsAllocation), out, usr, - usrBytes, cptr); + usrBytes, call); } } |