2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/render/common/render-tracker.h>
22 #include <dali/integration-api/gl-sync-abstraction.h>
23 #include <dali/internal/render/common/render-tracker-debug.h>
36 RenderTracker::RenderTracker()
37 : mGlSyncAbstraction( NULL ),
41 TRACKER_LOG(Debug::Verbose);
44 RenderTracker::~RenderTracker()
46 TRACKER_LOG(Debug::Verbose);
49 mGlSyncAbstraction->DestroySyncObject( mSyncObject );
54 void RenderTracker::CreateSyncObject( Integration::GlSyncAbstraction& glSyncAbstraction )
56 mGlSyncAbstraction = &glSyncAbstraction;
57 TRACKER_LOG(Debug::General);
59 // Destroy any previous sync object
62 mGlSyncAbstraction->DestroySyncObject( mSyncObject );
66 mSyncObject = mGlSyncAbstraction->CreateSyncObject();
69 void RenderTracker::PollSyncObject()
71 if( mSyncObject && mSyncObject->IsSynced() )
74 mGlSyncAbstraction->DestroySyncObject( mSyncObject );
77 TRACKER_LOG_FMT(Debug::General, " Synced\n");
80 TRACKER_LOG_FMT(Debug::General, " Not Synced\n");
83 bool RenderTracker::IsSynced()
85 int x = __sync_val_compare_and_swap(&mSyncTrigger, 0xFF, 0x0);
87 TRACKER_LOG_FMT(Debug::General, " = %s\n", x!=0?"T":"F");
91 void RenderTracker::ResetSyncFlag()
93 TRACKER_LOG(Debug::General);
94 (void)__sync_lock_test_and_set(&mSyncTrigger, 0x0);
97 void RenderTracker::SetSyncFlag()
99 (void)__sync_lock_test_and_set(&mSyncTrigger, 0xFF);