Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012, 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 | |
Zonr Chang | 80232dd | 2012-04-12 15:38:53 +0800 | [diff] [blame] | 17 | #include "bcc/RenderScript/RSScript.h" |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 18 | |
Shih-wei Liao | 0467d9a | 2012-04-25 04:06:52 -0700 | [diff] [blame] | 19 | #include "bcc/RenderScript/RSInfo.h" |
| 20 | #include "bcc/Source.h" |
Zonr Chang | b519fe3 | 2012-04-12 16:44:01 +0800 | [diff] [blame] | 21 | #include "bcc/Support/Log.h" |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 22 | |
Zonr Chang | fef9a1b | 2012-04-13 15:58:24 +0800 | [diff] [blame] | 23 | using namespace bcc; |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 24 | |
Shih-wei Liao | 0467d9a | 2012-04-25 04:06:52 -0700 | [diff] [blame] | 25 | bool RSScript::LinkRuntime(RSScript &pScript) { |
| 26 | // Using the same context with the source in pScript. |
| 27 | BCCContext &context = pScript.getSource().getContext(); |
| 28 | Source *libclcore_source = Source::CreateFromFile(context, |
| 29 | RSInfo::LibCLCorePath); |
| 30 | if (libclcore_source == NULL) { |
| 31 | ALOGE("Failed to load Renderscript library '%s' to link!", |
| 32 | RSInfo::LibCLCorePath); |
| 33 | return false; |
| 34 | } |
| 35 | |
| 36 | if (!pScript.getSource().merge(*libclcore_source, |
| 37 | /* pPreserveSource */false)) { |
| 38 | ALOGE("Failed to link RenderScript library '%s'!", RSInfo::LibCLCorePath); |
| 39 | delete libclcore_source; |
| 40 | return false; |
| 41 | } |
| 42 | |
| 43 | return true; |
| 44 | } |
| 45 | |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 46 | RSScript::RSScript(Source &pSource) |
Zonr Chang | fef9a1b | 2012-04-13 15:58:24 +0800 | [diff] [blame] | 47 | : Script(pSource), mInfo(NULL), mCompilerVersion(0), |
| 48 | mOptimizationLevel(kOptLvl3) { } |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 49 | |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 50 | bool RSScript::doReset() { |
Zonr Chang | fef9a1b | 2012-04-13 15:58:24 +0800 | [diff] [blame] | 51 | mInfo = NULL; |
| 52 | mCompilerVersion = 0; |
| 53 | mOptimizationLevel = kOptLvl3; |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 54 | return true; |
| 55 | } |