blob: 4072f066526ddb696b08b76caf8e3ceac756e680 [file] [log] [blame]
Jason Samsd19f10d2009-05-22 14:03:28 -07001/*
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
Jason Samsd19f10d2009-05-22 14:03:28 -070019#include "rsThreadIO.h"
20
21using namespace android;
22using namespace android::renderscript;
23
Jason Samsd19f10d2009-05-22 14:03:28 -070024ThreadIO::ThreadIO()
25{
26 mToCore.init(16 * 1024);
27}
28
29ThreadIO::~ThreadIO()
30{
31}
32
Jason Samsf5b45962009-08-25 14:49:07 -070033void ThreadIO::shutdown()
34{
35 mToCore.shutdown();
36}
37
Jason Sams5f7fc272009-06-18 16:58:42 -070038bool ThreadIO::playCoreCommands(Context *con, bool waitForCommand)
Jason Samsd19f10d2009-05-22 14:03:28 -070039{
Jason Samsa09f11d2009-06-04 17:58:03 -070040 bool ret = false;
Jason Sams5f7fc272009-06-18 16:58:42 -070041 while(!mToCore.isEmpty() || waitForCommand) {
Jason Samsf4d16062009-08-19 12:17:14 -070042 uint32_t cmdID = 0;
43 uint32_t cmdSize = 0;
Jason Samsa09f11d2009-06-04 17:58:03 -070044 ret = true;
Joe Onorato9ac2c662009-09-23 16:37:36 -070045 if (con->logTimes) {
46 con->timerSet(Context::RS_TIMER_IDLE);
47 }
Jason Samsd19f10d2009-05-22 14:03:28 -070048 const void * data = mToCore.get(&cmdID, &cmdSize);
Joe Onorato9ac2c662009-09-23 16:37:36 -070049 if (con->logTimes) {
50 con->timerSet(Context::RS_TIMER_INTERNAL);
51 }
Jason Sams5f7fc272009-06-18 16:58:42 -070052 waitForCommand = false;
Jason Samsf29ca502009-06-23 12:22:47 -070053 //LOGV("playCoreCommands 3 %i %i", cmdID, cmdSize);
Jason Samsd19f10d2009-05-22 14:03:28 -070054
55 gPlaybackFuncs[cmdID](con, data);
Jason Samsd19f10d2009-05-22 14:03:28 -070056 mToCore.next();
Jason Samsd19f10d2009-05-22 14:03:28 -070057 }
Jason Samsa09f11d2009-06-04 17:58:03 -070058 return ret;
Jason Samsd19f10d2009-05-22 14:03:28 -070059}
60
61