blob: 4a1dbbb9f0044b59b58243d7717654000928950a [file] [log] [blame]
Jason Sams326e0dd2009-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 Sams326e0dd2009-05-22 14:03:28 -070019#include "rsThreadIO.h"
20
21using namespace android;
22using namespace android::renderscript;
23
Jason Sams326e0dd2009-05-22 14:03:28 -070024ThreadIO::ThreadIO()
25{
26 mToCore.init(16 * 1024);
27}
28
29ThreadIO::~ThreadIO()
30{
31}
32
Jason Sams732f1c02009-06-18 16:58:42 -070033bool ThreadIO::playCoreCommands(Context *con, bool waitForCommand)
Jason Sams326e0dd2009-05-22 14:03:28 -070034{
Jason Samsa44cb292009-06-04 17:58:03 -070035 bool ret = false;
Jason Sams732f1c02009-06-18 16:58:42 -070036 while(!mToCore.isEmpty() || waitForCommand) {
Jason Sams24371d92009-08-19 12:17:14 -070037 uint32_t cmdID = 0;
38 uint32_t cmdSize = 0;
Jason Samsa44cb292009-06-04 17:58:03 -070039 ret = true;
Jason Sams24371d92009-08-19 12:17:14 -070040#if RS_LOG_TIMES
41 con->timerSet(Context::RS_TIMER_IDLE);
42#endif
Jason Sams326e0dd2009-05-22 14:03:28 -070043 const void * data = mToCore.get(&cmdID, &cmdSize);
Jason Sams24371d92009-08-19 12:17:14 -070044#if RS_LOG_TIMES
45 con->timerSet(Context::RS_TIMER_INTERNAL);
46#endif
Jason Sams732f1c02009-06-18 16:58:42 -070047 waitForCommand = false;
Jason Sams992a0b72009-06-23 12:22:47 -070048 //LOGV("playCoreCommands 3 %i %i", cmdID, cmdSize);
Jason Sams326e0dd2009-05-22 14:03:28 -070049
50 gPlaybackFuncs[cmdID](con, data);
Jason Sams326e0dd2009-05-22 14:03:28 -070051 mToCore.next();
Jason Sams326e0dd2009-05-22 14:03:28 -070052 }
Jason Samsa44cb292009-06-04 17:58:03 -070053 return ret;
Jason Sams326e0dd2009-05-22 14:03:28 -070054}
55
56