diff options
| author | Yang Ni <yangni@google.com> | 2016-04-04 10:26:48 -0700 |
|---|---|---|
| committer | Yang Ni <yangni@google.com> | 2016-04-04 14:22:48 -0700 |
| commit | 8ca49acfcc784355bd806f87701747a4c1ab9749 (patch) | |
| tree | f8d4c86e09a732e27409638606d9b2424f475995 /cpp/RenderScript.cpp | |
| parent | ce67164960770b35a40aa8cb897ac9a6d7d4f321 (diff) | |
Avoid destroying Device separately
Bug: 27983025
Device should be destroyed inside the destructor of the associated
Context.
Change-Id: I921a89974e1174f837349a89aef9b03efa4882f5
Diffstat (limited to 'cpp/RenderScript.cpp')
| -rw-r--r-- | cpp/RenderScript.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/cpp/RenderScript.cpp b/cpp/RenderScript.cpp index 31414f4b..fb2d742f 100644 --- a/cpp/RenderScript.cpp +++ b/cpp/RenderScript.cpp @@ -42,7 +42,6 @@ dispatchTable* RS::dispatch = nullptr; static int gInitError = 0; RS::RS() { - mDev = nullptr; mContext = nullptr; mErrorFunc = nullptr; mMessageFunc = nullptr; @@ -68,10 +67,6 @@ RS::~RS() { RS::dispatch->ContextDestroy(mContext); mContext = nullptr; } - if (mDev) { - RS::dispatch->DeviceDestroy(mDev); - mDev = nullptr; - } } } @@ -164,8 +159,8 @@ bool RS::init(const char * name, uint32_t flags, int targetApi) { mCacheDir[nameLen] = 0; mCacheDirLen = nameLen + 1; - mDev = RS::dispatch->DeviceCreate(); - if (mDev == 0) { + RsDevice device = RS::dispatch->DeviceCreate(); + if (device == 0) { ALOGE("Device creation failed"); return false; } @@ -176,7 +171,7 @@ bool RS::init(const char * name, uint32_t flags, int targetApi) { return false; } - mContext = RS::dispatch->ContextCreate(mDev, 0, targetApi, RS_CONTEXT_TYPE_NORMAL, flags); + mContext = RS::dispatch->ContextCreate(device, 0, targetApi, RS_CONTEXT_TYPE_NORMAL, flags); if (mContext == 0) { ALOGE("Context creation failed"); return false; |
