blob: a96b114ce3c9d39b5987a6865faed2d957c9ae46 [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
27Device::Device()
28{
Jason Sams5fd09d82009-09-23 13:57:02 -070029 mForceSW = false;
Jason Sams326e0dd2009-05-22 14:03:28 -070030
31}
32
33Device::~Device()
34{
35
36}
37
38void Device::addContext(Context *rsc)
39{
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -070040 mContexts.push(rsc);
Jason Sams326e0dd2009-05-22 14:03:28 -070041}
42
43void Device::removeContext(Context *rsc)
44{
45 for (size_t idx=0; idx < mContexts.size(); idx++) {
46 if (mContexts[idx] == rsc) {
47 mContexts.removeAt(idx);
48 break;
49 }
50 }
51}
52
53
54
55RsDevice rsDeviceCreate()
56{
57 Device * d = new Device();
58 return d;
59}
60
61void rsDeviceDestroy(RsDevice dev)
62{
63 Device * d = static_cast<Device *>(dev);
64 delete d;
65
66}
67
Jason Sams5fd09d82009-09-23 13:57:02 -070068void rsDeviceSetConfig(RsDevice dev, RsDeviceParam p, int32_t value)
69{
70 Device * d = static_cast<Device *>(dev);
71 if (p == RS_DEVICE_PARAM_FORCE_SOFTWARE_GL) {
72 d->mForceSW = value != 0;
73 return;
74 }
75 rsAssert(0);
76}
77