blob: 4a39d0e5a414f86f292ca61c83994a614e78dc03 [file] [log] [blame]
Tim Murray7f0d5682012-11-08 16:35:24 -08001/*
2 * Copyright (C) 2008-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
17#include <utils/Log.h>
18#include <malloc.h>
19
20#include "RenderScript.h"
Tim Murrayb206ace2013-02-13 14:52:20 -080021#include <rs.h>
Tim Murray7f0d5682012-11-08 16:35:24 -080022#include "rsDefines.h"
23
24using namespace android;
Tim Murray9eb7f4b2012-11-16 14:02:18 -080025using namespace RSC;
Tim Murray7f0d5682012-11-08 16:35:24 -080026
Tim Murray3cd44af2012-11-14 11:25:27 -080027ScriptIntrinsic::ScriptIntrinsic(sp<RS> rs, int id, sp<const Element> e)
Tim Murray7f0d5682012-11-08 16:35:24 -080028 : Script(NULL, rs) {
Tim Murray3cd44af2012-11-14 11:25:27 -080029 mID = rsScriptIntrinsicCreate(rs->getContext(), id, e->getID());
Tim Murray7f0d5682012-11-08 16:35:24 -080030}
31
Tim Murray3cd44af2012-11-14 11:25:27 -080032ScriptIntrinsicBlend::ScriptIntrinsicBlend(sp<RS> rs, sp<const Element> e)
Tim Murray7f0d5682012-11-08 16:35:24 -080033 : ScriptIntrinsic(rs, RS_SCRIPT_INTRINSIC_ID_BLEND, e) {
34
35}
36
37void ScriptIntrinsicBlend::blendClear(sp<Allocation> in, sp<Allocation> out) {
38 Script::forEach(0, in, out, NULL, 0);
39}
40
41void ScriptIntrinsicBlend::blendSrc(sp<Allocation> in, sp<Allocation> out) {
42 Script::forEach(1, in, out, NULL, 0);
43}
44
45void ScriptIntrinsicBlend::blendDst(sp<Allocation> in, sp<Allocation> out) {
46 Script::forEach(2, in, out, NULL, 0);
47}
48
49void ScriptIntrinsicBlend::blendSrcOver(sp<Allocation> in, sp<Allocation> out) {
50 Script::forEach(3, in, out, NULL, 0);
51}
52
53void ScriptIntrinsicBlend::blendDstOver(sp<Allocation> in, sp<Allocation> out) {
54 Script::forEach(4, in, out, NULL, 0);
55}
56
57void ScriptIntrinsicBlend::blendSrcIn(sp<Allocation> in, sp<Allocation> out) {
58 Script::forEach(5, in, out, NULL, 0);
59}
60
61void ScriptIntrinsicBlend::blendDstIn(sp<Allocation> in, sp<Allocation> out) {
62 Script::forEach(6, in, out, NULL, 0);
63}
64
65void ScriptIntrinsicBlend::blendSrcOut(sp<Allocation> in, sp<Allocation> out) {
66 Script::forEach(7, in, out, NULL, 0);
67}
68
69void ScriptIntrinsicBlend::blendDstOut(sp<Allocation> in, sp<Allocation> out) {
70 Script::forEach(8, in, out, NULL, 0);
71}
72
73void ScriptIntrinsicBlend::blendSrcAtop(sp<Allocation> in, sp<Allocation> out) {
74 Script::forEach(9, in, out, NULL, 0);
75}
76
77void ScriptIntrinsicBlend::blendDstAtop(sp<Allocation> in, sp<Allocation> out) {
78 Script::forEach(10, in, out, NULL, 0);
79}
80
81void ScriptIntrinsicBlend::blendXor(sp<Allocation> in, sp<Allocation> out) {
82 Script::forEach(11, in, out, NULL, 0);
83}
84
85// Numbering jumps here
86void ScriptIntrinsicBlend::blendMultiply(sp<Allocation> in, sp<Allocation> out) {
87 Script::forEach(14, in, out, NULL, 0);
88}
89
90// Numbering jumps here
91void ScriptIntrinsicBlend::blendAdd(sp<Allocation> in, sp<Allocation> out) {
92 Script::forEach(34, in, out, NULL, 0);
93}
94
95void ScriptIntrinsicBlend::blendSubtract(sp<Allocation> in, sp<Allocation> out) {
96 Script::forEach(35, in, out, NULL, 0);
97}
98
Tim Murray3cd44af2012-11-14 11:25:27 -080099ScriptIntrinsicBlur::ScriptIntrinsicBlur(sp<RS> rs, sp<const Element> e)
Tim Murray8f1e60c2012-11-13 12:25:11 -0800100 : ScriptIntrinsic(rs, RS_SCRIPT_INTRINSIC_ID_BLUR, e) {
Tim Murray7f0d5682012-11-08 16:35:24 -0800101
Tim Murray8f1e60c2012-11-13 12:25:11 -0800102}
Tim Murray7f0d5682012-11-08 16:35:24 -0800103
Tim Murray8f1e60c2012-11-13 12:25:11 -0800104void ScriptIntrinsicBlur::blur(sp<Allocation> in, sp<Allocation> out) {
105 Script::setVar(1, in);
106 Script::forEach(0, NULL, out, NULL, 0);
107}
Tim Murray7f0d5682012-11-08 16:35:24 -0800108
Tim Murray8f1e60c2012-11-13 12:25:11 -0800109void ScriptIntrinsicBlur::setRadius(float radius) {
110 Script::setVar(0, &radius, sizeof(float));
111}