summaryrefslogtreecommitdiff
path: root/cpp/ScriptIntrinsics.cpp
blob: 4a39d0e5a414f86f292ca61c83994a614e78dc03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
 * Copyright (C) 2008-2012 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <utils/Log.h>
#include <malloc.h>

#include "RenderScript.h"
#include <rs.h>
#include "rsDefines.h"

using namespace android;
using namespace RSC;

ScriptIntrinsic::ScriptIntrinsic(sp<RS> rs, int id, sp<const Element> e)
    : Script(NULL, rs) {
    mID = rsScriptIntrinsicCreate(rs->getContext(), id, e->getID());
}

ScriptIntrinsicBlend::ScriptIntrinsicBlend(sp<RS> rs, sp<const Element> e)
    : ScriptIntrinsic(rs, RS_SCRIPT_INTRINSIC_ID_BLEND, e) {

}

void ScriptIntrinsicBlend::blendClear(sp<Allocation> in, sp<Allocation> out) {
    Script::forEach(0, in, out, NULL, 0);
}

void ScriptIntrinsicBlend::blendSrc(sp<Allocation> in, sp<Allocation> out) {
    Script::forEach(1, in, out, NULL, 0);
}

void ScriptIntrinsicBlend::blendDst(sp<Allocation> in, sp<Allocation> out) {
    Script::forEach(2, in, out, NULL, 0);
}

void ScriptIntrinsicBlend::blendSrcOver(sp<Allocation> in, sp<Allocation> out) {
    Script::forEach(3, in, out, NULL, 0);
}

void ScriptIntrinsicBlend::blendDstOver(sp<Allocation> in, sp<Allocation> out) {
    Script::forEach(4, in, out, NULL, 0);
}

void ScriptIntrinsicBlend::blendSrcIn(sp<Allocation> in, sp<Allocation> out) {
    Script::forEach(5, in, out, NULL, 0);
}

void ScriptIntrinsicBlend::blendDstIn(sp<Allocation> in, sp<Allocation> out) {
    Script::forEach(6, in, out, NULL, 0);
}

void ScriptIntrinsicBlend::blendSrcOut(sp<Allocation> in, sp<Allocation> out) {
    Script::forEach(7, in, out, NULL, 0);
}

void ScriptIntrinsicBlend::blendDstOut(sp<Allocation> in, sp<Allocation> out) {
    Script::forEach(8, in, out, NULL, 0);
}

void ScriptIntrinsicBlend::blendSrcAtop(sp<Allocation> in, sp<Allocation> out) {
    Script::forEach(9, in, out, NULL, 0);
}

void ScriptIntrinsicBlend::blendDstAtop(sp<Allocation> in, sp<Allocation> out) {
    Script::forEach(10, in, out, NULL, 0);
}

void ScriptIntrinsicBlend::blendXor(sp<Allocation> in, sp<Allocation> out) {
    Script::forEach(11, in, out, NULL, 0);
}

// Numbering jumps here
void ScriptIntrinsicBlend::blendMultiply(sp<Allocation> in, sp<Allocation> out) {
    Script::forEach(14, in, out, NULL, 0);
}

// Numbering jumps here
void ScriptIntrinsicBlend::blendAdd(sp<Allocation> in, sp<Allocation> out) {
    Script::forEach(34, in, out, NULL, 0);
}

void ScriptIntrinsicBlend::blendSubtract(sp<Allocation> in, sp<Allocation> out) {
    Script::forEach(35, in, out, NULL, 0);
}

ScriptIntrinsicBlur::ScriptIntrinsicBlur(sp<RS> rs, sp<const Element> e)
    : ScriptIntrinsic(rs, RS_SCRIPT_INTRINSIC_ID_BLUR, e) {

}

void ScriptIntrinsicBlur::blur(sp<Allocation> in, sp<Allocation> out) {
    Script::setVar(1, in);
    Script::forEach(0, NULL, out, NULL, 0);
}

void ScriptIntrinsicBlur::setRadius(float radius) {
    Script::setVar(0, &radius, sizeof(float));
}