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