blob: dd964452e5b58dddfc2ba69f17b7c61f692f28db [file] [log] [blame]
Jason Sams326e0dd2009-05-22 14:03:28 -07001/*
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 Sakhartchoukfb6b6142010-05-21 12:53:13 -070018#ifndef ANDROID_RS_BUILD_FOR_HOST
Jason Sams326e0dd2009-05-22 14:03:28 -070019#include "rsContext.h"
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -070020#else
21#include "rsContextHostStub.h"
22#endif
Jason Sams326e0dd2009-05-22 14:03:28 -070023
24using namespace android;
25using namespace android::renderscript;
26
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080027Device::Device() {
Jason Sams5fd09d82009-09-23 13:57:02 -070028 mForceSW = false;
Jason Sams326e0dd2009-05-22 14:03:28 -070029}
30
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080031Device::~Device() {
Jason Sams326e0dd2009-05-22 14:03:28 -070032}
33
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080034void Device::addContext(Context *rsc) {
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -070035 mContexts.push(rsc);
Jason Sams326e0dd2009-05-22 14:03:28 -070036}
37
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080038void Device::removeContext(Context *rsc) {
Jason Sams326e0dd2009-05-22 14:03:28 -070039 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 Sakhartchoukafb743a2010-11-09 17:00:54 -080047RsDevice rsDeviceCreate() {
Jason Sams326e0dd2009-05-22 14:03:28 -070048 Device * d = new Device();
49 return d;
50}
51
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080052void rsDeviceDestroy(RsDevice dev) {
Jason Sams326e0dd2009-05-22 14:03:28 -070053 Device * d = static_cast<Device *>(dev);
54 delete d;
Jason Sams326e0dd2009-05-22 14:03:28 -070055}
56
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080057void rsDeviceSetConfig(RsDevice dev, RsDeviceParam p, int32_t value) {
Jason Sams5fd09d82009-09-23 13:57:02 -070058 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