diff options
author | 2011-11-08 19:03:43 +0000 | |
---|---|---|
committer | 2011-11-08 19:03:43 +0000 | |
commit | 318cf92202b765e90b7b53cb92a5a3649f8536d0 (patch) | |
tree | f7696a74b3d27cbe06f0da2684eb059641e3899f | |
parent | 56c69773aea56c6c6bd47bc7e7970dd081205184 (diff) |
Cleanup for the Android build.
git-svn-id: http://skia.googlecode.com/svn/trunk@2630 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | gyp/common_conditions.gypi | 2 | ||||
-rw-r--r-- | gyp/core.gyp | 2 | ||||
-rw-r--r-- | src/ports/SkDebug_android.cpp | 19 | ||||
-rw-r--r-- | src/ports/SkOSEvent_android.cpp | 147 | ||||
-rw-r--r-- | src/ports/SkOSEvent_dummy.cpp | 20 |
5 files changed, 6 insertions, 184 deletions
diff --git a/gyp/common_conditions.gypi b/gyp/common_conditions.gypi index 766a04f758..bf3252d8c1 100644 --- a/gyp/common_conditions.gypi +++ b/gyp/common_conditions.gypi @@ -154,7 +154,7 @@ 'libraries': [ '-lstdc++', '-lm', - + '-llog', ], 'conditions': [ [ 'skia_target_arch == "arm" and arm_thumb == 1', { diff --git a/gyp/core.gyp b/gyp/core.gyp index a79af6b73e..00db957fa1 100644 --- a/gyp/core.gyp +++ b/gyp/core.gyp @@ -343,10 +343,12 @@ [ 'skia_os == "android"', { 'sources!': [ '../src/opts/opts_check_SSE2.cpp', + '../src/ports/SkDebug_stdio.cpp', ], 'sources': [ '../include/core/SkMMapStream.h', '../src/core/SkMMapStream.cpp', + '../src/ports/SkDebug_android.cpp', '../src/ports/SkThread_pthread.cpp', '../src/ports/SkFontHost_android.cpp', '../src/ports/SkFontHost_gamma.cpp', diff --git a/src/ports/SkDebug_android.cpp b/src/ports/SkDebug_android.cpp index 25cd630ea7..8e7d1d48a3 100644 --- a/src/ports/SkDebug_android.cpp +++ b/src/ports/SkDebug_android.cpp @@ -12,24 +12,11 @@ static const size_t kBufferSize = 256; #define LOG_TAG "skia" -#include <utils/Log.h> +#include <android/log.h> -void Android_SkDebugf(const char* file, int line, const char* function, - const char* format, ...) -{ - if (format[0] == '\n' && format[1] == '\0') - return; +void SkDebugf(const char format[], ...) { va_list args; va_start(args, format); -#ifdef HAVE_ANDROID_OS - char buffer[kBufferSize + 1]; - vsnprintf(buffer, kBufferSize, format, args); - if (buffer[0] != 0) - __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, "%s", buffer); -#else - android_vprintLog(ANDROID_LOG_DEBUG, NULL, LOG_TAG, format, args); -#endif + __android_log_vprint(ANDROID_LOG_DEBUG, LOG_TAG, format, args); va_end(args); } - - diff --git a/src/ports/SkOSEvent_android.cpp b/src/ports/SkOSEvent_android.cpp deleted file mode 100644 index 9750ec919a..0000000000 --- a/src/ports/SkOSEvent_android.cpp +++ /dev/null @@ -1,147 +0,0 @@ - -/* - * Copyright 2006 The Android Open Source Project - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - -#include "SkEvent.h" -#include "utils/threads.h" -#include <stdio.h> - -using namespace android; - -Mutex gEventQMutex; -Condition gEventQCondition; - -void SkEvent::SignalNonEmptyQueue() -{ - gEventQCondition.broadcast(); -} - -/////////////////////////////////////////////////////////////////// - -#ifdef FMS_ARCH_ANDROID_ARM - -// don't have pthreads.h, and therefore no timedwait(), so we punt for the demo - -void SkEvent::SignalQueueTimer(SkMSec delay) -{ -} - -void SkEvent_start_timer_thread() -{ -} - -void SkEvent_stop_timer_thread() -{ -} - -#else - -#include <pthread.h> -#include <errno.h> - -static pthread_t gTimerThread; -static pthread_mutex_t gTimerMutex; -static pthread_cond_t gTimerCond; -static timespec gTimeSpec; - -static void* timer_event_thread_proc(void*) -{ - for (;;) - { - int status; - - pthread_mutex_lock(&gTimerMutex); - - timespec spec = gTimeSpec; - // mark our global to be zero - // so we don't call timedwait again on a stale value - gTimeSpec.tv_sec = 0; - gTimeSpec.tv_nsec = 0; - - if (spec.tv_sec == 0 && spec.tv_nsec == 0) - status = pthread_cond_wait(&gTimerCond, &gTimerMutex); - else - status = pthread_cond_timedwait(&gTimerCond, &gTimerMutex, &spec); - - if (status == 0) // someone signaled us with a new time - { - pthread_mutex_unlock(&gTimerMutex); - } - else - { - SkASSERT(status == ETIMEDOUT); // no need to unlock the mutex (its unlocked) - // this is the payoff. Signal the event queue to wake up - // and also check the delay-queue - gEventQCondition.broadcast(); - } - } - return 0; -} - -#define kThousand (1000) -#define kMillion (kThousand * kThousand) -#define kBillion (kThousand * kThousand * kThousand) - -void SkEvent::SignalQueueTimer(SkMSec delay) -{ - pthread_mutex_lock(&gTimerMutex); - - if (delay) - { - struct timeval tv; - gettimeofday(&tv, NULL); - - // normalize tv - if (tv.tv_usec >= kMillion) - { - tv.tv_sec += tv.tv_usec / kMillion; - tv.tv_usec %= kMillion; - } - - // add tv + delay, scale each up to land on nanoseconds - gTimeSpec.tv_nsec = (tv.tv_usec + (delay % kThousand) * kThousand) * kThousand; - gTimeSpec.tv_sec = (tv.tv_sec + (delay / kThousand) * kThousand) * kThousand; - - // check for overflow in nsec - if ((unsigned long)gTimeSpec.tv_nsec >= kBillion) - { - gTimeSpec.tv_nsec -= kBillion; - gTimeSpec.tv_sec += 1; - SkASSERT((unsigned long)gTimeSpec.tv_nsec < kBillion); - } - - // printf("SignalQueueTimer(%d) timespec(%d %d)\n", delay, gTimeSpec.tv_sec, gTimeSpec.tv_nsec); - } - else // cancel the timer - { - gTimeSpec.tv_nsec = 0; - gTimeSpec.tv_sec = 0; - } - - pthread_mutex_unlock(&gTimerMutex); - pthread_cond_signal(&gTimerCond); -} - -void SkEvent_start_timer_thread() -{ - int status; - pthread_attr_t attr; - - status = pthread_attr_init(&attr); - SkASSERT(status == 0); - status = pthread_create(&gTimerThread, &attr, timer_event_thread_proc, 0); - SkASSERT(status == 0); -} - -void SkEvent_stop_timer_thread() -{ - int status = pthread_cancel(gTimerThread); - SkASSERT(status == 0); -} - -#endif diff --git a/src/ports/SkOSEvent_dummy.cpp b/src/ports/SkOSEvent_dummy.cpp deleted file mode 100644 index c7e477dfa0..0000000000 --- a/src/ports/SkOSEvent_dummy.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -/* - * Copyright 2006 The Android Open Source Project - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - -#include "SkEvent.h" - -void SkEvent::SignalNonEmptyQueue() -{ - -} - -void SkEvent::SignalQueueTimer(SkMSec delay) -{ - -} |