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