Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 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 | |
| 20 | using namespace android; |
| 21 | using namespace android::renderscript; |
| 22 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 23 | Device::Device() { |
Jason Sams | 5fd09d8 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 24 | mForceSW = false; |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 25 | } |
| 26 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 27 | Device::~Device() { |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 28 | } |
| 29 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 30 | void Device::addContext(Context *rsc) { |
Chris Wailes | 93d6bc8 | 2014-07-28 16:54:38 -0700 | [diff] [blame^] | 31 | mContexts.push_back(rsc); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 32 | } |
| 33 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 34 | void Device::removeContext(Context *rsc) { |
Chris Wailes | 93d6bc8 | 2014-07-28 16:54:38 -0700 | [diff] [blame^] | 35 | for (auto ctxIter = mContexts.begin(), endIter = mContexts.end(); |
| 36 | ctxIter != endIter; ctxIter++) { |
| 37 | |
| 38 | if (rsc == *ctxIter) { |
| 39 | mContexts.erase(ctxIter); |
| 40 | return; |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 41 | } |
| 42 | } |
| 43 | } |
| 44 | |
Tim Murray | c2ce707 | 2013-07-17 18:38:53 -0700 | [diff] [blame] | 45 | extern "C" RsDevice rsDeviceCreate() { |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 46 | Device * d = new Device(); |
| 47 | return d; |
| 48 | } |
| 49 | |
Tim Murray | c2ce707 | 2013-07-17 18:38:53 -0700 | [diff] [blame] | 50 | extern "C" void rsDeviceDestroy(RsDevice dev) { |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 51 | Device * d = static_cast<Device *>(dev); |
| 52 | delete d; |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Tim Murray | c2ce707 | 2013-07-17 18:38:53 -0700 | [diff] [blame] | 55 | extern "C" void rsDeviceSetConfig(RsDevice dev, RsDeviceParam p, int32_t value) { |
Jason Sams | 5fd09d8 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 56 | Device * d = static_cast<Device *>(dev); |
| 57 | if (p == RS_DEVICE_PARAM_FORCE_SOFTWARE_GL) { |
| 58 | d->mForceSW = value != 0; |
| 59 | return; |
| 60 | } |
| 61 | rsAssert(0); |
| 62 | } |