Home | History | Annotate | Download | only in driver
      1 /*
      2  * Copyright (C) 2011 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 <rs_hal.h>
     19 #include <rsContext.h>
     20 #include <rsMesh.h>
     21 
     22 #include "rsdCore.h"
     23 #include "rsdMesh.h"
     24 #include "rsdMeshObj.h"
     25 #include "rsdShaderCache.h"
     26 
     27 using namespace android;
     28 using namespace android::renderscript;
     29 
     30 bool rsdMeshInit(const Context *rsc, const Mesh *m) {
     31     RsdMeshObj *drv = nullptr;
     32     if(m->mHal.drv) {
     33         drv = (RsdMeshObj*)m->mHal.drv;
     34         delete drv;
     35     }
     36     drv = new RsdMeshObj(rsc, m);
     37     m->mHal.drv = drv;
     38     return drv->init(rsc);
     39 }
     40 
     41 void rsdMeshDraw(const Context *rsc, const Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len) {
     42     if(m->mHal.drv) {
     43         RsdHal *dc = (RsdHal *)rsc->mHal.drv;
     44         if (!dc->gl.shaderCache->setup(rsc)) {
     45             return;
     46         }
     47 
     48         RsdMeshObj *drv = (RsdMeshObj*)m->mHal.drv;
     49         drv->renderPrimitiveRange(rsc, primIndex, start, len);
     50     }
     51 }
     52 
     53 void rsdMeshDestroy(const Context *rsc, const Mesh *m) {
     54     if(m->mHal.drv) {
     55         RsdMeshObj *drv = (RsdMeshObj*)m->mHal.drv;
     56         delete drv;
     57     }
     58 }
     59 
     60 
     61