Jason Sams | d19f10d | 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" |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 18 | #ifndef ANDROID_RS_BUILD_FOR_HOST |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 19 | #include "rsContext.h" |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 20 | #else |
| 21 | #include "rsContextHostStub.h" |
| 22 | #endif |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 23 | |
| 24 | using namespace android; |
| 25 | using namespace android::renderscript; |
| 26 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame^] | 27 | Device::Device() { |
Jason Sams | ebfb436 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 28 | mForceSW = false; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 29 | } |
| 30 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame^] | 31 | Device::~Device() { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 32 | } |
| 33 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame^] | 34 | void Device::addContext(Context *rsc) { |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 35 | mContexts.push(rsc); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 36 | } |
| 37 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame^] | 38 | void Device::removeContext(Context *rsc) { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 39 | for (size_t idx=0; idx < mContexts.size(); idx++) { |
| 40 | if (mContexts[idx] == rsc) { |
| 41 | mContexts.removeAt(idx); |
| 42 | break; |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame^] | 47 | RsDevice rsDeviceCreate() { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 48 | Device * d = new Device(); |
| 49 | return d; |
| 50 | } |
| 51 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame^] | 52 | void rsDeviceDestroy(RsDevice dev) { |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 53 | Device * d = static_cast<Device *>(dev); |
| 54 | delete d; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 55 | } |
| 56 | |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame^] | 57 | void rsDeviceSetConfig(RsDevice dev, RsDeviceParam p, int32_t value) { |
Jason Sams | ebfb436 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 58 | Device * d = static_cast<Device *>(dev); |
| 59 | if (p == RS_DEVICE_PARAM_FORCE_SOFTWARE_GL) { |
| 60 | d->mForceSW = value != 0; |
| 61 | return; |
| 62 | } |
| 63 | rsAssert(0); |
| 64 | } |
| 65 | |