blob: 9058ff9ba2ab3091230673ee79426d87be04f86c [file] [log] [blame]
Zonr Chang19218c02012-04-05 10:44:53 +08001/*
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 Chang80232dd2012-04-12 15:38:53 +080017#include "bcc/RenderScript/RSScript.h"
Zonr Chang19218c02012-04-05 10:44:53 +080018
Shih-wei Liao0467d9a2012-04-25 04:06:52 -070019#include "bcc/RenderScript/RSInfo.h"
20#include "bcc/Source.h"
Zonr Changb519fe32012-04-12 16:44:01 +080021#include "bcc/Support/Log.h"
Zonr Chang19218c02012-04-05 10:44:53 +080022
Zonr Changfef9a1b2012-04-13 15:58:24 +080023using namespace bcc;
Zonr Chang19218c02012-04-05 10:44:53 +080024
Shih-wei Liao0467d9a2012-04-25 04:06:52 -070025bool 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 Chang19218c02012-04-05 10:44:53 +080046RSScript::RSScript(Source &pSource)
Zonr Changfef9a1b2012-04-13 15:58:24 +080047 : Script(pSource), mInfo(NULL), mCompilerVersion(0),
48 mOptimizationLevel(kOptLvl3) { }
Zonr Chang19218c02012-04-05 10:44:53 +080049
Zonr Chang19218c02012-04-05 10:44:53 +080050bool RSScript::doReset() {
Zonr Changfef9a1b2012-04-13 15:58:24 +080051 mInfo = NULL;
52 mCompilerVersion = 0;
53 mOptimizationLevel = kOptLvl3;
Zonr Chang19218c02012-04-05 10:44:53 +080054 return true;
55}