blob: 53d9e4a7e606c8bad96044173c524ee2074d754a [file] [log] [blame]
Yang Ni3df9bb02016-03-18 15:33:52 -07001/*
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
Chih-Hung Hsieh11496ac2016-11-15 15:14:05 -080024using android::renderscript::Context;
25using android::renderscript::Device;
26using android::renderscript::ObjectBase;
Yang Ni3df9bb02016-03-18 15:33:52 -070027
Miao Wang5fccd072017-05-16 15:39:34 -070028extern "C" RsContext rsContextCreateVendor(RsDevice vdev, uint32_t version, uint32_t sdkVersion,
29 RsContextType ct, uint32_t flags,
30 const char* vendorDriverName) {
Yang Ni3df9bb02016-03-18 15:33:52 -070031 Device * dev = static_cast<Device *>(vdev);
Miao Wang5fccd072017-05-16 15:39:34 -070032 Context *rsc = Context::createContext(dev, nullptr, ct, flags, vendorDriverName);
Yang Ni3df9bb02016-03-18 15:33:52 -070033 if (rsc) {
34 rsc->setTargetSdkVersion(sdkVersion);
35 }
36 return rsc;
37}
38
Miao Wang5fccd072017-05-16 15:39:34 -070039extern "C" RsContext rsContextCreate(RsDevice vdev, uint32_t version, uint32_t sdkVersion,
40 RsContextType ct, uint32_t flags) {
41 return rsContextCreateVendor(vdev, version, sdkVersion, ct, flags, nullptr);
42}
43
Yang Ni3df9bb02016-03-18 15:33:52 -070044extern "C" void rsaContextSetNativeLibDir(RsContext con, char *libDir, size_t length) {
45#ifdef RS_COMPATIBILITY_LIB
46 Context *rsc = static_cast<Context *>(con);
47 rsc->setNativeLibDir(libDir, length);
48#endif
49}
50
Miao Wangdd4c8f12017-01-20 15:39:17 -080051// TODO: Figure out better naming schemes for all the rs* functions.
52// Currently they share the same names as the NDK counterparts, and that is
53// causing lots of confusion.
Miao Wang59f61422017-03-14 14:23:52 -070054#if !defined(RS_VENDOR_LIB) && !defined(RS_COMPATIBILITY_LIB)
Miao Wangdd4c8f12017-01-20 15:39:17 -080055extern "C" RsContext rsContextCreateGL(RsDevice vdev, uint32_t version,
56 uint32_t sdkVersion, RsSurfaceConfig sc,
57 uint32_t dpi) {
Yang Ni3df9bb02016-03-18 15:33:52 -070058 //ALOGV("rsContextCreateGL dev=%p", vdev);
59 Device * dev = static_cast<Device *>(vdev);
60 Context *rsc = Context::createContext(dev, &sc);
61 if (rsc) {
62 rsc->setTargetSdkVersion(sdkVersion);
63 rsc->setDPI(dpi);
64 }
65 //ALOGV("%p rsContextCreateGL ret", rsc);
66 return rsc;
67}
68#endif
69
70// Only to be called at a3d load time, before object is visible to user
71// not thread safe
72extern "C" void rsaGetName(RsContext con, void * obj, const char **name) {
73 ObjectBase *ob = static_cast<ObjectBase *>(obj);
74 (*name) = ob->getName();
75}