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