blob: 413caabebc62045468edb52bd2f318bc17656960 [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 "rsDevice.h"
18#include "rsContext.h"
19#include "rsThreadIO.h"
Mathias Agopian5ae678f2009-06-22 18:01:09 -070020#include <ui/FramebufferNativeWindow.h>
Jason Sams326e0dd2009-05-22 14:03:28 -070021
Jason Sams1aa5a4e2009-06-22 17:15:15 -070022#include <GLES/gl.h>
23#include <GLES/glext.h>
24
Jason Sams326e0dd2009-05-22 14:03:28 -070025using namespace android;
26using namespace android::renderscript;
27
Jason Samse5769102009-06-19 16:03:18 -070028pthread_key_t Context::gThreadTLSKey = 0;
Jason Sams326e0dd2009-05-22 14:03:28 -070029
30void Context::initEGL()
31{
32 mNumConfigs = -1;
33
34 EGLint s_configAttribs[] = {
35 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
Jason Samsb80dfa72009-07-10 17:32:40 -070036#if 1
37 EGL_RED_SIZE, 8,
38 EGL_GREEN_SIZE, 8,
39 EGL_BLUE_SIZE, 8,
40 EGL_ALPHA_SIZE, 8,
41#else
Jason Sams326e0dd2009-05-22 14:03:28 -070042 EGL_RED_SIZE, 5,
43 EGL_GREEN_SIZE, 6,
44 EGL_BLUE_SIZE, 5,
Jason Samsb80dfa72009-07-10 17:32:40 -070045#endif
Jason Sams326e0dd2009-05-22 14:03:28 -070046 EGL_DEPTH_SIZE, 16,
47 EGL_NONE
48 };
49
Jason Sams326e0dd2009-05-22 14:03:28 -070050 mDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
Jason Sams326e0dd2009-05-22 14:03:28 -070051 eglInitialize(mDisplay, &mMajorVersion, &mMinorVersion);
Jason Sams326e0dd2009-05-22 14:03:28 -070052 eglChooseConfig(mDisplay, s_configAttribs, &mConfig, 1, &mNumConfigs);
Jason Sams326e0dd2009-05-22 14:03:28 -070053
54 if (mWndSurface) {
Mathias Agopian5ae678f2009-06-22 18:01:09 -070055 mSurface = eglCreateWindowSurface(mDisplay, mConfig, mWndSurface,
Jason Sams326e0dd2009-05-22 14:03:28 -070056 NULL);
57 } else {
58 mSurface = eglCreateWindowSurface(mDisplay, mConfig,
59 android_createDisplaySurface(),
60 NULL);
61 }
62
Jason Sams326e0dd2009-05-22 14:03:28 -070063 mContext = eglCreateContext(mDisplay, mConfig, NULL, NULL);
Jason Samsa44cb292009-06-04 17:58:03 -070064 eglMakeCurrent(mDisplay, mSurface, mSurface, mContext);
Jason Sams326e0dd2009-05-22 14:03:28 -070065 eglQuerySurface(mDisplay, mSurface, EGL_WIDTH, &mWidth);
66 eglQuerySurface(mDisplay, mSurface, EGL_HEIGHT, &mHeight);
Jason Sams326e0dd2009-05-22 14:03:28 -070067}
68
Jason Samsa0a1b6f2009-06-10 15:04:38 -070069bool Context::runScript(Script *s, uint32_t launchID)
Jason Sams10308932009-06-09 12:15:30 -070070{
71 ObjectBaseRef<ProgramFragment> frag(mFragment);
72 ObjectBaseRef<ProgramVertex> vtx(mVertex);
73 ObjectBaseRef<ProgramFragmentStore> store(mFragmentStore);
74
Jason Samsa0a1b6f2009-06-10 15:04:38 -070075 bool ret = s->run(this, launchID);
Jason Sams10308932009-06-09 12:15:30 -070076
Jason Samsa0a1b6f2009-06-10 15:04:38 -070077 mFragment.set(frag);
78 mVertex.set(vtx);
79 mFragmentStore.set(store);
Jason Samsc9d43db2009-07-28 12:02:16 -070080 return ret;
Jason Sams10308932009-06-09 12:15:30 -070081}
82
83
Jason Samsa44cb292009-06-04 17:58:03 -070084bool Context::runRootScript()
Jason Sams326e0dd2009-05-22 14:03:28 -070085{
Jason Sams24371d92009-08-19 12:17:14 -070086#if RS_LOG_TIMES
87 timerSet(RS_TIMER_CLEAR_SWAP);
88#endif
Jason Sams10308932009-06-09 12:15:30 -070089 rsAssert(mRootScript->mEnviroment.mIsRoot);
Jason Sams326e0dd2009-05-22 14:03:28 -070090
Jason Samscfb1d112009-08-05 13:57:03 -070091 //glColor4f(1,1,1,1);
92 //glEnable(GL_LIGHT0);
Jason Sams10308932009-06-09 12:15:30 -070093 glViewport(0, 0, mWidth, mHeight);
Jason Sams326e0dd2009-05-22 14:03:28 -070094
Jason Sams326e0dd2009-05-22 14:03:28 -070095 glDepthMask(GL_TRUE);
96 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
97
Jason Sams928b7342009-06-08 18:50:13 -070098 glClearColor(mRootScript->mEnviroment.mClearColor[0],
99 mRootScript->mEnviroment.mClearColor[1],
100 mRootScript->mEnviroment.mClearColor[2],
101 mRootScript->mEnviroment.mClearColor[3]);
102 glClearDepthf(mRootScript->mEnviroment.mClearDepth);
Jason Sams326e0dd2009-05-22 14:03:28 -0700103 glClear(GL_COLOR_BUFFER_BIT);
104 glClear(GL_DEPTH_BUFFER_BIT);
105
Jason Samscfb1d112009-08-05 13:57:03 -0700106#if RS_LOG_TIMES
Jason Sams24371d92009-08-19 12:17:14 -0700107 timerSet(RS_TIMER_SCRIPT);
Jason Samscfb1d112009-08-05 13:57:03 -0700108#endif
109 bool ret = runScript(mRootScript.get(), 0);
Jason Samscfb1d112009-08-05 13:57:03 -0700110 return ret;
Jason Sams326e0dd2009-05-22 14:03:28 -0700111}
112
Jason Sams24371d92009-08-19 12:17:14 -0700113uint64_t Context::getTime() const
114{
115 struct timespec t;
116 clock_gettime(CLOCK_MONOTONIC, &t);
117 return t.tv_nsec + ((uint64_t)t.tv_sec * 1000 * 1000 * 1000);
118}
119
120void Context::timerReset()
121{
122 for (int ct=0; ct < _RS_TIMER_TOTAL; ct++) {
123 mTimers[ct] = 0;
124 }
125}
126
127void Context::timerInit()
128{
129 mTimeLast = getTime();
130 mTimerActive = RS_TIMER_INTERNAL;
131 timerReset();
132}
133
134void Context::timerSet(Timers tm)
135{
136 uint64_t last = mTimeLast;
137 mTimeLast = getTime();
138 mTimers[mTimerActive] += mTimeLast - last;
139 mTimerActive = tm;
140}
141
142void Context::timerPrint()
143{
144 double total = 0;
145 for (int ct = 0; ct < _RS_TIMER_TOTAL; ct++) {
146 total += mTimers[ct];
147 }
148
149 LOGV("RS Time Data: Idle %2.1f (%lli), Internal %2.1f (%lli), Script %2.1f (%lli), Clear & Swap %2.1f (%lli)",
150 100.0 * mTimers[RS_TIMER_IDLE] / total, mTimers[RS_TIMER_IDLE] / 1000000,
151 100.0 * mTimers[RS_TIMER_INTERNAL] / total, mTimers[RS_TIMER_INTERNAL] / 1000000,
152 100.0 * mTimers[RS_TIMER_SCRIPT] / total, mTimers[RS_TIMER_SCRIPT] / 1000000,
153 100.0 * mTimers[RS_TIMER_CLEAR_SWAP] / total, mTimers[RS_TIMER_CLEAR_SWAP] / 1000000);
154}
155
Jason Sams326e0dd2009-05-22 14:03:28 -0700156void Context::setupCheck()
157{
158 if (mFragmentStore.get()) {
Jason Samscfb1d112009-08-05 13:57:03 -0700159 mFragmentStore->setupGL(&mStateFragmentStore);
Jason Sams326e0dd2009-05-22 14:03:28 -0700160 }
161 if (mFragment.get()) {
Jason Samscfb1d112009-08-05 13:57:03 -0700162 mFragment->setupGL(&mStateFragment);
Jason Sams326e0dd2009-05-22 14:03:28 -0700163 }
164 if (mVertex.get()) {
Jason Samscfb1d112009-08-05 13:57:03 -0700165 mVertex->setupGL(&mStateVertex);
Jason Sams326e0dd2009-05-22 14:03:28 -0700166 }
167
168}
169
170
171void * Context::threadProc(void *vrsc)
172{
173 Context *rsc = static_cast<Context *>(vrsc);
174
Jason Sams326e0dd2009-05-22 14:03:28 -0700175 rsc->initEGL();
Jason Sams8ce125b2009-06-17 16:52:59 -0700176
Jason Samse5769102009-06-19 16:03:18 -0700177 ScriptTLSStruct *tlsStruct = new ScriptTLSStruct;
178 if (!tlsStruct) {
179 LOGE("Error allocating tls storage");
180 return NULL;
181 }
182 tlsStruct->mContext = rsc;
183 tlsStruct->mScript = NULL;
184 int status = pthread_setspecific(rsc->gThreadTLSKey, tlsStruct);
185 if (status) {
186 LOGE("pthread_setspecific %i", status);
187 }
188
Jason Sams8ce125b2009-06-17 16:52:59 -0700189 rsc->mStateVertex.init(rsc, rsc->mWidth, rsc->mHeight);
190 rsc->setVertex(NULL);
191 rsc->mStateFragment.init(rsc, rsc->mWidth, rsc->mHeight);
192 rsc->setFragment(NULL);
193 rsc->mStateFragmentStore.init(rsc, rsc->mWidth, rsc->mHeight);
194 rsc->setFragmentStore(NULL);
195
Jason Sams326e0dd2009-05-22 14:03:28 -0700196 rsc->mRunning = true;
Jason Samsa44cb292009-06-04 17:58:03 -0700197 bool mDraw = true;
Jason Sams326e0dd2009-05-22 14:03:28 -0700198 while (!rsc->mExit) {
Jason Samsfcd31922009-08-17 18:35:48 -0700199 mDraw |= rsc->mIO.playCoreCommands(rsc, !mDraw);
Jason Sams732f1c02009-06-18 16:58:42 -0700200 mDraw &= (rsc->mRootScript.get() != NULL);
Jason Sams326e0dd2009-05-22 14:03:28 -0700201
Jason Sams732f1c02009-06-18 16:58:42 -0700202 if (mDraw) {
Jason Samsa44cb292009-06-04 17:58:03 -0700203 mDraw = rsc->runRootScript();
Jason Sams24371d92009-08-19 12:17:14 -0700204#if RS_LOG_TIMES
205 rsc->timerSet(RS_TIMER_CLEAR_SWAP);
206#endif
Jason Samsa44cb292009-06-04 17:58:03 -0700207 eglSwapBuffers(rsc->mDisplay, rsc->mSurface);
Jason Sams24371d92009-08-19 12:17:14 -0700208#if RS_LOG_TIMES
209 rsc->timerSet(RS_TIMER_INTERNAL);
210 rsc->timerPrint();
211 rsc->timerReset();
212#endif
Jason Sams326e0dd2009-05-22 14:03:28 -0700213 }
Jason Sams24371d92009-08-19 12:17:14 -0700214 if (rsc->mObjDestroy.mNeedToEmpty) {
215 rsc->objDestroyOOBRun();
216 }
Jason Sams326e0dd2009-05-22 14:03:28 -0700217 }
218
Jason Sams326e0dd2009-05-22 14:03:28 -0700219 glClearColor(0,0,0,0);
220 glClear(GL_COLOR_BUFFER_BIT);
221 eglSwapBuffers(rsc->mDisplay, rsc->mSurface);
222 eglTerminate(rsc->mDisplay);
Jason Sams50869382009-08-18 17:07:09 -0700223 rsc->objDestroyOOBRun();
Jason Sams326e0dd2009-05-22 14:03:28 -0700224 return NULL;
225}
226
227Context::Context(Device *dev, Surface *sur)
228{
Jason Sams326e0dd2009-05-22 14:03:28 -0700229 dev->addContext(this);
230 mDev = dev;
231 mRunning = false;
232 mExit = false;
233
Jason Samsa658e902009-06-04 14:35:01 -0700234 int status;
235 pthread_attr_t threadAttr;
236
Jason Samse5769102009-06-19 16:03:18 -0700237 status = pthread_key_create(&gThreadTLSKey, NULL);
238 if (status) {
239 LOGE("Failed to init thread tls key.");
240 return;
241 }
242
Jason Samsa658e902009-06-04 14:35:01 -0700243 status = pthread_attr_init(&threadAttr);
244 if (status) {
245 LOGE("Failed to init thread attribute.");
246 return;
247 }
248
249 sched_param sparam;
250 sparam.sched_priority = ANDROID_PRIORITY_DISPLAY;
251 pthread_attr_setschedparam(&threadAttr, &sparam);
252
Jason Sams992a0b72009-06-23 12:22:47 -0700253 mWndSurface = sur;
254
Jason Sams50869382009-08-18 17:07:09 -0700255 objDestroyOOBInit();
Jason Sams24371d92009-08-19 12:17:14 -0700256 timerInit();
Jason Sams50869382009-08-18 17:07:09 -0700257
Jason Sams992a0b72009-06-23 12:22:47 -0700258 LOGV("RS Launching thread");
Jason Samsa658e902009-06-04 14:35:01 -0700259 status = pthread_create(&mThreadId, &threadAttr, threadProc, this);
Jason Sams326e0dd2009-05-22 14:03:28 -0700260 if (status) {
261 LOGE("Failed to start rs context thread.");
262 }
263
Jason Sams326e0dd2009-05-22 14:03:28 -0700264 while(!mRunning) {
265 sleep(1);
266 }
Jason Sams326e0dd2009-05-22 14:03:28 -0700267
Jason Samsa658e902009-06-04 14:35:01 -0700268 pthread_attr_destroy(&threadAttr);
Jason Sams326e0dd2009-05-22 14:03:28 -0700269}
270
271Context::~Context()
272{
273 mExit = true;
274 void *res;
275
Jason Sams326e0dd2009-05-22 14:03:28 -0700276 int status = pthread_join(mThreadId, &res);
Jason Sams50869382009-08-18 17:07:09 -0700277 objDestroyOOBRun();
Jason Sams326e0dd2009-05-22 14:03:28 -0700278
279 if (mDev) {
280 mDev->removeContext(this);
Jason Samse5769102009-06-19 16:03:18 -0700281 pthread_key_delete(gThreadTLSKey);
Jason Sams326e0dd2009-05-22 14:03:28 -0700282 }
Jason Sams50869382009-08-18 17:07:09 -0700283
284 objDestroyOOBDestroy();
Jason Sams326e0dd2009-05-22 14:03:28 -0700285}
286
287void Context::swapBuffers()
288{
289 eglSwapBuffers(mDisplay, mSurface);
290}
291
292void rsContextSwap(RsContext vrsc)
293{
294 Context *rsc = static_cast<Context *>(vrsc);
295 rsc->swapBuffers();
296}
297
298void Context::setRootScript(Script *s)
299{
300 mRootScript.set(s);
301}
302
303void Context::setFragmentStore(ProgramFragmentStore *pfs)
304{
Jason Sams8ce125b2009-06-17 16:52:59 -0700305 if (pfs == NULL) {
306 mFragmentStore.set(mStateFragmentStore.mDefault);
307 } else {
308 mFragmentStore.set(pfs);
309 }
Jason Sams326e0dd2009-05-22 14:03:28 -0700310}
311
312void Context::setFragment(ProgramFragment *pf)
313{
Jason Sams8ce125b2009-06-17 16:52:59 -0700314 if (pf == NULL) {
315 mFragment.set(mStateFragment.mDefault);
316 } else {
317 mFragment.set(pf);
318 }
Jason Samscfb1d112009-08-05 13:57:03 -0700319}
320
321void Context::allocationCheck(const Allocation *a)
322{
323 mVertex->checkUpdatedAllocation(a);
324 mFragment->checkUpdatedAllocation(a);
325 mFragmentStore->checkUpdatedAllocation(a);
Jason Sams326e0dd2009-05-22 14:03:28 -0700326}
327
328void Context::setVertex(ProgramVertex *pv)
329{
Jason Sams8ce125b2009-06-17 16:52:59 -0700330 if (pv == NULL) {
331 mVertex.set(mStateVertex.mDefault);
332 } else {
333 mVertex.set(pv);
334 }
Jason Sams326e0dd2009-05-22 14:03:28 -0700335}
336
Jason Samsa4a54e42009-06-10 18:39:40 -0700337void Context::assignName(ObjectBase *obj, const char *name, uint32_t len)
Jason Samsa0a1b6f2009-06-10 15:04:38 -0700338{
339 rsAssert(!obj->getName());
Jason Samsa4a54e42009-06-10 18:39:40 -0700340 obj->setName(name, len);
Jason Samsa0a1b6f2009-06-10 15:04:38 -0700341 mNames.add(obj);
342}
343
344void Context::removeName(ObjectBase *obj)
345{
346 for(size_t ct=0; ct < mNames.size(); ct++) {
347 if (obj == mNames[ct]) {
348 mNames.removeAt(ct);
349 return;
350 }
351 }
352}
353
354ObjectBase * Context::lookupName(const char *name) const
355{
356 for(size_t ct=0; ct < mNames.size(); ct++) {
357 if (!strcmp(name, mNames[ct]->getName())) {
358 return mNames[ct];
359 }
360 }
361 return NULL;
362}
363
Jason Samsa4a54e42009-06-10 18:39:40 -0700364void Context::appendNameDefines(String8 *str) const
365{
366 char buf[256];
367 for (size_t ct=0; ct < mNames.size(); ct++) {
368 str->append("#define NAMED_");
369 str->append(mNames[ct]->getName());
370 str->append(" ");
371 sprintf(buf, "%i\n", (int)mNames[ct]);
372 str->append(buf);
373 }
374}
375
Joe Onorato57b79ce2009-08-09 22:57:44 -0700376void Context::appendVarDefines(String8 *str) const
377{
378 char buf[256];
379 for (size_t ct=0; ct < mInt32Defines.size(); ct++) {
380 str->append("#define ");
381 str->append(mInt32Defines.keyAt(ct));
382 str->append(" ");
383 sprintf(buf, "%i\n", (int)mInt32Defines.valueAt(ct));
384 str->append(buf);
385
386 }
387 for (size_t ct=0; ct < mFloatDefines.size(); ct++) {
388 str->append("#define ");
389 str->append(mFloatDefines.keyAt(ct));
390 str->append(" ");
391 sprintf(buf, "%ff\n", mFloatDefines.valueAt(ct));
392 str->append(buf);
393 }
394}
395
Jason Sams50869382009-08-18 17:07:09 -0700396bool Context::objDestroyOOBInit()
397{
398 int status = pthread_mutex_init(&mObjDestroy.mMutex, NULL);
399 if (status) {
400 LOGE("Context::ObjDestroyOOBInit mutex init failure");
401 return false;
402 }
403 return true;
404}
405
406void Context::objDestroyOOBRun()
407{
408 if (mObjDestroy.mNeedToEmpty) {
409 int status = pthread_mutex_lock(&mObjDestroy.mMutex);
410 if (status) {
411 LOGE("Context::ObjDestroyOOBRun: error %i locking for OOBRun.", status);
412 return;
413 }
414
415 for (size_t ct = 0; ct < mObjDestroy.mDestroyList.size(); ct++) {
416 mObjDestroy.mDestroyList[ct]->decRef();
417 }
418 mObjDestroy.mDestroyList.clear();
419 mObjDestroy.mNeedToEmpty = false;
420
421 status = pthread_mutex_unlock(&mObjDestroy.mMutex);
422 if (status) {
423 LOGE("Context::ObjDestroyOOBRun: error %i unlocking for set condition.", status);
424 }
425 }
426}
427
428void Context::objDestroyOOBDestroy()
429{
430 rsAssert(!mObjDestroy.mNeedToEmpty);
431 pthread_mutex_destroy(&mObjDestroy.mMutex);
432}
433
434void Context::objDestroyAdd(ObjectBase *obj)
435{
436 int status = pthread_mutex_lock(&mObjDestroy.mMutex);
437 if (status) {
438 LOGE("Context::ObjDestroyOOBRun: error %i locking for OOBRun.", status);
439 return;
440 }
441
442 mObjDestroy.mNeedToEmpty = true;
443 mObjDestroy.mDestroyList.add(obj);
444
445 status = pthread_mutex_unlock(&mObjDestroy.mMutex);
446 if (status) {
447 LOGE("Context::ObjDestroyOOBRun: error %i unlocking for set condition.", status);
448 }
449}
450
451
Jason Samsa4a54e42009-06-10 18:39:40 -0700452
Jason Sams326e0dd2009-05-22 14:03:28 -0700453///////////////////////////////////////////////////////////////////////////////////////////
Jason Samsa44cb292009-06-04 17:58:03 -0700454//
Jason Sams326e0dd2009-05-22 14:03:28 -0700455
456namespace android {
457namespace renderscript {
458
459
460void rsi_ContextBindRootScript(Context *rsc, RsScript vs)
461{
462 Script *s = static_cast<Script *>(vs);
463 rsc->setRootScript(s);
464}
465
466void rsi_ContextBindSampler(Context *rsc, uint32_t slot, RsSampler vs)
467{
468 Sampler *s = static_cast<Sampler *>(vs);
469
470 if (slot > RS_MAX_SAMPLER_SLOT) {
471 LOGE("Invalid sampler slot");
472 return;
473 }
474
475 s->bindToContext(&rsc->mStateSampler, slot);
476}
477
478void rsi_ContextBindProgramFragmentStore(Context *rsc, RsProgramFragmentStore vpfs)
479{
480 ProgramFragmentStore *pfs = static_cast<ProgramFragmentStore *>(vpfs);
481 rsc->setFragmentStore(pfs);
482}
483
484void rsi_ContextBindProgramFragment(Context *rsc, RsProgramFragment vpf)
485{
486 ProgramFragment *pf = static_cast<ProgramFragment *>(vpf);
487 rsc->setFragment(pf);
488}
489
490void rsi_ContextBindProgramVertex(Context *rsc, RsProgramVertex vpv)
491{
492 ProgramVertex *pv = static_cast<ProgramVertex *>(vpv);
493 rsc->setVertex(pv);
494}
495
Jason Samsa4a54e42009-06-10 18:39:40 -0700496void rsi_AssignName(Context *rsc, void * obj, const char *name, uint32_t len)
Jason Samsa0a1b6f2009-06-10 15:04:38 -0700497{
498 ObjectBase *ob = static_cast<ObjectBase *>(obj);
Jason Samsa4a54e42009-06-10 18:39:40 -0700499 rsc->assignName(ob, name, len);
Jason Samsa0a1b6f2009-06-10 15:04:38 -0700500}
Jason Sams326e0dd2009-05-22 14:03:28 -0700501
Jason Sams707aaf32009-08-18 14:14:24 -0700502void rsi_ObjDestroy(Context *rsc, void *obj)
503{
504 ObjectBase *ob = static_cast<ObjectBase *>(obj);
505 rsc->removeName(ob);
506 ob->decRef();
507}
508
Joe Onorato57b79ce2009-08-09 22:57:44 -0700509void rsi_ContextSetDefineF(Context *rsc, const char* name, float value)
510{
511 rsc->addInt32Define(name, value);
512}
513
514void rsi_ContextSetDefineI32(Context *rsc, const char* name, int32_t value)
515{
516 rsc->addFloatDefine(name, value);
517}
Jason Sams326e0dd2009-05-22 14:03:28 -0700518
519}
520}
521
522
523RsContext rsContextCreate(RsDevice vdev, void *sur, uint32_t version)
524{
525 Device * dev = static_cast<Device *>(vdev);
526 Context *rsc = new Context(dev, (Surface *)sur);
527 return rsc;
528}
529
530void rsContextDestroy(RsContext vrsc)
531{
532 Context * rsc = static_cast<Context *>(vrsc);
533 delete rsc;
534}
535
Jason Sams50869382009-08-18 17:07:09 -0700536void rsObjDestroyOOB(RsContext vrsc, void *obj)
537{
538 Context * rsc = static_cast<Context *>(vrsc);
539 rsc->objDestroyAdd(static_cast<ObjectBase *>(obj));
540}
541