Home | History | Annotate | Download | only in driver
      1 /*
      2  * Copyright (C) 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 
     18 #include "rsdCore.h"
     19 #include "rsdIntrinsics.h"
     20 #include "rsdAllocation.h"
     21 
     22 using namespace android;
     23 using namespace android::renderscript;
     24 
     25 void * rsdIntrinsic_InitBlur(const Context *, Script *, RsdIntriniscFuncs_t *);
     26 void * rsdIntrinsic_InitConvolve3x3(const Context *, Script *, RsdIntriniscFuncs_t *);
     27 void * rsdIntrinsic_InitConvolve5x5(const Context *, Script *, RsdIntriniscFuncs_t *);
     28 void * rsdIntrinsic_InitColorMatrix(const Context *, Script *, RsdIntriniscFuncs_t *);
     29 void * rsdIntrinsic_InitLUT(const Context *, Script *, RsdIntriniscFuncs_t *);
     30 void * rsdIntrinsic_InitYuvToRGB(const Context *, Script *, RsdIntriniscFuncs_t *);
     31 void * rsdIntrinsic_InitBlend(const Context *, Script *, RsdIntriniscFuncs_t *);
     32 
     33 static void SetVarObj(const Context *, const Script *, void *, uint32_t, Allocation *) {
     34     rsAssert(!"Intrinsic_SetVarObj unexpectedly called");
     35 }
     36 
     37 static void SetVar(const Context *, const Script *, void *, uint32_t, void *, size_t) {
     38     rsAssert(!"Intrinsic_Bind unexpectedly called");
     39 }
     40 
     41 static void Destroy(const Context *dc, const Script *script, void * intrinsicData) {
     42     free(intrinsicData);
     43 }
     44 
     45 void * rsdIntrinsic_Init(const android::renderscript::Context *dc,
     46                        android::renderscript::Script *script,
     47                        RsScriptIntrinsicID iid,
     48                        RsdIntriniscFuncs_t *funcs) {
     49 
     50     funcs->setVarObj = SetVarObj;
     51     funcs->setVar = SetVar;
     52     funcs->destroy = Destroy;
     53 
     54     switch(iid) {
     55     case RS_SCRIPT_INTRINSIC_ID_CONVOLVE_3x3:
     56         return rsdIntrinsic_InitConvolve3x3(dc, script, funcs);
     57     case RS_SCRIPT_INTRINSIC_ID_CONVOLVE_5x5:
     58         return rsdIntrinsic_InitConvolve5x5(dc, script, funcs);
     59     case RS_SCRIPT_INTRINSIC_ID_COLOR_MATRIX:
     60         return rsdIntrinsic_InitColorMatrix(dc, script, funcs);
     61     case RS_SCRIPT_INTRINSIC_ID_LUT:
     62         return rsdIntrinsic_InitLUT(dc, script, funcs);
     63     case RS_SCRIPT_INTRINSIC_ID_BLUR:
     64         return rsdIntrinsic_InitBlur(dc, script, funcs);
     65     case RS_SCRIPT_INTRINSIC_ID_YUV_TO_RGB:
     66         return rsdIntrinsic_InitYuvToRGB(dc, script, funcs);
     67     case RS_SCRIPT_INTRINSIC_ID_BLEND:
     68         return rsdIntrinsic_InitBlend(dc, script, funcs);
     69 
     70     default:
     71         return NULL;
     72     }
     73     return NULL;
     74 }
     75 
     76 
     77 
     78