ScriptIntrinsics.cpp revision a423096c0d49e5cfe13a400b4323a76f89c6885c
1/* 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 <malloc.h> 18 19#include "RenderScript.h" 20#include <rs.h> 21#include "rsDefines.h" 22 23using namespace android; 24using namespace RSC; 25 26ScriptIntrinsic::ScriptIntrinsic(sp<RS> rs, int id, sp<const Element> e) 27 : Script(NULL, rs) { 28 mID = RS::dispatch->ScriptIntrinsicCreate(rs->getContext(), id, e->getID()); 29} 30 31ScriptIntrinsicBlend::ScriptIntrinsicBlend(sp<RS> rs, sp<const Element> e) 32 : 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 98ScriptIntrinsicBlur::ScriptIntrinsicBlur(sp<RS> rs, sp<const Element> e) 99 : ScriptIntrinsic(rs, RS_SCRIPT_INTRINSIC_ID_BLUR, e) { 100 101} 102 103void ScriptIntrinsicBlur::blur(sp<Allocation> in, sp<Allocation> out) { 104 Script::setVar(1, in); 105 Script::forEach(0, NULL, out, NULL, 0); 106} 107 108void ScriptIntrinsicBlur::setRadius(float radius) { 109 Script::setVar(0, &radius, sizeof(float)); 110} 111