Yang Ni | 3df9bb0 | 2016-03-18 15:33:52 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "rsDevice.h" |
| 18 | #include "rsContext.h" |
| 19 | #include "rsThreadIO.h" |
| 20 | #include "rsgApiStructs.h" |
| 21 | #include "rsgApiFuncDecl.h" |
| 22 | #include "rsFifo.h" |
| 23 | |
| 24 | using namespace android; |
| 25 | using namespace android::renderscript; |
| 26 | |
Stephen Hines | 98cb2d1 | 2016-03-30 17:54:01 -0700 | [diff] [blame] | 27 | /* |
| 28 | * This global will be found by the debugger and will have its value flipped. |
| 29 | * It's independent of the Context class to allow the debugger to do the above |
| 30 | * without knowing the type makeup. This allows the debugger to be attached at |
| 31 | * an earlier stage. |
| 32 | */ |
| 33 | extern "C" int gDebuggerPresent = 0; |
| 34 | |
Yang Ni | 3df9bb0 | 2016-03-18 15:33:52 -0700 | [diff] [blame] | 35 | extern "C" RsContext rsContextCreate(RsDevice vdev, uint32_t version, uint32_t sdkVersion, |
| 36 | RsContextType ct, uint32_t flags) { |
Stephen Hines | 98cb2d1 | 2016-03-30 17:54:01 -0700 | [diff] [blame] | 37 | if (!gInternalDebuggerPresent) { |
| 38 | gInternalDebuggerPresent = &gDebuggerPresent; |
| 39 | } |
Yang Ni | 3df9bb0 | 2016-03-18 15:33:52 -0700 | [diff] [blame] | 40 | //ALOGV("rsContextCreate dev=%p", vdev); |
| 41 | Device * dev = static_cast<Device *>(vdev); |
| 42 | Context *rsc = Context::createContext(dev, nullptr, ct, flags); |
| 43 | if (rsc) { |
| 44 | rsc->setTargetSdkVersion(sdkVersion); |
| 45 | } |
| 46 | return rsc; |
| 47 | } |
| 48 | |
| 49 | extern "C" void rsaContextSetNativeLibDir(RsContext con, char *libDir, size_t length) { |
| 50 | #ifdef RS_COMPATIBILITY_LIB |
| 51 | Context *rsc = static_cast<Context *>(con); |
| 52 | rsc->setNativeLibDir(libDir, length); |
| 53 | #endif |
| 54 | } |
| 55 | |
| 56 | #ifndef RS_COMPATIBILITY_LIB |
| 57 | RsContext rsContextCreateGL(RsDevice vdev, uint32_t version, |
| 58 | uint32_t sdkVersion, RsSurfaceConfig sc, |
| 59 | uint32_t dpi) { |
| 60 | //ALOGV("rsContextCreateGL dev=%p", vdev); |
| 61 | Device * dev = static_cast<Device *>(vdev); |
| 62 | Context *rsc = Context::createContext(dev, &sc); |
| 63 | if (rsc) { |
| 64 | rsc->setTargetSdkVersion(sdkVersion); |
| 65 | rsc->setDPI(dpi); |
| 66 | } |
| 67 | //ALOGV("%p rsContextCreateGL ret", rsc); |
| 68 | return rsc; |
| 69 | } |
| 70 | #endif |
| 71 | |
| 72 | // Only to be called at a3d load time, before object is visible to user |
| 73 | // not thread safe |
| 74 | extern "C" void rsaGetName(RsContext con, void * obj, const char **name) { |
| 75 | ObjectBase *ob = static_cast<ObjectBase *>(obj); |
| 76 | (*name) = ob->getName(); |
| 77 | } |