Home | History | Annotate | Download | only in rs
      1 /*
      2  * Copyright (C) 2009 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 "rsContext.h"
     18 
     19 #include "rsThreadIO.h"
     20 
     21 using namespace android;
     22 using namespace android::renderscript;
     23 
     24 ThreadIO::ThreadIO()
     25 {
     26     mToCore.init(16 * 1024);
     27     mToClient.init(1024);
     28 }
     29 
     30 ThreadIO::~ThreadIO()
     31 {
     32 }
     33 
     34 void ThreadIO::shutdown()
     35 {
     36     mToCore.shutdown();
     37 }
     38 
     39 bool ThreadIO::playCoreCommands(Context *con, bool waitForCommand)
     40 {
     41     bool ret = false;
     42     while(!mToCore.isEmpty() || waitForCommand) {
     43         uint32_t cmdID = 0;
     44         uint32_t cmdSize = 0;
     45         ret = true;
     46         if (con->props.mLogTimes) {
     47             con->timerSet(Context::RS_TIMER_IDLE);
     48         }
     49         const void * data = mToCore.get(&cmdID, &cmdSize);
     50         if (!cmdSize) {
     51             // exception occured, probably shutdown.
     52             return false;
     53         }
     54         if (con->props.mLogTimes) {
     55             con->timerSet(Context::RS_TIMER_INTERNAL);
     56         }
     57         waitForCommand = false;
     58         //LOGV("playCoreCommands 3 %i %i", cmdID, cmdSize);
     59 
     60         gPlaybackFuncs[cmdID](con, data);
     61         mToCore.next();
     62     }
     63     return ret;
     64 }
     65 
     66 
     67